@rific/auto-paper 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,6 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
4
7
 
5
8
  // src/BlurContext.tsx
6
9
  import { useContext } from "react";
@@ -65,24 +68,34 @@ var APPEARANCES = [
65
68
  var AppearancePicker = ({ value, onChange }) => /* @__PURE__ */ jsx2(SegmentedButtons, { value, onValueChange: (v) => onChange(v), buttons: APPEARANCES.map((a) => ({ value: a.value, label: a.label, icon: a.icon })) });
66
69
 
67
70
  // src/components/BlurView.tsx
68
- import { BlurView as ExpoBlurView } from "expo-blur";
69
71
  import { useContext as useContext3 } from "react";
70
72
  import { StyleSheet, View } from "react-native";
71
73
  import { useTheme as useTheme2 } from "react-native-paper";
72
74
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
75
+ var ExpoBlurView = (() => {
76
+ try {
77
+ return __require("expo-blur").BlurView;
78
+ } catch {
79
+ return null;
80
+ }
81
+ })();
73
82
  var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
74
- var BlurView = ({ blur = true, children, elevation, style, ...props }) => {
83
+ var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
84
+ var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
75
85
  const { dark, colors } = useTheme2();
76
86
  const { settings } = useContext3(ThemeSettingsContext);
77
- const tintOpacity = elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0;
78
- const tint = tintOpacity > 0 ? /* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: colors.primary, opacity: tintOpacity }] }) : null;
79
- if (blur)
87
+ const surfaceColor = variant === "surfaceVariant" ? colors.surfaceVariant : colors.surface;
88
+ const variantColor = variant === "primary" ? colors.primary : variant === "secondary" ? colors.secondary : variant === "tertiary" ? colors.tertiary : variant === "error" ? colors.error : void 0;
89
+ const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
90
+ const resolvedTintOpacity = tintOpacity ?? (tintColor ? dark ? 0.24 : 0.16 : variantColor ? dark ? VARIANT_TINT_OPACITY.dark : VARIANT_TINT_OPACITY.light : elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0);
91
+ const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: resolvedTintColor, opacity: resolvedTintOpacity }] }) : null;
92
+ if (blur && ExpoBlurView)
80
93
  return /* @__PURE__ */ jsxs2(ExpoBlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
81
- /* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: colors.surface, opacity: settings.blurTint }] }),
94
+ /* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
82
95
  tint,
83
96
  children
84
97
  ] });
85
- return /* @__PURE__ */ jsxs2(View, { style: [{ backgroundColor: colors.surface }, style], children: [
98
+ return /* @__PURE__ */ jsxs2(View, { style: [{ backgroundColor: surfaceColor }, style], children: [
86
99
  tint,
87
100
  children
88
101
  ] });
@@ -93,6 +106,19 @@ import { useEffect as useEffect3 } from "react";
93
106
  import { Platform } from "react-native";
94
107
  import { BottomNavigation as PaperBottomNavigation, useTheme as useTheme3 } from "react-native-paper";
95
108
 
109
+ // src/navigation-bar.ts
110
+ var navigationBar = (() => {
111
+ try {
112
+ return __require("expo-navigation-bar");
113
+ } catch {
114
+ return null;
115
+ }
116
+ })();
117
+ var setNavigationBarStyle = (dark) => {
118
+ if (!navigationBar) return;
119
+ navigationBar.NavigationBar.setStyle(dark ? "light" : "dark");
120
+ };
121
+
96
122
  // src/ThemeProvider.tsx
97
123
  import { createContext as createContext3, useCallback as useCallback2, useContext as useContext4, useEffect as useEffect2, useRef, useState as useState2 } from "react";
98
124
  import { StatusBar as StatusBar2, StyleSheet as StyleSheet2, View as View2 } from "react-native";
@@ -535,16 +561,18 @@ var NavBarContext = createContext3({});
535
561
  var useNavBarContext = () => useContext4(NavBarContext);
536
562
  function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
537
563
  const [settings, setSettings] = useState2(() => ({ ...defaultThemeSettings, ...initialValue }));
538
- const set2 = useCallback2(
539
- (patch) => {
540
- setSettings((prev) => {
541
- const next = { ...prev, ...patch };
542
- onChange?.(next);
543
- return next;
544
- });
545
- },
546
- [onChange]
547
- );
564
+ const set = useCallback2((patch) => {
565
+ setSettings((prev) => ({ ...prev, ...patch }));
566
+ }, []);
567
+ const onChangeRef = useRef(onChange);
568
+ onChangeRef.current = onChange;
569
+ const prevSettings = useRef(settings);
570
+ useEffect2(() => {
571
+ if (prevSettings.current !== settings) {
572
+ prevSettings.current = settings;
573
+ onChangeRef.current?.(settings);
574
+ }
575
+ }, [settings]);
548
576
  const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
549
577
  const called = useRef(false);
550
578
  useEffect2(() => {
@@ -554,7 +582,7 @@ function Provider({ initialValue, onChange, children, defaults, onNavBarChange,
554
582
  }
555
583
  }, [theme, onReady]);
556
584
  if (!theme) return null;
557
- return /* @__PURE__ */ jsx4(ThemeSettingsContext.Provider, { value: { settings, set: set2 }, children: /* @__PURE__ */ jsxs3(PaperProvider, { theme, children: [
585
+ return /* @__PURE__ */ jsx4(ThemeSettingsContext.Provider, { value: { settings, set }, children: /* @__PURE__ */ jsxs3(PaperProvider, { theme, children: [
558
586
  /* @__PURE__ */ jsx4(StatusBar2, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
559
587
  /* @__PURE__ */ jsx4(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ jsx4(NavBarContext.Provider, { value: { onNavBarChange }, children: /* @__PURE__ */ jsx4(View2, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) }) })
560
588
  ] }) });
@@ -569,8 +597,9 @@ function useNavigationBarSync() {
569
597
  const theme = useTheme3();
570
598
  const { onNavBarChange } = useNavBarContext();
571
599
  useEffect3(() => {
572
- if (Platform.OS !== "android" || !onNavBarChange) return;
573
- onNavBarChange(theme.colors.surface, theme.dark);
600
+ if (Platform.OS !== "android") return;
601
+ if (onNavBarChange) onNavBarChange(theme.colors.surface, theme.dark);
602
+ else if (navigationBar) setNavigationBarStyle(theme.dark);
574
603
  }, [theme, onNavBarChange]);
575
604
  }
576
605
  function BottomNavigationComponent(props) {
@@ -583,7 +612,7 @@ function Bar(props) {
583
612
  return /* @__PURE__ */ jsx5(PaperBottomNavigation.Bar, { ...props });
584
613
  }
585
614
  BottomNavigationComponent.Bar = Bar;
586
- BottomNavigationComponent.SceneMap = PaperBottomNavigation.SceneMap;
615
+ BottomNavigationComponent.SceneMap = PaperBottomNavigation?.SceneMap;
587
616
  var BottomNavigation = BottomNavigationComponent;
588
617
 
589
618
  // src/components/Button.tsx
@@ -779,1544 +808,6 @@ var TextInput = forwardRef(function TextInput2(props, ref) {
779
808
  return /* @__PURE__ */ jsx14(PaperTextInput, { ref, ...defaults.TextInput, ...props });
780
809
  });
781
810
 
782
- // node_modules/redux/dist/redux.mjs
783
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
784
- var ActionTypes = {
785
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
786
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
787
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
788
- };
789
- function isPlainObject(obj) {
790
- if (typeof obj !== "object" || obj === null)
791
- return false;
792
- let proto = obj;
793
- while (Object.getPrototypeOf(proto) !== null) {
794
- proto = Object.getPrototypeOf(proto);
795
- }
796
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
797
- }
798
- function compose(...funcs) {
799
- if (funcs.length === 0) {
800
- return (arg) => arg;
801
- }
802
- if (funcs.length === 1) {
803
- return funcs[0];
804
- }
805
- return funcs.reduce((a, b) => (...args) => a(b(...args)));
806
- }
807
- function isAction(action) {
808
- return isPlainObject(action) && "type" in action && typeof action.type === "string";
809
- }
810
-
811
- // node_modules/immer/dist/immer.mjs
812
- var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
813
- var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
814
- var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
815
- var errors = process.env.NODE_ENV !== "production" ? [
816
- // All error codes, starting by 0:
817
- function(plugin) {
818
- return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
819
- },
820
- function(thing) {
821
- return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
822
- },
823
- "This object has been frozen and should not be mutated",
824
- function(data) {
825
- return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
826
- },
827
- "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
828
- "Immer forbids circular references",
829
- "The first or second argument to `produce` must be a function",
830
- "The third argument to `produce` must be a function or undefined",
831
- "First argument to `createDraft` must be a plain object, an array, or an immerable object",
832
- "First argument to `finishDraft` must be a draft returned by `createDraft`",
833
- function(thing) {
834
- return `'current' expects a draft, got: ${thing}`;
835
- },
836
- "Object.defineProperty() cannot be used on an Immer draft",
837
- "Object.setPrototypeOf() cannot be used on an Immer draft",
838
- "Immer only supports deleting array indices",
839
- "Immer only supports setting array indices and the 'length' property",
840
- function(thing) {
841
- return `'original' expects a draft, got: ${thing}`;
842
- }
843
- // Note: if more errors are added, the errorOffset in Patches.ts should be increased
844
- // See Patches.ts for additional errors
845
- ] : [];
846
- function die(error, ...args) {
847
- if (process.env.NODE_ENV !== "production") {
848
- const e = errors[error];
849
- const msg = isFunction(e) ? e.apply(null, args) : e;
850
- throw new Error(`[Immer] ${msg}`);
851
- }
852
- throw new Error(
853
- `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
854
- );
855
- }
856
- var O = Object;
857
- var getPrototypeOf = O.getPrototypeOf;
858
- var CONSTRUCTOR = "constructor";
859
- var PROTOTYPE = "prototype";
860
- var CONFIGURABLE = "configurable";
861
- var ENUMERABLE = "enumerable";
862
- var WRITABLE = "writable";
863
- var VALUE = "value";
864
- var isDraft = (value) => !!value && !!value[DRAFT_STATE];
865
- function isDraftable(value) {
866
- if (!value)
867
- return false;
868
- return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
869
- }
870
- var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
871
- var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
872
- function isPlainObject2(value) {
873
- if (!value || !isObjectish(value))
874
- return false;
875
- const proto = getPrototypeOf(value);
876
- if (proto === null || proto === O[PROTOTYPE])
877
- return true;
878
- const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
879
- if (Ctor === Object)
880
- return true;
881
- if (!isFunction(Ctor))
882
- return false;
883
- let ctorString = cachedCtorStrings.get(Ctor);
884
- if (ctorString === void 0) {
885
- ctorString = Function.toString.call(Ctor);
886
- cachedCtorStrings.set(Ctor, ctorString);
887
- }
888
- return ctorString === objectCtorString;
889
- }
890
- function each(obj, iter, strict = true) {
891
- if (getArchtype(obj) === 0) {
892
- const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
893
- keys.forEach((key) => {
894
- iter(key, obj[key], obj);
895
- });
896
- } else {
897
- obj.forEach((entry, index) => iter(index, entry, obj));
898
- }
899
- }
900
- function getArchtype(thing) {
901
- const state = thing[DRAFT_STATE];
902
- return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
903
- }
904
- var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
905
- var get = (thing, prop, type = getArchtype(thing)) => (
906
- // @ts-ignore
907
- type === 2 ? thing.get(prop) : thing[prop]
908
- );
909
- var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
910
- if (type === 2)
911
- thing.set(propOrOldValue, value);
912
- else if (type === 3) {
913
- thing.add(value);
914
- } else
915
- thing[propOrOldValue] = value;
916
- };
917
- function is(x, y) {
918
- if (x === y) {
919
- return x !== 0 || 1 / x === 1 / y;
920
- } else {
921
- return x !== x && y !== y;
922
- }
923
- }
924
- var isArray = Array.isArray;
925
- var isMap = (target) => target instanceof Map;
926
- var isSet = (target) => target instanceof Set;
927
- var isObjectish = (target) => typeof target === "object";
928
- var isFunction = (target) => typeof target === "function";
929
- var isBoolean = (target) => typeof target === "boolean";
930
- function isArrayIndex(value) {
931
- const n = +value;
932
- return Number.isInteger(n) && String(n) === value;
933
- }
934
- var latest = (state) => state.copy_ || state.base_;
935
- var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
936
- function shallowCopy(base, strict) {
937
- if (isMap(base)) {
938
- return new Map(base);
939
- }
940
- if (isSet(base)) {
941
- return new Set(base);
942
- }
943
- if (isArray(base))
944
- return Array[PROTOTYPE].slice.call(base);
945
- const isPlain = isPlainObject2(base);
946
- if (strict === true || strict === "class_only" && !isPlain) {
947
- const descriptors = O.getOwnPropertyDescriptors(base);
948
- delete descriptors[DRAFT_STATE];
949
- let keys = Reflect.ownKeys(descriptors);
950
- for (let i = 0; i < keys.length; i++) {
951
- const key = keys[i];
952
- const desc = descriptors[key];
953
- if (desc[WRITABLE] === false) {
954
- desc[WRITABLE] = true;
955
- desc[CONFIGURABLE] = true;
956
- }
957
- if (desc.get || desc.set)
958
- descriptors[key] = {
959
- [CONFIGURABLE]: true,
960
- [WRITABLE]: true,
961
- // could live with !!desc.set as well here...
962
- [ENUMERABLE]: desc[ENUMERABLE],
963
- [VALUE]: base[key]
964
- };
965
- }
966
- return O.create(getPrototypeOf(base), descriptors);
967
- } else {
968
- const proto = getPrototypeOf(base);
969
- if (proto !== null && isPlain) {
970
- return { ...base };
971
- }
972
- const obj = O.create(proto);
973
- return O.assign(obj, base);
974
- }
975
- }
976
- function freeze(obj, deep = false) {
977
- if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
978
- return obj;
979
- if (getArchtype(obj) > 1) {
980
- O.defineProperties(obj, {
981
- set: dontMutateMethodOverride,
982
- add: dontMutateMethodOverride,
983
- clear: dontMutateMethodOverride,
984
- delete: dontMutateMethodOverride
985
- });
986
- }
987
- O.freeze(obj);
988
- if (deep)
989
- each(
990
- obj,
991
- (_key, value) => {
992
- freeze(value, true);
993
- },
994
- false
995
- );
996
- return obj;
997
- }
998
- function dontMutateFrozenCollections() {
999
- die(2);
1000
- }
1001
- var dontMutateMethodOverride = {
1002
- [VALUE]: dontMutateFrozenCollections
1003
- };
1004
- function isFrozen(obj) {
1005
- if (obj === null || !isObjectish(obj))
1006
- return true;
1007
- return O.isFrozen(obj);
1008
- }
1009
- var PluginMapSet = "MapSet";
1010
- var PluginPatches = "Patches";
1011
- var PluginArrayMethods = "ArrayMethods";
1012
- var plugins = {};
1013
- function getPlugin(pluginKey) {
1014
- const plugin = plugins[pluginKey];
1015
- if (!plugin) {
1016
- die(0, pluginKey);
1017
- }
1018
- return plugin;
1019
- }
1020
- var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
1021
- var currentScope;
1022
- var getCurrentScope = () => currentScope;
1023
- var createScope = (parent_, immer_) => ({
1024
- drafts_: [],
1025
- parent_,
1026
- immer_,
1027
- // Whenever the modified draft contains a draft from another scope, we
1028
- // need to prevent auto-freezing so the unowned draft can be finalized.
1029
- canAutoFreeze_: true,
1030
- unfinalizedDrafts_: 0,
1031
- handledSet_: /* @__PURE__ */ new Set(),
1032
- processedForPatches_: /* @__PURE__ */ new Set(),
1033
- mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
1034
- arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
1035
- });
1036
- function usePatchesInScope(scope, patchListener) {
1037
- if (patchListener) {
1038
- scope.patchPlugin_ = getPlugin(PluginPatches);
1039
- scope.patches_ = [];
1040
- scope.inversePatches_ = [];
1041
- scope.patchListener_ = patchListener;
1042
- }
1043
- }
1044
- function revokeScope(scope) {
1045
- leaveScope(scope);
1046
- scope.drafts_.forEach(revokeDraft);
1047
- scope.drafts_ = null;
1048
- }
1049
- function leaveScope(scope) {
1050
- if (scope === currentScope) {
1051
- currentScope = scope.parent_;
1052
- }
1053
- }
1054
- var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
1055
- function revokeDraft(draft) {
1056
- const state = draft[DRAFT_STATE];
1057
- if (state.type_ === 0 || state.type_ === 1)
1058
- state.revoke_();
1059
- else
1060
- state.revoked_ = true;
1061
- }
1062
- function processResult(result, scope) {
1063
- scope.unfinalizedDrafts_ = scope.drafts_.length;
1064
- const baseDraft = scope.drafts_[0];
1065
- const isReplaced = result !== void 0 && result !== baseDraft;
1066
- if (isReplaced) {
1067
- if (baseDraft[DRAFT_STATE].modified_) {
1068
- revokeScope(scope);
1069
- die(4);
1070
- }
1071
- if (isDraftable(result)) {
1072
- result = finalize(scope, result);
1073
- }
1074
- const { patchPlugin_ } = scope;
1075
- if (patchPlugin_) {
1076
- patchPlugin_.generateReplacementPatches_(
1077
- baseDraft[DRAFT_STATE].base_,
1078
- result,
1079
- scope
1080
- );
1081
- }
1082
- } else {
1083
- result = finalize(scope, baseDraft);
1084
- }
1085
- maybeFreeze(scope, result, true);
1086
- revokeScope(scope);
1087
- if (scope.patches_) {
1088
- scope.patchListener_(scope.patches_, scope.inversePatches_);
1089
- }
1090
- return result !== NOTHING ? result : void 0;
1091
- }
1092
- function finalize(rootScope, value) {
1093
- if (isFrozen(value))
1094
- return value;
1095
- const state = value[DRAFT_STATE];
1096
- if (!state) {
1097
- const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
1098
- return finalValue;
1099
- }
1100
- if (!isSameScope(state, rootScope)) {
1101
- return value;
1102
- }
1103
- if (!state.modified_) {
1104
- return state.base_;
1105
- }
1106
- if (!state.finalized_) {
1107
- const { callbacks_ } = state;
1108
- if (callbacks_) {
1109
- while (callbacks_.length > 0) {
1110
- const callback = callbacks_.pop();
1111
- callback(rootScope);
1112
- }
1113
- }
1114
- generatePatchesAndFinalize(state, rootScope);
1115
- }
1116
- return state.copy_;
1117
- }
1118
- function maybeFreeze(scope, value, deep = false) {
1119
- if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
1120
- freeze(value, deep);
1121
- }
1122
- }
1123
- function markStateFinalized(state) {
1124
- state.finalized_ = true;
1125
- state.scope_.unfinalizedDrafts_--;
1126
- }
1127
- var isSameScope = (state, rootScope) => state.scope_ === rootScope;
1128
- var EMPTY_LOCATIONS_RESULT = [];
1129
- function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
1130
- const parentCopy = latest(parent);
1131
- const parentType = parent.type_;
1132
- if (originalKey !== void 0) {
1133
- const currentValue = get(parentCopy, originalKey, parentType);
1134
- if (currentValue === draftValue) {
1135
- set(parentCopy, originalKey, finalizedValue, parentType);
1136
- return;
1137
- }
1138
- }
1139
- if (!parent.draftLocations_) {
1140
- const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
1141
- each(parentCopy, (key, value) => {
1142
- if (isDraft(value)) {
1143
- const keys = draftLocations.get(value) || [];
1144
- keys.push(key);
1145
- draftLocations.set(value, keys);
1146
- }
1147
- });
1148
- }
1149
- const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
1150
- for (const location of locations) {
1151
- set(parentCopy, location, finalizedValue, parentType);
1152
- }
1153
- }
1154
- function registerChildFinalizationCallback(parent, child, key) {
1155
- parent.callbacks_.push(function childCleanup(rootScope) {
1156
- const state = child;
1157
- if (!state || !isSameScope(state, rootScope)) {
1158
- return;
1159
- }
1160
- rootScope.mapSetPlugin_?.fixSetContents(state);
1161
- const finalizedValue = getFinalValue(state);
1162
- updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
1163
- generatePatchesAndFinalize(state, rootScope);
1164
- });
1165
- }
1166
- function generatePatchesAndFinalize(state, rootScope) {
1167
- const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
1168
- if (shouldFinalize) {
1169
- const { patchPlugin_ } = rootScope;
1170
- if (patchPlugin_) {
1171
- const basePath = patchPlugin_.getPath(state);
1172
- if (basePath) {
1173
- patchPlugin_.generatePatches_(state, basePath, rootScope);
1174
- }
1175
- }
1176
- markStateFinalized(state);
1177
- }
1178
- }
1179
- function handleCrossReference(target, key, value) {
1180
- const { scope_ } = target;
1181
- if (isDraft(value)) {
1182
- const state = value[DRAFT_STATE];
1183
- if (isSameScope(state, scope_)) {
1184
- state.callbacks_.push(function crossReferenceCleanup() {
1185
- prepareCopy(target);
1186
- const finalizedValue = getFinalValue(state);
1187
- updateDraftInParent(target, value, finalizedValue, key);
1188
- });
1189
- }
1190
- } else if (isDraftable(value)) {
1191
- target.callbacks_.push(function nestedDraftCleanup() {
1192
- const targetCopy = latest(target);
1193
- if (target.type_ === 3) {
1194
- if (targetCopy.has(value)) {
1195
- handleValue(value, scope_.handledSet_, scope_);
1196
- }
1197
- } else {
1198
- if (get(targetCopy, key, target.type_) === value) {
1199
- if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
1200
- handleValue(
1201
- get(target.copy_, key, target.type_),
1202
- scope_.handledSet_,
1203
- scope_
1204
- );
1205
- }
1206
- }
1207
- }
1208
- });
1209
- }
1210
- }
1211
- function handleValue(target, handledSet, rootScope) {
1212
- if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
1213
- return target;
1214
- }
1215
- if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
1216
- return target;
1217
- }
1218
- handledSet.add(target);
1219
- each(target, (key, value) => {
1220
- if (isDraft(value)) {
1221
- const state = value[DRAFT_STATE];
1222
- if (isSameScope(state, rootScope)) {
1223
- const updatedValue = getFinalValue(state);
1224
- set(target, key, updatedValue, target.type_);
1225
- markStateFinalized(state);
1226
- }
1227
- } else if (isDraftable(value)) {
1228
- handleValue(value, handledSet, rootScope);
1229
- }
1230
- });
1231
- return target;
1232
- }
1233
- function createProxyProxy(base, parent) {
1234
- const baseIsArray = isArray(base);
1235
- const state = {
1236
- type_: baseIsArray ? 1 : 0,
1237
- // Track which produce call this is associated with.
1238
- scope_: parent ? parent.scope_ : getCurrentScope(),
1239
- // True for both shallow and deep changes.
1240
- modified_: false,
1241
- // Used during finalization.
1242
- finalized_: false,
1243
- // Track which properties have been assigned (true) or deleted (false).
1244
- // actually instantiated in `prepareCopy()`
1245
- assigned_: void 0,
1246
- // The parent draft state.
1247
- parent_: parent,
1248
- // The base state.
1249
- base_: base,
1250
- // The base proxy.
1251
- draft_: null,
1252
- // set below
1253
- // The base copy with any updated values.
1254
- copy_: null,
1255
- // Called by the `produce` function.
1256
- revoke_: null,
1257
- isManual_: false,
1258
- // `callbacks` actually gets assigned in `createProxy`
1259
- callbacks_: void 0
1260
- };
1261
- let target = state;
1262
- let traps = objectTraps;
1263
- if (baseIsArray) {
1264
- target = [state];
1265
- traps = arrayTraps;
1266
- }
1267
- const { revoke, proxy } = Proxy.revocable(target, traps);
1268
- state.draft_ = proxy;
1269
- state.revoke_ = revoke;
1270
- return [proxy, state];
1271
- }
1272
- var objectTraps = {
1273
- get(state, prop) {
1274
- if (prop === DRAFT_STATE)
1275
- return state;
1276
- let arrayPlugin = state.scope_.arrayMethodsPlugin_;
1277
- const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
1278
- if (isArrayWithStringProp) {
1279
- if (arrayPlugin?.isArrayOperationMethod(prop)) {
1280
- return arrayPlugin.createMethodInterceptor(state, prop);
1281
- }
1282
- }
1283
- const source = latest(state);
1284
- if (!has(source, prop, state.type_)) {
1285
- return readPropFromProto(state, source, prop);
1286
- }
1287
- const value = source[prop];
1288
- if (state.finalized_ || !isDraftable(value)) {
1289
- return value;
1290
- }
1291
- if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
1292
- state.operationMethod
1293
- ) && isArrayIndex(prop)) {
1294
- return value;
1295
- }
1296
- if (value === peek(state.base_, prop)) {
1297
- prepareCopy(state);
1298
- const childKey = state.type_ === 1 ? +prop : prop;
1299
- const childDraft = createProxy(state.scope_, value, state, childKey);
1300
- return state.copy_[childKey] = childDraft;
1301
- }
1302
- return value;
1303
- },
1304
- has(state, prop) {
1305
- return prop in latest(state);
1306
- },
1307
- ownKeys(state) {
1308
- return Reflect.ownKeys(latest(state));
1309
- },
1310
- set(state, prop, value) {
1311
- const desc = getDescriptorFromProto(latest(state), prop);
1312
- if (desc?.set) {
1313
- desc.set.call(state.draft_, value);
1314
- return true;
1315
- }
1316
- if (!state.modified_) {
1317
- const current2 = peek(latest(state), prop);
1318
- const currentState = current2?.[DRAFT_STATE];
1319
- if (currentState && currentState.base_ === value) {
1320
- state.copy_[prop] = value;
1321
- state.assigned_.set(prop, false);
1322
- return true;
1323
- }
1324
- if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
1325
- return true;
1326
- prepareCopy(state);
1327
- markChanged(state);
1328
- }
1329
- if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
1330
- (value !== void 0 || prop in state.copy_) || // special case: NaN
1331
- Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
1332
- return true;
1333
- state.copy_[prop] = value;
1334
- state.assigned_.set(prop, true);
1335
- handleCrossReference(state, prop, value);
1336
- return true;
1337
- },
1338
- deleteProperty(state, prop) {
1339
- prepareCopy(state);
1340
- if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
1341
- state.assigned_.set(prop, false);
1342
- markChanged(state);
1343
- } else {
1344
- state.assigned_.delete(prop);
1345
- }
1346
- if (state.copy_) {
1347
- delete state.copy_[prop];
1348
- }
1349
- return true;
1350
- },
1351
- // Note: We never coerce `desc.value` into an Immer draft, because we can't make
1352
- // the same guarantee in ES5 mode.
1353
- getOwnPropertyDescriptor(state, prop) {
1354
- const owner = latest(state);
1355
- const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
1356
- if (!desc)
1357
- return desc;
1358
- return {
1359
- [WRITABLE]: true,
1360
- [CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
1361
- [ENUMERABLE]: desc[ENUMERABLE],
1362
- [VALUE]: owner[prop]
1363
- };
1364
- },
1365
- defineProperty() {
1366
- die(11);
1367
- },
1368
- getPrototypeOf(state) {
1369
- return getPrototypeOf(state.base_);
1370
- },
1371
- setPrototypeOf() {
1372
- die(12);
1373
- }
1374
- };
1375
- var arrayTraps = {};
1376
- for (let key in objectTraps) {
1377
- let fn = objectTraps[key];
1378
- arrayTraps[key] = function() {
1379
- const args = arguments;
1380
- args[0] = args[0][0];
1381
- return fn.apply(this, args);
1382
- };
1383
- }
1384
- arrayTraps.deleteProperty = function(state, prop) {
1385
- if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
1386
- die(13);
1387
- return arrayTraps.set.call(this, state, prop, void 0);
1388
- };
1389
- arrayTraps.set = function(state, prop, value) {
1390
- if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
1391
- die(14);
1392
- return objectTraps.set.call(this, state[0], prop, value, state[0]);
1393
- };
1394
- function peek(draft, prop) {
1395
- const state = draft[DRAFT_STATE];
1396
- const source = state ? latest(state) : draft;
1397
- return source[prop];
1398
- }
1399
- function readPropFromProto(state, source, prop) {
1400
- const desc = getDescriptorFromProto(source, prop);
1401
- return desc ? VALUE in desc ? desc[VALUE] : (
1402
- // This is a very special case, if the prop is a getter defined by the
1403
- // prototype, we should invoke it with the draft as context!
1404
- desc.get?.call(state.draft_)
1405
- ) : void 0;
1406
- }
1407
- function getDescriptorFromProto(source, prop) {
1408
- if (!(prop in source))
1409
- return void 0;
1410
- let proto = getPrototypeOf(source);
1411
- while (proto) {
1412
- const desc = Object.getOwnPropertyDescriptor(proto, prop);
1413
- if (desc)
1414
- return desc;
1415
- proto = getPrototypeOf(proto);
1416
- }
1417
- return void 0;
1418
- }
1419
- function markChanged(state) {
1420
- if (!state.modified_) {
1421
- state.modified_ = true;
1422
- if (state.parent_) {
1423
- markChanged(state.parent_);
1424
- }
1425
- }
1426
- }
1427
- function prepareCopy(state) {
1428
- if (!state.copy_) {
1429
- state.assigned_ = /* @__PURE__ */ new Map();
1430
- state.copy_ = shallowCopy(
1431
- state.base_,
1432
- state.scope_.immer_.useStrictShallowCopy_
1433
- );
1434
- }
1435
- }
1436
- var Immer2 = class {
1437
- constructor(config) {
1438
- this.autoFreeze_ = true;
1439
- this.useStrictShallowCopy_ = false;
1440
- this.useStrictIteration_ = false;
1441
- this.produce = (base, recipe, patchListener) => {
1442
- if (isFunction(base) && !isFunction(recipe)) {
1443
- const defaultBase = recipe;
1444
- recipe = base;
1445
- const self = this;
1446
- return function curriedProduce(base2 = defaultBase, ...args) {
1447
- return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
1448
- };
1449
- }
1450
- if (!isFunction(recipe))
1451
- die(6);
1452
- if (patchListener !== void 0 && !isFunction(patchListener))
1453
- die(7);
1454
- let result;
1455
- if (isDraftable(base)) {
1456
- const scope = enterScope(this);
1457
- const proxy = createProxy(scope, base, void 0);
1458
- let hasError = true;
1459
- try {
1460
- result = recipe(proxy);
1461
- hasError = false;
1462
- } finally {
1463
- if (hasError)
1464
- revokeScope(scope);
1465
- else
1466
- leaveScope(scope);
1467
- }
1468
- usePatchesInScope(scope, patchListener);
1469
- return processResult(result, scope);
1470
- } else if (!base || !isObjectish(base)) {
1471
- result = recipe(base);
1472
- if (result === void 0)
1473
- result = base;
1474
- if (result === NOTHING)
1475
- result = void 0;
1476
- if (this.autoFreeze_)
1477
- freeze(result, true);
1478
- if (patchListener) {
1479
- const p = [];
1480
- const ip = [];
1481
- getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
1482
- patches_: p,
1483
- inversePatches_: ip
1484
- });
1485
- patchListener(p, ip);
1486
- }
1487
- return result;
1488
- } else
1489
- die(1, base);
1490
- };
1491
- this.produceWithPatches = (base, recipe) => {
1492
- if (isFunction(base)) {
1493
- return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
1494
- }
1495
- let patches, inversePatches;
1496
- const result = this.produce(base, recipe, (p, ip) => {
1497
- patches = p;
1498
- inversePatches = ip;
1499
- });
1500
- return [result, patches, inversePatches];
1501
- };
1502
- if (isBoolean(config?.autoFreeze))
1503
- this.setAutoFreeze(config.autoFreeze);
1504
- if (isBoolean(config?.useStrictShallowCopy))
1505
- this.setUseStrictShallowCopy(config.useStrictShallowCopy);
1506
- if (isBoolean(config?.useStrictIteration))
1507
- this.setUseStrictIteration(config.useStrictIteration);
1508
- }
1509
- createDraft(base) {
1510
- if (!isDraftable(base))
1511
- die(8);
1512
- if (isDraft(base))
1513
- base = current(base);
1514
- const scope = enterScope(this);
1515
- const proxy = createProxy(scope, base, void 0);
1516
- proxy[DRAFT_STATE].isManual_ = true;
1517
- leaveScope(scope);
1518
- return proxy;
1519
- }
1520
- finishDraft(draft, patchListener) {
1521
- const state = draft && draft[DRAFT_STATE];
1522
- if (!state || !state.isManual_)
1523
- die(9);
1524
- const { scope_: scope } = state;
1525
- usePatchesInScope(scope, patchListener);
1526
- return processResult(void 0, scope);
1527
- }
1528
- /**
1529
- * Pass true to automatically freeze all copies created by Immer.
1530
- *
1531
- * By default, auto-freezing is enabled.
1532
- */
1533
- setAutoFreeze(value) {
1534
- this.autoFreeze_ = value;
1535
- }
1536
- /**
1537
- * Pass true to enable strict shallow copy.
1538
- *
1539
- * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
1540
- */
1541
- setUseStrictShallowCopy(value) {
1542
- this.useStrictShallowCopy_ = value;
1543
- }
1544
- /**
1545
- * Pass false to use faster iteration that skips non-enumerable properties
1546
- * but still handles symbols for compatibility.
1547
- *
1548
- * By default, strict iteration is enabled (includes all own properties).
1549
- */
1550
- setUseStrictIteration(value) {
1551
- this.useStrictIteration_ = value;
1552
- }
1553
- shouldUseStrictIteration() {
1554
- return this.useStrictIteration_;
1555
- }
1556
- applyPatches(base, patches) {
1557
- let i;
1558
- for (i = patches.length - 1; i >= 0; i--) {
1559
- const patch = patches[i];
1560
- if (patch.path.length === 0 && patch.op === "replace") {
1561
- base = patch.value;
1562
- break;
1563
- }
1564
- }
1565
- if (i > -1) {
1566
- patches = patches.slice(i + 1);
1567
- }
1568
- const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
1569
- if (isDraft(base)) {
1570
- return applyPatchesImpl(base, patches);
1571
- }
1572
- return this.produce(
1573
- base,
1574
- (draft) => applyPatchesImpl(draft, patches)
1575
- );
1576
- }
1577
- };
1578
- function createProxy(rootScope, value, parent, key) {
1579
- const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
1580
- const scope = parent?.scope_ ?? getCurrentScope();
1581
- scope.drafts_.push(draft);
1582
- state.callbacks_ = parent?.callbacks_ ?? [];
1583
- state.key_ = key;
1584
- if (parent && key !== void 0) {
1585
- registerChildFinalizationCallback(parent, state, key);
1586
- } else {
1587
- state.callbacks_.push(function rootDraftCleanup(rootScope2) {
1588
- rootScope2.mapSetPlugin_?.fixSetContents(state);
1589
- const { patchPlugin_ } = rootScope2;
1590
- if (state.modified_ && patchPlugin_) {
1591
- patchPlugin_.generatePatches_(state, [], rootScope2);
1592
- }
1593
- });
1594
- }
1595
- return draft;
1596
- }
1597
- function current(value) {
1598
- if (!isDraft(value))
1599
- die(10, value);
1600
- return currentImpl(value);
1601
- }
1602
- function currentImpl(value) {
1603
- if (!isDraftable(value) || isFrozen(value))
1604
- return value;
1605
- const state = value[DRAFT_STATE];
1606
- let copy;
1607
- let strict = true;
1608
- if (state) {
1609
- if (!state.modified_)
1610
- return state.base_;
1611
- state.finalized_ = true;
1612
- copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
1613
- strict = state.scope_.immer_.shouldUseStrictIteration();
1614
- } else {
1615
- copy = shallowCopy(value, true);
1616
- }
1617
- each(
1618
- copy,
1619
- (key, childValue) => {
1620
- set(copy, key, currentImpl(childValue));
1621
- },
1622
- strict
1623
- );
1624
- if (state) {
1625
- state.finalized_ = false;
1626
- }
1627
- return copy;
1628
- }
1629
- var immer = new Immer2();
1630
- var produce = immer.produce;
1631
-
1632
- // node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
1633
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
1634
- if (arguments.length === 0) return void 0;
1635
- if (typeof arguments[0] === "object") return compose;
1636
- return compose.apply(null, arguments);
1637
- };
1638
- var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
1639
- return function(noop3) {
1640
- return noop3;
1641
- };
1642
- };
1643
- var hasMatchFunction = (v) => {
1644
- return v && typeof v.match === "function";
1645
- };
1646
- function createAction(type, prepareAction) {
1647
- function actionCreator(...args) {
1648
- if (prepareAction) {
1649
- let prepared = prepareAction(...args);
1650
- if (!prepared) {
1651
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
1652
- }
1653
- return {
1654
- type,
1655
- payload: prepared.payload,
1656
- ..."meta" in prepared && {
1657
- meta: prepared.meta
1658
- },
1659
- ..."error" in prepared && {
1660
- error: prepared.error
1661
- }
1662
- };
1663
- }
1664
- return {
1665
- type,
1666
- payload: args[0]
1667
- };
1668
- }
1669
- actionCreator.toString = () => `${type}`;
1670
- actionCreator.type = type;
1671
- actionCreator.match = (action) => isAction(action) && action.type === type;
1672
- return actionCreator;
1673
- }
1674
- function freezeDraftable(val) {
1675
- return isDraftable(val) ? produce(val, () => {
1676
- }) : val;
1677
- }
1678
- function getOrInsertComputed(map, key, compute) {
1679
- if (map.has(key)) return map.get(key);
1680
- return map.set(key, compute(key)).get(key);
1681
- }
1682
- function executeReducerBuilderCallback(builderCallback) {
1683
- const actionsMap = {};
1684
- const actionMatchers = [];
1685
- let defaultCaseReducer;
1686
- const builder = {
1687
- addCase(typeOrActionCreator, reducer) {
1688
- if (process.env.NODE_ENV !== "production") {
1689
- if (actionMatchers.length > 0) {
1690
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
1691
- }
1692
- if (defaultCaseReducer) {
1693
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
1694
- }
1695
- }
1696
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1697
- if (!type) {
1698
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
1699
- }
1700
- if (type in actionsMap) {
1701
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
1702
- }
1703
- actionsMap[type] = reducer;
1704
- return builder;
1705
- },
1706
- addAsyncThunk(asyncThunk, reducers2) {
1707
- if (process.env.NODE_ENV !== "production") {
1708
- if (defaultCaseReducer) {
1709
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
1710
- }
1711
- }
1712
- if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
1713
- if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
1714
- if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
1715
- if (reducers2.settled) actionMatchers.push({
1716
- matcher: asyncThunk.settled,
1717
- reducer: reducers2.settled
1718
- });
1719
- return builder;
1720
- },
1721
- addMatcher(matcher, reducer) {
1722
- if (process.env.NODE_ENV !== "production") {
1723
- if (defaultCaseReducer) {
1724
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
1725
- }
1726
- }
1727
- actionMatchers.push({
1728
- matcher,
1729
- reducer
1730
- });
1731
- return builder;
1732
- },
1733
- addDefaultCase(reducer) {
1734
- if (process.env.NODE_ENV !== "production") {
1735
- if (defaultCaseReducer) {
1736
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
1737
- }
1738
- }
1739
- defaultCaseReducer = reducer;
1740
- return builder;
1741
- }
1742
- };
1743
- builderCallback(builder);
1744
- return [actionsMap, actionMatchers, defaultCaseReducer];
1745
- }
1746
- function isStateFunction(x) {
1747
- return typeof x === "function";
1748
- }
1749
- function createReducer(initialState, mapOrBuilderCallback) {
1750
- if (process.env.NODE_ENV !== "production") {
1751
- if (typeof mapOrBuilderCallback === "object") {
1752
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
1753
- }
1754
- }
1755
- let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
1756
- let getInitialState;
1757
- if (isStateFunction(initialState)) {
1758
- getInitialState = () => freezeDraftable(initialState());
1759
- } else {
1760
- const frozenInitialState = freezeDraftable(initialState);
1761
- getInitialState = () => frozenInitialState;
1762
- }
1763
- function reducer(state = getInitialState(), action) {
1764
- let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
1765
- matcher
1766
- }) => matcher(action)).map(({
1767
- reducer: reducer2
1768
- }) => reducer2)];
1769
- if (caseReducers.filter((cr) => !!cr).length === 0) {
1770
- caseReducers = [finalDefaultCaseReducer];
1771
- }
1772
- return caseReducers.reduce((previousState, caseReducer) => {
1773
- if (caseReducer) {
1774
- if (isDraft(previousState)) {
1775
- const draft = previousState;
1776
- const result = caseReducer(draft, action);
1777
- if (result === void 0) {
1778
- return previousState;
1779
- }
1780
- return result;
1781
- } else if (!isDraftable(previousState)) {
1782
- const result = caseReducer(previousState, action);
1783
- if (result === void 0) {
1784
- if (previousState === null) {
1785
- return previousState;
1786
- }
1787
- throw Error("A case reducer on a non-draftable value must not return undefined");
1788
- }
1789
- return result;
1790
- } else {
1791
- return produce(previousState, (draft) => {
1792
- return caseReducer(draft, action);
1793
- });
1794
- }
1795
- }
1796
- return previousState;
1797
- }, state);
1798
- }
1799
- reducer.getInitialState = getInitialState;
1800
- return reducer;
1801
- }
1802
- var matches = (matcher, action) => {
1803
- if (hasMatchFunction(matcher)) {
1804
- return matcher.match(action);
1805
- } else {
1806
- return matcher(action);
1807
- }
1808
- };
1809
- function isAnyOf(...matchers) {
1810
- return (action) => {
1811
- return matchers.some((matcher) => matches(matcher, action));
1812
- };
1813
- }
1814
- var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
1815
- var nanoid = (size = 21) => {
1816
- let id = "";
1817
- let i = size;
1818
- while (i--) {
1819
- id += urlAlphabet[Math.random() * 64 | 0];
1820
- }
1821
- return id;
1822
- };
1823
- var commonProperties = ["name", "message", "stack", "code"];
1824
- var RejectWithValue = class {
1825
- constructor(payload, meta) {
1826
- __publicField(this, "payload");
1827
- __publicField(this, "meta");
1828
- /*
1829
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1830
- does not exist at runtime
1831
- */
1832
- __publicField(this, "_type");
1833
- this.payload = payload;
1834
- this.meta = meta;
1835
- }
1836
- };
1837
- var FulfillWithMeta = class {
1838
- constructor(payload, meta) {
1839
- __publicField(this, "payload");
1840
- __publicField(this, "meta");
1841
- /*
1842
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1843
- does not exist at runtime
1844
- */
1845
- __publicField(this, "_type");
1846
- this.payload = payload;
1847
- this.meta = meta;
1848
- }
1849
- };
1850
- var miniSerializeError = (value) => {
1851
- if (typeof value === "object" && value !== null) {
1852
- const simpleError = {};
1853
- for (const property of commonProperties) {
1854
- if (typeof value[property] === "string") {
1855
- simpleError[property] = value[property];
1856
- }
1857
- }
1858
- return simpleError;
1859
- }
1860
- return {
1861
- message: String(value)
1862
- };
1863
- };
1864
- var externalAbortMessage = "External signal was aborted";
1865
- var createAsyncThunk = /* @__PURE__ */ (() => {
1866
- function createAsyncThunk2(typePrefix, payloadCreator, options) {
1867
- const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
1868
- payload,
1869
- meta: {
1870
- ...meta || {},
1871
- arg,
1872
- requestId,
1873
- requestStatus: "fulfilled"
1874
- }
1875
- }));
1876
- const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
1877
- payload: void 0,
1878
- meta: {
1879
- ...meta || {},
1880
- arg,
1881
- requestId,
1882
- requestStatus: "pending"
1883
- }
1884
- }));
1885
- const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
1886
- payload,
1887
- error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1888
- meta: {
1889
- ...meta || {},
1890
- arg,
1891
- requestId,
1892
- rejectedWithValue: !!payload,
1893
- requestStatus: "rejected",
1894
- aborted: error?.name === "AbortError",
1895
- condition: error?.name === "ConditionError"
1896
- }
1897
- }));
1898
- function actionCreator(arg, {
1899
- signal
1900
- } = {}) {
1901
- return (dispatch, getState, extra) => {
1902
- const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
1903
- const abortController = new AbortController();
1904
- let abortHandler;
1905
- let abortReason;
1906
- function abort(reason) {
1907
- abortReason = reason;
1908
- abortController.abort();
1909
- }
1910
- if (signal) {
1911
- if (signal.aborted) {
1912
- abort(externalAbortMessage);
1913
- } else {
1914
- signal.addEventListener("abort", () => abort(externalAbortMessage), {
1915
- once: true
1916
- });
1917
- }
1918
- }
1919
- const promise = (async function() {
1920
- let finalAction;
1921
- try {
1922
- let conditionResult = options?.condition?.(arg, {
1923
- getState,
1924
- extra
1925
- });
1926
- if (isThenable(conditionResult)) {
1927
- conditionResult = await conditionResult;
1928
- }
1929
- if (conditionResult === false || abortController.signal.aborted) {
1930
- throw {
1931
- name: "ConditionError",
1932
- message: "Aborted due to condition callback returning false."
1933
- };
1934
- }
1935
- const abortedPromise = new Promise((_, reject) => {
1936
- abortHandler = () => {
1937
- reject({
1938
- name: "AbortError",
1939
- message: abortReason || "Aborted"
1940
- });
1941
- };
1942
- abortController.signal.addEventListener("abort", abortHandler, {
1943
- once: true
1944
- });
1945
- });
1946
- dispatch(pending(requestId, arg, options?.getPendingMeta?.({
1947
- requestId,
1948
- arg
1949
- }, {
1950
- getState,
1951
- extra
1952
- })));
1953
- finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
1954
- dispatch,
1955
- getState,
1956
- extra,
1957
- requestId,
1958
- signal: abortController.signal,
1959
- abort,
1960
- rejectWithValue: ((value, meta) => {
1961
- return new RejectWithValue(value, meta);
1962
- }),
1963
- fulfillWithValue: ((value, meta) => {
1964
- return new FulfillWithMeta(value, meta);
1965
- })
1966
- })).then((result) => {
1967
- if (result instanceof RejectWithValue) {
1968
- throw result;
1969
- }
1970
- if (result instanceof FulfillWithMeta) {
1971
- return fulfilled(result.payload, requestId, arg, result.meta);
1972
- }
1973
- return fulfilled(result, requestId, arg);
1974
- })]);
1975
- } catch (err) {
1976
- finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
1977
- } finally {
1978
- if (abortHandler) {
1979
- abortController.signal.removeEventListener("abort", abortHandler);
1980
- }
1981
- }
1982
- const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
1983
- if (!skipDispatch) {
1984
- dispatch(finalAction);
1985
- }
1986
- return finalAction;
1987
- })();
1988
- return Object.assign(promise, {
1989
- abort,
1990
- requestId,
1991
- arg,
1992
- unwrap() {
1993
- return promise.then(unwrapResult);
1994
- }
1995
- });
1996
- };
1997
- }
1998
- return Object.assign(actionCreator, {
1999
- pending,
2000
- rejected,
2001
- fulfilled,
2002
- settled: isAnyOf(rejected, fulfilled),
2003
- typePrefix
2004
- });
2005
- }
2006
- createAsyncThunk2.withTypes = () => createAsyncThunk2;
2007
- return createAsyncThunk2;
2008
- })();
2009
- function unwrapResult(action) {
2010
- if (action.meta && action.meta.rejectedWithValue) {
2011
- throw action.payload;
2012
- }
2013
- if (action.error) {
2014
- throw action.error;
2015
- }
2016
- return action.payload;
2017
- }
2018
- function isThenable(value) {
2019
- return value !== null && typeof value === "object" && typeof value.then === "function";
2020
- }
2021
- var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
2022
- var asyncThunkCreator = {
2023
- [asyncThunkSymbol]: createAsyncThunk
2024
- };
2025
- function getType(slice, actionKey) {
2026
- return `${slice}/${actionKey}`;
2027
- }
2028
- function buildCreateSlice({
2029
- creators
2030
- } = {}) {
2031
- const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
2032
- return function createSlice2(options) {
2033
- const {
2034
- name,
2035
- reducerPath = name
2036
- } = options;
2037
- if (!name) {
2038
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
2039
- }
2040
- if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
2041
- if (options.initialState === void 0) {
2042
- console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
2043
- }
2044
- }
2045
- const reducers2 = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
2046
- const reducerNames = Object.keys(reducers2);
2047
- const context = {
2048
- sliceCaseReducersByName: {},
2049
- sliceCaseReducersByType: {},
2050
- actionCreators: {},
2051
- sliceMatchers: []
2052
- };
2053
- const contextMethods = {
2054
- addCase(typeOrActionCreator, reducer2) {
2055
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
2056
- if (!type) {
2057
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
2058
- }
2059
- if (type in context.sliceCaseReducersByType) {
2060
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
2061
- }
2062
- context.sliceCaseReducersByType[type] = reducer2;
2063
- return contextMethods;
2064
- },
2065
- addMatcher(matcher, reducer2) {
2066
- context.sliceMatchers.push({
2067
- matcher,
2068
- reducer: reducer2
2069
- });
2070
- return contextMethods;
2071
- },
2072
- exposeAction(name2, actionCreator) {
2073
- context.actionCreators[name2] = actionCreator;
2074
- return contextMethods;
2075
- },
2076
- exposeCaseReducer(name2, reducer2) {
2077
- context.sliceCaseReducersByName[name2] = reducer2;
2078
- return contextMethods;
2079
- }
2080
- };
2081
- reducerNames.forEach((reducerName) => {
2082
- const reducerDefinition = reducers2[reducerName];
2083
- const reducerDetails = {
2084
- reducerName,
2085
- type: getType(name, reducerName),
2086
- createNotation: typeof options.reducers === "function"
2087
- };
2088
- if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
2089
- handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
2090
- } else {
2091
- handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
2092
- }
2093
- });
2094
- function buildReducer() {
2095
- if (process.env.NODE_ENV !== "production") {
2096
- if (typeof options.extraReducers === "object") {
2097
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
2098
- }
2099
- }
2100
- const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
2101
- const finalCaseReducers = {
2102
- ...extraReducers,
2103
- ...context.sliceCaseReducersByType
2104
- };
2105
- return createReducer(options.initialState, (builder) => {
2106
- for (let key in finalCaseReducers) {
2107
- builder.addCase(key, finalCaseReducers[key]);
2108
- }
2109
- for (let sM of context.sliceMatchers) {
2110
- builder.addMatcher(sM.matcher, sM.reducer);
2111
- }
2112
- for (let m of actionMatchers) {
2113
- builder.addMatcher(m.matcher, m.reducer);
2114
- }
2115
- if (defaultCaseReducer) {
2116
- builder.addDefaultCase(defaultCaseReducer);
2117
- }
2118
- });
2119
- }
2120
- const selectSelf = (state) => state;
2121
- const injectedSelectorCache = /* @__PURE__ */ new Map();
2122
- const injectedStateCache = /* @__PURE__ */ new WeakMap();
2123
- let _reducer;
2124
- function reducer(state, action) {
2125
- if (!_reducer) _reducer = buildReducer();
2126
- return _reducer(state, action);
2127
- }
2128
- function getInitialState() {
2129
- if (!_reducer) _reducer = buildReducer();
2130
- return _reducer.getInitialState();
2131
- }
2132
- function makeSelectorProps(reducerPath2, injected = false) {
2133
- function selectSlice(state) {
2134
- let sliceState = state[reducerPath2];
2135
- if (typeof sliceState === "undefined") {
2136
- if (injected) {
2137
- sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
2138
- } else if (process.env.NODE_ENV !== "production") {
2139
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
2140
- }
2141
- }
2142
- return sliceState;
2143
- }
2144
- function getSelectors(selectState = selectSelf) {
2145
- const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
2146
- return getOrInsertComputed(selectorCache, selectState, () => {
2147
- const map = {};
2148
- for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
2149
- map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
2150
- }
2151
- return map;
2152
- });
2153
- }
2154
- return {
2155
- reducerPath: reducerPath2,
2156
- getSelectors,
2157
- get selectors() {
2158
- return getSelectors(selectSlice);
2159
- },
2160
- selectSlice
2161
- };
2162
- }
2163
- const slice = {
2164
- name,
2165
- reducer,
2166
- actions: context.actionCreators,
2167
- caseReducers: context.sliceCaseReducersByName,
2168
- getInitialState,
2169
- ...makeSelectorProps(reducerPath),
2170
- injectInto(injectable, {
2171
- reducerPath: pathOpt,
2172
- ...config
2173
- } = {}) {
2174
- const newReducerPath = pathOpt ?? reducerPath;
2175
- injectable.inject({
2176
- reducerPath: newReducerPath,
2177
- reducer
2178
- }, config);
2179
- return {
2180
- ...slice,
2181
- ...makeSelectorProps(newReducerPath, true)
2182
- };
2183
- }
2184
- };
2185
- return slice;
2186
- };
2187
- }
2188
- function wrapSelector(selector, selectState, getInitialState, injected) {
2189
- function wrapper(rootState, ...args) {
2190
- let sliceState = selectState(rootState);
2191
- if (typeof sliceState === "undefined") {
2192
- if (injected) {
2193
- sliceState = getInitialState();
2194
- } else if (process.env.NODE_ENV !== "production") {
2195
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
2196
- }
2197
- }
2198
- return selector(sliceState, ...args);
2199
- }
2200
- wrapper.unwrapped = selector;
2201
- return wrapper;
2202
- }
2203
- var createSlice = /* @__PURE__ */ buildCreateSlice();
2204
- function buildReducerCreators() {
2205
- function asyncThunk(payloadCreator, config) {
2206
- return {
2207
- _reducerDefinitionType: "asyncThunk",
2208
- payloadCreator,
2209
- ...config
2210
- };
2211
- }
2212
- asyncThunk.withTypes = () => asyncThunk;
2213
- return {
2214
- reducer(caseReducer) {
2215
- return Object.assign({
2216
- // hack so the wrapping function has the same name as the original
2217
- // we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
2218
- [caseReducer.name](...args) {
2219
- return caseReducer(...args);
2220
- }
2221
- }[caseReducer.name], {
2222
- _reducerDefinitionType: "reducer"
2223
- /* reducer */
2224
- });
2225
- },
2226
- preparedReducer(prepare, reducer) {
2227
- return {
2228
- _reducerDefinitionType: "reducerWithPrepare",
2229
- prepare,
2230
- reducer
2231
- };
2232
- },
2233
- asyncThunk
2234
- };
2235
- }
2236
- function handleNormalReducerDefinition({
2237
- type,
2238
- reducerName,
2239
- createNotation
2240
- }, maybeReducerWithPrepare, context) {
2241
- let caseReducer;
2242
- let prepareCallback;
2243
- if ("reducer" in maybeReducerWithPrepare) {
2244
- if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
2245
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
2246
- }
2247
- caseReducer = maybeReducerWithPrepare.reducer;
2248
- prepareCallback = maybeReducerWithPrepare.prepare;
2249
- } else {
2250
- caseReducer = maybeReducerWithPrepare;
2251
- }
2252
- context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
2253
- }
2254
- function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
2255
- return reducerDefinition._reducerDefinitionType === "asyncThunk";
2256
- }
2257
- function isCaseReducerWithPrepareDefinition(reducerDefinition) {
2258
- return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
2259
- }
2260
- function handleThunkCaseReducerDefinition({
2261
- type,
2262
- reducerName
2263
- }, reducerDefinition, context, cAT) {
2264
- if (!cAT) {
2265
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(18) : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
2266
- }
2267
- const {
2268
- payloadCreator,
2269
- fulfilled,
2270
- pending,
2271
- rejected,
2272
- settled,
2273
- options
2274
- } = reducerDefinition;
2275
- const thunk = cAT(type, payloadCreator, options);
2276
- context.exposeAction(reducerName, thunk);
2277
- if (fulfilled) {
2278
- context.addCase(thunk.fulfilled, fulfilled);
2279
- }
2280
- if (pending) {
2281
- context.addCase(thunk.pending, pending);
2282
- }
2283
- if (rejected) {
2284
- context.addCase(thunk.rejected, rejected);
2285
- }
2286
- if (settled) {
2287
- context.addMatcher(thunk.settled, settled);
2288
- }
2289
- context.exposeCaseReducer(reducerName, {
2290
- fulfilled: fulfilled || noop,
2291
- pending: pending || noop,
2292
- rejected: rejected || noop,
2293
- settled: settled || noop
2294
- });
2295
- }
2296
- function noop() {
2297
- }
2298
- var listener = "listener";
2299
- var completed = "completed";
2300
- var cancelled = "cancelled";
2301
- var taskCancelled = `task-${cancelled}`;
2302
- var taskCompleted = `task-${completed}`;
2303
- var listenerCancelled = `${listener}-${cancelled}`;
2304
- var listenerCompleted = `${listener}-${completed}`;
2305
- var {
2306
- assign
2307
- } = Object;
2308
- var alm = "listenerMiddleware";
2309
- var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
2310
- withTypes: () => addListener
2311
- });
2312
- var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
2313
- var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
2314
- withTypes: () => removeListener
2315
- });
2316
- function formatProdErrorMessage(code) {
2317
- return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
2318
- }
2319
-
2320
811
  // src/redux/themeSlice.ts
2321
812
  var defaultInitialState = {
2322
813
  appearance: "system",
@@ -2324,27 +815,31 @@ var defaultInitialState = {
2324
815
  color: "#6750a4",
2325
816
  harmony: "split-complementary"
2326
817
  };
2327
- var reducers = {
2328
- initialize: (state, action) => ({ ...state, ...action.payload }),
2329
- setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
2330
- setBlur: (state, action) => ({ ...state, blur: action.payload }),
2331
- setColor: (state, action) => ({ ...state, color: action.payload }),
2332
- setHarmony: (state, action) => ({ ...state, harmony: action.payload })
818
+ var createAction = (type) => {
819
+ const actionCreator = (payload) => ({ payload, type });
820
+ actionCreator.type = type;
821
+ actionCreator.match = (action) => action.type === type;
822
+ return actionCreator;
823
+ };
824
+ var initialize = createAction("theme/initialize");
825
+ var setAppearance = createAction("theme/setAppearance");
826
+ var setBlur = createAction("theme/setBlur");
827
+ var setColor = createAction("theme/setColor");
828
+ var setHarmony = createAction("theme/setHarmony");
829
+ var themeActions = { initialize, setAppearance, setBlur, setColor, setHarmony };
830
+ var reduce = (state, action) => {
831
+ if (initialize.match(action)) return { ...state, ...action.payload };
832
+ if (setAppearance.match(action)) return { ...state, appearance: action.payload };
833
+ if (setBlur.match(action)) return { ...state, blur: action.payload };
834
+ if (setColor.match(action)) return { ...state, color: action.payload };
835
+ if (setHarmony.match(action)) return { ...state, harmony: action.payload };
836
+ return state;
2333
837
  };
2334
838
  function createThemeReducer(initialState) {
2335
- return createSlice({
2336
- name: "theme",
2337
- initialState: { ...defaultInitialState, ...initialState },
2338
- reducers
2339
- }).reducer;
839
+ const initial = { ...defaultInitialState, ...initialState };
840
+ return (state = initial, action) => reduce(state, action);
2340
841
  }
2341
- var defaultSlice = createSlice({
2342
- name: "theme",
2343
- initialState: defaultInitialState,
2344
- reducers
2345
- });
2346
- var themeActions = defaultSlice.actions;
2347
- var themeReducer = defaultSlice.reducer;
842
+ var themeReducer = (state = defaultInitialState, action) => reduce(state, action);
2348
843
  var selectThemeAppearance = (state) => state.appearance;
2349
844
  var selectThemeBlur = (state) => state.blur;
2350
845
  var selectThemeColor = (state) => state.color;
@@ -2353,6 +848,12 @@ var selectThemeHarmony = (state) => state.harmony;
2353
848
  // src/useThemeSettings.ts
2354
849
  import { useContext as useContext5 } from "react";
2355
850
  var useThemeSettings = () => useContext5(ThemeSettingsContext);
851
+
852
+ // src/utils/getTintTextColor.ts
853
+ var getTintTextColor = (tintColor, backdropColor, tintOpacity) => {
854
+ const blended = getBlendedColor(tintColor, backdropColor, tintOpacity);
855
+ return getTonalColor(tintColor, isDarkColor(blended) ? 0.92 : 0.12);
856
+ };
2356
857
  export {
2357
858
  Appbar,
2358
859
  AppearancePicker,
@@ -2375,6 +876,8 @@ export {
2375
876
  getBlendedColor,
2376
877
  getHex,
2377
878
  getRgb,
879
+ getTintTextColor,
880
+ getTonalColor,
2378
881
  getTriadicPalette,
2379
882
  isDarkColor,
2380
883
  selectThemeAppearance,