@availity/mui-file-selector 1.6.5 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,11 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
5
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -17,6 +21,12 @@ var __spreadValues = (a, b) => {
17
21
  return a;
18
22
  };
19
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
25
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
26
+ }) : x)(function(x) {
27
+ if (typeof require !== "undefined") return require.apply(this, arguments);
28
+ throw Error('Dynamic require of "' + x + '" is not supported');
29
+ });
20
30
  var __objRest = (source, exclude) => {
21
31
  var target = {};
22
32
  for (var prop in source)
@@ -29,6 +39,25 @@ var __objRest = (source, exclude) => {
29
39
  }
30
40
  return target;
31
41
  };
42
+ var __commonJS = (cb, mod) => function __require2() {
43
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
44
+ };
45
+ var __copyProps = (to, from, except, desc) => {
46
+ if (from && typeof from === "object" || typeof from === "function") {
47
+ for (let key of __getOwnPropNames(from))
48
+ if (!__hasOwnProp.call(to, key) && key !== except)
49
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
50
+ }
51
+ return to;
52
+ };
53
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
54
+ // If the importer is in node compatibility mode or this is not an ESM
55
+ // file that has been converted to a CommonJS file using a Babel-
56
+ // compatible transform (i.e. "__esModule" has not been set), then set
57
+ // "default" to the CommonJS "module.exports" for node compatibility.
58
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
59
+ mod
60
+ ));
32
61
  var __async = (__this, __arguments, generator) => {
33
62
  return new Promise((resolve, reject) => {
34
63
  var fulfilled = (value) => {
@@ -50,6 +79,135 @@ var __async = (__this, __arguments, generator) => {
50
79
  });
51
80
  };
52
81
 
82
+ // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
83
+ var require_use_sync_external_store_shim_production = __commonJS({
84
+ "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js"(exports) {
85
+ "use strict";
86
+ var React6 = __require("react");
87
+ function is(x, y) {
88
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
89
+ }
90
+ var objectIs = "function" === typeof Object.is ? Object.is : is;
91
+ var useState7 = React6.useState;
92
+ var useEffect4 = React6.useEffect;
93
+ var useLayoutEffect = React6.useLayoutEffect;
94
+ var useDebugValue = React6.useDebugValue;
95
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
96
+ var value = getSnapshot(), _useState = useState7({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
97
+ useLayoutEffect(
98
+ function() {
99
+ inst.value = value;
100
+ inst.getSnapshot = getSnapshot;
101
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102
+ },
103
+ [subscribe, value, getSnapshot]
104
+ );
105
+ useEffect4(
106
+ function() {
107
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
108
+ return subscribe(function() {
109
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
110
+ });
111
+ },
112
+ [subscribe]
113
+ );
114
+ useDebugValue(value);
115
+ return value;
116
+ }
117
+ function checkIfSnapshotChanged(inst) {
118
+ var latestGetSnapshot = inst.getSnapshot;
119
+ inst = inst.value;
120
+ try {
121
+ var nextValue = latestGetSnapshot();
122
+ return !objectIs(inst, nextValue);
123
+ } catch (error) {
124
+ return true;
125
+ }
126
+ }
127
+ function useSyncExternalStore$12(subscribe, getSnapshot) {
128
+ return getSnapshot();
129
+ }
130
+ var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$12 : useSyncExternalStore$2;
131
+ exports.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
132
+ }
133
+ });
134
+
135
+ // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
136
+ var require_use_sync_external_store_shim_development = __commonJS({
137
+ "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
138
+ "use strict";
139
+ "production" !== process.env.NODE_ENV && function() {
140
+ function is(x, y) {
141
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
142
+ }
143
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
144
+ didWarnOld18Alpha || void 0 === React6.startTransition || (didWarnOld18Alpha = true, console.error(
145
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
146
+ ));
147
+ var value = getSnapshot();
148
+ if (!didWarnUncachedGetSnapshot) {
149
+ var cachedValue = getSnapshot();
150
+ objectIs(value, cachedValue) || (console.error(
151
+ "The result of getSnapshot should be cached to avoid an infinite loop"
152
+ ), didWarnUncachedGetSnapshot = true);
153
+ }
154
+ cachedValue = useState7({
155
+ inst: { value, getSnapshot }
156
+ });
157
+ var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
158
+ useLayoutEffect(
159
+ function() {
160
+ inst.value = value;
161
+ inst.getSnapshot = getSnapshot;
162
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
163
+ },
164
+ [subscribe, value, getSnapshot]
165
+ );
166
+ useEffect4(
167
+ function() {
168
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
169
+ return subscribe(function() {
170
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
171
+ });
172
+ },
173
+ [subscribe]
174
+ );
175
+ useDebugValue(value);
176
+ return value;
177
+ }
178
+ function checkIfSnapshotChanged(inst) {
179
+ var latestGetSnapshot = inst.getSnapshot;
180
+ inst = inst.value;
181
+ try {
182
+ var nextValue = latestGetSnapshot();
183
+ return !objectIs(inst, nextValue);
184
+ } catch (error) {
185
+ return true;
186
+ }
187
+ }
188
+ function useSyncExternalStore$12(subscribe, getSnapshot) {
189
+ return getSnapshot();
190
+ }
191
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
192
+ var React6 = __require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState7 = React6.useState, useEffect4 = React6.useEffect, useLayoutEffect = React6.useLayoutEffect, useDebugValue = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$12 : useSyncExternalStore$2;
193
+ exports.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
194
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
195
+ }();
196
+ }
197
+ });
198
+
199
+ // ../../node_modules/use-sync-external-store/shim/index.js
200
+ var require_shim = __commonJS({
201
+ "../../node_modules/use-sync-external-store/shim/index.js"(exports, module) {
202
+ "use strict";
203
+ if (process.env.NODE_ENV === "production") {
204
+ module.exports = require_use_sync_external_store_shim_production();
205
+ } else {
206
+ module.exports = require_use_sync_external_store_shim_development();
207
+ }
208
+ }
209
+ });
210
+
53
211
  // src/lib/Dropzone.tsx
54
212
  import { useCallback } from "react";
55
213
  import { styled } from "@mui/material/styles";
@@ -297,9 +455,15 @@ var Dropzone = ({
297
455
  );
298
456
  };
299
457
 
300
- // src/lib/ErrorAlert.tsx
301
- import { Alert, AlertTitle } from "@availity/mui-alert";
302
- import { List, ListItem } from "@availity/mui-list";
458
+ // src/lib/Dropzone2.tsx
459
+ import { useCallback as useCallback2 } from "react";
460
+ import { useDropzone as useDropzone2 } from "react-dropzone";
461
+ import { useFormContext as useFormContext2 } from "react-hook-form";
462
+ import { Divider as Divider2 } from "@availity/mui-divider";
463
+ import { CloudUploadIcon as CloudUploadIcon2, PlusIcon as PlusIcon2 } from "@availity/mui-icon";
464
+ import { Box as Box2, Stack as Stack2 } from "@availity/mui-layout";
465
+ import { Typography as Typography2 } from "@availity/mui-typography";
466
+ import Upload from "@availity/upload-core";
303
467
 
304
468
  // src/lib/util.ts
305
469
  import {
@@ -343,15 +507,196 @@ var FILE_EXT_ICONS = {
343
507
  pdf: FilePdfIcon
344
508
  };
345
509
  var isValidKey = (key) => key ? key in FILE_EXT_ICONS : false;
346
- var getFileExtIcon = (fileName) => {
510
+ var getFileExtension = (fileName) => {
347
511
  var _a;
348
- const ext = ((_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
349
- const icon = isValidKey(ext) ? FILE_EXT_ICONS[ext] : FileIcon;
350
- return icon;
512
+ return ((_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
513
+ };
514
+ var getFileExtIcon = (fileName) => {
515
+ const ext = getFileExtension(fileName);
516
+ return isValidKey(ext) ? FILE_EXT_ICONS[ext] : FileIcon;
517
+ };
518
+ var dedupeErrors = (errors) => {
519
+ const dedupedErrors = errors.reduce((acc, error) => {
520
+ if (!acc.find((err) => err.code === error.code)) {
521
+ acc.push(error);
522
+ }
523
+ return acc;
524
+ }, []);
525
+ return dedupedErrors;
351
526
  };
352
527
 
353
- // src/lib/ErrorAlert.tsx
528
+ // src/lib/Dropzone2.tsx
354
529
  import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
530
+ var counter2 = createCounter();
531
+ function startUpload(file, options) {
532
+ return __async(this, null, function* () {
533
+ const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
534
+ const upload = new Upload(file, uploadOptions);
535
+ yield upload.generateId();
536
+ if (onSuccess) upload.onSuccess.push(onSuccess);
537
+ if (onError) upload.onError.push(onError);
538
+ if (onProgress) upload.onProgress.push(onProgress);
539
+ if (onChunkComplete) upload.onChunkComplete.push(onChunkComplete);
540
+ upload.start();
541
+ return upload;
542
+ });
543
+ }
544
+ var Dropzone2 = ({
545
+ allowedFileTypes = [],
546
+ disabled,
547
+ enableDropArea = true,
548
+ maxFiles,
549
+ maxSize,
550
+ multiple,
551
+ name,
552
+ onChange,
553
+ onClick,
554
+ onDrop,
555
+ setFileRejections,
556
+ setTotalSize,
557
+ uploadOptions,
558
+ validator
559
+ }) => {
560
+ const { getValues, setValue, watch } = useFormContext2();
561
+ const accept = allowedFileTypes.join(",");
562
+ const handleValidation = useCallback2(
563
+ (file) => {
564
+ var _a2;
565
+ const previous = (_a2 = watch(name)) != null ? _a2 : [];
566
+ const errors = [];
567
+ const isDuplicate = previous.some((prev) => prev.file.name === file.name);
568
+ if (isDuplicate) {
569
+ errors.push({
570
+ code: "duplicate-name",
571
+ message: "A file with this name already exists"
572
+ });
573
+ }
574
+ const hasMaxFiles = maxFiles && previous.length >= maxFiles;
575
+ if (hasMaxFiles) {
576
+ errors.push({
577
+ code: "too-many-files",
578
+ message: `Too many files. You may only upload ${maxFiles} file(s).`
579
+ });
580
+ }
581
+ if (validator) {
582
+ const validatorErrors = validator(file);
583
+ if (validatorErrors) {
584
+ if (Array.isArray(validatorErrors)) {
585
+ errors.push(...validatorErrors);
586
+ } else {
587
+ errors.push(validatorErrors);
588
+ }
589
+ }
590
+ }
591
+ return errors.length > 0 ? dedupeErrors(errors) : null;
592
+ },
593
+ [maxFiles, validator]
594
+ );
595
+ const handleOnDrop = useCallback2(
596
+ (acceptedFiles, fileRejections, event) => __async(void 0, null, function* () {
597
+ var _a2;
598
+ let newSize = 0;
599
+ for (const file of acceptedFiles) {
600
+ newSize += file.size;
601
+ }
602
+ setTotalSize((prev) => prev + newSize);
603
+ const previous = (_a2 = watch(name)) != null ? _a2 : [];
604
+ const uploads = acceptedFiles.map((file) => startUpload(file, uploadOptions));
605
+ setValue(name, previous.concat(yield Promise.all(uploads)));
606
+ if (fileRejections.length > 0) {
607
+ const TOO_MANY_FILES_CODE = "too-many-files";
608
+ let hasTooManyFiles = false;
609
+ fileRejections = fileRejections.reduce(
610
+ (acc, rejection) => {
611
+ const isTooManyFiles = rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE);
612
+ if (isTooManyFiles) {
613
+ if (!hasTooManyFiles) {
614
+ hasTooManyFiles = true;
615
+ acc.push(__spreadProps(__spreadValues({}, rejection), {
616
+ id: counter2.increment()
617
+ }));
618
+ }
619
+ } else {
620
+ acc.push(__spreadProps(__spreadValues({}, rejection), {
621
+ id: counter2.increment()
622
+ }));
623
+ }
624
+ return acc;
625
+ },
626
+ []
627
+ );
628
+ }
629
+ if (setFileRejections) setFileRejections(fileRejections);
630
+ if (onDrop) onDrop(acceptedFiles, fileRejections, event);
631
+ }),
632
+ [setFileRejections]
633
+ );
634
+ const { getRootProps, getInputProps } = useDropzone2({
635
+ onDrop: handleOnDrop,
636
+ maxSize,
637
+ maxFiles,
638
+ disabled,
639
+ multiple,
640
+ accept,
641
+ validator: handleValidation
642
+ });
643
+ const inputProps = getInputProps({
644
+ multiple,
645
+ accept,
646
+ onChange
647
+ });
648
+ const _a = getRootProps(), { role, tabIndex } = _a, rootProps = __objRest(_a, ["role", "tabIndex"]);
649
+ const handleOnChange = (event) => {
650
+ if (inputProps.onChange) {
651
+ inputProps.onChange(event);
652
+ }
653
+ };
654
+ const handleOnClick = (event) => {
655
+ if (!enableDropArea && rootProps.onClick) rootProps.onClick(event);
656
+ if (onClick) onClick;
657
+ };
658
+ const getFieldValue = () => {
659
+ const field = getValues();
660
+ return field[name] || [];
661
+ };
662
+ const hasFiles = getFieldValue().length > 0;
663
+ return enableDropArea ? /* @__PURE__ */ jsx3(DropzoneContainer, __spreadProps(__spreadValues({ sx: outerBoxStyles }, rootProps), { children: /* @__PURE__ */ jsx3(Box2, { sx: innerBoxStyles, children: /* @__PURE__ */ jsx3(Stack2, { spacing: 2, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs3(Fragment3, { children: [
664
+ /* @__PURE__ */ jsx3(CloudUploadIcon2, { fontSize: "xlarge", color: "secondary" }),
665
+ /* @__PURE__ */ jsx3(Typography2, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
666
+ /* @__PURE__ */ jsx3(Divider2, { flexItem: true, children: /* @__PURE__ */ jsx3(Typography2, { variant: "subtitle2", children: "OR" }) }),
667
+ /* @__PURE__ */ jsx3(
668
+ FilePickerBtn,
669
+ {
670
+ name,
671
+ color: "primary",
672
+ disabled,
673
+ maxSize,
674
+ onClick,
675
+ inputProps,
676
+ onChange: handleOnChange,
677
+ children: "Browse Files"
678
+ }
679
+ )
680
+ ] }) }) }) })) : /* @__PURE__ */ jsx3(
681
+ FilePickerBtn,
682
+ {
683
+ name,
684
+ color: "tertiary",
685
+ disabled,
686
+ maxSize,
687
+ onClick: handleOnClick,
688
+ inputProps,
689
+ onChange: handleOnChange,
690
+ startIcon: /* @__PURE__ */ jsx3(PlusIcon2, {}),
691
+ children: hasFiles ? "Add More Files" : "Add File(s)"
692
+ }
693
+ );
694
+ };
695
+
696
+ // src/lib/ErrorAlert.tsx
697
+ import { Alert, AlertTitle } from "@availity/mui-alert";
698
+ import { List, ListItem } from "@availity/mui-list";
699
+ import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
355
700
  var codes = {
356
701
  "file-too-large": "File exceeds maximum size",
357
702
  "file-invalid-type": "File has an invalid type",
@@ -368,14 +713,14 @@ var formatFileTooLarge = (message) => {
368
713
  };
369
714
  var ErrorAlert = ({ errors, fileName, id, onClose }) => {
370
715
  if (errors.length === 0) return null;
371
- return /* @__PURE__ */ jsx3(Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
372
- /* @__PURE__ */ jsxs3(AlertTitle, { children: [
716
+ return /* @__PURE__ */ jsx4(Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ jsxs4(Fragment4, { children: [
717
+ /* @__PURE__ */ jsxs4(AlertTitle, { children: [
373
718
  "There were ",
374
719
  errors.length,
375
720
  " error(s) found when uploading ",
376
721
  fileName
377
722
  ] }),
378
- /* @__PURE__ */ jsx3(
723
+ /* @__PURE__ */ jsx4(
379
724
  List,
380
725
  {
381
726
  sx: {
@@ -387,14 +732,14 @@ var ErrorAlert = ({ errors, fileName, id, onClose }) => {
387
732
  }
388
733
  },
389
734
  disablePadding: true,
390
- children: /* @__PURE__ */ jsx3(Fragment3, { children: errors.map((error) => {
735
+ children: /* @__PURE__ */ jsx4(Fragment4, { children: errors.map((error) => {
391
736
  const message = error.code === "file-too-large" ? formatFileTooLarge(error.message) : error.message;
392
- return /* @__PURE__ */ jsx3(ListItem, { disableGutters: true, disablePadding: true, divider: false, children: message }, `${id}-${error.code}`);
737
+ return /* @__PURE__ */ jsx4(ListItem, { disableGutters: true, disablePadding: true, divider: false, children: message }, `${id}-${error.code}`);
393
738
  }) })
394
739
  }
395
740
  )
396
- ] }) : /* @__PURE__ */ jsxs3(Fragment3, { children: [
397
- /* @__PURE__ */ jsxs3(AlertTitle, { children: [
741
+ ] }) : /* @__PURE__ */ jsxs4(Fragment4, { children: [
742
+ /* @__PURE__ */ jsxs4(AlertTitle, { children: [
398
743
  codes[errors[0].code] || "Error",
399
744
  ": ",
400
745
  fileName
@@ -408,7 +753,7 @@ import { List as List2, ListItem as ListItem2, ListItemText as ListItemText2, Li
408
753
  import { IconButton as IconButton3 } from "@availity/mui-button";
409
754
  import { DeleteIcon } from "@availity/mui-icon";
410
755
  import { Grid as Grid2 } from "@availity/mui-layout";
411
- import { Divider as Divider2 } from "@availity/mui-divider";
756
+ import { Divider as Divider3 } from "@availity/mui-divider";
412
757
 
413
758
  // src/lib/UploadProgressBar.tsx
414
759
  import { useState as useState2 } from "react";
@@ -419,8 +764,8 @@ import MuiDialog from "@mui/material/Dialog";
419
764
  import { styled as styled2 } from "@mui/material/styles";
420
765
  import { IconButton } from "@availity/mui-button";
421
766
  import { CloseIcon } from "@availity/mui-icon";
422
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
423
- var CloseButton = (args) => /* @__PURE__ */ jsx4(IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ jsx4(CloseIcon, { fontSize: "xsmall" }) }));
767
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
768
+ var CloseButton = (args) => /* @__PURE__ */ jsx5(IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ jsx5(CloseIcon, { fontSize: "xsmall" }) }));
424
769
  var CloseButtonSlot = styled2(CloseButton, {
425
770
  name: "MuiDialog",
426
771
  slot: "AvCloseButton",
@@ -435,37 +780,37 @@ var CloseButtonSlot = styled2(CloseButton, {
435
780
  });
436
781
  var Dialog = (_a) => {
437
782
  var _b = _a, { children, closeButton = true, onClose } = _b, rest = __objRest(_b, ["children", "closeButton", "onClose"]);
438
- return /* @__PURE__ */ jsxs4(MuiDialog, __spreadProps(__spreadValues({ onClose }, rest), { children: [
439
- closeButton ? /* @__PURE__ */ jsx4(CloseButtonSlot, { onClick: onClose }) : null,
783
+ return /* @__PURE__ */ jsxs5(MuiDialog, __spreadProps(__spreadValues({ onClose }, rest), { children: [
784
+ closeButton ? /* @__PURE__ */ jsx5(CloseButtonSlot, { onClick: onClose }) : null,
440
785
  children
441
786
  ] }));
442
787
  };
443
788
 
444
789
  // ../dialog/src/lib/DialogActions.tsx
445
790
  import MuiDialogActions from "@mui/material/DialogActions";
446
- import { jsx as jsx5 } from "react/jsx-runtime";
791
+ import { jsx as jsx6 } from "react/jsx-runtime";
447
792
  var DialogActions = (_a) => {
448
793
  var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
449
- return /* @__PURE__ */ jsx5(MuiDialogActions, __spreadProps(__spreadValues({}, rest), { children }));
794
+ return /* @__PURE__ */ jsx6(MuiDialogActions, __spreadProps(__spreadValues({}, rest), { children }));
450
795
  };
451
796
 
452
797
  // ../dialog/src/lib/DialogContent.tsx
453
798
  import MuiDialogContent from "@mui/material/DialogContent";
454
- import { jsx as jsx6 } from "react/jsx-runtime";
799
+ import { jsx as jsx7 } from "react/jsx-runtime";
455
800
  var DialogContent = (_a) => {
456
801
  var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
457
- return /* @__PURE__ */ jsx6(MuiDialogContent, __spreadProps(__spreadValues({}, rest), { children }));
802
+ return /* @__PURE__ */ jsx7(MuiDialogContent, __spreadProps(__spreadValues({}, rest), { children }));
458
803
  };
459
804
 
460
805
  // ../dialog/src/lib/DialogContentText.tsx
461
806
  import MuiDialogContentText from "@mui/material/DialogContentText";
462
- import { jsx as jsx7 } from "react/jsx-runtime";
807
+ import { jsx as jsx8 } from "react/jsx-runtime";
463
808
 
464
809
  // ../dialog/src/lib/DialogTitle.tsx
465
810
  import MuiDialogTitle from "@mui/material/DialogTitle";
466
811
  import { AlertIcons } from "@availity/mui-alert";
467
812
  import { styled as styled3 } from "@mui/material/styles";
468
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
813
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
469
814
  var AlertIcon = styled3("div", {
470
815
  name: "MuiDialogTitle",
471
816
  slot: "AvIcon",
@@ -478,8 +823,8 @@ var AlertIcon = styled3("div", {
478
823
  });
479
824
  var DialogTitle = (_a) => {
480
825
  var _b = _a, { children, component = "h2", icon, variant = "h5" } = _b, rest = __objRest(_b, ["children", "component", "icon", "variant"]);
481
- return /* @__PURE__ */ jsxs5(MuiDialogTitle, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
482
- icon ? /* @__PURE__ */ jsx8(AlertIcon, { children: AlertIcons[icon] }) : null,
826
+ return /* @__PURE__ */ jsxs6(MuiDialogTitle, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
827
+ icon ? /* @__PURE__ */ jsx9(AlertIcon, { children: AlertIcons[icon] }) : null,
483
828
  children
484
829
  ] }));
485
830
  };
@@ -487,7 +832,7 @@ var DialogTitle = (_a) => {
487
832
  // src/lib/UploadProgressBar.tsx
488
833
  import { InputAdornment } from "@availity/mui-form-utils";
489
834
  import { EyeIcon, EyeSlashIcon, WarningTriangleIcon } from "@availity/mui-icon";
490
- import { Box as Box2 } from "@availity/mui-layout";
835
+ import { Box as Box3 } from "@availity/mui-layout";
491
836
  import { ListItemText } from "@availity/mui-list";
492
837
  import { LinearProgress } from "@availity/mui-progress";
493
838
 
@@ -502,8 +847,8 @@ import {
502
847
  SelectPropOverrides
503
848
  } from "@availity/mui-form-utils";
504
849
  import { Grid } from "@availity/mui-layout";
505
- import { Typography as Typography2 } from "@availity/mui-typography";
506
- import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
850
+ import { Typography as Typography3 } from "@availity/mui-typography";
851
+ import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
507
852
  var TextFieldFormHelperText = (_a) => {
508
853
  var _b = _a, {
509
854
  charCount,
@@ -517,19 +862,19 @@ var TextFieldFormHelperText = (_a) => {
517
862
  "showCharacterCount"
518
863
  ]);
519
864
  if (showCharacterCount) {
520
- return /* @__PURE__ */ jsxs6(Grid, { container: true, justifyContent: "space-between", flexWrap: "nowrap", children: [
521
- /* @__PURE__ */ jsx9(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { sx: { marginRight: "12px" }, children: helperText })),
522
- /* @__PURE__ */ jsxs6(Typography2, { variant: "caption", marginTop: "4px", lineHeight: "1.25rem", children: [
523
- /* @__PURE__ */ jsx9(Typography2, { component: "span", variant: "inherit", color: charCount > maxLength ? "error" : "textPrimary", children: charCount || 0 }),
865
+ return /* @__PURE__ */ jsxs7(Grid, { container: true, justifyContent: "space-between", flexWrap: "nowrap", children: [
866
+ /* @__PURE__ */ jsx10(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { sx: { marginRight: "12px" }, children: helperText })),
867
+ /* @__PURE__ */ jsxs7(Typography3, { variant: "caption", marginTop: "4px", lineHeight: "1.25rem", children: [
868
+ /* @__PURE__ */ jsx10(Typography3, { component: "span", variant: "inherit", color: charCount > maxLength ? "error" : "textPrimary", children: charCount || 0 }),
524
869
  "/",
525
870
  maxLength
526
871
  ] })
527
872
  ] });
528
873
  }
529
- return /* @__PURE__ */ jsx9(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { children: helperText }));
874
+ return /* @__PURE__ */ jsx10(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { children: helperText }));
530
875
  };
531
876
  var TextField = forwardRef((props, ref) => {
532
- var _b, _c, _d, _e, _f, _g, _h;
877
+ var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
533
878
  const _a = props, {
534
879
  InputProps: InputProps2,
535
880
  helpTopicId,
@@ -556,37 +901,39 @@ var TextField = forwardRef((props, ref) => {
556
901
  const [openDetected, setOpenDetected] = useState(false);
557
902
  const [charCount, setCharCount] = useState(0);
558
903
  const maxLength = (inputProps == null ? void 0 : inputProps.maxLength) || ((_c = (_b = rest.slotProps) == null ? void 0 : _b.htmlInput) == null ? void 0 : _c.maxLength);
904
+ const allReadOnly = (InputProps2 == null ? void 0 : InputProps2.readOnly) || (inputProps == null ? void 0 : inputProps.readOnly) || ((_e = (_d = rest.slotProps) == null ? void 0 : _d.htmlInput) == null ? void 0 : _e.readOnly) || ((_g = (_f = rest.slotProps) == null ? void 0 : _f.input) == null ? void 0 : _g.readOnly);
559
905
  const resolvedProps = (props2) => !props2 || Object.keys(props2).length === 0 ? void 0 : props2;
560
- return /* @__PURE__ */ jsx9(
906
+ return /* @__PURE__ */ jsx10(
561
907
  MuiTextField,
562
908
  __spreadProps(__spreadValues({}, rest), {
563
909
  onChange: (event) => {
564
910
  setCharCount(event.target.value.length);
565
911
  if (rest.onChange) rest.onChange(event);
566
912
  },
567
- helperText: helperText || /* @__PURE__ */ jsx9(Fragment4, {}),
913
+ helperText: helperText || /* @__PURE__ */ jsx10(Fragment5, {}),
568
914
  slots: { formHelperText: TextFieldFormHelperText },
569
915
  slotProps: {
570
- input: resolvedProps(__spreadValues(__spreadValues(__spreadValues({}, InputProps2), InputPropOverrides), (_d = rest.slotProps) == null ? void 0 : _d.input)),
916
+ input: resolvedProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, InputProps2), InputPropOverrides), (_h = rest.slotProps) == null ? void 0 : _h.input), {
917
+ readOnly: allReadOnly
918
+ })),
571
919
  htmlInput: resolvedProps(__spreadProps(__spreadValues(__spreadValues({
572
920
  "aria-required": required
573
- }, inputProps), (_e = rest.slotProps) == null ? void 0 : _e.htmlInput), {
921
+ }, inputProps), (_i = rest.slotProps) == null ? void 0 : _i.htmlInput), {
574
922
  maxLength: !displayOverflowMaxLength ? maxLength : void 0
575
923
  })),
576
- select: resolvedProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, SelectProps2), SelectPropOverrides), SelectAccessibilityOverrides(openDetected, setOpenDetected, SelectProps2 == null ? void 0 : SelectProps2.open)), (_f = rest.slotProps) == null ? void 0 : _f.select)),
924
+ select: resolvedProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, SelectProps2), SelectPropOverrides), SelectAccessibilityOverrides(openDetected, setOpenDetected, SelectProps2 == null ? void 0 : SelectProps2.open)), (_j = rest.slotProps) == null ? void 0 : _j.select)),
577
925
  inputLabel: resolvedProps(__spreadValues(__spreadValues({
578
926
  component: FormLabel,
579
927
  helpTopicId,
580
928
  required,
581
929
  shrink: true
582
- }, InputLabelProps), (_g = rest.slotProps) == null ? void 0 : _g.inputLabel)),
930
+ }, InputLabelProps), (_k = rest.slotProps) == null ? void 0 : _k.inputLabel)),
583
931
  formHelperText: resolvedProps(__spreadProps(__spreadValues(__spreadValues({
584
932
  component: "div"
585
- }, FormHelperTextProps2), (_h = rest.slotProps) == null ? void 0 : _h.formHelperText), {
933
+ }, FormHelperTextProps2), (_l = rest.slotProps) == null ? void 0 : _l.formHelperText), {
586
934
  charCount,
587
935
  helperText,
588
936
  maxLength,
589
- displayOverflowMaxLength,
590
937
  showCharacterCount
591
938
  }))
592
939
  },
@@ -596,7 +943,7 @@ var TextField = forwardRef((props, ref) => {
596
943
  });
597
944
 
598
945
  // src/lib/UploadProgressBar.tsx
599
- import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
946
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
600
947
  var ERROR_MAPPINGS = [
601
948
  {
602
949
  pattern: /but has an extension for/i,
@@ -645,24 +992,24 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
645
992
  upload.onProgress.push(handleOnProgress);
646
993
  upload.onSuccess.push(handleOnSuccess);
647
994
  upload.onError.push(handleOnError);
648
- return errorMessage ? /* @__PURE__ */ jsxs7(Box2, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
649
- /* @__PURE__ */ jsxs7(
995
+ return errorMessage ? /* @__PURE__ */ jsxs8(Box3, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
996
+ /* @__PURE__ */ jsxs8(
650
997
  ListItemText,
651
998
  {
652
999
  slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } },
653
1000
  sx: { wordWrap: "break-word" },
654
1001
  children: [
655
- /* @__PURE__ */ jsx10(WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
1002
+ /* @__PURE__ */ jsx11(WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
656
1003
  " ",
657
1004
  errorMessage
658
1005
  ]
659
1006
  }
660
1007
  ),
661
- upload.status === "encrypted" && /* @__PURE__ */ jsxs7("div", { className: "pwRequired", children: [
662
- /* @__PURE__ */ jsx10(Button2, { color: "secondary", size: "small", onClick: toggleModal, children: "Enter Password" }),
663
- /* @__PURE__ */ jsx10(Dialog, { open: modalOpen, onClose: toggleModal, children: /* @__PURE__ */ jsxs7("form", { onSubmit: verifyPassword, children: [
664
- /* @__PURE__ */ jsx10(DialogTitle, { children: "Enter Password" }),
665
- /* @__PURE__ */ jsx10(DialogContent, { children: /* @__PURE__ */ jsx10(
1008
+ upload.status === "encrypted" && /* @__PURE__ */ jsxs8("div", { className: "pwRequired", children: [
1009
+ /* @__PURE__ */ jsx11(Button2, { color: "secondary", size: "small", onClick: toggleModal, children: "Enter Password" }),
1010
+ /* @__PURE__ */ jsx11(Dialog, { open: modalOpen, onClose: toggleModal, children: /* @__PURE__ */ jsxs8("form", { onSubmit: verifyPassword, children: [
1011
+ /* @__PURE__ */ jsx11(DialogTitle, { children: "Enter Password" }),
1012
+ /* @__PURE__ */ jsx11(DialogContent, { children: /* @__PURE__ */ jsx11(
666
1013
  TextField,
667
1014
  {
668
1015
  type: showPassword ? "text" : "password",
@@ -671,70 +1018,1014 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
671
1018
  onChange: handlePasswordChange,
672
1019
  autoFocus: true,
673
1020
  InputProps: {
674
- endAdornment: /* @__PURE__ */ jsx10(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx10(
1021
+ endAdornment: /* @__PURE__ */ jsx11(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx11(
675
1022
  IconButton2,
676
1023
  {
677
1024
  title: "password visibility",
678
1025
  onClick: () => setShowPassword((prev) => !prev),
679
1026
  edge: "end",
680
- children: showPassword ? /* @__PURE__ */ jsx10(EyeIcon, { fontSize: "small" }) : /* @__PURE__ */ jsx10(EyeSlashIcon, { fontSize: "small" })
1027
+ children: showPassword ? /* @__PURE__ */ jsx11(EyeIcon, { fontSize: "small" }) : /* @__PURE__ */ jsx11(EyeSlashIcon, { fontSize: "small" })
681
1028
  }
682
1029
  ) })
683
1030
  }
684
1031
  }
685
1032
  ) }),
686
- /* @__PURE__ */ jsx10(DialogActions, { children: /* @__PURE__ */ jsx10(Button2, { color: "primary", type: "submit", children: "Ok" }) })
1033
+ /* @__PURE__ */ jsx11(DialogActions, { children: /* @__PURE__ */ jsx11(Button2, { color: "primary", type: "submit", children: "Ok" }) })
687
1034
  ] }) })
688
1035
  ] })
689
- ] }) : /* @__PURE__ */ jsx10(LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
1036
+ ] }) : /* @__PURE__ */ jsx11(LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
690
1037
  };
691
1038
 
692
- // src/lib/useUploadCore.tsx
693
- import { useQuery } from "@tanstack/react-query";
694
- import Upload from "@availity/upload-core";
695
- function startUpload(file, options) {
696
- return __async(this, null, function* () {
697
- const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
698
- const upload = new Upload(file, uploadOptions);
699
- yield upload.generateId();
700
- if (onSuccess) upload.onSuccess.push(onSuccess);
701
- if (onError) upload.onError.push(onError);
702
- if (onProgress) upload.onProgress.push(onProgress);
703
- if (onChunkComplete) upload.onChunkComplete.push(onChunkComplete);
704
- upload.start();
705
- return upload;
1039
+ // ../../node_modules/@tanstack/query-core/build/lib/subscribable.mjs
1040
+ var Subscribable = class {
1041
+ constructor() {
1042
+ this.listeners = /* @__PURE__ */ new Set();
1043
+ this.subscribe = this.subscribe.bind(this);
1044
+ }
1045
+ subscribe(listener) {
1046
+ const identity = {
1047
+ listener
1048
+ };
1049
+ this.listeners.add(identity);
1050
+ this.onSubscribe();
1051
+ return () => {
1052
+ this.listeners.delete(identity);
1053
+ this.onUnsubscribe();
1054
+ };
1055
+ }
1056
+ hasListeners() {
1057
+ return this.listeners.size > 0;
1058
+ }
1059
+ onSubscribe() {
1060
+ }
1061
+ onUnsubscribe() {
1062
+ }
1063
+ };
1064
+
1065
+ // ../../node_modules/@tanstack/query-core/build/lib/utils.mjs
1066
+ var isServer = typeof window === "undefined" || "Deno" in window;
1067
+ function noop() {
1068
+ return void 0;
1069
+ }
1070
+ function isValidTimeout(value) {
1071
+ return typeof value === "number" && value >= 0 && value !== Infinity;
1072
+ }
1073
+ function timeUntilStale(updatedAt, staleTime) {
1074
+ return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
1075
+ }
1076
+ function parseQueryArgs(arg1, arg2, arg3) {
1077
+ if (!isQueryKey(arg1)) {
1078
+ return arg1;
1079
+ }
1080
+ if (typeof arg2 === "function") {
1081
+ return __spreadProps(__spreadValues({}, arg3), {
1082
+ queryKey: arg1,
1083
+ queryFn: arg2
1084
+ });
1085
+ }
1086
+ return __spreadProps(__spreadValues({}, arg2), {
1087
+ queryKey: arg1
706
1088
  });
707
1089
  }
708
- function useUploadCore(file, options, queryOptions) {
709
- const isQueryEnabled = !!file;
710
- return useQuery(__spreadValues({
711
- queryKey: ["upload", file.name, options],
712
- queryFn: () => startUpload(file, options),
713
- enabled: isQueryEnabled,
714
- retry: false,
715
- refetchOnWindowFocus: false
716
- }, queryOptions));
1090
+ function replaceEqualDeep(a, b) {
1091
+ if (a === b) {
1092
+ return a;
1093
+ }
1094
+ const array = isPlainArray(a) && isPlainArray(b);
1095
+ if (array || isPlainObject(a) && isPlainObject(b)) {
1096
+ const aSize = array ? a.length : Object.keys(a).length;
1097
+ const bItems = array ? b : Object.keys(b);
1098
+ const bSize = bItems.length;
1099
+ const copy = array ? [] : {};
1100
+ let equalItems = 0;
1101
+ for (let i = 0; i < bSize; i++) {
1102
+ const key = array ? i : bItems[i];
1103
+ copy[key] = replaceEqualDeep(a[key], b[key]);
1104
+ if (copy[key] === a[key]) {
1105
+ equalItems++;
1106
+ }
1107
+ }
1108
+ return aSize === bSize && equalItems === aSize ? a : copy;
1109
+ }
1110
+ return b;
717
1111
  }
718
-
719
- // src/lib/FileList.tsx
720
- import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
721
- var FileRow = ({
722
- file,
723
- options,
724
- onRemoveFile,
725
- queryOptions,
726
- customFileRow: CustomRow,
727
- disableRemove = false
728
- }) => {
729
- const Icon = getFileExtIcon(file.name);
1112
+ function shallowEqualObjects(a, b) {
1113
+ if (a && !b || b && !a) {
1114
+ return false;
1115
+ }
1116
+ for (const key in a) {
1117
+ if (a[key] !== b[key]) {
1118
+ return false;
1119
+ }
1120
+ }
1121
+ return true;
1122
+ }
1123
+ function isPlainArray(value) {
1124
+ return Array.isArray(value) && value.length === Object.keys(value).length;
1125
+ }
1126
+ function isPlainObject(o) {
1127
+ if (!hasObjectPrototype(o)) {
1128
+ return false;
1129
+ }
1130
+ const ctor = o.constructor;
1131
+ if (typeof ctor === "undefined") {
1132
+ return true;
1133
+ }
1134
+ const prot = ctor.prototype;
1135
+ if (!hasObjectPrototype(prot)) {
1136
+ return false;
1137
+ }
1138
+ if (!prot.hasOwnProperty("isPrototypeOf")) {
1139
+ return false;
1140
+ }
1141
+ return true;
1142
+ }
1143
+ function hasObjectPrototype(o) {
1144
+ return Object.prototype.toString.call(o) === "[object Object]";
1145
+ }
1146
+ function isQueryKey(value) {
1147
+ return Array.isArray(value);
1148
+ }
1149
+ function sleep(timeout) {
1150
+ return new Promise((resolve) => {
1151
+ setTimeout(resolve, timeout);
1152
+ });
1153
+ }
1154
+ function scheduleMicrotask(callback) {
1155
+ sleep(0).then(callback);
1156
+ }
1157
+ function replaceData(prevData, data, options) {
1158
+ if (options.isDataEqual != null && options.isDataEqual(prevData, data)) {
1159
+ return prevData;
1160
+ } else if (typeof options.structuralSharing === "function") {
1161
+ return options.structuralSharing(prevData, data);
1162
+ } else if (options.structuralSharing !== false) {
1163
+ return replaceEqualDeep(prevData, data);
1164
+ }
1165
+ return data;
1166
+ }
1167
+
1168
+ // ../../node_modules/@tanstack/query-core/build/lib/focusManager.mjs
1169
+ var FocusManager = class extends Subscribable {
1170
+ constructor() {
1171
+ super();
1172
+ this.setup = (onFocus) => {
1173
+ if (!isServer && window.addEventListener) {
1174
+ const listener = () => onFocus();
1175
+ window.addEventListener("visibilitychange", listener, false);
1176
+ window.addEventListener("focus", listener, false);
1177
+ return () => {
1178
+ window.removeEventListener("visibilitychange", listener);
1179
+ window.removeEventListener("focus", listener);
1180
+ };
1181
+ }
1182
+ return;
1183
+ };
1184
+ }
1185
+ onSubscribe() {
1186
+ if (!this.cleanup) {
1187
+ this.setEventListener(this.setup);
1188
+ }
1189
+ }
1190
+ onUnsubscribe() {
1191
+ if (!this.hasListeners()) {
1192
+ var _this$cleanup;
1193
+ (_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
1194
+ this.cleanup = void 0;
1195
+ }
1196
+ }
1197
+ setEventListener(setup) {
1198
+ var _this$cleanup2;
1199
+ this.setup = setup;
1200
+ (_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
1201
+ this.cleanup = setup((focused) => {
1202
+ if (typeof focused === "boolean") {
1203
+ this.setFocused(focused);
1204
+ } else {
1205
+ this.onFocus();
1206
+ }
1207
+ });
1208
+ }
1209
+ setFocused(focused) {
1210
+ const changed = this.focused !== focused;
1211
+ if (changed) {
1212
+ this.focused = focused;
1213
+ this.onFocus();
1214
+ }
1215
+ }
1216
+ onFocus() {
1217
+ this.listeners.forEach(({
1218
+ listener
1219
+ }) => {
1220
+ listener();
1221
+ });
1222
+ }
1223
+ isFocused() {
1224
+ if (typeof this.focused === "boolean") {
1225
+ return this.focused;
1226
+ }
1227
+ if (typeof document === "undefined") {
1228
+ return true;
1229
+ }
1230
+ return [void 0, "visible", "prerender"].includes(document.visibilityState);
1231
+ }
1232
+ };
1233
+ var focusManager = new FocusManager();
1234
+
1235
+ // ../../node_modules/@tanstack/query-core/build/lib/onlineManager.mjs
1236
+ var onlineEvents = ["online", "offline"];
1237
+ var OnlineManager = class extends Subscribable {
1238
+ constructor() {
1239
+ super();
1240
+ this.setup = (onOnline) => {
1241
+ if (!isServer && window.addEventListener) {
1242
+ const listener = () => onOnline();
1243
+ onlineEvents.forEach((event) => {
1244
+ window.addEventListener(event, listener, false);
1245
+ });
1246
+ return () => {
1247
+ onlineEvents.forEach((event) => {
1248
+ window.removeEventListener(event, listener);
1249
+ });
1250
+ };
1251
+ }
1252
+ return;
1253
+ };
1254
+ }
1255
+ onSubscribe() {
1256
+ if (!this.cleanup) {
1257
+ this.setEventListener(this.setup);
1258
+ }
1259
+ }
1260
+ onUnsubscribe() {
1261
+ if (!this.hasListeners()) {
1262
+ var _this$cleanup;
1263
+ (_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
1264
+ this.cleanup = void 0;
1265
+ }
1266
+ }
1267
+ setEventListener(setup) {
1268
+ var _this$cleanup2;
1269
+ this.setup = setup;
1270
+ (_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
1271
+ this.cleanup = setup((online) => {
1272
+ if (typeof online === "boolean") {
1273
+ this.setOnline(online);
1274
+ } else {
1275
+ this.onOnline();
1276
+ }
1277
+ });
1278
+ }
1279
+ setOnline(online) {
1280
+ const changed = this.online !== online;
1281
+ if (changed) {
1282
+ this.online = online;
1283
+ this.onOnline();
1284
+ }
1285
+ }
1286
+ onOnline() {
1287
+ this.listeners.forEach(({
1288
+ listener
1289
+ }) => {
1290
+ listener();
1291
+ });
1292
+ }
1293
+ isOnline() {
1294
+ if (typeof this.online === "boolean") {
1295
+ return this.online;
1296
+ }
1297
+ if (typeof navigator === "undefined" || typeof navigator.onLine === "undefined") {
1298
+ return true;
1299
+ }
1300
+ return navigator.onLine;
1301
+ }
1302
+ };
1303
+ var onlineManager = new OnlineManager();
1304
+
1305
+ // ../../node_modules/@tanstack/query-core/build/lib/retryer.mjs
1306
+ function canFetch(networkMode) {
1307
+ return (networkMode != null ? networkMode : "online") === "online" ? onlineManager.isOnline() : true;
1308
+ }
1309
+ var CancelledError = class {
1310
+ constructor(options) {
1311
+ this.revert = options == null ? void 0 : options.revert;
1312
+ this.silent = options == null ? void 0 : options.silent;
1313
+ }
1314
+ };
1315
+ function isCancelledError(value) {
1316
+ return value instanceof CancelledError;
1317
+ }
1318
+
1319
+ // ../../node_modules/@tanstack/query-core/build/lib/notifyManager.mjs
1320
+ function createNotifyManager() {
1321
+ let queue = [];
1322
+ let transactions = 0;
1323
+ let notifyFn = (callback) => {
1324
+ callback();
1325
+ };
1326
+ let batchNotifyFn = (callback) => {
1327
+ callback();
1328
+ };
1329
+ const batch = (callback) => {
1330
+ let result;
1331
+ transactions++;
1332
+ try {
1333
+ result = callback();
1334
+ } finally {
1335
+ transactions--;
1336
+ if (!transactions) {
1337
+ flush();
1338
+ }
1339
+ }
1340
+ return result;
1341
+ };
1342
+ const schedule = (callback) => {
1343
+ if (transactions) {
1344
+ queue.push(callback);
1345
+ } else {
1346
+ scheduleMicrotask(() => {
1347
+ notifyFn(callback);
1348
+ });
1349
+ }
1350
+ };
1351
+ const batchCalls = (callback) => {
1352
+ return (...args) => {
1353
+ schedule(() => {
1354
+ callback(...args);
1355
+ });
1356
+ };
1357
+ };
1358
+ const flush = () => {
1359
+ const originalQueue = queue;
1360
+ queue = [];
1361
+ if (originalQueue.length) {
1362
+ scheduleMicrotask(() => {
1363
+ batchNotifyFn(() => {
1364
+ originalQueue.forEach((callback) => {
1365
+ notifyFn(callback);
1366
+ });
1367
+ });
1368
+ });
1369
+ }
1370
+ };
1371
+ const setNotifyFunction = (fn) => {
1372
+ notifyFn = fn;
1373
+ };
1374
+ const setBatchNotifyFunction = (fn) => {
1375
+ batchNotifyFn = fn;
1376
+ };
1377
+ return {
1378
+ batch,
1379
+ batchCalls,
1380
+ schedule,
1381
+ setNotifyFunction,
1382
+ setBatchNotifyFunction
1383
+ };
1384
+ }
1385
+ var notifyManager = createNotifyManager();
1386
+
1387
+ // ../../node_modules/@tanstack/query-core/build/lib/queryObserver.mjs
1388
+ var QueryObserver = class extends Subscribable {
1389
+ constructor(client, options) {
1390
+ super();
1391
+ this.client = client;
1392
+ this.options = options;
1393
+ this.trackedProps = /* @__PURE__ */ new Set();
1394
+ this.selectError = null;
1395
+ this.bindMethods();
1396
+ this.setOptions(options);
1397
+ }
1398
+ bindMethods() {
1399
+ this.remove = this.remove.bind(this);
1400
+ this.refetch = this.refetch.bind(this);
1401
+ }
1402
+ onSubscribe() {
1403
+ if (this.listeners.size === 1) {
1404
+ this.currentQuery.addObserver(this);
1405
+ if (shouldFetchOnMount(this.currentQuery, this.options)) {
1406
+ this.executeFetch();
1407
+ }
1408
+ this.updateTimers();
1409
+ }
1410
+ }
1411
+ onUnsubscribe() {
1412
+ if (!this.hasListeners()) {
1413
+ this.destroy();
1414
+ }
1415
+ }
1416
+ shouldFetchOnReconnect() {
1417
+ return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnReconnect);
1418
+ }
1419
+ shouldFetchOnWindowFocus() {
1420
+ return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnWindowFocus);
1421
+ }
1422
+ destroy() {
1423
+ this.listeners = /* @__PURE__ */ new Set();
1424
+ this.clearStaleTimeout();
1425
+ this.clearRefetchInterval();
1426
+ this.currentQuery.removeObserver(this);
1427
+ }
1428
+ setOptions(options, notifyOptions) {
1429
+ const prevOptions = this.options;
1430
+ const prevQuery = this.currentQuery;
1431
+ this.options = this.client.defaultQueryOptions(options);
1432
+ if (process.env.NODE_ENV !== "production" && typeof (options == null ? void 0 : options.isDataEqual) !== "undefined") {
1433
+ this.client.getLogger().error("The isDataEqual option has been deprecated and will be removed in the next major version. You can achieve the same functionality by passing a function as the structuralSharing option");
1434
+ }
1435
+ if (!shallowEqualObjects(prevOptions, this.options)) {
1436
+ this.client.getQueryCache().notify({
1437
+ type: "observerOptionsUpdated",
1438
+ query: this.currentQuery,
1439
+ observer: this
1440
+ });
1441
+ }
1442
+ if (typeof this.options.enabled !== "undefined" && typeof this.options.enabled !== "boolean") {
1443
+ throw new Error("Expected enabled to be a boolean");
1444
+ }
1445
+ if (!this.options.queryKey) {
1446
+ this.options.queryKey = prevOptions.queryKey;
1447
+ }
1448
+ this.updateQuery();
1449
+ const mounted = this.hasListeners();
1450
+ if (mounted && shouldFetchOptionally(this.currentQuery, prevQuery, this.options, prevOptions)) {
1451
+ this.executeFetch();
1452
+ }
1453
+ this.updateResult(notifyOptions);
1454
+ if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
1455
+ this.updateStaleTimeout();
1456
+ }
1457
+ const nextRefetchInterval = this.computeRefetchInterval();
1458
+ if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.currentRefetchInterval)) {
1459
+ this.updateRefetchInterval(nextRefetchInterval);
1460
+ }
1461
+ }
1462
+ getOptimisticResult(options) {
1463
+ const query = this.client.getQueryCache().build(this.client, options);
1464
+ const result = this.createResult(query, options);
1465
+ if (shouldAssignObserverCurrentProperties(this, result, options)) {
1466
+ this.currentResult = result;
1467
+ this.currentResultOptions = this.options;
1468
+ this.currentResultState = this.currentQuery.state;
1469
+ }
1470
+ return result;
1471
+ }
1472
+ getCurrentResult() {
1473
+ return this.currentResult;
1474
+ }
1475
+ trackResult(result) {
1476
+ const trackedResult = {};
1477
+ Object.keys(result).forEach((key) => {
1478
+ Object.defineProperty(trackedResult, key, {
1479
+ configurable: false,
1480
+ enumerable: true,
1481
+ get: () => {
1482
+ this.trackedProps.add(key);
1483
+ return result[key];
1484
+ }
1485
+ });
1486
+ });
1487
+ return trackedResult;
1488
+ }
1489
+ getCurrentQuery() {
1490
+ return this.currentQuery;
1491
+ }
1492
+ remove() {
1493
+ this.client.getQueryCache().remove(this.currentQuery);
1494
+ }
1495
+ refetch(_a = {}) {
1496
+ var _b = _a, {
1497
+ refetchPage
1498
+ } = _b, options = __objRest(_b, [
1499
+ "refetchPage"
1500
+ ]);
1501
+ return this.fetch(__spreadProps(__spreadValues({}, options), {
1502
+ meta: {
1503
+ refetchPage
1504
+ }
1505
+ }));
1506
+ }
1507
+ fetchOptimistic(options) {
1508
+ const defaultedOptions = this.client.defaultQueryOptions(options);
1509
+ const query = this.client.getQueryCache().build(this.client, defaultedOptions);
1510
+ query.isFetchingOptimistic = true;
1511
+ return query.fetch().then(() => this.createResult(query, defaultedOptions));
1512
+ }
1513
+ fetch(fetchOptions) {
1514
+ var _fetchOptions$cancelR;
1515
+ return this.executeFetch(__spreadProps(__spreadValues({}, fetchOptions), {
1516
+ cancelRefetch: (_fetchOptions$cancelR = fetchOptions.cancelRefetch) != null ? _fetchOptions$cancelR : true
1517
+ })).then(() => {
1518
+ this.updateResult();
1519
+ return this.currentResult;
1520
+ });
1521
+ }
1522
+ executeFetch(fetchOptions) {
1523
+ this.updateQuery();
1524
+ let promise = this.currentQuery.fetch(this.options, fetchOptions);
1525
+ if (!(fetchOptions != null && fetchOptions.throwOnError)) {
1526
+ promise = promise.catch(noop);
1527
+ }
1528
+ return promise;
1529
+ }
1530
+ updateStaleTimeout() {
1531
+ this.clearStaleTimeout();
1532
+ if (isServer || this.currentResult.isStale || !isValidTimeout(this.options.staleTime)) {
1533
+ return;
1534
+ }
1535
+ const time = timeUntilStale(this.currentResult.dataUpdatedAt, this.options.staleTime);
1536
+ const timeout = time + 1;
1537
+ this.staleTimeoutId = setTimeout(() => {
1538
+ if (!this.currentResult.isStale) {
1539
+ this.updateResult();
1540
+ }
1541
+ }, timeout);
1542
+ }
1543
+ computeRefetchInterval() {
1544
+ var _this$options$refetch;
1545
+ return typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.currentResult.data, this.currentQuery) : (_this$options$refetch = this.options.refetchInterval) != null ? _this$options$refetch : false;
1546
+ }
1547
+ updateRefetchInterval(nextInterval) {
1548
+ this.clearRefetchInterval();
1549
+ this.currentRefetchInterval = nextInterval;
1550
+ if (isServer || this.options.enabled === false || !isValidTimeout(this.currentRefetchInterval) || this.currentRefetchInterval === 0) {
1551
+ return;
1552
+ }
1553
+ this.refetchIntervalId = setInterval(() => {
1554
+ if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
1555
+ this.executeFetch();
1556
+ }
1557
+ }, this.currentRefetchInterval);
1558
+ }
1559
+ updateTimers() {
1560
+ this.updateStaleTimeout();
1561
+ this.updateRefetchInterval(this.computeRefetchInterval());
1562
+ }
1563
+ clearStaleTimeout() {
1564
+ if (this.staleTimeoutId) {
1565
+ clearTimeout(this.staleTimeoutId);
1566
+ this.staleTimeoutId = void 0;
1567
+ }
1568
+ }
1569
+ clearRefetchInterval() {
1570
+ if (this.refetchIntervalId) {
1571
+ clearInterval(this.refetchIntervalId);
1572
+ this.refetchIntervalId = void 0;
1573
+ }
1574
+ }
1575
+ createResult(query, options) {
1576
+ const prevQuery = this.currentQuery;
1577
+ const prevOptions = this.options;
1578
+ const prevResult = this.currentResult;
1579
+ const prevResultState = this.currentResultState;
1580
+ const prevResultOptions = this.currentResultOptions;
1581
+ const queryChange = query !== prevQuery;
1582
+ const queryInitialState = queryChange ? query.state : this.currentQueryInitialState;
1583
+ const prevQueryResult = queryChange ? this.currentResult : this.previousQueryResult;
1584
+ const {
1585
+ state
1586
+ } = query;
1587
+ let {
1588
+ dataUpdatedAt,
1589
+ error,
1590
+ errorUpdatedAt,
1591
+ fetchStatus,
1592
+ status
1593
+ } = state;
1594
+ let isPreviousData = false;
1595
+ let isPlaceholderData = false;
1596
+ let data;
1597
+ if (options._optimisticResults) {
1598
+ const mounted = this.hasListeners();
1599
+ const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
1600
+ const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
1601
+ if (fetchOnMount || fetchOptionally) {
1602
+ fetchStatus = canFetch(query.options.networkMode) ? "fetching" : "paused";
1603
+ if (!dataUpdatedAt) {
1604
+ status = "loading";
1605
+ }
1606
+ }
1607
+ if (options._optimisticResults === "isRestoring") {
1608
+ fetchStatus = "idle";
1609
+ }
1610
+ }
1611
+ if (options.keepPreviousData && !state.dataUpdatedAt && prevQueryResult != null && prevQueryResult.isSuccess && status !== "error") {
1612
+ data = prevQueryResult.data;
1613
+ dataUpdatedAt = prevQueryResult.dataUpdatedAt;
1614
+ status = prevQueryResult.status;
1615
+ isPreviousData = true;
1616
+ } else if (options.select && typeof state.data !== "undefined") {
1617
+ if (prevResult && state.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === this.selectFn) {
1618
+ data = this.selectResult;
1619
+ } else {
1620
+ try {
1621
+ this.selectFn = options.select;
1622
+ data = options.select(state.data);
1623
+ data = replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
1624
+ this.selectResult = data;
1625
+ this.selectError = null;
1626
+ } catch (selectError) {
1627
+ if (process.env.NODE_ENV !== "production") {
1628
+ this.client.getLogger().error(selectError);
1629
+ }
1630
+ this.selectError = selectError;
1631
+ }
1632
+ }
1633
+ } else {
1634
+ data = state.data;
1635
+ }
1636
+ if (typeof options.placeholderData !== "undefined" && typeof data === "undefined" && status === "loading") {
1637
+ let placeholderData;
1638
+ if (prevResult != null && prevResult.isPlaceholderData && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
1639
+ placeholderData = prevResult.data;
1640
+ } else {
1641
+ placeholderData = typeof options.placeholderData === "function" ? options.placeholderData() : options.placeholderData;
1642
+ if (options.select && typeof placeholderData !== "undefined") {
1643
+ try {
1644
+ placeholderData = options.select(placeholderData);
1645
+ this.selectError = null;
1646
+ } catch (selectError) {
1647
+ if (process.env.NODE_ENV !== "production") {
1648
+ this.client.getLogger().error(selectError);
1649
+ }
1650
+ this.selectError = selectError;
1651
+ }
1652
+ }
1653
+ }
1654
+ if (typeof placeholderData !== "undefined") {
1655
+ status = "success";
1656
+ data = replaceData(prevResult == null ? void 0 : prevResult.data, placeholderData, options);
1657
+ isPlaceholderData = true;
1658
+ }
1659
+ }
1660
+ if (this.selectError) {
1661
+ error = this.selectError;
1662
+ data = this.selectResult;
1663
+ errorUpdatedAt = Date.now();
1664
+ status = "error";
1665
+ }
1666
+ const isFetching = fetchStatus === "fetching";
1667
+ const isLoading = status === "loading";
1668
+ const isError2 = status === "error";
1669
+ const result = {
1670
+ status,
1671
+ fetchStatus,
1672
+ isLoading,
1673
+ isSuccess: status === "success",
1674
+ isError: isError2,
1675
+ isInitialLoading: isLoading && isFetching,
1676
+ data,
1677
+ dataUpdatedAt,
1678
+ error,
1679
+ errorUpdatedAt,
1680
+ failureCount: state.fetchFailureCount,
1681
+ failureReason: state.fetchFailureReason,
1682
+ errorUpdateCount: state.errorUpdateCount,
1683
+ isFetched: state.dataUpdateCount > 0 || state.errorUpdateCount > 0,
1684
+ isFetchedAfterMount: state.dataUpdateCount > queryInitialState.dataUpdateCount || state.errorUpdateCount > queryInitialState.errorUpdateCount,
1685
+ isFetching,
1686
+ isRefetching: isFetching && !isLoading,
1687
+ isLoadingError: isError2 && state.dataUpdatedAt === 0,
1688
+ isPaused: fetchStatus === "paused",
1689
+ isPlaceholderData,
1690
+ isPreviousData,
1691
+ isRefetchError: isError2 && state.dataUpdatedAt !== 0,
1692
+ isStale: isStale(query, options),
1693
+ refetch: this.refetch,
1694
+ remove: this.remove
1695
+ };
1696
+ return result;
1697
+ }
1698
+ updateResult(notifyOptions) {
1699
+ const prevResult = this.currentResult;
1700
+ const nextResult = this.createResult(this.currentQuery, this.options);
1701
+ this.currentResultState = this.currentQuery.state;
1702
+ this.currentResultOptions = this.options;
1703
+ if (shallowEqualObjects(nextResult, prevResult)) {
1704
+ return;
1705
+ }
1706
+ this.currentResult = nextResult;
1707
+ const defaultNotifyOptions = {
1708
+ cache: true
1709
+ };
1710
+ const shouldNotifyListeners = () => {
1711
+ if (!prevResult) {
1712
+ return true;
1713
+ }
1714
+ const {
1715
+ notifyOnChangeProps
1716
+ } = this.options;
1717
+ const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
1718
+ if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.trackedProps.size) {
1719
+ return true;
1720
+ }
1721
+ const includedProps = new Set(notifyOnChangePropsValue != null ? notifyOnChangePropsValue : this.trackedProps);
1722
+ if (this.options.useErrorBoundary) {
1723
+ includedProps.add("error");
1724
+ }
1725
+ return Object.keys(this.currentResult).some((key) => {
1726
+ const typedKey = key;
1727
+ const changed = this.currentResult[typedKey] !== prevResult[typedKey];
1728
+ return changed && includedProps.has(typedKey);
1729
+ });
1730
+ };
1731
+ if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && shouldNotifyListeners()) {
1732
+ defaultNotifyOptions.listeners = true;
1733
+ }
1734
+ this.notify(__spreadValues(__spreadValues({}, defaultNotifyOptions), notifyOptions));
1735
+ }
1736
+ updateQuery() {
1737
+ const query = this.client.getQueryCache().build(this.client, this.options);
1738
+ if (query === this.currentQuery) {
1739
+ return;
1740
+ }
1741
+ const prevQuery = this.currentQuery;
1742
+ this.currentQuery = query;
1743
+ this.currentQueryInitialState = query.state;
1744
+ this.previousQueryResult = this.currentResult;
1745
+ if (this.hasListeners()) {
1746
+ prevQuery == null ? void 0 : prevQuery.removeObserver(this);
1747
+ query.addObserver(this);
1748
+ }
1749
+ }
1750
+ onQueryUpdate(action) {
1751
+ const notifyOptions = {};
1752
+ if (action.type === "success") {
1753
+ notifyOptions.onSuccess = !action.manual;
1754
+ } else if (action.type === "error" && !isCancelledError(action.error)) {
1755
+ notifyOptions.onError = true;
1756
+ }
1757
+ this.updateResult(notifyOptions);
1758
+ if (this.hasListeners()) {
1759
+ this.updateTimers();
1760
+ }
1761
+ }
1762
+ notify(notifyOptions) {
1763
+ notifyManager.batch(() => {
1764
+ if (notifyOptions.onSuccess) {
1765
+ var _this$options$onSucce, _this$options, _this$options$onSettl, _this$options2;
1766
+ (_this$options$onSucce = (_this$options = this.options).onSuccess) == null ? void 0 : _this$options$onSucce.call(_this$options, this.currentResult.data);
1767
+ (_this$options$onSettl = (_this$options2 = this.options).onSettled) == null ? void 0 : _this$options$onSettl.call(_this$options2, this.currentResult.data, null);
1768
+ } else if (notifyOptions.onError) {
1769
+ var _this$options$onError, _this$options3, _this$options$onSettl2, _this$options4;
1770
+ (_this$options$onError = (_this$options3 = this.options).onError) == null ? void 0 : _this$options$onError.call(_this$options3, this.currentResult.error);
1771
+ (_this$options$onSettl2 = (_this$options4 = this.options).onSettled) == null ? void 0 : _this$options$onSettl2.call(_this$options4, void 0, this.currentResult.error);
1772
+ }
1773
+ if (notifyOptions.listeners) {
1774
+ this.listeners.forEach(({
1775
+ listener
1776
+ }) => {
1777
+ listener(this.currentResult);
1778
+ });
1779
+ }
1780
+ if (notifyOptions.cache) {
1781
+ this.client.getQueryCache().notify({
1782
+ query: this.currentQuery,
1783
+ type: "observerResultsUpdated"
1784
+ });
1785
+ }
1786
+ });
1787
+ }
1788
+ };
1789
+ function shouldLoadOnMount(query, options) {
1790
+ return options.enabled !== false && !query.state.dataUpdatedAt && !(query.state.status === "error" && options.retryOnMount === false);
1791
+ }
1792
+ function shouldFetchOnMount(query, options) {
1793
+ return shouldLoadOnMount(query, options) || query.state.dataUpdatedAt > 0 && shouldFetchOn(query, options, options.refetchOnMount);
1794
+ }
1795
+ function shouldFetchOn(query, options, field) {
1796
+ if (options.enabled !== false) {
1797
+ const value = typeof field === "function" ? field(query) : field;
1798
+ return value === "always" || value !== false && isStale(query, options);
1799
+ }
1800
+ return false;
1801
+ }
1802
+ function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
1803
+ return options.enabled !== false && (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
1804
+ }
1805
+ function isStale(query, options) {
1806
+ return query.isStaleByTime(options.staleTime);
1807
+ }
1808
+ function shouldAssignObserverCurrentProperties(observer, optimisticResult, options) {
1809
+ if (options.keepPreviousData) {
1810
+ return false;
1811
+ }
1812
+ if (options.placeholderData !== void 0) {
1813
+ return optimisticResult.isPlaceholderData;
1814
+ }
1815
+ if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
1816
+ return true;
1817
+ }
1818
+ return false;
1819
+ }
1820
+
1821
+ // ../../node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.mjs
1822
+ var import_shim = __toESM(require_shim(), 1);
1823
+ var useSyncExternalStore = import_shim.useSyncExternalStore;
1824
+
1825
+ // ../../node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs
1826
+ import * as React from "react";
1827
+ var defaultContext = /* @__PURE__ */ React.createContext(void 0);
1828
+ var QueryClientSharingContext = /* @__PURE__ */ React.createContext(false);
1829
+ function getQueryClientContext(context, contextSharing) {
1830
+ if (context) {
1831
+ return context;
1832
+ }
1833
+ if (contextSharing && typeof window !== "undefined") {
1834
+ if (!window.ReactQueryClientContext) {
1835
+ window.ReactQueryClientContext = defaultContext;
1836
+ }
1837
+ return window.ReactQueryClientContext;
1838
+ }
1839
+ return defaultContext;
1840
+ }
1841
+ var useQueryClient = ({
1842
+ context
1843
+ } = {}) => {
1844
+ const queryClient = React.useContext(getQueryClientContext(context, React.useContext(QueryClientSharingContext)));
1845
+ if (!queryClient) {
1846
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
1847
+ }
1848
+ return queryClient;
1849
+ };
1850
+
1851
+ // ../../node_modules/@tanstack/react-query/build/lib/isRestoring.mjs
1852
+ import * as React2 from "react";
1853
+ var IsRestoringContext = /* @__PURE__ */ React2.createContext(false);
1854
+ var useIsRestoring = () => React2.useContext(IsRestoringContext);
1855
+ var IsRestoringProvider = IsRestoringContext.Provider;
1856
+
1857
+ // ../../node_modules/@tanstack/react-query/build/lib/QueryErrorResetBoundary.mjs
1858
+ import * as React3 from "react";
1859
+ function createValue() {
1860
+ let isReset = false;
1861
+ return {
1862
+ clearReset: () => {
1863
+ isReset = false;
1864
+ },
1865
+ reset: () => {
1866
+ isReset = true;
1867
+ },
1868
+ isReset: () => {
1869
+ return isReset;
1870
+ }
1871
+ };
1872
+ }
1873
+ var QueryErrorResetBoundaryContext = /* @__PURE__ */ React3.createContext(createValue());
1874
+ var useQueryErrorResetBoundary = () => React3.useContext(QueryErrorResetBoundaryContext);
1875
+
1876
+ // ../../node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.mjs
1877
+ import * as React4 from "react";
1878
+
1879
+ // ../../node_modules/@tanstack/react-query/build/lib/utils.mjs
1880
+ function shouldThrowError(_useErrorBoundary, params) {
1881
+ if (typeof _useErrorBoundary === "function") {
1882
+ return _useErrorBoundary(...params);
1883
+ }
1884
+ return !!_useErrorBoundary;
1885
+ }
1886
+
1887
+ // ../../node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.mjs
1888
+ var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
1889
+ if (options.suspense || options.useErrorBoundary) {
1890
+ if (!errorResetBoundary.isReset()) {
1891
+ options.retryOnMount = false;
1892
+ }
1893
+ }
1894
+ };
1895
+ var useClearResetErrorBoundary = (errorResetBoundary) => {
1896
+ React4.useEffect(() => {
1897
+ errorResetBoundary.clearReset();
1898
+ }, [errorResetBoundary]);
1899
+ };
1900
+ var getHasError = ({
1901
+ result,
1902
+ errorResetBoundary,
1903
+ useErrorBoundary,
1904
+ query
1905
+ }) => {
1906
+ return result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(useErrorBoundary, [result.error, query]);
1907
+ };
1908
+
1909
+ // ../../node_modules/@tanstack/react-query/build/lib/suspense.mjs
1910
+ var ensureStaleTime = (defaultedOptions) => {
1911
+ if (defaultedOptions.suspense) {
1912
+ if (typeof defaultedOptions.staleTime !== "number") {
1913
+ defaultedOptions.staleTime = 1e3;
1914
+ }
1915
+ }
1916
+ };
1917
+ var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
1918
+ var shouldSuspend = (defaultedOptions, result, isRestoring) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && willFetch(result, isRestoring);
1919
+ var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).then(({
1920
+ data
1921
+ }) => {
1922
+ defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
1923
+ defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
1924
+ }).catch((error) => {
1925
+ errorResetBoundary.clearReset();
1926
+ defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
1927
+ defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(void 0, error);
1928
+ });
1929
+
1930
+ // ../../node_modules/@tanstack/react-query/build/lib/useBaseQuery.mjs
1931
+ import * as React5 from "react";
1932
+ function useBaseQuery(options, Observer) {
1933
+ const queryClient = useQueryClient({
1934
+ context: options.context
1935
+ });
1936
+ const isRestoring = useIsRestoring();
1937
+ const errorResetBoundary = useQueryErrorResetBoundary();
1938
+ const defaultedOptions = queryClient.defaultQueryOptions(options);
1939
+ defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
1940
+ if (defaultedOptions.onError) {
1941
+ defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
1942
+ }
1943
+ if (defaultedOptions.onSuccess) {
1944
+ defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
1945
+ }
1946
+ if (defaultedOptions.onSettled) {
1947
+ defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
1948
+ }
1949
+ ensureStaleTime(defaultedOptions);
1950
+ ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
1951
+ useClearResetErrorBoundary(errorResetBoundary);
1952
+ const [observer] = React5.useState(() => new Observer(queryClient, defaultedOptions));
1953
+ const result = observer.getOptimisticResult(defaultedOptions);
1954
+ useSyncExternalStore(React5.useCallback((onStoreChange) => {
1955
+ const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
1956
+ observer.updateResult();
1957
+ return unsubscribe;
1958
+ }, [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
1959
+ React5.useEffect(() => {
1960
+ observer.setOptions(defaultedOptions, {
1961
+ listeners: false
1962
+ });
1963
+ }, [defaultedOptions, observer]);
1964
+ if (shouldSuspend(defaultedOptions, result, isRestoring)) {
1965
+ throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
1966
+ }
1967
+ if (getHasError({
1968
+ result,
1969
+ errorResetBoundary,
1970
+ useErrorBoundary: defaultedOptions.useErrorBoundary,
1971
+ query: observer.getCurrentQuery()
1972
+ })) {
1973
+ throw result.error;
1974
+ }
1975
+ return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
1976
+ }
1977
+
1978
+ // ../../node_modules/@tanstack/react-query/build/lib/useQuery.mjs
1979
+ function useQuery(arg1, arg2, arg3) {
1980
+ const parsedOptions = parseQueryArgs(arg1, arg2, arg3);
1981
+ return useBaseQuery(parsedOptions, QueryObserver);
1982
+ }
1983
+
1984
+ // src/lib/useUploadCore.tsx
1985
+ import Upload2 from "@availity/upload-core";
1986
+ function startUpload2(file, options) {
1987
+ return __async(this, null, function* () {
1988
+ const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
1989
+ const upload = new Upload2(file, uploadOptions);
1990
+ yield upload.generateId();
1991
+ if (onSuccess) upload.onSuccess.push(onSuccess);
1992
+ if (onError) upload.onError.push(onError);
1993
+ if (onProgress) upload.onProgress.push(onProgress);
1994
+ if (onChunkComplete) upload.onChunkComplete.push(onChunkComplete);
1995
+ upload.start();
1996
+ return upload;
1997
+ });
1998
+ }
1999
+ function useUploadCore(file, options, queryOptions) {
2000
+ const isQueryEnabled = !!file;
2001
+ return useQuery(__spreadValues({
2002
+ queryKey: ["upload", file.name, options],
2003
+ queryFn: () => startUpload2(file, options),
2004
+ enabled: isQueryEnabled,
2005
+ retry: false,
2006
+ refetchOnWindowFocus: false
2007
+ }, queryOptions));
2008
+ }
2009
+
2010
+ // src/lib/FileList.tsx
2011
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
2012
+ var FileRow = ({
2013
+ file,
2014
+ options,
2015
+ onRemoveFile,
2016
+ queryOptions,
2017
+ customFileRow: CustomRow,
2018
+ disableRemove = false
2019
+ }) => {
2020
+ const Icon = getFileExtIcon(file.name);
730
2021
  const { data: upload } = useUploadCore(file, options, queryOptions);
731
2022
  if (!upload) return null;
732
- if (CustomRow) return /* @__PURE__ */ jsx11(CustomRow, { upload, options, onRemoveFile });
733
- return /* @__PURE__ */ jsxs8(
2023
+ if (CustomRow) return /* @__PURE__ */ jsx12(CustomRow, { upload, options, onRemoveFile });
2024
+ return /* @__PURE__ */ jsxs9(
734
2025
  ListItem2,
735
2026
  {
736
2027
  disableGutters: true,
737
- secondaryAction: !disableRemove && /* @__PURE__ */ jsx11(
2028
+ secondaryAction: !disableRemove && /* @__PURE__ */ jsx12(
738
2029
  IconButton3,
739
2030
  {
740
2031
  title: "remove file",
@@ -742,17 +2033,17 @@ var FileRow = ({
742
2033
  onClick: () => {
743
2034
  onRemoveFile(upload.id, upload);
744
2035
  },
745
- children: /* @__PURE__ */ jsx11(DeleteIcon, {})
2036
+ children: /* @__PURE__ */ jsx12(DeleteIcon, {})
746
2037
  }
747
2038
  ),
748
2039
  children: [
749
- /* @__PURE__ */ jsxs8(Grid2, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
750
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: "auto" }, children: /* @__PURE__ */ jsx11(ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ jsx11(Icon, {}) }) }),
751
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ jsx11(ListItemText2, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
752
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ jsx11(ListItemText2, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
753
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ jsx11(UploadProgressBar, { upload }) })
2040
+ /* @__PURE__ */ jsxs9(Grid2, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
2041
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: "auto" }, children: /* @__PURE__ */ jsx12(ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ jsx12(Icon, {}) }) }),
2042
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ jsx12(ListItemText2, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
2043
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ jsx12(ListItemText2, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
2044
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ jsx12(UploadProgressBar, { upload }) })
754
2045
  ] }),
755
- /* @__PURE__ */ jsx11(Divider2, {})
2046
+ /* @__PURE__ */ jsx12(Divider3, {})
756
2047
  ]
757
2048
  }
758
2049
  );
@@ -766,8 +2057,8 @@ var FileList = ({
766
2057
  disableRemove
767
2058
  }) => {
768
2059
  if (files.length === 0) return null;
769
- return /* @__PURE__ */ jsx11(List2, { children: files.map((file) => {
770
- return /* @__PURE__ */ jsx11(
2060
+ return /* @__PURE__ */ jsx12(List2, { children: files.map((file) => {
2061
+ return /* @__PURE__ */ jsx12(
771
2062
  FileRow,
772
2063
  {
773
2064
  file,
@@ -782,17 +2073,83 @@ var FileList = ({
782
2073
  }) });
783
2074
  };
784
2075
 
785
- // src/lib/FileSelector.tsx
786
- import { useState as useState3 } from "react";
787
- import { useFormContext as useFormContext2 } from "react-hook-form";
788
- import { useQueryClient } from "@tanstack/react-query";
2076
+ // src/lib/FileList2.tsx
2077
+ import { List as List3, ListItem as ListItem3, ListItemText as ListItemText3, ListItemIcon as ListItemIcon2 } from "@availity/mui-list";
2078
+ import { IconButton as IconButton4 } from "@availity/mui-button";
2079
+ import { DeleteIcon as DeleteIcon2 } from "@availity/mui-icon";
789
2080
  import { Grid as Grid3 } from "@availity/mui-layout";
790
- import { Typography as Typography5 } from "@availity/mui-typography";
2081
+ import { Divider as Divider4 } from "@availity/mui-divider";
2082
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2083
+ var FileRow2 = ({
2084
+ upload,
2085
+ options,
2086
+ onRemoveFile,
2087
+ customFileRow: CustomRow,
2088
+ disableRemove = false
2089
+ }) => {
2090
+ const Icon = getFileExtIcon(upload.file.name);
2091
+ if (!upload) return null;
2092
+ if (CustomRow) return /* @__PURE__ */ jsx13(CustomRow, { upload, options, onRemoveFile });
2093
+ return /* @__PURE__ */ jsxs10(
2094
+ ListItem3,
2095
+ {
2096
+ disableGutters: true,
2097
+ secondaryAction: !disableRemove && /* @__PURE__ */ jsx13(
2098
+ IconButton4,
2099
+ {
2100
+ title: "remove file",
2101
+ edge: "end",
2102
+ onClick: () => {
2103
+ onRemoveFile(upload.id, upload);
2104
+ },
2105
+ children: /* @__PURE__ */ jsx13(DeleteIcon2, {})
2106
+ }
2107
+ ),
2108
+ children: [
2109
+ /* @__PURE__ */ jsxs10(Grid3, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
2110
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: "auto" }, children: /* @__PURE__ */ jsx13(ListItemIcon2, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ jsx13(Icon, {}) }) }),
2111
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ jsx13(ListItemText3, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
2112
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ jsx13(ListItemText3, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
2113
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ jsx13(UploadProgressBar, { upload }) })
2114
+ ] }),
2115
+ /* @__PURE__ */ jsx13(Divider4, {})
2116
+ ]
2117
+ }
2118
+ );
2119
+ };
2120
+ var FileList2 = ({
2121
+ uploads,
2122
+ options,
2123
+ onRemoveFile,
2124
+ customFileRow,
2125
+ disableRemove
2126
+ }) => {
2127
+ if (uploads.length === 0) return null;
2128
+ return /* @__PURE__ */ jsx13(List3, { children: uploads.map((upload) => {
2129
+ return /* @__PURE__ */ jsx13(
2130
+ FileRow2,
2131
+ {
2132
+ upload,
2133
+ options,
2134
+ onRemoveFile,
2135
+ customFileRow,
2136
+ disableRemove
2137
+ },
2138
+ upload.id
2139
+ );
2140
+ }) });
2141
+ };
2142
+
2143
+ // src/lib/FileSelector.tsx
2144
+ import { useState as useState5 } from "react";
2145
+ import { useFormContext as useFormContext3 } from "react-hook-form";
2146
+ import { Grid as Grid4 } from "@availity/mui-layout";
2147
+ import { Typography as Typography6 } from "@availity/mui-typography";
791
2148
  import { Alert as Alert2, AlertTitle as AlertTitle2 } from "@availity/mui-alert";
792
2149
 
793
2150
  // src/lib/FileTypesMessage.tsx
794
- import { Typography as Typography3 } from "@availity/mui-typography";
795
- import { jsxs as jsxs9 } from "react/jsx-runtime";
2151
+ import { Typography as Typography4 } from "@availity/mui-typography";
2152
+ import { jsxs as jsxs11 } from "react/jsx-runtime";
796
2153
  var FileTypesMessage = ({
797
2154
  allowedFileTypes = [],
798
2155
  customSizeMessage,
@@ -802,17 +2159,17 @@ var FileTypesMessage = ({
802
2159
  }) => {
803
2160
  const fileSizeMsg = customSizeMessage || (typeof maxFileSize === "number" ? `Maximum file size is ${formatBytes(maxFileSize)}. ` : null);
804
2161
  const fileTypesMsg = customTypesMessage || (allowedFileTypes.length > 0 ? `Supported file types include: ${allowedFileTypes.join(", ")}` : "All file types allowed.");
805
- return /* @__PURE__ */ jsxs9(Typography3, { variant, children: [
2162
+ return /* @__PURE__ */ jsxs11(Typography4, { variant, children: [
806
2163
  fileSizeMsg,
807
2164
  fileTypesMsg
808
2165
  ] });
809
2166
  };
810
2167
 
811
2168
  // src/lib/HeaderMessage.tsx
812
- import { Typography as Typography4 } from "@availity/mui-typography";
813
- import { jsxs as jsxs10 } from "react/jsx-runtime";
2169
+ import { Typography as Typography5 } from "@availity/mui-typography";
2170
+ import { jsxs as jsxs12 } from "react/jsx-runtime";
814
2171
  var HeaderMessage = ({ maxFiles, maxSize }) => {
815
- return /* @__PURE__ */ jsxs10(Typography4, { variant: "h6", children: [
2172
+ return /* @__PURE__ */ jsxs12(Typography5, { variant: "h6", children: [
816
2173
  "Attach up to ",
817
2174
  maxFiles,
818
2175
  " file(s), with a maximum individual size of ",
@@ -821,7 +2178,7 @@ var HeaderMessage = ({ maxFiles, maxSize }) => {
821
2178
  };
822
2179
 
823
2180
  // src/lib/FileSelector.tsx
824
- import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
2181
+ import { Fragment as Fragment6, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
825
2182
  var CLOUD_URL = "/cloud/web/appl/vault/upload/v1/resumable";
826
2183
  var FileSelector = ({
827
2184
  name,
@@ -850,10 +2207,10 @@ var FileSelector = ({
850
2207
  validator,
851
2208
  disableRemove
852
2209
  }) => {
853
- const [totalSize, setTotalSize] = useState3(0);
854
- const [fileRejections, setFileRejections] = useState3([]);
2210
+ const [totalSize, setTotalSize] = useState5(0);
2211
+ const [fileRejections, setFileRejections] = useState5([]);
855
2212
  const client = useQueryClient();
856
- const formMethods = useFormContext2();
2213
+ const formMethods = useFormContext3();
857
2214
  const options = __spreadProps(__spreadValues({}, uploadOptions), {
858
2215
  bucketId,
859
2216
  customerId,
@@ -892,10 +2249,10 @@ var FileSelector = ({
892
2249
  const otherRejections = fileRejections.filter(
893
2250
  (rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
894
2251
  );
895
- return /* @__PURE__ */ jsxs11(Fragment5, { children: [
896
- enableDropArea ? /* @__PURE__ */ jsxs11(Fragment5, { children: [
897
- label ? /* @__PURE__ */ jsx12(Typography5, { marginBottom: "4px", children: label }) : null,
898
- /* @__PURE__ */ jsx12(
2252
+ return /* @__PURE__ */ jsxs13(Fragment6, { children: [
2253
+ enableDropArea ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
2254
+ label ? /* @__PURE__ */ jsx14(Typography6, { marginBottom: "4px", children: label }) : null,
2255
+ /* @__PURE__ */ jsx14(
899
2256
  Dropzone,
900
2257
  {
901
2258
  name,
@@ -912,7 +2269,7 @@ var FileSelector = ({
912
2269
  validator
913
2270
  }
914
2271
  ),
915
- /* @__PURE__ */ jsx12(
2272
+ /* @__PURE__ */ jsx14(
916
2273
  FileTypesMessage,
917
2274
  {
918
2275
  allowedFileTypes,
@@ -923,10 +2280,10 @@ var FileSelector = ({
923
2280
  }
924
2281
  ),
925
2282
  children
926
- ] }) : /* @__PURE__ */ jsxs11(Grid3, { container: true, rowSpacing: 3, flexDirection: "column", children: [
927
- /* @__PURE__ */ jsxs11(Grid3, { children: [
928
- /* @__PURE__ */ jsx12(HeaderMessage, { maxFiles, maxSize }),
929
- /* @__PURE__ */ jsx12(
2283
+ ] }) : /* @__PURE__ */ jsxs13(Grid4, { container: true, rowSpacing: 3, flexDirection: "column", children: [
2284
+ /* @__PURE__ */ jsxs13(Grid4, { children: [
2285
+ /* @__PURE__ */ jsx14(HeaderMessage, { maxFiles, maxSize }),
2286
+ /* @__PURE__ */ jsx14(
930
2287
  FileTypesMessage,
931
2288
  {
932
2289
  allowedFileTypes,
@@ -936,8 +2293,8 @@ var FileSelector = ({
936
2293
  }
937
2294
  )
938
2295
  ] }),
939
- children ? /* @__PURE__ */ jsx12(Grid3, { children }) : null,
940
- /* @__PURE__ */ jsx12(Grid3, { children: /* @__PURE__ */ jsx12(
2296
+ children ? /* @__PURE__ */ jsx14(Grid4, { children }) : null,
2297
+ /* @__PURE__ */ jsx14(Grid4, { children: /* @__PURE__ */ jsx14(
941
2298
  Dropzone,
942
2299
  {
943
2300
  name,
@@ -955,20 +2312,20 @@ var FileSelector = ({
955
2312
  }
956
2313
  ) })
957
2314
  ] }),
958
- tooManyFilesRejections.length > 0 && /* @__PURE__ */ jsxs11(
2315
+ tooManyFilesRejections.length > 0 && /* @__PURE__ */ jsxs13(
959
2316
  Alert2,
960
2317
  {
961
2318
  severity: "error",
962
2319
  onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
963
2320
  children: [
964
- /* @__PURE__ */ jsx12(AlertTitle2, { children: "Items not allowed." }),
2321
+ /* @__PURE__ */ jsx14(AlertTitle2, { children: "Items not allowed." }),
965
2322
  "Too many files are selected for upload, maximum ",
966
2323
  maxFiles,
967
2324
  " allowed."
968
2325
  ]
969
2326
  }
970
2327
  ),
971
- otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ jsx12(
2328
+ otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ jsx14(
972
2329
  ErrorAlert,
973
2330
  {
974
2331
  errors: rejection.errors,
@@ -978,7 +2335,7 @@ var FileSelector = ({
978
2335
  },
979
2336
  rejection.id
980
2337
  )),
981
- /* @__PURE__ */ jsx12(
2338
+ /* @__PURE__ */ jsx14(
982
2339
  FileList,
983
2340
  {
984
2341
  files: files || [],
@@ -991,16 +2348,223 @@ var FileSelector = ({
991
2348
  )
992
2349
  ] });
993
2350
  };
2351
+
2352
+ // src/lib/FileSelector2.tsx
2353
+ import { useState as useState6 } from "react";
2354
+ import { useFormContext as useFormContext4 } from "react-hook-form";
2355
+ import { Grid as Grid5 } from "@availity/mui-layout";
2356
+ import { Typography as Typography7 } from "@availity/mui-typography";
2357
+ import { Alert as Alert3, AlertTitle as AlertTitle3 } from "@availity/mui-alert";
2358
+ import { Fragment as Fragment7, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
2359
+ var FileSelector2 = ({
2360
+ name,
2361
+ allowedFileNameCharacters,
2362
+ allowedFileTypes = [],
2363
+ bucketId,
2364
+ clientId,
2365
+ children,
2366
+ customSizeMessage,
2367
+ customTypesMessage,
2368
+ customerId,
2369
+ customFileRow,
2370
+ disabled = false,
2371
+ enableDropArea = true,
2372
+ endpoint,
2373
+ isCloud,
2374
+ label = "Upload file",
2375
+ maxFiles,
2376
+ maxSize,
2377
+ multiple = true,
2378
+ onChange,
2379
+ onDrop,
2380
+ onUploadRemove,
2381
+ uploadOptions,
2382
+ validator,
2383
+ disableRemove
2384
+ }) => {
2385
+ const [totalSize, setTotalSize] = useState6(0);
2386
+ const [fileRejections, setFileRejections] = useState6([]);
2387
+ const formMethods = useFormContext4();
2388
+ const options = __spreadProps(__spreadValues({}, uploadOptions), {
2389
+ bucketId,
2390
+ customerId,
2391
+ clientId,
2392
+ fileTypes: allowedFileTypes,
2393
+ maxSize,
2394
+ allowedFileNameCharacters
2395
+ });
2396
+ if (endpoint) options.endpoint = endpoint;
2397
+ if (isCloud) options.endpoint = CLOUD_URL;
2398
+ const handleOnRemoveFile = (uploadId, upload) => {
2399
+ const prevFiles = formMethods.getValues(name);
2400
+ const newFiles = prevFiles.filter((prev) => prev.file.name !== upload.file.name);
2401
+ if (newFiles.length !== prevFiles.length) {
2402
+ const removedFile = prevFiles.find((prev) => prev.file.name === upload.file.name);
2403
+ try {
2404
+ upload.abort();
2405
+ } catch (e) {
2406
+ console.error("Encountered an issue stopping the file upload");
2407
+ }
2408
+ formMethods.setValue(name, newFiles);
2409
+ if (removedFile == null ? void 0 : removedFile.file.size) setTotalSize(totalSize - removedFile.file.size);
2410
+ if (onUploadRemove) onUploadRemove(newFiles, uploadId);
2411
+ }
2412
+ };
2413
+ const uploads = formMethods.watch(name) || [];
2414
+ const handleRemoveRejection = (id) => {
2415
+ const rejections = fileRejections.filter((value) => value.id !== id);
2416
+ setFileRejections(rejections);
2417
+ };
2418
+ const TOO_MANY_FILES_CODE = "too-many-files";
2419
+ const tooManyFilesRejections = fileRejections.filter(
2420
+ (rejection) => rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
2421
+ );
2422
+ const otherRejections = fileRejections.filter(
2423
+ (rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
2424
+ );
2425
+ return /* @__PURE__ */ jsxs14(Fragment7, { children: [
2426
+ enableDropArea ? /* @__PURE__ */ jsxs14(Fragment7, { children: [
2427
+ label ? /* @__PURE__ */ jsx15(Typography7, { marginBottom: "4px", children: label }) : null,
2428
+ /* @__PURE__ */ jsx15(
2429
+ Dropzone2,
2430
+ {
2431
+ name,
2432
+ allowedFileTypes,
2433
+ disabled,
2434
+ enableDropArea,
2435
+ maxFiles,
2436
+ maxSize,
2437
+ multiple,
2438
+ onChange,
2439
+ onDrop,
2440
+ setFileRejections,
2441
+ setTotalSize,
2442
+ uploadOptions: options,
2443
+ validator
2444
+ }
2445
+ ),
2446
+ /* @__PURE__ */ jsx15(
2447
+ FileTypesMessage,
2448
+ {
2449
+ allowedFileTypes,
2450
+ maxFileSize: maxSize,
2451
+ customSizeMessage,
2452
+ customTypesMessage,
2453
+ variant: "caption"
2454
+ }
2455
+ ),
2456
+ children
2457
+ ] }) : /* @__PURE__ */ jsxs14(Grid5, { container: true, rowSpacing: 3, flexDirection: "column", children: [
2458
+ /* @__PURE__ */ jsxs14(Grid5, { children: [
2459
+ /* @__PURE__ */ jsx15(HeaderMessage, { maxFiles, maxSize }),
2460
+ /* @__PURE__ */ jsx15(
2461
+ FileTypesMessage,
2462
+ {
2463
+ allowedFileTypes,
2464
+ customSizeMessage,
2465
+ customTypesMessage,
2466
+ variant: "body2"
2467
+ }
2468
+ )
2469
+ ] }),
2470
+ children ? /* @__PURE__ */ jsx15(Grid5, { children }) : null,
2471
+ /* @__PURE__ */ jsx15(Grid5, { children: /* @__PURE__ */ jsx15(
2472
+ Dropzone2,
2473
+ {
2474
+ name,
2475
+ allowedFileTypes,
2476
+ disabled,
2477
+ enableDropArea,
2478
+ maxFiles,
2479
+ maxSize,
2480
+ multiple,
2481
+ onChange,
2482
+ onDrop,
2483
+ setFileRejections,
2484
+ setTotalSize,
2485
+ uploadOptions: options,
2486
+ validator
2487
+ }
2488
+ ) })
2489
+ ] }),
2490
+ tooManyFilesRejections.length > 0 && /* @__PURE__ */ jsxs14(
2491
+ Alert3,
2492
+ {
2493
+ severity: "error",
2494
+ onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
2495
+ children: [
2496
+ /* @__PURE__ */ jsx15(AlertTitle3, { children: "Items not allowed." }),
2497
+ "Too many files are selected for upload, maximum ",
2498
+ maxFiles,
2499
+ " allowed."
2500
+ ]
2501
+ }
2502
+ ),
2503
+ otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ jsx15(
2504
+ ErrorAlert,
2505
+ {
2506
+ errors: rejection.errors,
2507
+ fileName: rejection.file.name,
2508
+ id: rejection.id,
2509
+ onClose: () => handleRemoveRejection(rejection.id)
2510
+ },
2511
+ rejection.id
2512
+ )),
2513
+ /* @__PURE__ */ jsx15(
2514
+ FileList2,
2515
+ {
2516
+ uploads: uploads || [],
2517
+ options,
2518
+ onRemoveFile: handleOnRemoveFile,
2519
+ customFileRow,
2520
+ disableRemove
2521
+ }
2522
+ )
2523
+ ] });
2524
+ };
994
2525
  export {
2526
+ CLOUD_URL,
995
2527
  Dropzone,
2528
+ Dropzone2,
2529
+ DropzoneContainer,
996
2530
  ErrorAlert,
997
2531
  FileList,
2532
+ FileList2,
998
2533
  FilePickerBtn,
999
2534
  FileRow,
2535
+ FileRow2,
1000
2536
  FileSelector,
2537
+ FileSelector2,
1001
2538
  FileTypesMessage,
1002
2539
  HeaderMessage,
1003
2540
  UploadProgressBar,
2541
+ createCounter,
1004
2542
  formatFileTooLarge,
2543
+ innerBoxStyles,
2544
+ outerBoxStyles,
1005
2545
  useUploadCore
1006
2546
  };
2547
+ /*! Bundled license information:
2548
+
2549
+ use-sync-external-store/cjs/use-sync-external-store-shim.production.js:
2550
+ (**
2551
+ * @license React
2552
+ * use-sync-external-store-shim.production.js
2553
+ *
2554
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2555
+ *
2556
+ * This source code is licensed under the MIT license found in the
2557
+ * LICENSE file in the root directory of this source tree.
2558
+ *)
2559
+
2560
+ use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
2561
+ (**
2562
+ * @license React
2563
+ * use-sync-external-store-shim.development.js
2564
+ *
2565
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2566
+ *
2567
+ * This source code is licensed under the MIT license found in the
2568
+ * LICENSE file in the root directory of this source tree.
2569
+ *)
2570
+ */