qstd 0.1.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.
@@ -0,0 +1,3128 @@
1
+ import "./index.css";
2
+ import * as React11 from 'react';
3
+ import React11__default from 'react';
4
+ import { createPortal } from 'react-dom';
5
+ import { motion, MotionConfig, LayoutGroup, AnimatePresence, useDragControls, useMotionValue } from 'framer-motion';
6
+ import { useFloating, offset, flip, shift, hide, autoUpdate, FloatingPortal, arrow, useHover, safePolygon, useFocus, useDismiss, useRole, useInteractions } from '@floating-ui/react';
7
+ import { css } from 'panda/css';
8
+ import { BeatLoader } from 'react-spinners';
9
+ import { Oval, ThreeDots, TailSpin, RotatingLines } from 'react-loader-spinner';
10
+ import { styled } from 'panda/jsx';
11
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
+ import { nanoid } from 'nanoid';
13
+ import * as mmb from 'music-metadata-browser';
14
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
15
+ import { library } from '@fortawesome/fontawesome-svg-core';
16
+ import { far } from '@fortawesome/free-regular-svg-icons';
17
+ import { fab } from '@fortawesome/free-brands-svg-icons';
18
+ import { fas } from '@fortawesome/free-solid-svg-icons';
19
+ import { useImmer } from 'use-immer';
20
+
21
+ // src/react/index.ts
22
+ var base = styled("div", { base: { m: 0 } });
23
+ var tags = {
24
+ div: base,
25
+ a: styled("a"),
26
+ br: styled("br"),
27
+ button: styled("button"),
28
+ canvas: styled("canvas"),
29
+ form: styled("form"),
30
+ h1: styled("h1"),
31
+ h2: styled("h2"),
32
+ h3: styled("h3"),
33
+ hr: styled("hr"),
34
+ nav: styled("nav"),
35
+ main: styled("main"),
36
+ aside: styled("aside"),
37
+ article: styled("article"),
38
+ section: styled("section"),
39
+ details: styled("details"),
40
+ header: styled("header"),
41
+ footer: styled("footer"),
42
+ strong: styled("strong"),
43
+ em: styled("em"),
44
+ img: styled("img"),
45
+ del: styled("del"),
46
+ ins: styled("ins"),
47
+ kbd: styled("kbd"),
48
+ code: styled("code"),
49
+ mark: styled("mark"),
50
+ samp: styled("samp"),
51
+ small: styled("small"),
52
+ sub: styled("sub"),
53
+ sup: styled("sup"),
54
+ u: styled("u"),
55
+ var: styled("var"),
56
+ input: styled("input"),
57
+ label: styled("label"),
58
+ legend: styled("legend"),
59
+ p: styled("p"),
60
+ select: styled("select"),
61
+ span: styled("span"),
62
+ svg: styled("svg"),
63
+ textarea: styled("textarea"),
64
+ table: styled("table"),
65
+ tr: styled("tr"),
66
+ th: styled("th"),
67
+ td: styled("td"),
68
+ tbody: styled("tbody"),
69
+ thead: styled("thead"),
70
+ tfoot: styled("tfoot"),
71
+ progress: styled("progress"),
72
+ ol: styled("ol"),
73
+ ul: styled("ul"),
74
+ li: styled("li"),
75
+ blockquote: styled("blockquote"),
76
+ pre: styled("pre")
77
+ };
78
+ var motionTags = {
79
+ div: styled(motion.div, { base: { m: 0 } }),
80
+ a: styled(motion.a),
81
+ br: styled(motion.br),
82
+ button: styled(motion.button),
83
+ canvas: styled(motion.canvas),
84
+ form: styled(motion.form),
85
+ h1: styled(motion.h1),
86
+ h2: styled(motion.h2),
87
+ h3: styled(motion.h3),
88
+ hr: styled(motion.hr),
89
+ nav: styled(motion.nav),
90
+ main: styled(motion.main),
91
+ aside: styled(motion.aside),
92
+ article: styled(motion.article),
93
+ section: styled(motion.section),
94
+ details: styled(motion.details),
95
+ header: styled(motion.header),
96
+ footer: styled(motion.footer),
97
+ strong: styled(motion.strong),
98
+ em: styled(motion.em),
99
+ img: styled(motion.img),
100
+ del: styled(motion.del),
101
+ ins: styled(motion.ins),
102
+ kbd: styled(motion.kbd),
103
+ code: styled(motion.code),
104
+ mark: styled(motion.mark),
105
+ samp: styled(motion.samp),
106
+ small: styled(motion.small),
107
+ sub: styled(motion.sub),
108
+ sup: styled(motion.sup),
109
+ u: styled(motion.u),
110
+ var: styled(motion.var),
111
+ input: styled(motion.input),
112
+ label: styled(motion.label),
113
+ legend: styled(motion.legend),
114
+ p: styled(motion.p),
115
+ select: styled(motion.select),
116
+ span: styled(motion.span),
117
+ svg: styled(motion.svg),
118
+ textarea: styled(motion.textarea),
119
+ table: styled(motion.table),
120
+ tr: styled(motion.tr),
121
+ th: styled(motion.th),
122
+ td: styled(motion.td),
123
+ tbody: styled(motion.tbody),
124
+ thead: styled(motion.thead),
125
+ tfoot: styled(motion.tfoot),
126
+ progress: styled(motion.progress),
127
+ ol: styled(motion.ol),
128
+ ul: styled(motion.ul),
129
+ li: styled(motion.li),
130
+ blockquote: styled(motion.blockquote),
131
+ pre: styled(motion.pre)
132
+ };
133
+ var loadingIconsMap = {
134
+ rotatingLines: RotatingLines,
135
+ spinner: TailSpin,
136
+ beat: BeatLoader,
137
+ dots: ThreeDots,
138
+ oval: Oval
139
+ };
140
+ var loadingIcons = Object.keys(loadingIconsMap);
141
+ var Div = tags.div;
142
+ var MotionDiv = motionTags.div;
143
+ function MenuContainer(props) {
144
+ const { children, ...rest } = props;
145
+ return /* @__PURE__ */ jsx(Div, { ...rest, role: "menu", "data-menu-container": true, children });
146
+ }
147
+ function Menu(props) {
148
+ const {
149
+ variant = "click",
150
+ isOpen: isOpenControlled,
151
+ children,
152
+ trigger,
153
+ ...rest
154
+ } = props;
155
+ const hoverTimeoutRef = React11__default.useRef(null);
156
+ const [isOpen, setOpen] = React11__default.useState(isOpenControlled ?? false);
157
+ const onOpenChange = (open) => {
158
+ const newOpenState = typeof open === "function" ? open(isOpen) : open;
159
+ props.onOpenOrClose?.(newOpenState);
160
+ setOpen(newOpenState);
161
+ };
162
+ React11__default.useEffect(() => {
163
+ if (typeof isOpenControlled !== "boolean") return;
164
+ setOpen(isOpenControlled);
165
+ }, [isOpenControlled]);
166
+ const {
167
+ refs,
168
+ x,
169
+ y,
170
+ middlewareData: { hide: hideData },
171
+ context: floatingContext
172
+ } = useFloating({
173
+ placement: props.placement ?? "bottom-start",
174
+ whileElementsMounted: autoUpdate,
175
+ open: isOpen,
176
+ onOpenChange,
177
+ middleware: [
178
+ offset({ crossAxis: props.offset?.x, mainAxis: props.offset?.y }),
179
+ flip({ fallbackPlacements: ["top-end"] }),
180
+ shift({ padding: 5 }),
181
+ hide({ strategy: "referenceHidden" })
182
+ ]
183
+ });
184
+ const openMenu = () => {
185
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
186
+ hoverTimeoutRef.current = null;
187
+ onOpenChange(true);
188
+ };
189
+ const closeMenuHover = () => {
190
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
191
+ hoverTimeoutRef.current = setTimeout(
192
+ () => onOpenChange(false),
193
+ props.hoverDelay ?? 150
194
+ );
195
+ };
196
+ const closeMenuImmediate = () => {
197
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
198
+ hoverTimeoutRef.current = null;
199
+ onOpenChange(false);
200
+ };
201
+ const handleTriggerClick = () => {
202
+ if (variant === "click") onOpenChange((prev) => !prev);
203
+ };
204
+ const handleTriggerMouseEnter = () => {
205
+ if (variant === "hover") {
206
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
207
+ hoverTimeoutRef.current = setTimeout(() => {
208
+ openMenu();
209
+ }, props.hoverDelay ?? 250);
210
+ }
211
+ };
212
+ const handleTriggerMouseLeave = () => {
213
+ if (variant === "hover") {
214
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
215
+ closeMenuHover();
216
+ }
217
+ };
218
+ const handleMenuMouseEnter = () => {
219
+ if (variant === "hover") openMenu();
220
+ };
221
+ const handleMenuMouseLeave = () => {
222
+ if (variant === "hover") closeMenuHover();
223
+ };
224
+ useOutsideClick(
225
+ refs.floating,
226
+ (event) => {
227
+ const referenceElement = refs.reference.current;
228
+ if (isOpen && referenceElement instanceof Element && !referenceElement.contains(event.target)) {
229
+ closeMenuImmediate();
230
+ }
231
+ },
232
+ isOpen
233
+ );
234
+ React11__default.useEffect(() => {
235
+ if (!hideData?.referenceHidden) return;
236
+ closeMenuImmediate();
237
+ }, [hideData, closeMenuImmediate]);
238
+ React11__default.useEffect(() => {
239
+ return () => {
240
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
241
+ };
242
+ }, []);
243
+ const menuVariants = {
244
+ hidden: {
245
+ opacity: 0,
246
+ scale: 0.9,
247
+ transition: { duration: 0.1, ease: "easeOut" }
248
+ },
249
+ visible: {
250
+ opacity: 1,
251
+ scale: 1,
252
+ transition: { duration: 0.15, ease: "easeIn" }
253
+ }
254
+ };
255
+ const triggerEventProps = variant === "hover" ? {
256
+ onMouseEnter: handleTriggerMouseEnter,
257
+ onMouseLeave: handleTriggerMouseLeave
258
+ } : { onClick: handleTriggerClick };
259
+ const menuEventProps = variant === "hover" ? {
260
+ onMouseEnter: handleMenuMouseEnter,
261
+ onMouseLeave: handleMenuMouseLeave
262
+ } : {};
263
+ const transformOrigin = floatingContext.placement.startsWith("top") ? "bottom left" : "top left";
264
+ const childArray = React11__default.Children.toArray(children);
265
+ let customContainerEl = null;
266
+ for (const c of childArray) {
267
+ if (React11__default.isValidElement(c)) {
268
+ const anyType = c.type;
269
+ if (c.props?.["data-menu-container"] || anyType?.isBlockMenuContainer) {
270
+ customContainerEl = c;
271
+ break;
272
+ }
273
+ }
274
+ }
275
+ let floatingLayer = null;
276
+ if (customContainerEl) {
277
+ const childProps = customContainerEl.props || {};
278
+ const { style: restStyle, ...restPanda } = rest || {};
279
+ const defaultStyles = {};
280
+ if (childProps.borderRadius === void 0 && childProps.rounded === void 0 && childProps.style?.borderRadius === void 0)
281
+ defaultStyles.borderRadius = "md";
282
+ if (childProps.shadow === void 0 && childProps.boxShadow === void 0 && childProps.style?.boxShadow === void 0)
283
+ defaultStyles.shadow = "lg";
284
+ if (childProps.bg === void 0 && childProps.background === void 0 && !(childProps.style?.background || childProps.style?.backgroundColor))
285
+ defaultStyles.bg = { base: "neutral.100", _dark: "neutral.900" };
286
+ if (childProps.overflow === void 0 && childProps.style?.overflow === void 0)
287
+ defaultStyles.overflow = "hidden";
288
+ if (childProps.outline === void 0 && childProps.style?.outline === void 0)
289
+ defaultStyles.outline = "none";
290
+ const defaultsClassName = Object.keys(defaultStyles).length > 0 ? css(defaultStyles) : "";
291
+ const mergedStyle = {
292
+ ...childProps.style || {},
293
+ ...restStyle || {}
294
+ };
295
+ const mergedClassName = [defaultsClassName, childProps.className].filter(Boolean).join(" ");
296
+ const contentNode = React11__default.cloneElement(
297
+ customContainerEl,
298
+ {
299
+ // Defaults are now in mergedClassName via css()
300
+ // Then Panda props coming from the parent <Block is="menu" ...>
301
+ ...restPanda,
302
+ // Finally explicit props on the provided container win
303
+ ...childProps,
304
+ // Apply merged className
305
+ className: mergedClassName,
306
+ // Apply menu event props to the actual container
307
+ ...menuEventProps,
308
+ role: childProps.role ?? "menu",
309
+ "aria-orientation": childProps["aria-orientation"] ?? "vertical",
310
+ css: {
311
+ ...restPanda.css || {},
312
+ ...childProps.css || {},
313
+ ring: (childProps.css && childProps.css.ring) ?? (restPanda.css && restPanda.css.ring) ?? "1px solid rgba(208, 58, 58, 0.05)"
314
+ },
315
+ style: mergedStyle
316
+ },
317
+ childProps.children
318
+ );
319
+ floatingLayer = /* @__PURE__ */ jsx(
320
+ MotionDiv,
321
+ {
322
+ zIndex: props.zIndex,
323
+ ref: refs.setFloating,
324
+ onClick: (e) => e.stopPropagation(),
325
+ style: { position: "absolute", top: y, left: x, transformOrigin },
326
+ variants: menuVariants,
327
+ initial: "hidden",
328
+ animate: "visible",
329
+ exit: "hidden",
330
+ children: contentNode
331
+ }
332
+ );
333
+ } else {
334
+ const { style: restStyle, ...restPanda } = rest || {};
335
+ const container = /* @__PURE__ */ jsx(
336
+ MenuContainer,
337
+ {
338
+ role: "menu",
339
+ "aria-orientation": "vertical",
340
+ borderRadius: "md",
341
+ shadow: "lg",
342
+ bg: { base: "neutral.100", _dark: "neutral.900" },
343
+ overflow: "hidden",
344
+ outline: "none",
345
+ css: { ring: "1px solid rgba(208, 58, 58, 0.05)" },
346
+ ...restPanda,
347
+ ...menuEventProps,
348
+ style: { ...restStyle || {} },
349
+ children
350
+ }
351
+ );
352
+ floatingLayer = /* @__PURE__ */ jsx(
353
+ MotionDiv,
354
+ {
355
+ zIndex: props.zIndex,
356
+ ref: refs.setFloating,
357
+ onClick: (e) => e.stopPropagation(),
358
+ style: { position: "absolute", top: y, left: x, transformOrigin },
359
+ variants: menuVariants,
360
+ initial: "hidden",
361
+ animate: "visible",
362
+ exit: "hidden",
363
+ children: container
364
+ }
365
+ );
366
+ }
367
+ return /* @__PURE__ */ jsxs(
368
+ Div,
369
+ {
370
+ ref: refs.setReference,
371
+ h: "max-content",
372
+ style: { width: props.width || "max-content" },
373
+ ...triggerEventProps,
374
+ children: [
375
+ trigger,
376
+ /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && floatingLayer }) })
377
+ ]
378
+ }
379
+ );
380
+ }
381
+ function useOutsideClick(ref, handler, enabled = true) {
382
+ React11__default.useEffect(() => {
383
+ if (!enabled) return;
384
+ const listener = (event) => {
385
+ if (!ref.current || ref.current.contains(event.target)) {
386
+ return;
387
+ }
388
+ handler(event);
389
+ };
390
+ document.addEventListener("mousedown", listener);
391
+ document.addEventListener("touchstart", listener);
392
+ return () => {
393
+ document.removeEventListener("mousedown", listener);
394
+ document.removeEventListener("touchstart", listener);
395
+ };
396
+ }, [ref, handler, enabled]);
397
+ }
398
+ var extractImageMetadata = (f) => {
399
+ return new Promise((res, rej) => {
400
+ if (!f) rej("No image file provided.");
401
+ const ext = f.type.split("/").pop();
402
+ const id = `${ext}_${nanoid()}.${ext}`;
403
+ const preview = URL.createObjectURL(f);
404
+ const image = new Image();
405
+ image.onload = () => {
406
+ const { height, width } = image;
407
+ let orientation = "";
408
+ if (height === width) orientation = "square";
409
+ else if (height > width) orientation = "portrait";
410
+ else orientation = "landscape";
411
+ res({ id, preview, orientation, height, width });
412
+ };
413
+ image.onerror = (e, x, y, z, a) => {
414
+ if (ext?.includes("tif")) {
415
+ const { height, width } = image;
416
+ let orientation = "";
417
+ if (height === width) orientation = "square";
418
+ else if (height > width) orientation = "portrait";
419
+ else orientation = "landscape";
420
+ res({ id, preview, orientation, height, width });
421
+ } else {
422
+ console.log("image error");
423
+ rej("Image failed to load.");
424
+ }
425
+ };
426
+ image.src = preview;
427
+ });
428
+ };
429
+ var extractAudioMetadata = async (f) => {
430
+ const meta = await mmb.parseBlob(f, { duration: true });
431
+ return new Promise((res, rej) => {
432
+ if (!f) rej("No audio file provided.");
433
+ const ext = f.name.split(".").pop();
434
+ const id = `${ext}_${nanoid()}.${ext}`;
435
+ const [cover] = meta.common.picture ?? [];
436
+ const preview = URL.createObjectURL(
437
+ new Blob([cover.data], { type: cover.format })
438
+ );
439
+ const audioMetadata = {
440
+ id,
441
+ preview,
442
+ source: { ...meta.format, ...meta.common }
443
+ };
444
+ res(audioMetadata);
445
+ });
446
+ };
447
+ var extractVideoMetadata = (f) => {
448
+ return new Promise((res, rej) => {
449
+ if (!f) rej("No video file provided.");
450
+ const ext = f.type.split("/").pop();
451
+ const id = `${ext}_${nanoid()}.${ext}`;
452
+ const video = document.createElement("video");
453
+ video.addEventListener("loadedmetadata", () => {
454
+ const height = video.videoHeight;
455
+ const width = video.videoWidth;
456
+ const duration = video.duration;
457
+ let orientation = "";
458
+ if (height === width) orientation = "square";
459
+ else if (height > width) orientation = "portrait";
460
+ else orientation = "landscape";
461
+ res({ id, orientation, duration, height, width });
462
+ });
463
+ video.src = URL.createObjectURL(f);
464
+ });
465
+ };
466
+ var prepareFiles = async (acceptedFiles) => {
467
+ return Promise.all(
468
+ acceptedFiles.map(async (f) => {
469
+ if (f.type.startsWith("image")) {
470
+ const metadata = await extractImageMetadata(f);
471
+ return Object.assign(f, metadata);
472
+ } else if (f.type.startsWith("audio")) {
473
+ const metadata = await extractAudioMetadata(f);
474
+ return Object.assign(f, metadata);
475
+ } else if (f.type.startsWith("video")) {
476
+ const metadata = await extractVideoMetadata(f);
477
+ return Object.assign(f, metadata);
478
+ } else {
479
+ const ext = f.type.split("/").pop();
480
+ const id = `${ext}_${nanoid()}.${ext}`;
481
+ const metadata = { id };
482
+ return Object.assign(f, metadata);
483
+ }
484
+ })
485
+ );
486
+ };
487
+ var findChildrenByDisplayName = (children, displayName2) => {
488
+ return React11__default.Children.toArray(children).find(
489
+ (child) => {
490
+ if (React11__default.isValidElement(child)) {
491
+ const childType = child.type;
492
+ return childType.displayName === displayName2;
493
+ } else {
494
+ return false;
495
+ }
496
+ }
497
+ );
498
+ };
499
+ var extractElType = (is, props) => {
500
+ let el = "div";
501
+ if (is === "txt") el = "p";
502
+ else if (is === "hr") el = "hr";
503
+ else if (is === "btn") el = "button";
504
+ else if (is === "link") el = "button";
505
+ else if (is === "img") el = "img";
506
+ else if (is === "input") el = "input";
507
+ else if (is === "accordion") el = "div";
508
+ else if (is === "textarea") el = "textarea";
509
+ else if (is === "checkbox") el = "button";
510
+ else if (is === "radio") el = "div";
511
+ else if (is === "skeleton") el = "div";
512
+ else if (is === "switch") el = "button";
513
+ else if (is === "select") el = "select";
514
+ else if (is === "blockquote") el = "blockquote";
515
+ else if (is === "pre") el = "pre";
516
+ else if (is === "progress") el = "progress";
517
+ else if (is === "drawer") el = "div";
518
+ else if (is === "menu") el = "div";
519
+ else if (is === "form") el = "form";
520
+ else if (is === "table") el = "table";
521
+ else if (is === "list") el = "ul";
522
+ else if (is === "seo") el = "section";
523
+ else el = "div";
524
+ const isHr = is === "hr";
525
+ const isLink = is === "link";
526
+ const isMenu = is === "menu";
527
+ const isInput = is === "input";
528
+ const isRadio = is === "radio";
529
+ const isDrawer = is === "drawer";
530
+ const isSwitch = is === "switch";
531
+ const isSkeleton = is === "skeleton";
532
+ const isCheckbox = is === "checkbox";
533
+ const isTextarea = is === "textarea";
534
+ const isProgress = is === "progress";
535
+ const isAccordion = is === "accordion";
536
+ const isBtnLike = is === "btn" || is === "link";
537
+ const filepickerAllowed = !is && props.filepicker || is && (is === "txt" || is === "btn" || is === "link" || is === "img") && props.filepicker;
538
+ return {
539
+ el,
540
+ is,
541
+ isMenu,
542
+ isLink,
543
+ isInput,
544
+ isRadio,
545
+ isSwitch,
546
+ isBtnLike,
547
+ isAccordion,
548
+ filepickerAllowed,
549
+ isTextarea,
550
+ isCheckbox,
551
+ isSkeleton,
552
+ isProgress,
553
+ isDrawer,
554
+ isHr
555
+ };
556
+ };
557
+ var extractElAndStyles = (extract, anyProps) => {
558
+ const {
559
+ _motion,
560
+ layout,
561
+ initial,
562
+ animate,
563
+ exit,
564
+ whileTap,
565
+ whileHover,
566
+ whileFocus,
567
+ transition,
568
+ variants,
569
+ ...rest
570
+ } = anyProps;
571
+ const StdComp = tags[extract.el] || tags.div;
572
+ const MotionComp = motionTags[extract.el] || motionTags.div;
573
+ const hasMotionProps = layout !== void 0 || initial !== void 0 || animate !== void 0 || exit !== void 0 || whileHover !== void 0 || whileTap !== void 0 || whileFocus !== void 0 || variants !== void 0 || transition !== void 0;
574
+ const comp = hasMotionProps ? MotionComp : StdComp;
575
+ const motionProps = hasMotionProps ? {
576
+ layout,
577
+ initial,
578
+ animate,
579
+ exit,
580
+ whileHover,
581
+ whileTap,
582
+ whileFocus,
583
+ variants,
584
+ transition
585
+ } : void 0;
586
+ const remaining = omit(rest, ["loadingPosition", "loadingIcon", "isLoading"]);
587
+ const cursor = anyProps.isLoading ? "not-allowed" : "pointer";
588
+ const btnClassName = extract.is === "btn" ? css({ display: "flex", alignI: "center", cursor }) : "";
589
+ const linkClassName = extract.isLink ? css({
590
+ color: { base: "blue.500", _dark: "blue.400" },
591
+ _hover: { textDecoration: "underline" },
592
+ cursor
593
+ }) : "";
594
+ const mergedClassName = [btnClassName, linkClassName, anyProps.className].filter(Boolean).join(" ");
595
+ return [
596
+ comp,
597
+ {
598
+ ...motionProps,
599
+ ...remaining,
600
+ className: mergedClassName
601
+ }
602
+ ];
603
+ };
604
+ function getIcon(position, Icon2, props) {
605
+ const {
606
+ loadingIcon,
607
+ iconPrefix = "solid",
608
+ loadingPosition = "start",
609
+ loadingIconSize,
610
+ isLoading,
611
+ _loading,
612
+ strokeColor,
613
+ strokeWidth
614
+ } = props;
615
+ const prefix = iconPrefix === "solid" ? "fas" : iconPrefix === "regular" ? "far" : "fab";
616
+ if (isLoading && position === loadingPosition) {
617
+ const chosen = Icon2 ?? loadingIcon ?? null;
618
+ if (chosen) {
619
+ if (typeof chosen === "string" && loadingIcons.includes(chosen)) {
620
+ const Cmp = loadingIconsMap[chosen];
621
+ const sizePx = typeof loadingIconSize === "number" ? `${loadingIconSize}px` : "12px";
622
+ return Cmp({ width: sizePx, height: sizePx });
623
+ } else if (React11__default.isValidElement(chosen)) {
624
+ return chosen;
625
+ } else if (typeof chosen === "function") {
626
+ return chosen();
627
+ } else if (chosen?.iconName) {
628
+ return /* @__PURE__ */ jsx(
629
+ FontAwesomeIcon,
630
+ {
631
+ icon: chosen,
632
+ className: props.className,
633
+ spinPulse: props.pulse,
634
+ size: props.size,
635
+ spin: props.spin
636
+ }
637
+ );
638
+ }
639
+ }
640
+ const widthPx = typeof loadingIconSize === "number" ? `${loadingIconSize}px` : "12px";
641
+ const resolvedStrokeWidth = _loading?.strokeWidth ?? strokeWidth ?? 4;
642
+ const resolvedStrokeColor = typeof _loading?.strokeColor === "string" && _loading.strokeColor || typeof strokeColor === "string" && strokeColor || "var(--colors-neutral-200)";
643
+ return /* @__PURE__ */ jsx(
644
+ RotatingLines,
645
+ {
646
+ strokeWidth: `${resolvedStrokeWidth}`,
647
+ strokeColor: resolvedStrokeColor,
648
+ width: widthPx
649
+ }
650
+ );
651
+ }
652
+ if (!Icon2) return null;
653
+ else if (typeof Icon2 === "string") {
654
+ return /* @__PURE__ */ jsx(
655
+ FontAwesomeIcon,
656
+ {
657
+ icon: { prefix, iconName: Icon2 },
658
+ className: props.className,
659
+ spinPulse: props.pulse,
660
+ size: props.size,
661
+ spin: props.spin
662
+ }
663
+ );
664
+ } else if ("iconName" in Icon2) {
665
+ return /* @__PURE__ */ jsx(
666
+ FontAwesomeIcon,
667
+ {
668
+ icon: Icon2,
669
+ className: props.className,
670
+ spinPulse: props.pulse,
671
+ size: props.size,
672
+ spin: props.spin
673
+ }
674
+ );
675
+ } else if (typeof Icon2 === "function") {
676
+ return Icon2(props);
677
+ } else return Icon2;
678
+ }
679
+ var getIcons = (extract, anyProps) => {
680
+ const { icon, startIcon, endIcon } = anyProps;
681
+ let isLoading;
682
+ let loadingIcon;
683
+ let loadingPosition;
684
+ if (extract.isBtnLike) {
685
+ const loadingProps = anyProps;
686
+ loadingPosition = loadingProps.loadingPosition;
687
+ loadingIcon = loadingProps.loadingIcon;
688
+ isLoading = loadingProps.isLoading;
689
+ }
690
+ const leftArg = isLoading && loadingPosition === "start" ? loadingIcon ?? null : icon ?? startIcon;
691
+ const rightArg = isLoading && loadingPosition === "end" ? loadingIcon ?? null : endIcon ?? null;
692
+ const leftIcon = getIcon("start", leftArg, anyProps);
693
+ const rightIcon = getIcon("end", rightArg, anyProps);
694
+ return { leftIcon, rightIcon };
695
+ };
696
+ var omit = (obj, keys) => {
697
+ const result = {};
698
+ if (keys.length === 0) {
699
+ for (const k in obj) {
700
+ if (Object.prototype.hasOwnProperty.call(obj, k)) {
701
+ result[k] = obj[k];
702
+ }
703
+ }
704
+ return result;
705
+ }
706
+ const skip = new Set(keys);
707
+ for (const k in obj) {
708
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) continue;
709
+ if (!skip.has(k)) {
710
+ result[k] = obj[k];
711
+ }
712
+ }
713
+ return result;
714
+ };
715
+ var TrackNameKey = "Track";
716
+ var ThumbNameKey = "Thumb";
717
+ var Button = motionTags.button;
718
+ var Base = motionTags.div;
719
+ var SwitchContext = React11__default.createContext(null);
720
+ var useSwitchContext = () => {
721
+ const context = React11__default.useContext(SwitchContext);
722
+ if (!context) {
723
+ throw new Error("Switch compound components must be used within Switch");
724
+ }
725
+ return context;
726
+ };
727
+ function Switch(props) {
728
+ const {
729
+ checked = false,
730
+ disabled = false,
731
+ thumbSize = 20,
732
+ onChange,
733
+ children,
734
+ _motion,
735
+ ...rest
736
+ } = props;
737
+ const [x, setX] = React11__default.useState(0);
738
+ const [pressed, setPressed] = React11__default.useState(false);
739
+ const [growThumb, setGrowThumb] = React11__default.useState(false);
740
+ const borderWidth = 4;
741
+ const trackWidth = thumbSize * 1.5;
742
+ const borderRadius = thumbSize * 2.5;
743
+ const xWhileOn = thumbSize;
744
+ const checkedPosition = xWhileOn * 0.5;
745
+ const stopwatch = useStopwatch();
746
+ React11__default.useEffect(() => {
747
+ if (pressed && !disabled) {
748
+ stopwatch.start();
749
+ } else {
750
+ setGrowThumb(false);
751
+ stopwatch.clear();
752
+ }
753
+ }, [pressed, disabled]);
754
+ React11__default.useEffect(() => {
755
+ if (stopwatch.time > 200) {
756
+ setGrowThumb(true);
757
+ }
758
+ }, [stopwatch.time]);
759
+ React11__default.useEffect(() => {
760
+ setX(checked ? checkedPosition : 0);
761
+ }, [checked, checkedPosition]);
762
+ const toggle = () => {
763
+ if (disabled) return;
764
+ if (growThumb) {
765
+ setGrowThumb(false);
766
+ setPressed(false);
767
+ setTimeout(() => {
768
+ const isOff = x === 0;
769
+ setX(isOff ? checkedPosition : 0);
770
+ onChange?.(isOff);
771
+ }, 50);
772
+ } else {
773
+ const isOff = x === 0;
774
+ setX(isOff ? checkedPosition : 0);
775
+ onChange?.(isOff);
776
+ }
777
+ };
778
+ const handlePointerDown = () => {
779
+ if (disabled) return;
780
+ setPressed(true);
781
+ };
782
+ const handlePointerUp = () => setPressed(false);
783
+ const handleKeyDown = (event) => {
784
+ if (disabled) return;
785
+ if (event.code === "Space" || event.key === " ") {
786
+ event.preventDefault();
787
+ if (!pressed) {
788
+ setPressed(true);
789
+ }
790
+ }
791
+ };
792
+ const handleKeyUp = (event) => {
793
+ if (disabled) return;
794
+ if (event.code === "Space" || event.key === " ") {
795
+ event.preventDefault();
796
+ if (pressed) {
797
+ toggle();
798
+ }
799
+ setPressed(false);
800
+ }
801
+ };
802
+ const contextValue = {
803
+ checked,
804
+ disabled,
805
+ pressed,
806
+ growThumb,
807
+ thumbSize,
808
+ trackWidth,
809
+ thumbOffset: x,
810
+ // Use actual x position for animations
811
+ borderRadius,
812
+ borderWidth,
813
+ setPressed,
814
+ toggle
815
+ };
816
+ const track = findChildrenByDisplayName(
817
+ children,
818
+ TrackNameKey
819
+ );
820
+ const thumb = findChildrenByDisplayName(
821
+ children,
822
+ ThumbNameKey
823
+ );
824
+ const trackElement = track ? React11__default.cloneElement(track, {
825
+ _motion,
826
+ children: thumb ? React11__default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsx(Thumb, { _motion })
827
+ }) : /* @__PURE__ */ jsx(Track, { _motion, children: thumb ? React11__default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsx(Thumb, { _motion }) });
828
+ return /* @__PURE__ */ jsx(SwitchContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsx(
829
+ Button,
830
+ {
831
+ flex: true,
832
+ alignItems: "center",
833
+ justifyContent: "center",
834
+ m: 0,
835
+ px: 1,
836
+ py: 1,
837
+ h: "fit-content",
838
+ outlineOffset: 1,
839
+ initial: false,
840
+ animate: {
841
+ outlineOffset: pressed ? "-2px" : "0px",
842
+ transition: { duration: 0.1, ease: "linear" }
843
+ },
844
+ cursor: disabled ? "not-allowed" : "pointer",
845
+ _hover: { bg: "none!" },
846
+ _active: {
847
+ bg: "none",
848
+ transform: "none!",
849
+ scale: "none!"
850
+ // Disable any button press effects that might shrink the toggle
851
+ },
852
+ background: "none",
853
+ style: { borderRadius },
854
+ onClick: toggle,
855
+ onPointerDown: handlePointerDown,
856
+ onPointerUp: handlePointerUp,
857
+ onPointerLeave: handlePointerUp,
858
+ onTouchStart: handlePointerDown,
859
+ onTouchEnd: handlePointerUp,
860
+ onKeyDown: handleKeyDown,
861
+ onKeyUp: handleKeyUp,
862
+ disabled,
863
+ ...rest,
864
+ children: /* @__PURE__ */ jsx(
865
+ Base,
866
+ {
867
+ flex: true,
868
+ flexDirection: "column",
869
+ justifyContent: "center",
870
+ alignItems: "center",
871
+ boxSizing: "border-box",
872
+ children: trackElement
873
+ }
874
+ )
875
+ }
876
+ ) }) });
877
+ }
878
+ function Track(props) {
879
+ const { _motion, children, ...rest } = props;
880
+ const {
881
+ checked,
882
+ trackWidth,
883
+ thumbSize,
884
+ borderWidth,
885
+ borderRadius: toggleBorderRadius
886
+ } = useSwitchContext();
887
+ const defaultBg = checked ? "#60a5fa !important" : "#d1d5db !important";
888
+ return /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsx(
889
+ Base,
890
+ {
891
+ flex: true,
892
+ relative: true,
893
+ alignItems: "center",
894
+ justifyContent: "flex-start",
895
+ boxSizing: "content-box",
896
+ cursor: "pointer",
897
+ bg: defaultBg,
898
+ transition: "background-color 0.2s ease-in-out",
899
+ style: {
900
+ minHeight: thumbSize,
901
+ width: trackWidth,
902
+ border: `${borderWidth}px solid transparent`,
903
+ borderRadius: toggleBorderRadius
904
+ },
905
+ ...rest,
906
+ children
907
+ }
908
+ ) });
909
+ }
910
+ function Thumb(props) {
911
+ const { _motion, ...rest } = props;
912
+ const {
913
+ pressed,
914
+ growThumb,
915
+ thumbSize,
916
+ thumbOffset,
917
+ borderRadius: toggleBorderRadius
918
+ } = useSwitchContext();
919
+ const thumbWidth = thumbSize + (pressed && growThumb ? thumbSize * 0.2 : 0);
920
+ const shouldUseRightAnchor = thumbOffset && growThumb;
921
+ return /* @__PURE__ */ jsx(
922
+ MotionConfig,
923
+ {
924
+ transition: _motion || { type: "spring", stiffness: 700, damping: 30 },
925
+ children: /* @__PURE__ */ jsx(
926
+ Base,
927
+ {
928
+ grid: true,
929
+ bg: "white",
930
+ style: {
931
+ height: thumbSize,
932
+ // width: thumbWidth,
933
+ borderRadius: toggleBorderRadius,
934
+ transition: "background-color 0.2s ease-in-out"
935
+ },
936
+ animate: {
937
+ // Always use consistent x positioning - no switching
938
+ x: thumbOffset,
939
+ width: thumbWidth,
940
+ // Use negative margin to create left-directional growth when ON
941
+ marginLeft: shouldUseRightAnchor ? -(thumbWidth - thumbSize) : 0
942
+ },
943
+ ...rest
944
+ }
945
+ )
946
+ }
947
+ );
948
+ }
949
+ Track.displayName = TrackNameKey;
950
+ Thumb.displayName = ThumbNameKey;
951
+ function useStopwatch(props = {}) {
952
+ const [active, setActive] = React11__default.useState(false);
953
+ const [time, setTime] = React11__default.useState(0);
954
+ const timeInterval = props?.interval ?? 10;
955
+ React11__default.useEffect(() => {
956
+ let interval = null;
957
+ if (active) {
958
+ interval = setInterval(() => {
959
+ setTime((prevTime) => prevTime + timeInterval);
960
+ }, timeInterval);
961
+ } else {
962
+ clearInterval(interval);
963
+ }
964
+ return () => clearInterval(interval);
965
+ }, [active, timeInterval]);
966
+ const start = () => setActive(true);
967
+ const stop = () => setActive(false);
968
+ const clear = () => {
969
+ setActive(false);
970
+ setTime(0);
971
+ };
972
+ return { time, start, stop, clear };
973
+ }
974
+ var switch_default = Switch;
975
+ var RadioContext = React11__default.createContext(null);
976
+ var Base2 = base;
977
+ var MotionDiv2 = motionTags.div;
978
+ function Radio(props) {
979
+ const {
980
+ value: controlledValue,
981
+ defaultValue = null,
982
+ disabled,
983
+ onChange,
984
+ name,
985
+ options,
986
+ renderOption,
987
+ onKeyDown: onKeyDownProp,
988
+ ...rest
989
+ } = props;
990
+ const groupId = React11__default.useId();
991
+ const isControlled = controlledValue !== void 0;
992
+ const [uncontrolled, setUncontrolled] = React11__default.useState(
993
+ defaultValue
994
+ );
995
+ const selectedValue = isControlled ? controlledValue : uncontrolled;
996
+ const itemsRef = React11__default.useRef([]);
997
+ const [activeId, setActiveId] = React11__default.useState("");
998
+ const setSelectedValue = (val) => {
999
+ if (!isControlled) setUncontrolled(val);
1000
+ onChange?.(val);
1001
+ };
1002
+ const registerItem = (entry) => {
1003
+ const exists = itemsRef.current.find((x) => x.id === entry.id);
1004
+ if (exists) {
1005
+ exists.value = entry.value;
1006
+ exists.disabled = entry.disabled;
1007
+ exists.ref = entry.ref;
1008
+ } else {
1009
+ itemsRef.current.push(entry);
1010
+ }
1011
+ if (!activeId) {
1012
+ const selected = selectedValue ? itemsRef.current.find((x) => x.value === selectedValue) : void 0;
1013
+ const firstEnabled = itemsRef.current.find((x) => !x.disabled);
1014
+ const initial = (selected || firstEnabled)?.id;
1015
+ if (initial) setActiveId(initial);
1016
+ }
1017
+ };
1018
+ const unregisterItem = (id) => {
1019
+ itemsRef.current = itemsRef.current.filter((x) => x.id !== id);
1020
+ if (activeId === id) {
1021
+ const firstEnabled = itemsRef.current.find((x) => !x.disabled);
1022
+ if (firstEnabled) setActiveId(firstEnabled.id);
1023
+ else setActiveId("");
1024
+ }
1025
+ };
1026
+ const getIndexById = (id) => itemsRef.current.findIndex((x) => x.id === id);
1027
+ const moveActive = (delta) => {
1028
+ if (!itemsRef.current.length) return;
1029
+ const currentIndex = getIndexById(activeId);
1030
+ const total = itemsRef.current.length;
1031
+ let next = currentIndex;
1032
+ for (let i = 0; i < total; i++) {
1033
+ next = (next + delta + total) % total;
1034
+ const candidate = itemsRef.current[next];
1035
+ if (candidate && !candidate.disabled) {
1036
+ setActiveId(candidate.id);
1037
+ candidate.ref.current?.focus();
1038
+ setSelectedValue(candidate.value);
1039
+ break;
1040
+ }
1041
+ }
1042
+ };
1043
+ const isActiveId = (id) => id === activeId;
1044
+ const setActiveById = (id) => {
1045
+ const found = itemsRef.current.find((x) => x.id === id && !x.disabled);
1046
+ if (found) {
1047
+ setActiveId(found.id);
1048
+ }
1049
+ };
1050
+ React11__default.useEffect(() => {
1051
+ if (!selectedValue) return;
1052
+ const selected = itemsRef.current.find((x) => x.value === selectedValue);
1053
+ if (selected && !selected.disabled) setActiveId(selected.id);
1054
+ }, [selectedValue]);
1055
+ const ctx = {
1056
+ groupId,
1057
+ disabled,
1058
+ selectedValue: selectedValue ?? null,
1059
+ setSelectedValue,
1060
+ unregisterItem,
1061
+ registerItem,
1062
+ isActiveId,
1063
+ setActiveById
1064
+ };
1065
+ return /* @__PURE__ */ jsx(RadioContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
1066
+ Base2,
1067
+ {
1068
+ role: "radiogroup",
1069
+ "aria-disabled": disabled,
1070
+ ...rest,
1071
+ onKeyDown: (e) => {
1072
+ if (disabled) return;
1073
+ if (["ArrowUp", "ArrowLeft"].includes(e.code)) {
1074
+ e.preventDefault();
1075
+ moveActive(-1);
1076
+ } else if (["ArrowDown", "ArrowRight"].includes(e.code)) {
1077
+ e.preventDefault();
1078
+ moveActive(1);
1079
+ } else if (["Space", "Enter"].includes(e.code)) {
1080
+ e.preventDefault();
1081
+ const current = itemsRef.current.find((x) => x.id === activeId);
1082
+ if (current && !current.disabled) {
1083
+ setSelectedValue(current.value);
1084
+ current.ref.current?.focus();
1085
+ }
1086
+ }
1087
+ onKeyDownProp?.(e);
1088
+ },
1089
+ children: [
1090
+ (options ?? []).map(
1091
+ (opt) => renderOption ? /* @__PURE__ */ jsx(React11__default.Fragment, { children: renderOption(opt) }, opt.value) : /* @__PURE__ */ jsx(
1092
+ Item,
1093
+ {
1094
+ value: opt.value,
1095
+ disabled: !!(disabled || opt.disabled),
1096
+ alignI: true,
1097
+ gap: "8px",
1098
+ whiteSpace: "nowrap",
1099
+ children: opt.label
1100
+ },
1101
+ opt.value
1102
+ )
1103
+ ),
1104
+ typeof name === "string" && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: selectedValue ?? "" })
1105
+ ]
1106
+ }
1107
+ ) });
1108
+ }
1109
+ function Item(props) {
1110
+ const {
1111
+ value,
1112
+ children,
1113
+ grid: gridProp,
1114
+ cols: colsProp,
1115
+ disabled: itemDisabled,
1116
+ onClick: onClickProp,
1117
+ onFocus: onFocusProp,
1118
+ onBlur: onBlurProp,
1119
+ ...rest
1120
+ } = props;
1121
+ const ctx = React11__default.useContext(RadioContext);
1122
+ if (!ctx) {
1123
+ return /* @__PURE__ */ jsxs(Base2, { flex: true, alignI: true, cursor: "pointer", ...rest, children: [
1124
+ /* @__PURE__ */ jsx(Base2, { "data-radio-circle": true, w: 24, h: 24, br: 9999, mr: 8 }),
1125
+ children
1126
+ ] });
1127
+ }
1128
+ const {
1129
+ groupId,
1130
+ registerItem,
1131
+ unregisterItem,
1132
+ selectedValue,
1133
+ setSelectedValue,
1134
+ isActiveId,
1135
+ setActiveById,
1136
+ disabled: groupDisabled
1137
+ } = ctx;
1138
+ const disabled = !!(groupDisabled || itemDisabled);
1139
+ const id = `radio-item-${groupId}-${value}`;
1140
+ const ref = React11__default.useRef(null);
1141
+ React11__default.useEffect(() => {
1142
+ registerItem({ id, value, disabled, ref });
1143
+ return () => unregisterItem(id);
1144
+ }, [id, value, disabled]);
1145
+ const isSelected = selectedValue === value;
1146
+ const isActive = isActiveId(id);
1147
+ const [isFocused, setIsFocused] = React11__default.useState(false);
1148
+ const shouldUseGrid = gridProp || !!colsProp;
1149
+ const renderLabel = () => {
1150
+ const onlyChild = React11__default.Children.count(children) === 1 ? React11__default.Children.toArray(children)[0] : null;
1151
+ if (typeof onlyChild === "string") {
1152
+ return /* @__PURE__ */ jsx(Base2, { "data-radio-label": true, children: onlyChild });
1153
+ }
1154
+ if (React11__default.isValidElement(onlyChild)) {
1155
+ return React11__default.cloneElement(
1156
+ onlyChild,
1157
+ {
1158
+ ...onlyChild.props || {},
1159
+ ["data-radio-label"]: true
1160
+ }
1161
+ );
1162
+ }
1163
+ return /* @__PURE__ */ jsx(Base2, { "data-radio-label": true, children });
1164
+ };
1165
+ return /* @__PURE__ */ jsxs(
1166
+ Base2,
1167
+ {
1168
+ ref,
1169
+ flex: true,
1170
+ alignI: true,
1171
+ outline: "none",
1172
+ role: "radio",
1173
+ tabIndex: isActive ? 0 : -1,
1174
+ "aria-checked": isSelected,
1175
+ "aria-disabled": disabled,
1176
+ ...shouldUseGrid ? { grid: true } : { flex: true, alignI: true },
1177
+ ...colsProp && { cols: colsProp },
1178
+ gap: shouldUseGrid ? void 0 : "8px",
1179
+ cursor: disabled ? "not-allowed" : "pointer",
1180
+ userSelect: "none",
1181
+ ...isSelected && { "data-selected": true },
1182
+ ...disabled && { "data-disabled": true },
1183
+ _disabled: {
1184
+ _radioLabel: { color: { base: "neutral.400", _dark: "neutral.600" } }
1185
+ },
1186
+ onClick: (e) => {
1187
+ if (!disabled) setSelectedValue(value);
1188
+ onClickProp?.(e);
1189
+ },
1190
+ onFocus: (e) => {
1191
+ setActiveById(id);
1192
+ setIsFocused(true);
1193
+ onFocusProp?.(e);
1194
+ },
1195
+ onBlur: (e) => {
1196
+ setIsFocused(false);
1197
+ onBlurProp?.(e);
1198
+ },
1199
+ ...rest,
1200
+ children: [
1201
+ /* @__PURE__ */ jsxs(
1202
+ Base2,
1203
+ {
1204
+ "data-radio-outer": true,
1205
+ relative: true,
1206
+ ...isSelected && { "data-selected": true },
1207
+ ...disabled && { "data-disabled": true },
1208
+ w: "24px",
1209
+ h: "24px",
1210
+ grid: true,
1211
+ placeI: true,
1212
+ br: 9999,
1213
+ boxSizing: "border-box",
1214
+ borderWidth: 2,
1215
+ borderStyle: "solid",
1216
+ mr: shouldUseGrid ? void 0 : "8px",
1217
+ borderColor: { base: "neutral.400", _dark: "neutral.400" },
1218
+ _selected: { borderColor: { base: "blue.500", _dark: "blue.400" } },
1219
+ _disabled: {
1220
+ borderColor: { base: "neutral.400", _dark: "neutral.600" }
1221
+ },
1222
+ children: [
1223
+ /* @__PURE__ */ jsx(
1224
+ MotionDiv2,
1225
+ {
1226
+ "data-radio-focusring": true,
1227
+ absolute: true,
1228
+ top: 0,
1229
+ left: 0,
1230
+ w: "100%",
1231
+ h: "100%",
1232
+ br: 9999,
1233
+ pointerEvents: "none",
1234
+ boxShadow: {
1235
+ base: "0 0 0 6px rgba(0,0,0,.08)",
1236
+ _dark: "0 0 0 6px rgba(255,255,255,.08)"
1237
+ },
1238
+ initial: { scale: 0, opacity: 0 },
1239
+ animate: {
1240
+ scale: isFocused ? 1 : 0,
1241
+ opacity: isFocused ? 1 : 0,
1242
+ transition: { type: "spring", stiffness: 520, damping: 34 }
1243
+ }
1244
+ }
1245
+ ),
1246
+ /* @__PURE__ */ jsx(
1247
+ MotionDiv2,
1248
+ {
1249
+ "data-radio-inner": true,
1250
+ ...isSelected && { "data-selected": true },
1251
+ ...disabled && { "data-disabled": true },
1252
+ w: "12px",
1253
+ h: "12px",
1254
+ br: 9999,
1255
+ bg: { base: "blue.500", _dark: "blue.400" },
1256
+ initial: { scale: 0 },
1257
+ animate: {
1258
+ scale: isSelected ? 1 : 0,
1259
+ transition: { type: "spring", stiffness: 520, damping: 34 }
1260
+ },
1261
+ _disabled: { bg: { base: "neutral.400", _dark: "neutral.600" } }
1262
+ }
1263
+ )
1264
+ ]
1265
+ }
1266
+ ),
1267
+ renderLabel()
1268
+ ]
1269
+ }
1270
+ );
1271
+ }
1272
+ var LabelNameKey = "Label";
1273
+ var Base3 = base;
1274
+ var isBrowser = typeof window !== "undefined";
1275
+ var useIsomorphicLayoutEffect = isBrowser ? React11__default.useLayoutEffect : React11__default.useEffect;
1276
+ function pick(props, obj) {
1277
+ return props.reduce(
1278
+ (acc, prop) => {
1279
+ acc[prop] = obj[prop];
1280
+ return acc;
1281
+ },
1282
+ {}
1283
+ );
1284
+ }
1285
+ function assignRefs(targetRef, userRef) {
1286
+ return (node) => {
1287
+ targetRef.current = node;
1288
+ if (!userRef) return;
1289
+ if (typeof userRef === "function") userRef(node);
1290
+ else userRef.current = node;
1291
+ };
1292
+ }
1293
+ var HIDDEN_TEXTAREA_STYLE = {
1294
+ display: "block",
1295
+ position: "absolute",
1296
+ "max-height": "none",
1297
+ "min-height": "0",
1298
+ height: "0",
1299
+ top: "0",
1300
+ right: "0",
1301
+ "z-index": "-1000",
1302
+ visibility: "hidden",
1303
+ overflow: "hidden"
1304
+ };
1305
+ var forceHiddenStyles = (node) => {
1306
+ Object.keys(HIDDEN_TEXTAREA_STYLE).forEach((key) => {
1307
+ node.style.setProperty(
1308
+ key,
1309
+ HIDDEN_TEXTAREA_STYLE[key],
1310
+ "important"
1311
+ );
1312
+ });
1313
+ };
1314
+ var SIZING_STYLE = [
1315
+ "borderBottomWidth",
1316
+ "borderLeftWidth",
1317
+ "borderRightWidth",
1318
+ "borderTopWidth",
1319
+ "boxSizing",
1320
+ "fontFamily",
1321
+ "fontSize",
1322
+ "fontStyle",
1323
+ "fontWeight",
1324
+ "letterSpacing",
1325
+ "lineHeight",
1326
+ "paddingBottom",
1327
+ "paddingLeft",
1328
+ "paddingRight",
1329
+ "paddingTop",
1330
+ // Non-standard but may affect sizing
1331
+ "tabSize",
1332
+ "textIndent",
1333
+ "textRendering",
1334
+ "textTransform",
1335
+ "width",
1336
+ "wordBreak",
1337
+ "wordSpacing",
1338
+ "scrollbarGutter"
1339
+ ];
1340
+ var getSizingData = (node) => {
1341
+ const style = window.getComputedStyle(node);
1342
+ if (!style) return null;
1343
+ const sizingStyle = pick(SIZING_STYLE, style);
1344
+ const { boxSizing } = sizingStyle;
1345
+ if (!boxSizing) return null;
1346
+ const paddingSize = parseFloat(sizingStyle.paddingBottom) + parseFloat(sizingStyle.paddingTop);
1347
+ const borderSize = parseFloat(sizingStyle.borderBottomWidth) + parseFloat(sizingStyle.borderTopWidth);
1348
+ return { sizingStyle, paddingSize, borderSize };
1349
+ };
1350
+ var hiddenTextarea = null;
1351
+ var getHeight = (node, sizingData) => {
1352
+ const height = node.scrollHeight;
1353
+ if (sizingData.sizingStyle.boxSizing === "border-box") {
1354
+ return height + sizingData.borderSize;
1355
+ }
1356
+ return height - sizingData.paddingSize;
1357
+ };
1358
+ function calculateNodeHeight(sizingData, value, minRows = 1, maxRows = Infinity) {
1359
+ if (!hiddenTextarea) {
1360
+ hiddenTextarea = document.createElement("textarea");
1361
+ hiddenTextarea.setAttribute("tabindex", "-1");
1362
+ hiddenTextarea.setAttribute("aria-hidden", "true");
1363
+ forceHiddenStyles(hiddenTextarea);
1364
+ }
1365
+ if (hiddenTextarea.parentNode === null) {
1366
+ document.body.appendChild(hiddenTextarea);
1367
+ }
1368
+ const { paddingSize, borderSize, sizingStyle } = sizingData;
1369
+ const { boxSizing } = sizingStyle;
1370
+ Object.keys(sizingStyle).forEach((_key) => {
1371
+ const key = _key;
1372
+ hiddenTextarea.style[key] = sizingStyle[key];
1373
+ });
1374
+ forceHiddenStyles(hiddenTextarea);
1375
+ hiddenTextarea.value = value;
1376
+ let height = getHeight(hiddenTextarea, sizingData);
1377
+ hiddenTextarea.value = value;
1378
+ height = getHeight(hiddenTextarea, sizingData);
1379
+ hiddenTextarea.value = "x";
1380
+ const rowHeight = hiddenTextarea.scrollHeight - paddingSize;
1381
+ let minHeight = rowHeight * minRows;
1382
+ if (boxSizing === "border-box") {
1383
+ minHeight = minHeight + paddingSize + borderSize;
1384
+ }
1385
+ height = Math.max(minHeight, height);
1386
+ let maxHeight = rowHeight * maxRows;
1387
+ if (boxSizing === "border-box") {
1388
+ maxHeight = maxHeight + paddingSize + borderSize;
1389
+ }
1390
+ height = Math.min(maxHeight, height);
1391
+ return [height, rowHeight];
1392
+ }
1393
+ var Txtarea = tags.textarea;
1394
+ function Textarea(props) {
1395
+ const {
1396
+ maxRows,
1397
+ minRows,
1398
+ onChange,
1399
+ onHeightChange,
1400
+ ref: userRef,
1401
+ children,
1402
+ _motion,
1403
+ error,
1404
+ ...rest
1405
+ } = props;
1406
+ const isControlled = rest.value !== void 0;
1407
+ const libRef = React11__default.useRef(null);
1408
+ const ref = assignRefs(libRef, userRef);
1409
+ const heightRef = React11__default.useRef(0);
1410
+ const [_value, _setValue] = React11__default.useState("");
1411
+ const value = props.value ?? _value;
1412
+ const label = findChildrenByDisplayName(
1413
+ children,
1414
+ LabelNameKey
1415
+ );
1416
+ const labelWithProps = label ? React11__default.cloneElement(label, {
1417
+ required: props.required,
1418
+ value: props.value,
1419
+ error
1420
+ }) : null;
1421
+ const resizeTextarea = () => {
1422
+ const node = libRef.current;
1423
+ if (!node) return;
1424
+ const nodeSizingData = getSizingData(node);
1425
+ if (!nodeSizingData) return;
1426
+ const value2 = node.value || node.placeholder || "x";
1427
+ const [height, rowHeight] = calculateNodeHeight(
1428
+ nodeSizingData,
1429
+ value2,
1430
+ minRows,
1431
+ maxRows
1432
+ );
1433
+ if (heightRef.current !== height) {
1434
+ heightRef.current = height;
1435
+ node.style.setProperty("height", `${height}px`, "important");
1436
+ onHeightChange?.(height, { rowHeight });
1437
+ }
1438
+ };
1439
+ const handleChange = (e) => {
1440
+ if (!isControlled) resizeTextarea();
1441
+ _setValue(e.target.value);
1442
+ onChange?.(e);
1443
+ };
1444
+ useIsomorphicLayoutEffect(() => {
1445
+ resizeTextarea();
1446
+ }, [rest.value, rest.placeholder, minRows, maxRows]);
1447
+ React11__default.useEffect(() => {
1448
+ if (!isBrowser) return;
1449
+ const onResize = () => resizeTextarea();
1450
+ window.addEventListener("resize", onResize);
1451
+ return () => window.removeEventListener("resize", onResize);
1452
+ }, [minRows, maxRows, rest.placeholder, rest.value]);
1453
+ React11__default.useEffect(() => {
1454
+ const fonts = isBrowser ? document.fonts : void 0;
1455
+ if (!fonts || typeof fonts.addEventListener !== "function") return;
1456
+ const onFontsLoaded = () => resizeTextarea();
1457
+ fonts.addEventListener("loadingdone", onFontsLoaded);
1458
+ return () => fonts.removeEventListener("loadingdone", onFontsLoaded);
1459
+ }, [minRows, maxRows, rest.placeholder, rest.value]);
1460
+ React11__default.useEffect(() => {
1461
+ const node = libRef.current;
1462
+ const form = node?.form;
1463
+ if (!node || !form || isControlled) return;
1464
+ const onReset = () => {
1465
+ const currentValue = node.value;
1466
+ requestAnimationFrame(() => {
1467
+ if (node && currentValue !== node.value) resizeTextarea();
1468
+ });
1469
+ };
1470
+ form.addEventListener("reset", onReset);
1471
+ return () => form.removeEventListener("reset", onReset);
1472
+ }, [isControlled]);
1473
+ const resize = props.resize ?? "none";
1474
+ return /* @__PURE__ */ jsxs(Base3, { grid: true, rows: "/ 4", children: [
1475
+ /* @__PURE__ */ jsxs(Base3, { grid: true, relative: true, children: [
1476
+ labelWithProps,
1477
+ /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsx(
1478
+ Txtarea,
1479
+ {
1480
+ ref,
1481
+ value,
1482
+ onContextMenu: (e) => e.preventDefault(),
1483
+ resize,
1484
+ py: 0.5,
1485
+ px: 2,
1486
+ color: "text-primary",
1487
+ border: "1.5px solid",
1488
+ borderColor: error ? "input-border-color-error" : "input-border-color",
1489
+ ...error && { outlineColor: "input-outline-color-error" },
1490
+ borderRadius: 8,
1491
+ placeholder: props.placeholder ?? " ",
1492
+ _placeholder: {
1493
+ color: "input-label-color",
1494
+ opacity: label ? 0 : 1
1495
+ },
1496
+ _focusWithin: { _placeholder: { opacity: 1 } },
1497
+ css: {
1498
+ boxSizing: "border-box",
1499
+ /* Works on Firefox */
1500
+ scrollbarWidth: "thin",
1501
+ scrollbarColor: "neutral.300 neutral.300",
1502
+ /* Works on Chrome, Edge, and Safari */
1503
+ "&::-webkit-scrollbar": { height: 6, width: 6 },
1504
+ "&::-webkit-scrollbar-track": {
1505
+ background: "transparent !important"
1506
+ },
1507
+ "&::-webkit-scrollbar-thumb": {
1508
+ backgroundColor: "neutral.300",
1509
+ borderRadius: 20
1510
+ }
1511
+ },
1512
+ ...rest,
1513
+ onChange: handleChange
1514
+ }
1515
+ ) })
1516
+ ] }),
1517
+ error && /* @__PURE__ */ jsx(Base3, { pl: 3, fontSize: "sm", color: "text-alert", children: error })
1518
+ ] });
1519
+ }
1520
+ function Label(props) {
1521
+ const { value, error, required, children, ...rest } = props;
1522
+ return /* @__PURE__ */ jsxs(
1523
+ Base3,
1524
+ {
1525
+ position: "absolute",
1526
+ gridAutoFlow: "column",
1527
+ top: 1,
1528
+ transformOrigin: "top left",
1529
+ transform: "translate(0, 0) scale(1)",
1530
+ transition: "200ms cubic-bezier(0, 0, 0.2, 1) 0ms, .2s color ease-in-out, .2s background ease-in-out",
1531
+ ml: 1,
1532
+ mr: 1,
1533
+ px: 2,
1534
+ py: 0.5,
1535
+ br: 8,
1536
+ pointerEvents: "none",
1537
+ color: "input-label-color",
1538
+ zIndex: 1,
1539
+ css: {
1540
+ // lift label when sibling textarea has focus or blurred but not empty
1541
+ "&:has(+ textarea:focus, + textarea:not(:placeholder-shown))": {
1542
+ transformOrigin: "top left",
1543
+ transform: "scale(0.8)",
1544
+ top: "-14px",
1545
+ color: value ? "input-label-color-lifted" : "input-label-color",
1546
+ // only when lifted since autocomplete has lightblue background
1547
+ bg: "input-label-bg"
1548
+ },
1549
+ ...error && { color: "text-alert" }
1550
+ },
1551
+ ...rest,
1552
+ children: [
1553
+ children,
1554
+ required && "*"
1555
+ ]
1556
+ }
1557
+ );
1558
+ }
1559
+ Label.displayName = LabelNameKey;
1560
+ library.add(fas, far, fab);
1561
+ function Icon(props) {
1562
+ const { className, iconPrefix, pulse, spin } = props;
1563
+ const iconSize = props.iconSize;
1564
+ const IconComp = props.icon ?? props.startIcon;
1565
+ const prefix = !iconPrefix || iconPrefix === "solid" ? "fas" : iconPrefix === "regular" ? "far" : "fab";
1566
+ if (!IconComp) return null;
1567
+ else if (typeof IconComp === "string") {
1568
+ return /* @__PURE__ */ jsx(
1569
+ FontAwesomeIcon,
1570
+ {
1571
+ icon: { prefix, iconName: IconComp },
1572
+ className,
1573
+ spinPulse: pulse,
1574
+ size: iconSize,
1575
+ spin
1576
+ }
1577
+ );
1578
+ } else if ("iconName" in IconComp) {
1579
+ return /* @__PURE__ */ jsx(
1580
+ FontAwesomeIcon,
1581
+ {
1582
+ icon: IconComp,
1583
+ className,
1584
+ spinPulse: pulse,
1585
+ size: iconSize,
1586
+ spin
1587
+ }
1588
+ );
1589
+ } else if (typeof IconComp === "function") {
1590
+ return IconComp(props);
1591
+ } else return IconComp;
1592
+ }
1593
+ var LabelNameKey2 = "Label";
1594
+ var LeftSideNameKey = "LeftIcon";
1595
+ var RightSideNameKey = "RightSide";
1596
+ var InputBase = tags.input;
1597
+ var Base4 = base;
1598
+ function Input(props) {
1599
+ const { _motion, error, children, ...rest } = props;
1600
+ const label = findChildrenByDisplayName(
1601
+ children,
1602
+ LabelNameKey2
1603
+ );
1604
+ const leftIcon = findChildrenByDisplayName(
1605
+ children,
1606
+ LeftSideNameKey
1607
+ );
1608
+ const rightSide = findChildrenByDisplayName(
1609
+ children,
1610
+ RightSideNameKey
1611
+ );
1612
+ const labelWithProps = label ? React11__default.cloneElement(label, {
1613
+ hasLeftIcon: !!leftIcon,
1614
+ required: props.required,
1615
+ value: props.value,
1616
+ error
1617
+ }) : null;
1618
+ const rightSideWithProps = rightSide ? React11__default.cloneElement(rightSide, {
1619
+ onChange: props.onChange,
1620
+ value: props.value
1621
+ }) : null;
1622
+ return /* @__PURE__ */ jsxs(Base4, { grid: true, rows: "/ 4", children: [
1623
+ /* @__PURE__ */ jsxs(Base4, { grid: true, relative: true, children: [
1624
+ leftIcon,
1625
+ labelWithProps,
1626
+ /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsx(
1627
+ InputBase,
1628
+ {
1629
+ py: 0.5,
1630
+ pl: leftIcon ? 7 : 2,
1631
+ pr: rightSide ? 6 : 2,
1632
+ color: "text-primary",
1633
+ border: "1.5px solid",
1634
+ borderColor: error ? "input-border-color-error" : "input-border-color",
1635
+ ...error && { outlineColor: "input-outline-color-error" },
1636
+ borderRadius: 8,
1637
+ placeholder: props.placeholder ?? " ",
1638
+ _placeholder: {
1639
+ color: "input-label-color",
1640
+ opacity: label ? 0 : 1
1641
+ },
1642
+ _focusWithin: { _placeholder: { opacity: 1 } },
1643
+ ...rest
1644
+ }
1645
+ ) }),
1646
+ rightSideWithProps
1647
+ ] }),
1648
+ error && /* @__PURE__ */ jsx(Base4, { pl: 3, fontSize: "sm", color: "text-alert", children: error })
1649
+ ] });
1650
+ }
1651
+ function LeftIcon(props) {
1652
+ const remaining = omit(props, [
1653
+ "iconPrefix",
1654
+ "startIcon",
1655
+ "endIcon",
1656
+ "icon",
1657
+ "spin",
1658
+ "size",
1659
+ "pulse"
1660
+ ]);
1661
+ return /* @__PURE__ */ jsx(
1662
+ Base4,
1663
+ {
1664
+ position: "absolute",
1665
+ transform: "translateY(-50%)",
1666
+ top: "50%",
1667
+ left: "11px",
1668
+ ...remaining,
1669
+ children: /* @__PURE__ */ jsx(Icon, { ...props })
1670
+ }
1671
+ );
1672
+ }
1673
+ LeftIcon.displayName = LeftSideNameKey;
1674
+ function RightSide(props) {
1675
+ const { clearable, ...rest } = props;
1676
+ if (clearable && !props.value) return null;
1677
+ return /* @__PURE__ */ jsx(
1678
+ Base4,
1679
+ {
1680
+ position: "absolute",
1681
+ top: "50%",
1682
+ transform: "translateY(-50%)",
1683
+ right: "11px",
1684
+ ...rest,
1685
+ ...clearable && {
1686
+ cursor: "pointer",
1687
+ onClick: (e) => {
1688
+ const clearedValueEvent = {
1689
+ ...e,
1690
+ target: { ...e.target, value: "" }
1691
+ };
1692
+ props.onChange?.(clearedValueEvent);
1693
+ }
1694
+ }
1695
+ }
1696
+ );
1697
+ }
1698
+ RightSide.displayName = RightSideNameKey;
1699
+ function Label2(props) {
1700
+ const { value, error, required, children, hasLeftIcon, ...rest } = props;
1701
+ const ml = hasLeftIcon ? 6 : 1;
1702
+ return /* @__PURE__ */ jsxs(
1703
+ Base4,
1704
+ {
1705
+ gridAutoFlow: "column",
1706
+ position: "absolute",
1707
+ pointerEvents: "none",
1708
+ top: "50%",
1709
+ transformOrigin: "top left",
1710
+ transform: "translate(0, -50%) scale(1)",
1711
+ transition: "200ms cubic-bezier(0, 0, 0.2, 1) 0ms, .2s color ease-in-out, .2s background ease-in-out",
1712
+ ml,
1713
+ mr: 1,
1714
+ px: 2,
1715
+ py: 0.5,
1716
+ br: 8,
1717
+ color: "input-label-color",
1718
+ lineHeight: 1.1,
1719
+ css: {
1720
+ // lift label when sibling input has focus or blurred but empty
1721
+ "&:has(+ input:focus, + input:not(:placeholder-shown))": {
1722
+ transformOrigin: "top left",
1723
+ transform: "scale(0.8)",
1724
+ top: "-10px",
1725
+ ml,
1726
+ color: value ? "input-label-color-lifted" : "input-label-color",
1727
+ // only when lifted since autocomplete has lightblue background
1728
+ bg: "input-label-bg"
1729
+ },
1730
+ ...error && { color: "text-alert" }
1731
+ },
1732
+ ...rest,
1733
+ children: [
1734
+ children,
1735
+ required && "*"
1736
+ ]
1737
+ }
1738
+ );
1739
+ }
1740
+ Label2.displayName = LabelNameKey2;
1741
+ function useResizeObserver(opts = {}) {
1742
+ const onResize = opts.onResize;
1743
+ const onResizeRef = React11__default.useRef(void 0);
1744
+ onResizeRef.current = onResize;
1745
+ const round = opts.round || Math.round;
1746
+ const resizeObserverRef = React11__default.useRef(null);
1747
+ const [size, setSize] = React11__default.useState({
1748
+ width: void 0,
1749
+ height: void 0
1750
+ });
1751
+ const didUnmount = React11__default.useRef(false);
1752
+ React11__default.useEffect(() => {
1753
+ didUnmount.current = false;
1754
+ return () => {
1755
+ didUnmount.current = true;
1756
+ };
1757
+ }, []);
1758
+ const previous = React11__default.useRef({
1759
+ width: void 0,
1760
+ height: void 0
1761
+ });
1762
+ const refCallback = useResolvedElement(
1763
+ React11__default.useCallback(
1764
+ (element) => {
1765
+ if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
1766
+ resizeObserverRef.current = {
1767
+ box: opts.box,
1768
+ round,
1769
+ instance: new ResizeObserver((entries) => {
1770
+ const entry = entries[0];
1771
+ const boxProp = opts.box === "border-box" ? "borderBoxSize" : opts.box === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize";
1772
+ const reportedWidth = extractSize(entry, boxProp, "inlineSize");
1773
+ const reportedHeight = extractSize(entry, boxProp, "blockSize");
1774
+ const newWidth = reportedWidth ? round(reportedWidth) : void 0;
1775
+ const newHeight = reportedHeight ? round(reportedHeight) : void 0;
1776
+ if (previous.current.width !== newWidth || previous.current.height !== newHeight) {
1777
+ const newSize = { width: newWidth, height: newHeight };
1778
+ previous.current.width = newWidth;
1779
+ previous.current.height = newHeight;
1780
+ if (onResizeRef.current) {
1781
+ onResizeRef.current(newSize);
1782
+ } else {
1783
+ if (!didUnmount.current) {
1784
+ setSize(newSize);
1785
+ }
1786
+ }
1787
+ }
1788
+ })
1789
+ };
1790
+ }
1791
+ resizeObserverRef.current.instance.observe(element, { box: opts.box });
1792
+ return () => {
1793
+ if (resizeObserverRef.current) {
1794
+ resizeObserverRef.current.instance.unobserve(element);
1795
+ }
1796
+ };
1797
+ },
1798
+ [opts.box, round]
1799
+ ),
1800
+ opts.ref
1801
+ );
1802
+ return React11__default.useMemo(
1803
+ () => ({
1804
+ ref: refCallback,
1805
+ width: size.width,
1806
+ height: size.height
1807
+ }),
1808
+ // Note: when `onResize` is provided, width/height will remain whatever the
1809
+ // state was initialized to; consumers should rely on the callback in that mode.
1810
+ [refCallback, size.width, size.height]
1811
+ );
1812
+ }
1813
+ function useResolvedElement(subscriber, refOrElement) {
1814
+ const lastReportRef = React11__default.useRef(null);
1815
+ const refOrElementRef = React11__default.useRef(null);
1816
+ refOrElementRef.current = refOrElement;
1817
+ const cbElementRef = React11__default.useRef(null);
1818
+ React11__default.useEffect(() => {
1819
+ evaluateSubscription();
1820
+ });
1821
+ const evaluateSubscription = React11__default.useCallback(() => {
1822
+ const cbElement = cbElementRef.current;
1823
+ const refOrElement2 = refOrElementRef.current;
1824
+ const element = cbElement ? cbElement : refOrElement2 ? refOrElement2 instanceof Element ? refOrElement2 : refOrElement2.current : null;
1825
+ if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.subscriber === subscriber) {
1826
+ return;
1827
+ }
1828
+ if (lastReportRef.current && lastReportRef.current.cleanup) {
1829
+ lastReportRef.current.cleanup();
1830
+ }
1831
+ lastReportRef.current = {
1832
+ element,
1833
+ subscriber,
1834
+ // Only calling the subscriber, if there's an actual element to report.
1835
+ // Setting cleanup to undefined unless a subscriber returns one, as an existing cleanup function would've been just called.
1836
+ cleanup: element ? subscriber(element) : void 0
1837
+ };
1838
+ }, [subscriber]);
1839
+ React11__default.useEffect(() => {
1840
+ return () => {
1841
+ if (lastReportRef.current && lastReportRef.current.cleanup) {
1842
+ lastReportRef.current.cleanup();
1843
+ lastReportRef.current = null;
1844
+ }
1845
+ };
1846
+ }, []);
1847
+ return React11__default.useCallback(
1848
+ (element) => {
1849
+ cbElementRef.current = element;
1850
+ evaluateSubscription();
1851
+ },
1852
+ [evaluateSubscription]
1853
+ );
1854
+ }
1855
+ function extractSize(entry, boxProp, sizeType) {
1856
+ if (!entry[boxProp]) {
1857
+ if (boxProp === "contentBoxSize") {
1858
+ return entry.contentRect[sizeType === "inlineSize" ? "width" : "height"];
1859
+ }
1860
+ return void 0;
1861
+ }
1862
+ return entry[boxProp][0] ? entry[boxProp][0][sizeType] : (
1863
+ // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
1864
+ // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
1865
+ // @ts-ignore
1866
+ entry[boxProp][sizeType]
1867
+ );
1868
+ }
1869
+ var use_resize_observer_default = useResizeObserver;
1870
+ var MotionDiv3 = motionTags.div;
1871
+ var MotionBtn = motionTags.button;
1872
+ var displayName = "AccordionItem";
1873
+ var AccordionContext = React11__default.createContext({});
1874
+ function AccordionProvider(props) {
1875
+ const [state, setState] = useImmer({
1876
+ allowMultiple: false,
1877
+ allowToggle: true,
1878
+ open: []
1879
+ });
1880
+ return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: { setState, state }, children: props.children });
1881
+ }
1882
+ function useAccordion() {
1883
+ const context = React11__default.useContext(AccordionContext);
1884
+ if (context === void 0) {
1885
+ throw new Error("useAccordion must be used within a AccordionProvider");
1886
+ }
1887
+ return context;
1888
+ }
1889
+ function AccordionComponent(props) {
1890
+ const accordion = useAccordion();
1891
+ const accordionState = accordion.state;
1892
+ React11__default.useEffect(() => {
1893
+ accordion.setState((draft) => {
1894
+ draft.allowMultiple = !!props.allowMultiple;
1895
+ draft.allowToggle = !!props.allowToggle;
1896
+ });
1897
+ }, [props.allowMultiple, props.allowToggle]);
1898
+ React11__default.Children.forEach(props.children, (x) => {
1899
+ if (typeof x.type === "function" && "displayName" in x.type && x.type.displayName !== displayName) {
1900
+ throw new Error("Accordion can only have AccordionItems as children");
1901
+ }
1902
+ });
1903
+ const children = React11__default.Children.map(props.children, (child, i) => {
1904
+ if (!React11__default.isValidElement(child)) return child;
1905
+ return React11__default.cloneElement(child, { idx: i });
1906
+ });
1907
+ React11__default.useEffect(() => {
1908
+ if (accordionState.open.length === children.length) return;
1909
+ const defaultOpenIdx = props.defaultOpenIdx;
1910
+ const items = new Array(children.length).fill(null).map((x, i) => {
1911
+ if (defaultOpenIdx) return defaultOpenIdx.includes(i);
1912
+ else return false;
1913
+ });
1914
+ accordion.setState((draft) => {
1915
+ draft.open = items;
1916
+ });
1917
+ }, [
1918
+ accordionState.open.length,
1919
+ children.length,
1920
+ props.defaultOpenIdx?.length
1921
+ ]);
1922
+ return /* @__PURE__ */ jsx(MotionDiv3, { grid: true, children });
1923
+ }
1924
+ function Accordion(props) {
1925
+ return /* @__PURE__ */ jsx(AccordionProvider, { children: /* @__PURE__ */ jsx(AccordionComponent, { ...props }) });
1926
+ }
1927
+ function Item2(props) {
1928
+ const { ref, height } = use_resize_observer_default();
1929
+ const { idx, children, rightIndicator, rightStatusIcon, title, ...rest } = props;
1930
+ const accordion = useAccordion();
1931
+ const accordionState = accordion.state;
1932
+ const isOpen = accordionState.open.at(idx);
1933
+ const isLastItem = idx === accordionState.open.length - 1;
1934
+ const toggle = () => {
1935
+ const updatedItems = accordionState.open.map((x, i) => {
1936
+ if (accordionState.allowMultiple) return i === idx ? !x : x;
1937
+ else return i === idx ? !x : false;
1938
+ });
1939
+ accordion.setState((draft) => {
1940
+ draft.open = updatedItems;
1941
+ });
1942
+ };
1943
+ return /* @__PURE__ */ jsxs(
1944
+ MotionDiv3,
1945
+ {
1946
+ grid: true,
1947
+ alignC: "start",
1948
+ overflow: "auto",
1949
+ style: {
1950
+ borderBottom: isLastItem ? `1px solid ${props.borderBottomColor ?? props.borderColor ?? "var(--colors-neutral-300)!"}` : void 0,
1951
+ borderTop: `1px solid ${props.borderTopColor ?? props.borderColor ?? "var(--colors-neutral-300)!"}`
1952
+ },
1953
+ children: [
1954
+ /* @__PURE__ */ jsxs(
1955
+ MotionBtn,
1956
+ {
1957
+ flex: true,
1958
+ py: 2,
1959
+ rows: "between",
1960
+ borderRadius: 0,
1961
+ boxSizing: "border-box",
1962
+ cursor: "pointer",
1963
+ transition: ".2s all ease-in-out",
1964
+ _hover: { bg: { base: "neutral.100", _dark: "neutral.700" } },
1965
+ _active: { scale: 0.98 },
1966
+ overflow: "auto",
1967
+ zIndex: 1,
1968
+ ...rest,
1969
+ onClick: (e) => {
1970
+ toggle();
1971
+ props.onClick?.(e);
1972
+ },
1973
+ children: [
1974
+ /* @__PURE__ */ jsx(Fragment, { children: title }),
1975
+ rightIndicator ? rightIndicator?.(isOpen) : /* @__PURE__ */ jsx(MotionDiv3, { grid: true, pr: ".5rem", color: "neutral.500", children: /* @__PURE__ */ jsx(
1976
+ Icon,
1977
+ {
1978
+ fontSize: ".8rem",
1979
+ icon: isOpen ? "chevron-up" : "chevron-down"
1980
+ }
1981
+ ) }),
1982
+ rightStatusIcon ? rightStatusIcon : null
1983
+ ]
1984
+ }
1985
+ ),
1986
+ /* @__PURE__ */ jsx(MotionDiv3, { grid: true, overflowY: "auto", maxH: "100%", children: /* @__PURE__ */ jsx(
1987
+ MotionDiv3,
1988
+ {
1989
+ grid: true,
1990
+ animate: { height: isOpen ? height ?? 0 : 0 },
1991
+ overflowY: "hidden",
1992
+ children: /* @__PURE__ */ jsx(MotionDiv3, { grid: true, ref, children: isOpen && /* @__PURE__ */ jsx(
1993
+ MotionDiv3,
1994
+ {
1995
+ grid: true,
1996
+ initial: { opacity: 0 },
1997
+ animate: { opacity: 1 },
1998
+ exit: { opacity: 0 },
1999
+ children
2000
+ }
2001
+ ) })
2002
+ }
2003
+ ) })
2004
+ ]
2005
+ }
2006
+ );
2007
+ }
2008
+ Item2.displayName = displayName;
2009
+ var accordion_default = Accordion;
2010
+ var MotionDiv4 = motionTags.div;
2011
+ var MotionBtn2 = motionTags.button;
2012
+ var breakpoint = ["(min-width: 600px)"];
2013
+ function DrawerComponent(props) {
2014
+ const ref = React11__default.useRef(null);
2015
+ const dragHandleRef = React11__default.useRef(null);
2016
+ const [isDesktop] = useMatchMedia(breakpoint);
2017
+ const closeFnRef = React11__default.useRef(null);
2018
+ const dragControls = useDragControls();
2019
+ const { open, setOpen } = useDrawer();
2020
+ const { onClose, ...rest } = props;
2021
+ const y = useMotionValue(0);
2022
+ const openDrawer = () => {
2023
+ y.stop();
2024
+ y.set(0);
2025
+ setOpen(true);
2026
+ };
2027
+ const closeDrawer = () => setOpen(false);
2028
+ closeFnRef.current = () => {
2029
+ closeDrawer();
2030
+ onClose?.();
2031
+ };
2032
+ const onDragStart = (e, info) => {
2033
+ console.log({ e });
2034
+ if (isDesktop) return;
2035
+ const noDragEl = document.querySelector("[data-no-drag]");
2036
+ if (!noDragEl || !noDragEl.contains(e.target)) {
2037
+ dragControls.start(e);
2038
+ } else {
2039
+ dragControls.componentControls.forEach((entry) => {
2040
+ entry.stop(e, info);
2041
+ });
2042
+ }
2043
+ };
2044
+ React11__default.useEffect(() => {
2045
+ if (props.open) openDrawer();
2046
+ else closeFnRef.current();
2047
+ }, [props.open]);
2048
+ React11__default.useEffect(() => {
2049
+ const container = ref.current;
2050
+ if (!open || !container) return;
2051
+ container.setAttribute("tabindex", "0");
2052
+ const trapFocus = (e) => {
2053
+ if (container.contains(e.relatedTarget)) return;
2054
+ container.focus();
2055
+ };
2056
+ const closeOnEsc = (e) => {
2057
+ if (e.key !== "Escape" || props.closeOnEsc === false) return;
2058
+ console.log("[close] esc key");
2059
+ closeFnRef.current();
2060
+ };
2061
+ container.addEventListener("focusout", trapFocus);
2062
+ container.addEventListener("keydown", closeOnEsc);
2063
+ document.body.style.overflow = "hidden";
2064
+ return () => {
2065
+ container.removeEventListener("focusout", trapFocus);
2066
+ container.removeEventListener("keydown", closeOnEsc);
2067
+ document.body.style.overflow = "auto";
2068
+ };
2069
+ }, [open]);
2070
+ React11__default.useEffect(() => {
2071
+ const unsubscribeY = y.on("change", (latestY) => {
2072
+ if (latestY > 150) {
2073
+ console.log("[close] latestY > 150");
2074
+ closeFnRef.current();
2075
+ }
2076
+ });
2077
+ return () => {
2078
+ unsubscribeY();
2079
+ };
2080
+ }, [y]);
2081
+ const onBackdropClick = () => {
2082
+ const outsideClickClose = props.outsideClickClose ?? true;
2083
+ if (!outsideClickClose) return;
2084
+ console.log("[close] clicked backdrop");
2085
+ closeFnRef.current();
2086
+ };
2087
+ return createPortal(
2088
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "wait", children: open && /* @__PURE__ */ jsx(
2089
+ Backdrop,
2090
+ {
2091
+ onClick: () => onBackdropClick(),
2092
+ children: /* @__PURE__ */ jsx(
2093
+ MotionDiv4,
2094
+ {
2095
+ grid: true,
2096
+ onClick: (e) => e.stopPropagation(),
2097
+ position: "fixed",
2098
+ initial: "initial",
2099
+ animate: "animate",
2100
+ exit: "exit",
2101
+ ...isDesktop ? {
2102
+ drag: false,
2103
+ style: void 0,
2104
+ dragControls: null,
2105
+ dragConstraints: void 0,
2106
+ // style: null,
2107
+ // dragConstraints: null,
2108
+ height: props.height ?? "max-content!",
2109
+ // "min(50%, 300px)",
2110
+ width: props.width ?? "clamp(50%, 700px, 90%)",
2111
+ pt: 6,
2112
+ // px: 4,
2113
+ margin: "auto",
2114
+ borderRadius: 12,
2115
+ zIndex: 1,
2116
+ variants: {
2117
+ initial: { opacity: 0, scale: 0.5 },
2118
+ animate: {
2119
+ opacity: 1,
2120
+ scale: 1,
2121
+ transition: {
2122
+ type: "spring",
2123
+ damping: 20,
2124
+ stiffness: 300
2125
+ }
2126
+ },
2127
+ exit: {
2128
+ opacity: 0,
2129
+ scale: 0.3,
2130
+ transition: { type: "spring", duration: 0.45 }
2131
+ }
2132
+ }
2133
+ } : {
2134
+ w: "100vw",
2135
+ left: 0,
2136
+ right: 0,
2137
+ bottom: 0,
2138
+ borderTopLeftRadius: 12,
2139
+ borderTopRightRadius: 12,
2140
+ variants: {
2141
+ initial: { height: 0, opacity: 0 },
2142
+ animate: {
2143
+ height: "auto",
2144
+ opacity: 1,
2145
+ // transition: { type: "spring", damping: 26, stiffness: 300 },
2146
+ transition: { type: "spring", duration: 0.3 }
2147
+ },
2148
+ exit: { height: 0, opacity: 0 }
2149
+ },
2150
+ drag: "y",
2151
+ style: { y },
2152
+ dragControls,
2153
+ // @ts-ignore
2154
+ onPointerDown: (...args) => onDragStart(args[0], args[1]),
2155
+ // onPointerDown: (x, y) => onDragStart(x, y),
2156
+ // drag={hasBackdrop ? "y" : false}
2157
+ dragElastic: 0,
2158
+ // prevent drawer from being dragged higher than what its opened to
2159
+ dragConstraints: { top: 0 },
2160
+ onDragEnd: (_, drag) => {
2161
+ if (props.drag === false) return;
2162
+ const pageHeight = document.documentElement.scrollHeight;
2163
+ const yCoord = drag.point.y;
2164
+ const velocity = drag.velocity.y;
2165
+ const releaseThreshold = 0.8;
2166
+ const releasePct = yCoord / pageHeight;
2167
+ if (velocity > 25 && releasePct >= releaseThreshold || velocity > 750) {
2168
+ props.onClose?.();
2169
+ }
2170
+ }
2171
+ },
2172
+ boxSizing: "border-box",
2173
+ boxShadow: "hsl(0deg 0% 0% / 60%) 0px -4px 20px",
2174
+ bg: { base: "neutral.100", _dark: "neutral.900" },
2175
+ color: "text-primary",
2176
+ ref,
2177
+ ...rest,
2178
+ children: /* @__PURE__ */ jsxs(
2179
+ MotionDiv4,
2180
+ {
2181
+ grid: true,
2182
+ ...isDesktop ? { position: "relative" } : { rows: "max-content 1fr" },
2183
+ children: [
2184
+ !isDesktop && props.hideHandle !== false && /* @__PURE__ */ jsx(
2185
+ MotionDiv4,
2186
+ {
2187
+ grid: true,
2188
+ justifySelf: "center",
2189
+ h: 6,
2190
+ w: 34,
2191
+ mt: "16px",
2192
+ mb: 4,
2193
+ br: 20,
2194
+ bg: { base: "neutral.400", _dark: "neutral.600" },
2195
+ cursor: props.drag ? "row-resize" : "default",
2196
+ ref: dragHandleRef
2197
+ }
2198
+ ),
2199
+ props.children
2200
+ ]
2201
+ }
2202
+ )
2203
+ },
2204
+ "drawer"
2205
+ )
2206
+ }
2207
+ ) }),
2208
+ document.getElementById("portal")
2209
+ );
2210
+ }
2211
+ var DrawerContext = React11__default.createContext({
2212
+ open: false,
2213
+ setOpen: (_value) => {
2214
+ return;
2215
+ }
2216
+ });
2217
+ function DrawerProvider(props) {
2218
+ const [open, setOpen] = React11__default.useState(false);
2219
+ const value = { open, setOpen };
2220
+ return /* @__PURE__ */ jsx(DrawerContext.Provider, { value, children: props.children });
2221
+ }
2222
+ function useDrawer() {
2223
+ const context = React11__default.useContext(DrawerContext);
2224
+ if (context === void 0) {
2225
+ throw new Error("useDrawer must be used within a DrawerProvider");
2226
+ }
2227
+ return context;
2228
+ }
2229
+ function Drawer(props) {
2230
+ return /* @__PURE__ */ jsx(DrawerProvider, { children: /* @__PURE__ */ jsx(DrawerComponent, { ...props }) });
2231
+ }
2232
+ function BtnGroup(props) {
2233
+ const [isDesktop] = useMatchMedia(breakpoint);
2234
+ const { children, ...rest } = props;
2235
+ if (isDesktop) {
2236
+ return /* @__PURE__ */ jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children: React11__default.Children.toArray(children).toReversed() });
2237
+ } else {
2238
+ return /* @__PURE__ */ jsx(MotionDiv4, { grid: true, rowG: 14, ...props });
2239
+ }
2240
+ }
2241
+ function CloseBtn(props) {
2242
+ const [isDesktop] = useMatchMedia(breakpoint);
2243
+ const { children, ...rest } = props;
2244
+ if (isDesktop) {
2245
+ return /* @__PURE__ */ jsx(
2246
+ MotionBtn2,
2247
+ {
2248
+ transition: ".14s all ease-out",
2249
+ _after: {
2250
+ content: '""',
2251
+ position: "absolute",
2252
+ inset: 0,
2253
+ scale: 0,
2254
+ rounded: true,
2255
+ transition: ".14s all ease-out",
2256
+ zIndex: -1
2257
+ },
2258
+ _hover: {
2259
+ _after: {
2260
+ scale: 1,
2261
+ bg: { base: "neutral.200", _dark: "neutral.800" }
2262
+ }
2263
+ },
2264
+ _active: {
2265
+ scale: 0.9,
2266
+ _after: { scale: 0.94 },
2267
+ bg: { base: "neutral.200", _dark: "neutral.800" }
2268
+ },
2269
+ position: "absolute",
2270
+ h: 32,
2271
+ w: 32,
2272
+ top: -2,
2273
+ right: 3,
2274
+ borderRadius: 32,
2275
+ cursor: "pointer",
2276
+ ...rest,
2277
+ children: /* @__PURE__ */ jsx(
2278
+ Icon,
2279
+ {
2280
+ icon: "times",
2281
+ placeC: true,
2282
+ h: 16,
2283
+ w: 16,
2284
+ fontSize: 16,
2285
+ color: { base: "neutral.400", _dark: "neutral.300" }
2286
+ }
2287
+ )
2288
+ }
2289
+ );
2290
+ } else if (children) {
2291
+ return /* @__PURE__ */ jsx(MotionDiv4, { grid: true, children: /* @__PURE__ */ jsx(MotionBtn2, { ...props, children: "Close" }) });
2292
+ } else {
2293
+ return;
2294
+ }
2295
+ }
2296
+ function Backdrop(props) {
2297
+ const [allowOutsideClick, setAllowOutsideClick] = React11__default.useState(true);
2298
+ const [isDesktop] = useMatchMedia(breakpoint);
2299
+ return /* @__PURE__ */ jsx(
2300
+ MotionDiv4,
2301
+ {
2302
+ grid: true,
2303
+ "data-backdrop": true,
2304
+ background: "hsl(0 0% 0% / 0.3)",
2305
+ zIndex: 1,
2306
+ initial: { opacity: 0 },
2307
+ animate: { opacity: 1, transition: { duration: 0.2 } },
2308
+ exit: { opacity: 0, transition: { duration: 0.3 } },
2309
+ onAnimationStart: () => {
2310
+ setAllowOutsideClick(false);
2311
+ },
2312
+ onAnimationComplete: () => {
2313
+ setAllowOutsideClick(true);
2314
+ },
2315
+ position: "fixed",
2316
+ top: 0,
2317
+ left: 0,
2318
+ height: "100%",
2319
+ width: "100%",
2320
+ placeI: isDesktop,
2321
+ onClick: () => allowOutsideClick ? props.onClick() : void 0,
2322
+ children: props.children
2323
+ }
2324
+ );
2325
+ }
2326
+ function useMatchMedia(queries, defaultValues = []) {
2327
+ const initialValues = defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2328
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2329
+ const getValue = () => {
2330
+ const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
2331
+ return matchedQueries;
2332
+ };
2333
+ const [value, setValue] = React11__default.useState(getValue);
2334
+ React11__default.useLayoutEffect(() => {
2335
+ const handler = () => setValue(getValue);
2336
+ mediaQueryLists.forEach((mql) => mql.addListener(handler));
2337
+ return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
2338
+ }, []);
2339
+ if (typeof window === "undefined") return initialValues;
2340
+ return value;
2341
+ }
2342
+ var MotionDiv5 = motionTags.div;
2343
+ var TrackBgNameKey = "TrackBg";
2344
+ var TrackFillNameKey = "TrackFill";
2345
+ function Progress(props) {
2346
+ const { children, steps, value, max: maxProp, ...rest } = props;
2347
+ const [progress, setProgress] = React11__default.useState(0);
2348
+ const max = maxProp ?? 100;
2349
+ React11__default.useEffect(() => {
2350
+ setProgress(Math.min((value ?? 0) / max, 1) * 100);
2351
+ }, [value, max]);
2352
+ const width = `${progress}%`;
2353
+ const barBackground = "var(--colors-blue-500)";
2354
+ const trackBackground = "var(--colors-neutral-300)";
2355
+ if (typeof steps === "number") {
2356
+ const stepSize = max / steps;
2357
+ return /* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsx(MotionDiv5, { autoCols: "1fr", colG: 8, children: /* @__PURE__ */ jsx(AnimatePresence, { children: Array.from({ length: steps }, (_, i) => {
2358
+ const normalizedValue = stepSize * i;
2359
+ const isComplete = normalizedValue < (value ?? 0);
2360
+ const defaultBgColor = trackBackground;
2361
+ return /* @__PURE__ */ jsx(
2362
+ MotionDiv5,
2363
+ {
2364
+ layout: true,
2365
+ h: 8,
2366
+ rounded: true,
2367
+ initial: { scale: 0, width: 0, opacity: 0 },
2368
+ animate: {
2369
+ scale: 1,
2370
+ opacity: 1,
2371
+ width: "100%",
2372
+ background: isComplete ? barBackground : defaultBgColor
2373
+ },
2374
+ exit: { scale: 0, width: 0, opacity: 0 }
2375
+ },
2376
+ i
2377
+ );
2378
+ }) }) }) });
2379
+ }
2380
+ const trackBgChild = findChildrenByDisplayName(
2381
+ children,
2382
+ TrackBgNameKey
2383
+ );
2384
+ const trackFillChild = findChildrenByDisplayName(
2385
+ children,
2386
+ TrackFillNameKey
2387
+ );
2388
+ const barHeight = rest.h ?? 8;
2389
+ const bgEl = trackBgChild ? React11__default.cloneElement(trackBgChild, {
2390
+ gridArea: "1 / 1",
2391
+ h: barHeight,
2392
+ w: trackBgChild.props.w ?? true
2393
+ }) : /* @__PURE__ */ jsx(
2394
+ MotionDiv5,
2395
+ {
2396
+ "data-progress-bg": true,
2397
+ gridArea: "1 / 1",
2398
+ rounded: true,
2399
+ h: barHeight,
2400
+ w: true,
2401
+ bg: { base: "neutral.200", _dark: "neutral.700" }
2402
+ }
2403
+ );
2404
+ const fillEl = trackFillChild ? React11__default.cloneElement(trackFillChild, {
2405
+ gridArea: "1 / 1",
2406
+ h: barHeight,
2407
+ roundedLeft: 9999,
2408
+ roundedRight: width === "100%" ? 9999 : void 0,
2409
+ // Pass width via both animation and style for custom implementations
2410
+ animate: {
2411
+ ...trackFillChild.props.animate || {},
2412
+ width
2413
+ },
2414
+ style: {
2415
+ ...trackFillChild.props.style || {},
2416
+ width
2417
+ },
2418
+ progressWidth: width,
2419
+ progressPercent: progress,
2420
+ progressValue: value ?? 0,
2421
+ progressMax: max
2422
+ }) : /* @__PURE__ */ jsx(
2423
+ MotionDiv5,
2424
+ {
2425
+ "data-progress-bar": true,
2426
+ gridArea: "1 / 1",
2427
+ h: barHeight,
2428
+ roundedLeft: 9999,
2429
+ roundedRight: width === "100%" ? 9999 : void 0,
2430
+ animate: { width, background: barBackground },
2431
+ style: { width, background: barBackground }
2432
+ }
2433
+ );
2434
+ return /* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsxs(MotionDiv5, { layout: true, grid: true, cols: "1", rows: "1", w: true, ...rest, children: [
2435
+ bgEl,
2436
+ fillEl
2437
+ ] }) });
2438
+ }
2439
+ function TrackBg(props) {
2440
+ const { h, ...rest } = props;
2441
+ return /* @__PURE__ */ jsx(
2442
+ MotionDiv5,
2443
+ {
2444
+ "data-track-bg": true,
2445
+ gridArea: "1 / 1",
2446
+ rounded: true,
2447
+ h: h ?? 8,
2448
+ w: true,
2449
+ bg: { base: "neutral.200", _dark: "neutral.700" },
2450
+ ...rest
2451
+ }
2452
+ );
2453
+ }
2454
+ TrackBg.displayName = TrackBgNameKey;
2455
+ function TrackFill(props) {
2456
+ const { progressWidth, animate, style, h, ...rest } = props;
2457
+ const mergedAnimate = progressWidth ? animate && typeof animate === "object" && !Array.isArray(animate) ? { ...animate, width: progressWidth } : { width: progressWidth } : animate;
2458
+ const mergedStyle = progressWidth ? Object.assign({}, style, { width: progressWidth }) : style;
2459
+ return /* @__PURE__ */ jsx(
2460
+ MotionDiv5,
2461
+ {
2462
+ "data-track-fill": true,
2463
+ gridArea: "1 / 1",
2464
+ rounded: true,
2465
+ h: h ?? 8,
2466
+ bg: { base: "neutral.200", _dark: "neutral.700" },
2467
+ ...rest,
2468
+ animate: mergedAnimate,
2469
+ style: mergedStyle
2470
+ }
2471
+ );
2472
+ }
2473
+ TrackFill.displayName = TrackFillNameKey;
2474
+ var Base5 = base;
2475
+ var TooltipContainer = React11__default.forwardRef(function TooltipContainer2(props, ref) {
2476
+ const { children, className, style, ...rest } = props;
2477
+ return /* @__PURE__ */ jsx(
2478
+ Base5,
2479
+ {
2480
+ className,
2481
+ style,
2482
+ ref,
2483
+ role: "tooltip",
2484
+ ...rest,
2485
+ children
2486
+ }
2487
+ );
2488
+ });
2489
+ function Tooltip(props) {
2490
+ const {
2491
+ children,
2492
+ content,
2493
+ placement = "auto",
2494
+ interactive = true,
2495
+ disabled = false,
2496
+ showArrow = true,
2497
+ follow = false,
2498
+ offsetVal = 8,
2499
+ delay = 80,
2500
+ className
2501
+ } = props;
2502
+ const referenceRef = React11__default.useRef(null);
2503
+ const arrowRef = React11__default.useRef(null);
2504
+ const [open, setOpen] = React11__default.useState(false);
2505
+ const { x, y, refs, strategy, middlewareData, context } = useFloating({
2506
+ open,
2507
+ onOpenChange: setOpen,
2508
+ placement: placement === "auto" ? "top" : placement,
2509
+ middleware: [
2510
+ offset(offsetVal),
2511
+ flip(),
2512
+ shift({ padding: 6 }),
2513
+ arrow({ element: arrowRef })
2514
+ ],
2515
+ whileElementsMounted: autoUpdate,
2516
+ strategy: "fixed"
2517
+ });
2518
+ const hover = useHover(context, {
2519
+ delay: { open: delay, close: 120 },
2520
+ handleClose: safePolygon(),
2521
+ move: true
2522
+ });
2523
+ const focus = useFocus(context);
2524
+ const dismiss = useDismiss(context);
2525
+ const role = useRole(context, { role: "tooltip" });
2526
+ const { getReferenceProps, getFloatingProps } = useInteractions([
2527
+ hover,
2528
+ focus,
2529
+ dismiss,
2530
+ role
2531
+ ]);
2532
+ const referenceProps = getReferenceProps({});
2533
+ React11__default.useEffect(() => {
2534
+ if (!follow || !referenceRef.current) return;
2535
+ const el = referenceRef.current;
2536
+ const onMove = (e) => {
2537
+ const virtualElement = {
2538
+ getBoundingClientRect: () => new DOMRect(e.clientX, e.clientY, 0, 0),
2539
+ contextElement: document.body
2540
+ };
2541
+ refs.setReference(virtualElement);
2542
+ };
2543
+ el.addEventListener("pointermove", onMove);
2544
+ return () => {
2545
+ el.removeEventListener("pointermove", onMove);
2546
+ };
2547
+ }, [follow, refs]);
2548
+ const arrowX = middlewareData?.arrow?.x ?? 0;
2549
+ const arrowY = middlewareData?.arrow?.y ?? 0;
2550
+ const side = context.placement || "top";
2551
+ const ARROW_SIZE = 10;
2552
+ const anchorOffset = Math.max(ARROW_SIZE / 2 - 1, 3);
2553
+ const arrowAnchorStyle = side.startsWith("top") ? { bottom: -anchorOffset } : side.startsWith("bottom") ? { top: -anchorOffset } : side.startsWith("left") ? { right: -anchorOffset } : { left: -anchorOffset };
2554
+ const arrowStyle = side.startsWith("top") || side.startsWith("bottom") ? { left: arrowX || void 0, ...arrowAnchorStyle } : { top: arrowY || void 0, ...arrowAnchorStyle };
2555
+ const transformOrigin = side.startsWith("top") ? "center bottom" : side.startsWith("bottom") ? "center top" : side.startsWith("left") ? "right center" : side.startsWith("right") ? "left center" : "center";
2556
+ const childrenArray = React11__default.Children.toArray(children);
2557
+ const hasMultipleChildren = childrenArray.length > 1;
2558
+ let child;
2559
+ if (hasMultipleChildren) {
2560
+ child = /* @__PURE__ */ jsx("div", { style: { display: "inline-block" }, children });
2561
+ } else {
2562
+ const only = React11__default.Children.only(children);
2563
+ const isDomElement = React11__default.isValidElement(only) && typeof only.type === "string";
2564
+ child = isDomElement ? only : (
2565
+ // Ensure the wrapper reliably captures mouseenter/pointerenter and can contain block elements
2566
+ /* @__PURE__ */ jsx("div", { style: { display: "inline-block" }, children: only })
2567
+ );
2568
+ }
2569
+ const mergedRef = (node) => {
2570
+ referenceRef.current = node;
2571
+ if (!follow) {
2572
+ refs.setReference(node);
2573
+ }
2574
+ const childWithRef = child;
2575
+ const originalRef = childWithRef?.ref;
2576
+ if (typeof originalRef === "function") originalRef(node);
2577
+ else if (originalRef && "current" in originalRef)
2578
+ originalRef.current = node;
2579
+ };
2580
+ const refAttrs = referenceProps;
2581
+ const cloned = React11__default.cloneElement(
2582
+ child,
2583
+ {
2584
+ ...refAttrs,
2585
+ ref: mergedRef,
2586
+ "data-tooltip-ref": true
2587
+ }
2588
+ );
2589
+ if (disabled) return /* @__PURE__ */ jsx(Fragment, { children: cloned });
2590
+ const [isMounted, setIsMounted] = React11__default.useState(false);
2591
+ const closeTimerRef = React11__default.useRef(
2592
+ null
2593
+ );
2594
+ React11__default.useEffect(() => {
2595
+ if (closeTimerRef.current) {
2596
+ clearTimeout(closeTimerRef.current);
2597
+ closeTimerRef.current = null;
2598
+ }
2599
+ if (open) {
2600
+ setIsMounted(true);
2601
+ } else {
2602
+ closeTimerRef.current = setTimeout(() => {
2603
+ setIsMounted(false);
2604
+ closeTimerRef.current = null;
2605
+ }, 160);
2606
+ }
2607
+ return () => {
2608
+ if (closeTimerRef.current) {
2609
+ clearTimeout(closeTimerRef.current);
2610
+ closeTimerRef.current = null;
2611
+ }
2612
+ };
2613
+ }, [open]);
2614
+ let arrowEl = null;
2615
+ let floatingNode = null;
2616
+ const findRoleTooltipElement = (node) => {
2617
+ if (!React11__default.isValidElement(node)) return null;
2618
+ const el = node;
2619
+ if (el.props?.role === "tooltip") return el;
2620
+ const kids = el.props?.children;
2621
+ if (!kids) return null;
2622
+ const arr = React11__default.Children.toArray(kids);
2623
+ for (const c of arr) {
2624
+ if (React11__default.isValidElement(c) && c.props?.role === "tooltip") {
2625
+ return c;
2626
+ }
2627
+ }
2628
+ return null;
2629
+ };
2630
+ const isCustomTooltip = React11__default.isValidElement(content) && !!(content.type && content.type.isBlockTooltipContainer);
2631
+ const customEl = isCustomTooltip ? content : findRoleTooltipElement(content);
2632
+ const containerRef = React11__default.useRef(null);
2633
+ const [containerBg, setContainerBg] = React11__default.useState();
2634
+ React11__default.useEffect(() => {
2635
+ if (!(open || isMounted)) return;
2636
+ const el = containerRef.current;
2637
+ if (!el) return;
2638
+ try {
2639
+ const cs = getComputedStyle(el);
2640
+ const bg = cs.backgroundColor;
2641
+ if (bg && bg !== "transparent" && bg !== "rgba(0, 0, 0, 0)") {
2642
+ setContainerBg(bg);
2643
+ } else {
2644
+ setContainerBg("rgba(20,20,20,0.95)");
2645
+ }
2646
+ } catch {
2647
+ }
2648
+ }, [open, isMounted, isCustomTooltip]);
2649
+ if (isCustomTooltip) {
2650
+ const el = customEl;
2651
+ const childProps = el.props || {};
2652
+ const floatingProps = getFloatingProps({});
2653
+ const defaultStyles = {};
2654
+ if (childProps.bg === void 0 && childProps.background === void 0 && !(childProps.style?.background || childProps.style?.backgroundColor)) {
2655
+ defaultStyles.background = "rgba(20,20,20,0.95)";
2656
+ }
2657
+ if (childProps.color === void 0 && !childProps.style?.color) {
2658
+ defaultStyles.color = "white";
2659
+ }
2660
+ const hasPadding = childProps.p !== void 0 || childProps.padding !== void 0 || childProps.px !== void 0 || childProps.py !== void 0 || childProps.paddingLeft !== void 0 || childProps.paddingRight !== void 0 || childProps.paddingTop !== void 0 || childProps.paddingBottom !== void 0 || childProps.style?.padding !== void 0 || childProps.style?.paddingLeft !== void 0 || childProps.style?.paddingRight !== void 0 || childProps.style?.paddingTop !== void 0 || childProps.style?.paddingBottom !== void 0;
2661
+ if (!hasPadding) {
2662
+ defaultStyles.paddingLeft = "10px";
2663
+ defaultStyles.paddingRight = "10px";
2664
+ defaultStyles.paddingTop = "8px";
2665
+ defaultStyles.paddingBottom = "8px";
2666
+ }
2667
+ if (childProps.borderRadius === void 0 && childProps.rounded === void 0 && childProps.style?.borderRadius === void 0) {
2668
+ defaultStyles.borderRadius = "6px";
2669
+ }
2670
+ if (childProps.boxShadow === void 0 && childProps.shadow === void 0 && childProps.style?.boxShadow === void 0) {
2671
+ defaultStyles.boxShadow = "0 6px 18px rgba(0,0,0,0.18)";
2672
+ }
2673
+ if (childProps.fontSize === void 0 && childProps.style?.fontSize === void 0) {
2674
+ defaultStyles.fontSize = "13px";
2675
+ }
2676
+ const mergedClassName = [childProps.className, className ?? "tooltip-root"].filter(Boolean).join(" ");
2677
+ const mergedStyle = { ...defaultStyles, ...childProps.style };
2678
+ ({
2679
+ ...childProps,
2680
+ ...floatingProps});
2681
+ Object.keys(floatingProps).forEach((key) => {
2682
+ if (key.startsWith("on") && typeof floatingProps[key] === "function") {
2683
+ floatingProps[key];
2684
+ childProps[key];
2685
+ }
2686
+ });
2687
+ const originalRef = el.ref;
2688
+ const mergedFloatingRef = (node) => {
2689
+ refs.setFloating(node);
2690
+ if (typeof originalRef === "function") originalRef(node);
2691
+ else if (originalRef && typeof originalRef === "object")
2692
+ originalRef.current = node;
2693
+ };
2694
+ arrowEl = showArrow ? /* @__PURE__ */ jsx(
2695
+ "div",
2696
+ {
2697
+ ref: (node) => {
2698
+ arrowRef.current = node;
2699
+ },
2700
+ style: {
2701
+ position: "absolute",
2702
+ width: ARROW_SIZE,
2703
+ height: ARROW_SIZE,
2704
+ transform: "rotate(45deg) translateZ(0)",
2705
+ background: containerBg ?? "rgba(20,20,20,0.95)",
2706
+ ...arrowStyle
2707
+ },
2708
+ "data-arrow": true
2709
+ }
2710
+ ) : null;
2711
+ floatingNode = /* @__PURE__ */ jsxs(
2712
+ motion.div,
2713
+ {
2714
+ ref: mergedFloatingRef,
2715
+ ...floatingProps,
2716
+ className,
2717
+ style: {
2718
+ // Required runtime positioning (highest precedence - cannot be overridden)
2719
+ position: strategy,
2720
+ left: x || 0,
2721
+ top: y || 0,
2722
+ transformOrigin,
2723
+ pointerEvents: (open || isMounted) && interactive ? "auto" : "none",
2724
+ zIndex: 9999,
2725
+ maxWidth: 320,
2726
+ display: "inline-block",
2727
+ overflow: "visible"
2728
+ },
2729
+ initial: { opacity: 0, scale: 0.92 },
2730
+ animate: { opacity: open ? 1 : 0, scale: open ? 1 : 0.92 },
2731
+ transition: { type: "spring", stiffness: 520, damping: 34 },
2732
+ role: "tooltip",
2733
+ children: [
2734
+ (() => {
2735
+ const originalChildRef = el.ref;
2736
+ const mergedChildRef = (node) => {
2737
+ containerRef.current = node;
2738
+ if (typeof originalChildRef === "function") originalChildRef(node);
2739
+ else if (originalChildRef && typeof originalChildRef === "object")
2740
+ originalChildRef.current = node;
2741
+ };
2742
+ return React11__default.cloneElement(
2743
+ el,
2744
+ {
2745
+ // Spread childProps first
2746
+ ...childProps,
2747
+ ref: mergedChildRef,
2748
+ // Then override className with merged value (must be after ...childProps)
2749
+ className: mergedClassName,
2750
+ style: {
2751
+ // Apply inline defaults first, then user styles, then position
2752
+ ...mergedStyle,
2753
+ position: "relative"
2754
+ }
2755
+ },
2756
+ childProps.children
2757
+ );
2758
+ })(),
2759
+ arrowEl
2760
+ ]
2761
+ }
2762
+ );
2763
+ } else {
2764
+ arrowEl = showArrow ? /* @__PURE__ */ jsx(
2765
+ "div",
2766
+ {
2767
+ ref: (node) => {
2768
+ arrowRef.current = node;
2769
+ },
2770
+ style: {
2771
+ position: "absolute",
2772
+ width: ARROW_SIZE,
2773
+ height: ARROW_SIZE,
2774
+ transform: "rotate(45deg) translateZ(0)",
2775
+ background: containerBg ?? "rgba(20,20,20,0.95)",
2776
+ ...arrowStyle
2777
+ },
2778
+ "data-arrow": true
2779
+ }
2780
+ ) : null;
2781
+ floatingNode = /* @__PURE__ */ jsxs(
2782
+ motion.div,
2783
+ {
2784
+ ref: (node) => {
2785
+ refs.setFloating(node);
2786
+ },
2787
+ ...getFloatingProps({}),
2788
+ className,
2789
+ role: "tooltip",
2790
+ style: {
2791
+ position: strategy,
2792
+ left: x || 0,
2793
+ top: y || 0,
2794
+ transformOrigin,
2795
+ pointerEvents: (open || isMounted) && interactive ? "auto" : "none",
2796
+ zIndex: 9999,
2797
+ maxWidth: 320,
2798
+ display: "inline-block",
2799
+ overflow: "visible"
2800
+ },
2801
+ initial: { opacity: 0, scale: 0.92 },
2802
+ animate: { opacity: open ? 1 : 0, scale: open ? 1 : 0.92 },
2803
+ transition: { type: "spring", stiffness: 520, damping: 34 },
2804
+ children: [
2805
+ /* @__PURE__ */ jsx(
2806
+ Base5,
2807
+ {
2808
+ role: "tooltip",
2809
+ style: { position: "relative" },
2810
+ bg: "rgba(20,20,20,0.95)",
2811
+ color: "white",
2812
+ px: "10px",
2813
+ py: "8px",
2814
+ borderRadius: 6,
2815
+ boxShadow: "0 6px 18px rgba(0,0,0,0.18)",
2816
+ fontSize: 13,
2817
+ ref: containerRef,
2818
+ children: content
2819
+ }
2820
+ ),
2821
+ arrowEl
2822
+ ]
2823
+ }
2824
+ );
2825
+ }
2826
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2827
+ cloned,
2828
+ (open || isMounted) && createPortal(
2829
+ floatingNode,
2830
+ props.portalContainer || document.getElementById("portal") || document.body
2831
+ )
2832
+ ] });
2833
+ }
2834
+ var Base6 = base;
2835
+ var Svg = motionTags.svg;
2836
+ var CheckboxBtn = motionTags.button;
2837
+ function Checkbox(props) {
2838
+ const { children, onClick, ...rest } = props;
2839
+ const [checked, setChecked] = React11__default.useState(false);
2840
+ const [indeterminate, setIndeterminate] = React11__default.useState(false);
2841
+ React11__default.useEffect(() => {
2842
+ setChecked(!!rest.checked);
2843
+ }, [rest.checked]);
2844
+ React11__default.useEffect(() => {
2845
+ setIndeterminate(!!rest.indeterminate);
2846
+ }, [rest.indeterminate]);
2847
+ const isIndeterminate = typeof rest.indeterminate === "boolean";
2848
+ return /* @__PURE__ */ jsxs(
2849
+ Base6,
2850
+ {
2851
+ flex: true,
2852
+ alignI: true,
2853
+ gap: 2,
2854
+ cursor: "pointer",
2855
+ userSelect: "none",
2856
+ ...rest,
2857
+ onClick: () => rest.onChecked?.(!rest.checked),
2858
+ children: [
2859
+ /* @__PURE__ */ jsx(
2860
+ CheckboxBtn,
2861
+ {
2862
+ "data-checkbox": true,
2863
+ ...checked && { "data-checked": checked },
2864
+ w: "24px",
2865
+ p: 1,
2866
+ br: 6,
2867
+ cursor: "pointer",
2868
+ boxSizing: "border-box",
2869
+ outline: "none !important",
2870
+ bg: { base: "neutral.200", _dark: "neutral.700" },
2871
+ _checked: { bg: "blue.500", transition: ".14s background ease-out" },
2872
+ _active: { scale: 0.9 },
2873
+ color: "neutral.100",
2874
+ transition: ".14s background ease-out .1s",
2875
+ _focus: { boxShadow: "0 0 0 6px hsl(0 0% 100% / 0.05)" },
2876
+ children: /* @__PURE__ */ jsx(
2877
+ Svg,
2878
+ {
2879
+ fill: "none",
2880
+ width: "100%",
2881
+ viewBox: "0 0 24 24",
2882
+ stroke: "currentColor",
2883
+ strokeWidth: 4,
2884
+ children: /* @__PURE__ */ jsxs(AnimatePresence, { mode: "wait", children: [
2885
+ isIndeterminate && indeterminate && /* @__PURE__ */ jsx(
2886
+ motion.path,
2887
+ {
2888
+ initial: { scaleX: 0 },
2889
+ animate: { scaleX: 1 },
2890
+ exit: { scaleX: 0 },
2891
+ transition: {
2892
+ type: "tween",
2893
+ ease: "easeOut",
2894
+ duration: 0.3,
2895
+ delay: 0.2
2896
+ },
2897
+ strokeLinecap: "round",
2898
+ d: "M6 12 L18 12"
2899
+ },
2900
+ "indeterminate"
2901
+ ),
2902
+ !indeterminate && checked && /* @__PURE__ */ jsx(
2903
+ motion.path,
2904
+ {
2905
+ initial: { pathLength: 0 },
2906
+ animate: { pathLength: 1 },
2907
+ exit: { pathLength: 0 },
2908
+ transition: { type: "tween", ease: "easeOut", duration: 0.2 },
2909
+ strokeLinecap: "round",
2910
+ strokeLinejoin: "round",
2911
+ d: "M5 13l4 4L19 7"
2912
+ },
2913
+ "check"
2914
+ )
2915
+ ] })
2916
+ }
2917
+ )
2918
+ }
2919
+ ),
2920
+ children
2921
+ ]
2922
+ }
2923
+ );
2924
+ }
2925
+ var Hr = motionTags.hr;
2926
+ var Skeleton = motionTags.div;
2927
+ function Block(props) {
2928
+ const anyProps = props;
2929
+ const {
2930
+ _motion,
2931
+ sheenInterval = "1.4s",
2932
+ children,
2933
+ tooltip,
2934
+ ...rest
2935
+ } = anyProps;
2936
+ const fileInputRef = React11.useRef(null);
2937
+ const isLoading = anyProps.isLoading;
2938
+ const multiple = anyProps.multiple;
2939
+ const is = anyProps.is;
2940
+ const extract = extractElType(is, anyProps);
2941
+ const [Comp, initialStyles] = extractElAndStyles(extract, props);
2942
+ const icons = getIcons(extract, props);
2943
+ let component = /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: extract.isHr ? /* @__PURE__ */ jsx(Hr, { w: true, py: 2, color: "neutral.300", ...anyProps }) : extract.isProgress ? /* @__PURE__ */ jsx(Progress, { ...anyProps }) : extract.isDrawer ? /* @__PURE__ */ jsx(Drawer, { ...anyProps }) : extract.isAccordion ? /* @__PURE__ */ jsx(accordion_default, { ...anyProps }) : extract.isMenu ? /* @__PURE__ */ jsx(Menu, { ...anyProps }) : extract.isSwitch ? /* @__PURE__ */ jsx(switch_default, { ...anyProps }) : extract.isRadio ? /* @__PURE__ */ jsx(Radio, { ...anyProps }) : extract.isInput ? /* @__PURE__ */ jsx(Input, { ...anyProps }) : extract.isTextarea ? /* @__PURE__ */ jsx(Textarea, { ...anyProps }) : extract.isCheckbox ? /* @__PURE__ */ jsx(Checkbox, { ...anyProps }) : extract.isSkeleton ? /* @__PURE__ */ jsx(
2944
+ Skeleton,
2945
+ {
2946
+ ...anyProps.as === "circle" ? { br: "50%", size: 40 } : {
2947
+ height: 20,
2948
+ width: "100%",
2949
+ backgroundSize: "200% 100%",
2950
+ overflow: "hidden"
2951
+ },
2952
+ backgroundColor: { base: "neutral.300", _dark: "neutral.700" },
2953
+ backgroundImage: {
2954
+ base: `linear-gradient(
2955
+ 90deg,
2956
+ hsla(220, 8.94%, 66.08%, 0) 0%,
2957
+ {colors.neutral.100/80} 50%,
2958
+ hsla(220, 8.94%, 66.08%, 0) 100%
2959
+ )`,
2960
+ _dark: `linear-gradient(
2961
+ 90deg,
2962
+ hsla(220, 8.94%, 66.08%, 0) 0%,
2963
+ {colors.neutral.500/80} 50%,
2964
+ hsla(220, 8.94%, 66.08%, 0) 100%
2965
+ )`
2966
+ },
2967
+ backgroundRepeat: "no-repeat",
2968
+ backgroundSize: "200% 100%",
2969
+ animation: `sheen ${sheenInterval} infinite linear`,
2970
+ ...anyProps
2971
+ }
2972
+ ) : extract.filepickerAllowed ? /* @__PURE__ */ jsxs("div", { onClick: () => fileInputRef.current?.click(), children: [
2973
+ React11.createElement(
2974
+ Comp,
2975
+ {
2976
+ cursor: "pointer",
2977
+ ...isLoading && { "data-loading": isLoading },
2978
+ onContextMenu: (e) => e.preventDefault(),
2979
+ ...initialStyles
2980
+ },
2981
+ icons.leftIcon,
2982
+ children,
2983
+ icons.rightIcon
2984
+ ),
2985
+ /* @__PURE__ */ jsx(
2986
+ "input",
2987
+ {
2988
+ type: "file",
2989
+ ref: fileInputRef,
2990
+ multiple,
2991
+ accept: anyProps.accept,
2992
+ style: { display: "none" },
2993
+ onChange: async (e) => {
2994
+ const files = Array.from(e.target.files ?? []);
2995
+ const selectedFiles = files.length ? await prepareFiles(files) : [];
2996
+ if (anyProps.onChange) {
2997
+ anyProps.onChange(selectedFiles);
2998
+ }
2999
+ },
3000
+ value: ""
3001
+ }
3002
+ )
3003
+ ] }) : React11.createElement(
3004
+ Comp,
3005
+ {
3006
+ ...isLoading && { "data-loading": isLoading },
3007
+ onContextMenu: (e) => e.preventDefault(),
3008
+ ...initialStyles
3009
+ },
3010
+ icons.leftIcon,
3011
+ children,
3012
+ icons.rightIcon
3013
+ ) });
3014
+ if (tooltip) {
3015
+ const tooltipContent = typeof tooltip === "boolean" ? rest.content : tooltip;
3016
+ const tooltipProps = { ...rest, content: tooltipContent };
3017
+ component = /* @__PURE__ */ jsx(Tooltip, { ...tooltipProps, children: component });
3018
+ }
3019
+ if (rest.portal) {
3020
+ const portalContainer = rest.portalContainer;
3021
+ const fallback = document.getElementById("portal") || document.body;
3022
+ const container = portalContainer ?? fallback;
3023
+ return createPortal(
3024
+ component,
3025
+ container
3026
+ );
3027
+ } else {
3028
+ return component;
3029
+ }
3030
+ }
3031
+ TooltipContainer.isBlockTooltipContainer = true;
3032
+ MenuContainer.isBlockMenuContainer = true;
3033
+ var TooltipNamespace = { Container: TooltipContainer };
3034
+ var MenuNamespace = { Container: MenuContainer };
3035
+ var InputNamespace = {
3036
+ Label: Label2,
3037
+ RightSide,
3038
+ LeftIcon
3039
+ };
3040
+ var TextareaNamespace = {
3041
+ Label
3042
+ };
3043
+ var RadioNamespace = {
3044
+ Item
3045
+ };
3046
+ var SwitchNamespace = { Track, Thumb };
3047
+ var AccordionNamespace = {
3048
+ Item: Item2
3049
+ };
3050
+ var DrawerNamespace = {
3051
+ CloseBtn,
3052
+ BtnGroup
3053
+ };
3054
+ var ProgressNamespace = {
3055
+ TrackFill,
3056
+ TrackBg
3057
+ };
3058
+ var CompoundBlock = Object.assign(Block, {
3059
+ Accordion: AccordionNamespace,
3060
+ Progress: ProgressNamespace,
3061
+ Textarea: TextareaNamespace,
3062
+ Tooltip: TooltipNamespace,
3063
+ Switch: SwitchNamespace,
3064
+ Drawer: DrawerNamespace,
3065
+ Menu: MenuNamespace,
3066
+ Input: InputNamespace,
3067
+ Radio: RadioNamespace
3068
+ });
3069
+ var block_default = CompoundBlock;
3070
+
3071
+ // src/react/index.ts
3072
+ function useDebounce(value, delay = 500) {
3073
+ const [debouncedValue, setDebouncedValue] = React11__default.useState(value);
3074
+ React11__default.useEffect(() => {
3075
+ const handler = setTimeout(() => {
3076
+ setDebouncedValue(value);
3077
+ }, delay);
3078
+ return () => {
3079
+ clearTimeout(handler);
3080
+ };
3081
+ }, [value, delay]);
3082
+ return debouncedValue;
3083
+ }
3084
+ function useThrottle(value, interval = 500) {
3085
+ const [throttledValue, setThrottledValue] = React11__default.useState(value);
3086
+ const lastUpdate = React11__default.useRef(0);
3087
+ const timeoutRef = React11__default.useRef(null);
3088
+ React11__default.useEffect(() => {
3089
+ const now = Date.now();
3090
+ const timeSinceLastUpdate = now - lastUpdate.current;
3091
+ if (timeSinceLastUpdate >= interval) {
3092
+ setThrottledValue(value);
3093
+ lastUpdate.current = now;
3094
+ } else {
3095
+ if (timeoutRef.current) {
3096
+ clearTimeout(timeoutRef.current);
3097
+ }
3098
+ timeoutRef.current = setTimeout(() => {
3099
+ setThrottledValue(value);
3100
+ lastUpdate.current = Date.now();
3101
+ }, interval - timeSinceLastUpdate);
3102
+ }
3103
+ return () => {
3104
+ if (timeoutRef.current) {
3105
+ clearTimeout(timeoutRef.current);
3106
+ }
3107
+ };
3108
+ }, [value, interval]);
3109
+ return throttledValue;
3110
+ }
3111
+ function useMatchMedia2(queries, defaultValues = []) {
3112
+ const initialValues = defaultValues.length ? defaultValues : Array(queries.length).fill(false);
3113
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
3114
+ const getValue = () => {
3115
+ const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
3116
+ return matchedQueries;
3117
+ };
3118
+ const [value, setValue] = React11__default.useState(getValue);
3119
+ React11__default.useLayoutEffect(() => {
3120
+ const handler = () => setValue(getValue);
3121
+ mediaQueryLists.forEach((mql) => mql.addListener(handler));
3122
+ return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
3123
+ }, []);
3124
+ if (typeof window === "undefined") return initialValues;
3125
+ return value;
3126
+ }
3127
+
3128
+ export { block_default as default, useDebounce, useMatchMedia2 as useMatchMedia, useThrottle };