@graffiticode/l0000-view 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +363 -339
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
var
|
|
1
|
+
import { jsx as F, jsxs as Lt } from "react/jsx-runtime";
|
|
2
|
+
import ct, { createContext as ve, useEffect as at, useLayoutEffect as ye, useContext as Oe, useMemo as oe, useRef as q, useCallback as Et, useDebugValue as we, useState as J } from "react";
|
|
3
|
+
var bt = { exports: {} }, vt = {};
|
|
4
4
|
/**
|
|
5
5
|
* @license React
|
|
6
6
|
* use-sync-external-store-shim.production.js
|
|
@@ -11,47 +11,47 @@ var Ct = { exports: {} }, vt = {};
|
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
13
|
var Bt;
|
|
14
|
-
function
|
|
14
|
+
function _e() {
|
|
15
15
|
if (Bt) return vt;
|
|
16
16
|
Bt = 1;
|
|
17
|
-
var t =
|
|
18
|
-
function e(i,
|
|
19
|
-
return i ===
|
|
17
|
+
var t = ct;
|
|
18
|
+
function e(i, l) {
|
|
19
|
+
return i === l && (i !== 0 || 1 / i === 1 / l) || i !== i && l !== l;
|
|
20
20
|
}
|
|
21
|
-
var n = typeof Object.is == "function" ? Object.is : e, r = t.useState, o = t.useEffect,
|
|
22
|
-
function d(i,
|
|
23
|
-
var c =
|
|
24
|
-
return
|
|
21
|
+
var n = typeof Object.is == "function" ? Object.is : e, r = t.useState, o = t.useEffect, u = t.useLayoutEffect, a = t.useDebugValue;
|
|
22
|
+
function d(i, l) {
|
|
23
|
+
var c = l(), p = r({ inst: { value: c, getSnapshot: l } }), g = p[0].inst, h = p[1];
|
|
24
|
+
return u(
|
|
25
25
|
function() {
|
|
26
|
-
|
|
26
|
+
g.value = c, g.getSnapshot = l, m(g) && h({ inst: g });
|
|
27
27
|
},
|
|
28
|
-
[i, c,
|
|
28
|
+
[i, c, l]
|
|
29
29
|
), o(
|
|
30
30
|
function() {
|
|
31
|
-
return m(
|
|
32
|
-
m(
|
|
31
|
+
return m(g) && h({ inst: g }), i(function() {
|
|
32
|
+
m(g) && h({ inst: g });
|
|
33
33
|
});
|
|
34
34
|
},
|
|
35
35
|
[i]
|
|
36
36
|
), a(c), c;
|
|
37
37
|
}
|
|
38
38
|
function m(i) {
|
|
39
|
-
var
|
|
39
|
+
var l = i.getSnapshot;
|
|
40
40
|
i = i.value;
|
|
41
41
|
try {
|
|
42
|
-
var c =
|
|
42
|
+
var c = l();
|
|
43
43
|
return !n(i, c);
|
|
44
44
|
} catch {
|
|
45
45
|
return !0;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function R(i,
|
|
49
|
-
return
|
|
48
|
+
function R(i, l) {
|
|
49
|
+
return l();
|
|
50
50
|
}
|
|
51
|
-
var
|
|
52
|
-
return vt.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore :
|
|
51
|
+
var E = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? R : d;
|
|
52
|
+
return vt.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : E, vt;
|
|
53
53
|
}
|
|
54
|
-
var
|
|
54
|
+
var yt = {};
|
|
55
55
|
/**
|
|
56
56
|
* @license React
|
|
57
57
|
* use-sync-external-store-shim.development.js
|
|
@@ -61,32 +61,32 @@ var Ot = {};
|
|
|
61
61
|
* This source code is licensed under the MIT license found in the
|
|
62
62
|
* LICENSE file in the root directory of this source tree.
|
|
63
63
|
*/
|
|
64
|
-
var
|
|
65
|
-
function
|
|
66
|
-
return
|
|
67
|
-
function t(c,
|
|
68
|
-
return c ===
|
|
64
|
+
var Jt;
|
|
65
|
+
function Re() {
|
|
66
|
+
return Jt || (Jt = 1, process.env.NODE_ENV !== "production" && function() {
|
|
67
|
+
function t(c, p) {
|
|
68
|
+
return c === p && (c !== 0 || 1 / c === 1 / p) || c !== c && p !== p;
|
|
69
69
|
}
|
|
70
|
-
function e(c,
|
|
71
|
-
|
|
70
|
+
function e(c, p) {
|
|
71
|
+
E || o.startTransition === void 0 || (E = !0, console.error(
|
|
72
72
|
"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."
|
|
73
73
|
));
|
|
74
|
-
var
|
|
74
|
+
var g = p();
|
|
75
75
|
if (!i) {
|
|
76
|
-
var
|
|
77
|
-
|
|
76
|
+
var h = p();
|
|
77
|
+
u(g, h) || (console.error(
|
|
78
78
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
79
79
|
), i = !0);
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
inst: { value:
|
|
81
|
+
h = a({
|
|
82
|
+
inst: { value: g, getSnapshot: p }
|
|
83
83
|
});
|
|
84
|
-
var D =
|
|
84
|
+
var D = h[0].inst, s = h[1];
|
|
85
85
|
return m(
|
|
86
86
|
function() {
|
|
87
|
-
D.value =
|
|
87
|
+
D.value = g, D.getSnapshot = p, n(D) && s({ inst: D });
|
|
88
88
|
},
|
|
89
|
-
[c,
|
|
89
|
+
[c, g, p]
|
|
90
90
|
), d(
|
|
91
91
|
function() {
|
|
92
92
|
return n(D) && s({ inst: D }), c(function() {
|
|
@@ -94,31 +94,31 @@ function _e() {
|
|
|
94
94
|
});
|
|
95
95
|
},
|
|
96
96
|
[c]
|
|
97
|
-
), R(
|
|
97
|
+
), R(g), g;
|
|
98
98
|
}
|
|
99
99
|
function n(c) {
|
|
100
|
-
var
|
|
100
|
+
var p = c.getSnapshot;
|
|
101
101
|
c = c.value;
|
|
102
102
|
try {
|
|
103
|
-
var
|
|
104
|
-
return !
|
|
103
|
+
var g = p();
|
|
104
|
+
return !u(c, g);
|
|
105
105
|
} catch {
|
|
106
106
|
return !0;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function r(c,
|
|
110
|
-
return
|
|
109
|
+
function r(c, p) {
|
|
110
|
+
return p();
|
|
111
111
|
}
|
|
112
112
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
113
|
-
var o =
|
|
114
|
-
|
|
115
|
-
}()),
|
|
113
|
+
var o = ct, u = typeof Object.is == "function" ? Object.is : t, a = o.useState, d = o.useEffect, m = o.useLayoutEffect, R = o.useDebugValue, E = !1, i = !1, l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
|
|
114
|
+
yt.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : l, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
115
|
+
}()), yt;
|
|
116
116
|
}
|
|
117
|
-
process.env.NODE_ENV === "production" ?
|
|
118
|
-
var
|
|
119
|
-
const
|
|
117
|
+
process.env.NODE_ENV === "production" ? bt.exports = _e() : bt.exports = Re();
|
|
118
|
+
var Kt = bt.exports;
|
|
119
|
+
const se = 0, ie = 1, ae = 2, zt = 3;
|
|
120
120
|
var Yt = Object.prototype.hasOwnProperty;
|
|
121
|
-
function
|
|
121
|
+
function Ct(t, e) {
|
|
122
122
|
var n, r;
|
|
123
123
|
if (t === e) return !0;
|
|
124
124
|
if (t && e && (n = t.constructor) === e.constructor) {
|
|
@@ -126,184 +126,184 @@ function At(t, e) {
|
|
|
126
126
|
if (n === RegExp) return t.toString() === e.toString();
|
|
127
127
|
if (n === Array) {
|
|
128
128
|
if ((r = t.length) === e.length)
|
|
129
|
-
for (; r-- &&
|
|
129
|
+
for (; r-- && Ct(t[r], e[r]); ) ;
|
|
130
130
|
return r === -1;
|
|
131
131
|
}
|
|
132
132
|
if (!n || typeof t == "object") {
|
|
133
133
|
r = 0;
|
|
134
134
|
for (n in t)
|
|
135
|
-
if (Yt.call(t, n) && ++r && !Yt.call(e, n) || !(n in e) || !
|
|
135
|
+
if (Yt.call(t, n) && ++r && !Yt.call(e, n) || !(n in e) || !Ct(t[n], e[n])) return !1;
|
|
136
136
|
return Object.keys(e).length === r;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
return t !== t && e !== e;
|
|
140
140
|
}
|
|
141
|
-
const U = /* @__PURE__ */ new WeakMap(),
|
|
142
|
-
},
|
|
141
|
+
const U = /* @__PURE__ */ new WeakMap(), P = () => {
|
|
142
|
+
}, L = (
|
|
143
143
|
/*#__NOINLINE__*/
|
|
144
|
-
|
|
145
|
-
),
|
|
144
|
+
P()
|
|
145
|
+
), At = Object, f = (t) => t === L, M = (t) => typeof t == "function", H = (t, e) => ({
|
|
146
146
|
...t,
|
|
147
147
|
...e
|
|
148
|
-
}),
|
|
148
|
+
}), ce = (t) => M(t.then), Ot = {}, dt = {}, Wt = "undefined", ut = typeof window != Wt, xt = typeof document != Wt, De = ut && "Deno" in window, Te = () => ut && typeof window.requestAnimationFrame != Wt, ue = (t, e) => {
|
|
149
149
|
const n = U.get(t);
|
|
150
150
|
return [
|
|
151
151
|
// Getter
|
|
152
|
-
() => !f(e) && t.get(e) ||
|
|
152
|
+
() => !f(e) && t.get(e) || Ot,
|
|
153
153
|
// Setter
|
|
154
154
|
(r) => {
|
|
155
155
|
if (!f(e)) {
|
|
156
156
|
const o = t.get(e);
|
|
157
|
-
e in dt || (dt[e] = o), n[5](e,
|
|
157
|
+
e in dt || (dt[e] = o), n[5](e, H(o, r), o || Ot);
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
160
|
// Subscriber
|
|
161
161
|
n[6],
|
|
162
162
|
// Get server cache snapshot
|
|
163
|
-
() => !f(e) && e in dt ? dt[e] : !f(e) && t.get(e) ||
|
|
163
|
+
() => !f(e) && e in dt ? dt[e] : !f(e) && t.get(e) || Ot
|
|
164
164
|
];
|
|
165
165
|
};
|
|
166
|
-
let
|
|
167
|
-
const
|
|
166
|
+
let It = !0;
|
|
167
|
+
const Le = () => It, [Nt, Vt] = ut && window.addEventListener ? [
|
|
168
168
|
window.addEventListener.bind(window),
|
|
169
169
|
window.removeEventListener.bind(window)
|
|
170
170
|
] : [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
],
|
|
174
|
-
const t =
|
|
171
|
+
P,
|
|
172
|
+
P
|
|
173
|
+
], be = () => {
|
|
174
|
+
const t = xt && document.visibilityState;
|
|
175
175
|
return f(t) || t !== "hidden";
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
}),
|
|
176
|
+
}, Ce = (t) => (xt && document.addEventListener("visibilitychange", t), Nt("focus", t), () => {
|
|
177
|
+
xt && document.removeEventListener("visibilitychange", t), Vt("focus", t);
|
|
178
|
+
}), Ae = (t) => {
|
|
179
179
|
const e = () => {
|
|
180
|
-
|
|
180
|
+
It = !0, t();
|
|
181
181
|
}, n = () => {
|
|
182
|
-
|
|
182
|
+
It = !1;
|
|
183
183
|
};
|
|
184
|
-
return
|
|
185
|
-
|
|
184
|
+
return Nt("online", e), Nt("offline", n), () => {
|
|
185
|
+
Vt("online", e), Vt("offline", n);
|
|
186
186
|
};
|
|
187
|
-
}, be = {
|
|
188
|
-
isOnline: Te,
|
|
189
|
-
isVisible: Ce
|
|
190
187
|
}, xe = {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
},
|
|
188
|
+
isOnline: Le,
|
|
189
|
+
isVisible: be
|
|
190
|
+
}, Ie = {
|
|
191
|
+
initFocus: Ce,
|
|
192
|
+
initReconnect: Ae
|
|
193
|
+
}, Xt = !ct.useId, nt = !ut || De, Ne = (t) => Te() ? window.requestAnimationFrame(t) : setTimeout(t, 1), wt = nt ? at : ye, _t = typeof navigator < "u" && navigator.connection, Qt = !nt && _t && ([
|
|
194
194
|
"slow-2g",
|
|
195
195
|
"2g"
|
|
196
|
-
].includes(_t.effectiveType) || _t.saveData), pt = /* @__PURE__ */ new WeakMap(),
|
|
197
|
-
let
|
|
198
|
-
const
|
|
199
|
-
const e = typeof t, n =
|
|
196
|
+
].includes(_t.effectiveType) || _t.saveData), pt = /* @__PURE__ */ new WeakMap(), Ve = (t) => At.prototype.toString.call(t), Rt = (t, e) => t === `[object ${e}]`;
|
|
197
|
+
let je = 0;
|
|
198
|
+
const jt = (t) => {
|
|
199
|
+
const e = typeof t, n = Ve(t), r = Rt(n, "Date"), o = Rt(n, "RegExp"), u = Rt(n, "Object");
|
|
200
200
|
let a, d;
|
|
201
|
-
if (
|
|
201
|
+
if (At(t) === t && !r && !o) {
|
|
202
202
|
if (a = pt.get(t), a) return a;
|
|
203
|
-
if (a = ++
|
|
203
|
+
if (a = ++je + "~", pt.set(t, a), Array.isArray(t)) {
|
|
204
204
|
for (a = "@", d = 0; d < t.length; d++)
|
|
205
|
-
a +=
|
|
205
|
+
a += jt(t[d]) + ",";
|
|
206
206
|
pt.set(t, a);
|
|
207
207
|
}
|
|
208
|
-
if (
|
|
208
|
+
if (u) {
|
|
209
209
|
a = "#";
|
|
210
|
-
const m =
|
|
210
|
+
const m = At.keys(t).sort();
|
|
211
211
|
for (; !f(d = m.pop()); )
|
|
212
|
-
f(t[d]) || (a += d + ":" +
|
|
212
|
+
f(t[d]) || (a += d + ":" + jt(t[d]) + ",");
|
|
213
213
|
pt.set(t, a);
|
|
214
214
|
}
|
|
215
215
|
} else
|
|
216
216
|
a = r ? t.toJSON() : e == "symbol" ? t.toString() : e == "string" ? JSON.stringify(t) : "" + t;
|
|
217
217
|
return a;
|
|
218
|
-
},
|
|
219
|
-
if (
|
|
218
|
+
}, Ft = (t) => {
|
|
219
|
+
if (M(t))
|
|
220
220
|
try {
|
|
221
221
|
t = t();
|
|
222
222
|
} catch {
|
|
223
223
|
t = "";
|
|
224
224
|
}
|
|
225
225
|
const e = t;
|
|
226
|
-
return t = typeof t == "string" ? t : (Array.isArray(t) ? t.length : t) ?
|
|
226
|
+
return t = typeof t == "string" ? t : (Array.isArray(t) ? t.length : t) ? jt(t) : "", [
|
|
227
227
|
t,
|
|
228
228
|
e
|
|
229
229
|
];
|
|
230
230
|
};
|
|
231
|
-
let
|
|
232
|
-
const
|
|
233
|
-
async function
|
|
234
|
-
const [e, n, r, o] = t,
|
|
231
|
+
let Me = 0;
|
|
232
|
+
const Mt = () => ++Me;
|
|
233
|
+
async function le(...t) {
|
|
234
|
+
const [e, n, r, o] = t, u = H({
|
|
235
235
|
populateCache: !0,
|
|
236
236
|
throwOnError: !0
|
|
237
237
|
}, typeof o == "boolean" ? {
|
|
238
238
|
revalidate: o
|
|
239
239
|
} : o || {});
|
|
240
|
-
let a =
|
|
241
|
-
const d =
|
|
242
|
-
let m =
|
|
243
|
-
const R = (
|
|
244
|
-
if (
|
|
245
|
-
const
|
|
246
|
-
for (const
|
|
240
|
+
let a = u.populateCache;
|
|
241
|
+
const d = u.rollbackOnError;
|
|
242
|
+
let m = u.optimisticData;
|
|
243
|
+
const R = (l) => typeof d == "function" ? d(l) : d !== !1, E = u.throwOnError;
|
|
244
|
+
if (M(n)) {
|
|
245
|
+
const l = n, c = [], p = e.keys();
|
|
246
|
+
for (const g of p)
|
|
247
247
|
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
248
|
-
!/^\$(inf|sub)\$/.test(
|
|
248
|
+
!/^\$(inf|sub)\$/.test(g) && l(e.get(g)._k) && c.push(g);
|
|
249
249
|
return Promise.all(c.map(i));
|
|
250
250
|
}
|
|
251
251
|
return i(n);
|
|
252
|
-
async function i(
|
|
253
|
-
const [c] =
|
|
252
|
+
async function i(l) {
|
|
253
|
+
const [c] = Ft(l);
|
|
254
254
|
if (!c) return;
|
|
255
|
-
const [
|
|
256
|
-
const
|
|
257
|
-
return (
|
|
255
|
+
const [p, g] = ue(e, c), [h, D, s, $] = U.get(e), K = () => {
|
|
256
|
+
const A = h[c];
|
|
257
|
+
return (M(u.revalidate) ? u.revalidate(p().data, l) : u.revalidate !== !1) && (delete s[c], delete $[c], A && A[0]) ? A[0](ae).then(() => p().data) : p().data;
|
|
258
258
|
};
|
|
259
259
|
if (t.length < 3)
|
|
260
|
-
return
|
|
260
|
+
return K();
|
|
261
261
|
let T = r, I, N = !1;
|
|
262
|
-
const
|
|
262
|
+
const z = Mt();
|
|
263
263
|
D[c] = [
|
|
264
|
-
|
|
264
|
+
z,
|
|
265
265
|
0
|
|
266
266
|
];
|
|
267
|
-
const v = !f(m),
|
|
268
|
-
if (v && (m =
|
|
267
|
+
const v = !f(m), Y = p(), V = Y.data, X = Y._c, k = f(X) ? V : X;
|
|
268
|
+
if (v && (m = M(m) ? m(k, V) : m, g({
|
|
269
269
|
data: m,
|
|
270
|
-
_c:
|
|
271
|
-
})),
|
|
270
|
+
_c: k
|
|
271
|
+
})), M(T))
|
|
272
272
|
try {
|
|
273
|
-
T = T(
|
|
274
|
-
} catch (
|
|
275
|
-
I =
|
|
273
|
+
T = T(k);
|
|
274
|
+
} catch (A) {
|
|
275
|
+
I = A, N = !0;
|
|
276
276
|
}
|
|
277
|
-
if (T &&
|
|
278
|
-
if (T = await T.catch((
|
|
279
|
-
I =
|
|
280
|
-
}),
|
|
277
|
+
if (T && ce(T))
|
|
278
|
+
if (T = await T.catch((A) => {
|
|
279
|
+
I = A, N = !0;
|
|
280
|
+
}), z !== D[c][0]) {
|
|
281
281
|
if (N) throw I;
|
|
282
282
|
return T;
|
|
283
|
-
} else N && v && R(I) && (a = !0,
|
|
284
|
-
data:
|
|
285
|
-
_c:
|
|
283
|
+
} else N && v && R(I) && (a = !0, g({
|
|
284
|
+
data: k,
|
|
285
|
+
_c: L
|
|
286
286
|
}));
|
|
287
287
|
if (a && !N)
|
|
288
|
-
if (
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
data:
|
|
292
|
-
error:
|
|
293
|
-
_c:
|
|
288
|
+
if (M(a)) {
|
|
289
|
+
const A = a(T, k);
|
|
290
|
+
g({
|
|
291
|
+
data: A,
|
|
292
|
+
error: L,
|
|
293
|
+
_c: L
|
|
294
294
|
});
|
|
295
295
|
} else
|
|
296
|
-
|
|
296
|
+
g({
|
|
297
297
|
data: T,
|
|
298
|
-
error:
|
|
299
|
-
_c:
|
|
298
|
+
error: L,
|
|
299
|
+
_c: L
|
|
300
300
|
});
|
|
301
|
-
if (D[c][1] =
|
|
302
|
-
|
|
303
|
-
_c:
|
|
301
|
+
if (D[c][1] = Mt(), Promise.resolve(K()).then(() => {
|
|
302
|
+
g({
|
|
303
|
+
_c: L
|
|
304
304
|
});
|
|
305
305
|
}), N) {
|
|
306
|
-
if (
|
|
306
|
+
if (E) throw I;
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
309
|
return T;
|
|
@@ -312,19 +312,19 @@ async function ue(...t) {
|
|
|
312
312
|
const Zt = (t, e) => {
|
|
313
313
|
for (const n in t)
|
|
314
314
|
t[n][0] && t[n][0](e);
|
|
315
|
-
},
|
|
315
|
+
}, We = (t, e) => {
|
|
316
316
|
if (!U.has(t)) {
|
|
317
|
-
const n =
|
|
318
|
-
let
|
|
319
|
-
const a = /* @__PURE__ */ Object.create(null), d = (
|
|
320
|
-
const
|
|
321
|
-
return a[
|
|
322
|
-
}, m = (
|
|
323
|
-
t.set(
|
|
324
|
-
const c = a[
|
|
317
|
+
const n = H(Ie, e), r = /* @__PURE__ */ Object.create(null), o = le.bind(L, t);
|
|
318
|
+
let u = P;
|
|
319
|
+
const a = /* @__PURE__ */ Object.create(null), d = (E, i) => {
|
|
320
|
+
const l = a[E] || [];
|
|
321
|
+
return a[E] = l, l.push(i), () => l.splice(l.indexOf(i), 1);
|
|
322
|
+
}, m = (E, i, l) => {
|
|
323
|
+
t.set(E, i);
|
|
324
|
+
const c = a[E];
|
|
325
325
|
if (c)
|
|
326
|
-
for (const
|
|
327
|
-
|
|
326
|
+
for (const p of c)
|
|
327
|
+
p(i, l);
|
|
328
328
|
}, R = () => {
|
|
329
329
|
if (!U.has(t) && (U.set(t, [
|
|
330
330
|
r,
|
|
@@ -334,10 +334,10 @@ const Zt = (t, e) => {
|
|
|
334
334
|
o,
|
|
335
335
|
m,
|
|
336
336
|
d
|
|
337
|
-
]), !
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
337
|
+
]), !nt)) {
|
|
338
|
+
const E = n.initFocus(setTimeout.bind(L, Zt.bind(L, r, se))), i = n.initReconnect(setTimeout.bind(L, Zt.bind(L, r, ie)));
|
|
339
|
+
u = () => {
|
|
340
|
+
E && E(), i && i(), U.delete(t);
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
};
|
|
@@ -345,24 +345,24 @@ const Zt = (t, e) => {
|
|
|
345
345
|
t,
|
|
346
346
|
o,
|
|
347
347
|
R,
|
|
348
|
-
|
|
348
|
+
u
|
|
349
349
|
];
|
|
350
350
|
}
|
|
351
351
|
return [
|
|
352
352
|
t,
|
|
353
353
|
U.get(t)[4]
|
|
354
354
|
];
|
|
355
|
-
},
|
|
356
|
-
const
|
|
357
|
-
!f(
|
|
358
|
-
}, Ue =
|
|
355
|
+
}, Fe = (t, e, n, r, o) => {
|
|
356
|
+
const u = n.errorRetryCount, a = o.retryCount, d = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * n.errorRetryInterval;
|
|
357
|
+
!f(u) && a > u || setTimeout(r, d, o);
|
|
358
|
+
}, Ue = Ct, [fe, Pe] = We(/* @__PURE__ */ new Map()), $e = H(
|
|
359
359
|
{
|
|
360
360
|
// events
|
|
361
|
-
onLoadingSlow:
|
|
362
|
-
onSuccess:
|
|
363
|
-
onError:
|
|
364
|
-
onErrorRetry:
|
|
365
|
-
onDiscarded:
|
|
361
|
+
onLoadingSlow: P,
|
|
362
|
+
onSuccess: P,
|
|
363
|
+
onError: P,
|
|
364
|
+
onErrorRetry: Fe,
|
|
365
|
+
onDiscarded: P,
|
|
366
366
|
// switches
|
|
367
367
|
revalidateOnFocus: !0,
|
|
368
368
|
revalidateOnReconnect: !0,
|
|
@@ -376,22 +376,22 @@ const Zt = (t, e) => {
|
|
|
376
376
|
// providers
|
|
377
377
|
compare: Ue,
|
|
378
378
|
isPaused: () => !1,
|
|
379
|
-
cache:
|
|
380
|
-
mutate:
|
|
379
|
+
cache: fe,
|
|
380
|
+
mutate: Pe,
|
|
381
381
|
fallback: {}
|
|
382
382
|
},
|
|
383
383
|
// use web preset by default
|
|
384
|
-
|
|
385
|
-
),
|
|
386
|
-
const n =
|
|
384
|
+
xe
|
|
385
|
+
), qe = (t, e) => {
|
|
386
|
+
const n = H(t, e);
|
|
387
387
|
if (e) {
|
|
388
|
-
const { use: r, fallback: o } = t, { use:
|
|
389
|
-
r &&
|
|
388
|
+
const { use: r, fallback: o } = t, { use: u, fallback: a } = e;
|
|
389
|
+
r && u && (n.use = r.concat(u)), o && a && (n.fallback = H(o, a));
|
|
390
390
|
}
|
|
391
391
|
return n;
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
},
|
|
392
|
+
}, He = ve({}), ke = "$inf$", de = ut && window.__SWR_DEVTOOLS_USE__, Ge = de ? window.__SWR_DEVTOOLS_USE__ : [], Be = () => {
|
|
393
|
+
de && (window.__SWR_DEVTOOLS_REACT__ = ct);
|
|
394
|
+
}, Je = (t) => M(t[1]) ? [
|
|
395
395
|
t[0],
|
|
396
396
|
t[1],
|
|
397
397
|
t[2] || {}
|
|
@@ -400,32 +400,32 @@ const Zt = (t, e) => {
|
|
|
400
400
|
null,
|
|
401
401
|
(t[1] === null ? t[2] : t[1]) || {}
|
|
402
402
|
], Ke = () => {
|
|
403
|
-
const t = Oe(
|
|
404
|
-
return
|
|
403
|
+
const t = Oe(He);
|
|
404
|
+
return oe(() => H($e, t), [
|
|
405
405
|
t
|
|
406
406
|
]);
|
|
407
|
-
},
|
|
408
|
-
const [a] =
|
|
409
|
-
if (a.startsWith(
|
|
410
|
-
return n(...
|
|
407
|
+
}, ze = (t) => (e, n, r) => t(e, n && ((...u) => {
|
|
408
|
+
const [a] = Ft(e), [, , , d] = U.get(fe);
|
|
409
|
+
if (a.startsWith(ke))
|
|
410
|
+
return n(...u);
|
|
411
411
|
const m = d[a];
|
|
412
|
-
return f(m) ? n(...
|
|
413
|
-
}), r),
|
|
414
|
-
const r = Ke(), [o,
|
|
412
|
+
return f(m) ? n(...u) : (delete d[a], m);
|
|
413
|
+
}), r), Ye = Ge.concat(ze), Xe = (t) => function(...n) {
|
|
414
|
+
const r = Ke(), [o, u, a] = Je(n), d = qe(r, a);
|
|
415
415
|
let m = t;
|
|
416
|
-
const { use: R } = d,
|
|
417
|
-
for (let i =
|
|
418
|
-
m =
|
|
419
|
-
return m(o,
|
|
420
|
-
},
|
|
416
|
+
const { use: R } = d, E = (R || []).concat(Ye);
|
|
417
|
+
for (let i = E.length; i--; )
|
|
418
|
+
m = E[i](m);
|
|
419
|
+
return m(o, u || d.fetcher || null, d);
|
|
420
|
+
}, Qe = (t, e, n) => {
|
|
421
421
|
const r = e[t] || (e[t] = []);
|
|
422
422
|
return r.push(n), () => {
|
|
423
423
|
const o = r.indexOf(n);
|
|
424
424
|
o >= 0 && (r[o] = r[r.length - 1], r.pop());
|
|
425
425
|
};
|
|
426
426
|
};
|
|
427
|
-
|
|
428
|
-
const Dt =
|
|
427
|
+
Be();
|
|
428
|
+
const Dt = ct.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
|
|
429
429
|
// and emitting an error.
|
|
430
430
|
// We assume that this is only for the `use(thenable)` case, not `use(context)`.
|
|
431
431
|
// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
|
|
@@ -446,104 +446,104 @@ const Dt = at.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
446
446
|
}
|
|
447
447
|
}), Tt = {
|
|
448
448
|
dedupe: !0
|
|
449
|
-
}, te = Promise.resolve(
|
|
450
|
-
const { cache: r, compare: o, suspense:
|
|
451
|
-
for (const
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
454
|
-
if (!o(
|
|
449
|
+
}, te = Promise.resolve(L), Ze = () => P, tn = (t, e, n) => {
|
|
450
|
+
const { cache: r, compare: o, suspense: u, fallbackData: a, revalidateOnMount: d, revalidateIfStale: m, refreshInterval: R, refreshWhenHidden: E, refreshWhenOffline: i, keepPreviousData: l, strictServerPrefetchWarning: c } = n, [p, g, h, D] = U.get(r), [s, $] = Ft(t), K = q(!1), T = q(!1), I = q(s), N = q(e), z = q(n), v = () => z.current, Y = () => v().isVisible() && v().isOnline(), [V, X, k, A] = ue(r, s), Q = q({}).current, Z = f(a) ? f(n.fallback) ? L : n.fallback[s] : a, Ut = (S, y) => {
|
|
451
|
+
for (const O in Q) {
|
|
452
|
+
const w = O;
|
|
453
|
+
if (w === "data") {
|
|
454
|
+
if (!o(S[w], y[w]) && (!f(S[w]) || !o(ft, y[w])))
|
|
455
455
|
return !1;
|
|
456
|
-
} else if (
|
|
456
|
+
} else if (y[w] !== S[w])
|
|
457
457
|
return !1;
|
|
458
458
|
}
|
|
459
459
|
return !0;
|
|
460
|
-
}, ht = !
|
|
461
|
-
const
|
|
462
|
-
const x =
|
|
460
|
+
}, ht = !K.current, Pt = oe(() => {
|
|
461
|
+
const S = V(), y = A(), O = (_) => {
|
|
462
|
+
const x = H(_);
|
|
463
463
|
return delete x._k, (() => {
|
|
464
464
|
if (!s || !e || v().isPaused()) return !1;
|
|
465
465
|
if (ht && !f(d)) return d;
|
|
466
|
-
const
|
|
467
|
-
return f(
|
|
466
|
+
const it = f(Z) ? x.data : Z;
|
|
467
|
+
return f(it) || m;
|
|
468
468
|
})() ? {
|
|
469
469
|
isValidating: !0,
|
|
470
470
|
isLoading: !0,
|
|
471
471
|
...x
|
|
472
472
|
} : x;
|
|
473
|
-
},
|
|
474
|
-
let
|
|
473
|
+
}, w = O(S), j = S === y ? w : O(y);
|
|
474
|
+
let b = w;
|
|
475
475
|
return [
|
|
476
476
|
() => {
|
|
477
|
-
const _ =
|
|
478
|
-
return Ut(_,
|
|
477
|
+
const _ = O(V());
|
|
478
|
+
return Ut(_, b) ? (b.data = _.data, b.isLoading = _.isLoading, b.isValidating = _.isValidating, b.error = _.error, b) : (b = _, _);
|
|
479
479
|
},
|
|
480
480
|
() => j
|
|
481
481
|
];
|
|
482
482
|
}, [
|
|
483
483
|
r,
|
|
484
484
|
s
|
|
485
|
-
]),
|
|
486
|
-
(
|
|
487
|
-
Ut(
|
|
485
|
+
]), tt = Kt.useSyncExternalStore(Et(
|
|
486
|
+
(S) => k(s, (y, O) => {
|
|
487
|
+
Ut(O, y) || S();
|
|
488
488
|
}),
|
|
489
489
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
490
490
|
[
|
|
491
491
|
r,
|
|
492
492
|
s
|
|
493
493
|
]
|
|
494
|
-
),
|
|
495
|
-
!
|
|
494
|
+
), Pt[0], Pt[1]), he = p[s] && p[s].length > 0, et = tt.data, G = f(et) ? Z && ce(Z) ? Dt(Z) : Z : et, lt = tt.error, gt = q(G), ft = l ? f(et) ? f(gt.current) ? G : gt.current : et : G, B = s && f(G), rt = q(null);
|
|
495
|
+
!nt && // getServerSnapshot is only called during hydration
|
|
496
496
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
c &&
|
|
500
|
-
const
|
|
501
|
-
async (
|
|
502
|
-
const
|
|
503
|
-
if (!s || !
|
|
497
|
+
Kt.useSyncExternalStore(Ze, () => (rt.current = !1, rt), () => (rt.current = !0, rt));
|
|
498
|
+
const ge = rt.current;
|
|
499
|
+
c && ge && !u && B && console.warn(`Missing pre-initiated data for serialized key "${s}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);
|
|
500
|
+
const $t = !s || !e || v().isPaused() || he && !f(lt) ? !1 : ht && !f(d) ? d : u ? f(G) ? !1 : m : f(G) || m, qt = ht && $t, me = f(tt.isValidating) ? qt : tt.isValidating, Se = f(tt.isLoading) ? qt : tt.isLoading, ot = Et(
|
|
501
|
+
async (S) => {
|
|
502
|
+
const y = N.current;
|
|
503
|
+
if (!s || !y || T.current || v().isPaused())
|
|
504
504
|
return !1;
|
|
505
|
-
let
|
|
506
|
-
const
|
|
505
|
+
let O, w, j = !0;
|
|
506
|
+
const b = S || {}, _ = !h[s] || !b.dedupe, x = () => Xt ? !T.current && s === I.current && K.current : s === I.current, st = {
|
|
507
507
|
isValidating: !1,
|
|
508
508
|
isLoading: !1
|
|
509
|
-
},
|
|
510
|
-
|
|
511
|
-
},
|
|
512
|
-
const
|
|
513
|
-
|
|
509
|
+
}, it = () => {
|
|
510
|
+
X(st);
|
|
511
|
+
}, kt = () => {
|
|
512
|
+
const C = h[s];
|
|
513
|
+
C && C[1] === w && delete h[s];
|
|
514
514
|
}, Gt = {
|
|
515
515
|
isValidating: !0
|
|
516
516
|
};
|
|
517
517
|
f(V().data) && (Gt.isLoading = !0);
|
|
518
518
|
try {
|
|
519
|
-
if (_ && (
|
|
519
|
+
if (_ && (X(Gt), n.loadingTimeout && f(V().data) && setTimeout(() => {
|
|
520
520
|
j && x() && v().onLoadingSlow(s, n);
|
|
521
|
-
}, n.loadingTimeout),
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
]), [
|
|
521
|
+
}, n.loadingTimeout), h[s] = [
|
|
522
|
+
y($),
|
|
523
|
+
Mt()
|
|
524
|
+
]), [O, w] = h[s], O = await O, _ && setTimeout(kt, n.dedupingInterval), !h[s] || h[s][1] !== w)
|
|
525
525
|
return _ && x() && v().onDiscarded(s), !1;
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
if (!f(
|
|
529
|
-
(
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
return
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
} catch (
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
const St =
|
|
540
|
-
St && St[0] && St[0](zt,
|
|
526
|
+
st.error = L;
|
|
527
|
+
const C = g[s];
|
|
528
|
+
if (!f(C) && // case 1
|
|
529
|
+
(w <= C[0] || // case 2
|
|
530
|
+
w <= C[1] || // case 3
|
|
531
|
+
C[1] === 0))
|
|
532
|
+
return it(), _ && x() && v().onDiscarded(s), !1;
|
|
533
|
+
const W = V().data;
|
|
534
|
+
st.data = o(W, O) ? W : O, _ && x() && v().onSuccess(O, s, n);
|
|
535
|
+
} catch (C) {
|
|
536
|
+
kt();
|
|
537
|
+
const W = v(), { shouldRetryOnError: mt } = W;
|
|
538
|
+
W.isPaused() || (st.error = C, _ && x() && (W.onError(C, s, W), (mt === !0 || M(mt) && mt(C)) && (!v().revalidateOnFocus || !v().revalidateOnReconnect || Y()) && W.onErrorRetry(C, s, W, (Ee) => {
|
|
539
|
+
const St = p[s];
|
|
540
|
+
St && St[0] && St[0](zt, Ee);
|
|
541
541
|
}, {
|
|
542
|
-
retryCount: (
|
|
542
|
+
retryCount: (b.retryCount || 0) + 1,
|
|
543
543
|
dedupe: !0
|
|
544
544
|
})));
|
|
545
545
|
}
|
|
546
|
-
return j = !1,
|
|
546
|
+
return j = !1, it(), !0;
|
|
547
547
|
},
|
|
548
548
|
// `setState` is immutable, and `eventsCallback`, `fnArg`, and
|
|
549
549
|
// `keyValidating` are depending on `key`, so we can exclude them from
|
|
@@ -560,82 +560,82 @@ const Dt = at.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
560
560
|
s,
|
|
561
561
|
r
|
|
562
562
|
]
|
|
563
|
-
),
|
|
563
|
+
), Ht = Et(
|
|
564
564
|
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
565
|
-
(...
|
|
565
|
+
(...S) => le(r, I.current, ...S),
|
|
566
566
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
567
567
|
[]
|
|
568
568
|
);
|
|
569
|
-
if (
|
|
570
|
-
N.current = e,
|
|
571
|
-
}),
|
|
569
|
+
if (wt(() => {
|
|
570
|
+
N.current = e, z.current = n, f(et) || (gt.current = et);
|
|
571
|
+
}), wt(() => {
|
|
572
572
|
if (!s) return;
|
|
573
|
-
const
|
|
574
|
-
let
|
|
575
|
-
v().revalidateOnFocus && (
|
|
576
|
-
const
|
|
577
|
-
if (j ==
|
|
573
|
+
const S = ot.bind(L, Tt);
|
|
574
|
+
let y = 0;
|
|
575
|
+
v().revalidateOnFocus && (y = Date.now() + v().focusThrottleInterval);
|
|
576
|
+
const w = Qe(s, p, (j, b = {}) => {
|
|
577
|
+
if (j == se) {
|
|
578
578
|
const _ = Date.now();
|
|
579
|
-
v().revalidateOnFocus && _ >
|
|
580
|
-
} else if (j ==
|
|
581
|
-
v().revalidateOnReconnect &&
|
|
579
|
+
v().revalidateOnFocus && _ > y && Y() && (y = _ + v().focusThrottleInterval, S());
|
|
580
|
+
} else if (j == ie)
|
|
581
|
+
v().revalidateOnReconnect && Y() && S();
|
|
582
582
|
else {
|
|
583
|
-
if (j ==
|
|
584
|
-
return
|
|
583
|
+
if (j == ae)
|
|
584
|
+
return ot();
|
|
585
585
|
if (j == zt)
|
|
586
|
-
return
|
|
586
|
+
return ot(b);
|
|
587
587
|
}
|
|
588
588
|
});
|
|
589
|
-
return T.current = !1, I.current = s,
|
|
590
|
-
_k:
|
|
591
|
-
}),
|
|
592
|
-
T.current = !0,
|
|
589
|
+
return T.current = !1, I.current = s, K.current = !0, X({
|
|
590
|
+
_k: $
|
|
591
|
+
}), $t && (h[s] || (f(G) || nt ? S() : Ne(S))), () => {
|
|
592
|
+
T.current = !0, w();
|
|
593
593
|
};
|
|
594
594
|
}, [
|
|
595
595
|
s
|
|
596
|
-
]),
|
|
597
|
-
let
|
|
598
|
-
function
|
|
599
|
-
const
|
|
600
|
-
|
|
596
|
+
]), wt(() => {
|
|
597
|
+
let S;
|
|
598
|
+
function y() {
|
|
599
|
+
const w = M(R) ? R(V().data) : R;
|
|
600
|
+
w && S !== -1 && (S = setTimeout(O, w));
|
|
601
601
|
}
|
|
602
|
-
function
|
|
603
|
-
!V().error && (
|
|
602
|
+
function O() {
|
|
603
|
+
!V().error && (E || v().isVisible()) && (i || v().isOnline()) ? ot(Tt).then(y) : y();
|
|
604
604
|
}
|
|
605
|
-
return
|
|
606
|
-
|
|
605
|
+
return y(), () => {
|
|
606
|
+
S && (clearTimeout(S), S = -1);
|
|
607
607
|
};
|
|
608
608
|
}, [
|
|
609
609
|
R,
|
|
610
|
-
|
|
610
|
+
E,
|
|
611
611
|
i,
|
|
612
612
|
s
|
|
613
|
-
]), we(ft),
|
|
614
|
-
if (!Xt &&
|
|
613
|
+
]), we(ft), u) {
|
|
614
|
+
if (!Xt && nt && B)
|
|
615
615
|
throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
if (Dt(
|
|
616
|
+
B && (N.current = e, z.current = n, T.current = !1);
|
|
617
|
+
const S = D[s], y = !f(S) && B ? Ht(S) : te;
|
|
618
|
+
if (Dt(y), !f(lt) && B)
|
|
619
619
|
throw lt;
|
|
620
|
-
const
|
|
621
|
-
!f(ft) &&
|
|
620
|
+
const O = B ? ot(Tt) : te;
|
|
621
|
+
!f(ft) && B && (O.status = "fulfilled", O.value = !0), Dt(O);
|
|
622
622
|
}
|
|
623
623
|
return {
|
|
624
|
-
mutate:
|
|
624
|
+
mutate: Ht,
|
|
625
625
|
get data() {
|
|
626
|
-
return
|
|
626
|
+
return Q.data = !0, ft;
|
|
627
627
|
},
|
|
628
628
|
get error() {
|
|
629
|
-
return
|
|
629
|
+
return Q.error = !0, lt;
|
|
630
630
|
},
|
|
631
631
|
get isValidating() {
|
|
632
|
-
return
|
|
632
|
+
return Q.isValidating = !0, me;
|
|
633
633
|
},
|
|
634
634
|
get isLoading() {
|
|
635
|
-
return
|
|
635
|
+
return Q.isLoading = !0, Se;
|
|
636
636
|
}
|
|
637
637
|
};
|
|
638
|
-
}, ee =
|
|
638
|
+
}, ee = Xe(tn), en = (t, e) => {
|
|
639
639
|
let n = t;
|
|
640
640
|
return {
|
|
641
641
|
apply(r) {
|
|
@@ -646,26 +646,26 @@ const Dt = at.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
646
646
|
}
|
|
647
647
|
};
|
|
648
648
|
};
|
|
649
|
-
function
|
|
649
|
+
function pe() {
|
|
650
650
|
return window.document.location.host.indexOf("localhost") === 0 ? "http://localhost:3100" : "https://api.graffiticode.org";
|
|
651
651
|
}
|
|
652
|
-
const
|
|
652
|
+
const nn = async ({
|
|
653
653
|
accessToken: t,
|
|
654
654
|
id: e
|
|
655
655
|
}) => {
|
|
656
|
-
const n = await fetch(`${
|
|
656
|
+
const n = await fetch(`${pe()}/data?id=${e}`, {
|
|
657
657
|
headers: { Authorization: t || "" }
|
|
658
|
-
}), { status: r, error: o, data:
|
|
658
|
+
}), { status: r, error: o, data: u } = await n.json();
|
|
659
659
|
if (r !== "success")
|
|
660
660
|
throw new Error(`failed to get data ${e}: ${o == null ? void 0 : o.message}`);
|
|
661
|
-
return
|
|
662
|
-
},
|
|
661
|
+
return u;
|
|
662
|
+
}, rn = async ({
|
|
663
663
|
accessToken: t,
|
|
664
664
|
id: e,
|
|
665
665
|
data: n
|
|
666
666
|
}) => {
|
|
667
|
-
var
|
|
668
|
-
const o = await (await fetch(`${
|
|
667
|
+
var u;
|
|
668
|
+
const o = await (await fetch(`${pe()}/compile`, {
|
|
669
669
|
method: "POST",
|
|
670
670
|
headers: {
|
|
671
671
|
"Content-Type": "application/json",
|
|
@@ -675,79 +675,103 @@ const en = async ({
|
|
|
675
675
|
body: JSON.stringify({ id: e, data: n })
|
|
676
676
|
})).json();
|
|
677
677
|
if (o.status !== "success")
|
|
678
|
-
throw new Error(`failed to post compile ${e}: ${(
|
|
678
|
+
throw new Error(`failed to post compile ${e}: ${(u = o.error) == null ? void 0 : u.message}`);
|
|
679
679
|
return o.data;
|
|
680
|
-
},
|
|
680
|
+
}, on = async ({
|
|
681
681
|
accessToken: t,
|
|
682
682
|
id: e,
|
|
683
683
|
data: n
|
|
684
684
|
}) => {
|
|
685
685
|
const r = Object.keys(n).length > 0 ? 1 : 2;
|
|
686
|
-
return e = e.split("+").slice(0, r).join("+"), await
|
|
687
|
-
},
|
|
686
|
+
return e = e.split("+").slice(0, r).join("+"), await rn({ accessToken: t, id: e, data: n });
|
|
687
|
+
}, sn = async ({
|
|
688
688
|
accessToken: t,
|
|
689
689
|
id: e
|
|
690
|
-
}) => await
|
|
690
|
+
}) => await nn({ accessToken: t, id: e });
|
|
691
691
|
function ne(t) {
|
|
692
692
|
return t && typeof t == "object" && Array.isArray(t.errors) ? { data: t.data ?? null, errors: t.errors } : { data: t, errors: [] };
|
|
693
693
|
}
|
|
694
|
-
function
|
|
694
|
+
function an(t, e) {
|
|
695
695
|
return e.length > 0 ? !0 : !(t == null || typeof t == "object" && !Array.isArray(t) && Object.keys(t).length === 0);
|
|
696
696
|
}
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
697
|
+
const pn = ({ Form: t }) => {
|
|
698
|
+
var g;
|
|
699
|
+
const e = new URLSearchParams(window.location.search), [n] = J(e.get("id") ?? void 0), [r] = J(e.get("access_token") ?? void 0), [o] = J(e.get("origin") ?? void 0), [u, a] = J(!1), [d, m] = J(!1), [R, E] = J([]), [i] = J(
|
|
700
|
+
() => en({}, (h, { type: D, args: s }) => {
|
|
701
|
+
switch (console.log(
|
|
702
|
+
"L0000 View()",
|
|
703
|
+
"type=" + D,
|
|
704
|
+
"args=" + JSON.stringify(s, null, 2)
|
|
705
|
+
), D) {
|
|
701
706
|
case "init":
|
|
702
|
-
return
|
|
707
|
+
return s;
|
|
703
708
|
case "compiled":
|
|
704
|
-
return
|
|
709
|
+
return s;
|
|
705
710
|
case "update": {
|
|
706
|
-
const
|
|
707
|
-
return JSON.stringify(
|
|
711
|
+
const $ = { ...h, ...s };
|
|
712
|
+
return JSON.stringify($) !== JSON.stringify(h) && (m(!0), o && window.parent.postMessage({ focus: { type: "update", value: $ } }, o)), $;
|
|
708
713
|
}
|
|
709
714
|
default:
|
|
710
|
-
return console.error(`Unimplemented action type: ${
|
|
715
|
+
return console.error(`Unimplemented action type: ${D}`), h;
|
|
711
716
|
}
|
|
712
717
|
})
|
|
713
718
|
);
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
}, []),
|
|
719
|
+
at(() => {
|
|
720
|
+
const h = e.get("data");
|
|
721
|
+
h && i.apply({ type: "init", args: JSON.parse(h) });
|
|
722
|
+
}, []), at(() => {
|
|
718
723
|
o && window.parent.postMessage({ type: "onload", data: i.data }, o);
|
|
719
|
-
}, []),
|
|
724
|
+
}, []), at(() => {
|
|
720
725
|
n && a(!0);
|
|
721
|
-
}, [n]),
|
|
726
|
+
}, [n]), at(() => {
|
|
722
727
|
o && window.parent.postMessage({ type: "data-updated", data: i.data }, o);
|
|
723
728
|
}, [JSON.stringify(i.data)]);
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
|
|
729
|
+
const l = ee(
|
|
730
|
+
u && n ? { accessToken: r, id: n } : null,
|
|
731
|
+
sn
|
|
727
732
|
);
|
|
728
|
-
if (
|
|
729
|
-
const
|
|
730
|
-
i.apply({ type: "compiled", args:
|
|
733
|
+
if (l.data !== void 0) {
|
|
734
|
+
const h = ne(l.data);
|
|
735
|
+
i.apply({ type: "compiled", args: h.data }), E(h.errors), a(!1);
|
|
731
736
|
}
|
|
732
737
|
const c = ee(
|
|
733
|
-
d &&
|
|
734
|
-
|
|
738
|
+
d && n ? { accessToken: r, id: n, data: i.data } : null,
|
|
739
|
+
on
|
|
735
740
|
);
|
|
736
741
|
if (c.data !== void 0) {
|
|
737
|
-
const
|
|
738
|
-
i.apply({ type: "compiled", args:
|
|
742
|
+
const h = ne(c.data);
|
|
743
|
+
i.apply({ type: "compiled", args: h.data }), E(h.errors), m(!1);
|
|
739
744
|
}
|
|
740
|
-
const
|
|
741
|
-
return
|
|
745
|
+
const p = { data: i.data, errors: R, apply: i.apply };
|
|
746
|
+
return an(i.data, R) ? /* @__PURE__ */ F(t, { state: p }) : l.error ? /* @__PURE__ */ Lt("div", { role: "alert", style: re, children: [
|
|
747
|
+
/* @__PURE__ */ F("p", { style: { margin: 0, fontWeight: 600 }, children: "Couldn’t load this form." }),
|
|
748
|
+
/* @__PURE__ */ F("p", { style: { margin: "4px 0 12px", color: "#555" }, children: String(((g = l.error) == null ? void 0 : g.message) ?? l.error) }),
|
|
749
|
+
/* @__PURE__ */ F("button", { type: "button", style: cn, onClick: () => l.mutate(), children: "Retry" })
|
|
750
|
+
] }) : l.isLoading ? /* @__PURE__ */ F("div", { role: "status", "aria-live": "polite", style: re, children: "Loading…" }) : /* @__PURE__ */ F("div", {});
|
|
751
|
+
}, re = {
|
|
752
|
+
display: "flex",
|
|
753
|
+
flexDirection: "column",
|
|
754
|
+
alignItems: "center",
|
|
755
|
+
justifyContent: "center",
|
|
756
|
+
height: "100%",
|
|
757
|
+
padding: "24px",
|
|
758
|
+
textAlign: "center",
|
|
759
|
+
font: "14px/1.4 system-ui, sans-serif"
|
|
760
|
+
}, cn = {
|
|
761
|
+
padding: "6px 14px",
|
|
762
|
+
border: "1px solid #888",
|
|
763
|
+
borderRadius: "4px",
|
|
764
|
+
background: "#fff",
|
|
765
|
+
cursor: "pointer"
|
|
742
766
|
};
|
|
743
|
-
function
|
|
744
|
-
return /* @__PURE__ */
|
|
767
|
+
function un({ errors: t }) {
|
|
768
|
+
return /* @__PURE__ */ F("div", { className: "flex flex-col gap-2 font-mono text-xs", children: t.map((e, n) => /* @__PURE__ */ Lt(
|
|
745
769
|
"div",
|
|
746
770
|
{
|
|
747
771
|
className: "rounded-md border border-red-200 bg-red-50 p-3 text-red-800",
|
|
748
772
|
children: [
|
|
749
773
|
e.message,
|
|
750
|
-
typeof e.from == "number" && e.from >= 0 && /* @__PURE__ */
|
|
774
|
+
typeof e.from == "number" && e.from >= 0 && /* @__PURE__ */ Lt("span", { className: "ml-2 text-red-400", children: [
|
|
751
775
|
"[",
|
|
752
776
|
e.from,
|
|
753
777
|
typeof e.to == "number" && e.to >= 0 ? `–${e.to}` : "",
|
|
@@ -758,15 +782,15 @@ function an({ errors: t }) {
|
|
|
758
782
|
n
|
|
759
783
|
)) });
|
|
760
784
|
}
|
|
761
|
-
const
|
|
785
|
+
const hn = ({ state: t }) => {
|
|
762
786
|
const e = t.errors ?? [];
|
|
763
787
|
if (e.length > 0)
|
|
764
|
-
return /* @__PURE__ */
|
|
788
|
+
return /* @__PURE__ */ F(un, { errors: e });
|
|
765
789
|
const n = t.data;
|
|
766
|
-
return /* @__PURE__ */
|
|
790
|
+
return /* @__PURE__ */ F("pre", { className: "rounded-md bg-zinc-50 text-zinc-900 text-xs font-mono p-4 overflow-auto", children: JSON.stringify(n, null, 2) });
|
|
767
791
|
};
|
|
768
792
|
export {
|
|
769
|
-
|
|
770
|
-
|
|
793
|
+
hn as Form,
|
|
794
|
+
pn as View
|
|
771
795
|
};
|
|
772
796
|
//# sourceMappingURL=index.js.map
|