@taskon/widget-react 0.0.1-beta.5 → 0.0.1-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +61 -47
  2. package/dist/CommunityTaskList.css +9 -1
  3. package/dist/EligibilityInfo.css +48 -75
  4. package/dist/LeaderboardWidget.css +73 -71
  5. package/dist/PageBuilder.css +5 -0
  6. package/dist/Quest.css +18 -14
  7. package/dist/TaskOnProvider.css +289 -0
  8. package/dist/ThemeProvider.css +227 -0
  9. package/dist/UserCenterWidget.css +6 -6
  10. package/dist/UserCenterWidget2.css +1388 -1621
  11. package/dist/{dynamic-import-helper.css → WidgetShell.css} +0 -227
  12. package/dist/chunks/{CommunityTaskList-CrMvOB8w.js → CommunityTaskList-D0uVD8wD.js} +393 -208
  13. package/dist/chunks/{EligibilityInfo-Beww12QX.js → EligibilityInfo-Cf6hx9-a.js} +459 -679
  14. package/dist/chunks/{LeaderboardWidget-DwuSpVl0.js → LeaderboardWidget-DyoiiNS6.js} +274 -252
  15. package/dist/chunks/{PageBuilder-DsX6Tv0N.js → PageBuilder-DoAFPm6-.js} +5 -5
  16. package/dist/chunks/{Quest-CuD2LElS.js → Quest-ySZlYd4u.js} +74 -57
  17. package/dist/chunks/TaskOnProvider-CxtFIs3n.js +2072 -0
  18. package/dist/chunks/{dynamic-import-helper-WmIF58Sb.js → ThemeProvider-CulHkqqY.js} +1282 -555
  19. package/dist/chunks/UserCenterWidget-BJsc_GSZ.js +3246 -0
  20. package/dist/chunks/{UserCenterWidget-CvU6K4AC.js → UserCenterWidget-STq8kpV4.js} +1174 -1386
  21. package/dist/chunks/WidgetShell-8xn-Jivw.js +659 -0
  22. package/dist/chunks/communitytask-es-CBNnS4o2.js +521 -0
  23. package/dist/chunks/communitytask-ja-GRf9cbdx.js +521 -0
  24. package/dist/chunks/communitytask-ko-Bf24PQKI.js +521 -0
  25. package/dist/chunks/{communitytask-ru-DhySaZL8.js → communitytask-ru-CZm2CPoV.js} +211 -1
  26. package/dist/chunks/leaderboardwidget-es-vKjrjQaz.js +146 -0
  27. package/dist/chunks/leaderboardwidget-ja-Q6u0HxKG.js +146 -0
  28. package/dist/chunks/leaderboardwidget-ko-CG6SWgxf.js +146 -0
  29. package/dist/chunks/leaderboardwidget-ru-DCcHcJGz.js +146 -0
  30. package/dist/chunks/{quest-es-D-b5xcme.js → quest-es-Dyyy0zaw.js} +8 -93
  31. package/dist/chunks/{quest-ja-Dxd2vqBF.js → quest-ja-Depog33y.js} +8 -93
  32. package/dist/chunks/{quest-ko-CSmRWgK_.js → quest-ko-BMu3uRQJ.js} +8 -93
  33. package/dist/chunks/{quest-ru-CkEKv1_F.js → quest-ru-xne814Rw.js} +8 -93
  34. package/dist/chunks/useIsMobile-D6Ybur-6.js +30 -0
  35. package/dist/chunks/useToast-BGJhd3BX.js +93 -0
  36. package/dist/chunks/usercenter-es-Dz3Wp2vV.js +512 -0
  37. package/dist/chunks/usercenter-ja-CKE4DJC6.js +512 -0
  38. package/dist/chunks/usercenter-ko-Dtpkn2qb.js +512 -0
  39. package/dist/chunks/usercenter-ru-DnBGee45.js +512 -0
  40. package/dist/community-task.d.ts +0 -390
  41. package/dist/community-task.js +2 -7
  42. package/dist/core.d.ts +38 -20
  43. package/dist/core.js +9 -10
  44. package/dist/index.d.ts +86 -709
  45. package/dist/index.js +22 -28
  46. package/dist/leaderboard.d.ts +0 -498
  47. package/dist/leaderboard.js +2 -16
  48. package/dist/page-builder.js +1 -1
  49. package/dist/quest.d.ts +0 -971
  50. package/dist/quest.js +2 -7
  51. package/dist/user-center.d.ts +0 -1610
  52. package/dist/user-center.js +2 -494
  53. package/package.json +2 -2
  54. package/dist/chunks/TaskOnProvider-xUeP2Nro.js +0 -1243
  55. package/dist/chunks/ThemeProvider-Bt4UZ33y.js +0 -1334
  56. package/dist/chunks/UserCenterWidget-CB0hnj-L.js +0 -3230
  57. package/dist/chunks/communitytask-es-1zawvXEX.js +0 -311
  58. package/dist/chunks/communitytask-ja-CmW6nP-L.js +0 -311
  59. package/dist/chunks/communitytask-ko-BD0hzQSi.js +0 -311
  60. package/dist/chunks/createLocaleLoader-BameiEhU.js +0 -65
  61. package/dist/chunks/leaderboardwidget-ja-Bj6gz6y1.js +0 -119
  62. package/dist/chunks/leaderboardwidget-ko-f1cLO9ic.js +0 -119
  63. package/dist/chunks/useToast-CaRkylKe.js +0 -304
  64. package/dist/chunks/usercenter-ja-B2465c1O.js +0 -326
  65. package/dist/chunks/usercenter-ko-xAEYxqLg.js +0 -326
@@ -1,1334 +0,0 @@
1
- import * as React from "react";
2
- import { createContext, useContext, useMemo, useState, useRef, useEffect } from "react";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import * as ReactDOM from "react-dom";
5
- import ReactDOM__default from "react-dom";
6
- const ThemeContext = createContext(null);
7
- const ThemePortalContainerContext = createContext(void 0);
8
- function useTaskOnTheme() {
9
- const theme = useContext(ThemeContext);
10
- if (!theme) {
11
- throw new Error("useTaskOnTheme must be used within a ThemeProvider");
12
- }
13
- return theme;
14
- }
15
- function useTaskOnPortalContainer() {
16
- const container = useContext(ThemePortalContainerContext);
17
- if (container !== void 0) {
18
- return container;
19
- }
20
- if (typeof document !== "undefined") {
21
- return document.body;
22
- }
23
- return null;
24
- }
25
- const TaskOnContext = createContext(null);
26
- function useTaskOnContext() {
27
- const context = useContext(TaskOnContext);
28
- if (!context) {
29
- throw new Error("useTaskOnContext must be used within a TaskOnProvider");
30
- }
31
- return context;
32
- }
33
- function useTaskOnAuth() {
34
- const context = useTaskOnContext();
35
- return useMemo(
36
- () => ({
37
- // User state
38
- userId: context.userId,
39
- isLoggedIn: context.isLoggedIn,
40
- isInitializing: context.isInitializing,
41
- // Unified login
42
- login: context.login,
43
- // Logout
44
- logout: context.logout,
45
- // Request login (triggers config.onRequestLogin)
46
- requestLogin: context.requestLogin
47
- }),
48
- [
49
- context.userId,
50
- context.isLoggedIn,
51
- context.isInitializing,
52
- context.login,
53
- context.logout,
54
- context.requestLogin
55
- ]
56
- );
57
- }
58
- function isSupportedLocale(locale) {
59
- return locale === "en" || locale === "ko" || locale === "ja" || locale === "ru" || locale === "es";
60
- }
61
- function warnUnsupportedLocale(locale, widgetId) {
62
- if (process.env.NODE_ENV !== "production" && !isSupportedLocale(locale)) {
63
- console.warn(
64
- `[widget-react] Locale "${locale}" is not fully supported in ${widgetId}. Falling back to English. Supported locales: en, ko, ja, ru, es`
65
- );
66
- }
67
- }
68
- const localeCache = /* @__PURE__ */ new Map();
69
- const DEFAULT_LOCALE = "en";
70
- function useWidgetLocale(options) {
71
- const { widgetId, defaultMessages, loadMessages } = options;
72
- const { locale } = useTaskOnContext();
73
- const getInitialState = () => {
74
- if (locale === DEFAULT_LOCALE) {
75
- return { messages: defaultMessages, isLoading: false };
76
- }
77
- const cacheKey = `${widgetId}-${locale}`;
78
- if (localeCache.has(cacheKey)) {
79
- return { messages: localeCache.get(cacheKey), isLoading: false };
80
- }
81
- return { messages: defaultMessages, isLoading: true };
82
- };
83
- const [state, setState] = useState(getInitialState);
84
- const loadMessagesRef = useRef(loadMessages);
85
- loadMessagesRef.current = loadMessages;
86
- const defaultMessagesRef = useRef(defaultMessages);
87
- defaultMessagesRef.current = defaultMessages;
88
- useEffect(() => {
89
- if (locale === DEFAULT_LOCALE) {
90
- setState({ messages: defaultMessagesRef.current, isLoading: false });
91
- return;
92
- }
93
- warnUnsupportedLocale(locale, widgetId);
94
- const cacheKey = `${widgetId}-${locale}`;
95
- if (localeCache.has(cacheKey)) {
96
- setState({ messages: localeCache.get(cacheKey), isLoading: false });
97
- return;
98
- }
99
- let isMounted = true;
100
- setState((prev) => ({ ...prev, isLoading: true }));
101
- loadMessagesRef.current(locale).then((module) => {
102
- if (isMounted) {
103
- const loadedMessages = module.default;
104
- localeCache.set(cacheKey, loadedMessages);
105
- setState({ messages: loadedMessages, isLoading: false });
106
- }
107
- }).catch((error) => {
108
- console.warn(
109
- `[widget-react] Failed to load locale "${locale}" for ${widgetId}, falling back to English:`,
110
- error
111
- );
112
- if (isMounted) {
113
- setState({ messages: defaultMessagesRef.current, isLoading: false });
114
- }
115
- });
116
- return () => {
117
- isMounted = false;
118
- };
119
- }, [locale, widgetId]);
120
- return state;
121
- }
122
- function clearLocaleCache() {
123
- localeCache.clear();
124
- }
125
- async function preloadWidgetLocale(widgetId, locale, loadMessages) {
126
- if (locale === DEFAULT_LOCALE) return;
127
- const cacheKey = `${widgetId}-${locale}`;
128
- if (localeCache.has(cacheKey)) return;
129
- try {
130
- const module = await loadMessages(locale);
131
- localeCache.set(cacheKey, module.default);
132
- } catch (error) {
133
- console.warn(
134
- `[widget-react] Failed to preload locale "${locale}" for ${widgetId}:`,
135
- error
136
- );
137
- }
138
- }
139
- function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
140
- return function handleEvent(event) {
141
- originalEventHandler == null ? void 0 : originalEventHandler(event);
142
- if (checkForDefaultPrevented === false || !event.defaultPrevented) {
143
- return ourEventHandler == null ? void 0 : ourEventHandler(event);
144
- }
145
- };
146
- }
147
- function setRef(ref, value) {
148
- if (typeof ref === "function") {
149
- return ref(value);
150
- } else if (ref !== null && ref !== void 0) {
151
- ref.current = value;
152
- }
153
- }
154
- function composeRefs(...refs) {
155
- return (node) => {
156
- let hasCleanup = false;
157
- const cleanups = refs.map((ref) => {
158
- const cleanup = setRef(ref, node);
159
- if (!hasCleanup && typeof cleanup == "function") {
160
- hasCleanup = true;
161
- }
162
- return cleanup;
163
- });
164
- if (hasCleanup) {
165
- return () => {
166
- for (let i = 0; i < cleanups.length; i++) {
167
- const cleanup = cleanups[i];
168
- if (typeof cleanup == "function") {
169
- cleanup();
170
- } else {
171
- setRef(refs[i], null);
172
- }
173
- }
174
- };
175
- }
176
- };
177
- }
178
- function useComposedRefs(...refs) {
179
- return React.useCallback(composeRefs(...refs), refs);
180
- }
181
- function createContext2(rootComponentName, defaultContext) {
182
- const Context = React.createContext(defaultContext);
183
- const Provider = (props) => {
184
- const { children, ...context } = props;
185
- const value = React.useMemo(() => context, Object.values(context));
186
- return /* @__PURE__ */ jsx(Context.Provider, { value, children });
187
- };
188
- Provider.displayName = rootComponentName + "Provider";
189
- function useContext2(consumerName) {
190
- const context = React.useContext(Context);
191
- if (context) return context;
192
- if (defaultContext !== void 0) return defaultContext;
193
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
194
- }
195
- return [Provider, useContext2];
196
- }
197
- function createContextScope(scopeName, createContextScopeDeps = []) {
198
- let defaultContexts = [];
199
- function createContext3(rootComponentName, defaultContext) {
200
- const BaseContext = React.createContext(defaultContext);
201
- const index = defaultContexts.length;
202
- defaultContexts = [...defaultContexts, defaultContext];
203
- const Provider = (props) => {
204
- var _a;
205
- const { scope, children, ...context } = props;
206
- const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
207
- const value = React.useMemo(() => context, Object.values(context));
208
- return /* @__PURE__ */ jsx(Context.Provider, { value, children });
209
- };
210
- Provider.displayName = rootComponentName + "Provider";
211
- function useContext2(consumerName, scope) {
212
- var _a;
213
- const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
214
- const context = React.useContext(Context);
215
- if (context) return context;
216
- if (defaultContext !== void 0) return defaultContext;
217
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
218
- }
219
- return [Provider, useContext2];
220
- }
221
- const createScope = () => {
222
- const scopeContexts = defaultContexts.map((defaultContext) => {
223
- return React.createContext(defaultContext);
224
- });
225
- return function useScope(scope) {
226
- const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
227
- return React.useMemo(
228
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
229
- [scope, contexts]
230
- );
231
- };
232
- };
233
- createScope.scopeName = scopeName;
234
- return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
235
- }
236
- function composeContextScopes(...scopes) {
237
- const baseScope = scopes[0];
238
- if (scopes.length === 1) return baseScope;
239
- const createScope = () => {
240
- const scopeHooks = scopes.map((createScope2) => ({
241
- useScope: createScope2(),
242
- scopeName: createScope2.scopeName
243
- }));
244
- return function useComposedScopes(overrideScopes) {
245
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
246
- const scopeProps = useScope(overrideScopes);
247
- const currentScope = scopeProps[`__scope${scopeName}`];
248
- return { ...nextScopes2, ...currentScope };
249
- }, {});
250
- return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
251
- };
252
- };
253
- createScope.scopeName = baseScope.scopeName;
254
- return createScope;
255
- }
256
- // @__NO_SIDE_EFFECTS__
257
- function createSlot(ownerName) {
258
- const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
259
- const Slot2 = React.forwardRef((props, forwardedRef) => {
260
- const { children, ...slotProps } = props;
261
- const childrenArray = React.Children.toArray(children);
262
- const slottable = childrenArray.find(isSlottable);
263
- if (slottable) {
264
- const newElement = slottable.props.children;
265
- const newChildren = childrenArray.map((child) => {
266
- if (child === slottable) {
267
- if (React.Children.count(newElement) > 1) return React.Children.only(null);
268
- return React.isValidElement(newElement) ? newElement.props.children : null;
269
- } else {
270
- return child;
271
- }
272
- });
273
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
274
- }
275
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
276
- });
277
- Slot2.displayName = `${ownerName}.Slot`;
278
- return Slot2;
279
- }
280
- // @__NO_SIDE_EFFECTS__
281
- function createSlotClone(ownerName) {
282
- const SlotClone = React.forwardRef((props, forwardedRef) => {
283
- const { children, ...slotProps } = props;
284
- if (React.isValidElement(children)) {
285
- const childrenRef = getElementRef$1(children);
286
- const props2 = mergeProps(slotProps, children.props);
287
- if (children.type !== React.Fragment) {
288
- props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
289
- }
290
- return React.cloneElement(children, props2);
291
- }
292
- return React.Children.count(children) > 1 ? React.Children.only(null) : null;
293
- });
294
- SlotClone.displayName = `${ownerName}.SlotClone`;
295
- return SlotClone;
296
- }
297
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
298
- function isSlottable(child) {
299
- return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
300
- }
301
- function mergeProps(slotProps, childProps) {
302
- const overrideProps = { ...childProps };
303
- for (const propName in childProps) {
304
- const slotPropValue = slotProps[propName];
305
- const childPropValue = childProps[propName];
306
- const isHandler = /^on[A-Z]/.test(propName);
307
- if (isHandler) {
308
- if (slotPropValue && childPropValue) {
309
- overrideProps[propName] = (...args) => {
310
- const result = childPropValue(...args);
311
- slotPropValue(...args);
312
- return result;
313
- };
314
- } else if (slotPropValue) {
315
- overrideProps[propName] = slotPropValue;
316
- }
317
- } else if (propName === "style") {
318
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
319
- } else if (propName === "className") {
320
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
321
- }
322
- }
323
- return { ...slotProps, ...overrideProps };
324
- }
325
- function getElementRef$1(element) {
326
- var _a, _b;
327
- let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
328
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
329
- if (mayWarn) {
330
- return element.ref;
331
- }
332
- getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
333
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
334
- if (mayWarn) {
335
- return element.props.ref;
336
- }
337
- return element.props.ref || element.ref;
338
- }
339
- var NODES = [
340
- "a",
341
- "button",
342
- "div",
343
- "form",
344
- "h2",
345
- "h3",
346
- "img",
347
- "input",
348
- "label",
349
- "li",
350
- "nav",
351
- "ol",
352
- "p",
353
- "select",
354
- "span",
355
- "svg",
356
- "ul"
357
- ];
358
- var Primitive = NODES.reduce((primitive, node) => {
359
- const Slot = /* @__PURE__ */ createSlot(`Primitive.${node}`);
360
- const Node = React.forwardRef((props, forwardedRef) => {
361
- const { asChild, ...primitiveProps } = props;
362
- const Comp = asChild ? Slot : node;
363
- if (typeof window !== "undefined") {
364
- window[Symbol.for("radix-ui")] = true;
365
- }
366
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
367
- });
368
- Node.displayName = `Primitive.${node}`;
369
- return { ...primitive, [node]: Node };
370
- }, {});
371
- function dispatchDiscreteCustomEvent(target, event) {
372
- if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
373
- }
374
- function useCallbackRef(callback) {
375
- const callbackRef = React.useRef(callback);
376
- React.useEffect(() => {
377
- callbackRef.current = callback;
378
- });
379
- return React.useMemo(() => (...args) => {
380
- var _a;
381
- return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
382
- }, []);
383
- }
384
- function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
385
- const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
386
- React.useEffect(() => {
387
- const handleKeyDown = (event) => {
388
- if (event.key === "Escape") {
389
- onEscapeKeyDown(event);
390
- }
391
- };
392
- ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
393
- return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
394
- }, [onEscapeKeyDown, ownerDocument]);
395
- }
396
- var DISMISSABLE_LAYER_NAME = "DismissableLayer";
397
- var CONTEXT_UPDATE = "dismissableLayer.update";
398
- var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
399
- var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
400
- var originalBodyPointerEvents;
401
- var DismissableLayerContext = React.createContext({
402
- layers: /* @__PURE__ */ new Set(),
403
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
404
- branches: /* @__PURE__ */ new Set()
405
- });
406
- var DismissableLayer = React.forwardRef(
407
- (props, forwardedRef) => {
408
- const {
409
- disableOutsidePointerEvents = false,
410
- onEscapeKeyDown,
411
- onPointerDownOutside,
412
- onFocusOutside,
413
- onInteractOutside,
414
- onDismiss,
415
- ...layerProps
416
- } = props;
417
- const context = React.useContext(DismissableLayerContext);
418
- const [node, setNode] = React.useState(null);
419
- const ownerDocument = (node == null ? void 0 : node.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document);
420
- const [, force] = React.useState({});
421
- const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
422
- const layers = Array.from(context.layers);
423
- const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
424
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
425
- const index = node ? layers.indexOf(node) : -1;
426
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
427
- const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
428
- const pointerDownOutside = usePointerDownOutside((event) => {
429
- const target = event.target;
430
- const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
431
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
432
- onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
433
- onInteractOutside == null ? void 0 : onInteractOutside(event);
434
- if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
435
- }, ownerDocument);
436
- const focusOutside = useFocusOutside((event) => {
437
- const target = event.target;
438
- const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
439
- if (isFocusInBranch) return;
440
- onFocusOutside == null ? void 0 : onFocusOutside(event);
441
- onInteractOutside == null ? void 0 : onInteractOutside(event);
442
- if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
443
- }, ownerDocument);
444
- useEscapeKeydown((event) => {
445
- const isHighestLayer = index === context.layers.size - 1;
446
- if (!isHighestLayer) return;
447
- onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
448
- if (!event.defaultPrevented && onDismiss) {
449
- event.preventDefault();
450
- onDismiss();
451
- }
452
- }, ownerDocument);
453
- React.useEffect(() => {
454
- if (!node) return;
455
- if (disableOutsidePointerEvents) {
456
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
457
- originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
458
- ownerDocument.body.style.pointerEvents = "none";
459
- }
460
- context.layersWithOutsidePointerEventsDisabled.add(node);
461
- }
462
- context.layers.add(node);
463
- dispatchUpdate();
464
- return () => {
465
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
466
- ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
467
- }
468
- };
469
- }, [node, ownerDocument, disableOutsidePointerEvents, context]);
470
- React.useEffect(() => {
471
- return () => {
472
- if (!node) return;
473
- context.layers.delete(node);
474
- context.layersWithOutsidePointerEventsDisabled.delete(node);
475
- dispatchUpdate();
476
- };
477
- }, [node, context]);
478
- React.useEffect(() => {
479
- const handleUpdate = () => force({});
480
- document.addEventListener(CONTEXT_UPDATE, handleUpdate);
481
- return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
482
- }, []);
483
- return /* @__PURE__ */ jsx(
484
- Primitive.div,
485
- {
486
- ...layerProps,
487
- ref: composedRefs,
488
- style: {
489
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
490
- ...props.style
491
- },
492
- onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
493
- onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
494
- onPointerDownCapture: composeEventHandlers(
495
- props.onPointerDownCapture,
496
- pointerDownOutside.onPointerDownCapture
497
- )
498
- }
499
- );
500
- }
501
- );
502
- DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
503
- var BRANCH_NAME = "DismissableLayerBranch";
504
- var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
505
- const context = React.useContext(DismissableLayerContext);
506
- const ref = React.useRef(null);
507
- const composedRefs = useComposedRefs(forwardedRef, ref);
508
- React.useEffect(() => {
509
- const node = ref.current;
510
- if (node) {
511
- context.branches.add(node);
512
- return () => {
513
- context.branches.delete(node);
514
- };
515
- }
516
- }, [context.branches]);
517
- return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
518
- });
519
- DismissableLayerBranch.displayName = BRANCH_NAME;
520
- function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
521
- const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
522
- const isPointerInsideReactTreeRef = React.useRef(false);
523
- const handleClickRef = React.useRef(() => {
524
- });
525
- React.useEffect(() => {
526
- const handlePointerDown = (event) => {
527
- if (event.target && !isPointerInsideReactTreeRef.current) {
528
- let handleAndDispatchPointerDownOutsideEvent2 = function() {
529
- handleAndDispatchCustomEvent(
530
- POINTER_DOWN_OUTSIDE,
531
- handlePointerDownOutside,
532
- eventDetail,
533
- { discrete: true }
534
- );
535
- };
536
- const eventDetail = { originalEvent: event };
537
- if (event.pointerType === "touch") {
538
- ownerDocument.removeEventListener("click", handleClickRef.current);
539
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
540
- ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
541
- } else {
542
- handleAndDispatchPointerDownOutsideEvent2();
543
- }
544
- } else {
545
- ownerDocument.removeEventListener("click", handleClickRef.current);
546
- }
547
- isPointerInsideReactTreeRef.current = false;
548
- };
549
- const timerId = window.setTimeout(() => {
550
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
551
- }, 0);
552
- return () => {
553
- window.clearTimeout(timerId);
554
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
555
- ownerDocument.removeEventListener("click", handleClickRef.current);
556
- };
557
- }, [ownerDocument, handlePointerDownOutside]);
558
- return {
559
- // ensures we check React component tree (not just DOM tree)
560
- onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
561
- };
562
- }
563
- function useFocusOutside(onFocusOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
564
- const handleFocusOutside = useCallbackRef(onFocusOutside);
565
- const isFocusInsideReactTreeRef = React.useRef(false);
566
- React.useEffect(() => {
567
- const handleFocus = (event) => {
568
- if (event.target && !isFocusInsideReactTreeRef.current) {
569
- const eventDetail = { originalEvent: event };
570
- handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
571
- discrete: false
572
- });
573
- }
574
- };
575
- ownerDocument.addEventListener("focusin", handleFocus);
576
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
577
- }, [ownerDocument, handleFocusOutside]);
578
- return {
579
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
580
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
581
- };
582
- }
583
- function dispatchUpdate() {
584
- const event = new CustomEvent(CONTEXT_UPDATE);
585
- document.dispatchEvent(event);
586
- }
587
- function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
588
- const target = detail.originalEvent.target;
589
- const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
590
- if (handler) target.addEventListener(name, handler, { once: true });
591
- if (discrete) {
592
- dispatchDiscreteCustomEvent(target, event);
593
- } else {
594
- target.dispatchEvent(event);
595
- }
596
- }
597
- var Root = DismissableLayer;
598
- var Branch = DismissableLayerBranch;
599
- var useLayoutEffect2 = (globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
600
- };
601
- var PORTAL_NAME = "Portal";
602
- var Portal = React.forwardRef((props, forwardedRef) => {
603
- var _a;
604
- const { container: containerProp, ...portalProps } = props;
605
- const [mounted, setMounted] = React.useState(false);
606
- useLayoutEffect2(() => setMounted(true), []);
607
- const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
608
- return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
609
- });
610
- Portal.displayName = PORTAL_NAME;
611
- function useStateMachine(initialState, machine) {
612
- return React.useReducer((state, event) => {
613
- const nextState = machine[state][event];
614
- return nextState ?? state;
615
- }, initialState);
616
- }
617
- var Presence = (props) => {
618
- const { present, children } = props;
619
- const presence = usePresence(present);
620
- const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
621
- const ref = useComposedRefs(presence.ref, getElementRef(child));
622
- const forceMount = typeof children === "function";
623
- return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
624
- };
625
- Presence.displayName = "Presence";
626
- function usePresence(present) {
627
- const [node, setNode] = React.useState();
628
- const stylesRef = React.useRef(null);
629
- const prevPresentRef = React.useRef(present);
630
- const prevAnimationNameRef = React.useRef("none");
631
- const initialState = present ? "mounted" : "unmounted";
632
- const [state, send] = useStateMachine(initialState, {
633
- mounted: {
634
- UNMOUNT: "unmounted",
635
- ANIMATION_OUT: "unmountSuspended"
636
- },
637
- unmountSuspended: {
638
- MOUNT: "mounted",
639
- ANIMATION_END: "unmounted"
640
- },
641
- unmounted: {
642
- MOUNT: "mounted"
643
- }
644
- });
645
- React.useEffect(() => {
646
- const currentAnimationName = getAnimationName(stylesRef.current);
647
- prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
648
- }, [state]);
649
- useLayoutEffect2(() => {
650
- const styles = stylesRef.current;
651
- const wasPresent = prevPresentRef.current;
652
- const hasPresentChanged = wasPresent !== present;
653
- if (hasPresentChanged) {
654
- const prevAnimationName = prevAnimationNameRef.current;
655
- const currentAnimationName = getAnimationName(styles);
656
- if (present) {
657
- send("MOUNT");
658
- } else if (currentAnimationName === "none" || (styles == null ? void 0 : styles.display) === "none") {
659
- send("UNMOUNT");
660
- } else {
661
- const isAnimating = prevAnimationName !== currentAnimationName;
662
- if (wasPresent && isAnimating) {
663
- send("ANIMATION_OUT");
664
- } else {
665
- send("UNMOUNT");
666
- }
667
- }
668
- prevPresentRef.current = present;
669
- }
670
- }, [present, send]);
671
- useLayoutEffect2(() => {
672
- if (node) {
673
- let timeoutId;
674
- const ownerWindow = node.ownerDocument.defaultView ?? window;
675
- const handleAnimationEnd = (event) => {
676
- const currentAnimationName = getAnimationName(stylesRef.current);
677
- const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
678
- if (event.target === node && isCurrentAnimation) {
679
- send("ANIMATION_END");
680
- if (!prevPresentRef.current) {
681
- const currentFillMode = node.style.animationFillMode;
682
- node.style.animationFillMode = "forwards";
683
- timeoutId = ownerWindow.setTimeout(() => {
684
- if (node.style.animationFillMode === "forwards") {
685
- node.style.animationFillMode = currentFillMode;
686
- }
687
- });
688
- }
689
- }
690
- };
691
- const handleAnimationStart = (event) => {
692
- if (event.target === node) {
693
- prevAnimationNameRef.current = getAnimationName(stylesRef.current);
694
- }
695
- };
696
- node.addEventListener("animationstart", handleAnimationStart);
697
- node.addEventListener("animationcancel", handleAnimationEnd);
698
- node.addEventListener("animationend", handleAnimationEnd);
699
- return () => {
700
- ownerWindow.clearTimeout(timeoutId);
701
- node.removeEventListener("animationstart", handleAnimationStart);
702
- node.removeEventListener("animationcancel", handleAnimationEnd);
703
- node.removeEventListener("animationend", handleAnimationEnd);
704
- };
705
- } else {
706
- send("ANIMATION_END");
707
- }
708
- }, [node, send]);
709
- return {
710
- isPresent: ["mounted", "unmountSuspended"].includes(state),
711
- ref: React.useCallback((node2) => {
712
- stylesRef.current = node2 ? getComputedStyle(node2) : null;
713
- setNode(node2);
714
- }, [])
715
- };
716
- }
717
- function getAnimationName(styles) {
718
- return (styles == null ? void 0 : styles.animationName) || "none";
719
- }
720
- function getElementRef(element) {
721
- var _a, _b;
722
- let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
723
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
724
- if (mayWarn) {
725
- return element.ref;
726
- }
727
- getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
728
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
729
- if (mayWarn) {
730
- return element.props.ref;
731
- }
732
- return element.props.ref || element.ref;
733
- }
734
- var useInsertionEffect = React[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
735
- function useControllableState({
736
- prop,
737
- defaultProp,
738
- onChange = () => {
739
- },
740
- caller
741
- }) {
742
- const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
743
- defaultProp,
744
- onChange
745
- });
746
- const isControlled = prop !== void 0;
747
- const value = isControlled ? prop : uncontrolledProp;
748
- {
749
- const isControlledRef = React.useRef(prop !== void 0);
750
- React.useEffect(() => {
751
- const wasControlled = isControlledRef.current;
752
- if (wasControlled !== isControlled) {
753
- const from = wasControlled ? "controlled" : "uncontrolled";
754
- const to = isControlled ? "controlled" : "uncontrolled";
755
- console.warn(
756
- `${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
757
- );
758
- }
759
- isControlledRef.current = isControlled;
760
- }, [isControlled, caller]);
761
- }
762
- const setValue = React.useCallback(
763
- (nextValue) => {
764
- var _a;
765
- if (isControlled) {
766
- const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
767
- if (value2 !== prop) {
768
- (_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, value2);
769
- }
770
- } else {
771
- setUncontrolledProp(nextValue);
772
- }
773
- },
774
- [isControlled, prop, setUncontrolledProp, onChangeRef]
775
- );
776
- return [value, setValue];
777
- }
778
- function useUncontrolledState({
779
- defaultProp,
780
- onChange
781
- }) {
782
- const [value, setValue] = React.useState(defaultProp);
783
- const prevValueRef = React.useRef(value);
784
- const onChangeRef = React.useRef(onChange);
785
- useInsertionEffect(() => {
786
- onChangeRef.current = onChange;
787
- }, [onChange]);
788
- React.useEffect(() => {
789
- var _a;
790
- if (prevValueRef.current !== value) {
791
- (_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, value);
792
- prevValueRef.current = value;
793
- }
794
- }, [value, prevValueRef]);
795
- return [value, setValue, onChangeRef];
796
- }
797
- function isFunction(value) {
798
- return typeof value === "function";
799
- }
800
- const lightDefaultTokens = {
801
- // Primary colors
802
- colorPrimary: "#CBFF01",
803
- colorPrimaryHover: "#daff2a",
804
- colorPrimaryActive: "#a5d900",
805
- colorPrimaryBg: "#fdffcd",
806
- // Secondary color
807
- colorSecondary: "#00FFA3",
808
- // Status colors
809
- colorSuccess: "#1FCBAF",
810
- colorWarning: "#FFB800",
811
- colorError: "#FF4D4D",
812
- // Background colors (V2)
813
- colorBgCanvas: "#FFFFFF",
814
- colorBgSurface: "#fafafb",
815
- colorBgSurfaceSubtle: "rgba(26, 29, 31, 0.04)",
816
- colorBgSurfaceStrong: "rgba(26, 29, 31, 0.06)",
817
- colorBgFloating: "#f4f4f4",
818
- colorBgMask: "rgba(26, 29, 31, 0.45)",
819
- colorBgInset: "#eaebeb",
820
- colorSuccessBg: "#1fcbaf1a",
821
- colorWarningBg: "#ffb8001a",
822
- colorErrorBg: "#ff4d4d1a",
823
- colorSecondaryBg: "#00ffa31a",
824
- // Text colors
825
- colorText: "#1A1D1F",
826
- colorTextSecondary: "rgba(26, 29, 31, 0.72)",
827
- colorTextTertiary: "rgba(26, 29, 31, 0.6)",
828
- colorTextDisabled: "rgba(26, 29, 31, 0.4)",
829
- colorLink: "#58AFFF",
830
- colorTextOnPrimary: "#000000",
831
- // Border colors
832
- colorBorder: "rgba(26, 29, 31, 0.1)",
833
- colorBorderSecondary: "rgba(26, 29, 31, 0.06)",
834
- // Border radius
835
- borderRadius: 8,
836
- borderRadiusSm: 4,
837
- borderRadiusLg: 12,
838
- // Font
839
- fontSize: 14,
840
- fontSizeSm: 12,
841
- fontSizeLg: 16,
842
- fontSizeXl: 18,
843
- fontSizeXxl: 22,
844
- fontSizeXxxl: 24,
845
- // Spacing
846
- spacing: 8,
847
- spacingXs: 4,
848
- spacingSm: 8,
849
- spacingMd: 16,
850
- spacingLg: 24,
851
- spacingXl: 32
852
- };
853
- const darkDefaultTokens = {
854
- // Primary colors
855
- colorPrimary: "#CBFF01",
856
- colorPrimaryHover: "#daff2a",
857
- colorPrimaryActive: "#a5d900",
858
- colorPrimaryBg: "#1e2600",
859
- // Secondary color
860
- colorSecondary: "#00FFA3",
861
- // Status colors
862
- colorSuccess: "#1FCBAF",
863
- colorWarning: "#FFB800",
864
- colorError: "#FF4D4D",
865
- // Background colors (V2)
866
- colorBgCanvas: "#1A1D1F",
867
- colorBgSurface: "#282b2c",
868
- colorBgSurfaceSubtle: "rgba(255, 255, 255, 0.04)",
869
- colorBgSurfaceStrong: "rgba(255, 255, 255, 0.12)",
870
- colorBgFloating: "#313435",
871
- colorBgMask: "rgba(26, 29, 31, 0.6)",
872
- colorBgInset: "#3a3d3e",
873
- colorSuccessBg: "#1fcbaf26",
874
- colorWarningBg: "#ffb80026",
875
- colorErrorBg: "#ff4d4d26",
876
- colorSecondaryBg: "#00ffa326",
877
- // Text colors
878
- colorText: "#FFFFFF",
879
- colorTextSecondary: "rgba(255, 255, 255, 0.72)",
880
- colorTextTertiary: "rgba(255, 255, 255, 0.6)",
881
- colorTextDisabled: "rgba(255, 255, 255, 0.4)",
882
- colorLink: "#58AFFF",
883
- colorTextOnPrimary: "#000000",
884
- // Border colors
885
- colorBorder: "rgba(255, 255, 255, 0.1)",
886
- colorBorderSecondary: "rgba(255, 255, 255, 0.06)",
887
- // Border radius
888
- borderRadius: 8,
889
- borderRadiusSm: 4,
890
- borderRadiusLg: 12,
891
- // Font
892
- fontSize: 14,
893
- fontSizeSm: 12,
894
- fontSizeLg: 16,
895
- fontSizeXl: 18,
896
- fontSizeXxl: 22,
897
- fontSizeXxxl: 24,
898
- // Spacing
899
- spacing: 8,
900
- spacingXs: 4,
901
- spacingSm: 8,
902
- spacingMd: 16,
903
- spacingLg: 24,
904
- spacingXl: 32
905
- };
906
- const hueStep = 2;
907
- const saturationStep = 0.16;
908
- const saturationStep2 = 0.05;
909
- const brightnessStep1 = 0.05;
910
- const brightnessStep2 = 0.15;
911
- const lightColorCount = 5;
912
- const darkColorCount = 4;
913
- function hexToRgb(hex) {
914
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
915
- if (!result || !result[1] || !result[2] || !result[3]) {
916
- return null;
917
- }
918
- return {
919
- r: parseInt(result[1], 16),
920
- g: parseInt(result[2], 16),
921
- b: parseInt(result[3], 16)
922
- };
923
- }
924
- function rgbToHex(rgb) {
925
- const toHex = (n) => {
926
- const hex = Math.round(Math.max(0, Math.min(255, n))).toString(16);
927
- return hex.length === 1 ? "0" + hex : hex;
928
- };
929
- return "#" + toHex(rgb.r) + toHex(rgb.g) + toHex(rgb.b);
930
- }
931
- function rgbToHsv(rgb) {
932
- const r = rgb.r / 255;
933
- const g = rgb.g / 255;
934
- const b = rgb.b / 255;
935
- const max = Math.max(r, g, b);
936
- const min = Math.min(r, g, b);
937
- const delta = max - min;
938
- let h = 0;
939
- const v = max;
940
- const s = max === 0 ? 0 : delta / max;
941
- if (delta !== 0) {
942
- if (max === r) {
943
- h = ((g - b) / delta + (g < b ? 6 : 0)) * 60;
944
- } else if (max === g) {
945
- h = ((b - r) / delta + 2) * 60;
946
- } else {
947
- h = ((r - g) / delta + 4) * 60;
948
- }
949
- }
950
- return { h, s, v };
951
- }
952
- function hsvToRgb(hsv) {
953
- const h = hsv.h / 60;
954
- const s = hsv.s;
955
- const v = hsv.v;
956
- const i = Math.floor(h) % 6;
957
- const f = h - Math.floor(h);
958
- const p = v * (1 - s);
959
- const q = v * (1 - f * s);
960
- const t = v * (1 - (1 - f) * s);
961
- let r = 0, g = 0, b = 0;
962
- switch (i) {
963
- case 0:
964
- r = v;
965
- g = t;
966
- b = p;
967
- break;
968
- case 1:
969
- r = q;
970
- g = v;
971
- b = p;
972
- break;
973
- case 2:
974
- r = p;
975
- g = v;
976
- b = t;
977
- break;
978
- case 3:
979
- r = p;
980
- g = q;
981
- b = v;
982
- break;
983
- case 4:
984
- r = t;
985
- g = p;
986
- b = v;
987
- break;
988
- case 5:
989
- r = v;
990
- g = p;
991
- b = q;
992
- break;
993
- }
994
- return {
995
- r: Math.round(r * 255),
996
- g: Math.round(g * 255),
997
- b: Math.round(b * 255)
998
- };
999
- }
1000
- function getHue(hsv, i, isLight) {
1001
- let hue;
1002
- if (hsv.h >= 60 && hsv.h <= 240) {
1003
- hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i;
1004
- } else {
1005
- hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i;
1006
- }
1007
- if (hue < 0) {
1008
- hue += 360;
1009
- } else if (hue >= 360) {
1010
- hue -= 360;
1011
- }
1012
- return hue;
1013
- }
1014
- function getSaturation(hsv, i, isLight) {
1015
- if (hsv.s === 0) {
1016
- return hsv.s;
1017
- }
1018
- let saturation;
1019
- if (isLight) {
1020
- saturation = hsv.s - saturationStep * i;
1021
- } else {
1022
- saturation = hsv.s + saturationStep2 * i;
1023
- }
1024
- if (saturation < 0.06) {
1025
- saturation = 0.06;
1026
- }
1027
- if (saturation > 1) {
1028
- saturation = 1;
1029
- }
1030
- return saturation;
1031
- }
1032
- function getValue(hsv, i, isLight) {
1033
- let value;
1034
- if (isLight) {
1035
- value = hsv.v + brightnessStep1 * i;
1036
- } else {
1037
- value = hsv.v - brightnessStep2 * i;
1038
- }
1039
- if (value < 0) {
1040
- value = 0;
1041
- }
1042
- if (value > 1) {
1043
- value = 1;
1044
- }
1045
- return value;
1046
- }
1047
- function generatePalette(primaryColor) {
1048
- const rgb = hexToRgb(primaryColor);
1049
- if (!rgb) {
1050
- return Array(10).fill(primaryColor);
1051
- }
1052
- const hsv = rgbToHsv(rgb);
1053
- const palette = [];
1054
- for (let i = lightColorCount; i > 0; i--) {
1055
- const newHsv = {
1056
- h: getHue(hsv, i, true),
1057
- s: getSaturation(hsv, i, true),
1058
- v: getValue(hsv, i, true)
1059
- };
1060
- palette.push(rgbToHex(hsvToRgb(newHsv)));
1061
- }
1062
- palette.push(primaryColor);
1063
- for (let i = 1; i <= darkColorCount; i++) {
1064
- const newHsv = {
1065
- h: getHue(hsv, i, false),
1066
- s: getSaturation(hsv, i, false),
1067
- v: getValue(hsv, i, false)
1068
- };
1069
- palette.push(rgbToHex(hsvToRgb(newHsv)));
1070
- }
1071
- return palette;
1072
- }
1073
- function mixColors(color1, color2, weight) {
1074
- const rgb1 = hexToRgb(color1);
1075
- const rgb2 = hexToRgb(color2);
1076
- if (!rgb1 || !rgb2) return color1;
1077
- return rgbToHex({
1078
- r: rgb1.r + (rgb2.r - rgb1.r) * weight,
1079
- g: rgb1.g + (rgb2.g - rgb1.g) * weight,
1080
- b: rgb1.b + (rgb2.b - rgb1.b) * weight
1081
- });
1082
- }
1083
- function withAlpha(color, alpha) {
1084
- const rgb = hexToRgb(color);
1085
- if (!rgb) return color;
1086
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
1087
- }
1088
- function deriveTokens(seed, mode) {
1089
- const derived = {};
1090
- const isLight = mode === "light";
1091
- if (seed.colorPrimary) {
1092
- const palette = generatePalette(seed.colorPrimary);
1093
- derived.colorPrimary = seed.colorPrimary;
1094
- if (isLight) {
1095
- derived.colorPrimaryHover = palette[4];
1096
- derived.colorPrimaryActive = palette[6];
1097
- derived.colorPrimaryBg = palette[0];
1098
- } else {
1099
- derived.colorPrimaryHover = palette[4];
1100
- derived.colorPrimaryActive = palette[6];
1101
- derived.colorPrimaryBg = mixColors(seed.colorPrimary, "#000000", 0.85);
1102
- }
1103
- }
1104
- if (seed.colorSecondary) derived.colorSecondary = seed.colorSecondary;
1105
- if (seed.colorSuccess) derived.colorSuccess = seed.colorSuccess;
1106
- if (seed.colorWarning) derived.colorWarning = seed.colorWarning;
1107
- if (seed.colorError) derived.colorError = seed.colorError;
1108
- if (seed.colorLink) derived.colorLink = seed.colorLink;
1109
- if (seed.colorText) derived.colorText = seed.colorText;
1110
- if (seed.colorTextOnPrimary) {
1111
- derived.colorTextOnPrimary = seed.colorTextOnPrimary;
1112
- }
1113
- if (seed.colorText) {
1114
- derived.colorTextSecondary = withAlpha(seed.colorText, 0.72);
1115
- derived.colorTextTertiary = withAlpha(seed.colorText, 0.6);
1116
- derived.colorTextDisabled = withAlpha(seed.colorText, 0.4);
1117
- derived.colorBorder = withAlpha(seed.colorText, 0.1);
1118
- derived.colorBorderSecondary = withAlpha(seed.colorText, 0.06);
1119
- }
1120
- if (seed.colorBgBase) {
1121
- derived.colorBgCanvas = seed.colorBgBase;
1122
- if (seed.colorText) {
1123
- derived.colorBgSurface = mixColors(
1124
- seed.colorBgBase,
1125
- seed.colorText,
1126
- 0.06
1127
- );
1128
- derived.colorBgSurfaceSubtle = withAlpha(seed.colorText, 0.04);
1129
- derived.colorBgSurfaceStrong = withAlpha(seed.colorText, 0.12);
1130
- derived.colorBgFloating = mixColors(
1131
- seed.colorBgBase,
1132
- seed.colorText,
1133
- 0.1
1134
- );
1135
- derived.colorBgInset = mixColors(
1136
- seed.colorBgBase,
1137
- seed.colorText,
1138
- 0.14
1139
- );
1140
- derived.colorBgMask = isLight ? withAlpha(seed.colorText, 0.45) : withAlpha(seed.colorBgBase, 0.6);
1141
- } else {
1142
- derived.colorBgSurface = seed.colorBgBase;
1143
- derived.colorBgFloating = seed.colorBgBase;
1144
- derived.colorBgInset = seed.colorBgBase;
1145
- }
1146
- }
1147
- if (seed.colorSecondary) {
1148
- derived.colorSecondaryBg = withAlpha(seed.colorSecondary, 0.15);
1149
- }
1150
- if (seed.colorSuccess) {
1151
- derived.colorSuccessBg = withAlpha(seed.colorSuccess, 0.15);
1152
- }
1153
- if (seed.colorWarning) {
1154
- derived.colorWarningBg = withAlpha(seed.colorWarning, 0.15);
1155
- }
1156
- if (seed.colorError) {
1157
- derived.colorErrorBg = withAlpha(seed.colorError, 0.15);
1158
- }
1159
- if (seed.borderRadius !== void 0) {
1160
- derived.borderRadius = seed.borderRadius;
1161
- derived.borderRadiusSm = Math.max(0, seed.borderRadius - 4);
1162
- derived.borderRadiusLg = seed.borderRadius + 4;
1163
- }
1164
- if (seed.fontSize !== void 0) {
1165
- derived.fontSize = seed.fontSize;
1166
- derived.fontSizeSm = seed.fontSize - 2;
1167
- derived.fontSizeLg = seed.fontSize + 2;
1168
- derived.fontSizeXl = seed.fontSize + 4;
1169
- derived.fontSizeXxl = seed.fontSize + 8;
1170
- derived.fontSizeXxxl = seed.fontSize + 10;
1171
- }
1172
- if (seed.spacingBaseStep !== void 0 || seed.spacingChangeUnit !== void 0) {
1173
- const base = Math.max(1, Number(seed.spacingBaseStep) || 1);
1174
- const unit = Math.max(1, Number(seed.spacingChangeUnit) || 1);
1175
- const spacingXs = base;
1176
- const spacingSm = base + unit;
1177
- const spacingMd = base + unit * 3;
1178
- const spacingLg = base + unit * 5;
1179
- const spacingXl = base + unit * 7;
1180
- derived.spacing = spacingSm;
1181
- derived.spacingXs = spacingXs;
1182
- derived.spacingSm = spacingSm;
1183
- derived.spacingMd = spacingMd;
1184
- derived.spacingLg = spacingLg;
1185
- derived.spacingXl = spacingXl;
1186
- }
1187
- return derived;
1188
- }
1189
- function mergeTokens(defaults, derived, override) {
1190
- return {
1191
- ...defaults,
1192
- ...derived,
1193
- ...override
1194
- };
1195
- }
1196
- function getSystemThemeMode() {
1197
- if (typeof window === "undefined") {
1198
- return "light";
1199
- }
1200
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
1201
- }
1202
- const defaultTheme = {
1203
- mode: "dark",
1204
- compact: false,
1205
- tokens: darkDefaultTokens
1206
- };
1207
- function toKebabCase(str) {
1208
- return str.replace(/([A-Z])/g, "-$1").toLowerCase();
1209
- }
1210
- function tokensToCssVariables(tokens) {
1211
- const cssVars = {};
1212
- for (const [key, value] of Object.entries(tokens)) {
1213
- const cssVarName = `--taskon-${toKebabCase(key)}`;
1214
- if (typeof value === "number") {
1215
- cssVars[cssVarName] = `${value}px`;
1216
- } else {
1217
- cssVars[cssVarName] = value;
1218
- }
1219
- }
1220
- return cssVars;
1221
- }
1222
- function resolveTheme(config, systemMode) {
1223
- if (!config) {
1224
- return defaultTheme;
1225
- }
1226
- let resolvedMode;
1227
- if (config.mode === "auto") {
1228
- resolvedMode = systemMode;
1229
- } else if (config.mode) {
1230
- resolvedMode = config.mode;
1231
- } else {
1232
- resolvedMode = "dark";
1233
- }
1234
- const defaultTokens = resolvedMode === "light" ? lightDefaultTokens : darkDefaultTokens;
1235
- const modeConfig = resolvedMode === "light" ? config.light : config.dark;
1236
- const mergedSeed = {
1237
- ...config.seed,
1238
- ...modeConfig == null ? void 0 : modeConfig.seed
1239
- };
1240
- const derivedTokens = deriveTokens(mergedSeed, resolvedMode);
1241
- const mergedMap = {
1242
- ...config.map,
1243
- ...modeConfig == null ? void 0 : modeConfig.map
1244
- };
1245
- const finalTokens = mergeTokens(defaultTokens, derivedTokens, mergedMap);
1246
- return {
1247
- mode: resolvedMode,
1248
- compact: config.compact ?? false,
1249
- tokens: finalTokens
1250
- };
1251
- }
1252
- function ThemeProvider({
1253
- theme: themeConfig,
1254
- children
1255
- }) {
1256
- const [portalContainer, setPortalContainer] = useState(
1257
- null
1258
- );
1259
- const [systemMode, setSystemMode] = useState(
1260
- () => getSystemThemeMode()
1261
- );
1262
- const effectiveMode = themeConfig == null ? void 0 : themeConfig.mode;
1263
- useEffect(() => {
1264
- if (effectiveMode !== "auto") {
1265
- return;
1266
- }
1267
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
1268
- const handler = (e) => {
1269
- setSystemMode(e.matches ? "dark" : "light");
1270
- };
1271
- mediaQuery.addEventListener("change", handler);
1272
- return () => mediaQuery.removeEventListener("change", handler);
1273
- }, [effectiveMode]);
1274
- const resolvedTheme = useMemo(
1275
- () => resolveTheme(themeConfig, systemMode),
1276
- [themeConfig, systemMode]
1277
- );
1278
- const cssVariables = useMemo(
1279
- () => tokensToCssVariables(resolvedTheme.tokens),
1280
- [resolvedTheme.tokens]
1281
- );
1282
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ jsx(ThemePortalContainerContext.Provider, { value: portalContainer, children: /* @__PURE__ */ jsxs(
1283
- "div",
1284
- {
1285
- style: cssVariables,
1286
- "data-taskon-theme": resolvedTheme.mode,
1287
- children: [
1288
- /* @__PURE__ */ jsx(
1289
- "div",
1290
- {
1291
- ref: setPortalContainer,
1292
- "aria-hidden": "true",
1293
- style: {
1294
- position: "absolute",
1295
- top: 0,
1296
- left: 0,
1297
- width: 0,
1298
- height: 0
1299
- }
1300
- }
1301
- ),
1302
- children
1303
- ]
1304
- }
1305
- ) }) });
1306
- }
1307
- export {
1308
- Branch as B,
1309
- DismissableLayer as D,
1310
- Primitive as P,
1311
- Root as R,
1312
- ThemeProvider as T,
1313
- useTaskOnTheme as a,
1314
- useWidgetLocale as b,
1315
- clearLocaleCache as c,
1316
- useTaskOnContext as d,
1317
- createContextScope as e,
1318
- useComposedRefs as f,
1319
- createSlot as g,
1320
- useControllableState as h,
1321
- isSupportedLocale as i,
1322
- Presence as j,
1323
- composeEventHandlers as k,
1324
- useCallbackRef as l,
1325
- Portal as m,
1326
- dispatchDiscreteCustomEvent as n,
1327
- useLayoutEffect2 as o,
1328
- preloadWidgetLocale as p,
1329
- TaskOnContext as q,
1330
- composeRefs as r,
1331
- createContext2 as s,
1332
- useTaskOnPortalContainer as t,
1333
- useTaskOnAuth as u
1334
- };