@multiplatform.one/theme 9.0.2 → 9.0.3

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 (119) hide show
  1. package/dist/cjs/theme/createThemes.cjs +151 -106
  2. package/dist/cjs/theme/createThemes.native.js +256 -197
  3. package/dist/cjs/theme/createThemes.native.js.map +1 -1
  4. package/dist/esm/audit/constraintAudit.native.js.map +1 -1
  5. package/dist/esm/audit/designTokens.native.js.map +1 -1
  6. package/dist/esm/audit/diffReport.native.js.map +1 -1
  7. package/dist/esm/audit/index.native.js.map +1 -1
  8. package/dist/esm/audit/themeMatrix.native.js.map +1 -1
  9. package/dist/esm/dates.native.js.map +1 -1
  10. package/dist/esm/devWarn.native.js.map +1 -1
  11. package/dist/esm/expo.native.js.map +1 -1
  12. package/dist/esm/figma/figmaTokens.native.js.map +1 -1
  13. package/dist/esm/font.native.js.map +1 -1
  14. package/dist/esm/fonts/createFontLoader.native.js.map +1 -1
  15. package/dist/esm/fonts/index.native.js.map +1 -1
  16. package/dist/esm/fonts/interFaces.native.js.map +1 -1
  17. package/dist/esm/fonts/types.native.js.map +1 -1
  18. package/dist/esm/index.gnome.native.js.map +1 -1
  19. package/dist/esm/index.native.js.map +1 -1
  20. package/dist/esm/keyboardFocusRing.native.js.map +1 -1
  21. package/dist/esm/menuRow.native.js.map +1 -1
  22. package/dist/esm/nativeTwins.native.js.map +1 -1
  23. package/dist/esm/numbers.native.js.map +1 -1
  24. package/dist/esm/theme/Heading.native.js.map +1 -1
  25. package/dist/esm/theme/IconSlot.native.js.map +1 -1
  26. package/dist/esm/theme/Intent.native.js.map +1 -1
  27. package/dist/esm/theme/Preset.native.js.map +1 -1
  28. package/dist/esm/theme/PresetContext.native.js.map +1 -1
  29. package/dist/esm/theme/Surface.native.js.map +1 -1
  30. package/dist/esm/theme/Text.native.js.map +1 -1
  31. package/dist/esm/theme/Tint.native.js.map +1 -1
  32. package/dist/esm/theme/accentInk.native.js.map +1 -1
  33. package/dist/esm/theme/activateThemeConfig.native.js.map +1 -1
  34. package/dist/esm/theme/animations/css.native.js.map +1 -1
  35. package/dist/esm/theme/animations/index.native.js.map +1 -1
  36. package/dist/esm/theme/animations/reactNative.native.js.map +1 -1
  37. package/dist/esm/theme/chartPalette.native.js.map +1 -1
  38. package/dist/esm/theme/colorRules.native.js.map +1 -1
  39. package/dist/esm/theme/controlTiers.native.js.map +1 -1
  40. package/dist/esm/theme/cookies.native.js.map +1 -1
  41. package/dist/esm/theme/createDefaultThemeConfig.native.js.map +1 -1
  42. package/dist/esm/theme/createThemes.mjs +151 -106
  43. package/dist/esm/theme/createThemes.mjs.map +1 -1
  44. package/dist/esm/theme/createThemes.native.js +256 -197
  45. package/dist/esm/theme/createThemes.native.js.map +1 -1
  46. package/dist/esm/theme/dedupeInherited.native.js.map +1 -1
  47. package/dist/esm/theme/defaults/accent.native.js.map +1 -1
  48. package/dist/esm/theme/defaults/base.native.js.map +1 -1
  49. package/dist/esm/theme/defaults/builderOptions.native.js.map +1 -1
  50. package/dist/esm/theme/defaults/categoryFonts.native.js.map +1 -1
  51. package/dist/esm/theme/defaults/fonts.native.js.map +1 -1
  52. package/dist/esm/theme/defaults/house.native.js.map +1 -1
  53. package/dist/esm/theme/defaults/index.native.js.map +1 -1
  54. package/dist/esm/theme/devtools/animationOptions.native.js.map +1 -1
  55. package/dist/esm/theme/devtools/buildSnapshot.native.js.map +1 -1
  56. package/dist/esm/theme/devtools/index.native.js.map +1 -1
  57. package/dist/esm/theme/devtools/knobIcons.native.js.map +1 -1
  58. package/dist/esm/theme/devtools/vizConstants.native.js.map +1 -1
  59. package/dist/esm/theme/dynamicType.native.js.map +1 -1
  60. package/dist/esm/theme/fieldFocus.native.js.map +1 -1
  61. package/dist/esm/theme/fillContrast.native.js.map +1 -1
  62. package/dist/esm/theme/focusState.native.js.map +1 -1
  63. package/dist/esm/theme/fontCategoryMetrics.native.js.map +1 -1
  64. package/dist/esm/theme/fontCategoryStacks.native.js.map +1 -1
  65. package/dist/esm/theme/glyphPaint.native.js.map +1 -1
  66. package/dist/esm/theme/glyphTint.native.js.map +1 -1
  67. package/dist/esm/theme/groupGeometry.native.js.map +1 -1
  68. package/dist/esm/theme/index.native.js.map +1 -1
  69. package/dist/esm/theme/intents.native.js.map +1 -1
  70. package/dist/esm/theme/knobs.native.js.map +1 -1
  71. package/dist/esm/theme/layoutTokens.native.js.map +1 -1
  72. package/dist/esm/theme/listRows.native.js.map +1 -1
  73. package/dist/esm/theme/mergedTokens.native.js.map +1 -1
  74. package/dist/esm/theme/motion.native.js.map +1 -1
  75. package/dist/esm/theme/motionStops.native.js.map +1 -1
  76. package/dist/esm/theme/motionTiming.native.js.map +1 -1
  77. package/dist/esm/theme/nativeMonoFamily.native.js.map +1 -1
  78. package/dist/esm/theme/nativePresetSwitch.native.js.map +1 -1
  79. package/dist/esm/theme/nativeSchemePreference.native.js.map +1 -1
  80. package/dist/esm/theme/nativeTheme.native.js.map +1 -1
  81. package/dist/esm/theme/nativeTransitionProps.native.js.map +1 -1
  82. package/dist/esm/theme/overlaySurfaces.native.js.map +1 -1
  83. package/dist/esm/theme/pageGutter.native.js.map +1 -1
  84. package/dist/esm/theme/preset.types.native.js.map +1 -1
  85. package/dist/esm/theme/presetPreview.native.js.map +1 -1
  86. package/dist/esm/theme/presetStore.native.js.map +1 -1
  87. package/dist/esm/theme/presetUserSync.native.js.map +1 -1
  88. package/dist/esm/theme/presets.native.js.map +1 -1
  89. package/dist/esm/theme/radiusClass.native.js.map +1 -1
  90. package/dist/esm/theme/radiusClassTable.generated.native.js.map +1 -1
  91. package/dist/esm/theme/ramps.native.js.map +1 -1
  92. package/dist/esm/theme/readableColor.native.js.map +1 -1
  93. package/dist/esm/theme/recipeInputs.native.js.map +1 -1
  94. package/dist/esm/theme/recipes.native.js.map +1 -1
  95. package/dist/esm/theme/resolveKnobs.native.js.map +1 -1
  96. package/dist/esm/theme/scale/activeScale.native.js.map +1 -1
  97. package/dist/esm/theme/scale/deriveRecipeInputs.native.js.map +1 -1
  98. package/dist/esm/theme/scale/index.native.js.map +1 -1
  99. package/dist/esm/theme/scale/scaleAttribute.native.js.map +1 -1
  100. package/dist/esm/theme/scale/scaleCss.native.js.map +1 -1
  101. package/dist/esm/theme/scale/scaleFonts.native.js.map +1 -1
  102. package/dist/esm/theme/scale/scaleInputs.native.js.map +1 -1
  103. package/dist/esm/theme/scale/themeScales.native.js.map +1 -1
  104. package/dist/esm/theme/scale/useActiveScale.native.js.map +1 -1
  105. package/dist/esm/theme/schemeStore.native.js.map +1 -1
  106. package/dist/esm/theme/shared.native.js.map +1 -1
  107. package/dist/esm/theme/sizeRecipes.native.js.map +1 -1
  108. package/dist/esm/theme/subsetThemes.native.js.map +1 -1
  109. package/dist/esm/theme/themeValue.native.js.map +1 -1
  110. package/dist/esm/theme/tileSizes.native.js.map +1 -1
  111. package/dist/esm/theme/tintHues.native.js.map +1 -1
  112. package/dist/esm/theme/tokenNumber.native.js.map +1 -1
  113. package/dist/esm/theme/touchManipulation.native.js.map +1 -1
  114. package/dist/esm/theme/useResolvedKnobs.native.js.map +1 -1
  115. package/dist/esm/theme/useTouchSurface.native.js.map +1 -1
  116. package/dist/esm/theme/v3TokenRoles.native.js.map +1 -1
  117. package/package.json +5 -5
  118. package/src/theme/createThemes.ts +229 -135
  119. package/types/theme/createThemes.d.ts.map +1 -1
@@ -509,91 +509,122 @@ function holdSelectionSurface(themes) {
509
509
  }
510
510
  return out;
511
511
  }
512
+ function ownerScope(scopes, name) {
513
+ return scopes.filter(function (scope) {
514
+ return name === scope || name.startsWith(`${scope}_`);
515
+ }).reduce(function (longest, scope) {
516
+ return scope.length > longest.length ? scope : longest;
517
+ }, "");
518
+ }
519
+ function clearsDarkGrounds(color, grounds) {
520
+ var brightest = Math.max(...grounds);
521
+ var luminance = luminanceOf(color);
522
+ return luminance !== null && luminance > brightest && grounds.every(function (ground) {
523
+ return (0, import_colorRules.contrastRatio)(luminance, ground) >= import_builderOptions.darkHairlineContrast;
524
+ });
525
+ }
526
+ function darkHairlineOf(scope) {
527
+ var ramp = Array.from({
528
+ length: 12
529
+ }, function (_, index) {
530
+ return scope[`color${index + 1}`];
531
+ });
532
+ var grounds = [scope.background, scope.color4].map(function (color) {
533
+ return luminanceOf(color);
534
+ });
535
+ if (grounds.some(function (ground) {
536
+ return ground === null;
537
+ })) return void 0;
538
+ var hairline = ramp.findIndex(function (color, index) {
539
+ return index < 11 && clearsDarkGrounds(color, grounds);
540
+ });
541
+ return hairline < 0 ? void 0 : {
542
+ ramp,
543
+ hairline
544
+ };
545
+ }
546
+ var darkEdgeStateKeys = ["borderColor", "borderColorHover", "borderColorFocus", "borderColorPress"];
547
+ function darkEdgesOf(name, theme, scopeName, scope, param) {
548
+ var {
549
+ ramp,
550
+ hairline
551
+ } = param;
552
+ var medium = hairline + 1;
553
+ var surface = name === scopeName || theme.background === scope.color4;
554
+ var step = ramp.indexOf(theme.borderColor);
555
+ var shift = surface && step >= 0 ? medium - step : 0;
556
+ var moved = {};
557
+ if ("borderColorHairline" in theme || name === scopeName) moved.borderColorHairline = ramp[hairline];
558
+ if (shift <= 0) return moved;
559
+ var _iteratorNormalCompletion = true,
560
+ _didIteratorError = false,
561
+ _iteratorError = void 0;
562
+ try {
563
+ for (var _iterator = darkEdgeStateKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
564
+ var key = _step.value;
565
+ var at = ramp.indexOf(theme[key]);
566
+ if (at >= 0) moved[key] = ramp[Math.min(11, at + shift)];
567
+ }
568
+ } catch (err) {
569
+ _didIteratorError = true;
570
+ _iteratorError = err;
571
+ } finally {
572
+ try {
573
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
574
+ _iterator.return();
575
+ }
576
+ } finally {
577
+ if (_didIteratorError) {
578
+ throw _iteratorError;
579
+ }
580
+ }
581
+ }
582
+ return moved;
583
+ }
512
584
  function holdDarkEdges(themes) {
513
585
  var out = {
514
586
  ...themes
515
587
  };
516
- var scopes = Object.keys(themes).filter(function (name) {
517
- return /^dark(_[a-z]+)?$/.test(name);
588
+ var scopes = Object.keys(themes).filter(function (name2) {
589
+ return /^dark(_[a-z]+)?$/.test(name2);
518
590
  });
519
- var ownerOf = function ownerOf2(name) {
520
- return scopes.filter(function (scope) {
521
- return name === scope || name.startsWith(`${scope}_`);
522
- }).reduce(function (longest, scope) {
523
- return scope.length > longest.length ? scope : longest;
524
- }, "");
525
- };
526
591
  var _iteratorNormalCompletion = true,
527
592
  _didIteratorError = false,
528
593
  _iteratorError = void 0;
529
594
  try {
530
- var _loop = function () {
595
+ for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
531
596
  var scopeName = _step.value;
532
- if (/_(accent|active)$/.test(scopeName)) return "continue";
597
+ if (/_(accent|active)$/.test(scopeName)) continue;
533
598
  var scope = themes[scopeName];
534
- var ramp = Array.from({
535
- length: 12
536
- }, function (_, index) {
537
- return scope[`color${index + 1}`];
538
- });
539
- var grounds = [scope.background, scope.color4].map(function (color) {
540
- return luminanceOf(color);
541
- });
542
- if (grounds.some(function (ground) {
543
- return ground === null;
544
- })) return "continue";
545
- var brightest = Math.max(...grounds);
546
- var clears = function clears2(color) {
547
- var luminance = luminanceOf(color);
548
- return luminance !== null && luminance > brightest && grounds.every(function (ground) {
549
- return (0, import_colorRules.contrastRatio)(luminance, ground) >= import_builderOptions.darkHairlineContrast;
550
- });
551
- };
552
- var hairline = ramp.findIndex(function (color, index) {
553
- return index < 11 && clears(color);
554
- });
555
- if (hairline < 0) return "continue";
556
- var medium = hairline + 1;
557
- var _iteratorNormalCompletion2 = true,
558
- _didIteratorError2 = false,
559
- _iteratorError2 = void 0;
599
+ var pick = darkHairlineOf(scope);
600
+ if (!pick) continue;
601
+ var _iteratorNormalCompletion1 = true,
602
+ _didIteratorError1 = false,
603
+ _iteratorError1 = void 0;
560
604
  try {
561
- for (var _iterator2 = Object.entries(themes)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
605
+ for (var _iterator1 = Object.entries(themes)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
562
606
  var [name, theme] = _step1.value;
563
- if (ownerOf(name) !== scopeName) continue;
564
- var surface = name === scopeName || theme.background === scope.color4;
565
- var step = ramp.indexOf(theme.borderColor);
566
- var shift = surface && step >= 0 ? medium - step : 0;
567
- var moved = {};
568
- if ("borderColorHairline" in theme || name === scopeName) moved.borderColorHairline = ramp[hairline];
569
- if (shift > 0) {
570
- for (var _i = 0, _iter = ["borderColor", "borderColorHover", "borderColorFocus", "borderColorPress"]; _i < _iter.length; _i++) {
571
- var key = _iter[_i];
572
- var at = ramp.indexOf(theme[key]);
573
- if (at >= 0) moved[key] = ramp[Math.min(11, at + shift)];
574
- }
575
- }
607
+ if (ownerScope(scopes, name) !== scopeName) continue;
576
608
  out[name] = {
577
609
  ...out[name],
578
- ...moved
610
+ ...darkEdgesOf(name, theme, scopeName, scope, pick)
579
611
  };
580
612
  }
581
613
  } catch (err) {
582
- _didIteratorError2 = true;
583
- _iteratorError2 = err;
614
+ _didIteratorError1 = true;
615
+ _iteratorError1 = err;
584
616
  } finally {
585
617
  try {
586
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
587
- _iterator2.return();
618
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
619
+ _iterator1.return();
588
620
  }
589
621
  } finally {
590
- if (_didIteratorError2) {
591
- throw _iteratorError2;
622
+ if (_didIteratorError1) {
623
+ throw _iteratorError1;
592
624
  }
593
625
  }
594
626
  }
595
- };
596
- for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
627
+ }
597
628
  } catch (err) {
598
629
  _didIteratorError = true;
599
630
  _iteratorError = err;
@@ -610,6 +641,117 @@ function holdDarkEdges(themes) {
610
641
  }
611
642
  return out;
612
643
  }
644
+ function firstClearing(neutral, grounds) {
645
+ var lums = grounds.map(function (ground) {
646
+ return luminanceOf(ground);
647
+ });
648
+ if (lums.some(function (lum) {
649
+ return lum === null;
650
+ })) return -1;
651
+ var darkest = Math.min(...lums);
652
+ var brightest = Math.max(...lums);
653
+ var light = (0, import_colorRules.isLightGround)(grounds[0]);
654
+ return neutral.findIndex(function (color) {
655
+ var lum = luminanceOf(color);
656
+ return lum !== null && (light ? lum < darkest : lum > brightest) && lums.every(function (ground) {
657
+ return (0, import_colorRules.contrastRatio)(lum, ground) >= import_colorRules.minContrastRatio;
658
+ });
659
+ });
660
+ }
661
+ function inheritedValue(out, themes, name, key) {
662
+ for (var at = name; at; at = at.slice(0, Math.max(0, at.lastIndexOf("_")))) {
663
+ var _out_at;
664
+ var _this;
665
+ var value = (_this = (_out_at = out[at]) !== null && _out_at !== void 0 ? _out_at : themes[at]) === null || _this === void 0 ? void 0 : _this[key];
666
+ if (value !== void 0) return value;
667
+ if (!at.includes("_")) break;
668
+ }
669
+ return void 0;
670
+ }
671
+ function nearestStep(ramp, color) {
672
+ var lum = luminanceOf(color);
673
+ if (lum === null) return -1;
674
+ return ramp.reduce(function (best, step, index) {
675
+ var _luminanceOf, _luminanceOf1;
676
+ return Math.abs(((_luminanceOf = luminanceOf(step)) !== null && _luminanceOf !== void 0 ? _luminanceOf : 2) - lum) < Math.abs(((_luminanceOf1 = luminanceOf(ramp[best])) !== null && _luminanceOf1 !== void 0 ? _luminanceOf1 : 2) - lum) ? index : best;
677
+ }, 0);
678
+ }
679
+ function fieldEdgesOf(themes, out, neutral, scopeName) {
680
+ var scope = themes[scopeName];
681
+ var field = `${scopeName}_Input`;
682
+ var edge = firstClearing(neutral, [scope.background, inheritedValue(out, themes, field, "background")]);
683
+ if (edge < 0) return void 0;
684
+ var ramp = Array.from({
685
+ length: 12
686
+ }, function (_, index) {
687
+ return scope[`color${index + 1}`];
688
+ });
689
+ var rest = nearestStep(ramp, inheritedValue(out, themes, field, "borderColor"));
690
+ var hover = nearestStep(ramp, inheritedValue(out, themes, field, "borderColorHover"));
691
+ return {
692
+ borderColorField: neutral[edge],
693
+ borderColorFieldHover: neutral[Math.min(11, Math.max(edge, edge + hover - rest))]
694
+ };
695
+ }
696
+ function intentFieldEdges(themes, out, scopeName, pages) {
697
+ var scope = themes[scopeName];
698
+ var field = `${scopeName}_Input`;
699
+ var ramp = Array.from({
700
+ length: 12
701
+ }, function (_, index) {
702
+ return scope[`color${index + 1}`];
703
+ });
704
+ var edge = firstClearing(ramp, [...pages, inheritedValue(out, themes, field, "background")]);
705
+ if (edge < 0) return {
706
+ borderColorField: inheritedValue(out, themes, field, "borderColor"),
707
+ borderColorFieldHover: inheritedValue(out, themes, field, "borderColorHover")
708
+ };
709
+ return {
710
+ borderColorField: ramp[edge],
711
+ borderColorFieldHover: ramp[Math.min(11, edge + 1)]
712
+ };
713
+ }
714
+ function controlEdgePatch(themes, out, scopeName, param) {
715
+ var {
716
+ scheme,
717
+ neutral,
718
+ pages,
719
+ rootFields,
720
+ rootControl
721
+ } = param;
722
+ var scope = themes[scopeName];
723
+ var patch = {};
724
+ if (scheme === "dark" && "switchTrackOff" in scope) patch.switchTrackOffBorder = scope.switchTrackOff;
725
+ if (semanticIntentNames.has(scopeName.slice(scheme.length + 1))) return Object.assign(patch, intentFieldEdges(themes, out, scopeName, pages));
726
+ var fields = fieldEdgesOf(themes, out, neutral, scopeName);
727
+ if (fields) {
728
+ var _iteratorNormalCompletion = true,
729
+ _didIteratorError = false,
730
+ _iteratorError = void 0;
731
+ try {
732
+ for (var _iterator = Object.entries(fields)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
733
+ var [key, value] = _step.value;
734
+ if (value !== rootFields[key]) patch[key] = value;
735
+ }
736
+ } catch (err) {
737
+ _didIteratorError = true;
738
+ _iteratorError = err;
739
+ } finally {
740
+ try {
741
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
742
+ _iterator.return();
743
+ }
744
+ } finally {
745
+ if (_didIteratorError) {
746
+ throw _iteratorError;
747
+ }
748
+ }
749
+ }
750
+ }
751
+ var control = firstClearing(neutral, [scope.background]);
752
+ if (control >= 0 && control !== rootControl) patch.borderColorControl = neutral[control];
753
+ return patch;
754
+ }
613
755
  function holdControlEdges(themes) {
614
756
  var _loop = function (_i2, _iter2) {
615
757
  var scheme = _iter2[_i2];
@@ -620,32 +762,7 @@ function holdControlEdges(themes) {
620
762
  }, function (_, index) {
621
763
  return root[`color${index + 1}`];
622
764
  });
623
- var fieldEdges = function fieldEdges2(scopeName) {
624
- var scope = themes[scopeName];
625
- var field = `${scopeName}_Input`;
626
- var edge = firstClearing(neutral, [scope.background, resolved(field, "background")]);
627
- if (edge < 0) return void 0;
628
- var ramp = Array.from({
629
- length: 12
630
- }, function (_, index) {
631
- return scope[`color${index + 1}`];
632
- });
633
- var stepOf = function stepOf2(color) {
634
- var lum = luminanceOf(color);
635
- if (lum === null) return -1;
636
- return ramp.reduce(function (best, step, index) {
637
- var _luminanceOf, _luminanceOf1;
638
- return Math.abs(((_luminanceOf = luminanceOf(step)) !== null && _luminanceOf !== void 0 ? _luminanceOf : 2) - lum) < Math.abs(((_luminanceOf1 = luminanceOf(ramp[best])) !== null && _luminanceOf1 !== void 0 ? _luminanceOf1 : 2) - lum) ? index : best;
639
- }, 0);
640
- };
641
- var rest = stepOf(resolved(field, "borderColor"));
642
- var hover = stepOf(resolved(field, "borderColorHover"));
643
- return {
644
- borderColorField: neutral[edge],
645
- borderColorFieldHover: neutral[Math.min(11, Math.max(edge, edge + hover - rest))]
646
- };
647
- };
648
- var rootFields = fieldEdges(scheme);
765
+ var rootFields = fieldEdgesOf(themes, out, neutral, scheme);
649
766
  var rootControl = firstClearing(neutral, [root.background]);
650
767
  if (!rootFields || rootControl < 0) return "continue";
651
768
  out[scheme] = {
@@ -662,60 +779,25 @@ function holdControlEdges(themes) {
662
779
  }).map(function (name) {
663
780
  return themes[name].background;
664
781
  })];
782
+ var context = {
783
+ scheme,
784
+ neutral,
785
+ pages,
786
+ rootFields,
787
+ rootControl
788
+ };
665
789
  var _iteratorNormalCompletion = true,
666
790
  _didIteratorError = false,
667
791
  _iteratorError = void 0;
668
792
  try {
669
- var _loop2 = function () {
793
+ for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
670
794
  var scopeName = _step.value;
671
- var scope = themes[scopeName];
672
- var patch = {};
673
- if (scheme === "dark" && "switchTrackOff" in scope) patch.switchTrackOffBorder = scope.switchTrackOff;
674
- if (semanticIntentNames.has(scopeName.slice(scheme.length + 1))) {
675
- var field = `${scopeName}_Input`;
676
- var ramp = Array.from({
677
- length: 12
678
- }, function (_, index) {
679
- return scope[`color${index + 1}`];
680
- });
681
- var edge = firstClearing(ramp, [...pages, resolved(field, "background")]);
682
- patch.borderColorField = edge < 0 ? resolved(field, "borderColor") : ramp[edge];
683
- patch.borderColorFieldHover = edge < 0 ? resolved(field, "borderColorHover") : ramp[Math.min(11, edge + 1)];
684
- } else {
685
- var fields = fieldEdges(scopeName);
686
- if (fields) {
687
- var _iteratorNormalCompletion2 = true,
688
- _didIteratorError2 = false,
689
- _iteratorError2 = void 0;
690
- try {
691
- for (var _iterator2 = Object.entries(fields)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
692
- var [key, value] = _step1.value;
693
- if (value !== rootFields[key]) patch[key] = value;
694
- }
695
- } catch (err) {
696
- _didIteratorError2 = true;
697
- _iteratorError2 = err;
698
- } finally {
699
- try {
700
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
701
- _iterator2.return();
702
- }
703
- } finally {
704
- if (_didIteratorError2) {
705
- throw _iteratorError2;
706
- }
707
- }
708
- }
709
- }
710
- var control = firstClearing(neutral, [scope.background]);
711
- if (control >= 0 && control !== rootControl) patch.borderColorControl = neutral[control];
712
- }
795
+ var patch = controlEdgePatch(themes, out, scopeName, context);
713
796
  if (Object.keys(patch).length > 0) out[scopeName] = {
714
797
  ...out[scopeName],
715
798
  ...patch
716
799
  };
717
- };
718
- for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop2();
800
+ }
719
801
  } catch (err) {
720
802
  _didIteratorError = true;
721
803
  _iteratorError = err;
@@ -734,33 +816,6 @@ function holdControlEdges(themes) {
734
816
  var out = {
735
817
  ...themes
736
818
  };
737
- var firstClearing = function firstClearing2(neutral, grounds) {
738
- var lums = grounds.map(function (ground) {
739
- return luminanceOf(ground);
740
- });
741
- if (lums.some(function (lum) {
742
- return lum === null;
743
- })) return -1;
744
- var darkest = Math.min(...lums);
745
- var brightest = Math.max(...lums);
746
- var light = (0, import_colorRules.isLightGround)(grounds[0]);
747
- return neutral.findIndex(function (color) {
748
- var lum = luminanceOf(color);
749
- return lum !== null && (light ? lum < darkest : lum > brightest) && lums.every(function (ground) {
750
- return (0, import_colorRules.contrastRatio)(lum, ground) >= import_colorRules.minContrastRatio;
751
- });
752
- });
753
- };
754
- var resolved = function resolved2(name, key) {
755
- for (var at = name; at; at = at.slice(0, Math.max(0, at.lastIndexOf("_")))) {
756
- var _out_at;
757
- var _this;
758
- var value = (_this = (_out_at = out[at]) !== null && _out_at !== void 0 ? _out_at : themes[at]) === null || _this === void 0 ? void 0 : _this[key];
759
- if (value !== void 0) return value;
760
- if (!at.includes("_")) break;
761
- }
762
- return void 0;
763
- };
764
819
  for (var _i = 0, _iter = ["light", "dark"]; _i < _iter.length; _i++) _loop(_i, _iter);
765
820
  return out;
766
821
  }
@@ -893,24 +948,15 @@ function holdSwitchTrack(themes) {
893
948
  _didIteratorError = false,
894
949
  _iteratorError = void 0;
895
950
  try {
896
- var _loop = function () {
951
+ for (var _iterator = semanticIntentNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
897
952
  var intent = _step.value;
898
- var _scope_accentBackground;
899
953
  var scope = themes[`${scheme}_${intent}`];
900
- var off = luminanceOf(paint.switchTrackOff);
901
- if (!(scope === null || scope === void 0 ? void 0 : scope.color4) || !scope.color5 || off === null) return "continue";
902
- var holds = (0, import_colorRules.inSwitchOffBand)(paint.switchTrackOff, scope.color4) && [scope.color4, scope.color5].every(function (ground) {
903
- var _luminanceOf;
904
- return (0, import_colorRules.contrastRatio)(off, (_luminanceOf = luminanceOf(ground)) !== null && _luminanceOf !== void 0 ? _luminanceOf : off) >= import_colorRules.plateContrastRatio;
905
- });
906
- if (holds) return "continue";
907
- var track = switchTrackPaint(base, (_scope_accentBackground = scope.accentBackground) !== null && _scope_accentBackground !== void 0 ? _scope_accentBackground : base.accentBackground, scope.color4, [base.color4, scope.color4, scope.color5]);
954
+ var track = intentSwitchTrack(base, scope, paint);
908
955
  if (track) out[`${scheme}_${intent}`] = {
909
956
  ...scope,
910
957
  ...track
911
958
  };
912
- };
913
- for (var _iterator = semanticIntentNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
959
+ }
914
960
  } catch (err) {
915
961
  _didIteratorError = true;
916
962
  _iteratorError = err;
@@ -928,6 +974,17 @@ function holdSwitchTrack(themes) {
928
974
  }
929
975
  return out;
930
976
  }
977
+ function intentSwitchTrack(base, scope, paint) {
978
+ var _scope_accentBackground;
979
+ var off = luminanceOf(paint.switchTrackOff);
980
+ if (!(scope === null || scope === void 0 ? void 0 : scope.color4) || !scope.color5 || off === null) return void 0;
981
+ var holds = (0, import_colorRules.inSwitchOffBand)(paint.switchTrackOff, scope.color4) && [scope.color4, scope.color5].every(function (ground) {
982
+ var _luminanceOf;
983
+ return (0, import_colorRules.contrastRatio)(off, (_luminanceOf = luminanceOf(ground)) !== null && _luminanceOf !== void 0 ? _luminanceOf : off) >= import_colorRules.plateContrastRatio;
984
+ });
985
+ if (holds) return void 0;
986
+ return switchTrackPaint(base, (_scope_accentBackground = scope.accentBackground) !== null && _scope_accentBackground !== void 0 ? _scope_accentBackground : base.accentBackground, scope.color4, [base.color4, scope.color4, scope.color5]);
987
+ }
931
988
  function switchTrackPaint(base, onFill, ground) {
932
989
  var raised = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [];
933
990
  var _ref, _inBand_find;
@@ -1438,37 +1495,26 @@ function holdHouseAccent(themes) {
1438
1495
  return out;
1439
1496
  }
1440
1497
  function holdHouseIdentityInk(themes) {
1441
- var _loop = function (_i2, _iter2) {
1442
- var scheme = _iter2[_i2];
1498
+ var out = {
1499
+ ...themes
1500
+ };
1501
+ for (var _i = 0, _iter = ["light", "dark"]; _i < _iter.length; _i++) {
1502
+ var scheme = _iter[_i];
1443
1503
  var _themes_;
1444
1504
  var base = themes[scheme];
1445
1505
  var blueInk = (_themes_ = themes[`${scheme}_blue`]) === null || _themes_ === void 0 ? void 0 : _themes_.identityInk;
1446
- if (!(base === null || base === void 0 ? void 0 : base.identityInk) || !blueInk || base.identityInk === blueInk) return "continue";
1447
- var held = Array.from({
1448
- length: 12
1449
- }, function (_, index) {
1450
- return index + 1;
1451
- }).every(function (step) {
1452
- return base[`accent${step}`] !== void 0 && base[`accent${step}`] === base[`blue${step}`];
1453
- });
1454
- if (!held) return "continue";
1506
+ if (!(base === null || base === void 0 ? void 0 : base.identityInk) || !blueInk || base.identityInk === blueInk) continue;
1507
+ if (!accentIsBlue(base)) continue;
1455
1508
  var _iteratorNormalCompletion = true,
1456
1509
  _didIteratorError = false,
1457
1510
  _iteratorError = void 0;
1458
1511
  try {
1459
1512
  for (var _iterator = Object.entries(themes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1460
1513
  var [name, theme] = _step.value;
1461
- if (name !== scheme && !name.startsWith(`${scheme}_`)) continue;
1462
- var scope = name.split("_")[1];
1463
- if (scope === "accent" || childrenHues.includes(scope)) continue;
1464
- if (theme.identityInk !== base.identityInk) continue;
1465
- var values = (0, import_dedupeInherited.resolveThemeThroughParents)(themes, name);
1466
- if ((0, import_accentInk.pickIdentityInk)([blueInk], (0, import_accentInk.pageSurfaces)(name, values)) === blueInk) {
1467
- out[name] = {
1468
- ...theme,
1469
- identityInk: blueInk
1470
- };
1471
- }
1514
+ if (takesBlueInk(themes, scheme, name, theme, base, blueInk)) out[name] = {
1515
+ ...theme,
1516
+ identityInk: blueInk
1517
+ };
1472
1518
  }
1473
1519
  } catch (err) {
1474
1520
  _didIteratorError = true;
@@ -1484,13 +1530,26 @@ function holdHouseIdentityInk(themes) {
1484
1530
  }
1485
1531
  }
1486
1532
  }
1487
- };
1488
- var out = {
1489
- ...themes
1490
- };
1491
- for (var _i = 0, _iter = ["light", "dark"]; _i < _iter.length; _i++) _loop(_i, _iter);
1533
+ }
1492
1534
  return out;
1493
1535
  }
1536
+ function accentIsBlue(base) {
1537
+ return Array.from({
1538
+ length: 12
1539
+ }, function (_, index) {
1540
+ return index + 1;
1541
+ }).every(function (step) {
1542
+ return base[`accent${step}`] !== void 0 && base[`accent${step}`] === base[`blue${step}`];
1543
+ });
1544
+ }
1545
+ function takesBlueInk(themes, scheme, name, theme, base, blueInk) {
1546
+ if (name !== scheme && !name.startsWith(`${scheme}_`)) return false;
1547
+ var scope = name.split("_")[1];
1548
+ if (scope === "accent" || childrenHues.includes(scope)) return false;
1549
+ if (theme.identityInk !== base.identityInk) return false;
1550
+ var values = (0, import_dedupeInherited.resolveThemeThroughParents)(themes, name);
1551
+ return (0, import_accentInk.pickIdentityInk)([blueInk], (0, import_accentInk.pageSurfaces)(name, values)) === blueInk;
1552
+ }
1494
1553
  var defaultLightShadows = {
1495
1554
  shadow1: "rgba(0,0,0,0.04)",
1496
1555
  shadow2: "rgba(0,0,0,0.08)",