@reactive-vscode/reactivity 1.0.0-beta.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2276 +1,1813 @@
1
- // @__NO_SIDE_EFFECTS__
1
+ //#region ../../node_modules/.pnpm/@vue+shared@3.5.32/node_modules/@vue/shared/dist/shared.esm-bundler.js
2
+ /**
3
+ * @vue/shared v3.5.32
4
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
5
+ * @license MIT
6
+ **/
7
+ /* @__NO_SIDE_EFFECTS__ */
2
8
  function makeMap(str) {
3
- const map = /* @__PURE__ */ Object.create(null);
4
- for (const key of str.split(",")) map[key] = 1;
5
- return (val) => val in map;
6
- }
7
- const EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
8
- !!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
9
- const NOOP = () => {
10
- };
11
- const extend = Object.assign;
12
- const remove = (arr, el) => {
13
- const i = arr.indexOf(el);
14
- if (i > -1) {
15
- arr.splice(i, 1);
16
- }
9
+ const map = /* @__PURE__ */ Object.create(null);
10
+ for (const key of str.split(",")) map[key] = 1;
11
+ return (val) => val in map;
12
+ }
13
+ var EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
14
+ process.env.NODE_ENV !== "production" && Object.freeze([]);
15
+ var NOOP = () => {};
16
+ var extend = Object.assign;
17
+ var remove = (arr, el) => {
18
+ const i = arr.indexOf(el);
19
+ if (i > -1) arr.splice(i, 1);
17
20
  };
18
- const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
19
- const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
20
- const isArray = Array.isArray;
21
- const isMap = (val) => toTypeString(val) === "[object Map]";
22
- const isSet = (val) => toTypeString(val) === "[object Set]";
23
- const isFunction = (val) => typeof val === "function";
24
- const isString = (val) => typeof val === "string";
25
- const isSymbol = (val) => typeof val === "symbol";
26
- const isObject = (val) => val !== null && typeof val === "object";
27
- const isPromise = (val) => {
28
- return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
21
+ var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
22
+ var hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
23
+ var isArray = Array.isArray;
24
+ var isMap = (val) => toTypeString(val) === "[object Map]";
25
+ var isSet = (val) => toTypeString(val) === "[object Set]";
26
+ var isFunction = (val) => typeof val === "function";
27
+ var isString = (val) => typeof val === "string";
28
+ var isSymbol = (val) => typeof val === "symbol";
29
+ var isObject = (val) => val !== null && typeof val === "object";
30
+ var isPromise = (val) => {
31
+ return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
29
32
  };
30
- const objectToString = Object.prototype.toString;
31
- const toTypeString = (value) => objectToString.call(value);
32
- const toRawType = (value) => {
33
- return toTypeString(value).slice(8, -1);
33
+ var objectToString = Object.prototype.toString;
34
+ var toTypeString = (value) => objectToString.call(value);
35
+ var toRawType = (value) => {
36
+ return toTypeString(value).slice(8, -1);
34
37
  };
35
- const isPlainObject = (val) => toTypeString(val) === "[object Object]";
36
- const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
37
- const cacheStringFunction = (fn) => {
38
- const cache = /* @__PURE__ */ Object.create(null);
39
- return ((str) => {
40
- const hit = cache[str];
41
- return hit || (cache[str] = fn(str));
42
- });
38
+ var isPlainObject = (val) => toTypeString(val) === "[object Object]";
39
+ var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
40
+ var cacheStringFunction = (fn) => {
41
+ const cache = /* @__PURE__ */ Object.create(null);
42
+ return ((str) => {
43
+ return cache[str] || (cache[str] = fn(str));
44
+ });
43
45
  };
44
- const capitalize = cacheStringFunction((str) => {
45
- return str.charAt(0).toUpperCase() + str.slice(1);
46
+ var camelizeRE = /-\w/g;
47
+ cacheStringFunction((str) => {
48
+ return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
49
+ });
50
+ var hyphenateRE = /\B([A-Z])/g;
51
+ cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
52
+ var capitalize = cacheStringFunction((str) => {
53
+ return str.charAt(0).toUpperCase() + str.slice(1);
54
+ });
55
+ cacheStringFunction((str) => {
56
+ return str ? `on${capitalize(str)}` : ``;
46
57
  });
47
- const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
48
- const def = (obj, key, value, writable = false) => {
49
- Object.defineProperty(obj, key, {
50
- configurable: true,
51
- enumerable: false,
52
- writable,
53
- value
54
- });
58
+ var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
59
+ var def = (obj, key, value, writable = false) => {
60
+ Object.defineProperty(obj, key, {
61
+ configurable: true,
62
+ enumerable: false,
63
+ writable,
64
+ value
65
+ });
55
66
  };
67
+ //#endregion
68
+ //#region ../../node_modules/.pnpm/@vue+reactivity@3.5.32/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
69
+ /**
70
+ * @vue/reactivity v3.5.32
71
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
72
+ * @license MIT
73
+ **/
56
74
  function warn$1(msg, ...args) {
57
- console.warn(`[Vue warn] ${msg}`, ...args);
58
- }
59
- let activeEffectScope;
60
- class EffectScope {
61
- constructor(detached = false) {
62
- this.detached = detached;
63
- this._active = true;
64
- this._on = 0;
65
- this.effects = [];
66
- this.cleanups = [];
67
- this._isPaused = false;
68
- this.parent = activeEffectScope;
69
- if (!detached && activeEffectScope) {
70
- this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
71
- this
72
- ) - 1;
73
- }
74
- }
75
- get active() {
76
- return this._active;
77
- }
78
- pause() {
79
- if (this._active) {
80
- this._isPaused = true;
81
- let i, l;
82
- if (this.scopes) {
83
- for (i = 0, l = this.scopes.length; i < l; i++) {
84
- this.scopes[i].pause();
85
- }
86
- }
87
- for (i = 0, l = this.effects.length; i < l; i++) {
88
- this.effects[i].pause();
89
- }
90
- }
91
- }
92
- /**
93
- * Resumes the effect scope, including all child scopes and effects.
94
- */
95
- resume() {
96
- if (this._active) {
97
- if (this._isPaused) {
98
- this._isPaused = false;
99
- let i, l;
100
- if (this.scopes) {
101
- for (i = 0, l = this.scopes.length; i < l; i++) {
102
- this.scopes[i].resume();
103
- }
104
- }
105
- for (i = 0, l = this.effects.length; i < l; i++) {
106
- this.effects[i].resume();
107
- }
108
- }
109
- }
110
- }
111
- run(fn) {
112
- if (this._active) {
113
- const currentEffectScope = activeEffectScope;
114
- try {
115
- activeEffectScope = this;
116
- return fn();
117
- } finally {
118
- activeEffectScope = currentEffectScope;
119
- }
120
- } else if (!!(process.env.NODE_ENV !== "production")) {
121
- warn$1(`cannot run an inactive effect scope.`);
122
- }
123
- }
124
- /**
125
- * This should only be called on non-detached scopes
126
- * @internal
127
- */
128
- on() {
129
- if (++this._on === 1) {
130
- this.prevScope = activeEffectScope;
131
- activeEffectScope = this;
132
- }
133
- }
134
- /**
135
- * This should only be called on non-detached scopes
136
- * @internal
137
- */
138
- off() {
139
- if (this._on > 0 && --this._on === 0) {
140
- activeEffectScope = this.prevScope;
141
- this.prevScope = void 0;
142
- }
143
- }
144
- stop(fromParent) {
145
- if (this._active) {
146
- this._active = false;
147
- let i, l;
148
- for (i = 0, l = this.effects.length; i < l; i++) {
149
- this.effects[i].stop();
150
- }
151
- this.effects.length = 0;
152
- for (i = 0, l = this.cleanups.length; i < l; i++) {
153
- this.cleanups[i]();
154
- }
155
- this.cleanups.length = 0;
156
- if (this.scopes) {
157
- for (i = 0, l = this.scopes.length; i < l; i++) {
158
- this.scopes[i].stop(true);
159
- }
160
- this.scopes.length = 0;
161
- }
162
- if (!this.detached && this.parent && !fromParent) {
163
- const last = this.parent.scopes.pop();
164
- if (last && last !== this) {
165
- this.parent.scopes[this.index] = last;
166
- last.index = this.index;
167
- }
168
- }
169
- this.parent = void 0;
170
- }
171
- }
172
- }
75
+ console.warn(`[Vue warn] ${msg}`, ...args);
76
+ }
77
+ var activeEffectScope;
78
+ var EffectScope = class {
79
+ constructor(detached = false) {
80
+ this.detached = detached;
81
+ /**
82
+ * @internal
83
+ */
84
+ this._active = true;
85
+ /**
86
+ * @internal track `on` calls, allow `on` call multiple times
87
+ */
88
+ this._on = 0;
89
+ /**
90
+ * @internal
91
+ */
92
+ this.effects = [];
93
+ /**
94
+ * @internal
95
+ */
96
+ this.cleanups = [];
97
+ this._isPaused = false;
98
+ this.__v_skip = true;
99
+ this.parent = activeEffectScope;
100
+ if (!detached && activeEffectScope) this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
101
+ }
102
+ get active() {
103
+ return this._active;
104
+ }
105
+ pause() {
106
+ if (this._active) {
107
+ this._isPaused = true;
108
+ let i, l;
109
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause();
110
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause();
111
+ }
112
+ }
113
+ /**
114
+ * Resumes the effect scope, including all child scopes and effects.
115
+ */
116
+ resume() {
117
+ if (this._active) {
118
+ if (this._isPaused) {
119
+ this._isPaused = false;
120
+ let i, l;
121
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume();
122
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume();
123
+ }
124
+ }
125
+ }
126
+ run(fn) {
127
+ if (this._active) {
128
+ const currentEffectScope = activeEffectScope;
129
+ try {
130
+ activeEffectScope = this;
131
+ return fn();
132
+ } finally {
133
+ activeEffectScope = currentEffectScope;
134
+ }
135
+ } else if (!!(process.env.NODE_ENV !== "production")) warn$1(`cannot run an inactive effect scope.`);
136
+ }
137
+ /**
138
+ * This should only be called on non-detached scopes
139
+ * @internal
140
+ */
141
+ on() {
142
+ if (++this._on === 1) {
143
+ this.prevScope = activeEffectScope;
144
+ activeEffectScope = this;
145
+ }
146
+ }
147
+ /**
148
+ * This should only be called on non-detached scopes
149
+ * @internal
150
+ */
151
+ off() {
152
+ if (this._on > 0 && --this._on === 0) {
153
+ activeEffectScope = this.prevScope;
154
+ this.prevScope = void 0;
155
+ }
156
+ }
157
+ stop(fromParent) {
158
+ if (this._active) {
159
+ this._active = false;
160
+ let i, l;
161
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
162
+ this.effects.length = 0;
163
+ for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
164
+ this.cleanups.length = 0;
165
+ if (this.scopes) {
166
+ for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
167
+ this.scopes.length = 0;
168
+ }
169
+ if (!this.detached && this.parent && !fromParent) {
170
+ const last = this.parent.scopes.pop();
171
+ if (last && last !== this) {
172
+ this.parent.scopes[this.index] = last;
173
+ last.index = this.index;
174
+ }
175
+ }
176
+ this.parent = void 0;
177
+ }
178
+ }
179
+ };
173
180
  function effectScope(detached) {
174
- return new EffectScope(detached);
181
+ return new EffectScope(detached);
175
182
  }
176
183
  function getCurrentScope() {
177
- return activeEffectScope;
184
+ return activeEffectScope;
178
185
  }
179
186
  function onScopeDispose(fn, failSilently = false) {
180
- if (activeEffectScope) {
181
- activeEffectScope.cleanups.push(fn);
182
- } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
183
- warn$1(
184
- `onScopeDispose() is called when there is no active effect scope to be associated with.`
185
- );
186
- }
187
- }
188
- let activeSub;
189
- const EffectFlags = {
190
- "ACTIVE": 1,
191
- "1": "ACTIVE",
192
- "RUNNING": 2,
193
- "2": "RUNNING",
194
- "TRACKING": 4,
195
- "4": "TRACKING",
196
- "NOTIFIED": 8,
197
- "8": "NOTIFIED",
198
- "DIRTY": 16,
199
- "16": "DIRTY",
200
- "ALLOW_RECURSE": 32,
201
- "32": "ALLOW_RECURSE",
202
- "PAUSED": 64,
203
- "64": "PAUSED",
204
- "EVALUATED": 128,
205
- "128": "EVALUATED"
187
+ if (activeEffectScope) activeEffectScope.cleanups.push(fn);
188
+ else if (!!(process.env.NODE_ENV !== "production") && !failSilently) warn$1(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
189
+ }
190
+ var activeSub;
191
+ var EffectFlags = {
192
+ "ACTIVE": 1,
193
+ "1": "ACTIVE",
194
+ "RUNNING": 2,
195
+ "2": "RUNNING",
196
+ "TRACKING": 4,
197
+ "4": "TRACKING",
198
+ "NOTIFIED": 8,
199
+ "8": "NOTIFIED",
200
+ "DIRTY": 16,
201
+ "16": "DIRTY",
202
+ "ALLOW_RECURSE": 32,
203
+ "32": "ALLOW_RECURSE",
204
+ "PAUSED": 64,
205
+ "64": "PAUSED",
206
+ "EVALUATED": 128,
207
+ "128": "EVALUATED"
206
208
  };
207
- const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
208
- class ReactiveEffect {
209
- constructor(fn) {
210
- this.fn = fn;
211
- this.deps = void 0;
212
- this.depsTail = void 0;
213
- this.flags = 1 | 4;
214
- this.next = void 0;
215
- this.cleanup = void 0;
216
- this.scheduler = void 0;
217
- if (activeEffectScope && activeEffectScope.active) {
218
- activeEffectScope.effects.push(this);
219
- }
220
- }
221
- pause() {
222
- this.flags |= 64;
223
- }
224
- resume() {
225
- if (this.flags & 64) {
226
- this.flags &= -65;
227
- if (pausedQueueEffects.has(this)) {
228
- pausedQueueEffects.delete(this);
229
- this.trigger();
230
- }
231
- }
232
- }
233
- /**
234
- * @internal
235
- */
236
- notify() {
237
- if (this.flags & 2 && !(this.flags & 32)) {
238
- return;
239
- }
240
- if (!(this.flags & 8)) {
241
- batch(this);
242
- }
243
- }
244
- run() {
245
- if (!(this.flags & 1)) {
246
- return this.fn();
247
- }
248
- this.flags |= 2;
249
- cleanupEffect(this);
250
- prepareDeps(this);
251
- const prevEffect = activeSub;
252
- const prevShouldTrack = shouldTrack;
253
- activeSub = this;
254
- shouldTrack = true;
255
- try {
256
- return this.fn();
257
- } finally {
258
- if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) {
259
- warn$1(
260
- "Active effect was not restored correctly - this is likely a Vue internal bug."
261
- );
262
- }
263
- cleanupDeps(this);
264
- activeSub = prevEffect;
265
- shouldTrack = prevShouldTrack;
266
- this.flags &= -3;
267
- }
268
- }
269
- stop() {
270
- if (this.flags & 1) {
271
- for (let link = this.deps; link; link = link.nextDep) {
272
- removeSub(link);
273
- }
274
- this.deps = this.depsTail = void 0;
275
- cleanupEffect(this);
276
- this.onStop && this.onStop();
277
- this.flags &= -2;
278
- }
279
- }
280
- trigger() {
281
- if (this.flags & 64) {
282
- pausedQueueEffects.add(this);
283
- } else if (this.scheduler) {
284
- this.scheduler();
285
- } else {
286
- this.runIfDirty();
287
- }
288
- }
289
- /**
290
- * @internal
291
- */
292
- runIfDirty() {
293
- if (isDirty(this)) {
294
- this.run();
295
- }
296
- }
297
- get dirty() {
298
- return isDirty(this);
299
- }
300
- }
301
- let batchDepth = 0;
302
- let batchedSub;
303
- let batchedComputed;
209
+ var pausedQueueEffects = /* @__PURE__ */ new WeakSet();
210
+ var ReactiveEffect = class {
211
+ constructor(fn) {
212
+ this.fn = fn;
213
+ /**
214
+ * @internal
215
+ */
216
+ this.deps = void 0;
217
+ /**
218
+ * @internal
219
+ */
220
+ this.depsTail = void 0;
221
+ /**
222
+ * @internal
223
+ */
224
+ this.flags = 5;
225
+ /**
226
+ * @internal
227
+ */
228
+ this.next = void 0;
229
+ /**
230
+ * @internal
231
+ */
232
+ this.cleanup = void 0;
233
+ this.scheduler = void 0;
234
+ if (activeEffectScope && activeEffectScope.active) activeEffectScope.effects.push(this);
235
+ }
236
+ pause() {
237
+ this.flags |= 64;
238
+ }
239
+ resume() {
240
+ if (this.flags & 64) {
241
+ this.flags &= -65;
242
+ if (pausedQueueEffects.has(this)) {
243
+ pausedQueueEffects.delete(this);
244
+ this.trigger();
245
+ }
246
+ }
247
+ }
248
+ /**
249
+ * @internal
250
+ */
251
+ notify() {
252
+ if (this.flags & 2 && !(this.flags & 32)) return;
253
+ if (!(this.flags & 8)) batch(this);
254
+ }
255
+ run() {
256
+ if (!(this.flags & 1)) return this.fn();
257
+ this.flags |= 2;
258
+ cleanupEffect(this);
259
+ prepareDeps(this);
260
+ const prevEffect = activeSub;
261
+ const prevShouldTrack = shouldTrack;
262
+ activeSub = this;
263
+ shouldTrack = true;
264
+ try {
265
+ return this.fn();
266
+ } finally {
267
+ if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) warn$1("Active effect was not restored correctly - this is likely a Vue internal bug.");
268
+ cleanupDeps(this);
269
+ activeSub = prevEffect;
270
+ shouldTrack = prevShouldTrack;
271
+ this.flags &= -3;
272
+ }
273
+ }
274
+ stop() {
275
+ if (this.flags & 1) {
276
+ for (let link = this.deps; link; link = link.nextDep) removeSub(link);
277
+ this.deps = this.depsTail = void 0;
278
+ cleanupEffect(this);
279
+ this.onStop && this.onStop();
280
+ this.flags &= -2;
281
+ }
282
+ }
283
+ trigger() {
284
+ if (this.flags & 64) pausedQueueEffects.add(this);
285
+ else if (this.scheduler) this.scheduler();
286
+ else this.runIfDirty();
287
+ }
288
+ /**
289
+ * @internal
290
+ */
291
+ runIfDirty() {
292
+ if (isDirty(this)) this.run();
293
+ }
294
+ get dirty() {
295
+ return isDirty(this);
296
+ }
297
+ };
298
+ var batchDepth = 0;
299
+ var batchedSub;
300
+ var batchedComputed;
304
301
  function batch(sub, isComputed = false) {
305
- sub.flags |= 8;
306
- if (isComputed) {
307
- sub.next = batchedComputed;
308
- batchedComputed = sub;
309
- return;
310
- }
311
- sub.next = batchedSub;
312
- batchedSub = sub;
302
+ sub.flags |= 8;
303
+ if (isComputed) {
304
+ sub.next = batchedComputed;
305
+ batchedComputed = sub;
306
+ return;
307
+ }
308
+ sub.next = batchedSub;
309
+ batchedSub = sub;
313
310
  }
314
311
  function startBatch() {
315
- batchDepth++;
312
+ batchDepth++;
316
313
  }
317
314
  function endBatch() {
318
- if (--batchDepth > 0) {
319
- return;
320
- }
321
- if (batchedComputed) {
322
- let e = batchedComputed;
323
- batchedComputed = void 0;
324
- while (e) {
325
- const next = e.next;
326
- e.next = void 0;
327
- e.flags &= -9;
328
- e = next;
329
- }
330
- }
331
- let error;
332
- while (batchedSub) {
333
- let e = batchedSub;
334
- batchedSub = void 0;
335
- while (e) {
336
- const next = e.next;
337
- e.next = void 0;
338
- e.flags &= -9;
339
- if (e.flags & 1) {
340
- try {
341
- ;
342
- e.trigger();
343
- } catch (err) {
344
- if (!error) error = err;
345
- }
346
- }
347
- e = next;
348
- }
349
- }
350
- if (error) throw error;
315
+ if (--batchDepth > 0) return;
316
+ if (batchedComputed) {
317
+ let e = batchedComputed;
318
+ batchedComputed = void 0;
319
+ while (e) {
320
+ const next = e.next;
321
+ e.next = void 0;
322
+ e.flags &= -9;
323
+ e = next;
324
+ }
325
+ }
326
+ let error;
327
+ while (batchedSub) {
328
+ let e = batchedSub;
329
+ batchedSub = void 0;
330
+ while (e) {
331
+ const next = e.next;
332
+ e.next = void 0;
333
+ e.flags &= -9;
334
+ if (e.flags & 1) try {
335
+ e.trigger();
336
+ } catch (err) {
337
+ if (!error) error = err;
338
+ }
339
+ e = next;
340
+ }
341
+ }
342
+ if (error) throw error;
351
343
  }
352
344
  function prepareDeps(sub) {
353
- for (let link = sub.deps; link; link = link.nextDep) {
354
- link.version = -1;
355
- link.prevActiveLink = link.dep.activeLink;
356
- link.dep.activeLink = link;
357
- }
345
+ for (let link = sub.deps; link; link = link.nextDep) {
346
+ link.version = -1;
347
+ link.prevActiveLink = link.dep.activeLink;
348
+ link.dep.activeLink = link;
349
+ }
358
350
  }
359
351
  function cleanupDeps(sub) {
360
- let head;
361
- let tail = sub.depsTail;
362
- let link = tail;
363
- while (link) {
364
- const prev = link.prevDep;
365
- if (link.version === -1) {
366
- if (link === tail) tail = prev;
367
- removeSub(link);
368
- removeDep(link);
369
- } else {
370
- head = link;
371
- }
372
- link.dep.activeLink = link.prevActiveLink;
373
- link.prevActiveLink = void 0;
374
- link = prev;
375
- }
376
- sub.deps = head;
377
- sub.depsTail = tail;
352
+ let head;
353
+ let tail = sub.depsTail;
354
+ let link = tail;
355
+ while (link) {
356
+ const prev = link.prevDep;
357
+ if (link.version === -1) {
358
+ if (link === tail) tail = prev;
359
+ removeSub(link);
360
+ removeDep(link);
361
+ } else head = link;
362
+ link.dep.activeLink = link.prevActiveLink;
363
+ link.prevActiveLink = void 0;
364
+ link = prev;
365
+ }
366
+ sub.deps = head;
367
+ sub.depsTail = tail;
378
368
  }
379
369
  function isDirty(sub) {
380
- for (let link = sub.deps; link; link = link.nextDep) {
381
- if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
382
- return true;
383
- }
384
- }
385
- if (sub._dirty) {
386
- return true;
387
- }
388
- return false;
389
- }
390
- function refreshComputed(computed2) {
391
- if (computed2.flags & 4 && !(computed2.flags & 16)) {
392
- return;
393
- }
394
- computed2.flags &= -17;
395
- if (computed2.globalVersion === globalVersion) {
396
- return;
397
- }
398
- computed2.globalVersion = globalVersion;
399
- if (!computed2.isSSR && computed2.flags & 128 && (!computed2.deps && !computed2._dirty || !isDirty(computed2))) {
400
- return;
401
- }
402
- computed2.flags |= 2;
403
- const dep = computed2.dep;
404
- const prevSub = activeSub;
405
- const prevShouldTrack = shouldTrack;
406
- activeSub = computed2;
407
- shouldTrack = true;
408
- try {
409
- prepareDeps(computed2);
410
- const value = computed2.fn(computed2._value);
411
- if (dep.version === 0 || hasChanged(value, computed2._value)) {
412
- computed2.flags |= 128;
413
- computed2._value = value;
414
- dep.version++;
415
- }
416
- } catch (err) {
417
- dep.version++;
418
- throw err;
419
- } finally {
420
- activeSub = prevSub;
421
- shouldTrack = prevShouldTrack;
422
- cleanupDeps(computed2);
423
- computed2.flags &= -3;
424
- }
370
+ for (let link = sub.deps; link; link = link.nextDep) if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) return true;
371
+ if (sub._dirty) return true;
372
+ return false;
373
+ }
374
+ function refreshComputed(computed) {
375
+ if (computed.flags & 4 && !(computed.flags & 16)) return;
376
+ computed.flags &= -17;
377
+ if (computed.globalVersion === globalVersion) return;
378
+ computed.globalVersion = globalVersion;
379
+ if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return;
380
+ computed.flags |= 2;
381
+ const dep = computed.dep;
382
+ const prevSub = activeSub;
383
+ const prevShouldTrack = shouldTrack;
384
+ activeSub = computed;
385
+ shouldTrack = true;
386
+ try {
387
+ prepareDeps(computed);
388
+ const value = computed.fn(computed._value);
389
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
390
+ computed.flags |= 128;
391
+ computed._value = value;
392
+ dep.version++;
393
+ }
394
+ } catch (err) {
395
+ dep.version++;
396
+ throw err;
397
+ } finally {
398
+ activeSub = prevSub;
399
+ shouldTrack = prevShouldTrack;
400
+ cleanupDeps(computed);
401
+ computed.flags &= -3;
402
+ }
425
403
  }
426
404
  function removeSub(link, soft = false) {
427
- const { dep, prevSub, nextSub } = link;
428
- if (prevSub) {
429
- prevSub.nextSub = nextSub;
430
- link.prevSub = void 0;
431
- }
432
- if (nextSub) {
433
- nextSub.prevSub = prevSub;
434
- link.nextSub = void 0;
435
- }
436
- if (!!(process.env.NODE_ENV !== "production") && dep.subsHead === link) {
437
- dep.subsHead = nextSub;
438
- }
439
- if (dep.subs === link) {
440
- dep.subs = prevSub;
441
- if (!prevSub && dep.computed) {
442
- dep.computed.flags &= -5;
443
- for (let l = dep.computed.deps; l; l = l.nextDep) {
444
- removeSub(l, true);
445
- }
446
- }
447
- }
448
- if (!soft && !--dep.sc && dep.map) {
449
- dep.map.delete(dep.key);
450
- }
405
+ const { dep, prevSub, nextSub } = link;
406
+ if (prevSub) {
407
+ prevSub.nextSub = nextSub;
408
+ link.prevSub = void 0;
409
+ }
410
+ if (nextSub) {
411
+ nextSub.prevSub = prevSub;
412
+ link.nextSub = void 0;
413
+ }
414
+ if (!!(process.env.NODE_ENV !== "production") && dep.subsHead === link) dep.subsHead = nextSub;
415
+ if (dep.subs === link) {
416
+ dep.subs = prevSub;
417
+ if (!prevSub && dep.computed) {
418
+ dep.computed.flags &= -5;
419
+ for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true);
420
+ }
421
+ }
422
+ if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key);
451
423
  }
452
424
  function removeDep(link) {
453
- const { prevDep, nextDep } = link;
454
- if (prevDep) {
455
- prevDep.nextDep = nextDep;
456
- link.prevDep = void 0;
457
- }
458
- if (nextDep) {
459
- nextDep.prevDep = prevDep;
460
- link.nextDep = void 0;
461
- }
425
+ const { prevDep, nextDep } = link;
426
+ if (prevDep) {
427
+ prevDep.nextDep = nextDep;
428
+ link.prevDep = void 0;
429
+ }
430
+ if (nextDep) {
431
+ nextDep.prevDep = prevDep;
432
+ link.nextDep = void 0;
433
+ }
462
434
  }
463
435
  function effect(fn, options) {
464
- if (fn.effect instanceof ReactiveEffect) {
465
- fn = fn.effect.fn;
466
- }
467
- const e = new ReactiveEffect(fn);
468
- if (options) {
469
- extend(e, options);
470
- }
471
- try {
472
- e.run();
473
- } catch (err) {
474
- e.stop();
475
- throw err;
476
- }
477
- const runner = e.run.bind(e);
478
- runner.effect = e;
479
- return runner;
436
+ if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
437
+ const e = new ReactiveEffect(fn);
438
+ if (options) extend(e, options);
439
+ try {
440
+ e.run();
441
+ } catch (err) {
442
+ e.stop();
443
+ throw err;
444
+ }
445
+ const runner = e.run.bind(e);
446
+ runner.effect = e;
447
+ return runner;
480
448
  }
481
449
  function stop(runner) {
482
- runner.effect.stop();
450
+ runner.effect.stop();
483
451
  }
484
- let shouldTrack = true;
485
- const trackStack = [];
452
+ var shouldTrack = true;
453
+ var trackStack = [];
486
454
  function pauseTracking() {
487
- trackStack.push(shouldTrack);
488
- shouldTrack = false;
455
+ trackStack.push(shouldTrack);
456
+ shouldTrack = false;
489
457
  }
490
458
  function enableTracking() {
491
- trackStack.push(shouldTrack);
492
- shouldTrack = true;
459
+ trackStack.push(shouldTrack);
460
+ shouldTrack = true;
493
461
  }
494
462
  function resetTracking() {
495
- const last = trackStack.pop();
496
- shouldTrack = last === void 0 ? true : last;
463
+ const last = trackStack.pop();
464
+ shouldTrack = last === void 0 ? true : last;
497
465
  }
498
466
  function onEffectCleanup(fn, failSilently = false) {
499
- if (activeSub instanceof ReactiveEffect) {
500
- activeSub.cleanup = fn;
501
- } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
502
- warn$1(
503
- `onEffectCleanup() was called when there was no active effect to associate with.`
504
- );
505
- }
467
+ if (activeSub instanceof ReactiveEffect) activeSub.cleanup = fn;
468
+ else if (!!(process.env.NODE_ENV !== "production") && !failSilently) warn$1(`onEffectCleanup() was called when there was no active effect to associate with.`);
506
469
  }
507
470
  function cleanupEffect(e) {
508
- const { cleanup } = e;
509
- e.cleanup = void 0;
510
- if (cleanup) {
511
- const prevSub = activeSub;
512
- activeSub = void 0;
513
- try {
514
- cleanup();
515
- } finally {
516
- activeSub = prevSub;
517
- }
518
- }
519
- }
520
- let globalVersion = 0;
521
- class Link {
522
- constructor(sub, dep) {
523
- this.sub = sub;
524
- this.dep = dep;
525
- this.version = dep.version;
526
- this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
527
- }
528
- }
529
- class Dep {
530
- // TODO isolatedDeclarations "__v_skip"
531
- constructor(computed2) {
532
- this.computed = computed2;
533
- this.version = 0;
534
- this.activeLink = void 0;
535
- this.subs = void 0;
536
- this.map = void 0;
537
- this.key = void 0;
538
- this.sc = 0;
539
- this.__v_skip = true;
540
- if (!!(process.env.NODE_ENV !== "production")) {
541
- this.subsHead = void 0;
542
- }
543
- }
544
- track(debugInfo) {
545
- if (!activeSub || !shouldTrack || activeSub === this.computed) {
546
- return;
547
- }
548
- let link = this.activeLink;
549
- if (link === void 0 || link.sub !== activeSub) {
550
- link = this.activeLink = new Link(activeSub, this);
551
- if (!activeSub.deps) {
552
- activeSub.deps = activeSub.depsTail = link;
553
- } else {
554
- link.prevDep = activeSub.depsTail;
555
- activeSub.depsTail.nextDep = link;
556
- activeSub.depsTail = link;
557
- }
558
- addSub(link);
559
- } else if (link.version === -1) {
560
- link.version = this.version;
561
- if (link.nextDep) {
562
- const next = link.nextDep;
563
- next.prevDep = link.prevDep;
564
- if (link.prevDep) {
565
- link.prevDep.nextDep = next;
566
- }
567
- link.prevDep = activeSub.depsTail;
568
- link.nextDep = void 0;
569
- activeSub.depsTail.nextDep = link;
570
- activeSub.depsTail = link;
571
- if (activeSub.deps === link) {
572
- activeSub.deps = next;
573
- }
574
- }
575
- }
576
- if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) {
577
- activeSub.onTrack(
578
- extend(
579
- {
580
- effect: activeSub
581
- },
582
- debugInfo
583
- )
584
- );
585
- }
586
- return link;
587
- }
588
- trigger(debugInfo) {
589
- this.version++;
590
- globalVersion++;
591
- this.notify(debugInfo);
592
- }
593
- notify(debugInfo) {
594
- startBatch();
595
- try {
596
- if (!!(process.env.NODE_ENV !== "production")) {
597
- for (let head = this.subsHead; head; head = head.nextSub) {
598
- if (head.sub.onTrigger && !(head.sub.flags & 8)) {
599
- head.sub.onTrigger(
600
- extend(
601
- {
602
- effect: head.sub
603
- },
604
- debugInfo
605
- )
606
- );
607
- }
608
- }
609
- }
610
- for (let link = this.subs; link; link = link.prevSub) {
611
- if (link.sub.notify()) {
612
- ;
613
- link.sub.dep.notify();
614
- }
615
- }
616
- } finally {
617
- endBatch();
618
- }
619
- }
620
- }
471
+ const { cleanup } = e;
472
+ e.cleanup = void 0;
473
+ if (cleanup) {
474
+ const prevSub = activeSub;
475
+ activeSub = void 0;
476
+ try {
477
+ cleanup();
478
+ } finally {
479
+ activeSub = prevSub;
480
+ }
481
+ }
482
+ }
483
+ var globalVersion = 0;
484
+ var Link = class {
485
+ constructor(sub, dep) {
486
+ this.sub = sub;
487
+ this.dep = dep;
488
+ this.version = dep.version;
489
+ this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
490
+ }
491
+ };
492
+ var Dep = class {
493
+ constructor(computed) {
494
+ this.computed = computed;
495
+ this.version = 0;
496
+ /**
497
+ * Link between this dep and the current active effect
498
+ */
499
+ this.activeLink = void 0;
500
+ /**
501
+ * Doubly linked list representing the subscribing effects (tail)
502
+ */
503
+ this.subs = void 0;
504
+ /**
505
+ * For object property deps cleanup
506
+ */
507
+ this.map = void 0;
508
+ this.key = void 0;
509
+ /**
510
+ * Subscriber counter
511
+ */
512
+ this.sc = 0;
513
+ /**
514
+ * @internal
515
+ */
516
+ this.__v_skip = true;
517
+ if (!!(process.env.NODE_ENV !== "production")) this.subsHead = void 0;
518
+ }
519
+ track(debugInfo) {
520
+ if (!activeSub || !shouldTrack || activeSub === this.computed) return;
521
+ let link = this.activeLink;
522
+ if (link === void 0 || link.sub !== activeSub) {
523
+ link = this.activeLink = new Link(activeSub, this);
524
+ if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link;
525
+ else {
526
+ link.prevDep = activeSub.depsTail;
527
+ activeSub.depsTail.nextDep = link;
528
+ activeSub.depsTail = link;
529
+ }
530
+ addSub(link);
531
+ } else if (link.version === -1) {
532
+ link.version = this.version;
533
+ if (link.nextDep) {
534
+ const next = link.nextDep;
535
+ next.prevDep = link.prevDep;
536
+ if (link.prevDep) link.prevDep.nextDep = next;
537
+ link.prevDep = activeSub.depsTail;
538
+ link.nextDep = void 0;
539
+ activeSub.depsTail.nextDep = link;
540
+ activeSub.depsTail = link;
541
+ if (activeSub.deps === link) activeSub.deps = next;
542
+ }
543
+ }
544
+ if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) activeSub.onTrack(extend({ effect: activeSub }, debugInfo));
545
+ return link;
546
+ }
547
+ trigger(debugInfo) {
548
+ this.version++;
549
+ globalVersion++;
550
+ this.notify(debugInfo);
551
+ }
552
+ notify(debugInfo) {
553
+ startBatch();
554
+ try {
555
+ if (!!(process.env.NODE_ENV !== "production")) {
556
+ for (let head = this.subsHead; head; head = head.nextSub) if (head.sub.onTrigger && !(head.sub.flags & 8)) head.sub.onTrigger(extend({ effect: head.sub }, debugInfo));
557
+ }
558
+ for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify();
559
+ } finally {
560
+ endBatch();
561
+ }
562
+ }
563
+ };
621
564
  function addSub(link) {
622
- link.dep.sc++;
623
- if (link.sub.flags & 4) {
624
- const computed2 = link.dep.computed;
625
- if (computed2 && !link.dep.subs) {
626
- computed2.flags |= 4 | 16;
627
- for (let l = computed2.deps; l; l = l.nextDep) {
628
- addSub(l);
629
- }
630
- }
631
- const currentTail = link.dep.subs;
632
- if (currentTail !== link) {
633
- link.prevSub = currentTail;
634
- if (currentTail) currentTail.nextSub = link;
635
- }
636
- if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) {
637
- link.dep.subsHead = link;
638
- }
639
- link.dep.subs = link;
640
- }
641
- }
642
- const targetMap = /* @__PURE__ */ new WeakMap();
643
- const ITERATE_KEY = /* @__PURE__ */ Symbol(
644
- !!(process.env.NODE_ENV !== "production") ? "Object iterate" : ""
645
- );
646
- const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(
647
- !!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : ""
648
- );
649
- const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(
650
- !!(process.env.NODE_ENV !== "production") ? "Array iterate" : ""
651
- );
565
+ link.dep.sc++;
566
+ if (link.sub.flags & 4) {
567
+ const computed = link.dep.computed;
568
+ if (computed && !link.dep.subs) {
569
+ computed.flags |= 20;
570
+ for (let l = computed.deps; l; l = l.nextDep) addSub(l);
571
+ }
572
+ const currentTail = link.dep.subs;
573
+ if (currentTail !== link) {
574
+ link.prevSub = currentTail;
575
+ if (currentTail) currentTail.nextSub = link;
576
+ }
577
+ if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) link.dep.subsHead = link;
578
+ link.dep.subs = link;
579
+ }
580
+ }
581
+ var targetMap = /* @__PURE__ */ new WeakMap();
582
+ var ITERATE_KEY = /* @__PURE__ */ Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
583
+ var MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
584
+ var ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(!!(process.env.NODE_ENV !== "production") ? "Array iterate" : "");
652
585
  function track(target, type, key) {
653
- if (shouldTrack && activeSub) {
654
- let depsMap = targetMap.get(target);
655
- if (!depsMap) {
656
- targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
657
- }
658
- let dep = depsMap.get(key);
659
- if (!dep) {
660
- depsMap.set(key, dep = new Dep());
661
- dep.map = depsMap;
662
- dep.key = key;
663
- }
664
- if (!!(process.env.NODE_ENV !== "production")) {
665
- dep.track({
666
- target,
667
- type,
668
- key
669
- });
670
- } else {
671
- dep.track();
672
- }
673
- }
586
+ if (shouldTrack && activeSub) {
587
+ let depsMap = targetMap.get(target);
588
+ if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
589
+ let dep = depsMap.get(key);
590
+ if (!dep) {
591
+ depsMap.set(key, dep = new Dep());
592
+ dep.map = depsMap;
593
+ dep.key = key;
594
+ }
595
+ if (!!(process.env.NODE_ENV !== "production")) dep.track({
596
+ target,
597
+ type,
598
+ key
599
+ });
600
+ else dep.track();
601
+ }
674
602
  }
675
603
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
676
- const depsMap = targetMap.get(target);
677
- if (!depsMap) {
678
- globalVersion++;
679
- return;
680
- }
681
- const run = (dep) => {
682
- if (dep) {
683
- if (!!(process.env.NODE_ENV !== "production")) {
684
- dep.trigger({
685
- target,
686
- type,
687
- key,
688
- newValue,
689
- oldValue,
690
- oldTarget
691
- });
692
- } else {
693
- dep.trigger();
694
- }
695
- }
696
- };
697
- startBatch();
698
- if (type === "clear") {
699
- depsMap.forEach(run);
700
- } else {
701
- const targetIsArray = isArray(target);
702
- const isArrayIndex = targetIsArray && isIntegerKey(key);
703
- if (targetIsArray && key === "length") {
704
- const newLength = Number(newValue);
705
- depsMap.forEach((dep, key2) => {
706
- if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
707
- run(dep);
708
- }
709
- });
710
- } else {
711
- if (key !== void 0 || depsMap.has(void 0)) {
712
- run(depsMap.get(key));
713
- }
714
- if (isArrayIndex) {
715
- run(depsMap.get(ARRAY_ITERATE_KEY));
716
- }
717
- switch (type) {
718
- case "add":
719
- if (!targetIsArray) {
720
- run(depsMap.get(ITERATE_KEY));
721
- if (isMap(target)) {
722
- run(depsMap.get(MAP_KEY_ITERATE_KEY));
723
- }
724
- } else if (isArrayIndex) {
725
- run(depsMap.get("length"));
726
- }
727
- break;
728
- case "delete":
729
- if (!targetIsArray) {
730
- run(depsMap.get(ITERATE_KEY));
731
- if (isMap(target)) {
732
- run(depsMap.get(MAP_KEY_ITERATE_KEY));
733
- }
734
- }
735
- break;
736
- case "set":
737
- if (isMap(target)) {
738
- run(depsMap.get(ITERATE_KEY));
739
- }
740
- break;
741
- }
742
- }
743
- }
744
- endBatch();
604
+ const depsMap = targetMap.get(target);
605
+ if (!depsMap) {
606
+ globalVersion++;
607
+ return;
608
+ }
609
+ const run = (dep) => {
610
+ if (dep) if (!!(process.env.NODE_ENV !== "production")) dep.trigger({
611
+ target,
612
+ type,
613
+ key,
614
+ newValue,
615
+ oldValue,
616
+ oldTarget
617
+ });
618
+ else dep.trigger();
619
+ };
620
+ startBatch();
621
+ if (type === "clear") depsMap.forEach(run);
622
+ else {
623
+ const targetIsArray = isArray(target);
624
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
625
+ if (targetIsArray && key === "length") {
626
+ const newLength = Number(newValue);
627
+ depsMap.forEach((dep, key2) => {
628
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) run(dep);
629
+ });
630
+ } else {
631
+ if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
632
+ if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
633
+ switch (type) {
634
+ case "add":
635
+ if (!targetIsArray) {
636
+ run(depsMap.get(ITERATE_KEY));
637
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
638
+ } else if (isArrayIndex) run(depsMap.get("length"));
639
+ break;
640
+ case "delete":
641
+ if (!targetIsArray) {
642
+ run(depsMap.get(ITERATE_KEY));
643
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
644
+ }
645
+ break;
646
+ case "set":
647
+ if (isMap(target)) run(depsMap.get(ITERATE_KEY));
648
+ break;
649
+ }
650
+ }
651
+ }
652
+ endBatch();
745
653
  }
746
654
  function getDepFromReactive(object, key) {
747
- const depMap = targetMap.get(object);
748
- return depMap && depMap.get(key);
655
+ const depMap = targetMap.get(object);
656
+ return depMap && depMap.get(key);
749
657
  }
750
658
  function reactiveReadArray(array) {
751
- const raw = toRaw(array);
752
- if (raw === array) return raw;
753
- track(raw, "iterate", ARRAY_ITERATE_KEY);
754
- return isShallow(array) ? raw : raw.map(toReactive);
659
+ const raw = /* @__PURE__ */ toRaw(array);
660
+ if (raw === array) return raw;
661
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
662
+ return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
755
663
  }
756
664
  function shallowReadArray(arr) {
757
- track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
758
- return arr;
665
+ track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
666
+ return arr;
759
667
  }
760
668
  function toWrapped(target, item) {
761
- if (isReadonly(target)) {
762
- return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
763
- }
764
- return toReactive(item);
765
- }
766
- const arrayInstrumentations = {
767
- __proto__: null,
768
- [Symbol.iterator]() {
769
- return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
770
- },
771
- concat(...args) {
772
- return reactiveReadArray(this).concat(
773
- ...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
774
- );
775
- },
776
- entries() {
777
- return iterator(this, "entries", (value) => {
778
- value[1] = toWrapped(this, value[1]);
779
- return value;
780
- });
781
- },
782
- every(fn, thisArg) {
783
- return apply(this, "every", fn, thisArg, void 0, arguments);
784
- },
785
- filter(fn, thisArg) {
786
- return apply(
787
- this,
788
- "filter",
789
- fn,
790
- thisArg,
791
- (v) => v.map((item) => toWrapped(this, item)),
792
- arguments
793
- );
794
- },
795
- find(fn, thisArg) {
796
- return apply(
797
- this,
798
- "find",
799
- fn,
800
- thisArg,
801
- (item) => toWrapped(this, item),
802
- arguments
803
- );
804
- },
805
- findIndex(fn, thisArg) {
806
- return apply(this, "findIndex", fn, thisArg, void 0, arguments);
807
- },
808
- findLast(fn, thisArg) {
809
- return apply(
810
- this,
811
- "findLast",
812
- fn,
813
- thisArg,
814
- (item) => toWrapped(this, item),
815
- arguments
816
- );
817
- },
818
- findLastIndex(fn, thisArg) {
819
- return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
820
- },
821
- // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
822
- forEach(fn, thisArg) {
823
- return apply(this, "forEach", fn, thisArg, void 0, arguments);
824
- },
825
- includes(...args) {
826
- return searchProxy(this, "includes", args);
827
- },
828
- indexOf(...args) {
829
- return searchProxy(this, "indexOf", args);
830
- },
831
- join(separator) {
832
- return reactiveReadArray(this).join(separator);
833
- },
834
- // keys() iterator only reads `length`, no optimization required
835
- lastIndexOf(...args) {
836
- return searchProxy(this, "lastIndexOf", args);
837
- },
838
- map(fn, thisArg) {
839
- return apply(this, "map", fn, thisArg, void 0, arguments);
840
- },
841
- pop() {
842
- return noTracking(this, "pop");
843
- },
844
- push(...args) {
845
- return noTracking(this, "push", args);
846
- },
847
- reduce(fn, ...args) {
848
- return reduce(this, "reduce", fn, args);
849
- },
850
- reduceRight(fn, ...args) {
851
- return reduce(this, "reduceRight", fn, args);
852
- },
853
- shift() {
854
- return noTracking(this, "shift");
855
- },
856
- // slice could use ARRAY_ITERATE but also seems to beg for range tracking
857
- some(fn, thisArg) {
858
- return apply(this, "some", fn, thisArg, void 0, arguments);
859
- },
860
- splice(...args) {
861
- return noTracking(this, "splice", args);
862
- },
863
- toReversed() {
864
- return reactiveReadArray(this).toReversed();
865
- },
866
- toSorted(comparer) {
867
- return reactiveReadArray(this).toSorted(comparer);
868
- },
869
- toSpliced(...args) {
870
- return reactiveReadArray(this).toSpliced(...args);
871
- },
872
- unshift(...args) {
873
- return noTracking(this, "unshift", args);
874
- },
875
- values() {
876
- return iterator(this, "values", (item) => toWrapped(this, item));
877
- }
669
+ if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
670
+ return toReactive(item);
671
+ }
672
+ var arrayInstrumentations = {
673
+ __proto__: null,
674
+ [Symbol.iterator]() {
675
+ return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
676
+ },
677
+ concat(...args) {
678
+ return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
679
+ },
680
+ entries() {
681
+ return iterator(this, "entries", (value) => {
682
+ value[1] = toWrapped(this, value[1]);
683
+ return value;
684
+ });
685
+ },
686
+ every(fn, thisArg) {
687
+ return apply(this, "every", fn, thisArg, void 0, arguments);
688
+ },
689
+ filter(fn, thisArg) {
690
+ return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
691
+ },
692
+ find(fn, thisArg) {
693
+ return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
694
+ },
695
+ findIndex(fn, thisArg) {
696
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
697
+ },
698
+ findLast(fn, thisArg) {
699
+ return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
700
+ },
701
+ findLastIndex(fn, thisArg) {
702
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
703
+ },
704
+ forEach(fn, thisArg) {
705
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
706
+ },
707
+ includes(...args) {
708
+ return searchProxy(this, "includes", args);
709
+ },
710
+ indexOf(...args) {
711
+ return searchProxy(this, "indexOf", args);
712
+ },
713
+ join(separator) {
714
+ return reactiveReadArray(this).join(separator);
715
+ },
716
+ lastIndexOf(...args) {
717
+ return searchProxy(this, "lastIndexOf", args);
718
+ },
719
+ map(fn, thisArg) {
720
+ return apply(this, "map", fn, thisArg, void 0, arguments);
721
+ },
722
+ pop() {
723
+ return noTracking(this, "pop");
724
+ },
725
+ push(...args) {
726
+ return noTracking(this, "push", args);
727
+ },
728
+ reduce(fn, ...args) {
729
+ return reduce(this, "reduce", fn, args);
730
+ },
731
+ reduceRight(fn, ...args) {
732
+ return reduce(this, "reduceRight", fn, args);
733
+ },
734
+ shift() {
735
+ return noTracking(this, "shift");
736
+ },
737
+ some(fn, thisArg) {
738
+ return apply(this, "some", fn, thisArg, void 0, arguments);
739
+ },
740
+ splice(...args) {
741
+ return noTracking(this, "splice", args);
742
+ },
743
+ toReversed() {
744
+ return reactiveReadArray(this).toReversed();
745
+ },
746
+ toSorted(comparer) {
747
+ return reactiveReadArray(this).toSorted(comparer);
748
+ },
749
+ toSpliced(...args) {
750
+ return reactiveReadArray(this).toSpliced(...args);
751
+ },
752
+ unshift(...args) {
753
+ return noTracking(this, "unshift", args);
754
+ },
755
+ values() {
756
+ return iterator(this, "values", (item) => toWrapped(this, item));
757
+ }
878
758
  };
879
759
  function iterator(self, method, wrapValue) {
880
- const arr = shallowReadArray(self);
881
- const iter = arr[method]();
882
- if (arr !== self && !isShallow(self)) {
883
- iter._next = iter.next;
884
- iter.next = () => {
885
- const result = iter._next();
886
- if (!result.done) {
887
- result.value = wrapValue(result.value);
888
- }
889
- return result;
890
- };
891
- }
892
- return iter;
893
- }
894
- const arrayProto = Array.prototype;
760
+ const arr = shallowReadArray(self);
761
+ const iter = arr[method]();
762
+ if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
763
+ iter._next = iter.next;
764
+ iter.next = () => {
765
+ const result = iter._next();
766
+ if (!result.done) result.value = wrapValue(result.value);
767
+ return result;
768
+ };
769
+ }
770
+ return iter;
771
+ }
772
+ var arrayProto = Array.prototype;
895
773
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
896
- const arr = shallowReadArray(self);
897
- const needsWrap = arr !== self && !isShallow(self);
898
- const methodFn = arr[method];
899
- if (methodFn !== arrayProto[method]) {
900
- const result2 = methodFn.apply(self, args);
901
- return needsWrap ? toReactive(result2) : result2;
902
- }
903
- let wrappedFn = fn;
904
- if (arr !== self) {
905
- if (needsWrap) {
906
- wrappedFn = function(item, index) {
907
- return fn.call(this, toWrapped(self, item), index, self);
908
- };
909
- } else if (fn.length > 2) {
910
- wrappedFn = function(item, index) {
911
- return fn.call(this, item, index, self);
912
- };
913
- }
914
- }
915
- const result = methodFn.call(arr, wrappedFn, thisArg);
916
- return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
774
+ const arr = shallowReadArray(self);
775
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
776
+ const methodFn = arr[method];
777
+ if (methodFn !== arrayProto[method]) {
778
+ const result2 = methodFn.apply(self, args);
779
+ return needsWrap ? toReactive(result2) : result2;
780
+ }
781
+ let wrappedFn = fn;
782
+ if (arr !== self) {
783
+ if (needsWrap) wrappedFn = function(item, index) {
784
+ return fn.call(this, toWrapped(self, item), index, self);
785
+ };
786
+ else if (fn.length > 2) wrappedFn = function(item, index) {
787
+ return fn.call(this, item, index, self);
788
+ };
789
+ }
790
+ const result = methodFn.call(arr, wrappedFn, thisArg);
791
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
917
792
  }
918
793
  function reduce(self, method, fn, args) {
919
- const arr = shallowReadArray(self);
920
- let wrappedFn = fn;
921
- if (arr !== self) {
922
- if (!isShallow(self)) {
923
- wrappedFn = function(acc, item, index) {
924
- return fn.call(this, acc, toWrapped(self, item), index, self);
925
- };
926
- } else if (fn.length > 3) {
927
- wrappedFn = function(acc, item, index) {
928
- return fn.call(this, acc, item, index, self);
929
- };
930
- }
931
- }
932
- return arr[method](wrappedFn, ...args);
794
+ const arr = shallowReadArray(self);
795
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
796
+ let wrappedFn = fn;
797
+ let wrapInitialAccumulator = false;
798
+ if (arr !== self) {
799
+ if (needsWrap) {
800
+ wrapInitialAccumulator = args.length === 0;
801
+ wrappedFn = function(acc, item, index) {
802
+ if (wrapInitialAccumulator) {
803
+ wrapInitialAccumulator = false;
804
+ acc = toWrapped(self, acc);
805
+ }
806
+ return fn.call(this, acc, toWrapped(self, item), index, self);
807
+ };
808
+ } else if (fn.length > 3) wrappedFn = function(acc, item, index) {
809
+ return fn.call(this, acc, item, index, self);
810
+ };
811
+ }
812
+ const result = arr[method](wrappedFn, ...args);
813
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
933
814
  }
934
815
  function searchProxy(self, method, args) {
935
- const arr = toRaw(self);
936
- track(arr, "iterate", ARRAY_ITERATE_KEY);
937
- const res = arr[method](...args);
938
- if ((res === -1 || res === false) && isProxy(args[0])) {
939
- args[0] = toRaw(args[0]);
940
- return arr[method](...args);
941
- }
942
- return res;
816
+ const arr = /* @__PURE__ */ toRaw(self);
817
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
818
+ const res = arr[method](...args);
819
+ if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
820
+ args[0] = /* @__PURE__ */ toRaw(args[0]);
821
+ return arr[method](...args);
822
+ }
823
+ return res;
943
824
  }
944
825
  function noTracking(self, method, args = []) {
945
- pauseTracking();
946
- startBatch();
947
- const res = toRaw(self)[method].apply(self, args);
948
- endBatch();
949
- resetTracking();
950
- return res;
951
- }
952
- const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
953
- const builtInSymbols = new Set(
954
- /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
955
- );
826
+ pauseTracking();
827
+ startBatch();
828
+ const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
829
+ endBatch();
830
+ resetTracking();
831
+ return res;
832
+ }
833
+ var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
834
+ var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
956
835
  function hasOwnProperty(key) {
957
- if (!isSymbol(key)) key = String(key);
958
- const obj = toRaw(this);
959
- track(obj, "has", key);
960
- return obj.hasOwnProperty(key);
961
- }
962
- class BaseReactiveHandler {
963
- constructor(_isReadonly = false, _isShallow = false) {
964
- this._isReadonly = _isReadonly;
965
- this._isShallow = _isShallow;
966
- }
967
- get(target, key, receiver) {
968
- if (key === "__v_skip") return target["__v_skip"];
969
- const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
970
- if (key === "__v_isReactive") {
971
- return !isReadonly2;
972
- } else if (key === "__v_isReadonly") {
973
- return isReadonly2;
974
- } else if (key === "__v_isShallow") {
975
- return isShallow2;
976
- } else if (key === "__v_raw") {
977
- if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
978
- // this means the receiver is a user proxy of the reactive proxy
979
- Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
980
- return target;
981
- }
982
- return;
983
- }
984
- const targetIsArray = isArray(target);
985
- if (!isReadonly2) {
986
- let fn;
987
- if (targetIsArray && (fn = arrayInstrumentations[key])) {
988
- return fn;
989
- }
990
- if (key === "hasOwnProperty") {
991
- return hasOwnProperty;
992
- }
993
- }
994
- const res = Reflect.get(
995
- target,
996
- key,
997
- // if this is a proxy wrapping a ref, return methods using the raw ref
998
- // as receiver so that we don't have to call `toRaw` on the ref in all
999
- // its class methods
1000
- isRef(target) ? target : receiver
1001
- );
1002
- if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
1003
- return res;
1004
- }
1005
- if (!isReadonly2) {
1006
- track(target, "get", key);
1007
- }
1008
- if (isShallow2) {
1009
- return res;
1010
- }
1011
- if (isRef(res)) {
1012
- const value = targetIsArray && isIntegerKey(key) ? res : res.value;
1013
- return isReadonly2 && isObject(value) ? readonly(value) : value;
1014
- }
1015
- if (isObject(res)) {
1016
- return isReadonly2 ? readonly(res) : reactive(res);
1017
- }
1018
- return res;
1019
- }
1020
- }
1021
- class MutableReactiveHandler extends BaseReactiveHandler {
1022
- constructor(isShallow2 = false) {
1023
- super(false, isShallow2);
1024
- }
1025
- set(target, key, value, receiver) {
1026
- let oldValue = target[key];
1027
- const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
1028
- if (!this._isShallow) {
1029
- const isOldValueReadonly = isReadonly(oldValue);
1030
- if (!isShallow(value) && !isReadonly(value)) {
1031
- oldValue = toRaw(oldValue);
1032
- value = toRaw(value);
1033
- }
1034
- if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
1035
- if (isOldValueReadonly) {
1036
- if (!!(process.env.NODE_ENV !== "production")) {
1037
- warn$1(
1038
- `Set operation on key "${String(key)}" failed: target is readonly.`,
1039
- target[key]
1040
- );
1041
- }
1042
- return true;
1043
- } else {
1044
- oldValue.value = value;
1045
- return true;
1046
- }
1047
- }
1048
- }
1049
- const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
1050
- const result = Reflect.set(
1051
- target,
1052
- key,
1053
- value,
1054
- isRef(target) ? target : receiver
1055
- );
1056
- if (target === toRaw(receiver)) {
1057
- if (!hadKey) {
1058
- trigger(target, "add", key, value);
1059
- } else if (hasChanged(value, oldValue)) {
1060
- trigger(target, "set", key, value, oldValue);
1061
- }
1062
- }
1063
- return result;
1064
- }
1065
- deleteProperty(target, key) {
1066
- const hadKey = hasOwn(target, key);
1067
- const oldValue = target[key];
1068
- const result = Reflect.deleteProperty(target, key);
1069
- if (result && hadKey) {
1070
- trigger(target, "delete", key, void 0, oldValue);
1071
- }
1072
- return result;
1073
- }
1074
- has(target, key) {
1075
- const result = Reflect.has(target, key);
1076
- if (!isSymbol(key) || !builtInSymbols.has(key)) {
1077
- track(target, "has", key);
1078
- }
1079
- return result;
1080
- }
1081
- ownKeys(target) {
1082
- track(
1083
- target,
1084
- "iterate",
1085
- isArray(target) ? "length" : ITERATE_KEY
1086
- );
1087
- return Reflect.ownKeys(target);
1088
- }
1089
- }
1090
- class ReadonlyReactiveHandler extends BaseReactiveHandler {
1091
- constructor(isShallow2 = false) {
1092
- super(true, isShallow2);
1093
- }
1094
- set(target, key) {
1095
- if (!!(process.env.NODE_ENV !== "production")) {
1096
- warn$1(
1097
- `Set operation on key "${String(key)}" failed: target is readonly.`,
1098
- target
1099
- );
1100
- }
1101
- return true;
1102
- }
1103
- deleteProperty(target, key) {
1104
- if (!!(process.env.NODE_ENV !== "production")) {
1105
- warn$1(
1106
- `Delete operation on key "${String(key)}" failed: target is readonly.`,
1107
- target
1108
- );
1109
- }
1110
- return true;
1111
- }
1112
- }
1113
- const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
1114
- const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
1115
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
1116
- const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
1117
- const toShallow = (value) => value;
1118
- const getProto = (v) => Reflect.getPrototypeOf(v);
836
+ if (!isSymbol(key)) key = String(key);
837
+ const obj = /* @__PURE__ */ toRaw(this);
838
+ track(obj, "has", key);
839
+ return obj.hasOwnProperty(key);
840
+ }
841
+ var BaseReactiveHandler = class {
842
+ constructor(_isReadonly = false, _isShallow = false) {
843
+ this._isReadonly = _isReadonly;
844
+ this._isShallow = _isShallow;
845
+ }
846
+ get(target, key, receiver) {
847
+ if (key === "__v_skip") return target["__v_skip"];
848
+ const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
849
+ if (key === "__v_isReactive") return !isReadonly2;
850
+ else if (key === "__v_isReadonly") return isReadonly2;
851
+ else if (key === "__v_isShallow") return isShallow2;
852
+ else if (key === "__v_raw") {
853
+ if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
854
+ return;
855
+ }
856
+ const targetIsArray = isArray(target);
857
+ if (!isReadonly2) {
858
+ let fn;
859
+ if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
860
+ if (key === "hasOwnProperty") return hasOwnProperty;
861
+ }
862
+ const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver);
863
+ if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
864
+ if (!isReadonly2) track(target, "get", key);
865
+ if (isShallow2) return res;
866
+ if (/* @__PURE__ */ isRef(res)) {
867
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
868
+ return isReadonly2 && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
869
+ }
870
+ if (isObject(res)) return isReadonly2 ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
871
+ return res;
872
+ }
873
+ };
874
+ var MutableReactiveHandler = class extends BaseReactiveHandler {
875
+ constructor(isShallow2 = false) {
876
+ super(false, isShallow2);
877
+ }
878
+ set(target, key, value, receiver) {
879
+ let oldValue = target[key];
880
+ const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
881
+ if (!this._isShallow) {
882
+ const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
883
+ if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
884
+ oldValue = /* @__PURE__ */ toRaw(oldValue);
885
+ value = /* @__PURE__ */ toRaw(value);
886
+ }
887
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
888
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
889
+ return true;
890
+ } else {
891
+ oldValue.value = value;
892
+ return true;
893
+ }
894
+ }
895
+ const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
896
+ const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
897
+ if (target === /* @__PURE__ */ toRaw(receiver)) {
898
+ if (!hadKey) trigger(target, "add", key, value);
899
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
900
+ }
901
+ return result;
902
+ }
903
+ deleteProperty(target, key) {
904
+ const hadKey = hasOwn(target, key);
905
+ const oldValue = target[key];
906
+ const result = Reflect.deleteProperty(target, key);
907
+ if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
908
+ return result;
909
+ }
910
+ has(target, key) {
911
+ const result = Reflect.has(target, key);
912
+ if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
913
+ return result;
914
+ }
915
+ ownKeys(target) {
916
+ track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
917
+ return Reflect.ownKeys(target);
918
+ }
919
+ };
920
+ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
921
+ constructor(isShallow2 = false) {
922
+ super(true, isShallow2);
923
+ }
924
+ set(target, key) {
925
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
926
+ return true;
927
+ }
928
+ deleteProperty(target, key) {
929
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
930
+ return true;
931
+ }
932
+ };
933
+ var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
934
+ var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
935
+ var shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
936
+ var shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
937
+ var toShallow = (value) => value;
938
+ var getProto = (v) => Reflect.getPrototypeOf(v);
1119
939
  function createIterableMethod(method, isReadonly2, isShallow2) {
1120
- return function(...args) {
1121
- const target = this["__v_raw"];
1122
- const rawTarget = toRaw(target);
1123
- const targetIsMap = isMap(rawTarget);
1124
- const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1125
- const isKeyOnly = method === "keys" && targetIsMap;
1126
- const innerIterator = target[method](...args);
1127
- const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
1128
- !isReadonly2 && track(
1129
- rawTarget,
1130
- "iterate",
1131
- isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
1132
- );
1133
- return {
1134
- // iterator protocol
1135
- next() {
1136
- const { value, done } = innerIterator.next();
1137
- return done ? { value, done } : {
1138
- value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1139
- done
1140
- };
1141
- },
1142
- // iterable protocol
1143
- [Symbol.iterator]() {
1144
- return this;
1145
- }
1146
- };
1147
- };
940
+ return function(...args) {
941
+ const target = this["__v_raw"];
942
+ const rawTarget = /* @__PURE__ */ toRaw(target);
943
+ const targetIsMap = isMap(rawTarget);
944
+ const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
945
+ const isKeyOnly = method === "keys" && targetIsMap;
946
+ const innerIterator = target[method](...args);
947
+ const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
948
+ !isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
949
+ return extend(Object.create(innerIterator), { next() {
950
+ const { value, done } = innerIterator.next();
951
+ return done ? {
952
+ value,
953
+ done
954
+ } : {
955
+ value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
956
+ done
957
+ };
958
+ } });
959
+ };
1148
960
  }
1149
961
  function createReadonlyMethod(type) {
1150
- return function(...args) {
1151
- if (!!(process.env.NODE_ENV !== "production")) {
1152
- const key = args[0] ? `on key "${args[0]}" ` : ``;
1153
- warn$1(
1154
- `${capitalize(type)} operation ${key}failed: target is readonly.`,
1155
- toRaw(this)
1156
- );
1157
- }
1158
- return type === "delete" ? false : type === "clear" ? void 0 : this;
1159
- };
1160
- }
1161
- function createInstrumentations(readonly2, shallow) {
1162
- const instrumentations = {
1163
- get(key) {
1164
- const target = this["__v_raw"];
1165
- const rawTarget = toRaw(target);
1166
- const rawKey = toRaw(key);
1167
- if (!readonly2) {
1168
- if (hasChanged(key, rawKey)) {
1169
- track(rawTarget, "get", key);
1170
- }
1171
- track(rawTarget, "get", rawKey);
1172
- }
1173
- const { has } = getProto(rawTarget);
1174
- const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
1175
- if (has.call(rawTarget, key)) {
1176
- return wrap(target.get(key));
1177
- } else if (has.call(rawTarget, rawKey)) {
1178
- return wrap(target.get(rawKey));
1179
- } else if (target !== rawTarget) {
1180
- target.get(key);
1181
- }
1182
- },
1183
- get size() {
1184
- const target = this["__v_raw"];
1185
- !readonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
1186
- return target.size;
1187
- },
1188
- has(key) {
1189
- const target = this["__v_raw"];
1190
- const rawTarget = toRaw(target);
1191
- const rawKey = toRaw(key);
1192
- if (!readonly2) {
1193
- if (hasChanged(key, rawKey)) {
1194
- track(rawTarget, "has", key);
1195
- }
1196
- track(rawTarget, "has", rawKey);
1197
- }
1198
- return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1199
- },
1200
- forEach(callback, thisArg) {
1201
- const observed = this;
1202
- const target = observed["__v_raw"];
1203
- const rawTarget = toRaw(target);
1204
- const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
1205
- !readonly2 && track(rawTarget, "iterate", ITERATE_KEY);
1206
- return target.forEach((value, key) => {
1207
- return callback.call(thisArg, wrap(value), wrap(key), observed);
1208
- });
1209
- }
1210
- };
1211
- extend(
1212
- instrumentations,
1213
- readonly2 ? {
1214
- add: createReadonlyMethod("add"),
1215
- set: createReadonlyMethod("set"),
1216
- delete: createReadonlyMethod("delete"),
1217
- clear: createReadonlyMethod("clear")
1218
- } : {
1219
- add(value) {
1220
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1221
- value = toRaw(value);
1222
- }
1223
- const target = toRaw(this);
1224
- const proto = getProto(target);
1225
- const hadKey = proto.has.call(target, value);
1226
- if (!hadKey) {
1227
- target.add(value);
1228
- trigger(target, "add", value, value);
1229
- }
1230
- return this;
1231
- },
1232
- set(key, value) {
1233
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1234
- value = toRaw(value);
1235
- }
1236
- const target = toRaw(this);
1237
- const { has, get } = getProto(target);
1238
- let hadKey = has.call(target, key);
1239
- if (!hadKey) {
1240
- key = toRaw(key);
1241
- hadKey = has.call(target, key);
1242
- } else if (!!(process.env.NODE_ENV !== "production")) {
1243
- checkIdentityKeys(target, has, key);
1244
- }
1245
- const oldValue = get.call(target, key);
1246
- target.set(key, value);
1247
- if (!hadKey) {
1248
- trigger(target, "add", key, value);
1249
- } else if (hasChanged(value, oldValue)) {
1250
- trigger(target, "set", key, value, oldValue);
1251
- }
1252
- return this;
1253
- },
1254
- delete(key) {
1255
- const target = toRaw(this);
1256
- const { has, get } = getProto(target);
1257
- let hadKey = has.call(target, key);
1258
- if (!hadKey) {
1259
- key = toRaw(key);
1260
- hadKey = has.call(target, key);
1261
- } else if (!!(process.env.NODE_ENV !== "production")) {
1262
- checkIdentityKeys(target, has, key);
1263
- }
1264
- const oldValue = get ? get.call(target, key) : void 0;
1265
- const result = target.delete(key);
1266
- if (hadKey) {
1267
- trigger(target, "delete", key, void 0, oldValue);
1268
- }
1269
- return result;
1270
- },
1271
- clear() {
1272
- const target = toRaw(this);
1273
- const hadItems = target.size !== 0;
1274
- const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
1275
- const result = target.clear();
1276
- if (hadItems) {
1277
- trigger(
1278
- target,
1279
- "clear",
1280
- void 0,
1281
- void 0,
1282
- oldTarget
1283
- );
1284
- }
1285
- return result;
1286
- }
1287
- }
1288
- );
1289
- const iteratorMethods = [
1290
- "keys",
1291
- "values",
1292
- "entries",
1293
- Symbol.iterator
1294
- ];
1295
- iteratorMethods.forEach((method) => {
1296
- instrumentations[method] = createIterableMethod(method, readonly2, shallow);
1297
- });
1298
- return instrumentations;
962
+ return function(...args) {
963
+ if (!!(process.env.NODE_ENV !== "production")) {
964
+ const key = args[0] ? `on key "${args[0]}" ` : ``;
965
+ warn$1(`${capitalize(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this));
966
+ }
967
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
968
+ };
969
+ }
970
+ function createInstrumentations(readonly, shallow) {
971
+ const instrumentations = {
972
+ get(key) {
973
+ const target = this["__v_raw"];
974
+ const rawTarget = /* @__PURE__ */ toRaw(target);
975
+ const rawKey = /* @__PURE__ */ toRaw(key);
976
+ if (!readonly) {
977
+ if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
978
+ track(rawTarget, "get", rawKey);
979
+ }
980
+ const { has } = getProto(rawTarget);
981
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
982
+ if (has.call(rawTarget, key)) return wrap(target.get(key));
983
+ else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
984
+ else if (target !== rawTarget) target.get(key);
985
+ },
986
+ get size() {
987
+ const target = this["__v_raw"];
988
+ !readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
989
+ return target.size;
990
+ },
991
+ has(key) {
992
+ const target = this["__v_raw"];
993
+ const rawTarget = /* @__PURE__ */ toRaw(target);
994
+ const rawKey = /* @__PURE__ */ toRaw(key);
995
+ if (!readonly) {
996
+ if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
997
+ track(rawTarget, "has", rawKey);
998
+ }
999
+ return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1000
+ },
1001
+ forEach(callback, thisArg) {
1002
+ const observed = this;
1003
+ const target = observed["__v_raw"];
1004
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1005
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1006
+ !readonly && track(rawTarget, "iterate", ITERATE_KEY);
1007
+ return target.forEach((value, key) => {
1008
+ return callback.call(thisArg, wrap(value), wrap(key), observed);
1009
+ });
1010
+ }
1011
+ };
1012
+ extend(instrumentations, readonly ? {
1013
+ add: createReadonlyMethod("add"),
1014
+ set: createReadonlyMethod("set"),
1015
+ delete: createReadonlyMethod("delete"),
1016
+ clear: createReadonlyMethod("clear")
1017
+ } : {
1018
+ add(value) {
1019
+ const target = /* @__PURE__ */ toRaw(this);
1020
+ const proto = getProto(target);
1021
+ const rawValue = /* @__PURE__ */ toRaw(value);
1022
+ const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value;
1023
+ if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) {
1024
+ target.add(valueToAdd);
1025
+ trigger(target, "add", valueToAdd, valueToAdd);
1026
+ }
1027
+ return this;
1028
+ },
1029
+ set(key, value) {
1030
+ if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
1031
+ const target = /* @__PURE__ */ toRaw(this);
1032
+ const { has, get } = getProto(target);
1033
+ let hadKey = has.call(target, key);
1034
+ if (!hadKey) {
1035
+ key = /* @__PURE__ */ toRaw(key);
1036
+ hadKey = has.call(target, key);
1037
+ } else if (!!(process.env.NODE_ENV !== "production")) checkIdentityKeys(target, has, key);
1038
+ const oldValue = get.call(target, key);
1039
+ target.set(key, value);
1040
+ if (!hadKey) trigger(target, "add", key, value);
1041
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1042
+ return this;
1043
+ },
1044
+ delete(key) {
1045
+ const target = /* @__PURE__ */ toRaw(this);
1046
+ const { has, get } = getProto(target);
1047
+ let hadKey = has.call(target, key);
1048
+ if (!hadKey) {
1049
+ key = /* @__PURE__ */ toRaw(key);
1050
+ hadKey = has.call(target, key);
1051
+ } else if (!!(process.env.NODE_ENV !== "production")) checkIdentityKeys(target, has, key);
1052
+ const oldValue = get ? get.call(target, key) : void 0;
1053
+ const result = target.delete(key);
1054
+ if (hadKey) trigger(target, "delete", key, void 0, oldValue);
1055
+ return result;
1056
+ },
1057
+ clear() {
1058
+ const target = /* @__PURE__ */ toRaw(this);
1059
+ const hadItems = target.size !== 0;
1060
+ const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
1061
+ const result = target.clear();
1062
+ if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
1063
+ return result;
1064
+ }
1065
+ });
1066
+ [
1067
+ "keys",
1068
+ "values",
1069
+ "entries",
1070
+ Symbol.iterator
1071
+ ].forEach((method) => {
1072
+ instrumentations[method] = createIterableMethod(method, readonly, shallow);
1073
+ });
1074
+ return instrumentations;
1299
1075
  }
1300
1076
  function createInstrumentationGetter(isReadonly2, shallow) {
1301
- const instrumentations = createInstrumentations(isReadonly2, shallow);
1302
- return (target, key, receiver) => {
1303
- if (key === "__v_isReactive") {
1304
- return !isReadonly2;
1305
- } else if (key === "__v_isReadonly") {
1306
- return isReadonly2;
1307
- } else if (key === "__v_raw") {
1308
- return target;
1309
- }
1310
- return Reflect.get(
1311
- hasOwn(instrumentations, key) && key in target ? instrumentations : target,
1312
- key,
1313
- receiver
1314
- );
1315
- };
1316
- }
1317
- const mutableCollectionHandlers = {
1318
- get: /* @__PURE__ */ createInstrumentationGetter(false, false)
1319
- };
1320
- const shallowCollectionHandlers = {
1321
- get: /* @__PURE__ */ createInstrumentationGetter(false, true)
1322
- };
1323
- const readonlyCollectionHandlers = {
1324
- get: /* @__PURE__ */ createInstrumentationGetter(true, false)
1325
- };
1326
- const shallowReadonlyCollectionHandlers = {
1327
- get: /* @__PURE__ */ createInstrumentationGetter(true, true)
1328
- };
1077
+ const instrumentations = createInstrumentations(isReadonly2, shallow);
1078
+ return (target, key, receiver) => {
1079
+ if (key === "__v_isReactive") return !isReadonly2;
1080
+ else if (key === "__v_isReadonly") return isReadonly2;
1081
+ else if (key === "__v_raw") return target;
1082
+ return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
1083
+ };
1084
+ }
1085
+ var mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) };
1086
+ var shallowCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, true) };
1087
+ var readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) };
1088
+ var shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) };
1329
1089
  function checkIdentityKeys(target, has, key) {
1330
- const rawKey = toRaw(key);
1331
- if (rawKey !== key && has.call(target, rawKey)) {
1332
- const type = toRawType(target);
1333
- warn$1(
1334
- `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
1335
- );
1336
- }
1337
- }
1338
- const reactiveMap = /* @__PURE__ */ new WeakMap();
1339
- const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
1340
- const readonlyMap = /* @__PURE__ */ new WeakMap();
1341
- const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
1090
+ const rawKey = /* @__PURE__ */ toRaw(key);
1091
+ if (rawKey !== key && has.call(target, rawKey)) {
1092
+ const type = toRawType(target);
1093
+ warn$1(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
1094
+ }
1095
+ }
1096
+ var reactiveMap = /* @__PURE__ */ new WeakMap();
1097
+ var shallowReactiveMap = /* @__PURE__ */ new WeakMap();
1098
+ var readonlyMap = /* @__PURE__ */ new WeakMap();
1099
+ var shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
1342
1100
  function targetTypeMap(rawType) {
1343
- switch (rawType) {
1344
- case "Object":
1345
- case "Array":
1346
- return 1;
1347
- case "Map":
1348
- case "Set":
1349
- case "WeakMap":
1350
- case "WeakSet":
1351
- return 2;
1352
- default:
1353
- return 0;
1354
- }
1101
+ switch (rawType) {
1102
+ case "Object":
1103
+ case "Array": return 1;
1104
+ case "Map":
1105
+ case "Set":
1106
+ case "WeakMap":
1107
+ case "WeakSet": return 2;
1108
+ default: return 0;
1109
+ }
1355
1110
  }
1356
1111
  function getTargetType(value) {
1357
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1112
+ return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1358
1113
  }
1114
+ /* @__NO_SIDE_EFFECTS__ */
1359
1115
  function reactive(target) {
1360
- if (isReadonly(target)) {
1361
- return target;
1362
- }
1363
- return createReactiveObject(
1364
- target,
1365
- false,
1366
- mutableHandlers,
1367
- mutableCollectionHandlers,
1368
- reactiveMap
1369
- );
1116
+ if (/* @__PURE__ */ isReadonly(target)) return target;
1117
+ return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1370
1118
  }
1119
+ /* @__NO_SIDE_EFFECTS__ */
1371
1120
  function shallowReactive(target) {
1372
- return createReactiveObject(
1373
- target,
1374
- false,
1375
- shallowReactiveHandlers,
1376
- shallowCollectionHandlers,
1377
- shallowReactiveMap
1378
- );
1121
+ return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
1379
1122
  }
1123
+ /* @__NO_SIDE_EFFECTS__ */
1380
1124
  function readonly(target) {
1381
- return createReactiveObject(
1382
- target,
1383
- true,
1384
- readonlyHandlers,
1385
- readonlyCollectionHandlers,
1386
- readonlyMap
1387
- );
1125
+ return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1388
1126
  }
1127
+ /* @__NO_SIDE_EFFECTS__ */
1389
1128
  function shallowReadonly(target) {
1390
- return createReactiveObject(
1391
- target,
1392
- true,
1393
- shallowReadonlyHandlers,
1394
- shallowReadonlyCollectionHandlers,
1395
- shallowReadonlyMap
1396
- );
1129
+ return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1397
1130
  }
1398
1131
  function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
1399
- if (!isObject(target)) {
1400
- if (!!(process.env.NODE_ENV !== "production")) {
1401
- warn$1(
1402
- `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
1403
- target
1404
- )}`
1405
- );
1406
- }
1407
- return target;
1408
- }
1409
- if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
1410
- return target;
1411
- }
1412
- const targetType = getTargetType(target);
1413
- if (targetType === 0) {
1414
- return target;
1415
- }
1416
- const existingProxy = proxyMap.get(target);
1417
- if (existingProxy) {
1418
- return existingProxy;
1419
- }
1420
- const proxy = new Proxy(
1421
- target,
1422
- targetType === 2 ? collectionHandlers : baseHandlers
1423
- );
1424
- proxyMap.set(target, proxy);
1425
- return proxy;
1426
- }
1132
+ if (!isObject(target)) {
1133
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(target)}`);
1134
+ return target;
1135
+ }
1136
+ if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) return target;
1137
+ const targetType = getTargetType(target);
1138
+ if (targetType === 0) return target;
1139
+ const existingProxy = proxyMap.get(target);
1140
+ if (existingProxy) return existingProxy;
1141
+ const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1142
+ proxyMap.set(target, proxy);
1143
+ return proxy;
1144
+ }
1145
+ /* @__NO_SIDE_EFFECTS__ */
1427
1146
  function isReactive(value) {
1428
- if (isReadonly(value)) {
1429
- return isReactive(value["__v_raw"]);
1430
- }
1431
- return !!(value && value["__v_isReactive"]);
1147
+ if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
1148
+ return !!(value && value["__v_isReactive"]);
1432
1149
  }
1150
+ /* @__NO_SIDE_EFFECTS__ */
1433
1151
  function isReadonly(value) {
1434
- return !!(value && value["__v_isReadonly"]);
1152
+ return !!(value && value["__v_isReadonly"]);
1435
1153
  }
1154
+ /* @__NO_SIDE_EFFECTS__ */
1436
1155
  function isShallow(value) {
1437
- return !!(value && value["__v_isShallow"]);
1156
+ return !!(value && value["__v_isShallow"]);
1438
1157
  }
1158
+ /* @__NO_SIDE_EFFECTS__ */
1439
1159
  function isProxy(value) {
1440
- return value ? !!value["__v_raw"] : false;
1160
+ return value ? !!value["__v_raw"] : false;
1441
1161
  }
1162
+ /* @__NO_SIDE_EFFECTS__ */
1442
1163
  function toRaw(observed) {
1443
- const raw = observed && observed["__v_raw"];
1444
- return raw ? toRaw(raw) : observed;
1164
+ const raw = observed && observed["__v_raw"];
1165
+ return raw ? /* @__PURE__ */ toRaw(raw) : observed;
1445
1166
  }
1446
1167
  function markRaw(value) {
1447
- if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
1448
- def(value, "__v_skip", true);
1449
- }
1450
- return value;
1168
+ if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) def(value, "__v_skip", true);
1169
+ return value;
1451
1170
  }
1452
- const toReactive = (value) => isObject(value) ? reactive(value) : value;
1453
- const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1171
+ var toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
1172
+ var toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1173
+ /* @__NO_SIDE_EFFECTS__ */
1454
1174
  function isRef(r) {
1455
- return r ? r["__v_isRef"] === true : false;
1175
+ return r ? r["__v_isRef"] === true : false;
1456
1176
  }
1177
+ /* @__NO_SIDE_EFFECTS__ */
1457
1178
  function ref(value) {
1458
- return createRef(value, false);
1179
+ return createRef(value, false);
1459
1180
  }
1181
+ /* @__NO_SIDE_EFFECTS__ */
1460
1182
  function shallowRef(value) {
1461
- return createRef(value, true);
1183
+ return createRef(value, true);
1462
1184
  }
1463
1185
  function createRef(rawValue, shallow) {
1464
- if (isRef(rawValue)) {
1465
- return rawValue;
1466
- }
1467
- return new RefImpl(rawValue, shallow);
1468
- }
1469
- class RefImpl {
1470
- constructor(value, isShallow2) {
1471
- this.dep = new Dep();
1472
- this["__v_isRef"] = true;
1473
- this["__v_isShallow"] = false;
1474
- this._rawValue = isShallow2 ? value : toRaw(value);
1475
- this._value = isShallow2 ? value : toReactive(value);
1476
- this["__v_isShallow"] = isShallow2;
1477
- }
1478
- get value() {
1479
- if (!!(process.env.NODE_ENV !== "production")) {
1480
- this.dep.track({
1481
- target: this,
1482
- type: "get",
1483
- key: "value"
1484
- });
1485
- } else {
1486
- this.dep.track();
1487
- }
1488
- return this._value;
1489
- }
1490
- set value(newValue) {
1491
- const oldValue = this._rawValue;
1492
- const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
1493
- newValue = useDirectValue ? newValue : toRaw(newValue);
1494
- if (hasChanged(newValue, oldValue)) {
1495
- this._rawValue = newValue;
1496
- this._value = useDirectValue ? newValue : toReactive(newValue);
1497
- if (!!(process.env.NODE_ENV !== "production")) {
1498
- this.dep.trigger({
1499
- target: this,
1500
- type: "set",
1501
- key: "value",
1502
- newValue,
1503
- oldValue
1504
- });
1505
- } else {
1506
- this.dep.trigger();
1507
- }
1508
- }
1509
- }
1510
- }
1186
+ if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
1187
+ return new RefImpl(rawValue, shallow);
1188
+ }
1189
+ var RefImpl = class {
1190
+ constructor(value, isShallow2) {
1191
+ this.dep = new Dep();
1192
+ this["__v_isRef"] = true;
1193
+ this["__v_isShallow"] = false;
1194
+ this._rawValue = isShallow2 ? value : /* @__PURE__ */ toRaw(value);
1195
+ this._value = isShallow2 ? value : toReactive(value);
1196
+ this["__v_isShallow"] = isShallow2;
1197
+ }
1198
+ get value() {
1199
+ if (!!(process.env.NODE_ENV !== "production")) this.dep.track({
1200
+ target: this,
1201
+ type: "get",
1202
+ key: "value"
1203
+ });
1204
+ else this.dep.track();
1205
+ return this._value;
1206
+ }
1207
+ set value(newValue) {
1208
+ const oldValue = this._rawValue;
1209
+ const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
1210
+ newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
1211
+ if (hasChanged(newValue, oldValue)) {
1212
+ this._rawValue = newValue;
1213
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1214
+ if (!!(process.env.NODE_ENV !== "production")) this.dep.trigger({
1215
+ target: this,
1216
+ type: "set",
1217
+ key: "value",
1218
+ newValue,
1219
+ oldValue
1220
+ });
1221
+ else this.dep.trigger();
1222
+ }
1223
+ }
1224
+ };
1511
1225
  function triggerRef(ref2) {
1512
- if (ref2.dep) {
1513
- if (!!(process.env.NODE_ENV !== "production")) {
1514
- ref2.dep.trigger({
1515
- target: ref2,
1516
- type: "set",
1517
- key: "value",
1518
- newValue: ref2._value
1519
- });
1520
- } else {
1521
- ref2.dep.trigger();
1522
- }
1523
- }
1226
+ if (ref2.dep) if (!!(process.env.NODE_ENV !== "production")) ref2.dep.trigger({
1227
+ target: ref2,
1228
+ type: "set",
1229
+ key: "value",
1230
+ newValue: ref2._value
1231
+ });
1232
+ else ref2.dep.trigger();
1524
1233
  }
1525
1234
  function unref(ref2) {
1526
- return isRef(ref2) ? ref2.value : ref2;
1235
+ return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
1527
1236
  }
1528
1237
  function toValue(source) {
1529
- return isFunction(source) ? source() : unref(source);
1530
- }
1531
- const shallowUnwrapHandlers = {
1532
- get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
1533
- set: (target, key, value, receiver) => {
1534
- const oldValue = target[key];
1535
- if (isRef(oldValue) && !isRef(value)) {
1536
- oldValue.value = value;
1537
- return true;
1538
- } else {
1539
- return Reflect.set(target, key, value, receiver);
1540
- }
1541
- }
1238
+ return isFunction(source) ? source() : unref(source);
1239
+ }
1240
+ var shallowUnwrapHandlers = {
1241
+ get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
1242
+ set: (target, key, value, receiver) => {
1243
+ const oldValue = target[key];
1244
+ if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
1245
+ oldValue.value = value;
1246
+ return true;
1247
+ } else return Reflect.set(target, key, value, receiver);
1248
+ }
1542
1249
  };
1543
1250
  function proxyRefs(objectWithRefs) {
1544
- return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1545
- }
1546
- class CustomRefImpl {
1547
- constructor(factory) {
1548
- this["__v_isRef"] = true;
1549
- this._value = void 0;
1550
- const dep = this.dep = new Dep();
1551
- const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1552
- this._get = get;
1553
- this._set = set;
1554
- }
1555
- get value() {
1556
- return this._value = this._get();
1557
- }
1558
- set value(newVal) {
1559
- this._set(newVal);
1560
- }
1561
- }
1251
+ return /* @__PURE__ */ isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1252
+ }
1253
+ var CustomRefImpl = class {
1254
+ constructor(factory) {
1255
+ this["__v_isRef"] = true;
1256
+ this._value = void 0;
1257
+ const dep = this.dep = new Dep();
1258
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1259
+ this._get = get;
1260
+ this._set = set;
1261
+ }
1262
+ get value() {
1263
+ return this._value = this._get();
1264
+ }
1265
+ set value(newVal) {
1266
+ this._set(newVal);
1267
+ }
1268
+ };
1562
1269
  function customRef(factory) {
1563
- return new CustomRefImpl(factory);
1270
+ return new CustomRefImpl(factory);
1564
1271
  }
1272
+ /* @__NO_SIDE_EFFECTS__ */
1565
1273
  function toRefs(object) {
1566
- if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
1567
- warn$1(`toRefs() expects a reactive object but received a plain one.`);
1568
- }
1569
- const ret = isArray(object) ? new Array(object.length) : {};
1570
- for (const key in object) {
1571
- ret[key] = propertyToRef(object, key);
1572
- }
1573
- return ret;
1574
- }
1575
- class ObjectRefImpl {
1576
- constructor(_object, _key, _defaultValue) {
1577
- this._object = _object;
1578
- this._key = _key;
1579
- this._defaultValue = _defaultValue;
1580
- this["__v_isRef"] = true;
1581
- this._value = void 0;
1582
- this._raw = toRaw(_object);
1583
- let shallow = true;
1584
- let obj = _object;
1585
- if (!isArray(_object) || !isIntegerKey(String(_key))) {
1586
- do {
1587
- shallow = !isProxy(obj) || isShallow(obj);
1588
- } while (shallow && (obj = obj["__v_raw"]));
1589
- }
1590
- this._shallow = shallow;
1591
- }
1592
- get value() {
1593
- let val = this._object[this._key];
1594
- if (this._shallow) {
1595
- val = unref(val);
1596
- }
1597
- return this._value = val === void 0 ? this._defaultValue : val;
1598
- }
1599
- set value(newVal) {
1600
- if (this._shallow && isRef(this._raw[this._key])) {
1601
- const nestedRef = this._object[this._key];
1602
- if (isRef(nestedRef)) {
1603
- nestedRef.value = newVal;
1604
- return;
1605
- }
1606
- }
1607
- this._object[this._key] = newVal;
1608
- }
1609
- get dep() {
1610
- return getDepFromReactive(this._raw, this._key);
1611
- }
1612
- }
1613
- class GetterRefImpl {
1614
- constructor(_getter) {
1615
- this._getter = _getter;
1616
- this["__v_isRef"] = true;
1617
- this["__v_isReadonly"] = true;
1618
- this._value = void 0;
1619
- }
1620
- get value() {
1621
- return this._value = this._getter();
1622
- }
1623
- }
1274
+ if (!!(process.env.NODE_ENV !== "production") && !/* @__PURE__ */ isProxy(object)) warn$1(`toRefs() expects a reactive object but received a plain one.`);
1275
+ const ret = isArray(object) ? new Array(object.length) : {};
1276
+ for (const key in object) ret[key] = propertyToRef(object, key);
1277
+ return ret;
1278
+ }
1279
+ var ObjectRefImpl = class {
1280
+ constructor(_object, key, _defaultValue) {
1281
+ this._object = _object;
1282
+ this._defaultValue = _defaultValue;
1283
+ this["__v_isRef"] = true;
1284
+ this._value = void 0;
1285
+ this._key = isSymbol(key) ? key : String(key);
1286
+ this._raw = /* @__PURE__ */ toRaw(_object);
1287
+ let shallow = true;
1288
+ let obj = _object;
1289
+ if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) do
1290
+ shallow = !/* @__PURE__ */ isProxy(obj) || /* @__PURE__ */ isShallow(obj);
1291
+ while (shallow && (obj = obj["__v_raw"]));
1292
+ this._shallow = shallow;
1293
+ }
1294
+ get value() {
1295
+ let val = this._object[this._key];
1296
+ if (this._shallow) val = unref(val);
1297
+ return this._value = val === void 0 ? this._defaultValue : val;
1298
+ }
1299
+ set value(newVal) {
1300
+ if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
1301
+ const nestedRef = this._object[this._key];
1302
+ if (/* @__PURE__ */ isRef(nestedRef)) {
1303
+ nestedRef.value = newVal;
1304
+ return;
1305
+ }
1306
+ }
1307
+ this._object[this._key] = newVal;
1308
+ }
1309
+ get dep() {
1310
+ return getDepFromReactive(this._raw, this._key);
1311
+ }
1312
+ };
1313
+ var GetterRefImpl = class {
1314
+ constructor(_getter) {
1315
+ this._getter = _getter;
1316
+ this["__v_isRef"] = true;
1317
+ this["__v_isReadonly"] = true;
1318
+ this._value = void 0;
1319
+ }
1320
+ get value() {
1321
+ return this._value = this._getter();
1322
+ }
1323
+ };
1324
+ /* @__NO_SIDE_EFFECTS__ */
1624
1325
  function toRef(source, key, defaultValue) {
1625
- if (isRef(source)) {
1626
- return source;
1627
- } else if (isFunction(source)) {
1628
- return new GetterRefImpl(source);
1629
- } else if (isObject(source) && arguments.length > 1) {
1630
- return propertyToRef(source, key, defaultValue);
1631
- } else {
1632
- return ref(source);
1633
- }
1326
+ if (/* @__PURE__ */ isRef(source)) return source;
1327
+ else if (isFunction(source)) return new GetterRefImpl(source);
1328
+ else if (isObject(source) && arguments.length > 1) return propertyToRef(source, key, defaultValue);
1329
+ else return /* @__PURE__ */ ref(source);
1634
1330
  }
1635
1331
  function propertyToRef(source, key, defaultValue) {
1636
- return new ObjectRefImpl(source, key, defaultValue);
1637
- }
1638
- class ComputedRefImpl {
1639
- constructor(fn, setter, isSSR) {
1640
- this.fn = fn;
1641
- this.setter = setter;
1642
- this._value = void 0;
1643
- this.dep = new Dep(this);
1644
- this.__v_isRef = true;
1645
- this.deps = void 0;
1646
- this.depsTail = void 0;
1647
- this.flags = 16;
1648
- this.globalVersion = globalVersion - 1;
1649
- this.next = void 0;
1650
- this.effect = this;
1651
- this["__v_isReadonly"] = !setter;
1652
- this.isSSR = isSSR;
1653
- }
1654
- /**
1655
- * @internal
1656
- */
1657
- notify() {
1658
- this.flags |= 16;
1659
- if (!(this.flags & 8) && // avoid infinite self recursion
1660
- activeSub !== this) {
1661
- batch(this, true);
1662
- return true;
1663
- } else if (!!(process.env.NODE_ENV !== "production")) ;
1664
- }
1665
- get value() {
1666
- const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
1667
- target: this,
1668
- type: "get",
1669
- key: "value"
1670
- }) : this.dep.track();
1671
- refreshComputed(this);
1672
- if (link) {
1673
- link.version = this.dep.version;
1674
- }
1675
- return this._value;
1676
- }
1677
- set value(newValue) {
1678
- if (this.setter) {
1679
- this.setter(newValue);
1680
- } else if (!!(process.env.NODE_ENV !== "production")) {
1681
- warn$1("Write operation failed: computed value is readonly");
1682
- }
1683
- }
1684
- }
1332
+ return new ObjectRefImpl(source, key, defaultValue);
1333
+ }
1334
+ var ComputedRefImpl = class {
1335
+ constructor(fn, setter, isSSR) {
1336
+ this.fn = fn;
1337
+ this.setter = setter;
1338
+ /**
1339
+ * @internal
1340
+ */
1341
+ this._value = void 0;
1342
+ /**
1343
+ * @internal
1344
+ */
1345
+ this.dep = new Dep(this);
1346
+ /**
1347
+ * @internal
1348
+ */
1349
+ this.__v_isRef = true;
1350
+ /**
1351
+ * @internal
1352
+ */
1353
+ this.deps = void 0;
1354
+ /**
1355
+ * @internal
1356
+ */
1357
+ this.depsTail = void 0;
1358
+ /**
1359
+ * @internal
1360
+ */
1361
+ this.flags = 16;
1362
+ /**
1363
+ * @internal
1364
+ */
1365
+ this.globalVersion = globalVersion - 1;
1366
+ /**
1367
+ * @internal
1368
+ */
1369
+ this.next = void 0;
1370
+ this.effect = this;
1371
+ this["__v_isReadonly"] = !setter;
1372
+ this.isSSR = isSSR;
1373
+ }
1374
+ /**
1375
+ * @internal
1376
+ */
1377
+ notify() {
1378
+ this.flags |= 16;
1379
+ if (!(this.flags & 8) && activeSub !== this) {
1380
+ batch(this, true);
1381
+ return true;
1382
+ } else if (!!(process.env.NODE_ENV !== "production"));
1383
+ }
1384
+ get value() {
1385
+ const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
1386
+ target: this,
1387
+ type: "get",
1388
+ key: "value"
1389
+ }) : this.dep.track();
1390
+ refreshComputed(this);
1391
+ if (link) link.version = this.dep.version;
1392
+ return this._value;
1393
+ }
1394
+ set value(newValue) {
1395
+ if (this.setter) this.setter(newValue);
1396
+ else if (!!(process.env.NODE_ENV !== "production")) warn$1("Write operation failed: computed value is readonly");
1397
+ }
1398
+ };
1399
+ /* @__NO_SIDE_EFFECTS__ */
1685
1400
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1686
- let getter;
1687
- let setter;
1688
- if (isFunction(getterOrOptions)) {
1689
- getter = getterOrOptions;
1690
- } else {
1691
- getter = getterOrOptions.get;
1692
- setter = getterOrOptions.set;
1693
- }
1694
- const cRef = new ComputedRefImpl(getter, setter, isSSR);
1695
- if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1696
- cRef.onTrack = debugOptions.onTrack;
1697
- cRef.onTrigger = debugOptions.onTrigger;
1698
- }
1699
- return cRef;
1700
- }
1701
- const TrackOpTypes = {
1702
- "GET": "get",
1703
- "HAS": "has",
1704
- "ITERATE": "iterate"
1401
+ let getter;
1402
+ let setter;
1403
+ if (isFunction(getterOrOptions)) getter = getterOrOptions;
1404
+ else {
1405
+ getter = getterOrOptions.get;
1406
+ setter = getterOrOptions.set;
1407
+ }
1408
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1409
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1410
+ cRef.onTrack = debugOptions.onTrack;
1411
+ cRef.onTrigger = debugOptions.onTrigger;
1412
+ }
1413
+ return cRef;
1414
+ }
1415
+ var TrackOpTypes = {
1416
+ "GET": "get",
1417
+ "HAS": "has",
1418
+ "ITERATE": "iterate"
1705
1419
  };
1706
- const TriggerOpTypes = {
1707
- "SET": "set",
1708
- "ADD": "add",
1709
- "DELETE": "delete",
1710
- "CLEAR": "clear"
1420
+ var TriggerOpTypes = {
1421
+ "SET": "set",
1422
+ "ADD": "add",
1423
+ "DELETE": "delete",
1424
+ "CLEAR": "clear"
1711
1425
  };
1712
- const ReactiveFlags = {
1713
- "SKIP": "__v_skip",
1714
- "IS_REACTIVE": "__v_isReactive",
1715
- "IS_READONLY": "__v_isReadonly",
1716
- "IS_SHALLOW": "__v_isShallow",
1717
- "RAW": "__v_raw",
1718
- "IS_REF": "__v_isRef"
1426
+ var ReactiveFlags = {
1427
+ "SKIP": "__v_skip",
1428
+ "IS_REACTIVE": "__v_isReactive",
1429
+ "IS_READONLY": "__v_isReadonly",
1430
+ "IS_SHALLOW": "__v_isShallow",
1431
+ "RAW": "__v_raw",
1432
+ "IS_REF": "__v_isRef"
1719
1433
  };
1720
- const WatchErrorCodes = {
1721
- "WATCH_GETTER": 2,
1722
- "2": "WATCH_GETTER",
1723
- "WATCH_CALLBACK": 3,
1724
- "3": "WATCH_CALLBACK",
1725
- "WATCH_CLEANUP": 4,
1726
- "4": "WATCH_CLEANUP"
1434
+ var WatchErrorCodes = {
1435
+ "WATCH_GETTER": 2,
1436
+ "2": "WATCH_GETTER",
1437
+ "WATCH_CALLBACK": 3,
1438
+ "3": "WATCH_CALLBACK",
1439
+ "WATCH_CLEANUP": 4,
1440
+ "4": "WATCH_CLEANUP"
1727
1441
  };
1728
- const INITIAL_WATCHER_VALUE = {};
1729
- const cleanupMap = /* @__PURE__ */ new WeakMap();
1730
- let activeWatcher = void 0;
1442
+ var INITIAL_WATCHER_VALUE = {};
1443
+ var cleanupMap = /* @__PURE__ */ new WeakMap();
1444
+ var activeWatcher = void 0;
1731
1445
  function getCurrentWatcher() {
1732
- return activeWatcher;
1446
+ return activeWatcher;
1733
1447
  }
1734
1448
  function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1735
- if (owner) {
1736
- let cleanups = cleanupMap.get(owner);
1737
- if (!cleanups) cleanupMap.set(owner, cleanups = []);
1738
- cleanups.push(cleanupFn);
1739
- } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
1740
- warn$1(
1741
- `onWatcherCleanup() was called when there was no active watcher to associate with.`
1742
- );
1743
- }
1449
+ if (owner) {
1450
+ let cleanups = cleanupMap.get(owner);
1451
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1452
+ cleanups.push(cleanupFn);
1453
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) warn$1(`onWatcherCleanup() was called when there was no active watcher to associate with.`);
1744
1454
  }
1745
1455
  function watch$1(source, cb, options = EMPTY_OBJ) {
1746
- const { immediate, deep, once, scheduler, augmentJob, call } = options;
1747
- const warnInvalidSource = (s) => {
1748
- (options.onWarn || warn$1)(
1749
- `Invalid watch source: `,
1750
- s,
1751
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1752
- );
1753
- };
1754
- const reactiveGetter = (source2) => {
1755
- if (deep) return source2;
1756
- if (isShallow(source2) || deep === false || deep === 0)
1757
- return traverse(source2, 1);
1758
- return traverse(source2);
1759
- };
1760
- let effect2;
1761
- let getter;
1762
- let cleanup;
1763
- let boundCleanup;
1764
- let forceTrigger = false;
1765
- let isMultiSource = false;
1766
- if (isRef(source)) {
1767
- getter = () => source.value;
1768
- forceTrigger = isShallow(source);
1769
- } else if (isReactive(source)) {
1770
- getter = () => reactiveGetter(source);
1771
- forceTrigger = true;
1772
- } else if (isArray(source)) {
1773
- isMultiSource = true;
1774
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1775
- getter = () => source.map((s) => {
1776
- if (isRef(s)) {
1777
- return s.value;
1778
- } else if (isReactive(s)) {
1779
- return reactiveGetter(s);
1780
- } else if (isFunction(s)) {
1781
- return call ? call(s, 2) : s();
1782
- } else {
1783
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
1784
- }
1785
- });
1786
- } else if (isFunction(source)) {
1787
- if (cb) {
1788
- getter = call ? () => call(source, 2) : source;
1789
- } else {
1790
- getter = () => {
1791
- if (cleanup) {
1792
- pauseTracking();
1793
- try {
1794
- cleanup();
1795
- } finally {
1796
- resetTracking();
1797
- }
1798
- }
1799
- const currentEffect = activeWatcher;
1800
- activeWatcher = effect2;
1801
- try {
1802
- return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1803
- } finally {
1804
- activeWatcher = currentEffect;
1805
- }
1806
- };
1807
- }
1808
- } else {
1809
- getter = NOOP;
1810
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
1811
- }
1812
- if (cb && deep) {
1813
- const baseGetter = getter;
1814
- const depth = deep === true ? Infinity : deep;
1815
- getter = () => traverse(baseGetter(), depth);
1816
- }
1817
- const scope = getCurrentScope();
1818
- const watchHandle = () => {
1819
- effect2.stop();
1820
- if (scope && scope.active) {
1821
- remove(scope.effects, effect2);
1822
- }
1823
- };
1824
- if (once && cb) {
1825
- const _cb = cb;
1826
- cb = (...args) => {
1827
- _cb(...args);
1828
- watchHandle();
1829
- };
1830
- }
1831
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1832
- const job = (immediateFirstRun) => {
1833
- if (!(effect2.flags & 1) || !effect2.dirty && !immediateFirstRun) {
1834
- return;
1835
- }
1836
- if (cb) {
1837
- const newValue = effect2.run();
1838
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1839
- if (cleanup) {
1840
- cleanup();
1841
- }
1842
- const currentWatcher = activeWatcher;
1843
- activeWatcher = effect2;
1844
- try {
1845
- const args = [
1846
- newValue,
1847
- // pass undefined as the old value when it's changed for the first time
1848
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1849
- boundCleanup
1850
- ];
1851
- oldValue = newValue;
1852
- call ? call(cb, 3, args) : (
1853
- // @ts-expect-error
1854
- cb(...args)
1855
- );
1856
- } finally {
1857
- activeWatcher = currentWatcher;
1858
- }
1859
- }
1860
- } else {
1861
- effect2.run();
1862
- }
1863
- };
1864
- if (augmentJob) {
1865
- augmentJob(job);
1866
- }
1867
- effect2 = new ReactiveEffect(getter);
1868
- effect2.scheduler = scheduler ? () => scheduler(job, false) : job;
1869
- boundCleanup = (fn) => onWatcherCleanup(fn, false, effect2);
1870
- cleanup = effect2.onStop = () => {
1871
- const cleanups = cleanupMap.get(effect2);
1872
- if (cleanups) {
1873
- if (call) {
1874
- call(cleanups, 4);
1875
- } else {
1876
- for (const cleanup2 of cleanups) cleanup2();
1877
- }
1878
- cleanupMap.delete(effect2);
1879
- }
1880
- };
1881
- if (!!(process.env.NODE_ENV !== "production")) {
1882
- effect2.onTrack = options.onTrack;
1883
- effect2.onTrigger = options.onTrigger;
1884
- }
1885
- if (cb) {
1886
- if (immediate) {
1887
- job(true);
1888
- } else {
1889
- oldValue = effect2.run();
1890
- }
1891
- } else if (scheduler) {
1892
- scheduler(job.bind(null, true), true);
1893
- } else {
1894
- effect2.run();
1895
- }
1896
- watchHandle.pause = effect2.pause.bind(effect2);
1897
- watchHandle.resume = effect2.resume.bind(effect2);
1898
- watchHandle.stop = watchHandle;
1899
- return watchHandle;
1456
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1457
+ const warnInvalidSource = (s) => {
1458
+ (options.onWarn || warn$1)(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`);
1459
+ };
1460
+ const reactiveGetter = (source2) => {
1461
+ if (deep) return source2;
1462
+ if (/* @__PURE__ */ isShallow(source2) || deep === false || deep === 0) return traverse(source2, 1);
1463
+ return traverse(source2);
1464
+ };
1465
+ let effect;
1466
+ let getter;
1467
+ let cleanup;
1468
+ let boundCleanup;
1469
+ let forceTrigger = false;
1470
+ let isMultiSource = false;
1471
+ if (/* @__PURE__ */ isRef(source)) {
1472
+ getter = () => source.value;
1473
+ forceTrigger = /* @__PURE__ */ isShallow(source);
1474
+ } else if (/* @__PURE__ */ isReactive(source)) {
1475
+ getter = () => reactiveGetter(source);
1476
+ forceTrigger = true;
1477
+ } else if (isArray(source)) {
1478
+ isMultiSource = true;
1479
+ forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s));
1480
+ getter = () => source.map((s) => {
1481
+ if (/* @__PURE__ */ isRef(s)) return s.value;
1482
+ else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s);
1483
+ else if (isFunction(s)) return call ? call(s, 2) : s();
1484
+ else process.env.NODE_ENV !== "production" && warnInvalidSource(s);
1485
+ });
1486
+ } else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
1487
+ else getter = () => {
1488
+ if (cleanup) {
1489
+ pauseTracking();
1490
+ try {
1491
+ cleanup();
1492
+ } finally {
1493
+ resetTracking();
1494
+ }
1495
+ }
1496
+ const currentEffect = activeWatcher;
1497
+ activeWatcher = effect;
1498
+ try {
1499
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1500
+ } finally {
1501
+ activeWatcher = currentEffect;
1502
+ }
1503
+ };
1504
+ else {
1505
+ getter = NOOP;
1506
+ process.env.NODE_ENV !== "production" && warnInvalidSource(source);
1507
+ }
1508
+ if (cb && deep) {
1509
+ const baseGetter = getter;
1510
+ const depth = deep === true ? Infinity : deep;
1511
+ getter = () => traverse(baseGetter(), depth);
1512
+ }
1513
+ const scope = getCurrentScope();
1514
+ const watchHandle = () => {
1515
+ effect.stop();
1516
+ if (scope && scope.active) remove(scope.effects, effect);
1517
+ };
1518
+ if (once && cb) {
1519
+ const _cb = cb;
1520
+ cb = (...args) => {
1521
+ _cb(...args);
1522
+ watchHandle();
1523
+ };
1524
+ }
1525
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1526
+ const job = (immediateFirstRun) => {
1527
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) return;
1528
+ if (cb) {
1529
+ const newValue = effect.run();
1530
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1531
+ if (cleanup) cleanup();
1532
+ const currentWatcher = activeWatcher;
1533
+ activeWatcher = effect;
1534
+ try {
1535
+ const args = [
1536
+ newValue,
1537
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1538
+ boundCleanup
1539
+ ];
1540
+ oldValue = newValue;
1541
+ call ? call(cb, 3, args) : cb(...args);
1542
+ } finally {
1543
+ activeWatcher = currentWatcher;
1544
+ }
1545
+ }
1546
+ } else effect.run();
1547
+ };
1548
+ if (augmentJob) augmentJob(job);
1549
+ effect = new ReactiveEffect(getter);
1550
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1551
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1552
+ cleanup = effect.onStop = () => {
1553
+ const cleanups = cleanupMap.get(effect);
1554
+ if (cleanups) {
1555
+ if (call) call(cleanups, 4);
1556
+ else for (const cleanup2 of cleanups) cleanup2();
1557
+ cleanupMap.delete(effect);
1558
+ }
1559
+ };
1560
+ if (!!(process.env.NODE_ENV !== "production")) {
1561
+ effect.onTrack = options.onTrack;
1562
+ effect.onTrigger = options.onTrigger;
1563
+ }
1564
+ if (cb) if (immediate) job(true);
1565
+ else oldValue = effect.run();
1566
+ else if (scheduler) scheduler(job.bind(null, true), true);
1567
+ else effect.run();
1568
+ watchHandle.pause = effect.pause.bind(effect);
1569
+ watchHandle.resume = effect.resume.bind(effect);
1570
+ watchHandle.stop = watchHandle;
1571
+ return watchHandle;
1900
1572
  }
1901
1573
  function traverse(value, depth = Infinity, seen) {
1902
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
1903
- return value;
1904
- }
1905
- seen = seen || /* @__PURE__ */ new Map();
1906
- if ((seen.get(value) || 0) >= depth) {
1907
- return value;
1908
- }
1909
- seen.set(value, depth);
1910
- depth--;
1911
- if (isRef(value)) {
1912
- traverse(value.value, depth, seen);
1913
- } else if (isArray(value)) {
1914
- for (let i = 0; i < value.length; i++) {
1915
- traverse(value[i], depth, seen);
1916
- }
1917
- } else if (isSet(value) || isMap(value)) {
1918
- value.forEach((v) => {
1919
- traverse(v, depth, seen);
1920
- });
1921
- } else if (isPlainObject(value)) {
1922
- for (const key in value) {
1923
- traverse(value[key], depth, seen);
1924
- }
1925
- for (const key of Object.getOwnPropertySymbols(value)) {
1926
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
1927
- traverse(value[key], depth, seen);
1928
- }
1929
- }
1930
- }
1931
- return value;
1932
- }
1574
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) return value;
1575
+ seen = seen || /* @__PURE__ */ new Map();
1576
+ if ((seen.get(value) || 0) >= depth) return value;
1577
+ seen.set(value, depth);
1578
+ depth--;
1579
+ if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen);
1580
+ else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen);
1581
+ else if (isSet(value) || isMap(value)) value.forEach((v) => {
1582
+ traverse(v, depth, seen);
1583
+ });
1584
+ else if (isPlainObject(value)) {
1585
+ for (const key in value) traverse(value[key], depth, seen);
1586
+ for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen);
1587
+ }
1588
+ return value;
1589
+ }
1590
+ //#endregion
1591
+ //#region src/warning.ts
1933
1592
  function warn(msg, ...args) {
1934
- pauseTracking();
1935
- const warnArgs = [`[Vue warn]: ${msg}`, ...args];
1936
- console.warn(...warnArgs);
1937
- resetTracking();
1938
- }
1939
- var LifecycleHooks = /* @__PURE__ */ ((LifecycleHooks2) => {
1940
- LifecycleHooks2["ACTIVATED"] = "a";
1941
- LifecycleHooks2["DEACTIVATED"] = "da";
1942
- return LifecycleHooks2;
1943
- })(LifecycleHooks || {});
1944
- var ErrorCodes = /* @__PURE__ */ ((ErrorCodes2) => {
1945
- ErrorCodes2[ErrorCodes2["WATCH_GETTER"] = 0] = "WATCH_GETTER";
1946
- ErrorCodes2[ErrorCodes2["WATCH_CALLBACK"] = 1] = "WATCH_CALLBACK";
1947
- ErrorCodes2[ErrorCodes2["WATCH_CLEANUP"] = 2] = "WATCH_CLEANUP";
1948
- ErrorCodes2[ErrorCodes2["APP_ERROR_HANDLER"] = 3] = "APP_ERROR_HANDLER";
1949
- ErrorCodes2[ErrorCodes2["SCHEDULER"] = 4] = "SCHEDULER";
1950
- return ErrorCodes2;
1951
- })(ErrorCodes || {});
1952
- const ErrorTypeStrings = {
1953
- [LifecycleHooks.ACTIVATED]: "activated hook",
1954
- [LifecycleHooks.DEACTIVATED]: "deactivated hook",
1955
- [
1956
- 0
1957
- /* WATCH_GETTER */
1958
- ]: "watcher getter",
1959
- [
1960
- 1
1961
- /* WATCH_CALLBACK */
1962
- ]: "watcher callback",
1963
- [
1964
- 2
1965
- /* WATCH_CLEANUP */
1966
- ]: "watcher cleanup function",
1967
- [
1968
- 3
1969
- /* APP_ERROR_HANDLER */
1970
- ]: "app errorHandler",
1971
- [
1972
- 4
1973
- /* SCHEDULER */
1974
- ]: "scheduler flush"
1593
+ pauseTracking();
1594
+ const warnArgs = [`[Vue warn]: ${msg}`, ...args];
1595
+ /* istanbul ignore if */
1596
+ console.warn(...warnArgs);
1597
+ resetTracking();
1598
+ }
1599
+ //#endregion
1600
+ //#region src/enums.ts
1601
+ var LifecycleHooks = /* @__PURE__ */ function(LifecycleHooks) {
1602
+ LifecycleHooks["ACTIVATED"] = "a";
1603
+ LifecycleHooks["DEACTIVATED"] = "da";
1604
+ return LifecycleHooks;
1605
+ }({});
1606
+ //#endregion
1607
+ //#region src/errorHandling.ts
1608
+ var ErrorCodes = /* @__PURE__ */ function(ErrorCodes) {
1609
+ ErrorCodes[ErrorCodes["WATCH_GETTER"] = 0] = "WATCH_GETTER";
1610
+ ErrorCodes[ErrorCodes["WATCH_CALLBACK"] = 1] = "WATCH_CALLBACK";
1611
+ ErrorCodes[ErrorCodes["WATCH_CLEANUP"] = 2] = "WATCH_CLEANUP";
1612
+ ErrorCodes[ErrorCodes["APP_ERROR_HANDLER"] = 3] = "APP_ERROR_HANDLER";
1613
+ ErrorCodes[ErrorCodes["SCHEDULER"] = 4] = "SCHEDULER";
1614
+ return ErrorCodes;
1615
+ }({});
1616
+ var ErrorTypeStrings = {
1617
+ [LifecycleHooks.ACTIVATED]: "activated hook",
1618
+ [LifecycleHooks.DEACTIVATED]: "deactivated hook",
1619
+ [ErrorCodes.WATCH_GETTER]: "watcher getter",
1620
+ [ErrorCodes.WATCH_CALLBACK]: "watcher callback",
1621
+ [ErrorCodes.WATCH_CLEANUP]: "watcher cleanup function",
1622
+ [ErrorCodes.APP_ERROR_HANDLER]: "app errorHandler",
1623
+ [ErrorCodes.SCHEDULER]: "scheduler flush"
1975
1624
  };
1976
1625
  function callWithErrorHandling(fn, instance, type, args) {
1977
- try {
1978
- return args ? fn(...args) : fn();
1979
- } catch (err) {
1980
- handleError(err, instance, type);
1981
- }
1626
+ try {
1627
+ return args ? fn(...args) : fn();
1628
+ } catch (err) {
1629
+ handleError(err, instance, type);
1630
+ }
1982
1631
  }
1983
1632
  function callWithAsyncErrorHandling(fn, instance, type, args) {
1984
- if (isFunction(fn)) {
1985
- const res = callWithErrorHandling(fn, instance, type, args);
1986
- if (res && isPromise(res)) {
1987
- res.catch((err) => {
1988
- handleError(err, instance, type);
1989
- });
1990
- }
1991
- return res;
1992
- }
1993
- if (isArray(fn)) {
1994
- const values = [];
1995
- for (let i = 0; i < fn.length; i++) {
1996
- values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
1997
- }
1998
- return values;
1999
- } else if (!!(process.env.NODE_ENV !== "production")) {
2000
- warn(
2001
- `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
2002
- );
2003
- }
1633
+ if (isFunction(fn)) {
1634
+ const res = callWithErrorHandling(fn, instance, type, args);
1635
+ if (res && isPromise(res)) res.catch((err) => {
1636
+ handleError(err, instance, type);
1637
+ });
1638
+ return res;
1639
+ }
1640
+ if (isArray(fn)) {
1641
+ const values = [];
1642
+ for (let i = 0; i < fn.length; i++) values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
1643
+ return values;
1644
+ } else if (!!(process.env.NODE_ENV !== "production")) warn(`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`);
2004
1645
  }
2005
1646
  function handleError(err, instance, type, throwInDev = true) {
2006
- const contextVNode = null;
2007
- logError(err, type, contextVNode, throwInDev);
1647
+ logError(err, type, null, throwInDev);
2008
1648
  }
2009
1649
  function logError(err, type, contextVNode, throwInDev = true) {
2010
- if (!!(process.env.NODE_ENV !== "production")) {
2011
- const info = ErrorTypeStrings[type];
2012
- warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
2013
- if (throwInDev) {
2014
- throw err;
2015
- } else {
2016
- console.error(err);
2017
- }
2018
- } else {
2019
- console.error(err);
2020
- }
2021
- }
2022
- var SchedulerJobFlags = /* @__PURE__ */ ((SchedulerJobFlags2) => {
2023
- SchedulerJobFlags2[SchedulerJobFlags2["QUEUED"] = 1] = "QUEUED";
2024
- SchedulerJobFlags2[SchedulerJobFlags2["PRE"] = 2] = "PRE";
2025
- SchedulerJobFlags2[SchedulerJobFlags2["ALLOW_RECURSE"] = 4] = "ALLOW_RECURSE";
2026
- SchedulerJobFlags2[SchedulerJobFlags2["DISPOSED"] = 8] = "DISPOSED";
2027
- return SchedulerJobFlags2;
2028
- })(SchedulerJobFlags || {});
2029
- const queue = [];
2030
- let flushIndex = -1;
2031
- const pendingPostFlushCbs = [];
2032
- let activePostFlushCbs = null;
2033
- let postFlushIndex = 0;
2034
- const resolvedPromise = /* @__PURE__ */ Promise.resolve();
2035
- let currentFlushPromise = null;
2036
- const RECURSION_LIMIT = 100;
1650
+ if (!!(process.env.NODE_ENV !== "production")) {
1651
+ const info = ErrorTypeStrings[type];
1652
+ warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
1653
+ if (throwInDev) throw err;
1654
+ else console.error(err);
1655
+ } else console.error(err);
1656
+ }
1657
+ //#endregion
1658
+ //#region src/scheduler.ts
1659
+ var SchedulerJobFlags = /* @__PURE__ */ function(SchedulerJobFlags) {
1660
+ SchedulerJobFlags[SchedulerJobFlags["QUEUED"] = 1] = "QUEUED";
1661
+ SchedulerJobFlags[SchedulerJobFlags["PRE"] = 2] = "PRE";
1662
+ /**
1663
+ * Indicates whether the effect is allowed to recursively trigger itself
1664
+ * when managed by the scheduler.
1665
+ *
1666
+ * By default, a job cannot trigger itself because some built-in method calls,
1667
+ * e.g. Array.prototype.push actually performs reads as well (#1740) which
1668
+ * can lead to confusing infinite loops.
1669
+ * The allowed cases are component update functions and watch callbacks.
1670
+ * Component update functions may update child component props, which in turn
1671
+ * trigger flush: "pre" watch callbacks that mutates state that the parent
1672
+ * relies on (#1801). Watch callbacks doesn't track its dependencies so if it
1673
+ * triggers itself again, it's likely intentional and it is the user's
1674
+ * responsibility to perform recursive state mutation that eventually
1675
+ * stabilizes (#1727).
1676
+ */
1677
+ SchedulerJobFlags[SchedulerJobFlags["ALLOW_RECURSE"] = 4] = "ALLOW_RECURSE";
1678
+ SchedulerJobFlags[SchedulerJobFlags["DISPOSED"] = 8] = "DISPOSED";
1679
+ return SchedulerJobFlags;
1680
+ }({});
1681
+ var queue = [];
1682
+ var flushIndex = -1;
1683
+ var pendingPostFlushCbs = [];
1684
+ var activePostFlushCbs = null;
1685
+ var postFlushIndex = 0;
1686
+ var resolvedPromise = /* @__PURE__ */ Promise.resolve();
1687
+ var currentFlushPromise = null;
1688
+ var RECURSION_LIMIT = 100;
2037
1689
  function nextTick(fn) {
2038
- const p = currentFlushPromise || resolvedPromise;
2039
- return fn ? p.then(this ? fn.bind(this) : fn) : p;
1690
+ const p = currentFlushPromise || resolvedPromise;
1691
+ return fn ? p.then(this ? fn.bind(this) : fn) : p;
2040
1692
  }
2041
1693
  function findInsertionIndex(id) {
2042
- let start = flushIndex + 1;
2043
- let end = queue.length;
2044
- while (start < end) {
2045
- const middle = start + end >>> 1;
2046
- const middleJob = queue[middle];
2047
- const middleJobId = getId(middleJob);
2048
- if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
2049
- start = middle + 1;
2050
- } else {
2051
- end = middle;
2052
- }
2053
- }
2054
- return start;
1694
+ let start = flushIndex + 1;
1695
+ let end = queue.length;
1696
+ while (start < end) {
1697
+ const middle = start + end >>> 1;
1698
+ const middleJob = queue[middle];
1699
+ const middleJobId = getId(middleJob);
1700
+ if (middleJobId < id || middleJobId === id && middleJob.flags & SchedulerJobFlags.PRE) start = middle + 1;
1701
+ else end = middle;
1702
+ }
1703
+ return start;
2055
1704
  }
2056
1705
  function queueJob(job) {
2057
- if (!(job.flags & 1)) {
2058
- const jobId = getId(job);
2059
- const lastJob = queue[queue.length - 1];
2060
- if (!lastJob || // fast path when the job id is larger than the tail
2061
- !(job.flags & 2) && jobId >= getId(lastJob)) {
2062
- queue.push(job);
2063
- } else {
2064
- queue.splice(findInsertionIndex(jobId), 0, job);
2065
- }
2066
- job.flags |= 1;
2067
- queueFlush();
2068
- }
1706
+ if (!(job.flags & SchedulerJobFlags.QUEUED)) {
1707
+ const jobId = getId(job);
1708
+ const lastJob = queue[queue.length - 1];
1709
+ if (!lastJob || !(job.flags & SchedulerJobFlags.PRE) && jobId >= getId(lastJob)) queue.push(job);
1710
+ else queue.splice(findInsertionIndex(jobId), 0, job);
1711
+ job.flags |= SchedulerJobFlags.QUEUED;
1712
+ queueFlush();
1713
+ }
2069
1714
  }
2070
1715
  function queueFlush() {
2071
- if (!currentFlushPromise) {
2072
- currentFlushPromise = resolvedPromise.then(flushJobs);
2073
- }
1716
+ if (!currentFlushPromise) currentFlushPromise = resolvedPromise.then(flushJobs);
2074
1717
  }
2075
1718
  function flushPostFlushCbs(seen) {
2076
- if (pendingPostFlushCbs.length) {
2077
- const deduped = [...new Set(pendingPostFlushCbs)].sort(
2078
- (a, b) => getId(a) - getId(b)
2079
- );
2080
- pendingPostFlushCbs.length = 0;
2081
- if (activePostFlushCbs) {
2082
- activePostFlushCbs.push(...deduped);
2083
- return;
2084
- }
2085
- activePostFlushCbs = deduped;
2086
- if (!!(process.env.NODE_ENV !== "production")) {
2087
- seen = seen || /* @__PURE__ */ new Map();
2088
- }
2089
- for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
2090
- const cb = activePostFlushCbs[postFlushIndex];
2091
- if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) {
2092
- continue;
2093
- }
2094
- if (cb.flags & 4) {
2095
- cb.flags &= -2;
2096
- }
2097
- if (!(cb.flags & 8)) cb();
2098
- cb.flags &= -2;
2099
- }
2100
- activePostFlushCbs = null;
2101
- postFlushIndex = 0;
2102
- }
2103
- }
2104
- const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
1719
+ if (pendingPostFlushCbs.length) {
1720
+ const deduped = [...new Set(pendingPostFlushCbs)].sort((a, b) => getId(a) - getId(b));
1721
+ pendingPostFlushCbs.length = 0;
1722
+ if (activePostFlushCbs) {
1723
+ activePostFlushCbs.push(...deduped);
1724
+ return;
1725
+ }
1726
+ activePostFlushCbs = deduped;
1727
+ if (!!(process.env.NODE_ENV !== "production")) seen = seen || /* @__PURE__ */ new Map();
1728
+ for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
1729
+ const cb = activePostFlushCbs[postFlushIndex];
1730
+ if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) continue;
1731
+ if (cb.flags & SchedulerJobFlags.ALLOW_RECURSE) cb.flags &= ~SchedulerJobFlags.QUEUED;
1732
+ if (!(cb.flags & SchedulerJobFlags.DISPOSED)) cb();
1733
+ cb.flags &= ~SchedulerJobFlags.QUEUED;
1734
+ }
1735
+ activePostFlushCbs = null;
1736
+ postFlushIndex = 0;
1737
+ }
1738
+ }
1739
+ var getId = (job) => job.id == null ? job.flags & SchedulerJobFlags.PRE ? -1 : Infinity : job.id;
2105
1740
  function flushJobs(seen) {
2106
- if (!!(process.env.NODE_ENV !== "production")) {
2107
- seen = seen || /* @__PURE__ */ new Map();
2108
- }
2109
- const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
2110
- try {
2111
- for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
2112
- const job = queue[flushIndex];
2113
- if (job && !(job.flags & 8)) {
2114
- if (!!(process.env.NODE_ENV !== "production") && check(job)) {
2115
- continue;
2116
- }
2117
- if (job.flags & 4) {
2118
- job.flags &= ~1;
2119
- }
2120
- callWithErrorHandling(
2121
- job,
2122
- null,
2123
- ErrorCodes.SCHEDULER
2124
- );
2125
- if (!(job.flags & 4)) {
2126
- job.flags &= ~1;
2127
- }
2128
- }
2129
- }
2130
- } finally {
2131
- for (; flushIndex < queue.length; flushIndex++) {
2132
- const job = queue[flushIndex];
2133
- if (job) {
2134
- job.flags &= -2;
2135
- }
2136
- }
2137
- flushIndex = -1;
2138
- queue.length = 0;
2139
- flushPostFlushCbs(seen);
2140
- currentFlushPromise = null;
2141
- if (queue.length || pendingPostFlushCbs.length) {
2142
- flushJobs(seen);
2143
- }
2144
- }
1741
+ if (!!(process.env.NODE_ENV !== "production")) seen = seen || /* @__PURE__ */ new Map();
1742
+ const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
1743
+ try {
1744
+ for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1745
+ const job = queue[flushIndex];
1746
+ if (job && !(job.flags & SchedulerJobFlags.DISPOSED)) {
1747
+ if (!!(process.env.NODE_ENV !== "production") && check(job)) continue;
1748
+ if (job.flags & SchedulerJobFlags.ALLOW_RECURSE) job.flags &= ~SchedulerJobFlags.QUEUED;
1749
+ callWithErrorHandling(job, null, ErrorCodes.SCHEDULER);
1750
+ if (!(job.flags & SchedulerJobFlags.ALLOW_RECURSE)) job.flags &= ~SchedulerJobFlags.QUEUED;
1751
+ }
1752
+ }
1753
+ } finally {
1754
+ for (; flushIndex < queue.length; flushIndex++) {
1755
+ const job = queue[flushIndex];
1756
+ if (job) job.flags &= ~SchedulerJobFlags.QUEUED;
1757
+ }
1758
+ flushIndex = -1;
1759
+ queue.length = 0;
1760
+ flushPostFlushCbs(seen);
1761
+ currentFlushPromise = null;
1762
+ if (queue.length || pendingPostFlushCbs.length) flushJobs(seen);
1763
+ }
2145
1764
  }
2146
1765
  function checkRecursiveUpdates(seen, fn) {
2147
- const count = seen.get(fn) || 0;
2148
- if (count > RECURSION_LIMIT) {
2149
- handleError(
2150
- `Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
2151
- null,
2152
- ErrorCodes.APP_ERROR_HANDLER
2153
- );
2154
- return true;
2155
- }
2156
- seen.set(fn, count + 1);
2157
- return false;
2158
- }
2159
- function watchEffect(effect2, options) {
2160
- return doWatch(effect2, null, options);
2161
- }
2162
- function watchSyncEffect(effect2, options) {
2163
- return doWatch(
2164
- effect2,
2165
- null,
2166
- !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
2167
- );
1766
+ const count = seen.get(fn) || 0;
1767
+ if (count > RECURSION_LIMIT) {
1768
+ handleError("Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.", null, ErrorCodes.APP_ERROR_HANDLER);
1769
+ return true;
1770
+ }
1771
+ seen.set(fn, count + 1);
1772
+ return false;
1773
+ }
1774
+ //#endregion
1775
+ //#region src/apiWatch.ts
1776
+ function watchEffect(effect, options) {
1777
+ return doWatch(effect, null, options);
1778
+ }
1779
+ function watchSyncEffect(effect, options) {
1780
+ return doWatch(effect, null, !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" });
2168
1781
  }
2169
1782
  function watch(source, cb, options) {
2170
- if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
2171
- warn(
2172
- `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
2173
- );
2174
- }
2175
- return doWatch(source, cb, options);
1783
+ if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) warn("`watch(fn, options?)` signature has been moved to a separate API. Use `watchEffect(fn, options?)` instead. `watch` now only supports `watch(source, cb, options?) signature.");
1784
+ return doWatch(source, cb, options);
2176
1785
  }
2177
1786
  function doWatch(source, cb, options = EMPTY_OBJ) {
2178
- const { immediate, deep, flush, once } = options;
2179
- if (!!(process.env.NODE_ENV !== "production") && !cb) {
2180
- if (immediate !== void 0) {
2181
- warn(
2182
- `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
2183
- );
2184
- }
2185
- if (deep !== void 0) {
2186
- warn(
2187
- `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
2188
- );
2189
- }
2190
- if (once !== void 0) {
2191
- warn(
2192
- `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
2193
- );
2194
- }
2195
- }
2196
- const baseWatchOptions = extend({}, options);
2197
- if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn;
2198
- baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, null, type, args);
2199
- let isPre = false;
2200
- if (flush !== "sync") {
2201
- isPre = true;
2202
- baseWatchOptions.scheduler = (job, isFirstRun) => {
2203
- if (isFirstRun) {
2204
- job();
2205
- } else {
2206
- queueJob(job);
2207
- }
2208
- };
2209
- }
2210
- baseWatchOptions.augmentJob = (job) => {
2211
- if (cb) {
2212
- job.flags |= SchedulerJobFlags.ALLOW_RECURSE;
2213
- }
2214
- if (isPre) {
2215
- job.flags |= SchedulerJobFlags.PRE;
2216
- }
2217
- };
2218
- const watchHandle = watch$1(source, cb, baseWatchOptions);
2219
- return watchHandle;
2220
- }
2221
- export {
2222
- ARRAY_ITERATE_KEY,
2223
- EffectFlags,
2224
- EffectScope,
2225
- ITERATE_KEY,
2226
- MAP_KEY_ITERATE_KEY,
2227
- ReactiveEffect,
2228
- ReactiveFlags,
2229
- TrackOpTypes,
2230
- TriggerOpTypes,
2231
- WatchErrorCodes,
2232
- computed,
2233
- customRef,
2234
- effect,
2235
- effectScope,
2236
- enableTracking,
2237
- getCurrentScope,
2238
- getCurrentWatcher,
2239
- isProxy,
2240
- isReactive,
2241
- isReadonly,
2242
- isRef,
2243
- isShallow,
2244
- markRaw,
2245
- nextTick,
2246
- onEffectCleanup,
2247
- onScopeDispose,
2248
- onWatcherCleanup,
2249
- pauseTracking,
2250
- proxyRefs,
2251
- reactive,
2252
- reactiveReadArray,
2253
- readonly,
2254
- ref,
2255
- resetTracking,
2256
- shallowReactive,
2257
- shallowReadArray,
2258
- shallowReadonly,
2259
- shallowRef,
2260
- stop,
2261
- toRaw,
2262
- toReactive,
2263
- toReadonly,
2264
- toRef,
2265
- toRefs,
2266
- toValue,
2267
- track,
2268
- traverse,
2269
- trigger,
2270
- triggerRef,
2271
- unref,
2272
- watch,
2273
- watchEffect,
2274
- watchSyncEffect
2275
- };
2276
- //# sourceMappingURL=index.js.map
1787
+ const { immediate, deep, flush, once } = options;
1788
+ if (!!(process.env.NODE_ENV !== "production") && !cb) {
1789
+ if (immediate !== void 0) warn("watch() \"immediate\" option is only respected when using the watch(source, callback, options?) signature.");
1790
+ if (deep !== void 0) warn("watch() \"deep\" option is only respected when using the watch(source, callback, options?) signature.");
1791
+ if (once !== void 0) warn("watch() \"once\" option is only respected when using the watch(source, callback, options?) signature.");
1792
+ }
1793
+ const baseWatchOptions = extend({}, options);
1794
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn;
1795
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, null, type, args);
1796
+ let isPre = false;
1797
+ if (flush !== "sync") {
1798
+ isPre = true;
1799
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
1800
+ if (isFirstRun) job();
1801
+ else queueJob(job);
1802
+ };
1803
+ }
1804
+ baseWatchOptions.augmentJob = (job) => {
1805
+ if (cb) job.flags |= SchedulerJobFlags.ALLOW_RECURSE;
1806
+ if (isPre) job.flags |= SchedulerJobFlags.PRE;
1807
+ };
1808
+ return watch$1(source, cb, baseWatchOptions);
1809
+ }
1810
+ //#endregion
1811
+ export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, nextTick, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, traverse, trigger, triggerRef, unref, watch, watchEffect, watchSyncEffect };
1812
+
1813
+ //# sourceMappingURL=index.js.map