@rific/auto-paper 0.2.0 → 0.4.0

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