@wistia/kaleidoscope 0.0.7 → 0.0.8

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 (44) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{color-BgYVUbOQ.js → color-BuPhQjcd.js} +3 -3
  3. package/dist/{color-BgYVUbOQ.js.map → color-BuPhQjcd.js.map} +1 -1
  4. package/dist/{engine-DHDkDPaV.js → engine-6ocr431e.js} +788 -374
  5. package/dist/engine-6ocr431e.js.map +1 -0
  6. package/dist/{engine-B00ZVZ0d.d.ts → engine-CcU0Q8Jg.d.ts} +5 -3
  7. package/dist/{engine-B00ZVZ0d.d.ts.map → engine-CcU0Q8Jg.d.ts.map} +1 -1
  8. package/dist/entries/color.js +3 -3
  9. package/dist/entries/engine.d.ts +1 -1
  10. package/dist/entries/engine.js +2 -2
  11. package/dist/entries/styleRegistry.d.ts +1 -1
  12. package/dist/entries/styleRegistry.js +2 -2
  13. package/dist/entries/validate.d.ts +1 -1
  14. package/dist/entries/validate.js +2 -2
  15. package/dist/entries/vocabulary.d.ts +2 -2
  16. package/dist/entries/vocabulary.js +4 -4
  17. package/dist/{getColorLightnessClassification-C6BXD8Da.js → getColorLightnessClassification-Dgr8qirZ.js} +2 -2
  18. package/dist/{getColorLightnessClassification-C6BXD8Da.js.map → getColorLightnessClassification-Dgr8qirZ.js.map} +1 -1
  19. package/dist/{guards-BJfumKYK.js → guards-BPewjm9T.js} +2 -2
  20. package/dist/{guards-BJfumKYK.js.map → guards-BPewjm9T.js.map} +1 -1
  21. package/dist/{index-BOJCY_MU.d.ts → index-BTumAeju.d.ts} +26 -7
  22. package/dist/index-BTumAeju.d.ts.map +1 -0
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +9 -9
  25. package/dist/{styleRegistry-Dcho9r3B.js → styleRegistry-BqGmp-3z.js} +5 -5
  26. package/dist/{styleRegistry-Dcho9r3B.js.map → styleRegistry-BqGmp-3z.js.map} +1 -1
  27. package/dist/{styleRegistry-A0nrsHk-.d.ts → styleRegistry-BsMmbH_0.d.ts} +2 -2
  28. package/dist/{styleRegistry-A0nrsHk-.d.ts.map → styleRegistry-BsMmbH_0.d.ts.map} +1 -1
  29. package/dist/{styleVocabulary-DMhXOr4F.js → styleVocabulary-CDTPCMhZ.js} +11 -5
  30. package/dist/{styleVocabulary-DMhXOr4F.js.map → styleVocabulary-CDTPCMhZ.js.map} +1 -1
  31. package/dist/{typography-BLPIIq_8.js → typography-BCKqcNDx.js} +2 -2
  32. package/dist/{typography-BLPIIq_8.js.map → typography-BCKqcNDx.js.map} +1 -1
  33. package/dist/{validate-Bqx__f3d.d.ts → validate-8Ow1tYvz.d.ts} +2 -2
  34. package/dist/{validate-Bqx__f3d.d.ts.map → validate-8Ow1tYvz.d.ts.map} +1 -1
  35. package/dist/{validate-BkOpEpch.js → validate-D_VsJM1q.js} +88 -26
  36. package/dist/validate-D_VsJM1q.js.map +1 -0
  37. package/package.json +7 -7
  38. package/schema/style-v1.json +128 -20
  39. package/styles/opaque-bright.json +1 -1
  40. package/styles/opaque-heavy.json +1 -1
  41. package/styles/opaque-minimal.json +1 -1
  42. package/dist/engine-DHDkDPaV.js.map +0 -1
  43. package/dist/index-BOJCY_MU.d.ts.map +0 -1
  44. package/dist/validate-BkOpEpch.js.map +0 -1
@@ -1,15 +1,15 @@
1
1
 
2
2
  /*
3
- * @license @wistia/kaleidoscope v0.0.7
3
+ * @license @wistia/kaleidoscope v0.0.8
4
4
  *
5
5
  * Copyright (c) 2026, Wistia, Inc. and its affiliates.
6
6
  *
7
7
  * This source code is unlicensed, all rights reserved.
8
8
  */
9
9
 
10
- import { c as getBestColorForText, d as colorContrastRatiosByShape, f as Color, h as clamp, n as buildBrandedColorScale, o as getBrandLightBackgroundColor, s as getBrandDarkBackgroundColor, t as getColorLightnessClassification, u as adjustColorForProperContrast } from "./getColorLightnessClassification-C6BXD8Da.js";
11
- import { l as ORNAMENTAL_BORDER_STYLES, n as TYPE_ROLES, o as STACKABLE_ON, s as SURFACE_NAMES } from "./typography-BLPIIq_8.js";
12
- import { n as isOneOf } from "./guards-BJfumKYK.js";
10
+ import { c as getBestColorForText, d as colorContrastRatiosByShape, f as Color, h as clamp, n as buildBrandedColorScale, o as getBrandLightBackgroundColor, s as getBrandDarkBackgroundColor, t as getColorLightnessClassification, u as adjustColorForProperContrast } from "./getColorLightnessClassification-Dgr8qirZ.js";
11
+ import { l as ORNAMENTAL_BORDER_STYLES, n as TYPE_ROLES, o as STACKABLE_ON, s as SURFACE_NAMES } from "./typography-BCKqcNDx.js";
12
+ import { n as isOneOf } from "./guards-BPewjm9T.js";
13
13
  // src/brandTokens.ts
14
14
  /** The Brand Kit tokens a Style document can reference, each as `$<name>`. */
15
15
  const BRAND_TOKEN_NAMES = [
@@ -41,6 +41,8 @@ const RELATION_HUE_DEGREES = {
41
41
  const INVERT_BELOW_CONTRAST = colorContrastRatiosByShape.nonText;
42
42
  /** How far low-emphasis text fades from the surface's text color. Placeholder. */
43
43
  const LOW_EMPHASIS_TEXT_ALPHA = .7;
44
+ /** How strongly a surface with no fill washes in its text color on hover. Placeholder. */
45
+ const NONE_HOVER_WASH_ALPHA = .08;
44
46
  // src/private/engine/scale.ts
45
47
  const MAX_CACHED_SCALES = 600;
46
48
  const scaleCache = /* @__PURE__ */ new Map();
@@ -148,12 +150,15 @@ const ANCHOR_BY_REF = {
148
150
  "anchors.colors.primary": "primary",
149
151
  "anchors.colors.ground": "ground"
150
152
  };
153
+ const isAnchorRef = (value) => Object.hasOwn(ANCHOR_BY_REF, value);
151
154
  const anchorName = (ref) => ANCHOR_BY_REF[ref];
152
155
  const anchorColor = (ref, anchors) => {
153
156
  const color = anchors.colors[ANCHOR_BY_REF[ref]];
154
157
  if (color === null) throw new Error(`${ref} is referenced but not declared`);
155
158
  return color;
156
159
  };
160
+ /** A setting that names a color either way: through an anchor, or written out. */
161
+ const anchorOrSingleColor = (value, anchors) => typeof value === "string" && isAnchorRef(value) ? anchorColor(value, anchors) : resolveSingleColor(value, anchors.tokens);
157
162
  /** The scale stepping from an anchor walks: its token's if it's toned, or else its own. */
158
163
  const anchorScale = (ref, anchors) => anchors.scales[anchorName(ref)] ?? scaleOf(anchorColor(ref, anchors));
159
164
  // src/private/engine/rules/border.ts
@@ -180,30 +185,94 @@ const borderSlots = (border, solid, anchors) => {
180
185
  /** An ornament is a drawn tile rather than a CSS border, and draws whatever the width. */
181
186
  const borderGaps = ({ border }) => ORNAMENTAL_BORDER_STYLES.some((ornament) => ornament === border?.style) ? [`border.style: ${border?.style}`] : [];
182
187
  // src/private/engine/constants/elevation.ts
188
+ /** What `elevation.source: shade` is before each shadow's alpha. */
189
+ const SHADE_COLOR = "#000000";
183
190
  /**
184
- * The shadow each hardness casts at each depth. A pairing missing here is one the engine does not
185
- * resolve yet. `soft · low` is from the Phase 1 carousel sandbox.
191
+ * The shadow each hardness casts at each depth. `soft · low` is from the Phase 1 carousel sandbox;
192
+ * the rest are placeholders carried over from the Style Sampler prototype.
186
193
  */
187
- const SHADOWS = { soft: { low: {
188
- x: 0,
189
- y: 8,
190
- blur: 32,
191
- alpha: .2
192
- } } };
193
- // src/private/engine/rules/elevation.ts
194
- const ELEVATION_SLOTS = {
195
- surfaces: SURFACE_NAMES,
196
- initialValues: { "box-shadow": "none" }
197
- };
198
- /** The elevation's shadow, if it casts one, with any layers the treatment draws after it. */
199
- const elevationSlots = ({ depth, hardness }, treatmentLayers = []) => {
200
- const shadow = depth === "none" ? void 0 : SHADOWS[hardness]?.[depth];
201
- const layers = [...shadow === void 0 ? [] : [`${shadow.x}px ${shadow.y}px ${shadow.blur}px rgba(0, 0, 0, ${shadow.alpha})`], ...treatmentLayers];
202
- return layers.length === 0 ? {} : { "box-shadow": layers.join(", ") };
194
+ const SHADOWS = {
195
+ soft: {
196
+ low: {
197
+ x: 0,
198
+ y: 3,
199
+ blur: 5,
200
+ alpha: .125
201
+ },
202
+ medium: {
203
+ x: 0,
204
+ y: 6,
205
+ blur: 12,
206
+ alpha: .2
207
+ },
208
+ high: {
209
+ x: 0,
210
+ y: 8,
211
+ blur: 18,
212
+ alpha: .32
213
+ }
214
+ },
215
+ hard: {
216
+ low: {
217
+ x: 3,
218
+ y: 3,
219
+ blur: 0,
220
+ alpha: 1
221
+ },
222
+ medium: {
223
+ x: 5,
224
+ y: 5,
225
+ blur: 0,
226
+ alpha: 1
227
+ },
228
+ high: {
229
+ x: 8,
230
+ y: 8,
231
+ blur: 0,
232
+ alpha: 1
233
+ }
234
+ },
235
+ glow: {
236
+ low: {
237
+ x: 0,
238
+ y: 0,
239
+ blur: 12,
240
+ alpha: .65
241
+ },
242
+ medium: {
243
+ x: 0,
244
+ y: 0,
245
+ blur: 22,
246
+ alpha: .72
247
+ },
248
+ high: {
249
+ x: 0,
250
+ y: 0,
251
+ blur: 36,
252
+ alpha: .8
253
+ }
254
+ }
203
255
  };
204
- const elevationGaps = ({ elevation: { depth, hardness, source } }) => {
205
- if (depth === "none") return [];
206
- return [...SHADOWS[hardness]?.[depth] === void 0 ? [`elevation: ${hardness} ${depth}`] : [], ...source === "shade" ? [] : [`elevation.source: ${JSON.stringify(source)}`]];
256
+ /** A glow also draws a tight core, a little stronger than its halo, so the edge reads as lit. */
257
+ const GLOW_CORES = {
258
+ low: {
259
+ x: 0,
260
+ y: 0,
261
+ blur: 3,
262
+ alpha: .85
263
+ },
264
+ medium: {
265
+ x: 0,
266
+ y: 0,
267
+ blur: 3,
268
+ alpha: .92
269
+ },
270
+ high: {
271
+ x: 0,
272
+ y: 0,
273
+ blur: 3,
274
+ alpha: 1
275
+ }
207
276
  };
208
277
  // src/private/engine/kebab.ts
209
278
  /** `buttonPrimary` → `button-primary`, as surface names appear in variable names. */
@@ -214,27 +283,32 @@ const SURFACES = {
214
283
  page: {
215
284
  holdsContent: true,
216
285
  interactive: false,
217
- mayContainForm: false
286
+ mayContainForm: false,
287
+ shadowScale: 1
218
288
  },
219
289
  panel: {
220
290
  holdsContent: true,
221
291
  interactive: false,
222
- mayContainForm: true
292
+ mayContainForm: true,
293
+ shadowScale: 1.25
223
294
  },
224
295
  card: {
225
296
  holdsContent: true,
226
297
  interactive: true,
227
- mayContainForm: false
298
+ mayContainForm: false,
299
+ shadowScale: 1
228
300
  },
229
301
  buttonPrimary: {
230
302
  holdsContent: false,
231
303
  interactive: true,
232
- mayContainForm: false
304
+ mayContainForm: false,
305
+ shadowScale: .5
233
306
  },
234
307
  buttonSecondary: {
235
308
  holdsContent: false,
236
309
  interactive: true,
237
- mayContainForm: false
310
+ mayContainForm: false,
311
+ shadowScale: .5
238
312
  }
239
313
  };
240
314
  /** Every surface group, parents before the surfaces that sit on them. */
@@ -251,11 +325,405 @@ const SURFACE_GROUPS = SURFACE_NAMES.flatMap((surface) => {
251
325
  prefix: `${kebab(surface)}-on-${kebab(parent)}`
252
326
  }));
253
327
  });
328
+ // src/private/engine/rules/elevation.ts
329
+ const SHADE = new Color(SHADE_COLOR);
330
+ /** The opaque color of an elevation. Each shadow sets its own alpha. */
331
+ const elevationColor = (source, anchors) => source === "shade" ? SHADE : anchorOrSingleColor(source, anchors);
332
+ const ELEVATION_SLOTS = {
333
+ surfaces: SURFACE_NAMES,
334
+ initialValues: { "box-shadow": "none" }
335
+ };
336
+ const shadowLayer = ({ alpha, blur, x, y }, color) => `${x}px ${y}px ${blur}px ${color.withAlpha(alpha).toRgba()}`;
337
+ /** Whole pixels, and an offset that was there stays at least 1px so a small hard shadow survives. */
338
+ const scaled = (length, scale) => length === 0 ? 0 : Math.max(1, Math.round(length * scale));
339
+ const scaleShadow = ({ alpha, blur, x, y }, scale) => ({
340
+ alpha,
341
+ blur: scaled(blur, scale),
342
+ x: scaled(x, scale),
343
+ y: scaled(y, scale)
344
+ });
345
+ /** The glow's core stays tight on every surface, since it's what makes the edge read as lit. */
346
+ const castShadows = (surface, { depth, hardness, source }, anchors) => {
347
+ if (depth === "none") return [];
348
+ const color = elevationColor(source, anchors);
349
+ return [scaleShadow(SHADOWS[hardness][depth], SURFACES[surface].shadowScale), ...hardness === "glow" ? [GLOW_CORES[depth]] : []].map((shadow) => shadowLayer(shadow, color));
350
+ };
351
+ /**
352
+ * The elevation's shadow, if it casts one, scaled to the surface, with any layers the treatment
353
+ * draws after it.
354
+ */
355
+ const elevationSlots = (surface, elevation, anchors, treatmentLayers = []) => {
356
+ const layers = [...castShadows(surface, elevation, anchors), ...treatmentLayers];
357
+ return layers.length === 0 ? {} : { "box-shadow": layers.join(", ") };
358
+ };
254
359
  // src/private/engine/slots.ts
255
360
  const VARIABLE_PREFIX = "--wistia-kaleidoscope-";
256
361
  const surfacesWhere = (flag) => SURFACE_NAMES.filter((name) => SURFACES[name][flag]);
257
362
  const surfaceVariable = (prefix, slot) => `${VARIABLE_PREFIX}${prefix}-${slot}`;
258
363
  const typeVariable = (role, slot) => `${VARIABLE_PREFIX}type-${role}-${slot}`;
364
+ // src/private/engine/rules/fill.ts
365
+ /**
366
+ * A surface's fill. `background-image` holds layers drawn over `background-color` — glass sheens,
367
+ * gradients — and `backdrop-filter` blurs what is behind a translucent fill.
368
+ */
369
+ const FILL_SLOTS = {
370
+ surfaces: SURFACE_NAMES,
371
+ initialValues: {
372
+ "background-color": "transparent",
373
+ "background-image": "none",
374
+ "backdrop-filter": "none"
375
+ }
376
+ };
377
+ const HOVER_FILL_SLOTS = {
378
+ surfaces: surfacesWhere("interactive"),
379
+ initialValues: {
380
+ "background-color-hover": "transparent",
381
+ "background-image-hover": "none"
382
+ }
383
+ };
384
+ /** Inverting repaints a surface as a flat fill, so no other treatment can invert. */
385
+ const fillGaps = ({ backgroundColor: { invert }, treatment }) => treatment === "flat" || invert === "never" ? [] : [`backgroundColor.invert: ${invert}`];
386
+ // src/private/engine/constants/motion.ts
387
+ /** How long a surface takes to move between states. Placeholder. */
388
+ const TRANSITION_DURATIONS = {
389
+ none: null,
390
+ quick: "120ms",
391
+ smooth: "240ms"
392
+ };
393
+ /** The properties a state change animates. */
394
+ const TRANSITIONED_PROPERTIES = [
395
+ "background-color",
396
+ "box-shadow",
397
+ "border-color",
398
+ "color"
399
+ ];
400
+ const TRANSITION_EASING = "ease";
401
+ /** How long one drift takes per speed. */
402
+ const DRIFT_DURATIONS = {
403
+ slow: "10s",
404
+ medium: "6s",
405
+ fast: "3s"
406
+ };
407
+ /** How long one pulse takes per speed. Placeholder. */
408
+ const PULSE_DURATIONS = {
409
+ slow: "2.8s",
410
+ medium: "1.6s",
411
+ fast: "0.9s"
412
+ };
413
+ /** The shadow a pulse moves towards per size, in pixels. Placeholder. */
414
+ const PULSE_SHADOWS = {
415
+ small: {
416
+ y: 1,
417
+ blur: 6,
418
+ spread: 1
419
+ },
420
+ medium: {
421
+ y: 2,
422
+ blur: 14,
423
+ spread: 2
424
+ },
425
+ large: {
426
+ y: 4,
427
+ blur: 24,
428
+ spread: 4
429
+ }
430
+ };
431
+ /** How much of the pulse color its shadow shows. Placeholder. */
432
+ const PULSE_SHADOW_ALPHA = .7;
433
+ // src/private/engine/rules/motion.ts
434
+ const MOTION_SLOTS = {
435
+ surfaces: SURFACE_NAMES,
436
+ initialValues: { transition: "none" }
437
+ };
438
+ /**
439
+ * How long a pulse takes, and the color and shadow it moves towards, so each consumer writes its
440
+ * own `@keyframes`. `0s` means the surface doesn't pulse. A page can't pulse.
441
+ */
442
+ const PULSE_SLOTS = {
443
+ surfaces: SURFACE_NAMES.filter((surface) => surface !== "page"),
444
+ initialValues: {
445
+ "pulse-duration": "0s",
446
+ "pulse-color": "transparent",
447
+ "pulse-box-shadow": "none"
448
+ }
449
+ };
450
+ /**
451
+ * Only how long a page's drift takes. The contract is CSS variables only, so each consumer writes
452
+ * its own `@keyframes` and the layer that moves. `0s` means the page is still.
453
+ */
454
+ const PAGE_ANIMATION_SLOTS = {
455
+ surfaces: ["page"],
456
+ initialValues: { "animation-duration": "0s" }
457
+ };
458
+ const transitionSlots = (transition) => {
459
+ const duration = TRANSITION_DURATIONS[transition];
460
+ if (duration === null) return {};
461
+ return { transition: TRANSITIONED_PROPERTIES.map((property) => `${property} ${duration} ${TRANSITION_EASING}`).join(", ") };
462
+ };
463
+ /** `motionGaps` only lets `drift` through on the page, so this never names another surface's slot. */
464
+ const driftSlots = ({ ambient, speed }) => ambient === "drift" ? { "animation-duration": DRIFT_DURATIONS[speed] } : {};
465
+ /** `motionGaps` keeps a pulse off the page, so this never names a slot the page doesn't have. */
466
+ const pulseSlots = ({ elevation, motion }, anchors) => {
467
+ if (motion.ambient !== "pulse") return {};
468
+ const color = motion.pulseColor === "derive" ? elevationColor(elevation.source, anchors) : anchorOrSingleColor(motion.pulseColor, anchors);
469
+ const { blur, spread, y } = PULSE_SHADOWS[motion.pulseSize];
470
+ return {
471
+ "pulse-duration": PULSE_DURATIONS[motion.speed],
472
+ "pulse-color": color.toRgba(),
473
+ "pulse-box-shadow": `0 ${y}px ${blur}px ${spread}px ${color.withAlpha(PULSE_SHADOW_ALPHA).toRgba()}`
474
+ };
475
+ };
476
+ const motionSlots = (settings, anchors) => ({
477
+ ...transitionSlots(settings.motion.transition),
478
+ ...driftSlots(settings.motion),
479
+ ...pulseSlots(settings, anchors)
480
+ });
481
+ /** Only the page drifts so far, and every surface but the page can pulse. */
482
+ const motionGaps = ({ motion: { ambient } }, surface) => ambient === "drift" && surface !== "page" || ambient === "pulse" && surface === "page" ? [`motion.ambient: ${ambient}`] : [];
483
+ // src/private/engine/rules/panelInput.ts
484
+ /** The form fields inside a panel. */
485
+ const PANEL_INPUT_SLOTS = {
486
+ surfaces: surfacesWhere("mayContainForm"),
487
+ initialValues: {
488
+ "input-background-color": "transparent",
489
+ "input-background-color-focus": "transparent",
490
+ "input-border-color-focus": "transparent"
491
+ }
492
+ };
493
+ /** Inputs step off the panel's fill unless given `fills`, and take the primary color when focused. */
494
+ const panelInputSlots = (solid, anchors, fills) => ({
495
+ ...fills ?? {
496
+ "input-background-color": stepFrom(solid, 1).toHex(),
497
+ "input-background-color-focus": stepFrom(solid, 2).toHex()
498
+ },
499
+ "input-border-color-focus": anchorColor("anchors.colors.primary", anchors).toHex()
500
+ });
501
+ // src/private/engine/constants/radius.ts
502
+ /** How the radius anchor scales on each surface. Placeholder. */
503
+ const RADIUS_FACTORS = {
504
+ page: 0,
505
+ panel: 1,
506
+ card: .7,
507
+ buttonPrimary: .5,
508
+ buttonSecondary: .5
509
+ };
510
+ // src/private/engine/rules/radius.ts
511
+ const RADIUS_SLOTS = {
512
+ surfaces: SURFACE_NAMES,
513
+ initialValues: { "border-radius": "0" }
514
+ };
515
+ const radiusSlots = (surface, { source }, anchors) => ({ "border-radius": source === "anchors.dimensions.borderRadius" ? `${Math.round(anchors.borderRadius * RADIUS_FACTORS[surface])}px` : `${anchors.dimension(source)}px` });
516
+ // src/private/engine/rules/text.ts
517
+ const TEXT_SLOTS = {
518
+ surfaces: SURFACE_NAMES,
519
+ initialValues: { "text-color": "canvastext" }
520
+ };
521
+ const CONTENT_TEXT_SLOTS = {
522
+ surfaces: surfacesWhere("holdsContent"),
523
+ initialValues: {
524
+ "heading-text-color": "canvastext",
525
+ "low-emphasis-text-color": "canvastext"
526
+ }
527
+ };
528
+ const HOVER_TEXT_SLOTS = {
529
+ surfaces: surfacesWhere("interactive"),
530
+ initialValues: { "text-color-hover": "canvastext" }
531
+ };
532
+ const CONTENT_HOVER_TEXT_SLOTS = {
533
+ surfaces: surfacesWhere("interactive").filter((surface) => SURFACES[surface].holdsContent),
534
+ initialValues: {
535
+ "heading-text-color-hover": "canvastext",
536
+ "low-emphasis-text-color-hover": "canvastext"
537
+ }
538
+ };
539
+ const isPreference = (textColor) => typeof textColor === "object" && "source" in textColor;
540
+ /** A color anchor or a color, used as written. */
541
+ const isFixed = (textColor) => textColor !== "derive" && !isPreference(textColor);
542
+ /**
543
+ * `derive` allows text color to be calculated by the engine so we can pick a color with appropriate contrast.
544
+ * A preferred color starts from a reference point (a color anchor) and adjusts it until it meets required contrast rule
545
+ * A color anchor or a color is used as written, with no contrast guarantee.
546
+ */
547
+ const resolveTextColor = (textColor, solid, anchors) => {
548
+ if (isFixed(textColor)) return anchorOrSingleColor(textColor, anchors);
549
+ if (textColor === "derive") return getBestColorForText({ backgroundColor: solid });
550
+ const { offset, source } = textColor;
551
+ const preferred = stepAlong(anchorScale(source, anchors), anchorColor(source, anchors), offset);
552
+ return adjustColorForProperContrast({
553
+ foregroundColor: preferred,
554
+ backgroundColor: solid
555
+ });
556
+ };
557
+ /**
558
+ * A surface's text. One with no fill shows its parent, so it takes its parent's text and hover rule
559
+ * in place of its own `textColor`.
560
+ */
561
+ const surfaceText = ({ textColor, treatment }, solid, anchors, parent) => treatment === "none" && parent !== null ? {
562
+ text: parent.text,
563
+ textColor: parent.textColor
564
+ } : {
565
+ text: resolveTextColor(textColor, solid, anchors),
566
+ textColor
567
+ };
568
+ const textSlots = (surface, text) => ({
569
+ "text-color": text.toHex(),
570
+ ...SURFACES[surface].holdsContent ? {
571
+ "heading-text-color": text.toHex(),
572
+ "low-emphasis-text-color": text.withAlpha(LOW_EMPHASIS_TEXT_ALPHA).toRgba()
573
+ } : {}
574
+ });
575
+ /**
576
+ * The same text slots with a `-hover` suffix, moved only as far as the hovered fill needs. A fixed
577
+ * color stays as written.
578
+ */
579
+ const hoverTextSlots = (surface, textColor, text, solidHover) => {
580
+ const readable = isFixed(textColor) ? text : adjustColorForProperContrast({
581
+ foregroundColor: text,
582
+ backgroundColor: solidHover
583
+ });
584
+ return Object.fromEntries(Object.entries(textSlots(surface, readable)).map(([slot, value]) => [`${slot}-hover`, value]));
585
+ };
586
+ // src/private/engine/constants/texture.ts
587
+ /** How opaque each intensity draws a texture's tile. Placeholder. */
588
+ const TEXTURE_OPACITY = {
589
+ low: .35,
590
+ medium: .6,
591
+ high: .9
592
+ };
593
+ /**
594
+ * How much of its intensity's opacity a texture keeps near either end. Specks and dots that
595
+ * `multiply` or `screen` show far more than `soft-light` does in between, so they draw fainter.
596
+ * Placeholder.
597
+ */
598
+ const TEXTURE_EDGE_OPACITY = {
599
+ dark: .6,
600
+ light: .3
601
+ };
602
+ // src/private/engine/rules/texture.ts
603
+ /**
604
+ * A texture is a tile laid over the fill. `texture-image` is a `background-image` that repeats at
605
+ * the tile's own size, and `texture-blend-mode` blends it with the fill beneath.
606
+ */
607
+ const TEXTURE_SLOTS = {
608
+ surfaces: SURFACE_NAMES,
609
+ initialValues: {
610
+ "texture-image": "none",
611
+ "texture-blend-mode": "normal"
612
+ }
613
+ };
614
+ const svgTile = (size, body) => `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='${size}' height='${size}'>${body}</svg>`)}")`;
615
+ const SOFT_STRETCH = "type='linear' slope='2.4' intercept='-0.7'";
616
+ /** Every pixel lands on black or white, like screen static. */
617
+ const HARD_THRESHOLD = "type='discrete' tableValues='0 1'";
618
+ const toneOf = (solid) => {
619
+ const luminance = solid.luminance();
620
+ if (luminance < .2) return "dark";
621
+ return luminance > .9 ? "light" : "mid";
622
+ };
623
+ /**
624
+ * What the gray noise becomes. On a mid fill it stays opaque gray, so the blend alone decides how it
625
+ * shows. Near either end only its dark or light half survives, as black or white specks on a clear
626
+ * tile, alpha running from 0 at middle gray.
627
+ */
628
+ const NOISE_INK = {
629
+ mid: "<feComponentTransfer><feFuncA type='table' tableValues='1 1'/></feComponentTransfer>",
630
+ light: "<feColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.4252 -1.4304 -0.1444 0 1'/>",
631
+ dark: "<feColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0.4252 1.4304 0.1444 0 -1'/>"
632
+ };
633
+ const noise = (size, frequency, stretch, opacity, tone) => svgTile(size, `<filter id='t' x='0' y='0'><feTurbulence type='fractalNoise' baseFrequency='${frequency}' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/><feComponentTransfer><feFuncR ${stretch}/><feFuncG ${stretch}/><feFuncB ${stretch}/></feComponentTransfer>${NOISE_INK[tone]}</filter><rect width='100%' height='100%' filter='url(#t)' opacity='${opacity}'/>`);
634
+ const dot = (color, opacity) => svgTile(5, `<radialGradient id='d'><stop offset='.65' stop-color='${color}'/><stop offset='1' stop-color='${color}' stop-opacity='0'/></radialGradient><circle cx='2.5' cy='2.5' r='1.7' fill='url(#d)' opacity='${opacity}'/>`);
635
+ const round = (value) => Math.round(value * 1e3) / 1e3;
636
+ const TILES = {
637
+ grain: (opacity, tone) => noise(160, .9, SOFT_STRETCH, opacity, tone),
638
+ static: (opacity, tone) => noise(200, .65, HARD_THRESHOLD, round(opacity * .75), tone),
639
+ halftone: (opacity, tone) => dot(tone === "dark" ? "#fff" : "#000", opacity)
640
+ };
641
+ const opacityFor = (intensity, tone) => tone === "mid" ? TEXTURE_OPACITY[intensity] : round(TEXTURE_OPACITY[intensity] * TEXTURE_EDGE_OPACITY[tone]);
642
+ const BLEND_MODES = {
643
+ dark: "screen",
644
+ light: "multiply",
645
+ mid: "soft-light"
646
+ };
647
+ /**
648
+ * The texture's tile and blend for a fill. Near white it draws only dark specks or dots with
649
+ * `multiply`, near black only light ones with `screen`, and `soft-light` in between.
650
+ */
651
+ const textureSlots = ({ intensity, kind }, solid) => {
652
+ if (kind === "none") return {};
653
+ const tone = toneOf(solid);
654
+ return {
655
+ "texture-image": TILES[kind](opacityFor(intensity, tone), tone),
656
+ "texture-blend-mode": BLEND_MODES[tone]
657
+ };
658
+ };
659
+ // src/private/engine/constants/typography.ts
660
+ /** Letter spacing for `case: upper`, which reads cramped at the spacing set for mixed case. */
661
+ const UPPERCASE_LETTER_SPACING = "0.05em";
662
+ // src/private/engine/rules/typography.ts
663
+ /**
664
+ * `font-family` has no fixed initial value — it is up to the browser — so its unused value is the
665
+ * generic family instead.
666
+ */
667
+ const TYPE_INITIAL_VALUES = {
668
+ "font-family": "sans-serif",
669
+ "font-size": "medium",
670
+ "font-weight": "normal",
671
+ "text-transform": "none",
672
+ "letter-spacing": "normal"
673
+ };
674
+ const TYPOGRAPHY_CONTRACT = Object.fromEntries(TYPE_ROLES.flatMap((role) => Object.entries(TYPE_INITIAL_VALUES).map(([slot, value]) => [typeVariable(role, slot), value])));
675
+ const typographyVariables = ({ typography }, anchors) => Object.fromEntries(TYPE_ROLES.flatMap((role) => {
676
+ const type = typography[role];
677
+ const upper = type.case === "upper";
678
+ return [
679
+ [typeVariable(role, "font-family"), anchors.fonts[type.font]],
680
+ [typeVariable(role, "font-size"), `${type.fontSize}px`],
681
+ [typeVariable(role, "font-weight"), String(type.fontWeight)],
682
+ [typeVariable(role, "text-transform"), upper ? "uppercase" : "none"],
683
+ [typeVariable(role, "letter-spacing"), upper ? UPPERCASE_LETTER_SPACING : "normal"]
684
+ ];
685
+ }));
686
+ // src/private/engine/contract.ts
687
+ /** Every rule's surface slots. A rule that adds slots adds its fragment here. */
688
+ const SURFACE_SLOT_FRAGMENTS = [
689
+ FILL_SLOTS,
690
+ HOVER_FILL_SLOTS,
691
+ TEXT_SLOTS,
692
+ CONTENT_TEXT_SLOTS,
693
+ HOVER_TEXT_SLOTS,
694
+ CONTENT_HOVER_TEXT_SLOTS,
695
+ PANEL_INPUT_SLOTS,
696
+ BORDER_SLOTS,
697
+ ELEVATION_SLOTS,
698
+ RADIUS_SLOTS,
699
+ MOTION_SLOTS,
700
+ PULSE_SLOTS,
701
+ PAGE_ANIMATION_SLOTS,
702
+ TEXTURE_SLOTS
703
+ ];
704
+ const surfaceContract = () => Object.fromEntries(SURFACE_GROUPS.flatMap(({ prefix, surface }) => SURFACE_SLOT_FRAGMENTS.filter(({ surfaces }) => surfaces.includes(surface)).flatMap(({ initialValues }) => Object.entries(initialValues).map(([slot, value]) => [surfaceVariable(prefix, slot), value]))));
705
+ // src/kaleidoscopeContract.ts
706
+ /**
707
+ * Every variable the engine emits, with the value it takes when a Style doesn't use the rule
708
+ * behind it: the CSS initial value of the property it feeds, or the value that draws nothing.
709
+ * Every Style emits exactly these names, so embeds and hosted pages can rely on each one.
710
+ *
711
+ * Surface variables are `--wistia-kaleidoscope-<surface>-<slot>`. A surface that can sit on several
712
+ * parents is emitted once per parent, as `<surface>-on-<parent>`: `button-primary-on-panel`. Slots
713
+ * are named after the CSS property they feed — `background-color`, `border-radius`, `box-shadow` —
714
+ * with a `-hover` or `-focus` suffix for a state. There are two exceptions: `text-color`,
715
+ * `heading-text-color` and `low-emphasis-text-color` all feed `color`, and a panel's input slots
716
+ * carry an `input-` prefix, as in `input-background-color`. A texture is a layer of its own:
717
+ * `texture-image` is a `background-image` to draw over the fill, and `texture-blend-mode` is the
718
+ * blend mode to draw it with.
719
+ *
720
+ * Typography variables are `--wistia-kaleidoscope-type-<role>-<property>`, for the `heading`,
721
+ * `body` and `button` roles.
722
+ */
723
+ const KALEIDOSCOPE_CONTRACT = {
724
+ ...surfaceContract(),
725
+ ...TYPOGRAPHY_CONTRACT
726
+ };
259
727
  // src/private/engine/treatments/flat.ts
260
728
  /**
261
729
  * A step away from the text, unless that lands too close to the resting fill or the parent to be
@@ -288,6 +756,34 @@ const flat = ({ anchors, parent, settings }) => {
288
756
  if (parent !== null && solid.contrast(parent.solid) < 1.1) solid = stepAlong(scale, start, offset + 1);
289
757
  return flatFill(solid, scale, parent);
290
758
  };
759
+ // src/private/engine/rules/invert.ts
760
+ /**
761
+ * `invert: when-indistinct`: if a surface's background fill color is too close to its parent background fill,
762
+ * invert: when-indistinct allows the fill and text color to be inverted. This provides better contrast between the surface
763
+ * and its parent while also preserving legible contrast between the surface and its text color.
764
+ */
765
+ const invertWhenIndistinct = ({ backgroundColor: { invert }, treatment }, treated, text, parent) => {
766
+ if (invert !== "when-indistinct" || treatment !== "flat" || parent === null) return {
767
+ text,
768
+ treated
769
+ };
770
+ const fillContrast = treated.solid.contrast(parent.solid);
771
+ return fillContrast < INVERT_BELOW_CONTRAST && text.contrast(parent.solid) > fillContrast ? {
772
+ text: treated.solid,
773
+ treated: flatFill(text, null, parent)
774
+ } : {
775
+ text,
776
+ treated
777
+ };
778
+ };
779
+ // src/private/engine/composite.ts
780
+ /** `top` laid over `under`, flattened to the opaque color the eye sees. */
781
+ const composite = (top, under) => new Color([
782
+ top.r * top.a + under.r * (1 - top.a),
783
+ top.g * top.a + under.g * (1 - top.a),
784
+ top.b * top.a + under.b * (1 - top.a),
785
+ 1
786
+ ]);
291
787
  // src/private/engine/constants/glass.ts
292
788
  const GLASS_LIGHT_COLOR = "#ffffff";
293
789
  const GLASS_SHADE_COLOR = "#000000";
@@ -402,115 +898,172 @@ const LIGHT_CONTROL = {
402
898
  liftsParent: false,
403
899
  specularAlpha: .5
404
900
  };
405
- const GLASS_TIERS = {
901
+ const GLASS_TIER_DEFAULTS = {
406
902
  dark: {
407
- page: DARK_CONTAINER,
408
- panel: DARK_CONTAINER,
903
+ container: DARK_CONTAINER,
409
904
  card: DARK_CARD,
410
- buttonPrimary: DARK_CONTROL,
411
- buttonSecondary: DARK_CONTROL
905
+ control: DARK_CONTROL
412
906
  },
413
907
  light: {
414
- page: LIGHT_CONTAINER,
415
- panel: LIGHT_CONTAINER,
908
+ container: LIGHT_CONTAINER,
416
909
  card: LIGHT_CARD,
417
- buttonPrimary: LIGHT_CONTROL,
418
- buttonSecondary: LIGHT_CONTROL
419
- }
420
- };
421
- // src/private/engine/rules/text.ts
422
- const TEXT_SLOTS = {
423
- surfaces: SURFACE_NAMES,
424
- initialValues: { "text-color": "canvastext" }
425
- };
426
- const CONTENT_TEXT_SLOTS = {
427
- surfaces: surfacesWhere("holdsContent"),
428
- initialValues: {
429
- "heading-text-color": "canvastext",
430
- "low-emphasis-text-color": "canvastext"
431
- }
432
- };
433
- const HOVER_TEXT_SLOTS = {
434
- surfaces: surfacesWhere("interactive"),
435
- initialValues: { "text-color-hover": "canvastext" }
436
- };
437
- const CONTENT_HOVER_TEXT_SLOTS = {
438
- surfaces: surfacesWhere("interactive").filter((surface) => SURFACES[surface].holdsContent),
439
- initialValues: {
440
- "heading-text-color-hover": "canvastext",
441
- "low-emphasis-text-color-hover": "canvastext"
910
+ control: LIGHT_CONTROL
442
911
  }
443
912
  };
444
- const isPreference = (textColor) => typeof textColor === "object" && "source" in textColor;
445
- const isLiteral = (textColor) => typeof textColor === "string" && (textColor.startsWith("#") || textColor.startsWith("rgb"));
446
- /**
447
- * `derive` allows text color to be calculated by the engine so we can pick a color with appropriate contrast.
448
- * A preferred color starts from a reference point (a color anchor) and adjusts it until it meets required contrast rule
449
- * A literal is used as written, with no contrast guarantee.
450
- */
451
- const resolveTextColor = (textColor, solid, anchors) => {
452
- if (isLiteral(textColor)) return new Color(textColor);
453
- if (!isPreference(textColor)) return getBestColorForText({ backgroundColor: solid });
454
- const { offset, source } = textColor;
455
- const preferred = stepAlong(anchorScale(source, anchors), anchorColor(source, anchors), offset);
456
- return adjustColorForProperContrast({
457
- foregroundColor: preferred,
458
- backgroundColor: solid
459
- });
913
+ const GLASS_TIER_OF_SURFACE = {
914
+ page: "container",
915
+ panel: "container",
916
+ card: "card",
917
+ buttonPrimary: "control",
918
+ buttonSecondary: "control"
919
+ };
920
+ /** Glass over a ground anchor darker than this is dark glass. */
921
+ const GLASS_DARK_BELOW_LUMINANCE = .2;
922
+ // src/private/engine/constants/gradient.ts
923
+ const GLOWS = {
924
+ alpha: .42,
925
+ size: "62% 56%",
926
+ fadeStop: 70,
927
+ darkFillLuminance: .2,
928
+ dark: {
929
+ alpha: .72,
930
+ size: "72% 66%",
931
+ midAlphaFactor: .6,
932
+ midStop: 38,
933
+ fadeStop: 72
934
+ },
935
+ positions: [
936
+ "14% 16%",
937
+ "86% 22%",
938
+ "62% 92%",
939
+ "10% 80%",
940
+ "48% 50%",
941
+ "94% 66%"
942
+ ]
943
+ };
944
+ const LINEAR_ANGLES = {
945
+ "to-top": 0,
946
+ "to-top-right": 45,
947
+ "to-right": 90,
948
+ "to-bottom-right": 135,
949
+ "to-bottom": 180,
950
+ "to-bottom-left": 225,
951
+ "to-left": 270,
952
+ "to-top-left": 315
953
+ };
954
+ const RADIAL_POSITIONS = {
955
+ center: "50% 50%",
956
+ top: "50% 0%",
957
+ "top-right": "100% 0%",
958
+ right: "100% 50%",
959
+ "bottom-right": "100% 100%",
960
+ bottom: "50% 100%",
961
+ "bottom-left": "0% 100%",
962
+ left: "0% 50%",
963
+ "top-left": "0% 0%"
460
964
  };
461
- const textSlots = (surface, text) => ({
462
- "text-color": text.toHex(),
463
- ...SURFACES[surface].holdsContent ? {
464
- "heading-text-color": text.toHex(),
465
- "low-emphasis-text-color": text.withAlpha(LOW_EMPHASIS_TEXT_ALPHA).toRgba()
466
- } : {}
467
- });
468
965
  /**
469
- * The same text slots with a `-hover` suffix, moved only as far as the hovered fill needs. A literal
470
- * stays as written.
966
+ * `near` is `farthest-side`, not `closest-side`: every position but `center` sits on an edge or a
967
+ * corner, where the closest side is zero away, and a circle with no radius paints only its last stop.
471
968
  */
472
- const hoverTextSlots = (surface, textColor, text, solidHover) => {
473
- const readable = isLiteral(textColor) ? text : adjustColorForProperContrast({
474
- foregroundColor: text,
475
- backgroundColor: solidHover
476
- });
477
- return Object.fromEntries(Object.entries(textSlots(surface, readable)).map(([slot, value]) => [`${slot}-hover`, value]));
969
+ const RADIAL_EXTENTS = {
970
+ near: "farthest-side",
971
+ far: "farthest-corner"
972
+ };
973
+ /**
974
+ * `beams`: crossed lines in the stop colors over the surface's own fill. Each line is a tinted
975
+ * core inside a glow that falls off through `bands`, as px from its center and alpha, all scaled
976
+ * by `opacity`. Two faint pools of the first and last stop sit beneath. Placeholder.
977
+ */
978
+ const BEAMS = {
979
+ lines: [
980
+ {
981
+ angle: 64,
982
+ at: 16,
983
+ stop: 0
984
+ },
985
+ {
986
+ angle: 116,
987
+ at: 34,
988
+ stop: 1
989
+ },
990
+ {
991
+ angle: 76,
992
+ at: 62,
993
+ stop: 2
994
+ },
995
+ {
996
+ angle: 14,
997
+ at: 40,
998
+ stop: 1
999
+ },
1000
+ {
1001
+ angle: 164,
1002
+ at: 58,
1003
+ stop: 0
1004
+ }
1005
+ ],
1006
+ bands: [
1007
+ [34, 0],
1008
+ [18, .07],
1009
+ [9, .18],
1010
+ [2.5, .34]
1011
+ ],
1012
+ core: [.8, .55],
1013
+ coreTint: .45,
1014
+ opacity: .6,
1015
+ pools: [{
1016
+ first: true,
1017
+ alpha: .12,
1018
+ geometry: "70% 45% at 50% 100%"
1019
+ }, {
1020
+ first: false,
1021
+ alpha: .096,
1022
+ geometry: "50% 35% at 10% 0%"
1023
+ }]
1024
+ };
1025
+ let current = {
1026
+ glass: {
1027
+ darkBelowLuminance: GLASS_DARK_BELOW_LUMINANCE,
1028
+ inputAlpha: GLASS_INPUT_ALPHA,
1029
+ inputFocusAlpha: GLASS_INPUT_FOCUS_ALPHA,
1030
+ lightColor: GLASS_LIGHT_COLOR,
1031
+ sheenAngle: GLASS_SHEEN_ANGLE,
1032
+ sheenStops: GLASS_SHEEN_STOPS,
1033
+ tiers: GLASS_TIER_DEFAULTS
1034
+ },
1035
+ glows: GLOWS
478
1036
  };
479
- const textGaps = ({ textColor }) => textColor === "derive" || isPreference(textColor) || isLiteral(textColor) ? [] : [`textColor: ${JSON.stringify(textColor)}`];
1037
+ /** The tuning treatments read. The defaults, except inside `withEngineTuning`. */
1038
+ const engineTuning = () => current;
480
1039
  // src/private/engine/treatments/glassy.ts
481
- const LIGHT = new Color(GLASS_LIGHT_COLOR);
482
- /** `top` laid over `under`, flattened to the opaque color the eye sees. */
483
- const composite = (top, under) => new Color([
484
- top.r * top.a + under.r * (1 - top.a),
485
- top.g * top.a + under.g * (1 - top.a),
486
- top.b * top.a + under.b * (1 - top.a),
487
- 1
488
- ]);
489
- const sheen = ({ sheen: alphas }) => {
490
- const stops = alphas.map((alpha, index) => `${LIGHT.withAlpha(alpha).toRgba()} ${GLASS_SHEEN_STOPS[index] ?? 100}%`);
491
- return `linear-gradient(${GLASS_SHEEN_ANGLE}, ${stops.join(", ")})`;
1040
+ const sheen = ({ sheen: alphas }, glass) => {
1041
+ const light = new Color(glass.lightColor);
1042
+ const stops = alphas.map((alpha, index) => `${light.withAlpha(alpha).toRgba()} ${glass.sheenStops[index] ?? 100}%`);
1043
+ return `linear-gradient(${glass.sheenAngle}, ${stops.join(", ")})`;
492
1044
  };
493
1045
  /** Inner shade, then the edge, then the specular highlights and the fainter edge opposite them. */
494
- const glassShadowLayers = (tier) => [
1046
+ const glassShadowLayers = (tier, light) => [
495
1047
  ...tier.innerShade === null ? [] : [`${tier.innerShade[0]} ${new Color(tier.innerShade[1]).withAlpha(tier.innerShade[2]).toRgba()}`],
496
- `${tier.edge} ${LIGHT.withAlpha(tier.edgeAlpha).toRgba()}`,
497
- ...tier.specular.map((geometry) => `${geometry} ${LIGHT.withAlpha(tier.specularAlpha).toRgba()}`),
498
- `${tier.counterEdge[0]} ${LIGHT.withAlpha(tier.counterEdge[1]).toRgba()}`
1048
+ `${tier.edge} ${light.withAlpha(tier.edgeAlpha).toRgba()}`,
1049
+ ...tier.specular.map((geometry) => `${geometry} ${light.withAlpha(tier.specularAlpha).toRgba()}`),
1050
+ `${tier.counterEdge[0]} ${light.withAlpha(tier.counterEdge[1]).toRgba()}`
499
1051
  ];
500
1052
  /**
501
1053
  * A translucent ground under a sheen. `solid` is that ground flattened over the parent, so text and
502
1054
  * children resolve against what the eye sees.
503
1055
  */
504
1056
  const glassy = ({ anchors, parent, settings, surface }) => {
1057
+ const { glass } = engineTuning();
505
1058
  const { offset, source } = settings.backgroundColor;
506
1059
  const sourceColor = source === "parent" ? parent?.solid ?? anchorColor("anchors.colors.pageBackground", anchors) : anchorColor(source, anchors);
507
- const tone = (anchors.colors.ground ?? sourceColor).luminance() < .2 ? "dark" : "light";
508
- const tier = GLASS_TIERS[tone][surface];
1060
+ const tone = (anchors.colors.ground ?? sourceColor).luminance() < glass.darkBelowLuminance ? "dark" : "light";
1061
+ const tier = glass.tiers[tone][GLASS_TIER_OF_SURFACE[surface]];
509
1062
  const inherited = source === "parent" ? parent?.scale ?? null : anchors.scales[anchorName(source)];
510
1063
  const base = stepAlong(inherited ?? scaleOf(sourceColor), sourceColor, offset);
511
1064
  const under = parent?.solid ?? base;
512
1065
  const ground = (tier.liftsParent ? resolveTextColor(settings.textColor, under, anchors) : base).withAlpha(tier.groundAlpha);
513
- const image = sheen(tier);
1066
+ const image = sheen(tier, glass);
514
1067
  return {
515
1068
  solid: composite(ground, under),
516
1069
  scale: null,
@@ -529,69 +1082,91 @@ const glassy = ({ anchors, parent, settings, surface }) => {
529
1082
  }
530
1083
  };
531
1084
  },
1085
+ layersOver: (solid) => tier.sheen.map((alpha) => composite(new Color(glass.lightColor).withAlpha(alpha), solid)),
532
1086
  tintedBy: (text) => ({
533
1087
  inputFills: {
534
- "input-background-color": text.withAlpha(GLASS_INPUT_ALPHA).toRgba(),
535
- "input-background-color-focus": text.withAlpha(GLASS_INPUT_FOCUS_ALPHA).toRgba()
1088
+ "input-background-color": text.withAlpha(glass.inputAlpha).toRgba(),
1089
+ "input-background-color-focus": text.withAlpha(glass.inputFocusAlpha).toRgba()
536
1090
  },
537
- shadowLayers: glassShadowLayers(tier)
1091
+ shadowLayers: glassShadowLayers(tier, new Color(glass.lightColor))
538
1092
  })
539
1093
  };
540
1094
  };
541
- // src/private/engine/constants/gradient.ts
542
- /**
543
- * `glows`: soft orbs in the stop colors over the surface's own fill. A dark fill swallows them, so
544
- * there they are stronger and fuller. Placeholder.
545
- */
546
- const GLOWS = {
547
- alpha: .42,
548
- size: "62% 56%",
549
- fadeStop: 70,
550
- darkFillLuminance: .2,
551
- dark: {
552
- alpha: .72,
553
- size: "72% 66%",
554
- midAlphaFactor: .6,
555
- midStop: 38,
556
- fadeStop: 72
557
- },
558
- positions: [
559
- "14% 16%",
560
- "86% 22%",
561
- "62% 92%",
562
- "10% 80%",
563
- "48% 50%",
564
- "94% 66%"
565
- ]
566
- };
1095
+ /** Glass has a fixed ground that its parent shows through, so it can't count from its parent. */
1096
+ const glassyGaps = ({ backgroundColor: { from }, treatment }) => treatment === "glassy" && from === "parent" ? ["backgroundColor.from: parent"] : [];
567
1097
  // src/private/engine/treatments/gradient.ts
568
- const glowLayer = (stop, position, onDark) => {
1098
+ const glowLayer = (glows, stop, position, onDark) => {
569
1099
  if (onDark) {
570
- const { alpha, fadeStop, midAlphaFactor, midStop, size } = GLOWS.dark;
1100
+ const { alpha, fadeStop, midAlphaFactor, midStop, size } = glows.dark;
571
1101
  return `radial-gradient(${size} at ${position}, ${stop.withAlpha(alpha).toRgba()} 0%, ${stop.withAlpha(alpha * midAlphaFactor).toRgba()} ${midStop}%, transparent ${fadeStop}%)`;
572
1102
  }
573
- return `radial-gradient(${GLOWS.size} at ${position}, ${stop.withAlpha(GLOWS.alpha).toRgba()} 0%, transparent ${GLOWS.fadeStop}%)`;
1103
+ return `radial-gradient(${glows.size} at ${position}, ${stop.withAlpha(glows.alpha).toRgba()} 0%, transparent ${glows.fadeStop}%)`;
574
1104
  };
575
1105
  const glowsImage = (stops, fill) => {
576
- const onDark = fill.luminance() < GLOWS.darkFillLuminance;
577
- return stops.map((stop, index) => glowLayer(stop, GLOWS.positions[index % GLOWS.positions.length] ?? "center", onDark)).join(", ");
1106
+ const { glows } = engineTuning();
1107
+ const onDark = fill.luminance() < glows.darkFillLuminance;
1108
+ return stops.map((stop, index) => glowLayer(glows, stop, glows.positions[index % glows.positions.length] ?? "center", onDark)).join(", ");
1109
+ };
1110
+ const offsetFrom = (at, px) => `calc(${at}% ${px < 0 ? "-" : "+"} ${Math.abs(px)}px)`;
1111
+ /** One beam: its bands from the outside in, the core, and the same bands back out. */
1112
+ const beamLayer = (color, angle, at) => {
1113
+ const [coreWidth, coreAlpha] = BEAMS.core;
1114
+ const core = color.tint(BEAMS.coreTint);
1115
+ const stopAt = (shade, alpha, px) => `${shade.withAlpha(Number((alpha * BEAMS.opacity).toFixed(3))).toRgba()} ${offsetFrom(at, px)}`;
1116
+ const rising = BEAMS.bands.map(([px, alpha]) => stopAt(color, alpha, -px));
1117
+ const falling = BEAMS.bands.map(([px, alpha]) => stopAt(color, alpha, px)).toReversed();
1118
+ const [[edge]] = BEAMS.bands;
1119
+ return `linear-gradient(${angle}deg, transparent ${offsetFrom(at, -edge - 1)}, ${[
1120
+ ...rising,
1121
+ stopAt(core, coreAlpha, -coreWidth),
1122
+ stopAt(core, coreAlpha, coreWidth),
1123
+ ...falling
1124
+ ].join(", ")}, transparent ${offsetFrom(at, edge + 1)})`;
1125
+ };
1126
+ const beamsImage = (stops, fill) => {
1127
+ const stopAt = (index) => stops[index % stops.length] ?? fill;
1128
+ return [...BEAMS.lines.map(({ angle, at, stop }) => beamLayer(stopAt(stop), angle, at)), ...BEAMS.pools.map(({ alpha, first, geometry }) => `radial-gradient(${geometry}, ${stopAt(first ? 0 : stops.length - 1).withAlpha(alpha).toRgba()}, transparent 70%)`)].join(", ");
1129
+ };
1130
+ const evenStops = (stops) => stops.map((stop, index) => `${stop.toHex()} ${Math.round(index / (stops.length - 1) * 100)}%`).join(", ");
1131
+ const SHAPE_IMAGES = {
1132
+ glows: (_shape, stops, fill) => glowsImage(stops, fill),
1133
+ beams: (_shape, stops, fill) => beamsImage(stops, fill),
1134
+ linear: ({ direction }, stops) => `linear-gradient(${LINEAR_ANGLES[direction]}deg, ${evenStops(stops)})`,
1135
+ radial: ({ extent, position }, stops) => `radial-gradient(circle ${RADIAL_EXTENTS[extent]} at ${RADIAL_POSITIONS[position]}, ${evenStops(stops)})`
1136
+ };
1137
+ const shapeImage = (kind, shape, stops, fill) => SHAPE_IMAGES[kind](shape, stops, fill);
1138
+ /** `linear` and `radial` paint over the whole surface, so the fill under them never shows. */
1139
+ const isCovering = (shape) => shape.kind === "linear" || shape.kind === "radial";
1140
+ const meanOf = (stops) => {
1141
+ const mean = (channel) => stops.reduce((sum, stop) => sum + stop[channel], 0) / stops.length;
1142
+ return new Color([
1143
+ mean("r"),
1144
+ mean("g"),
1145
+ mean("b"),
1146
+ 1
1147
+ ]);
578
1148
  };
579
1149
  /**
580
- * Gradient layers over the surface's own fill. The fill is `solid`: it is what text is solved
581
- * against, so nothing derives a color from the layers moving over it.
1150
+ * Gradient layers in the stop colors: the shape's own `stops`, or else the Style's. `glows` and
1151
+ * `beams` move over the surface's own fill, which is `solid`, so nothing derives a color from the
1152
+ * layers. `linear` and `radial` cover the fill, so `solid`, what text is solved against, is the
1153
+ * stops' average instead.
582
1154
  */
583
1155
  const gradient = ({ anchors, parent, settings }) => {
584
- const { gradientStops } = anchors;
1156
+ const shape = settings.gradientShape ?? { kind: "glows" };
1157
+ const gradientStops = shape.stops?.map((stop) => anchorOrSingleColor(stop, anchors)) ?? anchors.gradientStops;
585
1158
  if (gradientStops === null) throw new Error("anchors.colors.gradientStops is referenced but not declared");
586
1159
  const { from, offset, source } = settings.backgroundColor;
587
1160
  const sourceColor = source === "parent" ? parent?.solid ?? anchorColor("anchors.colors.pageBackground", anchors) : anchorColor(source, anchors);
588
- const scale = (source === "parent" ? parent?.scale ?? null : anchors.scales[anchorName(source)]) ?? scaleOf(sourceColor);
1161
+ const inherited = source === "parent" ? parent?.scale ?? null : anchors.scales[anchorName(source)];
589
1162
  const start = from === "parent" && parent !== null ? parent.solid : sourceColor;
590
- const solid = stepAlong(scale, start, offset);
591
- const image = glowsImage(gradientStops, solid);
1163
+ const fillScale = inherited ?? scaleOf(sourceColor);
1164
+ const covers = isCovering(shape);
1165
+ const solid = covers ? meanOf(gradientStops) : stepAlong(fillScale, start, offset);
1166
+ const image = shapeImage(shape.kind, shape, gradientStops, solid);
592
1167
  return {
593
1168
  solid,
594
- scale,
1169
+ scale: covers ? null : fillScale,
595
1170
  fill: {
596
1171
  "background-color": solid.toHex(),
597
1172
  "background-image": image
@@ -602,278 +1177,117 @@ const gradient = ({ anchors, parent, settings }) => {
602
1177
  "background-color-hover": solid.toHex(),
603
1178
  "background-image-hover": image
604
1179
  }
605
- })
1180
+ }),
1181
+ ...covers ? { layersOver: () => gradientStops.map((stop) => stop.withAlpha(1)) } : {}
1182
+ };
1183
+ };
1184
+ // src/private/engine/treatments/none.ts
1185
+ const PAGE_BACKGROUND = "anchors.colors.pageBackground";
1186
+ /**
1187
+ * No fill: the surface shows what it sits on, so its text and its children are solved against its
1188
+ * parent's fill and step along its parent's scale. It hovers with a wash of its own text color.
1189
+ */
1190
+ const none = ({ anchors, parent }) => {
1191
+ const solid = parent?.solid ?? anchorColor(PAGE_BACKGROUND, anchors);
1192
+ return {
1193
+ solid,
1194
+ scale: parent === null ? anchorScale(PAGE_BACKGROUND, anchors) : parent.scale,
1195
+ fill: { "background-color": "transparent" },
1196
+ hover: (text) => {
1197
+ const wash = text.withAlpha(NONE_HOVER_WASH_ALPHA);
1198
+ return {
1199
+ solid: composite(wash, solid),
1200
+ slots: { "background-color-hover": wash.toRgba() }
1201
+ };
1202
+ }
606
1203
  };
607
1204
  };
608
- /** Only `glows` so far. */
609
- const gradientGaps = ({ gradientShape }) => gradientShape === void 0 || gradientShape.kind === "glows" ? [] : [`gradientShape: ${gradientShape.kind}`];
610
1205
  // src/private/engine/treatments/index.ts
611
- /** The treatments the engine can paint. A Style using any other is not supported yet. */
1206
+ /** How the engine paints each treatment. */
612
1207
  const TREATMENT_FUNCTIONS = {
1208
+ none,
613
1209
  flat,
614
1210
  glassy,
615
1211
  gradient
616
1212
  };
617
- // src/private/engine/rules/fill.ts
618
- /**
619
- * A surface's fill. `background-image` holds layers drawn over `background-color` — glass sheens,
620
- * gradients — and `backdrop-filter` blurs what is behind a translucent fill.
621
- */
622
- const FILL_SLOTS = {
623
- surfaces: SURFACE_NAMES,
624
- initialValues: {
625
- "background-color": "transparent",
626
- "background-image": "none",
627
- "backdrop-filter": "none"
628
- }
629
- };
630
- const HOVER_FILL_SLOTS = {
631
- surfaces: surfacesWhere("interactive"),
632
- initialValues: {
633
- "background-color-hover": "transparent",
634
- "background-image-hover": "none"
635
- }
636
- };
637
- /** Glass has a fixed ground that its parent shows through, so it can't count from its parent. */
638
- const fromGaps = ({ backgroundColor: { from }, treatment }) => treatment === "glassy" && from === "parent" ? ["backgroundColor.from: parent"] : [];
639
- /** Inverting repaints a surface as a flat fill, so no other treatment can invert. */
640
- const invertGaps = ({ backgroundColor: { invert }, treatment }) => treatment === "flat" || invert === "never" ? [] : [`backgroundColor.invert: ${invert}`];
641
- const fillGaps = (settings) => {
642
- const { treatment } = settings;
643
- return [
644
- ...Object.hasOwn(TREATMENT_FUNCTIONS, treatment) ? [] : [`treatment: ${treatment}`],
645
- ...fromGaps(settings),
646
- ...invertGaps(settings)
647
- ];
648
- };
649
- // src/private/engine/constants/motion.ts
650
- /** How long a surface takes to move between states. Placeholder. */
651
- const TRANSITION_DURATIONS = {
652
- none: null,
653
- quick: "120ms",
654
- smooth: "240ms"
655
- };
656
- /** The properties a state change animates. */
657
- const TRANSITIONED_PROPERTIES = [
658
- "background-color",
659
- "box-shadow",
660
- "border-color",
661
- "color"
662
- ];
663
- const TRANSITION_EASING = "ease";
664
- /** How long one drift takes per speed. */
665
- const DRIFT_DURATIONS = {
666
- slow: "10s",
667
- medium: "6s",
668
- fast: "3s"
669
- };
670
- // src/private/engine/rules/motion.ts
671
- const MOTION_SLOTS = {
672
- surfaces: SURFACE_NAMES,
673
- initialValues: { transition: "none" }
674
- };
675
- /**
676
- * Only how long a page's drift takes. The contract is CSS variables only, so each consumer writes
677
- * its own `@keyframes` and the layer that moves. `0s` means the page is still. Other surfaces have
678
- * no animation slots until a Style first animates one.
679
- */
680
- const PAGE_ANIMATION_SLOTS = {
681
- surfaces: ["page"],
682
- initialValues: { "animation-duration": "0s" }
683
- };
684
- const transitionSlots = (transition) => {
685
- const duration = TRANSITION_DURATIONS[transition];
686
- if (duration === null) return {};
687
- return { transition: TRANSITIONED_PROPERTIES.map((property) => `${property} ${duration} ${TRANSITION_EASING}`).join(", ") };
688
- };
689
- /** `motionGaps` only lets `drift` through on the page, so this never names another surface's slot. */
690
- const driftSlots = ({ ambient, speed }) => ambient === "drift" ? { "animation-duration": DRIFT_DURATIONS[speed] } : {};
691
- const motionSlots = (motion) => ({
692
- ...transitionSlots(motion.transition),
693
- ...driftSlots(motion)
694
- });
695
- /** Only the page drifts so far, and nothing pulses. */
696
- const motionGaps = ({ motion: { ambient } }, surface) => ambient === "none" || ambient === "drift" && surface === "page" ? [] : [`motion.ambient: ${ambient}`];
697
- // src/private/engine/rules/panelInput.ts
698
- /** The form fields inside a panel. */
699
- const PANEL_INPUT_SLOTS = {
700
- surfaces: surfacesWhere("mayContainForm"),
701
- initialValues: {
702
- "input-background-color": "transparent",
703
- "input-background-color-focus": "transparent",
704
- "input-border-color-focus": "transparent"
705
- }
706
- };
707
- /** Inputs step off the panel's fill unless given `fills`, and take the primary color when focused. */
708
- const panelInputSlots = (solid, anchors, fills) => ({
709
- ...fills ?? {
710
- "input-background-color": stepFrom(solid, 1).toHex(),
711
- "input-background-color-focus": stepFrom(solid, 2).toHex()
712
- },
713
- "input-border-color-focus": anchorColor("anchors.colors.primary", anchors).toHex()
714
- });
715
- // src/private/engine/constants/radius.ts
716
- /** How the radius anchor scales on each surface. Placeholder. */
717
- const RADIUS_FACTORS = {
718
- page: 0,
719
- panel: 1,
720
- card: .7,
721
- buttonPrimary: .5,
722
- buttonSecondary: .5
723
- };
724
- // src/private/engine/rules/radius.ts
725
- const RADIUS_SLOTS = {
726
- surfaces: SURFACE_NAMES,
727
- initialValues: { "border-radius": "0" }
728
- };
729
- const radiusSlots = (surface, { source }, anchors) => ({ "border-radius": source === "anchors.dimensions.borderRadius" ? `${Math.round(anchors.borderRadius * RADIUS_FACTORS[surface])}px` : `${anchors.dimension(source)}px` });
730
- // src/private/engine/constants/typography.ts
731
- /** Letter spacing for `case: upper`, which reads cramped at the spacing set for mixed case. */
732
- const UPPERCASE_LETTER_SPACING = "0.05em";
733
- // src/private/engine/rules/typography.ts
734
- /**
735
- * `font-family` has no fixed initial value — it is up to the browser — so its unused value is the
736
- * generic family instead.
737
- */
738
- const TYPE_INITIAL_VALUES = {
739
- "font-family": "sans-serif",
740
- "font-size": "medium",
741
- "font-weight": "normal",
742
- "text-transform": "none",
743
- "letter-spacing": "normal"
744
- };
745
- const TYPOGRAPHY_CONTRACT = Object.fromEntries(TYPE_ROLES.flatMap((role) => Object.entries(TYPE_INITIAL_VALUES).map(([slot, value]) => [typeVariable(role, slot), value])));
746
- const typographyVariables = ({ typography }, anchors) => Object.fromEntries(TYPE_ROLES.flatMap((role) => {
747
- const type = typography[role];
748
- const upper = type.case === "upper";
749
- return [
750
- [typeVariable(role, "font-family"), anchors.fonts[type.font]],
751
- [typeVariable(role, "font-size"), `${type.fontSize}px`],
752
- [typeVariable(role, "font-weight"), String(type.fontWeight)],
753
- [typeVariable(role, "text-transform"), upper ? "uppercase" : "none"],
754
- [typeVariable(role, "letter-spacing"), upper ? UPPERCASE_LETTER_SPACING : "normal"]
755
- ];
756
- }));
757
- // src/private/engine/contract.ts
758
- /** Every rule's surface slots. A rule that adds slots adds its fragment here. */
759
- const SURFACE_SLOT_FRAGMENTS = [
760
- FILL_SLOTS,
761
- HOVER_FILL_SLOTS,
762
- TEXT_SLOTS,
763
- CONTENT_TEXT_SLOTS,
764
- HOVER_TEXT_SLOTS,
765
- CONTENT_HOVER_TEXT_SLOTS,
766
- PANEL_INPUT_SLOTS,
767
- BORDER_SLOTS,
768
- ELEVATION_SLOTS,
769
- RADIUS_SLOTS,
770
- MOTION_SLOTS,
771
- PAGE_ANIMATION_SLOTS
772
- ];
773
- const surfaceContract = () => Object.fromEntries(SURFACE_GROUPS.flatMap(({ prefix, surface }) => SURFACE_SLOT_FRAGMENTS.filter(({ surfaces }) => surfaces.includes(surface)).flatMap(({ initialValues }) => Object.entries(initialValues).map(([slot, value]) => [surfaceVariable(prefix, slot), value]))));
774
- // src/kaleidoscopeContract.ts
775
- /**
776
- * Every variable the engine emits, with the value it takes when a Style doesn't use the rule
777
- * behind it: the CSS initial value of the property it feeds, or the value that draws nothing.
778
- * Every Style emits exactly these names, so embeds and hosted pages can rely on each one.
779
- *
780
- * Surface variables are `--wistia-kaleidoscope-<surface>-<slot>`. A surface that can sit on several
781
- * parents is emitted once per parent, as `<surface>-on-<parent>`: `button-primary-on-panel`. Slots
782
- * are named after the CSS property they feed — `background-color`, `border-radius`, `box-shadow` —
783
- * with a `-hover` or `-focus` suffix for a state. There are two exceptions: `text-color`,
784
- * `heading-text-color` and `low-emphasis-text-color` all feed `color`, and a panel's input slots
785
- * carry an `input-` prefix, as in `input-background-color`.
786
- *
787
- * Typography variables are `--wistia-kaleidoscope-type-<role>-<property>`, for the `heading`,
788
- * `body` and `button` roles.
789
- */
790
- const KALEIDOSCOPE_CONTRACT = {
791
- ...surfaceContract(),
792
- ...TYPOGRAPHY_CONTRACT
793
- };
794
- // src/private/engine/rules/invert.ts
795
- /**
796
- * `invert: when-indistinct`: if a surface's background fill color is too close to its parent background fill,
797
- * invert: when-indistinct allows the fill and text color to be inverted. This provides better contrast between the surface
798
- * and its parent while also preserving legible contrast between the surface and its text color.
799
- */
800
- const invertWhenIndistinct = ({ backgroundColor: { invert }, treatment }, treated, text, parent) => {
801
- if (invert !== "when-indistinct" || treatment !== "flat" || parent === null) return {
802
- text,
803
- treated
804
- };
805
- const fillContrast = treated.solid.contrast(parent.solid);
806
- return fillContrast < INVERT_BELOW_CONTRAST && text.contrast(parent.solid) > fillContrast ? {
807
- text: treated.solid,
808
- treated: flatFill(text, null, parent)
809
- } : {
810
- text,
811
- treated
1213
+ // src/private/engine/evaluateSurfaces.ts
1214
+ /** The fill's image layers flattened over its solid, and over its hover when it is interactive. */
1215
+ const layerSolidsOf = (treated, hoverSolid, interactive) => {
1216
+ const over = (solid) => treated.layersOver?.(solid) ?? [];
1217
+ return {
1218
+ hoverLayerSolids: interactive ? over(hoverSolid) : [],
1219
+ layerSolids: over(treated.solid)
812
1220
  };
813
1221
  };
814
- // src/private/engine/evaluateSurfaces.ts
815
1222
  /**
816
1223
  * One surface on one parent. A slot a Style doesn't use is left out, so it keeps the contract's
817
1224
  * initial value.
818
1225
  */
819
1226
  const evaluateSurface = (style, surface, anchors, parent) => {
820
1227
  const settings = style.surfaces[surface];
821
- const treatment = TREATMENT_FUNCTIONS[settings.treatment];
822
- if (treatment === void 0) throw new Error(`The engine cannot paint a ${settings.treatment} ${surface} yet`);
823
- const painted = treatment({
1228
+ const painted = TREATMENT_FUNCTIONS[settings.treatment]({
824
1229
  anchors,
825
1230
  parent,
826
1231
  settings,
827
1232
  surface
828
1233
  });
829
- const { text, treated } = invertWhenIndistinct(settings, painted, resolveTextColor(settings.textColor, painted.solid, anchors), parent);
1234
+ const own = surfaceText(settings, painted.solid, anchors, parent);
1235
+ const { text, treated } = invertWhenIndistinct(settings, painted, own.text, parent);
830
1236
  const spec = SURFACES[surface];
831
1237
  const hover = treated.hover(text);
832
1238
  const tinted = treated.tintedBy?.(text);
833
1239
  return {
834
1240
  solid: treated.solid,
835
1241
  scale: treated.scale,
1242
+ text,
1243
+ textColor: own.textColor,
1244
+ hoverSolid: spec.interactive ? hover.solid : null,
1245
+ ...layerSolidsOf(treated, hover.solid, spec.interactive),
836
1246
  slots: {
837
1247
  ...treated.fill,
838
1248
  ...spec.interactive ? {
839
1249
  ...hover.slots,
840
- ...hoverTextSlots(surface, settings.textColor, text, hover.solid)
1250
+ ...hoverTextSlots(surface, own.textColor, text, hover.solid)
841
1251
  } : {},
842
1252
  ...textSlots(surface, text),
843
1253
  ...spec.mayContainForm ? panelInputSlots(treated.solid, anchors, tinted?.inputFills) : {},
844
1254
  ...borderSlots(settings.border, treated.solid, anchors),
845
- ...elevationSlots(settings.elevation, tinted?.shadowLayers),
1255
+ ...elevationSlots(surface, settings.elevation, anchors, tinted?.shadowLayers),
846
1256
  ...radiusSlots(surface, settings.radius, anchors),
847
- ...motionSlots(settings.motion)
1257
+ ...motionSlots(settings, anchors),
1258
+ ...textureSlots(settings.texture, treated.solid)
848
1259
  }
849
1260
  };
850
1261
  };
851
1262
  /**
852
- * Evaluates every surface group parents first, so each surface knows the fill it sits on, and
853
- * names each slot after its group.
1263
+ * Evaluates every surface group parents first, so each surface knows the fill it sits on.
854
1264
  */
855
- const evaluateSurfaces = (style, anchors) => {
1265
+ const evaluateSurfaceGroups = (style, anchors) => {
856
1266
  const containers = /* @__PURE__ */ new Map();
857
- const variables = {};
1267
+ const groups = [];
858
1268
  for (const { parent, prefix, surface } of SURFACE_GROUPS) {
859
1269
  const evaluated = evaluateSurface(style, surface, anchors, parent === null ? null : containers.get(parent) ?? null);
860
1270
  containers.set(surface, evaluated);
861
- for (const [slot, value] of Object.entries(evaluated.slots)) variables[surfaceVariable(prefix, slot)] = value;
1271
+ groups.push({
1272
+ ...evaluated,
1273
+ prefix,
1274
+ surface
1275
+ });
862
1276
  }
1277
+ return groups;
1278
+ };
1279
+ /** Every surface group's slots, each named after its group. */
1280
+ const evaluateSurfaces = (style, anchors) => {
1281
+ const variables = {};
1282
+ for (const { prefix, slots } of evaluateSurfaceGroups(style, anchors)) for (const [slot, value] of Object.entries(slots)) variables[surfaceVariable(prefix, slot)] = value;
863
1283
  return variables;
864
1284
  };
865
- // src/private/engine/rules/texture.ts
866
- /** No textures yet, so no texture slots: the Style that first uses one adds them. */
867
- const textureGaps = ({ texture: { kind } }) => kind === "none" ? [] : [`texture.kind: ${kind}`];
868
1285
  // src/private/engine/support.ts
869
1286
  const GAP_FINDERS = [
1287
+ glassyGaps,
870
1288
  fillGaps,
871
- gradientGaps,
872
- textGaps,
873
1289
  borderGaps,
874
- elevationGaps,
875
- motionGaps,
876
- textureGaps
1290
+ motionGaps
877
1291
  ];
878
1292
  /** The rules in `style` the engine cannot resolve yet, as `<surface>.<setting>: <value>`. */
879
1293
  const findUnsupportedRules = (style) => SURFACE_NAMES.flatMap((surface) => GAP_FINDERS.flatMap((findGaps) => findGaps(style.surfaces[surface], surface)).map((gap) => `${surface}.${gap}`));
@@ -963,4 +1377,4 @@ const serializeKaleidoscopeStyles = (variables, selector) => {
963
1377
  };
964
1378
  export { BRAND_TOKEN_NAMES as a, VARIABLE_PREFIX as i, getKaleidoscopeStyles as n, DEFAULT_BRAND_TOKENS as o, KALEIDOSCOPE_CONTRACT as r, serializeKaleidoscopeStyles as t };
965
1379
 
966
- //# sourceMappingURL=engine-DHDkDPaV.js.map
1380
+ //# sourceMappingURL=engine-6ocr431e.js.map