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