@rific/auto-paper 0.1.3 → 0.3.1

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
@@ -2,2031 +2,2383 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
 
5
- // src/components/Button.tsx
6
- import { Button as PaperButton } from "react-native-paper";
5
+ // src/BlurContext.tsx
6
+ import { useContext } from "react";
7
+
8
+ // src/ThemeSettingsContext.ts
9
+ import { createContext } from "react";
10
+ var defaultThemeSettings = {
11
+ appearance: "system",
12
+ blur: true,
13
+ blurTint: 0.2,
14
+ color: "#6750a4",
15
+ harmony: "split-complementary"
16
+ };
17
+ var ThemeSettingsContext = createContext({
18
+ settings: defaultThemeSettings,
19
+ set: () => {
20
+ }
21
+ });
22
+
23
+ // src/BlurContext.tsx
24
+ function useBlur(override) {
25
+ const { settings } = useContext(ThemeSettingsContext);
26
+ return override ?? settings.blur;
27
+ }
28
+
29
+ // src/components/Appbar.tsx
30
+ import { StatusBar } from "react-native";
31
+ import { Appbar as PaperAppbar, useTheme } from "react-native-paper";
7
32
 
8
33
  // src/PaperDefaultsContext.tsx
9
- import { createContext, useContext } from "react";
10
- var PaperDefaultsContext = createContext({});
34
+ import { createContext as createContext2, useContext as useContext2 } from "react";
35
+ var PaperDefaultsContext = createContext2({});
11
36
  function usePaperDefaults() {
12
- return useContext(PaperDefaultsContext);
37
+ return useContext2(PaperDefaultsContext);
13
38
  }
14
39
 
15
- // src/components/Button.tsx
16
- import { jsx } from "react/jsx-runtime";
17
- function Button(props) {
40
+ // src/components/Appbar.tsx
41
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
42
+ function Header({ style, ...props }) {
18
43
  const defaults = usePaperDefaults();
19
- return /* @__PURE__ */ jsx(PaperButton, { ...defaults.Button, ...props });
44
+ const theme = useTheme();
45
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
46
+ /* @__PURE__ */ jsx(StatusBar, { backgroundColor: theme.colors.surface, barStyle: theme.dark ? "light-content" : "dark-content" }),
47
+ /* @__PURE__ */ jsx(PaperAppbar.Header, { ...defaults.AppbarHeader, ...props, style })
48
+ ] });
20
49
  }
50
+ var Appbar = {
51
+ Header,
52
+ Content: PaperAppbar.Content,
53
+ Action: PaperAppbar.Action,
54
+ BackAction: PaperAppbar.BackAction
55
+ };
21
56
 
22
- // src/components/Chip.tsx
23
- import { Chip as PaperChip } from "react-native-paper";
57
+ // src/components/AppearancePicker.tsx
58
+ import { SegmentedButtons } from "react-native-paper";
24
59
  import { jsx as jsx2 } from "react/jsx-runtime";
25
- function Chip(props) {
26
- const defaults = usePaperDefaults();
27
- return /* @__PURE__ */ jsx2(PaperChip, { ...defaults.Chip, ...props });
28
- }
60
+ var APPEARANCES = [
61
+ { label: "System", value: "system", icon: "brightness-auto" },
62
+ { label: "Light", value: "light", icon: "white-balance-sunny" },
63
+ { label: "Dark", value: "dark", icon: "weather-night" }
64
+ ];
65
+ 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 })) });
29
66
 
30
- // src/components/FAB.tsx
31
- import { FAB as PaperFAB } from "react-native-paper";
32
- import { jsx as jsx3 } from "react/jsx-runtime";
33
- function FAB(props) {
34
- const defaults = usePaperDefaults();
35
- return /* @__PURE__ */ jsx3(PaperFAB, { ...defaults.FAB, ...props });
36
- }
67
+ // src/components/BlurView.tsx
68
+ import { BlurView as ExpoBlurView } from "expo-blur";
69
+ import { useContext as useContext3 } from "react";
70
+ import { StyleSheet, View } from "react-native";
71
+ import { useTheme as useTheme2 } from "react-native-paper";
72
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
73
+ 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 }) => {
75
+ const { dark, colors } = useTheme2();
76
+ 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)
80
+ return /* @__PURE__ */ jsxs2(ExpoBlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
81
+ /* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: colors.surface, opacity: settings.blurTint }] }),
82
+ tint,
83
+ children
84
+ ] });
85
+ return /* @__PURE__ */ jsxs2(View, { style: [{ backgroundColor: colors.surface }, style], children: [
86
+ tint,
87
+ children
88
+ ] });
89
+ };
37
90
 
38
- // src/components/IconButton.tsx
39
- import { IconButton as PaperIconButton } from "react-native-paper";
40
- import { jsx as jsx4 } from "react/jsx-runtime";
41
- function IconButton(props) {
42
- const defaults = usePaperDefaults();
43
- return /* @__PURE__ */ jsx4(PaperIconButton, { ...defaults.IconButton, ...props });
44
- }
91
+ // src/components/BottomNavigation.tsx
92
+ import { useEffect as useEffect3 } from "react";
93
+ import { Platform } from "react-native";
94
+ import { BottomNavigation as PaperBottomNavigation, useTheme as useTheme3 } from "react-native-paper";
45
95
 
46
- // src/components/TextInput.tsx
47
- import { forwardRef } from "react";
48
- import { TextInput as PaperTextInput } from "react-native-paper";
49
- import { jsx as jsx5 } from "react/jsx-runtime";
50
- var TextInput = forwardRef(function TextInput2(props, ref) {
51
- const defaults = usePaperDefaults();
52
- return /* @__PURE__ */ jsx5(PaperTextInput, { ref, ...defaults.TextInput, ...props });
53
- });
96
+ // src/ThemeProvider.tsx
97
+ import { createContext as createContext3, useCallback as useCallback2, useContext as useContext4, useEffect as useEffect2, useRef, useState as useState2 } from "react";
98
+ import { StatusBar as StatusBar2, StyleSheet as StyleSheet2, View as View2 } from "react-native";
99
+ import { Provider as PaperProvider } from "react-native-paper";
54
100
 
55
- // node_modules/redux/dist/redux.mjs
56
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
57
- var ActionTypes = {
58
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
59
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
60
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
101
+ // src/useComputedTheme.ts
102
+ import { useCallback, useEffect, useState } from "react";
103
+ import { Appearance } from "react-native";
104
+ import { MD3DarkTheme, MD3LightTheme } from "react-native-paper";
105
+
106
+ // src/utils/colorNames.ts
107
+ var colorNames = {
108
+ aliceblue: "#f0f8ff",
109
+ antiquewhite: "#faebd7",
110
+ aqua: "#00ffff",
111
+ aquamarine: "#7fffd4",
112
+ azure: "#f0ffff",
113
+ beige: "#f5f5dc",
114
+ bisque: "#ffe4c4",
115
+ black: "#000000",
116
+ blanchedalmond: "#ffebcd",
117
+ blue: "#0000ff",
118
+ blueviolet: "#8a2be2",
119
+ brown: "#a52a2a",
120
+ burlywood: "#deb887",
121
+ cadetblue: "#5f9ea0",
122
+ chartreuse: "#7fff00",
123
+ chocolate: "#d2691e",
124
+ coral: "#ff7f50",
125
+ cornflowerblue: "#6495ed",
126
+ cornsilk: "#fff8dc",
127
+ crimson: "#dc143c",
128
+ cyan: "#00ffff",
129
+ darkblue: "#00008b",
130
+ darkcyan: "#008b8b",
131
+ darkgoldenrod: "#b8860b",
132
+ darkgray: "#a9a9a9",
133
+ darkgrey: "#a9a9a9",
134
+ darkgreen: "#006400",
135
+ darkkhaki: "#bdb76b",
136
+ darkmagenta: "#8b008b",
137
+ darkolivegreen: "#556b2f",
138
+ darkorange: "#ff8c00",
139
+ darkorchid: "#9932cc",
140
+ darkred: "#8b0000",
141
+ darksalmon: "#e9967a",
142
+ darkseagreen: "#8fbc8f",
143
+ darkslateblue: "#483d8b",
144
+ darkslategray: "#2f4f4f",
145
+ darkslategrey: "#2f4f4f",
146
+ darkturquoise: "#00ced1",
147
+ darkviolet: "#9400d3",
148
+ deeppink: "#ff1493",
149
+ deepskyblue: "#00bfff",
150
+ dimgray: "#696969",
151
+ dimgrey: "#696969",
152
+ dodgerblue: "#1e90ff",
153
+ firebrick: "#b22222",
154
+ floralwhite: "#fffaf0",
155
+ forestgreen: "#228b22",
156
+ fuchsia: "#ff00ff",
157
+ gainsboro: "#dcdcdc",
158
+ ghostwhite: "#f8f8ff",
159
+ gold: "#ffd700",
160
+ goldenrod: "#daa520",
161
+ gray: "#808080",
162
+ grey: "#808080",
163
+ green: "#008000",
164
+ greenyellow: "#adff2f",
165
+ honeydew: "#f0fff0",
166
+ hotpink: "#ff69b4",
167
+ indianred: "#cd5c5c",
168
+ indigo: "#4b0082",
169
+ ivory: "#fffff0",
170
+ khaki: "#f0e68c",
171
+ lavender: "#e6e6fa",
172
+ lavenderblush: "#fff0f5",
173
+ lawngreen: "#7cfc00",
174
+ lemonchiffon: "#fffacd",
175
+ lightblue: "#add8e6",
176
+ lightcoral: "#f08080",
177
+ lightcyan: "#e0ffff",
178
+ lightgoldenrodyellow: "#fafad2",
179
+ lightgray: "#d3d3d3",
180
+ lightgrey: "#d3d3d3",
181
+ lightgreen: "#90ee90",
182
+ lightpink: "#ffb6c1",
183
+ lightsalmon: "#ffa07a",
184
+ lightseagreen: "#20b2aa",
185
+ lightskyblue: "#87cefa",
186
+ lightslategray: "#778899",
187
+ lightslategrey: "#778899",
188
+ lightsteelblue: "#b0c4de",
189
+ lightyellow: "#ffffe0",
190
+ lime: "#00ff00",
191
+ limegreen: "#32cd32",
192
+ linen: "#faf0e6",
193
+ magenta: "#ff00ff",
194
+ maroon: "#800000",
195
+ mediumaquamarine: "#66cdaa",
196
+ mediumblue: "#0000cd",
197
+ mediumorchid: "#ba55d3",
198
+ mediumpurple: "#9370db",
199
+ mediumseagreen: "#3cb371",
200
+ mediumslateblue: "#7b68ee",
201
+ mediumspringgreen: "#00fa9a",
202
+ mediumturquoise: "#48d1cc",
203
+ mediumvioletred: "#c71585",
204
+ midnightblue: "#191970",
205
+ mintcream: "#f5fffa",
206
+ mistyrose: "#ffe4e1",
207
+ moccasin: "#ffe4b5",
208
+ navajowhite: "#ffdead",
209
+ navy: "#000080",
210
+ oldlace: "#fdf5e6",
211
+ olive: "#808000",
212
+ olivedrab: "#6b8e23",
213
+ orange: "#ffa500",
214
+ orangered: "#ff4500",
215
+ orchid: "#da70d6",
216
+ palegoldenrod: "#eee8aa",
217
+ palegreen: "#98fb98",
218
+ paleturquoise: "#afeeee",
219
+ palevioletred: "#db7093",
220
+ papayawhip: "#ffefd5",
221
+ peachpuff: "#ffdab9",
222
+ peru: "#cd853f",
223
+ pink: "#ffc0cb",
224
+ plum: "#dda0dd",
225
+ powderblue: "#b0e0e6",
226
+ purple: "#800080",
227
+ rebeccapurple: "#663399",
228
+ red: "#ff0000",
229
+ rosybrown: "#bc8f8f",
230
+ royalblue: "#4169e1",
231
+ saddlebrown: "#8b4513",
232
+ salmon: "#fa8072",
233
+ sandybrown: "#f4a460",
234
+ seagreen: "#2e8b57",
235
+ seashell: "#fff5ee",
236
+ sienna: "#a0522d",
237
+ silver: "#c0c0c0",
238
+ skyblue: "#87ceeb",
239
+ slateblue: "#6a5acd",
240
+ slategray: "#708090",
241
+ slategrey: "#708090",
242
+ snow: "#fffafa",
243
+ springgreen: "#00ff7f",
244
+ steelblue: "#4682b4",
245
+ tan: "#d2b48c",
246
+ teal: "#008080",
247
+ thistle: "#d8bfd8",
248
+ tomato: "#ff6347",
249
+ transparent: "transparent",
250
+ turquoise: "#40e0d0",
251
+ violet: "#ee82ee",
252
+ wheat: "#f5deb3",
253
+ white: "#ffffff",
254
+ whitesmoke: "#f5f5f5",
255
+ yellow: "#ffff00",
256
+ yellowgreen: "#9acd32"
61
257
  };
62
- function isPlainObject(obj) {
63
- if (typeof obj !== "object" || obj === null)
64
- return false;
65
- let proto = obj;
66
- while (Object.getPrototypeOf(proto) !== null) {
67
- proto = Object.getPrototypeOf(proto);
258
+
259
+ // src/utils/getRgb.ts
260
+ var getRgb = (value) => {
261
+ if (!value) return null;
262
+ let trimmed = value.trim().toLowerCase();
263
+ const namedColor = colorNames[trimmed];
264
+ if (namedColor) trimmed = namedColor;
265
+ const hexMatch = trimmed.match(/^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i);
266
+ if (hexMatch) {
267
+ const hex = hexMatch[1];
268
+ let normalized = hex;
269
+ if (hex.length === 3) {
270
+ normalized = hex.split("").map((c) => c + c).join("");
271
+ } else if (hex.length === 8) {
272
+ const alpha = parseInt(hex.substring(6, 8), 16);
273
+ normalized = hex.substring(0, 6);
274
+ const intVal2 = parseInt(normalized, 16);
275
+ return {
276
+ r: intVal2 >> 16 & 255,
277
+ g: intVal2 >> 8 & 255,
278
+ b: intVal2 & 255,
279
+ a: alpha / 255
280
+ };
281
+ }
282
+ const intVal = parseInt(normalized, 16);
283
+ return {
284
+ r: intVal >> 16 & 255,
285
+ g: intVal >> 8 & 255,
286
+ b: intVal & 255
287
+ };
68
288
  }
69
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
70
- }
71
- function compose(...funcs) {
72
- if (funcs.length === 0) {
73
- return (arg) => arg;
289
+ const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*([0-9.]+))?\s*\)$/i);
290
+ if (rgbMatch) {
291
+ const result = {
292
+ r: Number(rgbMatch[1]),
293
+ g: Number(rgbMatch[2]),
294
+ b: Number(rgbMatch[3])
295
+ };
296
+ if (rgbMatch[4] !== void 0) {
297
+ result.a = Number(rgbMatch[4]);
298
+ }
299
+ return result;
74
300
  }
75
- if (funcs.length === 1) {
76
- return funcs[0];
77
- }
78
- return funcs.reduce((a, b) => (...args) => a(b(...args)));
79
- }
80
- function isAction(action) {
81
- return isPlainObject(action) && "type" in action && typeof action.type === "string";
82
- }
301
+ return null;
302
+ };
83
303
 
84
- // node_modules/immer/dist/immer.mjs
85
- var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
86
- var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
87
- var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
88
- var errors = process.env.NODE_ENV !== "production" ? [
89
- // All error codes, starting by 0:
90
- function(plugin) {
91
- return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
92
- },
93
- function(thing) {
94
- 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}'`;
95
- },
96
- "This object has been frozen and should not be mutated",
97
- function(data) {
98
- return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
99
- },
100
- "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
101
- "Immer forbids circular references",
102
- "The first or second argument to `produce` must be a function",
103
- "The third argument to `produce` must be a function or undefined",
104
- "First argument to `createDraft` must be a plain object, an array, or an immerable object",
105
- "First argument to `finishDraft` must be a draft returned by `createDraft`",
106
- function(thing) {
107
- return `'current' expects a draft, got: ${thing}`;
108
- },
109
- "Object.defineProperty() cannot be used on an Immer draft",
110
- "Object.setPrototypeOf() cannot be used on an Immer draft",
111
- "Immer only supports deleting array indices",
112
- "Immer only supports setting array indices and the 'length' property",
113
- function(thing) {
114
- return `'original' expects a draft, got: ${thing}`;
115
- }
116
- // Note: if more errors are added, the errorOffset in Patches.ts should be increased
117
- // See Patches.ts for additional errors
118
- ] : [];
119
- function die(error, ...args) {
120
- if (process.env.NODE_ENV !== "production") {
121
- const e = errors[error];
122
- const msg = isFunction(e) ? e.apply(null, args) : e;
123
- throw new Error(`[Immer] ${msg}`);
304
+ // src/utils/getHex.ts
305
+ var getHex = (value) => {
306
+ const rgb = getRgb(value);
307
+ if (!rgb) return null;
308
+ const toHex = (n) => {
309
+ const hex = Math.round(n).toString(16);
310
+ return hex.length === 1 ? "0" + hex : hex;
311
+ };
312
+ const hexString = `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`;
313
+ if (rgb.a !== void 0) {
314
+ return `${hexString}${toHex(rgb.a * 255)}`;
124
315
  }
125
- throw new Error(
126
- `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
127
- );
128
- }
129
- var O = Object;
130
- var getPrototypeOf = O.getPrototypeOf;
131
- var CONSTRUCTOR = "constructor";
132
- var PROTOTYPE = "prototype";
133
- var CONFIGURABLE = "configurable";
134
- var ENUMERABLE = "enumerable";
135
- var WRITABLE = "writable";
136
- var VALUE = "value";
137
- var isDraft = (value) => !!value && !!value[DRAFT_STATE];
138
- function isDraftable(value) {
139
- if (!value)
140
- return false;
141
- return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
142
- }
143
- var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
144
- var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
145
- function isPlainObject2(value) {
146
- if (!value || !isObjectish(value))
147
- return false;
148
- const proto = getPrototypeOf(value);
149
- if (proto === null || proto === O[PROTOTYPE])
150
- return true;
151
- const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
152
- if (Ctor === Object)
153
- return true;
154
- if (!isFunction(Ctor))
155
- return false;
156
- let ctorString = cachedCtorStrings.get(Ctor);
157
- if (ctorString === void 0) {
158
- ctorString = Function.toString.call(Ctor);
159
- cachedCtorStrings.set(Ctor, ctorString);
316
+ return hexString;
317
+ };
318
+
319
+ // src/utils/getBlendedColor.ts
320
+ var getBlendedColor = (foreground, background, alpha) => {
321
+ const fg = getRgb(foreground);
322
+ const bg = getRgb(background);
323
+ if (!fg || !bg) return background;
324
+ const safeAlpha = Math.min(1, Math.max(0, alpha));
325
+ const r = Math.round(fg.r * safeAlpha + bg.r * (1 - safeAlpha));
326
+ const g = Math.round(fg.g * safeAlpha + bg.g * (1 - safeAlpha));
327
+ const b = Math.round(fg.b * safeAlpha + bg.b * (1 - safeAlpha));
328
+ return getHex(`rgb(${r}, ${g}, ${b})`) ?? background;
329
+ };
330
+
331
+ // src/utils/getTonalColor.ts
332
+ var getTonalColor = (color, lightness) => {
333
+ const rgb = getRgb(color);
334
+ if (!rgb) return color;
335
+ const r = rgb.r / 255;
336
+ const g = rgb.g / 255;
337
+ const b = rgb.b / 255;
338
+ const max = Math.max(r, g, b);
339
+ const min = Math.min(r, g, b);
340
+ const delta = max - min;
341
+ let h = 0;
342
+ if (delta !== 0) {
343
+ if (max === r) h = (g - b) / delta % 6;
344
+ else if (max === g) h = (b - r) / delta + 2;
345
+ else h = (r - g) / delta + 4;
346
+ h = (h * 60 + 360) % 360;
160
347
  }
161
- return ctorString === objectCtorString;
162
- }
163
- function each(obj, iter, strict = true) {
164
- if (getArchtype(obj) === 0) {
165
- const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
166
- keys.forEach((key) => {
167
- iter(key, obj[key], obj);
168
- });
348
+ const l = (max + min) / 2;
349
+ const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
350
+ const targetL = Math.min(1, Math.max(0, lightness));
351
+ const c = (1 - Math.abs(2 * targetL - 1)) * s;
352
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
353
+ const m = targetL - c / 2;
354
+ let r2 = 0, g2 = 0, b2 = 0;
355
+ if (h < 60) {
356
+ r2 = c;
357
+ g2 = x;
358
+ b2 = 0;
359
+ } else if (h < 120) {
360
+ r2 = x;
361
+ g2 = c;
362
+ b2 = 0;
363
+ } else if (h < 180) {
364
+ r2 = 0;
365
+ g2 = c;
366
+ b2 = x;
367
+ } else if (h < 240) {
368
+ r2 = 0;
369
+ g2 = x;
370
+ b2 = c;
371
+ } else if (h < 300) {
372
+ r2 = x;
373
+ g2 = 0;
374
+ b2 = c;
169
375
  } else {
170
- obj.forEach((entry, index) => iter(index, entry, obj));
376
+ r2 = c;
377
+ g2 = 0;
378
+ b2 = x;
171
379
  }
172
- }
173
- function getArchtype(thing) {
174
- const state = thing[DRAFT_STATE];
175
- return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
176
- }
177
- var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
178
- var get = (thing, prop, type = getArchtype(thing)) => (
179
- // @ts-ignore
180
- type === 2 ? thing.get(prop) : thing[prop]
181
- );
182
- var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
183
- if (type === 2)
184
- thing.set(propOrOldValue, value);
185
- else if (type === 3) {
186
- thing.add(value);
187
- } else
188
- thing[propOrOldValue] = value;
380
+ const toInt = (n) => Math.round((n + m) * 255);
381
+ return getHex(`rgb(${toInt(r2)}, ${toInt(g2)}, ${toInt(b2)})`) ?? color;
189
382
  };
190
- function is(x, y) {
191
- if (x === y) {
192
- return x !== 0 || 1 / x === 1 / y;
193
- } else {
194
- return x !== x && y !== y;
383
+
384
+ // src/utils/getTriadicPalette.ts
385
+ var HARMONY_OFFSETS = {
386
+ analogous: [1 / 12, 2 / 12],
387
+ complementary: [1 / 4, 1 / 2],
388
+ "double-split": [1 / 12, 11 / 12],
389
+ "split-complementary": [5 / 12, 7 / 12],
390
+ square: [1 / 4, 3 / 4],
391
+ triadic: [1 / 3, 2 / 3]
392
+ };
393
+ function getTriadicPalette(primaryColor, harmony = "split-complementary") {
394
+ const rgb = getRgb(primaryColor);
395
+ if (!rgb) throw new Error(`Invalid color format: ${primaryColor}`);
396
+ const r = rgb.r / 255;
397
+ const g = rgb.g / 255;
398
+ const b = rgb.b / 255;
399
+ const max = Math.max(r, g, b);
400
+ const min = Math.min(r, g, b);
401
+ const l = (max + min) / 2;
402
+ let h = 0;
403
+ let s = 0;
404
+ if (max !== min) {
405
+ const d = max - min;
406
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
407
+ switch (max) {
408
+ case r:
409
+ h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
410
+ break;
411
+ case g:
412
+ h = ((b - r) / d + 2) / 6;
413
+ break;
414
+ case b:
415
+ h = ((r - g) / d + 4) / 6;
416
+ break;
417
+ }
195
418
  }
419
+ const [o1, o2] = HARMONY_OFFSETS[harmony];
420
+ return {
421
+ primary: getHex(primaryColor) ?? primaryColor,
422
+ secondary: hslToHex((h + o1) % 1, s, l),
423
+ tertiary: hslToHex((h + o2) % 1, s, l)
424
+ };
196
425
  }
197
- var isArray = Array.isArray;
198
- var isMap = (target) => target instanceof Map;
199
- var isSet = (target) => target instanceof Set;
200
- var isObjectish = (target) => typeof target === "object";
201
- var isFunction = (target) => typeof target === "function";
202
- var isBoolean = (target) => typeof target === "boolean";
203
- function isArrayIndex(value) {
204
- const n = +value;
205
- return Number.isInteger(n) && String(n) === value;
206
- }
207
- var latest = (state) => state.copy_ || state.base_;
208
- var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
209
- function shallowCopy(base, strict) {
210
- if (isMap(base)) {
211
- return new Map(base);
212
- }
213
- if (isSet(base)) {
214
- return new Set(base);
215
- }
216
- if (isArray(base))
217
- return Array[PROTOTYPE].slice.call(base);
218
- const isPlain = isPlainObject2(base);
219
- if (strict === true || strict === "class_only" && !isPlain) {
220
- const descriptors = O.getOwnPropertyDescriptors(base);
221
- delete descriptors[DRAFT_STATE];
222
- let keys = Reflect.ownKeys(descriptors);
223
- for (let i = 0; i < keys.length; i++) {
224
- const key = keys[i];
225
- const desc = descriptors[key];
226
- if (desc[WRITABLE] === false) {
227
- desc[WRITABLE] = true;
228
- desc[CONFIGURABLE] = true;
229
- }
230
- if (desc.get || desc.set)
231
- descriptors[key] = {
232
- [CONFIGURABLE]: true,
233
- [WRITABLE]: true,
234
- // could live with !!desc.set as well here...
235
- [ENUMERABLE]: desc[ENUMERABLE],
236
- [VALUE]: base[key]
237
- };
238
- }
239
- return O.create(getPrototypeOf(base), descriptors);
426
+ function hslToHex(h, s, l) {
427
+ const c = (1 - Math.abs(2 * l - 1)) * s;
428
+ const x = c * (1 - Math.abs(h * 6 % 2 - 1));
429
+ const m = l - c / 2;
430
+ let r = 0;
431
+ let g = 0;
432
+ let b = 0;
433
+ if (h < 1 / 6) {
434
+ r = c;
435
+ g = x;
436
+ b = 0;
437
+ } else if (h < 2 / 6) {
438
+ r = x;
439
+ g = c;
440
+ b = 0;
441
+ } else if (h < 3 / 6) {
442
+ r = 0;
443
+ g = c;
444
+ b = x;
445
+ } else if (h < 4 / 6) {
446
+ r = 0;
447
+ g = x;
448
+ b = c;
449
+ } else if (h < 5 / 6) {
450
+ r = x;
451
+ g = 0;
452
+ b = c;
240
453
  } else {
241
- const proto = getPrototypeOf(base);
242
- if (proto !== null && isPlain) {
243
- return { ...base };
244
- }
245
- const obj = O.create(proto);
246
- return O.assign(obj, base);
454
+ r = c;
455
+ g = 0;
456
+ b = x;
247
457
  }
458
+ const toHex = (value) => {
459
+ const hex = Math.round((value + m) * 255).toString(16);
460
+ return hex.length === 1 ? `0${hex}` : hex;
461
+ };
462
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
248
463
  }
249
- function freeze(obj, deep = false) {
250
- if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
251
- return obj;
252
- if (getArchtype(obj) > 1) {
253
- O.defineProperties(obj, {
254
- set: dontMutateMethodOverride,
255
- add: dontMutateMethodOverride,
256
- clear: dontMutateMethodOverride,
257
- delete: dontMutateMethodOverride
258
- });
259
- }
260
- O.freeze(obj);
261
- if (deep)
262
- each(
263
- obj,
264
- (_key, value) => {
265
- freeze(value, true);
266
- },
267
- false
268
- );
269
- return obj;
270
- }
271
- function dontMutateFrozenCollections() {
272
- die(2);
273
- }
274
- var dontMutateMethodOverride = {
275
- [VALUE]: dontMutateFrozenCollections
464
+
465
+ // src/utils/isDarkColor.ts
466
+ var isDarkColor = (value) => {
467
+ const rgb = getRgb(value);
468
+ if (!rgb) return false;
469
+ const [r, g, b] = [rgb.r / 255, rgb.g / 255, rgb.b / 255];
470
+ const [rs, gs, bs] = [r, g, b].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
471
+ const luminance = 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
472
+ return luminance < 0.5;
276
473
  };
277
- function isFrozen(obj) {
278
- if (obj === null || !isObjectish(obj))
279
- return true;
280
- return O.isFrozen(obj);
474
+
475
+ // src/useComputedTheme.ts
476
+ function useComputedTheme(appearance, color, harmony = "split-complementary") {
477
+ const [theme, setTheme] = useState(null);
478
+ const computeTheme = useCallback(() => {
479
+ let resolved = appearance;
480
+ if (resolved === "system") resolved = Appearance.getColorScheme();
481
+ if (resolved === "no-preference" || !resolved) resolved = "light";
482
+ const base = resolved === "dark" ? MD3DarkTheme : MD3LightTheme;
483
+ const _theme = {
484
+ ...base,
485
+ colors: {
486
+ ...base.colors,
487
+ elevation: { ...base.colors.elevation }
488
+ }
489
+ };
490
+ const palette = getTriadicPalette(color, harmony);
491
+ const surface = base.colors.surface;
492
+ _theme.colors.primary = palette.primary;
493
+ _theme.colors.onPrimary = getTonalColor(palette.primary, isDarkColor(palette.primary) ? 0.95 : 0.08);
494
+ _theme.colors.primaryContainer = getBlendedColor(palette.primary, surface, 0.15);
495
+ _theme.colors.onPrimaryContainer = getTonalColor(palette.primary, isDarkColor(_theme.colors.primaryContainer) ? 0.92 : 0.12);
496
+ _theme.colors.secondary = palette.secondary;
497
+ _theme.colors.onSecondary = getTonalColor(palette.secondary, isDarkColor(palette.secondary) ? 0.95 : 0.08);
498
+ _theme.colors.secondaryContainer = getBlendedColor(palette.secondary, surface, 0.15);
499
+ _theme.colors.onSecondaryContainer = getTonalColor(palette.secondary, isDarkColor(_theme.colors.secondaryContainer) ? 0.92 : 0.12);
500
+ _theme.colors.tertiary = palette.tertiary;
501
+ _theme.colors.onTertiary = getTonalColor(palette.tertiary, isDarkColor(palette.tertiary) ? 0.95 : 0.08);
502
+ _theme.colors.tertiaryContainer = getBlendedColor(palette.tertiary, surface, 0.15);
503
+ _theme.colors.onTertiaryContainer = getTonalColor(palette.tertiary, isDarkColor(_theme.colors.tertiaryContainer) ? 0.92 : 0.12);
504
+ const blended = getBlendedColor(color, palette.secondary, 0.5);
505
+ const tintSurface = (alpha) => getBlendedColor(blended, surface, alpha);
506
+ _theme.colors.background = base.dark ? "#0F0F0F" : "#F0F0F0";
507
+ _theme.colors.surface = surface;
508
+ _theme.colors.surfaceVariant = tintSurface(0.2);
509
+ _theme.colors.outline = getBlendedColor(color, base.colors.outline, 0.45);
510
+ const grey = base.dark ? "#424242" : "#c2c2c2";
511
+ const blendedGrey = getBlendedColor(blended, grey, 0.05);
512
+ _theme.colors.elevation = {
513
+ ..._theme.colors.elevation,
514
+ level1: _theme.colors.surface,
515
+ level2: getBlendedColor(blendedGrey, _theme.colors.surface, 0.25),
516
+ level3: getBlendedColor(blendedGrey, _theme.colors.surface, 0.4),
517
+ level4: getBlendedColor(blendedGrey, _theme.colors.surface, 0.55),
518
+ level5: getBlendedColor(blendedGrey, _theme.colors.surface, 0.7)
519
+ };
520
+ setTheme(_theme);
521
+ }, [appearance, color, harmony]);
522
+ useEffect(() => {
523
+ computeTheme();
524
+ }, [computeTheme]);
525
+ useEffect(() => {
526
+ const subscription = Appearance.addChangeListener(computeTheme);
527
+ return subscription.remove;
528
+ }, [computeTheme]);
529
+ return theme;
281
530
  }
282
- var PluginMapSet = "MapSet";
283
- var PluginPatches = "Patches";
284
- var PluginArrayMethods = "ArrayMethods";
285
- var plugins = {};
286
- function getPlugin(pluginKey) {
287
- const plugin = plugins[pluginKey];
288
- if (!plugin) {
289
- die(0, pluginKey);
290
- }
291
- return plugin;
531
+
532
+ // src/ThemeProvider.tsx
533
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
534
+ var NavBarContext = createContext3({});
535
+ var useNavBarContext = () => useContext4(NavBarContext);
536
+ function Provider({ overrides, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
537
+ const [settings, setSettings] = useState2(() => ({ ...defaultThemeSettings, ...overrides }));
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
+ );
548
+ const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
549
+ const called = useRef(false);
550
+ useEffect2(() => {
551
+ if (theme && !called.current) {
552
+ called.current = true;
553
+ onReady?.();
554
+ }
555
+ }, [theme, onReady]);
556
+ if (!theme) return null;
557
+ return /* @__PURE__ */ jsx4(ThemeSettingsContext.Provider, { value: { settings, set: set2 }, children: /* @__PURE__ */ jsxs3(PaperProvider, { theme, children: [
558
+ /* @__PURE__ */ jsx4(StatusBar2, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
559
+ /* @__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
+ ] }) });
292
561
  }
293
- var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
294
- var currentScope;
295
- var getCurrentScope = () => currentScope;
296
- var createScope = (parent_, immer_) => ({
297
- drafts_: [],
298
- parent_,
299
- immer_,
300
- // Whenever the modified draft contains a draft from another scope, we
301
- // need to prevent auto-freezing so the unowned draft can be finalized.
302
- canAutoFreeze_: true,
303
- unfinalizedDrafts_: 0,
304
- handledSet_: /* @__PURE__ */ new Set(),
305
- processedForPatches_: /* @__PURE__ */ new Set(),
306
- mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
307
- arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
562
+ var styles = StyleSheet2.create({
563
+ flex: { flex: 1 }
308
564
  });
309
- function usePatchesInScope(scope, patchListener) {
310
- if (patchListener) {
311
- scope.patchPlugin_ = getPlugin(PluginPatches);
312
- scope.patches_ = [];
313
- scope.inversePatches_ = [];
314
- scope.patchListener_ = patchListener;
315
- }
565
+
566
+ // src/components/BottomNavigation.tsx
567
+ import { jsx as jsx5 } from "react/jsx-runtime";
568
+ function useNavigationBarSync() {
569
+ const theme = useTheme3();
570
+ const { onNavBarChange } = useNavBarContext();
571
+ useEffect3(() => {
572
+ if (Platform.OS !== "android" || !onNavBarChange) return;
573
+ onNavBarChange(theme.colors.surface, theme.dark);
574
+ }, [theme, onNavBarChange]);
575
+ }
576
+ function BottomNavigationComponent(props) {
577
+ const defaults = usePaperDefaults();
578
+ useNavigationBarSync();
579
+ return /* @__PURE__ */ jsx5(PaperBottomNavigation, { ...defaults.BottomNavigation, ...props });
316
580
  }
317
- function revokeScope(scope) {
318
- leaveScope(scope);
319
- scope.drafts_.forEach(revokeDraft);
320
- scope.drafts_ = null;
581
+ function Bar(props) {
582
+ useNavigationBarSync();
583
+ return /* @__PURE__ */ jsx5(PaperBottomNavigation.Bar, { ...props });
321
584
  }
322
- function leaveScope(scope) {
323
- if (scope === currentScope) {
324
- currentScope = scope.parent_;
325
- }
585
+ BottomNavigationComponent.Bar = Bar;
586
+ BottomNavigationComponent.SceneMap = PaperBottomNavigation.SceneMap;
587
+ var BottomNavigation = BottomNavigationComponent;
588
+
589
+ // src/components/Button.tsx
590
+ import { Button as PaperButton } from "react-native-paper";
591
+ import { jsx as jsx6 } from "react/jsx-runtime";
592
+ function Button(props) {
593
+ const defaults = usePaperDefaults();
594
+ return /* @__PURE__ */ jsx6(PaperButton, { ...defaults.Button, ...props });
326
595
  }
327
- var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
328
- function revokeDraft(draft) {
329
- const state = draft[DRAFT_STATE];
330
- if (state.type_ === 0 || state.type_ === 1)
331
- state.revoke_();
332
- else
333
- state.revoked_ = true;
596
+
597
+ // src/components/Chip.tsx
598
+ import { Chip as PaperChip } from "react-native-paper";
599
+ import { jsx as jsx7 } from "react/jsx-runtime";
600
+ function Chip(props) {
601
+ const defaults = usePaperDefaults();
602
+ return /* @__PURE__ */ jsx7(PaperChip, { ...defaults.Chip, ...props });
334
603
  }
335
- function processResult(result, scope) {
336
- scope.unfinalizedDrafts_ = scope.drafts_.length;
337
- const baseDraft = scope.drafts_[0];
338
- const isReplaced = result !== void 0 && result !== baseDraft;
339
- if (isReplaced) {
340
- if (baseDraft[DRAFT_STATE].modified_) {
341
- revokeScope(scope);
342
- die(4);
343
- }
344
- if (isDraftable(result)) {
345
- result = finalize(scope, result);
604
+
605
+ // src/components/ColorPicker.tsx
606
+ import { useState as useState4 } from "react";
607
+ import { StyleSheet as StyleSheet4, TouchableOpacity, View as View4 } from "react-native";
608
+ import { Icon, TouchableRipple } from "react-native-paper";
609
+
610
+ // src/components/Dialog.tsx
611
+ import { useEffect as useEffect4, useRef as useRef2, useState as useState3 } from "react";
612
+ import { Animated, StyleSheet as StyleSheet3, TouchableWithoutFeedback, View as View3 } from "react-native";
613
+ import { Dialog as PaperDialog, Portal, useTheme as useTheme4 } from "react-native-paper";
614
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
615
+ function DialogComponent({ blur: blurProp, visible, onDismiss, children, style, ...rest }) {
616
+ const blur = useBlur(blurProp);
617
+ const { roundness, colors } = useTheme4();
618
+ const opacity = useRef2(new Animated.Value(0)).current;
619
+ const [mounted, setMounted] = useState3(visible);
620
+ useEffect4(() => {
621
+ if (visible) {
622
+ setMounted(true);
623
+ Animated.timing(opacity, { toValue: 1, duration: 200, useNativeDriver: true }).start();
624
+ } else {
625
+ Animated.timing(opacity, { toValue: 0, duration: 150, useNativeDriver: true }).start(() => setMounted(false));
346
626
  }
347
- const { patchPlugin_ } = scope;
348
- if (patchPlugin_) {
349
- patchPlugin_.generateReplacementPatches_(
350
- baseDraft[DRAFT_STATE].base_,
351
- result,
352
- scope
353
- );
627
+ }, [visible]);
628
+ if (!blur) {
629
+ return /* @__PURE__ */ jsx8(PaperDialog, { visible, onDismiss, style, ...rest, children });
630
+ }
631
+ if (!mounted) return null;
632
+ return /* @__PURE__ */ jsx8(Portal, { children: /* @__PURE__ */ jsxs4(Animated.View, { style: [StyleSheet3.absoluteFill, { opacity }], pointerEvents: visible ? "box-none" : "none", children: [
633
+ /* @__PURE__ */ jsx8(TouchableWithoutFeedback, { onPress: onDismiss, children: /* @__PURE__ */ jsx8(View3, { style: [StyleSheet3.absoluteFill, { backgroundColor: colors.backdrop }] }) }),
634
+ /* @__PURE__ */ jsx8(View3, { style: styles2.wrapper, pointerEvents: "box-none", children: /* @__PURE__ */ jsx8(BlurView, { style: [styles2.card, { borderRadius: roundness * 7 }], children }) })
635
+ ] }) });
636
+ }
637
+ DialogComponent.Title = PaperDialog.Title;
638
+ DialogComponent.Content = PaperDialog.Content;
639
+ DialogComponent.Actions = PaperDialog.Actions;
640
+ DialogComponent.ScrollArea = PaperDialog.ScrollArea;
641
+ var Dialog = DialogComponent;
642
+ var styles2 = StyleSheet3.create({
643
+ card: { overflow: "hidden" },
644
+ wrapper: { flex: 1, justifyContent: "center", paddingHorizontal: 26 }
645
+ });
646
+
647
+ // src/components/ColorPicker.tsx
648
+ import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
649
+ var defaultColors = [
650
+ { label: "Red", value: "#f44336" },
651
+ { label: "Coral", value: "#ff5722" },
652
+ { label: "Orange", value: "#ff6d00" },
653
+ { label: "Amber", value: "#ff9800" },
654
+ { label: "Yellow", value: "#fdd835" },
655
+ { label: "Lime", value: "#8bc34a" },
656
+ { label: "Emerald", value: "#4caf50" },
657
+ { label: "Teal", value: "#009688" },
658
+ { label: "Cyan", value: "#00bcd4" },
659
+ { label: "Blue", value: "#2196f3" },
660
+ { label: "Indigo", value: "#3f51b5" },
661
+ { label: "Deep Purple", value: "#673ab7" },
662
+ { label: "Violet", value: "#9c27b0" },
663
+ { label: "Magenta", value: "#d500f9" },
664
+ { label: "Pink", value: "#ec407a" },
665
+ { label: "Rose", value: "#e91e63" },
666
+ { label: "Brown", value: "#795548" },
667
+ { label: "Blue Grey", value: "#607d8b" }
668
+ ];
669
+ var ColorPicker = ({ value, onChange, colors = defaultColors, blur: blurProp }) => {
670
+ const blur = useBlur(blurProp);
671
+ const [open, setOpen] = useState4(false);
672
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
673
+ /* @__PURE__ */ jsx9(TouchableRipple, { onPress: () => setOpen(true), style: [styles3.trigger, { backgroundColor: value }], borderless: true, children: /* @__PURE__ */ jsx9(Icon, { source: "palette", size: 20, color: "white" }) }),
674
+ /* @__PURE__ */ jsx9(Dialog, { blur, visible: open, onDismiss: () => setOpen(false), children: /* @__PURE__ */ jsx9(Dialog.Content, { children: /* @__PURE__ */ jsx9(View4, { style: styles3.swatches, children: colors.map(({ value: hex }) => /* @__PURE__ */ jsx9(
675
+ TouchableOpacity,
676
+ {
677
+ onPress: () => {
678
+ onChange(hex);
679
+ setOpen(false);
680
+ },
681
+ style: [styles3.swatch, { backgroundColor: hex }, value === hex && styles3.selected],
682
+ children: value === hex && /* @__PURE__ */ jsx9(Icon, { source: "check", size: 20, color: "white" })
683
+ },
684
+ hex
685
+ )) }) }) })
686
+ ] });
687
+ };
688
+ var styles3 = StyleSheet4.create({
689
+ selected: { borderColor: "white", borderWidth: 3 },
690
+ swatch: { alignItems: "center", borderRadius: 24, height: 48, justifyContent: "center", width: 48 },
691
+ swatches: { flexDirection: "row", flexWrap: "wrap", gap: 12, paddingTop: 12 },
692
+ trigger: { alignItems: "center", alignSelf: "flex-start", borderRadius: 24, height: 48, justifyContent: "center", width: 48 }
693
+ });
694
+
695
+ // src/components/FAB.tsx
696
+ import { FAB as PaperFAB } from "react-native-paper";
697
+ import { jsx as jsx10 } from "react/jsx-runtime";
698
+ function FAB(props) {
699
+ const defaults = usePaperDefaults();
700
+ return /* @__PURE__ */ jsx10(PaperFAB, { ...defaults.FAB, ...props });
701
+ }
702
+
703
+ // src/components/HarmonyPicker.tsx
704
+ import { useState as useState5 } from "react";
705
+ import { Button as Button2 } from "react-native-paper";
706
+
707
+ // src/components/Menu.tsx
708
+ import { StyleSheet as StyleSheet5 } from "react-native";
709
+ import { Menu as PaperMenu } from "react-native-paper";
710
+ import { jsx as jsx11 } from "react/jsx-runtime";
711
+ var MenuComponent = ({ blur: blurProp, children, ...props }) => {
712
+ const blur = useBlur(blurProp);
713
+ return /* @__PURE__ */ jsx11(PaperMenu, { ...props, contentStyle: [styles4.content, props.contentStyle], children: /* @__PURE__ */ jsx11(BlurView, { blur, children }) });
714
+ };
715
+ var Menu = Object.assign(MenuComponent, {
716
+ Item: PaperMenu.Item
717
+ });
718
+ var styles4 = StyleSheet5.create({
719
+ content: { backgroundColor: "transparent", paddingVertical: 0 }
720
+ });
721
+
722
+ // src/components/HarmonyPicker.tsx
723
+ import { jsx as jsx12 } from "react/jsx-runtime";
724
+ var HARMONIES = [
725
+ { label: "Triadic", value: "triadic", icon: "triangle-outline" },
726
+ { label: "Split", value: "split-complementary", icon: "arrow-split-vertical" },
727
+ { label: "Analogous", value: "analogous", icon: "ray-end-arrow" },
728
+ { label: "Square", value: "square", icon: "square-outline" },
729
+ { label: "Complement", value: "complementary", icon: "circle-half-full" },
730
+ { label: "Dbl Split", value: "double-split", icon: "arrow-expand-horizontal" }
731
+ ];
732
+ var HarmonyPicker = ({ value, onChange, blur: blurProp }) => {
733
+ const blur = useBlur(blurProp);
734
+ const [open, setOpen] = useState5(false);
735
+ const selected = HARMONIES.find((h) => h.value === value);
736
+ return /* @__PURE__ */ jsx12(
737
+ Menu,
738
+ {
739
+ blur,
740
+ visible: open,
741
+ onDismiss: () => setOpen(false),
742
+ anchor: /* @__PURE__ */ jsx12(Button2, { mode: "outlined", icon: selected.icon, onPress: () => setOpen(true), children: selected.label }),
743
+ children: HARMONIES.map((h) => /* @__PURE__ */ jsx12(
744
+ Menu.Item,
745
+ {
746
+ leadingIcon: h.value === value ? "check" : h.icon,
747
+ title: h.label,
748
+ onPress: () => {
749
+ onChange(h.value);
750
+ setOpen(false);
751
+ }
752
+ },
753
+ h.value
754
+ ))
354
755
  }
355
- } else {
356
- result = finalize(scope, baseDraft);
357
- }
358
- maybeFreeze(scope, result, true);
359
- revokeScope(scope);
360
- if (scope.patches_) {
361
- scope.patchListener_(scope.patches_, scope.inversePatches_);
756
+ );
757
+ };
758
+
759
+ // src/components/IconButton.tsx
760
+ import { IconButton as PaperIconButton } from "react-native-paper";
761
+ import { jsx as jsx13 } from "react/jsx-runtime";
762
+ function IconButton(props) {
763
+ const defaults = usePaperDefaults();
764
+ return /* @__PURE__ */ jsx13(PaperIconButton, { ...defaults.IconButton, ...props });
765
+ }
766
+
767
+ // src/components/TextInput.tsx
768
+ import { forwardRef } from "react";
769
+ import { TextInput as PaperTextInput } from "react-native-paper";
770
+ import { jsx as jsx14 } from "react/jsx-runtime";
771
+ var TextInput = forwardRef(function TextInput2(props, ref) {
772
+ const defaults = usePaperDefaults();
773
+ return /* @__PURE__ */ jsx14(PaperTextInput, { ref, ...defaults.TextInput, ...props });
774
+ });
775
+
776
+ // node_modules/redux/dist/redux.mjs
777
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
778
+ var ActionTypes = {
779
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
780
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
781
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
782
+ };
783
+ function isPlainObject(obj) {
784
+ if (typeof obj !== "object" || obj === null)
785
+ return false;
786
+ let proto = obj;
787
+ while (Object.getPrototypeOf(proto) !== null) {
788
+ proto = Object.getPrototypeOf(proto);
362
789
  }
363
- return result !== NOTHING ? result : void 0;
790
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
364
791
  }
365
- function finalize(rootScope, value) {
366
- if (isFrozen(value))
367
- return value;
368
- const state = value[DRAFT_STATE];
369
- if (!state) {
370
- const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
371
- return finalValue;
792
+ function compose(...funcs) {
793
+ if (funcs.length === 0) {
794
+ return (arg) => arg;
372
795
  }
373
- if (!isSameScope(state, rootScope)) {
374
- return value;
375
- }
376
- if (!state.modified_) {
377
- return state.base_;
378
- }
379
- if (!state.finalized_) {
380
- const { callbacks_ } = state;
381
- if (callbacks_) {
382
- while (callbacks_.length > 0) {
383
- const callback = callbacks_.pop();
384
- callback(rootScope);
385
- }
386
- }
387
- generatePatchesAndFinalize(state, rootScope);
796
+ if (funcs.length === 1) {
797
+ return funcs[0];
388
798
  }
389
- return state.copy_;
799
+ return funcs.reduce((a, b) => (...args) => a(b(...args)));
390
800
  }
391
- function maybeFreeze(scope, value, deep = false) {
392
- if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
393
- freeze(value, deep);
801
+ function isAction(action) {
802
+ return isPlainObject(action) && "type" in action && typeof action.type === "string";
803
+ }
804
+
805
+ // node_modules/immer/dist/immer.mjs
806
+ var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
807
+ var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
808
+ var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
809
+ var errors = process.env.NODE_ENV !== "production" ? [
810
+ // All error codes, starting by 0:
811
+ function(plugin) {
812
+ return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
813
+ },
814
+ function(thing) {
815
+ 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}'`;
816
+ },
817
+ "This object has been frozen and should not be mutated",
818
+ function(data) {
819
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
820
+ },
821
+ "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
822
+ "Immer forbids circular references",
823
+ "The first or second argument to `produce` must be a function",
824
+ "The third argument to `produce` must be a function or undefined",
825
+ "First argument to `createDraft` must be a plain object, an array, or an immerable object",
826
+ "First argument to `finishDraft` must be a draft returned by `createDraft`",
827
+ function(thing) {
828
+ return `'current' expects a draft, got: ${thing}`;
829
+ },
830
+ "Object.defineProperty() cannot be used on an Immer draft",
831
+ "Object.setPrototypeOf() cannot be used on an Immer draft",
832
+ "Immer only supports deleting array indices",
833
+ "Immer only supports setting array indices and the 'length' property",
834
+ function(thing) {
835
+ return `'original' expects a draft, got: ${thing}`;
836
+ }
837
+ // Note: if more errors are added, the errorOffset in Patches.ts should be increased
838
+ // See Patches.ts for additional errors
839
+ ] : [];
840
+ function die(error, ...args) {
841
+ if (process.env.NODE_ENV !== "production") {
842
+ const e = errors[error];
843
+ const msg = isFunction(e) ? e.apply(null, args) : e;
844
+ throw new Error(`[Immer] ${msg}`);
394
845
  }
846
+ throw new Error(
847
+ `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
848
+ );
395
849
  }
396
- function markStateFinalized(state) {
397
- state.finalized_ = true;
398
- state.scope_.unfinalizedDrafts_--;
850
+ var O = Object;
851
+ var getPrototypeOf = O.getPrototypeOf;
852
+ var CONSTRUCTOR = "constructor";
853
+ var PROTOTYPE = "prototype";
854
+ var CONFIGURABLE = "configurable";
855
+ var ENUMERABLE = "enumerable";
856
+ var WRITABLE = "writable";
857
+ var VALUE = "value";
858
+ var isDraft = (value) => !!value && !!value[DRAFT_STATE];
859
+ function isDraftable(value) {
860
+ if (!value)
861
+ return false;
862
+ return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
399
863
  }
400
- var isSameScope = (state, rootScope) => state.scope_ === rootScope;
401
- var EMPTY_LOCATIONS_RESULT = [];
402
- function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
403
- const parentCopy = latest(parent);
404
- const parentType = parent.type_;
405
- if (originalKey !== void 0) {
406
- const currentValue = get(parentCopy, originalKey, parentType);
407
- if (currentValue === draftValue) {
408
- set(parentCopy, originalKey, finalizedValue, parentType);
409
- return;
410
- }
864
+ var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
865
+ var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
866
+ function isPlainObject2(value) {
867
+ if (!value || !isObjectish(value))
868
+ return false;
869
+ const proto = getPrototypeOf(value);
870
+ if (proto === null || proto === O[PROTOTYPE])
871
+ return true;
872
+ const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
873
+ if (Ctor === Object)
874
+ return true;
875
+ if (!isFunction(Ctor))
876
+ return false;
877
+ let ctorString = cachedCtorStrings.get(Ctor);
878
+ if (ctorString === void 0) {
879
+ ctorString = Function.toString.call(Ctor);
880
+ cachedCtorStrings.set(Ctor, ctorString);
411
881
  }
412
- if (!parent.draftLocations_) {
413
- const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
414
- each(parentCopy, (key, value) => {
415
- if (isDraft(value)) {
416
- const keys = draftLocations.get(value) || [];
417
- keys.push(key);
418
- draftLocations.set(value, keys);
419
- }
882
+ return ctorString === objectCtorString;
883
+ }
884
+ function each(obj, iter, strict = true) {
885
+ if (getArchtype(obj) === 0) {
886
+ const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
887
+ keys.forEach((key) => {
888
+ iter(key, obj[key], obj);
420
889
  });
421
- }
422
- const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
423
- for (const location of locations) {
424
- set(parentCopy, location, finalizedValue, parentType);
890
+ } else {
891
+ obj.forEach((entry, index) => iter(index, entry, obj));
425
892
  }
426
893
  }
427
- function registerChildFinalizationCallback(parent, child, key) {
428
- parent.callbacks_.push(function childCleanup(rootScope) {
429
- const state = child;
430
- if (!state || !isSameScope(state, rootScope)) {
431
- return;
432
- }
433
- rootScope.mapSetPlugin_?.fixSetContents(state);
434
- const finalizedValue = getFinalValue(state);
435
- updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
436
- generatePatchesAndFinalize(state, rootScope);
437
- });
894
+ function getArchtype(thing) {
895
+ const state = thing[DRAFT_STATE];
896
+ return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
438
897
  }
439
- function generatePatchesAndFinalize(state, rootScope) {
440
- const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
441
- if (shouldFinalize) {
442
- const { patchPlugin_ } = rootScope;
443
- if (patchPlugin_) {
444
- const basePath = patchPlugin_.getPath(state);
445
- if (basePath) {
446
- patchPlugin_.generatePatches_(state, basePath, rootScope);
447
- }
448
- }
449
- markStateFinalized(state);
898
+ var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
899
+ var get = (thing, prop, type = getArchtype(thing)) => (
900
+ // @ts-ignore
901
+ type === 2 ? thing.get(prop) : thing[prop]
902
+ );
903
+ var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
904
+ if (type === 2)
905
+ thing.set(propOrOldValue, value);
906
+ else if (type === 3) {
907
+ thing.add(value);
908
+ } else
909
+ thing[propOrOldValue] = value;
910
+ };
911
+ function is(x, y) {
912
+ if (x === y) {
913
+ return x !== 0 || 1 / x === 1 / y;
914
+ } else {
915
+ return x !== x && y !== y;
450
916
  }
451
917
  }
452
- function handleCrossReference(target, key, value) {
453
- const { scope_ } = target;
454
- if (isDraft(value)) {
455
- const state = value[DRAFT_STATE];
456
- if (isSameScope(state, scope_)) {
457
- state.callbacks_.push(function crossReferenceCleanup() {
458
- prepareCopy(target);
459
- const finalizedValue = getFinalValue(state);
460
- updateDraftInParent(target, value, finalizedValue, key);
461
- });
462
- }
463
- } else if (isDraftable(value)) {
464
- target.callbacks_.push(function nestedDraftCleanup() {
465
- const targetCopy = latest(target);
466
- if (target.type_ === 3) {
467
- if (targetCopy.has(value)) {
468
- handleValue(value, scope_.handledSet_, scope_);
469
- }
470
- } else {
471
- if (get(targetCopy, key, target.type_) === value) {
472
- if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
473
- handleValue(
474
- get(target.copy_, key, target.type_),
475
- scope_.handledSet_,
476
- scope_
477
- );
478
- }
479
- }
480
- }
481
- });
482
- }
918
+ var isArray = Array.isArray;
919
+ var isMap = (target) => target instanceof Map;
920
+ var isSet = (target) => target instanceof Set;
921
+ var isObjectish = (target) => typeof target === "object";
922
+ var isFunction = (target) => typeof target === "function";
923
+ var isBoolean = (target) => typeof target === "boolean";
924
+ function isArrayIndex(value) {
925
+ const n = +value;
926
+ return Number.isInteger(n) && String(n) === value;
483
927
  }
484
- function handleValue(target, handledSet, rootScope) {
485
- if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
486
- return target;
928
+ var latest = (state) => state.copy_ || state.base_;
929
+ var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
930
+ function shallowCopy(base, strict) {
931
+ if (isMap(base)) {
932
+ return new Map(base);
487
933
  }
488
- if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
489
- return target;
934
+ if (isSet(base)) {
935
+ return new Set(base);
490
936
  }
491
- handledSet.add(target);
492
- each(target, (key, value) => {
493
- if (isDraft(value)) {
494
- const state = value[DRAFT_STATE];
495
- if (isSameScope(state, rootScope)) {
496
- const updatedValue = getFinalValue(state);
497
- set(target, key, updatedValue, target.type_);
498
- markStateFinalized(state);
937
+ if (isArray(base))
938
+ return Array[PROTOTYPE].slice.call(base);
939
+ const isPlain = isPlainObject2(base);
940
+ if (strict === true || strict === "class_only" && !isPlain) {
941
+ const descriptors = O.getOwnPropertyDescriptors(base);
942
+ delete descriptors[DRAFT_STATE];
943
+ let keys = Reflect.ownKeys(descriptors);
944
+ for (let i = 0; i < keys.length; i++) {
945
+ const key = keys[i];
946
+ const desc = descriptors[key];
947
+ if (desc[WRITABLE] === false) {
948
+ desc[WRITABLE] = true;
949
+ desc[CONFIGURABLE] = true;
499
950
  }
500
- } else if (isDraftable(value)) {
501
- handleValue(value, handledSet, rootScope);
502
- }
503
- });
504
- return target;
505
- }
506
- function createProxyProxy(base, parent) {
507
- const baseIsArray = isArray(base);
508
- const state = {
509
- type_: baseIsArray ? 1 : 0,
510
- // Track which produce call this is associated with.
511
- scope_: parent ? parent.scope_ : getCurrentScope(),
512
- // True for both shallow and deep changes.
513
- modified_: false,
514
- // Used during finalization.
515
- finalized_: false,
516
- // Track which properties have been assigned (true) or deleted (false).
517
- // actually instantiated in `prepareCopy()`
518
- assigned_: void 0,
519
- // The parent draft state.
520
- parent_: parent,
521
- // The base state.
522
- base_: base,
523
- // The base proxy.
524
- draft_: null,
525
- // set below
526
- // The base copy with any updated values.
527
- copy_: null,
528
- // Called by the `produce` function.
529
- revoke_: null,
530
- isManual_: false,
531
- // `callbacks` actually gets assigned in `createProxy`
532
- callbacks_: void 0
533
- };
534
- let target = state;
535
- let traps = objectTraps;
536
- if (baseIsArray) {
537
- target = [state];
538
- traps = arrayTraps;
539
- }
540
- const { revoke, proxy } = Proxy.revocable(target, traps);
541
- state.draft_ = proxy;
542
- state.revoke_ = revoke;
543
- return [proxy, state];
544
- }
545
- var objectTraps = {
546
- get(state, prop) {
547
- if (prop === DRAFT_STATE)
548
- return state;
549
- let arrayPlugin = state.scope_.arrayMethodsPlugin_;
550
- const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
551
- if (isArrayWithStringProp) {
552
- if (arrayPlugin?.isArrayOperationMethod(prop)) {
553
- return arrayPlugin.createMethodInterceptor(state, prop);
554
- }
555
- }
556
- const source = latest(state);
557
- if (!has(source, prop, state.type_)) {
558
- return readPropFromProto(state, source, prop);
559
- }
560
- const value = source[prop];
561
- if (state.finalized_ || !isDraftable(value)) {
562
- return value;
563
- }
564
- if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
565
- state.operationMethod
566
- ) && isArrayIndex(prop)) {
567
- return value;
568
- }
569
- if (value === peek(state.base_, prop)) {
570
- prepareCopy(state);
571
- const childKey = state.type_ === 1 ? +prop : prop;
572
- const childDraft = createProxy(state.scope_, value, state, childKey);
573
- return state.copy_[childKey] = childDraft;
574
- }
575
- return value;
576
- },
577
- has(state, prop) {
578
- return prop in latest(state);
579
- },
580
- ownKeys(state) {
581
- return Reflect.ownKeys(latest(state));
582
- },
583
- set(state, prop, value) {
584
- const desc = getDescriptorFromProto(latest(state), prop);
585
- if (desc?.set) {
586
- desc.set.call(state.draft_, value);
587
- return true;
588
- }
589
- if (!state.modified_) {
590
- const current2 = peek(latest(state), prop);
591
- const currentState = current2?.[DRAFT_STATE];
592
- if (currentState && currentState.base_ === value) {
593
- state.copy_[prop] = value;
594
- state.assigned_.set(prop, false);
595
- return true;
596
- }
597
- if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
598
- return true;
599
- prepareCopy(state);
600
- markChanged(state);
601
- }
602
- if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
603
- (value !== void 0 || prop in state.copy_) || // special case: NaN
604
- Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
605
- return true;
606
- state.copy_[prop] = value;
607
- state.assigned_.set(prop, true);
608
- handleCrossReference(state, prop, value);
609
- return true;
610
- },
611
- deleteProperty(state, prop) {
612
- prepareCopy(state);
613
- if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
614
- state.assigned_.set(prop, false);
615
- markChanged(state);
616
- } else {
617
- state.assigned_.delete(prop);
951
+ if (desc.get || desc.set)
952
+ descriptors[key] = {
953
+ [CONFIGURABLE]: true,
954
+ [WRITABLE]: true,
955
+ // could live with !!desc.set as well here...
956
+ [ENUMERABLE]: desc[ENUMERABLE],
957
+ [VALUE]: base[key]
958
+ };
618
959
  }
619
- if (state.copy_) {
620
- delete state.copy_[prop];
960
+ return O.create(getPrototypeOf(base), descriptors);
961
+ } else {
962
+ const proto = getPrototypeOf(base);
963
+ if (proto !== null && isPlain) {
964
+ return { ...base };
621
965
  }
622
- return true;
623
- },
624
- // Note: We never coerce `desc.value` into an Immer draft, because we can't make
625
- // the same guarantee in ES5 mode.
626
- getOwnPropertyDescriptor(state, prop) {
627
- const owner = latest(state);
628
- const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
629
- if (!desc)
630
- return desc;
631
- return {
632
- [WRITABLE]: true,
633
- [CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
634
- [ENUMERABLE]: desc[ENUMERABLE],
635
- [VALUE]: owner[prop]
636
- };
637
- },
638
- defineProperty() {
639
- die(11);
640
- },
641
- getPrototypeOf(state) {
642
- return getPrototypeOf(state.base_);
643
- },
644
- setPrototypeOf() {
645
- die(12);
966
+ const obj = O.create(proto);
967
+ return O.assign(obj, base);
646
968
  }
647
- };
648
- var arrayTraps = {};
649
- for (let key in objectTraps) {
650
- let fn = objectTraps[key];
651
- arrayTraps[key] = function() {
652
- const args = arguments;
653
- args[0] = args[0][0];
654
- return fn.apply(this, args);
655
- };
656
- }
657
- arrayTraps.deleteProperty = function(state, prop) {
658
- if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
659
- die(13);
660
- return arrayTraps.set.call(this, state, prop, void 0);
661
- };
662
- arrayTraps.set = function(state, prop, value) {
663
- if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
664
- die(14);
665
- return objectTraps.set.call(this, state[0], prop, value, state[0]);
666
- };
667
- function peek(draft, prop) {
668
- const state = draft[DRAFT_STATE];
669
- const source = state ? latest(state) : draft;
670
- return source[prop];
671
969
  }
672
- function readPropFromProto(state, source, prop) {
673
- const desc = getDescriptorFromProto(source, prop);
674
- return desc ? VALUE in desc ? desc[VALUE] : (
675
- // This is a very special case, if the prop is a getter defined by the
676
- // prototype, we should invoke it with the draft as context!
677
- desc.get?.call(state.draft_)
678
- ) : void 0;
679
- }
680
- function getDescriptorFromProto(source, prop) {
681
- if (!(prop in source))
682
- return void 0;
683
- let proto = getPrototypeOf(source);
684
- while (proto) {
685
- const desc = Object.getOwnPropertyDescriptor(proto, prop);
686
- if (desc)
687
- return desc;
688
- proto = getPrototypeOf(proto);
970
+ function freeze(obj, deep = false) {
971
+ if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
972
+ return obj;
973
+ if (getArchtype(obj) > 1) {
974
+ O.defineProperties(obj, {
975
+ set: dontMutateMethodOverride,
976
+ add: dontMutateMethodOverride,
977
+ clear: dontMutateMethodOverride,
978
+ delete: dontMutateMethodOverride
979
+ });
689
980
  }
690
- return void 0;
981
+ O.freeze(obj);
982
+ if (deep)
983
+ each(
984
+ obj,
985
+ (_key, value) => {
986
+ freeze(value, true);
987
+ },
988
+ false
989
+ );
990
+ return obj;
691
991
  }
692
- function markChanged(state) {
693
- if (!state.modified_) {
694
- state.modified_ = true;
695
- if (state.parent_) {
696
- markChanged(state.parent_);
697
- }
698
- }
992
+ function dontMutateFrozenCollections() {
993
+ die(2);
699
994
  }
700
- function prepareCopy(state) {
701
- if (!state.copy_) {
702
- state.assigned_ = /* @__PURE__ */ new Map();
703
- state.copy_ = shallowCopy(
704
- state.base_,
705
- state.scope_.immer_.useStrictShallowCopy_
706
- );
995
+ var dontMutateMethodOverride = {
996
+ [VALUE]: dontMutateFrozenCollections
997
+ };
998
+ function isFrozen(obj) {
999
+ if (obj === null || !isObjectish(obj))
1000
+ return true;
1001
+ return O.isFrozen(obj);
1002
+ }
1003
+ var PluginMapSet = "MapSet";
1004
+ var PluginPatches = "Patches";
1005
+ var PluginArrayMethods = "ArrayMethods";
1006
+ var plugins = {};
1007
+ function getPlugin(pluginKey) {
1008
+ const plugin = plugins[pluginKey];
1009
+ if (!plugin) {
1010
+ die(0, pluginKey);
707
1011
  }
1012
+ return plugin;
708
1013
  }
709
- var Immer2 = class {
710
- constructor(config) {
711
- this.autoFreeze_ = true;
712
- this.useStrictShallowCopy_ = false;
713
- this.useStrictIteration_ = false;
714
- this.produce = (base, recipe, patchListener) => {
715
- if (isFunction(base) && !isFunction(recipe)) {
716
- const defaultBase = recipe;
717
- recipe = base;
718
- const self = this;
719
- return function curriedProduce(base2 = defaultBase, ...args) {
720
- return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
721
- };
722
- }
723
- if (!isFunction(recipe))
724
- die(6);
725
- if (patchListener !== void 0 && !isFunction(patchListener))
726
- die(7);
727
- let result;
728
- if (isDraftable(base)) {
729
- const scope = enterScope(this);
730
- const proxy = createProxy(scope, base, void 0);
731
- let hasError = true;
732
- try {
733
- result = recipe(proxy);
734
- hasError = false;
735
- } finally {
736
- if (hasError)
737
- revokeScope(scope);
738
- else
739
- leaveScope(scope);
740
- }
741
- usePatchesInScope(scope, patchListener);
742
- return processResult(result, scope);
743
- } else if (!base || !isObjectish(base)) {
744
- result = recipe(base);
745
- if (result === void 0)
746
- result = base;
747
- if (result === NOTHING)
748
- result = void 0;
749
- if (this.autoFreeze_)
750
- freeze(result, true);
751
- if (patchListener) {
752
- const p = [];
753
- const ip = [];
754
- getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
755
- patches_: p,
756
- inversePatches_: ip
757
- });
758
- patchListener(p, ip);
759
- }
760
- return result;
761
- } else
762
- die(1, base);
763
- };
764
- this.produceWithPatches = (base, recipe) => {
765
- if (isFunction(base)) {
766
- return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
767
- }
768
- let patches, inversePatches;
769
- const result = this.produce(base, recipe, (p, ip) => {
770
- patches = p;
771
- inversePatches = ip;
772
- });
773
- return [result, patches, inversePatches];
774
- };
775
- if (isBoolean(config?.autoFreeze))
776
- this.setAutoFreeze(config.autoFreeze);
777
- if (isBoolean(config?.useStrictShallowCopy))
778
- this.setUseStrictShallowCopy(config.useStrictShallowCopy);
779
- if (isBoolean(config?.useStrictIteration))
780
- this.setUseStrictIteration(config.useStrictIteration);
1014
+ var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
1015
+ var currentScope;
1016
+ var getCurrentScope = () => currentScope;
1017
+ var createScope = (parent_, immer_) => ({
1018
+ drafts_: [],
1019
+ parent_,
1020
+ immer_,
1021
+ // Whenever the modified draft contains a draft from another scope, we
1022
+ // need to prevent auto-freezing so the unowned draft can be finalized.
1023
+ canAutoFreeze_: true,
1024
+ unfinalizedDrafts_: 0,
1025
+ handledSet_: /* @__PURE__ */ new Set(),
1026
+ processedForPatches_: /* @__PURE__ */ new Set(),
1027
+ mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
1028
+ arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
1029
+ });
1030
+ function usePatchesInScope(scope, patchListener) {
1031
+ if (patchListener) {
1032
+ scope.patchPlugin_ = getPlugin(PluginPatches);
1033
+ scope.patches_ = [];
1034
+ scope.inversePatches_ = [];
1035
+ scope.patchListener_ = patchListener;
781
1036
  }
782
- createDraft(base) {
783
- if (!isDraftable(base))
784
- die(8);
785
- if (isDraft(base))
786
- base = current(base);
787
- const scope = enterScope(this);
788
- const proxy = createProxy(scope, base, void 0);
789
- proxy[DRAFT_STATE].isManual_ = true;
790
- leaveScope(scope);
791
- return proxy;
1037
+ }
1038
+ function revokeScope(scope) {
1039
+ leaveScope(scope);
1040
+ scope.drafts_.forEach(revokeDraft);
1041
+ scope.drafts_ = null;
1042
+ }
1043
+ function leaveScope(scope) {
1044
+ if (scope === currentScope) {
1045
+ currentScope = scope.parent_;
792
1046
  }
793
- finishDraft(draft, patchListener) {
794
- const state = draft && draft[DRAFT_STATE];
795
- if (!state || !state.isManual_)
796
- die(9);
797
- const { scope_: scope } = state;
798
- usePatchesInScope(scope, patchListener);
799
- return processResult(void 0, scope);
1047
+ }
1048
+ var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
1049
+ function revokeDraft(draft) {
1050
+ const state = draft[DRAFT_STATE];
1051
+ if (state.type_ === 0 || state.type_ === 1)
1052
+ state.revoke_();
1053
+ else
1054
+ state.revoked_ = true;
1055
+ }
1056
+ function processResult(result, scope) {
1057
+ scope.unfinalizedDrafts_ = scope.drafts_.length;
1058
+ const baseDraft = scope.drafts_[0];
1059
+ const isReplaced = result !== void 0 && result !== baseDraft;
1060
+ if (isReplaced) {
1061
+ if (baseDraft[DRAFT_STATE].modified_) {
1062
+ revokeScope(scope);
1063
+ die(4);
1064
+ }
1065
+ if (isDraftable(result)) {
1066
+ result = finalize(scope, result);
1067
+ }
1068
+ const { patchPlugin_ } = scope;
1069
+ if (patchPlugin_) {
1070
+ patchPlugin_.generateReplacementPatches_(
1071
+ baseDraft[DRAFT_STATE].base_,
1072
+ result,
1073
+ scope
1074
+ );
1075
+ }
1076
+ } else {
1077
+ result = finalize(scope, baseDraft);
800
1078
  }
801
- /**
802
- * Pass true to automatically freeze all copies created by Immer.
803
- *
804
- * By default, auto-freezing is enabled.
805
- */
806
- setAutoFreeze(value) {
807
- this.autoFreeze_ = value;
1079
+ maybeFreeze(scope, result, true);
1080
+ revokeScope(scope);
1081
+ if (scope.patches_) {
1082
+ scope.patchListener_(scope.patches_, scope.inversePatches_);
808
1083
  }
809
- /**
810
- * Pass true to enable strict shallow copy.
811
- *
812
- * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
813
- */
814
- setUseStrictShallowCopy(value) {
815
- this.useStrictShallowCopy_ = value;
1084
+ return result !== NOTHING ? result : void 0;
1085
+ }
1086
+ function finalize(rootScope, value) {
1087
+ if (isFrozen(value))
1088
+ return value;
1089
+ const state = value[DRAFT_STATE];
1090
+ if (!state) {
1091
+ const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
1092
+ return finalValue;
816
1093
  }
817
- /**
818
- * Pass false to use faster iteration that skips non-enumerable properties
819
- * but still handles symbols for compatibility.
820
- *
821
- * By default, strict iteration is enabled (includes all own properties).
822
- */
823
- setUseStrictIteration(value) {
824
- this.useStrictIteration_ = value;
1094
+ if (!isSameScope(state, rootScope)) {
1095
+ return value;
825
1096
  }
826
- shouldUseStrictIteration() {
827
- return this.useStrictIteration_;
1097
+ if (!state.modified_) {
1098
+ return state.base_;
828
1099
  }
829
- applyPatches(base, patches) {
830
- let i;
831
- for (i = patches.length - 1; i >= 0; i--) {
832
- const patch = patches[i];
833
- if (patch.path.length === 0 && patch.op === "replace") {
834
- base = patch.value;
835
- break;
1100
+ if (!state.finalized_) {
1101
+ const { callbacks_ } = state;
1102
+ if (callbacks_) {
1103
+ while (callbacks_.length > 0) {
1104
+ const callback = callbacks_.pop();
1105
+ callback(rootScope);
836
1106
  }
837
1107
  }
838
- if (i > -1) {
839
- patches = patches.slice(i + 1);
840
- }
841
- const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
842
- if (isDraft(base)) {
843
- return applyPatchesImpl(base, patches);
1108
+ generatePatchesAndFinalize(state, rootScope);
1109
+ }
1110
+ return state.copy_;
1111
+ }
1112
+ function maybeFreeze(scope, value, deep = false) {
1113
+ if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
1114
+ freeze(value, deep);
1115
+ }
1116
+ }
1117
+ function markStateFinalized(state) {
1118
+ state.finalized_ = true;
1119
+ state.scope_.unfinalizedDrafts_--;
1120
+ }
1121
+ var isSameScope = (state, rootScope) => state.scope_ === rootScope;
1122
+ var EMPTY_LOCATIONS_RESULT = [];
1123
+ function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
1124
+ const parentCopy = latest(parent);
1125
+ const parentType = parent.type_;
1126
+ if (originalKey !== void 0) {
1127
+ const currentValue = get(parentCopy, originalKey, parentType);
1128
+ if (currentValue === draftValue) {
1129
+ set(parentCopy, originalKey, finalizedValue, parentType);
1130
+ return;
844
1131
  }
845
- return this.produce(
846
- base,
847
- (draft) => applyPatchesImpl(draft, patches)
848
- );
849
1132
  }
850
- };
851
- function createProxy(rootScope, value, parent, key) {
852
- const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
853
- const scope = parent?.scope_ ?? getCurrentScope();
854
- scope.drafts_.push(draft);
855
- state.callbacks_ = parent?.callbacks_ ?? [];
856
- state.key_ = key;
857
- if (parent && key !== void 0) {
858
- registerChildFinalizationCallback(parent, state, key);
859
- } else {
860
- state.callbacks_.push(function rootDraftCleanup(rootScope2) {
861
- rootScope2.mapSetPlugin_?.fixSetContents(state);
862
- const { patchPlugin_ } = rootScope2;
863
- if (state.modified_ && patchPlugin_) {
864
- patchPlugin_.generatePatches_(state, [], rootScope2);
1133
+ if (!parent.draftLocations_) {
1134
+ const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
1135
+ each(parentCopy, (key, value) => {
1136
+ if (isDraft(value)) {
1137
+ const keys = draftLocations.get(value) || [];
1138
+ keys.push(key);
1139
+ draftLocations.set(value, keys);
865
1140
  }
866
1141
  });
867
1142
  }
868
- return draft;
1143
+ const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
1144
+ for (const location of locations) {
1145
+ set(parentCopy, location, finalizedValue, parentType);
1146
+ }
869
1147
  }
870
- function current(value) {
871
- if (!isDraft(value))
872
- die(10, value);
873
- return currentImpl(value);
874
- }
875
- function currentImpl(value) {
876
- if (!isDraftable(value) || isFrozen(value))
877
- return value;
878
- const state = value[DRAFT_STATE];
879
- let copy;
880
- let strict = true;
881
- if (state) {
882
- if (!state.modified_)
883
- return state.base_;
884
- state.finalized_ = true;
885
- copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
886
- strict = state.scope_.immer_.shouldUseStrictIteration();
887
- } else {
888
- copy = shallowCopy(value, true);
889
- }
890
- each(
891
- copy,
892
- (key, childValue) => {
893
- set(copy, key, currentImpl(childValue));
894
- },
895
- strict
896
- );
897
- if (state) {
898
- state.finalized_ = false;
899
- }
900
- return copy;
1148
+ function registerChildFinalizationCallback(parent, child, key) {
1149
+ parent.callbacks_.push(function childCleanup(rootScope) {
1150
+ const state = child;
1151
+ if (!state || !isSameScope(state, rootScope)) {
1152
+ return;
1153
+ }
1154
+ rootScope.mapSetPlugin_?.fixSetContents(state);
1155
+ const finalizedValue = getFinalValue(state);
1156
+ updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
1157
+ generatePatchesAndFinalize(state, rootScope);
1158
+ });
901
1159
  }
902
- var immer = new Immer2();
903
- var produce = immer.produce;
904
-
905
- // node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
906
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
907
- if (arguments.length === 0) return void 0;
908
- if (typeof arguments[0] === "object") return compose;
909
- return compose.apply(null, arguments);
910
- };
911
- var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
912
- return function(noop3) {
913
- return noop3;
914
- };
915
- };
916
- var hasMatchFunction = (v) => {
917
- return v && typeof v.match === "function";
918
- };
919
- function createAction(type, prepareAction) {
920
- function actionCreator(...args) {
921
- if (prepareAction) {
922
- let prepared = prepareAction(...args);
923
- if (!prepared) {
924
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
1160
+ function generatePatchesAndFinalize(state, rootScope) {
1161
+ const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
1162
+ if (shouldFinalize) {
1163
+ const { patchPlugin_ } = rootScope;
1164
+ if (patchPlugin_) {
1165
+ const basePath = patchPlugin_.getPath(state);
1166
+ if (basePath) {
1167
+ patchPlugin_.generatePatches_(state, basePath, rootScope);
925
1168
  }
926
- return {
927
- type,
928
- payload: prepared.payload,
929
- ..."meta" in prepared && {
930
- meta: prepared.meta
931
- },
932
- ..."error" in prepared && {
933
- error: prepared.error
934
- }
935
- };
936
1169
  }
937
- return {
938
- type,
939
- payload: args[0]
940
- };
1170
+ markStateFinalized(state);
941
1171
  }
942
- actionCreator.toString = () => `${type}`;
943
- actionCreator.type = type;
944
- actionCreator.match = (action) => isAction(action) && action.type === type;
945
- return actionCreator;
946
- }
947
- function freezeDraftable(val) {
948
- return isDraftable(val) ? produce(val, () => {
949
- }) : val;
950
1172
  }
951
- function getOrInsertComputed(map, key, compute) {
952
- if (map.has(key)) return map.get(key);
953
- return map.set(key, compute(key)).get(key);
954
- }
955
- function executeReducerBuilderCallback(builderCallback) {
956
- const actionsMap = {};
957
- const actionMatchers = [];
958
- let defaultCaseReducer;
959
- const builder = {
960
- addCase(typeOrActionCreator, reducer) {
961
- if (process.env.NODE_ENV !== "production") {
962
- if (actionMatchers.length > 0) {
963
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
964
- }
965
- if (defaultCaseReducer) {
966
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
967
- }
968
- }
969
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
970
- if (!type) {
971
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
972
- }
973
- if (type in actionsMap) {
974
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
975
- }
976
- actionsMap[type] = reducer;
977
- return builder;
978
- },
979
- addAsyncThunk(asyncThunk, reducers2) {
980
- if (process.env.NODE_ENV !== "production") {
981
- if (defaultCaseReducer) {
982
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
983
- }
984
- }
985
- if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
986
- if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
987
- if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
988
- if (reducers2.settled) actionMatchers.push({
989
- matcher: asyncThunk.settled,
990
- reducer: reducers2.settled
1173
+ function handleCrossReference(target, key, value) {
1174
+ const { scope_ } = target;
1175
+ if (isDraft(value)) {
1176
+ const state = value[DRAFT_STATE];
1177
+ if (isSameScope(state, scope_)) {
1178
+ state.callbacks_.push(function crossReferenceCleanup() {
1179
+ prepareCopy(target);
1180
+ const finalizedValue = getFinalValue(state);
1181
+ updateDraftInParent(target, value, finalizedValue, key);
991
1182
  });
992
- return builder;
993
- },
994
- addMatcher(matcher, reducer) {
995
- if (process.env.NODE_ENV !== "production") {
996
- if (defaultCaseReducer) {
997
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
1183
+ }
1184
+ } else if (isDraftable(value)) {
1185
+ target.callbacks_.push(function nestedDraftCleanup() {
1186
+ const targetCopy = latest(target);
1187
+ if (target.type_ === 3) {
1188
+ if (targetCopy.has(value)) {
1189
+ handleValue(value, scope_.handledSet_, scope_);
998
1190
  }
999
- }
1000
- actionMatchers.push({
1001
- matcher,
1002
- reducer
1003
- });
1004
- return builder;
1005
- },
1006
- addDefaultCase(reducer) {
1007
- if (process.env.NODE_ENV !== "production") {
1008
- if (defaultCaseReducer) {
1009
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
1191
+ } else {
1192
+ if (get(targetCopy, key, target.type_) === value) {
1193
+ if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
1194
+ handleValue(
1195
+ get(target.copy_, key, target.type_),
1196
+ scope_.handledSet_,
1197
+ scope_
1198
+ );
1199
+ }
1010
1200
  }
1011
1201
  }
1012
- defaultCaseReducer = reducer;
1013
- return builder;
1014
- }
1015
- };
1016
- builderCallback(builder);
1017
- return [actionsMap, actionMatchers, defaultCaseReducer];
1018
- }
1019
- function isStateFunction(x) {
1020
- return typeof x === "function";
1202
+ });
1203
+ }
1021
1204
  }
1022
- function createReducer(initialState, mapOrBuilderCallback) {
1023
- if (process.env.NODE_ENV !== "production") {
1024
- if (typeof mapOrBuilderCallback === "object") {
1025
- 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");
1026
- }
1205
+ function handleValue(target, handledSet, rootScope) {
1206
+ if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
1207
+ return target;
1027
1208
  }
1028
- let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
1029
- let getInitialState;
1030
- if (isStateFunction(initialState)) {
1031
- getInitialState = () => freezeDraftable(initialState());
1032
- } else {
1033
- const frozenInitialState = freezeDraftable(initialState);
1034
- getInitialState = () => frozenInitialState;
1209
+ if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
1210
+ return target;
1035
1211
  }
1036
- function reducer(state = getInitialState(), action) {
1037
- let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
1038
- matcher
1039
- }) => matcher(action)).map(({
1040
- reducer: reducer2
1041
- }) => reducer2)];
1042
- if (caseReducers.filter((cr) => !!cr).length === 0) {
1043
- caseReducers = [finalDefaultCaseReducer];
1044
- }
1045
- return caseReducers.reduce((previousState, caseReducer) => {
1046
- if (caseReducer) {
1047
- if (isDraft(previousState)) {
1048
- const draft = previousState;
1049
- const result = caseReducer(draft, action);
1050
- if (result === void 0) {
1051
- return previousState;
1052
- }
1053
- return result;
1054
- } else if (!isDraftable(previousState)) {
1055
- const result = caseReducer(previousState, action);
1056
- if (result === void 0) {
1057
- if (previousState === null) {
1058
- return previousState;
1059
- }
1060
- throw Error("A case reducer on a non-draftable value must not return undefined");
1061
- }
1062
- return result;
1063
- } else {
1064
- return produce(previousState, (draft) => {
1065
- return caseReducer(draft, action);
1066
- });
1067
- }
1212
+ handledSet.add(target);
1213
+ each(target, (key, value) => {
1214
+ if (isDraft(value)) {
1215
+ const state = value[DRAFT_STATE];
1216
+ if (isSameScope(state, rootScope)) {
1217
+ const updatedValue = getFinalValue(state);
1218
+ set(target, key, updatedValue, target.type_);
1219
+ markStateFinalized(state);
1068
1220
  }
1069
- return previousState;
1070
- }, state);
1071
- }
1072
- reducer.getInitialState = getInitialState;
1073
- return reducer;
1221
+ } else if (isDraftable(value)) {
1222
+ handleValue(value, handledSet, rootScope);
1223
+ }
1224
+ });
1225
+ return target;
1074
1226
  }
1075
- var matches = (matcher, action) => {
1076
- if (hasMatchFunction(matcher)) {
1077
- return matcher.match(action);
1078
- } else {
1079
- return matcher(action);
1227
+ function createProxyProxy(base, parent) {
1228
+ const baseIsArray = isArray(base);
1229
+ const state = {
1230
+ type_: baseIsArray ? 1 : 0,
1231
+ // Track which produce call this is associated with.
1232
+ scope_: parent ? parent.scope_ : getCurrentScope(),
1233
+ // True for both shallow and deep changes.
1234
+ modified_: false,
1235
+ // Used during finalization.
1236
+ finalized_: false,
1237
+ // Track which properties have been assigned (true) or deleted (false).
1238
+ // actually instantiated in `prepareCopy()`
1239
+ assigned_: void 0,
1240
+ // The parent draft state.
1241
+ parent_: parent,
1242
+ // The base state.
1243
+ base_: base,
1244
+ // The base proxy.
1245
+ draft_: null,
1246
+ // set below
1247
+ // The base copy with any updated values.
1248
+ copy_: null,
1249
+ // Called by the `produce` function.
1250
+ revoke_: null,
1251
+ isManual_: false,
1252
+ // `callbacks` actually gets assigned in `createProxy`
1253
+ callbacks_: void 0
1254
+ };
1255
+ let target = state;
1256
+ let traps = objectTraps;
1257
+ if (baseIsArray) {
1258
+ target = [state];
1259
+ traps = arrayTraps;
1260
+ }
1261
+ const { revoke, proxy } = Proxy.revocable(target, traps);
1262
+ state.draft_ = proxy;
1263
+ state.revoke_ = revoke;
1264
+ return [proxy, state];
1265
+ }
1266
+ var objectTraps = {
1267
+ get(state, prop) {
1268
+ if (prop === DRAFT_STATE)
1269
+ return state;
1270
+ let arrayPlugin = state.scope_.arrayMethodsPlugin_;
1271
+ const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
1272
+ if (isArrayWithStringProp) {
1273
+ if (arrayPlugin?.isArrayOperationMethod(prop)) {
1274
+ return arrayPlugin.createMethodInterceptor(state, prop);
1275
+ }
1276
+ }
1277
+ const source = latest(state);
1278
+ if (!has(source, prop, state.type_)) {
1279
+ return readPropFromProto(state, source, prop);
1280
+ }
1281
+ const value = source[prop];
1282
+ if (state.finalized_ || !isDraftable(value)) {
1283
+ return value;
1284
+ }
1285
+ if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
1286
+ state.operationMethod
1287
+ ) && isArrayIndex(prop)) {
1288
+ return value;
1289
+ }
1290
+ if (value === peek(state.base_, prop)) {
1291
+ prepareCopy(state);
1292
+ const childKey = state.type_ === 1 ? +prop : prop;
1293
+ const childDraft = createProxy(state.scope_, value, state, childKey);
1294
+ return state.copy_[childKey] = childDraft;
1295
+ }
1296
+ return value;
1297
+ },
1298
+ has(state, prop) {
1299
+ return prop in latest(state);
1300
+ },
1301
+ ownKeys(state) {
1302
+ return Reflect.ownKeys(latest(state));
1303
+ },
1304
+ set(state, prop, value) {
1305
+ const desc = getDescriptorFromProto(latest(state), prop);
1306
+ if (desc?.set) {
1307
+ desc.set.call(state.draft_, value);
1308
+ return true;
1309
+ }
1310
+ if (!state.modified_) {
1311
+ const current2 = peek(latest(state), prop);
1312
+ const currentState = current2?.[DRAFT_STATE];
1313
+ if (currentState && currentState.base_ === value) {
1314
+ state.copy_[prop] = value;
1315
+ state.assigned_.set(prop, false);
1316
+ return true;
1317
+ }
1318
+ if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
1319
+ return true;
1320
+ prepareCopy(state);
1321
+ markChanged(state);
1322
+ }
1323
+ if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
1324
+ (value !== void 0 || prop in state.copy_) || // special case: NaN
1325
+ Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
1326
+ return true;
1327
+ state.copy_[prop] = value;
1328
+ state.assigned_.set(prop, true);
1329
+ handleCrossReference(state, prop, value);
1330
+ return true;
1331
+ },
1332
+ deleteProperty(state, prop) {
1333
+ prepareCopy(state);
1334
+ if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
1335
+ state.assigned_.set(prop, false);
1336
+ markChanged(state);
1337
+ } else {
1338
+ state.assigned_.delete(prop);
1339
+ }
1340
+ if (state.copy_) {
1341
+ delete state.copy_[prop];
1342
+ }
1343
+ return true;
1344
+ },
1345
+ // Note: We never coerce `desc.value` into an Immer draft, because we can't make
1346
+ // the same guarantee in ES5 mode.
1347
+ getOwnPropertyDescriptor(state, prop) {
1348
+ const owner = latest(state);
1349
+ const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
1350
+ if (!desc)
1351
+ return desc;
1352
+ return {
1353
+ [WRITABLE]: true,
1354
+ [CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
1355
+ [ENUMERABLE]: desc[ENUMERABLE],
1356
+ [VALUE]: owner[prop]
1357
+ };
1358
+ },
1359
+ defineProperty() {
1360
+ die(11);
1361
+ },
1362
+ getPrototypeOf(state) {
1363
+ return getPrototypeOf(state.base_);
1364
+ },
1365
+ setPrototypeOf() {
1366
+ die(12);
1080
1367
  }
1081
1368
  };
1082
- function isAnyOf(...matchers) {
1083
- return (action) => {
1084
- return matchers.some((matcher) => matches(matcher, action));
1369
+ var arrayTraps = {};
1370
+ for (let key in objectTraps) {
1371
+ let fn = objectTraps[key];
1372
+ arrayTraps[key] = function() {
1373
+ const args = arguments;
1374
+ args[0] = args[0][0];
1375
+ return fn.apply(this, args);
1085
1376
  };
1086
1377
  }
1087
- var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
1088
- var nanoid = (size = 21) => {
1089
- let id = "";
1090
- let i = size;
1091
- while (i--) {
1092
- id += urlAlphabet[Math.random() * 64 | 0];
1093
- }
1094
- return id;
1378
+ arrayTraps.deleteProperty = function(state, prop) {
1379
+ if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
1380
+ die(13);
1381
+ return arrayTraps.set.call(this, state, prop, void 0);
1095
1382
  };
1096
- var commonProperties = ["name", "message", "stack", "code"];
1097
- var RejectWithValue = class {
1098
- constructor(payload, meta) {
1099
- __publicField(this, "payload");
1100
- __publicField(this, "meta");
1101
- /*
1102
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1103
- does not exist at runtime
1104
- */
1105
- __publicField(this, "_type");
1106
- this.payload = payload;
1107
- this.meta = meta;
1108
- }
1383
+ arrayTraps.set = function(state, prop, value) {
1384
+ if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
1385
+ die(14);
1386
+ return objectTraps.set.call(this, state[0], prop, value, state[0]);
1109
1387
  };
1110
- var FulfillWithMeta = class {
1111
- constructor(payload, meta) {
1112
- __publicField(this, "payload");
1113
- __publicField(this, "meta");
1114
- /*
1115
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1116
- does not exist at runtime
1117
- */
1118
- __publicField(this, "_type");
1119
- this.payload = payload;
1120
- this.meta = meta;
1388
+ function peek(draft, prop) {
1389
+ const state = draft[DRAFT_STATE];
1390
+ const source = state ? latest(state) : draft;
1391
+ return source[prop];
1392
+ }
1393
+ function readPropFromProto(state, source, prop) {
1394
+ const desc = getDescriptorFromProto(source, prop);
1395
+ return desc ? VALUE in desc ? desc[VALUE] : (
1396
+ // This is a very special case, if the prop is a getter defined by the
1397
+ // prototype, we should invoke it with the draft as context!
1398
+ desc.get?.call(state.draft_)
1399
+ ) : void 0;
1400
+ }
1401
+ function getDescriptorFromProto(source, prop) {
1402
+ if (!(prop in source))
1403
+ return void 0;
1404
+ let proto = getPrototypeOf(source);
1405
+ while (proto) {
1406
+ const desc = Object.getOwnPropertyDescriptor(proto, prop);
1407
+ if (desc)
1408
+ return desc;
1409
+ proto = getPrototypeOf(proto);
1121
1410
  }
1122
- };
1123
- var miniSerializeError = (value) => {
1124
- if (typeof value === "object" && value !== null) {
1125
- const simpleError = {};
1126
- for (const property of commonProperties) {
1127
- if (typeof value[property] === "string") {
1128
- simpleError[property] = value[property];
1129
- }
1411
+ return void 0;
1412
+ }
1413
+ function markChanged(state) {
1414
+ if (!state.modified_) {
1415
+ state.modified_ = true;
1416
+ if (state.parent_) {
1417
+ markChanged(state.parent_);
1130
1418
  }
1131
- return simpleError;
1132
1419
  }
1133
- return {
1134
- message: String(value)
1135
- };
1136
- };
1137
- var externalAbortMessage = "External signal was aborted";
1138
- var createAsyncThunk = /* @__PURE__ */ (() => {
1139
- function createAsyncThunk2(typePrefix, payloadCreator, options) {
1140
- const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
1141
- payload,
1142
- meta: {
1143
- ...meta || {},
1144
- arg,
1145
- requestId,
1146
- requestStatus: "fulfilled"
1147
- }
1148
- }));
1149
- const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
1150
- payload: void 0,
1151
- meta: {
1152
- ...meta || {},
1153
- arg,
1154
- requestId,
1155
- requestStatus: "pending"
1156
- }
1157
- }));
1158
- const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
1159
- payload,
1160
- error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1161
- meta: {
1162
- ...meta || {},
1163
- arg,
1164
- requestId,
1165
- rejectedWithValue: !!payload,
1166
- requestStatus: "rejected",
1167
- aborted: error?.name === "AbortError",
1168
- condition: error?.name === "ConditionError"
1169
- }
1170
- }));
1171
- function actionCreator(arg, {
1172
- signal
1173
- } = {}) {
1174
- return (dispatch, getState, extra) => {
1175
- const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
1176
- const abortController = new AbortController();
1177
- let abortHandler;
1178
- let abortReason;
1179
- function abort(reason) {
1180
- abortReason = reason;
1181
- abortController.abort();
1182
- }
1183
- if (signal) {
1184
- if (signal.aborted) {
1185
- abort(externalAbortMessage);
1186
- } else {
1187
- signal.addEventListener("abort", () => abort(externalAbortMessage), {
1188
- once: true
1189
- });
1190
- }
1191
- }
1192
- const promise = (async function() {
1193
- let finalAction;
1194
- try {
1195
- let conditionResult = options?.condition?.(arg, {
1196
- getState,
1197
- extra
1198
- });
1199
- if (isThenable(conditionResult)) {
1200
- conditionResult = await conditionResult;
1201
- }
1202
- if (conditionResult === false || abortController.signal.aborted) {
1203
- throw {
1204
- name: "ConditionError",
1205
- message: "Aborted due to condition callback returning false."
1206
- };
1207
- }
1208
- const abortedPromise = new Promise((_, reject) => {
1209
- abortHandler = () => {
1210
- reject({
1211
- name: "AbortError",
1212
- message: abortReason || "Aborted"
1213
- });
1214
- };
1215
- abortController.signal.addEventListener("abort", abortHandler, {
1216
- once: true
1217
- });
1218
- });
1219
- dispatch(pending(requestId, arg, options?.getPendingMeta?.({
1220
- requestId,
1221
- arg
1222
- }, {
1223
- getState,
1224
- extra
1225
- })));
1226
- finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
1227
- dispatch,
1228
- getState,
1229
- extra,
1230
- requestId,
1231
- signal: abortController.signal,
1232
- abort,
1233
- rejectWithValue: ((value, meta) => {
1234
- return new RejectWithValue(value, meta);
1235
- }),
1236
- fulfillWithValue: ((value, meta) => {
1237
- return new FulfillWithMeta(value, meta);
1238
- })
1239
- })).then((result) => {
1240
- if (result instanceof RejectWithValue) {
1241
- throw result;
1242
- }
1243
- if (result instanceof FulfillWithMeta) {
1244
- return fulfilled(result.payload, requestId, arg, result.meta);
1245
- }
1246
- return fulfilled(result, requestId, arg);
1247
- })]);
1248
- } catch (err) {
1249
- finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
1250
- } finally {
1251
- if (abortHandler) {
1252
- abortController.signal.removeEventListener("abort", abortHandler);
1253
- }
1254
- }
1255
- const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
1256
- if (!skipDispatch) {
1257
- dispatch(finalAction);
1258
- }
1259
- return finalAction;
1260
- })();
1261
- return Object.assign(promise, {
1262
- abort,
1263
- requestId,
1264
- arg,
1265
- unwrap() {
1266
- return promise.then(unwrapResult);
1267
- }
1268
- });
1269
- };
1270
- }
1271
- return Object.assign(actionCreator, {
1272
- pending,
1273
- rejected,
1274
- fulfilled,
1275
- settled: isAnyOf(rejected, fulfilled),
1276
- typePrefix
1277
- });
1278
- }
1279
- createAsyncThunk2.withTypes = () => createAsyncThunk2;
1280
- return createAsyncThunk2;
1281
- })();
1282
- function unwrapResult(action) {
1283
- if (action.meta && action.meta.rejectedWithValue) {
1284
- throw action.payload;
1285
- }
1286
- if (action.error) {
1287
- throw action.error;
1288
- }
1289
- return action.payload;
1290
- }
1291
- function isThenable(value) {
1292
- return value !== null && typeof value === "object" && typeof value.then === "function";
1293
1420
  }
1294
- var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
1295
- var asyncThunkCreator = {
1296
- [asyncThunkSymbol]: createAsyncThunk
1297
- };
1298
- function getType(slice, actionKey) {
1299
- return `${slice}/${actionKey}`;
1421
+ function prepareCopy(state) {
1422
+ if (!state.copy_) {
1423
+ state.assigned_ = /* @__PURE__ */ new Map();
1424
+ state.copy_ = shallowCopy(
1425
+ state.base_,
1426
+ state.scope_.immer_.useStrictShallowCopy_
1427
+ );
1428
+ }
1300
1429
  }
1301
- function buildCreateSlice({
1302
- creators
1303
- } = {}) {
1304
- const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
1305
- return function createSlice2(options) {
1306
- const {
1307
- name,
1308
- reducerPath = name
1309
- } = options;
1310
- if (!name) {
1311
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
1312
- }
1313
- if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
1314
- if (options.initialState === void 0) {
1315
- console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
1430
+ var Immer2 = class {
1431
+ constructor(config) {
1432
+ this.autoFreeze_ = true;
1433
+ this.useStrictShallowCopy_ = false;
1434
+ this.useStrictIteration_ = false;
1435
+ this.produce = (base, recipe, patchListener) => {
1436
+ if (isFunction(base) && !isFunction(recipe)) {
1437
+ const defaultBase = recipe;
1438
+ recipe = base;
1439
+ const self = this;
1440
+ return function curriedProduce(base2 = defaultBase, ...args) {
1441
+ return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
1442
+ };
1316
1443
  }
1317
- }
1318
- const reducers2 = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
1319
- const reducerNames = Object.keys(reducers2);
1320
- const context = {
1321
- sliceCaseReducersByName: {},
1322
- sliceCaseReducersByType: {},
1323
- actionCreators: {},
1324
- sliceMatchers: []
1325
- };
1326
- const contextMethods = {
1327
- addCase(typeOrActionCreator, reducer2) {
1328
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1329
- if (!type) {
1330
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
1444
+ if (!isFunction(recipe))
1445
+ die(6);
1446
+ if (patchListener !== void 0 && !isFunction(patchListener))
1447
+ die(7);
1448
+ let result;
1449
+ if (isDraftable(base)) {
1450
+ const scope = enterScope(this);
1451
+ const proxy = createProxy(scope, base, void 0);
1452
+ let hasError = true;
1453
+ try {
1454
+ result = recipe(proxy);
1455
+ hasError = false;
1456
+ } finally {
1457
+ if (hasError)
1458
+ revokeScope(scope);
1459
+ else
1460
+ leaveScope(scope);
1331
1461
  }
1332
- if (type in context.sliceCaseReducersByType) {
1333
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
1462
+ usePatchesInScope(scope, patchListener);
1463
+ return processResult(result, scope);
1464
+ } else if (!base || !isObjectish(base)) {
1465
+ result = recipe(base);
1466
+ if (result === void 0)
1467
+ result = base;
1468
+ if (result === NOTHING)
1469
+ result = void 0;
1470
+ if (this.autoFreeze_)
1471
+ freeze(result, true);
1472
+ if (patchListener) {
1473
+ const p = [];
1474
+ const ip = [];
1475
+ getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
1476
+ patches_: p,
1477
+ inversePatches_: ip
1478
+ });
1479
+ patchListener(p, ip);
1334
1480
  }
1335
- context.sliceCaseReducersByType[type] = reducer2;
1336
- return contextMethods;
1337
- },
1338
- addMatcher(matcher, reducer2) {
1339
- context.sliceMatchers.push({
1340
- matcher,
1341
- reducer: reducer2
1342
- });
1343
- return contextMethods;
1344
- },
1345
- exposeAction(name2, actionCreator) {
1346
- context.actionCreators[name2] = actionCreator;
1347
- return contextMethods;
1348
- },
1349
- exposeCaseReducer(name2, reducer2) {
1350
- context.sliceCaseReducersByName[name2] = reducer2;
1351
- return contextMethods;
1352
- }
1481
+ return result;
1482
+ } else
1483
+ die(1, base);
1353
1484
  };
1354
- reducerNames.forEach((reducerName) => {
1355
- const reducerDefinition = reducers2[reducerName];
1356
- const reducerDetails = {
1357
- reducerName,
1358
- type: getType(name, reducerName),
1359
- createNotation: typeof options.reducers === "function"
1360
- };
1361
- if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
1362
- handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
1363
- } else {
1364
- handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
1365
- }
1366
- });
1367
- function buildReducer() {
1368
- if (process.env.NODE_ENV !== "production") {
1369
- if (typeof options.extraReducers === "object") {
1370
- 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");
1371
- }
1485
+ this.produceWithPatches = (base, recipe) => {
1486
+ if (isFunction(base)) {
1487
+ return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
1372
1488
  }
1373
- const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
1374
- const finalCaseReducers = {
1375
- ...extraReducers,
1376
- ...context.sliceCaseReducersByType
1377
- };
1378
- return createReducer(options.initialState, (builder) => {
1379
- for (let key in finalCaseReducers) {
1380
- builder.addCase(key, finalCaseReducers[key]);
1381
- }
1382
- for (let sM of context.sliceMatchers) {
1383
- builder.addMatcher(sM.matcher, sM.reducer);
1384
- }
1385
- for (let m of actionMatchers) {
1386
- builder.addMatcher(m.matcher, m.reducer);
1387
- }
1388
- if (defaultCaseReducer) {
1389
- builder.addDefaultCase(defaultCaseReducer);
1390
- }
1489
+ let patches, inversePatches;
1490
+ const result = this.produce(base, recipe, (p, ip) => {
1491
+ patches = p;
1492
+ inversePatches = ip;
1391
1493
  });
1494
+ return [result, patches, inversePatches];
1495
+ };
1496
+ if (isBoolean(config?.autoFreeze))
1497
+ this.setAutoFreeze(config.autoFreeze);
1498
+ if (isBoolean(config?.useStrictShallowCopy))
1499
+ this.setUseStrictShallowCopy(config.useStrictShallowCopy);
1500
+ if (isBoolean(config?.useStrictIteration))
1501
+ this.setUseStrictIteration(config.useStrictIteration);
1502
+ }
1503
+ createDraft(base) {
1504
+ if (!isDraftable(base))
1505
+ die(8);
1506
+ if (isDraft(base))
1507
+ base = current(base);
1508
+ const scope = enterScope(this);
1509
+ const proxy = createProxy(scope, base, void 0);
1510
+ proxy[DRAFT_STATE].isManual_ = true;
1511
+ leaveScope(scope);
1512
+ return proxy;
1513
+ }
1514
+ finishDraft(draft, patchListener) {
1515
+ const state = draft && draft[DRAFT_STATE];
1516
+ if (!state || !state.isManual_)
1517
+ die(9);
1518
+ const { scope_: scope } = state;
1519
+ usePatchesInScope(scope, patchListener);
1520
+ return processResult(void 0, scope);
1521
+ }
1522
+ /**
1523
+ * Pass true to automatically freeze all copies created by Immer.
1524
+ *
1525
+ * By default, auto-freezing is enabled.
1526
+ */
1527
+ setAutoFreeze(value) {
1528
+ this.autoFreeze_ = value;
1529
+ }
1530
+ /**
1531
+ * Pass true to enable strict shallow copy.
1532
+ *
1533
+ * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
1534
+ */
1535
+ setUseStrictShallowCopy(value) {
1536
+ this.useStrictShallowCopy_ = value;
1537
+ }
1538
+ /**
1539
+ * Pass false to use faster iteration that skips non-enumerable properties
1540
+ * but still handles symbols for compatibility.
1541
+ *
1542
+ * By default, strict iteration is enabled (includes all own properties).
1543
+ */
1544
+ setUseStrictIteration(value) {
1545
+ this.useStrictIteration_ = value;
1546
+ }
1547
+ shouldUseStrictIteration() {
1548
+ return this.useStrictIteration_;
1549
+ }
1550
+ applyPatches(base, patches) {
1551
+ let i;
1552
+ for (i = patches.length - 1; i >= 0; i--) {
1553
+ const patch = patches[i];
1554
+ if (patch.path.length === 0 && patch.op === "replace") {
1555
+ base = patch.value;
1556
+ break;
1557
+ }
1392
1558
  }
1393
- const selectSelf = (state) => state;
1394
- const injectedSelectorCache = /* @__PURE__ */ new Map();
1395
- const injectedStateCache = /* @__PURE__ */ new WeakMap();
1396
- let _reducer;
1397
- function reducer(state, action) {
1398
- if (!_reducer) _reducer = buildReducer();
1399
- return _reducer(state, action);
1559
+ if (i > -1) {
1560
+ patches = patches.slice(i + 1);
1400
1561
  }
1401
- function getInitialState() {
1402
- if (!_reducer) _reducer = buildReducer();
1403
- return _reducer.getInitialState();
1562
+ const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
1563
+ if (isDraft(base)) {
1564
+ return applyPatchesImpl(base, patches);
1404
1565
  }
1405
- function makeSelectorProps(reducerPath2, injected = false) {
1406
- function selectSlice(state) {
1407
- let sliceState = state[reducerPath2];
1408
- if (typeof sliceState === "undefined") {
1409
- if (injected) {
1410
- sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
1411
- } else if (process.env.NODE_ENV !== "production") {
1412
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
1413
- }
1414
- }
1415
- return sliceState;
1566
+ return this.produce(
1567
+ base,
1568
+ (draft) => applyPatchesImpl(draft, patches)
1569
+ );
1570
+ }
1571
+ };
1572
+ function createProxy(rootScope, value, parent, key) {
1573
+ const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
1574
+ const scope = parent?.scope_ ?? getCurrentScope();
1575
+ scope.drafts_.push(draft);
1576
+ state.callbacks_ = parent?.callbacks_ ?? [];
1577
+ state.key_ = key;
1578
+ if (parent && key !== void 0) {
1579
+ registerChildFinalizationCallback(parent, state, key);
1580
+ } else {
1581
+ state.callbacks_.push(function rootDraftCleanup(rootScope2) {
1582
+ rootScope2.mapSetPlugin_?.fixSetContents(state);
1583
+ const { patchPlugin_ } = rootScope2;
1584
+ if (state.modified_ && patchPlugin_) {
1585
+ patchPlugin_.generatePatches_(state, [], rootScope2);
1416
1586
  }
1417
- function getSelectors(selectState = selectSelf) {
1418
- const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
1419
- return getOrInsertComputed(selectorCache, selectState, () => {
1420
- const map = {};
1421
- for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
1422
- map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
1423
- }
1424
- return map;
1425
- });
1587
+ });
1588
+ }
1589
+ return draft;
1590
+ }
1591
+ function current(value) {
1592
+ if (!isDraft(value))
1593
+ die(10, value);
1594
+ return currentImpl(value);
1595
+ }
1596
+ function currentImpl(value) {
1597
+ if (!isDraftable(value) || isFrozen(value))
1598
+ return value;
1599
+ const state = value[DRAFT_STATE];
1600
+ let copy;
1601
+ let strict = true;
1602
+ if (state) {
1603
+ if (!state.modified_)
1604
+ return state.base_;
1605
+ state.finalized_ = true;
1606
+ copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
1607
+ strict = state.scope_.immer_.shouldUseStrictIteration();
1608
+ } else {
1609
+ copy = shallowCopy(value, true);
1610
+ }
1611
+ each(
1612
+ copy,
1613
+ (key, childValue) => {
1614
+ set(copy, key, currentImpl(childValue));
1615
+ },
1616
+ strict
1617
+ );
1618
+ if (state) {
1619
+ state.finalized_ = false;
1620
+ }
1621
+ return copy;
1622
+ }
1623
+ var immer = new Immer2();
1624
+ var produce = immer.produce;
1625
+
1626
+ // node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
1627
+ var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
1628
+ if (arguments.length === 0) return void 0;
1629
+ if (typeof arguments[0] === "object") return compose;
1630
+ return compose.apply(null, arguments);
1631
+ };
1632
+ var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
1633
+ return function(noop3) {
1634
+ return noop3;
1635
+ };
1636
+ };
1637
+ var hasMatchFunction = (v) => {
1638
+ return v && typeof v.match === "function";
1639
+ };
1640
+ function createAction(type, prepareAction) {
1641
+ function actionCreator(...args) {
1642
+ if (prepareAction) {
1643
+ let prepared = prepareAction(...args);
1644
+ if (!prepared) {
1645
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
1426
1646
  }
1427
1647
  return {
1428
- reducerPath: reducerPath2,
1429
- getSelectors,
1430
- get selectors() {
1431
- return getSelectors(selectSlice);
1648
+ type,
1649
+ payload: prepared.payload,
1650
+ ..."meta" in prepared && {
1651
+ meta: prepared.meta
1432
1652
  },
1433
- selectSlice
1653
+ ..."error" in prepared && {
1654
+ error: prepared.error
1655
+ }
1434
1656
  };
1435
1657
  }
1436
- const slice = {
1437
- name,
1438
- reducer,
1439
- actions: context.actionCreators,
1440
- caseReducers: context.sliceCaseReducersByName,
1441
- getInitialState,
1442
- ...makeSelectorProps(reducerPath),
1443
- injectInto(injectable, {
1444
- reducerPath: pathOpt,
1445
- ...config
1446
- } = {}) {
1447
- const newReducerPath = pathOpt ?? reducerPath;
1448
- injectable.inject({
1449
- reducerPath: newReducerPath,
1450
- reducer
1451
- }, config);
1452
- return {
1453
- ...slice,
1454
- ...makeSelectorProps(newReducerPath, true)
1455
- };
1456
- }
1658
+ return {
1659
+ type,
1660
+ payload: args[0]
1457
1661
  };
1458
- return slice;
1459
- };
1460
- }
1461
- function wrapSelector(selector, selectState, getInitialState, injected) {
1462
- function wrapper(rootState, ...args) {
1463
- let sliceState = selectState(rootState);
1464
- if (typeof sliceState === "undefined") {
1465
- if (injected) {
1466
- sliceState = getInitialState();
1467
- } else if (process.env.NODE_ENV !== "production") {
1468
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
1469
- }
1470
- }
1471
- return selector(sliceState, ...args);
1472
1662
  }
1473
- wrapper.unwrapped = selector;
1474
- return wrapper;
1663
+ actionCreator.toString = () => `${type}`;
1664
+ actionCreator.type = type;
1665
+ actionCreator.match = (action) => isAction(action) && action.type === type;
1666
+ return actionCreator;
1475
1667
  }
1476
- var createSlice = /* @__PURE__ */ buildCreateSlice();
1477
- function buildReducerCreators() {
1478
- function asyncThunk(payloadCreator, config) {
1479
- return {
1480
- _reducerDefinitionType: "asyncThunk",
1481
- payloadCreator,
1482
- ...config
1483
- };
1484
- }
1485
- asyncThunk.withTypes = () => asyncThunk;
1486
- return {
1487
- reducer(caseReducer) {
1488
- return Object.assign({
1489
- // hack so the wrapping function has the same name as the original
1490
- // we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
1491
- [caseReducer.name](...args) {
1492
- return caseReducer(...args);
1668
+ function freezeDraftable(val) {
1669
+ return isDraftable(val) ? produce(val, () => {
1670
+ }) : val;
1671
+ }
1672
+ function getOrInsertComputed(map, key, compute) {
1673
+ if (map.has(key)) return map.get(key);
1674
+ return map.set(key, compute(key)).get(key);
1675
+ }
1676
+ function executeReducerBuilderCallback(builderCallback) {
1677
+ const actionsMap = {};
1678
+ const actionMatchers = [];
1679
+ let defaultCaseReducer;
1680
+ const builder = {
1681
+ addCase(typeOrActionCreator, reducer) {
1682
+ if (process.env.NODE_ENV !== "production") {
1683
+ if (actionMatchers.length > 0) {
1684
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
1493
1685
  }
1494
- }[caseReducer.name], {
1495
- _reducerDefinitionType: "reducer"
1496
- /* reducer */
1686
+ if (defaultCaseReducer) {
1687
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
1688
+ }
1689
+ }
1690
+ const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1691
+ if (!type) {
1692
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
1693
+ }
1694
+ if (type in actionsMap) {
1695
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
1696
+ }
1697
+ actionsMap[type] = reducer;
1698
+ return builder;
1699
+ },
1700
+ addAsyncThunk(asyncThunk, reducers2) {
1701
+ if (process.env.NODE_ENV !== "production") {
1702
+ if (defaultCaseReducer) {
1703
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
1704
+ }
1705
+ }
1706
+ if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
1707
+ if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
1708
+ if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
1709
+ if (reducers2.settled) actionMatchers.push({
1710
+ matcher: asyncThunk.settled,
1711
+ reducer: reducers2.settled
1497
1712
  });
1713
+ return builder;
1498
1714
  },
1499
- preparedReducer(prepare, reducer) {
1500
- return {
1501
- _reducerDefinitionType: "reducerWithPrepare",
1502
- prepare,
1715
+ addMatcher(matcher, reducer) {
1716
+ if (process.env.NODE_ENV !== "production") {
1717
+ if (defaultCaseReducer) {
1718
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
1719
+ }
1720
+ }
1721
+ actionMatchers.push({
1722
+ matcher,
1503
1723
  reducer
1504
- };
1724
+ });
1725
+ return builder;
1505
1726
  },
1506
- asyncThunk
1727
+ addDefaultCase(reducer) {
1728
+ if (process.env.NODE_ENV !== "production") {
1729
+ if (defaultCaseReducer) {
1730
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
1731
+ }
1732
+ }
1733
+ defaultCaseReducer = reducer;
1734
+ return builder;
1735
+ }
1507
1736
  };
1737
+ builderCallback(builder);
1738
+ return [actionsMap, actionMatchers, defaultCaseReducer];
1508
1739
  }
1509
- function handleNormalReducerDefinition({
1510
- type,
1511
- reducerName,
1512
- createNotation
1513
- }, maybeReducerWithPrepare, context) {
1514
- let caseReducer;
1515
- let prepareCallback;
1516
- if ("reducer" in maybeReducerWithPrepare) {
1517
- if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
1518
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
1740
+ function isStateFunction(x) {
1741
+ return typeof x === "function";
1742
+ }
1743
+ function createReducer(initialState, mapOrBuilderCallback) {
1744
+ if (process.env.NODE_ENV !== "production") {
1745
+ if (typeof mapOrBuilderCallback === "object") {
1746
+ 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");
1519
1747
  }
1520
- caseReducer = maybeReducerWithPrepare.reducer;
1521
- prepareCallback = maybeReducerWithPrepare.prepare;
1748
+ }
1749
+ let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
1750
+ let getInitialState;
1751
+ if (isStateFunction(initialState)) {
1752
+ getInitialState = () => freezeDraftable(initialState());
1522
1753
  } else {
1523
- caseReducer = maybeReducerWithPrepare;
1754
+ const frozenInitialState = freezeDraftable(initialState);
1755
+ getInitialState = () => frozenInitialState;
1524
1756
  }
1525
- context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
1526
- }
1527
- function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
1528
- return reducerDefinition._reducerDefinitionType === "asyncThunk";
1529
- }
1530
- function isCaseReducerWithPrepareDefinition(reducerDefinition) {
1531
- return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
1757
+ function reducer(state = getInitialState(), action) {
1758
+ let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
1759
+ matcher
1760
+ }) => matcher(action)).map(({
1761
+ reducer: reducer2
1762
+ }) => reducer2)];
1763
+ if (caseReducers.filter((cr) => !!cr).length === 0) {
1764
+ caseReducers = [finalDefaultCaseReducer];
1765
+ }
1766
+ return caseReducers.reduce((previousState, caseReducer) => {
1767
+ if (caseReducer) {
1768
+ if (isDraft(previousState)) {
1769
+ const draft = previousState;
1770
+ const result = caseReducer(draft, action);
1771
+ if (result === void 0) {
1772
+ return previousState;
1773
+ }
1774
+ return result;
1775
+ } else if (!isDraftable(previousState)) {
1776
+ const result = caseReducer(previousState, action);
1777
+ if (result === void 0) {
1778
+ if (previousState === null) {
1779
+ return previousState;
1780
+ }
1781
+ throw Error("A case reducer on a non-draftable value must not return undefined");
1782
+ }
1783
+ return result;
1784
+ } else {
1785
+ return produce(previousState, (draft) => {
1786
+ return caseReducer(draft, action);
1787
+ });
1788
+ }
1789
+ }
1790
+ return previousState;
1791
+ }, state);
1792
+ }
1793
+ reducer.getInitialState = getInitialState;
1794
+ return reducer;
1532
1795
  }
1533
- function handleThunkCaseReducerDefinition({
1534
- type,
1535
- reducerName
1536
- }, reducerDefinition, context, cAT) {
1537
- if (!cAT) {
1538
- 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`.");
1796
+ var matches = (matcher, action) => {
1797
+ if (hasMatchFunction(matcher)) {
1798
+ return matcher.match(action);
1799
+ } else {
1800
+ return matcher(action);
1539
1801
  }
1540
- const {
1541
- payloadCreator,
1542
- fulfilled,
1543
- pending,
1544
- rejected,
1545
- settled,
1546
- options
1547
- } = reducerDefinition;
1548
- const thunk = cAT(type, payloadCreator, options);
1549
- context.exposeAction(reducerName, thunk);
1550
- if (fulfilled) {
1551
- context.addCase(thunk.fulfilled, fulfilled);
1802
+ };
1803
+ function isAnyOf(...matchers) {
1804
+ return (action) => {
1805
+ return matchers.some((matcher) => matches(matcher, action));
1806
+ };
1807
+ }
1808
+ var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
1809
+ var nanoid = (size = 21) => {
1810
+ let id = "";
1811
+ let i = size;
1812
+ while (i--) {
1813
+ id += urlAlphabet[Math.random() * 64 | 0];
1552
1814
  }
1553
- if (pending) {
1554
- context.addCase(thunk.pending, pending);
1815
+ return id;
1816
+ };
1817
+ var commonProperties = ["name", "message", "stack", "code"];
1818
+ var RejectWithValue = class {
1819
+ constructor(payload, meta) {
1820
+ __publicField(this, "payload");
1821
+ __publicField(this, "meta");
1822
+ /*
1823
+ type-only property to distinguish between RejectWithValue and FulfillWithMeta
1824
+ does not exist at runtime
1825
+ */
1826
+ __publicField(this, "_type");
1827
+ this.payload = payload;
1828
+ this.meta = meta;
1555
1829
  }
1556
- if (rejected) {
1557
- context.addCase(thunk.rejected, rejected);
1830
+ };
1831
+ var FulfillWithMeta = class {
1832
+ constructor(payload, meta) {
1833
+ __publicField(this, "payload");
1834
+ __publicField(this, "meta");
1835
+ /*
1836
+ type-only property to distinguish between RejectWithValue and FulfillWithMeta
1837
+ does not exist at runtime
1838
+ */
1839
+ __publicField(this, "_type");
1840
+ this.payload = payload;
1841
+ this.meta = meta;
1558
1842
  }
1559
- if (settled) {
1560
- context.addMatcher(thunk.settled, settled);
1843
+ };
1844
+ var miniSerializeError = (value) => {
1845
+ if (typeof value === "object" && value !== null) {
1846
+ const simpleError = {};
1847
+ for (const property of commonProperties) {
1848
+ if (typeof value[property] === "string") {
1849
+ simpleError[property] = value[property];
1850
+ }
1851
+ }
1852
+ return simpleError;
1561
1853
  }
1562
- context.exposeCaseReducer(reducerName, {
1563
- fulfilled: fulfilled || noop,
1564
- pending: pending || noop,
1565
- rejected: rejected || noop,
1566
- settled: settled || noop
1567
- });
1568
- }
1569
- function noop() {
1570
- }
1571
- var listener = "listener";
1572
- var completed = "completed";
1573
- var cancelled = "cancelled";
1574
- var taskCancelled = `task-${cancelled}`;
1575
- var taskCompleted = `task-${completed}`;
1576
- var listenerCancelled = `${listener}-${cancelled}`;
1577
- var listenerCompleted = `${listener}-${completed}`;
1578
- var {
1579
- assign
1580
- } = Object;
1581
- var alm = "listenerMiddleware";
1582
- var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
1583
- withTypes: () => addListener
1584
- });
1585
- var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
1586
- var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
1587
- withTypes: () => removeListener
1588
- });
1589
- function formatProdErrorMessage(code) {
1590
- 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. `;
1591
- }
1592
-
1593
- // src/redux/themeSlice.ts
1594
- var defaultInitialState = {
1595
- appearance: "system",
1596
- color: "#6750a4"
1597
- };
1598
- var reducers = {
1599
- initialize: (state, action) => ({ ...state, ...action.payload }),
1600
- setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
1601
- setColor: (state, action) => ({ ...state, color: action.payload })
1602
- };
1603
- function createThemeReducer(initialState) {
1604
- return createSlice({
1605
- name: "theme",
1606
- initialState: { ...defaultInitialState, ...initialState },
1607
- reducers
1608
- }).reducer;
1609
- }
1610
- var defaultSlice = createSlice({
1611
- name: "theme",
1612
- initialState: defaultInitialState,
1613
- reducers
1614
- });
1615
- var themeActions = defaultSlice.actions;
1616
- var themeReducer = defaultSlice.reducer;
1617
- var selectThemeAppearance = (state) => state.appearance;
1618
- var selectThemeColor = (state) => state.color;
1619
-
1620
- // src/ThemeProvider.tsx
1621
- import { useEffect as useEffect2, useRef } from "react";
1622
- import { StatusBar, StyleSheet, View } from "react-native";
1623
- import { Provider as PaperProvider } from "react-native-paper";
1624
-
1625
- // src/useComputedTheme.ts
1626
- import { useCallback, useEffect, useState } from "react";
1627
- import { Appearance } from "react-native";
1628
- import { MD3DarkTheme, MD3LightTheme } from "react-native-paper";
1629
-
1630
- // src/utils/colorNames.ts
1631
- var colorNames = {
1632
- aliceblue: "#f0f8ff",
1633
- antiquewhite: "#faebd7",
1634
- aqua: "#00ffff",
1635
- aquamarine: "#7fffd4",
1636
- azure: "#f0ffff",
1637
- beige: "#f5f5dc",
1638
- bisque: "#ffe4c4",
1639
- black: "#000000",
1640
- blanchedalmond: "#ffebcd",
1641
- blue: "#0000ff",
1642
- blueviolet: "#8a2be2",
1643
- brown: "#a52a2a",
1644
- burlywood: "#deb887",
1645
- cadetblue: "#5f9ea0",
1646
- chartreuse: "#7fff00",
1647
- chocolate: "#d2691e",
1648
- coral: "#ff7f50",
1649
- cornflowerblue: "#6495ed",
1650
- cornsilk: "#fff8dc",
1651
- crimson: "#dc143c",
1652
- cyan: "#00ffff",
1653
- darkblue: "#00008b",
1654
- darkcyan: "#008b8b",
1655
- darkgoldenrod: "#b8860b",
1656
- darkgray: "#a9a9a9",
1657
- darkgrey: "#a9a9a9",
1658
- darkgreen: "#006400",
1659
- darkkhaki: "#bdb76b",
1660
- darkmagenta: "#8b008b",
1661
- darkolivegreen: "#556b2f",
1662
- darkorange: "#ff8c00",
1663
- darkorchid: "#9932cc",
1664
- darkred: "#8b0000",
1665
- darksalmon: "#e9967a",
1666
- darkseagreen: "#8fbc8f",
1667
- darkslateblue: "#483d8b",
1668
- darkslategray: "#2f4f4f",
1669
- darkslategrey: "#2f4f4f",
1670
- darkturquoise: "#00ced1",
1671
- darkviolet: "#9400d3",
1672
- deeppink: "#ff1493",
1673
- deepskyblue: "#00bfff",
1674
- dimgray: "#696969",
1675
- dimgrey: "#696969",
1676
- dodgerblue: "#1e90ff",
1677
- firebrick: "#b22222",
1678
- floralwhite: "#fffaf0",
1679
- forestgreen: "#228b22",
1680
- fuchsia: "#ff00ff",
1681
- gainsboro: "#dcdcdc",
1682
- ghostwhite: "#f8f8ff",
1683
- gold: "#ffd700",
1684
- goldenrod: "#daa520",
1685
- gray: "#808080",
1686
- grey: "#808080",
1687
- green: "#008000",
1688
- greenyellow: "#adff2f",
1689
- honeydew: "#f0fff0",
1690
- hotpink: "#ff69b4",
1691
- indianred: "#cd5c5c",
1692
- indigo: "#4b0082",
1693
- ivory: "#fffff0",
1694
- khaki: "#f0e68c",
1695
- lavender: "#e6e6fa",
1696
- lavenderblush: "#fff0f5",
1697
- lawngreen: "#7cfc00",
1698
- lemonchiffon: "#fffacd",
1699
- lightblue: "#add8e6",
1700
- lightcoral: "#f08080",
1701
- lightcyan: "#e0ffff",
1702
- lightgoldenrodyellow: "#fafad2",
1703
- lightgray: "#d3d3d3",
1704
- lightgrey: "#d3d3d3",
1705
- lightgreen: "#90ee90",
1706
- lightpink: "#ffb6c1",
1707
- lightsalmon: "#ffa07a",
1708
- lightseagreen: "#20b2aa",
1709
- lightskyblue: "#87cefa",
1710
- lightslategray: "#778899",
1711
- lightslategrey: "#778899",
1712
- lightsteelblue: "#b0c4de",
1713
- lightyellow: "#ffffe0",
1714
- lime: "#00ff00",
1715
- limegreen: "#32cd32",
1716
- linen: "#faf0e6",
1717
- magenta: "#ff00ff",
1718
- maroon: "#800000",
1719
- mediumaquamarine: "#66cdaa",
1720
- mediumblue: "#0000cd",
1721
- mediumorchid: "#ba55d3",
1722
- mediumpurple: "#9370db",
1723
- mediumseagreen: "#3cb371",
1724
- mediumslateblue: "#7b68ee",
1725
- mediumspringgreen: "#00fa9a",
1726
- mediumturquoise: "#48d1cc",
1727
- mediumvioletred: "#c71585",
1728
- midnightblue: "#191970",
1729
- mintcream: "#f5fffa",
1730
- mistyrose: "#ffe4e1",
1731
- moccasin: "#ffe4b5",
1732
- navajowhite: "#ffdead",
1733
- navy: "#000080",
1734
- oldlace: "#fdf5e6",
1735
- olive: "#808000",
1736
- olivedrab: "#6b8e23",
1737
- orange: "#ffa500",
1738
- orangered: "#ff4500",
1739
- orchid: "#da70d6",
1740
- palegoldenrod: "#eee8aa",
1741
- palegreen: "#98fb98",
1742
- paleturquoise: "#afeeee",
1743
- palevioletred: "#db7093",
1744
- papayawhip: "#ffefd5",
1745
- peachpuff: "#ffdab9",
1746
- peru: "#cd853f",
1747
- pink: "#ffc0cb",
1748
- plum: "#dda0dd",
1749
- powderblue: "#b0e0e6",
1750
- purple: "#800080",
1751
- rebeccapurple: "#663399",
1752
- red: "#ff0000",
1753
- rosybrown: "#bc8f8f",
1754
- royalblue: "#4169e1",
1755
- saddlebrown: "#8b4513",
1756
- salmon: "#fa8072",
1757
- sandybrown: "#f4a460",
1758
- seagreen: "#2e8b57",
1759
- seashell: "#fff5ee",
1760
- sienna: "#a0522d",
1761
- silver: "#c0c0c0",
1762
- skyblue: "#87ceeb",
1763
- slateblue: "#6a5acd",
1764
- slategray: "#708090",
1765
- slategrey: "#708090",
1766
- snow: "#fffafa",
1767
- springgreen: "#00ff7f",
1768
- steelblue: "#4682b4",
1769
- tan: "#d2b48c",
1770
- teal: "#008080",
1771
- thistle: "#d8bfd8",
1772
- tomato: "#ff6347",
1773
- transparent: "transparent",
1774
- turquoise: "#40e0d0",
1775
- violet: "#ee82ee",
1776
- wheat: "#f5deb3",
1777
- white: "#ffffff",
1778
- whitesmoke: "#f5f5f5",
1779
- yellow: "#ffff00",
1780
- yellowgreen: "#9acd32"
1854
+ return {
1855
+ message: String(value)
1856
+ };
1781
1857
  };
1782
-
1783
- // src/utils/getRgb.ts
1784
- var getRgb = (value) => {
1785
- if (!value) return null;
1786
- let trimmed = value.trim().toLowerCase();
1787
- const namedColor = colorNames[trimmed];
1788
- if (namedColor) trimmed = namedColor;
1789
- const hexMatch = trimmed.match(/^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i);
1790
- if (hexMatch) {
1791
- const hex = hexMatch[1];
1792
- let normalized = hex;
1793
- if (hex.length === 3) {
1794
- normalized = hex.split("").map((c) => c + c).join("");
1795
- } else if (hex.length === 8) {
1796
- const alpha = parseInt(hex.substring(6, 8), 16);
1797
- normalized = hex.substring(0, 6);
1798
- const intVal2 = parseInt(normalized, 16);
1799
- return {
1800
- r: intVal2 >> 16 & 255,
1801
- g: intVal2 >> 8 & 255,
1802
- b: intVal2 & 255,
1803
- a: alpha / 255
1858
+ var externalAbortMessage = "External signal was aborted";
1859
+ var createAsyncThunk = /* @__PURE__ */ (() => {
1860
+ function createAsyncThunk2(typePrefix, payloadCreator, options) {
1861
+ const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
1862
+ payload,
1863
+ meta: {
1864
+ ...meta || {},
1865
+ arg,
1866
+ requestId,
1867
+ requestStatus: "fulfilled"
1868
+ }
1869
+ }));
1870
+ const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
1871
+ payload: void 0,
1872
+ meta: {
1873
+ ...meta || {},
1874
+ arg,
1875
+ requestId,
1876
+ requestStatus: "pending"
1877
+ }
1878
+ }));
1879
+ const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
1880
+ payload,
1881
+ error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1882
+ meta: {
1883
+ ...meta || {},
1884
+ arg,
1885
+ requestId,
1886
+ rejectedWithValue: !!payload,
1887
+ requestStatus: "rejected",
1888
+ aborted: error?.name === "AbortError",
1889
+ condition: error?.name === "ConditionError"
1890
+ }
1891
+ }));
1892
+ function actionCreator(arg, {
1893
+ signal
1894
+ } = {}) {
1895
+ return (dispatch, getState, extra) => {
1896
+ const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
1897
+ const abortController = new AbortController();
1898
+ let abortHandler;
1899
+ let abortReason;
1900
+ function abort(reason) {
1901
+ abortReason = reason;
1902
+ abortController.abort();
1903
+ }
1904
+ if (signal) {
1905
+ if (signal.aborted) {
1906
+ abort(externalAbortMessage);
1907
+ } else {
1908
+ signal.addEventListener("abort", () => abort(externalAbortMessage), {
1909
+ once: true
1910
+ });
1911
+ }
1912
+ }
1913
+ const promise = (async function() {
1914
+ let finalAction;
1915
+ try {
1916
+ let conditionResult = options?.condition?.(arg, {
1917
+ getState,
1918
+ extra
1919
+ });
1920
+ if (isThenable(conditionResult)) {
1921
+ conditionResult = await conditionResult;
1922
+ }
1923
+ if (conditionResult === false || abortController.signal.aborted) {
1924
+ throw {
1925
+ name: "ConditionError",
1926
+ message: "Aborted due to condition callback returning false."
1927
+ };
1928
+ }
1929
+ const abortedPromise = new Promise((_, reject) => {
1930
+ abortHandler = () => {
1931
+ reject({
1932
+ name: "AbortError",
1933
+ message: abortReason || "Aborted"
1934
+ });
1935
+ };
1936
+ abortController.signal.addEventListener("abort", abortHandler, {
1937
+ once: true
1938
+ });
1939
+ });
1940
+ dispatch(pending(requestId, arg, options?.getPendingMeta?.({
1941
+ requestId,
1942
+ arg
1943
+ }, {
1944
+ getState,
1945
+ extra
1946
+ })));
1947
+ finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
1948
+ dispatch,
1949
+ getState,
1950
+ extra,
1951
+ requestId,
1952
+ signal: abortController.signal,
1953
+ abort,
1954
+ rejectWithValue: ((value, meta) => {
1955
+ return new RejectWithValue(value, meta);
1956
+ }),
1957
+ fulfillWithValue: ((value, meta) => {
1958
+ return new FulfillWithMeta(value, meta);
1959
+ })
1960
+ })).then((result) => {
1961
+ if (result instanceof RejectWithValue) {
1962
+ throw result;
1963
+ }
1964
+ if (result instanceof FulfillWithMeta) {
1965
+ return fulfilled(result.payload, requestId, arg, result.meta);
1966
+ }
1967
+ return fulfilled(result, requestId, arg);
1968
+ })]);
1969
+ } catch (err) {
1970
+ finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
1971
+ } finally {
1972
+ if (abortHandler) {
1973
+ abortController.signal.removeEventListener("abort", abortHandler);
1974
+ }
1975
+ }
1976
+ const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
1977
+ if (!skipDispatch) {
1978
+ dispatch(finalAction);
1979
+ }
1980
+ return finalAction;
1981
+ })();
1982
+ return Object.assign(promise, {
1983
+ abort,
1984
+ requestId,
1985
+ arg,
1986
+ unwrap() {
1987
+ return promise.then(unwrapResult);
1988
+ }
1989
+ });
1804
1990
  };
1805
1991
  }
1806
- const intVal = parseInt(normalized, 16);
1807
- return {
1808
- r: intVal >> 16 & 255,
1809
- g: intVal >> 8 & 255,
1810
- b: intVal & 255
1811
- };
1992
+ return Object.assign(actionCreator, {
1993
+ pending,
1994
+ rejected,
1995
+ fulfilled,
1996
+ settled: isAnyOf(rejected, fulfilled),
1997
+ typePrefix
1998
+ });
1812
1999
  }
1813
- const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*([0-9.]+))?\s*\)$/i);
1814
- if (rgbMatch) {
1815
- const result = {
1816
- r: Number(rgbMatch[1]),
1817
- g: Number(rgbMatch[2]),
1818
- b: Number(rgbMatch[3])
1819
- };
1820
- if (rgbMatch[4] !== void 0) {
1821
- result.a = Number(rgbMatch[4]);
1822
- }
1823
- return result;
2000
+ createAsyncThunk2.withTypes = () => createAsyncThunk2;
2001
+ return createAsyncThunk2;
2002
+ })();
2003
+ function unwrapResult(action) {
2004
+ if (action.meta && action.meta.rejectedWithValue) {
2005
+ throw action.payload;
1824
2006
  }
1825
- return null;
1826
- };
1827
-
1828
- // src/utils/getHex.ts
1829
- var getHex = (value) => {
1830
- const rgb = getRgb(value);
1831
- if (!rgb) return null;
1832
- const toHex = (n) => {
1833
- const hex = Math.round(n).toString(16);
1834
- return hex.length === 1 ? "0" + hex : hex;
1835
- };
1836
- const hexString = `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`;
1837
- if (rgb.a !== void 0) {
1838
- return `${hexString}${toHex(rgb.a * 255)}`;
2007
+ if (action.error) {
2008
+ throw action.error;
1839
2009
  }
1840
- return hexString;
1841
- };
1842
-
1843
- // src/utils/getBlendedColor.ts
1844
- var getBlendedColor = (foreground, background, alpha) => {
1845
- const fg = getRgb(foreground);
1846
- const bg = getRgb(background);
1847
- if (!fg || !bg) return background;
1848
- const safeAlpha = Math.min(1, Math.max(0, alpha));
1849
- const r = Math.round(fg.r * safeAlpha + bg.r * (1 - safeAlpha));
1850
- const g = Math.round(fg.g * safeAlpha + bg.g * (1 - safeAlpha));
1851
- const b = Math.round(fg.b * safeAlpha + bg.b * (1 - safeAlpha));
1852
- return getHex(`rgb(${r}, ${g}, ${b})`) ?? background;
2010
+ return action.payload;
2011
+ }
2012
+ function isThenable(value) {
2013
+ return value !== null && typeof value === "object" && typeof value.then === "function";
2014
+ }
2015
+ var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
2016
+ var asyncThunkCreator = {
2017
+ [asyncThunkSymbol]: createAsyncThunk
1853
2018
  };
1854
-
1855
- // src/utils/getTriadicPalette.ts
1856
- function getTriadicPalette(primaryColor) {
1857
- const rgb = getRgb(primaryColor);
1858
- if (!rgb) throw new Error(`Invalid color format: ${primaryColor}`);
1859
- const r = rgb.r / 255;
1860
- const g = rgb.g / 255;
1861
- const b = rgb.b / 255;
1862
- const max = Math.max(r, g, b);
1863
- const min = Math.min(r, g, b);
1864
- const l = (max + min) / 2;
1865
- let h = 0;
1866
- let s = 0;
1867
- if (max !== min) {
1868
- const d = max - min;
1869
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
1870
- switch (max) {
1871
- case r:
1872
- h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
1873
- break;
1874
- case g:
1875
- h = ((b - r) / d + 2) / 6;
1876
- break;
1877
- case b:
1878
- h = ((r - g) / d + 4) / 6;
1879
- break;
2019
+ function getType(slice, actionKey) {
2020
+ return `${slice}/${actionKey}`;
2021
+ }
2022
+ function buildCreateSlice({
2023
+ creators
2024
+ } = {}) {
2025
+ const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
2026
+ return function createSlice2(options) {
2027
+ const {
2028
+ name,
2029
+ reducerPath = name
2030
+ } = options;
2031
+ if (!name) {
2032
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
2033
+ }
2034
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
2035
+ if (options.initialState === void 0) {
2036
+ console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
2037
+ }
2038
+ }
2039
+ const reducers2 = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
2040
+ const reducerNames = Object.keys(reducers2);
2041
+ const context = {
2042
+ sliceCaseReducersByName: {},
2043
+ sliceCaseReducersByType: {},
2044
+ actionCreators: {},
2045
+ sliceMatchers: []
2046
+ };
2047
+ const contextMethods = {
2048
+ addCase(typeOrActionCreator, reducer2) {
2049
+ const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
2050
+ if (!type) {
2051
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
2052
+ }
2053
+ if (type in context.sliceCaseReducersByType) {
2054
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
2055
+ }
2056
+ context.sliceCaseReducersByType[type] = reducer2;
2057
+ return contextMethods;
2058
+ },
2059
+ addMatcher(matcher, reducer2) {
2060
+ context.sliceMatchers.push({
2061
+ matcher,
2062
+ reducer: reducer2
2063
+ });
2064
+ return contextMethods;
2065
+ },
2066
+ exposeAction(name2, actionCreator) {
2067
+ context.actionCreators[name2] = actionCreator;
2068
+ return contextMethods;
2069
+ },
2070
+ exposeCaseReducer(name2, reducer2) {
2071
+ context.sliceCaseReducersByName[name2] = reducer2;
2072
+ return contextMethods;
2073
+ }
2074
+ };
2075
+ reducerNames.forEach((reducerName) => {
2076
+ const reducerDefinition = reducers2[reducerName];
2077
+ const reducerDetails = {
2078
+ reducerName,
2079
+ type: getType(name, reducerName),
2080
+ createNotation: typeof options.reducers === "function"
2081
+ };
2082
+ if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
2083
+ handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
2084
+ } else {
2085
+ handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
2086
+ }
2087
+ });
2088
+ function buildReducer() {
2089
+ if (process.env.NODE_ENV !== "production") {
2090
+ if (typeof options.extraReducers === "object") {
2091
+ 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");
2092
+ }
2093
+ }
2094
+ const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
2095
+ const finalCaseReducers = {
2096
+ ...extraReducers,
2097
+ ...context.sliceCaseReducersByType
2098
+ };
2099
+ return createReducer(options.initialState, (builder) => {
2100
+ for (let key in finalCaseReducers) {
2101
+ builder.addCase(key, finalCaseReducers[key]);
2102
+ }
2103
+ for (let sM of context.sliceMatchers) {
2104
+ builder.addMatcher(sM.matcher, sM.reducer);
2105
+ }
2106
+ for (let m of actionMatchers) {
2107
+ builder.addMatcher(m.matcher, m.reducer);
2108
+ }
2109
+ if (defaultCaseReducer) {
2110
+ builder.addDefaultCase(defaultCaseReducer);
2111
+ }
2112
+ });
2113
+ }
2114
+ const selectSelf = (state) => state;
2115
+ const injectedSelectorCache = /* @__PURE__ */ new Map();
2116
+ const injectedStateCache = /* @__PURE__ */ new WeakMap();
2117
+ let _reducer;
2118
+ function reducer(state, action) {
2119
+ if (!_reducer) _reducer = buildReducer();
2120
+ return _reducer(state, action);
2121
+ }
2122
+ function getInitialState() {
2123
+ if (!_reducer) _reducer = buildReducer();
2124
+ return _reducer.getInitialState();
2125
+ }
2126
+ function makeSelectorProps(reducerPath2, injected = false) {
2127
+ function selectSlice(state) {
2128
+ let sliceState = state[reducerPath2];
2129
+ if (typeof sliceState === "undefined") {
2130
+ if (injected) {
2131
+ sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
2132
+ } else if (process.env.NODE_ENV !== "production") {
2133
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
2134
+ }
2135
+ }
2136
+ return sliceState;
2137
+ }
2138
+ function getSelectors(selectState = selectSelf) {
2139
+ const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
2140
+ return getOrInsertComputed(selectorCache, selectState, () => {
2141
+ const map = {};
2142
+ for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
2143
+ map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
2144
+ }
2145
+ return map;
2146
+ });
2147
+ }
2148
+ return {
2149
+ reducerPath: reducerPath2,
2150
+ getSelectors,
2151
+ get selectors() {
2152
+ return getSelectors(selectSlice);
2153
+ },
2154
+ selectSlice
2155
+ };
2156
+ }
2157
+ const slice = {
2158
+ name,
2159
+ reducer,
2160
+ actions: context.actionCreators,
2161
+ caseReducers: context.sliceCaseReducersByName,
2162
+ getInitialState,
2163
+ ...makeSelectorProps(reducerPath),
2164
+ injectInto(injectable, {
2165
+ reducerPath: pathOpt,
2166
+ ...config
2167
+ } = {}) {
2168
+ const newReducerPath = pathOpt ?? reducerPath;
2169
+ injectable.inject({
2170
+ reducerPath: newReducerPath,
2171
+ reducer
2172
+ }, config);
2173
+ return {
2174
+ ...slice,
2175
+ ...makeSelectorProps(newReducerPath, true)
2176
+ };
2177
+ }
2178
+ };
2179
+ return slice;
2180
+ };
2181
+ }
2182
+ function wrapSelector(selector, selectState, getInitialState, injected) {
2183
+ function wrapper(rootState, ...args) {
2184
+ let sliceState = selectState(rootState);
2185
+ if (typeof sliceState === "undefined") {
2186
+ if (injected) {
2187
+ sliceState = getInitialState();
2188
+ } else if (process.env.NODE_ENV !== "production") {
2189
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
2190
+ }
1880
2191
  }
2192
+ return selector(sliceState, ...args);
2193
+ }
2194
+ wrapper.unwrapped = selector;
2195
+ return wrapper;
2196
+ }
2197
+ var createSlice = /* @__PURE__ */ buildCreateSlice();
2198
+ function buildReducerCreators() {
2199
+ function asyncThunk(payloadCreator, config) {
2200
+ return {
2201
+ _reducerDefinitionType: "asyncThunk",
2202
+ payloadCreator,
2203
+ ...config
2204
+ };
1881
2205
  }
2206
+ asyncThunk.withTypes = () => asyncThunk;
1882
2207
  return {
1883
- primary: getHex(primaryColor) ?? primaryColor,
1884
- secondary: hslToHex((h + 1 / 3) % 1, s, l),
1885
- tertiary: hslToHex((h + 2 / 3) % 1, s, l)
2208
+ reducer(caseReducer) {
2209
+ return Object.assign({
2210
+ // hack so the wrapping function has the same name as the original
2211
+ // we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
2212
+ [caseReducer.name](...args) {
2213
+ return caseReducer(...args);
2214
+ }
2215
+ }[caseReducer.name], {
2216
+ _reducerDefinitionType: "reducer"
2217
+ /* reducer */
2218
+ });
2219
+ },
2220
+ preparedReducer(prepare, reducer) {
2221
+ return {
2222
+ _reducerDefinitionType: "reducerWithPrepare",
2223
+ prepare,
2224
+ reducer
2225
+ };
2226
+ },
2227
+ asyncThunk
1886
2228
  };
1887
2229
  }
1888
- function hslToHex(h, s, l) {
1889
- const c = (1 - Math.abs(2 * l - 1)) * s;
1890
- const x = c * (1 - Math.abs(h * 6 % 2 - 1));
1891
- const m = l - c / 2;
1892
- let r = 0;
1893
- let g = 0;
1894
- let b = 0;
1895
- if (h < 1 / 6) {
1896
- r = c;
1897
- g = x;
1898
- b = 0;
1899
- } else if (h < 2 / 6) {
1900
- r = x;
1901
- g = c;
1902
- b = 0;
1903
- } else if (h < 3 / 6) {
1904
- r = 0;
1905
- g = c;
1906
- b = x;
1907
- } else if (h < 4 / 6) {
1908
- r = 0;
1909
- g = x;
1910
- b = c;
1911
- } else if (h < 5 / 6) {
1912
- r = x;
1913
- g = 0;
1914
- b = c;
2230
+ function handleNormalReducerDefinition({
2231
+ type,
2232
+ reducerName,
2233
+ createNotation
2234
+ }, maybeReducerWithPrepare, context) {
2235
+ let caseReducer;
2236
+ let prepareCallback;
2237
+ if ("reducer" in maybeReducerWithPrepare) {
2238
+ if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
2239
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
2240
+ }
2241
+ caseReducer = maybeReducerWithPrepare.reducer;
2242
+ prepareCallback = maybeReducerWithPrepare.prepare;
1915
2243
  } else {
1916
- r = c;
1917
- g = 0;
1918
- b = x;
2244
+ caseReducer = maybeReducerWithPrepare;
1919
2245
  }
1920
- const toHex = (value) => {
1921
- const hex = Math.round((value + m) * 255).toString(16);
1922
- return hex.length === 1 ? `0${hex}` : hex;
1923
- };
1924
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
2246
+ context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
1925
2247
  }
1926
-
1927
- // src/utils/isDarkColor.ts
1928
- var isDarkColor = (value) => {
1929
- const rgb = getRgb(value);
1930
- if (!rgb) return false;
1931
- const [r, g, b] = [rgb.r / 255, rgb.g / 255, rgb.b / 255];
1932
- const [rs, gs, bs] = [r, g, b].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
1933
- const luminance = 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
1934
- return luminance < 0.5;
1935
- };
1936
-
1937
- // src/useComputedTheme.ts
1938
- function useComputedTheme(appearance, color) {
1939
- const [theme, setTheme] = useState(null);
1940
- const computeTheme = useCallback(() => {
1941
- let resolved = appearance;
1942
- if (resolved === "system") resolved = Appearance.getColorScheme();
1943
- if (resolved === "no-preference" || !resolved) resolved = "light";
1944
- const base = resolved === "dark" ? MD3DarkTheme : MD3LightTheme;
1945
- const _theme = {
1946
- ...base,
1947
- colors: {
1948
- ...base.colors,
1949
- elevation: { ...base.colors.elevation }
1950
- }
1951
- };
1952
- const palette = getTriadicPalette(color);
1953
- const surface = base.colors.surface;
1954
- _theme.colors.primary = palette.primary;
1955
- _theme.colors.onPrimary = isDarkColor(palette.primary) ? "#ffffff" : "#000000";
1956
- _theme.colors.primaryContainer = getBlendedColor(palette.primary, surface, 0.15);
1957
- _theme.colors.onPrimaryContainer = isDarkColor(_theme.colors.primaryContainer) ? "#ffffff" : "#000000";
1958
- _theme.colors.secondary = palette.secondary;
1959
- _theme.colors.onSecondary = isDarkColor(palette.secondary) ? "#ffffff" : "#000000";
1960
- _theme.colors.secondaryContainer = getBlendedColor(palette.secondary, surface, 0.15);
1961
- _theme.colors.onSecondaryContainer = isDarkColor(_theme.colors.secondaryContainer) ? "#ffffff" : "#000000";
1962
- _theme.colors.tertiary = palette.tertiary;
1963
- _theme.colors.onTertiary = isDarkColor(palette.tertiary) ? "#ffffff" : "#000000";
1964
- _theme.colors.tertiaryContainer = getBlendedColor(palette.tertiary, surface, 0.15);
1965
- _theme.colors.onTertiaryContainer = isDarkColor(_theme.colors.tertiaryContainer) ? "#ffffff" : "#000000";
1966
- const blended = getBlendedColor(color, palette.secondary, 0.5);
1967
- const tintSurface = (alpha) => getBlendedColor(blended, surface, alpha);
1968
- _theme.colors.surface = surface;
1969
- _theme.colors.surfaceVariant = tintSurface(0.2);
1970
- _theme.colors.outline = getBlendedColor(color, base.colors.outline, 0.45);
1971
- const grey = base.dark ? "#424242" : "#c2c2c2";
1972
- const blendedGrey = getBlendedColor(blended, grey, 0.05);
1973
- _theme.colors.elevation = {
1974
- ..._theme.colors.elevation,
1975
- level1: _theme.colors.surface,
1976
- level2: getBlendedColor(blendedGrey, _theme.colors.surface, 0.25),
1977
- level3: getBlendedColor(blendedGrey, _theme.colors.surface, 0.4),
1978
- level4: getBlendedColor(blendedGrey, _theme.colors.surface, 0.55),
1979
- level5: getBlendedColor(blendedGrey, _theme.colors.surface, 0.7)
1980
- };
1981
- setTheme(_theme);
1982
- }, [appearance, color]);
1983
- useEffect(() => {
1984
- computeTheme();
1985
- }, [computeTheme]);
1986
- useEffect(() => {
1987
- const subscription = Appearance.addChangeListener(computeTheme);
1988
- return subscription.remove;
1989
- }, [computeTheme]);
1990
- return theme;
2248
+ function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
2249
+ return reducerDefinition._reducerDefinitionType === "asyncThunk";
2250
+ }
2251
+ function isCaseReducerWithPrepareDefinition(reducerDefinition) {
2252
+ return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
2253
+ }
2254
+ function handleThunkCaseReducerDefinition({
2255
+ type,
2256
+ reducerName
2257
+ }, reducerDefinition, context, cAT) {
2258
+ if (!cAT) {
2259
+ 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`.");
2260
+ }
2261
+ const {
2262
+ payloadCreator,
2263
+ fulfilled,
2264
+ pending,
2265
+ rejected,
2266
+ settled,
2267
+ options
2268
+ } = reducerDefinition;
2269
+ const thunk = cAT(type, payloadCreator, options);
2270
+ context.exposeAction(reducerName, thunk);
2271
+ if (fulfilled) {
2272
+ context.addCase(thunk.fulfilled, fulfilled);
2273
+ }
2274
+ if (pending) {
2275
+ context.addCase(thunk.pending, pending);
2276
+ }
2277
+ if (rejected) {
2278
+ context.addCase(thunk.rejected, rejected);
2279
+ }
2280
+ if (settled) {
2281
+ context.addMatcher(thunk.settled, settled);
2282
+ }
2283
+ context.exposeCaseReducer(reducerName, {
2284
+ fulfilled: fulfilled || noop,
2285
+ pending: pending || noop,
2286
+ rejected: rejected || noop,
2287
+ settled: settled || noop
2288
+ });
2289
+ }
2290
+ function noop() {
2291
+ }
2292
+ var listener = "listener";
2293
+ var completed = "completed";
2294
+ var cancelled = "cancelled";
2295
+ var taskCancelled = `task-${cancelled}`;
2296
+ var taskCompleted = `task-${completed}`;
2297
+ var listenerCancelled = `${listener}-${cancelled}`;
2298
+ var listenerCompleted = `${listener}-${completed}`;
2299
+ var {
2300
+ assign
2301
+ } = Object;
2302
+ var alm = "listenerMiddleware";
2303
+ var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
2304
+ withTypes: () => addListener
2305
+ });
2306
+ var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
2307
+ var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
2308
+ withTypes: () => removeListener
2309
+ });
2310
+ function formatProdErrorMessage(code) {
2311
+ 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. `;
1991
2312
  }
1992
2313
 
1993
- // src/ThemeProvider.tsx
1994
- import { jsx as jsx6, jsxs } from "react/jsx-runtime";
1995
- function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }) {
1996
- const theme = useComputedTheme(appearance, color);
1997
- const called = useRef(false);
1998
- useEffect2(() => {
1999
- if (theme && !called.current) {
2000
- called.current = true;
2001
- onReady?.();
2002
- }
2003
- }, [theme, onReady]);
2004
- if (!theme) return null;
2005
- return /* @__PURE__ */ jsxs(PaperProvider, { theme, children: [
2006
- /* @__PURE__ */ jsx6(StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
2007
- /* @__PURE__ */ jsx6(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ jsx6(View, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) })
2008
- ] });
2314
+ // src/redux/themeSlice.ts
2315
+ var defaultInitialState = {
2316
+ appearance: "system",
2317
+ blur: true,
2318
+ color: "#6750a4",
2319
+ harmony: "split-complementary"
2320
+ };
2321
+ var reducers = {
2322
+ initialize: (state, action) => ({ ...state, ...action.payload }),
2323
+ setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
2324
+ setBlur: (state, action) => ({ ...state, blur: action.payload }),
2325
+ setColor: (state, action) => ({ ...state, color: action.payload }),
2326
+ setHarmony: (state, action) => ({ ...state, harmony: action.payload })
2327
+ };
2328
+ function createThemeReducer(initialState) {
2329
+ return createSlice({
2330
+ name: "theme",
2331
+ initialState: { ...defaultInitialState, ...initialState },
2332
+ reducers
2333
+ }).reducer;
2009
2334
  }
2010
- var styles = StyleSheet.create({
2011
- flex: { flex: 1 }
2335
+ var defaultSlice = createSlice({
2336
+ name: "theme",
2337
+ initialState: defaultInitialState,
2338
+ reducers
2012
2339
  });
2340
+ var themeActions = defaultSlice.actions;
2341
+ var themeReducer = defaultSlice.reducer;
2342
+ var selectThemeAppearance = (state) => state.appearance;
2343
+ var selectThemeBlur = (state) => state.blur;
2344
+ var selectThemeColor = (state) => state.color;
2345
+ var selectThemeHarmony = (state) => state.harmony;
2346
+
2347
+ // src/useThemeSettings.ts
2348
+ import { useContext as useContext5 } from "react";
2349
+ var useThemeSettings = () => useContext5(ThemeSettingsContext);
2013
2350
  export {
2351
+ Appbar,
2352
+ AppearancePicker,
2353
+ BlurView,
2354
+ BottomNavigation,
2014
2355
  Button,
2015
2356
  Chip,
2357
+ ColorPicker,
2358
+ Dialog,
2016
2359
  FAB,
2360
+ HarmonyPicker,
2017
2361
  IconButton,
2362
+ Menu,
2018
2363
  Provider,
2019
2364
  TextInput,
2365
+ ThemeSettingsContext,
2020
2366
  createThemeReducer,
2367
+ defaultColors,
2368
+ defaultThemeSettings,
2021
2369
  getBlendedColor,
2022
2370
  getHex,
2023
2371
  getRgb,
2024
2372
  getTriadicPalette,
2025
2373
  isDarkColor,
2026
2374
  selectThemeAppearance,
2375
+ selectThemeBlur,
2027
2376
  selectThemeColor,
2377
+ selectThemeHarmony,
2028
2378
  themeActions,
2029
2379
  themeReducer,
2380
+ useBlur,
2030
2381
  useComputedTheme,
2031
- usePaperDefaults
2382
+ usePaperDefaults,
2383
+ useThemeSettings
2032
2384
  };