@vitejs/devtools 0.0.0-alpha.3 → 0.0.0-alpha.31

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.
@@ -0,0 +1,916 @@
1
+ import { B as toRef$1, F as onScopeDispose, H as toValue, L as readonly, M as customRef, N as getCurrentScope, O as watch, R as ref, S as onMounted, U as unref, _ as getCurrentInstance, b as inject, k as watchEffect, s as computed, x as nextTick, y as hasInjectionContext, z as shallowRef } from "./vue.runtime.esm-bundler-DL0i8o0W.js";
2
+
3
+ //#region ../../node_modules/.pnpm/@vueuse+shared@14.2.0_vue@3.5.27_typescript@5.9.3_/node_modules/@vueuse/shared/dist/index.js
4
+ /**
5
+ * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
6
+ *
7
+ * @param fn
8
+ */
9
+ function tryOnScopeDispose(fn, failSilently) {
10
+ if (getCurrentScope()) {
11
+ onScopeDispose(fn, failSilently);
12
+ return true;
13
+ }
14
+ return false;
15
+ }
16
+ const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
17
+ /**
18
+ * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * injectLocal('MyInjectionKey', 1)
23
+ * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
24
+ * ```
25
+ *
26
+ * @__NO_SIDE_EFFECTS__
27
+ */
28
+ const injectLocal = (...args) => {
29
+ var _getCurrentInstance;
30
+ const key = args[0];
31
+ const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
32
+ const owner = instance !== null && instance !== void 0 ? instance : getCurrentScope();
33
+ if (owner == null && !hasInjectionContext()) throw new Error("injectLocal must be called in setup");
34
+ if (owner && localProvidedStateMap.has(owner) && key in localProvidedStateMap.get(owner)) return localProvidedStateMap.get(owner)[key];
35
+ return inject(...args);
36
+ };
37
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
38
+ const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
39
+ const notNullish = (val) => val != null;
40
+ const toString = Object.prototype.toString;
41
+ const isObject = (val) => toString.call(val) === "[object Object]";
42
+ const noop = () => {};
43
+ const isIOS = /* @__PURE__ */ getIsIOS();
44
+ function getIsIOS() {
45
+ var _window, _window2, _window3;
46
+ return isClient && !!((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent));
47
+ }
48
+ function toRef(...args) {
49
+ if (args.length !== 1) return toRef$1(...args);
50
+ const r = args[0];
51
+ return typeof r === "function" ? readonly(customRef(() => ({
52
+ get: r,
53
+ set: noop
54
+ }))) : ref(r);
55
+ }
56
+ /**
57
+ * @internal
58
+ */
59
+ function createFilterWrapper(filter, fn) {
60
+ function wrapper(...args) {
61
+ return new Promise((resolve, reject) => {
62
+ Promise.resolve(filter(() => fn.apply(this, args), {
63
+ fn,
64
+ thisArg: this,
65
+ args
66
+ })).then(resolve).catch(reject);
67
+ });
68
+ }
69
+ return wrapper;
70
+ }
71
+ const bypassFilter = (invoke$1) => {
72
+ return invoke$1();
73
+ };
74
+ /**
75
+ * Create an EventFilter that debounce the events
76
+ */
77
+ function debounceFilter(ms, options = {}) {
78
+ let timer;
79
+ let maxTimer;
80
+ let lastRejector = noop;
81
+ const _clearTimeout = (timer$1) => {
82
+ clearTimeout(timer$1);
83
+ lastRejector();
84
+ lastRejector = noop;
85
+ };
86
+ let lastInvoker;
87
+ const filter = (invoke$1) => {
88
+ const duration = toValue(ms);
89
+ const maxDuration = toValue(options.maxWait);
90
+ if (timer) _clearTimeout(timer);
91
+ if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
92
+ if (maxTimer) {
93
+ _clearTimeout(maxTimer);
94
+ maxTimer = void 0;
95
+ }
96
+ return Promise.resolve(invoke$1());
97
+ }
98
+ return new Promise((resolve, reject) => {
99
+ lastRejector = options.rejectOnCancel ? reject : resolve;
100
+ lastInvoker = invoke$1;
101
+ if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
102
+ if (timer) _clearTimeout(timer);
103
+ maxTimer = void 0;
104
+ resolve(lastInvoker());
105
+ }, maxDuration);
106
+ timer = setTimeout(() => {
107
+ if (maxTimer) _clearTimeout(maxTimer);
108
+ maxTimer = void 0;
109
+ resolve(invoke$1());
110
+ }, duration);
111
+ });
112
+ };
113
+ return filter;
114
+ }
115
+ /**
116
+ * EventFilter that gives extra controls to pause and resume the filter
117
+ *
118
+ * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none
119
+ * @param options Options to configure the filter
120
+ */
121
+ function pausableFilter(extendFilter = bypassFilter, options = {}) {
122
+ const { initialState = "active" } = options;
123
+ const isActive = toRef(initialState === "active");
124
+ function pause() {
125
+ isActive.value = false;
126
+ }
127
+ function resume() {
128
+ isActive.value = true;
129
+ }
130
+ const eventFilter = (...args) => {
131
+ if (isActive.value) extendFilter(...args);
132
+ };
133
+ return {
134
+ isActive: readonly(isActive),
135
+ pause,
136
+ resume,
137
+ eventFilter
138
+ };
139
+ }
140
+ /**
141
+ * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client
142
+ */
143
+ function pxValue(px) {
144
+ return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
145
+ }
146
+ function toArray(value) {
147
+ return Array.isArray(value) ? value : [value];
148
+ }
149
+ function cacheStringFunction(fn) {
150
+ const cache = Object.create(null);
151
+ return ((str) => {
152
+ return cache[str] || (cache[str] = fn(str));
153
+ });
154
+ }
155
+ const hyphenateRE = /\B([A-Z])/g;
156
+ const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
157
+ const camelizeRE = /-(\w)/g;
158
+ const camelize = cacheStringFunction((str) => {
159
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
160
+ });
161
+ function getLifeCycleTarget(target) {
162
+ return target || getCurrentInstance();
163
+ }
164
+ /**
165
+ * Debounce execution of a function.
166
+ *
167
+ * @see https://vueuse.org/useDebounceFn
168
+ * @param fn A function to be executed after delay milliseconds debounced.
169
+ * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
170
+ * @param options Options
171
+ *
172
+ * @return A new, debounce, function.
173
+ *
174
+ * @__NO_SIDE_EFFECTS__
175
+ */
176
+ function useDebounceFn(fn, ms = 200, options = {}) {
177
+ return createFilterWrapper(debounceFilter(ms, options), fn);
178
+ }
179
+ function watchWithFilter(source, cb, options = {}) {
180
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
181
+ return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
182
+ }
183
+ /** @deprecated Use Vue's built-in `watch` instead. This function will be removed in future version. */
184
+ function watchPausable(source, cb, options = {}) {
185
+ const { eventFilter: filter, initialState = "active", ...watchOptions } = options;
186
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
187
+ return {
188
+ stop: watchWithFilter(source, cb, {
189
+ ...watchOptions,
190
+ eventFilter
191
+ }),
192
+ pause,
193
+ resume,
194
+ isActive
195
+ };
196
+ }
197
+ /**
198
+ * Call onMounted() if it's inside a component lifecycle, if not, just call the function
199
+ *
200
+ * @param fn
201
+ * @param sync if set to false, it will run in the nextTick() of Vue
202
+ * @param target
203
+ */
204
+ function tryOnMounted(fn, sync = true, target) {
205
+ if (getLifeCycleTarget(target)) onMounted(fn, target);
206
+ else if (sync) fn();
207
+ else nextTick(fn);
208
+ }
209
+ function watchDebounced(source, cb, options = {}) {
210
+ const { debounce = 0, maxWait = void 0, ...watchOptions } = options;
211
+ return watchWithFilter(source, cb, {
212
+ ...watchOptions,
213
+ eventFilter: debounceFilter(debounce, { maxWait })
214
+ });
215
+ }
216
+ /**
217
+ * Shorthand for watching value with {immediate: true}
218
+ *
219
+ * @see https://vueuse.org/watchImmediate
220
+ */
221
+ function watchImmediate(source, cb, options) {
222
+ return watch(source, cb, {
223
+ ...options,
224
+ immediate: true
225
+ });
226
+ }
227
+
228
+ //#endregion
229
+ //#region ../../node_modules/.pnpm/@vueuse+core@14.2.0_vue@3.5.27_typescript@5.9.3_/node_modules/@vueuse/core/dist/index.js
230
+ const defaultWindow = isClient ? window : void 0;
231
+ const defaultDocument = isClient ? window.document : void 0;
232
+ const defaultNavigator = isClient ? window.navigator : void 0;
233
+ const defaultLocation = isClient ? window.location : void 0;
234
+ /**
235
+ * Get the dom element of a ref of element or Vue component instance
236
+ *
237
+ * @param elRef
238
+ */
239
+ function unrefElement(elRef) {
240
+ var _$el;
241
+ const plain = toValue(elRef);
242
+ return (_$el = plain === null || plain === void 0 ? void 0 : plain.$el) !== null && _$el !== void 0 ? _$el : plain;
243
+ }
244
+ function useEventListener(...args) {
245
+ const register = (el, event, listener, options) => {
246
+ el.addEventListener(event, listener, options);
247
+ return () => el.removeEventListener(event, listener, options);
248
+ };
249
+ const firstParamTargets = computed(() => {
250
+ const test = toArray(toValue(args[0])).filter((e) => e != null);
251
+ return test.every((e) => typeof e !== "string") ? test : void 0;
252
+ });
253
+ return watchImmediate(() => {
254
+ var _firstParamTargets$va, _firstParamTargets$va2;
255
+ return [
256
+ (_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),
257
+ toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
258
+ toArray(unref(firstParamTargets.value ? args[2] : args[1])),
259
+ toValue(firstParamTargets.value ? args[3] : args[2])
260
+ ];
261
+ }, ([raw_targets, raw_events, raw_listeners, raw_options], _, onCleanup) => {
262
+ 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;
263
+ const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
264
+ const cleanups = raw_targets.flatMap((el) => raw_events.flatMap((event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))));
265
+ onCleanup(() => {
266
+ cleanups.forEach((fn) => fn());
267
+ });
268
+ }, { flush: "post" });
269
+ }
270
+ let _iOSWorkaround = false;
271
+ function onClickOutside(target, handler, options = {}) {
272
+ const { window: window$1 = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
273
+ if (!window$1) return controls ? {
274
+ stop: noop,
275
+ cancel: noop,
276
+ trigger: noop
277
+ } : noop;
278
+ if (isIOS && !_iOSWorkaround) {
279
+ _iOSWorkaround = true;
280
+ const listenerOptions = { passive: true };
281
+ Array.from(window$1.document.body.children).forEach((el) => el.addEventListener("click", noop, listenerOptions));
282
+ window$1.document.documentElement.addEventListener("click", noop, listenerOptions);
283
+ }
284
+ let shouldListen = true;
285
+ const shouldIgnore = (event) => {
286
+ return toValue(ignore).some((target$1) => {
287
+ if (typeof target$1 === "string") return Array.from(window$1.document.querySelectorAll(target$1)).some((el) => el === event.target || event.composedPath().includes(el));
288
+ else {
289
+ const el = unrefElement(target$1);
290
+ return el && (event.target === el || event.composedPath().includes(el));
291
+ }
292
+ });
293
+ };
294
+ /**
295
+ * Determines if the given target has multiple root elements.
296
+ * Referenced from: https://github.com/vuejs/test-utils/blob/ccb460be55f9f6be05ab708500a41ec8adf6f4bc/src/vue-wrapper.ts#L21
297
+ */
298
+ function hasMultipleRoots(target$1) {
299
+ const vm = toValue(target$1);
300
+ return vm && vm.$.subTree.shapeFlag === 16;
301
+ }
302
+ function checkMultipleRoots(target$1, event) {
303
+ const vm = toValue(target$1);
304
+ const children = vm.$.subTree && vm.$.subTree.children;
305
+ if (children == null || !Array.isArray(children)) return false;
306
+ return children.some((child) => child.el === event.target || event.composedPath().includes(child.el));
307
+ }
308
+ const listener = (event) => {
309
+ const el = unrefElement(target);
310
+ if (event.target == null) return;
311
+ if (!(el instanceof Element) && hasMultipleRoots(target) && checkMultipleRoots(target, event)) return;
312
+ if (!el || el === event.target || event.composedPath().includes(el)) return;
313
+ if ("detail" in event && event.detail === 0) shouldListen = !shouldIgnore(event);
314
+ if (!shouldListen) {
315
+ shouldListen = true;
316
+ return;
317
+ }
318
+ handler(event);
319
+ };
320
+ let isProcessingClick = false;
321
+ const cleanup = [
322
+ useEventListener(window$1, "click", (event) => {
323
+ if (!isProcessingClick) {
324
+ isProcessingClick = true;
325
+ setTimeout(() => {
326
+ isProcessingClick = false;
327
+ }, 0);
328
+ listener(event);
329
+ }
330
+ }, {
331
+ passive: true,
332
+ capture
333
+ }),
334
+ useEventListener(window$1, "pointerdown", (e) => {
335
+ const el = unrefElement(target);
336
+ shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el));
337
+ }, { passive: true }),
338
+ detectIframe && useEventListener(window$1, "blur", (event) => {
339
+ setTimeout(() => {
340
+ var _window$document$acti;
341
+ const el = unrefElement(target);
342
+ if (((_window$document$acti = window$1.document.activeElement) === null || _window$document$acti === void 0 ? void 0 : _window$document$acti.tagName) === "IFRAME" && !(el === null || el === void 0 ? void 0 : el.contains(window$1.document.activeElement))) handler(event);
343
+ }, 0);
344
+ }, { passive: true })
345
+ ].filter(Boolean);
346
+ const stop = () => cleanup.forEach((fn) => fn());
347
+ if (controls) return {
348
+ stop,
349
+ cancel: () => {
350
+ shouldListen = false;
351
+ },
352
+ trigger: (event) => {
353
+ shouldListen = true;
354
+ listener(event);
355
+ shouldListen = false;
356
+ }
357
+ };
358
+ return stop;
359
+ }
360
+ /**
361
+ * Mounted state in ref.
362
+ *
363
+ * @see https://vueuse.org/useMounted
364
+ *
365
+ * @__NO_SIDE_EFFECTS__
366
+ */
367
+ function useMounted() {
368
+ const isMounted = shallowRef(false);
369
+ const instance = getCurrentInstance();
370
+ if (instance) onMounted(() => {
371
+ isMounted.value = true;
372
+ }, instance);
373
+ return isMounted;
374
+ }
375
+ /* @__NO_SIDE_EFFECTS__ */
376
+ function useSupported(callback) {
377
+ const isMounted = useMounted();
378
+ return computed(() => {
379
+ isMounted.value;
380
+ return Boolean(callback());
381
+ });
382
+ }
383
+ /**
384
+ * Watch for changes being made to the DOM tree.
385
+ *
386
+ * @see https://vueuse.org/useMutationObserver
387
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver MutationObserver MDN
388
+ * @param target
389
+ * @param callback
390
+ * @param options
391
+ */
392
+ function useMutationObserver(target, callback, options = {}) {
393
+ const { window: window$1 = defaultWindow, ...mutationOptions } = options;
394
+ let observer;
395
+ const isSupported = /* @__PURE__ */ useSupported(() => window$1 && "MutationObserver" in window$1);
396
+ const cleanup = () => {
397
+ if (observer) {
398
+ observer.disconnect();
399
+ observer = void 0;
400
+ }
401
+ };
402
+ const stopWatch = watch(computed(() => {
403
+ const items = toArray(toValue(target)).map(unrefElement).filter(notNullish);
404
+ return new Set(items);
405
+ }), (newTargets) => {
406
+ cleanup();
407
+ if (isSupported.value && newTargets.size) {
408
+ observer = new MutationObserver(callback);
409
+ newTargets.forEach((el) => observer.observe(el, mutationOptions));
410
+ }
411
+ }, {
412
+ immediate: true,
413
+ flush: "post"
414
+ });
415
+ const takeRecords = () => {
416
+ return observer === null || observer === void 0 ? void 0 : observer.takeRecords();
417
+ };
418
+ const stop = () => {
419
+ stopWatch();
420
+ cleanup();
421
+ };
422
+ tryOnScopeDispose(stop);
423
+ return {
424
+ isSupported,
425
+ stop,
426
+ takeRecords
427
+ };
428
+ }
429
+ const ssrWidthSymbol = Symbol("vueuse-ssr-width");
430
+ /* @__NO_SIDE_EFFECTS__ */
431
+ function useSSRWidth() {
432
+ const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
433
+ return typeof ssrWidth === "number" ? ssrWidth : void 0;
434
+ }
435
+ /**
436
+ * Reactive Media Query.
437
+ *
438
+ * @see https://vueuse.org/useMediaQuery
439
+ * @param query
440
+ * @param options
441
+ */
442
+ function useMediaQuery(query, options = {}) {
443
+ const { window: window$1 = defaultWindow, ssrWidth = /* @__PURE__ */ useSSRWidth() } = options;
444
+ const isSupported = /* @__PURE__ */ useSupported(() => window$1 && "matchMedia" in window$1 && typeof window$1.matchMedia === "function");
445
+ const ssrSupport = shallowRef(typeof ssrWidth === "number");
446
+ const mediaQuery = shallowRef();
447
+ const matches = shallowRef(false);
448
+ const handler = (event) => {
449
+ matches.value = event.matches;
450
+ };
451
+ watchEffect(() => {
452
+ if (ssrSupport.value) {
453
+ ssrSupport.value = !isSupported.value;
454
+ matches.value = toValue(query).split(",").some((queryString) => {
455
+ const not = queryString.includes("not all");
456
+ const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
457
+ const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
458
+ let res = Boolean(minWidth || maxWidth);
459
+ if (minWidth && res) res = ssrWidth >= pxValue(minWidth[1]);
460
+ if (maxWidth && res) res = ssrWidth <= pxValue(maxWidth[1]);
461
+ return not ? !res : res;
462
+ });
463
+ return;
464
+ }
465
+ if (!isSupported.value) return;
466
+ mediaQuery.value = window$1.matchMedia(toValue(query));
467
+ matches.value = mediaQuery.value.matches;
468
+ });
469
+ useEventListener(mediaQuery, "change", handler, { passive: true });
470
+ return computed(() => matches.value);
471
+ }
472
+ const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
473
+ const globalKey = "__vueuse_ssr_handlers__";
474
+ const handlers = /* @__PURE__ */ getHandlers();
475
+ function getHandlers() {
476
+ if (!(globalKey in _global)) _global[globalKey] = _global[globalKey] || {};
477
+ return _global[globalKey];
478
+ }
479
+ function getSSRHandler(key, fallback) {
480
+ return handlers[key] || fallback;
481
+ }
482
+ function guessSerializerType(rawInit) {
483
+ return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
484
+ }
485
+ const StorageSerializers = {
486
+ boolean: {
487
+ read: (v) => v === "true",
488
+ write: (v) => String(v)
489
+ },
490
+ object: {
491
+ read: (v) => JSON.parse(v),
492
+ write: (v) => JSON.stringify(v)
493
+ },
494
+ number: {
495
+ read: (v) => Number.parseFloat(v),
496
+ write: (v) => String(v)
497
+ },
498
+ any: {
499
+ read: (v) => v,
500
+ write: (v) => String(v)
501
+ },
502
+ string: {
503
+ read: (v) => v,
504
+ write: (v) => String(v)
505
+ },
506
+ map: {
507
+ read: (v) => new Map(JSON.parse(v)),
508
+ write: (v) => JSON.stringify(Array.from(v.entries()))
509
+ },
510
+ set: {
511
+ read: (v) => new Set(JSON.parse(v)),
512
+ write: (v) => JSON.stringify(Array.from(v))
513
+ },
514
+ date: {
515
+ read: (v) => new Date(v),
516
+ write: (v) => v.toISOString()
517
+ }
518
+ };
519
+ const customStorageEventName = "vueuse-storage";
520
+ /**
521
+ * Reactive LocalStorage/SessionStorage.
522
+ *
523
+ * @see https://vueuse.org/useStorage
524
+ */
525
+ function useStorage(key, defaults$1, storage, options = {}) {
526
+ var _options$serializer;
527
+ const { flush = "pre", deep = true, listenToStorageChanges = true, writeDefaults = true, mergeDefaults = false, shallow, window: window$1 = defaultWindow, eventFilter, onError = (e) => {
528
+ console.error(e);
529
+ }, initOnMounted } = options;
530
+ const data = (shallow ? shallowRef : ref)(typeof defaults$1 === "function" ? defaults$1() : defaults$1);
531
+ const keyComputed = computed(() => toValue(key));
532
+ if (!storage) try {
533
+ storage = getSSRHandler("getDefaultStorage", () => defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.localStorage)();
534
+ } catch (e) {
535
+ onError(e);
536
+ }
537
+ if (!storage) return data;
538
+ const rawInit = toValue(defaults$1);
539
+ const type = guessSerializerType(rawInit);
540
+ const serializer = (_options$serializer = options.serializer) !== null && _options$serializer !== void 0 ? _options$serializer : StorageSerializers[type];
541
+ const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, (newValue) => write(newValue), {
542
+ flush,
543
+ deep,
544
+ eventFilter
545
+ });
546
+ watch(keyComputed, () => update(), { flush });
547
+ let firstMounted = false;
548
+ const onStorageEvent = (ev) => {
549
+ if (initOnMounted && !firstMounted) return;
550
+ update(ev);
551
+ };
552
+ const onStorageCustomEvent = (ev) => {
553
+ if (initOnMounted && !firstMounted) return;
554
+ updateFromCustomEvent(ev);
555
+ };
556
+ /**
557
+ * The custom event is needed for same-document syncing when using custom
558
+ * storage backends, but it doesn't work across different documents.
559
+ *
560
+ * TODO: Consider implementing a BroadcastChannel-based solution that fixes this.
561
+ */
562
+ if (window$1 && listenToStorageChanges) if (storage instanceof Storage) useEventListener(window$1, "storage", onStorageEvent, { passive: true });
563
+ else useEventListener(window$1, customStorageEventName, onStorageCustomEvent);
564
+ if (initOnMounted) tryOnMounted(() => {
565
+ firstMounted = true;
566
+ update();
567
+ });
568
+ else update();
569
+ function dispatchWriteEvent(oldValue, newValue) {
570
+ if (window$1) {
571
+ const payload = {
572
+ key: keyComputed.value,
573
+ oldValue,
574
+ newValue,
575
+ storageArea: storage
576
+ };
577
+ window$1.dispatchEvent(storage instanceof Storage ? new StorageEvent("storage", payload) : new CustomEvent(customStorageEventName, { detail: payload }));
578
+ }
579
+ }
580
+ function write(v) {
581
+ try {
582
+ const oldValue = storage.getItem(keyComputed.value);
583
+ if (v == null) {
584
+ dispatchWriteEvent(oldValue, null);
585
+ storage.removeItem(keyComputed.value);
586
+ } else {
587
+ const serialized = serializer.write(v);
588
+ if (oldValue !== serialized) {
589
+ storage.setItem(keyComputed.value, serialized);
590
+ dispatchWriteEvent(oldValue, serialized);
591
+ }
592
+ }
593
+ } catch (e) {
594
+ onError(e);
595
+ }
596
+ }
597
+ function read(event) {
598
+ const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
599
+ if (rawValue == null) {
600
+ if (writeDefaults && rawInit != null) storage.setItem(keyComputed.value, serializer.write(rawInit));
601
+ return rawInit;
602
+ } else if (!event && mergeDefaults) {
603
+ const value = serializer.read(rawValue);
604
+ if (typeof mergeDefaults === "function") return mergeDefaults(value, rawInit);
605
+ else if (type === "object" && !Array.isArray(value)) return {
606
+ ...rawInit,
607
+ ...value
608
+ };
609
+ return value;
610
+ } else if (typeof rawValue !== "string") return rawValue;
611
+ else return serializer.read(rawValue);
612
+ }
613
+ function update(event) {
614
+ if (event && event.storageArea !== storage) return;
615
+ if (event && event.key == null) {
616
+ data.value = rawInit;
617
+ return;
618
+ }
619
+ if (event && event.key !== keyComputed.value) return;
620
+ pauseWatch();
621
+ try {
622
+ const serializedData = serializer.write(data.value);
623
+ if (event === void 0 || (event === null || event === void 0 ? void 0 : event.newValue) !== serializedData) data.value = read(event);
624
+ } catch (e) {
625
+ onError(e);
626
+ } finally {
627
+ if (event) nextTick(resumeWatch);
628
+ else resumeWatch();
629
+ }
630
+ }
631
+ function updateFromCustomEvent(event) {
632
+ update(event.detail);
633
+ }
634
+ return data;
635
+ }
636
+ /**
637
+ * Manipulate CSS variables.
638
+ *
639
+ * @see https://vueuse.org/useCssVar
640
+ * @param prop
641
+ * @param target
642
+ * @param options
643
+ */
644
+ function useCssVar(prop, target, options = {}) {
645
+ const { window: window$1 = defaultWindow, initialValue, observe = false } = options;
646
+ const variable = shallowRef(initialValue);
647
+ const elRef = computed(() => {
648
+ var _window$document;
649
+ return unrefElement(target) || (window$1 === null || window$1 === void 0 || (_window$document = window$1.document) === null || _window$document === void 0 ? void 0 : _window$document.documentElement);
650
+ });
651
+ function updateCssVar() {
652
+ const key = toValue(prop);
653
+ const el = toValue(elRef);
654
+ if (el && window$1 && key) {
655
+ var _window$getComputedSt;
656
+ variable.value = ((_window$getComputedSt = window$1.getComputedStyle(el).getPropertyValue(key)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.trim()) || variable.value || initialValue;
657
+ }
658
+ }
659
+ if (observe) useMutationObserver(elRef, updateCssVar, {
660
+ attributeFilter: ["style", "class"],
661
+ window: window$1
662
+ });
663
+ watch([elRef, () => toValue(prop)], (_, old) => {
664
+ if (old[0] && old[1]) old[0].style.removeProperty(old[1]);
665
+ updateCssVar();
666
+ }, { immediate: true });
667
+ watch([variable, elRef], ([val, el]) => {
668
+ const raw_prop = toValue(prop);
669
+ if ((el === null || el === void 0 ? void 0 : el.style) && raw_prop) if (val == null) el.style.removeProperty(raw_prop);
670
+ else el.style.setProperty(raw_prop, val);
671
+ }, { immediate: true });
672
+ return variable;
673
+ }
674
+ /**
675
+ * Reports changes to the dimensions of an Element's content or the border-box
676
+ *
677
+ * @see https://vueuse.org/useResizeObserver
678
+ * @param target
679
+ * @param callback
680
+ * @param options
681
+ */
682
+ function useResizeObserver(target, callback, options = {}) {
683
+ const { window: window$1 = defaultWindow, ...observerOptions } = options;
684
+ let observer;
685
+ const isSupported = /* @__PURE__ */ useSupported(() => window$1 && "ResizeObserver" in window$1);
686
+ const cleanup = () => {
687
+ if (observer) {
688
+ observer.disconnect();
689
+ observer = void 0;
690
+ }
691
+ };
692
+ const stopWatch = watch(computed(() => {
693
+ const _targets = toValue(target);
694
+ return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
695
+ }), (els) => {
696
+ cleanup();
697
+ if (isSupported.value && window$1) {
698
+ observer = new ResizeObserver(callback);
699
+ for (const _el of els) if (_el) observer.observe(_el, observerOptions);
700
+ }
701
+ }, {
702
+ immediate: true,
703
+ flush: "post"
704
+ });
705
+ const stop = () => {
706
+ cleanup();
707
+ stopWatch();
708
+ };
709
+ tryOnScopeDispose(stop);
710
+ return {
711
+ isSupported,
712
+ stop
713
+ };
714
+ }
715
+ /**
716
+ * Reactive bounding box of an HTML element.
717
+ *
718
+ * @see https://vueuse.org/useElementBounding
719
+ * @param target
720
+ */
721
+ function useElementBounding(target, options = {}) {
722
+ const { reset = true, windowResize = true, windowScroll = true, immediate = true, updateTiming = "sync" } = options;
723
+ const height = shallowRef(0);
724
+ const bottom = shallowRef(0);
725
+ const left = shallowRef(0);
726
+ const right = shallowRef(0);
727
+ const top = shallowRef(0);
728
+ const width = shallowRef(0);
729
+ const x = shallowRef(0);
730
+ const y = shallowRef(0);
731
+ function recalculate() {
732
+ const el = unrefElement(target);
733
+ if (!el) {
734
+ if (reset) {
735
+ height.value = 0;
736
+ bottom.value = 0;
737
+ left.value = 0;
738
+ right.value = 0;
739
+ top.value = 0;
740
+ width.value = 0;
741
+ x.value = 0;
742
+ y.value = 0;
743
+ }
744
+ return;
745
+ }
746
+ const rect = el.getBoundingClientRect();
747
+ height.value = rect.height;
748
+ bottom.value = rect.bottom;
749
+ left.value = rect.left;
750
+ right.value = rect.right;
751
+ top.value = rect.top;
752
+ width.value = rect.width;
753
+ x.value = rect.x;
754
+ y.value = rect.y;
755
+ }
756
+ function update() {
757
+ if (updateTiming === "sync") recalculate();
758
+ else if (updateTiming === "next-frame") requestAnimationFrame(() => recalculate());
759
+ }
760
+ useResizeObserver(target, update);
761
+ watch(() => unrefElement(target), (ele) => !ele && update());
762
+ useMutationObserver(target, update, { attributeFilter: ["style", "class"] });
763
+ if (windowScroll) useEventListener("scroll", update, {
764
+ capture: true,
765
+ passive: true
766
+ });
767
+ if (windowResize) useEventListener("resize", update, { passive: true });
768
+ tryOnMounted(() => {
769
+ if (immediate) update();
770
+ });
771
+ return {
772
+ height,
773
+ bottom,
774
+ left,
775
+ right,
776
+ top,
777
+ width,
778
+ x,
779
+ y,
780
+ update
781
+ };
782
+ }
783
+ /**
784
+ * Reactive LocalStorage.
785
+ *
786
+ * @see https://vueuse.org/useLocalStorage
787
+ * @param key
788
+ * @param initialValue
789
+ * @param options
790
+ */
791
+ function useLocalStorage(key, initialValue, options = {}) {
792
+ const { window: window$1 = defaultWindow } = options;
793
+ return useStorage(key, initialValue, window$1 === null || window$1 === void 0 ? void 0 : window$1.localStorage, options);
794
+ }
795
+ const topVarName = "--vueuse-safe-area-top";
796
+ const rightVarName = "--vueuse-safe-area-right";
797
+ const bottomVarName = "--vueuse-safe-area-bottom";
798
+ const leftVarName = "--vueuse-safe-area-left";
799
+ /**
800
+ * Reactive `env(safe-area-inset-*)`
801
+ *
802
+ * @see https://vueuse.org/useScreenSafeArea
803
+ */
804
+ function useScreenSafeArea() {
805
+ const top = shallowRef("");
806
+ const right = shallowRef("");
807
+ const bottom = shallowRef("");
808
+ const left = shallowRef("");
809
+ if (isClient) {
810
+ const topCssVar = useCssVar(topVarName);
811
+ const rightCssVar = useCssVar(rightVarName);
812
+ const bottomCssVar = useCssVar(bottomVarName);
813
+ const leftCssVar = useCssVar(leftVarName);
814
+ topCssVar.value = "env(safe-area-inset-top, 0px)";
815
+ rightCssVar.value = "env(safe-area-inset-right, 0px)";
816
+ bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
817
+ leftCssVar.value = "env(safe-area-inset-left, 0px)";
818
+ tryOnMounted(update);
819
+ useEventListener("resize", useDebounceFn(update), { passive: true });
820
+ }
821
+ function update() {
822
+ top.value = getValue(topVarName);
823
+ right.value = getValue(rightVarName);
824
+ bottom.value = getValue(bottomVarName);
825
+ left.value = getValue(leftVarName);
826
+ }
827
+ return {
828
+ top,
829
+ right,
830
+ bottom,
831
+ left,
832
+ update
833
+ };
834
+ }
835
+ function getValue(position) {
836
+ return getComputedStyle(document.documentElement).getPropertyValue(position);
837
+ }
838
+ const DEFAULT_UNITS = [
839
+ {
840
+ max: 6e4,
841
+ value: 1e3,
842
+ name: "second"
843
+ },
844
+ {
845
+ max: 276e4,
846
+ value: 6e4,
847
+ name: "minute"
848
+ },
849
+ {
850
+ max: 72e6,
851
+ value: 36e5,
852
+ name: "hour"
853
+ },
854
+ {
855
+ max: 5184e5,
856
+ value: 864e5,
857
+ name: "day"
858
+ },
859
+ {
860
+ max: 24192e5,
861
+ value: 6048e5,
862
+ name: "week"
863
+ },
864
+ {
865
+ max: 28512e6,
866
+ value: 2592e6,
867
+ name: "month"
868
+ },
869
+ {
870
+ max: Number.POSITIVE_INFINITY,
871
+ value: 31536e6,
872
+ name: "year"
873
+ }
874
+ ];
875
+ /**
876
+ * Reactive window size.
877
+ *
878
+ * @see https://vueuse.org/useWindowSize
879
+ * @param options
880
+ *
881
+ * @__NO_SIDE_EFFECTS__
882
+ */
883
+ function useWindowSize(options = {}) {
884
+ const { window: window$1 = defaultWindow, initialWidth = Number.POSITIVE_INFINITY, initialHeight = Number.POSITIVE_INFINITY, listenOrientation = true, includeScrollbar = true, type = "inner" } = options;
885
+ const width = shallowRef(initialWidth);
886
+ const height = shallowRef(initialHeight);
887
+ const update = () => {
888
+ if (window$1) if (type === "outer") {
889
+ width.value = window$1.outerWidth;
890
+ height.value = window$1.outerHeight;
891
+ } else if (type === "visual" && window$1.visualViewport) {
892
+ const { width: visualViewportWidth, height: visualViewportHeight, scale } = window$1.visualViewport;
893
+ width.value = Math.round(visualViewportWidth * scale);
894
+ height.value = Math.round(visualViewportHeight * scale);
895
+ } else if (includeScrollbar) {
896
+ width.value = window$1.innerWidth;
897
+ height.value = window$1.innerHeight;
898
+ } else {
899
+ width.value = window$1.document.documentElement.clientWidth;
900
+ height.value = window$1.document.documentElement.clientHeight;
901
+ }
902
+ };
903
+ update();
904
+ tryOnMounted(update);
905
+ const listenerOptions = { passive: true };
906
+ useEventListener("resize", update, listenerOptions);
907
+ if (window$1 && type === "visual" && window$1.visualViewport) useEventListener(window$1.visualViewport, "resize", update, listenerOptions);
908
+ if (listenOrientation) watch(useMediaQuery("(orientation: portrait)"), () => update());
909
+ return {
910
+ width,
911
+ height
912
+ };
913
+ }
914
+
915
+ //#endregion
916
+ export { useScreenSafeArea as a, watchDebounced as c, useLocalStorage as i, watchImmediate as l, useElementBounding as n, useWindowSize as o, useEventListener as r, useDebounceFn as s, onClickOutside as t };