use-abcd 1.4.3 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +225 -406
  2. package/dist/chunks/client-lHRDCo64.js +30 -0
  3. package/dist/chunks/client-lHRDCo64.js.map +1 -0
  4. package/dist/chunks/utils-DL5mgkvm.js +828 -0
  5. package/dist/chunks/utils-DL5mgkvm.js.map +1 -0
  6. package/dist/collection.d.ts +13 -5
  7. package/dist/examples/Benchmark.d.ts +2 -0
  8. package/dist/examples/LocalNotes.d.ts +2 -0
  9. package/dist/index.d.ts +5 -4
  10. package/dist/index.js +1071 -1789
  11. package/dist/index.js.map +1 -1
  12. package/dist/item.d.ts +3 -2
  13. package/dist/mocks/handlers.d.ts +0 -1
  14. package/dist/node.d.ts +5 -1
  15. package/dist/runtime/client.d.ts +10 -48
  16. package/dist/runtime/client.js +5 -13
  17. package/dist/runtime/client.js.map +1 -1
  18. package/dist/runtime/index.d.ts +5 -5
  19. package/dist/runtime/local.d.ts +32 -0
  20. package/dist/runtime/server.d.ts +25 -35
  21. package/dist/runtime/server.js +59 -108
  22. package/dist/runtime/server.js.map +1 -1
  23. package/dist/runtime/types.d.ts +28 -63
  24. package/dist/sync-queue.d.ts +7 -44
  25. package/dist/types.d.ts +22 -18
  26. package/dist/useCrud.d.ts +5 -3
  27. package/dist/useCrudTree.d.ts +3 -3
  28. package/dist/useItem.d.ts +3 -1
  29. package/dist/useNode.d.ts +3 -0
  30. package/dist/useSyncState.d.ts +2 -2
  31. package/dist/utils.d.ts +3 -4
  32. package/package.json +4 -2
  33. package/dist/cache.test.d.ts +0 -1
  34. package/dist/chunks/client-BfugfaiH.js +0 -144
  35. package/dist/chunks/client-BfugfaiH.js.map +0 -1
  36. package/dist/chunks/types-Dy4rYb2N.js +0 -19
  37. package/dist/chunks/types-Dy4rYb2N.js.map +0 -1
  38. package/dist/collection.e2e.test.d.ts +0 -1
  39. package/dist/fetch-handler.test.d.ts +0 -1
  40. package/dist/item-cache.test.d.ts +0 -1
  41. package/dist/node.test.d.ts +0 -1
  42. package/dist/runtime/client.test.d.ts +0 -1
  43. package/dist/runtime/server.test.d.ts +0 -1
  44. package/dist/sync-queue.test.d.ts +0 -1
  45. package/dist/useCrud.test.d.ts +0 -1
  46. package/dist/useCrudTree.test.d.ts +0 -1
  47. /package/dist/{App.d.ts → examples/App.d.ts} +0 -0
  48. /package/dist/{main.d.ts → examples/main.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,146 +1,147 @@
1
- import { useSyncExternalStore as j, useCallback as T, useRef as Nn, useMemo as Dn } from "react";
2
- import { c as Ga } from "./chunks/types-Dy4rYb2N.js";
3
- import { c as Wa, b as Va, a as Ja, f as Ya, d as Xa, s as Za } from "./chunks/client-BfugfaiH.js";
4
- const v = {
1
+ import { useMemo as le, useSyncExternalStore as v, useCallback as S } from "react";
2
+ import { a as oe, b as G, c as bt, d as fe, e as Je, f as he, h as Ye, S as ze, i as W, j as Ge, k as mt, l as Xe, n as gt, o as V, p as St, q as wt, r as vt, s as Mt, t as Ct, u as Ze, v as xt, w as ke, x as Ot, y as Pt, z as Rt, A as de, B as Et, C as It, D as Nt, E as zt, F as z, m as K, g as be } from "./chunks/utils-DL5mgkvm.js";
3
+ import { H as Ds, G as Ts } from "./chunks/utils-DL5mgkvm.js";
4
+ import { c as Qs } from "./chunks/client-lHRDCo64.js";
5
+ const b = {
5
6
  Remove: "remove",
6
7
  Replace: "replace",
7
8
  Add: "add"
8
- }, en = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Hn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), ve = Symbol.iterator, E = {
9
+ }, et = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), At = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), ee = Symbol.iterator, x = {
9
10
  mutable: "mutable",
10
11
  immutable: "immutable"
11
- }, tt = {};
12
- function he(e, t) {
12
+ }, xe = {};
13
+ function Y(e, t) {
13
14
  return e instanceof Map ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
14
15
  }
15
- function yt(e, t) {
16
+ function Ae(e, t) {
16
17
  if (t in e) {
17
18
  let n = Reflect.getPrototypeOf(e);
18
19
  for (; n; ) {
19
- const r = Reflect.getOwnPropertyDescriptor(n, t);
20
- if (r)
21
- return r;
20
+ const s = Reflect.getOwnPropertyDescriptor(n, t);
21
+ if (s)
22
+ return s;
22
23
  n = Reflect.getPrototypeOf(n);
23
24
  }
24
25
  }
25
26
  }
26
- function nt(e) {
27
+ function Oe(e) {
27
28
  return Object.getPrototypeOf(e) === Set.prototype;
28
29
  }
29
- function rt(e) {
30
+ function Pe(e) {
30
31
  return Object.getPrototypeOf(e) === Map.prototype;
31
32
  }
32
- function P(e) {
33
+ function C(e) {
33
34
  var t;
34
35
  return (t = e.copy) !== null && t !== void 0 ? t : e.original;
35
36
  }
36
- function K(e) {
37
- return !!d(e);
37
+ function T(e) {
38
+ return !!h(e);
38
39
  }
39
- function d(e) {
40
- return typeof e != "object" ? null : e?.[en];
40
+ function h(e) {
41
+ return typeof e != "object" ? null : e?.[et];
41
42
  }
42
- function it(e) {
43
+ function Re(e) {
43
44
  var t;
44
- const n = d(e);
45
+ const n = h(e);
45
46
  return n ? (t = n.copy) !== null && t !== void 0 ? t : n.original : e;
46
47
  }
47
- function $(e, t) {
48
+ function R(e, t) {
48
49
  if (!e || typeof e != "object")
49
50
  return !1;
50
51
  let n;
51
- return Object.getPrototypeOf(e) === Object.prototype || Array.isArray(e) || e instanceof Map || e instanceof Set || !!t?.mark && ((n = t.mark(e, E)) === E.immutable || typeof n == "function");
52
+ return Object.getPrototypeOf(e) === Object.prototype || Array.isArray(e) || e instanceof Map || e instanceof Set || !!t?.mark && ((n = t.mark(e, x)) === x.immutable || typeof n == "function");
52
53
  }
53
- function tn(e, t = []) {
54
+ function tt(e, t = []) {
54
55
  if (Object.hasOwnProperty.call(e, "key")) {
55
- const n = e.parent.copy, r = d(q(n, e.key));
56
- if (r !== null && r?.original !== e.original)
56
+ const n = e.parent.copy, s = h(F(n, e.key));
57
+ if (s !== null && s?.original !== e.original)
57
58
  return null;
58
- const i = e.parent.type === 3, s = i ? Array.from(e.parent.setMap.keys()).indexOf(e.key) : e.key;
59
- if (!(i && n.size > s || he(n, s)))
59
+ const i = e.parent.type === 3, r = i ? Array.from(e.parent.setMap.keys()).indexOf(e.key) : e.key;
60
+ if (!(i && n.size > r || Y(n, r)))
60
61
  return null;
61
- t.push(s);
62
+ t.push(r);
62
63
  }
63
64
  if (e.parent)
64
- return tn(e.parent, t);
65
+ return tt(e.parent, t);
65
66
  t.reverse();
66
67
  try {
67
- Ln(e.copy, t);
68
+ Ft(e.copy, t);
68
69
  } catch {
69
70
  return null;
70
71
  }
71
72
  return t;
72
73
  }
73
- function ee(e) {
74
+ function Q(e) {
74
75
  return Array.isArray(e) ? 1 : e instanceof Map ? 2 : e instanceof Set ? 3 : 0;
75
76
  }
76
- function q(e, t) {
77
- return ee(e) === 2 ? e.get(t) : e[t];
77
+ function F(e, t) {
78
+ return Q(e) === 2 ? e.get(t) : e[t];
78
79
  }
79
- function be(e, t, n) {
80
- ee(e) === 2 ? e.set(t, n) : e[t] = n;
80
+ function Z(e, t, n) {
81
+ Q(e) === 2 ? e.set(t, n) : e[t] = n;
81
82
  }
82
- function Ne(e, t) {
83
- const n = d(e);
84
- return (n ? P(n) : e)[t];
83
+ function pe(e, t) {
84
+ const n = h(e);
85
+ return (n ? C(n) : e)[t];
85
86
  }
86
- function H(e, t) {
87
+ function A(e, t) {
87
88
  return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
88
89
  }
89
- function Be(e) {
90
+ function me(e) {
90
91
  if (e)
91
92
  for (; e.finalities.revoke.length > 0; )
92
93
  e.finalities.revoke.pop()();
93
94
  }
94
- function J(e, t) {
95
+ function q(e, t) {
95
96
  return t ? e : [""].concat(e).map((n) => {
96
- const r = `${n}`;
97
- return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
97
+ const s = `${n}`;
98
+ return s.indexOf("/") === -1 && s.indexOf("~") === -1 ? s : s.replace(/~/g, "~0").replace(/\//g, "~1");
98
99
  }).join("/");
99
100
  }
100
- function Ln(e, t) {
101
+ function Ft(e, t) {
101
102
  for (let n = 0; n < t.length - 1; n += 1) {
102
- const r = t[n];
103
- if (e = q(ee(e) === 3 ? Array.from(e) : e, r), typeof e != "object")
103
+ const s = t[n];
104
+ if (e = F(Q(e) === 3 ? Array.from(e) : e, s), typeof e != "object")
104
105
  throw new Error(`Cannot resolve patch at '${t.join("/")}'.`);
105
106
  }
106
107
  return e;
107
108
  }
108
- function qn(e) {
109
+ function jt(e) {
109
110
  const t = Object.create(Object.getPrototypeOf(e));
110
111
  return Reflect.ownKeys(e).forEach((n) => {
111
- let r = Reflect.getOwnPropertyDescriptor(e, n);
112
- if (r.enumerable && r.configurable && r.writable) {
112
+ let s = Reflect.getOwnPropertyDescriptor(e, n);
113
+ if (s.enumerable && s.configurable && s.writable) {
113
114
  t[n] = e[n];
114
115
  return;
115
116
  }
116
- r.writable || (r.writable = !0, r.configurable = !0), (r.get || r.set) && (r = {
117
+ s.writable || (s.writable = !0, s.configurable = !0), (s.get || s.set) && (s = {
117
118
  configurable: !0,
118
119
  writable: !0,
119
- enumerable: r.enumerable,
120
+ enumerable: s.enumerable,
120
121
  value: e[n]
121
- }), Reflect.defineProperty(t, n, r);
122
+ }), Reflect.defineProperty(t, n, s);
122
123
  }), t;
123
124
  }
124
- const Qn = Object.prototype.propertyIsEnumerable;
125
- function nn(e, t) {
125
+ const Dt = Object.prototype.propertyIsEnumerable;
126
+ function nt(e, t) {
126
127
  let n;
127
128
  if (Array.isArray(e))
128
129
  return Array.prototype.concat.call(e);
129
130
  if (e instanceof Set) {
130
- if (!nt(e)) {
131
- const r = Object.getPrototypeOf(e).constructor;
132
- return new r(e.values());
131
+ if (!Oe(e)) {
132
+ const s = Object.getPrototypeOf(e).constructor;
133
+ return new s(e.values());
133
134
  }
134
135
  return Set.prototype.difference ? Set.prototype.difference.call(e, /* @__PURE__ */ new Set()) : new Set(e.values());
135
136
  } else if (e instanceof Map) {
136
- if (!rt(e)) {
137
- const r = Object.getPrototypeOf(e).constructor;
138
- return new r(e);
137
+ if (!Pe(e)) {
138
+ const s = Object.getPrototypeOf(e).constructor;
139
+ return new s(e);
139
140
  }
140
141
  return new Map(e);
141
- } else if (t?.mark && (n = t.mark(e, E), n !== void 0) && n !== E.mutable) {
142
- if (n === E.immutable)
143
- return qn(e);
142
+ } else if (t?.mark && (n = t.mark(e, x), n !== void 0) && n !== x.mutable) {
143
+ if (n === x.immutable)
144
+ return jt(e);
144
145
  if (typeof n == "function") {
145
146
  if (t.enablePatches || t.enableAutoFreeze)
146
147
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -148,323 +149,323 @@ function nn(e, t) {
148
149
  }
149
150
  throw new Error(`Unsupported mark result: ${n}`);
150
151
  } else if (typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype) {
151
- const r = {};
152
+ const s = {};
152
153
  return Object.keys(e).forEach((i) => {
153
- r[i] = e[i];
154
+ s[i] = e[i];
154
155
  }), Object.getOwnPropertySymbols(e).forEach((i) => {
155
- Qn.call(e, i) && (r[i] = e[i]);
156
- }), r;
156
+ Dt.call(e, i) && (s[i] = e[i]);
157
+ }), s;
157
158
  } else
158
159
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
159
160
  }
160
- function x(e) {
161
- e.copy || (e.copy = nn(e.original, e.options));
161
+ function w(e) {
162
+ e.copy || (e.copy = nt(e.original, e.options));
162
163
  }
163
- function le(e) {
164
- if (!$(e))
165
- return it(e);
164
+ function J(e) {
165
+ if (!R(e))
166
+ return Re(e);
166
167
  if (Array.isArray(e))
167
- return e.map(le);
168
+ return e.map(J);
168
169
  if (e instanceof Map) {
169
- const n = Array.from(e.entries()).map(([r, i]) => [
170
- r,
171
- le(i)
170
+ const n = Array.from(e.entries()).map(([s, i]) => [
171
+ s,
172
+ J(i)
172
173
  ]);
173
- if (!rt(e)) {
174
- const r = Object.getPrototypeOf(e).constructor;
175
- return new r(n);
174
+ if (!Pe(e)) {
175
+ const s = Object.getPrototypeOf(e).constructor;
176
+ return new s(n);
176
177
  }
177
178
  return new Map(n);
178
179
  }
179
180
  if (e instanceof Set) {
180
- const n = Array.from(e).map(le);
181
- if (!nt(e)) {
182
- const r = Object.getPrototypeOf(e).constructor;
183
- return new r(n);
181
+ const n = Array.from(e).map(J);
182
+ if (!Oe(e)) {
183
+ const s = Object.getPrototypeOf(e).constructor;
184
+ return new s(n);
184
185
  }
185
186
  return new Set(n);
186
187
  }
187
188
  const t = Object.create(Object.getPrototypeOf(e));
188
189
  for (const n in e)
189
- t[n] = le(e[n]);
190
+ t[n] = J(e[n]);
190
191
  return t;
191
192
  }
192
- function we(e) {
193
- return K(e) ? le(e) : e;
193
+ function te(e) {
194
+ return T(e) ? J(e) : e;
194
195
  }
195
- function z(e) {
196
+ function E(e) {
196
197
  var t;
197
- e.assignedMap = (t = e.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), e.operated || (e.operated = !0, e.parent && z(e.parent));
198
+ e.assignedMap = (t = e.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), e.operated || (e.operated = !0, e.parent && E(e.parent));
198
199
  }
199
- function gt() {
200
+ function Fe() {
200
201
  throw new Error("Cannot modify frozen object");
201
202
  }
202
- function se(e, t, n, r, i) {
203
+ function B(e, t, n, s, i) {
203
204
  {
204
- n = n ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], i = i ?? [];
205
+ n = n ?? /* @__PURE__ */ new WeakMap(), s = s ?? [], i = i ?? [];
205
206
  const o = n.has(e) ? n.get(e) : e;
206
- if (r.length > 0) {
207
- const a = r.indexOf(o);
208
- if (o && typeof o == "object" && a !== -1)
209
- throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, a).map((c, u) => {
210
- if (typeof c == "symbol")
211
- return `[${c.toString()}]`;
212
- const l = r[u];
213
- return typeof c == "object" && (l instanceof Map || l instanceof Set) ? Array.from(l.keys()).indexOf(c) : c;
207
+ if (s.length > 0) {
208
+ const c = s.indexOf(o);
209
+ if (o && typeof o == "object" && c !== -1)
210
+ throw s[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, c).map((a, u) => {
211
+ if (typeof a == "symbol")
212
+ return `[${a.toString()}]`;
213
+ const l = s[u];
214
+ return typeof a == "object" && (l instanceof Map || l instanceof Set) ? Array.from(l.keys()).indexOf(a) : a;
214
215
  }).join("/")}`);
215
- r.push(o), i.push(t);
216
+ s.push(o), i.push(t);
216
217
  } else
217
- r.push(o);
218
+ s.push(o);
218
219
  }
219
- if (Object.isFrozen(e) || K(e)) {
220
- r.pop(), i.pop();
220
+ if (Object.isFrozen(e) || T(e)) {
221
+ s.pop(), i.pop();
221
222
  return;
222
223
  }
223
- switch (ee(e)) {
224
+ switch (Q(e)) {
224
225
  case 2:
225
- for (const [a, c] of e)
226
- se(a, a, n, r, i), se(c, a, n, r, i);
227
- e.set = e.clear = e.delete = gt;
226
+ for (const [c, a] of e)
227
+ B(c, c, n, s, i), B(a, c, n, s, i);
228
+ e.set = e.clear = e.delete = Fe;
228
229
  break;
229
230
  case 3:
230
- for (const a of e)
231
- se(a, a, n, r, i);
232
- e.add = e.clear = e.delete = gt;
231
+ for (const c of e)
232
+ B(c, c, n, s, i);
233
+ e.add = e.clear = e.delete = Fe;
233
234
  break;
234
235
  case 1:
235
236
  Object.freeze(e);
236
237
  let o = 0;
237
- for (const a of e)
238
- se(a, o, n, r, i), o += 1;
238
+ for (const c of e)
239
+ B(c, o, n, s, i), o += 1;
239
240
  break;
240
241
  default:
241
- Object.freeze(e), Object.keys(e).forEach((a) => {
242
- const c = e[a];
243
- se(c, a, n, r, i);
242
+ Object.freeze(e), Object.keys(e).forEach((c) => {
243
+ const a = e[c];
244
+ B(a, c, n, s, i);
244
245
  });
245
246
  }
246
- r.pop(), i.pop();
247
+ s.pop(), i.pop();
247
248
  }
248
- function st(e, t) {
249
- const n = ee(e);
249
+ function Ee(e, t) {
250
+ const n = Q(e);
250
251
  if (n === 0)
251
- Reflect.ownKeys(e).forEach((r) => {
252
- t(r, e[r], e);
252
+ Reflect.ownKeys(e).forEach((s) => {
253
+ t(s, e[s], e);
253
254
  });
254
255
  else if (n === 1) {
255
- let r = 0;
256
+ let s = 0;
256
257
  for (const i of e)
257
- t(r, i, e), r += 1;
258
+ t(s, i, e), s += 1;
258
259
  } else
259
- e.forEach((r, i) => t(i, r, e));
260
+ e.forEach((s, i) => t(i, s, e));
260
261
  }
261
- function rn(e, t, n) {
262
- if (K(e) || !$(e, n) || t.has(e) || Object.isFrozen(e))
262
+ function st(e, t, n) {
263
+ if (T(e) || !R(e, n) || t.has(e) || Object.isFrozen(e))
263
264
  return;
264
- const r = e instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
265
- if (t.add(e), st(e, (s, o) => {
266
- var a;
267
- if (K(o)) {
268
- const c = d(o);
269
- x(c);
270
- const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
271
- be(r ? i : e, s, u);
265
+ const s = e instanceof Set, i = s ? /* @__PURE__ */ new Map() : void 0;
266
+ if (t.add(e), Ee(e, (r, o) => {
267
+ var c;
268
+ if (T(o)) {
269
+ const a = h(o);
270
+ w(a);
271
+ const u = !((c = a.assignedMap) === null || c === void 0) && c.size || a.operated ? a.copy : a.original;
272
+ Z(s ? i : e, r, u);
272
273
  } else
273
- rn(o, t, n);
274
+ st(o, t, n);
274
275
  }), i) {
275
- const s = e, o = Array.from(s);
276
- s.clear(), o.forEach((a) => {
277
- s.add(i.has(a) ? i.get(a) : a);
276
+ const r = e, o = Array.from(r);
277
+ r.clear(), o.forEach((c) => {
278
+ r.add(i.has(c) ? i.get(c) : c);
278
279
  });
279
280
  }
280
281
  }
281
- function Bn(e, t) {
282
+ function Tt(e, t) {
282
283
  const n = e.type === 3 ? e.setMap : e.copy;
283
- e.finalities.revoke.length > 1 && e.assignedMap.get(t) && n && rn(q(n, t), e.finalities.handledSet, e.options);
284
+ e.finalities.revoke.length > 1 && e.assignedMap.get(t) && n && st(F(n, t), e.finalities.handledSet, e.options);
284
285
  }
285
- function Ue(e) {
286
+ function ge(e) {
286
287
  e.type === 3 && e.copy && (e.copy.clear(), e.setMap.forEach((t) => {
287
- e.copy.add(it(t));
288
+ e.copy.add(Re(t));
288
289
  }));
289
290
  }
290
- function Ge(e, t, n, r) {
291
+ function Se(e, t, n, s) {
291
292
  if (e.operated && e.assignedMap && e.assignedMap.size > 0 && !e.finalized) {
292
- if (n && r) {
293
- const s = tn(e);
294
- s && t(e, s, n, r);
293
+ if (n && s) {
294
+ const r = tt(e);
295
+ r && t(e, r, n, s);
295
296
  }
296
297
  e.finalized = !0;
297
298
  }
298
299
  }
299
- function ot(e, t, n, r) {
300
- const i = d(n);
301
- i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
302
- var a;
303
- const c = e.type === 3 ? e.setMap : e.copy;
304
- if (H(q(c, t), n)) {
300
+ function Ie(e, t, n, s) {
301
+ const i = h(n);
302
+ i && (i.callbacks || (i.callbacks = []), i.callbacks.push((r, o) => {
303
+ var c;
304
+ const a = e.type === 3 ? e.setMap : e.copy;
305
+ if (A(F(a, t), n)) {
305
306
  let u = i.original;
306
- i.copy && (u = i.copy), Ue(e), Ge(e, r, s, o), e.options.enableAutoFreeze && (e.options.updatedValues = (a = e.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), e.options.updatedValues.set(u, i.original)), be(c, t, u);
307
+ i.copy && (u = i.copy), ge(e), Se(e, s, r, o), e.options.enableAutoFreeze && (e.options.updatedValues = (c = e.options.updatedValues) !== null && c !== void 0 ? c : /* @__PURE__ */ new WeakMap(), e.options.updatedValues.set(u, i.original)), Z(a, t, u);
307
308
  }
308
- }), e.options.enableAutoFreeze && i.finalities !== e.finalities && (e.options.enableAutoFreeze = !1)), $(n, e.options) && e.finalities.draft.push(() => {
309
- const s = e.type === 3 ? e.setMap : e.copy;
310
- H(q(s, t), n) && Bn(e, t);
309
+ }), e.options.enableAutoFreeze && i.finalities !== e.finalities && (e.options.enableAutoFreeze = !1)), R(n, e.options) && e.finalities.draft.push(() => {
310
+ const r = e.type === 3 ? e.setMap : e.copy;
311
+ A(F(r, t), n) && Tt(e, t);
311
312
  });
312
313
  }
313
- function Un(e, t, n, r, i) {
314
- let { original: s, assignedMap: o, options: a } = e, c = e.copy;
315
- c.length < s.length && ([s, c] = [c, s], [n, r] = [r, n]);
316
- for (let u = 0; u < s.length; u += 1)
317
- if (o.get(u.toString()) && c[u] !== s[u]) {
318
- const l = t.concat([u]), f = J(l, i);
314
+ function qt(e, t, n, s, i) {
315
+ let { original: r, assignedMap: o, options: c } = e, a = e.copy;
316
+ a.length < r.length && ([r, a] = [a, r], [n, s] = [s, n]);
317
+ for (let u = 0; u < r.length; u += 1)
318
+ if (o.get(u.toString()) && a[u] !== r[u]) {
319
+ const l = t.concat([u]), f = q(l, i);
319
320
  n.push({
320
- op: v.Replace,
321
+ op: b.Replace,
321
322
  path: f,
322
323
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
323
- value: we(c[u])
324
- }), r.push({
325
- op: v.Replace,
324
+ value: te(a[u])
325
+ }), s.push({
326
+ op: b.Replace,
326
327
  path: f,
327
328
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
328
- value: we(s[u])
329
+ value: te(r[u])
329
330
  });
330
331
  }
331
- for (let u = s.length; u < c.length; u += 1) {
332
- const l = t.concat([u]), f = J(l, i);
332
+ for (let u = r.length; u < a.length; u += 1) {
333
+ const l = t.concat([u]), f = q(l, i);
333
334
  n.push({
334
- op: v.Add,
335
+ op: b.Add,
335
336
  path: f,
336
337
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
337
- value: we(c[u])
338
+ value: te(a[u])
338
339
  });
339
340
  }
340
- if (s.length < c.length) {
341
- const { arrayLengthAssignment: u = !0 } = a.enablePatches;
341
+ if (r.length < a.length) {
342
+ const { arrayLengthAssignment: u = !0 } = c.enablePatches;
342
343
  if (u) {
343
- const l = t.concat(["length"]), f = J(l, i);
344
- r.push({
345
- op: v.Replace,
344
+ const l = t.concat(["length"]), f = q(l, i);
345
+ s.push({
346
+ op: b.Replace,
346
347
  path: f,
347
- value: s.length
348
+ value: r.length
348
349
  });
349
350
  } else
350
- for (let l = c.length; s.length < l; l -= 1) {
351
- const f = t.concat([l - 1]), h = J(f, i);
352
- r.push({
353
- op: v.Remove,
354
- path: h
351
+ for (let l = a.length; r.length < l; l -= 1) {
352
+ const f = t.concat([l - 1]), y = q(f, i);
353
+ s.push({
354
+ op: b.Remove,
355
+ path: y
355
356
  });
356
357
  }
357
358
  }
358
359
  }
359
- function Gn({ original: e, copy: t, assignedMap: n }, r, i, s, o) {
360
- n.forEach((a, c) => {
361
- const u = q(e, c), l = we(q(t, c)), f = a ? he(e, c) ? v.Replace : v.Add : v.Remove;
362
- if (H(u, l) && f === v.Replace)
360
+ function Qt({ original: e, copy: t, assignedMap: n }, s, i, r, o) {
361
+ n.forEach((c, a) => {
362
+ const u = F(e, a), l = te(F(t, a)), f = c ? Y(e, a) ? b.Replace : b.Add : b.Remove;
363
+ if (A(u, l) && f === b.Replace)
363
364
  return;
364
- const h = r.concat(c), p = J(h, o);
365
- i.push(f === v.Remove ? { op: f, path: p } : { op: f, path: p, value: l }), s.push(f === v.Add ? { op: v.Remove, path: p } : f === v.Remove ? { op: v.Add, path: p, value: u } : { op: v.Replace, path: p, value: u });
365
+ const y = s.concat(a), p = q(y, o);
366
+ i.push(f === b.Remove ? { op: f, path: p } : { op: f, path: p, value: l }), r.push(f === b.Add ? { op: b.Remove, path: p } : f === b.Remove ? { op: b.Add, path: p, value: u } : { op: b.Replace, path: p, value: u });
366
367
  });
367
368
  }
368
- function Kn({ original: e, copy: t }, n, r, i, s) {
369
+ function $t({ original: e, copy: t }, n, s, i, r) {
369
370
  let o = 0;
370
- e.forEach((a) => {
371
- if (!t.has(a)) {
372
- const c = n.concat([o]), u = J(c, s);
373
- r.push({
374
- op: v.Remove,
371
+ e.forEach((c) => {
372
+ if (!t.has(c)) {
373
+ const a = n.concat([o]), u = q(a, r);
374
+ s.push({
375
+ op: b.Remove,
375
376
  path: u,
376
- value: a
377
+ value: c
377
378
  }), i.unshift({
378
- op: v.Add,
379
+ op: b.Add,
379
380
  path: u,
380
- value: a
381
+ value: c
381
382
  });
382
383
  }
383
384
  o += 1;
384
- }), o = 0, t.forEach((a) => {
385
- if (!e.has(a)) {
386
- const c = n.concat([o]), u = J(c, s);
387
- r.push({
388
- op: v.Add,
385
+ }), o = 0, t.forEach((c) => {
386
+ if (!e.has(c)) {
387
+ const a = n.concat([o]), u = q(a, r);
388
+ s.push({
389
+ op: b.Add,
389
390
  path: u,
390
- value: a
391
+ value: c
391
392
  }), i.unshift({
392
- op: v.Remove,
393
+ op: b.Remove,
393
394
  path: u,
394
- value: a
395
+ value: c
395
396
  });
396
397
  }
397
398
  o += 1;
398
399
  });
399
400
  }
400
- function _e(e, t, n, r) {
401
+ function X(e, t, n, s) {
401
402
  const { pathAsArray: i = !0 } = e.options.enablePatches;
402
403
  switch (e.type) {
403
404
  case 0:
404
405
  case 2:
405
- return Gn(e, t, n, r, i);
406
+ return Qt(e, t, n, s, i);
406
407
  case 1:
407
- return Un(e, t, n, r, i);
408
+ return qt(e, t, n, s, i);
408
409
  case 3:
409
- return Kn(e, t, n, r, i);
410
+ return $t(e, t, n, s, i);
410
411
  }
411
412
  }
412
- const xe = (e, t, n = !1) => {
413
- if (typeof e == "object" && e !== null && (!$(e, t) || n))
413
+ const ce = (e, t, n = !1) => {
414
+ if (typeof e == "object" && e !== null && (!R(e, t) || n))
414
415
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
415
- }, Ke = {
416
+ }, we = {
416
417
  get size() {
417
- return P(d(this)).size;
418
+ return C(h(this)).size;
418
419
  },
419
420
  has(e) {
420
- return P(d(this)).has(e);
421
+ return C(h(this)).has(e);
421
422
  },
422
423
  set(e, t) {
423
- const n = d(this), r = P(n);
424
- return (!r.has(e) || !H(r.get(e), t)) && (x(n), z(n), n.assignedMap.set(e, !0), n.copy.set(e, t), ot(n, e, t, _e)), this;
424
+ const n = h(this), s = C(n);
425
+ return (!s.has(e) || !A(s.get(e), t)) && (w(n), E(n), n.assignedMap.set(e, !0), n.copy.set(e, t), Ie(n, e, t, X)), this;
425
426
  },
426
427
  delete(e) {
427
428
  if (!this.has(e))
428
429
  return !1;
429
- const t = d(this);
430
- return x(t), z(t), t.original.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.copy.delete(e), !0;
430
+ const t = h(this);
431
+ return w(t), E(t), t.original.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.copy.delete(e), !0;
431
432
  },
432
433
  clear() {
433
- const e = d(this);
434
+ const e = h(this);
434
435
  if (this.size) {
435
- x(e), z(e), e.assignedMap = /* @__PURE__ */ new Map();
436
+ w(e), E(e), e.assignedMap = /* @__PURE__ */ new Map();
436
437
  for (const [t] of e.original)
437
438
  e.assignedMap.set(t, !1);
438
439
  e.copy.clear();
439
440
  }
440
441
  },
441
442
  forEach(e, t) {
442
- const n = d(this);
443
- P(n).forEach((r, i) => {
443
+ const n = h(this);
444
+ C(n).forEach((s, i) => {
444
445
  e.call(t, this.get(i), i, this);
445
446
  });
446
447
  },
447
448
  get(e) {
448
449
  var t, n;
449
- const r = d(this), i = P(r).get(e), s = ((n = (t = r.options).mark) === null || n === void 0 ? void 0 : n.call(t, i, E)) === E.mutable;
450
- if (r.options.strict && xe(i, r.options, s), s || r.finalized || !$(i, r.options) || i !== r.original.get(e))
450
+ const s = h(this), i = C(s).get(e), r = ((n = (t = s.options).mark) === null || n === void 0 ? void 0 : n.call(t, i, x)) === x.mutable;
451
+ if (s.options.strict && ce(i, s.options, r), r || s.finalized || !R(i, s.options) || i !== s.original.get(e))
451
452
  return i;
452
- const o = tt.createDraft({
453
+ const o = xe.createDraft({
453
454
  original: i,
454
- parentDraft: r,
455
+ parentDraft: s,
455
456
  key: e,
456
- finalities: r.finalities,
457
- options: r.options
457
+ finalities: s.finalities,
458
+ options: s.options
458
459
  });
459
- return x(r), r.copy.set(e, o), o;
460
+ return w(s), s.copy.set(e, o), o;
460
461
  },
461
462
  keys() {
462
- return P(d(this)).keys();
463
+ return C(h(this)).keys();
463
464
  },
464
465
  values() {
465
466
  const e = this.keys();
466
467
  return {
467
- [ve]: () => this.values(),
468
+ [ee]: () => this.values(),
468
469
  next: () => {
469
470
  const t = e.next();
470
471
  return t.done ? t : {
@@ -477,7 +478,7 @@ const xe = (e, t, n = !1) => {
477
478
  entries() {
478
479
  const e = this.keys();
479
480
  return {
480
- [ve]: () => this.entries(),
481
+ [ee]: () => this.entries(),
481
482
  next: () => {
482
483
  const t = e.next();
483
484
  if (t.done)
@@ -490,80 +491,80 @@ const xe = (e, t, n = !1) => {
490
491
  }
491
492
  };
492
493
  },
493
- [ve]() {
494
+ [ee]() {
494
495
  return this.entries();
495
496
  }
496
- }, Wn = Reflect.ownKeys(Ke), bt = (e, t, { isValuesIterator: n }) => () => {
497
- var r, i;
498
- const s = t.next();
499
- if (s.done)
500
- return s;
501
- const o = s.value;
502
- let a = e.setMap.get(o);
503
- const c = d(a), u = ((i = (r = e.options).mark) === null || i === void 0 ? void 0 : i.call(r, a, E)) === E.mutable;
504
- if (e.options.strict && xe(o, e.options, u), !u && !c && $(o, e.options) && !e.finalized && e.original.has(o)) {
505
- const l = tt.createDraft({
497
+ }, Ht = Reflect.ownKeys(we), je = (e, t, { isValuesIterator: n }) => () => {
498
+ var s, i;
499
+ const r = t.next();
500
+ if (r.done)
501
+ return r;
502
+ const o = r.value;
503
+ let c = e.setMap.get(o);
504
+ const a = h(c), u = ((i = (s = e.options).mark) === null || i === void 0 ? void 0 : i.call(s, c, x)) === x.mutable;
505
+ if (e.options.strict && ce(o, e.options, u), !u && !a && R(o, e.options) && !e.finalized && e.original.has(o)) {
506
+ const l = xe.createDraft({
506
507
  original: o,
507
508
  parentDraft: e,
508
509
  key: o,
509
510
  finalities: e.finalities,
510
511
  options: e.options
511
512
  });
512
- e.setMap.set(o, l), a = l;
513
- } else c && (a = c.proxy);
513
+ e.setMap.set(o, l), c = l;
514
+ } else a && (c = a.proxy);
514
515
  return {
515
516
  done: !1,
516
- value: n ? a : [a, a]
517
+ value: n ? c : [c, c]
517
518
  };
518
- }, Ae = {
519
+ }, ae = {
519
520
  get size() {
520
- return d(this).setMap.size;
521
+ return h(this).setMap.size;
521
522
  },
522
523
  has(e) {
523
- const t = d(this);
524
+ const t = h(this);
524
525
  if (t.setMap.has(e))
525
526
  return !0;
526
- x(t);
527
- const n = d(e);
527
+ w(t);
528
+ const n = h(e);
528
529
  return !!(n && t.setMap.has(n.original));
529
530
  },
530
531
  add(e) {
531
- const t = d(this);
532
- return this.has(e) || (x(t), z(t), t.assignedMap.set(e, !0), t.setMap.set(e, e), ot(t, e, e, _e)), this;
532
+ const t = h(this);
533
+ return this.has(e) || (w(t), E(t), t.assignedMap.set(e, !0), t.setMap.set(e, e), Ie(t, e, e, X)), this;
533
534
  },
534
535
  delete(e) {
535
536
  if (!this.has(e))
536
537
  return !1;
537
- const t = d(this);
538
- x(t), z(t);
539
- const n = d(e);
538
+ const t = h(this);
539
+ w(t), E(t);
540
+ const n = h(e);
540
541
  return n && t.setMap.has(n.original) ? (t.assignedMap.set(n.original, !1), t.setMap.delete(n.original)) : (!n && t.setMap.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.setMap.delete(e));
541
542
  },
542
543
  clear() {
543
544
  if (!this.size)
544
545
  return;
545
- const e = d(this);
546
- x(e), z(e);
546
+ const e = h(this);
547
+ w(e), E(e);
547
548
  for (const t of e.original)
548
549
  e.assignedMap.set(t, !1);
549
550
  e.setMap.clear();
550
551
  },
551
552
  values() {
552
- const e = d(this);
553
- x(e);
553
+ const e = h(this);
554
+ w(e);
554
555
  const t = e.setMap.keys();
555
556
  return {
556
557
  [Symbol.iterator]: () => this.values(),
557
- next: bt(e, t, { isValuesIterator: !0 })
558
+ next: je(e, t, { isValuesIterator: !0 })
558
559
  };
559
560
  },
560
561
  entries() {
561
- const e = d(this);
562
- x(e);
562
+ const e = h(this);
563
+ w(e);
563
564
  const t = e.setMap.keys();
564
565
  return {
565
566
  [Symbol.iterator]: () => this.entries(),
566
- next: bt(e, t, {
567
+ next: je(e, t, {
567
568
  isValuesIterator: !1
568
569
  })
569
570
  };
@@ -571,17 +572,17 @@ const xe = (e, t, n = !1) => {
571
572
  keys() {
572
573
  return this.values();
573
574
  },
574
- [ve]() {
575
+ [ee]() {
575
576
  return this.values();
576
577
  },
577
578
  forEach(e, t) {
578
579
  const n = this.values();
579
- let r = n.next();
580
- for (; !r.done; )
581
- e.call(t, r.value, r.value, this), r = n.next();
580
+ let s = n.next();
581
+ for (; !s.done; )
582
+ e.call(t, s.value, s.value, this), s = n.next();
582
583
  }
583
584
  };
584
- Set.prototype.difference && Object.assign(Ae, {
585
+ Set.prototype.difference && Object.assign(ae, {
585
586
  intersection(e) {
586
587
  return Set.prototype.intersection.call(new Set(this.values()), e);
587
588
  },
@@ -604,75 +605,75 @@ Set.prototype.difference && Object.assign(Ae, {
604
605
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), e);
605
606
  }
606
607
  });
607
- const Vn = Reflect.ownKeys(Ae), sn = {
608
+ const Bt = Reflect.ownKeys(ae), it = {
608
609
  get(e, t, n) {
609
- var r, i;
610
- const s = (r = e.copy) === null || r === void 0 ? void 0 : r[t];
611
- if (s && e.finalities.draftsCache.has(s))
612
- return s;
613
- if (t === en)
610
+ var s, i;
611
+ const r = (s = e.copy) === null || s === void 0 ? void 0 : s[t];
612
+ if (r && e.finalities.draftsCache.has(r))
613
+ return r;
614
+ if (t === et)
614
615
  return e;
615
616
  let o;
616
617
  if (e.options.mark) {
617
618
  const u = t === "size" && (e.original instanceof Map || e.original instanceof Set) ? Reflect.get(e.original, t) : Reflect.get(e.original, t, n);
618
- if (o = e.options.mark(u, E), o === E.mutable)
619
- return e.options.strict && xe(u, e.options, !0), u;
619
+ if (o = e.options.mark(u, x), o === x.mutable)
620
+ return e.options.strict && ce(u, e.options, !0), u;
620
621
  }
621
- const a = P(e);
622
- if (a instanceof Map && Wn.includes(t))
623
- return t === "size" ? Object.getOwnPropertyDescriptor(Ke, "size").get.call(e.proxy) : Ke[t].bind(e.proxy);
624
- if (a instanceof Set && Vn.includes(t))
625
- return t === "size" ? Object.getOwnPropertyDescriptor(Ae, "size").get.call(e.proxy) : Ae[t].bind(e.proxy);
626
- if (!he(a, t)) {
627
- const u = yt(a, t);
622
+ const c = C(e);
623
+ if (c instanceof Map && Ht.includes(t))
624
+ return t === "size" ? Object.getOwnPropertyDescriptor(we, "size").get.call(e.proxy) : we[t].bind(e.proxy);
625
+ if (c instanceof Set && Bt.includes(t))
626
+ return t === "size" ? Object.getOwnPropertyDescriptor(ae, "size").get.call(e.proxy) : ae[t].bind(e.proxy);
627
+ if (!Y(c, t)) {
628
+ const u = Ae(c, t);
628
629
  return u ? "value" in u ? u.value : (
629
630
  // !case: support for getter
630
631
  (i = u.get) === null || i === void 0 ? void 0 : i.call(e.proxy)
631
632
  ) : void 0;
632
633
  }
633
- const c = a[t];
634
- if (e.options.strict && xe(c, e.options), e.finalized || !$(c, e.options))
635
- return c;
636
- if (c === Ne(e.original, t)) {
637
- if (x(e), e.copy[t] = at({
634
+ const a = c[t];
635
+ if (e.options.strict && ce(a, e.options), e.finalized || !R(a, e.options))
636
+ return a;
637
+ if (a === pe(e.original, t)) {
638
+ if (w(e), e.copy[t] = Ne({
638
639
  original: e.original[t],
639
640
  parentDraft: e,
640
641
  key: e.type === 1 ? Number(t) : t,
641
642
  finalities: e.finalities,
642
643
  options: e.options
643
644
  }), typeof o == "function") {
644
- const u = d(e.copy[t]);
645
- return x(u), z(u), u.copy;
645
+ const u = h(e.copy[t]);
646
+ return w(u), E(u), u.copy;
646
647
  }
647
648
  return e.copy[t];
648
649
  }
649
- return K(c) && e.finalities.draftsCache.add(c), c;
650
+ return T(a) && e.finalities.draftsCache.add(a), a;
650
651
  },
651
652
  set(e, t, n) {
652
- var r;
653
+ var s;
653
654
  if (e.type === 3 || e.type === 2)
654
655
  throw new Error("Map/Set draft does not support any property assignment.");
655
656
  let i;
656
657
  if (e.type === 1 && t !== "length" && !(Number.isInteger(i = Number(t)) && i >= 0 && (t === 0 || i === 0 || String(i) === String(t))))
657
658
  throw new Error("Only supports setting array indices and the 'length' property.");
658
- const s = yt(P(e), t);
659
- if (s?.set)
660
- return s.set.call(e.proxy, n), !0;
661
- const o = Ne(P(e), t), a = d(o);
662
- return a && H(a.original, n) ? (e.copy[t] = n, e.assignedMap = (r = e.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), e.assignedMap.set(t, !1), !0) : (H(n, o) && (n !== void 0 || he(e.original, t)) || (x(e), z(e), he(e.original, t) && H(n, e.original[t]) ? e.assignedMap.delete(t) : e.assignedMap.set(t, !0), e.copy[t] = n, ot(e, t, n, _e)), !0);
659
+ const r = Ae(C(e), t);
660
+ if (r?.set)
661
+ return r.set.call(e.proxy, n), !0;
662
+ const o = pe(C(e), t), c = h(o);
663
+ return c && A(c.original, n) ? (e.copy[t] = n, e.assignedMap = (s = e.assignedMap) !== null && s !== void 0 ? s : /* @__PURE__ */ new Map(), e.assignedMap.set(t, !1), !0) : (A(n, o) && (n !== void 0 || Y(e.original, t)) || (w(e), E(e), Y(e.original, t) && A(n, e.original[t]) ? e.assignedMap.delete(t) : e.assignedMap.set(t, !0), e.copy[t] = n, Ie(e, t, n, X)), !0);
663
664
  },
664
665
  has(e, t) {
665
- return t in P(e);
666
+ return t in C(e);
666
667
  },
667
668
  ownKeys(e) {
668
- return Reflect.ownKeys(P(e));
669
+ return Reflect.ownKeys(C(e));
669
670
  },
670
671
  getOwnPropertyDescriptor(e, t) {
671
- const n = P(e), r = Reflect.getOwnPropertyDescriptor(n, t);
672
- return r && {
672
+ const n = C(e), s = Reflect.getOwnPropertyDescriptor(n, t);
673
+ return s && {
673
674
  writable: !0,
674
675
  configurable: e.type !== 1 || t !== "length",
675
- enumerable: r.enumerable,
676
+ enumerable: s.enumerable,
676
677
  value: n[t]
677
678
  };
678
679
  },
@@ -687,11 +688,11 @@ const Vn = Reflect.ownKeys(Ae), sn = {
687
688
  },
688
689
  deleteProperty(e, t) {
689
690
  var n;
690
- return e.type === 1 ? sn.set.call(this, e, t, void 0, e.proxy) : (Ne(e.original, t) !== void 0 || t in e.original ? (x(e), z(e), e.assignedMap.set(t, !1)) : (e.assignedMap = (n = e.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), e.assignedMap.delete(t)), e.copy && delete e.copy[t], !0);
691
+ return e.type === 1 ? it.set.call(this, e, t, void 0, e.proxy) : (pe(e.original, t) !== void 0 || t in e.original ? (w(e), E(e), e.assignedMap.set(t, !1)) : (e.assignedMap = (n = e.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), e.assignedMap.delete(t)), e.copy && delete e.copy[t], !0);
691
692
  }
692
693
  };
693
- function at(e) {
694
- const { original: t, parentDraft: n, key: r, finalities: i, options: s } = e, o = ee(t), a = {
694
+ function Ne(e) {
695
+ const { original: t, parentDraft: n, key: s, finalities: i, options: r } = e, o = Q(t), c = {
695
696
  type: o,
696
697
  finalized: !1,
697
698
  parent: n,
@@ -699,331 +700,237 @@ function at(e) {
699
700
  copy: null,
700
701
  proxy: null,
701
702
  finalities: i,
702
- options: s,
703
+ options: r,
703
704
  // Mapping of draft Set items to their corresponding draft values.
704
705
  setMap: o === 3 ? new Map(t.entries()) : void 0
705
706
  };
706
- (r || "key" in e) && (a.key = r);
707
- const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, sn);
708
- if (i.revoke.push(u), a.proxy = c, n) {
707
+ (s || "key" in e) && (c.key = s);
708
+ const { proxy: a, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], c) : c, it);
709
+ if (i.revoke.push(u), c.proxy = a, n) {
709
710
  const l = n;
710
- l.finalities.draft.push((f, h) => {
711
- var p, g;
712
- const b = d(c);
713
- let w = l.type === 3 ? l.setMap : l.copy;
714
- const C = q(w, r), S = d(C);
715
- if (S) {
716
- let A = S.original;
717
- S.operated && (A = it(C)), Ue(S), Ge(S, _e, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(A, S.original)), be(w, r, A);
711
+ l.finalities.draft.push((f, y) => {
712
+ var p, I;
713
+ const $ = h(a);
714
+ let M = l.type === 3 ? l.setMap : l.copy;
715
+ const m = F(M, s), g = h(m);
716
+ if (g) {
717
+ let _ = g.original;
718
+ g.operated && (_ = Re(m)), ge(g), Se(g, X, f, y), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(_, g.original)), Z(M, s, _);
718
719
  }
719
- (g = b.callbacks) === null || g === void 0 || g.forEach((A) => {
720
- A(f, h);
720
+ (I = $.callbacks) === null || I === void 0 || I.forEach((_) => {
721
+ _(f, y);
721
722
  });
722
723
  });
723
724
  } else {
724
- const l = d(c);
725
- l.finalities.draft.push((f, h) => {
726
- Ue(l), Ge(l, _e, f, h);
725
+ const l = h(a);
726
+ l.finalities.draft.push((f, y) => {
727
+ ge(l), Se(l, X, f, y);
727
728
  });
728
729
  }
729
- return c;
730
+ return a;
730
731
  }
731
- tt.createDraft = at;
732
- function Jn(e, t, n, r, i) {
733
- var s;
734
- const o = d(e), a = (s = o?.original) !== null && s !== void 0 ? s : e, c = !!t.length;
732
+ xe.createDraft = Ne;
733
+ function Ut(e, t, n, s, i) {
734
+ var r;
735
+ const o = h(e), c = (r = o?.original) !== null && r !== void 0 ? r : e, a = !!t.length;
735
736
  if (o?.operated)
736
737
  for (; o.finalities.draft.length > 0; )
737
- o.finalities.draft.pop()(n, r);
738
- const u = c ? t[0] : o ? o.operated ? o.copy : o.original : e;
739
- return o && Be(o), i && se(u, u, o?.options.updatedValues), [
738
+ o.finalities.draft.pop()(n, s);
739
+ const u = a ? t[0] : o ? o.operated ? o.copy : o.original : e;
740
+ return o && me(o), i && B(u, u, o?.options.updatedValues), [
740
741
  u,
741
- n && c ? [{ op: v.Replace, path: [], value: t[0] }] : n,
742
- r && c ? [{ op: v.Replace, path: [], value: a }] : r
742
+ n && a ? [{ op: b.Replace, path: [], value: t[0] }] : n,
743
+ s && a ? [{ op: b.Replace, path: [], value: c }] : s
743
744
  ];
744
745
  }
745
- function Yn(e, t) {
746
+ function Kt(e, t) {
746
747
  var n;
747
- const r = {
748
+ const s = {
748
749
  draft: [],
749
750
  revoke: [],
750
751
  handledSet: /* @__PURE__ */ new WeakSet(),
751
752
  draftsCache: /* @__PURE__ */ new WeakSet()
752
753
  };
753
- let i, s;
754
- t.enablePatches && (i = [], s = []);
755
- const a = ((n = t.mark) === null || n === void 0 ? void 0 : n.call(t, e, E)) === E.mutable || !$(e, t) ? e : at({
754
+ let i, r;
755
+ t.enablePatches && (i = [], r = []);
756
+ const c = ((n = t.mark) === null || n === void 0 ? void 0 : n.call(t, e, x)) === x.mutable || !R(e, t) ? e : Ne({
756
757
  original: e,
757
758
  parentDraft: null,
758
- finalities: r,
759
+ finalities: s,
759
760
  options: t
760
761
  });
761
762
  return [
762
- a,
763
- (c = []) => {
764
- const [u, l, f] = Jn(a, c, i, s, t.enableAutoFreeze);
763
+ c,
764
+ (a = []) => {
765
+ const [u, l, f] = Ut(c, a, i, r, t.enableAutoFreeze);
765
766
  return t.enablePatches ? [u, l, f] : u;
766
767
  }
767
768
  ];
768
769
  }
769
- function We(e) {
770
- const { rootDraft: t, value: n, useRawReturn: r = !1, isRoot: i = !0 } = e;
771
- st(n, (s, o, a) => {
772
- const c = d(o);
773
- if (c && t && c.finalities === t.finalities) {
770
+ function ve(e) {
771
+ const { rootDraft: t, value: n, useRawReturn: s = !1, isRoot: i = !0 } = e;
772
+ Ee(n, (r, o, c) => {
773
+ const a = h(o);
774
+ if (a && t && a.finalities === t.finalities) {
774
775
  e.isContainDraft = !0;
775
- const u = c.original;
776
- if (a instanceof Set) {
777
- const l = Array.from(a);
778
- a.clear(), l.forEach((f) => a.add(s === f ? u : f));
776
+ const u = a.original;
777
+ if (c instanceof Set) {
778
+ const l = Array.from(c);
779
+ c.clear(), l.forEach((f) => c.add(r === f ? u : f));
779
780
  } else
780
- be(a, s, u);
781
- } else typeof o == "object" && o !== null && (e.value = o, e.isRoot = !1, We(e));
782
- }), i && (e.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
781
+ Z(c, r, u);
782
+ } else typeof o == "object" && o !== null && (e.value = o, e.isRoot = !1, ve(e));
783
+ }), i && (e.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), s && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
783
784
  }
784
- function on(e) {
785
+ function rt(e) {
785
786
  var t;
786
- const n = d(e);
787
- if (!$(e, n?.options))
787
+ const n = h(e);
788
+ if (!R(e, n?.options))
788
789
  return e;
789
- const r = ee(e);
790
+ const s = Q(e);
790
791
  if (n && !n.operated)
791
792
  return n.original;
792
793
  let i;
793
- function s() {
794
- i = r === 2 ? rt(e) ? new Map(e) : new (Object.getPrototypeOf(e)).constructor(e) : r === 3 ? Array.from(n.setMap.values()) : nn(e, n?.options);
794
+ function r() {
795
+ i = s === 2 ? Pe(e) ? new Map(e) : new (Object.getPrototypeOf(e)).constructor(e) : s === 3 ? Array.from(n.setMap.values()) : nt(e, n?.options);
795
796
  }
796
797
  if (n) {
797
798
  n.finalized = !0;
798
799
  try {
799
- s();
800
+ r();
800
801
  } finally {
801
802
  n.finalized = !1;
802
803
  }
803
804
  } else
804
805
  i = e;
805
- if (st(i, (o, a) => {
806
- if (n && H(q(n.original, o), a))
806
+ if (Ee(i, (o, c) => {
807
+ if (n && A(F(n.original, o), c))
807
808
  return;
808
- const c = on(a);
809
- c !== a && (i === e && s(), be(i, o, c));
810
- }), r === 3) {
809
+ const a = rt(c);
810
+ a !== c && (i === e && r(), Z(i, o, a));
811
+ }), s === 3) {
811
812
  const o = (t = n?.original) !== null && t !== void 0 ? t : i;
812
- return nt(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
813
+ return Oe(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
813
814
  }
814
815
  return i;
815
816
  }
816
- function mt(e) {
817
- if (!K(e))
817
+ function De(e) {
818
+ if (!T(e))
818
819
  throw new Error(`current() is only used for Draft, parameter: ${e}`);
819
- return on(e);
820
+ return rt(e);
820
821
  }
821
- const Xn = (e) => function t(n, r, i) {
822
- var s, o, a;
823
- if (typeof n == "function" && typeof r != "function")
824
- return function(_, ...D) {
825
- return t(_, (G) => n.call(this, G, ...D), r);
822
+ const Wt = (e) => function t(n, s, i) {
823
+ var r, o, c;
824
+ if (typeof n == "function" && typeof s != "function")
825
+ return function(d, ...N) {
826
+ return t(d, (D) => n.call(this, D, ...N), s);
826
827
  };
827
- const c = n, u = r;
828
+ const a = n, u = s;
828
829
  let l = i;
829
- if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
830
+ if (typeof s != "function" && (l = s), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
830
831
  throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
831
832
  l = Object.assign(Object.assign({}, e), l);
832
- const f = K(c) ? mt(c) : c, h = Array.isArray(l.mark) ? ((_, D) => {
833
- for (const G of l.mark) {
834
- if (typeof G != "function")
835
- throw new Error(`Invalid mark: ${G}, 'mark' should be a function.`);
836
- const ce = G(_, D);
837
- if (ce)
838
- return ce;
833
+ const f = T(a) ? De(a) : a, y = Array.isArray(l.mark) ? ((d, N) => {
834
+ for (const D of l.mark) {
835
+ if (typeof D != "function")
836
+ throw new Error(`Invalid mark: ${D}, 'mark' should be a function.`);
837
+ const L = D(d, N);
838
+ if (L)
839
+ return L;
839
840
  }
840
- }) : l.mark, p = (s = l.enablePatches) !== null && s !== void 0 ? s : !1, g = (o = l.strict) !== null && o !== void 0 ? o : !1, w = {
841
- enableAutoFreeze: (a = l.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
842
- mark: h,
843
- strict: g,
841
+ }) : l.mark, p = (r = l.enablePatches) !== null && r !== void 0 ? r : !1, I = (o = l.strict) !== null && o !== void 0 ? o : !1, M = {
842
+ enableAutoFreeze: (c = l.enableAutoFreeze) !== null && c !== void 0 ? c : !1,
843
+ mark: y,
844
+ strict: I,
844
845
  enablePatches: p
845
846
  };
846
- if (!$(f, w) && typeof f == "object" && f !== null)
847
+ if (!R(f, M) && typeof f == "object" && f !== null)
847
848
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
848
- const [C, S] = Yn(f, w);
849
- if (typeof r != "function") {
850
- if (!$(f, w))
849
+ const [m, g] = Kt(f, M);
850
+ if (typeof s != "function") {
851
+ if (!R(f, M))
851
852
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
852
- return [C, S];
853
+ return [m, g];
853
854
  }
854
- let A;
855
+ let _;
855
856
  try {
856
- A = u(C);
857
- } catch (_) {
858
- throw Be(d(C)), _;
859
- }
860
- const V = (_) => {
861
- const D = d(C);
862
- if (!K(_)) {
863
- if (_ !== void 0 && !H(_, C) && D?.operated)
857
+ _ = u(m);
858
+ } catch (d) {
859
+ throw me(h(m)), d;
860
+ }
861
+ const j = (d) => {
862
+ const N = h(m);
863
+ if (!T(d)) {
864
+ if (d !== void 0 && !A(d, m) && N?.operated)
864
865
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
865
- const ce = _?.[Hn];
866
- if (ce) {
867
- const zn = ce[0];
868
- return w.strict && typeof _ == "object" && _ !== null && We({
869
- rootDraft: D,
870
- value: _,
866
+ const L = d?.[At];
867
+ if (L) {
868
+ const yt = L[0];
869
+ return M.strict && typeof d == "object" && d !== null && ve({
870
+ rootDraft: N,
871
+ value: d,
871
872
  useRawReturn: !0
872
- }), S([zn]);
873
+ }), g([yt]);
873
874
  }
874
- if (_ !== void 0)
875
- return typeof _ == "object" && _ !== null && We({ rootDraft: D, value: _ }), S([_]);
875
+ if (d !== void 0)
876
+ return typeof d == "object" && d !== null && ve({ rootDraft: N, value: d }), g([d]);
876
877
  }
877
- if (_ === C || _ === void 0)
878
- return S([]);
879
- const G = d(_);
880
- if (w === G.options) {
881
- if (G.operated)
878
+ if (d === m || d === void 0)
879
+ return g([]);
880
+ const D = h(d);
881
+ if (M === D.options) {
882
+ if (D.operated)
882
883
  throw new Error("Cannot return a modified child draft.");
883
- return S([mt(_)]);
884
+ return g([De(d)]);
884
885
  }
885
- return S([_]);
886
+ return g([d]);
886
887
  };
887
- return A instanceof Promise ? A.then(V, (_) => {
888
- throw Be(d(C)), _;
889
- }) : V(A);
890
- }, I = Xn();
888
+ return _ instanceof Promise ? _.then(j, (d) => {
889
+ throw me(h(m)), d;
890
+ }) : j(_);
891
+ }, P = Wt();
891
892
  Object.prototype.constructor.toString();
892
- var an = typeof global == "object" && global && global.Object === Object && global, Zn = typeof self == "object" && self && self.Object === Object && self, Q = an || Zn || Function("return this")(), N = Q.Symbol, cn = Object.prototype, kn = cn.hasOwnProperty, er = cn.toString, ue = N ? N.toStringTag : void 0;
893
- function tr(e) {
894
- var t = kn.call(e, ue), n = e[ue];
895
- try {
896
- e[ue] = void 0;
897
- var r = !0;
898
- } catch {
899
- }
900
- var i = er.call(e);
901
- return r && (t ? e[ue] = n : delete e[ue]), i;
902
- }
903
- var nr = Object.prototype, rr = nr.toString;
904
- function ir(e) {
905
- return rr.call(e);
906
- }
907
- var sr = "[object Null]", or = "[object Undefined]", St = N ? N.toStringTag : void 0;
908
- function te(e) {
909
- return e == null ? e === void 0 ? or : sr : St && St in Object(e) ? tr(e) : ir(e);
910
- }
911
- function X(e) {
912
- return e != null && typeof e == "object";
913
- }
914
- var ar = "[object Symbol]";
915
- function Z(e) {
916
- return typeof e == "symbol" || X(e) && te(e) == ar;
917
- }
918
- function de(e, t) {
919
- for (var n = -1, r = e == null ? 0 : e.length, i = Array(r); ++n < r; )
920
- i[n] = t(e[n], n, e);
921
- return i;
922
- }
923
- var M = Array.isArray, vt = N ? N.prototype : void 0, wt = vt ? vt.toString : void 0;
924
- function un(e) {
925
- if (typeof e == "string")
926
- return e;
927
- if (M(e))
928
- return de(e, un) + "";
929
- if (Z(e))
930
- return wt ? wt.call(e) : "";
931
- var t = e + "";
932
- return t == "0" && 1 / e == -1 / 0 ? "-0" : t;
933
- }
934
- var cr = /\s/;
935
- function ur(e) {
936
- for (var t = e.length; t-- && cr.test(e.charAt(t)); )
893
+ var Vt = /\s/;
894
+ function Lt(e) {
895
+ for (var t = e.length; t-- && Vt.test(e.charAt(t)); )
937
896
  ;
938
897
  return t;
939
898
  }
940
- var lr = /^\s+/;
941
- function fr(e) {
942
- return e && e.slice(0, ur(e) + 1).replace(lr, "");
899
+ var Jt = /^\s+/;
900
+ function Yt(e) {
901
+ return e && e.slice(0, Lt(e) + 1).replace(Jt, "");
943
902
  }
944
- function ae(e) {
945
- var t = typeof e;
946
- return e != null && (t == "object" || t == "function");
947
- }
948
- var Ot = NaN, hr = /^[-+]0x[0-9a-f]+$/i, dr = /^0b[01]+$/i, pr = /^0o[0-7]+$/i, _r = parseInt;
949
- function yr(e) {
903
+ var Te = NaN, Gt = /^[-+]0x[0-9a-f]+$/i, Xt = /^0b[01]+$/i, Zt = /^0o[0-7]+$/i, kt = parseInt;
904
+ function ne(e) {
950
905
  if (typeof e == "number")
951
906
  return e;
952
- if (Z(e))
953
- return Ot;
954
- if (ae(e)) {
907
+ if (oe(e))
908
+ return Te;
909
+ if (G(e)) {
955
910
  var t = typeof e.valueOf == "function" ? e.valueOf() : e;
956
- e = ae(t) ? t + "" : t;
911
+ e = G(t) ? t + "" : t;
957
912
  }
958
913
  if (typeof e != "string")
959
914
  return e === 0 ? e : +e;
960
- e = fr(e);
961
- var n = dr.test(e);
962
- return n || pr.test(e) ? _r(e.slice(2), n ? 2 : 8) : hr.test(e) ? Ot : +e;
915
+ e = Yt(e);
916
+ var n = Xt.test(e);
917
+ return n || Zt.test(e) ? kt(e.slice(2), n ? 2 : 8) : Gt.test(e) ? Te : +e;
963
918
  }
964
- var Ct = 1 / 0, gr = 17976931348623157e292;
965
- function br(e) {
919
+ var qe = 1 / 0, en = 17976931348623157e292;
920
+ function tn(e) {
966
921
  if (!e)
967
922
  return e === 0 ? e : 0;
968
- if (e = yr(e), e === Ct || e === -Ct) {
923
+ if (e = ne(e), e === qe || e === -qe) {
969
924
  var t = e < 0 ? -1 : 1;
970
- return t * gr;
925
+ return t * en;
971
926
  }
972
927
  return e === e ? e : 0;
973
928
  }
974
- function ln(e) {
975
- var t = br(e), n = t % 1;
929
+ function ot(e) {
930
+ var t = tn(e), n = t % 1;
976
931
  return t === t ? n ? t - n : t : 0;
977
932
  }
978
- function me(e) {
979
- return e;
980
- }
981
- var mr = "[object AsyncFunction]", Sr = "[object Function]", vr = "[object GeneratorFunction]", wr = "[object Proxy]";
982
- function fn(e) {
983
- if (!ae(e))
984
- return !1;
985
- var t = te(e);
986
- return t == Sr || t == vr || t == mr || t == wr;
987
- }
988
- var De = Q["__core-js_shared__"], Mt = (function() {
989
- var e = /[^.]+$/.exec(De && De.keys && De.keys.IE_PROTO || "");
990
- return e ? "Symbol(src)_1." + e : "";
991
- })();
992
- function Or(e) {
993
- return !!Mt && Mt in e;
994
- }
995
- var Cr = Function.prototype, Mr = Cr.toString;
996
- function ne(e) {
997
- if (e != null) {
998
- try {
999
- return Mr.call(e);
1000
- } catch {
1001
- }
1002
- try {
1003
- return e + "";
1004
- } catch {
1005
- }
1006
- }
1007
- return "";
1008
- }
1009
- var xr = /[\\^$.*+?()[\]{}|]/g, Ar = /^\[object .+?Constructor\]$/, Pr = Function.prototype, Er = Object.prototype, Tr = Pr.toString, Rr = Er.hasOwnProperty, Ir = RegExp(
1010
- "^" + Tr.call(Rr).replace(xr, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
1011
- );
1012
- function jr(e) {
1013
- if (!ae(e) || Or(e))
1014
- return !1;
1015
- var t = fn(e) ? Ir : Ar;
1016
- return t.test(ne(e));
1017
- }
1018
- function $r(e, t) {
1019
- return e?.[t];
1020
- }
1021
- function re(e, t) {
1022
- var n = $r(e, t);
1023
- return jr(n) ? n : void 0;
1024
- }
1025
- var Ve = re(Q, "WeakMap");
1026
- function Fr(e, t, n) {
933
+ function nn(e, t, n) {
1027
934
  switch (n.length) {
1028
935
  case 0:
1029
936
  return e.call(t);
@@ -1036,917 +943,294 @@ function Fr(e, t, n) {
1036
943
  }
1037
944
  return e.apply(t, n);
1038
945
  }
1039
- var zr = 800, Nr = 16, Dr = Date.now;
1040
- function Hr(e) {
946
+ var sn = 800, rn = 16, on = Date.now;
947
+ function cn(e) {
1041
948
  var t = 0, n = 0;
1042
949
  return function() {
1043
- var r = Dr(), i = Nr - (r - n);
1044
- if (n = r, i > 0) {
1045
- if (++t >= zr)
950
+ var s = on(), i = rn - (s - n);
951
+ if (n = s, i > 0) {
952
+ if (++t >= sn)
1046
953
  return arguments[0];
1047
954
  } else
1048
955
  t = 0;
1049
956
  return e.apply(void 0, arguments);
1050
957
  };
1051
958
  }
1052
- function Lr(e) {
959
+ function an(e) {
1053
960
  return function() {
1054
961
  return e;
1055
962
  };
1056
963
  }
1057
- var xt = (function() {
964
+ var ue = (function() {
1058
965
  try {
1059
- var e = re(Object, "defineProperty");
966
+ var e = bt(Object, "defineProperty");
1060
967
  return e({}, "", {}), e;
1061
968
  } catch {
1062
969
  }
1063
- })(), qr = xt ? function(e, t) {
1064
- return xt(e, "toString", {
970
+ })(), un = ue ? function(e, t) {
971
+ return ue(e, "toString", {
1065
972
  configurable: !0,
1066
973
  enumerable: !1,
1067
- value: Lr(t),
974
+ value: an(t),
1068
975
  writable: !0
1069
976
  });
1070
- } : me, Qr = Hr(qr);
1071
- function Br(e, t) {
1072
- for (var n = -1, r = e == null ? 0 : e.length; ++n < r && t(e[n], n, e) !== !1; )
977
+ } : fe, ln = cn(un);
978
+ function fn(e, t) {
979
+ for (var n = -1, s = e == null ? 0 : e.length; ++n < s && t(e[n], n, e) !== !1; )
1073
980
  ;
1074
981
  return e;
1075
982
  }
1076
- function Ur(e, t, n, r) {
1077
- for (var i = e.length, s = n + -1; ++s < i; )
1078
- if (t(e[s], s, e))
1079
- return s;
983
+ function hn(e, t, n, s) {
984
+ for (var i = e.length, r = n + -1; ++r < i; )
985
+ if (t(e[r], r, e))
986
+ return r;
1080
987
  return -1;
1081
988
  }
1082
- var Gr = 9007199254740991, Kr = /^(?:0|[1-9]\d*)$/;
1083
- function ct(e, t) {
1084
- var n = typeof e;
1085
- return t = t ?? Gr, !!t && (n == "number" || n != "symbol" && Kr.test(e)) && e > -1 && e % 1 == 0 && e < t;
1086
- }
1087
- function ut(e, t) {
1088
- return e === t || e !== e && t !== t;
1089
- }
1090
- var At = Math.max;
1091
- function Wr(e, t, n) {
1092
- return t = At(t === void 0 ? e.length - 1 : t, 0), function() {
1093
- for (var r = arguments, i = -1, s = At(r.length - t, 0), o = Array(s); ++i < s; )
1094
- o[i] = r[t + i];
989
+ function dn(e, t, n) {
990
+ t == "__proto__" && ue ? ue(e, t, {
991
+ configurable: !0,
992
+ enumerable: !0,
993
+ value: n,
994
+ writable: !0
995
+ }) : e[t] = n;
996
+ }
997
+ var pn = Object.prototype, _n = pn.hasOwnProperty;
998
+ function yn(e, t, n) {
999
+ var s = e[t];
1000
+ (!(_n.call(e, t) && Je(s, n)) || n === void 0 && !(t in e)) && dn(e, t, n);
1001
+ }
1002
+ var Qe = Math.max;
1003
+ function bn(e, t, n) {
1004
+ return t = Qe(t === void 0 ? e.length - 1 : t, 0), function() {
1005
+ for (var s = arguments, i = -1, r = Qe(s.length - t, 0), o = Array(r); ++i < r; )
1006
+ o[i] = s[t + i];
1095
1007
  i = -1;
1096
- for (var a = Array(t + 1); ++i < t; )
1097
- a[i] = r[i];
1098
- return a[t] = n(o), Fr(e, this, a);
1008
+ for (var c = Array(t + 1); ++i < t; )
1009
+ c[i] = s[i];
1010
+ return c[t] = n(o), nn(e, this, c);
1099
1011
  };
1100
1012
  }
1101
- function Vr(e, t) {
1102
- return Qr(Wr(e, t, me), e + "");
1103
- }
1104
- var Jr = 9007199254740991;
1105
- function lt(e) {
1106
- return typeof e == "number" && e > -1 && e % 1 == 0 && e <= Jr;
1107
- }
1108
- function ie(e) {
1109
- return e != null && lt(e.length) && !fn(e);
1110
- }
1111
- function Pt(e, t, n) {
1112
- if (!ae(n))
1113
- return !1;
1114
- var r = typeof t;
1115
- return (r == "number" ? ie(n) && ct(t, n.length) : r == "string" && t in n) ? ut(n[t], e) : !1;
1116
- }
1117
- var Yr = Object.prototype;
1118
- function hn(e) {
1119
- var t = e && e.constructor, n = typeof t == "function" && t.prototype || Yr;
1120
- return e === n;
1121
- }
1122
- function Xr(e, t) {
1123
- for (var n = -1, r = Array(e); ++n < e; )
1124
- r[n] = t(n);
1125
- return r;
1126
- }
1127
- var Zr = "[object Arguments]";
1128
- function Et(e) {
1129
- return X(e) && te(e) == Zr;
1130
- }
1131
- var dn = Object.prototype, kr = dn.hasOwnProperty, ei = dn.propertyIsEnumerable, Te = Et(/* @__PURE__ */ (function() {
1132
- return arguments;
1133
- })()) ? Et : function(e) {
1134
- return X(e) && kr.call(e, "callee") && !ei.call(e, "callee");
1135
- };
1136
- function ti() {
1137
- return !1;
1138
- }
1139
- var pn = typeof exports == "object" && exports && !exports.nodeType && exports, Tt = pn && typeof module == "object" && module && !module.nodeType && module, ni = Tt && Tt.exports === pn, Rt = ni ? Q.Buffer : void 0, ri = Rt ? Rt.isBuffer : void 0, Pe = ri || ti, ii = "[object Arguments]", si = "[object Array]", oi = "[object Boolean]", ai = "[object Date]", ci = "[object Error]", ui = "[object Function]", li = "[object Map]", fi = "[object Number]", hi = "[object Object]", di = "[object RegExp]", pi = "[object Set]", _i = "[object String]", yi = "[object WeakMap]", gi = "[object ArrayBuffer]", bi = "[object DataView]", mi = "[object Float32Array]", Si = "[object Float64Array]", vi = "[object Int8Array]", wi = "[object Int16Array]", Oi = "[object Int32Array]", Ci = "[object Uint8Array]", Mi = "[object Uint8ClampedArray]", xi = "[object Uint16Array]", Ai = "[object Uint32Array]", y = {};
1140
- y[mi] = y[Si] = y[vi] = y[wi] = y[Oi] = y[Ci] = y[Mi] = y[xi] = y[Ai] = !0;
1141
- y[ii] = y[si] = y[gi] = y[oi] = y[bi] = y[ai] = y[ci] = y[ui] = y[li] = y[fi] = y[hi] = y[di] = y[pi] = y[_i] = y[yi] = !1;
1142
- function Pi(e) {
1143
- return X(e) && lt(e.length) && !!y[te(e)];
1144
- }
1145
- function _n(e) {
1146
- return function(t) {
1147
- return e(t);
1148
- };
1149
- }
1150
- var yn = typeof exports == "object" && exports && !exports.nodeType && exports, pe = yn && typeof module == "object" && module && !module.nodeType && module, Ei = pe && pe.exports === yn, He = Ei && an.process, It = (function() {
1151
- try {
1152
- var e = pe && pe.require && pe.require("util").types;
1153
- return e || He && He.binding && He.binding("util");
1154
- } catch {
1155
- }
1156
- })(), jt = It && It.isTypedArray, ft = jt ? _n(jt) : Pi, Ti = Object.prototype, Ri = Ti.hasOwnProperty;
1157
- function Ii(e, t) {
1158
- var n = M(e), r = !n && Te(e), i = !n && !r && Pe(e), s = !n && !r && !i && ft(e), o = n || r || i || s, a = o ? Xr(e.length, String) : [], c = a.length;
1159
- for (var u in e)
1160
- Ri.call(e, u) && !(o && // Safari 9 has enumerable `arguments.length` in strict mode.
1161
- (u == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1162
- i && (u == "offset" || u == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1163
- s && (u == "buffer" || u == "byteLength" || u == "byteOffset") || // Skip index properties.
1164
- ct(u, c))) && a.push(u);
1165
- return a;
1166
- }
1167
- function ji(e, t) {
1168
- return function(n) {
1169
- return e(t(n));
1170
- };
1171
- }
1172
- var $i = ji(Object.keys, Object), Fi = Object.prototype, zi = Fi.hasOwnProperty;
1173
- function ht(e) {
1174
- if (!hn(e))
1175
- return $i(e);
1176
- var t = [];
1177
- for (var n in Object(e))
1178
- zi.call(e, n) && n != "constructor" && t.push(n);
1179
- return t;
1180
- }
1181
- function Re(e) {
1182
- return ie(e) ? Ii(e) : ht(e);
1013
+ function mn(e, t) {
1014
+ return ln(bn(e, t, fe), e + "");
1183
1015
  }
1184
- var Ni = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Di = /^\w*$/;
1185
- function dt(e, t) {
1186
- if (M(e))
1016
+ function $e(e, t, n) {
1017
+ if (!G(n))
1187
1018
  return !1;
1188
- var n = typeof e;
1189
- return n == "number" || n == "symbol" || n == "boolean" || e == null || Z(e) ? !0 : Di.test(e) || !Ni.test(e) || t != null && e in Object(t);
1190
- }
1191
- var ye = re(Object, "create");
1192
- function Hi() {
1193
- this.__data__ = ye ? ye(null) : {}, this.size = 0;
1194
- }
1195
- function Li(e) {
1196
- var t = this.has(e) && delete this.__data__[e];
1197
- return this.size -= t ? 1 : 0, t;
1198
- }
1199
- var qi = "__lodash_hash_undefined__", Qi = Object.prototype, Bi = Qi.hasOwnProperty;
1200
- function Ui(e) {
1201
- var t = this.__data__;
1202
- if (ye) {
1203
- var n = t[e];
1204
- return n === qi ? void 0 : n;
1205
- }
1206
- return Bi.call(t, e) ? t[e] : void 0;
1207
- }
1208
- var Gi = Object.prototype, Ki = Gi.hasOwnProperty;
1209
- function Wi(e) {
1210
- var t = this.__data__;
1211
- return ye ? t[e] !== void 0 : Ki.call(t, e);
1212
- }
1213
- var Vi = "__lodash_hash_undefined__";
1214
- function Ji(e, t) {
1215
- var n = this.__data__;
1216
- return this.size += this.has(e) ? 0 : 1, n[e] = ye && t === void 0 ? Vi : t, this;
1217
- }
1218
- function k(e) {
1219
- var t = -1, n = e == null ? 0 : e.length;
1220
- for (this.clear(); ++t < n; ) {
1221
- var r = e[t];
1222
- this.set(r[0], r[1]);
1223
- }
1224
- }
1225
- k.prototype.clear = Hi;
1226
- k.prototype.delete = Li;
1227
- k.prototype.get = Ui;
1228
- k.prototype.has = Wi;
1229
- k.prototype.set = Ji;
1230
- function Yi() {
1231
- this.__data__ = [], this.size = 0;
1232
- }
1233
- function Ie(e, t) {
1234
- for (var n = e.length; n--; )
1235
- if (ut(e[n][0], t))
1236
- return n;
1237
- return -1;
1019
+ var s = typeof t;
1020
+ return (s == "number" ? he(n) && Ye(t, n.length) : s == "string" && t in n) ? Je(n[t], e) : !1;
1238
1021
  }
1239
- var Xi = Array.prototype, Zi = Xi.splice;
1240
- function ki(e) {
1241
- var t = this.__data__, n = Ie(t, e);
1242
- if (n < 0)
1243
- return !1;
1244
- var r = t.length - 1;
1245
- return n == r ? t.pop() : Zi.call(t, n, 1), --this.size, !0;
1246
- }
1247
- function es(e) {
1248
- var t = this.__data__, n = Ie(t, e);
1249
- return n < 0 ? void 0 : t[n][1];
1250
- }
1251
- function ts(e) {
1252
- return Ie(this.__data__, e) > -1;
1253
- }
1254
- function ns(e, t) {
1255
- var n = this.__data__, r = Ie(n, e);
1256
- return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this;
1257
- }
1258
- function B(e) {
1259
- var t = -1, n = e == null ? 0 : e.length;
1260
- for (this.clear(); ++t < n; ) {
1261
- var r = e[t];
1262
- this.set(r[0], r[1]);
1263
- }
1264
- }
1265
- B.prototype.clear = Yi;
1266
- B.prototype.delete = ki;
1267
- B.prototype.get = es;
1268
- B.prototype.has = ts;
1269
- B.prototype.set = ns;
1270
- var ge = re(Q, "Map");
1271
- function rs() {
1272
- this.size = 0, this.__data__ = {
1273
- hash: new k(),
1274
- map: new (ge || B)(),
1275
- string: new k()
1276
- };
1277
- }
1278
- function is(e) {
1279
- var t = typeof e;
1280
- return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
1281
- }
1282
- function je(e, t) {
1283
- var n = e.__data__;
1284
- return is(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
1285
- }
1286
- function ss(e) {
1287
- var t = je(this, e).delete(e);
1288
- return this.size -= t ? 1 : 0, t;
1289
- }
1290
- function os(e) {
1291
- return je(this, e).get(e);
1292
- }
1293
- function as(e) {
1294
- return je(this, e).has(e);
1295
- }
1296
- function cs(e, t) {
1297
- var n = je(this, e), r = n.size;
1298
- return n.set(e, t), this.size += n.size == r ? 0 : 1, this;
1299
- }
1300
- function U(e) {
1301
- var t = -1, n = e == null ? 0 : e.length;
1302
- for (this.clear(); ++t < n; ) {
1303
- var r = e[t];
1304
- this.set(r[0], r[1]);
1305
- }
1306
- }
1307
- U.prototype.clear = rs;
1308
- U.prototype.delete = ss;
1309
- U.prototype.get = os;
1310
- U.prototype.has = as;
1311
- U.prototype.set = cs;
1312
- var us = "Expected a function";
1313
- function pt(e, t) {
1314
- if (typeof e != "function" || t != null && typeof t != "function")
1315
- throw new TypeError(us);
1316
- var n = function() {
1317
- var r = arguments, i = t ? t.apply(this, r) : r[0], s = n.cache;
1318
- if (s.has(i))
1319
- return s.get(i);
1320
- var o = e.apply(this, r);
1321
- return n.cache = s.set(i, o) || s, o;
1322
- };
1323
- return n.cache = new (pt.Cache || U)(), n;
1324
- }
1325
- pt.Cache = U;
1326
- var ls = 500;
1327
- function fs(e) {
1328
- var t = pt(e, function(r) {
1329
- return n.size === ls && n.clear(), r;
1330
- }), n = t.cache;
1331
- return t;
1332
- }
1333
- var hs = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, ds = /\\(\\)?/g, ps = fs(function(e) {
1334
- var t = [];
1335
- return e.charCodeAt(0) === 46 && t.push(""), e.replace(hs, function(n, r, i, s) {
1336
- t.push(i ? s.replace(ds, "$1") : r || n);
1337
- }), t;
1338
- });
1022
+ var He = ze ? ze.isConcatSpreadable : void 0;
1339
1023
  function gn(e) {
1340
- return e == null ? "" : un(e);
1024
+ return W(e) || Ge(e) || !!(He && e && e[He]);
1341
1025
  }
1342
- function bn(e, t) {
1343
- return M(e) ? e : dt(e, t) ? [e] : ps(gn(e));
1344
- }
1345
- function $e(e) {
1346
- if (typeof e == "string" || Z(e))
1347
- return e;
1348
- var t = e + "";
1349
- return t == "0" && 1 / e == -1 / 0 ? "-0" : t;
1350
- }
1351
- function _t(e, t) {
1352
- t = bn(t, e);
1353
- for (var n = 0, r = t.length; e != null && n < r; )
1354
- e = e[$e(t[n++])];
1355
- return n && n == r ? e : void 0;
1356
- }
1357
- function m(e, t, n) {
1358
- var r = e == null ? void 0 : _t(e, t);
1359
- return r === void 0 ? n : r;
1360
- }
1361
- function mn(e, t) {
1362
- for (var n = -1, r = t.length, i = e.length; ++n < r; )
1363
- e[i + n] = t[n];
1364
- return e;
1365
- }
1366
- var $t = N ? N.isConcatSpreadable : void 0;
1367
- function _s(e) {
1368
- return M(e) || Te(e) || !!($t && e && e[$t]);
1369
- }
1370
- function Sn(e, t, n, r, i) {
1371
- var s = -1, o = e.length;
1372
- for (n || (n = _s), i || (i = []); ++s < o; ) {
1373
- var a = e[s];
1374
- n(a) ? mn(i, a) : i[i.length] = a;
1026
+ function Sn(e, t, n, s, i) {
1027
+ var r = -1, o = e.length;
1028
+ for (n || (n = gn), i || (i = []); ++r < o; ) {
1029
+ var c = e[r];
1030
+ n(c) ? mt(i, c) : i[i.length] = c;
1375
1031
  }
1376
1032
  return i;
1377
1033
  }
1378
- function vn(e, t, n) {
1379
- var r = -1, i = e.length;
1034
+ function wn(e, t, n) {
1035
+ var s = -1, i = e.length;
1380
1036
  t < 0 && (t = -t > i ? 0 : i + t), n = n > i ? i : n, n < 0 && (n += i), i = t > n ? 0 : n - t >>> 0, t >>>= 0;
1381
- for (var s = Array(i); ++r < i; )
1382
- s[r] = e[r + t];
1383
- return s;
1384
- }
1385
- var ys = "\\ud800-\\udfff", gs = "\\u0300-\\u036f", bs = "\\ufe20-\\ufe2f", ms = "\\u20d0-\\u20ff", Ss = gs + bs + ms, vs = "\\ufe0e\\ufe0f", ws = "\\u200d", Os = RegExp("[" + ws + ys + Ss + vs + "]");
1386
- function Cs(e) {
1387
- return Os.test(e);
1388
- }
1389
- function Ms() {
1390
- this.__data__ = new B(), this.size = 0;
1391
- }
1392
- function xs(e) {
1393
- var t = this.__data__, n = t.delete(e);
1394
- return this.size = t.size, n;
1395
- }
1396
- function As(e) {
1397
- return this.__data__.get(e);
1398
- }
1399
- function Ps(e) {
1400
- return this.__data__.has(e);
1401
- }
1402
- var Es = 200;
1403
- function Ts(e, t) {
1404
- var n = this.__data__;
1405
- if (n instanceof B) {
1406
- var r = n.__data__;
1407
- if (!ge || r.length < Es - 1)
1408
- return r.push([e, t]), this.size = ++n.size, this;
1409
- n = this.__data__ = new U(r);
1410
- }
1411
- return n.set(e, t), this.size = n.size, this;
1412
- }
1413
- function L(e) {
1414
- var t = this.__data__ = new B(e);
1415
- this.size = t.size;
1416
- }
1417
- L.prototype.clear = Ms;
1418
- L.prototype.delete = xs;
1419
- L.prototype.get = As;
1420
- L.prototype.has = Ps;
1421
- L.prototype.set = Ts;
1422
- function wn(e, t) {
1423
- for (var n = -1, r = e == null ? 0 : e.length, i = 0, s = []; ++n < r; ) {
1424
- var o = e[n];
1425
- t(o, n, e) && (s[i++] = o);
1426
- }
1427
- return s;
1428
- }
1429
- function Rs() {
1430
- return [];
1431
- }
1432
- var Is = Object.prototype, js = Is.propertyIsEnumerable, Ft = Object.getOwnPropertySymbols, $s = Ft ? function(e) {
1433
- return e == null ? [] : (e = Object(e), wn(Ft(e), function(t) {
1434
- return js.call(e, t);
1435
- }));
1436
- } : Rs;
1437
- function Fs(e, t, n) {
1438
- var r = t(e);
1439
- return M(e) ? r : mn(r, n(e));
1440
- }
1441
- function zt(e) {
1442
- return Fs(e, Re, $s);
1443
- }
1444
- var Je = re(Q, "DataView"), Ye = re(Q, "Promise"), Xe = re(Q, "Set"), Nt = "[object Map]", zs = "[object Object]", Dt = "[object Promise]", Ht = "[object Set]", Lt = "[object WeakMap]", qt = "[object DataView]", Ns = ne(Je), Ds = ne(ge), Hs = ne(Ye), Ls = ne(Xe), qs = ne(Ve), F = te;
1445
- (Je && F(new Je(new ArrayBuffer(1))) != qt || ge && F(new ge()) != Nt || Ye && F(Ye.resolve()) != Dt || Xe && F(new Xe()) != Ht || Ve && F(new Ve()) != Lt) && (F = function(e) {
1446
- var t = te(e), n = t == zs ? e.constructor : void 0, r = n ? ne(n) : "";
1447
- if (r)
1448
- switch (r) {
1449
- case Ns:
1450
- return qt;
1451
- case Ds:
1452
- return Nt;
1453
- case Hs:
1454
- return Dt;
1455
- case Ls:
1456
- return Ht;
1457
- case qs:
1458
- return Lt;
1459
- }
1460
- return t;
1461
- });
1462
- var Qt = Q.Uint8Array, Qs = "__lodash_hash_undefined__";
1463
- function Bs(e) {
1464
- return this.__data__.set(e, Qs), this;
1465
- }
1466
- function Us(e) {
1467
- return this.__data__.has(e);
1468
- }
1469
- function Ee(e) {
1470
- var t = -1, n = e == null ? 0 : e.length;
1471
- for (this.__data__ = new U(); ++t < n; )
1472
- this.add(e[t]);
1473
- }
1474
- Ee.prototype.add = Ee.prototype.push = Bs;
1475
- Ee.prototype.has = Us;
1476
- function Gs(e, t) {
1477
- for (var n = -1, r = e == null ? 0 : e.length; ++n < r; )
1478
- if (t(e[n], n, e))
1479
- return !0;
1480
- return !1;
1481
- }
1482
- function Ks(e, t) {
1483
- return e.has(t);
1484
- }
1485
- var Ws = 1, Vs = 2;
1486
- function On(e, t, n, r, i, s) {
1487
- var o = n & Ws, a = e.length, c = t.length;
1488
- if (a != c && !(o && c > a))
1489
- return !1;
1490
- var u = s.get(e), l = s.get(t);
1491
- if (u && l)
1492
- return u == t && l == e;
1493
- var f = -1, h = !0, p = n & Vs ? new Ee() : void 0;
1494
- for (s.set(e, t), s.set(t, e); ++f < a; ) {
1495
- var g = e[f], b = t[f];
1496
- if (r)
1497
- var w = o ? r(b, g, f, t, e, s) : r(g, b, f, e, t, s);
1498
- if (w !== void 0) {
1499
- if (w)
1500
- continue;
1501
- h = !1;
1502
- break;
1503
- }
1504
- if (p) {
1505
- if (!Gs(t, function(C, S) {
1506
- if (!Ks(p, S) && (g === C || i(g, C, n, r, s)))
1507
- return p.push(S);
1508
- })) {
1509
- h = !1;
1510
- break;
1511
- }
1512
- } else if (!(g === b || i(g, b, n, r, s))) {
1513
- h = !1;
1514
- break;
1515
- }
1516
- }
1517
- return s.delete(e), s.delete(t), h;
1518
- }
1519
- function Js(e) {
1520
- var t = -1, n = Array(e.size);
1521
- return e.forEach(function(r, i) {
1522
- n[++t] = [i, r];
1523
- }), n;
1524
- }
1525
- function Ys(e) {
1526
- var t = -1, n = Array(e.size);
1527
- return e.forEach(function(r) {
1528
- n[++t] = r;
1529
- }), n;
1530
- }
1531
- var Xs = 1, Zs = 2, ks = "[object Boolean]", eo = "[object Date]", to = "[object Error]", no = "[object Map]", ro = "[object Number]", io = "[object RegExp]", so = "[object Set]", oo = "[object String]", ao = "[object Symbol]", co = "[object ArrayBuffer]", uo = "[object DataView]", Bt = N ? N.prototype : void 0, Le = Bt ? Bt.valueOf : void 0;
1532
- function lo(e, t, n, r, i, s, o) {
1533
- switch (n) {
1534
- case uo:
1535
- if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset)
1536
- return !1;
1537
- e = e.buffer, t = t.buffer;
1538
- case co:
1539
- return !(e.byteLength != t.byteLength || !s(new Qt(e), new Qt(t)));
1540
- case ks:
1541
- case eo:
1542
- case ro:
1543
- return ut(+e, +t);
1544
- case to:
1545
- return e.name == t.name && e.message == t.message;
1546
- case io:
1547
- case oo:
1548
- return e == t + "";
1549
- case no:
1550
- var a = Js;
1551
- case so:
1552
- var c = r & Xs;
1553
- if (a || (a = Ys), e.size != t.size && !c)
1554
- return !1;
1555
- var u = o.get(e);
1556
- if (u)
1557
- return u == t;
1558
- r |= Zs, o.set(e, t);
1559
- var l = On(a(e), a(t), r, i, s, o);
1560
- return o.delete(e), l;
1561
- case ao:
1562
- if (Le)
1563
- return Le.call(e) == Le.call(t);
1564
- }
1565
- return !1;
1566
- }
1567
- var fo = 1, ho = Object.prototype, po = ho.hasOwnProperty;
1568
- function _o(e, t, n, r, i, s) {
1569
- var o = n & fo, a = zt(e), c = a.length, u = zt(t), l = u.length;
1570
- if (c != l && !o)
1571
- return !1;
1572
- for (var f = c; f--; ) {
1573
- var h = a[f];
1574
- if (!(o ? h in t : po.call(t, h)))
1575
- return !1;
1576
- }
1577
- var p = s.get(e), g = s.get(t);
1578
- if (p && g)
1579
- return p == t && g == e;
1580
- var b = !0;
1581
- s.set(e, t), s.set(t, e);
1582
- for (var w = o; ++f < c; ) {
1583
- h = a[f];
1584
- var C = e[h], S = t[h];
1585
- if (r)
1586
- var A = o ? r(S, C, h, t, e, s) : r(C, S, h, e, t, s);
1587
- if (!(A === void 0 ? C === S || i(C, S, n, r, s) : A)) {
1588
- b = !1;
1589
- break;
1590
- }
1591
- w || (w = h == "constructor");
1592
- }
1593
- if (b && !w) {
1594
- var V = e.constructor, _ = t.constructor;
1595
- V != _ && "constructor" in e && "constructor" in t && !(typeof V == "function" && V instanceof V && typeof _ == "function" && _ instanceof _) && (b = !1);
1596
- }
1597
- return s.delete(e), s.delete(t), b;
1598
- }
1599
- var yo = 1, Ut = "[object Arguments]", Gt = "[object Array]", Se = "[object Object]", go = Object.prototype, Kt = go.hasOwnProperty;
1600
- function bo(e, t, n, r, i, s) {
1601
- var o = M(e), a = M(t), c = o ? Gt : F(e), u = a ? Gt : F(t);
1602
- c = c == Ut ? Se : c, u = u == Ut ? Se : u;
1603
- var l = c == Se, f = u == Se, h = c == u;
1604
- if (h && Pe(e)) {
1605
- if (!Pe(t))
1606
- return !1;
1607
- o = !0, l = !1;
1608
- }
1609
- if (h && !l)
1610
- return s || (s = new L()), o || ft(e) ? On(e, t, n, r, i, s) : lo(e, t, c, n, r, i, s);
1611
- if (!(n & yo)) {
1612
- var p = l && Kt.call(e, "__wrapped__"), g = f && Kt.call(t, "__wrapped__");
1613
- if (p || g) {
1614
- var b = p ? e.value() : e, w = g ? t.value() : t;
1615
- return s || (s = new L()), i(b, w, n, r, s);
1616
- }
1617
- }
1618
- return h ? (s || (s = new L()), _o(e, t, n, r, i, s)) : !1;
1619
- }
1620
- function Fe(e, t, n, r, i) {
1621
- return e === t ? !0 : e == null || t == null || !X(e) && !X(t) ? e !== e && t !== t : bo(e, t, n, r, Fe, i);
1622
- }
1623
- var mo = 1, So = 2;
1624
- function vo(e, t, n, r) {
1625
- var i = n.length, s = i;
1626
- if (e == null)
1627
- return !s;
1628
- for (e = Object(e); i--; ) {
1629
- var o = n[i];
1630
- if (o[2] ? o[1] !== e[o[0]] : !(o[0] in e))
1631
- return !1;
1632
- }
1633
- for (; ++i < s; ) {
1634
- o = n[i];
1635
- var a = o[0], c = e[a], u = o[1];
1636
- if (o[2]) {
1637
- if (c === void 0 && !(a in e))
1638
- return !1;
1639
- } else {
1640
- var l = new L(), f;
1641
- if (!(f === void 0 ? Fe(u, c, mo | So, r, l) : f))
1642
- return !1;
1643
- }
1644
- }
1645
- return !0;
1646
- }
1647
- function Cn(e) {
1648
- return e === e && !ae(e);
1649
- }
1650
- function wo(e) {
1651
- for (var t = Re(e), n = t.length; n--; ) {
1652
- var r = t[n], i = e[r];
1653
- t[n] = [r, i, Cn(i)];
1654
- }
1655
- return t;
1656
- }
1657
- function Mn(e, t) {
1658
- return function(n) {
1659
- return n == null ? !1 : n[e] === t && (t !== void 0 || e in Object(n));
1660
- };
1661
- }
1662
- function Oo(e) {
1663
- var t = wo(e);
1664
- return t.length == 1 && t[0][2] ? Mn(t[0][0], t[0][1]) : function(n) {
1665
- return n === e || vo(n, e, t);
1666
- };
1667
- }
1668
- function Co(e, t) {
1669
- return e != null && t in Object(e);
1670
- }
1671
- function Mo(e, t, n) {
1672
- t = bn(t, e);
1673
- for (var r = -1, i = t.length, s = !1; ++r < i; ) {
1674
- var o = $e(t[r]);
1675
- if (!(s = e != null && n(e, o)))
1676
- break;
1677
- e = e[o];
1678
- }
1679
- return s || ++r != i ? s : (i = e == null ? 0 : e.length, !!i && lt(i) && ct(o, i) && (M(e) || Te(e)));
1680
- }
1681
- function xo(e, t) {
1682
- return e != null && Mo(e, t, Co);
1683
- }
1684
- var Ao = 1, Po = 2;
1685
- function Eo(e, t) {
1686
- return dt(e) && Cn(t) ? Mn($e(e), t) : function(n) {
1687
- var r = m(n, e);
1688
- return r === void 0 && r === t ? xo(n, e) : Fe(t, r, Ao | Po);
1689
- };
1690
- }
1691
- function xn(e) {
1692
- return function(t) {
1693
- return t?.[e];
1694
- };
1695
- }
1696
- function To(e) {
1697
- return function(t) {
1698
- return _t(t, e);
1699
- };
1700
- }
1701
- function Ro(e) {
1702
- return dt(e) ? xn($e(e)) : To(e);
1703
- }
1704
- function W(e) {
1705
- return typeof e == "function" ? e : e == null ? me : typeof e == "object" ? M(e) ? Eo(e[0], e[1]) : Oo(e) : Ro(e);
1706
- }
1707
- function Io(e) {
1708
- return function(t, n, r) {
1709
- for (var i = -1, s = Object(t), o = r(t), a = o.length; a--; ) {
1710
- var c = o[++i];
1711
- if (n(s[c], c, s) === !1)
1712
- break;
1713
- }
1714
- return t;
1715
- };
1037
+ for (var r = Array(i); ++s < i; )
1038
+ r[s] = e[s + t];
1039
+ return r;
1716
1040
  }
1717
- var jo = Io();
1718
- function $o(e, t) {
1719
- return e && jo(e, t, Re);
1720
- }
1721
- function Fo(e, t) {
1722
- return function(n, r) {
1723
- if (n == null)
1724
- return n;
1725
- if (!ie(n))
1726
- return e(n, r);
1727
- for (var i = n.length, s = -1, o = Object(n); ++s < i && r(o[s], s, o) !== !1; )
1728
- ;
1729
- return n;
1730
- };
1041
+ var vn = "\\ud800-\\udfff", Mn = "\\u0300-\\u036f", Cn = "\\ufe20-\\ufe2f", xn = "\\u20d0-\\u20ff", On = Mn + Cn + xn, Pn = "\\ufe0e\\ufe0f", Rn = "\\u200d", En = RegExp("[" + Rn + vn + On + Pn + "]");
1042
+ function In(e) {
1043
+ return En.test(e);
1731
1044
  }
1732
- var ze = Fo($o);
1733
- function fe(e) {
1734
- var t = e == null ? 0 : e.length;
1735
- return t ? e[t - 1] : void 0;
1045
+ function Nn(e, t, n) {
1046
+ return e === e && (n !== void 0 && (e = e <= n ? e : n), t !== void 0 && (e = e >= t ? e : t)), e;
1736
1047
  }
1737
- function zo(e) {
1738
- return typeof e == "function" ? e : me;
1048
+ function zn(e, t, n) {
1049
+ return n === void 0 && (n = t, t = void 0), n !== void 0 && (n = ne(n), n = n === n ? n : 0), t !== void 0 && (t = ne(t), t = t === t ? t : 0), Nn(ne(e), t, n);
1739
1050
  }
1740
- function Oe(e, t) {
1741
- var n = M(e) ? Br : ze;
1742
- return n(e, zo(t));
1051
+ function An(e) {
1052
+ return typeof e == "function" ? e : fe;
1743
1053
  }
1744
- function No(e, t) {
1745
- for (var n = -1, r = e == null ? 0 : e.length; ++n < r; )
1746
- if (!t(e[n], n, e))
1747
- return !1;
1748
- return !0;
1054
+ function k(e, t) {
1055
+ var n = W(e) ? fn : Xe;
1056
+ return n(e, An(t));
1749
1057
  }
1750
- function Do(e, t) {
1751
- var n = !0;
1752
- return ze(e, function(r, i, s) {
1753
- return n = !!t(r, i, s), n;
1754
- }), n;
1755
- }
1756
- function Ho(e, t, n) {
1757
- var r = M(e) ? No : Do;
1758
- return r(e, W(t));
1759
- }
1760
- function Lo(e, t) {
1058
+ function Fn(e, t) {
1761
1059
  var n = [];
1762
- return ze(e, function(r, i, s) {
1763
- t(r, i, s) && n.push(r);
1060
+ return Xe(e, function(s, i, r) {
1061
+ t(s, i, r) && n.push(s);
1764
1062
  }), n;
1765
1063
  }
1766
- function Ce(e, t) {
1767
- var n = M(e) ? wn : Lo;
1768
- return n(e, W(t));
1064
+ function se(e, t) {
1065
+ var n = W(e) ? gt : Fn;
1066
+ return n(e, V(t));
1769
1067
  }
1770
- function qo(e) {
1771
- return function(t, n, r) {
1068
+ function jn(e) {
1069
+ return function(t, n, s) {
1772
1070
  var i = Object(t);
1773
- if (!ie(t)) {
1774
- var s = W(n);
1775
- t = Re(t), n = function(a) {
1776
- return s(i[a], a, i);
1071
+ if (!he(t)) {
1072
+ var r = V(n);
1073
+ t = St(t), n = function(c) {
1074
+ return r(i[c], c, i);
1777
1075
  };
1778
1076
  }
1779
- var o = e(t, n, r);
1780
- return o > -1 ? i[s ? t[o] : o] : void 0;
1077
+ var o = e(t, n, s);
1078
+ return o > -1 ? i[r ? t[o] : o] : void 0;
1781
1079
  };
1782
1080
  }
1783
- var Qo = Math.max;
1784
- function Bo(e, t, n) {
1785
- var r = e == null ? 0 : e.length;
1786
- if (!r)
1081
+ var Dn = Math.max;
1082
+ function ie(e, t, n) {
1083
+ var s = e == null ? 0 : e.length;
1084
+ if (!s)
1787
1085
  return -1;
1788
- var i = n == null ? 0 : ln(n);
1789
- return i < 0 && (i = Qo(r + i, 0)), Ur(e, W(t), i);
1086
+ var i = n == null ? 0 : ot(n);
1087
+ return i < 0 && (i = Dn(s + i, 0)), hn(e, V(t), i);
1790
1088
  }
1791
- var Ze = qo(Bo);
1792
- function Uo(e) {
1089
+ var Be = jn(ie);
1090
+ function Tn(e) {
1793
1091
  return e && e.length ? e[0] : void 0;
1794
1092
  }
1795
- function An(e, t) {
1796
- var n = -1, r = ie(e) ? Array(e.length) : [];
1797
- return ze(e, function(i, s, o) {
1798
- r[++n] = t(i, s, o);
1799
- }), r;
1800
- }
1801
- function Y(e, t) {
1802
- var n = M(e) ? de : An;
1803
- return n(e, W(t));
1804
- }
1805
- function Go(e, t) {
1806
- return Sn(Y(e, t));
1807
- }
1808
- function Ko(e) {
1809
- for (var t = -1, n = e == null ? 0 : e.length, r = {}; ++t < n; ) {
1810
- var i = e[t];
1811
- r[i[0]] = i[1];
1812
- }
1813
- return r;
1814
- }
1815
- function Wo(e, t) {
1093
+ function qn(e, t) {
1816
1094
  return e > t;
1817
1095
  }
1818
- var Vo = "[object String]";
1819
- function Jo(e) {
1820
- return typeof e == "string" || !M(e) && X(e) && te(e) == Vo;
1096
+ var Qn = "[object String]";
1097
+ function $n(e) {
1098
+ return typeof e == "string" || !W(e) && wt(e) && vt(e) == Qn;
1821
1099
  }
1822
- function Yo(e) {
1823
- var t = e == null ? 0 : e.length;
1824
- return t ? vn(e, 0, -1) : [];
1825
- }
1826
- var Xo = "[object Map]", Zo = "[object Set]", ko = Object.prototype, ea = ko.hasOwnProperty;
1827
- function Pn(e) {
1100
+ var Hn = "[object Map]", Bn = "[object Set]", Un = Object.prototype, Kn = Un.hasOwnProperty;
1101
+ function Wn(e) {
1828
1102
  if (e == null)
1829
1103
  return !0;
1830
- if (ie(e) && (M(e) || typeof e == "string" || typeof e.splice == "function" || Pe(e) || ft(e) || Te(e)))
1104
+ if (he(e) && (W(e) || typeof e == "string" || typeof e.splice == "function" || Mt(e) || Ct(e) || Ge(e)))
1831
1105
  return !e.length;
1832
- var t = F(e);
1833
- if (t == Xo || t == Zo)
1106
+ var t = Ze(e);
1107
+ if (t == Hn || t == Bn)
1834
1108
  return !e.size;
1835
- if (hn(e))
1836
- return !ht(e).length;
1109
+ if (xt(e))
1110
+ return !ke(e).length;
1837
1111
  for (var n in e)
1838
- if (ea.call(e, n))
1112
+ if (Kn.call(e, n))
1839
1113
  return !1;
1840
1114
  return !0;
1841
1115
  }
1842
- function O(e, t) {
1843
- return Fe(e, t);
1116
+ function ct(e, t) {
1117
+ return Ot(e, t);
1844
1118
  }
1845
- var ta = Array.prototype, na = ta.join;
1846
- function qe(e, t) {
1847
- return e == null ? "" : na.call(e, t);
1119
+ var Vn = Array.prototype, Ln = Vn.join;
1120
+ function _e(e, t) {
1121
+ return e == null ? "" : Ln.call(e, t);
1848
1122
  }
1849
- function ra(e, t) {
1123
+ function Jn(e, t) {
1850
1124
  return e < t;
1851
1125
  }
1852
- function En(e, t, n) {
1853
- for (var r = -1, i = e.length; ++r < i; ) {
1854
- var s = e[r], o = t(s);
1855
- if (o != null && (a === void 0 ? o === o && !Z(o) : n(o, a)))
1856
- var a = o, c = s;
1126
+ function at(e, t, n) {
1127
+ for (var s = -1, i = e.length; ++s < i; ) {
1128
+ var r = e[s], o = t(r);
1129
+ if (o != null && (c === void 0 ? o === o && !oe(o) : n(o, c)))
1130
+ var c = o, a = r;
1857
1131
  }
1858
- return c;
1132
+ return a;
1133
+ }
1134
+ function Ue(e, t) {
1135
+ return e && e.length ? at(e, V(t), qn) : void 0;
1859
1136
  }
1860
- function Wt(e, t) {
1861
- return e && e.length ? En(e, W(t), Wo) : void 0;
1137
+ function Yn(e, t) {
1138
+ return e && e.length ? at(e, V(t), Jn) : void 0;
1862
1139
  }
1863
- function ia(e, t) {
1864
- return e && e.length ? En(e, W(t), ra) : void 0;
1140
+ function Gn(e, t, n, s) {
1141
+ if (!G(e))
1142
+ return e;
1143
+ t = Pt(t, e);
1144
+ for (var i = -1, r = t.length, o = r - 1, c = e; c != null && ++i < r; ) {
1145
+ var a = Rt(t[i]), u = n;
1146
+ if (a === "__proto__" || a === "constructor" || a === "prototype")
1147
+ return e;
1148
+ if (i != o) {
1149
+ var l = c[a];
1150
+ u = void 0, u === void 0 && (u = G(l) ? l : Ye(t[i + 1]) ? [] : {});
1151
+ }
1152
+ yn(c, a, u), c = c[a];
1153
+ }
1154
+ return e;
1865
1155
  }
1866
- function sa(e, t) {
1156
+ function Xn(e, t) {
1867
1157
  var n = e.length;
1868
1158
  for (e.sort(t); n--; )
1869
1159
  e[n] = e[n].value;
1870
1160
  return e;
1871
1161
  }
1872
- function oa(e, t) {
1162
+ function Zn(e, t) {
1873
1163
  if (e !== t) {
1874
- var n = e !== void 0, r = e === null, i = e === e, s = Z(e), o = t !== void 0, a = t === null, c = t === t, u = Z(t);
1875
- if (!a && !u && !s && e > t || s && o && c && !a && !u || r && o && c || !n && c || !i)
1164
+ var n = e !== void 0, s = e === null, i = e === e, r = oe(e), o = t !== void 0, c = t === null, a = t === t, u = oe(t);
1165
+ if (!c && !u && !r && e > t || r && o && a && !c && !u || s && o && a || !n && a || !i)
1876
1166
  return 1;
1877
- if (!r && !s && !u && e < t || u && n && i && !r && !s || a && n && i || !o && i || !c)
1167
+ if (!s && !r && !u && e < t || u && n && i && !s && !r || c && n && i || !o && i || !a)
1878
1168
  return -1;
1879
1169
  }
1880
1170
  return 0;
1881
1171
  }
1882
- function aa(e, t, n) {
1883
- for (var r = -1, i = e.criteria, s = t.criteria, o = i.length, a = n.length; ++r < o; ) {
1884
- var c = oa(i[r], s[r]);
1885
- if (c) {
1886
- if (r >= a)
1887
- return c;
1888
- var u = n[r];
1889
- return c * (u == "desc" ? -1 : 1);
1172
+ function kn(e, t, n) {
1173
+ for (var s = -1, i = e.criteria, r = t.criteria, o = i.length, c = n.length; ++s < o; ) {
1174
+ var a = Zn(i[s], r[s]);
1175
+ if (a) {
1176
+ if (s >= c)
1177
+ return a;
1178
+ var u = n[s];
1179
+ return a * (u == "desc" ? -1 : 1);
1890
1180
  }
1891
1181
  }
1892
1182
  return e.index - t.index;
1893
1183
  }
1894
- function ca(e, t, n) {
1895
- t.length ? t = de(t, function(s) {
1896
- return M(s) ? function(o) {
1897
- return _t(o, s.length === 1 ? s[0] : s);
1898
- } : s;
1899
- }) : t = [me];
1900
- var r = -1;
1901
- t = de(t, _n(W));
1902
- var i = An(e, function(s, o, a) {
1903
- var c = de(t, function(u) {
1904
- return u(s);
1184
+ function es(e, t, n) {
1185
+ t.length ? t = de(t, function(r) {
1186
+ return W(r) ? function(o) {
1187
+ return Et(o, r.length === 1 ? r[0] : r);
1188
+ } : r;
1189
+ }) : t = [fe];
1190
+ var s = -1;
1191
+ t = de(t, It(V));
1192
+ var i = Nt(e, function(r, o, c) {
1193
+ var a = de(t, function(u) {
1194
+ return u(r);
1905
1195
  });
1906
- return { criteria: c, index: ++r, value: s };
1196
+ return { criteria: a, index: ++s, value: r };
1907
1197
  });
1908
- return sa(i, function(s, o) {
1909
- return aa(s, o, n);
1198
+ return Xn(i, function(r, o) {
1199
+ return kn(r, o, n);
1910
1200
  });
1911
1201
  }
1912
- var ua = xn("length"), Tn = "\\ud800-\\udfff", la = "\\u0300-\\u036f", fa = "\\ufe20-\\ufe2f", ha = "\\u20d0-\\u20ff", da = la + fa + ha, pa = "\\ufe0e\\ufe0f", _a = "[" + Tn + "]", ke = "[" + da + "]", et = "\\ud83c[\\udffb-\\udfff]", ya = "(?:" + ke + "|" + et + ")", Rn = "[^" + Tn + "]", In = "(?:\\ud83c[\\udde6-\\uddff]){2}", jn = "[\\ud800-\\udbff][\\udc00-\\udfff]", ga = "\\u200d", $n = ya + "?", Fn = "[" + pa + "]?", ba = "(?:" + ga + "(?:" + [Rn, In, jn].join("|") + ")" + Fn + $n + ")*", ma = Fn + $n + ba, Sa = "(?:" + [Rn + ke + "?", ke, In, jn, _a].join("|") + ")", Vt = RegExp(et + "(?=" + et + ")|" + Sa + ma, "g");
1913
- function va(e) {
1914
- for (var t = Vt.lastIndex = 0; Vt.test(e); )
1202
+ var ts = zt("length"), ut = "\\ud800-\\udfff", ns = "\\u0300-\\u036f", ss = "\\ufe20-\\ufe2f", is = "\\u20d0-\\u20ff", rs = ns + ss + is, os = "\\ufe0e\\ufe0f", cs = "[" + ut + "]", Me = "[" + rs + "]", Ce = "\\ud83c[\\udffb-\\udfff]", as = "(?:" + Me + "|" + Ce + ")", lt = "[^" + ut + "]", ft = "(?:\\ud83c[\\udde6-\\uddff]){2}", ht = "[\\ud800-\\udbff][\\udc00-\\udfff]", us = "\\u200d", dt = as + "?", pt = "[" + os + "]?", ls = "(?:" + us + "(?:" + [lt, ft, ht].join("|") + ")" + pt + dt + ")*", fs = pt + dt + ls, hs = "(?:" + [lt + Me + "?", Me, ft, ht, cs].join("|") + ")", Ke = RegExp(Ce + "(?=" + Ce + ")|" + hs + fs, "g");
1203
+ function ds(e) {
1204
+ for (var t = Ke.lastIndex = 0; Ke.test(e); )
1915
1205
  ++t;
1916
1206
  return t;
1917
1207
  }
1918
- function wa(e) {
1919
- return Cs(e) ? va(e) : ua(e);
1208
+ function ps(e) {
1209
+ return In(e) ? ds(e) : ts(e);
1210
+ }
1211
+ function _s(e, t, n) {
1212
+ return e == null ? e : Gn(e, t, n);
1920
1213
  }
1921
- var Oa = "[object Map]", Ca = "[object Set]";
1922
- function oe(e) {
1214
+ var ys = "[object Map]", bs = "[object Set]";
1215
+ function U(e) {
1923
1216
  if (e == null)
1924
1217
  return 0;
1925
- if (ie(e))
1926
- return Jo(e) ? wa(e) : e.length;
1927
- var t = F(e);
1928
- return t == Oa || t == Ca ? e.size : ht(e).length;
1218
+ if (he(e))
1219
+ return $n(e) ? ps(e) : e.length;
1220
+ var t = Ze(e);
1221
+ return t == ys || t == bs ? e.size : ke(e).length;
1929
1222
  }
1930
- var Me = Vr(function(e, t) {
1223
+ var re = mn(function(e, t) {
1931
1224
  if (e == null)
1932
1225
  return [];
1933
1226
  var n = t.length;
1934
- return n > 1 && Pt(e, t[0], t[1]) ? t = [] : n > 2 && Pt(t[0], t[1], t[2]) && (t = [t[0]]), ca(e, Sn(t), []);
1227
+ return n > 1 && $e(e, t[0], t[1]) ? t = [] : n > 2 && $e(t[0], t[1], t[2]) && (t = [t[0]]), es(e, Sn(t), []);
1935
1228
  });
1936
- function Ma(e, t, n) {
1937
- return e && e.length ? (t = t === void 0 ? 1 : ln(t), vn(e, 0, t < 0 ? 0 : t)) : [];
1938
- }
1939
- var xa = 0;
1940
- function Jt(e) {
1941
- var t = ++xa;
1942
- return gn(e) + t;
1943
- }
1944
- const Aa = (e, t) => {
1945
- if (Pn(e)) return [t];
1946
- const n = fe(e);
1947
- return O(n.type, "create") && O(t.type, "delete") ? null : O(n.type, "create") && O(t.type, "update") ? [{ ...n, data: t.data }] : O(n.type, "update") && O(t.type, "update") ? [...Yo(e), t] : O(n.type, "update") && O(t.type, "delete") ? [...e, t] : [t];
1948
- };
1949
- class Pa {
1229
+ function ms(e, t, n) {
1230
+ return e && e.length ? (t = t === void 0 ? 1 : ot(t), wn(e, 0, t < 0 ? 0 : t)) : [];
1231
+ }
1232
+ const gs = (e, t) => e ? e.type === "create" && t.type === "delete" ? null : e.type === "create" && t.type === "update" ? { ...e, data: t.data } : (e.type === "update" && t.type === "update" || e.type === "update" && t.type === "delete", t) : t;
1233
+ class Ss {
1950
1234
  _config;
1951
1235
  _state;
1952
1236
  _subscribers = /* @__PURE__ */ new Set();
@@ -1963,7 +1247,7 @@ class Pa {
1963
1247
  }
1964
1248
  enqueue(t) {
1965
1249
  this._updateState((n) => {
1966
- const r = [...n.queue.get(t.id) ?? []], i = Aa(r, t);
1250
+ const s = n.queue.get(t.id), i = gs(s, t);
1967
1251
  i ? n.queue.set(t.id, i) : n.queue.delete(t.id), n.errors.delete(t.id);
1968
1252
  }), this._scheduleFlush();
1969
1253
  }
@@ -1980,21 +1264,21 @@ class Pa {
1980
1264
  retryAll() {
1981
1265
  const t = this._state.errors;
1982
1266
  t.size !== 0 && (this._updateState((n) => {
1983
- for (const [r, i] of t)
1984
- n.queue.has(r) || n.queue.set(r, i.operations);
1267
+ for (const [s, i] of t)
1268
+ n.queue.has(s) || n.queue.set(s, i.operation);
1985
1269
  n.errors.clear();
1986
1270
  }), this._scheduleFlush());
1987
1271
  }
1988
1272
  retry(t) {
1989
1273
  const n = this._state.errors.get(t);
1990
- n && (this._updateState((r) => {
1991
- r.queue.has(t) || r.queue.set(t, n.operations), r.errors.delete(t);
1274
+ n && (this._updateState((s) => {
1275
+ s.queue.has(t) || s.queue.set(t, n.operation), s.errors.delete(t);
1992
1276
  }), this._scheduleFlush());
1993
1277
  }
1994
1278
  resetRetries(t) {
1995
1279
  this._state.errors.has(t) && this._updateState((n) => {
1996
- const r = n.errors.get(t);
1997
- r && (r.retries = 0);
1280
+ const s = n.errors.get(t);
1281
+ s && (s.retries = 0);
1998
1282
  });
1999
1283
  }
2000
1284
  destroy() {
@@ -2013,7 +1297,7 @@ class Pa {
2013
1297
  return this._subscribers.add(t), () => this._subscribers.delete(t);
2014
1298
  }
2015
1299
  _updateState(t) {
2016
- this._state = I(this._state, t), this._subscribers.forEach((n) => n());
1300
+ this._state = P(this._state, t), this._subscribers.forEach((n) => n());
2017
1301
  }
2018
1302
  _scheduleFlush() {
2019
1303
  this._state.isPaused || this._state.isSyncing || (this._clearTimer(), this._debounceTimer = setTimeout(() => this._flush(), this._config.debounce));
@@ -2021,97 +1305,66 @@ class Pa {
2021
1305
  _clearTimer() {
2022
1306
  this._debounceTimer && (clearTimeout(this._debounceTimer), this._debounceTimer = null);
2023
1307
  }
2024
- /**
2025
- * Flush pending changes to the server.
2026
- *
2027
- * Flow:
2028
- * 1. Move queued items to inFlight (atomic swap prevents duplicate sends)
2029
- * 2. Flatten all changes and optionally batch by batchSize
2030
- * 3. Send to server via onSync callback
2031
- * 4. Process results (handle success, retries, ID remapping)
2032
- * 5. Schedule next flush if more items queued
2033
- */
2034
1308
  async _flush() {
2035
- const { isPaused: t, isSyncing: n, queue: r } = this._state;
2036
- if (t || n || O(oe(r), 0)) return;
2037
- const i = m(this._config, "batchSize", 1 / 0), s = [...r.entries()], o = Ma(s, i), a = s.slice(oe(o));
1309
+ const { isPaused: t, isSyncing: n, queue: s } = this._state;
1310
+ if (t || n || Wn(s)) return;
1311
+ const i = z(this._config, "batchSize", 1 / 0), r = [...s.entries()], o = ms(r, i), c = r.slice(U(o));
2038
1312
  this._updateState((l) => {
2039
- l.inFlight = new Map(o), l.queue = new Map(a), l.isSyncing = !0;
1313
+ l.inFlight = new Map(o), l.queue = new Map(c), l.isSyncing = !0;
2040
1314
  });
2041
- const c = Go([...this._state.inFlight.values()]), u = this._config.getContext?.();
1315
+ const a = [...this._state.inFlight.values()], u = this._config.getContext?.();
2042
1316
  this._abortController = new AbortController();
2043
1317
  try {
2044
- const l = await this._config.onSync(c, u, this._abortController.signal);
2045
- this._processResults(Ko(Y(l, (f) => [f.id, f])));
1318
+ const l = await this._config.onSync(a, u, this._abortController.signal);
1319
+ this._processResponse(l);
2046
1320
  } catch (l) {
2047
1321
  this._handleError(l);
2048
1322
  }
2049
- this._abortController = null, oe(this._state.queue) > 0 && !this._state.isPaused && this._scheduleFlush();
2050
- }
2051
- /**
2052
- * Process sync results and update state accordingly.
2053
- *
2054
- * For each item in flight:
2055
- * - If ALL operations succeeded: clear errors, collect ID remappings
2056
- * - If ANY operation failed: increment retry counter, re-queue if under maxRetries
2057
- *
2058
- * ID Remapping: When server assigns new IDs to created items (e.g., temp ID -> DB ID),
2059
- * we collect these mappings and notify via onIdRemap callback so the collection
2060
- * can update its local state.
2061
- */
2062
- _processResults(t) {
2063
- const n = this._state.inFlight, r = [];
2064
- this._updateState((i) => {
2065
- for (const [s, o] of n)
2066
- if (Ho(
2067
- o,
2068
- (c) => O(m(t, [c.id, "status"]), "success")
2069
- ))
2070
- i.errors.delete(s), Oe(o, (c) => {
2071
- const u = m(t, c.id);
2072
- O(c.type, "create") && m(u, "newId") && !O(m(u, "newId"), c.id) && r.push({ tempId: c.id, newId: u.newId });
2073
- });
1323
+ this._abortController = null, U(this._state.queue) > 0 && !this._state.isPaused && this._scheduleFlush();
1324
+ }
1325
+ _processResponse(t) {
1326
+ const n = this._state.inFlight, s = new Map((t.syncResults ?? []).map((i) => [i.id, i]));
1327
+ if (this._updateState((i) => {
1328
+ for (const [r, o] of n) {
1329
+ const c = s.get(r);
1330
+ if (c?.status === "success")
1331
+ i.errors.delete(r);
2074
1332
  else {
2075
- const c = m(i.errors.get(s), "retries", 0) + 1;
2076
- c < this._config.maxRetries && !i.queue.has(s) && i.queue.set(s, o);
2077
- const u = Ze(o, (l) => !O(m(t, [l.id, "status"]), "success"));
2078
- i.errors.set(s, {
2079
- error: m(t, [m(u, "id", ""), "error"], "Unknown error"),
2080
- retries: c,
2081
- operations: o
1333
+ const a = (i.errors.get(r)?.retries ?? 0) + 1;
1334
+ a < this._config.maxRetries && !i.queue.has(r) && i.queue.set(r, o), i.errors.set(r, {
1335
+ error: c?.error ?? "Unknown error",
1336
+ retries: a,
1337
+ operation: o
2082
1338
  });
2083
1339
  }
1340
+ }
2084
1341
  i.inFlight = /* @__PURE__ */ new Map(), i.isSyncing = !1;
2085
- }), !Pn(r) && this._config.onIdRemap && this._config.onIdRemap(r);
1342
+ }), this._config.onServerItems && U(t.items) > 0) {
1343
+ const i = new Set((t.syncResults ?? []).map((o) => o.id)), r = (t.items ?? []).filter(
1344
+ (o) => !i.has(o.id)
1345
+ );
1346
+ U(r) > 0 && this._config.onServerItems(r);
1347
+ }
2086
1348
  }
2087
- /**
2088
- * Handle network or unexpected errors during sync.
2089
- *
2090
- * Two scenarios:
2091
- * 1. Aborted (e.g., SyncQueue destroyed): Re-queue all items without incrementing retries
2092
- * 2. Actual error: Increment retries, re-queue if under limit, record error
2093
- *
2094
- * This ensures no data loss - failed operations are preserved for retry.
2095
- */
2096
1349
  _handleError(t) {
2097
- const n = this._state.inFlight, r = m(this._abortController, "signal.aborted", !1), i = t instanceof Error ? t.message : String(t);
2098
- this._updateState((s) => {
2099
- for (const [o, a] of n)
2100
- if (r)
2101
- s.queue.has(o) || s.queue.set(o, a);
1350
+ const n = this._state.inFlight, s = z(this._abortController, "signal.aborted", !1), i = t instanceof Error ? t.message : String(t);
1351
+ this._updateState((r) => {
1352
+ for (const [o, c] of n)
1353
+ if (s)
1354
+ r.queue.has(o) || r.queue.set(o, c);
2102
1355
  else {
2103
- const c = m(s.errors.get(o), "retries", 0) + 1;
2104
- c < this._config.maxRetries && !s.queue.has(o) && s.queue.set(o, a), s.errors.set(o, {
1356
+ const a = (r.errors.get(o)?.retries ?? 0) + 1;
1357
+ a < this._config.maxRetries && !r.queue.has(o) && r.queue.set(o, c), r.errors.set(o, {
2105
1358
  error: i,
2106
- retries: c,
2107
- operations: a
1359
+ retries: a,
1360
+ operation: c
2108
1361
  });
2109
1362
  }
2110
- s.inFlight = /* @__PURE__ */ new Map(), s.isSyncing = !1;
1363
+ r.inFlight = /* @__PURE__ */ new Map(), r.isSyncing = !1;
2111
1364
  });
2112
1365
  }
2113
1366
  }
2114
- class Ea {
1367
+ class ws {
2115
1368
  _cache = /* @__PURE__ */ new Map();
2116
1369
  _capacity;
2117
1370
  _ttl;
@@ -2126,8 +1379,8 @@ class Ea {
2126
1379
  if (this._cache.has(t))
2127
1380
  this._cache.delete(t);
2128
1381
  else if (this._cache.size >= this._capacity) {
2129
- const r = this._cache.keys().next().value;
2130
- r !== void 0 && this._cache.delete(r);
1382
+ const s = this._cache.keys().next().value;
1383
+ s !== void 0 && this._cache.delete(s);
2131
1384
  }
2132
1385
  this._cache.set(t, { data: n, ts: Date.now() });
2133
1386
  }
@@ -2144,7 +1397,7 @@ class Ea {
2144
1397
  return this._cache.size;
2145
1398
  }
2146
1399
  }
2147
- class Ta {
1400
+ class vs {
2148
1401
  _config;
2149
1402
  _cache;
2150
1403
  _state = { status: "idle", items: [] };
@@ -2152,43 +1405,43 @@ class Ta {
2152
1405
  _abortController = null;
2153
1406
  _currentContext = null;
2154
1407
  constructor(t) {
2155
- this._config = { retries: 0, ...t }, this._cache = new Ea(t.cacheCapacity, t.cacheTtl);
1408
+ this._config = { retries: 0, ...t }, this._cache = new ws(t.cacheCapacity, t.cacheTtl);
2156
1409
  }
2157
1410
  _getCacheKey = (t) => JSON.stringify([this._config.id, t]);
2158
1411
  _setState(t) {
2159
- this._state = I(this._state, (n) => {
1412
+ this._state = P(this._state, (n) => {
2160
1413
  Object.assign(n, t);
2161
1414
  }), this._subscribers.forEach((n) => n());
2162
1415
  }
2163
1416
  async _fetchWithRetry(t, n) {
2164
- const r = this._config.retries;
1417
+ const s = this._config.retries;
2165
1418
  let i;
2166
- for (let s = 0; s <= r; s++) {
1419
+ for (let r = 0; r <= s; r++) {
2167
1420
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
2168
1421
  try {
2169
- return s > 0 && this._setState({ retryCount: s }), await this._config.onFetch(t, n);
1422
+ return r > 0 && this._setState({ retryCount: r }), await this._config.onFetch(t, n);
2170
1423
  } catch (o) {
2171
- if (i = o, n.aborted || s === r) throw o;
1424
+ if (i = o, n.aborted || r === s) throw o;
2172
1425
  }
2173
1426
  }
2174
1427
  throw i;
2175
1428
  }
2176
1429
  async fetch(t) {
2177
- const n = this._getCacheKey(t), r = this._cache.get(n);
2178
- if (r !== null)
2179
- return this._currentContext = t, this._setState({ status: "idle", items: r, error: void 0, retryCount: void 0 }), r;
1430
+ const n = this._getCacheKey(t), s = this._cache.get(n);
1431
+ if (s !== null)
1432
+ return this._currentContext = t, this._setState({ status: "idle", items: s, error: void 0, retryCount: void 0 }), s;
2180
1433
  this._abortController?.abort("New fetch request started");
2181
1434
  const i = new AbortController();
2182
1435
  this._abortController = i, this._currentContext = t, this._setState({ status: "fetching", error: void 0, retryCount: void 0 });
2183
1436
  try {
2184
- const s = await this._fetchWithRetry(t, i.signal);
2185
- return this._cache.set(n, s), this._abortController = null, this._setState({ status: "idle", items: s, error: void 0, retryCount: void 0 }), s;
2186
- } catch (s) {
1437
+ const r = await this._fetchWithRetry(t, i.signal);
1438
+ return this._cache.set(n, r), this._abortController = null, this._setState({ status: "idle", items: r, error: void 0, retryCount: void 0 }), r;
1439
+ } catch (r) {
2187
1440
  if (i.signal.aborted) return this._state.items;
2188
1441
  throw this._abortController = null, this._setState({
2189
1442
  status: "error",
2190
- error: s instanceof Error ? s.message : String(s)
2191
- }), s;
1443
+ error: r instanceof Error ? r.message : String(r)
1444
+ }), r;
2192
1445
  }
2193
1446
  }
2194
1447
  async refresh(t) {
@@ -2214,7 +1467,7 @@ class Ta {
2214
1467
  };
2215
1468
  }
2216
1469
  }
2217
- class Yt {
1470
+ class We {
2218
1471
  _collection;
2219
1472
  _id;
2220
1473
  _cachedStatus = null;
@@ -2235,36 +1488,30 @@ class Yt {
2235
1488
  }
2236
1489
  getStatus() {
2237
1490
  const t = this._collection.getItemStatus(this._id);
2238
- return O(this._cachedStatus, t) || (this._cachedStatus = t), this._cachedStatus;
1491
+ return ct(this._cachedStatus, t) || (this._cachedStatus = t), this._cachedStatus;
2239
1492
  }
2240
1493
  exists() {
2241
1494
  return this._collection.getState().items.has(this._id);
2242
1495
  }
2243
- // Expose collection for useItem hook
2244
1496
  get collection() {
2245
1497
  return this._collection;
2246
1498
  }
2247
- // Internal method to update ID after server assigns permanent ID
2248
- // Called by Collection when handling ID remapping
2249
- _updateId(t) {
2250
- this._id = t;
2251
- }
2252
1499
  }
2253
- const Ra = ".";
2254
- function Xt(e, t) {
1500
+ const Ms = ".";
1501
+ function H(e, t) {
2255
1502
  const n = e.lastIndexOf(t);
2256
1503
  return n === -1 ? null : e.slice(0, n);
2257
1504
  }
2258
- function Ia(e, t, n) {
1505
+ function Cs(e, t, n) {
2259
1506
  return e.startsWith(t + n) ? !e.slice(t.length + 1).includes(n) : !1;
2260
1507
  }
2261
- function Qe(e, t, n) {
1508
+ function ye(e, t, n) {
2262
1509
  return e.startsWith(t + n);
2263
1510
  }
2264
- function Zt(e, t) {
1511
+ function Ve(e, t) {
2265
1512
  return e.split(t).length - 1;
2266
1513
  }
2267
- class kt {
1514
+ class Le {
2268
1515
  _id;
2269
1516
  _collection;
2270
1517
  _cachedStatus = null;
@@ -2272,7 +1519,7 @@ class kt {
2272
1519
  this._collection = t, this._id = n;
2273
1520
  }
2274
1521
  get _separator() {
2275
- return this._collection.config.nodeSeparator ?? Ra;
1522
+ return this._collection.config.nodeSeparator ?? Ms;
2276
1523
  }
2277
1524
  get id() {
2278
1525
  return this._id;
@@ -2284,37 +1531,100 @@ class kt {
2284
1531
  return this._collection;
2285
1532
  }
2286
1533
  get depth() {
2287
- return Zt(this._id, this._separator);
1534
+ return Ve(this._id, this._separator);
2288
1535
  }
2289
1536
  exists() {
2290
1537
  return this._collection.getState().items.has(this._id);
2291
1538
  }
2292
1539
  getStatus() {
2293
1540
  const t = this._collection.getItemStatus(this._id);
2294
- return O(this._cachedStatus, t) || (this._cachedStatus = t), this._cachedStatus;
1541
+ return ct(this._cachedStatus, t) || (this._cachedStatus = t), this._cachedStatus;
1542
+ }
1543
+ _touch(t) {
1544
+ this._collection.items.has(t) && this._collection.update(t, (n) => {
1545
+ n.clientUpdatedAt = Date.now();
1546
+ });
2295
1547
  }
2296
1548
  getParent() {
2297
- const t = Xt(this._id, this._separator);
1549
+ const t = H(this._id, this._separator);
2298
1550
  return t ? this._collection.getNode(t) : null;
2299
1551
  }
2300
1552
  getChildren() {
2301
- const t = [...this._collection.items.entries()], n = Y(
2302
- Ce(t, ([i]) => Ia(i, this._id, this._separator)),
2303
- ([i, s]) => ({ id: i, position: s.position })
2304
- ), r = Me(n, "position");
2305
- return Y(r, (i) => this._collection.getNode(i.id));
1553
+ const t = [...this._collection.items.entries()], n = K(
1554
+ se(t, ([i]) => Cs(i, this._id, this._separator)),
1555
+ ([i, r]) => ({ id: i, position: r.position })
1556
+ ), s = re(n, "position");
1557
+ return K(s, (i) => this._collection.getNode(i.id));
2306
1558
  }
2307
1559
  _generateChildId() {
2308
- const { getNodeId: t } = this._collection.config, n = t ? t() : Jt();
2309
- return qe([this._id, n], this._separator);
1560
+ const { getNodeId: t } = this._collection.config, n = t ? t() : be();
1561
+ return _e([this._id, n], this._separator);
1562
+ }
1563
+ moveUp() {
1564
+ const t = this.data;
1565
+ if (!t) return;
1566
+ const n = H(this._id, this._separator);
1567
+ if (!n) return;
1568
+ const i = this._collection.getNode(n).getChildren(), r = ie(i, (u) => u.id === this._id);
1569
+ if (r <= 0) return;
1570
+ const o = i[r - 1], c = o.data;
1571
+ if (!c) return;
1572
+ const a = t.position;
1573
+ this._collection.batch(() => {
1574
+ this._collection.update(o.id, (u) => {
1575
+ u.position = a;
1576
+ }), this._collection.update(this._id, (u) => {
1577
+ u.position = c.position;
1578
+ }), this._touch(n);
1579
+ });
1580
+ }
1581
+ moveDown() {
1582
+ const t = this.data;
1583
+ if (!t) return;
1584
+ const n = H(this._id, this._separator);
1585
+ if (!n) return;
1586
+ const i = this._collection.getNode(n).getChildren(), r = ie(i, (u) => u.id === this._id);
1587
+ if (r === -1 || r >= U(i) - 1) return;
1588
+ const o = i[r + 1], c = o.data;
1589
+ if (!c) return;
1590
+ const a = t.position;
1591
+ this._collection.batch(() => {
1592
+ this._collection.update(o.id, (u) => {
1593
+ u.position = a;
1594
+ }), this._collection.update(this._id, (u) => {
1595
+ u.position = c.position;
1596
+ }), this._touch(n);
1597
+ });
1598
+ }
1599
+ setPosition(t) {
1600
+ if (!this.data) return;
1601
+ const s = H(this._id, this._separator);
1602
+ if (!s) return;
1603
+ const r = this._collection.getNode(s).getChildren(), o = ie(r, (l) => l.id === this._id);
1604
+ if (o === -1) return;
1605
+ const c = zn(t, 0, U(r) - 1);
1606
+ if (c === o) return;
1607
+ const a = [...r], [u] = a.splice(o, 1);
1608
+ a.splice(c, 0, u), this._collection.batch(() => {
1609
+ k(a, (l, f) => {
1610
+ const y = l.data;
1611
+ y && y.position !== f && this._collection.update(l.id, (p) => {
1612
+ p.position = f;
1613
+ });
1614
+ }), this._touch(s);
1615
+ });
2310
1616
  }
2311
1617
  append(t, n = "object") {
2312
- const r = this.getChildren(), i = Wt(r, (u) => m(u, "data.position", 0)), o = (i ? m(i, "data.position", 0) : -1) + 1, a = this._generateChildId(), c = { id: a, position: o, value: t, type: n };
2313
- return this._collection.create(c), a;
1618
+ const s = this.getChildren(), i = Ue(s, (u) => z(u, "data.position", 0)), o = (i ? z(i, "data.position", 0) : -1) + 1, c = this._generateChildId(), a = { id: c, position: o, value: t, type: n };
1619
+ return this._collection.batch(() => {
1620
+ this._collection.create(a), this._touch(this._id);
1621
+ }), c;
2314
1622
  }
2315
1623
  prepend(t, n = "object") {
2316
- const r = this.getChildren(), i = ia(r, (u) => m(u, "data.position", 0)), o = (i ? m(i, "data.position", 0) : 1) - 1, a = this._generateChildId(), c = { id: a, position: o, value: t, type: n };
2317
- return this._collection.create(c), a;
1624
+ const s = this.getChildren(), i = Yn(s, (u) => z(u, "data.position", 0)), o = (i ? z(i, "data.position", 0) : 1) - 1, c = this._generateChildId(), a = { id: c, position: o, value: t, type: n };
1625
+ return this._collection.batch(() => {
1626
+ this._collection.create(a), this._touch(this._id);
1627
+ }), c;
2318
1628
  }
2319
1629
  /**
2320
1630
  * Move node to a new position within the same parent (reordering)
@@ -2324,20 +1634,20 @@ class kt {
2324
1634
  * @param targetParent - Optional target parent node. If not provided, moves within current parent.
2325
1635
  */
2326
1636
  move(t, n) {
2327
- const r = this.data;
2328
- if (!r) return;
2329
- const i = Xt(this._id, this._separator);
1637
+ const s = this.data;
1638
+ if (!s) return;
1639
+ const i = H(this._id, this._separator);
2330
1640
  if (!i) return;
2331
1641
  if (!n) {
2332
- const o = r.position;
1642
+ const o = s.position;
2333
1643
  if (o === t) return;
2334
- const c = this._collection.getNode(i).getChildren(), u = Ze(c, (l) => m(l, "data.position") === t);
1644
+ const a = this._collection.getNode(i).getChildren(), u = Be(a, (l) => z(l, "data.position") === t);
2335
1645
  this._collection.batch(() => {
2336
1646
  u && this._collection.update(u.id, (l) => {
2337
1647
  l.position = o;
2338
1648
  }), this._collection.update(this._id, (l) => {
2339
1649
  l.position = t;
2340
- });
1650
+ }), this._touch(i);
2341
1651
  });
2342
1652
  return;
2343
1653
  }
@@ -2345,11 +1655,11 @@ class kt {
2345
1655
  this.move(t);
2346
1656
  return;
2347
1657
  }
2348
- if (n.id === this._id || Qe(n.id, this._id, this._separator))
1658
+ if (n.id === this._id || ye(n.id, this._id, this._separator))
2349
1659
  return;
2350
- const s = this.clone();
1660
+ const r = this.clone();
2351
1661
  this._collection.batch(() => {
2352
- n._mergeClonedSubset(s, t), this.remove();
1662
+ n._mergeClonedSubset(r, t), this.remove();
2353
1663
  });
2354
1664
  }
2355
1665
  /**
@@ -2360,19 +1670,19 @@ class kt {
2360
1670
  clone() {
2361
1671
  const t = this.data;
2362
1672
  if (!t) return /* @__PURE__ */ new Map();
2363
- const { getNodeId: n } = this._collection.config, r = n ? n() : Jt(), i = /* @__PURE__ */ new Map();
2364
- i.set(r, {
2365
- id: r,
1673
+ const { getNodeId: n } = this._collection.config, s = n ? n() : be(), i = /* @__PURE__ */ new Map();
1674
+ i.set(s, {
1675
+ id: s,
2366
1676
  position: t.position,
2367
1677
  value: t.value,
2368
1678
  type: t.type
2369
1679
  });
2370
- const s = Ce(
1680
+ const r = se(
2371
1681
  [...this._collection.items.entries()],
2372
- ([o]) => Qe(o, this._id, this._separator)
1682
+ ([o]) => ye(o, this._id, this._separator)
2373
1683
  );
2374
- return Oe(s, ([o, a]) => {
2375
- const c = o.slice(this._id.length + 1), u = qe([r, c], this._separator), l = a;
1684
+ return k(r, ([o, c]) => {
1685
+ const a = o.slice(this._id.length + 1), u = _e([s, a], this._separator), l = c;
2376
1686
  i.set(u, {
2377
1687
  id: u,
2378
1688
  position: l.position,
@@ -2387,33 +1697,33 @@ class kt {
2387
1697
  */
2388
1698
  _mergeClonedSubset(t, n) {
2389
1699
  if (t.size === 0) return;
2390
- const r = [...t.keys()];
2391
- let i = Ze(r, (a) => !a.includes(this._separator));
2392
- if (i || (i = Uo(Me(r, (a) => a.length))), !i) return;
2393
- const s = this._generateChildId();
1700
+ const s = [...t.keys()];
1701
+ let i = Be(s, (c) => !c.includes(this._separator));
1702
+ if (i || (i = Tn(re(s, (c) => c.length))), !i) return;
1703
+ const r = this._generateChildId();
2394
1704
  let o;
2395
1705
  if (n !== void 0)
2396
1706
  o = n;
2397
1707
  else {
2398
- const a = this.getChildren(), c = Wt(a, (l) => m(l, "data.position", 0));
2399
- o = (c ? m(c, "data.position", 0) : -1) + 1;
1708
+ const c = this.getChildren(), a = Ue(c, (l) => z(l, "data.position", 0));
1709
+ o = (a ? z(a, "data.position", 0) : -1) + 1;
2400
1710
  }
2401
- return Oe([...t.entries()], ([a, c]) => {
1711
+ return k([...t.entries()], ([c, a]) => {
2402
1712
  let u;
2403
- if (a === i)
2404
- u = s;
1713
+ if (c === i)
1714
+ u = r;
2405
1715
  else {
2406
- const f = a.slice(i.length);
2407
- u = qe([s, f.slice(this._separator.length)], this._separator);
1716
+ const f = c.slice(i.length);
1717
+ u = _e([r, f.slice(this._separator.length)], this._separator);
2408
1718
  }
2409
1719
  const l = {
2410
1720
  id: u,
2411
- position: a === i ? o : c.position,
2412
- value: c.value,
2413
- type: c.type
1721
+ position: c === i ? o : a.position,
1722
+ value: a.value,
1723
+ type: a.type
2414
1724
  };
2415
1725
  this._collection.create(l);
2416
- }), s;
1726
+ }), this._touch(this._id), r;
2417
1727
  }
2418
1728
  updateProp(t) {
2419
1729
  this._collection.update(this._id, (n) => {
@@ -2421,45 +1731,58 @@ class kt {
2421
1731
  });
2422
1732
  }
2423
1733
  remove() {
2424
- const t = [...this._collection.items.keys()], n = Y(
2425
- Ce(t, (i) => Qe(i, this._id, this._separator)),
2426
- (i) => i
2427
- ), r = [this._id, ...n];
1734
+ const t = H(this._id, this._separator), n = [...this._collection.items.keys()], s = K(
1735
+ se(n, (r) => ye(r, this._id, this._separator)),
1736
+ (r) => r
1737
+ ), i = [this._id, ...s];
2428
1738
  this._collection.batch(() => {
2429
- const i = Me(r, (s) => -Zt(s, this._separator));
2430
- Oe(i, (s) => this._collection.remove(s));
1739
+ const r = re(i, (o) => -Ve(o, this._separator));
1740
+ k(r, (o) => this._collection.remove(o)), t && this._touch(t);
2431
1741
  });
2432
1742
  }
2433
1743
  select() {
2434
1744
  this._collection.selectNode(this._id);
2435
1745
  }
2436
- _updateId(t) {
2437
- this._id = t;
2438
- }
2439
1746
  }
2440
- class R {
2441
- // Global cache of collection instances by id
1747
+ function _t(e) {
1748
+ const t = /* @__PURE__ */ new Map();
1749
+ if (e.serverItems)
1750
+ for (const n of e.serverItems)
1751
+ t.set(n.id, n);
1752
+ return {
1753
+ context: e.initialContext,
1754
+ items: t,
1755
+ syncState: "idle",
1756
+ loading: !1,
1757
+ syncing: !1,
1758
+ syncQueue: {
1759
+ queue: /* @__PURE__ */ new Map(),
1760
+ inFlight: /* @__PURE__ */ new Map(),
1761
+ errors: /* @__PURE__ */ new Map(),
1762
+ isSyncing: !1,
1763
+ isPaused: !1
1764
+ },
1765
+ fetchStatus: "idle",
1766
+ fetchError: void 0
1767
+ };
1768
+ }
1769
+ class O {
2442
1770
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2443
1771
  static _cache = /* @__PURE__ */ new Map();
2444
- // Get or create a collection instance
2445
1772
  static get(t) {
2446
- const n = R._cache.get(t.id);
2447
- if (n)
2448
- return n;
2449
- const r = new R(t);
2450
- return R._cache.set(t.id, r), r;
1773
+ const n = O._cache.get(t.id);
1774
+ if (n) return n;
1775
+ const s = new O(t);
1776
+ return O._cache.set(t.id, s), s;
2451
1777
  }
2452
- // Clear a specific collection from cache
2453
1778
  static clear(t) {
2454
- R._cache.delete(t);
1779
+ O._cache.get(t)?.destroy();
2455
1780
  }
2456
- // Clear all collections from cache
2457
1781
  static clearAll() {
2458
- R._cache.clear();
1782
+ O._cache.forEach((t) => t.destroy());
2459
1783
  }
2460
- // Get existing collection by ID (returns undefined if not found)
2461
1784
  static getById(t) {
2462
- return R._cache.get(t);
1785
+ return O._cache.get(t);
2463
1786
  }
2464
1787
  id;
2465
1788
  config;
@@ -2475,37 +1798,39 @@ class R {
2475
1798
  _batchMode = !1;
2476
1799
  constructor(t) {
2477
1800
  this.id = t.id, this.config = t;
2478
- const n = async (s) => s.map((o) => ({ id: o.id, status: "success" }));
2479
- this._syncQueue = new Pa({
1801
+ const n = t.handler ? (o, c) => t.handler({ query: o }, c).then((a) => a.items ?? []) : async () => [], s = t.handler ? (o, c, a) => t.handler({ changes: o }, a) : async (o) => ({
1802
+ syncResults: K(o, (c) => ({
1803
+ status: "success",
1804
+ id: c.id,
1805
+ type: c.type,
1806
+ serverSyncedAt: ""
1807
+ })),
1808
+ serverSyncedAt: ""
1809
+ });
1810
+ this._syncQueue = new Ss({
2480
1811
  debounce: t.syncDebounce ?? 300,
2481
1812
  maxRetries: t.syncRetries ?? 3,
2482
1813
  getContext: () => this._state.context,
2483
- onSync: t.onSync ?? n,
2484
- onIdRemap: (s) => this._handleIdRemap(s)
2485
- }), this._fetchHandler = new Ta({
1814
+ onSync: s
1815
+ }), this._fetchHandler = new vs({
2486
1816
  id: t.id,
2487
1817
  cacheCapacity: t.cacheCapacity ?? 10,
2488
1818
  cacheTtl: t.cacheTtl ?? 6e4,
2489
1819
  retries: t.fetchRetries ?? 0,
2490
- onFetch: t.onFetch
1820
+ onFetch: n
2491
1821
  });
2492
- const r = this._syncQueue.getState(), i = this._fetchHandler.getState();
1822
+ const i = this._syncQueue.getState(), r = this._fetchHandler.getState();
2493
1823
  this._state = {
2494
1824
  context: t.initialContext,
2495
1825
  items: /* @__PURE__ */ new Map(),
2496
1826
  syncState: "idle",
2497
1827
  loading: !1,
2498
1828
  syncing: !1,
2499
- syncQueue: r,
2500
- fetchStatus: i.status,
2501
- fetchError: i.error
2502
- }, this._syncQueue.subscribe(() => {
2503
- this._onSyncQueueChange();
2504
- }), this._fetchHandler.subscribe(() => {
2505
- this._onFetchChange();
2506
- }), this._initialFetch();
2507
- }
2508
- // Getters for convenience (read from state)
1829
+ syncQueue: i,
1830
+ fetchStatus: r.status,
1831
+ fetchError: r.error
1832
+ }, this._syncQueue.subscribe(() => this._onSyncQueueChange()), this._fetchHandler.subscribe(() => this._onFetchChange()), this._initialFetch();
1833
+ }
2509
1834
  get context() {
2510
1835
  return this._state.context;
2511
1836
  }
@@ -2521,94 +1846,82 @@ class R {
2521
1846
  get syncQueue() {
2522
1847
  return this._state.syncQueue;
2523
1848
  }
2524
- // Subscribe to state changes
2525
1849
  subscribe(t) {
2526
- return this._subscribers.add(t), () => {
2527
- this._subscribers.delete(t);
2528
- };
1850
+ return this._subscribers.add(t), () => this._subscribers.delete(t);
2529
1851
  }
2530
- // Get current state (for useSyncExternalStore) - returns cached reference
2531
1852
  getState() {
2532
1853
  return this._state;
2533
1854
  }
2534
- // Get item status from sync queue state
2535
1855
  getItemStatus(t) {
2536
- const { queue: n, inFlight: r, errors: i } = this._state.syncQueue, s = r.get(t), o = fe(s);
2537
- if (o)
1856
+ const { queue: n, inFlight: s, errors: i } = this._state.syncQueue, r = s.get(t);
1857
+ if (r)
2538
1858
  return {
2539
- type: o.type,
1859
+ type: r.type,
2540
1860
  status: "syncing",
2541
- retries: m(i.get(t), "retries", 0)
1861
+ retries: i.get(t)?.retries ?? 0
2542
1862
  };
2543
- const a = n.get(t), c = fe(a);
2544
- if (c) {
2545
- const l = i.get(t);
1863
+ const o = n.get(t);
1864
+ if (o) {
1865
+ const a = i.get(t);
2546
1866
  return {
2547
- type: c.type,
2548
- status: l ? "error" : "pending",
2549
- retries: m(l, "retries", 0),
2550
- error: m(l, "error")
1867
+ type: o.type,
1868
+ status: a ? "error" : "pending",
1869
+ retries: a?.retries ?? 0,
1870
+ error: a?.error
2551
1871
  };
2552
1872
  }
2553
- const u = i.get(t);
2554
- return u ? {
1873
+ const c = i.get(t);
1874
+ return c ? {
2555
1875
  type: "update",
2556
1876
  status: "error",
2557
- retries: u.retries,
2558
- error: u.error
1877
+ retries: c.retries,
1878
+ error: c.error
2559
1879
  } : null;
2560
1880
  }
2561
- // Create a new item (local-first)
2562
1881
  create(t) {
2563
- const n = this.config.getId(t);
2564
- this._state = I(this._state, (r) => {
2565
- r.items.set(n, t);
2566
- }), this._fetchHandler.invalidateCache(), this._notifySubscribers(), this._syncQueue.enqueue({ id: n, type: "create", data: t });
1882
+ const { id: n } = t;
1883
+ return this._state = P(this._state, (s) => {
1884
+ s.items.set(n, t);
1885
+ }), this._fetchHandler.invalidateCache(), this._notifySubscribers(), this._syncQueue.enqueue({ id: n, type: "create", data: t }), n;
2567
1886
  }
2568
- // Update an existing item (local-first)
2569
1887
  update(t, n) {
2570
- const r = this._state.items.get(t);
2571
- if (!r) return;
2572
- const i = I(r, n);
2573
- this._state = I(this._state, (s) => {
2574
- s.items.set(t, i);
1888
+ const s = this._state.items.get(t);
1889
+ if (!s) return;
1890
+ const i = P(s, n);
1891
+ this._state = P(this._state, (r) => {
1892
+ _s(i, "id", t), r.items.set(t, i);
2575
1893
  }), this._fetchHandler.invalidateCache(), this._notifySubscribers(), this._syncQueue.enqueue({ id: t, type: "update", data: i });
2576
1894
  }
2577
- // Remove an item (local-first)
2578
1895
  remove(t) {
2579
1896
  const n = this._state.items.get(t);
2580
- n && (this._state = I(this._state, (r) => {
2581
- r.items.delete(t);
1897
+ n && (this._state = P(this._state, (s) => {
1898
+ s.items.delete(t);
2582
1899
  }), this._fetchHandler.invalidateCache(), this._notifySubscribers(), this._syncQueue.enqueue({ id: t, type: "delete", data: n }));
2583
1900
  }
2584
- // Get Item reference (cached by data object)
2585
1901
  getItem(t) {
2586
1902
  const n = this._state.items.get(t);
2587
- if (!n)
2588
- return new Yt(this, t);
2589
- const r = n;
2590
- let i = this._itemCache.get(r);
2591
- return i || (i = new Yt(this, t), this._itemCache.set(r, i)), i;
1903
+ if (!n) return new We(this, t);
1904
+ const s = n;
1905
+ let i = this._itemCache.get(s);
1906
+ return i || (i = new We(this, t), this._itemCache.set(s, i)), i;
2592
1907
  }
2593
- // Get Node reference (cached by data object) - for tree collections
2594
1908
  getNode(t) {
2595
1909
  const n = this._state.items.get(t);
2596
1910
  if (!n)
2597
- return new kt(this, t);
2598
- const r = n;
2599
- let i = this._nodeCache.get(r);
2600
- return i || (i = new kt(this, t), this._nodeCache.set(r, i)), i;
1911
+ return new Le(this, t);
1912
+ const s = n;
1913
+ let i = this._nodeCache.get(s);
1914
+ return i || (i = new Le(this, t), this._nodeCache.set(s, i)), i;
2601
1915
  }
2602
- // Execute multiple operations with single notification at the end
2603
1916
  batch(t) {
1917
+ const n = this._batchMode;
2604
1918
  this._batchMode = !0;
2605
1919
  try {
2606
1920
  t();
2607
1921
  } finally {
2608
- this._batchMode = !1, this._notifySubscribers();
1922
+ this._batchMode = n, n || this._notifySubscribers();
2609
1923
  }
2610
1924
  }
2611
- // Selection methods for tree nodes
2612
1925
  selectNode(t) {
2613
1926
  this._selectedNodeId !== t && (this._selectedNodeId = t, this._notifySubscribers());
2614
1927
  }
@@ -2622,18 +1935,15 @@ class R {
2622
1935
  get selectedNode() {
2623
1936
  return this._selectedNodeId ? this.getNode(this._selectedNodeId) : null;
2624
1937
  }
2625
- // Update context and refetch
2626
1938
  setContext(t) {
2627
- const n = this._state.context, r = I(n, t);
2628
- n !== r && (this._state = I(this._state, (i) => {
2629
- i.context = r;
2630
- }), this._fetchHandler.fetch(r), this._notifySubscribers());
1939
+ const n = this._state.context, s = P(n, t);
1940
+ n !== s && (this._state = P(this._state, (i) => {
1941
+ i.context = s;
1942
+ }), this._fetchHandler.fetch(s), this._notifySubscribers());
2631
1943
  }
2632
- // Force refresh (bypass cache)
2633
1944
  async refresh() {
2634
1945
  this._fetchHandler.invalidateCache(), await this._fetchHandler.fetch(this._state.context);
2635
1946
  }
2636
- // SyncQueue controls
2637
1947
  pauseSync() {
2638
1948
  this._syncQueue.pause();
2639
1949
  }
@@ -2643,40 +1953,36 @@ class R {
2643
1953
  retrySync(t) {
2644
1954
  t ? this._syncQueue.retry(t) : this._syncQueue.retryAll();
2645
1955
  }
2646
- // Cleanup everything and remove from global cache
2647
1956
  destroy() {
2648
- this._syncQueue.destroy(), this._fetchHandler.destroy(), this._subscribers.clear(), R._cache.delete(this.id);
1957
+ this._syncQueue.destroy(), this._fetchHandler.destroy(), this._subscribers.clear(), O._cache.delete(this.id);
2649
1958
  }
2650
- // Private methods
2651
1959
  async _initialFetch() {
2652
- this._hasInitialized || (this._hasInitialized = !0, await this._fetchHandler.fetch(this._state.context));
1960
+ if (!this._hasInitialized) {
1961
+ if (this._hasInitialized = !0, this.config.serverItems) {
1962
+ this._state = P(this._state, (t) => {
1963
+ for (const n of this.config.serverItems)
1964
+ t.items.set(n.id, n);
1965
+ }), this._notifySubscribers();
1966
+ return;
1967
+ }
1968
+ typeof window > "u" || await this._fetchHandler.fetch(this._state.context);
1969
+ }
2653
1970
  }
2654
1971
  _onSyncQueueChange() {
2655
- const t = this._syncQueue.getState();
2656
- this._updateSyncState(t);
1972
+ this._updateSyncState(this._syncQueue.getState());
2657
1973
  }
2658
1974
  _onFetchChange() {
2659
1975
  const t = this._fetchHandler.getState();
2660
- this._state = I(this._state, (n) => {
1976
+ this._state = P(this._state, (n) => {
2661
1977
  n.fetchStatus = t.status, n.fetchError = t.error, n.loading = t.status === "fetching", n.syncState = this._computeSyncState(t.status, n.syncQueue.isSyncing);
2662
- const { queue: r, inFlight: i } = this._state.syncQueue, s = /* @__PURE__ */ new Map();
2663
- for (const o of t.items) {
2664
- const a = this.config.getId(o);
2665
- s.set(a, o);
2666
- }
2667
- for (const [o, a] of r) {
2668
- const c = fe(a);
2669
- c && (c.type === "create" || c.type === "update") && s.set(o, c.data);
2670
- }
2671
- for (const [o, a] of i) {
2672
- const c = fe(a);
2673
- c && (c.type === "create" || c.type === "update") && s.set(o, c.data);
2674
- }
1978
+ const s = /* @__PURE__ */ new Map();
1979
+ for (const i of t.items)
1980
+ s.set(i.id, i);
2675
1981
  n.items = s;
2676
1982
  }), this._notifySubscribers();
2677
1983
  }
2678
1984
  _updateSyncState(t) {
2679
- this._state = I(this._state, (n) => {
1985
+ this._state = P(this._state, (n) => {
2680
1986
  n.syncQueue = t, n.syncing = t.isSyncing, n.syncState = this._computeSyncState(n.fetchStatus, t.isSyncing);
2681
1987
  }), this._notifySubscribers();
2682
1988
  }
@@ -2688,194 +1994,166 @@ class R {
2688
1994
  for (const t of this._subscribers)
2689
1995
  t();
2690
1996
  }
2691
- _handleIdRemap(t) {
2692
- if (t.length === 0) return;
2693
- const { setId: n } = this.config;
2694
- this._state = I(this._state, (r) => {
2695
- for (const { tempId: i, newId: s } of t) {
2696
- const o = r.items.get(i);
2697
- if (o) {
2698
- let a;
2699
- n ? a = n(o, s) : (o.id = s, a = o), r.items.delete(i), r.items.set(s, a);
2700
- }
2701
- }
2702
- });
2703
- for (const { newId: r } of t) {
2704
- const i = this._state.items.get(r);
2705
- if (i) {
2706
- const s = i, o = this._itemCache.get(s);
2707
- o && o._updateId(r);
2708
- }
2709
- }
2710
- this._notifySubscribers();
2711
- }
2712
1997
  }
2713
- function Da(e) {
2714
- const t = R.get(e), n = j(
2715
- (r) => t.subscribe(r),
1998
+ function Es(e) {
1999
+ const t = O.get(e), n = le(() => _t(e), [e.id]), s = v(
2000
+ (i) => t.subscribe(i),
2716
2001
  () => t.getState(),
2717
- () => t.getState()
2002
+ () => n
2718
2003
  );
2719
2004
  return {
2720
- // State (all from single immutable state object)
2721
- items: n.items,
2722
- context: n.context,
2723
- syncState: n.syncState,
2724
- syncQueue: n.syncQueue,
2725
- loading: n.loading,
2726
- syncing: n.syncing,
2727
- fetchStatus: n.fetchStatus,
2728
- fetchError: n.fetchError,
2005
+ // State
2006
+ items: s.items,
2007
+ context: s.context,
2008
+ syncState: s.syncState,
2009
+ syncQueue: s.syncQueue,
2010
+ loading: s.loading,
2011
+ syncing: s.syncing,
2012
+ fetchStatus: s.fetchStatus,
2013
+ fetchError: s.fetchError,
2729
2014
  // Item operations
2730
- create: (r) => t.create(r),
2731
- update: (r, i) => t.update(r, i),
2732
- remove: (r) => t.remove(r),
2733
- getItem: (r) => t.getItem(r),
2734
- getItemStatus: (r) => t.getItemStatus(r),
2015
+ create: (i) => t.create({ ...i, id: be() }),
2016
+ update: (i, r) => t.update(i, r),
2017
+ remove: (i) => t.remove(i),
2018
+ getItem: (i) => t.getItem(i),
2019
+ getItemStatus: (i) => t.getItemStatus(i),
2735
2020
  // Context & refresh
2736
- setContext: (r) => t.setContext(r),
2021
+ setContext: (i) => t.setContext(i),
2737
2022
  refresh: () => t.refresh(),
2738
2023
  // Sync controls
2739
2024
  pauseSync: () => t.pauseSync(),
2740
2025
  resumeSync: () => t.resumeSync(),
2741
- retrySync: (r) => t.retrySync(r)
2026
+ retrySync: (i) => t.retrySync(i)
2742
2027
  };
2743
2028
  }
2744
- function Ha(e) {
2745
- const t = R.get(e), n = j(
2746
- (a) => t.subscribe(a),
2747
- () => t.getState(),
2748
- () => t.getState()
2749
- ), r = j(
2750
- (a) => t.subscribe(a),
2751
- () => t.items.get(e.rootId) ? t.getNode(e.rootId) : null,
2752
- () => t.items.get(e.rootId) ? t.getNode(e.rootId) : null
2753
- ), i = j(
2754
- (a) => t.subscribe(a),
2755
- () => t.selectedNodeId,
2756
- () => t.selectedNodeId
2757
- ), s = j(
2758
- (a) => t.subscribe(a),
2759
- () => t.selectedNode,
2760
- () => t.selectedNode
2761
- ), o = T(() => {
2762
- const a = e.nodeSeparator ?? ".", c = (l, f) => l.startsWith(f + a) ? !l.slice(f.length + 1).includes(a) : !1, u = (l) => {
2763
- const f = n.items.get(l);
2764
- if (!f) return null;
2765
- const h = Y(
2766
- Ce([...n.items.entries()], ([b]) => c(b, l)),
2767
- ([b, w]) => ({ id: b, position: w.position })
2768
- ), p = Me(h, "position"), g = Y(p, (b) => u(b.id)).filter(Boolean);
2029
+ function Is(e) {
2030
+ const t = e, n = O.get(t), s = le(() => _t(t), [e.id]), i = v(
2031
+ (u) => n.subscribe(u),
2032
+ () => n.getState(),
2033
+ () => s
2034
+ ), r = v(
2035
+ (u) => n.subscribe(u),
2036
+ () => n.items.get(e.rootId) ? n.getNode(e.rootId) : null,
2037
+ () => null
2038
+ ), o = v(
2039
+ (u) => n.subscribe(u),
2040
+ () => n.selectedNodeId,
2041
+ () => null
2042
+ ), c = v(
2043
+ (u) => n.subscribe(u),
2044
+ () => n.selectedNode,
2045
+ () => null
2046
+ ), a = S(() => {
2047
+ const u = e.nodeSeparator ?? ".", l = (y, p) => y.startsWith(p + u) ? !y.slice(p.length + 1).includes(u) : !1, f = (y) => {
2048
+ const p = i.items.get(y);
2049
+ if (!p) return null;
2050
+ const I = K(
2051
+ se([...i.items.entries()], ([m]) => l(m, y)),
2052
+ ([m, g]) => ({ id: m, position: g.position })
2053
+ ), $ = re(I, "position"), M = K($, (m) => f(m.id)).filter(Boolean);
2769
2054
  return {
2770
- id: f.id,
2771
- type: f.type,
2772
- value: f.value,
2773
- ...g.length > 0 ? { children: g } : {}
2055
+ id: p.id,
2056
+ type: p.type,
2057
+ value: p.value,
2058
+ ...M.length > 0 ? { children: M } : {}
2774
2059
  };
2775
2060
  };
2776
- return u(e.rootId);
2777
- }, [n.items, e.rootId, e.nodeSeparator]);
2061
+ return f(e.rootId);
2062
+ }, [i.items, e.rootId, e.nodeSeparator]);
2778
2063
  return {
2779
2064
  // Root node for tree operations
2780
2065
  rootNode: r,
2781
2066
  // State (all from single immutable state object)
2782
- items: n.items,
2783
- context: n.context,
2784
- syncState: n.syncState,
2785
- syncQueue: n.syncQueue,
2786
- loading: n.loading,
2787
- syncing: n.syncing,
2788
- fetchStatus: n.fetchStatus,
2789
- fetchError: n.fetchError,
2067
+ items: i.items,
2068
+ context: i.context,
2069
+ syncState: i.syncState,
2070
+ syncQueue: i.syncQueue,
2071
+ loading: i.loading,
2072
+ syncing: i.syncing,
2073
+ fetchStatus: i.fetchStatus,
2074
+ fetchError: i.fetchError,
2790
2075
  // Node operations
2791
- getNode: (a) => t.getNode(a),
2792
- getNodeStatus: (a) => t.getItemStatus(a),
2076
+ getNode: (u) => n.getNode(u),
2077
+ getNodeStatus: (u) => n.getItemStatus(u),
2793
2078
  // Context & refresh
2794
- setContext: (a) => t.setContext(a),
2795
- refresh: () => t.refresh(),
2079
+ setContext: (u) => n.setContext(u),
2080
+ refresh: () => n.refresh(),
2796
2081
  // Sync controls
2797
- pauseSync: () => t.pauseSync(),
2798
- resumeSync: () => t.resumeSync(),
2799
- retrySync: (a) => t.retrySync(a),
2082
+ pauseSync: () => n.pauseSync(),
2083
+ resumeSync: () => n.resumeSync(),
2084
+ retrySync: (u) => n.retrySync(u),
2800
2085
  // Selection
2801
- selectNode: (a) => t.selectNode(a),
2802
- deselectNode: () => t.deselectNode(),
2803
- selectedNodeId: i,
2804
- selectedNode: s,
2086
+ selectNode: (u) => n.selectNode(u),
2087
+ deselectNode: () => n.deselectNode(),
2088
+ selectedNodeId: o,
2089
+ selectedNode: c,
2805
2090
  // Serialization
2806
- toJson: o
2091
+ toJson: a
2807
2092
  };
2808
2093
  }
2809
- function La(e) {
2810
- const t = j(
2094
+ function Ns(e) {
2095
+ const t = v(
2811
2096
  (o) => e.collection.subscribe(o),
2812
2097
  () => e.data,
2813
2098
  () => e.data
2814
- ), n = j(
2099
+ ), n = v(
2815
2100
  (o) => e.collection.subscribe(o),
2816
2101
  () => e.getStatus(),
2817
2102
  () => e.getStatus()
2818
- ), r = j(
2103
+ ), s = v(
2819
2104
  (o) => e.collection.subscribe(o),
2820
2105
  () => e.exists(),
2821
2106
  () => e.exists()
2822
- ), i = T((o) => e.update(o), [e]), s = T(() => e.remove(), [e]);
2823
- return { data: t, status: n, update: i, remove: s, exists: r };
2824
- }
2825
- function ja(e, t) {
2826
- if (!O(oe(e), oe(t))) return !0;
2827
- for (let n = 0; n < oe(e); n++)
2828
- if (!O(e[n].id, t[n].id)) return !0;
2829
- return !1;
2107
+ ), i = S((o) => e.update(o), [e]), r = S(() => e.remove(), [e]);
2108
+ return { data: t, status: n, update: i, remove: r, exists: s };
2830
2109
  }
2831
- const $a = {
2832
- data: void 0,
2833
- status: null,
2834
- exists: !1,
2835
- isSelected: !1,
2836
- children: []
2837
- };
2838
- function Fa(e) {
2839
- const t = Nn($a), n = j(
2840
- (h) => e.collection.subscribe(h),
2841
- () => {
2842
- const h = e.getChildren(), p = t.current, g = ja(p.children, h) ? h : p.children, b = {
2843
- data: e.data,
2844
- status: e.getStatus(),
2845
- exists: e.exists(),
2846
- isSelected: O(e.collection.selectedNodeId, e.id),
2847
- children: g
2848
- };
2849
- return O(p, b) || (t.current = b), t.current;
2850
- },
2851
- () => t.current
2852
- ), r = T(() => e.getParent(), [e]), i = T((h, p) => e.append(h, p), [e]), s = T((h, p) => e.prepend(h, p), [e]), o = T(
2853
- (h, p) => e.move(h, p),
2110
+ function xs(e) {
2111
+ const t = S((_) => e.collection.subscribe(_), [e]), n = v(
2112
+ t,
2113
+ () => e.data,
2114
+ () => e.data
2115
+ ), s = v(
2116
+ t,
2117
+ () => e.getStatus(),
2118
+ () => e.getStatus()
2119
+ ), i = v(
2120
+ t,
2121
+ () => e.exists(),
2122
+ () => e.exists()
2123
+ ), r = v(
2124
+ t,
2125
+ () => e.collection.selectedNodeId === e.id,
2126
+ () => e.collection.selectedNodeId === e.id
2127
+ ), o = le(() => e.getChildren(), [n, e]), c = S(() => e.getParent(), [e]), a = S((_, j) => e.append(_, j), [e]), u = S((_, j) => e.prepend(_, j), [e]), l = S(
2128
+ (_, j) => e.move(_, j),
2854
2129
  [e]
2855
- ), a = T(() => e.clone(), [e]), c = T(
2856
- (h) => e.updateProp(h),
2130
+ ), f = S(() => e.moveUp(), [e]), y = S(() => e.moveDown(), [e]), p = S((_) => e.setPosition(_), [e]), I = S(() => e.clone(), [e]), $ = S(
2131
+ (_) => e.updateProp(_),
2857
2132
  [e]
2858
- ), u = T(() => e.remove(), [e]), l = T(() => e.select(), [e]), f = T(() => e.collection.deselectNode(), [e]);
2133
+ ), M = S(() => e.remove(), [e]), m = S(() => e.select(), [e]), g = S(() => e.collection.deselectNode(), [e]);
2859
2134
  return {
2860
2135
  isPresent: !0,
2861
- data: n.data,
2862
- status: n.status,
2863
- exists: n.exists,
2864
- isSelected: n.isSelected,
2136
+ data: n,
2137
+ status: s,
2138
+ exists: i,
2139
+ isSelected: r,
2865
2140
  depth: e.depth,
2866
- getParent: r,
2867
- children: n.children,
2868
- append: i,
2869
- prepend: s,
2870
- move: o,
2871
- clone: a,
2872
- updateProp: c,
2873
- remove: u,
2874
- select: l,
2875
- deselect: f
2141
+ getParent: c,
2142
+ children: o,
2143
+ append: a,
2144
+ prepend: u,
2145
+ move: l,
2146
+ moveUp: f,
2147
+ moveDown: y,
2148
+ setPosition: p,
2149
+ clone: I,
2150
+ updateProp: $,
2151
+ remove: M,
2152
+ select: m,
2153
+ deselect: g
2876
2154
  };
2877
2155
  }
2878
- const za = {
2156
+ const Os = {
2879
2157
  isPresent: !1,
2880
2158
  data: void 0,
2881
2159
  status: null,
@@ -2888,6 +2166,12 @@ const za = {
2888
2166
  prepend: () => "",
2889
2167
  move: () => {
2890
2168
  },
2169
+ moveUp: () => {
2170
+ },
2171
+ moveDown: () => {
2172
+ },
2173
+ setPosition: () => {
2174
+ },
2891
2175
  clone: () => /* @__PURE__ */ new Map(),
2892
2176
  updateProp: () => {
2893
2177
  },
@@ -2898,27 +2182,27 @@ const za = {
2898
2182
  deselect: () => {
2899
2183
  }
2900
2184
  };
2901
- function qa(e) {
2902
- const t = R.getById(e);
2185
+ function zs(e) {
2186
+ const t = O.getById(e);
2903
2187
  if (!t)
2904
2188
  throw new Error(
2905
2189
  `Collection with id "${e}" not found. Make sure useCrud is called first.`
2906
2190
  );
2907
- const n = j(
2908
- (s) => t.subscribe(s),
2191
+ const n = v(
2192
+ (r) => t.subscribe(r),
2909
2193
  () => t.selectedNode,
2910
2194
  () => t.selectedNode
2911
- ), r = Dn(() => t.getNode("__dummy__"), [t]), i = Fa(n ?? r);
2912
- return n ? i : za;
2195
+ ), s = le(() => t.getNode("__dummy__"), [t]), i = xs(n ?? s);
2196
+ return n ? i : Os;
2913
2197
  }
2914
- function Qa(e) {
2915
- const t = R.getById(e);
2198
+ function As(e) {
2199
+ const t = O.getById(e);
2916
2200
  if (!t)
2917
2201
  throw new Error(
2918
2202
  `Collection with id "${e}" not found. Make sure useCrud is called first.`
2919
2203
  );
2920
- const n = j(
2921
- (r) => t.subscribe(r),
2204
+ const n = v(
2205
+ (s) => t.subscribe(s),
2922
2206
  () => t.getState(),
2923
2207
  () => t.getState()
2924
2208
  );
@@ -2933,24 +2217,22 @@ function Qa(e) {
2933
2217
  };
2934
2218
  }
2935
2219
  export {
2936
- Ea as Cache,
2937
- R as Collection,
2938
- Ta as FetchHandler,
2939
- Yt as Item,
2940
- kt as Node,
2941
- Pa as SyncQueue,
2942
- Ga as categorizeResults,
2943
- Wa as createSyncClient,
2944
- Va as createSyncClientFromEndpoint,
2945
- Ja as createSyncClientWithStats,
2946
- Ya as fetchToSyncResult,
2947
- Xa as syncError,
2948
- Za as syncSuccess,
2949
- Da as useCrud,
2950
- Ha as useCrudTree,
2951
- La as useItem,
2952
- Fa as useNode,
2953
- qa as useSelectedNode,
2954
- Qa as useSyncState
2220
+ ws as Cache,
2221
+ O as Collection,
2222
+ vs as FetchHandler,
2223
+ We as Item,
2224
+ Le as Node,
2225
+ Ss as SyncQueue,
2226
+ _t as buildServerSnapshot,
2227
+ Ds as compareTimeIds,
2228
+ Qs as createSyncClient,
2229
+ be as getIdFromTime,
2230
+ Ts as getTimeFromId,
2231
+ Es as useCrud,
2232
+ Is as useCrudTree,
2233
+ Ns as useItem,
2234
+ xs as useNode,
2235
+ zs as useSelectedNode,
2236
+ As as useSyncState
2955
2237
  };
2956
2238
  //# sourceMappingURL=index.js.map