atomaric 0.0.82 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +498 -8
- package/build/atomaric.js +326 -827
- package/build/atomaric.umd.cjs +1 -1
- package/package.json +5 -2
- package/types/do.classes.model/IObject.ts +2 -1
- package/types/index.d.ts +69 -6
package/build/atomaric.js
CHANGED
|
@@ -1,917 +1,416 @@
|
|
|
1
|
-
let
|
|
1
|
+
let re = () => {
|
|
2
|
+
throw "call configureAtomaric() before all!";
|
|
3
|
+
}, F = () => {
|
|
2
4
|
throw "call configureAtomaric() before all!";
|
|
3
5
|
};
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
},
|
|
7
|
-
class
|
|
6
|
+
const w = {}, Me = (s) => {
|
|
7
|
+
w.useSyncExternalStore = re = s.useSyncExternalStore, w.produce = F = s.produce, w.keyPathSeparator = s.keyPathSeparator, w.securifyKeyLevel = s.securifyKeyLevel, w.securifyValueLevel = s.securifyValueLevel, w.storage = s.storage, be(s.storage);
|
|
8
|
+
}, le = (s) => re(s.subscribe, s.get), ue = (s) => s.set, _e = (s) => s.setDeferred, $e = (s) => s.get, Le = (s) => s.do, Pe = (s) => [le(s), ue(s)], Te = (s, t) => new Se(s, t);
|
|
9
|
+
class M {
|
|
8
10
|
constructor(t) {
|
|
9
11
|
if (t)
|
|
10
12
|
return new Proxy(this, {
|
|
11
|
-
get: (
|
|
13
|
+
get: (a, e) => e in this ? a[e] : t[e]
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
38
|
-
"Immer only supports deleting array indices",
|
|
39
|
-
"Immer only supports setting array indices and the 'length' property",
|
|
40
|
-
function(e) {
|
|
41
|
-
return `'original' expects a draft, got: ${e}`;
|
|
42
|
-
}
|
|
43
|
-
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
44
|
-
// See Patches.ts for additional errors
|
|
45
|
-
] : [];
|
|
46
|
-
function g(e, ...t) {
|
|
47
|
-
if (process.env.NODE_ENV !== "production") {
|
|
48
|
-
const r = ht[e], n = v(r) ? r.apply(null, t) : r;
|
|
49
|
-
throw new Error(`[Immer] ${n}`);
|
|
50
|
-
}
|
|
51
|
-
throw new Error(
|
|
52
|
-
`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
var w = Object, O = w.getPrototypeOf, Z = "constructor", oe = "prototype", Pe = "configurable", ee = "enumerable", Y = "writable", W = "value", M = (e) => !!e && !!e[p];
|
|
56
|
-
function C(e) {
|
|
57
|
-
var t;
|
|
58
|
-
return e ? Xe(e) || ae(e) || !!e[Ue] || !!((t = e[Z]) != null && t[Ue]) || ue(e) || fe(e) : !1;
|
|
59
|
-
}
|
|
60
|
-
var _t = w[oe][Z].toString(), je = /* @__PURE__ */ new WeakMap();
|
|
61
|
-
function Xe(e) {
|
|
62
|
-
if (!e || !Fe(e))
|
|
63
|
-
return !1;
|
|
64
|
-
const t = O(e);
|
|
65
|
-
if (t === null || t === w[oe])
|
|
66
|
-
return !0;
|
|
67
|
-
const r = w.hasOwnProperty.call(t, Z) && t[Z];
|
|
68
|
-
if (r === Object)
|
|
69
|
-
return !0;
|
|
70
|
-
if (!v(r))
|
|
71
|
-
return !1;
|
|
72
|
-
let n = je.get(r);
|
|
73
|
-
return n === void 0 && (n = Function.toString.call(r), je.set(r, n)), n === _t;
|
|
74
|
-
}
|
|
75
|
-
function ce(e, t, r = !0) {
|
|
76
|
-
H(e) === 0 ? (r ? Reflect.ownKeys(e) : w.keys(e)).forEach((s) => {
|
|
77
|
-
t(s, e[s], e);
|
|
78
|
-
}) : e.forEach((n, s) => t(s, n, e));
|
|
79
|
-
}
|
|
80
|
-
function H(e) {
|
|
81
|
-
const t = e[p];
|
|
82
|
-
return t ? t.type_ : ae(e) ? 1 : ue(e) ? 2 : fe(e) ? 3 : 0;
|
|
83
|
-
}
|
|
84
|
-
var Oe = (e, t, r = H(e)) => r === 2 ? e.has(t) : w[oe].hasOwnProperty.call(e, t), Ae = (e, t, r = H(e)) => (
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
r === 2 ? e.get(t) : e[t]
|
|
87
|
-
), te = (e, t, r, n = H(e)) => {
|
|
88
|
-
n === 2 ? e.set(t, r) : n === 3 ? e.add(r) : e[t] = r;
|
|
89
|
-
};
|
|
90
|
-
function yt(e, t) {
|
|
91
|
-
return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
|
|
92
|
-
}
|
|
93
|
-
var ae = Array.isArray, ue = (e) => e instanceof Map, fe = (e) => e instanceof Set, Fe = (e) => typeof e == "object", v = (e) => typeof e == "function", we = (e) => typeof e == "boolean";
|
|
94
|
-
function pt(e) {
|
|
95
|
-
const t = +e;
|
|
96
|
-
return Number.isInteger(t) && String(t) === e;
|
|
97
|
-
}
|
|
98
|
-
var I = (e) => e.copy_ || e.base_, Ne = (e) => e.modified_ ? e.copy_ : e.base_;
|
|
99
|
-
function be(e, t) {
|
|
100
|
-
if (ue(e))
|
|
101
|
-
return new Map(e);
|
|
102
|
-
if (fe(e))
|
|
103
|
-
return new Set(e);
|
|
104
|
-
if (ae(e))
|
|
105
|
-
return Array[oe].slice.call(e);
|
|
106
|
-
const r = Xe(e);
|
|
107
|
-
if (t === !0 || t === "class_only" && !r) {
|
|
108
|
-
const n = w.getOwnPropertyDescriptors(e);
|
|
109
|
-
delete n[p];
|
|
110
|
-
let s = Reflect.ownKeys(n);
|
|
111
|
-
for (let i = 0; i < s.length; i++) {
|
|
112
|
-
const c = s[i], u = n[c];
|
|
113
|
-
u[Y] === !1 && (u[Y] = !0, u[Pe] = !0), (u.get || u.set) && (n[c] = {
|
|
114
|
-
[Pe]: !0,
|
|
115
|
-
[Y]: !0,
|
|
116
|
-
// could live with !!desc.set as well here...
|
|
117
|
-
[ee]: u[ee],
|
|
118
|
-
[W]: e[c]
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return w.create(O(e), n);
|
|
122
|
-
} else {
|
|
123
|
-
const n = O(e);
|
|
124
|
-
if (n !== null && r)
|
|
125
|
-
return { ...e };
|
|
126
|
-
const s = w.create(n);
|
|
127
|
-
return w.assign(s, e);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function $e(e, t = !1) {
|
|
131
|
-
return le(e) || M(e) || !C(e) || (H(e) > 1 && w.defineProperties(e, {
|
|
132
|
-
set: K,
|
|
133
|
-
add: K,
|
|
134
|
-
clear: K,
|
|
135
|
-
delete: K
|
|
136
|
-
}), w.freeze(e), t && ce(
|
|
137
|
-
e,
|
|
138
|
-
(r, n) => {
|
|
139
|
-
$e(n, !0);
|
|
140
|
-
},
|
|
141
|
-
!1
|
|
142
|
-
)), e;
|
|
143
|
-
}
|
|
144
|
-
function mt() {
|
|
145
|
-
g(2);
|
|
146
|
-
}
|
|
147
|
-
var K = {
|
|
148
|
-
[W]: mt
|
|
149
|
-
};
|
|
150
|
-
function le(e) {
|
|
151
|
-
return e === null || !Fe(e) ? !0 : w.isFrozen(e);
|
|
152
|
-
}
|
|
153
|
-
var re = "MapSet", De = "Patches", Be = "ArrayMethods", Ze = {};
|
|
154
|
-
function E(e) {
|
|
155
|
-
const t = Ze[e];
|
|
156
|
-
return t || g(0, e), t;
|
|
157
|
-
}
|
|
158
|
-
var We = (e) => !!Ze[e], q, et = () => q, gt = (e, t) => ({
|
|
159
|
-
drafts_: [],
|
|
160
|
-
parent_: e,
|
|
161
|
-
immer_: t,
|
|
162
|
-
// Whenever the modified draft contains a draft from another scope, we
|
|
163
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
164
|
-
canAutoFreeze_: !0,
|
|
165
|
-
unfinalizedDrafts_: 0,
|
|
166
|
-
handledSet_: /* @__PURE__ */ new Set(),
|
|
167
|
-
processedForPatches_: /* @__PURE__ */ new Set(),
|
|
168
|
-
mapSetPlugin_: We(re) ? E(re) : void 0,
|
|
169
|
-
arrayMethodsPlugin_: We(Be) ? E(Be) : void 0
|
|
170
|
-
});
|
|
171
|
-
function qe(e, t) {
|
|
172
|
-
t && (e.patchPlugin_ = E(De), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
|
|
173
|
-
}
|
|
174
|
-
function Ie(e) {
|
|
175
|
-
Ce(e), e.drafts_.forEach(wt), e.drafts_ = null;
|
|
176
|
-
}
|
|
177
|
-
function Ce(e) {
|
|
178
|
-
e === q && (q = e.parent_);
|
|
179
|
-
}
|
|
180
|
-
var Ge = (e) => q = gt(q, e);
|
|
181
|
-
function wt(e) {
|
|
182
|
-
const t = e[p];
|
|
183
|
-
t.type_ === 0 || t.type_ === 1 ? t.revoke_() : t.revoked_ = !0;
|
|
184
|
-
}
|
|
185
|
-
function He(e, t) {
|
|
186
|
-
t.unfinalizedDrafts_ = t.drafts_.length;
|
|
187
|
-
const r = t.drafts_[0];
|
|
188
|
-
if (e !== void 0 && e !== r) {
|
|
189
|
-
r[p].modified_ && (Ie(t), g(4)), C(e) && (e = Je(t, e));
|
|
190
|
-
const { patchPlugin_: s } = t;
|
|
191
|
-
s && s.generateReplacementPatches_(
|
|
192
|
-
r[p].base_,
|
|
193
|
-
e,
|
|
194
|
-
t
|
|
195
|
-
);
|
|
196
|
-
} else
|
|
197
|
-
e = Je(t, r);
|
|
198
|
-
return St(t, e, !0), Ie(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_), e !== Qe ? e : void 0;
|
|
199
|
-
}
|
|
200
|
-
function Je(e, t) {
|
|
201
|
-
if (le(t))
|
|
202
|
-
return t;
|
|
203
|
-
const r = t[p];
|
|
204
|
-
if (!r)
|
|
205
|
-
return ne(t, e.handledSet_, e);
|
|
206
|
-
if (!de(r, e))
|
|
207
|
-
return t;
|
|
208
|
-
if (!r.modified_)
|
|
209
|
-
return r.base_;
|
|
210
|
-
if (!r.finalized_) {
|
|
211
|
-
const { callbacks_: n } = r;
|
|
212
|
-
if (n)
|
|
213
|
-
for (; n.length > 0; )
|
|
214
|
-
n.pop()(e);
|
|
215
|
-
nt(r, e);
|
|
216
|
-
}
|
|
217
|
-
return r.copy_;
|
|
218
|
-
}
|
|
219
|
-
function St(e, t, r = !1) {
|
|
220
|
-
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && $e(t, r);
|
|
221
|
-
}
|
|
222
|
-
function tt(e) {
|
|
223
|
-
e.finalized_ = !0, e.scope_.unfinalizedDrafts_--;
|
|
224
|
-
}
|
|
225
|
-
var de = (e, t) => e.scope_ === t, Pt = [];
|
|
226
|
-
function rt(e, t, r, n) {
|
|
227
|
-
const s = I(e), i = e.type_;
|
|
228
|
-
if (n !== void 0 && Ae(s, n, i) === t) {
|
|
229
|
-
te(s, n, r, i);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (!e.draftLocations_) {
|
|
233
|
-
const u = e.draftLocations_ = /* @__PURE__ */ new Map();
|
|
234
|
-
ce(s, (h, d) => {
|
|
235
|
-
if (M(d)) {
|
|
236
|
-
const _ = u.get(d) || [];
|
|
237
|
-
_.push(h), u.set(d, _);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
const c = e.draftLocations_.get(t) ?? Pt;
|
|
242
|
-
for (const u of c)
|
|
243
|
-
te(s, u, r, i);
|
|
244
|
-
}
|
|
245
|
-
function At(e, t, r) {
|
|
246
|
-
e.callbacks_.push(function(s) {
|
|
247
|
-
var u;
|
|
248
|
-
const i = t;
|
|
249
|
-
if (!i || !de(i, s))
|
|
250
|
-
return;
|
|
251
|
-
(u = s.mapSetPlugin_) == null || u.fixSetContents(i);
|
|
252
|
-
const c = Ne(i);
|
|
253
|
-
rt(e, i.draft_ ?? i, c, r), nt(i, s);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
function nt(e, t) {
|
|
257
|
-
var n;
|
|
258
|
-
if (e.modified_ && !e.finalized_ && (e.type_ === 3 || e.type_ === 1 && e.allIndicesReassigned_ || (((n = e.assigned_) == null ? void 0 : n.size) ?? 0) > 0)) {
|
|
259
|
-
const { patchPlugin_: s } = t;
|
|
260
|
-
if (s) {
|
|
261
|
-
const i = s.getPath(e);
|
|
262
|
-
i && s.generatePatches_(e, i, t);
|
|
263
|
-
}
|
|
264
|
-
tt(e);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
function bt(e, t, r) {
|
|
268
|
-
const { scope_: n } = e;
|
|
269
|
-
if (M(r)) {
|
|
270
|
-
const s = r[p];
|
|
271
|
-
de(s, n) && s.callbacks_.push(function() {
|
|
272
|
-
Q(e);
|
|
273
|
-
const c = Ne(s);
|
|
274
|
-
rt(e, r, c, t);
|
|
275
|
-
});
|
|
276
|
-
} else C(r) && e.callbacks_.push(function() {
|
|
277
|
-
const i = I(e);
|
|
278
|
-
e.type_ === 3 ? i.has(r) && ne(r, n.handledSet_, n) : Ae(i, t, e.type_) === r && n.drafts_.length > 1 && (e.assigned_.get(t) ?? !1) === !0 && e.copy_ && ne(
|
|
279
|
-
Ae(e.copy_, t, e.type_),
|
|
280
|
-
n.handledSet_,
|
|
281
|
-
n
|
|
282
|
-
);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
function ne(e, t, r) {
|
|
286
|
-
return !r.immer_.autoFreeze_ && r.unfinalizedDrafts_ < 1 || M(e) || t.has(e) || !C(e) || le(e) || (t.add(e), ce(e, (n, s) => {
|
|
287
|
-
if (M(s)) {
|
|
288
|
-
const i = s[p];
|
|
289
|
-
if (de(i, r)) {
|
|
290
|
-
const c = Ne(i);
|
|
291
|
-
te(e, n, c, e.type_), tt(i);
|
|
292
|
-
}
|
|
293
|
-
} else C(s) && ne(s, t, r);
|
|
294
|
-
})), e;
|
|
295
|
-
}
|
|
296
|
-
function Dt(e, t) {
|
|
297
|
-
const r = ae(e), n = {
|
|
298
|
-
type_: r ? 1 : 0,
|
|
299
|
-
// Track which produce call this is associated with.
|
|
300
|
-
scope_: t ? t.scope_ : et(),
|
|
301
|
-
// True for both shallow and deep changes.
|
|
302
|
-
modified_: !1,
|
|
303
|
-
// Used during finalization.
|
|
304
|
-
finalized_: !1,
|
|
305
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
306
|
-
// actually instantiated in `prepareCopy()`
|
|
307
|
-
assigned_: void 0,
|
|
308
|
-
// The parent draft state.
|
|
309
|
-
parent_: t,
|
|
310
|
-
// The base state.
|
|
311
|
-
base_: e,
|
|
312
|
-
// The base proxy.
|
|
313
|
-
draft_: null,
|
|
314
|
-
// set below
|
|
315
|
-
// The base copy with any updated values.
|
|
316
|
-
copy_: null,
|
|
317
|
-
// Called by the `produce` function.
|
|
318
|
-
revoke_: null,
|
|
319
|
-
isManual_: !1,
|
|
320
|
-
// `callbacks` actually gets assigned in `createProxy`
|
|
321
|
-
callbacks_: void 0
|
|
322
|
-
};
|
|
323
|
-
let s = n, i = se;
|
|
324
|
-
r && (s = [n], i = G);
|
|
325
|
-
const { revoke: c, proxy: u } = Proxy.revocable(s, i);
|
|
326
|
-
return n.draft_ = u, n.revoke_ = c, [u, n];
|
|
327
|
-
}
|
|
328
|
-
var se = {
|
|
329
|
-
get(e, t) {
|
|
330
|
-
if (t === p)
|
|
331
|
-
return e;
|
|
332
|
-
let r = e.scope_.arrayMethodsPlugin_;
|
|
333
|
-
const n = e.type_ === 1 && typeof t == "string";
|
|
334
|
-
if (n && r != null && r.isArrayOperationMethod(t))
|
|
335
|
-
return r.createMethodInterceptor(e, t);
|
|
336
|
-
const s = I(e);
|
|
337
|
-
if (!Oe(s, t, e.type_))
|
|
338
|
-
return It(e, s, t);
|
|
339
|
-
const i = s[t];
|
|
340
|
-
if (e.finalized_ || !C(i) || n && e.operationMethod && (r != null && r.isMutatingArrayMethod(
|
|
341
|
-
e.operationMethod
|
|
342
|
-
)) && pt(t))
|
|
343
|
-
return i;
|
|
344
|
-
if (i === Se(e.base_, t)) {
|
|
345
|
-
Q(e);
|
|
346
|
-
const c = e.type_ === 1 ? +t : t, u = ze(e.scope_, i, e, c);
|
|
347
|
-
return e.copy_[c] = u;
|
|
348
|
-
}
|
|
349
|
-
return i;
|
|
350
|
-
},
|
|
351
|
-
has(e, t) {
|
|
352
|
-
return t in I(e);
|
|
353
|
-
},
|
|
354
|
-
ownKeys(e) {
|
|
355
|
-
return Reflect.ownKeys(I(e));
|
|
356
|
-
},
|
|
357
|
-
set(e, t, r) {
|
|
358
|
-
const n = st(I(e), t);
|
|
359
|
-
if (n != null && n.set)
|
|
360
|
-
return n.set.call(e.draft_, r), !0;
|
|
361
|
-
if (!e.modified_) {
|
|
362
|
-
const s = Se(I(e), t), i = s == null ? void 0 : s[p];
|
|
363
|
-
if (i && i.base_ === r)
|
|
364
|
-
return e.copy_[t] = r, e.assigned_.set(t, !1), !0;
|
|
365
|
-
if (yt(r, s) && (r !== void 0 || Oe(e.base_, t, e.type_)))
|
|
366
|
-
return !0;
|
|
367
|
-
Q(e), Me(e);
|
|
368
|
-
}
|
|
369
|
-
return e.copy_[t] === r && // special case: handle new props with value 'undefined'
|
|
370
|
-
(r !== void 0 || t in e.copy_) || // special case: NaN
|
|
371
|
-
Number.isNaN(r) && Number.isNaN(e.copy_[t]) || (e.copy_[t] = r, e.assigned_.set(t, !0), bt(e, t, r)), !0;
|
|
372
|
-
},
|
|
373
|
-
deleteProperty(e, t) {
|
|
374
|
-
return Q(e), Se(e.base_, t) !== void 0 || t in e.base_ ? (e.assigned_.set(t, !1), Me(e)) : e.assigned_.delete(t), e.copy_ && delete e.copy_[t], !0;
|
|
375
|
-
},
|
|
376
|
-
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
377
|
-
// the same guarantee in ES5 mode.
|
|
378
|
-
getOwnPropertyDescriptor(e, t) {
|
|
379
|
-
const r = I(e), n = Reflect.getOwnPropertyDescriptor(r, t);
|
|
380
|
-
return n && {
|
|
381
|
-
[Y]: !0,
|
|
382
|
-
[Pe]: e.type_ !== 1 || t !== "length",
|
|
383
|
-
[ee]: n[ee],
|
|
384
|
-
[W]: r[t]
|
|
17
|
+
class he extends M {
|
|
18
|
+
constructor(t, a) {
|
|
19
|
+
super(a), this.a = t, this.push = (...e) => {
|
|
20
|
+
e.length !== 0 && this.a.set(this.a.get().concat(e));
|
|
21
|
+
}, this.unshift = (...e) => {
|
|
22
|
+
e.length !== 0 && this.a.set(e.concat(this.a.get()));
|
|
23
|
+
}, this.update = (e) => {
|
|
24
|
+
const i = this.a.get(), n = F(i, (u) => void e(u));
|
|
25
|
+
n !== i && this.a.set(n);
|
|
26
|
+
}, this.filter = (e) => {
|
|
27
|
+
const i = this.a.get().filter(e ?? fe);
|
|
28
|
+
i.length !== this.a.get().length && this.a.set(i);
|
|
29
|
+
}, this.add = (e) => {
|
|
30
|
+
this.a.get().includes(e) || this.a.set(this.a.get().concat([e]));
|
|
31
|
+
}, this.removeFirst = (e) => {
|
|
32
|
+
const i = this.a.get().indexOf(e);
|
|
33
|
+
if (i < 0) return;
|
|
34
|
+
const n = this.a.get().slice(0);
|
|
35
|
+
n.splice(i, 1), this.a.set(n);
|
|
36
|
+
}, this.toggle = (e, i) => {
|
|
37
|
+
const n = this.a.get().slice(), u = n.indexOf(e);
|
|
38
|
+
u < 0 ? i ? n.unshift(e) : n.push(e) : n.splice(u, 1), this.a.set(n);
|
|
385
39
|
};
|
|
386
|
-
},
|
|
387
|
-
defineProperty() {
|
|
388
|
-
g(11);
|
|
389
|
-
},
|
|
390
|
-
getPrototypeOf(e) {
|
|
391
|
-
return O(e.base_);
|
|
392
|
-
},
|
|
393
|
-
setPrototypeOf() {
|
|
394
|
-
g(12);
|
|
395
40
|
}
|
|
396
|
-
}, G = {};
|
|
397
|
-
for (let e in se) {
|
|
398
|
-
let t = se[e];
|
|
399
|
-
G[e] = function() {
|
|
400
|
-
const r = arguments;
|
|
401
|
-
return r[0] = r[0][0], t.apply(this, r);
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
G.deleteProperty = function(e, t) {
|
|
405
|
-
return process.env.NODE_ENV !== "production" && isNaN(parseInt(t)) && g(13), G.set.call(this, e, t, void 0);
|
|
406
|
-
};
|
|
407
|
-
G.set = function(e, t, r) {
|
|
408
|
-
return process.env.NODE_ENV !== "production" && t !== "length" && isNaN(parseInt(t)) && g(14), se.set.call(this, e[0], t, r, e[0]);
|
|
409
|
-
};
|
|
410
|
-
function Se(e, t) {
|
|
411
|
-
const r = e[p];
|
|
412
|
-
return (r ? I(r) : e)[t];
|
|
413
|
-
}
|
|
414
|
-
function It(e, t, r) {
|
|
415
|
-
var s;
|
|
416
|
-
const n = st(t, r);
|
|
417
|
-
return n ? W in n ? n[W] : (
|
|
418
|
-
// This is a very special case, if the prop is a getter defined by the
|
|
419
|
-
// prototype, we should invoke it with the draft as context!
|
|
420
|
-
(s = n.get) == null ? void 0 : s.call(e.draft_)
|
|
421
|
-
) : void 0;
|
|
422
|
-
}
|
|
423
|
-
function st(e, t) {
|
|
424
|
-
if (!(t in e))
|
|
425
|
-
return;
|
|
426
|
-
let r = O(e);
|
|
427
|
-
for (; r; ) {
|
|
428
|
-
const n = Object.getOwnPropertyDescriptor(r, t);
|
|
429
|
-
if (n)
|
|
430
|
-
return n;
|
|
431
|
-
r = O(r);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
function Me(e) {
|
|
435
|
-
e.modified_ || (e.modified_ = !0, e.parent_ && Me(e.parent_));
|
|
436
|
-
}
|
|
437
|
-
function Q(e) {
|
|
438
|
-
e.copy_ || (e.assigned_ = /* @__PURE__ */ new Map(), e.copy_ = be(
|
|
439
|
-
e.base_,
|
|
440
|
-
e.scope_.immer_.useStrictShallowCopy_
|
|
441
|
-
));
|
|
442
41
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
const i = r;
|
|
448
|
-
r = t;
|
|
449
|
-
const c = this;
|
|
450
|
-
return function(h = i, ...d) {
|
|
451
|
-
return c.produce(h, (_) => r.call(this, _, ...d));
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
v(r) || g(6), n !== void 0 && !v(n) && g(7);
|
|
455
|
-
let s;
|
|
456
|
-
if (C(t)) {
|
|
457
|
-
const i = Ge(this), c = ze(i, t, void 0);
|
|
458
|
-
let u = !0;
|
|
459
|
-
try {
|
|
460
|
-
s = r(c), u = !1;
|
|
461
|
-
} finally {
|
|
462
|
-
u ? Ie(i) : Ce(i);
|
|
463
|
-
}
|
|
464
|
-
return qe(i, n), He(s, i);
|
|
465
|
-
} else if (!t || !Fe(t)) {
|
|
466
|
-
if (s = r(t), s === void 0 && (s = t), s === Qe && (s = void 0), this.autoFreeze_ && $e(s, !0), n) {
|
|
467
|
-
const i = [], c = [];
|
|
468
|
-
E(De).generateReplacementPatches_(t, s, {
|
|
469
|
-
patches_: i,
|
|
470
|
-
inversePatches_: c
|
|
471
|
-
}), n(i, c);
|
|
472
|
-
}
|
|
473
|
-
return s;
|
|
474
|
-
} else
|
|
475
|
-
g(1, t);
|
|
476
|
-
}, this.produceWithPatches = (t, r) => {
|
|
477
|
-
if (v(t))
|
|
478
|
-
return (c, ...u) => this.produceWithPatches(c, (h) => t(h, ...u));
|
|
479
|
-
let n, s;
|
|
480
|
-
return [this.produce(t, r, (c, u) => {
|
|
481
|
-
n = c, s = u;
|
|
482
|
-
}), n, s];
|
|
483
|
-
}, we(e == null ? void 0 : e.autoFreeze) && this.setAutoFreeze(e.autoFreeze), we(e == null ? void 0 : e.useStrictShallowCopy) && this.setUseStrictShallowCopy(e.useStrictShallowCopy), we(e == null ? void 0 : e.useStrictIteration) && this.setUseStrictIteration(e.useStrictIteration);
|
|
484
|
-
}
|
|
485
|
-
createDraft(e) {
|
|
486
|
-
C(e) || g(8), M(e) && (e = Mt(e));
|
|
487
|
-
const t = Ge(this), r = ze(t, e, void 0);
|
|
488
|
-
return r[p].isManual_ = !0, Ce(t), r;
|
|
489
|
-
}
|
|
490
|
-
finishDraft(e, t) {
|
|
491
|
-
const r = e && e[p];
|
|
492
|
-
(!r || !r.isManual_) && g(9);
|
|
493
|
-
const { scope_: n } = r;
|
|
494
|
-
return qe(n, t), He(void 0, n);
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
498
|
-
*
|
|
499
|
-
* By default, auto-freezing is enabled.
|
|
500
|
-
*/
|
|
501
|
-
setAutoFreeze(e) {
|
|
502
|
-
this.autoFreeze_ = e;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Pass true to enable strict shallow copy.
|
|
506
|
-
*
|
|
507
|
-
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
508
|
-
*/
|
|
509
|
-
setUseStrictShallowCopy(e) {
|
|
510
|
-
this.useStrictShallowCopy_ = e;
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Pass false to use faster iteration that skips non-enumerable properties
|
|
514
|
-
* but still handles symbols for compatibility.
|
|
515
|
-
*
|
|
516
|
-
* By default, strict iteration is enabled (includes all own properties).
|
|
517
|
-
*/
|
|
518
|
-
setUseStrictIteration(e) {
|
|
519
|
-
this.useStrictIteration_ = e;
|
|
520
|
-
}
|
|
521
|
-
shouldUseStrictIteration() {
|
|
522
|
-
return this.useStrictIteration_;
|
|
523
|
-
}
|
|
524
|
-
applyPatches(e, t) {
|
|
525
|
-
let r;
|
|
526
|
-
for (r = t.length - 1; r >= 0; r--) {
|
|
527
|
-
const s = t[r];
|
|
528
|
-
if (s.path.length === 0 && s.op === "replace") {
|
|
529
|
-
e = s.value;
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
r > -1 && (t = t.slice(r + 1));
|
|
534
|
-
const n = E(De).applyPatches_;
|
|
535
|
-
return M(e) ? n(e, t) : this.produce(
|
|
536
|
-
e,
|
|
537
|
-
(s) => n(s, t)
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
function ze(e, t, r, n) {
|
|
542
|
-
const [s, i] = ue(t) ? E(re).proxyMap_(t, r) : fe(t) ? E(re).proxySet_(t, r) : Dt(t, r);
|
|
543
|
-
return ((r == null ? void 0 : r.scope_) ?? et()).drafts_.push(s), i.callbacks_ = (r == null ? void 0 : r.callbacks_) ?? [], i.key_ = n, r && n !== void 0 ? At(r, i, n) : i.callbacks_.push(function(h) {
|
|
544
|
-
var _;
|
|
545
|
-
(_ = h.mapSetPlugin_) == null || _.fixSetContents(i);
|
|
546
|
-
const { patchPlugin_: d } = h;
|
|
547
|
-
i.modified_ && d && d.generatePatches_(i, [], h);
|
|
548
|
-
}), s;
|
|
549
|
-
}
|
|
550
|
-
function Mt(e) {
|
|
551
|
-
return M(e) || g(10, e), it(e);
|
|
552
|
-
}
|
|
553
|
-
function it(e) {
|
|
554
|
-
if (!C(e) || le(e))
|
|
555
|
-
return e;
|
|
556
|
-
const t = e[p];
|
|
557
|
-
let r, n = !0;
|
|
558
|
-
if (t) {
|
|
559
|
-
if (!t.modified_)
|
|
560
|
-
return t.base_;
|
|
561
|
-
t.finalized_ = !0, r = be(e, t.scope_.immer_.useStrictShallowCopy_), n = t.scope_.immer_.shouldUseStrictIteration();
|
|
562
|
-
} else
|
|
563
|
-
r = be(e, !0);
|
|
564
|
-
return ce(
|
|
565
|
-
r,
|
|
566
|
-
(s, i) => {
|
|
567
|
-
te(r, s, it(i));
|
|
568
|
-
},
|
|
569
|
-
n
|
|
570
|
-
), t && (t.finalized_ = !1), r;
|
|
571
|
-
}
|
|
572
|
-
var zt = new Ct(), ot = zt.produce;
|
|
573
|
-
class xt extends F {
|
|
574
|
-
constructor(t, r) {
|
|
575
|
-
super(r), this.a = t, this.push = (...n) => {
|
|
576
|
-
n.length !== 0 && this.a.set(this.a.get().concat(n));
|
|
577
|
-
}, this.unshift = (...n) => {
|
|
578
|
-
n.length !== 0 && this.a.set(n.concat(this.a.get()));
|
|
579
|
-
}, this.update = (n) => {
|
|
580
|
-
const s = this.a.get(), i = ot(s, (c) => void n(c));
|
|
581
|
-
i !== s && this.a.set(i);
|
|
582
|
-
}, this.filter = (n) => {
|
|
583
|
-
const s = this.a.get().filter(n ?? vt);
|
|
584
|
-
s.length !== this.a.get().length && this.a.set(s);
|
|
585
|
-
}, this.add = (n) => {
|
|
586
|
-
this.a.get().includes(n) || this.a.set(this.a.get().concat([n]));
|
|
587
|
-
}, this.removeFirst = (n) => {
|
|
588
|
-
const s = this.a.get().indexOf(n);
|
|
589
|
-
if (s < 0) return;
|
|
590
|
-
const i = this.a.get().slice(0);
|
|
591
|
-
i.splice(s, 1), this.a.set(i);
|
|
592
|
-
}, this.toggle = (n, s) => {
|
|
593
|
-
const i = this.a.get().slice(), c = i.indexOf(n);
|
|
594
|
-
c < 0 ? s ? i.unshift(n) : i.push(n) : i.splice(c, 1), this.a.set(i);
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
const vt = (e) => e;
|
|
599
|
-
class Tt extends F {
|
|
600
|
-
constructor(t, r) {
|
|
601
|
-
super(r), this.a = t, this.toggle = () => {
|
|
42
|
+
const fe = (s) => s;
|
|
43
|
+
class ge extends M {
|
|
44
|
+
constructor(t, a) {
|
|
45
|
+
super(a), this.a = t, this.toggle = () => {
|
|
602
46
|
this.a.set(!this.a.get());
|
|
603
47
|
};
|
|
604
48
|
}
|
|
605
49
|
}
|
|
606
|
-
class
|
|
607
|
-
constructor(t,
|
|
608
|
-
super(
|
|
609
|
-
if (this.a.get().get(
|
|
50
|
+
class de extends M {
|
|
51
|
+
constructor(t, a) {
|
|
52
|
+
super(a), this.a = t, this.setValue = (e, i) => {
|
|
53
|
+
if (this.a.get().get(e) === i) return;
|
|
54
|
+
const n = new Map(this.a.get());
|
|
55
|
+
n.set(e, i), this.a.set(n);
|
|
56
|
+
}, this.setIfNo = (e, i) => {
|
|
57
|
+
if (this.a.get().has(e)) return;
|
|
58
|
+
const n = new Map(this.a.get());
|
|
59
|
+
n.set(e, i), this.a.set(n);
|
|
60
|
+
}, this.delete = (e) => {
|
|
61
|
+
if (!this.a.get().has(e)) return;
|
|
610
62
|
const i = new Map(this.a.get());
|
|
611
|
-
i.
|
|
612
|
-
}, this.
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
i.set(n, s), this.a.set(i);
|
|
616
|
-
}, this.delete = (n) => {
|
|
617
|
-
if (!this.a.get().has(n)) return;
|
|
618
|
-
const s = new Map(this.a.get());
|
|
619
|
-
s.delete(n), this.a.set(s);
|
|
620
|
-
}, this.toggle = (n, s) => {
|
|
621
|
-
const i = new Map(this.a.get());
|
|
622
|
-
i.has(n) ? i.delete(n) : i.set(n, s), this.a.set(i);
|
|
63
|
+
i.delete(e), this.a.set(i);
|
|
64
|
+
}, this.toggle = (e, i) => {
|
|
65
|
+
const n = new Map(this.a.get());
|
|
66
|
+
n.has(e) ? n.delete(e) : n.set(e, i), this.a.set(n);
|
|
623
67
|
}, this.clear = () => {
|
|
624
68
|
this.a.set(/* @__PURE__ */ new Map());
|
|
625
69
|
}, this.a = t;
|
|
626
70
|
}
|
|
627
71
|
}
|
|
628
|
-
class
|
|
629
|
-
constructor(t,
|
|
630
|
-
super(
|
|
631
|
-
this.a.set(+this.a.get() + (
|
|
72
|
+
class pe extends M {
|
|
73
|
+
constructor(t, a) {
|
|
74
|
+
super(a), this.a = t, this.increment = (e) => {
|
|
75
|
+
this.a.set(+this.a.get() + (e ?? 1));
|
|
632
76
|
};
|
|
633
77
|
}
|
|
634
78
|
}
|
|
635
|
-
class
|
|
636
|
-
constructor(t,
|
|
637
|
-
super(
|
|
638
|
-
...
|
|
639
|
-
...typeof
|
|
640
|
-
})), this.update = (
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
}, this.setDeepPartial = (
|
|
644
|
-
if (!
|
|
645
|
-
if (
|
|
646
|
-
let
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
const
|
|
650
|
-
let
|
|
651
|
-
for (const
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
655
|
-
if (
|
|
656
|
-
const
|
|
657
|
-
this.a.get()[
|
|
79
|
+
class we extends M {
|
|
80
|
+
constructor(t, a) {
|
|
81
|
+
super(a), this.a = t, this.setPartial = (e) => this.a.set((i) => ({
|
|
82
|
+
...i,
|
|
83
|
+
...typeof e == "function" ? e(this.a.get()) : e
|
|
84
|
+
})), this.update = (e) => {
|
|
85
|
+
const i = this.a.get(), n = F(i, (u) => void e(u));
|
|
86
|
+
n !== i && this.a.set(n);
|
|
87
|
+
}, this.setDeepPartial = (e, i, n, u = w.keyPathSeparator || ".") => {
|
|
88
|
+
if (!u) return;
|
|
89
|
+
if (e.includes(u)) {
|
|
90
|
+
let V = e.split(u);
|
|
91
|
+
const m = V[V.length - 1];
|
|
92
|
+
V = V.slice(0, -1);
|
|
93
|
+
const C = { ...this.a.get() };
|
|
94
|
+
let h = C, f = n;
|
|
95
|
+
for (const c of V) {
|
|
96
|
+
f = f == null ? void 0 : f[Array.isArray(f) ? "0" : c];
|
|
97
|
+
const x = h[Z(h, c)] ?? (Array.isArray(f) ? [] : {});
|
|
98
|
+
if (x == null || typeof x != "object") {
|
|
99
|
+
if (n == null) throw "Incorrect path for setDeepPartial";
|
|
100
|
+
const y = typeof i == "function" ? i(void 0) : i;
|
|
101
|
+
this.a.get()[e] !== y && this.setPartial({ [e]: y });
|
|
658
102
|
return;
|
|
659
103
|
}
|
|
660
|
-
|
|
104
|
+
h = h[Z(h, c)] = Array.isArray(x) ? [...x] : { ...x };
|
|
661
105
|
}
|
|
662
|
-
const
|
|
663
|
-
|
|
106
|
+
const O = h[m];
|
|
107
|
+
h[m] = typeof i == "function" ? i(h[m]) : i, O !== h[m] && this.a.set(C);
|
|
664
108
|
return;
|
|
665
109
|
}
|
|
666
|
-
const
|
|
667
|
-
|
|
110
|
+
const A = this.a.get()[e], b = typeof i == "function" ? i(A) : i;
|
|
111
|
+
b !== A && this.setPartial({ [e]: b });
|
|
668
112
|
};
|
|
669
113
|
}
|
|
670
114
|
}
|
|
671
|
-
const
|
|
672
|
-
class
|
|
673
|
-
constructor(t,
|
|
674
|
-
super(
|
|
675
|
-
this.a.get().has(
|
|
676
|
-
}, this.delete = (
|
|
677
|
-
if (!this.a.get().has(
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
}, this.toggle = (
|
|
681
|
-
const
|
|
682
|
-
|
|
115
|
+
const Z = (s, t) => Array.isArray(s) ? `${+t}` : t;
|
|
116
|
+
class me extends M {
|
|
117
|
+
constructor(t, a) {
|
|
118
|
+
super(a), this.a = t, this.add = (e) => {
|
|
119
|
+
this.a.get().has(e) || this.a.set(new Set(this.a.get()).add(e));
|
|
120
|
+
}, this.delete = (e) => {
|
|
121
|
+
if (!this.a.get().has(e)) return;
|
|
122
|
+
const i = new Set(this.a.get());
|
|
123
|
+
i.delete(e), this.a.set(i);
|
|
124
|
+
}, this.toggle = (e) => {
|
|
125
|
+
const i = new Set(this.a.get());
|
|
126
|
+
i.has(e) ? i.delete(e) : i.add(e), this.a.set(i);
|
|
683
127
|
}, this.clear = () => {
|
|
684
128
|
this.a.set(/* @__PURE__ */ new Set());
|
|
685
129
|
}, this.a = t;
|
|
686
130
|
}
|
|
687
131
|
}
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
(
|
|
132
|
+
const ye = (s, t, a) => {
|
|
133
|
+
const e = typeof a == "object" && a != null && "do" in a ? a.do(
|
|
134
|
+
(n, u) => t.set(n, u),
|
|
691
135
|
() => t.get(),
|
|
692
136
|
t,
|
|
693
|
-
(
|
|
694
|
-
) : null,
|
|
695
|
-
return
|
|
137
|
+
(n, u, A, b) => t.setDeferred(n, u, A, b)
|
|
138
|
+
) : null, i = {};
|
|
139
|
+
return e && Object.keys(e).forEach((n) => Object.defineProperty(i, n, { get: () => e[n] })), typeof s == "number" ? new pe(t, e) : typeof s == "boolean" ? new ge(t, e) : Array.isArray(s) ? new he(t, e) : s instanceof Set ? new me(t, e) : s instanceof Map ? new de(t, e) : s instanceof Object ? new we(t, e) : new M(e);
|
|
696
140
|
};
|
|
697
|
-
class
|
|
698
|
-
constructor(t,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
141
|
+
class Se {
|
|
142
|
+
constructor(t, a) {
|
|
143
|
+
this.isInited = !1, this.rawInitialValue = t, this.rawOptions = a;
|
|
144
|
+
}
|
|
145
|
+
get initialValue() {
|
|
146
|
+
return this.init(), this.initialValue;
|
|
147
|
+
}
|
|
148
|
+
get get() {
|
|
149
|
+
return this.init(), this.get;
|
|
150
|
+
}
|
|
151
|
+
get set() {
|
|
152
|
+
return this.init(), this.set;
|
|
153
|
+
}
|
|
154
|
+
get setDeferred() {
|
|
155
|
+
return this.init(), this.setDeferred;
|
|
156
|
+
}
|
|
157
|
+
get reset() {
|
|
158
|
+
return this.init(), this.reset;
|
|
159
|
+
}
|
|
160
|
+
get subscribe() {
|
|
161
|
+
return this.init(), this.subscribe;
|
|
162
|
+
}
|
|
163
|
+
get isInitialValue() {
|
|
164
|
+
return this.init(), this.isInitialValue;
|
|
165
|
+
}
|
|
166
|
+
get do() {
|
|
167
|
+
return this.init(), this.doActions ?? (this.doActions = ye(this.initialValue, this, this.rawOptions));
|
|
168
|
+
}
|
|
169
|
+
init() {
|
|
170
|
+
var X;
|
|
171
|
+
if (this.isInited) return;
|
|
172
|
+
this.isInited = !0;
|
|
173
|
+
const t = typeof this.rawInitialValue == "function" ? this.rawInitialValue() : this.rawInitialValue, a = (r) => V = r, e = () => V, i = /* @__PURE__ */ new Set(), n = (r) => r(h());
|
|
174
|
+
let u = !0, A = !1, b = (r) => r, V = t, m, C = () => {
|
|
175
|
+
}, h = () => e(), f = null, O = () => {
|
|
176
|
+
y(t, !0);
|
|
177
|
+
}, c = "";
|
|
178
|
+
const x = () => {
|
|
179
|
+
if (u = !0, A !== !0 && C(h()), A = !1, !!c)
|
|
180
|
+
try {
|
|
181
|
+
W.postMessage({ key: c, value: e() });
|
|
182
|
+
} catch {
|
|
183
|
+
}
|
|
184
|
+
}, y = (r, l) => {
|
|
185
|
+
let d = typeof r == "function" ? r(h()) : r;
|
|
186
|
+
d = b(d, h()), d !== h() && (a(d), A = l, u && (u = !1, i.forEach(n), queueMicrotask(x)));
|
|
187
|
+
}, I = (r, l) => Object.defineProperty(this, r, { value: l, writable: !1, configurable: !0, enumerable: !0 });
|
|
188
|
+
I("initialValue", t), I("get", () => h()), I(
|
|
189
|
+
"set",
|
|
190
|
+
(r, l) => y(r, l)
|
|
191
|
+
), I("isInitialValue", () => t === e()), I("subscribe", (r) => (i.add(r), () => {
|
|
192
|
+
i.delete(r);
|
|
193
|
+
})), I("reset", () => O());
|
|
194
|
+
const ce = (r, l) => {
|
|
195
|
+
y(r, l), m = void 0;
|
|
705
196
|
};
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
u = !0, h !== !0 && S(y()), h = !1;
|
|
711
|
-
try {
|
|
712
|
-
xe.postMessage({ key: f, value: s() });
|
|
713
|
-
} catch {
|
|
197
|
+
I(
|
|
198
|
+
"setDeferred",
|
|
199
|
+
(r, l = 500, d, S = !0) => {
|
|
200
|
+
S && m === void 0 && y(r, d), clearTimeout(m), m = setTimeout(ce, l, r, d);
|
|
714
201
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
};
|
|
724
|
-
const ft = (o, l) => {
|
|
725
|
-
$(o, l), z = void 0;
|
|
726
|
-
};
|
|
727
|
-
if (this.setDeferred = (o, l = 500, A, D = !0) => {
|
|
728
|
-
D && z === void 0 && $(o, A), clearTimeout(z), z = setTimeout(ft, l, o, A);
|
|
729
|
-
}, r == null) return m;
|
|
730
|
-
let P = null, B = null, _e = !0, ye = !0, pe = !1, x = 0, R = 0, Re = -1, k = t instanceof Set ? (o) => new Set(o) : t instanceof Map ? (o) => new Map(o) : (o) => o, L = t instanceof Set ? (o) => {
|
|
731
|
-
if (o instanceof Set) return Array.from(o);
|
|
732
|
-
throw console.error(o), "The value is not Set instance";
|
|
733
|
-
} : t instanceof Map ? (o) => {
|
|
734
|
-
if (o instanceof Map) {
|
|
202
|
+
);
|
|
203
|
+
const g = this.rawOptions;
|
|
204
|
+
if (g == null) return;
|
|
205
|
+
let p = null, K = null, R = !0, D = 0, _ = 0, H = -1, $ = t instanceof Set ? (r) => new Set(r) : t instanceof Map ? (r) => new Map(r) : (r) => r, L = t instanceof Set ? (r) => {
|
|
206
|
+
if (r instanceof Set) return Array.from(r);
|
|
207
|
+
throw console.error(r), "The value is not Set instance";
|
|
208
|
+
} : t instanceof Map ? (r) => {
|
|
209
|
+
if (r instanceof Map) {
|
|
735
210
|
const l = [];
|
|
736
|
-
return
|
|
211
|
+
return r.forEach((d, S) => l.push([S, d])), l;
|
|
737
212
|
}
|
|
738
|
-
throw console.error(
|
|
739
|
-
} : (
|
|
740
|
-
if (typeof
|
|
741
|
-
|
|
742
|
-
else
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
213
|
+
throw console.error(r), "The value is not Set instance";
|
|
214
|
+
} : (r) => r;
|
|
215
|
+
if (typeof g == "string")
|
|
216
|
+
p = g;
|
|
217
|
+
else {
|
|
218
|
+
if (b = g.map ?? b, !("storageKey" in g)) return;
|
|
219
|
+
R = g.warnOnDuplicateStorageKey ?? R, p = g.storageKey, $ = g.unzipValue ?? $, L = g.zipValue ?? L, D = g.securifyKeyLevel ?? w.securifyKeyLevel ?? D, _ = g.securifyValueLevel ?? w.securifyValueLevel ?? _, K = g.exp ?? K;
|
|
220
|
+
}
|
|
221
|
+
const o = w.storage;
|
|
222
|
+
if (!o) throw "call configureAtomaric({storage: new AtomaricLocalStorage()}) before all!";
|
|
223
|
+
const z = D ? P(p, D) : p;
|
|
224
|
+
if (c = `${_ ? q : T}${z}`, D) {
|
|
225
|
+
const r = `${T}${p}`;
|
|
226
|
+
o.has(r) && (o.set(c, o.get(r)), o.rem(r));
|
|
749
227
|
} else {
|
|
750
|
-
const
|
|
751
|
-
o
|
|
228
|
+
const r = `${T}${P(p, D)}`;
|
|
229
|
+
o.has(r) && (o.set(c, o.get(r)), o.rem(r));
|
|
752
230
|
}
|
|
753
|
-
const
|
|
754
|
-
if (
|
|
755
|
-
const
|
|
756
|
-
if (L = (
|
|
231
|
+
const U = K === null || !(K(this, o.has(c)) instanceof Date) ? (r) => P([L(r)], 0) : (r) => (f ?? (f = {}), f.exp = K(this, o.has(c)).getTime(), f.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout(H), clearTimeout(ne[c]), H = setTimeout(() => this.reset(), f.exp - Date.now())), f.exp = Math.trunc(f.exp / 1e3), P([L(r), f], 0));
|
|
232
|
+
if (_) {
|
|
233
|
+
const r = `${T}${z}`, l = L, d = $;
|
|
234
|
+
if (L = (S) => {
|
|
757
235
|
try {
|
|
758
|
-
return
|
|
236
|
+
return P([l(S)], _);
|
|
759
237
|
} catch {
|
|
760
|
-
return
|
|
238
|
+
return o.rem(c), "";
|
|
761
239
|
}
|
|
762
|
-
}, o
|
|
763
|
-
const
|
|
240
|
+
}, o.has(r)) {
|
|
241
|
+
const S = `${T}${P(p, D)}`;
|
|
764
242
|
try {
|
|
765
|
-
|
|
243
|
+
o.set(S, U($(j(o.get(r), 0)[0]))), o.rem(r);
|
|
766
244
|
} catch {
|
|
767
245
|
}
|
|
768
246
|
}
|
|
769
|
-
|
|
247
|
+
$ = (S) => {
|
|
770
248
|
try {
|
|
771
|
-
return
|
|
249
|
+
return d(j(S, _)[0]);
|
|
772
250
|
} catch {
|
|
773
|
-
return
|
|
251
|
+
return o.rem(c), "";
|
|
774
252
|
}
|
|
775
253
|
};
|
|
776
|
-
} else
|
|
777
|
-
const
|
|
778
|
-
const l =
|
|
779
|
-
return
|
|
254
|
+
} else o.rem(`${q}${z}`);
|
|
255
|
+
const J = (r) => {
|
|
256
|
+
const l = j(r, 0);
|
|
257
|
+
return f = l[1], $(l[0]);
|
|
780
258
|
};
|
|
781
|
-
let
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
259
|
+
let G = !0;
|
|
260
|
+
N[c] = this;
|
|
261
|
+
const Q = o.get(`atom/${p}`);
|
|
262
|
+
if (Q !== void 0 && (o.get(c) || o.set(c, `[${Q}]`), o.rem(`atom/${p}`)), h = () => {
|
|
263
|
+
if (h = e, G) {
|
|
264
|
+
G = !1;
|
|
785
265
|
try {
|
|
786
|
-
|
|
266
|
+
const r = o.get(c);
|
|
267
|
+
a(r !== void 0 ? J(r) : t);
|
|
787
268
|
} catch {
|
|
788
|
-
console.warn("Invalid json value",
|
|
269
|
+
console.warn("Invalid json value", o.get(c));
|
|
789
270
|
}
|
|
790
271
|
}
|
|
791
|
-
return
|
|
792
|
-
},
|
|
793
|
-
if (
|
|
272
|
+
return e();
|
|
273
|
+
}, C = (r) => {
|
|
274
|
+
if (r === t) {
|
|
794
275
|
this.reset();
|
|
795
276
|
return;
|
|
796
277
|
}
|
|
797
|
-
|
|
798
|
-
},
|
|
799
|
-
|
|
800
|
-
},
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
return m;
|
|
278
|
+
o.set(c, U(r));
|
|
279
|
+
}, O = () => {
|
|
280
|
+
o.rem(c), y(t, !0);
|
|
281
|
+
}, R && ee.has(c) && console.warn("Duplicate Atom key", p), ee.add(c), o.unchangable ?? !1) {
|
|
282
|
+
(X = o.protect) == null || X.call(o, c);
|
|
283
|
+
let r = !1, l;
|
|
284
|
+
ie[c] = this, o.listen(c, () => {
|
|
285
|
+
clearTimeout(l), l = setTimeout(() => r = !1, 10), !r && (r = !0, o.set(c, U(e())));
|
|
286
|
+
});
|
|
287
|
+
} else
|
|
288
|
+
o.listen(c, (r) => {
|
|
289
|
+
if (r.newValue === null) {
|
|
290
|
+
this.reset();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
y(J(r.newValue));
|
|
295
|
+
} catch {
|
|
296
|
+
console.warn("Invalid json value", r.newValue);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
819
299
|
}
|
|
820
300
|
}
|
|
821
|
-
let
|
|
301
|
+
let W;
|
|
822
302
|
try {
|
|
823
|
-
|
|
303
|
+
W = new BroadcastChannel("updateHere"), W.addEventListener("message", (s) => {
|
|
824
304
|
var t;
|
|
825
|
-
(t =
|
|
305
|
+
(t = ie[s.data.key]) == null || t.set(s.data.value, !0);
|
|
826
306
|
});
|
|
827
307
|
} catch {
|
|
828
308
|
}
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
e.key === null || e.newValue === e.oldValue || (t = j[e.key]) == null || t.call(j, e);
|
|
835
|
-
});
|
|
836
|
-
const Vt = a.setItem.bind(a), Ut = a.removeItem.bind(a);
|
|
837
|
-
a.setItem = (e, t) => {
|
|
838
|
-
he[e] === void 0 && Vt.call(a, e, t);
|
|
839
|
-
};
|
|
840
|
-
a.removeItem = (e) => {
|
|
841
|
-
he[e] === void 0 && Ut.call(a, e);
|
|
842
|
-
};
|
|
843
|
-
const jt = /"exp":\s*(\d+)/, U = "atom\\", ve = "atom`s\\", Te = {}, ct = {}, at = /[a-z]/gi, ie = 5, Ee = {};
|
|
844
|
-
for (let e = 54; e < 80; e++) {
|
|
845
|
-
if (e === 68 || e === 72 || e === 55) continue;
|
|
846
|
-
const t = String.fromCharCode(e + 43).toUpperCase(), r = String.fromCharCode(e + 43).toLowerCase();
|
|
847
|
-
Ee[t] = r, Ee[r] = t;
|
|
309
|
+
const ee = /* @__PURE__ */ new Set(), ie = {}, Ae = /"exp":\s*(\d+)/, T = "atom\\", q = "atom`s\\", N = {}, ne = {}, ae = /[a-z]/gi, E = 5, k = {};
|
|
310
|
+
for (let s = 54; s < 80; s++) {
|
|
311
|
+
if (s === 68 || s === 72 || s === 55) continue;
|
|
312
|
+
const t = String.fromCharCode(s + 43).toUpperCase(), a = String.fromCharCode(s + 43).toLowerCase();
|
|
313
|
+
k[t] = a, k[a] = t;
|
|
848
314
|
}
|
|
849
|
-
const
|
|
850
|
-
const
|
|
315
|
+
const oe = (s) => k[s] ?? s, P = /* @__PURE__ */ (() => {
|
|
316
|
+
const s = [
|
|
851
317
|
(t) => JSON.stringify(t),
|
|
852
|
-
(t) => btoa(encodeURI(
|
|
318
|
+
(t) => btoa(encodeURI(s[0](t))),
|
|
853
319
|
(t) => {
|
|
854
|
-
const
|
|
855
|
-
return `${
|
|
320
|
+
const a = s[1](t);
|
|
321
|
+
return `${a.slice(0, E)}${a.slice(E).replace(ae, oe)}`;
|
|
856
322
|
},
|
|
857
|
-
(t) => btoa(
|
|
323
|
+
(t) => btoa(s[2](t))
|
|
858
324
|
];
|
|
859
|
-
return (t,
|
|
325
|
+
return (t, a) => {
|
|
860
326
|
try {
|
|
861
|
-
return
|
|
862
|
-
} catch (
|
|
863
|
-
if (
|
|
864
|
-
return
|
|
327
|
+
return s[a](t);
|
|
328
|
+
} catch (e) {
|
|
329
|
+
if (a === 0) throw e;
|
|
330
|
+
return s[0](t);
|
|
865
331
|
}
|
|
866
332
|
};
|
|
867
|
-
})(),
|
|
868
|
-
const
|
|
333
|
+
})(), j = /* @__PURE__ */ (() => {
|
|
334
|
+
const s = [
|
|
869
335
|
(t) => JSON.parse(t),
|
|
870
|
-
(t) =>
|
|
871
|
-
(t) =>
|
|
872
|
-
`${t.slice(0,
|
|
336
|
+
(t) => s[0](decodeURI(atob(t))),
|
|
337
|
+
(t) => s[1](
|
|
338
|
+
`${t.slice(0, E)}${t.slice(E).replace(ae, oe)}`
|
|
873
339
|
),
|
|
874
|
-
(t) =>
|
|
340
|
+
(t) => s[2](atob(t))
|
|
875
341
|
];
|
|
876
|
-
return (t,
|
|
342
|
+
return (t, a) => {
|
|
877
343
|
try {
|
|
878
|
-
return
|
|
879
|
-
} catch (
|
|
880
|
-
if (
|
|
881
|
-
return
|
|
344
|
+
return s[a](t);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
if (a === 0) throw e;
|
|
347
|
+
return s[0](t);
|
|
882
348
|
}
|
|
883
349
|
};
|
|
884
350
|
})();
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
()
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
351
|
+
let te = !1;
|
|
352
|
+
const be = (s) => {
|
|
353
|
+
te || (te = !0, setTimeout(() => {
|
|
354
|
+
s.keys().forEach((t) => {
|
|
355
|
+
var i, n;
|
|
356
|
+
if (!t.startsWith(T) && !t.startsWith(q)) return;
|
|
357
|
+
const a = (n = (i = s.get(t)) == null ? void 0 : i.match(Ae)) == null ? void 0 : n[1];
|
|
358
|
+
if (!a || +a * 1e3 - Date.now() > 24 * 60 * 60 * 1e3) return;
|
|
359
|
+
const e = j(s.get(t), 0);
|
|
360
|
+
!Array.isArray(e) || e[1] == null || !("exp" in e[1]) || e[1].exp !== a || (ne[t] = setTimeout(
|
|
361
|
+
() => {
|
|
362
|
+
N[t] ? N[t].reset() : s.rem(t);
|
|
363
|
+
},
|
|
364
|
+
+a * 1e3 - Date.now()
|
|
365
|
+
));
|
|
366
|
+
});
|
|
367
|
+
}, 1e3));
|
|
368
|
+
}, Ve = localStorage.setItem.bind(localStorage), xe = localStorage.removeItem.bind(localStorage), v = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Set();
|
|
369
|
+
let se = !1;
|
|
370
|
+
function Ie() {
|
|
371
|
+
if (se) return;
|
|
372
|
+
se = !0;
|
|
373
|
+
const s = Object.getPrototypeOf(localStorage), t = s.setItem, a = s.removeItem;
|
|
374
|
+
s.setItem = function(e, i) {
|
|
375
|
+
B.has(e) || t.call(this, e, i);
|
|
376
|
+
}, s.removeItem = function(e) {
|
|
377
|
+
B.has(e) || a.call(this, e);
|
|
378
|
+
}, window.addEventListener("storage", (e) => {
|
|
379
|
+
var i;
|
|
380
|
+
e.key === null || e.newValue === e.oldValue || (i = v.get(e.key)) == null || i.forEach((n) => n({ newValue: e.newValue }));
|
|
898
381
|
});
|
|
899
|
-
}
|
|
382
|
+
}
|
|
383
|
+
class Ce {
|
|
384
|
+
constructor({ listenStorageChanges: t = !0, unchangable: a = !1 } = {}) {
|
|
385
|
+
this.set = (e, i) => Ve(e, i), this.get = (e) => localStorage.getItem(e) ?? void 0, this.rem = (e) => xe(e), this.has = (e) => localStorage.getItem(e) !== null, this.keys = () => Array.from({ length: localStorage.length }, (e, i) => localStorage.key(i)).filter(
|
|
386
|
+
(e) => e !== null
|
|
387
|
+
), this.listen = (e, i) => {
|
|
388
|
+
if (!this.listenStorageChanges) return () => {
|
|
389
|
+
};
|
|
390
|
+
let n = v.get(e);
|
|
391
|
+
return n || v.set(e, n = /* @__PURE__ */ new Set()), n.add(i), () => n.delete(i);
|
|
392
|
+
}, this.protect = (e) => {
|
|
393
|
+
this.listenStorageChanges && B.add(e);
|
|
394
|
+
}, this.listenStorageChanges = t, this.unchangable = a, t && Ie();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
900
397
|
export {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
398
|
+
Se as Atom,
|
|
399
|
+
he as AtomArrayDoActions,
|
|
400
|
+
ge as AtomBooleanDoActions,
|
|
401
|
+
de as AtomMapDoActions,
|
|
402
|
+
pe as AtomNumberDoActions,
|
|
403
|
+
we as AtomObjectDoActions,
|
|
404
|
+
me as AtomSetDoActions,
|
|
405
|
+
Ce as AtomaricLocalStorage,
|
|
406
|
+
Te as atom,
|
|
407
|
+
Me as configureAtomaric,
|
|
408
|
+
w as configuredOptions,
|
|
409
|
+
be as initExpWatcher,
|
|
410
|
+
Pe as useAtom,
|
|
411
|
+
Le as useAtomDo,
|
|
412
|
+
$e as useAtomGet,
|
|
413
|
+
ue as useAtomSet,
|
|
414
|
+
_e as useAtomSetDeferred,
|
|
415
|
+
le as useAtomValue
|
|
917
416
|
};
|