@opencx/widget 3.0.11 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/designs.cjs +59 -59
- package/dist/designs.cjs.map +1 -1
- package/dist/designs.js +8642 -8522
- package/dist/designs.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.js +12 -12
- package/dist/src/designs/react/components/lib/button.d.ts +1 -1
- package/dist/src/designs/react/components/lib/loading.d.ts +4 -0
- package/dist/src/designs/react/screens/sessions/index.d.ts +2 -0
- package/dist/src/headless/core/context/{contact.d.ts → contact.ctx.d.ts} +3 -3
- package/dist/src/headless/core/context/message.ctx.d.ts +33 -0
- package/dist/src/headless/core/context/router.ctx.d.ts +29 -0
- package/dist/src/headless/core/context/{session.d.ts → session.ctx.d.ts} +23 -17
- package/dist/src/headless/core/context/{widget.d.ts → widget.ctx.d.ts} +5 -3
- package/dist/src/headless/core/index.d.ts +6 -5
- package/dist/src/headless/core/sdk/schema.d.ts +2 -0
- package/dist/src/headless/core/utils/Poller.d.ts +2 -2
- package/dist/src/headless/core/utils/{PubSub.d.ts → PrimitiveState.d.ts} +1 -1
- package/dist/src/headless/react/hooks/useContact.d.ts +1 -1
- package/dist/src/headless/react/hooks/useMessages.d.ts +1 -1
- package/dist/src/headless/react/hooks/usePreludeData.d.ts +3 -1
- package/dist/src/headless/react/hooks/usePrimitiveState.d.ts +2 -0
- package/dist/src/headless/react/hooks/useSession.d.ts +8 -7
- package/dist/src/headless/react/hooks/useWidgetRouter.d.ts +7 -0
- package/dist/src/headless/react/index.d.ts +1 -1
- package/dist/useUploadFiles-CiUgziil.cjs +18 -0
- package/dist/useUploadFiles-CiUgziil.cjs.map +1 -0
- package/dist/{useUploadFiles-B-HZXbPR.js → useUploadFiles-ClUXwfKK.js} +243 -237
- package/dist/useUploadFiles-ClUXwfKK.js.map +1 -0
- package/dist/widget.ctx-C7UzbSii.cjs +2 -0
- package/dist/widget.ctx-C7UzbSii.cjs.map +1 -0
- package/dist/{widget-BOaF1U-p.js → widget.ctx-DkDwIMJZ.js} +108 -73
- package/dist/widget.ctx-DkDwIMJZ.js.map +1 -0
- package/dist-embed/script.js +112 -102
- package/dist-embed/script.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/designs/react/components/lib/dialog.d.ts +0 -276
- package/dist/src/headless/core/context/message.d.ts +0 -42
- package/dist/src/headless/react/hooks/usePubsub.d.ts +0 -2
- package/dist/useUploadFiles-B-HZXbPR.js.map +0 -1
- package/dist/useUploadFiles-WylOvupS.cjs +0 -18
- package/dist/useUploadFiles-WylOvupS.cjs.map +0 -1
- package/dist/widget-6i5ISSQC.cjs +0 -2
- package/dist/widget-6i5ISSQC.cjs.map +0 -1
- package/dist/widget-BOaF1U-p.js.map +0 -1
- /package/dist/src/designs/react/screens/{chat-screen → chat}/ChatFooter.d.ts +0 -0
- /package/dist/src/designs/react/screens/{chat-screen → chat}/ChatHeader.d.ts +0 -0
- /package/dist/src/designs/react/screens/{chat-screen → chat}/ChatMain.d.ts +0 -0
- /package/dist/src/designs/react/screens/{chat-screen/ChatScreen.d.ts → chat/index.d.ts} +0 -0
- /package/dist/src/designs/react/screens/{root-screen.d.ts → index.d.ts} +0 -0
- /package/dist/src/designs/react/screens/{welcome-screen/WelcomeScreen.d.ts → welcome/index.d.ts} +0 -0
- /package/dist/src/headless/core/utils/{PubSub.test.d.ts → PrimitiveState.test.d.ts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var Kt = Object.defineProperty;
|
|
2
2
|
var kt = (e, t, n) => t in e ? Kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var Ye = (e, t, n) => kt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import k, { createContext as rt, useContext as ot, useMemo as le, useSyncExternalStore as zt, useEffect as st, useLayoutEffect as Yt, useRef as K, useCallback as
|
|
4
|
+
import k, { createContext as rt, useContext as ot, useMemo as le, useSyncExternalStore as zt, useEffect as st, useLayoutEffect as Yt, useRef as K, useCallback as ve, useDebugValue as Jt, useState as Xt } from "react";
|
|
5
5
|
import { jsx as Qt } from "react/jsx-runtime";
|
|
6
|
-
import { W as Zt } from "./widget-
|
|
6
|
+
import { W as Zt } from "./widget.ctx-DkDwIMJZ.js";
|
|
7
7
|
import { v4 as en } from "uuid";
|
|
8
8
|
class tn {
|
|
9
9
|
constructor(t) {
|
|
@@ -50,7 +50,7 @@ function nn(e) {
|
|
|
50
50
|
return r;
|
|
51
51
|
}, t.Provider];
|
|
52
52
|
}
|
|
53
|
-
const rn = "3.0.
|
|
53
|
+
const rn = "3.0.13", [te, on] = nn();
|
|
54
54
|
function tr({
|
|
55
55
|
options: e,
|
|
56
56
|
children: t,
|
|
@@ -82,23 +82,27 @@ function nr() {
|
|
|
82
82
|
const { widgetCtx: e } = te();
|
|
83
83
|
return e.config;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function de(e) {
|
|
86
86
|
return zt(e.subscribe, e.get, e.get);
|
|
87
87
|
}
|
|
88
88
|
function rr() {
|
|
89
89
|
const { widgetCtx: e } = te();
|
|
90
90
|
return {
|
|
91
|
-
contactState:
|
|
92
|
-
|
|
91
|
+
contactState: de(e.contactCtx.state),
|
|
92
|
+
createUnverifiedContact: e.contactCtx.createUnverifiedContact
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
function sn() {
|
|
96
96
|
const { widgetCtx: e } = te();
|
|
97
|
-
return { messagesState:
|
|
97
|
+
return { messagesState: de(e.messageCtx.state), sendMessage: e.messageCtx.sendMessage };
|
|
98
98
|
}
|
|
99
99
|
function an() {
|
|
100
|
-
const { widgetCtx: e } = te();
|
|
101
|
-
return {
|
|
100
|
+
const { widgetCtx: e } = te(), t = de(e.sessionCtx.sessionState), n = de(e.sessionCtx.sessionsState);
|
|
101
|
+
return {
|
|
102
|
+
sessionState: t,
|
|
103
|
+
sessionsState: n,
|
|
104
|
+
loadMoreSessions: e.sessionCtx.loadMoreSessions
|
|
105
|
+
};
|
|
102
106
|
}
|
|
103
107
|
function or() {
|
|
104
108
|
var r;
|
|
@@ -109,7 +113,7 @@ var sr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
|
|
|
109
113
|
function ir(e) {
|
|
110
114
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
111
115
|
}
|
|
112
|
-
function
|
|
116
|
+
function cn(e) {
|
|
113
117
|
if (e.__esModule) return e;
|
|
114
118
|
var t = e.default;
|
|
115
119
|
if (typeof t == "function") {
|
|
@@ -128,7 +132,7 @@ function un(e) {
|
|
|
128
132
|
});
|
|
129
133
|
}), n;
|
|
130
134
|
}
|
|
131
|
-
var
|
|
135
|
+
var De = { exports: {} }, we = {};
|
|
132
136
|
/**
|
|
133
137
|
* @license React
|
|
134
138
|
* use-sync-external-store-shim.production.min.js
|
|
@@ -139,41 +143,41 @@ var Ce = { exports: {} }, ve = {};
|
|
|
139
143
|
* LICENSE file in the root directory of this source tree.
|
|
140
144
|
*/
|
|
141
145
|
var Je;
|
|
142
|
-
function
|
|
143
|
-
if (Je) return
|
|
146
|
+
function un() {
|
|
147
|
+
if (Je) return we;
|
|
144
148
|
Je = 1;
|
|
145
149
|
var e = k;
|
|
146
|
-
function t(
|
|
147
|
-
return
|
|
150
|
+
function t(c, l) {
|
|
151
|
+
return c === l && (c !== 0 || 1 / c === 1 / l) || c !== c && l !== l;
|
|
148
152
|
}
|
|
149
153
|
var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, o = e.useEffect, s = e.useLayoutEffect, i = e.useDebugValue;
|
|
150
|
-
function d(
|
|
151
|
-
var
|
|
154
|
+
function d(c, l) {
|
|
155
|
+
var u = l(), y = r({ inst: { value: u, getSnapshot: l } }), _ = y[0].inst, T = y[1];
|
|
152
156
|
return s(function() {
|
|
153
|
-
_.value =
|
|
154
|
-
}, [
|
|
155
|
-
return h(_) && T({ inst: _ }),
|
|
157
|
+
_.value = u, _.getSnapshot = l, h(_) && T({ inst: _ });
|
|
158
|
+
}, [c, u, l]), o(function() {
|
|
159
|
+
return h(_) && T({ inst: _ }), c(function() {
|
|
156
160
|
h(_) && T({ inst: _ });
|
|
157
161
|
});
|
|
158
|
-
}, [
|
|
162
|
+
}, [c]), i(u), u;
|
|
159
163
|
}
|
|
160
|
-
function h(
|
|
161
|
-
var l =
|
|
162
|
-
|
|
164
|
+
function h(c) {
|
|
165
|
+
var l = c.getSnapshot;
|
|
166
|
+
c = c.value;
|
|
163
167
|
try {
|
|
164
|
-
var
|
|
165
|
-
return !n(
|
|
168
|
+
var u = l();
|
|
169
|
+
return !n(c, u);
|
|
166
170
|
} catch {
|
|
167
171
|
return !0;
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
|
-
function f(
|
|
174
|
+
function f(c, l) {
|
|
171
175
|
return l();
|
|
172
176
|
}
|
|
173
177
|
var a = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : d;
|
|
174
|
-
return
|
|
178
|
+
return we.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : a, we;
|
|
175
179
|
}
|
|
176
|
-
var
|
|
180
|
+
var Se = {};
|
|
177
181
|
/**
|
|
178
182
|
* @license React
|
|
179
183
|
* use-sync-external-store-shim.development.js
|
|
@@ -208,37 +212,37 @@ function fn() {
|
|
|
208
212
|
function o(O, E) {
|
|
209
213
|
return O === E && (O !== 0 || 1 / O === 1 / E) || O !== O && E !== E;
|
|
210
214
|
}
|
|
211
|
-
var s = typeof Object.is == "function" ? Object.is : o, i = e.useState, d = e.useEffect, h = e.useLayoutEffect, f = e.useDebugValue, a = !1,
|
|
215
|
+
var s = typeof Object.is == "function" ? Object.is : o, i = e.useState, d = e.useEffect, h = e.useLayoutEffect, f = e.useDebugValue, a = !1, c = !1;
|
|
212
216
|
function l(O, E, w) {
|
|
213
217
|
a || e.startTransition !== void 0 && (a = !0, n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
214
218
|
var v = E();
|
|
215
|
-
if (!
|
|
219
|
+
if (!c) {
|
|
216
220
|
var L = E();
|
|
217
|
-
s(v, L) || (n("The result of getSnapshot should be cached to avoid an infinite loop"),
|
|
221
|
+
s(v, L) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), c = !0);
|
|
218
222
|
}
|
|
219
223
|
var S = i({
|
|
220
224
|
inst: {
|
|
221
225
|
value: v,
|
|
222
226
|
getSnapshot: E
|
|
223
227
|
}
|
|
224
|
-
}), C = S[0].inst,
|
|
228
|
+
}), C = S[0].inst, x = S[1];
|
|
225
229
|
return h(function() {
|
|
226
|
-
C.value = v, C.getSnapshot = E,
|
|
230
|
+
C.value = v, C.getSnapshot = E, u(C) && x({
|
|
227
231
|
inst: C
|
|
228
232
|
});
|
|
229
233
|
}, [O, v, E]), d(function() {
|
|
230
|
-
|
|
234
|
+
u(C) && x({
|
|
231
235
|
inst: C
|
|
232
236
|
});
|
|
233
237
|
var q = function() {
|
|
234
|
-
|
|
238
|
+
u(C) && x({
|
|
235
239
|
inst: C
|
|
236
240
|
});
|
|
237
241
|
};
|
|
238
242
|
return O(q);
|
|
239
243
|
}, [O]), f(v), v;
|
|
240
244
|
}
|
|
241
|
-
function
|
|
245
|
+
function u(O) {
|
|
242
246
|
var E = O.getSnapshot, w = O.value;
|
|
243
247
|
try {
|
|
244
248
|
var v = E();
|
|
@@ -251,78 +255,78 @@ function fn() {
|
|
|
251
255
|
return E();
|
|
252
256
|
}
|
|
253
257
|
var _ = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", T = !_, p = T ? y : l, z = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : p;
|
|
254
|
-
|
|
255
|
-
}()),
|
|
258
|
+
Se.useSyncExternalStore = z, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
259
|
+
}()), Se;
|
|
256
260
|
}
|
|
257
|
-
process.env.NODE_ENV === "production" ?
|
|
258
|
-
var ln =
|
|
261
|
+
process.env.NODE_ENV === "production" ? De.exports = un() : De.exports = fn();
|
|
262
|
+
var ln = De.exports;
|
|
259
263
|
const H = () => {
|
|
260
264
|
}, P = (
|
|
261
265
|
/*#__NOINLINE__*/
|
|
262
266
|
H()
|
|
263
|
-
),
|
|
267
|
+
), me = Object, g = (e) => e === P, M = (e) => typeof e == "function", G = (e, t) => ({
|
|
264
268
|
...e,
|
|
265
269
|
...t
|
|
266
|
-
}), dn = (e) =>
|
|
270
|
+
}), dn = (e) => M(e.then), ce = /* @__PURE__ */ new WeakMap();
|
|
267
271
|
let pn = 0;
|
|
268
272
|
const oe = (e) => {
|
|
269
273
|
const t = typeof e, n = e && e.constructor, r = n == Date;
|
|
270
274
|
let o, s;
|
|
271
|
-
if (
|
|
272
|
-
if (o =
|
|
273
|
-
if (o = ++pn + "~",
|
|
275
|
+
if (me(e) === e && !r && n != RegExp) {
|
|
276
|
+
if (o = ce.get(e), o) return o;
|
|
277
|
+
if (o = ++pn + "~", ce.set(e, o), n == Array) {
|
|
274
278
|
for (o = "@", s = 0; s < e.length; s++)
|
|
275
279
|
o += oe(e[s]) + ",";
|
|
276
|
-
|
|
280
|
+
ce.set(e, o);
|
|
277
281
|
}
|
|
278
|
-
if (n ==
|
|
282
|
+
if (n == me) {
|
|
279
283
|
o = "#";
|
|
280
|
-
const i =
|
|
284
|
+
const i = me.keys(e).sort();
|
|
281
285
|
for (; !g(s = i.pop()); )
|
|
282
286
|
g(e[s]) || (o += s + ":" + oe(e[s]) + ",");
|
|
283
|
-
|
|
287
|
+
ce.set(e, o);
|
|
284
288
|
}
|
|
285
289
|
} else
|
|
286
290
|
o = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
|
|
287
291
|
return o;
|
|
288
|
-
}, W = /* @__PURE__ */ new WeakMap(),
|
|
292
|
+
}, W = /* @__PURE__ */ new WeakMap(), be = {}, ue = {}, Fe = "undefined", _e = typeof window != Fe, Ae = typeof document != Fe, hn = () => _e && typeof window.requestAnimationFrame != Fe, it = (e, t) => {
|
|
289
293
|
const n = W.get(e);
|
|
290
294
|
return [
|
|
291
295
|
// Getter
|
|
292
|
-
() => !g(t) && e.get(t) ||
|
|
296
|
+
() => !g(t) && e.get(t) || be,
|
|
293
297
|
// Setter
|
|
294
298
|
(r) => {
|
|
295
299
|
if (!g(t)) {
|
|
296
300
|
const o = e.get(t);
|
|
297
|
-
t in
|
|
301
|
+
t in ue || (ue[t] = o), n[5](t, G(o, r), o || be);
|
|
298
302
|
}
|
|
299
303
|
},
|
|
300
304
|
// Subscriber
|
|
301
305
|
n[6],
|
|
302
306
|
// Get server cache snapshot
|
|
303
|
-
() => !g(t) && t in
|
|
307
|
+
() => !g(t) && t in ue ? ue[t] : !g(t) && e.get(t) || be
|
|
304
308
|
];
|
|
305
309
|
};
|
|
306
|
-
let
|
|
307
|
-
const _n = () =>
|
|
310
|
+
let je = !0;
|
|
311
|
+
const _n = () => je, [xe, Pe] = _e && window.addEventListener ? [
|
|
308
312
|
window.addEventListener.bind(window),
|
|
309
313
|
window.removeEventListener.bind(window)
|
|
310
314
|
] : [
|
|
311
315
|
H,
|
|
312
316
|
H
|
|
313
317
|
], yn = () => {
|
|
314
|
-
const e =
|
|
318
|
+
const e = Ae && document.visibilityState;
|
|
315
319
|
return g(e) || e !== "hidden";
|
|
316
|
-
}, gn = (e) => (
|
|
317
|
-
|
|
320
|
+
}, gn = (e) => (Ae && document.addEventListener("visibilitychange", e), xe("focus", e), () => {
|
|
321
|
+
Ae && document.removeEventListener("visibilitychange", e), Pe("focus", e);
|
|
318
322
|
}), En = (e) => {
|
|
319
323
|
const t = () => {
|
|
320
|
-
|
|
324
|
+
je = !0, e();
|
|
321
325
|
}, n = () => {
|
|
322
|
-
|
|
326
|
+
je = !1;
|
|
323
327
|
};
|
|
324
328
|
return xe("online", t), xe("offline", n), () => {
|
|
325
|
-
|
|
329
|
+
Pe("online", t), Pe("offline", n);
|
|
326
330
|
};
|
|
327
331
|
}, vn = {
|
|
328
332
|
isOnline: _n,
|
|
@@ -330,11 +334,11 @@ const _n = () => Ae, [xe, je] = he && window.addEventListener ? [
|
|
|
330
334
|
}, wn = {
|
|
331
335
|
initFocus: gn,
|
|
332
336
|
initReconnect: En
|
|
333
|
-
}, Qe = !k.useId, se = !
|
|
337
|
+
}, Qe = !k.useId, se = !_e || "Deno" in window, Sn = (e) => hn() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Oe = se ? st : Yt, Re = typeof navigator < "u" && navigator.connection, Ze = !se && Re && ([
|
|
334
338
|
"slow-2g",
|
|
335
339
|
"2g"
|
|
336
|
-
].includes(
|
|
337
|
-
if (
|
|
340
|
+
].includes(Re.effectiveType) || Re.saveData), Me = (e) => {
|
|
341
|
+
if (M(e))
|
|
338
342
|
try {
|
|
339
343
|
e = e();
|
|
340
344
|
} catch {
|
|
@@ -347,13 +351,13 @@ const _n = () => Ae, [xe, je] = he && window.addEventListener ? [
|
|
|
347
351
|
];
|
|
348
352
|
};
|
|
349
353
|
let mn = 0;
|
|
350
|
-
const
|
|
354
|
+
const Le = () => ++mn, at = 0, ct = 1, ut = 2, bn = 3;
|
|
351
355
|
var re = {
|
|
352
356
|
__proto__: null,
|
|
353
357
|
ERROR_REVALIDATE_EVENT: bn,
|
|
354
358
|
FOCUS_EVENT: at,
|
|
355
|
-
MUTATE_EVENT:
|
|
356
|
-
RECONNECT_EVENT:
|
|
359
|
+
MUTATE_EVENT: ut,
|
|
360
|
+
RECONNECT_EVENT: ct
|
|
357
361
|
};
|
|
358
362
|
async function ft(...e) {
|
|
359
363
|
const [t, n, r, o] = e, s = G({
|
|
@@ -366,34 +370,34 @@ async function ft(...e) {
|
|
|
366
370
|
const d = s.rollbackOnError;
|
|
367
371
|
let h = s.optimisticData;
|
|
368
372
|
const f = (l) => typeof d == "function" ? d(l) : d !== !1, a = s.throwOnError;
|
|
369
|
-
if (
|
|
370
|
-
const l = n,
|
|
373
|
+
if (M(n)) {
|
|
374
|
+
const l = n, u = [], y = t.keys();
|
|
371
375
|
for (const _ of y)
|
|
372
376
|
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
373
|
-
!/^\$(inf|sub)\$/.test(_) && l(t.get(_)._k) &&
|
|
374
|
-
return Promise.all(
|
|
377
|
+
!/^\$(inf|sub)\$/.test(_) && l(t.get(_)._k) && u.push(_);
|
|
378
|
+
return Promise.all(u.map(c));
|
|
375
379
|
}
|
|
376
|
-
return
|
|
377
|
-
async function
|
|
378
|
-
const [
|
|
379
|
-
if (!
|
|
380
|
-
const [y, _] = it(t,
|
|
381
|
-
const V = T[
|
|
382
|
-
return (
|
|
380
|
+
return c(n);
|
|
381
|
+
async function c(l) {
|
|
382
|
+
const [u] = Me(l);
|
|
383
|
+
if (!u) return;
|
|
384
|
+
const [y, _] = it(t, u), [T, p, z, O] = W.get(t), E = () => {
|
|
385
|
+
const V = T[u];
|
|
386
|
+
return (M(s.revalidate) ? s.revalidate(y().data, l) : s.revalidate !== !1) && (delete z[u], delete O[u], V && V[0]) ? V[0](ut).then(() => y().data) : y().data;
|
|
383
387
|
};
|
|
384
388
|
if (e.length < 3)
|
|
385
389
|
return E();
|
|
386
390
|
let w = r, v;
|
|
387
|
-
const L =
|
|
388
|
-
p[
|
|
391
|
+
const L = Le();
|
|
392
|
+
p[u] = [
|
|
389
393
|
L,
|
|
390
394
|
0
|
|
391
395
|
];
|
|
392
|
-
const S = !g(h), C = y(),
|
|
393
|
-
if (S && (h =
|
|
396
|
+
const S = !g(h), C = y(), x = C.data, q = C._c, $ = g(q) ? x : q;
|
|
397
|
+
if (S && (h = M(h) ? h($, x) : h, _({
|
|
394
398
|
data: h,
|
|
395
399
|
_c: $
|
|
396
|
-
})),
|
|
400
|
+
})), M(w))
|
|
397
401
|
try {
|
|
398
402
|
w = w($);
|
|
399
403
|
} catch (V) {
|
|
@@ -402,7 +406,7 @@ async function ft(...e) {
|
|
|
402
406
|
if (w && dn(w))
|
|
403
407
|
if (w = await w.catch((V) => {
|
|
404
408
|
v = V;
|
|
405
|
-
}), L !== p[
|
|
409
|
+
}), L !== p[u][0]) {
|
|
406
410
|
if (v) throw v;
|
|
407
411
|
return w;
|
|
408
412
|
} else v && S && f(v) && (i = !0, _({
|
|
@@ -410,7 +414,7 @@ async function ft(...e) {
|
|
|
410
414
|
_c: P
|
|
411
415
|
}));
|
|
412
416
|
if (i && !v)
|
|
413
|
-
if (
|
|
417
|
+
if (M(i)) {
|
|
414
418
|
const V = i(w, $);
|
|
415
419
|
_({
|
|
416
420
|
data: V,
|
|
@@ -423,7 +427,7 @@ async function ft(...e) {
|
|
|
423
427
|
error: P,
|
|
424
428
|
_c: P
|
|
425
429
|
});
|
|
426
|
-
if (p[
|
|
430
|
+
if (p[u][1] = Le(), Promise.resolve(E()).then(() => {
|
|
427
431
|
_({
|
|
428
432
|
_c: P
|
|
429
433
|
});
|
|
@@ -441,15 +445,15 @@ const et = (e, t) => {
|
|
|
441
445
|
if (!W.has(e)) {
|
|
442
446
|
const n = G(wn, t), r = {}, o = ft.bind(P, e);
|
|
443
447
|
let s = H;
|
|
444
|
-
const i = {}, d = (a,
|
|
448
|
+
const i = {}, d = (a, c) => {
|
|
445
449
|
const l = i[a] || [];
|
|
446
|
-
return i[a] = l, l.push(
|
|
447
|
-
}, h = (a,
|
|
448
|
-
e.set(a,
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
for (const y of
|
|
452
|
-
y(
|
|
450
|
+
return i[a] = l, l.push(c), () => l.splice(l.indexOf(c), 1);
|
|
451
|
+
}, h = (a, c, l) => {
|
|
452
|
+
e.set(a, c);
|
|
453
|
+
const u = i[a];
|
|
454
|
+
if (u)
|
|
455
|
+
for (const y of u)
|
|
456
|
+
y(c, l);
|
|
453
457
|
}, f = () => {
|
|
454
458
|
if (!W.has(e) && (W.set(e, [
|
|
455
459
|
r,
|
|
@@ -460,9 +464,9 @@ const et = (e, t) => {
|
|
|
460
464
|
h,
|
|
461
465
|
d
|
|
462
466
|
]), !se)) {
|
|
463
|
-
const a = n.initFocus(setTimeout.bind(P, et.bind(P, r, at))),
|
|
467
|
+
const a = n.initFocus(setTimeout.bind(P, et.bind(P, r, at))), c = n.initReconnect(setTimeout.bind(P, et.bind(P, r, ct)));
|
|
464
468
|
s = () => {
|
|
465
|
-
a && a(),
|
|
469
|
+
a && a(), c && c(), W.delete(e);
|
|
466
470
|
};
|
|
467
471
|
}
|
|
468
472
|
};
|
|
@@ -514,9 +518,9 @@ const et = (e, t) => {
|
|
|
514
518
|
r && s && (n.use = r.concat(s)), o && i && (n.fallback = G(o, i));
|
|
515
519
|
}
|
|
516
520
|
return n;
|
|
517
|
-
},
|
|
521
|
+
}, jn = rt({}), xn = "$inf$", dt = _e && window.__SWR_DEVTOOLS_USE__, Pn = dt ? window.__SWR_DEVTOOLS_USE__ : [], Ln = () => {
|
|
518
522
|
dt && (window.__SWR_DEVTOOLS_REACT__ = k);
|
|
519
|
-
}, In = (e) =>
|
|
523
|
+
}, In = (e) => M(e[1]) ? [
|
|
520
524
|
e[0],
|
|
521
525
|
e[1],
|
|
522
526
|
e[2] || {}
|
|
@@ -524,18 +528,18 @@ const et = (e, t) => {
|
|
|
524
528
|
e[0],
|
|
525
529
|
null,
|
|
526
530
|
(e[1] === null ? e[2] : e[1]) || {}
|
|
527
|
-
], Vn = () => G(Dn, ot(
|
|
528
|
-
const [i] =
|
|
529
|
-
if (i.startsWith(
|
|
531
|
+
], Vn = () => G(Dn, ot(jn)), Fn = (e) => (t, n, r) => e(t, n && ((...s) => {
|
|
532
|
+
const [i] = Me(t), [, , , d] = W.get(lt);
|
|
533
|
+
if (i.startsWith(xn))
|
|
530
534
|
return n(...s);
|
|
531
535
|
const h = d[i];
|
|
532
536
|
return g(h) ? n(...s) : (delete d[i], h);
|
|
533
|
-
}), r),
|
|
537
|
+
}), r), Mn = Pn.concat(Fn), Nn = (e) => function(...n) {
|
|
534
538
|
const r = Vn(), [o, s, i] = In(n), d = An(r, i);
|
|
535
539
|
let h = e;
|
|
536
|
-
const { use: f } = d, a = (f || []).concat(
|
|
537
|
-
for (let
|
|
538
|
-
h = a[
|
|
540
|
+
const { use: f } = d, a = (f || []).concat(Mn);
|
|
541
|
+
for (let c = a.length; c--; )
|
|
542
|
+
h = a[c](h);
|
|
539
543
|
return h(o, s || d.fetcher || null, d);
|
|
540
544
|
}, Un = (e, t, n) => {
|
|
541
545
|
const r = t[e] || (t[e] = []);
|
|
@@ -555,10 +559,10 @@ const tt = k.use || ((e) => {
|
|
|
555
559
|
}, (t) => {
|
|
556
560
|
e.status = "rejected", e.reason = t;
|
|
557
561
|
}), e);
|
|
558
|
-
}),
|
|
562
|
+
}), Te = {
|
|
559
563
|
dedupe: !0
|
|
560
564
|
}, Wn = (e, t, n) => {
|
|
561
|
-
const { cache: r, compare: o, suspense: s, fallbackData: i, revalidateOnMount: d, revalidateIfStale: h, refreshInterval: f, refreshWhenHidden: a, refreshWhenOffline:
|
|
565
|
+
const { cache: r, compare: o, suspense: s, fallbackData: i, revalidateOnMount: d, revalidateIfStale: h, refreshInterval: f, refreshWhenHidden: a, refreshWhenOffline: c, keepPreviousData: l } = n, [u, y, _, T] = W.get(r), [p, z] = Me(e), O = K(!1), E = K(!1), w = K(p), v = K(t), L = K(n), S = () => L.current, C = () => S().isVisible() && S().isOnline(), [x, q, $, V] = it(r, p), Y = K({}).current, qt = g(i) ? n.fallback[p] : i, Ue = (m, b) => {
|
|
562
566
|
for (const A in Y) {
|
|
563
567
|
const R = A;
|
|
564
568
|
if (R === "data") {
|
|
@@ -569,26 +573,26 @@ const tt = k.use || ((e) => {
|
|
|
569
573
|
}
|
|
570
574
|
return !0;
|
|
571
575
|
}, We = le(() => {
|
|
572
|
-
const m = !p || !t ? !1 : g(d) ? S().isPaused() || s ? !1 : g(h) ? !0 : h : d, b = (
|
|
573
|
-
const
|
|
574
|
-
return delete
|
|
576
|
+
const m = !p || !t ? !1 : g(d) ? S().isPaused() || s ? !1 : g(h) ? !0 : h : d, b = (j) => {
|
|
577
|
+
const N = G(j);
|
|
578
|
+
return delete N._k, m ? {
|
|
575
579
|
isValidating: !0,
|
|
576
580
|
isLoading: !0,
|
|
577
|
-
...
|
|
578
|
-
} :
|
|
579
|
-
}, A =
|
|
581
|
+
...N
|
|
582
|
+
} : N;
|
|
583
|
+
}, A = x(), R = V(), F = b(A), Z = A === R ? F : b(R);
|
|
580
584
|
let D = F;
|
|
581
585
|
return [
|
|
582
586
|
() => {
|
|
583
|
-
const
|
|
584
|
-
return Ue(
|
|
587
|
+
const j = b(x());
|
|
588
|
+
return Ue(j, D) ? (D.data = j.data, D.isLoading = j.isLoading, D.isValidating = j.isValidating, D.error = j.error, D) : (D = j, j);
|
|
585
589
|
},
|
|
586
590
|
() => Z
|
|
587
591
|
];
|
|
588
592
|
}, [
|
|
589
593
|
r,
|
|
590
594
|
p
|
|
591
|
-
]), J = ln.useSyncExternalStore(
|
|
595
|
+
]), J = ln.useSyncExternalStore(ve(
|
|
592
596
|
(m) => $(p, (b, A) => {
|
|
593
597
|
Ue(A, b) || m();
|
|
594
598
|
}),
|
|
@@ -597,47 +601,47 @@ const tt = k.use || ((e) => {
|
|
|
597
601
|
r,
|
|
598
602
|
p
|
|
599
603
|
]
|
|
600
|
-
), We[0], We[1]), qe = !O.current, Bt =
|
|
604
|
+
), We[0], We[1]), qe = !O.current, Bt = u[p] && u[p].length > 0, X = J.data, Q = g(X) ? qt : X, ie = J.error, Be = K(Q), ae = l ? g(X) ? Be.current : X : Q, He = Bt && !g(ie) ? !1 : qe && !g(d) ? d : S().isPaused() ? !1 : s ? g(Q) ? !1 : h : g(Q) || h, Ge = !!(p && t && qe && He), Ht = g(J.isValidating) ? Ge : J.isValidating, Gt = g(J.isLoading) ? Ge : J.isLoading, ne = ve(
|
|
601
605
|
async (m) => {
|
|
602
606
|
const b = v.current;
|
|
603
607
|
if (!p || !b || E.current || S().isPaused())
|
|
604
608
|
return !1;
|
|
605
609
|
let A, R, F = !0;
|
|
606
|
-
const Z = m || {}, D = !_[p] || !Z.dedupe,
|
|
610
|
+
const Z = m || {}, D = !_[p] || !Z.dedupe, j = () => Qe ? !E.current && p === w.current && O.current : p === w.current, N = {
|
|
607
611
|
isValidating: !1,
|
|
608
612
|
isLoading: !1
|
|
609
613
|
}, Ke = () => {
|
|
610
|
-
q(
|
|
614
|
+
q(N);
|
|
611
615
|
}, ke = () => {
|
|
612
616
|
const I = _[p];
|
|
613
617
|
I && I[1] === R && delete _[p];
|
|
614
618
|
}, ze = {
|
|
615
619
|
isValidating: !0
|
|
616
620
|
};
|
|
617
|
-
g(
|
|
621
|
+
g(x().data) && (ze.isLoading = !0);
|
|
618
622
|
try {
|
|
619
|
-
if (D && (q(ze), n.loadingTimeout && g(
|
|
620
|
-
F &&
|
|
623
|
+
if (D && (q(ze), n.loadingTimeout && g(x().data) && setTimeout(() => {
|
|
624
|
+
F && j() && S().onLoadingSlow(p, n);
|
|
621
625
|
}, n.loadingTimeout), _[p] = [
|
|
622
626
|
b(z),
|
|
623
|
-
|
|
627
|
+
Le()
|
|
624
628
|
]), [A, R] = _[p], A = await A, D && setTimeout(ke, n.dedupingInterval), !_[p] || _[p][1] !== R)
|
|
625
|
-
return D &&
|
|
626
|
-
|
|
629
|
+
return D && j() && S().onDiscarded(p), !1;
|
|
630
|
+
N.error = P;
|
|
627
631
|
const I = y[p];
|
|
628
632
|
if (!g(I) && // case 1
|
|
629
633
|
(R <= I[0] || // case 2
|
|
630
634
|
R <= I[1] || // case 3
|
|
631
635
|
I[1] === 0))
|
|
632
|
-
return Ke(), D &&
|
|
633
|
-
const U =
|
|
634
|
-
|
|
636
|
+
return Ke(), D && j() && S().onDiscarded(p), !1;
|
|
637
|
+
const U = x().data;
|
|
638
|
+
N.data = o(U, A) ? U : A, D && j() && S().onSuccess(A, p, n);
|
|
635
639
|
} catch (I) {
|
|
636
640
|
ke();
|
|
637
|
-
const U = S(), { shouldRetryOnError:
|
|
638
|
-
U.isPaused() || (
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
+
const U = S(), { shouldRetryOnError: ge } = U;
|
|
642
|
+
U.isPaused() || (N.error = I, D && j() && (U.onError(I, p, U), (ge === !0 || M(ge) && ge(I)) && (!S().revalidateOnFocus || !S().revalidateOnReconnect || C()) && U.onErrorRetry(I, p, U, ($t) => {
|
|
643
|
+
const Ee = u[p];
|
|
644
|
+
Ee && Ee[0] && Ee[0](re.ERROR_REVALIDATE_EVENT, $t);
|
|
641
645
|
}, {
|
|
642
646
|
retryCount: (Z.retryCount || 0) + 1,
|
|
643
647
|
dedupe: !0
|
|
@@ -660,19 +664,19 @@ const tt = k.use || ((e) => {
|
|
|
660
664
|
p,
|
|
661
665
|
r
|
|
662
666
|
]
|
|
663
|
-
), $e =
|
|
667
|
+
), $e = ve(
|
|
664
668
|
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
665
669
|
(...m) => ft(r, w.current, ...m),
|
|
666
670
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
667
671
|
[]
|
|
668
672
|
);
|
|
669
|
-
if (
|
|
673
|
+
if (Oe(() => {
|
|
670
674
|
v.current = t, L.current = n, g(X) || (Be.current = X);
|
|
671
|
-
}),
|
|
675
|
+
}), Oe(() => {
|
|
672
676
|
if (!p) return;
|
|
673
|
-
const m = ne.bind(P,
|
|
677
|
+
const m = ne.bind(P, Te);
|
|
674
678
|
let b = 0;
|
|
675
|
-
const R = Un(p,
|
|
679
|
+
const R = Un(p, u, (F, Z = {}) => {
|
|
676
680
|
if (F == re.FOCUS_EVENT) {
|
|
677
681
|
const D = Date.now();
|
|
678
682
|
S().revalidateOnFocus && D > b && C() && (b = D + S().focusThrottleInterval, m());
|
|
@@ -692,14 +696,14 @@ const tt = k.use || ((e) => {
|
|
|
692
696
|
};
|
|
693
697
|
}, [
|
|
694
698
|
p
|
|
695
|
-
]),
|
|
699
|
+
]), Oe(() => {
|
|
696
700
|
let m;
|
|
697
701
|
function b() {
|
|
698
|
-
const R =
|
|
702
|
+
const R = M(f) ? f(x().data) : f;
|
|
699
703
|
R && m !== -1 && (m = setTimeout(A, R));
|
|
700
704
|
}
|
|
701
705
|
function A() {
|
|
702
|
-
!
|
|
706
|
+
!x().error && (a || S().isVisible()) && (c || S().isOnline()) ? ne(Te).then(b) : b();
|
|
703
707
|
}
|
|
704
708
|
return b(), () => {
|
|
705
709
|
m && (clearTimeout(m), m = -1);
|
|
@@ -707,7 +711,7 @@ const tt = k.use || ((e) => {
|
|
|
707
711
|
}, [
|
|
708
712
|
f,
|
|
709
713
|
a,
|
|
710
|
-
|
|
714
|
+
c,
|
|
711
715
|
p
|
|
712
716
|
]), Jt(ae), s && g(Q) && p) {
|
|
713
717
|
if (!Qe && se)
|
|
@@ -719,7 +723,7 @@ const tt = k.use || ((e) => {
|
|
|
719
723
|
tt(b);
|
|
720
724
|
}
|
|
721
725
|
if (g(ie)) {
|
|
722
|
-
const b = ne(
|
|
726
|
+
const b = ne(Te);
|
|
723
727
|
g(ae) || (b.status = "fulfilled", b.value = !0), tt(b);
|
|
724
728
|
} else
|
|
725
729
|
throw ie;
|
|
@@ -739,35 +743,37 @@ const tt = k.use || ((e) => {
|
|
|
739
743
|
return Y.isLoading = !0, Gt;
|
|
740
744
|
}
|
|
741
745
|
};
|
|
742
|
-
}, qn =
|
|
746
|
+
}, qn = Nn(Wn);
|
|
743
747
|
function ar() {
|
|
744
748
|
const { widgetCtx: e } = te();
|
|
745
|
-
return qn([e.config.token], e.api.widgetPrelude
|
|
749
|
+
return qn([e.config.token], e.api.widgetPrelude, {
|
|
750
|
+
revalidateOnFocus: !1
|
|
751
|
+
});
|
|
746
752
|
}
|
|
747
|
-
var pt = {},
|
|
748
|
-
return
|
|
753
|
+
var pt = {}, Ie = function(e, t) {
|
|
754
|
+
return Ie = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
|
|
749
755
|
n.__proto__ = r;
|
|
750
756
|
} || function(n, r) {
|
|
751
757
|
for (var o in r) Object.prototype.hasOwnProperty.call(r, o) && (n[o] = r[o]);
|
|
752
|
-
},
|
|
758
|
+
}, Ie(e, t);
|
|
753
759
|
};
|
|
754
760
|
function ht(e, t) {
|
|
755
761
|
if (typeof t != "function" && t !== null)
|
|
756
762
|
throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
|
757
|
-
|
|
763
|
+
Ie(e, t);
|
|
758
764
|
function n() {
|
|
759
765
|
this.constructor = e;
|
|
760
766
|
}
|
|
761
767
|
e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
|
|
762
768
|
}
|
|
763
|
-
var
|
|
764
|
-
return
|
|
769
|
+
var pe = function() {
|
|
770
|
+
return pe = Object.assign || function(t) {
|
|
765
771
|
for (var n, r = 1, o = arguments.length; r < o; r++) {
|
|
766
772
|
n = arguments[r];
|
|
767
773
|
for (var s in n) Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
|
|
768
774
|
}
|
|
769
775
|
return t;
|
|
770
|
-
},
|
|
776
|
+
}, pe.apply(this, arguments);
|
|
771
777
|
};
|
|
772
778
|
function _t(e, t) {
|
|
773
779
|
var n = {};
|
|
@@ -793,7 +799,7 @@ function Et(e, t, n, r, o, s) {
|
|
|
793
799
|
if (p !== void 0 && typeof p != "function") throw new TypeError("Function expected");
|
|
794
800
|
return p;
|
|
795
801
|
}
|
|
796
|
-
for (var d = r.kind, h = d === "getter" ? "get" : d === "setter" ? "set" : "value", f = !t && e ? r.static ? e : e.prototype : null, a = t || (f ? Object.getOwnPropertyDescriptor(f, r.name) : {}),
|
|
802
|
+
for (var d = r.kind, h = d === "getter" ? "get" : d === "setter" ? "set" : "value", f = !t && e ? r.static ? e : e.prototype : null, a = t || (f ? Object.getOwnPropertyDescriptor(f, r.name) : {}), c, l = !1, u = n.length - 1; u >= 0; u--) {
|
|
797
803
|
var y = {};
|
|
798
804
|
for (var _ in r) y[_] = _ === "access" ? {} : r[_];
|
|
799
805
|
for (var _ in r.access) y.access[_] = r.access[_];
|
|
@@ -801,12 +807,12 @@ function Et(e, t, n, r, o, s) {
|
|
|
801
807
|
if (l) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
802
808
|
s.push(i(p || null));
|
|
803
809
|
};
|
|
804
|
-
var T = (0, n[
|
|
810
|
+
var T = (0, n[u])(d === "accessor" ? { get: a.get, set: a.set } : a[h], y);
|
|
805
811
|
if (d === "accessor") {
|
|
806
812
|
if (T === void 0) continue;
|
|
807
813
|
if (T === null || typeof T != "object") throw new TypeError("Object expected");
|
|
808
|
-
(
|
|
809
|
-
} else (
|
|
814
|
+
(c = i(T.get)) && (a.get = c), (c = i(T.set)) && (a.set = c), (c = i(T.init)) && o.unshift(c);
|
|
815
|
+
} else (c = i(T)) && (d === "field" ? o.unshift(c) : a[h] = c);
|
|
810
816
|
}
|
|
811
817
|
f && Object.defineProperty(f, r.name, a), l = !0;
|
|
812
818
|
}
|
|
@@ -834,15 +840,15 @@ function bt(e, t, n, r) {
|
|
|
834
840
|
function d(a) {
|
|
835
841
|
try {
|
|
836
842
|
f(r.next(a));
|
|
837
|
-
} catch (
|
|
838
|
-
i(
|
|
843
|
+
} catch (c) {
|
|
844
|
+
i(c);
|
|
839
845
|
}
|
|
840
846
|
}
|
|
841
847
|
function h(a) {
|
|
842
848
|
try {
|
|
843
849
|
f(r.throw(a));
|
|
844
|
-
} catch (
|
|
845
|
-
i(
|
|
850
|
+
} catch (c) {
|
|
851
|
+
i(c);
|
|
846
852
|
}
|
|
847
853
|
}
|
|
848
854
|
function f(a) {
|
|
@@ -911,7 +917,7 @@ function Ot(e, t) {
|
|
|
911
917
|
return { value: f[0] ? f[1] : void 0, done: !0 };
|
|
912
918
|
}
|
|
913
919
|
}
|
|
914
|
-
var
|
|
920
|
+
var ye = Object.create ? function(e, t, n, r) {
|
|
915
921
|
r === void 0 && (r = n);
|
|
916
922
|
var o = Object.getOwnPropertyDescriptor(t, n);
|
|
917
923
|
(!o || ("get" in o ? !t.__esModule : o.writable || o.configurable)) && (o = { enumerable: !0, get: function() {
|
|
@@ -921,9 +927,9 @@ var _e = Object.create ? function(e, t, n, r) {
|
|
|
921
927
|
r === void 0 && (r = n), e[r] = t[n];
|
|
922
928
|
};
|
|
923
929
|
function Rt(e, t) {
|
|
924
|
-
for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) &&
|
|
930
|
+
for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) && ye(t, e, n);
|
|
925
931
|
}
|
|
926
|
-
function
|
|
932
|
+
function he(e) {
|
|
927
933
|
var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
|
|
928
934
|
if (n) return n.call(e);
|
|
929
935
|
if (e && typeof e.length == "number") return {
|
|
@@ -933,7 +939,7 @@ function pe(e) {
|
|
|
933
939
|
};
|
|
934
940
|
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
935
941
|
}
|
|
936
|
-
function
|
|
942
|
+
function Ne(e, t) {
|
|
937
943
|
var n = typeof Symbol == "function" && e[Symbol.iterator];
|
|
938
944
|
if (!n) return e;
|
|
939
945
|
var r = n.call(e), o, s = [], i;
|
|
@@ -952,7 +958,7 @@ function Me(e, t) {
|
|
|
952
958
|
}
|
|
953
959
|
function Tt() {
|
|
954
960
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
955
|
-
e = e.concat(
|
|
961
|
+
e = e.concat(Ne(arguments[t]));
|
|
956
962
|
return e;
|
|
957
963
|
}
|
|
958
964
|
function Ct() {
|
|
@@ -976,39 +982,39 @@ function At(e, t, n) {
|
|
|
976
982
|
return o = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), d("next"), d("throw"), d("return", i), o[Symbol.asyncIterator] = function() {
|
|
977
983
|
return this;
|
|
978
984
|
}, o;
|
|
979
|
-
function i(
|
|
985
|
+
function i(u) {
|
|
980
986
|
return function(y) {
|
|
981
|
-
return Promise.resolve(y).then(
|
|
987
|
+
return Promise.resolve(y).then(u, c);
|
|
982
988
|
};
|
|
983
989
|
}
|
|
984
|
-
function d(
|
|
985
|
-
r[
|
|
990
|
+
function d(u, y) {
|
|
991
|
+
r[u] && (o[u] = function(_) {
|
|
986
992
|
return new Promise(function(T, p) {
|
|
987
|
-
s.push([
|
|
993
|
+
s.push([u, _, T, p]) > 1 || h(u, _);
|
|
988
994
|
});
|
|
989
|
-
}, y && (o[
|
|
995
|
+
}, y && (o[u] = y(o[u])));
|
|
990
996
|
}
|
|
991
|
-
function h(
|
|
997
|
+
function h(u, y) {
|
|
992
998
|
try {
|
|
993
|
-
f(r[
|
|
999
|
+
f(r[u](y));
|
|
994
1000
|
} catch (_) {
|
|
995
1001
|
l(s[0][3], _);
|
|
996
1002
|
}
|
|
997
1003
|
}
|
|
998
|
-
function f(
|
|
999
|
-
|
|
1004
|
+
function f(u) {
|
|
1005
|
+
u.value instanceof ee ? Promise.resolve(u.value.v).then(a, c) : l(s[0][2], u);
|
|
1000
1006
|
}
|
|
1001
|
-
function a(
|
|
1002
|
-
h("next",
|
|
1007
|
+
function a(u) {
|
|
1008
|
+
h("next", u);
|
|
1003
1009
|
}
|
|
1004
|
-
function u
|
|
1005
|
-
h("throw",
|
|
1010
|
+
function c(u) {
|
|
1011
|
+
h("throw", u);
|
|
1006
1012
|
}
|
|
1007
|
-
function l(
|
|
1008
|
-
|
|
1013
|
+
function l(u, y) {
|
|
1014
|
+
u(y), s.shift(), s.length && h(s[0][0], s[0][1]);
|
|
1009
1015
|
}
|
|
1010
1016
|
}
|
|
1011
|
-
function
|
|
1017
|
+
function jt(e) {
|
|
1012
1018
|
var t, n;
|
|
1013
1019
|
return t = {}, r("next"), r("throw", function(o) {
|
|
1014
1020
|
throw o;
|
|
@@ -1021,10 +1027,10 @@ function xt(e) {
|
|
|
1021
1027
|
} : s;
|
|
1022
1028
|
}
|
|
1023
1029
|
}
|
|
1024
|
-
function
|
|
1030
|
+
function xt(e) {
|
|
1025
1031
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1026
1032
|
var t = e[Symbol.asyncIterator], n;
|
|
1027
|
-
return t ? t.call(e) : (e = typeof
|
|
1033
|
+
return t ? t.call(e) : (e = typeof he == "function" ? he(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
|
|
1028
1034
|
return this;
|
|
1029
1035
|
}, n);
|
|
1030
1036
|
function r(s) {
|
|
@@ -1051,7 +1057,7 @@ var Bn = Object.create ? function(e, t) {
|
|
|
1051
1057
|
function Lt(e) {
|
|
1052
1058
|
if (e && e.__esModule) return e;
|
|
1053
1059
|
var t = {};
|
|
1054
|
-
if (e != null) for (var n in e) n !== "default" && Object.prototype.hasOwnProperty.call(e, n) &&
|
|
1060
|
+
if (e != null) for (var n in e) n !== "default" && Object.prototype.hasOwnProperty.call(e, n) && ye(t, e, n);
|
|
1055
1061
|
return Bn(t, e), t;
|
|
1056
1062
|
}
|
|
1057
1063
|
function It(e) {
|
|
@@ -1068,11 +1074,11 @@ function Ft(e, t, n, r, o) {
|
|
|
1068
1074
|
if (typeof t == "function" ? e !== t || !o : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1069
1075
|
return r === "a" ? o.call(e, n) : o ? o.value = n : t.set(e, n), n;
|
|
1070
1076
|
}
|
|
1071
|
-
function
|
|
1077
|
+
function Mt(e, t) {
|
|
1072
1078
|
if (t === null || typeof t != "object" && typeof t != "function") throw new TypeError("Cannot use 'in' operator on non-object");
|
|
1073
1079
|
return typeof e == "function" ? t === e : e.has(t);
|
|
1074
1080
|
}
|
|
1075
|
-
function
|
|
1081
|
+
function Nt(e, t, n) {
|
|
1076
1082
|
if (t != null) {
|
|
1077
1083
|
if (typeof t != "object" && typeof t != "function") throw new TypeError("Object expected.");
|
|
1078
1084
|
var r, o;
|
|
@@ -1129,7 +1135,7 @@ function Wt(e, t) {
|
|
|
1129
1135
|
}
|
|
1130
1136
|
const Gn = {
|
|
1131
1137
|
__extends: ht,
|
|
1132
|
-
__assign:
|
|
1138
|
+
__assign: pe,
|
|
1133
1139
|
__rest: _t,
|
|
1134
1140
|
__decorate: yt,
|
|
1135
1141
|
__param: gt,
|
|
@@ -1140,41 +1146,41 @@ const Gn = {
|
|
|
1140
1146
|
__metadata: mt,
|
|
1141
1147
|
__awaiter: bt,
|
|
1142
1148
|
__generator: Ot,
|
|
1143
|
-
__createBinding:
|
|
1149
|
+
__createBinding: ye,
|
|
1144
1150
|
__exportStar: Rt,
|
|
1145
|
-
__values:
|
|
1146
|
-
__read:
|
|
1151
|
+
__values: he,
|
|
1152
|
+
__read: Ne,
|
|
1147
1153
|
__spread: Tt,
|
|
1148
1154
|
__spreadArrays: Ct,
|
|
1149
1155
|
__spreadArray: Dt,
|
|
1150
1156
|
__await: ee,
|
|
1151
1157
|
__asyncGenerator: At,
|
|
1152
|
-
__asyncDelegator:
|
|
1153
|
-
__asyncValues:
|
|
1158
|
+
__asyncDelegator: jt,
|
|
1159
|
+
__asyncValues: xt,
|
|
1154
1160
|
__makeTemplateObject: Pt,
|
|
1155
1161
|
__importStar: Lt,
|
|
1156
1162
|
__importDefault: It,
|
|
1157
1163
|
__classPrivateFieldGet: Vt,
|
|
1158
1164
|
__classPrivateFieldSet: Ft,
|
|
1159
|
-
__classPrivateFieldIn:
|
|
1160
|
-
__addDisposableResource:
|
|
1165
|
+
__classPrivateFieldIn: Mt,
|
|
1166
|
+
__addDisposableResource: Nt,
|
|
1161
1167
|
__disposeResources: Ut,
|
|
1162
1168
|
__rewriteRelativeImportExtension: Wt
|
|
1163
1169
|
}, $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1164
1170
|
__proto__: null,
|
|
1165
|
-
__addDisposableResource:
|
|
1171
|
+
__addDisposableResource: Nt,
|
|
1166
1172
|
get __assign() {
|
|
1167
|
-
return
|
|
1173
|
+
return pe;
|
|
1168
1174
|
},
|
|
1169
|
-
__asyncDelegator:
|
|
1175
|
+
__asyncDelegator: jt,
|
|
1170
1176
|
__asyncGenerator: At,
|
|
1171
|
-
__asyncValues:
|
|
1177
|
+
__asyncValues: xt,
|
|
1172
1178
|
__await: ee,
|
|
1173
1179
|
__awaiter: bt,
|
|
1174
1180
|
__classPrivateFieldGet: Vt,
|
|
1175
|
-
__classPrivateFieldIn:
|
|
1181
|
+
__classPrivateFieldIn: Mt,
|
|
1176
1182
|
__classPrivateFieldSet: Ft,
|
|
1177
|
-
__createBinding:
|
|
1183
|
+
__createBinding: ye,
|
|
1178
1184
|
__decorate: yt,
|
|
1179
1185
|
__disposeResources: Ut,
|
|
1180
1186
|
__esDecorate: Et,
|
|
@@ -1187,7 +1193,7 @@ const Gn = {
|
|
|
1187
1193
|
__metadata: mt,
|
|
1188
1194
|
__param: gt,
|
|
1189
1195
|
__propKey: wt,
|
|
1190
|
-
__read:
|
|
1196
|
+
__read: Ne,
|
|
1191
1197
|
__rest: _t,
|
|
1192
1198
|
__rewriteRelativeImportExtension: Wt,
|
|
1193
1199
|
__runInitializers: vt,
|
|
@@ -1195,9 +1201,9 @@ const Gn = {
|
|
|
1195
1201
|
__spread: Tt,
|
|
1196
1202
|
__spreadArray: Dt,
|
|
1197
1203
|
__spreadArrays: Ct,
|
|
1198
|
-
__values:
|
|
1204
|
+
__values: he,
|
|
1199
1205
|
default: Gn
|
|
1200
|
-
}, Symbol.toStringTag, { value: "Module" })), Kn = /* @__PURE__ */
|
|
1206
|
+
}, Symbol.toStringTag, { value: "Module" })), Kn = /* @__PURE__ */ cn($n);
|
|
1201
1207
|
var fe = {}, nt;
|
|
1202
1208
|
function kn() {
|
|
1203
1209
|
if (nt) return fe;
|
|
@@ -1216,59 +1222,59 @@ function kn() {
|
|
|
1216
1222
|
return fe.default = t, fe;
|
|
1217
1223
|
}
|
|
1218
1224
|
Object.defineProperty(pt, "__esModule", { value: !0 });
|
|
1219
|
-
var
|
|
1225
|
+
var Ve = Kn, Ce = k, zn = Ve.__importDefault(kn());
|
|
1220
1226
|
function Yn(e, t, n) {
|
|
1221
1227
|
t === void 0 && (t = []), n === void 0 && (n = { loading: !1 });
|
|
1222
|
-
var r =
|
|
1228
|
+
var r = Ce.useRef(0), o = zn.default(), s = Ce.useState(n), i = s[0], d = s[1], h = Ce.useCallback(function() {
|
|
1223
1229
|
for (var f = [], a = 0; a < arguments.length; a++)
|
|
1224
1230
|
f[a] = arguments[a];
|
|
1225
|
-
var
|
|
1231
|
+
var c = ++r.current;
|
|
1226
1232
|
return i.loading || d(function(l) {
|
|
1227
|
-
return
|
|
1233
|
+
return Ve.__assign(Ve.__assign({}, l), { loading: !0 });
|
|
1228
1234
|
}), e.apply(void 0, f).then(function(l) {
|
|
1229
|
-
return o() &&
|
|
1235
|
+
return o() && c === r.current && d({ value: l, loading: !1 }), l;
|
|
1230
1236
|
}, function(l) {
|
|
1231
|
-
return o() &&
|
|
1237
|
+
return o() && c === r.current && d({ error: l, loading: !1 }), l;
|
|
1232
1238
|
});
|
|
1233
1239
|
}, t);
|
|
1234
1240
|
return [i, h];
|
|
1235
1241
|
}
|
|
1236
|
-
var
|
|
1242
|
+
var cr = pt.default = Yn;
|
|
1237
1243
|
const B = /* @__PURE__ */ new Map();
|
|
1238
|
-
function
|
|
1244
|
+
function ur() {
|
|
1239
1245
|
const [e, t] = Xt([]), { widgetCtx: { api: n } } = te();
|
|
1240
1246
|
function r(a) {
|
|
1241
|
-
const
|
|
1247
|
+
const c = a.map((l) => ({
|
|
1242
1248
|
file: l,
|
|
1243
1249
|
id: en(),
|
|
1244
1250
|
status: "pending",
|
|
1245
1251
|
progress: 0
|
|
1246
1252
|
}));
|
|
1247
|
-
t((l) => [...l, ...
|
|
1253
|
+
t((l) => [...l, ...c]), c.forEach(i);
|
|
1248
1254
|
}
|
|
1249
|
-
function o(a,
|
|
1255
|
+
function o(a, c) {
|
|
1250
1256
|
t(
|
|
1251
|
-
(l) => l.map((
|
|
1257
|
+
(l) => l.map((u) => u.id === a ? { ...u, ...c } : u)
|
|
1252
1258
|
);
|
|
1253
1259
|
}
|
|
1254
1260
|
function s(a) {
|
|
1255
|
-
t((
|
|
1261
|
+
t((c) => c.filter((l) => l.id !== a));
|
|
1256
1262
|
}
|
|
1257
1263
|
const i = async (a) => {
|
|
1258
|
-
const
|
|
1259
|
-
B.set(a.id,
|
|
1264
|
+
const c = new AbortController();
|
|
1265
|
+
B.set(a.id, c);
|
|
1260
1266
|
try {
|
|
1261
1267
|
t(
|
|
1262
|
-
(
|
|
1268
|
+
(u) => u.map(
|
|
1263
1269
|
(y) => y.id === a.id ? { ...y, status: "uploading", progress: 0 } : y
|
|
1264
1270
|
)
|
|
1265
1271
|
);
|
|
1266
1272
|
const l = await n.uploadFile(a, {
|
|
1267
|
-
signal:
|
|
1268
|
-
onUploadProgress: (
|
|
1269
|
-
if (!
|
|
1273
|
+
signal: c.signal,
|
|
1274
|
+
onUploadProgress: (u) => {
|
|
1275
|
+
if (!u.total) return;
|
|
1270
1276
|
const y = Math.round(
|
|
1271
|
-
|
|
1277
|
+
u.loaded * 100 / u.total
|
|
1272
1278
|
);
|
|
1273
1279
|
o(a.id, { progress: y });
|
|
1274
1280
|
}
|
|
@@ -1279,7 +1285,7 @@ function cr() {
|
|
|
1279
1285
|
progress: 100
|
|
1280
1286
|
});
|
|
1281
1287
|
} catch (l) {
|
|
1282
|
-
|
|
1288
|
+
c.signal.aborted || o(a.id, {
|
|
1283
1289
|
status: "error",
|
|
1284
1290
|
error: l instanceof Error ? l.message : "Upload failed",
|
|
1285
1291
|
progress: 0
|
|
@@ -1288,8 +1294,8 @@ function cr() {
|
|
|
1288
1294
|
B.delete(a.id);
|
|
1289
1295
|
}
|
|
1290
1296
|
}, d = (a) => {
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1297
|
+
const c = B.get(a);
|
|
1298
|
+
c && (c.abort(), B.delete(a)), s(a);
|
|
1293
1299
|
}, h = le(() => e.filter((a) => a.status === "success" && a.fileUrl), [e]);
|
|
1294
1300
|
function f() {
|
|
1295
1301
|
B.forEach((a) => a.abort()), B.clear(), t([]);
|
|
@@ -1302,14 +1308,14 @@ function cr() {
|
|
|
1302
1308
|
handleCancelUpload: d,
|
|
1303
1309
|
successFiles: h,
|
|
1304
1310
|
emptyTheFiles: f,
|
|
1305
|
-
getFileById: (a) => e.find((
|
|
1311
|
+
getFileById: (a) => e.find((c) => c.id === a),
|
|
1306
1312
|
getUploadProgress: (a) => {
|
|
1307
|
-
var
|
|
1308
|
-
return ((
|
|
1313
|
+
var c;
|
|
1314
|
+
return ((c = e.find((l) => l.id === a)) == null ? void 0 : c.progress) ?? 0;
|
|
1309
1315
|
},
|
|
1310
1316
|
getUploadStatus: (a) => {
|
|
1311
|
-
var
|
|
1312
|
-
return (
|
|
1317
|
+
var c;
|
|
1318
|
+
return (c = e.find((l) => l.id === a)) == null ? void 0 : c.status;
|
|
1313
1319
|
},
|
|
1314
1320
|
hasErrors: e.some((a) => a.status === "error"),
|
|
1315
1321
|
isUploading: e.some((a) => a.status === "uploading")
|
|
@@ -1317,20 +1323,20 @@ function cr() {
|
|
|
1317
1323
|
}
|
|
1318
1324
|
export {
|
|
1319
1325
|
tr as W,
|
|
1320
|
-
|
|
1326
|
+
cr as _,
|
|
1321
1327
|
nr as a,
|
|
1322
1328
|
rr as b,
|
|
1323
1329
|
or as c,
|
|
1324
1330
|
sn as d,
|
|
1325
1331
|
ar as e,
|
|
1326
|
-
|
|
1332
|
+
de as f,
|
|
1327
1333
|
an as g,
|
|
1328
|
-
|
|
1329
|
-
|
|
1334
|
+
ur as h,
|
|
1335
|
+
pe as i,
|
|
1330
1336
|
_t as j,
|
|
1331
1337
|
Dt as k,
|
|
1332
1338
|
sr as l,
|
|
1333
1339
|
ir as m,
|
|
1334
1340
|
te as u
|
|
1335
1341
|
};
|
|
1336
|
-
//# sourceMappingURL=useUploadFiles-
|
|
1342
|
+
//# sourceMappingURL=useUploadFiles-ClUXwfKK.js.map
|