@figma-vars/hooks 1.2.0 → 1.3.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.
@@ -1,302 +1,20 @@
1
- import ce, { createContext as rt, useContext as ot, useEffect as ht, useLayoutEffect as _t, useRef as oe, useMemo as Re, useCallback as ge, useDebugValue as St } from "react";
2
- var he = { exports: {} }, de = {};
3
- /**
4
- * @license React
5
- * react-jsx-runtime.production.js
6
- *
7
- * Copyright (c) Meta Platforms, Inc. and affiliates.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- */
12
- var He;
13
- function Ot() {
14
- if (He) return de;
15
- He = 1;
16
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
17
- function n(o, s, a) {
18
- var u = null;
19
- if (a !== void 0 && (u = "" + a), s.key !== void 0 && (u = "" + s.key), "key" in s) {
20
- a = {};
21
- for (var p in s)
22
- p !== "key" && (a[p] = s[p]);
23
- } else a = s;
24
- return s = a.ref, {
25
- $$typeof: e,
26
- type: o,
27
- key: u,
28
- ref: s !== void 0 ? s : null,
29
- props: a
30
- };
31
- }
32
- return de.Fragment = t, de.jsx = n, de.jsxs = n, de;
33
- }
34
- var me = {};
35
- /**
36
- * @license React
37
- * react-jsx-runtime.development.js
38
- *
39
- * Copyright (c) Meta Platforms, Inc. and affiliates.
40
- *
41
- * This source code is licensed under the MIT license found in the
42
- * LICENSE file in the root directory of this source tree.
43
- */
44
- var Be;
45
- function Rt() {
46
- return Be || (Be = 1, process.env.NODE_ENV !== "production" && function() {
47
- function e(r) {
48
- if (r == null) return null;
49
- if (typeof r == "function")
50
- return r.$$typeof === N ? null : r.displayName || r.name || null;
51
- if (typeof r == "string") return r;
52
- switch (r) {
53
- case d:
54
- return "Fragment";
55
- case i:
56
- return "Profiler";
57
- case I:
58
- return "StrictMode";
59
- case b:
60
- return "Suspense";
61
- case j:
62
- return "SuspenseList";
63
- case Z:
64
- return "Activity";
65
- }
66
- if (typeof r == "object")
67
- switch (typeof r.tag == "number" && console.error(
68
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
- ), r.$$typeof) {
70
- case v:
71
- return "Portal";
72
- case ne:
73
- return (r.displayName || "Context") + ".Provider";
74
- case q:
75
- return (r._context.displayName || "Context") + ".Consumer";
76
- case U:
77
- var l = r.render;
78
- return r = r.displayName, r || (r = l.displayName || l.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
79
- case z:
80
- return l = r.displayName || null, l !== null ? l : e(r.type) || "Memo";
81
- case O:
82
- l = r._payload, r = r._init;
83
- try {
84
- return e(r(l));
85
- } catch {
86
- }
87
- }
88
- return null;
89
- }
90
- function t(r) {
91
- return "" + r;
92
- }
93
- function n(r) {
94
- try {
95
- t(r);
96
- var l = !1;
97
- } catch {
98
- l = !0;
99
- }
100
- if (l) {
101
- l = console;
102
- var h = l.error, T = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
103
- return h.call(
104
- l,
105
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
- T
107
- ), t(r);
108
- }
109
- }
110
- function o(r) {
111
- if (r === d) return "<>";
112
- if (typeof r == "object" && r !== null && r.$$typeof === O)
113
- return "<...>";
114
- try {
115
- var l = e(r);
116
- return l ? "<" + l + ">" : "<...>";
117
- } catch {
118
- return "<...>";
119
- }
120
- }
121
- function s() {
122
- var r = W.A;
123
- return r === null ? null : r.getOwner();
124
- }
125
- function a() {
126
- return Error("react-stack-top-frame");
127
- }
128
- function u(r) {
129
- if ($.call(r, "key")) {
130
- var l = Object.getOwnPropertyDescriptor(r, "key").get;
131
- if (l && l.isReactWarning) return !1;
132
- }
133
- return r.key !== void 0;
134
- }
135
- function p(r, l) {
136
- function h() {
137
- re || (re = !0, console.error(
138
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
139
- l
140
- ));
141
- }
142
- h.isReactWarning = !0, Object.defineProperty(r, "key", {
143
- get: h,
144
- configurable: !0
145
- });
146
- }
147
- function _() {
148
- var r = e(this.type);
149
- return ue[r] || (ue[r] = !0, console.error(
150
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
151
- )), r = this.props.ref, r !== void 0 ? r : null;
152
- }
153
- function A(r, l, h, T, F, x, se, ae) {
154
- return h = x.ref, r = {
155
- $$typeof: c,
156
- type: r,
157
- key: l,
158
- props: x,
159
- _owner: F
160
- }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(r, "ref", {
161
- enumerable: !1,
162
- get: _
163
- }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
164
- configurable: !1,
165
- enumerable: !1,
166
- writable: !0,
167
- value: 0
168
- }), Object.defineProperty(r, "_debugInfo", {
169
- configurable: !1,
170
- enumerable: !1,
171
- writable: !0,
172
- value: null
173
- }), Object.defineProperty(r, "_debugStack", {
174
- configurable: !1,
175
- enumerable: !1,
176
- writable: !0,
177
- value: se
178
- }), Object.defineProperty(r, "_debugTask", {
179
- configurable: !1,
180
- enumerable: !1,
181
- writable: !0,
182
- value: ae
183
- }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
184
- }
185
- function w(r, l, h, T, F, x, se, ae) {
186
- var y = l.children;
187
- if (y !== void 0)
188
- if (T)
189
- if (k(y)) {
190
- for (T = 0; T < y.length; T++)
191
- f(y[T]);
192
- Object.freeze && Object.freeze(y);
193
- } else
194
- console.error(
195
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
196
- );
197
- else f(y);
198
- if ($.call(l, "key")) {
199
- y = e(r);
200
- var Q = Object.keys(l).filter(function(ve) {
201
- return ve !== "key";
202
- });
203
- T = 0 < Q.length ? "{key: someKey, " + Q.join(": ..., ") + ": ...}" : "{key: someKey}", fe[y + T] || (Q = 0 < Q.length ? "{" + Q.join(": ..., ") + ": ...}" : "{}", console.error(
204
- `A props object containing a "key" prop is being spread into JSX:
205
- let props = %s;
206
- <%s {...props} />
207
- React keys must be passed directly to JSX without using spread:
208
- let props = %s;
209
- <%s key={someKey} {...props} />`,
210
- T,
211
- y,
212
- Q,
213
- y
214
- ), fe[y + T] = !0);
215
- }
216
- if (y = null, h !== void 0 && (n(h), y = "" + h), u(l) && (n(l.key), y = "" + l.key), "key" in l) {
217
- h = {};
218
- for (var B in l)
219
- B !== "key" && (h[B] = l[B]);
220
- } else h = l;
221
- return y && p(
222
- h,
223
- typeof r == "function" ? r.displayName || r.name || "Unknown" : r
224
- ), A(
225
- r,
226
- y,
227
- x,
228
- F,
229
- s(),
230
- h,
231
- se,
232
- ae
233
- );
234
- }
235
- function f(r) {
236
- typeof r == "object" && r !== null && r.$$typeof === c && r._store && (r._store.validated = 1);
237
- }
238
- var m = ce, c = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), I = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), q = Symbol.for("react.consumer"), ne = Symbol.for("react.context"), U = Symbol.for("react.forward_ref"), b = Symbol.for("react.suspense"), j = Symbol.for("react.suspense_list"), z = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), N = Symbol.for("react.client.reference"), W = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, $ = Object.prototype.hasOwnProperty, k = Array.isArray, Y = console.createTask ? console.createTask : function() {
239
- return null;
240
- };
241
- m = {
242
- "react-stack-bottom-frame": function(r) {
243
- return r();
244
- }
245
- };
246
- var re, ue = {}, le = m["react-stack-bottom-frame"].bind(
247
- m,
248
- a
249
- )(), H = Y(o(a)), fe = {};
250
- me.Fragment = d, me.jsx = function(r, l, h, T, F) {
251
- var x = 1e4 > W.recentlyCreatedOwnerStacks++;
252
- return w(
253
- r,
254
- l,
255
- h,
256
- !1,
257
- T,
258
- F,
259
- x ? Error("react-stack-top-frame") : le,
260
- x ? Y(o(r)) : H
261
- );
262
- }, me.jsxs = function(r, l, h, T, F) {
263
- var x = 1e4 > W.recentlyCreatedOwnerStacks++;
264
- return w(
265
- r,
266
- l,
267
- h,
268
- !0,
269
- T,
270
- F,
271
- x ? Error("react-stack-top-frame") : le,
272
- x ? Y(o(r)) : H
273
- );
274
- };
275
- }()), me;
276
- }
277
- var Je;
278
- function wt() {
279
- return Je || (Je = 1, process.env.NODE_ENV === "production" ? he.exports = Ot() : he.exports = Rt()), he.exports;
280
- }
281
- var Tt = wt();
282
- const st = rt(
1
+ import { jsx as we } from "react/jsx-runtime";
2
+ import et, { createContext as Qt, useContext as Zt, useEffect as Re, useLayoutEffect as ge, useRef as B, useMemo as ft, useCallback as lt, useDebugValue as ye, useReducer as Te } from "react";
3
+ const te = Qt(
283
4
  void 0
284
- ), an = ({
285
- children: e,
286
- token: t,
5
+ ), En = ({
6
+ children: t,
7
+ token: e,
287
8
  fileKey: n
288
- }) => /* @__PURE__ */ Tt.jsx(st.Provider, { value: { token: t, fileKey: n }, children: e }), at = () => {
289
- const e = ot(st);
290
- if (e === void 0)
9
+ }) => /* @__PURE__ */ we(te.Provider, { value: { token: e, fileKey: n }, children: t }), X = () => {
10
+ const t = Zt(te);
11
+ if (t === void 0)
291
12
  throw new Error(
292
13
  "useFigmaTokenContext must be used within a FigmaVarsProvider"
293
14
  );
294
- return e;
295
- }, cn = () => {
296
- const { token: e } = at();
297
- return e;
15
+ return t;
298
16
  };
299
- var _e = { exports: {} }, be = {};
17
+ var at = { exports: {} }, St = {};
300
18
  /**
301
19
  * @license React
302
20
  * use-sync-external-store-shim.production.js
@@ -306,48 +24,48 @@ var _e = { exports: {} }, be = {};
306
24
  * This source code is licensed under the MIT license found in the
307
25
  * LICENSE file in the root directory of this source tree.
308
26
  */
309
- var Ke;
310
- function gt() {
311
- if (Ke) return be;
312
- Ke = 1;
313
- var e = ce;
314
- function t(f, m) {
315
- return f === m && (f !== 0 || 1 / f === 1 / m) || f !== f && m !== m;
27
+ var kt;
28
+ function Ae() {
29
+ if (kt) return St;
30
+ kt = 1;
31
+ var t = et;
32
+ function e(u, d) {
33
+ return u === d && (u !== 0 || 1 / u === 1 / d) || u !== u && d !== d;
316
34
  }
317
- var n = typeof Object.is == "function" ? Object.is : t, o = e.useState, s = e.useEffect, a = e.useLayoutEffect, u = e.useDebugValue;
318
- function p(f, m) {
319
- var c = m(), v = o({ inst: { value: c, getSnapshot: m } }), d = v[0].inst, I = v[1];
320
- return a(
35
+ var n = typeof Object.is == "function" ? Object.is : e, r = t.useState, o = t.useEffect, s = t.useLayoutEffect, a = t.useDebugValue;
36
+ function m(u, d) {
37
+ var c = d(), E = r({ inst: { value: c, getSnapshot: d } }), l = E[0].inst, D = E[1];
38
+ return s(
321
39
  function() {
322
- d.value = c, d.getSnapshot = m, _(d) && I({ inst: d });
40
+ l.value = c, l.getSnapshot = d, _(l) && D({ inst: l });
323
41
  },
324
- [f, c, m]
325
- ), s(
42
+ [u, c, d]
43
+ ), o(
326
44
  function() {
327
- return _(d) && I({ inst: d }), f(function() {
328
- _(d) && I({ inst: d });
45
+ return _(l) && D({ inst: l }), u(function() {
46
+ _(l) && D({ inst: l });
329
47
  });
330
48
  },
331
- [f]
332
- ), u(c), c;
49
+ [u]
50
+ ), a(c), c;
333
51
  }
334
- function _(f) {
335
- var m = f.getSnapshot;
336
- f = f.value;
52
+ function _(u) {
53
+ var d = u.getSnapshot;
54
+ u = u.value;
337
55
  try {
338
- var c = m();
339
- return !n(f, c);
56
+ var c = d();
57
+ return !n(u, c);
340
58
  } catch {
341
59
  return !0;
342
60
  }
343
61
  }
344
- function A(f, m) {
345
- return m();
62
+ function y(u, d) {
63
+ return d();
346
64
  }
347
- var w = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? A : p;
348
- return be.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : w, be;
65
+ var O = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? y : m;
66
+ return St.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : O, St;
349
67
  }
350
- var ye = {};
68
+ var ht = {};
351
69
  /**
352
70
  * @license React
353
71
  * use-sync-external-store-shim.development.js
@@ -357,476 +75,476 @@ var ye = {};
357
75
  * This source code is licensed under the MIT license found in the
358
76
  * LICENSE file in the root directory of this source tree.
359
77
  */
360
- var Xe;
361
- function bt() {
362
- return Xe || (Xe = 1, process.env.NODE_ENV !== "production" && function() {
363
- function e(c, v) {
364
- return c === v && (c !== 0 || 1 / c === 1 / v) || c !== c && v !== v;
78
+ var $t;
79
+ function De() {
80
+ return $t || ($t = 1, process.env.NODE_ENV !== "production" && function() {
81
+ function t(c, E) {
82
+ return c === E && (c !== 0 || 1 / c === 1 / E) || c !== c && E !== E;
365
83
  }
366
- function t(c, v) {
367
- w || s.startTransition === void 0 || (w = !0, console.error(
84
+ function e(c, E) {
85
+ O || o.startTransition === void 0 || (O = !0, console.error(
368
86
  "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."
369
87
  ));
370
- var d = v();
371
- if (!f) {
372
- var I = v();
373
- a(d, I) || (console.error(
88
+ var l = E();
89
+ if (!u) {
90
+ var D = E();
91
+ s(l, D) || (console.error(
374
92
  "The result of getSnapshot should be cached to avoid an infinite loop"
375
- ), f = !0);
93
+ ), u = !0);
376
94
  }
377
- I = u({
378
- inst: { value: d, getSnapshot: v }
95
+ D = a({
96
+ inst: { value: l, getSnapshot: E }
379
97
  });
380
- var i = I[0].inst, q = I[1];
98
+ var i = D[0].inst, M = D[1];
381
99
  return _(
382
100
  function() {
383
- i.value = d, i.getSnapshot = v, n(i) && q({ inst: i });
101
+ i.value = l, i.getSnapshot = E, n(i) && M({ inst: i });
384
102
  },
385
- [c, d, v]
386
- ), p(
103
+ [c, l, E]
104
+ ), m(
387
105
  function() {
388
- return n(i) && q({ inst: i }), c(function() {
389
- n(i) && q({ inst: i });
106
+ return n(i) && M({ inst: i }), c(function() {
107
+ n(i) && M({ inst: i });
390
108
  });
391
109
  },
392
110
  [c]
393
- ), A(d), d;
111
+ ), y(l), l;
394
112
  }
395
113
  function n(c) {
396
- var v = c.getSnapshot;
114
+ var E = c.getSnapshot;
397
115
  c = c.value;
398
116
  try {
399
- var d = v();
400
- return !a(c, d);
117
+ var l = E();
118
+ return !s(c, l);
401
119
  } catch {
402
120
  return !0;
403
121
  }
404
122
  }
405
- function o(c, v) {
406
- return v();
123
+ function r(c, E) {
124
+ return E();
407
125
  }
408
126
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
409
- var s = ce, a = typeof Object.is == "function" ? Object.is : e, u = s.useState, p = s.useEffect, _ = s.useLayoutEffect, A = s.useDebugValue, w = !1, f = !1, m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? o : t;
410
- ye.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : m, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
411
- }()), ye;
127
+ var o = et, s = typeof Object.is == "function" ? Object.is : t, a = o.useState, m = o.useEffect, _ = o.useLayoutEffect, y = o.useDebugValue, O = !1, u = !1, d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
128
+ ht.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : d, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
129
+ }()), ht;
412
130
  }
413
- var ze;
414
- function yt() {
415
- return ze || (ze = 1, process.env.NODE_ENV === "production" ? _e.exports = gt() : _e.exports = bt()), _e.exports;
131
+ var Ht;
132
+ function Ie() {
133
+ return Ht || (Ht = 1, process.env.NODE_ENV === "production" ? at.exports = Ae() : at.exports = De()), at.exports;
416
134
  }
417
- var At = yt();
418
- const it = 0, ct = 1, ut = 2, Ze = 3;
419
- var Qe = Object.prototype.hasOwnProperty;
420
- function Le(e, t) {
421
- var n, o;
422
- if (e === t) return !0;
423
- if (e && t && (n = e.constructor) === t.constructor) {
424
- if (n === Date) return e.getTime() === t.getTime();
425
- if (n === RegExp) return e.toString() === t.toString();
135
+ var Le = Ie();
136
+ const ee = 0, ne = 1, re = 2, Kt = 3;
137
+ var Jt = Object.prototype.hasOwnProperty;
138
+ function Tt(t, e) {
139
+ var n, r;
140
+ if (t === e) return !0;
141
+ if (t && e && (n = t.constructor) === e.constructor) {
142
+ if (n === Date) return t.getTime() === e.getTime();
143
+ if (n === RegExp) return t.toString() === e.toString();
426
144
  if (n === Array) {
427
- if ((o = e.length) === t.length)
428
- for (; o-- && Le(e[o], t[o]); ) ;
429
- return o === -1;
145
+ if ((r = t.length) === e.length)
146
+ for (; r-- && Tt(t[r], e[r]); ) ;
147
+ return r === -1;
430
148
  }
431
- if (!n || typeof e == "object") {
432
- o = 0;
433
- for (n in e)
434
- if (Qe.call(e, n) && ++o && !Qe.call(t, n) || !(n in t) || !Le(e[n], t[n])) return !1;
435
- return Object.keys(t).length === o;
149
+ if (!n || typeof t == "object") {
150
+ r = 0;
151
+ for (n in t)
152
+ if (Jt.call(t, n) && ++r && !Jt.call(e, n) || !(n in e) || !Tt(t[n], e[n])) return !1;
153
+ return Object.keys(e).length === r;
436
154
  }
437
155
  }
438
- return e !== e && t !== t;
156
+ return t !== t && e !== e;
439
157
  }
440
- const X = /* @__PURE__ */ new WeakMap(), ee = () => {
441
- }, P = (
158
+ const P = /* @__PURE__ */ new WeakMap(), U = () => {
159
+ }, A = (
442
160
  /*#__NOINLINE__*/
443
- ee()
444
- ), Pe = Object, E = (e) => e === P, G = (e) => typeof e == "function", te = (e, t) => ({
445
- ...e,
446
- ...t
447
- }), lt = (e) => G(e.then), Ae = {}, Se = {}, Ue = "undefined", pe = typeof window != Ue, ke = typeof document != Ue, Ct = pe && "Deno" in window, Dt = () => pe && typeof window.requestAnimationFrame != Ue, ft = (e, t) => {
448
- const n = X.get(e);
161
+ U()
162
+ ), At = Object, f = (t) => t === A, N = (t) => typeof t == "function", G = (t, e) => ({
163
+ ...t,
164
+ ...e
165
+ }), oe = (t) => N(t.then), Ot = {}, ct = {}, Nt = "undefined", nt = typeof window != Nt, Dt = typeof document != Nt, Ce = nt && "Deno" in window, be = () => nt && typeof window.requestAnimationFrame != Nt, se = (t, e) => {
166
+ const n = P.get(t);
449
167
  return [
450
168
  // Getter
451
- () => !E(t) && e.get(t) || Ae,
169
+ () => !f(e) && t.get(e) || Ot,
452
170
  // Setter
453
- (o) => {
454
- if (!E(t)) {
455
- const s = e.get(t);
456
- t in Se || (Se[t] = s), n[5](t, te(s, o), s || Ae);
171
+ (r) => {
172
+ if (!f(e)) {
173
+ const o = t.get(e);
174
+ e in ct || (ct[e] = o), n[5](e, G(o, r), o || Ot);
457
175
  }
458
176
  },
459
177
  // Subscriber
460
178
  n[6],
461
179
  // Get server cache snapshot
462
- () => !E(t) && t in Se ? Se[t] : !E(t) && e.get(t) || Ae
180
+ () => !f(e) && e in ct ? ct[e] : !f(e) && t.get(e) || Ot
463
181
  ];
464
182
  };
465
- let Ne = !0;
466
- const It = () => Ne, [Fe, Ve] = pe && window.addEventListener ? [
183
+ let It = !0;
184
+ const Ve = () => It, [Lt, Ct] = nt && window.addEventListener ? [
467
185
  window.addEventListener.bind(window),
468
186
  window.removeEventListener.bind(window)
469
187
  ] : [
470
- ee,
471
- ee
472
- ], jt = () => {
473
- const e = ke && document.visibilityState;
474
- return E(e) || e !== "hidden";
475
- }, xt = (e) => (ke && document.addEventListener("visibilitychange", e), Fe("focus", e), () => {
476
- ke && document.removeEventListener("visibilitychange", e), Ve("focus", e);
477
- }), Lt = (e) => {
478
- const t = () => {
479
- Ne = !0, e();
188
+ U,
189
+ U
190
+ ], Ne = () => {
191
+ const t = Dt && document.visibilityState;
192
+ return f(t) || t !== "hidden";
193
+ }, Fe = (t) => (Dt && document.addEventListener("visibilitychange", t), Lt("focus", t), () => {
194
+ Dt && document.removeEventListener("visibilitychange", t), Ct("focus", t);
195
+ }), xe = (t) => {
196
+ const e = () => {
197
+ It = !0, t();
480
198
  }, n = () => {
481
- Ne = !1;
199
+ It = !1;
482
200
  };
483
- return Fe("online", t), Fe("offline", n), () => {
484
- Ve("online", t), Ve("offline", n);
201
+ return Lt("online", e), Lt("offline", n), () => {
202
+ Ct("online", e), Ct("offline", n);
485
203
  };
486
- }, Pt = {
487
- isOnline: It,
488
- isVisible: jt
489
- }, kt = {
490
- initFocus: xt,
491
- initReconnect: Lt
492
- }, et = !ce.useId, Ee = !pe || Ct, Nt = (e) => Dt() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Ce = Ee ? ht : _t, De = typeof navigator < "u" && navigator.connection, tt = !Ee && De && ([
204
+ }, Pe = {
205
+ isOnline: Ve,
206
+ isVisible: Ne
207
+ }, Me = {
208
+ initFocus: Fe,
209
+ initReconnect: xe
210
+ }, Yt = !et.useId, tt = !nt || Ce, je = (t) => be() ? window.requestAnimationFrame(t) : setTimeout(t, 1), vt = tt ? Re : ge, wt = typeof navigator < "u" && navigator.connection, zt = !tt && wt && ([
493
211
  "slow-2g",
494
212
  "2g"
495
- ].includes(De.effectiveType) || De.saveData), Oe = /* @__PURE__ */ new WeakMap(), Ie = (e, t) => Pe.prototype.toString.call(e) === `[object ${t}]`;
496
- let Ft = 0;
497
- const Me = (e) => {
498
- const t = typeof e, n = Ie(e, "Date"), o = Ie(e, "RegExp"), s = Ie(e, "Object");
499
- let a, u;
500
- if (Pe(e) === e && !n && !o) {
501
- if (a = Oe.get(e), a) return a;
502
- if (a = ++Ft + "~", Oe.set(e, a), Array.isArray(e)) {
503
- for (a = "@", u = 0; u < e.length; u++)
504
- a += Me(e[u]) + ",";
505
- Oe.set(e, a);
213
+ ].includes(wt.effectiveType) || wt.saveData), ut = /* @__PURE__ */ new WeakMap(), Rt = (t, e) => At.prototype.toString.call(t) === `[object ${e}]`;
214
+ let Ue = 0;
215
+ const bt = (t) => {
216
+ const e = typeof t, n = Rt(t, "Date"), r = Rt(t, "RegExp"), o = Rt(t, "Object");
217
+ let s, a;
218
+ if (At(t) === t && !n && !r) {
219
+ if (s = ut.get(t), s) return s;
220
+ if (s = ++Ue + "~", ut.set(t, s), Array.isArray(t)) {
221
+ for (s = "@", a = 0; a < t.length; a++)
222
+ s += bt(t[a]) + ",";
223
+ ut.set(t, s);
506
224
  }
507
- if (s) {
508
- a = "#";
509
- const p = Pe.keys(e).sort();
510
- for (; !E(u = p.pop()); )
511
- E(e[u]) || (a += u + ":" + Me(e[u]) + ",");
512
- Oe.set(e, a);
225
+ if (o) {
226
+ s = "#";
227
+ const m = At.keys(t).sort();
228
+ for (; !f(a = m.pop()); )
229
+ f(t[a]) || (s += a + ":" + bt(t[a]) + ",");
230
+ ut.set(t, s);
513
231
  }
514
232
  } else
515
- a = n ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
516
- return a;
517
- }, We = (e) => {
518
- if (G(e))
233
+ s = n ? t.toJSON() : e == "symbol" ? t.toString() : e == "string" ? JSON.stringify(t) : "" + t;
234
+ return s;
235
+ }, Ft = (t) => {
236
+ if (N(t))
519
237
  try {
520
- e = e();
238
+ t = t();
521
239
  } catch {
522
- e = "";
240
+ t = "";
523
241
  }
524
- const t = e;
525
- return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? Me(e) : "", [
526
- e,
527
- t
242
+ const e = t;
243
+ return t = typeof t == "string" ? t : (Array.isArray(t) ? t.length : t) ? bt(t) : "", [
244
+ t,
245
+ e
528
246
  ];
529
247
  };
530
- let Vt = 0;
531
- const qe = () => ++Vt;
532
- async function dt(...e) {
533
- const [t, n, o, s] = e, a = te({
248
+ let Ge = 0;
249
+ const Vt = () => ++Ge;
250
+ async function ie(...t) {
251
+ const [e, n, r, o] = t, s = G({
534
252
  populateCache: !0,
535
253
  throwOnError: !0
536
- }, typeof s == "boolean" ? {
537
- revalidate: s
538
- } : s || {});
539
- let u = a.populateCache;
540
- const p = a.rollbackOnError;
541
- let _ = a.optimisticData;
542
- const A = (m) => typeof p == "function" ? p(m) : p !== !1, w = a.throwOnError;
543
- if (G(n)) {
544
- const m = n, c = [], v = t.keys();
545
- for (const d of v)
254
+ }, typeof o == "boolean" ? {
255
+ revalidate: o
256
+ } : o || {});
257
+ let a = s.populateCache;
258
+ const m = s.rollbackOnError;
259
+ let _ = s.optimisticData;
260
+ const y = (d) => typeof m == "function" ? m(d) : m !== !1, O = s.throwOnError;
261
+ if (N(n)) {
262
+ const d = n, c = [], E = e.keys();
263
+ for (const l of E)
546
264
  // Skip the special useSWRInfinite and useSWRSubscription keys.
547
- !/^\$(inf|sub)\$/.test(d) && m(t.get(d)._k) && c.push(d);
548
- return Promise.all(c.map(f));
265
+ !/^\$(inf|sub)\$/.test(l) && d(e.get(l)._k) && c.push(l);
266
+ return Promise.all(c.map(u));
549
267
  }
550
- return f(n);
551
- async function f(m) {
552
- const [c] = We(m);
268
+ return u(n);
269
+ async function u(d) {
270
+ const [c] = Ft(d);
553
271
  if (!c) return;
554
- const [v, d] = ft(t, c), [I, i, q, ne] = X.get(t), U = () => {
555
- const k = I[c];
556
- return (G(a.revalidate) ? a.revalidate(v().data, m) : a.revalidate !== !1) && (delete q[c], delete ne[c], k && k[0]) ? k[0](ut).then(() => v().data) : v().data;
272
+ const [E, l] = se(e, c), [D, i, M, Q] = P.get(e), j = () => {
273
+ const C = D[c];
274
+ return (N(s.revalidate) ? s.revalidate(E().data, d) : s.revalidate !== !1) && (delete M[c], delete Q[c], C && C[0]) ? C[0](re).then(() => E().data) : E().data;
557
275
  };
558
- if (e.length < 3)
559
- return U();
560
- let b = o, j;
561
- const z = qe();
276
+ if (t.length < 3)
277
+ return j();
278
+ let R = r, I;
279
+ const k = Vt();
562
280
  i[c] = [
563
- z,
281
+ k,
564
282
  0
565
283
  ];
566
- const O = !E(_), Z = v(), N = Z.data, W = Z._c, $ = E(W) ? N : W;
567
- if (O && (_ = G(_) ? _($, N) : _, d({
284
+ const h = !f(_), $ = E(), V = $.data, H = $._c, W = f(H) ? V : H;
285
+ if (h && (_ = N(_) ? _(W, V) : _, l({
568
286
  data: _,
569
- _c: $
570
- })), G(b))
287
+ _c: W
288
+ })), N(R))
571
289
  try {
572
- b = b($);
573
- } catch (k) {
574
- j = k;
290
+ R = R(W);
291
+ } catch (C) {
292
+ I = C;
575
293
  }
576
- if (b && lt(b))
577
- if (b = await b.catch((k) => {
578
- j = k;
579
- }), z !== i[c][0]) {
580
- if (j) throw j;
581
- return b;
582
- } else j && O && A(j) && (u = !0, d({
583
- data: $,
584
- _c: P
294
+ if (R && oe(R))
295
+ if (R = await R.catch((C) => {
296
+ I = C;
297
+ }), k !== i[c][0]) {
298
+ if (I) throw I;
299
+ return R;
300
+ } else I && h && y(I) && (a = !0, l({
301
+ data: W,
302
+ _c: A
585
303
  }));
586
- if (u && !j)
587
- if (G(u)) {
588
- const k = u(b, $);
589
- d({
590
- data: k,
591
- error: P,
592
- _c: P
304
+ if (a && !I)
305
+ if (N(a)) {
306
+ const C = a(R, W);
307
+ l({
308
+ data: C,
309
+ error: A,
310
+ _c: A
593
311
  });
594
312
  } else
595
- d({
596
- data: b,
597
- error: P,
598
- _c: P
313
+ l({
314
+ data: R,
315
+ error: A,
316
+ _c: A
599
317
  });
600
- if (i[c][1] = qe(), Promise.resolve(U()).then(() => {
601
- d({
602
- _c: P
318
+ if (i[c][1] = Vt(), Promise.resolve(j()).then(() => {
319
+ l({
320
+ _c: A
603
321
  });
604
- }), j) {
605
- if (w) throw j;
322
+ }), I) {
323
+ if (O) throw I;
606
324
  return;
607
325
  }
608
- return b;
326
+ return R;
609
327
  }
610
328
  }
611
- const nt = (e, t) => {
612
- for (const n in e)
613
- e[n][0] && e[n][0](t);
614
- }, Mt = (e, t) => {
615
- if (!X.has(e)) {
616
- const n = te(kt, t), o = /* @__PURE__ */ Object.create(null), s = dt.bind(P, e);
617
- let a = ee;
618
- const u = /* @__PURE__ */ Object.create(null), p = (w, f) => {
619
- const m = u[w] || [];
620
- return u[w] = m, m.push(f), () => m.splice(m.indexOf(f), 1);
621
- }, _ = (w, f, m) => {
622
- e.set(w, f);
623
- const c = u[w];
329
+ const Xt = (t, e) => {
330
+ for (const n in t)
331
+ t[n][0] && t[n][0](e);
332
+ }, We = (t, e) => {
333
+ if (!P.has(t)) {
334
+ const n = G(Me, e), r = /* @__PURE__ */ Object.create(null), o = ie.bind(A, t);
335
+ let s = U;
336
+ const a = /* @__PURE__ */ Object.create(null), m = (O, u) => {
337
+ const d = a[O] || [];
338
+ return a[O] = d, d.push(u), () => d.splice(d.indexOf(u), 1);
339
+ }, _ = (O, u, d) => {
340
+ t.set(O, u);
341
+ const c = a[O];
624
342
  if (c)
625
- for (const v of c)
626
- v(f, m);
627
- }, A = () => {
628
- if (!X.has(e) && (X.set(e, [
629
- o,
343
+ for (const E of c)
344
+ E(u, d);
345
+ }, y = () => {
346
+ if (!P.has(t) && (P.set(t, [
347
+ r,
630
348
  /* @__PURE__ */ Object.create(null),
631
349
  /* @__PURE__ */ Object.create(null),
632
350
  /* @__PURE__ */ Object.create(null),
633
- s,
351
+ o,
634
352
  _,
635
- p
636
- ]), !Ee)) {
637
- const w = n.initFocus(setTimeout.bind(P, nt.bind(P, o, it))), f = n.initReconnect(setTimeout.bind(P, nt.bind(P, o, ct)));
638
- a = () => {
639
- w && w(), f && f(), X.delete(e);
353
+ m
354
+ ]), !tt)) {
355
+ const O = n.initFocus(setTimeout.bind(A, Xt.bind(A, r, ee))), u = n.initReconnect(setTimeout.bind(A, Xt.bind(A, r, ne)));
356
+ s = () => {
357
+ O && O(), u && u(), P.delete(t);
640
358
  };
641
359
  }
642
360
  };
643
- return A(), [
644
- e,
645
- s,
646
- A,
647
- a
361
+ return y(), [
362
+ t,
363
+ o,
364
+ y,
365
+ s
648
366
  ];
649
367
  }
650
368
  return [
651
- e,
652
- X.get(e)[4]
369
+ t,
370
+ P.get(t)[4]
653
371
  ];
654
- }, qt = (e, t, n, o, s) => {
655
- const a = n.errorRetryCount, u = s.retryCount, p = ~~((Math.random() + 0.5) * (1 << (u < 8 ? u : 8))) * n.errorRetryInterval;
656
- !E(a) && u > a || setTimeout(o, p, s);
657
- }, Ut = Le, [mt, Wt] = Mt(/* @__PURE__ */ new Map()), $t = te(
372
+ }, qe = (t, e, n, r, o) => {
373
+ const s = n.errorRetryCount, a = o.retryCount, m = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * n.errorRetryInterval;
374
+ !f(s) && a > s || setTimeout(r, m, o);
375
+ }, Be = Tt, [ae, ke] = We(/* @__PURE__ */ new Map()), $e = G(
658
376
  {
659
377
  // events
660
- onLoadingSlow: ee,
661
- onSuccess: ee,
662
- onError: ee,
663
- onErrorRetry: qt,
664
- onDiscarded: ee,
378
+ onLoadingSlow: U,
379
+ onSuccess: U,
380
+ onError: U,
381
+ onErrorRetry: qe,
382
+ onDiscarded: U,
665
383
  // switches
666
384
  revalidateOnFocus: !0,
667
385
  revalidateOnReconnect: !0,
668
386
  revalidateIfStale: !0,
669
387
  shouldRetryOnError: !0,
670
388
  // timeouts
671
- errorRetryInterval: tt ? 1e4 : 5e3,
389
+ errorRetryInterval: zt ? 1e4 : 5e3,
672
390
  focusThrottleInterval: 5 * 1e3,
673
391
  dedupingInterval: 2 * 1e3,
674
- loadingTimeout: tt ? 5e3 : 3e3,
392
+ loadingTimeout: zt ? 5e3 : 3e3,
675
393
  // providers
676
- compare: Ut,
394
+ compare: Be,
677
395
  isPaused: () => !1,
678
- cache: mt,
679
- mutate: Wt,
396
+ cache: ae,
397
+ mutate: ke,
680
398
  fallback: {}
681
399
  },
682
400
  // use web preset by default
683
- Pt
684
- ), Yt = (e, t) => {
685
- const n = te(e, t);
686
- if (t) {
687
- const { use: o, fallback: s } = e, { use: a, fallback: u } = t;
688
- o && a && (n.use = o.concat(a)), s && u && (n.fallback = te(s, u));
401
+ Pe
402
+ ), He = (t, e) => {
403
+ const n = G(t, e);
404
+ if (e) {
405
+ const { use: r, fallback: o } = t, { use: s, fallback: a } = e;
406
+ r && s && (n.use = r.concat(s)), o && a && (n.fallback = G(o, a));
689
407
  }
690
408
  return n;
691
- }, Gt = rt({}), Ht = "$inf$", Et = pe && window.__SWR_DEVTOOLS_USE__, Bt = Et ? window.__SWR_DEVTOOLS_USE__ : [], Jt = () => {
692
- Et && (window.__SWR_DEVTOOLS_REACT__ = ce);
693
- }, Kt = (e) => G(e[1]) ? [
694
- e[0],
695
- e[1],
696
- e[2] || {}
409
+ }, Ke = Qt({}), Je = "$inf$", ce = nt && window.__SWR_DEVTOOLS_USE__, Ye = ce ? window.__SWR_DEVTOOLS_USE__ : [], ze = () => {
410
+ ce && (window.__SWR_DEVTOOLS_REACT__ = et);
411
+ }, Xe = (t) => N(t[1]) ? [
412
+ t[0],
413
+ t[1],
414
+ t[2] || {}
697
415
  ] : [
698
- e[0],
416
+ t[0],
699
417
  null,
700
- (e[1] === null ? e[2] : e[1]) || {}
701
- ], Xt = () => te($t, ot(Gt)), zt = (e) => (t, n, o) => e(t, n && ((...a) => {
702
- const [u] = We(t), [, , , p] = X.get(mt);
703
- if (u.startsWith(Ht))
704
- return n(...a);
705
- const _ = p[u];
706
- return E(_) ? n(...a) : (delete p[u], _);
707
- }), o), Zt = Bt.concat(zt), Qt = (e) => function(...n) {
708
- const o = Xt(), [s, a, u] = Kt(n), p = Yt(o, u);
709
- let _ = e;
710
- const { use: A } = p, w = (A || []).concat(Zt);
711
- for (let f = w.length; f--; )
712
- _ = w[f](_);
713
- return _(s, a || p.fetcher || null, p);
714
- }, en = (e, t, n) => {
715
- const o = t[e] || (t[e] = []);
716
- return o.push(n), () => {
717
- const s = o.indexOf(n);
718
- s >= 0 && (o[s] = o[o.length - 1], o.pop());
418
+ (t[1] === null ? t[2] : t[1]) || {}
419
+ ], Qe = () => G($e, Zt(Ke)), Ze = (t) => (e, n, r) => t(e, n && ((...s) => {
420
+ const [a] = Ft(e), [, , , m] = P.get(ae);
421
+ if (a.startsWith(Je))
422
+ return n(...s);
423
+ const _ = m[a];
424
+ return f(_) ? n(...s) : (delete m[a], _);
425
+ }), r), tn = Ye.concat(Ze), en = (t) => function(...n) {
426
+ const r = Qe(), [o, s, a] = Xe(n), m = He(r, a);
427
+ let _ = t;
428
+ const { use: y } = m, O = (y || []).concat(tn);
429
+ for (let u = O.length; u--; )
430
+ _ = O[u](_);
431
+ return _(o, s || m.fetcher || null, m);
432
+ }, nn = (t, e, n) => {
433
+ const r = e[t] || (e[t] = []);
434
+ return r.push(n), () => {
435
+ const o = r.indexOf(n);
436
+ o >= 0 && (r[o] = r[r.length - 1], r.pop());
719
437
  };
720
438
  };
721
- Jt();
722
- const je = ce.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
439
+ ze();
440
+ const gt = et.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
723
441
  // and emitting an error.
724
442
  // We assume that this is only for the `use(thenable)` case, not `use(context)`.
725
443
  // https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
726
- ((e) => {
727
- switch (e.status) {
444
+ ((t) => {
445
+ switch (t.status) {
728
446
  case "pending":
729
- throw e;
447
+ throw t;
730
448
  case "fulfilled":
731
- return e.value;
449
+ return t.value;
732
450
  case "rejected":
733
- throw e.reason;
451
+ throw t.reason;
734
452
  default:
735
- throw e.status = "pending", e.then((t) => {
736
- e.status = "fulfilled", e.value = t;
737
- }, (t) => {
738
- e.status = "rejected", e.reason = t;
739
- }), e;
453
+ throw t.status = "pending", t.then((e) => {
454
+ t.status = "fulfilled", t.value = e;
455
+ }, (e) => {
456
+ t.status = "rejected", t.reason = e;
457
+ }), t;
740
458
  }
741
- }), xe = {
459
+ }), yt = {
742
460
  dedupe: !0
743
- }, tn = (e, t, n) => {
744
- const { cache: o, compare: s, suspense: a, fallbackData: u, revalidateOnMount: p, revalidateIfStale: _, refreshInterval: A, refreshWhenHidden: w, refreshWhenOffline: f, keepPreviousData: m } = n, [c, v, d, I] = X.get(o), [i, q] = We(e), ne = oe(!1), U = oe(!1), b = oe(i), j = oe(t), z = oe(n), O = () => z.current, Z = () => O().isVisible() && O().isOnline(), [N, W, $, k] = ft(o, i), Y = oe({}).current, re = E(u) ? E(n.fallback) ? P : n.fallback[i] : u, ue = (R, S) => {
745
- for (const D in Y) {
746
- const g = D;
747
- if (g === "data") {
748
- if (!s(R[g], S[g]) && (!E(R[g]) || !s(x, S[g])))
461
+ }, rn = (t, e, n) => {
462
+ const { cache: r, compare: o, suspense: s, fallbackData: a, revalidateOnMount: m, revalidateIfStale: _, refreshInterval: y, refreshWhenHidden: O, refreshWhenOffline: u, keepPreviousData: d } = n, [c, E, l, D] = P.get(r), [i, M] = Ft(t), Q = B(!1), j = B(!1), R = B(i), I = B(e), k = B(n), h = () => k.current, $ = () => h().isVisible() && h().isOnline(), [V, H, W, C] = se(r, i), K = B({}).current, ot = f(a) ? f(n.fallback) ? A : n.fallback[i] : a, xt = (S, p) => {
463
+ for (const g in K) {
464
+ const v = g;
465
+ if (v === "data") {
466
+ if (!o(S[v], p[v]) && (!f(S[v]) || !o(it, p[v])))
749
467
  return !1;
750
- } else if (S[g] !== R[g])
468
+ } else if (p[v] !== S[v])
751
469
  return !1;
752
470
  }
753
471
  return !0;
754
- }, le = Re(() => {
755
- const R = !i || !t ? !1 : E(p) ? O().isPaused() || a ? !1 : _ !== !1 : p, S = (L) => {
756
- const J = te(L);
757
- return delete J._k, R ? {
472
+ }, Pt = ft(() => {
473
+ const S = !i || !e ? !1 : f(m) ? h().isPaused() || s ? !1 : _ !== !1 : m, p = (T) => {
474
+ const F = G(T);
475
+ return delete F._k, S ? {
758
476
  isValidating: !0,
759
477
  isLoading: !0,
760
- ...J
761
- } : J;
762
- }, D = N(), g = k(), M = S(D), ie = D === g ? M : S(g);
763
- let C = M;
478
+ ...F
479
+ } : F;
480
+ }, g = V(), v = C(), b = p(g), z = g === v ? b : p(v);
481
+ let w = b;
764
482
  return [
765
483
  () => {
766
- const L = S(N());
767
- return ue(L, C) ? (C.data = L.data, C.isLoading = L.isLoading, C.isValidating = L.isValidating, C.error = L.error, C) : (C = L, L);
484
+ const T = p(V());
485
+ return xt(T, w) ? (w.data = T.data, w.isLoading = T.isLoading, w.isValidating = T.isValidating, w.error = T.error, w) : (w = T, T);
768
486
  },
769
- () => ie
487
+ () => z
770
488
  ];
771
489
  }, [
772
- o,
490
+ r,
773
491
  i
774
- ]), H = At.useSyncExternalStore(ge(
775
- (R) => $(i, (S, D) => {
776
- ue(D, S) || R();
492
+ ]), J = Le.useSyncExternalStore(lt(
493
+ (S) => W(i, (p, g) => {
494
+ xt(g, p) || S();
777
495
  }),
778
496
  // eslint-disable-next-line react-hooks/exhaustive-deps
779
497
  [
780
- o,
498
+ r,
781
499
  i
782
500
  ]
783
- ), le[0], le[1]), fe = !ne.current, r = c[i] && c[i].length > 0, l = H.data, h = E(l) ? re && lt(re) ? je(re) : re : l, T = H.error, F = oe(h), x = m ? E(l) ? E(F.current) ? h : F.current : l : h, se = r && !E(T) ? !1 : fe && !E(p) ? p : O().isPaused() ? !1 : a ? E(h) ? !1 : _ : E(h) || _, ae = !!(i && t && fe && se), y = E(H.isValidating) ? ae : H.isValidating, Q = E(H.isLoading) ? ae : H.isLoading, B = ge(
784
- async (R) => {
785
- const S = j.current;
786
- if (!i || !S || U.current || O().isPaused())
501
+ ), Pt[0], Pt[1]), Mt = !Q.current, Se = c[i] && c[i].length > 0, Y = J.data, q = f(Y) ? ot && oe(ot) ? gt(ot) : ot : Y, st = J.error, pt = B(q), it = d ? f(Y) ? f(pt.current) ? q : pt.current : Y : q, jt = Se && !f(st) ? !1 : Mt && !f(m) ? m : h().isPaused() ? !1 : s ? f(q) ? !1 : _ : f(q) || _, Ut = !!(i && e && Mt && jt), he = f(J.isValidating) ? Ut : J.isValidating, Oe = f(J.isLoading) ? Ut : J.isLoading, Z = lt(
502
+ async (S) => {
503
+ const p = I.current;
504
+ if (!i || !p || j.current || h().isPaused())
787
505
  return !1;
788
- let D, g, M = !0;
789
- const ie = R || {}, C = !d[i] || !ie.dedupe, L = () => et ? !U.current && i === b.current && ne.current : i === b.current, J = {
506
+ let g, v, b = !0;
507
+ const z = S || {}, w = !l[i] || !z.dedupe, T = () => Yt ? !j.current && i === R.current && Q.current : i === R.current, F = {
790
508
  isValidating: !1,
791
509
  isLoading: !1
792
- }, $e = () => {
793
- W(J);
794
- }, Ye = () => {
795
- const V = d[i];
796
- V && V[1] === g && delete d[i];
797
- }, Ge = {
510
+ }, Wt = () => {
511
+ H(F);
512
+ }, qt = () => {
513
+ const L = l[i];
514
+ L && L[1] === v && delete l[i];
515
+ }, Bt = {
798
516
  isValidating: !0
799
517
  };
800
- E(N().data) && (Ge.isLoading = !0);
518
+ f(V().data) && (Bt.isLoading = !0);
801
519
  try {
802
- if (C && (W(Ge), n.loadingTimeout && E(N().data) && setTimeout(() => {
803
- M && L() && O().onLoadingSlow(i, n);
804
- }, n.loadingTimeout), d[i] = [
805
- S(q),
806
- qe()
807
- ]), [D, g] = d[i], D = await D, C && setTimeout(Ye, n.dedupingInterval), !d[i] || d[i][1] !== g)
808
- return C && L() && O().onDiscarded(i), !1;
809
- J.error = P;
810
- const V = v[i];
811
- if (!E(V) && // case 1
812
- (g <= V[0] || // case 2
813
- g <= V[1] || // case 3
814
- V[1] === 0))
815
- return $e(), C && L() && O().onDiscarded(i), !1;
816
- const K = N().data;
817
- J.data = s(K, D) ? K : D, C && L() && O().onSuccess(D, i, n);
818
- } catch (V) {
819
- Ye();
820
- const K = O(), { shouldRetryOnError: we } = K;
821
- K.isPaused() || (J.error = V, C && L() && (K.onError(V, i, K), (we === !0 || G(we) && we(V)) && (!O().revalidateOnFocus || !O().revalidateOnReconnect || Z()) && K.onErrorRetry(V, i, K, (vt) => {
822
- const Te = c[i];
823
- Te && Te[0] && Te[0](Ze, vt);
520
+ if (w && (H(Bt), n.loadingTimeout && f(V().data) && setTimeout(() => {
521
+ b && T() && h().onLoadingSlow(i, n);
522
+ }, n.loadingTimeout), l[i] = [
523
+ p(M),
524
+ Vt()
525
+ ]), [g, v] = l[i], g = await g, w && setTimeout(qt, n.dedupingInterval), !l[i] || l[i][1] !== v)
526
+ return w && T() && h().onDiscarded(i), !1;
527
+ F.error = A;
528
+ const L = E[i];
529
+ if (!f(L) && // case 1
530
+ (v <= L[0] || // case 2
531
+ v <= L[1] || // case 3
532
+ L[1] === 0))
533
+ return Wt(), w && T() && h().onDiscarded(i), !1;
534
+ const x = V().data;
535
+ F.data = o(x, g) ? x : g, w && T() && h().onSuccess(g, i, n);
536
+ } catch (L) {
537
+ qt();
538
+ const x = h(), { shouldRetryOnError: mt } = x;
539
+ x.isPaused() || (F.error = L, w && T() && (x.onError(L, i, x), (mt === !0 || N(mt) && mt(L)) && (!h().revalidateOnFocus || !h().revalidateOnReconnect || $()) && x.onErrorRetry(L, i, x, (ve) => {
540
+ const _t = c[i];
541
+ _t && _t[0] && _t[0](Kt, ve);
824
542
  }, {
825
- retryCount: (ie.retryCount || 0) + 1,
543
+ retryCount: (z.retryCount || 0) + 1,
826
544
  dedupe: !0
827
545
  })));
828
546
  }
829
- return M = !1, $e(), !0;
547
+ return b = !1, Wt(), !0;
830
548
  },
831
549
  // `setState` is immutable, and `eventsCallback`, `fnArg`, and
832
550
  // `keyValidating` are depending on `key`, so we can exclude them from
@@ -841,220 +559,262 @@ const je = ce.use || // This extra generic is to avoid TypeScript mixing up the
841
559
  // eslint-disable-next-line react-hooks/exhaustive-deps
842
560
  [
843
561
  i,
844
- o
562
+ r
845
563
  ]
846
- ), ve = ge(
564
+ ), Gt = lt(
847
565
  // Use callback to make sure `keyRef.current` returns latest result every time
848
- (...R) => dt(o, b.current, ...R),
566
+ (...S) => ie(r, R.current, ...S),
849
567
  // eslint-disable-next-line react-hooks/exhaustive-deps
850
568
  []
851
569
  );
852
- if (Ce(() => {
853
- j.current = t, z.current = n, E(l) || (F.current = l);
854
- }), Ce(() => {
570
+ if (vt(() => {
571
+ I.current = e, k.current = n, f(Y) || (pt.current = Y);
572
+ }), vt(() => {
855
573
  if (!i) return;
856
- const R = B.bind(P, xe);
857
- let S = 0;
858
- O().revalidateOnFocus && (S = Date.now() + O().focusThrottleInterval);
859
- const g = en(i, c, (M, ie = {}) => {
860
- if (M == it) {
861
- const C = Date.now();
862
- O().revalidateOnFocus && C > S && Z() && (S = C + O().focusThrottleInterval, R());
863
- } else if (M == ct)
864
- O().revalidateOnReconnect && Z() && R();
574
+ const S = Z.bind(A, yt);
575
+ let p = 0;
576
+ h().revalidateOnFocus && (p = Date.now() + h().focusThrottleInterval);
577
+ const v = nn(i, c, (b, z = {}) => {
578
+ if (b == ee) {
579
+ const w = Date.now();
580
+ h().revalidateOnFocus && w > p && $() && (p = w + h().focusThrottleInterval, S());
581
+ } else if (b == ne)
582
+ h().revalidateOnReconnect && $() && S();
865
583
  else {
866
- if (M == ut)
867
- return B();
868
- if (M == Ze)
869
- return B(ie);
584
+ if (b == re)
585
+ return Z();
586
+ if (b == Kt)
587
+ return Z(z);
870
588
  }
871
589
  });
872
- return U.current = !1, b.current = i, ne.current = !0, W({
873
- _k: q
874
- }), se && (E(h) || Ee ? R() : Nt(R)), () => {
875
- U.current = !0, g();
590
+ return j.current = !1, R.current = i, Q.current = !0, H({
591
+ _k: M
592
+ }), jt && (f(q) || tt ? S() : je(S)), () => {
593
+ j.current = !0, v();
876
594
  };
877
595
  }, [
878
596
  i
879
- ]), Ce(() => {
880
- let R;
881
- function S() {
882
- const g = G(A) ? A(N().data) : A;
883
- g && R !== -1 && (R = setTimeout(D, g));
597
+ ]), vt(() => {
598
+ let S;
599
+ function p() {
600
+ const v = N(y) ? y(V().data) : y;
601
+ v && S !== -1 && (S = setTimeout(g, v));
884
602
  }
885
- function D() {
886
- !N().error && (w || O().isVisible()) && (f || O().isOnline()) ? B(xe).then(S) : S();
603
+ function g() {
604
+ !V().error && (O || h().isVisible()) && (u || h().isOnline()) ? Z(yt).then(p) : p();
887
605
  }
888
- return S(), () => {
889
- R && (clearTimeout(R), R = -1);
606
+ return p(), () => {
607
+ S && (clearTimeout(S), S = -1);
890
608
  };
891
609
  }, [
892
- A,
893
- w,
894
- f,
610
+ y,
611
+ O,
612
+ u,
895
613
  i
896
- ]), St(x), a && E(h) && i) {
897
- if (!et && Ee)
614
+ ]), ye(it), s && f(q) && i) {
615
+ if (!Yt && tt)
898
616
  throw new Error("Fallback data is required when using Suspense in SSR.");
899
- j.current = t, z.current = n, U.current = !1;
900
- const R = I[i];
901
- if (!E(R)) {
902
- const S = ve(R);
903
- je(S);
617
+ I.current = e, k.current = n, j.current = !1;
618
+ const S = D[i];
619
+ if (!f(S)) {
620
+ const p = Gt(S);
621
+ gt(p);
904
622
  }
905
- if (E(T)) {
906
- const S = B(xe);
907
- E(x) || (S.status = "fulfilled", S.value = !0), je(S);
623
+ if (f(st)) {
624
+ const p = Z(yt);
625
+ f(it) || (p.status = "fulfilled", p.value = !0), gt(p);
908
626
  } else
909
- throw T;
627
+ throw st;
910
628
  }
911
629
  return {
912
- mutate: ve,
630
+ mutate: Gt,
913
631
  get data() {
914
- return Y.data = !0, x;
632
+ return K.data = !0, it;
915
633
  },
916
634
  get error() {
917
- return Y.error = !0, T;
635
+ return K.error = !0, st;
918
636
  },
919
637
  get isValidating() {
920
- return Y.isValidating = !0, y;
638
+ return K.isValidating = !0, he;
921
639
  },
922
640
  get isLoading() {
923
- return Y.isLoading = !0, Q;
641
+ return K.isLoading = !0, Oe;
924
642
  }
925
643
  };
926
- }, nn = Qt(tn), rn = async (e, t) => {
927
- if (!t)
928
- throw new Error("A Figma API token is required to make this request.");
929
- const n = await fetch(e, {
644
+ }, on = en(rn), ue = "https://api.figma.com", sn = `${ue}/v1/files`, le = `${ue}/v1/variables`, fe = le, de = (t) => `${le}/${t}`, an = (t) => `${sn}/${t}/variables/local`, Ee = "application/json", pe = "X-FIGMA-TOKEN", rt = "A Figma API token is required.", me = "An error occurred while fetching data from the Figma API.", cn = async (t, e) => {
645
+ if (!e)
646
+ throw new Error(rt);
647
+ const n = await fetch(t, {
930
648
  headers: {
931
- "X-FIGMA-TOKEN": t,
932
- "Content-Type": "application/json"
649
+ [pe]: e,
650
+ "Content-Type": Ee
933
651
  }
934
652
  });
935
653
  if (!n.ok) {
936
- const o = await n.json();
937
- throw new Error(
938
- o.message || "An error occurred while fetching data from the Figma API."
939
- );
654
+ const r = await n.json();
655
+ throw new Error(r.message || me);
940
656
  }
941
657
  return n.json();
942
- }, pt = () => {
943
- const { token: e, fileKey: t } = at(), n = t ? `https://api.figma.com/v1/files/${t}/variables/local` : null, { data: o, error: s, isLoading: a, isValidating: u } = nn(
944
- e && n ? [n, e] : null,
945
- rn
658
+ }, _e = () => {
659
+ const { token: t, fileKey: e } = X(), n = e ? an(e) : null, { data: r, error: o, isLoading: s, isValidating: a } = on(
660
+ t && n ? [n, t] : null,
661
+ cn
946
662
  );
947
663
  return {
948
- data: o,
949
- isLoading: a,
950
- isValidating: u,
951
- error: s
664
+ data: r,
665
+ isLoading: s,
666
+ isValidating: a,
667
+ error: o
952
668
  };
953
- }, un = () => {
954
- const { data: e } = pt(), t = Re(
955
- () => e != null && e.meta ? Object.values(e.meta.variableCollections) : [],
956
- [e]
957
- ), n = Re(
958
- () => e != null && e.meta ? e.meta.variableCollections : {},
959
- [e]
669
+ }, pn = () => {
670
+ const { data: t } = _e(), e = ft(
671
+ () => t != null && t.meta ? Object.values(t.meta.variableCollections) : [],
672
+ [t]
673
+ ), n = ft(
674
+ () => t != null && t.meta ? t.meta.variableCollections : {},
675
+ [t]
960
676
  );
961
677
  return {
962
- collections: t,
678
+ collections: e,
963
679
  collectionsById: n
964
680
  };
965
- }, ln = () => {
966
- const { data: e } = pt();
967
- return Re(() => {
968
- const t = [], n = {}, o = {};
969
- if (e != null && e.meta)
970
- for (const s of Object.values(
971
- e.meta.variableCollections
681
+ }, mn = () => {
682
+ const { data: t } = _e();
683
+ return ft(() => {
684
+ const e = [], n = {}, r = {};
685
+ if (t != null && t.meta)
686
+ for (const o of Object.values(
687
+ t.meta.variableCollections
972
688
  )) {
973
- t.push(...s.modes), n[s.id] = s.modes;
974
- for (const a of s.modes)
975
- o[a.modeId] = a;
689
+ e.push(...o.modes), n[o.id] = o.modes;
690
+ for (const s of o.modes)
691
+ r[s.modeId] = s;
976
692
  }
977
693
  return {
978
- modes: t,
694
+ modes: e,
979
695
  modesByCollectionId: n,
980
- modesById: o
696
+ modesById: r
981
697
  };
982
- }, [e]);
983
- }, fn = async (e, t, n) => {
984
- if (!e || !t)
985
- throw new Error("A Figma API token and file key are required.");
986
- const o = `https://api.figma.com/v1/files/${t}/variables`, s = await fetch(o, {
987
- method: "POST",
988
- headers: {
989
- "Content-Type": "application/json",
990
- "X-FIGMA-TOKEN": e
991
- },
992
- body: JSON.stringify(n)
993
- }), a = await s.json();
994
- if (!s.ok)
995
- throw new Error(a.message || "Failed to perform bulk update.");
996
- return a;
997
- }, dn = async (e, t) => {
998
- if (!e)
999
- throw new Error("A Figma API token is required.");
1000
- const n = await fetch("https://api.figma.com/v1/variables", {
1001
- method: "POST",
1002
- headers: {
1003
- "Content-Type": "application/json",
1004
- "X-FIGMA-TOKEN": e
1005
- },
1006
- body: JSON.stringify(t)
1007
- });
1008
- if (!n.ok) {
1009
- const o = await n.json();
1010
- throw new Error(o.message || "Failed to create Figma variable.");
698
+ }, [t]);
699
+ }, _n = () => {
700
+ const { token: t } = X();
701
+ return t;
702
+ };
703
+ function un(t, e) {
704
+ switch (e.type) {
705
+ case "loading":
706
+ return { ...t, status: "loading", error: null };
707
+ case "success":
708
+ return { ...t, status: "success", data: e.payload };
709
+ case "error":
710
+ return { ...t, status: "error", error: e.payload };
711
+ default:
712
+ return t;
1011
713
  }
1012
- return n.json();
1013
- }, mn = async (e, t) => {
714
+ }
715
+ const dt = (t) => {
716
+ const e = {
717
+ status: "idle",
718
+ data: null,
719
+ error: null
720
+ }, [n, r] = Te(un, e);
721
+ return {
722
+ mutate: lt(
723
+ async (s) => {
724
+ r({ type: "loading" });
725
+ try {
726
+ const a = await t(s);
727
+ return r({ type: "success", payload: a }), a;
728
+ } catch (a) {
729
+ r({ type: "error", payload: a });
730
+ return;
731
+ }
732
+ },
733
+ [t]
734
+ ),
735
+ ...n,
736
+ isLoading: n.status === "loading",
737
+ isSuccess: n.status === "success",
738
+ isError: n.status === "error"
739
+ };
740
+ }, Et = async (t, e, n, r) => {
1014
741
  if (!e)
1015
- throw new Error("A Figma API token is required.");
1016
- const n = `https://api.figma.com/v1/variables/${t}`, o = await fetch(n, {
1017
- method: "DELETE",
742
+ throw new Error(rt);
743
+ const o = await fetch(t, {
744
+ method: n,
1018
745
  headers: {
1019
- "Content-Type": "application/json",
1020
- "X-FIGMA-TOKEN": e
1021
- }
746
+ [pe]: e,
747
+ "Content-Type": Ee
748
+ },
749
+ ...r && { body: JSON.stringify(r) }
1022
750
  });
1023
751
  if (!o.ok) {
1024
752
  const s = await o.json();
1025
- throw new Error(s.message || "Failed to delete Figma variable.");
753
+ throw new Error(s.message || me);
1026
754
  }
1027
- }, En = async (e, t, n) => {
1028
- if (!e)
1029
- throw new Error("A Figma API token is required.");
1030
- const o = `https://api.figma.com/v1/variables/${t}`, s = await fetch(o, {
1031
- method: "PUT",
1032
- headers: {
1033
- "Content-Type": "application/json",
1034
- "X-FIGMA-TOKEN": e
1035
- },
1036
- body: JSON.stringify(n)
755
+ return o.status === 204 ? Promise.resolve(void 0) : o.json();
756
+ }, Sn = () => {
757
+ const { token: t } = X();
758
+ if (!t)
759
+ throw new Error(rt);
760
+ return dt(async (n) => await Et(
761
+ fe,
762
+ t,
763
+ "POST",
764
+ n
765
+ ));
766
+ }, hn = () => {
767
+ const { token: t } = X();
768
+ if (!t)
769
+ throw new Error(rt);
770
+ return dt(async (n) => await Et(
771
+ de(n),
772
+ t,
773
+ "DELETE"
774
+ ));
775
+ }, On = () => {
776
+ const { token: t } = X();
777
+ return dt(
778
+ async ({ variableId: n, payload: r }) => {
779
+ if (!t)
780
+ throw new Error("A Figma API token is required.");
781
+ const o = de(n);
782
+ return await Et(
783
+ o,
784
+ t,
785
+ "PUT",
786
+ r
787
+ );
788
+ }
789
+ );
790
+ }, vn = () => {
791
+ const { token: t } = X();
792
+ return dt(async (n) => {
793
+ if (!t)
794
+ throw new Error(rt);
795
+ return await Et(
796
+ fe,
797
+ t,
798
+ "PUT",
799
+ n
800
+ );
1037
801
  });
1038
- if (!s.ok) {
1039
- const a = await s.json();
1040
- throw new Error(a.message || "Failed to update Figma variable.");
1041
- }
1042
802
  };
1043
- function pn(e, t) {
1044
- return e.filter((n) => {
1045
- let o = !0;
1046
- return t.resolvedType && (o = o && n.resolvedType === t.resolvedType), t.name && (o = o && n.name.includes(t.name)), o;
803
+ function wn(t, e) {
804
+ return t.filter((n) => {
805
+ let r = !0;
806
+ return e.resolvedType && (r = r && n.resolvedType === e.resolvedType), e.name && (r = r && n.name.includes(e.name)), r;
1047
807
  });
1048
808
  }
1049
809
  export {
1050
- an as FigmaVarsProvider,
1051
- fn as bulkUpdateVariables,
1052
- dn as createVariable,
1053
- mn as deleteVariable,
1054
- pn as filterVariables,
1055
- En as updateVariable,
1056
- cn as useFigmaToken,
1057
- un as useVariableCollections,
1058
- ln as useVariableModes,
1059
- pt as useVariables
810
+ En as FigmaVarsProvider,
811
+ wn as filterVariables,
812
+ vn as useBulkUpdateVariables,
813
+ Sn as useCreateVariable,
814
+ hn as useDeleteVariable,
815
+ _n as useFigmaToken,
816
+ On as useUpdateVariable,
817
+ pn as useVariableCollections,
818
+ mn as useVariableModes,
819
+ _e as useVariables
1060
820
  };