@verbb/formie-browser 1.0.4 → 1.0.6
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/CHANGELOG.md +76 -22
- package/dist/chunks/address-country-Rx6GQTND.js +68 -0
- package/dist/chunks/address-finder-yXU5yMjG.js +30 -0
- package/dist/chunks/address-state-BQ0xGV9n.js +344 -0
- package/dist/chunks/api-CmwLRq_n.js +780 -0
- package/dist/chunks/api-DMK8NSUI.js +407 -0
- package/dist/chunks/api-sPqGbOww.js +125 -0
- package/dist/chunks/async-nPFRNQ06.js +25 -0
- package/dist/chunks/bpoint-DSjqRv63.js +24 -0
- package/dist/chunks/calculations-CeDgB9jt.js +299 -0
- package/dist/chunks/captcha-eu-CWJb64_j.js +31 -0
- package/dist/chunks/checkbox-radio-DQ0H67Tj.js +125 -0
- package/dist/chunks/chunk-3b4jIN3o.js +13 -0
- package/dist/chunks/combobox-D-2b42wn.js +1954 -0
- package/dist/chunks/conditions-DjZOtHfS.js +412 -0
- package/dist/chunks/constants-DVcJAvc5.js +38 -0
- package/dist/chunks/country-from-ip-BwxKaBuJ.js +26 -0
- package/dist/chunks/custom-google-maps-BsaSirEZ.js +194 -0
- package/dist/chunks/custom-link-CJ1-FjEM.js +46 -0
- package/dist/chunks/custom-maps-DYW_pBid.js +161 -0
- package/dist/chunks/date-picker-5CA_-zGb.js +5311 -0
- package/dist/chunks/debug-BV0DvdHx.js +41 -0
- package/dist/chunks/dist-BQ4a9hmy.js +2659 -0
- package/dist/chunks/event-names-BCI2FLD8.js +51 -0
- package/dist/chunks/eway-D3ctTbEk.js +70 -0
- package/dist/chunks/field-references.keys-58ZSTrCW.js +21 -0
- package/dist/chunks/field-references.resolver-CHwn0G0L.js +145 -0
- package/dist/chunks/file-upload-D49m8-DR.js +287 -0
- package/dist/chunks/friendly-captcha-v1-ByXzENYZ.js +31 -0
- package/dist/chunks/friendly-captcha-v2-BPdlmhQu.js +36 -0
- package/dist/chunks/friendly-challenge-8uPatWqk.js +832 -0
- package/dist/chunks/go-cardless-BwASSYSK.js +23 -0
- package/dist/chunks/google-address-OhKilPWE.js +161 -0
- package/dist/chunks/hcaptcha-CdCd9oEi.js +54 -0
- package/dist/chunks/hidden-D7_Ch-QN.js +26 -0
- package/dist/chunks/http-D-JExro7.js +27 -0
- package/dist/chunks/i18n-BY1ds1BL.js +121 -0
- package/dist/chunks/leaflet-src-j-lHNmhR.js +4585 -0
- package/dist/chunks/loqate-Cp2zvwpE.js +76 -0
- package/dist/chunks/mollie-COG-ko2D.js +23 -0
- package/dist/chunks/moneris-CMH8PlRc.js +117 -0
- package/dist/chunks/opayo-D2jsR5vh.js +113 -0
- package/dist/chunks/paddle-DxF88RfC.js +55 -0
- package/dist/chunks/paypal-b5pnwrA2.js +95 -0
- package/dist/chunks/payway-BJYu9DIR.js +55 -0
- package/dist/chunks/phone-country-D3ayr60L.js +2645 -0
- package/dist/chunks/place-kit-BGHklIZ-.js +48 -0
- package/dist/chunks/placekit-autocomplete.esm-DWVabQlq.js +1236 -0
- package/dist/chunks/recaptcha-enterprise-BSwi8IVX.js +65 -0
- package/dist/chunks/recaptcha-shared-B4zAescW.js +15 -0
- package/dist/chunks/recaptcha-v2-checkbox-CnDQmsKa.js +40 -0
- package/dist/chunks/recaptcha-v2-invisible-Cz5uIlp-.js +53 -0
- package/dist/chunks/recaptcha-v3-BtbbP111.js +27 -0
- package/dist/chunks/repeater-B5leVxZU.js +102 -0
- package/dist/chunks/rich-text-D0sb8bmX.js +349 -0
- package/dist/chunks/scripts-6CYSUGKQ.js +24 -0
- package/dist/chunks/sdk-BhHAYgga.js +1397 -0
- package/dist/chunks/shared-Bx9s0i0P.js +100 -0
- package/dist/chunks/signature-xz4QO7CR.js +536 -0
- package/dist/chunks/snaptcha-vz1RnZ15.js +8 -0
- package/dist/chunks/square-BP8RWAKB.js +40 -0
- package/dist/chunks/stripe-MihN63uC.js +184 -0
- package/dist/chunks/styles-BfoIZwJp.js +19 -0
- package/dist/chunks/summary-D3AjxpYN.js +114 -0
- package/dist/chunks/table-C-lkQN6I.js +78 -0
- package/dist/chunks/text-limit-DbgEFHLO.js +125 -0
- package/dist/chunks/theme-classes-Tv7q7ToE.js +44 -0
- package/dist/chunks/turnstile-D_Pi1CKM.js +58 -0
- package/dist/chunks/upload-manager-BpqWSHmU.js +2558 -0
- package/dist/chunks/utils-Vqp8i_RM.js +49401 -0
- package/dist/css/formie-theme.css +2 -0
- package/dist/css/theme/_buttons.css +16 -0
- package/dist/css/theme/_tokens.css +2 -0
- package/dist/css/theme/fields/_address-state.css +94 -0
- package/dist/css/theme/fields/_combobox.css +246 -0
- package/dist/css/theme/fields/_select.css +13 -0
- package/dist/css/theme/fields/_signature.css +19 -0
- package/dist/css/theme/fields/_upload-manager.css +279 -0
- package/dist/index.js +2448 -39
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/core/validation-focus.d.ts +4 -0
- package/dist/js/core/validation-focus.d.ts.map +1 -0
- package/dist/js/modules/address/api.d.ts +1 -0
- package/dist/js/modules/address/api.d.ts.map +1 -1
- package/dist/js/modules/address/constants.d.ts +22 -1
- package/dist/js/modules/address/constants.d.ts.map +1 -1
- package/dist/js/modules/address/host.d.ts +2 -2
- package/dist/js/modules/address/host.d.ts.map +1 -1
- package/dist/js/modules/address/loqate.d.ts.map +1 -1
- package/dist/js/modules/fields/address-country.d.ts +3 -0
- package/dist/js/modules/fields/address-country.d.ts.map +1 -0
- package/dist/js/modules/fields/address-state.d.ts +3 -0
- package/dist/js/modules/fields/address-state.d.ts.map +1 -0
- package/dist/js/modules/fields/calculations.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts +17 -0
- package/dist/js/modules/fields/combobox.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-google-maps.d.ts +64 -0
- package/dist/js/modules/fields/custom-google-maps.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-link.d.ts +3 -0
- package/dist/js/modules/fields/custom-link.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-maps.d.ts +3 -0
- package/dist/js/modules/fields/custom-maps.d.ts.map +1 -0
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
- package/dist/js/modules/fields/index.d.ts.map +1 -1
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
- package/dist/js/modules/fields/signature.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts +3 -0
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -0
- package/dist/js/submit/pipeline.d.ts.map +1 -1
- package/dist/js/utils/country-from-ip.d.ts +7 -0
- package/dist/js/utils/country-from-ip.d.ts.map +1 -0
- package/dist/js/utils/field-references.d.ts +1 -0
- package/dist/js/utils/field-references.d.ts.map +1 -1
- package/dist/js/utils/field-references.row-scope.d.ts +11 -0
- package/dist/js/utils/field-references.row-scope.d.ts.map +1 -0
- package/package.json +8 -3
- package/src/css/formie-theme.css +2 -0
- package/src/css/theme/_buttons.css +16 -0
- package/src/css/theme/_tokens.css +2 -0
- package/src/css/theme/fields/_address-state.css +94 -0
- package/src/css/theme/fields/_combobox.css +246 -0
- package/src/css/theme/fields/_select.css +13 -0
- package/src/css/theme/fields/_signature.css +19 -0
- package/src/css/theme/fields/_upload-manager.css +279 -0
- package/src/js/core/create-formie-client.ts +27 -0
- package/src/js/core/submit-result-ui.ts +4 -4
- package/src/js/core/validation-focus.ts +117 -0
- package/src/js/modules/address/api.ts +7 -0
- package/src/js/modules/address/constants.ts +82 -2
- package/src/js/modules/address/host.ts +16 -6
- package/src/js/modules/address/loqate.ts +3 -17
- package/src/js/modules/fields/address-country.ts +156 -0
- package/src/js/modules/fields/address-state.ts +946 -0
- package/src/js/modules/fields/calculations.ts +32 -0
- package/src/js/modules/fields/combobox.ts +188 -0
- package/src/js/modules/fields/custom-google-maps.ts +416 -0
- package/src/js/modules/fields/custom-link.ts +95 -0
- package/src/js/modules/fields/custom-maps.ts +339 -0
- package/src/js/modules/fields/date-picker.ts +96 -3
- package/src/js/modules/fields/index.ts +7 -0
- package/src/js/modules/fields/phone-country.ts +6 -0
- package/src/js/modules/fields/signature.ts +199 -15
- package/src/js/modules/fields/upload-manager.ts +1277 -0
- package/src/js/submit/pipeline.ts +11 -1
- package/src/js/utils/country-from-ip.ts +54 -0
- package/src/js/utils/field-references.row-scope.ts +303 -0
- package/src/js/utils/field-references.ts +1 -0
- package/src/vendor.d.ts +1 -1
- package/dist/chunks/address-finder-BU4roxT6.js +0 -37
- package/dist/chunks/bpoint-uNg5j6rt.js +0 -26
- package/dist/chunks/calculations-C9t6Zop9.js +0 -147
- package/dist/chunks/captcha-eu-BAPzHNts.js +0 -34
- package/dist/chunks/checkbox-radio-CHeLNVIK.js +0 -141
- package/dist/chunks/conditions-DKxVCsjD.js +0 -459
- package/dist/chunks/date-picker-B3iQ797Z.js +0 -4994
- package/dist/chunks/eway-DCielIML.js +0 -74
- package/dist/chunks/file-upload-DP2TOUYV.js +0 -316
- package/dist/chunks/friendly-captcha-v1-DdlcGiFY.js +0 -33
- package/dist/chunks/friendly-captcha-v2-76w-YnFm.js +0 -38
- package/dist/chunks/go-cardless-rwCkzbNK.js +0 -24
- package/dist/chunks/google-address-BD8IZ86V.js +0 -181
- package/dist/chunks/hcaptcha-BNNTL6uf.js +0 -56
- package/dist/chunks/hidden-CW6Rcf1N.js +0 -31
- package/dist/chunks/index-BEsfee-D.js +0 -1839
- package/dist/chunks/index-BP7Unm5Y.js +0 -863
- package/dist/chunks/index-D6npYxvr.js +0 -4423
- package/dist/chunks/loqate-B-ZNS65B.js +0 -55
- package/dist/chunks/mollie-BDAZ-1X4.js +0 -24
- package/dist/chunks/moneris-B1b0uEtY.js +0 -101
- package/dist/chunks/opayo-CC5hraHo.js +0 -122
- package/dist/chunks/paddle-B4GmrDsq.js +0 -60
- package/dist/chunks/paypal-BFS6XsIS.js +0 -100
- package/dist/chunks/payway-DekoJead.js +0 -56
- package/dist/chunks/phone-country-Cm5YUeXI.js +0 -3765
- package/dist/chunks/place-kit-DizZWV_e.js +0 -42
- package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +0 -1299
- package/dist/chunks/recaptcha-enterprise-BbOvO7JZ.js +0 -71
- package/dist/chunks/recaptcha-shared-Dwg1eVFS.js +0 -15
- package/dist/chunks/recaptcha-v2-checkbox-SY3ti5iQ.js +0 -41
- package/dist/chunks/recaptcha-v2-invisible-DSmQnn6c.js +0 -59
- package/dist/chunks/recaptcha-v3-DNh7YCnR.js +0 -28
- package/dist/chunks/repeater-DM0vuFNQ.js +0 -124
- package/dist/chunks/rich-text-C8aGYp70.js +0 -304
- package/dist/chunks/scripts-CKTFtxPO.js +0 -36
- package/dist/chunks/sdk-3SicTWby.js +0 -1559
- package/dist/chunks/shared--BU5CFoL.js +0 -80
- package/dist/chunks/signature-pFhZfH7d.js +0 -550
- package/dist/chunks/snaptcha-VuOUOaLj.js +0 -8
- package/dist/chunks/square-BR9pvToy.js +0 -46
- package/dist/chunks/stripe-OHUwoV9g.js +0 -202
- package/dist/chunks/styles-C3aqgtek.js +0 -21
- package/dist/chunks/summary-Da7Ktg3N.js +0 -126
- package/dist/chunks/table-C0PmR9bI.js +0 -95
- package/dist/chunks/text-limit-mLEwZDIa.js +0 -144
- package/dist/chunks/turnstile-9tM7q_LK.js +0 -59
- package/dist/chunks/utils-BntI3W4S.js +0 -6149
|
@@ -0,0 +1,2558 @@
|
|
|
1
|
+
import { n as e, t } from "./chunk-3b4jIN3o.js";
|
|
2
|
+
import { a as n, r } from "./event-names-BCI2FLD8.js";
|
|
3
|
+
import { t as i } from "./debug-BV0DvdHx.js";
|
|
4
|
+
import { t as a } from "./http-D-JExro7.js";
|
|
5
|
+
import { t as o } from "./styles-BfoIZwJp.js";
|
|
6
|
+
import { c as s, l as c, t as l } from "./shared-Bx9s0i0P.js";
|
|
7
|
+
//#region ../../node_modules/@uppy/utils/lib/NetworkError.js
|
|
8
|
+
var u = class extends Error {
|
|
9
|
+
cause;
|
|
10
|
+
isNetworkError;
|
|
11
|
+
request;
|
|
12
|
+
constructor(e, t = null) {
|
|
13
|
+
super("This looks like a network error, the endpoint might be blocked by an internet provider or a firewall."), this.cause = e, this.isNetworkError = !0, this.request = t;
|
|
14
|
+
}
|
|
15
|
+
}, d = class {
|
|
16
|
+
#e;
|
|
17
|
+
#t = !1;
|
|
18
|
+
#n;
|
|
19
|
+
#r;
|
|
20
|
+
constructor(e, t) {
|
|
21
|
+
this.#r = e, this.#n = () => t(e);
|
|
22
|
+
}
|
|
23
|
+
progress() {
|
|
24
|
+
this.#t || this.#r > 0 && (clearTimeout(this.#e), this.#e = setTimeout(this.#n, this.#r));
|
|
25
|
+
}
|
|
26
|
+
done() {
|
|
27
|
+
this.#t ||= (clearTimeout(this.#e), this.#e = void 0, !0);
|
|
28
|
+
}
|
|
29
|
+
}, f = () => {};
|
|
30
|
+
function p(e, t = {}) {
|
|
31
|
+
let { body: n = null, headers: r = {}, method: i = "GET", onBeforeRequest: a = f, onUploadProgress: o = f, shouldRetry: s = () => !0, onAfterResponse: c = f, onTimeout: l = f, responseType: p, retries: m = 3, signal: h = null, timeout: g = 3e4, withCredentials: _ = !1 } = t, v = (e) => .3 * 2 ** (e - 1) * 1e3, y = new d(g, l);
|
|
32
|
+
function b(t = 0) {
|
|
33
|
+
return new Promise(async (l, d) => {
|
|
34
|
+
let f = new XMLHttpRequest(), g = (e) => {
|
|
35
|
+
s(f) && t < m ? setTimeout(() => {
|
|
36
|
+
b(t + 1).then(l, d);
|
|
37
|
+
}, v(t)) : (y.done(), d(e));
|
|
38
|
+
};
|
|
39
|
+
f.open(i, e, !0), f.withCredentials = _, p && (f.responseType = p), f.onload = async () => {
|
|
40
|
+
try {
|
|
41
|
+
await c(f, t);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
e.request = f, g(e);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
f.status >= 200 && f.status < 300 ? (y.done(), l(f)) : s(f) && t < m ? setTimeout(() => {
|
|
47
|
+
b(t + 1).then(l, d);
|
|
48
|
+
}, v(t)) : (y.done(), d(new u(f.statusText, f)));
|
|
49
|
+
}, f.onerror = () => g(new u(f.statusText, f)), f.upload.onprogress = (e) => {
|
|
50
|
+
y.progress(), o(e);
|
|
51
|
+
}, r && Object.keys(r).forEach((e) => {
|
|
52
|
+
f.setRequestHeader(e, r[e]);
|
|
53
|
+
});
|
|
54
|
+
function x() {
|
|
55
|
+
f.abort(), d(new DOMException("Aborted", "AbortError"));
|
|
56
|
+
}
|
|
57
|
+
if (h?.addEventListener("abort", x), h?.aborted) {
|
|
58
|
+
x();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await a(f, t), f.send(n);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return b();
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region ../../node_modules/@uppy/utils/lib/fileFilters.js
|
|
68
|
+
var m = (e) => "error" in e && !!e.error, h = (e) => e.progress.uploadComplete;
|
|
69
|
+
function g(e) {
|
|
70
|
+
return e.filter((e) => !m(e) && !h(e));
|
|
71
|
+
}
|
|
72
|
+
function _(e) {
|
|
73
|
+
return e.filter((e) => !e.progress?.uploadStarted || !e.isRestored);
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../../node_modules/@uppy/utils/lib/getFileNameAndExtension.js
|
|
77
|
+
function v(e) {
|
|
78
|
+
let t = e.lastIndexOf(".");
|
|
79
|
+
return t === -1 || t === e.length - 1 ? {
|
|
80
|
+
name: e,
|
|
81
|
+
extension: void 0
|
|
82
|
+
} : {
|
|
83
|
+
name: e.slice(0, t),
|
|
84
|
+
extension: e.slice(t + 1)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region ../../node_modules/@uppy/utils/lib/mimeTypes.js
|
|
89
|
+
var y = {
|
|
90
|
+
__proto__: null,
|
|
91
|
+
md: "text/markdown",
|
|
92
|
+
markdown: "text/markdown",
|
|
93
|
+
mp4: "video/mp4",
|
|
94
|
+
mp3: "audio/mp3",
|
|
95
|
+
svg: "image/svg+xml",
|
|
96
|
+
jpg: "image/jpeg",
|
|
97
|
+
png: "image/png",
|
|
98
|
+
webp: "image/webp",
|
|
99
|
+
gif: "image/gif",
|
|
100
|
+
heic: "image/heic",
|
|
101
|
+
heif: "image/heif",
|
|
102
|
+
yaml: "text/yaml",
|
|
103
|
+
yml: "text/yaml",
|
|
104
|
+
csv: "text/csv",
|
|
105
|
+
tsv: "text/tab-separated-values",
|
|
106
|
+
tab: "text/tab-separated-values",
|
|
107
|
+
avi: "video/x-msvideo",
|
|
108
|
+
mks: "video/x-matroska",
|
|
109
|
+
mkv: "video/x-matroska",
|
|
110
|
+
mov: "video/quicktime",
|
|
111
|
+
dicom: "application/dicom",
|
|
112
|
+
doc: "application/msword",
|
|
113
|
+
msg: "application/vnd.ms-outlook",
|
|
114
|
+
docm: "application/vnd.ms-word.document.macroenabled.12",
|
|
115
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
116
|
+
dot: "application/msword",
|
|
117
|
+
dotm: "application/vnd.ms-word.template.macroenabled.12",
|
|
118
|
+
dotx: "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
|
119
|
+
xla: "application/vnd.ms-excel",
|
|
120
|
+
xlam: "application/vnd.ms-excel.addin.macroenabled.12",
|
|
121
|
+
xlc: "application/vnd.ms-excel",
|
|
122
|
+
xlf: "application/x-xliff+xml",
|
|
123
|
+
xlm: "application/vnd.ms-excel",
|
|
124
|
+
xls: "application/vnd.ms-excel",
|
|
125
|
+
xlsb: "application/vnd.ms-excel.sheet.binary.macroenabled.12",
|
|
126
|
+
xlsm: "application/vnd.ms-excel.sheet.macroenabled.12",
|
|
127
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
128
|
+
xlt: "application/vnd.ms-excel",
|
|
129
|
+
xltm: "application/vnd.ms-excel.template.macroenabled.12",
|
|
130
|
+
xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
|
131
|
+
xlw: "application/vnd.ms-excel",
|
|
132
|
+
txt: "text/plain",
|
|
133
|
+
text: "text/plain",
|
|
134
|
+
conf: "text/plain",
|
|
135
|
+
log: "text/plain",
|
|
136
|
+
pdf: "application/pdf",
|
|
137
|
+
zip: "application/zip",
|
|
138
|
+
"7z": "application/x-7z-compressed",
|
|
139
|
+
rar: "application/x-rar-compressed",
|
|
140
|
+
tar: "application/x-tar",
|
|
141
|
+
gz: "application/gzip",
|
|
142
|
+
dmg: "application/x-apple-diskimage"
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region ../../node_modules/@uppy/utils/lib/getFileType.js
|
|
146
|
+
function b(e) {
|
|
147
|
+
if (e.type) return e.type;
|
|
148
|
+
let t = e.name ? v(e.name).extension?.toLowerCase() : null;
|
|
149
|
+
return t && t in y ? y[t] : "application/octet-stream";
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region ../../node_modules/@uppy/utils/lib/generateFileID.js
|
|
153
|
+
function x(e) {
|
|
154
|
+
return e.charCodeAt(0).toString(32);
|
|
155
|
+
}
|
|
156
|
+
function S(e) {
|
|
157
|
+
let t = "";
|
|
158
|
+
return e.replace(/[^A-Z0-9]/gi, (e) => (t += `-${x(e)}`, "/")) + t;
|
|
159
|
+
}
|
|
160
|
+
function C(e, t) {
|
|
161
|
+
let n = t || "uppy";
|
|
162
|
+
return typeof e.name == "string" && (n += `-${S(e.name.toLowerCase())}`), e.type !== void 0 && (n += `-${e.type}`), e.meta && typeof e.meta.relativePath == "string" && (n += `-${S(e.meta.relativePath.toLowerCase())}`), e.data?.size !== void 0 && (n += `-${e.data.size}`), e.data.lastModified !== void 0 && (n += `-${e.data.lastModified}`), n;
|
|
163
|
+
}
|
|
164
|
+
function w(e) {
|
|
165
|
+
return !e.isRemote || !e.remote ? !1 : new Set([
|
|
166
|
+
"box",
|
|
167
|
+
"dropbox",
|
|
168
|
+
"drive",
|
|
169
|
+
"facebook",
|
|
170
|
+
"unsplash"
|
|
171
|
+
]).has(e.remote.provider);
|
|
172
|
+
}
|
|
173
|
+
function T(e, t) {
|
|
174
|
+
if (w(e)) return e.id;
|
|
175
|
+
let n = b(e);
|
|
176
|
+
return C({
|
|
177
|
+
...e,
|
|
178
|
+
type: n
|
|
179
|
+
}, t);
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region ../../node_modules/@uppy/utils/lib/getAllowedMetaFields.js
|
|
183
|
+
function E(e, t) {
|
|
184
|
+
return e === !0 ? Object.keys(t) : Array.isArray(e) ? e : [];
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region ../../node_modules/@uppy/utils/lib/getTimeStamp.js
|
|
188
|
+
function D(e) {
|
|
189
|
+
return e < 10 ? `0${e}` : e.toString();
|
|
190
|
+
}
|
|
191
|
+
function O() {
|
|
192
|
+
let e = /* @__PURE__ */ new Date();
|
|
193
|
+
return `${D(e.getHours())}:${D(e.getMinutes())}:${D(e.getSeconds())}`;
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region ../../node_modules/@uppy/utils/lib/isNetworkError.js
|
|
197
|
+
function k(e) {
|
|
198
|
+
return e ? e.readyState === 4 && e.status === 0 : !1;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region ../../node_modules/@uppy/utils/lib/TaskQueue.js
|
|
202
|
+
var A = class {
|
|
203
|
+
#e = [];
|
|
204
|
+
#t = 0;
|
|
205
|
+
#n;
|
|
206
|
+
#r = !1;
|
|
207
|
+
constructor(e) {
|
|
208
|
+
let t = e?.concurrency;
|
|
209
|
+
this.#n = typeof t != "number" || t === 0 ? Infinity : t;
|
|
210
|
+
}
|
|
211
|
+
add(e) {
|
|
212
|
+
let t = new AbortController(), n, r, i = new Promise((e, t) => {
|
|
213
|
+
n = e, r = t;
|
|
214
|
+
}), a = {
|
|
215
|
+
run: () => e(t.signal),
|
|
216
|
+
resolve: n,
|
|
217
|
+
reject: r,
|
|
218
|
+
controller: t
|
|
219
|
+
};
|
|
220
|
+
return t.signal.addEventListener("abort", () => {
|
|
221
|
+
let e = this.#e.indexOf(a);
|
|
222
|
+
e !== -1 && (this.#e.splice(e, 1), r(t.signal.reason ?? new DOMException("Aborted", "AbortError")));
|
|
223
|
+
}, { once: !0 }), i.abort = (e) => {
|
|
224
|
+
t.abort(e ?? new DOMException("Aborted", "AbortError"));
|
|
225
|
+
}, i.abortOn = (e) => {
|
|
226
|
+
if (e) {
|
|
227
|
+
let t = () => i.abort(e.reason);
|
|
228
|
+
e.addEventListener("abort", t, { once: !0 }), i.then(() => e.removeEventListener("abort", t), () => e.removeEventListener("abort", t));
|
|
229
|
+
}
|
|
230
|
+
return i;
|
|
231
|
+
}, !this.#r && this.#t < this.#n ? this.#i(a) : this.#e.push(a), i;
|
|
232
|
+
}
|
|
233
|
+
#i(e) {
|
|
234
|
+
if (this.#t++, e.controller.signal.aborted) {
|
|
235
|
+
this.#t--, e.reject(e.controller.signal.reason ?? new DOMException("Aborted", "AbortError")), this.#a();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
let t;
|
|
239
|
+
try {
|
|
240
|
+
t = e.run();
|
|
241
|
+
} catch (e) {
|
|
242
|
+
t = Promise.reject(e);
|
|
243
|
+
}
|
|
244
|
+
t.then((t) => {
|
|
245
|
+
e.controller.signal.aborted ? e.reject(e.controller.signal.reason ?? new DOMException("Aborted", "AbortError")) : e.resolve(t);
|
|
246
|
+
}, (t) => {
|
|
247
|
+
e.reject(t);
|
|
248
|
+
}).finally(() => {
|
|
249
|
+
this.#t--, this.#a();
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
#a() {
|
|
253
|
+
queueMicrotask(() => {
|
|
254
|
+
if (!(this.#r || this.#t >= this.#n)) for (; this.#e.length > 0;) {
|
|
255
|
+
let e = this.#e.shift();
|
|
256
|
+
if (!e.controller.signal.aborted) {
|
|
257
|
+
this.#i(e);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
pause() {
|
|
264
|
+
this.#r = !0;
|
|
265
|
+
}
|
|
266
|
+
resume() {
|
|
267
|
+
this.#r = !1;
|
|
268
|
+
let e = this.#n - this.#t;
|
|
269
|
+
for (let t = 0; t < e; t++) this.#a();
|
|
270
|
+
}
|
|
271
|
+
clear(e) {
|
|
272
|
+
let t = this.#e.splice(0), n = e ?? new DOMException("Cleared", "AbortError");
|
|
273
|
+
for (let e of t) e.controller.abort(n), e.reject(n);
|
|
274
|
+
}
|
|
275
|
+
get concurrency() {
|
|
276
|
+
return this.#n;
|
|
277
|
+
}
|
|
278
|
+
set concurrency(e) {
|
|
279
|
+
if (this.#n = typeof e != "number" || e === 0 ? Infinity : e, !this.#r) {
|
|
280
|
+
let e = this.#n - this.#t;
|
|
281
|
+
for (let t = 0; t < e; t++) this.#a();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
get pending() {
|
|
285
|
+
return this.#e.length;
|
|
286
|
+
}
|
|
287
|
+
get running() {
|
|
288
|
+
return this.#t;
|
|
289
|
+
}
|
|
290
|
+
get isPaused() {
|
|
291
|
+
return this.#r;
|
|
292
|
+
}
|
|
293
|
+
wrapPromiseFunction(e) {
|
|
294
|
+
return (...t) => this.add((n) => e(...t));
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region ../../node_modules/@uppy/utils/lib/Translator.js
|
|
299
|
+
function ee(e, t, n) {
|
|
300
|
+
let r = [];
|
|
301
|
+
return e.forEach((e) => typeof e == "string" ? t[Symbol.split](e).forEach((e, t, i) => {
|
|
302
|
+
e !== "" && r.push(e), t < i.length - 1 && r.push(n);
|
|
303
|
+
}) : r.push(e)), r;
|
|
304
|
+
}
|
|
305
|
+
function j(e, t) {
|
|
306
|
+
let n = /\$/g, r = [e];
|
|
307
|
+
if (t == null) return r;
|
|
308
|
+
for (let e of Object.keys(t)) if (e !== "_") {
|
|
309
|
+
let i = t[e];
|
|
310
|
+
typeof i == "string" && (i = n[Symbol.replace](i, "$$$$")), r = ee(r, RegExp(`%\\{${e}\\}`, "g"), i);
|
|
311
|
+
}
|
|
312
|
+
return r;
|
|
313
|
+
}
|
|
314
|
+
var te = (e) => {
|
|
315
|
+
throw Error(`missing string: ${e}`);
|
|
316
|
+
}, M = class {
|
|
317
|
+
locale;
|
|
318
|
+
constructor(e, { onMissingKey: t = te } = {}) {
|
|
319
|
+
this.locale = {
|
|
320
|
+
strings: {},
|
|
321
|
+
pluralize(e) {
|
|
322
|
+
return e === 1 ? 0 : 1;
|
|
323
|
+
}
|
|
324
|
+
}, Array.isArray(e) ? e.forEach(this.#t, this) : this.#t(e), this.#e = t;
|
|
325
|
+
}
|
|
326
|
+
#e;
|
|
327
|
+
#t(e) {
|
|
328
|
+
if (!e?.strings) return;
|
|
329
|
+
let t = this.locale;
|
|
330
|
+
Object.assign(this.locale, {
|
|
331
|
+
strings: {
|
|
332
|
+
...t.strings,
|
|
333
|
+
...e.strings
|
|
334
|
+
},
|
|
335
|
+
pluralize: e.pluralize || t.pluralize
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
translate(e, t) {
|
|
339
|
+
return this.translateArray(e, t).join("");
|
|
340
|
+
}
|
|
341
|
+
translateArray(e, t) {
|
|
342
|
+
let n = this.locale.strings[e];
|
|
343
|
+
if (n ??= (this.#e(e), e), typeof n == "object") {
|
|
344
|
+
if (t && t.smart_count !== void 0) {
|
|
345
|
+
let e = this.locale.pluralize(t.smart_count);
|
|
346
|
+
return j(n[e], t);
|
|
347
|
+
}
|
|
348
|
+
throw Error("Attempted to use a string with plural forms, but no value was given for %{smart_count}");
|
|
349
|
+
}
|
|
350
|
+
if (typeof n != "string") throw Error("string was not a string");
|
|
351
|
+
return j(n, t);
|
|
352
|
+
}
|
|
353
|
+
}, N = class {
|
|
354
|
+
uppy;
|
|
355
|
+
opts;
|
|
356
|
+
id;
|
|
357
|
+
defaultLocale;
|
|
358
|
+
i18n;
|
|
359
|
+
i18nArray;
|
|
360
|
+
type;
|
|
361
|
+
VERSION;
|
|
362
|
+
constructor(e, t) {
|
|
363
|
+
this.uppy = e, this.opts = t ?? {};
|
|
364
|
+
}
|
|
365
|
+
getPluginState() {
|
|
366
|
+
let { plugins: e } = this.uppy.getState();
|
|
367
|
+
return e?.[this.id] || {};
|
|
368
|
+
}
|
|
369
|
+
setPluginState(e) {
|
|
370
|
+
let { plugins: t } = this.uppy.getState();
|
|
371
|
+
this.uppy.setState({ plugins: {
|
|
372
|
+
...t,
|
|
373
|
+
[this.id]: {
|
|
374
|
+
...t[this.id],
|
|
375
|
+
...e
|
|
376
|
+
}
|
|
377
|
+
} });
|
|
378
|
+
}
|
|
379
|
+
setOptions(e) {
|
|
380
|
+
this.opts = {
|
|
381
|
+
...this.opts,
|
|
382
|
+
...e
|
|
383
|
+
}, this.setPluginState(void 0), this.i18nInit();
|
|
384
|
+
}
|
|
385
|
+
i18nInit() {
|
|
386
|
+
let e = new M([
|
|
387
|
+
this.defaultLocale,
|
|
388
|
+
this.uppy.locale,
|
|
389
|
+
this.opts.locale
|
|
390
|
+
]);
|
|
391
|
+
this.i18n = e.translate.bind(e), this.i18nArray = e.translateArray.bind(e), this.setPluginState(void 0);
|
|
392
|
+
}
|
|
393
|
+
addTarget(e) {
|
|
394
|
+
throw Error("Extend the addTarget method to add your plugin to another plugin's target");
|
|
395
|
+
}
|
|
396
|
+
install() {}
|
|
397
|
+
uninstall() {}
|
|
398
|
+
update(e) {}
|
|
399
|
+
afterUpdate() {}
|
|
400
|
+
}, P = class {
|
|
401
|
+
#e;
|
|
402
|
+
#t = [];
|
|
403
|
+
constructor(e) {
|
|
404
|
+
this.#e = e;
|
|
405
|
+
}
|
|
406
|
+
on(e, t) {
|
|
407
|
+
return this.#t.push([e, t]), this.#e.on(e, t);
|
|
408
|
+
}
|
|
409
|
+
remove() {
|
|
410
|
+
for (let [e, t] of this.#t.splice(0)) this.#e.off(e, t);
|
|
411
|
+
}
|
|
412
|
+
onFilePause(e, t) {
|
|
413
|
+
this.on("upload-pause", (n, r) => {
|
|
414
|
+
e === n?.id && t(r);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
onFileRemove(e, t) {
|
|
418
|
+
this.on("file-removed", (n) => {
|
|
419
|
+
e === n.id && t(n.id);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
onPause(e, t) {
|
|
423
|
+
this.on("upload-pause", (n, r) => {
|
|
424
|
+
e === n?.id && t(r);
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
onRetry(e, t) {
|
|
428
|
+
this.on("upload-retry", (n) => {
|
|
429
|
+
e === n?.id && t();
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
onRetryAll(e, t) {
|
|
433
|
+
this.on("retry-all", () => {
|
|
434
|
+
this.#e.getFile(e) && t();
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
onPauseAll(e, t) {
|
|
438
|
+
this.on("pause-all", () => {
|
|
439
|
+
this.#e.getFile(e) && t();
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
onCancelAll(e, t) {
|
|
443
|
+
this.on("cancel-all", (...n) => {
|
|
444
|
+
this.#e.getFile(e) && t(...n);
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
onResumeAll(e, t) {
|
|
448
|
+
this.on("resume-all", () => {
|
|
449
|
+
this.#e.getFile(e) && t();
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}, ne = {
|
|
453
|
+
debug: () => {},
|
|
454
|
+
warn: () => {},
|
|
455
|
+
error: (...e) => console.error(`[Uppy] [${O()}]`, ...e)
|
|
456
|
+
}, re = {
|
|
457
|
+
debug: (...e) => console.debug(`[Uppy] [${O()}]`, ...e),
|
|
458
|
+
warn: (...e) => console.warn(`[Uppy] [${O()}]`, ...e),
|
|
459
|
+
error: (...e) => console.error(`[Uppy] [${O()}]`, ...e)
|
|
460
|
+
}, ie = /* @__PURE__ */ t(((e, t) => {
|
|
461
|
+
t.exports = function(e) {
|
|
462
|
+
if (typeof e != "number" || Number.isNaN(e)) throw TypeError(`Expected a number, got ${typeof e}`);
|
|
463
|
+
let t = e < 0, n = Math.abs(e);
|
|
464
|
+
if (t && (n = -n), n === 0) return "0 B";
|
|
465
|
+
let r = [
|
|
466
|
+
"B",
|
|
467
|
+
"KB",
|
|
468
|
+
"MB",
|
|
469
|
+
"GB",
|
|
470
|
+
"TB",
|
|
471
|
+
"PB",
|
|
472
|
+
"EB",
|
|
473
|
+
"ZB",
|
|
474
|
+
"YB"
|
|
475
|
+
], i = Math.min(Math.floor(Math.log(n) / Math.log(1024)), r.length - 1), a = Number(n / 1024 ** i), o = r[i];
|
|
476
|
+
return `${a >= 10 || a % 1 == 0 ? Math.round(a) : a.toFixed(1)} ${o}`;
|
|
477
|
+
};
|
|
478
|
+
})), ae = /* @__PURE__ */ t(((e, t) => {
|
|
479
|
+
function n(e, t) {
|
|
480
|
+
this.text = e ||= "", this.hasWild = ~e.indexOf("*"), this.separator = t, this.parts = e.split(t);
|
|
481
|
+
}
|
|
482
|
+
n.prototype.match = function(e) {
|
|
483
|
+
var t = !0, n = this.parts, r, i = n.length, a;
|
|
484
|
+
if (typeof e == "string" || e instanceof String) if (!this.hasWild && this.text != e) t = !1;
|
|
485
|
+
else {
|
|
486
|
+
for (a = (e || "").split(this.separator), r = 0; t && r < i; r++) if (n[r] === "*") continue;
|
|
487
|
+
else t = r < a.length ? n[r] === a[r] : !1;
|
|
488
|
+
t &&= a;
|
|
489
|
+
}
|
|
490
|
+
else if (typeof e.splice == "function") for (t = [], r = e.length; r--;) this.match(e[r]) && (t[t.length] = e[r]);
|
|
491
|
+
else if (typeof e == "object") for (var o in t = {}, e) this.match(o) && (t[o] = e[o]);
|
|
492
|
+
return t;
|
|
493
|
+
}, t.exports = function(e, t, r) {
|
|
494
|
+
var i = new n(e, r || /[\/\.]/);
|
|
495
|
+
return t === void 0 ? i : i.match(t);
|
|
496
|
+
};
|
|
497
|
+
})), oe = /* @__PURE__ */ t(((e, t) => {
|
|
498
|
+
var n = ae(), r = /[\/\+\.]/;
|
|
499
|
+
t.exports = function(e, t) {
|
|
500
|
+
function i(t) {
|
|
501
|
+
var i = n(t, e, r);
|
|
502
|
+
return i && i.length >= 2;
|
|
503
|
+
}
|
|
504
|
+
return t ? i(t.split(";")[0]) : i;
|
|
505
|
+
};
|
|
506
|
+
})), F = /* @__PURE__ */ e(ie(), 1), se = /* @__PURE__ */ e(oe(), 1), ce = {
|
|
507
|
+
maxFileSize: null,
|
|
508
|
+
minFileSize: null,
|
|
509
|
+
maxTotalFileSize: null,
|
|
510
|
+
maxNumberOfFiles: null,
|
|
511
|
+
minNumberOfFiles: null,
|
|
512
|
+
allowedFileTypes: null,
|
|
513
|
+
requiredMetaFields: []
|
|
514
|
+
}, I = class extends Error {
|
|
515
|
+
isUserFacing;
|
|
516
|
+
file;
|
|
517
|
+
constructor(e, t) {
|
|
518
|
+
super(e), this.isUserFacing = t?.isUserFacing ?? !0, t?.file && (this.file = t.file);
|
|
519
|
+
}
|
|
520
|
+
isRestriction = !0;
|
|
521
|
+
}, le = class {
|
|
522
|
+
getI18n;
|
|
523
|
+
getOpts;
|
|
524
|
+
constructor(e, t) {
|
|
525
|
+
this.getI18n = t, this.getOpts = () => {
|
|
526
|
+
let t = e();
|
|
527
|
+
if (t.restrictions?.allowedFileTypes != null && !Array.isArray(t.restrictions.allowedFileTypes)) throw TypeError("`restrictions.allowedFileTypes` must be an array");
|
|
528
|
+
return t;
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
validateAggregateRestrictions(e, t) {
|
|
532
|
+
let { maxTotalFileSize: n, maxNumberOfFiles: r } = this.getOpts().restrictions;
|
|
533
|
+
if (r && e.filter((e) => !e.isGhost).length + t.length > r) throw new I(`${this.getI18n()("youCanOnlyUploadX", { smart_count: r })}`);
|
|
534
|
+
if (n) {
|
|
535
|
+
let r = [...e, ...t].reduce((e, t) => e + (t.size ?? 0), 0);
|
|
536
|
+
if (r > n) throw new I(this.getI18n()("aggregateExceedsSize", {
|
|
537
|
+
sizeAllowed: (0, F.default)(n),
|
|
538
|
+
size: (0, F.default)(r)
|
|
539
|
+
}));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
validateSingleFile(e) {
|
|
543
|
+
let { maxFileSize: t, minFileSize: n, allowedFileTypes: r } = this.getOpts().restrictions;
|
|
544
|
+
if (r && !r.some((t) => t.includes("/") ? e.type ? (0, se.default)(e.type.replace(/;.*?$/, ""), t) : !1 : t[0] === "." && e.extension ? e.extension.toLowerCase() === t.slice(1).toLowerCase() : !1)) {
|
|
545
|
+
let t = r.join(", ");
|
|
546
|
+
throw new I(this.getI18n()("youCanOnlyUploadFileTypes", { types: t }), { file: e });
|
|
547
|
+
}
|
|
548
|
+
if (t && e.size != null && e.size > t) throw new I(this.getI18n()("exceedsSize", {
|
|
549
|
+
size: (0, F.default)(t),
|
|
550
|
+
file: e.name ?? this.getI18n()("unnamed")
|
|
551
|
+
}), { file: e });
|
|
552
|
+
if (n && e.size != null && e.size < n) throw new I(this.getI18n()("inferiorSize", { size: (0, F.default)(n) }), { file: e });
|
|
553
|
+
}
|
|
554
|
+
validate(e, t) {
|
|
555
|
+
t.forEach((e) => {
|
|
556
|
+
this.validateSingleFile(e);
|
|
557
|
+
}), this.validateAggregateRestrictions(e, t);
|
|
558
|
+
}
|
|
559
|
+
validateMinNumberOfFiles(e) {
|
|
560
|
+
let { minNumberOfFiles: t } = this.getOpts().restrictions;
|
|
561
|
+
if (t && Object.keys(e).length < t) throw new I(this.getI18n()("youHaveToAtLeastSelectX", { smart_count: t }));
|
|
562
|
+
}
|
|
563
|
+
getMissingRequiredMetaFields(e) {
|
|
564
|
+
let t = new I(this.getI18n()("missingRequiredMetaFieldOnFile", { fileName: e.name ?? this.getI18n()("unnamed") })), { requiredMetaFields: n } = this.getOpts().restrictions, r = [];
|
|
565
|
+
for (let t of n) (!Object.hasOwn(e.meta, t) || e.meta[t] === "") && r.push(t);
|
|
566
|
+
return {
|
|
567
|
+
missingFields: r,
|
|
568
|
+
error: t
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
}, ue = {
|
|
572
|
+
name: "@uppy/store-default",
|
|
573
|
+
description: "The default simple object-based store for Uppy.",
|
|
574
|
+
version: "5.0.0",
|
|
575
|
+
license: "MIT",
|
|
576
|
+
main: "lib/index.js",
|
|
577
|
+
type: "module",
|
|
578
|
+
sideEffects: !1,
|
|
579
|
+
scripts: {
|
|
580
|
+
build: "tsc --build tsconfig.build.json",
|
|
581
|
+
typecheck: "tsc --build",
|
|
582
|
+
test: "vitest run --environment=jsdom --silent='passed-only'"
|
|
583
|
+
},
|
|
584
|
+
keywords: [
|
|
585
|
+
"file uploader",
|
|
586
|
+
"uppy",
|
|
587
|
+
"uppy-store"
|
|
588
|
+
],
|
|
589
|
+
homepage: "https://uppy.io",
|
|
590
|
+
bugs: { url: "https://github.com/transloadit/uppy/issues" },
|
|
591
|
+
devDependencies: {
|
|
592
|
+
jsdom: "^26.1.0",
|
|
593
|
+
typescript: "^5.8.3",
|
|
594
|
+
vitest: "^3.2.4"
|
|
595
|
+
},
|
|
596
|
+
repository: {
|
|
597
|
+
type: "git",
|
|
598
|
+
url: "git+https://github.com/transloadit/uppy.git"
|
|
599
|
+
},
|
|
600
|
+
exports: {
|
|
601
|
+
".": "./lib/index.js",
|
|
602
|
+
"./package.json": "./package.json"
|
|
603
|
+
},
|
|
604
|
+
files: [
|
|
605
|
+
"src",
|
|
606
|
+
"lib",
|
|
607
|
+
"dist",
|
|
608
|
+
"CHANGELOG.md"
|
|
609
|
+
]
|
|
610
|
+
}, de = class {
|
|
611
|
+
static VERSION = ue.version;
|
|
612
|
+
state = {};
|
|
613
|
+
#e = /* @__PURE__ */ new Set();
|
|
614
|
+
getState() {
|
|
615
|
+
return this.state;
|
|
616
|
+
}
|
|
617
|
+
setState(e) {
|
|
618
|
+
let t = { ...this.state }, n = {
|
|
619
|
+
...this.state,
|
|
620
|
+
...e
|
|
621
|
+
};
|
|
622
|
+
this.state = n, this.#t(t, n, e);
|
|
623
|
+
}
|
|
624
|
+
subscribe(e) {
|
|
625
|
+
return this.#e.add(e), () => {
|
|
626
|
+
this.#e.delete(e);
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
#t(...e) {
|
|
630
|
+
this.#e.forEach((t) => {
|
|
631
|
+
t(...e);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
}, L = /* @__PURE__ */ t(((e, t) => {
|
|
635
|
+
function n(e) {
|
|
636
|
+
var t = typeof e;
|
|
637
|
+
return e != null && (t == "object" || t == "function");
|
|
638
|
+
}
|
|
639
|
+
t.exports = n;
|
|
640
|
+
})), fe = /* @__PURE__ */ t(((e, t) => {
|
|
641
|
+
t.exports = typeof global == "object" && global && global.Object === Object && global;
|
|
642
|
+
})), pe = /* @__PURE__ */ t(((e, t) => {
|
|
643
|
+
var n = fe(), r = typeof self == "object" && self && self.Object === Object && self;
|
|
644
|
+
t.exports = n || r || Function("return this")();
|
|
645
|
+
})), me = /* @__PURE__ */ t(((e, t) => {
|
|
646
|
+
var n = pe();
|
|
647
|
+
t.exports = function() {
|
|
648
|
+
return n.Date.now();
|
|
649
|
+
};
|
|
650
|
+
})), he = /* @__PURE__ */ t(((e, t) => {
|
|
651
|
+
var n = /\s/;
|
|
652
|
+
function r(e) {
|
|
653
|
+
for (var t = e.length; t-- && n.test(e.charAt(t)););
|
|
654
|
+
return t;
|
|
655
|
+
}
|
|
656
|
+
t.exports = r;
|
|
657
|
+
})), ge = /* @__PURE__ */ t(((e, t) => {
|
|
658
|
+
var n = he(), r = /^\s+/;
|
|
659
|
+
function i(e) {
|
|
660
|
+
return e && e.slice(0, n(e) + 1).replace(r, "");
|
|
661
|
+
}
|
|
662
|
+
t.exports = i;
|
|
663
|
+
})), _e = /* @__PURE__ */ t(((e, t) => {
|
|
664
|
+
t.exports = pe().Symbol;
|
|
665
|
+
})), ve = /* @__PURE__ */ t(((e, t) => {
|
|
666
|
+
var n = _e(), r = Object.prototype, i = r.hasOwnProperty, a = r.toString, o = n ? n.toStringTag : void 0;
|
|
667
|
+
function s(e) {
|
|
668
|
+
var t = i.call(e, o), n = e[o];
|
|
669
|
+
try {
|
|
670
|
+
e[o] = void 0;
|
|
671
|
+
var r = !0;
|
|
672
|
+
} catch {}
|
|
673
|
+
var s = a.call(e);
|
|
674
|
+
return r && (t ? e[o] = n : delete e[o]), s;
|
|
675
|
+
}
|
|
676
|
+
t.exports = s;
|
|
677
|
+
})), ye = /* @__PURE__ */ t(((e, t) => {
|
|
678
|
+
var n = Object.prototype.toString;
|
|
679
|
+
function r(e) {
|
|
680
|
+
return n.call(e);
|
|
681
|
+
}
|
|
682
|
+
t.exports = r;
|
|
683
|
+
})), be = /* @__PURE__ */ t(((e, t) => {
|
|
684
|
+
var n = _e(), r = ve(), i = ye(), a = "[object Null]", o = "[object Undefined]", s = n ? n.toStringTag : void 0;
|
|
685
|
+
function c(e) {
|
|
686
|
+
return e == null ? e === void 0 ? o : a : s && s in Object(e) ? r(e) : i(e);
|
|
687
|
+
}
|
|
688
|
+
t.exports = c;
|
|
689
|
+
})), xe = /* @__PURE__ */ t(((e, t) => {
|
|
690
|
+
function n(e) {
|
|
691
|
+
return typeof e == "object" && !!e;
|
|
692
|
+
}
|
|
693
|
+
t.exports = n;
|
|
694
|
+
})), Se = /* @__PURE__ */ t(((e, t) => {
|
|
695
|
+
var n = be(), r = xe(), i = "[object Symbol]";
|
|
696
|
+
function a(e) {
|
|
697
|
+
return typeof e == "symbol" || r(e) && n(e) == i;
|
|
698
|
+
}
|
|
699
|
+
t.exports = a;
|
|
700
|
+
})), Ce = /* @__PURE__ */ t(((e, t) => {
|
|
701
|
+
var n = ge(), r = L(), i = Se(), a = NaN, o = /^[-+]0x[0-9a-f]+$/i, s = /^0b[01]+$/i, c = /^0o[0-7]+$/i, l = parseInt;
|
|
702
|
+
function u(e) {
|
|
703
|
+
if (typeof e == "number") return e;
|
|
704
|
+
if (i(e)) return a;
|
|
705
|
+
if (r(e)) {
|
|
706
|
+
var t = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
707
|
+
e = r(t) ? t + "" : t;
|
|
708
|
+
}
|
|
709
|
+
if (typeof e != "string") return e === 0 ? e : +e;
|
|
710
|
+
e = n(e);
|
|
711
|
+
var u = s.test(e);
|
|
712
|
+
return u || c.test(e) ? l(e.slice(2), u ? 2 : 8) : o.test(e) ? a : +e;
|
|
713
|
+
}
|
|
714
|
+
t.exports = u;
|
|
715
|
+
})), we = /* @__PURE__ */ t(((e, t) => {
|
|
716
|
+
var n = L(), r = me(), i = Ce(), a = "Expected a function", o = Math.max, s = Math.min;
|
|
717
|
+
function c(e, t, c) {
|
|
718
|
+
var l, u, d, f, p, m, h = 0, g = !1, _ = !1, v = !0;
|
|
719
|
+
if (typeof e != "function") throw TypeError(a);
|
|
720
|
+
t = i(t) || 0, n(c) && (g = !!c.leading, _ = "maxWait" in c, d = _ ? o(i(c.maxWait) || 0, t) : d, v = "trailing" in c ? !!c.trailing : v);
|
|
721
|
+
function y(t) {
|
|
722
|
+
var n = l, r = u;
|
|
723
|
+
return l = u = void 0, h = t, f = e.apply(r, n), f;
|
|
724
|
+
}
|
|
725
|
+
function b(e) {
|
|
726
|
+
return h = e, p = setTimeout(C, t), g ? y(e) : f;
|
|
727
|
+
}
|
|
728
|
+
function x(e) {
|
|
729
|
+
var n = e - m, r = e - h, i = t - n;
|
|
730
|
+
return _ ? s(i, d - r) : i;
|
|
731
|
+
}
|
|
732
|
+
function S(e) {
|
|
733
|
+
var n = e - m, r = e - h;
|
|
734
|
+
return m === void 0 || n >= t || n < 0 || _ && r >= d;
|
|
735
|
+
}
|
|
736
|
+
function C() {
|
|
737
|
+
var e = r();
|
|
738
|
+
if (S(e)) return w(e);
|
|
739
|
+
p = setTimeout(C, x(e));
|
|
740
|
+
}
|
|
741
|
+
function w(e) {
|
|
742
|
+
return p = void 0, v && l ? y(e) : (l = u = void 0, f);
|
|
743
|
+
}
|
|
744
|
+
function T() {
|
|
745
|
+
p !== void 0 && clearTimeout(p), h = 0, l = m = u = p = void 0;
|
|
746
|
+
}
|
|
747
|
+
function E() {
|
|
748
|
+
return p === void 0 ? f : w(r());
|
|
749
|
+
}
|
|
750
|
+
function D() {
|
|
751
|
+
var e = r(), n = S(e);
|
|
752
|
+
if (l = arguments, u = this, m = e, n) {
|
|
753
|
+
if (p === void 0) return b(m);
|
|
754
|
+
if (_) return clearTimeout(p), p = setTimeout(C, t), y(m);
|
|
755
|
+
}
|
|
756
|
+
return p === void 0 && (p = setTimeout(C, t)), f;
|
|
757
|
+
}
|
|
758
|
+
return D.cancel = T, D.flush = E, D;
|
|
759
|
+
}
|
|
760
|
+
t.exports = c;
|
|
761
|
+
})), Te = /* @__PURE__ */ t(((e, t) => {
|
|
762
|
+
var n = we(), r = L(), i = "Expected a function";
|
|
763
|
+
function a(e, t, a) {
|
|
764
|
+
var o = !0, s = !0;
|
|
765
|
+
if (typeof e != "function") throw TypeError(i);
|
|
766
|
+
return r(a) && (o = "leading" in a ? !!a.leading : o, s = "trailing" in a ? !!a.trailing : s), n(e, t, {
|
|
767
|
+
leading: o,
|
|
768
|
+
maxWait: t,
|
|
769
|
+
trailing: s
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
t.exports = a;
|
|
773
|
+
})), Ee = /* @__PURE__ */ t(((e, t) => {
|
|
774
|
+
t.exports = function() {
|
|
775
|
+
var e = {}, t = e._fns = {};
|
|
776
|
+
e.emit = function(e, t, i, a, o, s, c) {
|
|
777
|
+
var l = n(e);
|
|
778
|
+
l.length && r(e, l, [
|
|
779
|
+
t,
|
|
780
|
+
i,
|
|
781
|
+
a,
|
|
782
|
+
o,
|
|
783
|
+
s,
|
|
784
|
+
c
|
|
785
|
+
]);
|
|
786
|
+
}, e.on = function(e, n) {
|
|
787
|
+
t[e] || (t[e] = []), t[e].push(n);
|
|
788
|
+
}, e.once = function(t, n) {
|
|
789
|
+
function r() {
|
|
790
|
+
n.apply(this, arguments), e.off(t, r);
|
|
791
|
+
}
|
|
792
|
+
this.on(t, r);
|
|
793
|
+
}, e.off = function(e, t) {
|
|
794
|
+
var n = [];
|
|
795
|
+
if (e && t) for (var r = this._fns[e], i = 0, a = r ? r.length : 0; i < a; i++) r[i] !== t && n.push(r[i]);
|
|
796
|
+
n.length ? this._fns[e] = n : delete this._fns[e];
|
|
797
|
+
};
|
|
798
|
+
function n(e) {
|
|
799
|
+
for (var n = t[e] ? t[e] : [], r = e.indexOf(":"), i = r === -1 ? [e] : [e.substring(0, r), e.substring(r + 1)], a = Object.keys(t), o = 0, s = a.length; o < s; o++) {
|
|
800
|
+
var c = a[o];
|
|
801
|
+
if (c === "*" && (n = n.concat(t[c])), i.length === 2 && i[0] === c) {
|
|
802
|
+
n = n.concat(t[c]);
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
return n;
|
|
807
|
+
}
|
|
808
|
+
function r(e, t, n) {
|
|
809
|
+
for (var r = 0, i = t.length; r < i && t[r]; r++) t[r].event = e, t[r].apply(t[r], n);
|
|
810
|
+
}
|
|
811
|
+
return e;
|
|
812
|
+
};
|
|
813
|
+
})), De = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Oe = (e = 21) => {
|
|
814
|
+
let t = "", n = e | 0;
|
|
815
|
+
for (; n--;) t += De[Math.random() * 64 | 0];
|
|
816
|
+
return t;
|
|
817
|
+
}, ke = {
|
|
818
|
+
name: "@uppy/core",
|
|
819
|
+
description: "Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:",
|
|
820
|
+
version: "5.2.0",
|
|
821
|
+
license: "MIT",
|
|
822
|
+
style: "dist/style.min.css",
|
|
823
|
+
type: "module",
|
|
824
|
+
sideEffects: ["*.css"],
|
|
825
|
+
scripts: {
|
|
826
|
+
build: "tsc --build tsconfig.build.json",
|
|
827
|
+
"build:css": "sass --load-path=../../ src/style.scss dist/style.css && postcss dist/style.css -u cssnano -o dist/style.min.css",
|
|
828
|
+
typecheck: "tsc --build",
|
|
829
|
+
test: "vitest run --environment=jsdom --silent='passed-only'"
|
|
830
|
+
},
|
|
831
|
+
keywords: [
|
|
832
|
+
"file uploader",
|
|
833
|
+
"uppy",
|
|
834
|
+
"uppy-plugin"
|
|
835
|
+
],
|
|
836
|
+
homepage: "https://uppy.io",
|
|
837
|
+
bugs: { url: "https://github.com/transloadit/uppy/issues" },
|
|
838
|
+
repository: {
|
|
839
|
+
type: "git",
|
|
840
|
+
url: "git+https://github.com/transloadit/uppy.git"
|
|
841
|
+
},
|
|
842
|
+
files: [
|
|
843
|
+
"src",
|
|
844
|
+
"lib",
|
|
845
|
+
"dist",
|
|
846
|
+
"CHANGELOG.md"
|
|
847
|
+
],
|
|
848
|
+
exports: {
|
|
849
|
+
".": "./lib/index.js",
|
|
850
|
+
"./css/style.min.css": "./dist/style.min.css",
|
|
851
|
+
"./css/style.css": "./dist/style.css",
|
|
852
|
+
"./css/style.scss": "./src/style.scss",
|
|
853
|
+
"./package.json": "./package.json"
|
|
854
|
+
},
|
|
855
|
+
dependencies: {
|
|
856
|
+
"@transloadit/prettier-bytes": "^0.3.4",
|
|
857
|
+
"@uppy/store-default": "^5.0.0",
|
|
858
|
+
"@uppy/utils": "^7.1.4",
|
|
859
|
+
lodash: "^4.17.21",
|
|
860
|
+
"mime-match": "^1.0.2",
|
|
861
|
+
"namespace-emitter": "^2.0.1",
|
|
862
|
+
nanoid: "^5.0.9",
|
|
863
|
+
preact: "^10.5.13"
|
|
864
|
+
},
|
|
865
|
+
devDependencies: {
|
|
866
|
+
"@types/deep-freeze": "^0",
|
|
867
|
+
cssnano: "^7.0.7",
|
|
868
|
+
"deep-freeze": "^0.0.1",
|
|
869
|
+
jsdom: "^26.1.0",
|
|
870
|
+
postcss: "^8.5.6",
|
|
871
|
+
"postcss-cli": "^11.0.1",
|
|
872
|
+
sass: "^1.89.2",
|
|
873
|
+
typescript: "^5.8.3",
|
|
874
|
+
vitest: "^3.2.4"
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
//#endregion
|
|
878
|
+
//#region ../../node_modules/@uppy/core/lib/getFileName.js
|
|
879
|
+
function Ae(e, t) {
|
|
880
|
+
return t.name ? t.name : e.split("/")[0] === "image" ? `${e.split("/")[0]}.${e.split("/")[1]}` : "noname";
|
|
881
|
+
}
|
|
882
|
+
//#endregion
|
|
883
|
+
//#region ../../node_modules/@uppy/core/lib/locale.js
|
|
884
|
+
var je = { strings: {
|
|
885
|
+
addBulkFilesFailed: {
|
|
886
|
+
0: "Failed to add %{smart_count} file due to an internal error",
|
|
887
|
+
1: "Failed to add %{smart_count} files due to internal errors"
|
|
888
|
+
},
|
|
889
|
+
youCanOnlyUploadX: {
|
|
890
|
+
0: "You can only upload %{smart_count} file",
|
|
891
|
+
1: "You can only upload %{smart_count} files"
|
|
892
|
+
},
|
|
893
|
+
youHaveToAtLeastSelectX: {
|
|
894
|
+
0: "You have to select at least %{smart_count} file",
|
|
895
|
+
1: "You have to select at least %{smart_count} files"
|
|
896
|
+
},
|
|
897
|
+
aggregateExceedsSize: "You selected %{size} of files, but maximum allowed size is %{sizeAllowed}",
|
|
898
|
+
exceedsSize: "%{file} exceeds maximum allowed size of %{size}",
|
|
899
|
+
missingRequiredMetaField: "Missing required meta fields",
|
|
900
|
+
missingRequiredMetaFieldOnFile: "Missing required meta fields in %{fileName}",
|
|
901
|
+
inferiorSize: "This file is smaller than the allowed size of %{size}",
|
|
902
|
+
youCanOnlyUploadFileTypes: "You can only upload: %{types}",
|
|
903
|
+
noMoreFilesAllowed: "Cannot add more files",
|
|
904
|
+
noDuplicates: "Cannot add the duplicate file '%{fileName}', it already exists",
|
|
905
|
+
companionError: "Connection with Companion failed",
|
|
906
|
+
authAborted: "Authentication aborted",
|
|
907
|
+
companionUnauthorizeHint: "To unauthorize to your %{provider} account, please go to %{url}",
|
|
908
|
+
failedToUpload: "Failed to upload %{file}",
|
|
909
|
+
noInternetConnection: "No Internet connection",
|
|
910
|
+
connectedToInternet: "Connected to the Internet",
|
|
911
|
+
noFilesFound: "You have no files or folders here",
|
|
912
|
+
noSearchResults: "Unfortunately, there are no results for this search",
|
|
913
|
+
selectX: {
|
|
914
|
+
0: "Select %{smart_count}",
|
|
915
|
+
1: "Select %{smart_count}"
|
|
916
|
+
},
|
|
917
|
+
allFilesFromFolderNamed: "All files from folder %{name}",
|
|
918
|
+
openFolderNamed: "Open folder %{name}",
|
|
919
|
+
cancel: "Cancel",
|
|
920
|
+
logOut: "Log out",
|
|
921
|
+
logIn: "Log in",
|
|
922
|
+
pickFiles: "Pick files",
|
|
923
|
+
pickPhotos: "Pick photos",
|
|
924
|
+
filter: "Filter",
|
|
925
|
+
resetFilter: "Reset filter",
|
|
926
|
+
loading: "Loading...",
|
|
927
|
+
loadedXFiles: "Loaded %{numFiles} files",
|
|
928
|
+
authenticateWithTitle: "Please authenticate with %{pluginName} to select files",
|
|
929
|
+
authenticateWith: "Connect to %{pluginName}",
|
|
930
|
+
signInWithGoogle: "Sign in with Google",
|
|
931
|
+
searchImages: "Search for images",
|
|
932
|
+
enterTextToSearch: "Enter text to search for images",
|
|
933
|
+
search: "Search",
|
|
934
|
+
resetSearch: "Reset search",
|
|
935
|
+
emptyFolderAdded: "No files were added from empty folder",
|
|
936
|
+
addedNumFiles: "Added %{numFiles} file(s)",
|
|
937
|
+
folderAlreadyAdded: "The folder \"%{folder}\" was already added",
|
|
938
|
+
folderAdded: {
|
|
939
|
+
0: "Added %{smart_count} file from %{folder}",
|
|
940
|
+
1: "Added %{smart_count} files from %{folder}"
|
|
941
|
+
},
|
|
942
|
+
additionalRestrictionsFailed: "%{count} additional restrictions were not fulfilled",
|
|
943
|
+
unnamed: "Unnamed",
|
|
944
|
+
pleaseWait: "Please wait"
|
|
945
|
+
} };
|
|
946
|
+
//#endregion
|
|
947
|
+
//#region ../../node_modules/@uppy/core/lib/supportsUploadProgress.js
|
|
948
|
+
function Me(e) {
|
|
949
|
+
if (e == null && typeof navigator < "u" && (e = navigator.userAgent), !e) return !0;
|
|
950
|
+
let t = /Edge\/(\d+\.\d+)/.exec(e);
|
|
951
|
+
if (!t) return !0;
|
|
952
|
+
let n = t[1].split(".", 2), r = parseInt(n[0], 10), i = parseInt(n[1], 10);
|
|
953
|
+
return r < 15 || r === 15 && i < 15063 || r > 18 || r === 18 && i >= 18218;
|
|
954
|
+
}
|
|
955
|
+
//#endregion
|
|
956
|
+
//#region ../../node_modules/@uppy/core/lib/Uppy.js
|
|
957
|
+
var Ne = /* @__PURE__ */ e(Te(), 1), Pe = /* @__PURE__ */ e(Ee(), 1), R = {
|
|
958
|
+
totalProgress: 0,
|
|
959
|
+
allowNewUpload: !0,
|
|
960
|
+
error: null,
|
|
961
|
+
recoveredState: null
|
|
962
|
+
}, Fe = class e {
|
|
963
|
+
static VERSION = ke.version;
|
|
964
|
+
#e = Object.create(null);
|
|
965
|
+
#t;
|
|
966
|
+
#n;
|
|
967
|
+
#r = (0, Pe.default)();
|
|
968
|
+
#i = /* @__PURE__ */ new Set();
|
|
969
|
+
#a = /* @__PURE__ */ new Set();
|
|
970
|
+
#o = /* @__PURE__ */ new Set();
|
|
971
|
+
defaultLocale;
|
|
972
|
+
locale;
|
|
973
|
+
opts;
|
|
974
|
+
store;
|
|
975
|
+
i18n;
|
|
976
|
+
i18nArray;
|
|
977
|
+
scheduledAutoProceed = null;
|
|
978
|
+
wasOffline = !1;
|
|
979
|
+
constructor(t) {
|
|
980
|
+
this.defaultLocale = je;
|
|
981
|
+
let n = {
|
|
982
|
+
id: "uppy",
|
|
983
|
+
autoProceed: !1,
|
|
984
|
+
allowMultipleUploadBatches: !0,
|
|
985
|
+
debug: !1,
|
|
986
|
+
restrictions: ce,
|
|
987
|
+
meta: {},
|
|
988
|
+
onBeforeFileAdded: (e, t) => !Object.hasOwn(t, e.id),
|
|
989
|
+
onBeforeUpload: (e) => e,
|
|
990
|
+
store: new de(),
|
|
991
|
+
logger: ne,
|
|
992
|
+
infoTimeout: 5e3
|
|
993
|
+
}, r = {
|
|
994
|
+
...n,
|
|
995
|
+
...t
|
|
996
|
+
};
|
|
997
|
+
this.opts = {
|
|
998
|
+
...r,
|
|
999
|
+
restrictions: {
|
|
1000
|
+
...n.restrictions,
|
|
1001
|
+
...t?.restrictions
|
|
1002
|
+
}
|
|
1003
|
+
}, t?.logger && t.debug ? this.log("You are using a custom `logger`, but also set `debug: true`, which uses built-in logger to output logs to console. Ignoring `debug: true` and using your custom `logger`.", "warning") : t?.debug && (this.opts.logger = re), this.log(`Using Core v${e.VERSION}`), this.i18nInit(), this.store = this.opts.store, this.setState({
|
|
1004
|
+
...R,
|
|
1005
|
+
plugins: {},
|
|
1006
|
+
files: {},
|
|
1007
|
+
currentUploads: {},
|
|
1008
|
+
capabilities: {
|
|
1009
|
+
uploadProgress: Me(),
|
|
1010
|
+
individualCancellation: !0,
|
|
1011
|
+
resumableUploads: !1
|
|
1012
|
+
},
|
|
1013
|
+
meta: { ...this.opts.meta },
|
|
1014
|
+
info: []
|
|
1015
|
+
}), this.#t = new le(() => this.opts, () => this.i18n), this.#n = this.store.subscribe((e, t, n) => {
|
|
1016
|
+
this.emit("state-update", e, t, n), this.updateAll(t);
|
|
1017
|
+
}), this.opts.debug && typeof window < "u" && (window[this.opts.id] = this), this.#b();
|
|
1018
|
+
}
|
|
1019
|
+
emit(e, ...t) {
|
|
1020
|
+
this.#r.emit(e, ...t);
|
|
1021
|
+
}
|
|
1022
|
+
on(e, t) {
|
|
1023
|
+
return this.#r.on(e, t), this;
|
|
1024
|
+
}
|
|
1025
|
+
once(e, t) {
|
|
1026
|
+
return this.#r.once(e, t), this;
|
|
1027
|
+
}
|
|
1028
|
+
off(e, t) {
|
|
1029
|
+
return this.#r.off(e, t), this;
|
|
1030
|
+
}
|
|
1031
|
+
updateAll(e) {
|
|
1032
|
+
this.iteratePlugins((t) => {
|
|
1033
|
+
t.update(e);
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
setState(e) {
|
|
1037
|
+
this.store.setState(e);
|
|
1038
|
+
}
|
|
1039
|
+
getState() {
|
|
1040
|
+
return this.store.getState();
|
|
1041
|
+
}
|
|
1042
|
+
patchFilesState(e) {
|
|
1043
|
+
let t = this.getState().files;
|
|
1044
|
+
this.setState({ files: {
|
|
1045
|
+
...t,
|
|
1046
|
+
...Object.fromEntries(Object.entries(e).map(([e, n]) => [e, {
|
|
1047
|
+
...t[e],
|
|
1048
|
+
...n
|
|
1049
|
+
}]))
|
|
1050
|
+
} });
|
|
1051
|
+
}
|
|
1052
|
+
setFileState(e, t) {
|
|
1053
|
+
if (!this.getState().files[e]) throw Error(`Can’t set state for ${e} (the file could have been removed)`);
|
|
1054
|
+
this.patchFilesState({ [e]: t });
|
|
1055
|
+
}
|
|
1056
|
+
i18nInit() {
|
|
1057
|
+
let e = new M([this.defaultLocale, this.opts.locale], { onMissingKey: (e) => this.log(`Missing i18n string: ${e}`, "error") });
|
|
1058
|
+
this.i18n = e.translate.bind(e), this.i18nArray = e.translateArray.bind(e), this.locale = e.locale;
|
|
1059
|
+
}
|
|
1060
|
+
setOptions(e) {
|
|
1061
|
+
this.opts = {
|
|
1062
|
+
...this.opts,
|
|
1063
|
+
...e,
|
|
1064
|
+
restrictions: {
|
|
1065
|
+
...this.opts.restrictions,
|
|
1066
|
+
...e?.restrictions
|
|
1067
|
+
}
|
|
1068
|
+
}, e.meta && this.setMeta(e.meta), this.i18nInit(), e.locale && this.iteratePlugins((t) => {
|
|
1069
|
+
t.setOptions(e);
|
|
1070
|
+
}), this.setState(void 0);
|
|
1071
|
+
}
|
|
1072
|
+
resetProgress() {
|
|
1073
|
+
let e = {
|
|
1074
|
+
percentage: 0,
|
|
1075
|
+
bytesUploaded: !1,
|
|
1076
|
+
uploadComplete: !1,
|
|
1077
|
+
uploadStarted: null
|
|
1078
|
+
}, t = { ...this.getState().files }, n = Object.create(null);
|
|
1079
|
+
Object.keys(t).forEach((r) => {
|
|
1080
|
+
n[r] = {
|
|
1081
|
+
...t[r],
|
|
1082
|
+
progress: {
|
|
1083
|
+
...t[r].progress,
|
|
1084
|
+
...e
|
|
1085
|
+
},
|
|
1086
|
+
tus: void 0,
|
|
1087
|
+
transloadit: void 0
|
|
1088
|
+
};
|
|
1089
|
+
}), this.setState({
|
|
1090
|
+
files: n,
|
|
1091
|
+
...R
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
clear() {
|
|
1095
|
+
let { capabilities: e, currentUploads: t } = this.getState();
|
|
1096
|
+
if (Object.keys(t).length > 0 && !e.individualCancellation) throw Error("The installed uploader plugin does not allow removing files during an upload.");
|
|
1097
|
+
this.setState({
|
|
1098
|
+
...R,
|
|
1099
|
+
files: {}
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
addPreProcessor(e) {
|
|
1103
|
+
this.#i.add(e);
|
|
1104
|
+
}
|
|
1105
|
+
removePreProcessor(e) {
|
|
1106
|
+
return this.#i.delete(e);
|
|
1107
|
+
}
|
|
1108
|
+
addPostProcessor(e) {
|
|
1109
|
+
this.#o.add(e);
|
|
1110
|
+
}
|
|
1111
|
+
removePostProcessor(e) {
|
|
1112
|
+
return this.#o.delete(e);
|
|
1113
|
+
}
|
|
1114
|
+
addUploader(e) {
|
|
1115
|
+
this.#a.add(e);
|
|
1116
|
+
}
|
|
1117
|
+
removeUploader(e) {
|
|
1118
|
+
return this.#a.delete(e);
|
|
1119
|
+
}
|
|
1120
|
+
setMeta(e) {
|
|
1121
|
+
let t = {
|
|
1122
|
+
...this.getState().meta,
|
|
1123
|
+
...e
|
|
1124
|
+
}, n = { ...this.getState().files };
|
|
1125
|
+
Object.keys(n).forEach((t) => {
|
|
1126
|
+
n[t] = {
|
|
1127
|
+
...n[t],
|
|
1128
|
+
meta: {
|
|
1129
|
+
...n[t].meta,
|
|
1130
|
+
...e
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}), this.log("Adding metadata:"), this.log(e), this.setState({
|
|
1134
|
+
meta: t,
|
|
1135
|
+
files: n
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
setFileMeta(e, t) {
|
|
1139
|
+
let n = { ...this.getState().files };
|
|
1140
|
+
if (!n[e]) {
|
|
1141
|
+
this.log(`Was trying to set metadata for a file that has been removed: ${e}`);
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
let r = {
|
|
1145
|
+
...n[e].meta,
|
|
1146
|
+
...t
|
|
1147
|
+
};
|
|
1148
|
+
n[e] = {
|
|
1149
|
+
...n[e],
|
|
1150
|
+
meta: r
|
|
1151
|
+
}, this.setState({ files: n });
|
|
1152
|
+
}
|
|
1153
|
+
getFile(e) {
|
|
1154
|
+
return this.getState().files[e];
|
|
1155
|
+
}
|
|
1156
|
+
getFiles() {
|
|
1157
|
+
let { files: e } = this.getState();
|
|
1158
|
+
return Object.values(e);
|
|
1159
|
+
}
|
|
1160
|
+
getFilesByIds(e) {
|
|
1161
|
+
return e.map((e) => this.getFile(e));
|
|
1162
|
+
}
|
|
1163
|
+
getObjectOfFilesPerState() {
|
|
1164
|
+
let { files: e, totalProgress: t, error: n } = this.getState(), r = Object.values(e), i = [], a = [], o = [], s = [], c = [], l = [], u = [], d = [], f = [];
|
|
1165
|
+
for (let e of r) {
|
|
1166
|
+
let { progress: t } = e;
|
|
1167
|
+
!t.uploadComplete && t.uploadStarted && (i.push(e), e.isPaused || d.push(e)), t.uploadStarted || a.push(e), (t.uploadStarted || t.preprocess || t.postprocess) && o.push(e), t.uploadStarted && s.push(e), e.isPaused && c.push(e), t.uploadComplete && l.push(e), e.error && u.push(e), (t.preprocess || t.postprocess) && f.push(e);
|
|
1168
|
+
}
|
|
1169
|
+
return {
|
|
1170
|
+
newFiles: a,
|
|
1171
|
+
startedFiles: o,
|
|
1172
|
+
uploadStartedFiles: s,
|
|
1173
|
+
pausedFiles: c,
|
|
1174
|
+
completeFiles: l,
|
|
1175
|
+
erroredFiles: u,
|
|
1176
|
+
inProgressFiles: i,
|
|
1177
|
+
inProgressNotPausedFiles: d,
|
|
1178
|
+
processingFiles: f,
|
|
1179
|
+
isUploadStarted: s.length > 0,
|
|
1180
|
+
isAllComplete: t === 100 && l.length === r.length && f.length === 0,
|
|
1181
|
+
isAllErrored: !!n && u.length === r.length,
|
|
1182
|
+
isAllPaused: i.length !== 0 && c.length === i.length,
|
|
1183
|
+
isUploadInProgress: i.length > 0,
|
|
1184
|
+
isSomeGhost: r.some((e) => e.isGhost)
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
#s(e) {
|
|
1188
|
+
for (let t of e) t.isRestriction ? this.emit("restriction-failed", t.file, t) : this.emit("error", t, t.file), this.log(t, "warning");
|
|
1189
|
+
let t = e.filter((e) => e.isUserFacing), n = t.slice(0, 4), r = t.slice(4);
|
|
1190
|
+
n.forEach(({ message: e, details: t = "" }) => {
|
|
1191
|
+
this.info({
|
|
1192
|
+
message: e,
|
|
1193
|
+
details: t
|
|
1194
|
+
}, "error", this.opts.infoTimeout);
|
|
1195
|
+
}), r.length > 0 && this.info({ message: this.i18n("additionalRestrictionsFailed", { count: r.length }) });
|
|
1196
|
+
}
|
|
1197
|
+
validateRestrictions(e, t = this.getFiles()) {
|
|
1198
|
+
try {
|
|
1199
|
+
this.#t.validate(t, [e]);
|
|
1200
|
+
} catch (e) {
|
|
1201
|
+
return e;
|
|
1202
|
+
}
|
|
1203
|
+
return null;
|
|
1204
|
+
}
|
|
1205
|
+
validateSingleFile(e) {
|
|
1206
|
+
try {
|
|
1207
|
+
this.#t.validateSingleFile(e);
|
|
1208
|
+
} catch (e) {
|
|
1209
|
+
return e.message;
|
|
1210
|
+
}
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
validateAggregateRestrictions(e) {
|
|
1214
|
+
let t = this.getFiles();
|
|
1215
|
+
try {
|
|
1216
|
+
this.#t.validateAggregateRestrictions(t, e);
|
|
1217
|
+
} catch (e) {
|
|
1218
|
+
return e.message;
|
|
1219
|
+
}
|
|
1220
|
+
return null;
|
|
1221
|
+
}
|
|
1222
|
+
#c(e) {
|
|
1223
|
+
let { missingFields: t, error: n } = this.#t.getMissingRequiredMetaFields(e);
|
|
1224
|
+
return t.length > 0 ? (this.setFileState(e.id, {
|
|
1225
|
+
missingRequiredMetaFields: t,
|
|
1226
|
+
error: n.message
|
|
1227
|
+
}), this.log(n.message), this.emit("restriction-failed", e, n), !1) : (t.length === 0 && e.missingRequiredMetaFields && this.setFileState(e.id, { missingRequiredMetaFields: [] }), !0);
|
|
1228
|
+
}
|
|
1229
|
+
#l(e) {
|
|
1230
|
+
let t = !0;
|
|
1231
|
+
for (let n of Object.values(e)) this.#c(n) || (t = !1);
|
|
1232
|
+
return t;
|
|
1233
|
+
}
|
|
1234
|
+
#u(e) {
|
|
1235
|
+
let { allowNewUpload: t } = this.getState();
|
|
1236
|
+
if (t === !1) {
|
|
1237
|
+
let t = new I(this.i18n("noMoreFilesAllowed"), { file: e });
|
|
1238
|
+
throw this.#s([t]), t;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
checkIfFileAlreadyExists(e) {
|
|
1242
|
+
let { files: t } = this.getState();
|
|
1243
|
+
return !!(t[e] && !t[e].isGhost);
|
|
1244
|
+
}
|
|
1245
|
+
#d(e) {
|
|
1246
|
+
let t = e instanceof File ? {
|
|
1247
|
+
name: e.name,
|
|
1248
|
+
type: e.type,
|
|
1249
|
+
size: e.size,
|
|
1250
|
+
data: e,
|
|
1251
|
+
meta: {},
|
|
1252
|
+
isRemote: !1,
|
|
1253
|
+
source: void 0,
|
|
1254
|
+
preview: void 0
|
|
1255
|
+
} : e, n = b(t), r = Ae(n, t), i = v(r).extension, a = T(t, this.getID()), o = {
|
|
1256
|
+
...t.meta,
|
|
1257
|
+
name: r,
|
|
1258
|
+
type: n
|
|
1259
|
+
}, s = Number.isFinite(t.data.size) ? t.data.size : null;
|
|
1260
|
+
return {
|
|
1261
|
+
source: t.source || "",
|
|
1262
|
+
id: a,
|
|
1263
|
+
name: r,
|
|
1264
|
+
extension: i || "",
|
|
1265
|
+
meta: {
|
|
1266
|
+
...this.getState().meta,
|
|
1267
|
+
...o
|
|
1268
|
+
},
|
|
1269
|
+
type: n,
|
|
1270
|
+
progress: {
|
|
1271
|
+
percentage: 0,
|
|
1272
|
+
bytesUploaded: !1,
|
|
1273
|
+
bytesTotal: s,
|
|
1274
|
+
uploadComplete: !1,
|
|
1275
|
+
uploadStarted: null
|
|
1276
|
+
},
|
|
1277
|
+
size: s,
|
|
1278
|
+
isGhost: !1,
|
|
1279
|
+
...t.isRemote ? {
|
|
1280
|
+
isRemote: !0,
|
|
1281
|
+
remote: t.remote,
|
|
1282
|
+
data: t.data
|
|
1283
|
+
} : {
|
|
1284
|
+
isRemote: !1,
|
|
1285
|
+
data: t.data
|
|
1286
|
+
},
|
|
1287
|
+
preview: t.preview
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
#f() {
|
|
1291
|
+
this.opts.autoProceed && !this.scheduledAutoProceed && (this.scheduledAutoProceed = setTimeout(() => {
|
|
1292
|
+
this.scheduledAutoProceed = null, this.upload().catch((e) => {
|
|
1293
|
+
e.isRestriction || this.log(e.stack || e.message || e);
|
|
1294
|
+
});
|
|
1295
|
+
}, 4));
|
|
1296
|
+
}
|
|
1297
|
+
#p(e) {
|
|
1298
|
+
let { files: t } = this.getState(), n = { ...t }, r = [], i = [];
|
|
1299
|
+
for (let a of e) try {
|
|
1300
|
+
let e = this.#d(a);
|
|
1301
|
+
this.#u(e);
|
|
1302
|
+
let i = t[e.id], o = i?.isGhost;
|
|
1303
|
+
if (o && !e.isRemote) {
|
|
1304
|
+
if (e.data == null) throw Error("File data is missing");
|
|
1305
|
+
e = {
|
|
1306
|
+
...i,
|
|
1307
|
+
isGhost: !1,
|
|
1308
|
+
data: e.data
|
|
1309
|
+
}, this.log(`Replaced the blob in the restored ghost file: ${e.name}, ${e.id}`);
|
|
1310
|
+
}
|
|
1311
|
+
let s = this.opts.onBeforeFileAdded(e, n);
|
|
1312
|
+
if (t = this.getState().files, n = {
|
|
1313
|
+
...t,
|
|
1314
|
+
...n
|
|
1315
|
+
}, !s && this.checkIfFileAlreadyExists(e.id)) throw new I(this.i18n("noDuplicates", { fileName: e.name ?? this.i18n("unnamed") }), { file: e });
|
|
1316
|
+
if (s === !1 && !o) throw new I("Cannot add the file because onBeforeFileAdded returned false.", {
|
|
1317
|
+
isUserFacing: !1,
|
|
1318
|
+
file: e
|
|
1319
|
+
});
|
|
1320
|
+
typeof s == "object" && s && (e = s), this.#t.validateSingleFile(e), n[e.id] = e, r.push(e);
|
|
1321
|
+
} catch (e) {
|
|
1322
|
+
i.push(e);
|
|
1323
|
+
}
|
|
1324
|
+
try {
|
|
1325
|
+
this.#t.validateAggregateRestrictions(Object.values(t), r);
|
|
1326
|
+
} catch (e) {
|
|
1327
|
+
return i.push(e), {
|
|
1328
|
+
nextFilesState: t,
|
|
1329
|
+
validFilesToAdd: [],
|
|
1330
|
+
errors: i
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
return {
|
|
1334
|
+
nextFilesState: n,
|
|
1335
|
+
validFilesToAdd: r,
|
|
1336
|
+
errors: i
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
addFile(e) {
|
|
1340
|
+
let { nextFilesState: t, validFilesToAdd: n, errors: r } = this.#p([e]), i = r.filter((e) => e.isRestriction);
|
|
1341
|
+
if (this.#s(i), r.length > 0) throw r[0];
|
|
1342
|
+
this.setState({ files: t });
|
|
1343
|
+
let [a] = n;
|
|
1344
|
+
return this.emit("file-added", a), this.emit("files-added", n), this.log(`Added file: ${a.name}, ${a.id}, mime type: ${a.type}`), this.#f(), a.id;
|
|
1345
|
+
}
|
|
1346
|
+
addFiles(e) {
|
|
1347
|
+
let { nextFilesState: t, validFilesToAdd: n, errors: r } = this.#p(e), i = r.filter((e) => e.isRestriction);
|
|
1348
|
+
this.#s(i);
|
|
1349
|
+
let a = r.filter((e) => !e.isRestriction);
|
|
1350
|
+
if (a.length > 0) {
|
|
1351
|
+
let e = "Multiple errors occurred while adding files:\n";
|
|
1352
|
+
if (a.forEach((t) => {
|
|
1353
|
+
e += `\n * ${t.message}`;
|
|
1354
|
+
}), this.info({
|
|
1355
|
+
message: this.i18n("addBulkFilesFailed", { smart_count: a.length }),
|
|
1356
|
+
details: e
|
|
1357
|
+
}, "error", this.opts.infoTimeout), typeof AggregateError == "function") throw AggregateError(a, e);
|
|
1358
|
+
{
|
|
1359
|
+
let t = Error(e);
|
|
1360
|
+
throw t.errors = a, t;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
this.setState({ files: t }), n.forEach((e) => {
|
|
1364
|
+
this.emit("file-added", e);
|
|
1365
|
+
}), this.emit("files-added", n), n.length > 5 ? this.log(`Added batch of ${n.length} files`) : Object.values(n).forEach((e) => {
|
|
1366
|
+
this.log(`Added file: ${e.name}\n id: ${e.id}\n type: ${e.type}`);
|
|
1367
|
+
}), n.length > 0 && this.#f();
|
|
1368
|
+
}
|
|
1369
|
+
removeFiles(e) {
|
|
1370
|
+
let { files: t, currentUploads: n } = this.getState(), r = { ...t }, i = { ...n }, a = Object.create(null);
|
|
1371
|
+
e.forEach((e) => {
|
|
1372
|
+
t[e] && (a[e] = t[e], delete r[e]);
|
|
1373
|
+
});
|
|
1374
|
+
function o(e) {
|
|
1375
|
+
return a[e] === void 0;
|
|
1376
|
+
}
|
|
1377
|
+
Object.keys(i).forEach((e) => {
|
|
1378
|
+
let t = n[e].fileIDs.filter(o);
|
|
1379
|
+
if (t.length === 0) {
|
|
1380
|
+
delete i[e];
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
let { capabilities: r } = this.getState();
|
|
1384
|
+
if (t.length !== n[e].fileIDs.length && !r.individualCancellation) throw Error("The installed uploader plugin does not allow removing files during an upload.");
|
|
1385
|
+
i[e] = {
|
|
1386
|
+
...n[e],
|
|
1387
|
+
fileIDs: t
|
|
1388
|
+
};
|
|
1389
|
+
});
|
|
1390
|
+
let s = {
|
|
1391
|
+
currentUploads: i,
|
|
1392
|
+
files: r
|
|
1393
|
+
};
|
|
1394
|
+
Object.keys(r).length === 0 && (s.allowNewUpload = !0, s.error = null, s.recoveredState = null), this.setState(s), this.#v();
|
|
1395
|
+
let c = Object.keys(a);
|
|
1396
|
+
c.forEach((e) => {
|
|
1397
|
+
this.emit("file-removed", a[e]);
|
|
1398
|
+
}), c.length > 5 ? this.log(`Removed ${c.length} files`) : this.log(`Removed files: ${c.join(", ")}`);
|
|
1399
|
+
}
|
|
1400
|
+
removeFile(e) {
|
|
1401
|
+
this.removeFiles([e]);
|
|
1402
|
+
}
|
|
1403
|
+
pauseResume(e) {
|
|
1404
|
+
if (!this.getState().capabilities.resumableUploads || this.getFile(e).progress.uploadComplete) return;
|
|
1405
|
+
let t = this.getFile(e), n = !t.isPaused;
|
|
1406
|
+
return this.setFileState(e, { isPaused: n }), this.emit("upload-pause", t, n), n;
|
|
1407
|
+
}
|
|
1408
|
+
pauseAll() {
|
|
1409
|
+
let e = { ...this.getState().files };
|
|
1410
|
+
Object.keys(e).filter((t) => !e[t].progress.uploadComplete && e[t].progress.uploadStarted).forEach((t) => {
|
|
1411
|
+
e[t] = {
|
|
1412
|
+
...e[t],
|
|
1413
|
+
isPaused: !0
|
|
1414
|
+
};
|
|
1415
|
+
}), this.setState({ files: e }), this.emit("pause-all");
|
|
1416
|
+
}
|
|
1417
|
+
resumeAll() {
|
|
1418
|
+
let e = { ...this.getState().files };
|
|
1419
|
+
Object.keys(e).filter((t) => !e[t].progress.uploadComplete && e[t].progress.uploadStarted).forEach((t) => {
|
|
1420
|
+
e[t] = {
|
|
1421
|
+
...e[t],
|
|
1422
|
+
isPaused: !1,
|
|
1423
|
+
error: null
|
|
1424
|
+
};
|
|
1425
|
+
}), this.setState({ files: e }), this.emit("resume-all");
|
|
1426
|
+
}
|
|
1427
|
+
#m() {
|
|
1428
|
+
let { files: e } = this.getState();
|
|
1429
|
+
return Object.keys(e).filter((t) => {
|
|
1430
|
+
let n = e[t];
|
|
1431
|
+
return n.error && (!n.missingRequiredMetaFields || n.missingRequiredMetaFields.length === 0);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
async #h() {
|
|
1435
|
+
let e = this.#m(), t = { ...this.getState().files };
|
|
1436
|
+
if (e.forEach((e) => {
|
|
1437
|
+
t[e] = {
|
|
1438
|
+
...t[e],
|
|
1439
|
+
isPaused: !1,
|
|
1440
|
+
error: null
|
|
1441
|
+
};
|
|
1442
|
+
}), this.setState({
|
|
1443
|
+
files: t,
|
|
1444
|
+
error: null
|
|
1445
|
+
}), this.emit("retry-all", this.getFilesByIds(e)), e.length === 0) return {
|
|
1446
|
+
successful: [],
|
|
1447
|
+
failed: []
|
|
1448
|
+
};
|
|
1449
|
+
let n = this.#C(e, { forceAllowNewUpload: !0 });
|
|
1450
|
+
return this.#E(n);
|
|
1451
|
+
}
|
|
1452
|
+
async retryAll() {
|
|
1453
|
+
let e = await this.#h();
|
|
1454
|
+
return this.emit("complete", e), e;
|
|
1455
|
+
}
|
|
1456
|
+
cancelAll() {
|
|
1457
|
+
this.emit("cancel-all");
|
|
1458
|
+
let { files: e } = this.getState(), t = Object.keys(e);
|
|
1459
|
+
t.length && this.removeFiles(t), this.setState(R);
|
|
1460
|
+
}
|
|
1461
|
+
retryUpload(e) {
|
|
1462
|
+
this.setFileState(e, {
|
|
1463
|
+
error: null,
|
|
1464
|
+
isPaused: !1
|
|
1465
|
+
}), this.emit("upload-retry", this.getFile(e));
|
|
1466
|
+
let t = this.#C([e], { forceAllowNewUpload: !0 });
|
|
1467
|
+
return this.#E(t);
|
|
1468
|
+
}
|
|
1469
|
+
logout() {
|
|
1470
|
+
this.iteratePlugins((e) => {
|
|
1471
|
+
e.provider?.logout?.();
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
#g = (e, t) => {
|
|
1475
|
+
let n = e ? this.getFile(e.id) : void 0;
|
|
1476
|
+
if (e == null || !n) {
|
|
1477
|
+
this.log(`Not setting progress for a file that has been removed: ${e?.id}`);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
if (n.progress.percentage === 100) {
|
|
1481
|
+
this.log(`Not setting progress for a file that has been already uploaded: ${e.id}`);
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
let r = {
|
|
1485
|
+
bytesTotal: t.bytesTotal,
|
|
1486
|
+
percentage: t.bytesTotal != null && Number.isFinite(t.bytesTotal) && t.bytesTotal > 0 ? Math.round(t.bytesUploaded / t.bytesTotal * 100) : void 0
|
|
1487
|
+
};
|
|
1488
|
+
n.progress.uploadStarted == null ? this.setFileState(e.id, { progress: {
|
|
1489
|
+
...n.progress,
|
|
1490
|
+
...r
|
|
1491
|
+
} }) : this.setFileState(e.id, { progress: {
|
|
1492
|
+
...n.progress,
|
|
1493
|
+
...r,
|
|
1494
|
+
bytesUploaded: t.bytesUploaded
|
|
1495
|
+
} }), this.#v();
|
|
1496
|
+
};
|
|
1497
|
+
#_() {
|
|
1498
|
+
let e = this.#y(), t = null;
|
|
1499
|
+
e != null && (t = Math.round(e * 100), t > 100 ? t = 100 : t < 0 && (t = 0)), this.emit("progress", t ?? 0), this.setState({ totalProgress: t ?? 0 });
|
|
1500
|
+
}
|
|
1501
|
+
#v = (0, Ne.default)(() => this.#_(), 500, {
|
|
1502
|
+
leading: !0,
|
|
1503
|
+
trailing: !0
|
|
1504
|
+
});
|
|
1505
|
+
[Symbol.for("uppy test: updateTotalProgress")]() {
|
|
1506
|
+
return this.#_();
|
|
1507
|
+
}
|
|
1508
|
+
#y() {
|
|
1509
|
+
let e = this.getFiles().filter((e) => e.progress.uploadStarted || e.progress.preprocess || e.progress.postprocess);
|
|
1510
|
+
if (e.length === 0) return 0;
|
|
1511
|
+
if (e.every((e) => e.progress.uploadComplete)) return 1;
|
|
1512
|
+
let t = (e) => e.progress.bytesTotal != null && e.progress.bytesTotal !== 0, n = e.filter(t), r = e.filter((e) => !t(e));
|
|
1513
|
+
if (n.every((e) => e.progress.uploadComplete) && r.length > 0 && !r.every((e) => e.progress.uploadComplete)) return null;
|
|
1514
|
+
let i = n.reduce((e, t) => e + (t.progress.bytesTotal ?? 0), 0), a = n.reduce((e, t) => e + (t.progress.bytesUploaded || 0), 0);
|
|
1515
|
+
return i === 0 ? 0 : a / i;
|
|
1516
|
+
}
|
|
1517
|
+
#b() {
|
|
1518
|
+
let e = (e, t, n) => {
|
|
1519
|
+
let r = e.message || "Unknown error";
|
|
1520
|
+
e.details && (r += ` ${e.details}`), this.setState({ error: r }), t != null && t.id in this.getState().files && this.setFileState(t.id, {
|
|
1521
|
+
error: r,
|
|
1522
|
+
response: n
|
|
1523
|
+
});
|
|
1524
|
+
};
|
|
1525
|
+
this.on("error", e), this.on("upload-error", (t, n, r) => {
|
|
1526
|
+
if (e(n, t, r), typeof n == "object" && n.message) {
|
|
1527
|
+
this.log(n.message, "error");
|
|
1528
|
+
let e = Error(this.i18n("failedToUpload", { file: t?.name ?? "" }));
|
|
1529
|
+
e.isUserFacing = !0, e.details = n.message, n.details && (e.details += ` ${n.details}`), this.#s([e]);
|
|
1530
|
+
} else this.#s([n]);
|
|
1531
|
+
});
|
|
1532
|
+
let t = null;
|
|
1533
|
+
this.on("upload-stalled", (e, n) => {
|
|
1534
|
+
let { message: r } = e, i = n.map((e) => e.meta.name).join(", ");
|
|
1535
|
+
t ||= (this.info({
|
|
1536
|
+
message: r,
|
|
1537
|
+
details: i
|
|
1538
|
+
}, "warning", this.opts.infoTimeout), setTimeout(() => {
|
|
1539
|
+
t = null;
|
|
1540
|
+
}, this.opts.infoTimeout)), this.log(`${r} ${i}`.trim(), "warning");
|
|
1541
|
+
}), this.on("upload", () => {
|
|
1542
|
+
this.setState({ error: null });
|
|
1543
|
+
}), this.on("upload-start", (e) => {
|
|
1544
|
+
let t = e.filter((e) => {
|
|
1545
|
+
let t = e != null && this.getFile(e.id);
|
|
1546
|
+
return t || this.log(`Not setting progress for a file that has been removed: ${e?.id}`), t;
|
|
1547
|
+
}), n = Object.fromEntries(t.map((e) => [e.id, { progress: {
|
|
1548
|
+
uploadStarted: Date.now(),
|
|
1549
|
+
uploadComplete: !1,
|
|
1550
|
+
bytesUploaded: 0,
|
|
1551
|
+
bytesTotal: e.size
|
|
1552
|
+
} }]));
|
|
1553
|
+
this.patchFilesState(n);
|
|
1554
|
+
}), this.on("upload-progress", this.#g), this.on("upload-success", (e, t) => {
|
|
1555
|
+
if (e == null || !this.getFile(e.id)) {
|
|
1556
|
+
this.log(`Not setting progress for a file that has been removed: ${e?.id}`);
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
let n = this.getFile(e.id).progress, r = this.#o.size > 0;
|
|
1560
|
+
this.setFileState(e.id, {
|
|
1561
|
+
progress: {
|
|
1562
|
+
...n,
|
|
1563
|
+
postprocess: r ? { mode: "indeterminate" } : void 0,
|
|
1564
|
+
uploadComplete: !0,
|
|
1565
|
+
...!r && { complete: !0 },
|
|
1566
|
+
percentage: 100,
|
|
1567
|
+
bytesUploaded: n.bytesTotal
|
|
1568
|
+
},
|
|
1569
|
+
response: t,
|
|
1570
|
+
uploadURL: t.uploadURL,
|
|
1571
|
+
isPaused: !1
|
|
1572
|
+
}), e.size ?? this.setFileState(e.id, { size: t.bytesUploaded || n.bytesTotal }), this.#v();
|
|
1573
|
+
}), this.on("preprocess-progress", (e, t) => {
|
|
1574
|
+
if (e == null || !this.getFile(e.id)) {
|
|
1575
|
+
this.log(`Not setting progress for a file that has been removed: ${e?.id}`);
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1578
|
+
this.setFileState(e.id, { progress: {
|
|
1579
|
+
...this.getFile(e.id).progress,
|
|
1580
|
+
preprocess: t
|
|
1581
|
+
} });
|
|
1582
|
+
}), this.on("preprocess-complete", (e) => {
|
|
1583
|
+
if (e == null || !this.getFile(e.id)) {
|
|
1584
|
+
this.log(`Not setting progress for a file that has been removed: ${e?.id}`);
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1587
|
+
let t = { ...this.getState().files };
|
|
1588
|
+
t[e.id] = {
|
|
1589
|
+
...t[e.id],
|
|
1590
|
+
progress: { ...t[e.id].progress }
|
|
1591
|
+
}, delete t[e.id].progress.preprocess, this.setState({ files: t });
|
|
1592
|
+
}), this.on("postprocess-progress", (e, t) => {
|
|
1593
|
+
if (e == null || !this.getFile(e.id)) {
|
|
1594
|
+
this.log(`Not setting progress for a file that has been removed: ${e?.id}`);
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
this.setFileState(e.id, { progress: {
|
|
1598
|
+
...this.getState().files[e.id].progress,
|
|
1599
|
+
postprocess: t
|
|
1600
|
+
} });
|
|
1601
|
+
}), this.on("postprocess-complete", (e) => {
|
|
1602
|
+
let t = e && this.getFile(e.id);
|
|
1603
|
+
if (t == null) {
|
|
1604
|
+
this.log(`Not setting progress for a file that has been removed: ${e?.id}`);
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
let { postprocess: n, ...r } = t.progress;
|
|
1608
|
+
this.patchFilesState({ [t.id]: { progress: {
|
|
1609
|
+
...r,
|
|
1610
|
+
complete: !0
|
|
1611
|
+
} } });
|
|
1612
|
+
}), this.on("restored", () => {
|
|
1613
|
+
this.#v();
|
|
1614
|
+
}), this.on("dashboard:file-edit-complete", (e) => {
|
|
1615
|
+
e && this.#c(e);
|
|
1616
|
+
}), typeof window < "u" && window.addEventListener && (window.addEventListener("online", this.#x), window.addEventListener("offline", this.#x), setTimeout(this.#x, 3e3));
|
|
1617
|
+
}
|
|
1618
|
+
updateOnlineStatus() {
|
|
1619
|
+
window.navigator.onLine ?? !0 ? (this.emit("is-online"), this.wasOffline &&= (this.emit("back-online"), this.info(this.i18n("connectedToInternet"), "success", 3e3), !1)) : (this.emit("is-offline"), this.info(this.i18n("noInternetConnection"), "error", 0), this.wasOffline = !0);
|
|
1620
|
+
}
|
|
1621
|
+
#x = this.updateOnlineStatus.bind(this);
|
|
1622
|
+
getID() {
|
|
1623
|
+
return this.opts.id;
|
|
1624
|
+
}
|
|
1625
|
+
use(e, ...t) {
|
|
1626
|
+
if (typeof e != "function") throw TypeError(`Expected a plugin class, but got ${e === null ? "null" : typeof e}. Please verify that the plugin was imported and spelled correctly.`);
|
|
1627
|
+
let n = new e(this, ...t), r = n.id;
|
|
1628
|
+
if (!r) throw Error("Your plugin must have an id");
|
|
1629
|
+
if (!n.type) throw Error("Your plugin must have a type");
|
|
1630
|
+
let i = this.getPlugin(r);
|
|
1631
|
+
if (i) {
|
|
1632
|
+
let e = `Already found a plugin named '${i.id}'. Tried to use: '${r}'.\nUppy plugins must have unique \`id\` options.`;
|
|
1633
|
+
throw Error(e);
|
|
1634
|
+
}
|
|
1635
|
+
return e.VERSION && this.log(`Using ${r} v${e.VERSION}`), n.type in this.#e ? this.#e[n.type].push(n) : this.#e[n.type] = [n], n.install(), this.emit("plugin-added", n), this;
|
|
1636
|
+
}
|
|
1637
|
+
getPlugin(e) {
|
|
1638
|
+
for (let t of Object.values(this.#e)) {
|
|
1639
|
+
let n = t.find((t) => t.id === e);
|
|
1640
|
+
if (n != null) return n;
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
[Symbol.for("uppy test: getPlugins")](e) {
|
|
1644
|
+
return this.#e[e];
|
|
1645
|
+
}
|
|
1646
|
+
iteratePlugins(e) {
|
|
1647
|
+
Object.values(this.#e).flat(1).forEach(e);
|
|
1648
|
+
}
|
|
1649
|
+
removePlugin(e) {
|
|
1650
|
+
this.log(`Removing plugin ${e.id}`), this.emit("plugin-remove", e), e.uninstall && e.uninstall();
|
|
1651
|
+
let t = this.#e[e.type], n = t.findIndex((t) => t.id === e.id);
|
|
1652
|
+
n !== -1 && t.splice(n, 1);
|
|
1653
|
+
let r = { plugins: {
|
|
1654
|
+
...this.getState().plugins,
|
|
1655
|
+
[e.id]: void 0
|
|
1656
|
+
} };
|
|
1657
|
+
this.setState(r);
|
|
1658
|
+
}
|
|
1659
|
+
destroy() {
|
|
1660
|
+
this.log(`Closing Uppy instance ${this.opts.id}: removing all files and uninstalling plugins`), this.cancelAll(), this.#n(), this.iteratePlugins((e) => {
|
|
1661
|
+
this.removePlugin(e);
|
|
1662
|
+
}), typeof window < "u" && window.removeEventListener && (window.removeEventListener("online", this.#x), window.removeEventListener("offline", this.#x));
|
|
1663
|
+
}
|
|
1664
|
+
hideInfo() {
|
|
1665
|
+
let { info: e } = this.getState();
|
|
1666
|
+
this.setState({ info: e.slice(1) }), this.emit("info-hidden");
|
|
1667
|
+
}
|
|
1668
|
+
info(e, t = "info", n = 3e3) {
|
|
1669
|
+
let r = typeof e == "object";
|
|
1670
|
+
this.setState({ info: [...this.getState().info, {
|
|
1671
|
+
type: t,
|
|
1672
|
+
message: r ? e.message : e,
|
|
1673
|
+
details: r ? e.details : null
|
|
1674
|
+
}] }), setTimeout(() => this.hideInfo(), n), this.emit("info-visible");
|
|
1675
|
+
}
|
|
1676
|
+
log(e, t) {
|
|
1677
|
+
let { logger: n } = this.opts;
|
|
1678
|
+
switch (t) {
|
|
1679
|
+
case "error":
|
|
1680
|
+
n.error(e);
|
|
1681
|
+
break;
|
|
1682
|
+
case "warning":
|
|
1683
|
+
n.warn(e);
|
|
1684
|
+
break;
|
|
1685
|
+
default:
|
|
1686
|
+
n.debug(e);
|
|
1687
|
+
break;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
#S = /* @__PURE__ */ new Map();
|
|
1691
|
+
registerRequestClient(e, t) {
|
|
1692
|
+
this.#S.set(e, t);
|
|
1693
|
+
}
|
|
1694
|
+
getRequestClientForFile(e) {
|
|
1695
|
+
if (!("remote" in e && e.remote)) throw Error(`Tried to get RequestClient for a non-remote file ${e.id}`);
|
|
1696
|
+
let t = this.#S.get(e.remote.requestClientId);
|
|
1697
|
+
if (t == null) throw Error(`requestClientId "${e.remote.requestClientId}" not registered for file "${e.id}"`);
|
|
1698
|
+
return t;
|
|
1699
|
+
}
|
|
1700
|
+
async restore(e) {
|
|
1701
|
+
this.log(`Core: Running restored upload "${e}"`);
|
|
1702
|
+
let t = await this.#E(e);
|
|
1703
|
+
return this.emit("complete", t), t;
|
|
1704
|
+
}
|
|
1705
|
+
#C(e, t = {}) {
|
|
1706
|
+
let { forceAllowNewUpload: n = !1 } = t, { allowNewUpload: r, currentUploads: i } = this.getState();
|
|
1707
|
+
if (!r && !n) throw Error("Cannot create a new upload: already uploading.");
|
|
1708
|
+
let a = Oe();
|
|
1709
|
+
return this.emit("upload", a, this.getFilesByIds(e)), this.setState({
|
|
1710
|
+
allowNewUpload: this.opts.allowMultipleUploadBatches !== !1 && this.opts.allowMultipleUploads !== !1,
|
|
1711
|
+
currentUploads: {
|
|
1712
|
+
...i,
|
|
1713
|
+
[a]: {
|
|
1714
|
+
fileIDs: e,
|
|
1715
|
+
step: 0,
|
|
1716
|
+
result: {}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}), a;
|
|
1720
|
+
}
|
|
1721
|
+
[Symbol.for("uppy test: createUpload")](...e) {
|
|
1722
|
+
return this.#C(...e);
|
|
1723
|
+
}
|
|
1724
|
+
#w(e) {
|
|
1725
|
+
let { currentUploads: t } = this.getState();
|
|
1726
|
+
return t[e];
|
|
1727
|
+
}
|
|
1728
|
+
addResultData(e, t) {
|
|
1729
|
+
if (!this.#w(e)) {
|
|
1730
|
+
this.log(`Not setting result for an upload that has been removed: ${e}`);
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
let { currentUploads: n } = this.getState(), r = {
|
|
1734
|
+
...n[e],
|
|
1735
|
+
result: {
|
|
1736
|
+
...n[e].result,
|
|
1737
|
+
...t
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
this.setState({ currentUploads: {
|
|
1741
|
+
...n,
|
|
1742
|
+
[e]: r
|
|
1743
|
+
} });
|
|
1744
|
+
}
|
|
1745
|
+
#T(e) {
|
|
1746
|
+
let { [e]: t, ...n } = this.getState().currentUploads;
|
|
1747
|
+
this.setState({ currentUploads: n });
|
|
1748
|
+
}
|
|
1749
|
+
async #E(e) {
|
|
1750
|
+
let t = () => {
|
|
1751
|
+
let { currentUploads: t } = this.getState();
|
|
1752
|
+
return t[e];
|
|
1753
|
+
}, n = t();
|
|
1754
|
+
if (!n) throw Error("Nonexistent upload");
|
|
1755
|
+
let r = [
|
|
1756
|
+
...this.#i,
|
|
1757
|
+
...this.#a,
|
|
1758
|
+
...this.#o
|
|
1759
|
+
];
|
|
1760
|
+
try {
|
|
1761
|
+
for (let i = n.step || 0; i < r.length; i++) {
|
|
1762
|
+
let a = r[i];
|
|
1763
|
+
this.setState({ currentUploads: {
|
|
1764
|
+
...this.getState().currentUploads,
|
|
1765
|
+
[e]: {
|
|
1766
|
+
...n,
|
|
1767
|
+
step: i
|
|
1768
|
+
}
|
|
1769
|
+
} });
|
|
1770
|
+
let { fileIDs: o } = n;
|
|
1771
|
+
if (await a(o, e), n = t(), !n) break;
|
|
1772
|
+
}
|
|
1773
|
+
} catch (t) {
|
|
1774
|
+
throw this.#T(e), t;
|
|
1775
|
+
}
|
|
1776
|
+
if (n) {
|
|
1777
|
+
n.fileIDs.forEach((e) => {
|
|
1778
|
+
let t = this.getFile(e);
|
|
1779
|
+
t?.progress.postprocess && this.emit("postprocess-complete", t);
|
|
1780
|
+
});
|
|
1781
|
+
let r = n.fileIDs.map((e) => this.getFile(e)), i = r.filter((e) => !e.error), a = r.filter((e) => e.error);
|
|
1782
|
+
this.addResultData(e, {
|
|
1783
|
+
successful: i,
|
|
1784
|
+
failed: a,
|
|
1785
|
+
uploadID: e
|
|
1786
|
+
}), n = t();
|
|
1787
|
+
}
|
|
1788
|
+
let i;
|
|
1789
|
+
return n && (i = n.result, this.#T(e)), i ??= (this.log(`Not setting result for an upload that has been removed: ${e}`), {
|
|
1790
|
+
successful: [],
|
|
1791
|
+
failed: [],
|
|
1792
|
+
uploadID: e
|
|
1793
|
+
}), i;
|
|
1794
|
+
}
|
|
1795
|
+
async upload() {
|
|
1796
|
+
this.#e.uploader?.length || this.log("No uploader type plugins are used", "warning");
|
|
1797
|
+
let { files: e } = this.getState();
|
|
1798
|
+
if (this.#m().length > 0) {
|
|
1799
|
+
let t = await this.#h();
|
|
1800
|
+
if (!(this.getFiles().filter((e) => e.progress.uploadStarted == null).length > 0)) return this.emit("complete", t), t;
|
|
1801
|
+
({files: e} = this.getState());
|
|
1802
|
+
}
|
|
1803
|
+
let t = this.opts.onBeforeUpload(e);
|
|
1804
|
+
if (t === !1) throw Error("Not starting the upload because onBeforeUpload returned false");
|
|
1805
|
+
t && typeof t == "object" && (e = t, this.setState({ files: e }));
|
|
1806
|
+
try {
|
|
1807
|
+
if (this.#t.validateMinNumberOfFiles(e), !this.#l(e)) throw new I(this.i18n("missingRequiredMetaField"));
|
|
1808
|
+
let { currentUploads: t } = this.getState(), n = Object.values(t).flatMap((e) => e.fileIDs), r = Object.keys(e).filter((e) => {
|
|
1809
|
+
let t = this.getFile(e);
|
|
1810
|
+
return t && !t.progress.uploadStarted && !n.includes(e);
|
|
1811
|
+
}), i = this.#C(r), a = await this.#E(i);
|
|
1812
|
+
return this.emit("complete", a), a;
|
|
1813
|
+
} catch (e) {
|
|
1814
|
+
throw this.#s([e]), e;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
}, Ie = {
|
|
1818
|
+
name: "@uppy/xhr-upload",
|
|
1819
|
+
description: "Plain and simple classic HTML multipart form uploads with Uppy, as well as uploads using the HTTP PUT method.",
|
|
1820
|
+
version: "5.2.0",
|
|
1821
|
+
license: "MIT",
|
|
1822
|
+
type: "module",
|
|
1823
|
+
sideEffects: !1,
|
|
1824
|
+
scripts: {
|
|
1825
|
+
build: "tsc --build tsconfig.build.json",
|
|
1826
|
+
typecheck: "tsc --build",
|
|
1827
|
+
test: "vitest run --silent='passed-only'",
|
|
1828
|
+
"test:e2e": "vitest run --project browser"
|
|
1829
|
+
},
|
|
1830
|
+
keywords: [
|
|
1831
|
+
"file uploader",
|
|
1832
|
+
"xhr",
|
|
1833
|
+
"xhr upload",
|
|
1834
|
+
"XMLHttpRequest",
|
|
1835
|
+
"ajax",
|
|
1836
|
+
"fetch",
|
|
1837
|
+
"uppy",
|
|
1838
|
+
"uppy-plugin"
|
|
1839
|
+
],
|
|
1840
|
+
homepage: "https://uppy.io",
|
|
1841
|
+
bugs: { url: "https://github.com/transloadit/uppy/issues" },
|
|
1842
|
+
repository: {
|
|
1843
|
+
type: "git",
|
|
1844
|
+
url: "git+https://github.com/transloadit/uppy.git"
|
|
1845
|
+
},
|
|
1846
|
+
files: [
|
|
1847
|
+
"src",
|
|
1848
|
+
"lib",
|
|
1849
|
+
"dist",
|
|
1850
|
+
"CHANGELOG.md"
|
|
1851
|
+
],
|
|
1852
|
+
exports: {
|
|
1853
|
+
".": "./lib/index.js",
|
|
1854
|
+
"./package.json": "./package.json"
|
|
1855
|
+
},
|
|
1856
|
+
dependencies: {
|
|
1857
|
+
"@uppy/companion-client": "^5.1.1",
|
|
1858
|
+
"@uppy/utils": "^7.2.0"
|
|
1859
|
+
},
|
|
1860
|
+
devDependencies: {
|
|
1861
|
+
"@uppy/core": "^5.2.0",
|
|
1862
|
+
"@uppy/dashboard": "^5.1.1",
|
|
1863
|
+
"@vitest/browser": "^3.2.4",
|
|
1864
|
+
jsdom: "^26.1.0",
|
|
1865
|
+
msw: "^2.10.4",
|
|
1866
|
+
nock: "^13.1.0",
|
|
1867
|
+
playwright: "1.57.0",
|
|
1868
|
+
typescript: "^5.8.3",
|
|
1869
|
+
vitest: "^3.2.4"
|
|
1870
|
+
},
|
|
1871
|
+
peerDependencies: { "@uppy/core": "^5.2.0" }
|
|
1872
|
+
}, Le = { strings: { uploadStalled: "Upload has not made any progress for %{seconds} seconds. You may want to retry it." } };
|
|
1873
|
+
//#endregion
|
|
1874
|
+
//#region ../../node_modules/@uppy/xhr-upload/lib/index.js
|
|
1875
|
+
function Re(e, t) {
|
|
1876
|
+
let n = t;
|
|
1877
|
+
return n ||= /* @__PURE__ */ Error("Upload error"), typeof n == "string" && (n = Error(n)), n instanceof Error || (n = Object.assign(/* @__PURE__ */ Error("Upload error"), { data: n })), k(e) ? (n = new u(n, e), n) : (n.request = e, n);
|
|
1878
|
+
}
|
|
1879
|
+
function ze(e) {
|
|
1880
|
+
return e.data.slice(0, e.data.size, e.meta.type);
|
|
1881
|
+
}
|
|
1882
|
+
var Be = {
|
|
1883
|
+
formData: !0,
|
|
1884
|
+
fieldName: "file",
|
|
1885
|
+
method: "post",
|
|
1886
|
+
allowedMetaFields: !0,
|
|
1887
|
+
bundle: !1,
|
|
1888
|
+
headers: {},
|
|
1889
|
+
timeout: 30 * 1e3,
|
|
1890
|
+
limit: 5,
|
|
1891
|
+
withCredentials: !1,
|
|
1892
|
+
responseType: ""
|
|
1893
|
+
}, Ve = class extends N {
|
|
1894
|
+
static VERSION = Ie.version;
|
|
1895
|
+
#e;
|
|
1896
|
+
#t;
|
|
1897
|
+
uploaderEvents;
|
|
1898
|
+
constructor(e, t) {
|
|
1899
|
+
if (super(e, {
|
|
1900
|
+
...Be,
|
|
1901
|
+
fieldName: t.bundle ? "files[]" : "file",
|
|
1902
|
+
...t
|
|
1903
|
+
}), this.type = "uploader", this.id = this.opts.id || "XHRUpload", this.defaultLocale = Le, this.i18nInit(), this.#t = new A({ concurrency: this.opts.limit }), this.opts.bundle && !this.opts.formData) throw Error("`opts.formData` must be true when `opts.bundle` is enabled.");
|
|
1904
|
+
if (this.opts.bundle && typeof this.opts.headers == "function") throw Error("`opts.headers` can not be a function when the `bundle: true` option is set.");
|
|
1905
|
+
if (t?.allowedMetaFields === void 0 && "metaFields" in this.opts) throw Error("The `metaFields` option has been renamed to `allowedMetaFields`.");
|
|
1906
|
+
this.uploaderEvents = Object.create(null), this.#e = (e) => async (t, n) => {
|
|
1907
|
+
try {
|
|
1908
|
+
let r = await p(t, {
|
|
1909
|
+
...n,
|
|
1910
|
+
onBeforeRequest: (t, n) => this.opts.onBeforeRequest?.(t, n, e),
|
|
1911
|
+
shouldRetry: this.opts.shouldRetry,
|
|
1912
|
+
onAfterResponse: this.opts.onAfterResponse,
|
|
1913
|
+
onTimeout: (t) => {
|
|
1914
|
+
let n = Math.ceil(t / 1e3), r = Error(this.i18n("uploadStalled", { seconds: n }));
|
|
1915
|
+
this.uppy.emit("upload-stalled", r, e);
|
|
1916
|
+
},
|
|
1917
|
+
onUploadProgress: (t) => {
|
|
1918
|
+
if (t.lengthComputable) for (let { id: n } of e) {
|
|
1919
|
+
let e = this.uppy.getFile(n);
|
|
1920
|
+
e != null && this.uppy.emit("upload-progress", e, {
|
|
1921
|
+
uploadStarted: e.progress.uploadStarted ?? 0,
|
|
1922
|
+
bytesUploaded: t.loaded / t.total * e.size,
|
|
1923
|
+
bytesTotal: e.size
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
}), i = await this.opts.getResponseData?.(r);
|
|
1928
|
+
if (r.responseType === "json") i ??= r.response;
|
|
1929
|
+
else try {
|
|
1930
|
+
i ??= JSON.parse(r.responseText);
|
|
1931
|
+
} catch (e) {
|
|
1932
|
+
throw Error("@uppy/xhr-upload expects a JSON response (with a `url` property). To parse non-JSON responses, use `getResponseData` to turn your response into JSON.", { cause: e });
|
|
1933
|
+
}
|
|
1934
|
+
let a = typeof i?.url == "string" ? i.url : void 0;
|
|
1935
|
+
for (let { id: t } of e) this.uppy.emit("upload-success", this.uppy.getFile(t), {
|
|
1936
|
+
status: r.status,
|
|
1937
|
+
body: i,
|
|
1938
|
+
uploadURL: a
|
|
1939
|
+
});
|
|
1940
|
+
return r;
|
|
1941
|
+
} catch (t) {
|
|
1942
|
+
if (t.name === "AbortError") return;
|
|
1943
|
+
let n = t.request;
|
|
1944
|
+
for (let r of e) this.uppy.emit("upload-error", this.uppy.getFile(r.id), Re(n, t), n);
|
|
1945
|
+
throw t;
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
getOptions(e) {
|
|
1950
|
+
let t = this.uppy.getState().xhrUpload, { headers: n } = this.opts, r = {
|
|
1951
|
+
...this.opts,
|
|
1952
|
+
...t || {},
|
|
1953
|
+
...e.xhrUpload || {},
|
|
1954
|
+
headers: {}
|
|
1955
|
+
};
|
|
1956
|
+
return typeof n == "function" ? r.headers = n(e) : Object.assign(r.headers, this.opts.headers), t && Object.assign(r.headers, t.headers), e.xhrUpload && Object.assign(r.headers, e.xhrUpload.headers), r;
|
|
1957
|
+
}
|
|
1958
|
+
addMetadata(e, t, n) {
|
|
1959
|
+
E(n.allowedMetaFields, t).forEach((n) => {
|
|
1960
|
+
let r = t[n];
|
|
1961
|
+
Array.isArray(r) ? r.forEach((t) => e.append(n, t)) : e.append(n, r);
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
createFormDataUpload(e, t) {
|
|
1965
|
+
let n = new FormData();
|
|
1966
|
+
this.addMetadata(n, e.meta, t);
|
|
1967
|
+
let r = ze(e);
|
|
1968
|
+
return e.name ? n.append(t.fieldName, r, e.meta.name) : n.append(t.fieldName, r), n;
|
|
1969
|
+
}
|
|
1970
|
+
createBundledUpload(e, t) {
|
|
1971
|
+
let n = new FormData(), { meta: r } = this.uppy.getState();
|
|
1972
|
+
return this.addMetadata(n, r, t), e.forEach((e) => {
|
|
1973
|
+
let t = this.getOptions(e), r = ze(e);
|
|
1974
|
+
e.name ? n.append(t.fieldName, r, e.name) : n.append(t.fieldName, r);
|
|
1975
|
+
}), n;
|
|
1976
|
+
}
|
|
1977
|
+
async #n(e) {
|
|
1978
|
+
let t = new P(this.uppy), n = new AbortController();
|
|
1979
|
+
t.onFileRemove(e.id, () => n.abort()), t.onCancelAll(e.id, () => n.abort());
|
|
1980
|
+
try {
|
|
1981
|
+
await this.#t.add(async (t) => {
|
|
1982
|
+
let r = this.getOptions(e), i = this.#e([e]), a = r.formData ? this.createFormDataUpload(e, r) : e.data;
|
|
1983
|
+
return i(typeof r.endpoint == "string" ? r.endpoint : await r.endpoint(e), {
|
|
1984
|
+
...r,
|
|
1985
|
+
body: a,
|
|
1986
|
+
signal: AbortSignal.any([t, n.signal])
|
|
1987
|
+
});
|
|
1988
|
+
});
|
|
1989
|
+
} catch (e) {
|
|
1990
|
+
if (e.name === "AbortError") return;
|
|
1991
|
+
throw e;
|
|
1992
|
+
} finally {
|
|
1993
|
+
t.remove();
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
async #r(e) {
|
|
1997
|
+
let t = new AbortController();
|
|
1998
|
+
function n() {
|
|
1999
|
+
t.abort();
|
|
2000
|
+
}
|
|
2001
|
+
this.uppy.once("cancel-all", n);
|
|
2002
|
+
try {
|
|
2003
|
+
await this.#t.add(async (n) => {
|
|
2004
|
+
let r = this.uppy.getState().xhrUpload ?? {}, i = this.#e(e), a = this.createBundledUpload(e, {
|
|
2005
|
+
...this.opts,
|
|
2006
|
+
...r
|
|
2007
|
+
});
|
|
2008
|
+
return i(typeof this.opts.endpoint == "string" ? this.opts.endpoint : await this.opts.endpoint(e), {
|
|
2009
|
+
...this.opts,
|
|
2010
|
+
body: a,
|
|
2011
|
+
signal: AbortSignal.any([n, t.signal])
|
|
2012
|
+
});
|
|
2013
|
+
});
|
|
2014
|
+
} catch (e) {
|
|
2015
|
+
if (e.name === "AbortError") return;
|
|
2016
|
+
throw e;
|
|
2017
|
+
} finally {
|
|
2018
|
+
this.uppy.off("cancel-all", n);
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
#i(e) {
|
|
2022
|
+
let t = this.getOptions(e), n = E(t.allowedMetaFields, e.meta);
|
|
2023
|
+
return {
|
|
2024
|
+
...e.remote?.body,
|
|
2025
|
+
protocol: "multipart",
|
|
2026
|
+
endpoint: t.endpoint,
|
|
2027
|
+
size: e.data.size,
|
|
2028
|
+
fieldname: t.fieldName,
|
|
2029
|
+
metadata: Object.fromEntries(n.map((t) => [t, e.meta[t]])),
|
|
2030
|
+
httpMethod: t.method,
|
|
2031
|
+
useFormData: t.formData,
|
|
2032
|
+
headers: t.headers
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
async #a(e) {
|
|
2036
|
+
await Promise.allSettled(e.map((e) => {
|
|
2037
|
+
if (e.isRemote) {
|
|
2038
|
+
let t = () => this.#t, n = new AbortController(), r = (t) => {
|
|
2039
|
+
t.id === e.id && n.abort();
|
|
2040
|
+
};
|
|
2041
|
+
return this.uppy.on("file-removed", r), this.uppy.getRequestClientForFile(e).uploadRemoteFile(e, this.#i(e), {
|
|
2042
|
+
signal: n.signal,
|
|
2043
|
+
getQueue: t
|
|
2044
|
+
}).finally(() => {
|
|
2045
|
+
this.uppy.off("file-removed", r);
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
return this.#n(e);
|
|
2049
|
+
}));
|
|
2050
|
+
}
|
|
2051
|
+
#o = async (e) => {
|
|
2052
|
+
if (e.length === 0) {
|
|
2053
|
+
this.uppy.log("[XHRUpload] No files to upload!");
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
this.opts.limit === 0 && this.uppy.log("[XHRUpload] When uploading multiple files at once, consider setting the `limit` option (to `10` for example), to limit the number of concurrent uploads, which helps prevent memory and network issues: https://uppy.io/docs/xhr-upload/#limit-0", "warning"), this.uppy.log("[XHRUpload] Uploading...");
|
|
2057
|
+
let t = g(this.uppy.getFilesByIds(e)), n = _(t);
|
|
2058
|
+
if (this.uppy.emit("upload-start", n), this.opts.bundle) {
|
|
2059
|
+
if (t.some((e) => e.isRemote)) throw Error("Can’t upload remote files when the `bundle: true` option is set");
|
|
2060
|
+
if (typeof this.opts.headers == "function") throw TypeError("`headers` may not be a function when the `bundle: true` option is set");
|
|
2061
|
+
await this.#r(t);
|
|
2062
|
+
} else await this.#a(t);
|
|
2063
|
+
};
|
|
2064
|
+
install() {
|
|
2065
|
+
if (this.opts.bundle) {
|
|
2066
|
+
let { capabilities: e } = this.uppy.getState();
|
|
2067
|
+
this.uppy.setState({ capabilities: {
|
|
2068
|
+
...e,
|
|
2069
|
+
individualCancellation: !1
|
|
2070
|
+
} });
|
|
2071
|
+
}
|
|
2072
|
+
this.uppy.addUploader(this.#o);
|
|
2073
|
+
}
|
|
2074
|
+
uninstall() {
|
|
2075
|
+
if (this.opts.bundle) {
|
|
2076
|
+
let { capabilities: e } = this.uppy.getState();
|
|
2077
|
+
this.uppy.setState({ capabilities: {
|
|
2078
|
+
...e,
|
|
2079
|
+
individualCancellation: !0
|
|
2080
|
+
} });
|
|
2081
|
+
}
|
|
2082
|
+
this.uppy.removeUploader(this.#o);
|
|
2083
|
+
}
|
|
2084
|
+
}, He = "@layer formie-theme{.formie-upload-manager{gap:var(--formie-gap-field);flex-direction:column;display:flex}.formie-upload-manager-dropzone{justify-content:center;align-items:center;gap:var(--formie-space-2);padding:var(--formie-space-4);min-height:calc(var(--formie-control-height) * 3);border:var(--formie-border-width) dashed var(--formie-color-border);border-radius:var(--formie-radius-sm);background:var(--formie-color-surface-subtle);color:var(--formie-color-text);text-align:center;cursor:pointer;flex-direction:column;transition:border-color .15s,background-color .15s,box-shadow .15s;display:flex}.formie-upload-manager-dropzone:hover,.formie-upload-manager-dropzone.formie-upload-manager-dropzone-active{border-color:var(--formie-color-focus-ring);background:var(--formie-color-surface-muted)}.formie-upload-manager-dropzone:focus{outline:0}.formie-upload-manager-dropzone:focus-visible{box-shadow:0 0 0 var(--formie-focus-ring-width) var(--formie-color-focus-ring)}.formie-field-has-error .formie-upload-manager-dropzone{border-color:var(--formie-color-danger)}.formie-upload-manager-prompt{font-size:var(--formie-font-size-sm);color:var(--formie-color-text-muted);margin:0}.formie-upload-manager-list{gap:var(--formie-space-2);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.formie-upload-manager-item{align-items:center;gap:var(--formie-space-2);padding:var(--formie-space-2) var(--formie-space-3);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm);background:var(--formie-color-surface);grid-template-columns:minmax(0,1fr) minmax(6.5rem,8rem) auto;display:grid}.formie-upload-manager-item.is-error{border-color:var(--formie-color-danger)}.formie-upload-manager-item.is-complete .formie-upload-manager-progress{opacity:0;visibility:hidden;pointer-events:none}.formie-upload-manager-filename{text-overflow:ellipsis;white-space:nowrap;font-size:var(--formie-font-size-sm);overflow:hidden}.formie-upload-manager-progress{justify-content:center;gap:var(--formie-space-1);min-height:var(--formie-button-icon-button-size);opacity:1;visibility:visible;flex-direction:column;align-self:center;transition:opacity .2s,visibility .2s;display:flex}.formie-upload-manager-progress-track{border-radius:var(--formie-radius-full);background:var(--formie-color-surface-muted);height:.375rem;position:relative;overflow:hidden}.formie-upload-manager-progress-bar{border-radius:inherit;background:var(--formie-color-primary);width:0;height:100%;transition:width .18s ease-out,background-color .2s}.formie-upload-manager-item.is-upload-complete .formie-upload-manager-progress-bar{background:var(--formie-color-success,var(--formie-color-primary));width:100%!important}.formie-upload-manager-item.is-uploading:not(.is-upload-complete) .formie-upload-manager-progress-track[data-indeterminate=true] .formie-upload-manager-progress-bar,.formie-upload-manager-item.is-preparing .formie-upload-manager-progress-bar,.formie-upload-manager-item.is-processing .formie-upload-manager-progress-bar{width:35%;animation:1.1s ease-in-out infinite formie-upload-manager-progress-indeterminate}.formie-upload-manager-item.is-processing .formie-upload-manager-progress-bar{opacity:.85}.formie-upload-manager-item.is-processing .formie-upload-manager-progress-label{color:var(--formie-color-text)}@keyframes formie-upload-manager-progress-indeterminate{0%{transform:translate(-120%)}to{transform:translate(320%)}}.formie-upload-manager-progress-label{font-size:var(--formie-font-size-xs);color:var(--formie-color-text-muted);text-align:center;white-space:nowrap;line-height:1.2}.formie-upload-manager-item.is-upload-complete .formie-upload-manager-progress-label{color:var(--formie-color-success,var(--formie-color-primary));font-weight:var(--formie-font-weight-medium)}.formie-upload-manager-error{font-size:var(--formie-font-size-xs);color:var(--formie-color-danger);grid-column:1/-1}.formie-upload-manager-browse-button{margin-top:var(--formie-space-1)}.formie-upload-manager-actions{align-items:center;gap:var(--formie-space-2);flex-shrink:0;align-self:center;display:flex}.formie-upload-manager-sort-controls{border-radius:var(--formie-radius-sm);background:0 0;flex-direction:row;align-items:center;gap:.0625rem;padding:0;display:inline-flex}.formie-upload-manager-sort-controls[hidden]{display:none}.formie-upload-manager-sort-button,.formie-upload-manager-action-button{border-radius:var(--formie-radius-sm);width:1.375rem;height:1.375rem;color:var(--formie-color-text-muted);cursor:pointer;text-indent:-9999px;white-space:nowrap;background:0 0;border:0;justify-content:center;align-items:center;padding:0;font-size:0;line-height:0;transition:background-color .15s,color .15s,opacity .15s;display:inline-flex;position:relative;overflow:hidden}.formie-upload-manager-sort-button{width:1.375rem;height:1.375rem}.formie-upload-manager-sort-button:hover:not(:disabled),.formie-upload-manager-action-button:hover{background:var(--formie-color-surface-muted);color:var(--formie-color-text)}.formie-upload-manager-sort-button:focus-visible,.formie-upload-manager-action-button:focus-visible{box-shadow:0 0 0 var(--formie-focus-ring-width) var(--formie-color-focus-ring);outline:0}.formie-upload-manager-sort-button:disabled{opacity:.28;cursor:not-allowed}.formie-upload-manager-sort-button:after,.formie-upload-manager-action-button:after{content:\"\";background-color:currentColor;display:block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}.formie-upload-manager-sort-button[data-formie-icon=arrow-up]{--formie-upload-manager-icon-mask:var(--formie-icon-mask-arrow-up)}.formie-upload-manager-sort-button[data-formie-icon=arrow-down]{--formie-upload-manager-icon-mask:var(--formie-icon-mask-arrow-down)}.formie-upload-manager-action-button[data-formie-icon=close]{--formie-upload-manager-icon-mask:var(--formie-icon-mask-close)}.formie-upload-manager-sort-button:after{width:.75rem;height:.75rem;-webkit-mask-image:var(--formie-upload-manager-icon-mask);-webkit-mask-image:var(--formie-upload-manager-icon-mask);mask-image:var(--formie-upload-manager-icon-mask)}.formie-upload-manager-action-button:after{width:.825rem;height:.825rem;-webkit-mask-image:var(--formie-upload-manager-icon-mask);-webkit-mask-image:var(--formie-upload-manager-icon-mask);mask-image:var(--formie-upload-manager-icon-mask)}.formie-upload-manager-remove-button{flex-shrink:0}}", z = "[data-formie-upload-manager-root]", B = "[data-formie-upload-manager]", Ue = "[data-formie-upload-manager-browse]", We = "[data-formie-upload-manager-input]", V = "[data-formie-upload-manager-status]", Ge = "[data-formie-upload-manager-list]", Ke = "[data-formie-upload-manager-sort-controls]", qe = "[data-formie-upload-manager-sort=\"up\"]", Je = "[data-formie-upload-manager-sort=\"down\"]", H = "data-formie-file-upload-anchor", Ye = "data-formie-file-upload-asset-id", Xe = n("reset"), Ze = r("repeater", "init-row"), Qe = "upload-manager", $e = "upload-manager", et = ["uploadManagerRequired", "uploadManagerFileLimit"], tt = 900, nt = 95, rt = 12e4, U = i("fields", "upload-manager");
|
|
2085
|
+
o(Qe, [He]);
|
|
2086
|
+
function W(e) {
|
|
2087
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
2088
|
+
}
|
|
2089
|
+
function G(e) {
|
|
2090
|
+
let t = Number(e);
|
|
2091
|
+
return Number.isInteger(t) && t > 0 ? t : null;
|
|
2092
|
+
}
|
|
2093
|
+
function K(e) {
|
|
2094
|
+
return e.getAttribute("data-formie-field-handle")?.trim() || "";
|
|
2095
|
+
}
|
|
2096
|
+
function it(e) {
|
|
2097
|
+
if (!e) return "";
|
|
2098
|
+
let t = e.querySelector("input[name=\"handle\"]");
|
|
2099
|
+
return t instanceof HTMLInputElement && t.value.trim() ? t.value.trim() : e.getAttribute("data-formie-handle")?.trim() || "";
|
|
2100
|
+
}
|
|
2101
|
+
function q(e) {
|
|
2102
|
+
return Array.from(e.querySelectorAll("input[type=\"hidden\"]")).filter((e) => e instanceof HTMLInputElement);
|
|
2103
|
+
}
|
|
2104
|
+
function at(e, t) {
|
|
2105
|
+
let n = q(e).find((e) => e.hasAttribute(H) || e.name === t.replace("[]", "") && e.value === "");
|
|
2106
|
+
if (n) return n.setAttribute(H, "true"), n;
|
|
2107
|
+
let r = document.createElement("input");
|
|
2108
|
+
return r.type = "hidden", r.name = t.replace("[]", ""), r.value = "", r.setAttribute(H, "true"), e.prepend(r), r;
|
|
2109
|
+
}
|
|
2110
|
+
function ot(e, t) {
|
|
2111
|
+
return q(e).filter((e) => e.name === t && e.value.trim() !== "");
|
|
2112
|
+
}
|
|
2113
|
+
function J(e, t) {
|
|
2114
|
+
return ot(e, t).map((e) => G(e.value)).filter((e) => e !== null);
|
|
2115
|
+
}
|
|
2116
|
+
function st(e, t, n, r) {
|
|
2117
|
+
let i = t;
|
|
2118
|
+
ot(e, n).forEach((e) => {
|
|
2119
|
+
e.remove();
|
|
2120
|
+
}), r.forEach((e) => {
|
|
2121
|
+
let t = document.createElement("input");
|
|
2122
|
+
t.type = "hidden", t.name = n, t.value = String(e), t.setAttribute(Ye, "true"), i.insertAdjacentElement("afterend", t), i = t;
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
function ct(e, t, n) {
|
|
2126
|
+
let r = n.getAttribute("data-formie-upload-key")?.trim() || n.getAttribute("data-formie-input-id")?.trim() || "", i = {
|
|
2127
|
+
handle: it(e),
|
|
2128
|
+
fieldHandle: K(t),
|
|
2129
|
+
inputKey: r
|
|
2130
|
+
};
|
|
2131
|
+
if (!e) return i;
|
|
2132
|
+
[
|
|
2133
|
+
"renderId",
|
|
2134
|
+
"draftContextToken",
|
|
2135
|
+
"draftContext",
|
|
2136
|
+
"submissionId"
|
|
2137
|
+
].forEach((t) => {
|
|
2138
|
+
let n = e.querySelector(`input[name="${t}"]`);
|
|
2139
|
+
n instanceof HTMLInputElement && n.value.trim() && (i[t] = n.value.trim());
|
|
2140
|
+
});
|
|
2141
|
+
let a = e.querySelector("input[name=\"CRAFT_CSRF_TOKEN\"]");
|
|
2142
|
+
return a instanceof HTMLInputElement && a.value.trim() && (i.CRAFT_CSRF_TOKEN = a.value.trim()), i;
|
|
2143
|
+
}
|
|
2144
|
+
function lt(e, t, n) {
|
|
2145
|
+
let r = new FormData(), i = it(e), a = K(t);
|
|
2146
|
+
i && r.append("handle", i), a && r.append("fieldHandle", a);
|
|
2147
|
+
let o = e?.querySelector("input[name=\"submissionUid\"]");
|
|
2148
|
+
return o instanceof HTMLInputElement && o.value.trim() && r.append("submissionUid", o.value.trim()), n.forEach((e) => {
|
|
2149
|
+
r.append("assetIds[]", String(e));
|
|
2150
|
+
}), r;
|
|
2151
|
+
}
|
|
2152
|
+
function ut(e) {
|
|
2153
|
+
if (!e) return null;
|
|
2154
|
+
let t = e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
2155
|
+
return t.length ? t : null;
|
|
2156
|
+
}
|
|
2157
|
+
function Y(e, t, n, r) {
|
|
2158
|
+
return t?.trim() || e.getAttribute(n)?.trim() || r;
|
|
2159
|
+
}
|
|
2160
|
+
function X(e) {
|
|
2161
|
+
let t = e.querySelector("[data-formie-upload-manager-progress]");
|
|
2162
|
+
if (!(t instanceof HTMLElement)) return {
|
|
2163
|
+
track: null,
|
|
2164
|
+
bar: null,
|
|
2165
|
+
label: null
|
|
2166
|
+
};
|
|
2167
|
+
let n = t.querySelector("[data-formie-upload-manager-progress-track]"), r = t.querySelector("[data-formie-upload-manager-progress-bar]"), i = t.querySelector("[data-formie-upload-manager-progress-label]");
|
|
2168
|
+
return {
|
|
2169
|
+
track: n instanceof HTMLElement ? n : null,
|
|
2170
|
+
bar: r instanceof HTMLElement ? r : null,
|
|
2171
|
+
label: i instanceof HTMLElement ? i : null
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
function Z(e, t, n = "uploading") {
|
|
2175
|
+
let { track: r, bar: i, label: a } = X(e);
|
|
2176
|
+
e.classList.add("is-uploading"), e.classList.remove("is-upload-complete", "is-complete", "is-processing", "is-preparing"), n === "processing" ? e.classList.add("is-processing") : n === "preparing" && e.classList.add("is-preparing"), r && r.setAttribute("data-indeterminate", "true"), i && (i.style.removeProperty("width"), i.setAttribute("data-progress", n)), a && (a.textContent = t);
|
|
2177
|
+
}
|
|
2178
|
+
function dt(e, t, n) {
|
|
2179
|
+
let { track: r, bar: i, label: a } = X(e), o = Math.max(0, Math.min(nt, Math.round(t)));
|
|
2180
|
+
e.classList.add("is-uploading"), e.classList.remove("is-upload-complete", "is-complete", "is-processing", "is-preparing"), r && r.setAttribute("data-indeterminate", "false"), i && (i.style.width = `${o}%`, i.setAttribute("data-progress", String(o))), a && (n ? a.textContent = n : o > 0 ? a.textContent = `Uploading… ${o}%` : a.textContent = "Uploading…");
|
|
2181
|
+
}
|
|
2182
|
+
function ft(e, t, n = {}) {
|
|
2183
|
+
let { loaded: r = 0, total: i = 0 } = n;
|
|
2184
|
+
if ((i > 0 ? r >= i : t >= 100) || t >= 100) {
|
|
2185
|
+
Z(e, "Processing…", "processing");
|
|
2186
|
+
return;
|
|
2187
|
+
}
|
|
2188
|
+
if (t <= 0 && r <= 0) {
|
|
2189
|
+
Z(e, "Uploading…", "uploading");
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2192
|
+
let a = Math.min(nt, Math.max(1, Math.round(t)));
|
|
2193
|
+
dt(e, a, `Uploading… ${a}%`);
|
|
2194
|
+
}
|
|
2195
|
+
function pt(e, t) {
|
|
2196
|
+
if (e instanceof XMLHttpRequest && e.responseText) try {
|
|
2197
|
+
let t = JSON.parse(e.responseText);
|
|
2198
|
+
if (t.message) return t.message;
|
|
2199
|
+
if (t.errors) {
|
|
2200
|
+
let e = Object.values(t.errors).flat().find(Boolean);
|
|
2201
|
+
if (e) return e;
|
|
2202
|
+
}
|
|
2203
|
+
} catch {}
|
|
2204
|
+
return t instanceof Error && t.message ? t.message : "Upload failed.";
|
|
2205
|
+
}
|
|
2206
|
+
function mt(e) {
|
|
2207
|
+
return e.status === 0 ? !0 : e.status >= 500;
|
|
2208
|
+
}
|
|
2209
|
+
function ht(e) {
|
|
2210
|
+
let { track: t, bar: n, label: r } = X(e);
|
|
2211
|
+
e.classList.add("is-uploading", "is-upload-complete"), e.classList.remove("is-complete", "is-processing", "is-preparing"), t && t.setAttribute("data-indeterminate", "false"), n && (n.style.width = "100%", n.setAttribute("data-progress", "100")), r && (r.textContent = "Complete"), window.setTimeout(() => {
|
|
2212
|
+
e.classList.add("is-complete"), e.classList.remove("is-uploading", "is-upload-complete");
|
|
2213
|
+
}, tt);
|
|
2214
|
+
}
|
|
2215
|
+
function gt(e) {
|
|
2216
|
+
let t = e === "up" ? "Move file up" : "Move file down", n = document.createElement("button");
|
|
2217
|
+
return n.type = "button", n.className = "formie-upload-manager-sort-button", n.setAttribute("data-formie-upload-manager-sort", e), n.setAttribute("data-formie-icon", e === "up" ? "arrow-up" : "arrow-down"), n.setAttribute("aria-label", t), n.setAttribute("title", t), n.textContent = t, n;
|
|
2218
|
+
}
|
|
2219
|
+
function _t(e, t) {
|
|
2220
|
+
let n = document.createElement("li");
|
|
2221
|
+
n.className = "formie-upload-manager-item", n.setAttribute("data-formie-upload-manager-item", "true");
|
|
2222
|
+
let r = document.createElement("span");
|
|
2223
|
+
r.className = "formie-upload-manager-filename", r.setAttribute("data-formie-upload-manager-filename", "true"), r.textContent = t;
|
|
2224
|
+
let i = document.createElement("div");
|
|
2225
|
+
i.className = "formie-upload-manager-progress", i.setAttribute("data-formie-upload-manager-progress", "true"), i.setAttribute("aria-live", "polite");
|
|
2226
|
+
let a = document.createElement("div");
|
|
2227
|
+
a.className = "formie-upload-manager-progress-track", a.setAttribute("data-formie-upload-manager-progress-track", "true"), a.setAttribute("data-indeterminate", "true");
|
|
2228
|
+
let o = document.createElement("div");
|
|
2229
|
+
o.className = "formie-upload-manager-progress-bar", o.setAttribute("data-formie-upload-manager-progress-bar", "true"), o.setAttribute("data-progress", "0"), o.style.width = "0%";
|
|
2230
|
+
let s = document.createElement("span");
|
|
2231
|
+
s.className = "formie-upload-manager-progress-label", s.setAttribute("data-formie-upload-manager-progress-label", "true"), s.textContent = "Preparing…", a.append(o), i.append(a, s);
|
|
2232
|
+
let c = document.createElement("div");
|
|
2233
|
+
c.className = "formie-upload-manager-sort-controls", c.setAttribute("data-formie-upload-manager-sort-controls", "true"), c.hidden = !0;
|
|
2234
|
+
let l = gt("up"), u = gt("down");
|
|
2235
|
+
c.append(l, u);
|
|
2236
|
+
let d = document.createElement("div");
|
|
2237
|
+
d.className = "formie-upload-manager-actions", d.setAttribute("data-formie-upload-manager-actions", "true");
|
|
2238
|
+
let f = document.createElement("button");
|
|
2239
|
+
f.type = "button", f.className = "formie-upload-manager-action-button formie-upload-manager-remove-button", f.setAttribute("data-formie-upload-manager-remove", "true"), f.setAttribute("aria-label", "Remove file"), f.setAttribute("title", "Remove file"), f.setAttribute("data-formie-icon", "close"), f.textContent = "Remove", d.append(c, f);
|
|
2240
|
+
let p = document.createElement("span");
|
|
2241
|
+
return p.className = "formie-upload-manager-error", p.setAttribute("data-formie-upload-manager-error", "true"), p.hidden = !0, n.append(r, i, d, p), Z(n, "Preparing…", "preparing"), {
|
|
2242
|
+
listItem: n,
|
|
2243
|
+
filenameEl: r,
|
|
2244
|
+
errorEl: p,
|
|
2245
|
+
removeButton: f,
|
|
2246
|
+
sortUpButton: l,
|
|
2247
|
+
sortDownButton: u
|
|
2248
|
+
};
|
|
2249
|
+
}
|
|
2250
|
+
function Q(e) {
|
|
2251
|
+
let t = q(e).find((e) => e.hasAttribute(Ye));
|
|
2252
|
+
if (t?.name) return t.name;
|
|
2253
|
+
let n = K(e);
|
|
2254
|
+
return n ? `fields[${n}][]` : "fields[fileUpload][]";
|
|
2255
|
+
}
|
|
2256
|
+
function vt(e) {
|
|
2257
|
+
return e.files.filter((e) => e.assetId !== null).length;
|
|
2258
|
+
}
|
|
2259
|
+
function $(e) {
|
|
2260
|
+
let t = e.files.map((e) => e.assetId).filter((e) => e !== null);
|
|
2261
|
+
st(e.field, e.anchorInput, e.assetInputName, t), e.statusInput && (e.statusInput.value = t.length ? "uploaded" : ""), l(e.field, "file-upload", "uploaded-assets-sync", { assets: t.map((t) => ({
|
|
2262
|
+
assetId: t,
|
|
2263
|
+
filename: e.files.find((e) => e.assetId === t)?.filename || ""
|
|
2264
|
+
})) });
|
|
2265
|
+
}
|
|
2266
|
+
function yt(e) {
|
|
2267
|
+
c(e, $e, (e) => {
|
|
2268
|
+
e.addValidator("uploadManagerRequired", ({ input: e }) => {
|
|
2269
|
+
if (!e.matches(V)) return !0;
|
|
2270
|
+
let t = e.closest("[data-formie-field-handle]");
|
|
2271
|
+
return !(t instanceof HTMLElement) || e.getAttribute("data-formie-validation-required") !== "true" ? !0 : J(t, Q(t)).length > 0;
|
|
2272
|
+
}, ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-required-message") ?? n("{label} cannot be blank.", { label: t })), e.addValidator("uploadManagerFileLimit", ({ input: e }) => {
|
|
2273
|
+
if (!e.matches(V)) return !0;
|
|
2274
|
+
let t = e.closest("[data-formie-field-handle]");
|
|
2275
|
+
if (!(t instanceof HTMLElement)) return !0;
|
|
2276
|
+
let n = t.querySelector(B);
|
|
2277
|
+
if (!(n instanceof HTMLElement)) return !0;
|
|
2278
|
+
let r = parseInt(n.getAttribute("data-formie-file-limit") || "", 10);
|
|
2279
|
+
return r ? J(t, Q(t)).length <= r : !0;
|
|
2280
|
+
}, ({ input: e, t }) => {
|
|
2281
|
+
let n = e.closest("[data-formie-field-handle]")?.querySelector(B);
|
|
2282
|
+
return n?.getAttribute("data-formie-validation-max-files-message") ?? t("Choose up to {files} files.", { files: n?.getAttribute("data-formie-file-limit") || "" });
|
|
2283
|
+
});
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
function bt(e) {
|
|
2287
|
+
s(e, $e, et);
|
|
2288
|
+
}
|
|
2289
|
+
function xt(e, t) {
|
|
2290
|
+
if (e instanceof HTMLFormElement) return e;
|
|
2291
|
+
let n = t.closest("form");
|
|
2292
|
+
return n instanceof HTMLFormElement ? n : null;
|
|
2293
|
+
}
|
|
2294
|
+
function St(e, t, n) {
|
|
2295
|
+
let r = e.querySelector(z);
|
|
2296
|
+
if (!(r instanceof HTMLElement)) return () => {};
|
|
2297
|
+
let i = r.querySelector(B);
|
|
2298
|
+
if (!(i instanceof HTMLElement)) return () => {};
|
|
2299
|
+
let o = r.querySelector(We), s = r.querySelector(Ue), c = r.querySelector(Ge), u = r.querySelector(V);
|
|
2300
|
+
if (!(o instanceof HTMLInputElement) || !(c instanceof HTMLElement)) return () => {};
|
|
2301
|
+
let d = xt(t, e), f = u instanceof HTMLInputElement ? u : null, p = Q(e), m = at(e, p), h = Y(i, n.uploadEndpoint, "data-formie-file-upload-upload-endpoint", "/actions/formie/file-upload/upload"), g = Y(i, n.deleteEndpoint, "data-formie-file-upload-delete-endpoint", "/actions/formie/file-upload/delete"), _ = Y(i, n.hydrateEndpoint, "data-formie-file-upload-hydrate-endpoint", "/actions/formie/file-upload/hydrate"), v = n.limitFiles ?? G(i.getAttribute("data-formie-file-limit")), y = n.sizeLimit ?? parseFloat(i.getAttribute("data-formie-size-max-limit") || ""), b = n.sizeMinLimit ?? parseFloat(i.getAttribute("data-formie-size-min-limit") || ""), x = ut(n.accept ?? i.getAttribute("accept") ?? o.accept), S = {};
|
|
2302
|
+
v && (S.maxNumberOfFiles = v), y && (S.maxFileSize = y * 1e3 * 1e3), b && (S.minFileSize = b * 1e3 * 1e3), x && (S.allowedFileTypes = x);
|
|
2303
|
+
let C = new Fe({
|
|
2304
|
+
autoProceed: !0,
|
|
2305
|
+
restrictions: S
|
|
2306
|
+
});
|
|
2307
|
+
C.use(Ve, {
|
|
2308
|
+
endpoint: h,
|
|
2309
|
+
fieldName: "file",
|
|
2310
|
+
formData: !0,
|
|
2311
|
+
withCredentials: !0,
|
|
2312
|
+
timeout: rt,
|
|
2313
|
+
shouldRetry: mt,
|
|
2314
|
+
headers: { Accept: "application/json" },
|
|
2315
|
+
allowedMetaFields: [
|
|
2316
|
+
"handle",
|
|
2317
|
+
"fieldHandle",
|
|
2318
|
+
"inputKey",
|
|
2319
|
+
"renderId",
|
|
2320
|
+
"draftContextToken",
|
|
2321
|
+
"draftContext",
|
|
2322
|
+
"submissionId",
|
|
2323
|
+
"CRAFT_CSRF_TOKEN"
|
|
2324
|
+
],
|
|
2325
|
+
getResponseData(e) {
|
|
2326
|
+
try {
|
|
2327
|
+
return JSON.parse(e.responseText);
|
|
2328
|
+
} catch {
|
|
2329
|
+
return {};
|
|
2330
|
+
}
|
|
2331
|
+
},
|
|
2332
|
+
onBeforeRequest(e, t, n) {
|
|
2333
|
+
let r = n[0];
|
|
2334
|
+
!r?.id || !r.size || e.upload.addEventListener("progress", (e) => {
|
|
2335
|
+
let t = M(r.id);
|
|
2336
|
+
if (!t) return;
|
|
2337
|
+
let n = 0;
|
|
2338
|
+
e.lengthComputable && e.total > 0 ? n = Math.round(e.loaded / e.total * 100) : e.loaded > 0 && r.size && (n = Math.min(100, Math.round(e.loaded / r.size * 100))), ft(t.listItem, n, {
|
|
2339
|
+
loaded: e.loaded,
|
|
2340
|
+
total: e.lengthComputable ? e.total : r.size ?? void 0
|
|
2341
|
+
});
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
});
|
|
2345
|
+
let w = {
|
|
2346
|
+
field: e,
|
|
2347
|
+
dropzone: i,
|
|
2348
|
+
browseInput: o,
|
|
2349
|
+
statusInput: f,
|
|
2350
|
+
fileList: c,
|
|
2351
|
+
anchorInput: m,
|
|
2352
|
+
assetInputName: p,
|
|
2353
|
+
uppy: C,
|
|
2354
|
+
files: []
|
|
2355
|
+
}, T = () => v ? Math.max(0, v - vt(w)) : null, E = (e) => {
|
|
2356
|
+
i.classList.toggle("formie-upload-manager-dropzone-active", e);
|
|
2357
|
+
}, D = (e) => e.assetId !== null && !e.listItem.classList.contains("is-error"), O = () => {
|
|
2358
|
+
let e = w.files.length >= 2;
|
|
2359
|
+
w.files.forEach((t, n) => {
|
|
2360
|
+
let r = t.listItem.querySelector(Ke), i = t.listItem.querySelector(qe), a = t.listItem.querySelector(Je);
|
|
2361
|
+
if (!(r instanceof HTMLElement)) return;
|
|
2362
|
+
let o = e && D(t);
|
|
2363
|
+
r.hidden = !o, i instanceof HTMLButtonElement && (i.disabled = !o || n === 0), a instanceof HTMLButtonElement && (a.disabled = !o || n >= w.files.length - 1);
|
|
2364
|
+
});
|
|
2365
|
+
}, k = (e, t) => {
|
|
2366
|
+
let n = w.files.indexOf(e), r = n + t;
|
|
2367
|
+
if (n < 0 || r < 0 || r >= w.files.length) return;
|
|
2368
|
+
let i = w.files[r];
|
|
2369
|
+
w.files[n] = i, w.files[r] = e, t === -1 ? e.listItem.before(i.listItem) : e.listItem.after(i.listItem), $(w), O(), l(w.field, "file-upload", "uploaded-assets-reordered", { assets: w.files.filter((e) => e.assetId !== null).map((e) => ({
|
|
2370
|
+
assetId: e.assetId,
|
|
2371
|
+
filename: e.filename
|
|
2372
|
+
})) });
|
|
2373
|
+
}, A = (e, t, n, r) => {
|
|
2374
|
+
t.addEventListener("click", () => {
|
|
2375
|
+
ee(e);
|
|
2376
|
+
}), n.addEventListener("click", () => {
|
|
2377
|
+
k(e, -1);
|
|
2378
|
+
}), r.addEventListener("click", () => {
|
|
2379
|
+
k(e, 1);
|
|
2380
|
+
});
|
|
2381
|
+
}, ee = async (t) => {
|
|
2382
|
+
if (t.uppyFileId && C.removeFile(t.uppyFileId), t.assetId) {
|
|
2383
|
+
let n = new FormData(), r = ct(d, e, i);
|
|
2384
|
+
Object.entries(r).forEach(([e, t]) => {
|
|
2385
|
+
n.append(e, t);
|
|
2386
|
+
}), n.append("assetId", String(t.assetId));
|
|
2387
|
+
try {
|
|
2388
|
+
await a(g, {
|
|
2389
|
+
method: "POST",
|
|
2390
|
+
body: n
|
|
2391
|
+
});
|
|
2392
|
+
} catch (e) {
|
|
2393
|
+
U.warn("Failed to delete uploaded asset.", {
|
|
2394
|
+
assetId: t.assetId,
|
|
2395
|
+
error: e
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
t.listItem.remove(), w.files = w.files.filter((e) => e !== t), $(w), O();
|
|
2400
|
+
}, j = (t, n) => {
|
|
2401
|
+
let { listItem: r, removeButton: i, sortUpButton: a, sortDownButton: o } = _t(e, n);
|
|
2402
|
+
r.classList.add("is-complete"), c.append(r);
|
|
2403
|
+
let s = {
|
|
2404
|
+
assetId: t,
|
|
2405
|
+
filename: n,
|
|
2406
|
+
uppyFileId: null,
|
|
2407
|
+
listItem: r
|
|
2408
|
+
};
|
|
2409
|
+
A(s, i, a, o), w.files.push(s), O();
|
|
2410
|
+
}, te = async () => {
|
|
2411
|
+
let t = J(e, p);
|
|
2412
|
+
if (t.length) try {
|
|
2413
|
+
let n = (await a(_, {
|
|
2414
|
+
method: "POST",
|
|
2415
|
+
body: lt(d, e, t)
|
|
2416
|
+
})).assets || [], r = new Map(n.map((e) => [G(e.assetId), e]).filter(([e]) => e !== null));
|
|
2417
|
+
t.forEach((e) => {
|
|
2418
|
+
if (w.files.some((t) => t.assetId === e)) return;
|
|
2419
|
+
let t = r.get(e);
|
|
2420
|
+
t && j(e, t.filename || `Asset #${e}`);
|
|
2421
|
+
}), $(w), O();
|
|
2422
|
+
} catch (e) {
|
|
2423
|
+
U.warn("Failed to hydrate uploaded assets.", { error: e });
|
|
2424
|
+
}
|
|
2425
|
+
}, M = (e) => e && w.files.find((t) => t.uppyFileId === e) || null;
|
|
2426
|
+
C.on("upload-progress", (e, t) => {
|
|
2427
|
+
let n = M(e?.id);
|
|
2428
|
+
if (!n) return;
|
|
2429
|
+
let r = t.bytesTotal || 0, i = t.bytesUploaded || 0, a = r > 0 ? Math.round(i / r * 100) : 0;
|
|
2430
|
+
ft(n.listItem, a, {
|
|
2431
|
+
loaded: i,
|
|
2432
|
+
total: r
|
|
2433
|
+
});
|
|
2434
|
+
}), C.on("upload-retry", (e) => {
|
|
2435
|
+
let t = M(e?.id);
|
|
2436
|
+
t && Z(t.listItem, "Retrying…", "retrying");
|
|
2437
|
+
}), C.on("upload-success", (e, t) => {
|
|
2438
|
+
let n = M(e?.id);
|
|
2439
|
+
if (!n) return;
|
|
2440
|
+
let r = n.listItem.querySelector("[data-formie-upload-manager-error]"), i = W(t?.body) ? t.body : {}, a = G(i.assetId);
|
|
2441
|
+
if (!i.success || !a) {
|
|
2442
|
+
if (n.listItem.classList.add("is-error"), n.listItem.classList.remove("is-uploading", "is-upload-complete", "is-processing", "is-preparing"), r instanceof HTMLElement) {
|
|
2443
|
+
r.hidden = !1, r.textContent = pt(null, { message: "Upload failed." });
|
|
2444
|
+
let e = i.errors ? Object.values(i.errors).flat().find(Boolean) : null;
|
|
2445
|
+
e && (r.textContent = e);
|
|
2446
|
+
}
|
|
2447
|
+
return;
|
|
2448
|
+
}
|
|
2449
|
+
n.assetId = a, n.filename = i.filename || n.filename, ht(n.listItem), $(w), O();
|
|
2450
|
+
}), C.on("upload-error", (e, t, n) => {
|
|
2451
|
+
let r = M(e?.id);
|
|
2452
|
+
if (!r) return;
|
|
2453
|
+
let i = r.listItem.querySelector("[data-formie-upload-manager-error]");
|
|
2454
|
+
r.listItem.classList.add("is-error"), r.listItem.classList.remove("is-uploading", "is-upload-complete", "is-processing", "is-preparing"), i instanceof HTMLElement && (i.hidden = !1, i.textContent = pt(n, t));
|
|
2455
|
+
}), C.on("file-added", (t) => {
|
|
2456
|
+
let n = T();
|
|
2457
|
+
if (n !== null && n <= 0) {
|
|
2458
|
+
C.removeFile(t.id), C.info("File limit reached.", "error", 3e3);
|
|
2459
|
+
return;
|
|
2460
|
+
}
|
|
2461
|
+
C.setFileMeta(t.id, ct(d, e, i));
|
|
2462
|
+
let { listItem: r, removeButton: a, sortUpButton: o, sortDownButton: s } = _t(e, t.name || "Upload");
|
|
2463
|
+
c.append(r);
|
|
2464
|
+
let l = {
|
|
2465
|
+
assetId: null,
|
|
2466
|
+
filename: t.name || "Upload",
|
|
2467
|
+
uppyFileId: t.id,
|
|
2468
|
+
listItem: r
|
|
2469
|
+
};
|
|
2470
|
+
A(l, a, o, s), w.files.push(l), O();
|
|
2471
|
+
});
|
|
2472
|
+
let N = () => {
|
|
2473
|
+
o.click();
|
|
2474
|
+
};
|
|
2475
|
+
s?.addEventListener("click", (e) => {
|
|
2476
|
+
e.preventDefault(), e.stopPropagation(), N();
|
|
2477
|
+
}), i.addEventListener("click", (e) => {
|
|
2478
|
+
e.target instanceof Element && e.target.closest(Ue) || N();
|
|
2479
|
+
}), i.addEventListener("keydown", (e) => {
|
|
2480
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), N());
|
|
2481
|
+
}), o.addEventListener("change", () => {
|
|
2482
|
+
if (!o.files?.length) return;
|
|
2483
|
+
let e = Array.from(o.files);
|
|
2484
|
+
o.value = "";
|
|
2485
|
+
try {
|
|
2486
|
+
C.addFiles(e.map((e) => ({
|
|
2487
|
+
name: e.name,
|
|
2488
|
+
type: e.type,
|
|
2489
|
+
data: e
|
|
2490
|
+
})));
|
|
2491
|
+
} catch (e) {
|
|
2492
|
+
e instanceof Error && C.info(e.message, "error", 3e3);
|
|
2493
|
+
}
|
|
2494
|
+
}), ["dragenter", "dragover"].forEach((e) => {
|
|
2495
|
+
i.addEventListener(e, (e) => {
|
|
2496
|
+
e.preventDefault(), e.stopPropagation(), E(!0);
|
|
2497
|
+
});
|
|
2498
|
+
}), ["dragleave", "drop"].forEach((e) => {
|
|
2499
|
+
i.addEventListener(e, (e) => {
|
|
2500
|
+
e.preventDefault(), e.stopPropagation(), E(!1);
|
|
2501
|
+
});
|
|
2502
|
+
}), i.addEventListener("drop", (e) => {
|
|
2503
|
+
let t = e.dataTransfer;
|
|
2504
|
+
if (!t?.files?.length) return;
|
|
2505
|
+
let n = Array.from(t.files);
|
|
2506
|
+
try {
|
|
2507
|
+
C.addFiles(n.map((e) => ({
|
|
2508
|
+
name: e.name,
|
|
2509
|
+
type: e.type,
|
|
2510
|
+
data: e
|
|
2511
|
+
})));
|
|
2512
|
+
} catch (e) {
|
|
2513
|
+
e instanceof Error && C.info(e.message, "error", 3e3);
|
|
2514
|
+
}
|
|
2515
|
+
});
|
|
2516
|
+
let P = () => {
|
|
2517
|
+
w.files.forEach((e) => {
|
|
2518
|
+
e.listItem.remove();
|
|
2519
|
+
}), w.files = [], C.cancelAll(), st(e, m, p, []);
|
|
2520
|
+
};
|
|
2521
|
+
return d?.addEventListener(Xe, P), te(), () => {
|
|
2522
|
+
d?.removeEventListener(Xe, P), C.destroy(), w.files = [];
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
var Ct = {
|
|
2526
|
+
id: Qe,
|
|
2527
|
+
kind: "field",
|
|
2528
|
+
match: (e) => !!e.target.querySelector(z),
|
|
2529
|
+
setup: async (e) => {
|
|
2530
|
+
let t = e.options || {}, n = e.form, r = /* @__PURE__ */ new WeakSet(), i = [];
|
|
2531
|
+
yt(n);
|
|
2532
|
+
let a = (e) => {
|
|
2533
|
+
let a = /* @__PURE__ */ new Set();
|
|
2534
|
+
e instanceof HTMLElement && e.hasAttribute("data-formie-field-handle") && a.add(e), e instanceof Element && (e.querySelectorAll("[data-formie-field-handle]").forEach((e) => {
|
|
2535
|
+
e instanceof HTMLElement && a.add(e);
|
|
2536
|
+
}), e.querySelectorAll(z).forEach((e) => {
|
|
2537
|
+
let t = e.closest("[data-formie-field-handle]");
|
|
2538
|
+
t instanceof HTMLElement && a.add(t);
|
|
2539
|
+
})), a.forEach((e) => {
|
|
2540
|
+
r.has(e) || !e.querySelector(z) || (r.add(e), i.push(St(e, n, t)));
|
|
2541
|
+
});
|
|
2542
|
+
};
|
|
2543
|
+
a(e.target);
|
|
2544
|
+
let o = (e) => {
|
|
2545
|
+
let t = e.detail;
|
|
2546
|
+
if (!W(t)) return;
|
|
2547
|
+
let n = t.row;
|
|
2548
|
+
n instanceof HTMLElement && a(n);
|
|
2549
|
+
};
|
|
2550
|
+
return n?.addEventListener(Ze, o), U.log("Module setup.", { count: i.length }), await e.emit("formie:module:upload-manager:init", { count: i.length }), { destroy: () => {
|
|
2551
|
+
n?.removeEventListener(Ze, o), i.forEach((e) => {
|
|
2552
|
+
e();
|
|
2553
|
+
}), bt(n), U.log("Module destroy."), e.emit("formie:module:upload-manager:destroy", {});
|
|
2554
|
+
} };
|
|
2555
|
+
}
|
|
2556
|
+
};
|
|
2557
|
+
//#endregion
|
|
2558
|
+
export { Ct as uploadManagerModule };
|