@reactive-vscode/vueuse 0.3.3 → 0.4.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.
Files changed (4) hide show
  1. package/dist/index.cjs +1059 -1578
  2. package/dist/index.d.ts +264 -300
  3. package/dist/index.js +1105 -1632
  4. package/package.json +5 -5
package/dist/index.cjs CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactivity = require("@reactive-vscode/reactivity");
4
+ function getCurrentInstance() {
5
+ return null;
6
+ }
4
7
  function computedWithControl(source, fn, options = {}) {
5
8
  let v = void 0;
6
9
  let track;
@@ -10,32 +13,35 @@ function computedWithControl(source, fn, options = {}) {
10
13
  dirty = true;
11
14
  trigger();
12
15
  };
13
- reactivity.watch(source, update, { flush: "sync", ...options });
14
- const get2 = typeof fn === "function" ? fn : fn.get;
15
- const set2 = typeof fn === "function" ? void 0 : fn.set;
16
+ reactivity.watch(source, update, {
17
+ flush: "sync",
18
+ ...options
19
+ });
20
+ const get$1 = typeof fn === "function" ? fn : fn.get;
21
+ const set$1 = typeof fn === "function" ? void 0 : fn.set;
16
22
  const result = reactivity.customRef((_track, _trigger) => {
17
23
  track = _track;
18
24
  trigger = _trigger;
19
25
  return {
20
26
  get() {
21
27
  if (dirty) {
22
- v = get2(v);
28
+ v = get$1(v);
23
29
  dirty = false;
24
30
  }
25
31
  track();
26
32
  return v;
27
33
  },
28
- set(v2) {
29
- set2 == null ? void 0 : set2(v2);
34
+ set(v$1) {
35
+ set$1 === null || set$1 === void 0 || set$1(v$1);
30
36
  }
31
37
  };
32
38
  });
33
39
  result.trigger = update;
34
40
  return result;
35
41
  }
36
- function tryOnScopeDispose(fn) {
42
+ function tryOnScopeDispose(fn, failSilently) {
37
43
  if (reactivity.getCurrentScope()) {
38
- reactivity.onScopeDispose(fn);
44
+ reactivity.onScopeDispose(fn, failSilently);
39
45
  return true;
40
46
  }
41
47
  return false;
@@ -53,9 +59,7 @@ function createEventHook() {
53
59
  fns.add(fn);
54
60
  const offFn = () => off(fn);
55
61
  tryOnScopeDispose(offFn);
56
- return {
57
- off: offFn
58
- };
62
+ return { off: offFn };
59
63
  };
60
64
  const trigger = (...args) => {
61
65
  return Promise.all(Array.from(fns).map((fn) => fn(...args)));
@@ -72,171 +76,25 @@ function createGlobalState(stateFactory) {
72
76
  let initialized = false;
73
77
  let state;
74
78
  const scope = reactivity.effectScope(true);
75
- return (...args) => {
79
+ return ((...args) => {
76
80
  if (!initialized) {
77
81
  state = scope.run(() => stateFactory(...args));
78
82
  initialized = true;
79
83
  }
80
84
  return state;
81
- };
85
+ });
82
86
  }
83
87
  // @__NO_SIDE_EFFECTS__
84
88
  function createRef(value, deep) {
85
- if (deep === true) {
86
- return reactivity.ref(value);
87
- } else {
88
- return reactivity.shallowRef(value);
89
- }
90
- }
91
- // @__NO_SIDE_EFFECTS__
92
- function createSharedComposable(composable) {
93
- let subscribers = 0;
94
- let state;
95
- let scope;
96
- const dispose = () => {
97
- subscribers -= 1;
98
- if (scope && subscribers <= 0) {
99
- scope.stop();
100
- state = void 0;
101
- scope = void 0;
102
- }
103
- };
104
- return (...args) => {
105
- subscribers += 1;
106
- if (!scope) {
107
- scope = reactivity.effectScope(true);
108
- state = scope.run(() => composable(...args));
109
- }
110
- tryOnScopeDispose(dispose);
111
- return state;
112
- };
113
- }
114
- function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
115
- for (const [key, value] of Object.entries(extend)) {
116
- if (key === "value")
117
- continue;
118
- if (reactivity.isRef(value) && unwrap) {
119
- Object.defineProperty(ref, key, {
120
- get() {
121
- return value.value;
122
- },
123
- set(v) {
124
- value.value = v;
125
- },
126
- enumerable
127
- });
128
- } else {
129
- Object.defineProperty(ref, key, { value, enumerable });
130
- }
131
- }
132
- return ref;
133
- }
134
- function get(obj, key) {
135
- if (key == null)
136
- return reactivity.unref(obj);
137
- return reactivity.unref(obj)[key];
138
- }
139
- function isDefined(v) {
140
- return reactivity.unref(v) != null;
141
- }
142
- // @__NO_SIDE_EFFECTS__
143
- function makeDestructurable(obj, arr) {
144
- if (typeof Symbol !== "undefined") {
145
- const clone = { ...obj };
146
- Object.defineProperty(clone, Symbol.iterator, {
147
- enumerable: false,
148
- value() {
149
- let index = 0;
150
- return {
151
- next: () => ({
152
- value: arr[index++],
153
- done: index > arr.length
154
- })
155
- };
156
- }
157
- });
158
- return clone;
159
- } else {
160
- return Object.assign([...arr], obj);
161
- }
162
- }
163
- // @__NO_SIDE_EFFECTS__
164
- function reactify(fn, options) {
165
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? reactivity.unref : reactivity.toValue;
166
- return function(...args) {
167
- return reactivity.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
168
- };
169
- }
170
- // @__NO_SIDE_EFFECTS__
171
- function reactifyObject(obj, optionsOrKeys = {}) {
172
- let keys = [];
173
- let options;
174
- if (Array.isArray(optionsOrKeys)) {
175
- keys = optionsOrKeys;
176
- } else {
177
- options = optionsOrKeys;
178
- const { includeOwnProperties = true } = optionsOrKeys;
179
- keys.push(...Object.keys(obj));
180
- if (includeOwnProperties)
181
- keys.push(...Object.getOwnPropertyNames(obj));
182
- }
183
- return Object.fromEntries(
184
- keys.map((key) => {
185
- const value = obj[key];
186
- return [
187
- key,
188
- typeof value === "function" ? /* @__PURE__ */ reactify(value.bind(obj), options) : value
189
- ];
190
- })
191
- );
192
- }
193
- function toReactive(objectRef) {
194
- if (!reactivity.isRef(objectRef))
195
- return reactivity.reactive(objectRef);
196
- const proxy = new Proxy({}, {
197
- get(_, p, receiver) {
198
- return reactivity.unref(Reflect.get(objectRef.value, p, receiver));
199
- },
200
- set(_, p, value) {
201
- if (reactivity.isRef(objectRef.value[p]) && !reactivity.isRef(value))
202
- objectRef.value[p].value = value;
203
- else
204
- objectRef.value[p] = value;
205
- return true;
206
- },
207
- deleteProperty(_, p) {
208
- return Reflect.deleteProperty(objectRef.value, p);
209
- },
210
- has(_, p) {
211
- return Reflect.has(objectRef.value, p);
212
- },
213
- ownKeys() {
214
- return Object.keys(objectRef.value);
215
- },
216
- getOwnPropertyDescriptor() {
217
- return {
218
- enumerable: true,
219
- configurable: true
220
- };
221
- }
222
- });
223
- return reactivity.reactive(proxy);
224
- }
225
- function reactiveComputed(fn) {
226
- return toReactive(reactivity.computed(fn));
227
- }
228
- function reactiveOmit(obj, ...keys) {
229
- const flatKeys = keys.flat();
230
- const predicate = flatKeys[0];
231
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => !predicate(reactivity.toValue(v), k))) : Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
89
+ if (deep === true) return reactivity.ref(value);
90
+ else return reactivity.shallowRef(value);
232
91
  }
233
92
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
234
93
  const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
235
94
  const isDef = (val) => typeof val !== "undefined";
236
95
  const notNullish = (val) => val != null;
237
96
  const assert = (condition, ...infos) => {
238
- if (!condition)
239
- console.warn(...infos);
97
+ if (!condition) console.warn(...infos);
240
98
  };
241
99
  const toString = Object.prototype.toString;
242
100
  const isObject = (val) => toString.call(val) === "[object Object]";
@@ -252,91 +110,61 @@ const rand = (min, max) => {
252
110
  };
253
111
  const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
254
112
  function toRef(...args) {
255
- if (args.length !== 1)
256
- return reactivity.toRef(...args);
113
+ if (args.length !== 1) return reactivity.toRef(...args);
257
114
  const r = args[0];
258
- return typeof r === "function" ? reactivity.readonly(reactivity.customRef(() => ({ get: r, set: noop }))) : reactivity.ref(r);
259
- }
260
- const resolveRef = toRef;
261
- function reactivePick(obj, ...keys) {
262
- const flatKeys = keys.flat();
263
- const predicate = flatKeys[0];
264
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => predicate(reactivity.toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
265
- }
266
- function refAutoReset(defaultValue, afterMs = 1e4) {
267
- return reactivity.customRef((track, trigger) => {
268
- let value = reactivity.toValue(defaultValue);
269
- let timer;
270
- const resetAfter = () => setTimeout(() => {
271
- value = reactivity.toValue(defaultValue);
272
- trigger();
273
- }, reactivity.toValue(afterMs));
274
- tryOnScopeDispose(() => {
275
- clearTimeout(timer);
276
- });
277
- return {
278
- get() {
279
- track();
280
- return value;
281
- },
282
- set(newValue) {
283
- value = newValue;
284
- trigger();
285
- clearTimeout(timer);
286
- timer = resetAfter();
287
- }
288
- };
289
- });
115
+ return typeof r === "function" ? reactivity.readonly(reactivity.customRef(() => ({
116
+ get: r,
117
+ set: noop
118
+ }))) : reactivity.ref(r);
290
119
  }
291
120
  function createFilterWrapper(filter, fn) {
292
121
  function wrapper(...args) {
293
122
  return new Promise((resolve, reject) => {
294
- Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
123
+ Promise.resolve(filter(() => fn.apply(this, args), {
124
+ fn,
125
+ thisArg: this,
126
+ args
127
+ })).then(resolve).catch(reject);
295
128
  });
296
129
  }
297
130
  return wrapper;
298
131
  }
299
- const bypassFilter = (invoke2) => {
300
- return invoke2();
132
+ const bypassFilter = (invoke$1) => {
133
+ return invoke$1();
301
134
  };
302
135
  function debounceFilter(ms, options = {}) {
303
136
  let timer;
304
137
  let maxTimer;
305
138
  let lastRejector = noop;
306
- const _clearTimeout = (timer2) => {
307
- clearTimeout(timer2);
139
+ const _clearTimeout = (timer$1) => {
140
+ clearTimeout(timer$1);
308
141
  lastRejector();
309
142
  lastRejector = noop;
310
143
  };
311
144
  let lastInvoker;
312
- const filter = (invoke2) => {
145
+ const filter = (invoke$1) => {
313
146
  const duration = reactivity.toValue(ms);
314
147
  const maxDuration = reactivity.toValue(options.maxWait);
315
- if (timer)
316
- _clearTimeout(timer);
148
+ if (timer) _clearTimeout(timer);
317
149
  if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
318
150
  if (maxTimer) {
319
151
  _clearTimeout(maxTimer);
320
152
  maxTimer = void 0;
321
153
  }
322
- return Promise.resolve(invoke2());
154
+ return Promise.resolve(invoke$1());
323
155
  }
324
156
  return new Promise((resolve, reject) => {
325
157
  lastRejector = options.rejectOnCancel ? reject : resolve;
326
- lastInvoker = invoke2;
327
- if (maxDuration && !maxTimer) {
328
- maxTimer = setTimeout(() => {
329
- if (timer)
330
- _clearTimeout(timer);
331
- maxTimer = void 0;
332
- resolve(lastInvoker());
333
- }, maxDuration);
334
- }
158
+ lastInvoker = invoke$1;
159
+ if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
160
+ if (timer) _clearTimeout(timer);
161
+ maxTimer = void 0;
162
+ resolve(lastInvoker());
163
+ }, maxDuration);
335
164
  timer = setTimeout(() => {
336
- if (maxTimer)
337
- _clearTimeout(maxTimer);
165
+ if (maxTimer) _clearTimeout(maxTimer);
338
166
  maxTimer = void 0;
339
- resolve(invoke2());
167
+ resolve(invoke$1());
340
168
  }, duration);
341
169
  });
342
170
  };
@@ -352,10 +180,8 @@ function throttleFilter(...args) {
352
180
  let trailing;
353
181
  let leading;
354
182
  let rejectOnCancel;
355
- if (!reactivity.isRef(args[0]) && typeof args[0] === "object")
356
- ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
357
- else
358
- [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
183
+ if (!reactivity.isRef(args[0]) && typeof args[0] === "object") ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
184
+ else [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
359
185
  const clear = () => {
360
186
  if (timer) {
361
187
  clearTimeout(timer);
@@ -367,39 +193,34 @@ function throttleFilter(...args) {
367
193
  const filter = (_invoke) => {
368
194
  const duration = reactivity.toValue(ms);
369
195
  const elapsed = Date.now() - lastExec;
370
- const invoke2 = () => {
196
+ const invoke$1 = () => {
371
197
  return lastValue = _invoke();
372
198
  };
373
199
  clear();
374
200
  if (duration <= 0) {
375
201
  lastExec = Date.now();
376
- return invoke2();
202
+ return invoke$1();
377
203
  }
378
- if (elapsed > duration && (leading || !isLeading)) {
204
+ if (elapsed > duration) {
379
205
  lastExec = Date.now();
380
- invoke2();
381
- } else if (trailing) {
382
- lastValue = new Promise((resolve, reject) => {
383
- lastRejector = rejectOnCancel ? reject : resolve;
384
- timer = setTimeout(() => {
385
- lastExec = Date.now();
386
- isLeading = true;
387
- resolve(invoke2());
388
- clear();
389
- }, Math.max(0, duration - elapsed));
390
- });
391
- }
392
- if (!leading && !timer)
393
- timer = setTimeout(() => isLeading = true, duration);
206
+ if (leading || !isLeading) invoke$1();
207
+ } else if (trailing) lastValue = new Promise((resolve, reject) => {
208
+ lastRejector = rejectOnCancel ? reject : resolve;
209
+ timer = setTimeout(() => {
210
+ lastExec = Date.now();
211
+ isLeading = true;
212
+ resolve(invoke$1());
213
+ clear();
214
+ }, Math.max(0, duration - elapsed));
215
+ });
216
+ if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration);
394
217
  isLeading = false;
395
218
  return lastValue;
396
219
  };
397
220
  return filter;
398
221
  }
399
222
  function pausableFilter(extendFilter = bypassFilter, options = {}) {
400
- const {
401
- initialState = "active"
402
- } = options;
223
+ const { initialState = "active" } = options;
403
224
  const isActive = toRef(initialState === "active");
404
225
  function pause() {
405
226
  isActive.value = false;
@@ -408,17 +229,19 @@ function pausableFilter(extendFilter = bypassFilter, options = {}) {
408
229
  isActive.value = true;
409
230
  }
410
231
  const eventFilter = (...args) => {
411
- if (isActive.value)
412
- extendFilter(...args);
232
+ if (isActive.value) extendFilter(...args);
233
+ };
234
+ return {
235
+ isActive: reactivity.readonly(isActive),
236
+ pause,
237
+ resume,
238
+ eventFilter
413
239
  };
414
- return { isActive: reactivity.readonly(isActive), pause, resume, eventFilter };
415
240
  }
416
241
  function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
417
242
  return new Promise((resolve, reject) => {
418
- if (throwOnTimeout)
419
- setTimeout(() => reject(reason), ms);
420
- else
421
- setTimeout(resolve, ms);
243
+ if (throwOnTimeout) setTimeout(() => reject(reason), ms);
244
+ else setTimeout(resolve, ms);
422
245
  });
423
246
  }
424
247
  function identity(arg) {
@@ -427,15 +250,13 @@ function identity(arg) {
427
250
  function createSingletonPromise(fn) {
428
251
  let _promise;
429
252
  function wrapper() {
430
- if (!_promise)
431
- _promise = fn();
253
+ if (!_promise) _promise = fn();
432
254
  return _promise;
433
255
  }
434
256
  wrapper.reset = async () => {
435
257
  const _prev = _promise;
436
258
  _promise = void 0;
437
- if (_prev)
438
- await _prev;
259
+ if (_prev) await _prev;
439
260
  };
440
261
  return wrapper;
441
262
  }
@@ -446,21 +267,18 @@ function containsProp(obj, ...props) {
446
267
  return props.some((k) => k in obj);
447
268
  }
448
269
  function increaseWithUnit(target, delta) {
449
- var _a;
450
- if (typeof target === "number")
451
- return target + delta;
452
- const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || "";
270
+ var _target$match;
271
+ if (typeof target === "number") return target + delta;
272
+ const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || "";
453
273
  const unit = target.slice(value.length);
454
274
  const result = Number.parseFloat(value) + delta;
455
- if (Number.isNaN(result))
456
- return target;
275
+ if (Number.isNaN(result)) return target;
457
276
  return result + unit;
458
277
  }
459
278
  function objectPick(obj, keys, omitUndefined = false) {
460
279
  return keys.reduce((n, k) => {
461
280
  if (k in obj) {
462
- if (!omitUndefined || obj[k] !== void 0)
463
- n[k] = obj[k];
281
+ if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k];
464
282
  }
465
283
  return n;
466
284
  }, {});
@@ -478,10 +296,9 @@ function toArray(value) {
478
296
  }
479
297
  function cacheStringFunction(fn) {
480
298
  const cache = /* @__PURE__ */ Object.create(null);
481
- return (str) => {
482
- const hit = cache[str];
483
- return hit || (cache[str] = fn(str));
484
- };
299
+ return ((str) => {
300
+ return cache[str] || (cache[str] = fn(str));
301
+ });
485
302
  }
486
303
  const hyphenateRE = /\B([A-Z])/g;
487
304
  const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
@@ -490,14 +307,167 @@ const camelize = cacheStringFunction((str) => {
490
307
  return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
491
308
  });
492
309
  function getLifeCycleTarget(target) {
493
- return target || null;
310
+ return target || getCurrentInstance();
311
+ }
312
+ // @__NO_SIDE_EFFECTS__
313
+ function createSharedComposable(composable) {
314
+ if (!isClient) return composable;
315
+ let subscribers = 0;
316
+ let state;
317
+ let scope;
318
+ const dispose = () => {
319
+ subscribers -= 1;
320
+ if (scope && subscribers <= 0) {
321
+ scope.stop();
322
+ state = void 0;
323
+ scope = void 0;
324
+ }
325
+ };
326
+ return ((...args) => {
327
+ subscribers += 1;
328
+ if (!scope) {
329
+ scope = reactivity.effectScope(true);
330
+ state = scope.run(() => composable(...args));
331
+ }
332
+ tryOnScopeDispose(dispose);
333
+ return state;
334
+ });
335
+ }
336
+ function extendRef(ref$1, extend, { enumerable = false, unwrap = true } = {}) {
337
+ for (const [key, value] of Object.entries(extend)) {
338
+ if (key === "value") continue;
339
+ if (reactivity.isRef(value) && unwrap) Object.defineProperty(ref$1, key, {
340
+ get() {
341
+ return value.value;
342
+ },
343
+ set(v) {
344
+ value.value = v;
345
+ },
346
+ enumerable
347
+ });
348
+ else Object.defineProperty(ref$1, key, {
349
+ value,
350
+ enumerable
351
+ });
352
+ }
353
+ return ref$1;
354
+ }
355
+ function get(obj, key) {
356
+ if (key == null) return reactivity.unref(obj);
357
+ return reactivity.unref(obj)[key];
358
+ }
359
+ function isDefined(v) {
360
+ return reactivity.unref(v) != null;
361
+ }
362
+ // @__NO_SIDE_EFFECTS__
363
+ function makeDestructurable(obj, arr) {
364
+ if (typeof Symbol !== "undefined") {
365
+ const clone = { ...obj };
366
+ Object.defineProperty(clone, Symbol.iterator, {
367
+ enumerable: false,
368
+ value() {
369
+ let index = 0;
370
+ return { next: () => ({
371
+ value: arr[index++],
372
+ done: index > arr.length
373
+ }) };
374
+ }
375
+ });
376
+ return clone;
377
+ } else return Object.assign([...arr], obj);
378
+ }
379
+ // @__NO_SIDE_EFFECTS__
380
+ function reactify(fn, options) {
381
+ const unrefFn = (options === null || options === void 0 ? void 0 : options.computedGetter) === false ? reactivity.unref : reactivity.toValue;
382
+ return function(...args) {
383
+ return reactivity.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
384
+ };
385
+ }
386
+ // @__NO_SIDE_EFFECTS__
387
+ function reactifyObject(obj, optionsOrKeys = {}) {
388
+ let keys = [];
389
+ let options;
390
+ if (Array.isArray(optionsOrKeys)) keys = optionsOrKeys;
391
+ else {
392
+ options = optionsOrKeys;
393
+ const { includeOwnProperties = true } = optionsOrKeys;
394
+ keys.push(...Object.keys(obj));
395
+ if (includeOwnProperties) keys.push(...Object.getOwnPropertyNames(obj));
396
+ }
397
+ return Object.fromEntries(keys.map((key) => {
398
+ const value = obj[key];
399
+ return [key, typeof value === "function" ? /* @__PURE__ */ reactify(value.bind(obj), options) : value];
400
+ }));
401
+ }
402
+ function toReactive(objectRef) {
403
+ if (!reactivity.isRef(objectRef)) return reactivity.reactive(objectRef);
404
+ return reactivity.reactive(new Proxy({}, {
405
+ get(_, p, receiver) {
406
+ return reactivity.unref(Reflect.get(objectRef.value, p, receiver));
407
+ },
408
+ set(_, p, value) {
409
+ if (reactivity.isRef(objectRef.value[p]) && !reactivity.isRef(value)) objectRef.value[p].value = value;
410
+ else objectRef.value[p] = value;
411
+ return true;
412
+ },
413
+ deleteProperty(_, p) {
414
+ return Reflect.deleteProperty(objectRef.value, p);
415
+ },
416
+ has(_, p) {
417
+ return Reflect.has(objectRef.value, p);
418
+ },
419
+ ownKeys() {
420
+ return Object.keys(objectRef.value);
421
+ },
422
+ getOwnPropertyDescriptor() {
423
+ return {
424
+ enumerable: true,
425
+ configurable: true
426
+ };
427
+ }
428
+ }));
429
+ }
430
+ function reactiveComputed(fn) {
431
+ return toReactive(reactivity.computed(fn));
432
+ }
433
+ function reactiveOmit(obj, ...keys) {
434
+ const flatKeys = keys.flat();
435
+ const predicate = flatKeys[0];
436
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => !predicate(reactivity.toValue(v), k))) : Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
437
+ }
438
+ function reactivePick(obj, ...keys) {
439
+ const flatKeys = keys.flat();
440
+ const predicate = flatKeys[0];
441
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => predicate(reactivity.toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
442
+ }
443
+ function refAutoReset(defaultValue, afterMs = 1e4) {
444
+ return reactivity.customRef((track, trigger) => {
445
+ let value = reactivity.toValue(defaultValue);
446
+ let timer;
447
+ const resetAfter = () => setTimeout(() => {
448
+ value = reactivity.toValue(defaultValue);
449
+ trigger();
450
+ }, reactivity.toValue(afterMs));
451
+ tryOnScopeDispose(() => {
452
+ clearTimeout(timer);
453
+ });
454
+ return {
455
+ get() {
456
+ track();
457
+ return value;
458
+ },
459
+ set(newValue) {
460
+ value = newValue;
461
+ trigger();
462
+ clearTimeout(timer);
463
+ timer = resetAfter();
464
+ }
465
+ };
466
+ });
494
467
  }
495
468
  // @__NO_SIDE_EFFECTS__
496
469
  function useDebounceFn(fn, ms = 200, options = {}) {
497
- return createFilterWrapper(
498
- debounceFilter(ms, options),
499
- fn
500
- );
470
+ return createFilterWrapper(debounceFilter(ms, options), fn);
501
471
  }
502
472
  function refDebounced(value, ms = 200, options = {}) {
503
473
  const debounced = reactivity.ref(reactivity.toValue(value));
@@ -511,8 +481,8 @@ function refDebounced(value, ms = 200, options = {}) {
511
481
  function refDefault(source, defaultValue) {
512
482
  return reactivity.computed({
513
483
  get() {
514
- var _a;
515
- return (_a = source.value) != null ? _a : defaultValue;
484
+ var _source$value;
485
+ return (_source$value = source.value) !== null && _source$value !== void 0 ? _source$value : defaultValue;
516
486
  },
517
487
  set(value) {
518
488
  source.value = value;
@@ -521,14 +491,10 @@ function refDefault(source, defaultValue) {
521
491
  }
522
492
  // @__NO_SIDE_EFFECTS__
523
493
  function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
524
- return createFilterWrapper(
525
- throttleFilter(ms, trailing, leading, rejectOnCancel),
526
- fn
527
- );
494
+ return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
528
495
  }
529
496
  function refThrottled(value, delay = 200, trailing = true, leading = true) {
530
- if (delay <= 0)
531
- return value;
497
+ if (delay <= 0) return value;
532
498
  const throttled = reactivity.ref(reactivity.toValue(value));
533
499
  const updater = /* @__PURE__ */ useThrottleFn(() => {
534
500
  throttled.value = value.value;
@@ -541,57 +507,49 @@ function refWithControl(initial, options = {}) {
541
507
  let source = initial;
542
508
  let track;
543
509
  let trigger;
544
- const ref = reactivity.customRef((_track, _trigger) => {
510
+ const ref$1 = reactivity.customRef((_track, _trigger) => {
545
511
  track = _track;
546
512
  trigger = _trigger;
547
513
  return {
548
514
  get() {
549
- return get2();
515
+ return get$1();
550
516
  },
551
517
  set(v) {
552
- set2(v);
518
+ set$1(v);
553
519
  }
554
520
  };
555
521
  });
556
- function get2(tracking = true) {
557
- if (tracking)
558
- track();
522
+ function get$1(tracking = true) {
523
+ if (tracking) track();
559
524
  return source;
560
525
  }
561
- function set2(value, triggering = true) {
562
- var _a, _b;
563
- if (value === source)
564
- return;
526
+ function set$1(value, triggering = true) {
527
+ var _options$onBeforeChan, _options$onChanged;
528
+ if (value === source) return;
565
529
  const old = source;
566
- if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
567
- return;
530
+ if (((_options$onBeforeChan = options.onBeforeChange) === null || _options$onBeforeChan === void 0 ? void 0 : _options$onBeforeChan.call(options, value, old)) === false) return;
568
531
  source = value;
569
- (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
570
- if (triggering)
571
- trigger();
572
- }
573
- const untrackedGet = () => get2(false);
574
- const silentSet = (v) => set2(v, false);
575
- const peek = () => get2(false);
576
- const lay = (v) => set2(v, false);
577
- return extendRef(
578
- ref,
579
- {
580
- get: get2,
581
- set: set2,
582
- untrackedGet,
583
- silentSet,
584
- peek,
585
- lay
586
- },
587
- { enumerable: true }
588
- );
532
+ (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, value, old);
533
+ if (triggering) trigger();
534
+ }
535
+ const untrackedGet = () => get$1(false);
536
+ const silentSet = (v) => set$1(v, false);
537
+ const peek = () => get$1(false);
538
+ const lay = (v) => set$1(v, false);
539
+ return extendRef(ref$1, {
540
+ get: get$1,
541
+ set: set$1,
542
+ untrackedGet,
543
+ silentSet,
544
+ peek,
545
+ lay
546
+ }, { enumerable: true });
589
547
  }
590
548
  const controlledRef = refWithControl;
591
549
  function set(...args) {
592
550
  if (args.length === 2) {
593
- const [ref, value] = args;
594
- ref.value = value;
551
+ const [ref$1, value] = args;
552
+ ref$1.value = value;
595
553
  }
596
554
  if (args.length === 3) {
597
555
  const [target, key, value] = args;
@@ -599,191 +557,131 @@ function set(...args) {
599
557
  }
600
558
  }
601
559
  function watchWithFilter(source, cb, options = {}) {
602
- const {
603
- eventFilter = bypassFilter,
604
- ...watchOptions
605
- } = options;
606
- return reactivity.watch(
607
- source,
608
- createFilterWrapper(
609
- eventFilter,
610
- cb
611
- ),
612
- watchOptions
613
- );
560
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
561
+ return reactivity.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
614
562
  }
615
563
  function watchPausable(source, cb, options = {}) {
616
- const {
617
- eventFilter: filter,
618
- initialState = "active",
619
- ...watchOptions
620
- } = options;
564
+ const { eventFilter: filter, initialState = "active", ...watchOptions } = options;
621
565
  const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
622
- const stop = watchWithFilter(
623
- source,
624
- cb,
625
- {
566
+ return {
567
+ stop: watchWithFilter(source, cb, {
626
568
  ...watchOptions,
627
569
  eventFilter
628
- }
629
- );
630
- return { stop, pause, resume, isActive };
570
+ }),
571
+ pause,
572
+ resume,
573
+ isActive
574
+ };
631
575
  }
576
+ const pausableWatch = watchPausable;
632
577
  function syncRef(left, right, ...[options]) {
633
- const {
634
- flush = "sync",
635
- deep = false,
636
- immediate = true,
637
- direction = "both",
638
- transform = {}
639
- } = options || {};
578
+ const { flush = "sync", deep = false, immediate = true, direction = "both", transform = {} } = options || {};
640
579
  const watchers = [];
641
580
  const transformLTR = "ltr" in transform && transform.ltr || ((v) => v);
642
581
  const transformRTL = "rtl" in transform && transform.rtl || ((v) => v);
643
- if (direction === "both" || direction === "ltr") {
644
- watchers.push(watchPausable(
645
- left,
646
- (newValue) => {
647
- watchers.forEach((w) => w.pause());
648
- right.value = transformLTR(newValue);
649
- watchers.forEach((w) => w.resume());
650
- },
651
- { flush, deep, immediate }
652
- ));
653
- }
654
- if (direction === "both" || direction === "rtl") {
655
- watchers.push(watchPausable(
656
- right,
657
- (newValue) => {
658
- watchers.forEach((w) => w.pause());
659
- left.value = transformRTL(newValue);
660
- watchers.forEach((w) => w.resume());
661
- },
662
- { flush, deep, immediate }
663
- ));
664
- }
582
+ if (direction === "both" || direction === "ltr") watchers.push(pausableWatch(left, (newValue) => {
583
+ watchers.forEach((w) => w.pause());
584
+ right.value = transformLTR(newValue);
585
+ watchers.forEach((w) => w.resume());
586
+ }, {
587
+ flush,
588
+ deep,
589
+ immediate
590
+ }));
591
+ if (direction === "both" || direction === "rtl") watchers.push(pausableWatch(right, (newValue) => {
592
+ watchers.forEach((w) => w.pause());
593
+ left.value = transformRTL(newValue);
594
+ watchers.forEach((w) => w.resume());
595
+ }, {
596
+ flush,
597
+ deep,
598
+ immediate
599
+ }));
665
600
  const stop = () => {
666
601
  watchers.forEach((w) => w.stop());
667
602
  };
668
603
  return stop;
669
604
  }
670
605
  function syncRefs(source, targets, options = {}) {
671
- const {
672
- flush = "sync",
673
- deep = false,
674
- immediate = true
675
- } = options;
606
+ const { flush = "sync", deep = false, immediate = true } = options;
676
607
  const targetsArray = toArray(targets);
677
- return reactivity.watch(
678
- source,
679
- (newValue) => targetsArray.forEach((target) => target.value = newValue),
680
- { flush, deep, immediate }
681
- );
608
+ return reactivity.watch(source, (newValue) => targetsArray.forEach((target) => target.value = newValue), {
609
+ flush,
610
+ deep,
611
+ immediate
612
+ });
682
613
  }
683
- function toRefs(objectRef, options = {}) {
684
- if (!reactivity.isRef(objectRef))
685
- return reactivity.toRefs(objectRef);
686
- const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
687
- for (const key in objectRef.value) {
688
- result[key] = reactivity.customRef(() => ({
689
- get() {
690
- return objectRef.value[key];
691
- },
692
- set(v) {
693
- var _a;
694
- const replaceRef = (_a = reactivity.toValue(options.replaceRef)) != null ? _a : true;
695
- if (replaceRef) {
696
- if (Array.isArray(objectRef.value)) {
697
- const copy = [...objectRef.value];
698
- copy[key] = v;
699
- objectRef.value = copy;
700
- } else {
701
- const newObject = { ...objectRef.value, [key]: v };
702
- Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
703
- objectRef.value = newObject;
704
- }
705
- } else {
706
- objectRef.value[key] = v;
707
- }
614
+ function toRefs(objectRef, options = {}) {
615
+ if (!reactivity.isRef(objectRef)) return reactivity.toRefs(objectRef);
616
+ const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
617
+ for (const key in objectRef.value) result[key] = reactivity.customRef(() => ({
618
+ get() {
619
+ return objectRef.value[key];
620
+ },
621
+ set(v) {
622
+ var _toValue;
623
+ if ((_toValue = reactivity.toValue(options.replaceRef)) !== null && _toValue !== void 0 ? _toValue : true) if (Array.isArray(objectRef.value)) {
624
+ const copy = [...objectRef.value];
625
+ copy[key] = v;
626
+ objectRef.value = copy;
627
+ } else {
628
+ const newObject = {
629
+ ...objectRef.value,
630
+ [key]: v
631
+ };
632
+ Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
633
+ objectRef.value = newObject;
708
634
  }
709
- }));
710
- }
635
+ else objectRef.value[key] = v;
636
+ }
637
+ }));
711
638
  return result;
712
639
  }
713
- const toValue = reactivity.toValue;
714
- const resolveUnref = reactivity.toValue;
715
640
  function tryOnMounted(fn, sync = true, target) {
716
- const instance = getLifeCycleTarget(target);
717
- if (instance)
718
- ;
719
- else if (sync)
720
- fn();
721
- else
722
- reactivity.nextTick(fn);
641
+ if (getLifeCycleTarget(target)) ;
642
+ else if (sync) fn();
643
+ else reactivity.nextTick(fn);
723
644
  }
724
645
  function createUntil(r, isNot = false) {
725
646
  function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
726
647
  let stop = null;
727
- const watcher = new Promise((resolve) => {
728
- stop = reactivity.watch(
729
- r,
730
- (v) => {
731
- if (condition(v) !== isNot) {
732
- if (stop)
733
- stop();
734
- else
735
- reactivity.nextTick(() => stop == null ? void 0 : stop());
736
- resolve(v);
737
- }
738
- },
739
- {
740
- flush,
741
- deep,
742
- immediate: true
648
+ const promises = [new Promise((resolve) => {
649
+ stop = reactivity.watch(r, (v) => {
650
+ if (condition(v) !== isNot) {
651
+ if (stop) stop();
652
+ else reactivity.nextTick(() => stop === null || stop === void 0 ? void 0 : stop());
653
+ resolve(v);
743
654
  }
744
- );
745
- });
746
- const promises = [watcher];
747
- if (timeout != null) {
748
- promises.push(
749
- promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => stop == null ? void 0 : stop())
750
- );
751
- }
655
+ }, {
656
+ flush,
657
+ deep,
658
+ immediate: true
659
+ });
660
+ })];
661
+ if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => stop === null || stop === void 0 ? void 0 : stop()));
752
662
  return Promise.race(promises);
753
663
  }
754
664
  function toBe(value, options) {
755
- if (!reactivity.isRef(value))
756
- return toMatch((v) => v === value, options);
757
- const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
665
+ if (!reactivity.isRef(value)) return toMatch((v) => v === value, options);
666
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options !== null && options !== void 0 ? options : {};
758
667
  let stop = null;
759
- const watcher = new Promise((resolve) => {
760
- stop = reactivity.watch(
761
- [r, value],
762
- ([v1, v2]) => {
763
- if (isNot !== (v1 === v2)) {
764
- if (stop)
765
- stop();
766
- else
767
- reactivity.nextTick(() => stop == null ? void 0 : stop());
768
- resolve(v1);
769
- }
770
- },
771
- {
772
- flush,
773
- deep,
774
- immediate: true
668
+ const promises = [new Promise((resolve) => {
669
+ stop = reactivity.watch([r, value], ([v1, v2]) => {
670
+ if (isNot !== (v1 === v2)) {
671
+ if (stop) stop();
672
+ else reactivity.nextTick(() => stop === null || stop === void 0 ? void 0 : stop());
673
+ resolve(v1);
775
674
  }
776
- );
777
- });
778
- const promises = [watcher];
779
- if (timeout != null) {
780
- promises.push(
781
- promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => {
782
- stop == null ? void 0 : stop();
783
- return reactivity.toValue(r);
784
- })
785
- );
786
- }
675
+ }, {
676
+ flush,
677
+ deep,
678
+ immediate: true
679
+ });
680
+ })];
681
+ if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => {
682
+ stop === null || stop === void 0 || stop();
683
+ return reactivity.toValue(r);
684
+ }));
787
685
  return Promise.race(promises);
788
686
  }
789
687
  function toBeTruthy(options) {
@@ -814,33 +712,28 @@ function createUntil(r, isNot = false) {
814
712
  return count >= n;
815
713
  }, options);
816
714
  }
817
- if (Array.isArray(reactivity.toValue(r))) {
818
- const instance = {
819
- toMatch,
820
- toContains,
821
- changed,
822
- changedTimes,
823
- get not() {
824
- return createUntil(r, !isNot);
825
- }
826
- };
827
- return instance;
828
- } else {
829
- const instance = {
830
- toMatch,
831
- toBe,
832
- toBeTruthy,
833
- toBeNull,
834
- toBeNaN,
835
- toBeUndefined,
836
- changed,
837
- changedTimes,
838
- get not() {
839
- return createUntil(r, !isNot);
840
- }
841
- };
842
- return instance;
843
- }
715
+ if (Array.isArray(reactivity.toValue(r))) return {
716
+ toMatch,
717
+ toContains,
718
+ changed,
719
+ changedTimes,
720
+ get not() {
721
+ return createUntil(r, !isNot);
722
+ }
723
+ };
724
+ else return {
725
+ toMatch,
726
+ toBe,
727
+ toBeTruthy,
728
+ toBeNull,
729
+ toBeNaN,
730
+ toBeUndefined,
731
+ changed,
732
+ changedTimes,
733
+ get not() {
734
+ return createUntil(r, !isNot);
735
+ }
736
+ };
844
737
  }
845
738
  function until(r) {
846
739
  return createUntil(r);
@@ -850,13 +743,11 @@ function defaultComparator(value, othVal) {
850
743
  }
851
744
  // @__NO_SIDE_EFFECTS__
852
745
  function useArrayDifference(...args) {
853
- var _a, _b;
746
+ var _args$, _args$2;
854
747
  const list = args[0];
855
748
  const values = args[1];
856
- let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
857
- const {
858
- symmetric = false
859
- } = (_b = args[3]) != null ? _b : {};
749
+ let compareFn = (_args$ = args[2]) !== null && _args$ !== void 0 ? _args$ : defaultComparator;
750
+ const { symmetric = false } = (_args$2 = args[3]) !== null && _args$2 !== void 0 ? _args$2 : {};
860
751
  if (typeof compareFn === "string") {
861
752
  const key = compareFn;
862
753
  compareFn = (value, othVal) => value[key] === othVal[key];
@@ -865,9 +756,7 @@ function useArrayDifference(...args) {
865
756
  if (symmetric) {
866
757
  const diff2 = reactivity.computed(() => reactivity.toValue(values).filter((x) => reactivity.toValue(list).findIndex((y) => compareFn(x, y)) === -1));
867
758
  return reactivity.computed(() => symmetric ? [...reactivity.toValue(diff1), ...reactivity.toValue(diff2)] : reactivity.toValue(diff1));
868
- } else {
869
- return diff1;
870
- }
759
+ } else return diff1;
871
760
  }
872
761
  // @__NO_SIDE_EFFECTS__
873
762
  function useArrayEvery(list, fn) {
@@ -879,9 +768,7 @@ function useArrayFilter(list, fn) {
879
768
  }
880
769
  // @__NO_SIDE_EFFECTS__
881
770
  function useArrayFind(list, fn) {
882
- return reactivity.computed(() => reactivity.toValue(
883
- reactivity.toValue(list).find((element, index, array) => fn(reactivity.toValue(element), index, array))
884
- ));
771
+ return reactivity.computed(() => reactivity.toValue(reactivity.toValue(list).find((element, index, array) => fn(reactivity.toValue(element), index, array))));
885
772
  }
886
773
  // @__NO_SIDE_EFFECTS__
887
774
  function useArrayFindIndex(list, fn) {
@@ -889,43 +776,33 @@ function useArrayFindIndex(list, fn) {
889
776
  }
890
777
  function findLast(arr, cb) {
891
778
  let index = arr.length;
892
- while (index-- > 0) {
893
- if (cb(arr[index], index, arr))
894
- return arr[index];
895
- }
896
- return void 0;
779
+ while (index-- > 0) if (cb(arr[index], index, arr)) return arr[index];
897
780
  }
898
781
  // @__NO_SIDE_EFFECTS__
899
782
  function useArrayFindLast(list, fn) {
900
- return reactivity.computed(() => reactivity.toValue(
901
- !Array.prototype.findLast ? findLast(reactivity.toValue(list), (element, index, array) => fn(reactivity.toValue(element), index, array)) : reactivity.toValue(list).findLast((element, index, array) => fn(reactivity.toValue(element), index, array))
902
- ));
783
+ return reactivity.computed(() => reactivity.toValue(!Array.prototype.findLast ? findLast(reactivity.toValue(list), (element, index, array) => fn(reactivity.toValue(element), index, array)) : reactivity.toValue(list).findLast((element, index, array) => fn(reactivity.toValue(element), index, array))));
903
784
  }
904
785
  function isArrayIncludesOptions(obj) {
905
786
  return isObject(obj) && containsProp(obj, "formIndex", "comparator");
906
787
  }
907
788
  // @__NO_SIDE_EFFECTS__
908
789
  function useArrayIncludes(...args) {
909
- var _a;
790
+ var _comparator;
910
791
  const list = args[0];
911
792
  const value = args[1];
912
793
  let comparator = args[2];
913
794
  let formIndex = 0;
914
795
  if (isArrayIncludesOptions(comparator)) {
915
- formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
796
+ var _comparator$fromIndex;
797
+ formIndex = (_comparator$fromIndex = comparator.fromIndex) !== null && _comparator$fromIndex !== void 0 ? _comparator$fromIndex : 0;
916
798
  comparator = comparator.comparator;
917
799
  }
918
800
  if (typeof comparator === "string") {
919
801
  const key = comparator;
920
- comparator = (element, value2) => element[key] === reactivity.toValue(value2);
802
+ comparator = (element, value$1) => element[key] === reactivity.toValue(value$1);
921
803
  }
922
- comparator = comparator != null ? comparator : (element, value2) => element === reactivity.toValue(value2);
923
- return reactivity.computed(() => reactivity.toValue(list).slice(formIndex).some((element, index, array) => comparator(
924
- reactivity.toValue(element),
925
- reactivity.toValue(value),
926
- index,
927
- reactivity.toValue(array)
928
- )));
804
+ comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value$1) => element === reactivity.toValue(value$1));
805
+ return reactivity.computed(() => reactivity.toValue(list).slice(formIndex).some((element, index, array) => comparator(reactivity.toValue(element), reactivity.toValue(value), index, reactivity.toValue(array))));
929
806
  }
930
807
  // @__NO_SIDE_EFFECTS__
931
808
  function useArrayJoin(list, separator) {
@@ -952,8 +829,7 @@ function uniq(array) {
952
829
  }
953
830
  function uniqueElementsBy(array, fn) {
954
831
  return array.reduce((acc, v) => {
955
- if (!acc.some((x) => fn(v, x, array)))
956
- acc.push(v);
832
+ if (!acc.some((x) => fn(v, x, array))) acc.push(v);
957
833
  return acc;
958
834
  }, []);
959
835
  }
@@ -967,35 +843,43 @@ function useArrayUnique(list, compareFn) {
967
843
  function useCounter(initialValue = 0, options = {}) {
968
844
  let _initialValue = reactivity.unref(initialValue);
969
845
  const count = reactivity.shallowRef(initialValue);
970
- const {
971
- max = Number.POSITIVE_INFINITY,
972
- min = Number.NEGATIVE_INFINITY
973
- } = options;
846
+ const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options;
974
847
  const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
975
848
  const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
976
- const get2 = () => count.value;
977
- const set2 = (val) => count.value = Math.max(min, Math.min(max, val));
849
+ const get$1 = () => count.value;
850
+ const set$1 = (val) => count.value = Math.max(min, Math.min(max, val));
978
851
  const reset = (val = _initialValue) => {
979
852
  _initialValue = val;
980
- return set2(val);
853
+ return set$1(val);
854
+ };
855
+ return {
856
+ count: reactivity.shallowReadonly(count),
857
+ inc,
858
+ dec,
859
+ get: get$1,
860
+ set: set$1,
861
+ reset
981
862
  };
982
- return { count: reactivity.shallowReadonly(count), inc, dec, get: get2, set: set2, reset };
983
863
  }
984
864
  const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
985
865
  const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;
986
866
  function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
987
867
  let m = hours < 12 ? "AM" : "PM";
988
- if (hasPeriod)
989
- m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
868
+ if (hasPeriod) m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
990
869
  return isLowercase ? m.toLowerCase() : m;
991
870
  }
992
871
  function formatOrdinal(num) {
993
- const suffixes = ["th", "st", "nd", "rd"];
872
+ const suffixes = [
873
+ "th",
874
+ "st",
875
+ "nd",
876
+ "rd"
877
+ ];
994
878
  const v = num % 100;
995
879
  return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
996
880
  }
997
881
  function formatDate(date, formatStr, options = {}) {
998
- var _a;
882
+ var _options$customMeridi;
999
883
  const years = date.getFullYear();
1000
884
  const month = date.getMonth();
1001
885
  const days = date.getDate();
@@ -1004,10 +888,10 @@ function formatDate(date, formatStr, options = {}) {
1004
888
  const seconds = date.getSeconds();
1005
889
  const milliseconds = date.getMilliseconds();
1006
890
  const day = date.getDay();
1007
- const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
891
+ const meridiem = (_options$customMeridi = options.customMeridiem) !== null && _options$customMeridi !== void 0 ? _options$customMeridi : defaultMeridiem;
1008
892
  const stripTimeZone = (dateString) => {
1009
- var _a2;
1010
- return (_a2 = dateString.split(" ")[1]) != null ? _a2 : "";
893
+ var _dateString$split$;
894
+ return (_dateString$split$ = dateString.split(" ")[1]) !== null && _dateString$split$ !== void 0 ? _dateString$split$ : "";
1011
895
  };
1012
896
  const matches = {
1013
897
  Yo: () => formatOrdinal(years),
@@ -1048,17 +932,14 @@ function formatDate(date, formatStr, options = {}) {
1048
932
  zzzz: () => stripTimeZone(date.toLocaleDateString(reactivity.toValue(options.locales), { timeZoneName: "longOffset" }))
1049
933
  };
1050
934
  return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1051
- var _a2, _b;
1052
- return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match;
935
+ var _ref, _matches$match;
936
+ return (_ref = $1 !== null && $1 !== void 0 ? $1 : (_matches$match = matches[match]) === null || _matches$match === void 0 ? void 0 : _matches$match.call(matches)) !== null && _ref !== void 0 ? _ref : match;
1053
937
  });
1054
938
  }
1055
939
  function normalizeDate(date) {
1056
- if (date === null)
1057
- return new Date(Number.NaN);
1058
- if (date === void 0)
1059
- return /* @__PURE__ */ new Date();
1060
- if (date instanceof Date)
1061
- return new Date(date);
940
+ if (date === null) return /* @__PURE__ */ new Date(NaN);
941
+ if (date === void 0) return /* @__PURE__ */ new Date();
942
+ if (date instanceof Date) return new Date(date);
1062
943
  if (typeof date === "string" && !/Z$/i.test(date)) {
1063
944
  const d = date.match(REGEX_PARSE);
1064
945
  if (d) {
@@ -1074,10 +955,7 @@ function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1074
955
  return reactivity.computed(() => formatDate(normalizeDate(reactivity.toValue(date)), reactivity.toValue(formatStr), options));
1075
956
  }
1076
957
  function useIntervalFn(cb, interval = 1e3, options = {}) {
1077
- const {
1078
- immediate = true,
1079
- immediateCallback = false
1080
- } = options;
958
+ const { immediate = true, immediateCallback = false } = options;
1081
959
  let timer = null;
1082
960
  const isActive = reactivity.shallowRef(false);
1083
961
  function clean() {
@@ -1092,24 +970,16 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1092
970
  }
1093
971
  function resume() {
1094
972
  const intervalValue = reactivity.toValue(interval);
1095
- if (intervalValue <= 0)
1096
- return;
973
+ if (intervalValue <= 0) return;
1097
974
  isActive.value = true;
1098
- if (immediateCallback)
1099
- cb();
975
+ if (immediateCallback) cb();
1100
976
  clean();
1101
- if (isActive.value)
1102
- timer = setInterval(cb, intervalValue);
1103
- }
1104
- if (immediate && isClient)
1105
- resume();
1106
- if (reactivity.isRef(interval) || typeof interval === "function") {
1107
- const stopWatch = reactivity.watch(interval, () => {
1108
- if (isActive.value && isClient)
1109
- resume();
1110
- });
1111
- tryOnScopeDispose(stopWatch);
977
+ if (isActive.value) timer = setInterval(cb, intervalValue);
1112
978
  }
979
+ if (immediate && isClient) resume();
980
+ if (reactivity.isRef(interval) || typeof interval === "function") tryOnScopeDispose(reactivity.watch(interval, () => {
981
+ if (isActive.value && isClient) resume();
982
+ }));
1113
983
  tryOnScopeDispose(pause);
1114
984
  return {
1115
985
  isActive: reactivity.shallowReadonly(isActive),
@@ -1118,49 +988,31 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1118
988
  };
1119
989
  }
1120
990
  function useInterval(interval = 1e3, options = {}) {
1121
- const {
1122
- controls: exposeControls = false,
1123
- immediate = true,
1124
- callback
1125
- } = options;
991
+ const { controls: exposeControls = false, immediate = true, callback } = options;
1126
992
  const counter = reactivity.shallowRef(0);
1127
993
  const update = () => counter.value += 1;
1128
994
  const reset = () => {
1129
995
  counter.value = 0;
1130
996
  };
1131
- const controls = useIntervalFn(
1132
- callback ? () => {
1133
- update();
1134
- callback(counter.value);
1135
- } : update,
1136
- interval,
1137
- { immediate }
1138
- );
1139
- if (exposeControls) {
1140
- return {
1141
- counter: reactivity.shallowReadonly(counter),
1142
- reset,
1143
- ...controls
1144
- };
1145
- } else {
1146
- return reactivity.shallowReadonly(counter);
1147
- }
997
+ const controls = useIntervalFn(callback ? () => {
998
+ update();
999
+ callback(counter.value);
1000
+ } : update, interval, { immediate });
1001
+ if (exposeControls) return {
1002
+ counter: reactivity.shallowReadonly(counter),
1003
+ reset,
1004
+ ...controls
1005
+ };
1006
+ else return reactivity.shallowReadonly(counter);
1148
1007
  }
1149
1008
  function useLastChanged(source, options = {}) {
1150
- var _a;
1151
- const ms = reactivity.shallowRef((_a = options.initialValue) != null ? _a : null);
1152
- reactivity.watch(
1153
- source,
1154
- () => ms.value = timestamp(),
1155
- options
1156
- );
1009
+ var _options$initialValue;
1010
+ const ms = reactivity.shallowRef((_options$initialValue = options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : null);
1011
+ reactivity.watch(source, () => ms.value = timestamp(), options);
1157
1012
  return reactivity.shallowReadonly(ms);
1158
1013
  }
1159
1014
  function useTimeoutFn(cb, interval, options = {}) {
1160
- const {
1161
- immediate = true,
1162
- immediateCallback = false
1163
- } = options;
1015
+ const { immediate = true, immediateCallback = false } = options;
1164
1016
  const isPending = reactivity.shallowRef(false);
1165
1017
  let timer;
1166
1018
  function clear() {
@@ -1174,8 +1026,7 @@ function useTimeoutFn(cb, interval, options = {}) {
1174
1026
  clear();
1175
1027
  }
1176
1028
  function start(...args) {
1177
- if (immediateCallback)
1178
- cb();
1029
+ if (immediateCallback) cb();
1179
1030
  clear();
1180
1031
  isPending.value = true;
1181
1032
  timer = setTimeout(() => {
@@ -1186,8 +1037,7 @@ function useTimeoutFn(cb, interval, options = {}) {
1186
1037
  }
1187
1038
  if (immediate) {
1188
1039
  isPending.value = true;
1189
- if (isClient)
1190
- start();
1040
+ if (isClient) start();
1191
1041
  }
1192
1042
  tryOnScopeDispose(stop);
1193
1043
  return {
@@ -1197,40 +1047,23 @@ function useTimeoutFn(cb, interval, options = {}) {
1197
1047
  };
1198
1048
  }
1199
1049
  function useTimeout(interval = 1e3, options = {}) {
1200
- const {
1201
- controls: exposeControls = false,
1202
- callback
1203
- } = options;
1204
- const controls = useTimeoutFn(
1205
- callback != null ? callback : noop,
1206
- interval,
1207
- options
1208
- );
1050
+ const { controls: exposeControls = false, callback } = options;
1051
+ const controls = useTimeoutFn(callback !== null && callback !== void 0 ? callback : noop, interval, options);
1209
1052
  const ready = reactivity.computed(() => !controls.isPending.value);
1210
- if (exposeControls) {
1211
- return {
1212
- ready,
1213
- ...controls
1214
- };
1215
- } else {
1216
- return ready;
1217
- }
1053
+ if (exposeControls) return {
1054
+ ready,
1055
+ ...controls
1056
+ };
1057
+ else return ready;
1218
1058
  }
1219
1059
  // @__NO_SIDE_EFFECTS__
1220
1060
  function useToNumber(value, options = {}) {
1221
- const {
1222
- method = "parseFloat",
1223
- radix,
1224
- nanToZero
1225
- } = options;
1061
+ const { method = "parseFloat", radix, nanToZero } = options;
1226
1062
  return reactivity.computed(() => {
1227
1063
  let resolved = reactivity.toValue(value);
1228
- if (typeof method === "function")
1229
- resolved = method(resolved);
1230
- else if (typeof resolved === "string")
1231
- resolved = Number[method](resolved, radix);
1232
- if (nanToZero && Number.isNaN(resolved))
1233
- resolved = 0;
1064
+ if (typeof method === "function") resolved = method(resolved);
1065
+ else if (typeof resolved === "string") resolved = Number[method](resolved, radix);
1066
+ if (nanToZero && Number.isNaN(resolved)) resolved = 0;
1234
1067
  return resolved;
1235
1068
  });
1236
1069
  }
@@ -1240,10 +1073,7 @@ function useToString(value) {
1240
1073
  }
1241
1074
  // @__NO_SIDE_EFFECTS__
1242
1075
  function useToggle(initialValue = false, options = {}) {
1243
- const {
1244
- truthyValue = true,
1245
- falsyValue = false
1246
- } = options;
1076
+ const { truthyValue = true, falsyValue = false } = options;
1247
1077
  const valueIsRef = reactivity.isRef(initialValue);
1248
1078
  const _value = reactivity.shallowRef(initialValue);
1249
1079
  function toggle(value) {
@@ -1256,85 +1086,59 @@ function useToggle(initialValue = false, options = {}) {
1256
1086
  return _value.value;
1257
1087
  }
1258
1088
  }
1259
- if (valueIsRef)
1260
- return toggle;
1261
- else
1262
- return [_value, toggle];
1089
+ if (valueIsRef) return toggle;
1090
+ else return [_value, toggle];
1263
1091
  }
1264
1092
  function watchArray(source, cb, options) {
1265
- let oldList = (options == null ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : reactivity.toValue(source)];
1093
+ let oldList = (options === null || options === void 0 ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : reactivity.toValue(source)];
1266
1094
  return reactivity.watch(source, (newList, _, onCleanup) => {
1267
1095
  const oldListRemains = Array.from({ length: oldList.length });
1268
1096
  const added = [];
1269
1097
  for (const obj of newList) {
1270
1098
  let found = false;
1271
- for (let i = 0; i < oldList.length; i++) {
1272
- if (!oldListRemains[i] && obj === oldList[i]) {
1273
- oldListRemains[i] = true;
1274
- found = true;
1275
- break;
1276
- }
1099
+ for (let i = 0; i < oldList.length; i++) if (!oldListRemains[i] && obj === oldList[i]) {
1100
+ oldListRemains[i] = true;
1101
+ found = true;
1102
+ break;
1277
1103
  }
1278
- if (!found)
1279
- added.push(obj);
1104
+ if (!found) added.push(obj);
1280
1105
  }
1281
- const removed = oldList.filter((_2, i) => !oldListRemains[i]);
1106
+ const removed = oldList.filter((_$1, i) => !oldListRemains[i]);
1282
1107
  cb(newList, oldList, added, removed, onCleanup);
1283
1108
  oldList = [...newList];
1284
1109
  }, options);
1285
1110
  }
1286
1111
  function watchAtMost(source, cb, options) {
1287
- const {
1288
- count,
1289
- ...watchOptions
1290
- } = options;
1112
+ const { count, ...watchOptions } = options;
1291
1113
  const current = reactivity.shallowRef(0);
1292
- const stop = watchWithFilter(
1293
- source,
1294
- (...args) => {
1295
- current.value += 1;
1296
- if (current.value >= reactivity.toValue(count))
1297
- reactivity.nextTick(() => stop());
1298
- cb(...args);
1299
- },
1300
- watchOptions
1301
- );
1302
- return { count: current, stop };
1114
+ const { stop, resume, pause } = watchWithFilter(source, (...args) => {
1115
+ current.value += 1;
1116
+ if (current.value >= reactivity.toValue(count)) reactivity.nextTick(() => stop());
1117
+ cb(...args);
1118
+ }, watchOptions);
1119
+ return {
1120
+ count: current,
1121
+ stop,
1122
+ resume,
1123
+ pause
1124
+ };
1303
1125
  }
1304
1126
  function watchDebounced(source, cb, options = {}) {
1305
- const {
1306
- debounce = 0,
1307
- maxWait = void 0,
1308
- ...watchOptions
1309
- } = options;
1310
- return watchWithFilter(
1311
- source,
1312
- cb,
1313
- {
1314
- ...watchOptions,
1315
- eventFilter: debounceFilter(debounce, { maxWait })
1316
- }
1317
- );
1127
+ const { debounce = 0, maxWait = void 0, ...watchOptions } = options;
1128
+ return watchWithFilter(source, cb, {
1129
+ ...watchOptions,
1130
+ eventFilter: debounceFilter(debounce, { maxWait })
1131
+ });
1318
1132
  }
1319
1133
  function watchDeep(source, cb, options) {
1320
- return reactivity.watch(
1321
- source,
1322
- cb,
1323
- {
1324
- ...options,
1325
- deep: true
1326
- }
1327
- );
1134
+ return reactivity.watch(source, cb, {
1135
+ ...options,
1136
+ deep: true
1137
+ });
1328
1138
  }
1329
1139
  function watchIgnorable(source, cb, options = {}) {
1330
- const {
1331
- eventFilter = bypassFilter,
1332
- ...watchOptions
1333
- } = options;
1334
- const filteredCb = createFilterWrapper(
1335
- eventFilter,
1336
- cb
1337
- );
1140
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
1141
+ const filteredCb = createFilterWrapper(eventFilter, cb);
1338
1142
  let ignoreUpdates;
1339
1143
  let ignorePrevAsyncUpdates;
1340
1144
  let stop;
@@ -1347,14 +1151,9 @@ function watchIgnorable(source, cb, options = {}) {
1347
1151
  updater();
1348
1152
  ignore = false;
1349
1153
  };
1350
- stop = reactivity.watch(
1351
- source,
1352
- (...args) => {
1353
- if (!ignore)
1354
- filteredCb(...args);
1355
- },
1356
- watchOptions
1357
- );
1154
+ stop = reactivity.watch(source, (...args) => {
1155
+ if (!ignore) filteredCb(...args);
1156
+ }, watchOptions);
1358
1157
  } else {
1359
1158
  const disposables = [];
1360
1159
  let ignoreCounter = 0;
@@ -1362,81 +1161,57 @@ function watchIgnorable(source, cb, options = {}) {
1362
1161
  ignorePrevAsyncUpdates = () => {
1363
1162
  ignoreCounter = syncCounter;
1364
1163
  };
1365
- disposables.push(
1366
- reactivity.watch(
1367
- source,
1368
- () => {
1369
- syncCounter++;
1370
- },
1371
- { ...watchOptions, flush: "sync" }
1372
- )
1373
- );
1164
+ disposables.push(reactivity.watch(source, () => {
1165
+ syncCounter++;
1166
+ }, {
1167
+ ...watchOptions,
1168
+ flush: "sync"
1169
+ }));
1374
1170
  ignoreUpdates = (updater) => {
1375
1171
  const syncCounterPrev = syncCounter;
1376
1172
  updater();
1377
1173
  ignoreCounter += syncCounter - syncCounterPrev;
1378
1174
  };
1379
- disposables.push(
1380
- reactivity.watch(
1381
- source,
1382
- (...args) => {
1383
- const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
1384
- ignoreCounter = 0;
1385
- syncCounter = 0;
1386
- if (ignore)
1387
- return;
1388
- filteredCb(...args);
1389
- },
1390
- watchOptions
1391
- )
1392
- );
1175
+ disposables.push(reactivity.watch(source, (...args) => {
1176
+ const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
1177
+ ignoreCounter = 0;
1178
+ syncCounter = 0;
1179
+ if (ignore) return;
1180
+ filteredCb(...args);
1181
+ }, watchOptions));
1393
1182
  stop = () => {
1394
1183
  disposables.forEach((fn) => fn());
1395
1184
  };
1396
1185
  }
1397
- return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
1186
+ return {
1187
+ stop,
1188
+ ignoreUpdates,
1189
+ ignorePrevAsyncUpdates
1190
+ };
1398
1191
  }
1399
1192
  function watchImmediate(source, cb, options) {
1400
- return reactivity.watch(
1401
- source,
1402
- cb,
1403
- {
1404
- ...options,
1405
- immediate: true
1406
- }
1407
- );
1193
+ return reactivity.watch(source, cb, {
1194
+ ...options,
1195
+ immediate: true
1196
+ });
1408
1197
  }
1409
1198
  function watchOnce(source, cb, options) {
1410
- return reactivity.watch(
1411
- source,
1412
- cb,
1413
- {
1414
- ...options,
1415
- once: true
1416
- }
1417
- );
1199
+ return reactivity.watch(source, cb, {
1200
+ ...options,
1201
+ once: true
1202
+ });
1418
1203
  }
1419
1204
  function watchThrottled(source, cb, options = {}) {
1420
- const {
1421
- throttle = 0,
1422
- trailing = true,
1423
- leading = true,
1424
- ...watchOptions
1425
- } = options;
1426
- return watchWithFilter(
1427
- source,
1428
- cb,
1429
- {
1430
- ...watchOptions,
1431
- eventFilter: throttleFilter(throttle, trailing, leading)
1432
- }
1433
- );
1205
+ const { throttle = 0, trailing = true, leading = true, ...watchOptions } = options;
1206
+ return watchWithFilter(source, cb, {
1207
+ ...watchOptions,
1208
+ eventFilter: throttleFilter(throttle, trailing, leading)
1209
+ });
1434
1210
  }
1435
1211
  function watchTriggerable(source, cb, options = {}) {
1436
1212
  let cleanupFn;
1437
1213
  function onEffect() {
1438
- if (!cleanupFn)
1439
- return;
1214
+ if (!cleanupFn) return;
1440
1215
  const fn = cleanupFn;
1441
1216
  cleanupFn = void 0;
1442
1217
  fn();
@@ -1451,11 +1226,11 @@ function watchTriggerable(source, cb, options = {}) {
1451
1226
  const res = watchIgnorable(source, _cb, options);
1452
1227
  const { ignoreUpdates } = res;
1453
1228
  const trigger = () => {
1454
- let res2;
1229
+ let res$1;
1455
1230
  ignoreUpdates(() => {
1456
- res2 = _cb(getWatchSources(source), getOldValue(source));
1231
+ res$1 = _cb(getWatchSources(source), getOldValue(source));
1457
1232
  });
1458
- return res2;
1233
+ return res$1;
1459
1234
  };
1460
1235
  return {
1461
1236
  ...res,
@@ -1463,90 +1238,62 @@ function watchTriggerable(source, cb, options = {}) {
1463
1238
  };
1464
1239
  }
1465
1240
  function getWatchSources(sources) {
1466
- if (reactivity.isReactive(sources))
1467
- return sources;
1468
- if (Array.isArray(sources))
1469
- return sources.map((item) => reactivity.toValue(item));
1241
+ if (reactivity.isReactive(sources)) return sources;
1242
+ if (Array.isArray(sources)) return sources.map((item) => reactivity.toValue(item));
1470
1243
  return reactivity.toValue(sources);
1471
1244
  }
1472
1245
  function getOldValue(source) {
1473
1246
  return Array.isArray(source) ? source.map(() => void 0) : void 0;
1474
1247
  }
1475
1248
  function whenever(source, cb, options) {
1476
- const stop = reactivity.watch(
1477
- source,
1478
- (v, ov, onInvalidate) => {
1479
- if (v) {
1480
- if (options == null ? void 0 : options.once)
1481
- reactivity.nextTick(() => stop());
1482
- cb(v, ov, onInvalidate);
1483
- }
1484
- },
1485
- {
1486
- ...options,
1487
- once: false
1249
+ const stop = reactivity.watch(source, (v, ov, onInvalidate) => {
1250
+ if (v) {
1251
+ if (options === null || options === void 0 ? void 0 : options.once) reactivity.nextTick(() => stop());
1252
+ cb(v, ov, onInvalidate);
1488
1253
  }
1489
- );
1254
+ }, {
1255
+ ...options,
1256
+ once: false
1257
+ });
1490
1258
  return stop;
1491
1259
  }
1492
1260
  function computedAsync(evaluationCallback, initialState, optionsOrRef) {
1493
- var _a;
1261
+ var _globalThis$reportErr;
1494
1262
  let options;
1495
- if (reactivity.isRef(optionsOrRef)) {
1496
- options = {
1497
- evaluating: optionsOrRef
1498
- };
1499
- } else {
1500
- options = optionsOrRef || {};
1501
- }
1502
- const {
1503
- lazy = false,
1504
- flush = "pre",
1505
- evaluating = void 0,
1506
- shallow = true,
1507
- onError = (_a = globalThis.reportError) != null ? _a : noop
1508
- } = options;
1263
+ if (reactivity.isRef(optionsOrRef)) options = { evaluating: optionsOrRef };
1264
+ else options = optionsOrRef || {};
1265
+ const { lazy = false, flush = "sync", evaluating = void 0, shallow = true, onError = (_globalThis$reportErr = globalThis.reportError) !== null && _globalThis$reportErr !== void 0 ? _globalThis$reportErr : noop } = options;
1509
1266
  const started = reactivity.shallowRef(!lazy);
1510
1267
  const current = shallow ? reactivity.shallowRef(initialState) : reactivity.ref(initialState);
1511
1268
  let counter = 0;
1512
1269
  reactivity.watchEffect(async (onInvalidate) => {
1513
- if (!started.value)
1514
- return;
1270
+ if (!started.value) return;
1515
1271
  counter++;
1516
1272
  const counterAtBeginning = counter;
1517
1273
  let hasFinished = false;
1518
- if (evaluating) {
1519
- Promise.resolve().then(() => {
1520
- evaluating.value = true;
1521
- });
1522
- }
1274
+ if (evaluating) Promise.resolve().then(() => {
1275
+ evaluating.value = true;
1276
+ });
1523
1277
  try {
1524
1278
  const result = await evaluationCallback((cancelCallback) => {
1525
1279
  onInvalidate(() => {
1526
- if (evaluating)
1527
- evaluating.value = false;
1528
- if (!hasFinished)
1529
- cancelCallback();
1280
+ if (evaluating) evaluating.value = false;
1281
+ if (!hasFinished) cancelCallback();
1530
1282
  });
1531
1283
  });
1532
- if (counterAtBeginning === counter)
1533
- current.value = result;
1284
+ if (counterAtBeginning === counter) current.value = result;
1534
1285
  } catch (e) {
1535
1286
  onError(e);
1536
1287
  } finally {
1537
- if (evaluating && counterAtBeginning === counter)
1538
- evaluating.value = false;
1288
+ if (evaluating && counterAtBeginning === counter) evaluating.value = false;
1539
1289
  hasFinished = true;
1540
1290
  }
1541
1291
  }, { flush });
1542
- if (lazy) {
1543
- return reactivity.computed(() => {
1544
- started.value = true;
1545
- return current.value;
1546
- });
1547
- } else {
1548
- return current;
1549
- }
1292
+ if (lazy) return reactivity.computed(() => {
1293
+ started.value = true;
1294
+ return current.value;
1295
+ });
1296
+ else return current;
1550
1297
  }
1551
1298
  // @__NO_SIDE_EFFECTS__
1552
1299
  function createUnrefFn(fn) {
@@ -1556,9 +1303,9 @@ function createUnrefFn(fn) {
1556
1303
  }
1557
1304
  const defaultWindow = isClient ? window : void 0;
1558
1305
  function unrefElement(elRef) {
1559
- var _a;
1306
+ var _$el;
1560
1307
  const plain = reactivity.toValue(elRef);
1561
- return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
1308
+ return (_$el = plain === null || plain === void 0 ? void 0 : plain.$el) !== null && _$el !== void 0 ? _$el : plain;
1562
1309
  }
1563
1310
  function useEventListener(...args) {
1564
1311
  const cleanups = [];
@@ -1574,32 +1321,20 @@ function useEventListener(...args) {
1574
1321
  const test = toArray(reactivity.toValue(args[0])).filter((e) => e != null);
1575
1322
  return test.every((e) => typeof e !== "string") ? test : void 0;
1576
1323
  });
1577
- const stopWatch = watchImmediate(
1578
- () => {
1579
- var _a, _b;
1580
- return [
1581
- (_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
1582
- toArray(reactivity.toValue(firstParamTargets.value ? args[1] : args[0])),
1583
- toArray(reactivity.unref(firstParamTargets.value ? args[2] : args[1])),
1584
- // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
1585
- reactivity.toValue(firstParamTargets.value ? args[3] : args[2])
1586
- ];
1587
- },
1588
- ([raw_targets, raw_events, raw_listeners, raw_options]) => {
1589
- cleanup();
1590
- if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
1591
- return;
1592
- const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
1593
- cleanups.push(
1594
- ...raw_targets.flatMap(
1595
- (el) => raw_events.flatMap(
1596
- (event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
1597
- )
1598
- )
1599
- );
1600
- },
1601
- { flush: "post" }
1602
- );
1324
+ const stopWatch = watchImmediate(() => {
1325
+ var _firstParamTargets$va, _firstParamTargets$va2;
1326
+ return [
1327
+ (_firstParamTargets$va = (_firstParamTargets$va2 = firstParamTargets.value) === null || _firstParamTargets$va2 === void 0 ? void 0 : _firstParamTargets$va2.map((e) => unrefElement(e))) !== null && _firstParamTargets$va !== void 0 ? _firstParamTargets$va : [defaultWindow].filter((e) => e != null),
1328
+ toArray(reactivity.toValue(firstParamTargets.value ? args[1] : args[0])),
1329
+ toArray(reactivity.unref(firstParamTargets.value ? args[2] : args[1])),
1330
+ reactivity.toValue(firstParamTargets.value ? args[3] : args[2])
1331
+ ];
1332
+ }, ([raw_targets, raw_events, raw_listeners, raw_options]) => {
1333
+ cleanup();
1334
+ if (!(raw_targets === null || raw_targets === void 0 ? void 0 : raw_targets.length) || !(raw_events === null || raw_events === void 0 ? void 0 : raw_events.length) || !(raw_listeners === null || raw_listeners === void 0 ? void 0 : raw_listeners.length)) return;
1335
+ const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
1336
+ cleanups.push(...raw_targets.flatMap((el) => raw_events.flatMap((event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone)))));
1337
+ }, { flush: "post" });
1603
1338
  const stop = () => {
1604
1339
  stopWatch();
1605
1340
  cleanup();
@@ -1621,53 +1356,48 @@ function useSupported(callback) {
1621
1356
  });
1622
1357
  }
1623
1358
  function useRafFn(fn, options = {}) {
1624
- const {
1625
- immediate = true,
1626
- fpsLimit = void 0,
1627
- window: window2 = defaultWindow,
1628
- once = false
1629
- } = options;
1359
+ const { immediate = true, fpsLimit = void 0, window: window$1 = defaultWindow, once = false } = options;
1630
1360
  const isActive = reactivity.shallowRef(false);
1631
1361
  const intervalLimit = reactivity.computed(() => {
1632
1362
  return fpsLimit ? 1e3 / reactivity.toValue(fpsLimit) : null;
1633
1363
  });
1634
1364
  let previousFrameTimestamp = 0;
1635
1365
  let rafId = null;
1636
- function loop(timestamp2) {
1637
- if (!isActive.value || !window2)
1638
- return;
1639
- if (!previousFrameTimestamp)
1640
- previousFrameTimestamp = timestamp2;
1641
- const delta = timestamp2 - previousFrameTimestamp;
1366
+ function loop(timestamp$1) {
1367
+ if (!isActive.value || !window$1) return;
1368
+ if (!previousFrameTimestamp) previousFrameTimestamp = timestamp$1;
1369
+ const delta = timestamp$1 - previousFrameTimestamp;
1642
1370
  if (intervalLimit.value && delta < intervalLimit.value) {
1643
- rafId = window2.requestAnimationFrame(loop);
1371
+ rafId = window$1.requestAnimationFrame(loop);
1644
1372
  return;
1645
1373
  }
1646
- previousFrameTimestamp = timestamp2;
1647
- fn({ delta, timestamp: timestamp2 });
1374
+ previousFrameTimestamp = timestamp$1;
1375
+ fn({
1376
+ delta,
1377
+ timestamp: timestamp$1
1378
+ });
1648
1379
  if (once) {
1649
1380
  isActive.value = false;
1650
1381
  rafId = null;
1651
1382
  return;
1652
1383
  }
1653
- rafId = window2.requestAnimationFrame(loop);
1384
+ rafId = window$1.requestAnimationFrame(loop);
1654
1385
  }
1655
1386
  function resume() {
1656
- if (!isActive.value && window2) {
1387
+ if (!isActive.value && window$1) {
1657
1388
  isActive.value = true;
1658
1389
  previousFrameTimestamp = 0;
1659
- rafId = window2.requestAnimationFrame(loop);
1390
+ rafId = window$1.requestAnimationFrame(loop);
1660
1391
  }
1661
1392
  }
1662
1393
  function pause() {
1663
1394
  isActive.value = false;
1664
- if (rafId != null && window2) {
1665
- window2.cancelAnimationFrame(rafId);
1395
+ if (rafId != null && window$1) {
1396
+ window$1.cancelAnimationFrame(rafId);
1666
1397
  rafId = null;
1667
1398
  }
1668
1399
  }
1669
- if (immediate)
1670
- resume();
1400
+ if (immediate) resume();
1671
1401
  tryOnScopeDispose(pause);
1672
1402
  return {
1673
1403
  isActive: reactivity.readonly(isActive),
@@ -1676,20 +1406,17 @@ function useRafFn(fn, options = {}) {
1676
1406
  };
1677
1407
  }
1678
1408
  function useAsyncQueue(tasks, options) {
1679
- const {
1680
- interrupt = true,
1681
- onError = noop,
1682
- onFinished = noop,
1683
- signal
1684
- } = options || {};
1409
+ const { interrupt = true, onError = noop, onFinished = noop, signal } = options || {};
1685
1410
  const promiseState = {
1686
1411
  aborted: "aborted",
1687
1412
  fulfilled: "fulfilled",
1688
1413
  pending: "pending",
1689
1414
  rejected: "rejected"
1690
1415
  };
1691
- const initialResult = Array.from(Array.from({ length: tasks.length }), () => ({ state: promiseState.pending, data: null }));
1692
- const result = reactivity.reactive(initialResult);
1416
+ const result = reactivity.reactive(Array.from(Array.from({ length: tasks.length }), () => ({
1417
+ state: promiseState.pending,
1418
+ data: null
1419
+ })));
1693
1420
  const activeIndex = reactivity.shallowRef(-1);
1694
1421
  if (!tasks || tasks.length === 0) {
1695
1422
  onFinished();
@@ -1705,26 +1432,24 @@ function useAsyncQueue(tasks, options) {
1705
1432
  }
1706
1433
  tasks.reduce((prev, curr) => {
1707
1434
  return prev.then((prevRes) => {
1708
- var _a;
1709
- if (signal == null ? void 0 : signal.aborted) {
1710
- updateResult(promiseState.aborted, new Error("aborted"));
1435
+ var _result$activeIndex$v;
1436
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
1437
+ updateResult(promiseState.aborted, /* @__PURE__ */ new Error("aborted"));
1711
1438
  return;
1712
1439
  }
1713
- if (((_a = result[activeIndex.value]) == null ? void 0 : _a.state) === promiseState.rejected && interrupt) {
1440
+ if (((_result$activeIndex$v = result[activeIndex.value]) === null || _result$activeIndex$v === void 0 ? void 0 : _result$activeIndex$v.state) === promiseState.rejected && interrupt) {
1714
1441
  onFinished();
1715
1442
  return;
1716
1443
  }
1717
1444
  const done = curr(prevRes).then((currentRes) => {
1718
1445
  updateResult(promiseState.fulfilled, currentRes);
1719
- if (activeIndex.value === tasks.length - 1)
1720
- onFinished();
1446
+ if (activeIndex.value === tasks.length - 1) onFinished();
1721
1447
  return currentRes;
1722
1448
  });
1723
- if (!signal)
1724
- return done;
1449
+ if (!signal) return done;
1725
1450
  return Promise.race([done, whenAborted(signal)]);
1726
1451
  }).catch((e) => {
1727
- if (signal == null ? void 0 : signal.aborted) {
1452
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
1728
1453
  updateResult(promiseState.aborted, e);
1729
1454
  return e;
1730
1455
  }
@@ -1740,55 +1465,44 @@ function useAsyncQueue(tasks, options) {
1740
1465
  }
1741
1466
  function whenAborted(signal) {
1742
1467
  return new Promise((resolve, reject) => {
1743
- const error = new Error("aborted");
1744
- if (signal.aborted)
1745
- reject(error);
1746
- else
1747
- signal.addEventListener("abort", () => reject(error), { once: true });
1468
+ const error = /* @__PURE__ */ new Error("aborted");
1469
+ if (signal.aborted) reject(error);
1470
+ else signal.addEventListener("abort", () => reject(error), { once: true });
1748
1471
  });
1749
1472
  }
1750
1473
  function useAsyncState(promise, initialState, options) {
1751
- var _a;
1752
- const {
1753
- immediate = true,
1754
- delay = 0,
1755
- onError = (_a = globalThis.reportError) != null ? _a : noop,
1756
- onSuccess = noop,
1757
- resetOnExecute = true,
1758
- shallow = true,
1759
- throwError
1760
- } = options != null ? options : {};
1474
+ var _globalThis$reportErr;
1475
+ const { immediate = true, delay = 0, onError = (_globalThis$reportErr = globalThis.reportError) !== null && _globalThis$reportErr !== void 0 ? _globalThis$reportErr : noop, onSuccess = noop, resetOnExecute = true, shallow = true, throwError } = options !== null && options !== void 0 ? options : {};
1761
1476
  const state = shallow ? reactivity.shallowRef(initialState) : reactivity.ref(initialState);
1762
1477
  const isReady = reactivity.shallowRef(false);
1763
1478
  const isLoading = reactivity.shallowRef(false);
1764
1479
  const error = reactivity.shallowRef(void 0);
1765
- async function execute(delay2 = 0, ...args) {
1766
- if (resetOnExecute)
1767
- state.value = reactivity.toValue(initialState);
1480
+ let executionsCount = 0;
1481
+ async function execute(delay$1 = 0, ...args) {
1482
+ const executionId = executionsCount += 1;
1483
+ if (resetOnExecute) state.value = reactivity.toValue(initialState);
1768
1484
  error.value = void 0;
1769
1485
  isReady.value = false;
1770
1486
  isLoading.value = true;
1771
- if (delay2 > 0)
1772
- await promiseTimeout(delay2);
1487
+ if (delay$1 > 0) await promiseTimeout(delay$1);
1773
1488
  const _promise = typeof promise === "function" ? promise(...args) : promise;
1774
1489
  try {
1775
1490
  const data = await _promise;
1776
- state.value = data;
1777
- isReady.value = true;
1491
+ if (executionId === executionsCount) {
1492
+ state.value = data;
1493
+ isReady.value = true;
1494
+ }
1778
1495
  onSuccess(data);
1779
1496
  } catch (e) {
1780
- error.value = e;
1497
+ if (executionId === executionsCount) error.value = e;
1781
1498
  onError(e);
1782
- if (throwError)
1783
- throw e;
1499
+ if (throwError) throw e;
1784
1500
  } finally {
1785
- isLoading.value = false;
1501
+ if (executionId === executionsCount) isLoading.value = false;
1786
1502
  }
1787
1503
  return state.value;
1788
1504
  }
1789
- if (immediate) {
1790
- execute(delay);
1791
- }
1505
+ if (immediate) execute(delay);
1792
1506
  const shell = {
1793
1507
  state,
1794
1508
  isReady,
@@ -1817,37 +1531,26 @@ const defaults = {
1817
1531
  null: () => ""
1818
1532
  };
1819
1533
  function getDefaultSerialization(target) {
1820
- if (!target)
1821
- return defaults.null;
1822
- if (target instanceof Map)
1823
- return defaults.map;
1824
- else if (target instanceof Set)
1825
- return defaults.set;
1826
- else if (Array.isArray(target))
1827
- return defaults.array;
1828
- else
1829
- return defaults.object;
1534
+ if (!target) return defaults.null;
1535
+ if (target instanceof Map) return defaults.map;
1536
+ else if (target instanceof Set) return defaults.set;
1537
+ else if (Array.isArray(target)) return defaults.array;
1538
+ else return defaults.object;
1830
1539
  }
1831
1540
  function useBase64(target, options) {
1832
1541
  const base64 = reactivity.shallowRef("");
1833
1542
  const promise = reactivity.shallowRef();
1834
1543
  function execute() {
1835
- if (!isClient)
1836
- return;
1544
+ if (!isClient) return;
1837
1545
  promise.value = new Promise((resolve, reject) => {
1838
1546
  try {
1839
1547
  const _target = reactivity.toValue(target);
1840
- if (_target == null) {
1841
- resolve("");
1842
- } else if (typeof _target === "string") {
1843
- resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
1844
- } else if (_target instanceof Blob) {
1845
- resolve(blobToBase64(_target));
1846
- } else if (_target instanceof ArrayBuffer) {
1847
- resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
1848
- } else if (_target instanceof HTMLCanvasElement) {
1849
- resolve(_target.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
1850
- } else if (_target instanceof HTMLImageElement) {
1548
+ if (_target == null) resolve("");
1549
+ else if (typeof _target === "string") resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
1550
+ else if (_target instanceof Blob) resolve(blobToBase64(_target));
1551
+ else if (_target instanceof ArrayBuffer) resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
1552
+ else if (_target instanceof HTMLCanvasElement) resolve(_target.toDataURL(options === null || options === void 0 ? void 0 : options.type, options === null || options === void 0 ? void 0 : options.quality));
1553
+ else if (_target instanceof HTMLImageElement) {
1851
1554
  const img = _target.cloneNode(false);
1852
1555
  img.crossOrigin = "Anonymous";
1853
1556
  imgLoaded(img).then(() => {
@@ -1856,28 +1559,23 @@ function useBase64(target, options) {
1856
1559
  canvas.width = img.width;
1857
1560
  canvas.height = img.height;
1858
1561
  ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
1859
- resolve(canvas.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
1562
+ resolve(canvas.toDataURL(options === null || options === void 0 ? void 0 : options.type, options === null || options === void 0 ? void 0 : options.quality));
1860
1563
  }).catch(reject);
1861
1564
  } else if (typeof _target === "object") {
1862
- const _serializeFn = (options == null ? void 0 : options.serializer) || getDefaultSerialization(_target);
1863
- const serialized = _serializeFn(_target);
1565
+ const serialized = ((options === null || options === void 0 ? void 0 : options.serializer) || getDefaultSerialization(_target))(_target);
1864
1566
  return resolve(blobToBase64(new Blob([serialized], { type: "application/json" })));
1865
- } else {
1866
- reject(new Error("target is unsupported types"));
1867
- }
1567
+ } else reject(/* @__PURE__ */ new Error("target is unsupported types"));
1868
1568
  } catch (error) {
1869
1569
  reject(error);
1870
1570
  }
1871
1571
  });
1872
1572
  promise.value.then((res) => {
1873
- base64.value = (options == null ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
1573
+ base64.value = (options === null || options === void 0 ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
1874
1574
  });
1875
1575
  return promise.value;
1876
1576
  }
1877
- if (reactivity.isRef(target) || typeof target === "function")
1878
- reactivity.watch(target, execute, { immediate: true });
1879
- else
1880
- execute();
1577
+ if (reactivity.isRef(target) || typeof target === "function") reactivity.watch(target, execute, { immediate: true });
1578
+ else execute();
1881
1579
  return {
1882
1580
  base64,
1883
1581
  promise,
@@ -1891,9 +1589,7 @@ function imgLoaded(img) {
1891
1589
  resolve();
1892
1590
  };
1893
1591
  img.onerror = reject;
1894
- } else {
1895
- resolve();
1896
- }
1592
+ } else resolve();
1897
1593
  });
1898
1594
  }
1899
1595
  function blobToBase64(blob) {
@@ -1907,42 +1603,33 @@ function blobToBase64(blob) {
1907
1603
  });
1908
1604
  }
1909
1605
  function useBroadcastChannel(options) {
1910
- const {
1911
- name,
1912
- window: window2 = defaultWindow
1913
- } = options;
1914
- const isSupported = /* @__PURE__ */ useSupported(() => window2 && "BroadcastChannel" in window2);
1606
+ const { name, window: window$1 = defaultWindow } = options;
1607
+ const isSupported = /* @__PURE__ */ useSupported(() => window$1 && "BroadcastChannel" in window$1);
1915
1608
  const isClosed = reactivity.shallowRef(false);
1916
1609
  const channel = reactivity.ref();
1917
1610
  const data = reactivity.ref();
1918
1611
  const error = reactivity.shallowRef(null);
1919
- const post = (data2) => {
1920
- if (channel.value)
1921
- channel.value.postMessage(data2);
1612
+ const post = (data$1) => {
1613
+ if (channel.value) channel.value.postMessage(data$1);
1922
1614
  };
1923
1615
  const close = () => {
1924
- if (channel.value)
1925
- channel.value.close();
1616
+ if (channel.value) channel.value.close();
1926
1617
  isClosed.value = true;
1927
1618
  };
1928
- if (isSupported.value) {
1929
- tryOnMounted(() => {
1930
- error.value = null;
1931
- channel.value = new BroadcastChannel(name);
1932
- const listenerOptions = {
1933
- passive: true
1934
- };
1935
- useEventListener(channel, "message", (e) => {
1936
- data.value = e.data;
1937
- }, listenerOptions);
1938
- useEventListener(channel, "messageerror", (e) => {
1939
- error.value = e;
1940
- }, listenerOptions);
1941
- useEventListener(channel, "close", () => {
1942
- isClosed.value = true;
1943
- }, listenerOptions);
1944
- });
1945
- }
1619
+ if (isSupported.value) tryOnMounted(() => {
1620
+ error.value = null;
1621
+ channel.value = new BroadcastChannel(name);
1622
+ const listenerOptions = { passive: true };
1623
+ useEventListener(channel, "message", (e) => {
1624
+ data.value = e.data;
1625
+ }, listenerOptions);
1626
+ useEventListener(channel, "messageerror", (e) => {
1627
+ error.value = e;
1628
+ }, listenerOptions);
1629
+ useEventListener(channel, "close", () => {
1630
+ isClosed.value = true;
1631
+ }, listenerOptions);
1632
+ });
1946
1633
  tryOnScopeDispose(() => {
1947
1634
  close();
1948
1635
  });
@@ -1960,8 +1647,7 @@ function useCached(refValue, comparator = (a, b) => a === b, options) {
1960
1647
  const { deepRefs = true, ...watchOptions } = options || {};
1961
1648
  const cachedValue = /* @__PURE__ */ createRef(refValue.value, deepRefs);
1962
1649
  reactivity.watch(() => refValue.value, (value) => {
1963
- if (!comparator(value, cachedValue.value))
1964
- cachedValue.value = value;
1650
+ if (!comparator(value, cachedValue.value)) cachedValue.value = value;
1965
1651
  }, watchOptions);
1966
1652
  return cachedValue;
1967
1653
  }
@@ -1972,13 +1658,7 @@ function useCloned(source, options = {}) {
1972
1658
  const cloned = reactivity.ref({});
1973
1659
  const isModified = reactivity.shallowRef(false);
1974
1660
  let _lastSync = false;
1975
- const {
1976
- manual,
1977
- clone = cloneFnJSON,
1978
- // watch options
1979
- deep = true,
1980
- immediate = true
1981
- } = options;
1661
+ const { manual, clone = cloneFnJSON, deep = true, immediate = true } = options;
1982
1662
  reactivity.watch(cloned, () => {
1983
1663
  if (_lastSync) {
1984
1664
  _lastSync = false;
@@ -1994,28 +1674,28 @@ function useCloned(source, options = {}) {
1994
1674
  isModified.value = false;
1995
1675
  cloned.value = clone(reactivity.toValue(source));
1996
1676
  }
1997
- if (!manual && (reactivity.isRef(source) || typeof source === "function")) {
1998
- reactivity.watch(source, sync, {
1999
- ...options,
2000
- deep,
2001
- immediate
2002
- });
2003
- } else {
2004
- sync();
2005
- }
2006
- return { cloned, isModified, sync };
1677
+ if (!manual && (reactivity.isRef(source) || typeof source === "function")) reactivity.watch(source, sync, {
1678
+ ...options,
1679
+ deep,
1680
+ immediate
1681
+ });
1682
+ else sync();
1683
+ return {
1684
+ cloned,
1685
+ isModified,
1686
+ sync
1687
+ };
2007
1688
  }
2008
1689
  function useCycleList(list, options) {
2009
1690
  const state = reactivity.shallowRef(getInitialValue());
2010
1691
  const listRef = toRef(list);
2011
1692
  const index = reactivity.computed({
2012
1693
  get() {
2013
- var _a;
1694
+ var _options$fallbackInde;
2014
1695
  const targetList = listRef.value;
2015
- let index2 = (options == null ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
2016
- if (index2 < 0)
2017
- index2 = (_a = options == null ? void 0 : options.fallbackIndex) != null ? _a : 0;
2018
- return index2;
1696
+ let index$1 = (options === null || options === void 0 ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
1697
+ if (index$1 < 0) index$1 = (_options$fallbackInde = options === null || options === void 0 ? void 0 : options.fallbackIndex) !== null && _options$fallbackInde !== void 0 ? _options$fallbackInde : 0;
1698
+ return index$1;
2019
1699
  },
2020
1700
  set(v) {
2021
1701
  set2(v);
@@ -2024,8 +1704,7 @@ function useCycleList(list, options) {
2024
1704
  function set2(i) {
2025
1705
  const targetList = listRef.value;
2026
1706
  const length = targetList.length;
2027
- const index2 = (i % length + length) % length;
2028
- const value = targetList[index2];
1707
+ const value = targetList[(i % length + length) % length];
2029
1708
  state.value = value;
2030
1709
  return value;
2031
1710
  }
@@ -2039,8 +1718,8 @@ function useCycleList(list, options) {
2039
1718
  return shift(-n);
2040
1719
  }
2041
1720
  function getInitialValue() {
2042
- var _a, _b;
2043
- return (_b = reactivity.toValue((_a = options == null ? void 0 : options.initialValue) != null ? _a : reactivity.toValue(list)[0])) != null ? _b : void 0;
1721
+ var _toValue, _options$initialValue;
1722
+ return (_toValue = reactivity.toValue((_options$initialValue = options === null || options === void 0 ? void 0 : options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : reactivity.toValue(list)[0])) !== null && _toValue !== void 0 ? _toValue : void 0;
2044
1723
  }
2045
1724
  reactivity.watch(listRef, () => set2(index.value));
2046
1725
  return {
@@ -2064,12 +1743,7 @@ function defaultParse(clone) {
2064
1743
  return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
2065
1744
  }
2066
1745
  function useManualRefHistory(source, options = {}) {
2067
- const {
2068
- clone = false,
2069
- dump = defaultDump(clone),
2070
- parse = defaultParse(clone),
2071
- setSource = fnSetSource
2072
- } = options;
1746
+ const { clone = false, dump = defaultDump(clone), parse = defaultParse(clone), setSource = fnSetSource } = options;
2073
1747
  function _createHistoryRecord() {
2074
1748
  return reactivity.markRaw({
2075
1749
  snapshot: dump(source.value),
@@ -2086,10 +1760,8 @@ function useManualRefHistory(source, options = {}) {
2086
1760
  const commit = () => {
2087
1761
  undoStack.value.unshift(last.value);
2088
1762
  last.value = _createHistoryRecord();
2089
- if (options.capacity && undoStack.value.length > options.capacity)
2090
- undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY);
2091
- if (redoStack.value.length)
2092
- redoStack.value.splice(0, redoStack.value.length);
1763
+ if (options.capacity && undoStack.value.length > options.capacity) undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY);
1764
+ if (redoStack.value.length) redoStack.value.splice(0, redoStack.value.length);
2093
1765
  };
2094
1766
  const clear = () => {
2095
1767
  undoStack.value.splice(0, undoStack.value.length);
@@ -2112,17 +1784,14 @@ function useManualRefHistory(source, options = {}) {
2112
1784
  const reset = () => {
2113
1785
  _setSource(last.value);
2114
1786
  };
2115
- const history = reactivity.computed(() => [last.value, ...undoStack.value]);
2116
- const canUndo = reactivity.computed(() => undoStack.value.length > 0);
2117
- const canRedo = reactivity.computed(() => redoStack.value.length > 0);
2118
1787
  return {
2119
1788
  source,
2120
1789
  undoStack,
2121
1790
  redoStack,
2122
1791
  last,
2123
- history,
2124
- canUndo,
2125
- canRedo,
1792
+ history: reactivity.computed(() => [last.value, ...undoStack.value]),
1793
+ canUndo: reactivity.computed(() => undoStack.value.length > 0),
1794
+ canRedo: reactivity.computed(() => redoStack.value.length > 0),
2126
1795
  clear,
2127
1796
  commit,
2128
1797
  reset,
@@ -2131,48 +1800,36 @@ function useManualRefHistory(source, options = {}) {
2131
1800
  };
2132
1801
  }
2133
1802
  function useRefHistory(source, options = {}) {
2134
- const {
2135
- deep = false,
2136
- flush = "pre",
2137
- eventFilter,
2138
- shouldCommit = () => true
2139
- } = options;
2140
- const {
2141
- eventFilter: composedFilter,
2142
- pause,
2143
- resume: resumeTracking,
2144
- isActive: isTracking
2145
- } = pausableFilter(eventFilter);
1803
+ const { deep = false, flush = "pre", eventFilter, shouldCommit = () => true } = options;
1804
+ const { eventFilter: composedFilter, pause, resume: resumeTracking, isActive: isTracking } = pausableFilter(eventFilter);
2146
1805
  let lastRawValue = source.value;
2147
- const {
2148
- ignoreUpdates,
2149
- ignorePrevAsyncUpdates,
2150
- stop
2151
- } = watchIgnorable(
2152
- source,
2153
- commit,
2154
- { deep, flush, eventFilter: composedFilter }
2155
- );
2156
- function setSource(source2, value) {
1806
+ const { ignoreUpdates, ignorePrevAsyncUpdates, stop } = watchIgnorable(source, commit, {
1807
+ deep,
1808
+ flush,
1809
+ eventFilter: composedFilter
1810
+ });
1811
+ function setSource(source$1, value) {
2157
1812
  ignorePrevAsyncUpdates();
2158
1813
  ignoreUpdates(() => {
2159
- source2.value = value;
1814
+ source$1.value = value;
2160
1815
  lastRawValue = value;
2161
1816
  });
2162
1817
  }
2163
- const manualHistory = useManualRefHistory(source, { ...options, clone: options.clone || deep, setSource });
1818
+ const manualHistory = useManualRefHistory(source, {
1819
+ ...options,
1820
+ clone: options.clone || deep,
1821
+ setSource
1822
+ });
2164
1823
  const { clear, commit: manualCommit } = manualHistory;
2165
1824
  function commit() {
2166
1825
  ignorePrevAsyncUpdates();
2167
- if (!shouldCommit(lastRawValue, source.value))
2168
- return;
1826
+ if (!shouldCommit(lastRawValue, source.value)) return;
2169
1827
  lastRawValue = source.value;
2170
1828
  manualCommit();
2171
1829
  }
2172
1830
  function resume(commitNow) {
2173
1831
  resumeTracking();
2174
- if (commitNow)
2175
- commit();
1832
+ if (commitNow) commit();
2176
1833
  }
2177
1834
  function batch(fn) {
2178
1835
  let canceled = false;
@@ -2180,8 +1837,7 @@ function useRefHistory(source, options = {}) {
2180
1837
  ignoreUpdates(() => {
2181
1838
  fn(cancel);
2182
1839
  });
2183
- if (!canceled)
2184
- commit();
1840
+ if (!canceled) commit();
2185
1841
  }
2186
1842
  function dispose() {
2187
1843
  stop();
@@ -2199,22 +1855,22 @@ function useRefHistory(source, options = {}) {
2199
1855
  }
2200
1856
  function useDebouncedRefHistory(source, options = {}) {
2201
1857
  const filter = options.debounce ? debounceFilter(options.debounce) : void 0;
2202
- const history = useRefHistory(source, { ...options, eventFilter: filter });
2203
- return {
2204
- ...history
2205
- };
1858
+ return { ...useRefHistory(source, {
1859
+ ...options,
1860
+ eventFilter: filter
1861
+ }) };
2206
1862
  }
2207
1863
  const events = /* @__PURE__ */ new Map();
2208
1864
  // @__NO_SIDE_EFFECTS__
2209
1865
  function useEventBus(key) {
2210
1866
  const scope = reactivity.getCurrentScope();
2211
1867
  function on(listener) {
2212
- var _a;
1868
+ var _scope$cleanups;
2213
1869
  const listeners = events.get(key) || /* @__PURE__ */ new Set();
2214
1870
  listeners.add(listener);
2215
1871
  events.set(key, listeners);
2216
1872
  const _off = () => off(listener);
2217
- (_a = scope == null ? void 0 : scope.cleanups) == null ? void 0 : _a.push(_off);
1873
+ scope === null || scope === void 0 || (_scope$cleanups = scope.cleanups) === null || _scope$cleanups === void 0 || _scope$cleanups.push(_off);
2218
1874
  return _off;
2219
1875
  }
2220
1876
  function once(listener) {
@@ -2226,20 +1882,24 @@ function useEventBus(key) {
2226
1882
  }
2227
1883
  function off(listener) {
2228
1884
  const listeners = events.get(key);
2229
- if (!listeners)
2230
- return;
1885
+ if (!listeners) return;
2231
1886
  listeners.delete(listener);
2232
- if (!listeners.size)
2233
- reset();
1887
+ if (!listeners.size) reset();
2234
1888
  }
2235
1889
  function reset() {
2236
1890
  events.delete(key);
2237
1891
  }
2238
1892
  function emit(event, payload) {
2239
- var _a;
2240
- (_a = events.get(key)) == null ? void 0 : _a.forEach((v) => v(event, payload));
1893
+ var _events$get;
1894
+ (_events$get = events.get(key)) === null || _events$get === void 0 || _events$get.forEach((v) => v(event, payload));
2241
1895
  }
2242
- return { on, once, off, emit, reset };
1896
+ return {
1897
+ on,
1898
+ once,
1899
+ off,
1900
+ emit,
1901
+ reset
1902
+ };
2243
1903
  }
2244
1904
  const payloadMapping = {
2245
1905
  json: "application/json",
@@ -2253,33 +1913,29 @@ function isAbsoluteURL(url) {
2253
1913
  return reAbsolute.test(url);
2254
1914
  }
2255
1915
  function headersToObject(headers) {
2256
- if (typeof Headers !== "undefined" && headers instanceof Headers)
2257
- return Object.fromEntries(headers.entries());
1916
+ if (typeof Headers !== "undefined" && headers instanceof Headers) return Object.fromEntries(headers.entries());
2258
1917
  return headers;
2259
1918
  }
2260
1919
  function combineCallbacks(combination, ...callbacks) {
2261
- if (combination === "overwrite") {
2262
- return async (ctx) => {
2263
- let callback;
2264
- for (let i = callbacks.length - 1; i >= 0; i--) {
2265
- if (callbacks[i] != null) {
2266
- callback = callbacks[i];
2267
- break;
2268
- }
2269
- }
2270
- if (callback)
2271
- return { ...ctx, ...await callback(ctx) };
2272
- return ctx;
1920
+ if (combination === "overwrite") return async (ctx) => {
1921
+ let callback;
1922
+ for (let i = callbacks.length - 1; i >= 0; i--) if (callbacks[i] != null) {
1923
+ callback = callbacks[i];
1924
+ break;
1925
+ }
1926
+ if (callback) return {
1927
+ ...ctx,
1928
+ ...await callback(ctx)
2273
1929
  };
2274
- } else {
2275
- return async (ctx) => {
2276
- for (const callback of callbacks) {
2277
- if (callback)
2278
- ctx = { ...ctx, ...await callback(ctx) };
2279
- }
2280
- return ctx;
1930
+ return ctx;
1931
+ };
1932
+ else return async (ctx) => {
1933
+ for (const callback of callbacks) if (callback) ctx = {
1934
+ ...ctx,
1935
+ ...await callback(ctx)
2281
1936
  };
2282
- }
1937
+ return ctx;
1938
+ };
2283
1939
  }
2284
1940
  function createFetch(config = {}) {
2285
1941
  const _combination = config.combination || "chain";
@@ -2293,41 +1949,34 @@ function createFetch(config = {}) {
2293
1949
  });
2294
1950
  let options = _options;
2295
1951
  let fetchOptions = _fetchOptions;
2296
- if (args.length > 0) {
2297
- if (isFetchOptions(args[0])) {
2298
- options = {
2299
- ...options,
2300
- ...args[0],
2301
- beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
2302
- afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
2303
- onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
2304
- };
2305
- } else {
2306
- fetchOptions = {
2307
- ...fetchOptions,
2308
- ...args[0],
2309
- headers: {
2310
- ...headersToObject(fetchOptions.headers) || {},
2311
- ...headersToObject(args[0].headers) || {}
2312
- }
2313
- };
1952
+ if (args.length > 0) if (isFetchOptions(args[0])) options = {
1953
+ ...options,
1954
+ ...args[0],
1955
+ beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
1956
+ afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
1957
+ onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
1958
+ };
1959
+ else fetchOptions = {
1960
+ ...fetchOptions,
1961
+ ...args[0],
1962
+ headers: {
1963
+ ...headersToObject(fetchOptions.headers) || {},
1964
+ ...headersToObject(args[0].headers) || {}
2314
1965
  }
2315
- }
2316
- if (args.length > 1 && isFetchOptions(args[1])) {
2317
- options = {
2318
- ...options,
2319
- ...args[1],
2320
- beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
2321
- afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
2322
- onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
2323
- };
2324
- }
1966
+ };
1967
+ if (args.length > 1 && isFetchOptions(args[1])) options = {
1968
+ ...options,
1969
+ ...args[1],
1970
+ beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
1971
+ afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
1972
+ onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
1973
+ };
2325
1974
  return useFetch(computedUrl, fetchOptions, options);
2326
1975
  }
2327
1976
  return useFactoryFetch;
2328
1977
  }
2329
1978
  function useFetch(url, ...args) {
2330
- var _a, _b;
1979
+ var _defaultWindow$fetch, _globalThis;
2331
1980
  const supportsAbort = typeof AbortController === "function";
2332
1981
  let fetchOptions = {};
2333
1982
  let options = {
@@ -2341,21 +1990,18 @@ function useFetch(url, ...args) {
2341
1990
  type: "text",
2342
1991
  payload: void 0
2343
1992
  };
2344
- if (args.length > 0) {
2345
- if (isFetchOptions(args[0]))
2346
- options = { ...options, ...args[0] };
2347
- else
2348
- fetchOptions = args[0];
2349
- }
1993
+ if (args.length > 0) if (isFetchOptions(args[0])) options = {
1994
+ ...options,
1995
+ ...args[0]
1996
+ };
1997
+ else fetchOptions = args[0];
2350
1998
  if (args.length > 1) {
2351
- if (isFetchOptions(args[1]))
2352
- options = { ...options, ...args[1] };
2353
- }
2354
- const {
2355
- fetch = (_b = (_a = defaultWindow) == null ? void 0 : _a.fetch) != null ? _b : globalThis == null ? void 0 : globalThis.fetch,
2356
- initialData,
2357
- timeout
2358
- } = options;
1999
+ if (isFetchOptions(args[1])) options = {
2000
+ ...options,
2001
+ ...args[1]
2002
+ };
2003
+ }
2004
+ const { fetch = (_defaultWindow$fetch = defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.fetch) !== null && _defaultWindow$fetch !== void 0 ? _defaultWindow$fetch : (_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.fetch, initialData, timeout } = options;
2359
2005
  const responseEvent = /* @__PURE__ */ createEventHook();
2360
2006
  const errorEvent = /* @__PURE__ */ createEventHook();
2361
2007
  const finallyEvent = /* @__PURE__ */ createEventHook();
@@ -2371,7 +2017,7 @@ function useFetch(url, ...args) {
2371
2017
  let timer;
2372
2018
  const abort = (reason) => {
2373
2019
  if (supportsAbort) {
2374
- controller == null ? void 0 : controller.abort(reason);
2020
+ controller === null || controller === void 0 || controller.abort(reason);
2375
2021
  controller = new AbortController();
2376
2022
  controller.signal.onabort = () => aborted.value = true;
2377
2023
  fetchOptions = {
@@ -2384,11 +2030,10 @@ function useFetch(url, ...args) {
2384
2030
  isFetching.value = isLoading;
2385
2031
  isFinished.value = !isLoading;
2386
2032
  };
2387
- if (timeout)
2388
- timer = useTimeoutFn(abort, timeout, { immediate: false });
2033
+ if (timeout) timer = useTimeoutFn(abort, timeout, { immediate: false });
2389
2034
  let executeCounter = 0;
2390
2035
  const execute = async (throwOnFailed = false) => {
2391
- var _a2, _b2;
2036
+ var _context$options;
2392
2037
  abort();
2393
2038
  loading(true);
2394
2039
  error.value = null;
@@ -2402,12 +2047,11 @@ function useFetch(url, ...args) {
2402
2047
  };
2403
2048
  const payload = reactivity.toValue(config.payload);
2404
2049
  if (payload) {
2050
+ var _payloadMapping$confi;
2405
2051
  const headers = headersToObject(defaultFetchOptions.headers);
2406
2052
  const proto = Object.getPrototypeOf(payload);
2407
- if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData))
2408
- config.payloadType = "json";
2409
- if (config.payloadType)
2410
- headers["Content-Type"] = (_a2 = payloadMapping[config.payloadType]) != null ? _a2 : config.payloadType;
2053
+ if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData)) config.payloadType = "json";
2054
+ if (config.payloadType) headers["Content-Type"] = (_payloadMapping$confi = payloadMapping[config.payloadType]) !== null && _payloadMapping$confi !== void 0 ? _payloadMapping$confi : config.payloadType;
2411
2055
  defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload;
2412
2056
  }
2413
2057
  let isCanceled = false;
@@ -2421,26 +2065,21 @@ function useFetch(url, ...args) {
2421
2065
  isCanceled = true;
2422
2066
  }
2423
2067
  };
2424
- if (options.beforeFetch)
2425
- Object.assign(context, await options.beforeFetch(context));
2068
+ if (options.beforeFetch) Object.assign(context, await options.beforeFetch(context));
2426
2069
  if (isCanceled || !fetch) {
2427
2070
  loading(false);
2428
2071
  return Promise.resolve(null);
2429
2072
  }
2430
2073
  let responseData = null;
2431
- if (timer)
2432
- timer.start();
2433
- return fetch(
2434
- context.url,
2435
- {
2436
- ...defaultFetchOptions,
2437
- ...context.options,
2438
- headers: {
2439
- ...headersToObject(defaultFetchOptions.headers),
2440
- ...headersToObject((_b2 = context.options) == null ? void 0 : _b2.headers)
2441
- }
2074
+ if (timer) timer.start();
2075
+ return fetch(context.url, {
2076
+ ...defaultFetchOptions,
2077
+ ...context.options,
2078
+ headers: {
2079
+ ...headersToObject(defaultFetchOptions.headers),
2080
+ ...headersToObject((_context$options = context.options) === null || _context$options === void 0 ? void 0 : _context$options.headers)
2442
2081
  }
2443
- ).then(async (fetchResponse) => {
2082
+ }).then(async (fetchResponse) => {
2444
2083
  response.value = fetchResponse;
2445
2084
  statusCode.value = fetchResponse.status;
2446
2085
  responseData = await fetchResponse.clone()[config.type]();
@@ -2448,52 +2087,37 @@ function useFetch(url, ...args) {
2448
2087
  data.value = initialData || null;
2449
2088
  throw new Error(fetchResponse.statusText);
2450
2089
  }
2451
- if (options.afterFetch) {
2452
- ({ data: responseData } = await options.afterFetch({
2453
- data: responseData,
2454
- response: fetchResponse,
2455
- context,
2456
- execute
2457
- }));
2458
- }
2090
+ if (options.afterFetch) ({ data: responseData } = await options.afterFetch({
2091
+ data: responseData,
2092
+ response: fetchResponse,
2093
+ context,
2094
+ execute
2095
+ }));
2459
2096
  data.value = responseData;
2460
2097
  responseEvent.trigger(fetchResponse);
2461
2098
  return fetchResponse;
2462
2099
  }).catch(async (fetchError) => {
2463
2100
  let errorData = fetchError.message || fetchError.name;
2464
- if (options.onFetchError) {
2465
- ({ error: errorData, data: responseData } = await options.onFetchError({
2466
- data: responseData,
2467
- error: fetchError,
2468
- response: response.value,
2469
- context,
2470
- execute
2471
- }));
2472
- }
2101
+ if (options.onFetchError) ({ error: errorData, data: responseData } = await options.onFetchError({
2102
+ data: responseData,
2103
+ error: fetchError,
2104
+ response: response.value,
2105
+ context,
2106
+ execute
2107
+ }));
2473
2108
  error.value = errorData;
2474
- if (options.updateDataOnError)
2475
- data.value = responseData;
2109
+ if (options.updateDataOnError) data.value = responseData;
2476
2110
  errorEvent.trigger(fetchError);
2477
- if (throwOnFailed)
2478
- throw fetchError;
2111
+ if (throwOnFailed) throw fetchError;
2479
2112
  return null;
2480
2113
  }).finally(() => {
2481
- if (currentExecuteCounter === executeCounter)
2482
- loading(false);
2483
- if (timer)
2484
- timer.stop();
2114
+ if (currentExecuteCounter === executeCounter) loading(false);
2115
+ if (timer) timer.stop();
2485
2116
  finallyEvent.trigger(null);
2486
2117
  });
2487
2118
  };
2488
2119
  const refetch = toRef(options.refetch);
2489
- reactivity.watch(
2490
- [
2491
- refetch,
2492
- toRef(url)
2493
- ],
2494
- ([refetch2]) => refetch2 && execute(),
2495
- { deep: true }
2496
- );
2120
+ reactivity.watch([refetch, toRef(url)], ([refetch$1]) => refetch$1 && execute(), { deep: true });
2497
2121
  const shell = {
2498
2122
  isFinished: reactivity.readonly(isFinished),
2499
2123
  isFetching: reactivity.readonly(isFetching),
@@ -2508,7 +2132,6 @@ function useFetch(url, ...args) {
2508
2132
  onFetchResponse: responseEvent.on,
2509
2133
  onFetchError: errorEvent.on,
2510
2134
  onFetchFinally: finallyEvent.on,
2511
- // method
2512
2135
  get: setMethod("GET"),
2513
2136
  put: setMethod("PUT"),
2514
2137
  post: setMethod("POST"),
@@ -2516,7 +2139,6 @@ function useFetch(url, ...args) {
2516
2139
  patch: setMethod("PATCH"),
2517
2140
  head: setMethod("HEAD"),
2518
2141
  options: setMethod("OPTIONS"),
2519
- // type
2520
2142
  json: setType("json"),
2521
2143
  text: setType("text"),
2522
2144
  blob: setType("blob"),
@@ -2529,16 +2151,7 @@ function useFetch(url, ...args) {
2529
2151
  config.method = method;
2530
2152
  config.payload = payload;
2531
2153
  config.payloadType = payloadType;
2532
- if (reactivity.isRef(config.payload)) {
2533
- reactivity.watch(
2534
- [
2535
- refetch,
2536
- toRef(config.payload)
2537
- ],
2538
- ([refetch2]) => refetch2 && execute(),
2539
- { deep: true }
2540
- );
2541
- }
2154
+ if (reactivity.isRef(config.payload)) reactivity.watch([refetch, toRef(config.payload)], ([refetch$1]) => refetch$1 && execute(), { deep: true });
2542
2155
  return {
2543
2156
  ...shell,
2544
2157
  then(onFulfilled, onRejected) {
@@ -2546,7 +2159,6 @@ function useFetch(url, ...args) {
2546
2159
  }
2547
2160
  };
2548
2161
  }
2549
- return void 0;
2550
2162
  };
2551
2163
  }
2552
2164
  function waitUntilFinished() {
@@ -2565,11 +2177,9 @@ function useFetch(url, ...args) {
2565
2177
  }
2566
2178
  };
2567
2179
  }
2568
- return void 0;
2569
2180
  };
2570
2181
  }
2571
- if (options.immediate)
2572
- Promise.resolve().then(() => execute());
2182
+ if (options.immediate) Promise.resolve().then(() => execute());
2573
2183
  return {
2574
2184
  ...shell,
2575
2185
  then(onFulfilled, onRejected) {
@@ -2578,138 +2188,113 @@ function useFetch(url, ...args) {
2578
2188
  };
2579
2189
  }
2580
2190
  function joinPaths(start, end) {
2581
- if (!start.endsWith("/") && !end.startsWith("/")) {
2582
- return `${start}/${end}`;
2583
- }
2584
- if (start.endsWith("/") && end.startsWith("/")) {
2585
- return `${start.slice(0, -1)}${end}`;
2586
- }
2191
+ if (!start.endsWith("/") && !end.startsWith("/")) return `${start}/${end}`;
2192
+ if (start.endsWith("/") && end.startsWith("/")) return `${start.slice(0, -1)}${end}`;
2587
2193
  return `${start}${end}`;
2588
2194
  }
2589
- const defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
2195
+ const defaultEvents$1 = [
2196
+ "mousemove",
2197
+ "mousedown",
2198
+ "resize",
2199
+ "keydown",
2200
+ "touchstart",
2201
+ "wheel"
2202
+ ];
2590
2203
  const oneMinute = 6e4;
2591
2204
  function useIdle(timeout = oneMinute, options = {}) {
2592
- const {
2593
- initialState = false,
2594
- listenForVisibilityChange = true,
2595
- events: events2 = defaultEvents$1,
2596
- window: window2 = defaultWindow,
2597
- eventFilter = throttleFilter(50)
2598
- } = options;
2205
+ const { initialState = false, listenForVisibilityChange = true, events: events$1 = defaultEvents$1, window: window$1 = defaultWindow, eventFilter = throttleFilter(50) } = options;
2599
2206
  const idle = reactivity.shallowRef(initialState);
2600
2207
  const lastActive = reactivity.shallowRef(timestamp());
2208
+ const isPending = reactivity.shallowRef(false);
2601
2209
  let timer;
2602
2210
  const reset = () => {
2603
2211
  idle.value = false;
2604
2212
  clearTimeout(timer);
2605
2213
  timer = setTimeout(() => idle.value = true, timeout);
2606
2214
  };
2607
- const onEvent = createFilterWrapper(
2608
- eventFilter,
2609
- () => {
2610
- lastActive.value = timestamp();
2611
- reset();
2612
- }
2613
- );
2614
- if (window2) {
2615
- const document2 = window2.document;
2215
+ const onEvent = createFilterWrapper(eventFilter, () => {
2216
+ lastActive.value = timestamp();
2217
+ reset();
2218
+ });
2219
+ if (window$1) {
2220
+ const document$1 = window$1.document;
2616
2221
  const listenerOptions = { passive: true };
2617
- for (const event of events2)
2618
- useEventListener(window2, event, onEvent, listenerOptions);
2619
- if (listenForVisibilityChange) {
2620
- useEventListener(document2, "visibilitychange", () => {
2621
- if (!document2.hidden)
2622
- onEvent();
2623
- }, listenerOptions);
2624
- }
2625
- if (!initialState)
2626
- reset();
2222
+ for (const event of events$1) useEventListener(window$1, event, () => {
2223
+ if (!isPending.value) return;
2224
+ onEvent();
2225
+ }, listenerOptions);
2226
+ if (listenForVisibilityChange) useEventListener(document$1, "visibilitychange", () => {
2227
+ if (document$1.hidden || !isPending.value) return;
2228
+ onEvent();
2229
+ }, listenerOptions);
2230
+ start();
2231
+ }
2232
+ function start() {
2233
+ if (isPending.value) return;
2234
+ isPending.value = true;
2235
+ if (!initialState) reset();
2236
+ }
2237
+ function stop() {
2238
+ idle.value = initialState;
2239
+ clearTimeout(timer);
2240
+ isPending.value = false;
2627
2241
  }
2628
2242
  return {
2629
2243
  idle,
2630
2244
  lastActive,
2631
- reset
2245
+ reset,
2246
+ stop,
2247
+ start,
2248
+ isPending: reactivity.shallowReadonly(isPending)
2632
2249
  };
2633
2250
  }
2634
2251
  // @__NO_SIDE_EFFECTS__
2635
2252
  function useNow(options = {}) {
2636
- const {
2637
- controls: exposeControls = false,
2638
- interval = "requestAnimationFrame",
2639
- immediate = true
2640
- } = options;
2253
+ const { controls: exposeControls = false, interval = "requestAnimationFrame", immediate = true } = options;
2641
2254
  const now2 = reactivity.ref(/* @__PURE__ */ new Date());
2642
2255
  const update = () => now2.value = /* @__PURE__ */ new Date();
2643
2256
  const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate }) : useIntervalFn(update, interval, { immediate });
2644
- if (exposeControls) {
2645
- return {
2646
- now: now2,
2647
- ...controls
2648
- };
2649
- } else {
2650
- return now2;
2651
- }
2257
+ if (exposeControls) return {
2258
+ now: now2,
2259
+ ...controls
2260
+ };
2261
+ else return now2;
2652
2262
  }
2653
2263
  function useObjectUrl(object) {
2654
2264
  const url = reactivity.shallowRef();
2655
2265
  const release = () => {
2656
- if (url.value)
2657
- URL.revokeObjectURL(url.value);
2266
+ if (url.value) URL.revokeObjectURL(url.value);
2658
2267
  url.value = void 0;
2659
2268
  };
2660
- reactivity.watch(
2661
- () => reactivity.toValue(object),
2662
- (newObject) => {
2663
- release();
2664
- if (newObject)
2665
- url.value = URL.createObjectURL(newObject);
2666
- },
2667
- { immediate: true }
2668
- );
2269
+ reactivity.watch(() => reactivity.toValue(object), (newObject) => {
2270
+ release();
2271
+ if (newObject) url.value = URL.createObjectURL(newObject);
2272
+ }, { immediate: true });
2669
2273
  tryOnScopeDispose(release);
2670
2274
  return reactivity.readonly(url);
2671
2275
  }
2672
2276
  // @__NO_SIDE_EFFECTS__
2673
2277
  function useClamp(value, min, max) {
2674
- if (typeof value === "function" || reactivity.isReadonly(value))
2675
- return reactivity.computed(() => clamp(reactivity.toValue(value), reactivity.toValue(min), reactivity.toValue(max)));
2278
+ if (typeof value === "function" || reactivity.isReadonly(value)) return reactivity.computed(() => clamp(reactivity.toValue(value), reactivity.toValue(min), reactivity.toValue(max)));
2676
2279
  const _value = reactivity.ref(value);
2677
2280
  return reactivity.computed({
2678
2281
  get() {
2679
2282
  return _value.value = clamp(_value.value, reactivity.toValue(min), reactivity.toValue(max));
2680
2283
  },
2681
- set(value2) {
2682
- _value.value = clamp(value2, reactivity.toValue(min), reactivity.toValue(max));
2284
+ set(value$1) {
2285
+ _value.value = clamp(value$1, reactivity.toValue(min), reactivity.toValue(max));
2683
2286
  }
2684
2287
  });
2685
2288
  }
2686
2289
  function useOffsetPagination(options) {
2687
- const {
2688
- total = Number.POSITIVE_INFINITY,
2689
- pageSize = 10,
2690
- page = 1,
2691
- onPageChange = noop,
2692
- onPageSizeChange = noop,
2693
- onPageCountChange = noop
2694
- } = options;
2290
+ const { total = Number.POSITIVE_INFINITY, pageSize = 10, page = 1, onPageChange = noop, onPageSizeChange = noop, onPageCountChange = noop } = options;
2695
2291
  const currentPageSize = /* @__PURE__ */ useClamp(pageSize, 1, Number.POSITIVE_INFINITY);
2696
- const pageCount = reactivity.computed(() => Math.max(
2697
- 1,
2698
- Math.ceil(reactivity.toValue(total) / reactivity.toValue(currentPageSize))
2699
- ));
2292
+ const pageCount = reactivity.computed(() => Math.max(1, Math.ceil(reactivity.toValue(total) / reactivity.toValue(currentPageSize))));
2700
2293
  const currentPage = /* @__PURE__ */ useClamp(page, 1, pageCount);
2701
2294
  const isFirstPage = reactivity.computed(() => currentPage.value === 1);
2702
2295
  const isLastPage = reactivity.computed(() => currentPage.value === pageCount.value);
2703
- if (reactivity.isRef(page)) {
2704
- syncRef(page, currentPage, {
2705
- direction: reactivity.isReadonly(page) ? "ltr" : "both"
2706
- });
2707
- }
2708
- if (reactivity.isRef(pageSize)) {
2709
- syncRef(pageSize, currentPageSize, {
2710
- direction: reactivity.isReadonly(pageSize) ? "ltr" : "both"
2711
- });
2712
- }
2296
+ if (reactivity.isRef(page)) syncRef(page, currentPage, { direction: reactivity.isReadonly(page) ? "ltr" : "both" });
2297
+ if (reactivity.isRef(pageSize)) syncRef(pageSize, currentPageSize, { direction: reactivity.isReadonly(pageSize) ? "ltr" : "both" });
2713
2298
  function prev() {
2714
2299
  currentPage.value--;
2715
2300
  }
@@ -2738,45 +2323,36 @@ function useOffsetPagination(options) {
2738
2323
  }
2739
2324
  function usePrevious(value, initialValue) {
2740
2325
  const previous = reactivity.shallowRef(initialValue);
2741
- reactivity.watch(
2742
- toRef(value),
2743
- (_, oldValue) => {
2744
- previous.value = oldValue;
2745
- },
2746
- { flush: "sync" }
2747
- );
2326
+ reactivity.watch(toRef(value), (_, oldValue) => {
2327
+ previous.value = oldValue;
2328
+ }, { flush: "sync" });
2748
2329
  return reactivity.readonly(previous);
2749
2330
  }
2750
2331
  const defaultSortFn = (source, compareFn) => source.sort(compareFn);
2751
2332
  const defaultCompare = (a, b) => a - b;
2752
2333
  function useSorted(...args) {
2753
- var _a, _b, _c, _d;
2754
2334
  const [source] = args;
2755
2335
  let compareFn = defaultCompare;
2756
2336
  let options = {};
2757
- if (args.length === 2) {
2758
- if (typeof args[1] === "object") {
2759
- options = args[1];
2760
- compareFn = (_a = options.compareFn) != null ? _a : defaultCompare;
2761
- } else {
2762
- compareFn = (_b = args[1]) != null ? _b : defaultCompare;
2763
- }
2764
- } else if (args.length > 2) {
2765
- compareFn = (_c = args[1]) != null ? _c : defaultCompare;
2766
- options = (_d = args[2]) != null ? _d : {};
2767
- }
2768
- const {
2769
- dirty = false,
2770
- sortFn = defaultSortFn
2771
- } = options;
2772
- if (!dirty)
2773
- return reactivity.computed(() => sortFn([...reactivity.toValue(source)], compareFn));
2337
+ if (args.length === 2) if (typeof args[1] === "object") {
2338
+ var _options$compareFn;
2339
+ options = args[1];
2340
+ compareFn = (_options$compareFn = options.compareFn) !== null && _options$compareFn !== void 0 ? _options$compareFn : defaultCompare;
2341
+ } else {
2342
+ var _args$;
2343
+ compareFn = (_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : defaultCompare;
2344
+ }
2345
+ else if (args.length > 2) {
2346
+ var _args$2, _args$3;
2347
+ compareFn = (_args$2 = args[1]) !== null && _args$2 !== void 0 ? _args$2 : defaultCompare;
2348
+ options = (_args$3 = args[2]) !== null && _args$3 !== void 0 ? _args$3 : {};
2349
+ }
2350
+ const { dirty = false, sortFn = defaultSortFn } = options;
2351
+ if (!dirty) return reactivity.computed(() => sortFn([...reactivity.toValue(source)], compareFn));
2774
2352
  reactivity.watchEffect(() => {
2775
2353
  const result = sortFn(reactivity.toValue(source), compareFn);
2776
- if (reactivity.isRef(source))
2777
- source.value = result;
2778
- else
2779
- source.splice(0, source.length, ...result);
2354
+ if (reactivity.isRef(source)) source.value = result;
2355
+ else source.splice(0, source.length, ...result);
2780
2356
  });
2781
2357
  return source;
2782
2358
  }
@@ -2784,39 +2360,33 @@ function useSorted(...args) {
2784
2360
  function useStepper(steps, initialStep) {
2785
2361
  const stepsRef = reactivity.ref(steps);
2786
2362
  const stepNames = reactivity.computed(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value));
2787
- const index = reactivity.ref(stepNames.value.indexOf(initialStep != null ? initialStep : stepNames.value[0]));
2363
+ const index = reactivity.ref(stepNames.value.indexOf(initialStep !== null && initialStep !== void 0 ? initialStep : stepNames.value[0]));
2788
2364
  const current = reactivity.computed(() => at(index.value));
2789
2365
  const isFirst = reactivity.computed(() => index.value === 0);
2790
2366
  const isLast = reactivity.computed(() => index.value === stepNames.value.length - 1);
2791
2367
  const next = reactivity.computed(() => stepNames.value[index.value + 1]);
2792
2368
  const previous = reactivity.computed(() => stepNames.value[index.value - 1]);
2793
- function at(index2) {
2794
- if (Array.isArray(stepsRef.value))
2795
- return stepsRef.value[index2];
2796
- return stepsRef.value[stepNames.value[index2]];
2369
+ function at(index$1) {
2370
+ if (Array.isArray(stepsRef.value)) return stepsRef.value[index$1];
2371
+ return stepsRef.value[stepNames.value[index$1]];
2797
2372
  }
2798
2373
  function get2(step) {
2799
- if (!stepNames.value.includes(step))
2800
- return;
2374
+ if (!stepNames.value.includes(step)) return;
2801
2375
  return at(stepNames.value.indexOf(step));
2802
2376
  }
2803
2377
  function goTo(step) {
2804
- if (stepNames.value.includes(step))
2805
- index.value = stepNames.value.indexOf(step);
2378
+ if (stepNames.value.includes(step)) index.value = stepNames.value.indexOf(step);
2806
2379
  }
2807
2380
  function goToNext() {
2808
- if (isLast.value)
2809
- return;
2381
+ if (isLast.value) return;
2810
2382
  index.value++;
2811
2383
  }
2812
2384
  function goToPrevious() {
2813
- if (isFirst.value)
2814
- return;
2385
+ if (isFirst.value) return;
2815
2386
  index.value--;
2816
2387
  }
2817
2388
  function goBackTo(step) {
2818
- if (isAfter(step))
2819
- goTo(step);
2389
+ if (isAfter(step)) goTo(step);
2820
2390
  }
2821
2391
  function isNext(step) {
2822
2392
  return stepNames.value.indexOf(step) === index.value + 1;
@@ -2858,19 +2428,47 @@ function useStepper(steps, initialStep) {
2858
2428
  function useThrottledRefHistory(source, options = {}) {
2859
2429
  const { throttle = 200, trailing = true } = options;
2860
2430
  const filter = throttleFilter(throttle, trailing);
2861
- const history = useRefHistory(source, { ...options, eventFilter: filter });
2862
- return {
2863
- ...history
2864
- };
2431
+ return { ...useRefHistory(source, {
2432
+ ...options,
2433
+ eventFilter: filter
2434
+ }) };
2865
2435
  }
2866
2436
  const DEFAULT_UNITS = [
2867
- { max: 6e4, value: 1e3, name: "second" },
2868
- { max: 276e4, value: 6e4, name: "minute" },
2869
- { max: 72e6, value: 36e5, name: "hour" },
2870
- { max: 5184e5, value: 864e5, name: "day" },
2871
- { max: 24192e5, value: 6048e5, name: "week" },
2872
- { max: 28512e6, value: 2592e6, name: "month" },
2873
- { max: Number.POSITIVE_INFINITY, value: 31536e6, name: "year" }
2437
+ {
2438
+ max: 6e4,
2439
+ value: 1e3,
2440
+ name: "second"
2441
+ },
2442
+ {
2443
+ max: 276e4,
2444
+ value: 6e4,
2445
+ name: "minute"
2446
+ },
2447
+ {
2448
+ max: 72e6,
2449
+ value: 36e5,
2450
+ name: "hour"
2451
+ },
2452
+ {
2453
+ max: 5184e5,
2454
+ value: 864e5,
2455
+ name: "day"
2456
+ },
2457
+ {
2458
+ max: 24192e5,
2459
+ value: 6048e5,
2460
+ name: "week"
2461
+ },
2462
+ {
2463
+ max: 28512e6,
2464
+ value: 2592e6,
2465
+ name: "month"
2466
+ },
2467
+ {
2468
+ max: Number.POSITIVE_INFINITY,
2469
+ value: 31536e6,
2470
+ name: "year"
2471
+ }
2874
2472
  ];
2875
2473
  const DEFAULT_MESSAGES = {
2876
2474
  justNow: "just now",
@@ -2890,93 +2488,70 @@ function DEFAULT_FORMATTER(date) {
2890
2488
  }
2891
2489
  // @__NO_SIDE_EFFECTS__
2892
2490
  function useTimeAgo(time, options = {}) {
2893
- const {
2894
- controls: exposeControls = false,
2895
- updateInterval = 3e4
2896
- } = options;
2897
- const { now: now2, ...controls } = /* @__PURE__ */ useNow({ interval: updateInterval, controls: true });
2491
+ const { controls: exposeControls = false, updateInterval = 3e4 } = options;
2492
+ const { now: now2, ...controls } = /* @__PURE__ */ useNow({
2493
+ interval: updateInterval,
2494
+ controls: true
2495
+ });
2898
2496
  const timeAgo = reactivity.computed(() => formatTimeAgo(new Date(reactivity.toValue(time)), options, reactivity.toValue(now2)));
2899
- if (exposeControls) {
2900
- return {
2901
- timeAgo,
2902
- ...controls
2903
- };
2904
- } else {
2905
- return timeAgo;
2906
- }
2497
+ if (exposeControls) return {
2498
+ timeAgo,
2499
+ ...controls
2500
+ };
2501
+ else return timeAgo;
2907
2502
  }
2908
2503
  function formatTimeAgo(from, options = {}, now2 = Date.now()) {
2909
- var _a;
2910
- const {
2911
- max,
2912
- messages = DEFAULT_MESSAGES,
2913
- fullDateFormatter = DEFAULT_FORMATTER,
2914
- units = DEFAULT_UNITS,
2915
- showSecond = false,
2916
- rounding = "round"
2917
- } = options;
2504
+ const { max, messages = DEFAULT_MESSAGES, fullDateFormatter = DEFAULT_FORMATTER, units = DEFAULT_UNITS, showSecond = false, rounding = "round" } = options;
2918
2505
  const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding];
2919
2506
  const diff = +now2 - +from;
2920
2507
  const absDiff = Math.abs(diff);
2921
- function getValue(diff2, unit) {
2922
- return roundFn(Math.abs(diff2) / unit.value);
2508
+ function getValue$1(diff$1, unit) {
2509
+ return roundFn(Math.abs(diff$1) / unit.value);
2923
2510
  }
2924
- function format(diff2, unit) {
2925
- const val = getValue(diff2, unit);
2926
- const past = diff2 > 0;
2511
+ function format(diff$1, unit) {
2512
+ const val = getValue$1(diff$1, unit);
2513
+ const past = diff$1 > 0;
2927
2514
  const str = applyFormat(unit.name, val, past);
2928
2515
  return applyFormat(past ? "past" : "future", str, past);
2929
2516
  }
2930
2517
  function applyFormat(name, val, isPast) {
2931
2518
  const formatter = messages[name];
2932
- if (typeof formatter === "function")
2933
- return formatter(val, isPast);
2519
+ if (typeof formatter === "function") return formatter(val, isPast);
2934
2520
  return formatter.replace("{0}", val.toString());
2935
2521
  }
2936
- if (absDiff < 6e4 && !showSecond)
2937
- return messages.justNow;
2938
- if (typeof max === "number" && absDiff > max)
2939
- return fullDateFormatter(new Date(from));
2522
+ if (absDiff < 6e4 && !showSecond) return messages.justNow;
2523
+ if (typeof max === "number" && absDiff > max) return fullDateFormatter(new Date(from));
2940
2524
  if (typeof max === "string") {
2941
- const unitMax = (_a = units.find((i) => i.name === max)) == null ? void 0 : _a.max;
2942
- if (unitMax && absDiff > unitMax)
2943
- return fullDateFormatter(new Date(from));
2525
+ var _units$find;
2526
+ const unitMax = (_units$find = units.find((i) => i.name === max)) === null || _units$find === void 0 ? void 0 : _units$find.max;
2527
+ if (unitMax && absDiff > unitMax) return fullDateFormatter(new Date(from));
2944
2528
  }
2945
2529
  for (const [idx, unit] of units.entries()) {
2946
- const val = getValue(diff, unit);
2947
- if (val <= 0 && units[idx - 1])
2948
- return format(diff, units[idx - 1]);
2949
- if (absDiff < unit.max)
2950
- return format(diff, unit);
2530
+ if (getValue$1(diff, unit) <= 0 && units[idx - 1]) return format(diff, units[idx - 1]);
2531
+ if (absDiff < unit.max) return format(diff, unit);
2951
2532
  }
2952
2533
  return messages.invalid;
2953
2534
  }
2954
2535
  function useTimeoutPoll(fn, interval, options = {}) {
2955
- const {
2956
- immediate = true,
2957
- immediateCallback = false
2958
- } = options;
2536
+ const { immediate = true, immediateCallback = false } = options;
2959
2537
  const { start } = useTimeoutFn(loop, interval, { immediate });
2960
2538
  const isActive = reactivity.shallowRef(false);
2961
2539
  async function loop() {
2962
- if (!isActive.value)
2963
- return;
2540
+ if (!isActive.value) return;
2964
2541
  await fn();
2965
2542
  start();
2966
2543
  }
2967
2544
  function resume() {
2968
2545
  if (!isActive.value) {
2969
2546
  isActive.value = true;
2970
- if (immediateCallback)
2971
- fn();
2547
+ if (immediateCallback) fn();
2972
2548
  start();
2973
2549
  }
2974
2550
  }
2975
2551
  function pause() {
2976
2552
  isActive.value = false;
2977
2553
  }
2978
- if (immediate && isClient)
2979
- resume();
2554
+ if (immediate && isClient) resume();
2980
2555
  tryOnScopeDispose(pause);
2981
2556
  return {
2982
2557
  isActive,
@@ -2985,13 +2560,7 @@ function useTimeoutPoll(fn, interval, options = {}) {
2985
2560
  };
2986
2561
  }
2987
2562
  function useTimestamp(options = {}) {
2988
- const {
2989
- controls: exposeControls = false,
2990
- offset = 0,
2991
- immediate = true,
2992
- interval = "requestAnimationFrame",
2993
- callback
2994
- } = options;
2563
+ const { controls: exposeControls = false, offset = 0, immediate = true, interval = "requestAnimationFrame", callback } = options;
2995
2564
  const ts = reactivity.shallowRef(timestamp() + offset);
2996
2565
  const update = () => ts.value = timestamp() + offset;
2997
2566
  const cb = callback ? () => {
@@ -2999,50 +2568,32 @@ function useTimestamp(options = {}) {
2999
2568
  callback(ts.value);
3000
2569
  } : update;
3001
2570
  const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
3002
- if (exposeControls) {
3003
- return {
3004
- timestamp: ts,
3005
- ...controls
3006
- };
3007
- } else {
3008
- return ts;
3009
- }
2571
+ if (exposeControls) return {
2572
+ timestamp: ts,
2573
+ ...controls
2574
+ };
2575
+ else return ts;
3010
2576
  }
3011
2577
  function useUrlSearchParams(mode = "history", options = {}) {
3012
- const {
3013
- initialValue = {},
3014
- removeNullishValues = true,
3015
- removeFalsyValues = false,
3016
- write: enableWrite = true,
3017
- writeMode = "replace",
3018
- window: window2 = defaultWindow,
3019
- stringify = (params) => params.toString()
3020
- } = options;
3021
- if (!window2)
3022
- return reactivity.reactive(initialValue);
2578
+ const { initialValue = {}, removeNullishValues = true, removeFalsyValues = false, write: enableWrite = true, writeMode = "replace", window: window$1 = defaultWindow, stringify = (params) => params.toString() } = options;
2579
+ if (!window$1) return reactivity.reactive(initialValue);
3023
2580
  const state = reactivity.reactive({});
3024
2581
  function getRawParams() {
3025
- if (mode === "history") {
3026
- return window2.location.search || "";
3027
- } else if (mode === "hash") {
3028
- const hash = window2.location.hash || "";
2582
+ if (mode === "history") return window$1.location.search || "";
2583
+ else if (mode === "hash") {
2584
+ const hash = window$1.location.hash || "";
3029
2585
  const index = hash.indexOf("?");
3030
2586
  return index > 0 ? hash.slice(index) : "";
3031
- } else {
3032
- return (window2.location.hash || "").replace(/^#/, "");
3033
- }
2587
+ } else return (window$1.location.hash || "").replace(/^#/, "");
3034
2588
  }
3035
2589
  function constructQuery(params) {
3036
2590
  const stringified = stringify(params);
3037
- if (mode === "history")
3038
- return `${stringified ? `?${stringified}` : ""}${window2.location.hash || ""}`;
3039
- if (mode === "hash-params")
3040
- return `${window2.location.search || ""}${stringified ? `#${stringified}` : ""}`;
3041
- const hash = window2.location.hash || "#";
2591
+ if (mode === "history") return `${stringified ? `?${stringified}` : ""}${window$1.location.hash || ""}`;
2592
+ if (mode === "hash-params") return `${window$1.location.search || ""}${stringified ? `#${stringified}` : ""}`;
2593
+ const hash = window$1.location.hash || "#";
3042
2594
  const index = hash.indexOf("?");
3043
- if (index > 0)
3044
- return `${window2.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
3045
- return `${window2.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`;
2595
+ if (index > 0) return `${window$1.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
2596
+ return `${window$1.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`;
3046
2597
  }
3047
2598
  function read() {
3048
2599
  return new URLSearchParams(getRawParams());
@@ -3056,79 +2607,43 @@ function useUrlSearchParams(mode = "history", options = {}) {
3056
2607
  }
3057
2608
  Array.from(unusedKeys).forEach((key) => delete state[key]);
3058
2609
  }
3059
- const { pause, resume } = watchPausable(
3060
- state,
3061
- () => {
3062
- const params = new URLSearchParams("");
3063
- Object.keys(state).forEach((key) => {
3064
- const mapEntry = state[key];
3065
- if (Array.isArray(mapEntry))
3066
- mapEntry.forEach((value) => params.append(key, value));
3067
- else if (removeNullishValues && mapEntry == null)
3068
- params.delete(key);
3069
- else if (removeFalsyValues && !mapEntry)
3070
- params.delete(key);
3071
- else
3072
- params.set(key, mapEntry);
3073
- });
3074
- write(params, false);
3075
- },
3076
- { deep: true }
3077
- );
2610
+ const { pause, resume } = pausableWatch(state, () => {
2611
+ const params = new URLSearchParams("");
2612
+ Object.keys(state).forEach((key) => {
2613
+ const mapEntry = state[key];
2614
+ if (Array.isArray(mapEntry)) mapEntry.forEach((value) => params.append(key, value));
2615
+ else if (removeNullishValues && mapEntry == null) params.delete(key);
2616
+ else if (removeFalsyValues && !mapEntry) params.delete(key);
2617
+ else params.set(key, mapEntry);
2618
+ });
2619
+ write(params, false);
2620
+ }, { deep: true });
3078
2621
  function write(params, shouldUpdate, shouldWriteHistory = true) {
3079
2622
  pause();
3080
- if (shouldUpdate)
3081
- updateState(params);
3082
- if (writeMode === "replace") {
3083
- window2.history.replaceState(
3084
- window2.history.state,
3085
- window2.document.title,
3086
- window2.location.pathname + constructQuery(params)
3087
- );
3088
- } else {
3089
- if (shouldWriteHistory) {
3090
- window2.history.pushState(
3091
- window2.history.state,
3092
- window2.document.title,
3093
- window2.location.pathname + constructQuery(params)
3094
- );
3095
- }
3096
- }
2623
+ if (shouldUpdate) updateState(params);
2624
+ if (writeMode === "replace") window$1.history.replaceState(window$1.history.state, window$1.document.title, window$1.location.pathname + constructQuery(params));
2625
+ else if (shouldWriteHistory) window$1.history.pushState(window$1.history.state, window$1.document.title, window$1.location.pathname + constructQuery(params));
3097
2626
  reactivity.nextTick(() => resume());
3098
2627
  }
3099
2628
  function onChanged() {
3100
- if (!enableWrite)
3101
- return;
2629
+ if (!enableWrite) return;
3102
2630
  write(read(), true, false);
3103
2631
  }
3104
2632
  const listenerOptions = { passive: true };
3105
- useEventListener(window2, "popstate", onChanged, listenerOptions);
3106
- if (mode !== "history")
3107
- useEventListener(window2, "hashchange", onChanged, listenerOptions);
2633
+ useEventListener(window$1, "popstate", onChanged, listenerOptions);
2634
+ if (mode !== "history") useEventListener(window$1, "hashchange", onChanged, listenerOptions);
3108
2635
  const initial = read();
3109
- if (initial.keys().next().value)
3110
- updateState(initial);
3111
- else
3112
- Object.assign(state, initialValue);
2636
+ if (initial.keys().next().value) updateState(initial);
2637
+ else Object.assign(state, initialValue);
3113
2638
  return state;
3114
2639
  }
3115
2640
  const DEFAULT_PING_MESSAGE = "ping";
3116
2641
  function resolveNestedOptions(options) {
3117
- if (options === true)
3118
- return {};
2642
+ if (options === true) return {};
3119
2643
  return options;
3120
2644
  }
3121
2645
  function useWebSocket(url, options = {}) {
3122
- const {
3123
- onConnected,
3124
- onDisconnected,
3125
- onError,
3126
- onMessage,
3127
- immediate = true,
3128
- autoConnect = true,
3129
- autoClose = true,
3130
- protocols = []
3131
- } = options;
2646
+ const { onConnected, onDisconnected, onError, onMessage, immediate = true, autoConnect = true, autoClose = true, protocols = [] } = options;
3132
2647
  const data = reactivity.ref(null);
3133
2648
  const status = reactivity.shallowRef("CLOSED");
3134
2649
  const wsRef = reactivity.ref();
@@ -3142,8 +2657,7 @@ function useWebSocket(url, options = {}) {
3142
2657
  let pongTimeoutWait;
3143
2658
  const _sendBuffer = () => {
3144
2659
  if (bufferedData.length && wsRef.value && status.value === "OPEN") {
3145
- for (const buffer of bufferedData)
3146
- wsRef.value.send(buffer);
2660
+ for (const buffer of bufferedData) wsRef.value.send(buffer);
3147
2661
  bufferedData = [];
3148
2662
  }
3149
2663
  };
@@ -3159,113 +2673,86 @@ function useWebSocket(url, options = {}) {
3159
2673
  };
3160
2674
  const close = (code = 1e3, reason) => {
3161
2675
  resetRetry();
3162
- if (!isClient && !isWorker || !wsRef.value)
3163
- return;
2676
+ if (!isClient && !isWorker || !wsRef.value) return;
3164
2677
  explicitlyClosed = true;
3165
2678
  resetHeartbeat();
3166
- heartbeatPause == null ? void 0 : heartbeatPause();
2679
+ heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause();
3167
2680
  wsRef.value.close(code, reason);
3168
2681
  wsRef.value = void 0;
3169
2682
  };
3170
- const send = (data2, useBuffer = true) => {
2683
+ const send = (data$1, useBuffer = true) => {
3171
2684
  if (!wsRef.value || status.value !== "OPEN") {
3172
- if (useBuffer)
3173
- bufferedData.push(data2);
2685
+ if (useBuffer) bufferedData.push(data$1);
3174
2686
  return false;
3175
2687
  }
3176
2688
  _sendBuffer();
3177
- wsRef.value.send(data2);
2689
+ wsRef.value.send(data$1);
3178
2690
  return true;
3179
2691
  };
3180
2692
  const _init = () => {
3181
- if (explicitlyClosed || typeof urlRef.value === "undefined")
3182
- return;
2693
+ if (explicitlyClosed || typeof urlRef.value === "undefined") return;
3183
2694
  const ws = new WebSocket(urlRef.value, protocols);
3184
2695
  wsRef.value = ws;
3185
2696
  status.value = "CONNECTING";
3186
2697
  ws.onopen = () => {
3187
2698
  status.value = "OPEN";
3188
2699
  retried = 0;
3189
- onConnected == null ? void 0 : onConnected(ws);
3190
- heartbeatResume == null ? void 0 : heartbeatResume();
2700
+ onConnected === null || onConnected === void 0 || onConnected(ws);
2701
+ heartbeatResume === null || heartbeatResume === void 0 || heartbeatResume();
3191
2702
  _sendBuffer();
3192
2703
  };
3193
2704
  ws.onclose = (ev) => {
3194
2705
  status.value = "CLOSED";
3195
2706
  resetHeartbeat();
3196
- heartbeatPause == null ? void 0 : heartbeatPause();
3197
- onDisconnected == null ? void 0 : onDisconnected(ws, ev);
2707
+ heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause();
2708
+ onDisconnected === null || onDisconnected === void 0 || onDisconnected(ws, ev);
3198
2709
  if (!explicitlyClosed && options.autoReconnect && (wsRef.value == null || ws === wsRef.value)) {
3199
- const {
3200
- retries = -1,
3201
- delay = 1e3,
3202
- onFailed
3203
- } = resolveNestedOptions(options.autoReconnect);
3204
- const checkRetires = typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries);
3205
- if (checkRetires(retried)) {
2710
+ const { retries = -1, delay = 1e3, onFailed } = resolveNestedOptions(options.autoReconnect);
2711
+ if ((typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries))(retried)) {
3206
2712
  retried += 1;
3207
2713
  retryTimeout = setTimeout(_init, delay);
3208
- } else {
3209
- onFailed == null ? void 0 : onFailed();
3210
- }
2714
+ } else onFailed === null || onFailed === void 0 || onFailed();
3211
2715
  }
3212
2716
  };
3213
2717
  ws.onerror = (e) => {
3214
- onError == null ? void 0 : onError(ws, e);
2718
+ onError === null || onError === void 0 || onError(ws, e);
3215
2719
  };
3216
2720
  ws.onmessage = (e) => {
3217
2721
  if (options.heartbeat) {
3218
2722
  resetHeartbeat();
3219
- const {
3220
- message = DEFAULT_PING_MESSAGE,
3221
- responseMessage = message
3222
- } = resolveNestedOptions(options.heartbeat);
3223
- if (e.data === reactivity.toValue(responseMessage))
3224
- return;
2723
+ const { message = DEFAULT_PING_MESSAGE, responseMessage = message } = resolveNestedOptions(options.heartbeat);
2724
+ if (e.data === reactivity.toValue(responseMessage)) return;
3225
2725
  }
3226
2726
  data.value = e.data;
3227
- onMessage == null ? void 0 : onMessage(ws, e);
2727
+ onMessage === null || onMessage === void 0 || onMessage(ws, e);
3228
2728
  };
3229
2729
  };
3230
2730
  if (options.heartbeat) {
3231
- const {
3232
- message = DEFAULT_PING_MESSAGE,
3233
- interval = 1e3,
3234
- pongTimeout = 1e3
3235
- } = resolveNestedOptions(options.heartbeat);
3236
- const { pause, resume } = useIntervalFn(
3237
- () => {
3238
- send(reactivity.toValue(message), false);
3239
- if (pongTimeoutWait != null)
3240
- return;
3241
- pongTimeoutWait = setTimeout(() => {
3242
- close();
3243
- explicitlyClosed = false;
3244
- }, pongTimeout);
3245
- },
3246
- interval,
3247
- { immediate: false }
3248
- );
2731
+ const { message = DEFAULT_PING_MESSAGE, interval = 1e3, pongTimeout = 1e3 } = resolveNestedOptions(options.heartbeat);
2732
+ const { pause, resume } = useIntervalFn(() => {
2733
+ send(reactivity.toValue(message), false);
2734
+ if (pongTimeoutWait != null) return;
2735
+ pongTimeoutWait = setTimeout(() => {
2736
+ close();
2737
+ explicitlyClosed = false;
2738
+ }, pongTimeout);
2739
+ }, interval, { immediate: false });
3249
2740
  heartbeatPause = pause;
3250
2741
  heartbeatResume = resume;
3251
2742
  }
3252
2743
  if (autoClose) {
3253
- if (isClient)
3254
- useEventListener("beforeunload", () => close(), { passive: true });
2744
+ if (isClient) useEventListener("beforeunload", () => close(), { passive: true });
3255
2745
  tryOnScopeDispose(close);
3256
2746
  }
3257
2747
  const open = () => {
3258
- if (!isClient && !isWorker)
3259
- return;
2748
+ if (!isClient && !isWorker) return;
3260
2749
  close();
3261
2750
  explicitlyClosed = false;
3262
2751
  retried = 0;
3263
2752
  _init();
3264
2753
  };
3265
- if (immediate)
3266
- open();
3267
- if (autoConnect)
3268
- reactivity.watch(urlRef, open);
2754
+ if (immediate) open();
2755
+ if (autoConnect) reactivity.watch(urlRef, open);
3269
2756
  return {
3270
2757
  data,
3271
2758
  status,
@@ -3276,21 +2763,17 @@ function useWebSocket(url, options = {}) {
3276
2763
  };
3277
2764
  }
3278
2765
  function depsParser(deps, localDeps) {
3279
- if (deps.length === 0 && localDeps.length === 0)
3280
- return "";
2766
+ if (deps.length === 0 && localDeps.length === 0) return "";
3281
2767
  const depsString = deps.map((dep) => `'${dep}'`).toString();
3282
2768
  const depsFunctionString = localDeps.filter((dep) => typeof dep === "function").map((fn) => {
3283
2769
  const str = fn.toString();
3284
- if (str.trim().startsWith("function")) {
3285
- return str;
3286
- } else {
3287
- const name = fn.name;
3288
- return `const ${name} = ${str}`;
3289
- }
2770
+ if (str.trim().startsWith("function")) return str;
2771
+ else return `const ${fn.name} = ${str}`;
3290
2772
  }).join(";");
3291
2773
  const importString = `importScripts(${depsString});`;
3292
2774
  return `${depsString.trim() === "" ? "" : importString} ${depsFunctionString}`;
3293
2775
  }
2776
+ var depsParser_default = depsParser;
3294
2777
  function jobRunner(userFunc) {
3295
2778
  return (e) => {
3296
2779
  const userFuncArgs = e.data[0];
@@ -3301,37 +2784,33 @@ function jobRunner(userFunc) {
3301
2784
  });
3302
2785
  };
3303
2786
  }
2787
+ var jobRunner_default = jobRunner;
3304
2788
  function createWorkerBlobUrl(fn, deps, localDeps) {
3305
- const blobCode = `${depsParser(deps, localDeps)}; onmessage=(${jobRunner})(${fn})`;
2789
+ const blobCode = `${depsParser_default(deps, localDeps)}; onmessage=(${jobRunner_default})(${fn})`;
3306
2790
  const blob = new Blob([blobCode], { type: "text/javascript" });
3307
- const url = URL.createObjectURL(blob);
3308
- return url;
2791
+ return URL.createObjectURL(blob);
3309
2792
  }
2793
+ var createWorkerBlobUrl_default = createWorkerBlobUrl;
3310
2794
  function useWebWorkerFn(fn, options = {}) {
3311
- const {
3312
- dependencies = [],
3313
- localDependencies = [],
3314
- timeout,
3315
- window: window2 = defaultWindow
3316
- } = options;
2795
+ const { dependencies = [], localDependencies = [], timeout, window: window$1 = defaultWindow } = options;
3317
2796
  const worker = reactivity.ref();
3318
2797
  const workerStatus = reactivity.shallowRef("PENDING");
3319
2798
  const promise = reactivity.ref({});
3320
2799
  const timeoutId = reactivity.shallowRef();
3321
2800
  const workerTerminate = (status = "PENDING") => {
3322
- if (worker.value && worker.value._url && window2) {
2801
+ if (worker.value && worker.value._url && window$1) {
3323
2802
  worker.value.terminate();
3324
2803
  URL.revokeObjectURL(worker.value._url);
3325
2804
  promise.value = {};
3326
2805
  worker.value = void 0;
3327
- window2.clearTimeout(timeoutId.value);
2806
+ window$1.clearTimeout(timeoutId.value);
3328
2807
  workerStatus.value = status;
3329
2808
  }
3330
2809
  };
3331
2810
  workerTerminate();
3332
2811
  tryOnScopeDispose(workerTerminate);
3333
2812
  const generateWorker = () => {
3334
- const blobUrl = createWorkerBlobUrl(fn, dependencies, localDependencies);
2813
+ const blobUrl = createWorkerBlobUrl_default(fn, dependencies, localDependencies);
3335
2814
  const newWorker = new Worker(blobUrl);
3336
2815
  newWorker._url = blobUrl;
3337
2816
  newWorker.onmessage = (e) => {
@@ -3357,28 +2836,21 @@ function useWebWorkerFn(fn, options = {}) {
3357
2836
  reject(e);
3358
2837
  workerTerminate("ERROR");
3359
2838
  };
3360
- if (timeout) {
3361
- timeoutId.value = setTimeout(
3362
- () => workerTerminate("TIMEOUT_EXPIRED"),
3363
- timeout
3364
- );
3365
- }
2839
+ if (timeout) timeoutId.value = setTimeout(() => workerTerminate("TIMEOUT_EXPIRED"), timeout);
3366
2840
  return newWorker;
3367
2841
  };
3368
2842
  const callWorker = (...fnArgs) => new Promise((resolve, reject) => {
3369
- var _a;
2843
+ var _worker$value;
3370
2844
  promise.value = {
3371
2845
  resolve,
3372
2846
  reject
3373
2847
  };
3374
- (_a = worker.value) == null ? void 0 : _a.postMessage([[...fnArgs]]);
2848
+ (_worker$value = worker.value) === null || _worker$value === void 0 || _worker$value.postMessage([[...fnArgs]]);
3375
2849
  workerStatus.value = "RUNNING";
3376
2850
  });
3377
2851
  const workerFn = (...fnArgs) => {
3378
2852
  if (workerStatus.value === "RUNNING") {
3379
- console.error(
3380
- "[useWebWorkerFn] You can only run one instance of the worker at a time."
3381
- );
2853
+ console.error("[useWebWorkerFn] You can only run one instance of the worker at a time.");
3382
2854
  return Promise.reject();
3383
2855
  }
3384
2856
  worker.value = generateWorker();
@@ -3390,6 +2862,18 @@ function useWebWorkerFn(fn, options = {}) {
3390
2862
  workerTerminate
3391
2863
  };
3392
2864
  }
2865
+ Object.defineProperty(exports, "resolveRef", {
2866
+ enumerable: true,
2867
+ get: () => reactivity.toRef
2868
+ });
2869
+ Object.defineProperty(exports, "resolveUnref", {
2870
+ enumerable: true,
2871
+ get: () => reactivity.toValue
2872
+ });
2873
+ Object.defineProperty(exports, "toValue", {
2874
+ enumerable: true,
2875
+ get: () => reactivity.toValue
2876
+ });
3393
2877
  exports.assert = assert;
3394
2878
  exports.asyncComputed = computedAsync;
3395
2879
  exports.autoResetRef = refAutoReset;
@@ -3449,8 +2933,6 @@ exports.refDebounced = refDebounced;
3449
2933
  exports.refDefault = refDefault;
3450
2934
  exports.refThrottled = refThrottled;
3451
2935
  exports.refWithControl = refWithControl;
3452
- exports.resolveRef = resolveRef;
3453
- exports.resolveUnref = resolveUnref;
3454
2936
  exports.set = set;
3455
2937
  exports.syncRef = syncRef;
3456
2938
  exports.syncRefs = syncRefs;
@@ -3460,7 +2942,6 @@ exports.throttledWatch = watchThrottled;
3460
2942
  exports.toReactive = toReactive;
3461
2943
  exports.toRef = toRef;
3462
2944
  exports.toRefs = toRefs;
3463
- exports.toValue = toValue;
3464
2945
  exports.tryOnScopeDispose = tryOnScopeDispose;
3465
2946
  exports.until = until;
3466
2947
  exports.useArrayDifference = useArrayDifference;