vitepress___@vueuse_core.js (305098B)
1 import { 2 Fragment, 3 TransitionGroup, 4 computed, 5 customRef, 6 defineComponent, 7 effectScope, 8 getCurrentInstance, 9 getCurrentScope, 10 h, 11 hasInjectionContext, 12 inject, 13 isReactive, 14 isReadonly, 15 isRef, 16 markRaw, 17 nextTick, 18 onBeforeMount, 19 onBeforeUnmount, 20 onBeforeUpdate, 21 onMounted, 22 onScopeDispose, 23 onUnmounted, 24 onUpdated, 25 provide, 26 reactive, 27 readonly, 28 ref, 29 shallowReactive, 30 shallowReadonly, 31 shallowRef, 32 toRaw, 33 toRef, 34 toRefs, 35 toValue, 36 unref, 37 watch, 38 watchEffect 39 } from "./chunk-LRIOPKVT.js"; 40 41 // node_modules/@vueuse/shared/dist/index.js 42 function computedEager(fn, options) { 43 var _options$flush; 44 const result = shallowRef(); 45 watchEffect(() => { 46 result.value = fn(); 47 }, { 48 ...options, 49 flush: (_options$flush = options === null || options === void 0 ? void 0 : options.flush) !== null && _options$flush !== void 0 ? _options$flush : "sync" 50 }); 51 return readonly(result); 52 } 53 var eagerComputed = computedEager; 54 function computedWithControl(source, fn, options = {}) { 55 let v = void 0; 56 let track; 57 let trigger; 58 let dirty = true; 59 const update = () => { 60 dirty = true; 61 trigger(); 62 }; 63 watch(source, update, { 64 flush: "sync", 65 ...options 66 }); 67 const get2 = typeof fn === "function" ? fn : fn.get; 68 const set2 = typeof fn === "function" ? void 0 : fn.set; 69 const result = customRef((_track, _trigger) => { 70 track = _track; 71 trigger = _trigger; 72 return { 73 get() { 74 if (dirty) { 75 v = get2(v); 76 dirty = false; 77 } 78 track(); 79 return v; 80 }, 81 set(v2) { 82 set2 === null || set2 === void 0 || set2(v2); 83 } 84 }; 85 }); 86 result.trigger = update; 87 return result; 88 } 89 var controlledComputed = computedWithControl; 90 function createDisposableDirective(origin = {}) { 91 function isFunc(fn) { 92 return typeof fn === "function"; 93 } 94 const normalisedOrigin = isFunc(origin) ? { 95 mounted: origin, 96 updated: origin 97 } : origin; 98 const { mounted, unmounted } = normalisedOrigin; 99 if (!isFunc(mounted)) return origin; 100 const scopeWeakMap = /* @__PURE__ */ new WeakMap(); 101 return { 102 ...normalisedOrigin, 103 mounted(el, binding, vNode, prevNode) { 104 var _scopeWeakMap$get; 105 const scope = (_scopeWeakMap$get = scopeWeakMap.get(el)) !== null && _scopeWeakMap$get !== void 0 ? _scopeWeakMap$get : effectScope(); 106 scopeWeakMap.set(el, scope); 107 scope.run(() => { 108 mounted === null || mounted === void 0 || mounted(el, binding, vNode, prevNode); 109 }); 110 }, 111 unmounted(el, binding, vNode, prevNode) { 112 var _scopeWeakMap$get2; 113 (_scopeWeakMap$get2 = scopeWeakMap.get(el)) === null || _scopeWeakMap$get2 === void 0 || _scopeWeakMap$get2.stop(); 114 scopeWeakMap.delete(el); 115 if (isFunc(unmounted)) unmounted(el, binding, vNode, prevNode); 116 } 117 }; 118 } 119 function tryOnScopeDispose(fn, failSilently) { 120 if (getCurrentScope()) { 121 onScopeDispose(fn, failSilently); 122 return true; 123 } 124 return false; 125 } 126 function createEventHook() { 127 const fns = /* @__PURE__ */ new Set(); 128 const off = (fn) => { 129 fns.delete(fn); 130 }; 131 const clear = () => { 132 fns.clear(); 133 }; 134 const on = (fn) => { 135 fns.add(fn); 136 const offFn = () => off(fn); 137 tryOnScopeDispose(offFn); 138 return { off: offFn }; 139 }; 140 const trigger = (...args) => { 141 return Promise.all(Array.from(fns).map((fn) => fn(...args))); 142 }; 143 return { 144 on, 145 off, 146 trigger, 147 clear 148 }; 149 } 150 function createGlobalState(stateFactory) { 151 let initialized = false; 152 let state; 153 const scope = effectScope(true); 154 return ((...args) => { 155 if (!initialized) { 156 state = scope.run(() => stateFactory(...args)); 157 initialized = true; 158 } 159 return state; 160 }); 161 } 162 var localProvidedStateMap = /* @__PURE__ */ new WeakMap(); 163 var injectLocal = (...args) => { 164 var _getCurrentInstance; 165 const key = args[0]; 166 const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy; 167 const owner = instance !== null && instance !== void 0 ? instance : getCurrentScope(); 168 if (owner == null && !hasInjectionContext()) throw new Error("injectLocal must be called in setup"); 169 if (owner && localProvidedStateMap.has(owner) && key in localProvidedStateMap.get(owner)) return localProvidedStateMap.get(owner)[key]; 170 return inject(...args); 171 }; 172 function provideLocal(key, value) { 173 var _getCurrentInstance; 174 const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy; 175 const owner = instance !== null && instance !== void 0 ? instance : getCurrentScope(); 176 if (owner == null) throw new Error("provideLocal must be called in setup"); 177 if (!localProvidedStateMap.has(owner)) localProvidedStateMap.set(owner, /* @__PURE__ */ Object.create(null)); 178 const localProvidedState = localProvidedStateMap.get(owner); 179 localProvidedState[key] = value; 180 return provide(key, value); 181 } 182 function createInjectionState(composable, options) { 183 const key = (options === null || options === void 0 ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState"); 184 const defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue; 185 const useProvidingState = (...args) => { 186 const state = composable(...args); 187 provideLocal(key, state); 188 return state; 189 }; 190 const useInjectedState = () => injectLocal(key, defaultValue); 191 return [useProvidingState, useInjectedState]; 192 } 193 function createRef(value, deep) { 194 if (deep === true) return ref(value); 195 else return shallowRef(value); 196 } 197 var isClient = typeof window !== "undefined" && typeof document !== "undefined"; 198 var isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; 199 var isDef = (val) => typeof val !== "undefined"; 200 var notNullish = (val) => val != null; 201 var assert = (condition, ...infos) => { 202 if (!condition) console.warn(...infos); 203 }; 204 var toString = Object.prototype.toString; 205 var isObject = (val) => toString.call(val) === "[object Object]"; 206 var now = () => Date.now(); 207 var timestamp = () => +Date.now(); 208 var clamp = (n, min, max) => Math.min(max, Math.max(min, n)); 209 var noop = () => { 210 }; 211 var rand = (min, max) => { 212 min = Math.ceil(min); 213 max = Math.floor(max); 214 return Math.floor(Math.random() * (max - min + 1)) + min; 215 }; 216 var hasOwn = (val, key) => Object.hasOwn(val, key); 217 var isIOS = getIsIOS(); 218 function getIsIOS() { 219 var _window, _window2, _window3; 220 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)); 221 } 222 function toRef2(...args) { 223 if (args.length !== 1) return toRef(...args); 224 const r = args[0]; 225 return typeof r === "function" ? readonly(customRef(() => ({ 226 get: r, 227 set: noop 228 }))) : ref(r); 229 } 230 function createFilterWrapper(filter, fn) { 231 function wrapper(...args) { 232 return new Promise((resolve, reject) => { 233 Promise.resolve(filter(() => fn.apply(this, args), { 234 fn, 235 thisArg: this, 236 args 237 })).then(resolve).catch(reject); 238 }); 239 } 240 return wrapper; 241 } 242 var bypassFilter = (invoke2) => { 243 return invoke2(); 244 }; 245 function debounceFilter(ms, options = {}) { 246 let timer; 247 let maxTimer; 248 let lastRejector = noop; 249 const _clearTimeout = (timer2) => { 250 clearTimeout(timer2); 251 lastRejector(); 252 lastRejector = noop; 253 }; 254 let lastInvoker; 255 const filter = (invoke2) => { 256 const duration = toValue(ms); 257 const maxDuration = toValue(options.maxWait); 258 if (timer) _clearTimeout(timer); 259 if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) { 260 if (maxTimer) { 261 _clearTimeout(maxTimer); 262 maxTimer = void 0; 263 } 264 return Promise.resolve(invoke2()); 265 } 266 return new Promise((resolve, reject) => { 267 lastRejector = options.rejectOnCancel ? reject : resolve; 268 lastInvoker = invoke2; 269 if (maxDuration && !maxTimer) maxTimer = setTimeout(() => { 270 if (timer) _clearTimeout(timer); 271 maxTimer = void 0; 272 resolve(lastInvoker()); 273 }, maxDuration); 274 timer = setTimeout(() => { 275 if (maxTimer) _clearTimeout(maxTimer); 276 maxTimer = void 0; 277 resolve(invoke2()); 278 }, duration); 279 }); 280 }; 281 return filter; 282 } 283 function throttleFilter(...args) { 284 let lastExec = 0; 285 let timer; 286 let isLeading = true; 287 let lastRejector = noop; 288 let lastValue; 289 let ms; 290 let trailing; 291 let leading; 292 let rejectOnCancel; 293 if (!isRef(args[0]) && typeof args[0] === "object") ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]); 294 else [ms, trailing = true, leading = true, rejectOnCancel = false] = args; 295 const clear = () => { 296 if (timer) { 297 clearTimeout(timer); 298 timer = void 0; 299 lastRejector(); 300 lastRejector = noop; 301 } 302 }; 303 const filter = (_invoke) => { 304 const duration = toValue(ms); 305 const elapsed = Date.now() - lastExec; 306 const invoke2 = () => { 307 return lastValue = _invoke(); 308 }; 309 clear(); 310 if (duration <= 0) { 311 lastExec = Date.now(); 312 return invoke2(); 313 } 314 if (elapsed > duration) { 315 lastExec = Date.now(); 316 if (leading || !isLeading) invoke2(); 317 } else if (trailing) lastValue = new Promise((resolve, reject) => { 318 lastRejector = rejectOnCancel ? reject : resolve; 319 timer = setTimeout(() => { 320 lastExec = Date.now(); 321 isLeading = true; 322 resolve(invoke2()); 323 clear(); 324 }, Math.max(0, duration - elapsed)); 325 }); 326 if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration); 327 isLeading = false; 328 return lastValue; 329 }; 330 return filter; 331 } 332 function pausableFilter(extendFilter = bypassFilter, options = {}) { 333 const { initialState = "active" } = options; 334 const isActive = toRef2(initialState === "active"); 335 function pause() { 336 isActive.value = false; 337 } 338 function resume() { 339 isActive.value = true; 340 } 341 const eventFilter = (...args) => { 342 if (isActive.value) extendFilter(...args); 343 }; 344 return { 345 isActive: shallowReadonly(isActive), 346 pause, 347 resume, 348 eventFilter 349 }; 350 } 351 function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") { 352 return new Promise((resolve, reject) => { 353 if (throwOnTimeout) setTimeout(reject, ms, reason); 354 else setTimeout(resolve, ms); 355 }); 356 } 357 function identity(arg) { 358 return arg; 359 } 360 function createSingletonPromise(fn) { 361 let _promise; 362 function wrapper() { 363 if (!_promise) _promise = fn(); 364 return _promise; 365 } 366 wrapper.reset = async () => { 367 const _prev = _promise; 368 _promise = void 0; 369 if (_prev) await _prev; 370 }; 371 return wrapper; 372 } 373 function invoke(fn) { 374 return fn(); 375 } 376 function containsProp(obj, ...props) { 377 return props.some((k) => k in obj); 378 } 379 function increaseWithUnit(target, delta) { 380 var _target$match; 381 if (typeof target === "number") return target + delta; 382 const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || ""; 383 const unit = target.slice(value.length); 384 const result = Number.parseFloat(value) + delta; 385 if (Number.isNaN(result)) return target; 386 return result + unit; 387 } 388 function pxValue(px) { 389 return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px); 390 } 391 function objectPick(obj, keys2, omitUndefined = false) { 392 return keys2.reduce((n, k) => { 393 if (k in obj) { 394 if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k]; 395 } 396 return n; 397 }, {}); 398 } 399 function objectOmit(obj, keys2, omitUndefined = false) { 400 return Object.fromEntries(Object.entries(obj).filter(([key, value]) => { 401 return (!omitUndefined || value !== void 0) && !keys2.includes(key); 402 })); 403 } 404 function objectEntries(obj) { 405 return Object.entries(obj); 406 } 407 function toArray(value) { 408 return Array.isArray(value) ? value : [value]; 409 } 410 function cacheStringFunction(fn) { 411 const cache = /* @__PURE__ */ Object.create(null); 412 return ((str) => { 413 return cache[str] || (cache[str] = fn(str)); 414 }); 415 } 416 var hyphenateRE = /\B([A-Z])/g; 417 var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); 418 var camelizeRE = /-(\w)/g; 419 var camelize = cacheStringFunction((str) => { 420 return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); 421 }); 422 function getLifeCycleTarget(target) { 423 return target || getCurrentInstance(); 424 } 425 function createSharedComposable(composable) { 426 if (!isClient) return composable; 427 let subscribers = 0; 428 let state; 429 let scope; 430 const dispose = () => { 431 subscribers -= 1; 432 if (scope && subscribers <= 0) { 433 scope.stop(); 434 state = void 0; 435 scope = void 0; 436 } 437 }; 438 return ((...args) => { 439 subscribers += 1; 440 if (!scope) { 441 scope = effectScope(true); 442 state = scope.run(() => composable(...args)); 443 } 444 tryOnScopeDispose(dispose); 445 return state; 446 }); 447 } 448 function extendRef(ref2, extend, { enumerable = false, unwrap = true } = {}) { 449 for (const [key, value] of Object.entries(extend)) { 450 if (key === "value") continue; 451 if (isRef(value) && unwrap) Object.defineProperty(ref2, key, { 452 get() { 453 return value.value; 454 }, 455 set(v) { 456 value.value = v; 457 }, 458 enumerable 459 }); 460 else Object.defineProperty(ref2, key, { 461 value, 462 enumerable 463 }); 464 } 465 return ref2; 466 } 467 function get(obj, key) { 468 if (key == null) return unref(obj); 469 return unref(obj)[key]; 470 } 471 function isDefined(v) { 472 return unref(v) != null; 473 } 474 function makeDestructurable(obj, arr) { 475 if (typeof Symbol !== "undefined") { 476 const clone = { ...obj }; 477 Object.defineProperty(clone, Symbol.iterator, { 478 enumerable: false, 479 value() { 480 let index = 0; 481 return { next: () => ({ 482 value: arr[index++], 483 done: index > arr.length 484 }) }; 485 } 486 }); 487 return clone; 488 } else return Object.assign([...arr], obj); 489 } 490 function reactify(fn, options) { 491 const unrefFn = (options === null || options === void 0 ? void 0 : options.computedGetter) === false ? unref : toValue; 492 return function(...args) { 493 return computed(() => fn.apply(this, args.map((i) => unrefFn(i)))); 494 }; 495 } 496 var createReactiveFn = reactify; 497 function reactifyObject(obj, optionsOrKeys = {}) { 498 let keys2 = []; 499 let options; 500 if (Array.isArray(optionsOrKeys)) keys2 = optionsOrKeys; 501 else { 502 options = optionsOrKeys; 503 const { includeOwnProperties = true } = optionsOrKeys; 504 keys2.push(...Object.keys(obj)); 505 if (includeOwnProperties) keys2.push(...Object.getOwnPropertyNames(obj)); 506 } 507 return Object.fromEntries(keys2.map((key) => { 508 const value = obj[key]; 509 return [key, typeof value === "function" ? reactify(value.bind(obj), options) : value]; 510 })); 511 } 512 function toReactive(objectRef) { 513 if (!isRef(objectRef)) return reactive(objectRef); 514 return reactive(new Proxy({}, { 515 get(_, p, receiver) { 516 return unref(Reflect.get(objectRef.value, p, receiver)); 517 }, 518 set(_, p, value) { 519 if (isRef(objectRef.value[p]) && !isRef(value)) objectRef.value[p].value = value; 520 else objectRef.value[p] = value; 521 return true; 522 }, 523 deleteProperty(_, p) { 524 return Reflect.deleteProperty(objectRef.value, p); 525 }, 526 has(_, p) { 527 return Reflect.has(objectRef.value, p); 528 }, 529 ownKeys() { 530 return Object.keys(objectRef.value); 531 }, 532 getOwnPropertyDescriptor() { 533 return { 534 enumerable: true, 535 configurable: true 536 }; 537 } 538 })); 539 } 540 function reactiveComputed(fn) { 541 return toReactive(computed(fn)); 542 } 543 function reactiveOmit(obj, ...keys2) { 544 const flatKeys = keys2.flat(); 545 const predicate = flatKeys[0]; 546 return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(toRefs(obj)).filter((e) => !flatKeys.includes(e[0])))); 547 } 548 function reactivePick(obj, ...keys2) { 549 const flatKeys = keys2.flat(); 550 const predicate = flatKeys[0]; 551 return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef2(obj, k)]))); 552 } 553 function refAutoReset(defaultValue, afterMs = 1e4) { 554 return customRef((track, trigger) => { 555 let value = toValue(defaultValue); 556 let timer; 557 const resetAfter = () => setTimeout(() => { 558 value = toValue(defaultValue); 559 trigger(); 560 }, toValue(afterMs)); 561 tryOnScopeDispose(() => { 562 clearTimeout(timer); 563 }); 564 return { 565 get() { 566 track(); 567 return value; 568 }, 569 set(newValue) { 570 value = newValue; 571 trigger(); 572 clearTimeout(timer); 573 timer = resetAfter(); 574 } 575 }; 576 }); 577 } 578 var autoResetRef = refAutoReset; 579 function useDebounceFn(fn, ms = 200, options = {}) { 580 return createFilterWrapper(debounceFilter(ms, options), fn); 581 } 582 function refDebounced(value, ms = 200, options = {}) { 583 const debounced = ref(toValue(value)); 584 const updater = useDebounceFn(() => { 585 debounced.value = value.value; 586 }, ms, options); 587 watch(value, () => updater()); 588 return shallowReadonly(debounced); 589 } 590 var debouncedRef = refDebounced; 591 var useDebounce = refDebounced; 592 function refDefault(source, defaultValue) { 593 return computed({ 594 get() { 595 var _source$value; 596 return (_source$value = source.value) !== null && _source$value !== void 0 ? _source$value : defaultValue; 597 }, 598 set(value) { 599 source.value = value; 600 } 601 }); 602 } 603 function refManualReset(defaultValue) { 604 let value = toValue(defaultValue); 605 let trigger; 606 const reset = () => { 607 value = toValue(defaultValue); 608 trigger(); 609 }; 610 const refValue = customRef((track, _trigger) => { 611 trigger = _trigger; 612 return { 613 get() { 614 track(); 615 return value; 616 }, 617 set(newValue) { 618 value = newValue; 619 trigger(); 620 } 621 }; 622 }); 623 refValue.reset = reset; 624 return refValue; 625 } 626 function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) { 627 return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn); 628 } 629 function refThrottled(value, delay = 200, trailing = true, leading = true) { 630 if (delay <= 0) return value; 631 const throttled = ref(toValue(value)); 632 const updater = useThrottleFn(() => { 633 throttled.value = value.value; 634 }, delay, trailing, leading); 635 watch(value, () => updater()); 636 return throttled; 637 } 638 var throttledRef = refThrottled; 639 var useThrottle = refThrottled; 640 function refWithControl(initial, options = {}) { 641 let source = initial; 642 let track; 643 let trigger; 644 const ref2 = customRef((_track, _trigger) => { 645 track = _track; 646 trigger = _trigger; 647 return { 648 get() { 649 return get2(); 650 }, 651 set(v) { 652 set2(v); 653 } 654 }; 655 }); 656 function get2(tracking = true) { 657 if (tracking) track(); 658 return source; 659 } 660 function set2(value, triggering = true) { 661 var _options$onBeforeChan, _options$onChanged; 662 if (value === source) return; 663 const old = source; 664 if (((_options$onBeforeChan = options.onBeforeChange) === null || _options$onBeforeChan === void 0 ? void 0 : _options$onBeforeChan.call(options, value, old)) === false) return; 665 source = value; 666 (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, value, old); 667 if (triggering) trigger(); 668 } 669 const untrackedGet = () => get2(false); 670 const silentSet = (v) => set2(v, false); 671 const peek = () => get2(false); 672 const lay = (v) => set2(v, false); 673 return extendRef(ref2, { 674 get: get2, 675 set: set2, 676 untrackedGet, 677 silentSet, 678 peek, 679 lay 680 }, { enumerable: true }); 681 } 682 var controlledRef = refWithControl; 683 function set(...args) { 684 if (args.length === 2) { 685 const [ref2, value] = args; 686 ref2.value = value; 687 } 688 if (args.length === 3) { 689 const [target, key, value] = args; 690 target[key] = value; 691 } 692 } 693 function watchWithFilter(source, cb, options = {}) { 694 const { eventFilter = bypassFilter, ...watchOptions } = options; 695 return watch(source, createFilterWrapper(eventFilter, cb), watchOptions); 696 } 697 function watchPausable(source, cb, options = {}) { 698 const { eventFilter: filter, initialState = "active", ...watchOptions } = options; 699 const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState }); 700 return { 701 stop: watchWithFilter(source, cb, { 702 ...watchOptions, 703 eventFilter 704 }), 705 pause, 706 resume, 707 isActive 708 }; 709 } 710 var pausableWatch = watchPausable; 711 function syncRef(left, right, ...[options]) { 712 const { flush = "sync", deep = false, immediate = true, direction = "both", transform = {} } = options || {}; 713 const watchers = []; 714 const transformLTR = "ltr" in transform && transform.ltr || ((v) => v); 715 const transformRTL = "rtl" in transform && transform.rtl || ((v) => v); 716 if (direction === "both" || direction === "ltr") watchers.push(watchPausable(left, (newValue) => { 717 watchers.forEach((w) => w.pause()); 718 right.value = transformLTR(newValue); 719 watchers.forEach((w) => w.resume()); 720 }, { 721 flush, 722 deep, 723 immediate 724 })); 725 if (direction === "both" || direction === "rtl") watchers.push(watchPausable(right, (newValue) => { 726 watchers.forEach((w) => w.pause()); 727 left.value = transformRTL(newValue); 728 watchers.forEach((w) => w.resume()); 729 }, { 730 flush, 731 deep, 732 immediate 733 })); 734 const stop = () => { 735 watchers.forEach((w) => w.stop()); 736 }; 737 return stop; 738 } 739 function syncRefs(source, targets, options = {}) { 740 const { flush = "sync", deep = false, immediate = true } = options; 741 const targetsArray = toArray(targets); 742 return watch(source, (newValue) => targetsArray.forEach((target) => target.value = newValue), { 743 flush, 744 deep, 745 immediate 746 }); 747 } 748 function toRefs2(objectRef, options = {}) { 749 if (!isRef(objectRef)) return toRefs(objectRef); 750 const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {}; 751 for (const key in objectRef.value) result[key] = customRef(() => ({ 752 get() { 753 return objectRef.value[key]; 754 }, 755 set(v) { 756 var _toValue; 757 if ((_toValue = toValue(options.replaceRef)) !== null && _toValue !== void 0 ? _toValue : true) if (Array.isArray(objectRef.value)) { 758 const copy = [...objectRef.value]; 759 copy[key] = v; 760 objectRef.value = copy; 761 } else { 762 const newObject = { 763 ...objectRef.value, 764 [key]: v 765 }; 766 Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value)); 767 objectRef.value = newObject; 768 } 769 else objectRef.value[key] = v; 770 } 771 })); 772 return result; 773 } 774 function tryOnBeforeMount(fn, sync = true, target) { 775 if (getLifeCycleTarget(target)) onBeforeMount(fn, target); 776 else if (sync) fn(); 777 else nextTick(fn); 778 } 779 function tryOnBeforeUnmount(fn, target) { 780 if (getLifeCycleTarget(target)) onBeforeUnmount(fn, target); 781 } 782 function tryOnMounted(fn, sync = true, target) { 783 if (getLifeCycleTarget(target)) onMounted(fn, target); 784 else if (sync) fn(); 785 else nextTick(fn); 786 } 787 function tryOnUnmounted(fn, target) { 788 if (getLifeCycleTarget(target)) onUnmounted(fn, target); 789 } 790 function createUntil(r, isNot = false) { 791 function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) { 792 let stop = null; 793 const promises = [new Promise((resolve) => { 794 stop = watch(r, (v) => { 795 if (condition(v) !== isNot) { 796 if (stop) stop(); 797 else nextTick(() => stop === null || stop === void 0 ? void 0 : stop()); 798 resolve(v); 799 } 800 }, { 801 flush, 802 deep, 803 immediate: true 804 }); 805 })]; 806 if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop === null || stop === void 0 ? void 0 : stop())); 807 return Promise.race(promises); 808 } 809 function toBe(value, options) { 810 if (!isRef(value)) return toMatch((v) => v === value, options); 811 const { flush = "sync", deep = false, timeout, throwOnTimeout } = options !== null && options !== void 0 ? options : {}; 812 let stop = null; 813 const promises = [new Promise((resolve) => { 814 stop = watch([r, value], ([v1, v2]) => { 815 if (isNot !== (v1 === v2)) { 816 if (stop) stop(); 817 else nextTick(() => stop === null || stop === void 0 ? void 0 : stop()); 818 resolve(v1); 819 } 820 }, { 821 flush, 822 deep, 823 immediate: true 824 }); 825 })]; 826 if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => { 827 stop === null || stop === void 0 || stop(); 828 return toValue(r); 829 })); 830 return Promise.race(promises); 831 } 832 function toBeTruthy(options) { 833 return toMatch((v) => Boolean(v), options); 834 } 835 function toBeNull(options) { 836 return toBe(null, options); 837 } 838 function toBeUndefined(options) { 839 return toBe(void 0, options); 840 } 841 function toBeNaN(options) { 842 return toMatch(Number.isNaN, options); 843 } 844 function toContains(value, options) { 845 return toMatch((v) => { 846 const array = Array.from(v); 847 return array.includes(value) || array.includes(toValue(value)); 848 }, options); 849 } 850 function changed(options) { 851 return changedTimes(1, options); 852 } 853 function changedTimes(n = 1, options) { 854 let count = -1; 855 return toMatch(() => { 856 count += 1; 857 return count >= n; 858 }, options); 859 } 860 if (Array.isArray(toValue(r))) return { 861 toMatch, 862 toContains, 863 changed, 864 changedTimes, 865 get not() { 866 return createUntil(r, !isNot); 867 } 868 }; 869 else return { 870 toMatch, 871 toBe, 872 toBeTruthy, 873 toBeNull, 874 toBeNaN, 875 toBeUndefined, 876 changed, 877 changedTimes, 878 get not() { 879 return createUntil(r, !isNot); 880 } 881 }; 882 } 883 function until(r) { 884 return createUntil(r); 885 } 886 function defaultComparator(value, othVal) { 887 return value === othVal; 888 } 889 function useArrayDifference(...args) { 890 var _args$, _args$2; 891 const list = args[0]; 892 const values = args[1]; 893 let compareFn = (_args$ = args[2]) !== null && _args$ !== void 0 ? _args$ : defaultComparator; 894 const { symmetric = false } = (_args$2 = args[3]) !== null && _args$2 !== void 0 ? _args$2 : {}; 895 if (typeof compareFn === "string") { 896 const key = compareFn; 897 compareFn = (value, othVal) => value[key] === othVal[key]; 898 } 899 const diff1 = computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1)); 900 if (symmetric) { 901 const diff2 = computed(() => toValue(values).filter((x) => toValue(list).findIndex((y) => compareFn(x, y)) === -1)); 902 return computed(() => symmetric ? [...toValue(diff1), ...toValue(diff2)] : toValue(diff1)); 903 } else return diff1; 904 } 905 function useArrayEvery(list, fn) { 906 return computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array))); 907 } 908 function useArrayFilter(list, fn) { 909 return computed(() => toValue(list).map((i) => toValue(i)).filter(fn)); 910 } 911 function useArrayFind(list, fn) { 912 return computed(() => toValue(toValue(list).find((element, index, array) => fn(toValue(element), index, array)))); 913 } 914 function useArrayFindIndex(list, fn) { 915 return computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array))); 916 } 917 function findLast(arr, cb) { 918 let index = arr.length; 919 while (index-- > 0) if (cb(arr[index], index, arr)) return arr[index]; 920 } 921 function useArrayFindLast(list, fn) { 922 return computed(() => toValue(!Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array)))); 923 } 924 function isArrayIncludesOptions(obj) { 925 return isObject(obj) && containsProp(obj, "formIndex", "comparator"); 926 } 927 function useArrayIncludes(...args) { 928 var _comparator; 929 const list = args[0]; 930 const value = args[1]; 931 let comparator = args[2]; 932 let formIndex = 0; 933 if (isArrayIncludesOptions(comparator)) { 934 var _comparator$fromIndex; 935 formIndex = (_comparator$fromIndex = comparator.fromIndex) !== null && _comparator$fromIndex !== void 0 ? _comparator$fromIndex : 0; 936 comparator = comparator.comparator; 937 } 938 if (typeof comparator === "string") { 939 const key = comparator; 940 comparator = (element, value2) => element[key] === toValue(value2); 941 } 942 comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value2) => element === toValue(value2)); 943 return computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array)))); 944 } 945 function useArrayJoin(list, separator) { 946 return computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator))); 947 } 948 function useArrayMap(list, fn) { 949 return computed(() => toValue(list).map((i) => toValue(i)).map(fn)); 950 } 951 function useArrayReduce(list, reducer, ...args) { 952 const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index); 953 return computed(() => { 954 const resolved = toValue(list); 955 return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback); 956 }); 957 } 958 function useArraySome(list, fn) { 959 return computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array))); 960 } 961 function uniq(array) { 962 return Array.from(new Set(array)); 963 } 964 function uniqueElementsBy(array, fn) { 965 return array.reduce((acc, v) => { 966 if (!acc.some((x) => fn(v, x, array))) acc.push(v); 967 return acc; 968 }, []); 969 } 970 function useArrayUnique(list, compareFn) { 971 return computed(() => { 972 const resolvedList = toValue(list).map((element) => toValue(element)); 973 return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList); 974 }); 975 } 976 function useCounter(initialValue = 0, options = {}) { 977 let _initialValue = unref(initialValue); 978 const count = shallowRef(initialValue); 979 const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options; 980 const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min); 981 const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max); 982 const get2 = () => count.value; 983 const set2 = (val) => count.value = Math.max(min, Math.min(max, val)); 984 const reset = (val = _initialValue) => { 985 _initialValue = val; 986 return set2(val); 987 }; 988 return { 989 count: shallowReadonly(count), 990 inc, 991 dec, 992 get: get2, 993 set: set2, 994 reset 995 }; 996 } 997 var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i; 998 var 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; 999 function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) { 1000 let m = hours < 12 ? "AM" : "PM"; 1001 if (hasPeriod) m = m.split("").reduce((acc, curr) => acc += `${curr}.`, ""); 1002 return isLowercase ? m.toLowerCase() : m; 1003 } 1004 function formatOrdinal(num) { 1005 const suffixes = [ 1006 "th", 1007 "st", 1008 "nd", 1009 "rd" 1010 ]; 1011 const v = num % 100; 1012 return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]); 1013 } 1014 function formatDate(date, formatStr, options = {}) { 1015 var _options$customMeridi; 1016 const years = date.getFullYear(); 1017 const month = date.getMonth(); 1018 const days = date.getDate(); 1019 const hours = date.getHours(); 1020 const minutes = date.getMinutes(); 1021 const seconds = date.getSeconds(); 1022 const milliseconds = date.getMilliseconds(); 1023 const day = date.getDay(); 1024 const meridiem = (_options$customMeridi = options.customMeridiem) !== null && _options$customMeridi !== void 0 ? _options$customMeridi : defaultMeridiem; 1025 const stripTimeZone = (dateString) => { 1026 var _dateString$split$; 1027 return (_dateString$split$ = dateString.split(" ")[1]) !== null && _dateString$split$ !== void 0 ? _dateString$split$ : ""; 1028 }; 1029 const matches = { 1030 Yo: () => formatOrdinal(years), 1031 YY: () => String(years).slice(-2), 1032 YYYY: () => years, 1033 M: () => month + 1, 1034 Mo: () => formatOrdinal(month + 1), 1035 MM: () => `${month + 1}`.padStart(2, "0"), 1036 MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }), 1037 MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }), 1038 D: () => String(days), 1039 Do: () => formatOrdinal(days), 1040 DD: () => `${days}`.padStart(2, "0"), 1041 H: () => String(hours), 1042 Ho: () => formatOrdinal(hours), 1043 HH: () => `${hours}`.padStart(2, "0"), 1044 h: () => `${hours % 12 || 12}`.padStart(1, "0"), 1045 ho: () => formatOrdinal(hours % 12 || 12), 1046 hh: () => `${hours % 12 || 12}`.padStart(2, "0"), 1047 m: () => String(minutes), 1048 mo: () => formatOrdinal(minutes), 1049 mm: () => `${minutes}`.padStart(2, "0"), 1050 s: () => String(seconds), 1051 so: () => formatOrdinal(seconds), 1052 ss: () => `${seconds}`.padStart(2, "0"), 1053 SSS: () => `${milliseconds}`.padStart(3, "0"), 1054 d: () => day, 1055 dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }), 1056 ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }), 1057 dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }), 1058 A: () => meridiem(hours, minutes), 1059 AA: () => meridiem(hours, minutes, false, true), 1060 a: () => meridiem(hours, minutes, true), 1061 aa: () => meridiem(hours, minutes, true, true), 1062 z: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "shortOffset" })), 1063 zz: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "shortOffset" })), 1064 zzz: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "shortOffset" })), 1065 zzzz: () => stripTimeZone(date.toLocaleDateString(toValue(options.locales), { timeZoneName: "longOffset" })) 1066 }; 1067 return formatStr.replace(REGEX_FORMAT, (match, $1) => { 1068 var _ref, _matches$match; 1069 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; 1070 }); 1071 } 1072 function normalizeDate(date) { 1073 if (date === null) return /* @__PURE__ */ new Date(NaN); 1074 if (date === void 0) return /* @__PURE__ */ new Date(); 1075 if (date instanceof Date) return new Date(date); 1076 if (typeof date === "string" && !/Z$/i.test(date)) { 1077 const d = date.match(REGEX_PARSE); 1078 if (d) { 1079 const m = d[2] - 1 || 0; 1080 const ms = (d[7] || "0").substring(0, 3); 1081 return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms); 1082 } 1083 } 1084 return new Date(date); 1085 } 1086 function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) { 1087 return computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options)); 1088 } 1089 function useIntervalFn(cb, interval = 1e3, options = {}) { 1090 const { immediate = true, immediateCallback = false } = options; 1091 let timer = null; 1092 const isActive = shallowRef(false); 1093 function clean() { 1094 if (timer) { 1095 clearInterval(timer); 1096 timer = null; 1097 } 1098 } 1099 function pause() { 1100 isActive.value = false; 1101 clean(); 1102 } 1103 function resume() { 1104 const intervalValue = toValue(interval); 1105 if (intervalValue <= 0) return; 1106 isActive.value = true; 1107 if (immediateCallback) cb(); 1108 clean(); 1109 if (isActive.value) timer = setInterval(cb, intervalValue); 1110 } 1111 if (immediate && isClient) resume(); 1112 if (isRef(interval) || typeof interval === "function") tryOnScopeDispose(watch(interval, () => { 1113 if (isActive.value && isClient) resume(); 1114 })); 1115 tryOnScopeDispose(pause); 1116 return { 1117 isActive: shallowReadonly(isActive), 1118 pause, 1119 resume 1120 }; 1121 } 1122 function useInterval(interval = 1e3, options = {}) { 1123 const { controls: exposeControls = false, immediate = true, callback } = options; 1124 const counter = shallowRef(0); 1125 const update = () => counter.value += 1; 1126 const reset = () => { 1127 counter.value = 0; 1128 }; 1129 const controls = useIntervalFn(callback ? () => { 1130 update(); 1131 callback(counter.value); 1132 } : update, interval, { immediate }); 1133 if (exposeControls) return { 1134 counter: shallowReadonly(counter), 1135 reset, 1136 ...controls 1137 }; 1138 else return shallowReadonly(counter); 1139 } 1140 function useLastChanged(source, options = {}) { 1141 var _options$initialValue; 1142 const ms = shallowRef((_options$initialValue = options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : null); 1143 watch(source, () => ms.value = timestamp(), options); 1144 return shallowReadonly(ms); 1145 } 1146 function useTimeoutFn(cb, interval, options = {}) { 1147 const { immediate = true, immediateCallback = false } = options; 1148 const isPending = shallowRef(false); 1149 let timer; 1150 function clear() { 1151 if (timer) { 1152 clearTimeout(timer); 1153 timer = void 0; 1154 } 1155 } 1156 function stop() { 1157 isPending.value = false; 1158 clear(); 1159 } 1160 function start(...args) { 1161 if (immediateCallback) cb(); 1162 clear(); 1163 isPending.value = true; 1164 timer = setTimeout(() => { 1165 isPending.value = false; 1166 timer = void 0; 1167 cb(...args); 1168 }, toValue(interval)); 1169 } 1170 if (immediate) { 1171 isPending.value = true; 1172 if (isClient) start(); 1173 } 1174 tryOnScopeDispose(stop); 1175 return { 1176 isPending: shallowReadonly(isPending), 1177 start, 1178 stop 1179 }; 1180 } 1181 function useTimeout(interval = 1e3, options = {}) { 1182 const { controls: exposeControls = false, callback } = options; 1183 const controls = useTimeoutFn(callback !== null && callback !== void 0 ? callback : noop, interval, options); 1184 const ready = computed(() => !controls.isPending.value); 1185 if (exposeControls) return { 1186 ready, 1187 ...controls 1188 }; 1189 else return ready; 1190 } 1191 function useToNumber(value, options = {}) { 1192 const { method = "parseFloat", radix, nanToZero } = options; 1193 return computed(() => { 1194 let resolved = toValue(value); 1195 if (typeof method === "function") resolved = method(resolved); 1196 else if (typeof resolved === "string") resolved = Number[method](resolved, radix); 1197 if (nanToZero && Number.isNaN(resolved)) resolved = 0; 1198 return resolved; 1199 }); 1200 } 1201 function useToString(value) { 1202 return computed(() => `${toValue(value)}`); 1203 } 1204 function useToggle(initialValue = false, options = {}) { 1205 const { truthyValue = true, falsyValue = false } = options; 1206 const valueIsRef = isRef(initialValue); 1207 const _value = shallowRef(initialValue); 1208 function toggle(value) { 1209 if (arguments.length) { 1210 _value.value = value; 1211 return _value.value; 1212 } else { 1213 const truthy = toValue(truthyValue); 1214 _value.value = _value.value === truthy ? toValue(falsyValue) : truthy; 1215 return _value.value; 1216 } 1217 } 1218 if (valueIsRef) return toggle; 1219 else return [_value, toggle]; 1220 } 1221 function watchArray(source, cb, options) { 1222 let oldList = (options === null || options === void 0 ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : toValue(source)]; 1223 return watch(source, (newList, _, onCleanup) => { 1224 const oldListRemains = Array.from({ length: oldList.length }); 1225 const added = []; 1226 for (const obj of newList) { 1227 let found = false; 1228 for (let i = 0; i < oldList.length; i++) if (!oldListRemains[i] && obj === oldList[i]) { 1229 oldListRemains[i] = true; 1230 found = true; 1231 break; 1232 } 1233 if (!found) added.push(obj); 1234 } 1235 const removed = oldList.filter((_2, i) => !oldListRemains[i]); 1236 cb(newList, oldList, added, removed, onCleanup); 1237 oldList = [...newList]; 1238 }, options); 1239 } 1240 function watchAtMost(source, cb, options) { 1241 const { count, ...watchOptions } = options; 1242 const current = shallowRef(0); 1243 const { stop, resume, pause } = watchWithFilter(source, (...args) => { 1244 current.value += 1; 1245 if (current.value >= toValue(count)) nextTick(() => stop()); 1246 cb(...args); 1247 }, watchOptions); 1248 return { 1249 count: current, 1250 stop, 1251 resume, 1252 pause 1253 }; 1254 } 1255 function watchDebounced(source, cb, options = {}) { 1256 const { debounce = 0, maxWait = void 0, ...watchOptions } = options; 1257 return watchWithFilter(source, cb, { 1258 ...watchOptions, 1259 eventFilter: debounceFilter(debounce, { maxWait }) 1260 }); 1261 } 1262 var debouncedWatch = watchDebounced; 1263 function watchDeep(source, cb, options) { 1264 return watch(source, cb, { 1265 ...options, 1266 deep: true 1267 }); 1268 } 1269 function watchIgnorable(source, cb, options = {}) { 1270 const { eventFilter = bypassFilter, ...watchOptions } = options; 1271 const filteredCb = createFilterWrapper(eventFilter, cb); 1272 let ignoreUpdates; 1273 let ignorePrevAsyncUpdates; 1274 let stop; 1275 if (watchOptions.flush === "sync") { 1276 let ignore = false; 1277 ignorePrevAsyncUpdates = () => { 1278 }; 1279 ignoreUpdates = (updater) => { 1280 ignore = true; 1281 updater(); 1282 ignore = false; 1283 }; 1284 stop = watch(source, (...args) => { 1285 if (!ignore) filteredCb(...args); 1286 }, watchOptions); 1287 } else { 1288 const disposables = []; 1289 let ignoreCounter = 0; 1290 let syncCounter = 0; 1291 ignorePrevAsyncUpdates = () => { 1292 ignoreCounter = syncCounter; 1293 }; 1294 disposables.push(watch(source, () => { 1295 syncCounter++; 1296 }, { 1297 ...watchOptions, 1298 flush: "sync" 1299 })); 1300 ignoreUpdates = (updater) => { 1301 const syncCounterPrev = syncCounter; 1302 updater(); 1303 ignoreCounter += syncCounter - syncCounterPrev; 1304 }; 1305 disposables.push(watch(source, (...args) => { 1306 const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter; 1307 ignoreCounter = 0; 1308 syncCounter = 0; 1309 if (ignore) return; 1310 filteredCb(...args); 1311 }, watchOptions)); 1312 stop = () => { 1313 disposables.forEach((fn) => fn()); 1314 }; 1315 } 1316 return { 1317 stop, 1318 ignoreUpdates, 1319 ignorePrevAsyncUpdates 1320 }; 1321 } 1322 var ignorableWatch = watchIgnorable; 1323 function watchImmediate(source, cb, options) { 1324 return watch(source, cb, { 1325 ...options, 1326 immediate: true 1327 }); 1328 } 1329 function watchOnce(source, cb, options) { 1330 return watch(source, cb, { 1331 ...options, 1332 once: true 1333 }); 1334 } 1335 function watchThrottled(source, cb, options = {}) { 1336 const { throttle = 0, trailing = true, leading = true, ...watchOptions } = options; 1337 return watchWithFilter(source, cb, { 1338 ...watchOptions, 1339 eventFilter: throttleFilter(throttle, trailing, leading) 1340 }); 1341 } 1342 var throttledWatch = watchThrottled; 1343 function watchTriggerable(source, cb, options = {}) { 1344 let cleanupFn; 1345 function onEffect() { 1346 if (!cleanupFn) return; 1347 const fn = cleanupFn; 1348 cleanupFn = void 0; 1349 fn(); 1350 } 1351 function onCleanup(callback) { 1352 cleanupFn = callback; 1353 } 1354 const _cb = (value, oldValue) => { 1355 onEffect(); 1356 return cb(value, oldValue, onCleanup); 1357 }; 1358 const res = watchIgnorable(source, _cb, options); 1359 const { ignoreUpdates } = res; 1360 const trigger = () => { 1361 let res2; 1362 ignoreUpdates(() => { 1363 res2 = _cb(getWatchSources(source), getOldValue(source)); 1364 }); 1365 return res2; 1366 }; 1367 return { 1368 ...res, 1369 trigger 1370 }; 1371 } 1372 function getWatchSources(sources) { 1373 if (isReactive(sources)) return sources; 1374 if (Array.isArray(sources)) return sources.map((item) => toValue(item)); 1375 return toValue(sources); 1376 } 1377 function getOldValue(source) { 1378 return Array.isArray(source) ? source.map(() => void 0) : void 0; 1379 } 1380 function whenever(source, cb, options) { 1381 const stop = watch(source, (v, ov, onInvalidate) => { 1382 if (v) { 1383 if (options === null || options === void 0 ? void 0 : options.once) nextTick(() => stop()); 1384 cb(v, ov, onInvalidate); 1385 } 1386 }, { 1387 ...options, 1388 once: false 1389 }); 1390 return stop; 1391 } 1392 1393 // node_modules/@vueuse/core/dist/index.js 1394 function computedAsync(evaluationCallback, initialState, optionsOrRef) { 1395 var _globalThis$reportErr; 1396 let options; 1397 if (isRef(optionsOrRef)) options = { evaluating: optionsOrRef }; 1398 else options = optionsOrRef || {}; 1399 const { lazy = false, flush = "sync", evaluating = void 0, shallow = true, onError = (_globalThis$reportErr = globalThis.reportError) !== null && _globalThis$reportErr !== void 0 ? _globalThis$reportErr : noop } = options; 1400 const started = shallowRef(!lazy); 1401 const current = shallow ? shallowRef(initialState) : ref(initialState); 1402 let counter = 0; 1403 watchEffect(async (onInvalidate) => { 1404 if (!started.value) return; 1405 counter++; 1406 const counterAtBeginning = counter; 1407 let hasFinished = false; 1408 if (evaluating) Promise.resolve().then(() => { 1409 evaluating.value = true; 1410 }); 1411 try { 1412 const result = await evaluationCallback((cancelCallback) => { 1413 onInvalidate(() => { 1414 if (evaluating) evaluating.value = false; 1415 if (!hasFinished) cancelCallback(); 1416 }); 1417 }); 1418 if (counterAtBeginning === counter) current.value = result; 1419 } catch (e) { 1420 onError(e); 1421 } finally { 1422 if (evaluating && counterAtBeginning === counter) evaluating.value = false; 1423 hasFinished = true; 1424 } 1425 }, { flush }); 1426 if (lazy) return computed(() => { 1427 started.value = true; 1428 return current.value; 1429 }); 1430 else return current; 1431 } 1432 var asyncComputed = computedAsync; 1433 function computedInject(key, options, defaultSource, treatDefaultAsFactory) { 1434 let source = inject(key); 1435 if (defaultSource) source = inject(key, defaultSource); 1436 if (treatDefaultAsFactory) source = inject(key, defaultSource, treatDefaultAsFactory); 1437 if (typeof options === "function") return computed((oldValue) => options(source, oldValue)); 1438 else return computed({ 1439 get: (oldValue) => options.get(source, oldValue), 1440 set: options.set 1441 }); 1442 } 1443 function createReusableTemplate(options = {}) { 1444 const { inheritAttrs = true, name = "ReusableTemplate" } = options; 1445 const render = shallowRef(); 1446 const define = defineComponent({ 1447 name: `${name}.define`, 1448 setup(_, { slots }) { 1449 return () => { 1450 render.value = slots.default; 1451 }; 1452 } 1453 }); 1454 const reuse = defineComponent({ 1455 inheritAttrs, 1456 name: `${name}.reuse`, 1457 props: options.props, 1458 setup(props, { attrs, slots }) { 1459 return () => { 1460 var _render$value; 1461 if (!render.value && true) throw new Error("[VueUse] Failed to find the definition of reusable template"); 1462 const vnode = (_render$value = render.value) === null || _render$value === void 0 ? void 0 : _render$value.call(render, { 1463 ...options.props == null ? keysToCamelKebabCase(attrs) : props, 1464 $slots: slots 1465 }); 1466 return inheritAttrs && (vnode === null || vnode === void 0 ? void 0 : vnode.length) === 1 ? vnode[0] : vnode; 1467 }; 1468 } 1469 }); 1470 return makeDestructurable({ 1471 define, 1472 reuse 1473 }, [define, reuse]); 1474 } 1475 function keysToCamelKebabCase(obj) { 1476 const newObj = {}; 1477 for (const key in obj) newObj[camelize(key)] = obj[key]; 1478 return newObj; 1479 } 1480 function createTemplatePromise(options = {}) { 1481 let index = 0; 1482 const instances = ref([]); 1483 function create(...args) { 1484 const props = shallowReactive({ 1485 key: index++, 1486 args, 1487 promise: void 0, 1488 resolve: () => { 1489 }, 1490 reject: () => { 1491 }, 1492 isResolving: false, 1493 options 1494 }); 1495 instances.value.push(props); 1496 props.promise = new Promise((_resolve, _reject) => { 1497 props.resolve = (v) => { 1498 props.isResolving = true; 1499 return _resolve(v); 1500 }; 1501 props.reject = _reject; 1502 }).finally(() => { 1503 props.promise = void 0; 1504 const index2 = instances.value.indexOf(props); 1505 if (index2 !== -1) instances.value.splice(index2, 1); 1506 }); 1507 return props.promise; 1508 } 1509 function start(...args) { 1510 if (options.singleton && instances.value.length > 0) return instances.value[0].promise; 1511 return create(...args); 1512 } 1513 const component = defineComponent((_, { slots }) => { 1514 const renderList = () => instances.value.map((props) => { 1515 var _slots$default; 1516 return h(Fragment, { key: props.key }, (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots, props)); 1517 }); 1518 if (options.transition) return () => h(TransitionGroup, options.transition, renderList); 1519 return renderList; 1520 }); 1521 component.start = start; 1522 return component; 1523 } 1524 function createUnrefFn(fn) { 1525 return function(...args) { 1526 return fn.apply(this, args.map((i) => toValue(i))); 1527 }; 1528 } 1529 var defaultWindow = isClient ? window : void 0; 1530 var defaultDocument = isClient ? window.document : void 0; 1531 var defaultNavigator = isClient ? window.navigator : void 0; 1532 var defaultLocation = isClient ? window.location : void 0; 1533 function unrefElement(elRef) { 1534 var _$el; 1535 const plain = toValue(elRef); 1536 return (_$el = plain === null || plain === void 0 ? void 0 : plain.$el) !== null && _$el !== void 0 ? _$el : plain; 1537 } 1538 function useEventListener(...args) { 1539 const register = (el, event, listener, options) => { 1540 el.addEventListener(event, listener, options); 1541 return () => el.removeEventListener(event, listener, options); 1542 }; 1543 const firstParamTargets = computed(() => { 1544 const test = toArray(toValue(args[0])).filter((e) => e != null); 1545 return test.every((e) => typeof e !== "string") ? test : void 0; 1546 }); 1547 return watchImmediate(() => { 1548 var _firstParamTargets$va, _firstParamTargets$va2; 1549 return [ 1550 (_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), 1551 toArray(toValue(firstParamTargets.value ? args[1] : args[0])), 1552 toArray(unref(firstParamTargets.value ? args[2] : args[1])), 1553 toValue(firstParamTargets.value ? args[3] : args[2]) 1554 ]; 1555 }, ([raw_targets, raw_events, raw_listeners, raw_options], _, onCleanup) => { 1556 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; 1557 const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options; 1558 const cleanups = raw_targets.flatMap((el) => raw_events.flatMap((event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone)))); 1559 onCleanup(() => { 1560 cleanups.forEach((fn) => fn()); 1561 }); 1562 }, { flush: "post" }); 1563 } 1564 var _iOSWorkaround = false; 1565 function onClickOutside(target, handler, options = {}) { 1566 const { window: window2 = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options; 1567 if (!window2) return controls ? { 1568 stop: noop, 1569 cancel: noop, 1570 trigger: noop 1571 } : noop; 1572 if (isIOS && !_iOSWorkaround) { 1573 _iOSWorkaround = true; 1574 const listenerOptions = { passive: true }; 1575 Array.from(window2.document.body.children).forEach((el) => el.addEventListener("click", noop, listenerOptions)); 1576 window2.document.documentElement.addEventListener("click", noop, listenerOptions); 1577 } 1578 let shouldListen = true; 1579 const shouldIgnore = (event) => { 1580 return toValue(ignore).some((target2) => { 1581 if (typeof target2 === "string") return Array.from(window2.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el)); 1582 else { 1583 const el = unrefElement(target2); 1584 return el && (event.target === el || event.composedPath().includes(el)); 1585 } 1586 }); 1587 }; 1588 function hasMultipleRoots(target2) { 1589 const vm = toValue(target2); 1590 return vm && vm.$.subTree.shapeFlag === 16; 1591 } 1592 function checkMultipleRoots(target2, event) { 1593 const vm = toValue(target2); 1594 const children = vm.$.subTree && vm.$.subTree.children; 1595 if (children == null || !Array.isArray(children)) return false; 1596 return children.some((child) => child.el === event.target || event.composedPath().includes(child.el)); 1597 } 1598 const listener = (event) => { 1599 const el = unrefElement(target); 1600 if (event.target == null) return; 1601 if (!(el instanceof Element) && hasMultipleRoots(target) && checkMultipleRoots(target, event)) return; 1602 if (!el || el === event.target || event.composedPath().includes(el)) return; 1603 if ("detail" in event && event.detail === 0) shouldListen = !shouldIgnore(event); 1604 if (!shouldListen) { 1605 shouldListen = true; 1606 return; 1607 } 1608 handler(event); 1609 }; 1610 let isProcessingClick = false; 1611 const cleanup = [ 1612 useEventListener(window2, "click", (event) => { 1613 if (!isProcessingClick) { 1614 isProcessingClick = true; 1615 setTimeout(() => { 1616 isProcessingClick = false; 1617 }, 0); 1618 listener(event); 1619 } 1620 }, { 1621 passive: true, 1622 capture 1623 }), 1624 useEventListener(window2, "pointerdown", (e) => { 1625 const el = unrefElement(target); 1626 shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el)); 1627 }, { passive: true }), 1628 detectIframe && useEventListener(window2, "blur", (event) => { 1629 setTimeout(() => { 1630 const el = unrefElement(target); 1631 let activeEl = window2.document.activeElement; 1632 while (activeEl === null || activeEl === void 0 ? void 0 : activeEl.shadowRoot) activeEl = activeEl.shadowRoot.activeElement; 1633 if ((activeEl === null || activeEl === void 0 ? void 0 : activeEl.tagName) === "IFRAME" && !(el === null || el === void 0 ? void 0 : el.contains(window2.document.activeElement))) handler(event); 1634 }, 0); 1635 }, { passive: true }) 1636 ].filter(Boolean); 1637 const stop = () => cleanup.forEach((fn) => fn()); 1638 if (controls) return { 1639 stop, 1640 cancel: () => { 1641 shouldListen = false; 1642 }, 1643 trigger: (event) => { 1644 shouldListen = true; 1645 listener(event); 1646 shouldListen = false; 1647 } 1648 }; 1649 return stop; 1650 } 1651 function useMounted() { 1652 const isMounted = shallowRef(false); 1653 const instance = getCurrentInstance(); 1654 if (instance) onMounted(() => { 1655 isMounted.value = true; 1656 }, instance); 1657 return isMounted; 1658 } 1659 function useSupported(callback) { 1660 const isMounted = useMounted(); 1661 return computed(() => { 1662 isMounted.value; 1663 return Boolean(callback()); 1664 }); 1665 } 1666 function useMutationObserver(target, callback, options = {}) { 1667 const { window: window2 = defaultWindow, ...mutationOptions } = options; 1668 let observer; 1669 const isSupported = useSupported(() => window2 && "MutationObserver" in window2); 1670 const cleanup = () => { 1671 if (observer) { 1672 observer.disconnect(); 1673 observer = void 0; 1674 } 1675 }; 1676 const stopWatch = watch(computed(() => { 1677 const items = toArray(toValue(target)).map(unrefElement).filter(notNullish); 1678 return new Set(items); 1679 }), (newTargets) => { 1680 cleanup(); 1681 if (isSupported.value && newTargets.size) { 1682 observer = new MutationObserver(callback); 1683 newTargets.forEach((el) => observer.observe(el, mutationOptions)); 1684 } 1685 }, { 1686 immediate: true, 1687 flush: "post" 1688 }); 1689 const takeRecords = () => { 1690 return observer === null || observer === void 0 ? void 0 : observer.takeRecords(); 1691 }; 1692 const stop = () => { 1693 stopWatch(); 1694 cleanup(); 1695 }; 1696 tryOnScopeDispose(stop); 1697 return { 1698 isSupported, 1699 stop, 1700 takeRecords 1701 }; 1702 } 1703 function onElementRemoval(target, callback, options = {}) { 1704 const { window: window2 = defaultWindow, document: document2 = window2 === null || window2 === void 0 ? void 0 : window2.document, flush = "sync" } = options; 1705 if (!window2 || !document2) return noop; 1706 let stopFn; 1707 const cleanupAndUpdate = (fn) => { 1708 stopFn === null || stopFn === void 0 || stopFn(); 1709 stopFn = fn; 1710 }; 1711 const stopWatch = watchEffect(() => { 1712 const el = unrefElement(target); 1713 if (el) { 1714 const { stop } = useMutationObserver(document2, (mutationsList) => { 1715 if (mutationsList.map((mutation) => [...mutation.removedNodes]).flat().some((node) => node === el || node.contains(el))) callback(mutationsList); 1716 }, { 1717 window: window2, 1718 childList: true, 1719 subtree: true 1720 }); 1721 cleanupAndUpdate(stop); 1722 } 1723 }, { flush }); 1724 const stopHandle = () => { 1725 stopWatch(); 1726 cleanupAndUpdate(); 1727 }; 1728 tryOnScopeDispose(stopHandle); 1729 return stopHandle; 1730 } 1731 function createKeyPredicate(keyFilter) { 1732 if (typeof keyFilter === "function") return keyFilter; 1733 else if (typeof keyFilter === "string") return (event) => event.key === keyFilter; 1734 else if (Array.isArray(keyFilter)) return (event) => keyFilter.includes(event.key); 1735 return () => true; 1736 } 1737 function onKeyStroke(...args) { 1738 let key; 1739 let handler; 1740 let options = {}; 1741 if (args.length === 3) { 1742 key = args[0]; 1743 handler = args[1]; 1744 options = args[2]; 1745 } else if (args.length === 2) if (typeof args[1] === "object") { 1746 key = true; 1747 handler = args[0]; 1748 options = args[1]; 1749 } else { 1750 key = args[0]; 1751 handler = args[1]; 1752 } 1753 else { 1754 key = true; 1755 handler = args[0]; 1756 } 1757 const { target = defaultWindow, eventName = "keydown", passive = false, dedupe = false } = options; 1758 const predicate = createKeyPredicate(key); 1759 const listener = (e) => { 1760 if (e.repeat && toValue(dedupe)) return; 1761 if (predicate(e)) handler(e); 1762 }; 1763 return useEventListener(target, eventName, listener, passive); 1764 } 1765 function onKeyDown(key, handler, options = {}) { 1766 return onKeyStroke(key, handler, { 1767 ...options, 1768 eventName: "keydown" 1769 }); 1770 } 1771 function onKeyPressed(key, handler, options = {}) { 1772 return onKeyStroke(key, handler, { 1773 ...options, 1774 eventName: "keypress" 1775 }); 1776 } 1777 function onKeyUp(key, handler, options = {}) { 1778 return onKeyStroke(key, handler, { 1779 ...options, 1780 eventName: "keyup" 1781 }); 1782 } 1783 var DEFAULT_DELAY = 500; 1784 var DEFAULT_THRESHOLD = 10; 1785 function onLongPress(target, handler, options) { 1786 var _options$modifiers10, _options$modifiers11; 1787 const elementRef = computed(() => unrefElement(target)); 1788 let timeout; 1789 let posStart; 1790 let startTimestamp; 1791 let hasLongPressed = false; 1792 function clear() { 1793 if (timeout) { 1794 clearTimeout(timeout); 1795 timeout = void 0; 1796 } 1797 posStart = void 0; 1798 startTimestamp = void 0; 1799 hasLongPressed = false; 1800 } 1801 function getDelay(ev) { 1802 const delay = options === null || options === void 0 ? void 0 : options.delay; 1803 if (typeof delay === "function") return delay(ev); 1804 return delay !== null && delay !== void 0 ? delay : DEFAULT_DELAY; 1805 } 1806 function onRelease(ev) { 1807 var _options$modifiers, _options$modifiers2, _options$modifiers3; 1808 const [_startTimestamp, _posStart, _hasLongPressed] = [ 1809 startTimestamp, 1810 posStart, 1811 hasLongPressed 1812 ]; 1813 clear(); 1814 if (!(options === null || options === void 0 ? void 0 : options.onMouseUp) || !_posStart || !_startTimestamp) return; 1815 if ((options === null || options === void 0 || (_options$modifiers = options.modifiers) === null || _options$modifiers === void 0 ? void 0 : _options$modifiers.self) && ev.target !== elementRef.value) return; 1816 if (options === null || options === void 0 || (_options$modifiers2 = options.modifiers) === null || _options$modifiers2 === void 0 ? void 0 : _options$modifiers2.prevent) ev.preventDefault(); 1817 if (options === null || options === void 0 || (_options$modifiers3 = options.modifiers) === null || _options$modifiers3 === void 0 ? void 0 : _options$modifiers3.stop) ev.stopPropagation(); 1818 const dx = ev.x - _posStart.x; 1819 const dy = ev.y - _posStart.y; 1820 const distance = Math.sqrt(dx * dx + dy * dy); 1821 options.onMouseUp(ev.timeStamp - _startTimestamp, distance, _hasLongPressed, ev); 1822 } 1823 function onDown(ev) { 1824 var _options$modifiers4, _options$modifiers5, _options$modifiers6; 1825 if ((options === null || options === void 0 || (_options$modifiers4 = options.modifiers) === null || _options$modifiers4 === void 0 ? void 0 : _options$modifiers4.self) && ev.target !== elementRef.value) return; 1826 clear(); 1827 if (options === null || options === void 0 || (_options$modifiers5 = options.modifiers) === null || _options$modifiers5 === void 0 ? void 0 : _options$modifiers5.prevent) ev.preventDefault(); 1828 if (options === null || options === void 0 || (_options$modifiers6 = options.modifiers) === null || _options$modifiers6 === void 0 ? void 0 : _options$modifiers6.stop) ev.stopPropagation(); 1829 posStart = { 1830 x: ev.x, 1831 y: ev.y 1832 }; 1833 startTimestamp = ev.timeStamp; 1834 timeout = setTimeout(() => { 1835 hasLongPressed = true; 1836 handler(ev); 1837 }, getDelay(ev)); 1838 } 1839 function onMove(ev) { 1840 var _options$modifiers7, _options$modifiers8, _options$modifiers9, _options$distanceThre; 1841 if ((options === null || options === void 0 || (_options$modifiers7 = options.modifiers) === null || _options$modifiers7 === void 0 ? void 0 : _options$modifiers7.self) && ev.target !== elementRef.value) return; 1842 if (!posStart || (options === null || options === void 0 ? void 0 : options.distanceThreshold) === false) return; 1843 if (options === null || options === void 0 || (_options$modifiers8 = options.modifiers) === null || _options$modifiers8 === void 0 ? void 0 : _options$modifiers8.prevent) ev.preventDefault(); 1844 if (options === null || options === void 0 || (_options$modifiers9 = options.modifiers) === null || _options$modifiers9 === void 0 ? void 0 : _options$modifiers9.stop) ev.stopPropagation(); 1845 const dx = ev.x - posStart.x; 1846 const dy = ev.y - posStart.y; 1847 if (Math.sqrt(dx * dx + dy * dy) >= ((_options$distanceThre = options === null || options === void 0 ? void 0 : options.distanceThreshold) !== null && _options$distanceThre !== void 0 ? _options$distanceThre : DEFAULT_THRESHOLD)) clear(); 1848 } 1849 const listenerOptions = { 1850 capture: options === null || options === void 0 || (_options$modifiers10 = options.modifiers) === null || _options$modifiers10 === void 0 ? void 0 : _options$modifiers10.capture, 1851 once: options === null || options === void 0 || (_options$modifiers11 = options.modifiers) === null || _options$modifiers11 === void 0 ? void 0 : _options$modifiers11.once 1852 }; 1853 const cleanup = [ 1854 useEventListener(elementRef, "pointerdown", onDown, listenerOptions), 1855 useEventListener(elementRef, "pointermove", onMove, listenerOptions), 1856 useEventListener(elementRef, ["pointerup", "pointerleave"], onRelease, listenerOptions) 1857 ]; 1858 const stop = () => cleanup.forEach((fn) => fn()); 1859 return stop; 1860 } 1861 function isFocusedElementEditable() { 1862 const { activeElement, body } = document; 1863 if (!activeElement) return false; 1864 if (activeElement === body) return false; 1865 switch (activeElement.tagName) { 1866 case "INPUT": 1867 case "TEXTAREA": 1868 return true; 1869 } 1870 return activeElement.hasAttribute("contenteditable"); 1871 } 1872 function isTypedCharValid({ keyCode, metaKey, ctrlKey, altKey }) { 1873 if (metaKey || ctrlKey || altKey) return false; 1874 if (keyCode >= 48 && keyCode <= 57 || keyCode >= 96 && keyCode <= 105) return true; 1875 if (keyCode >= 65 && keyCode <= 90) return true; 1876 return false; 1877 } 1878 function onStartTyping(callback, options = {}) { 1879 const { document: document2 = defaultDocument } = options; 1880 const keydown = (event) => { 1881 if (!isFocusedElementEditable() && isTypedCharValid(event)) callback(event); 1882 }; 1883 if (document2) useEventListener(document2, "keydown", keydown, { passive: true }); 1884 } 1885 function templateRef(key, initialValue = null) { 1886 const instance = getCurrentInstance(); 1887 let _trigger = () => { 1888 }; 1889 const element = customRef((track, trigger) => { 1890 _trigger = trigger; 1891 return { 1892 get() { 1893 var _instance$proxy$$refs, _instance$proxy; 1894 track(); 1895 return (_instance$proxy$$refs = instance === null || instance === void 0 || (_instance$proxy = instance.proxy) === null || _instance$proxy === void 0 ? void 0 : _instance$proxy.$refs[key]) !== null && _instance$proxy$$refs !== void 0 ? _instance$proxy$$refs : initialValue; 1896 }, 1897 set() { 1898 } 1899 }; 1900 }); 1901 tryOnMounted(_trigger); 1902 onUpdated(_trigger); 1903 return element; 1904 } 1905 function useActiveElement(options = {}) { 1906 var _options$document; 1907 const { window: window2 = defaultWindow, deep = true, triggerOnRemoval = false } = options; 1908 const document2 = (_options$document = options.document) !== null && _options$document !== void 0 ? _options$document : window2 === null || window2 === void 0 ? void 0 : window2.document; 1909 const getDeepActiveElement = () => { 1910 let element = document2 === null || document2 === void 0 ? void 0 : document2.activeElement; 1911 if (deep) { 1912 var _element$shadowRoot; 1913 while (element === null || element === void 0 ? void 0 : element.shadowRoot) element = element === null || element === void 0 || (_element$shadowRoot = element.shadowRoot) === null || _element$shadowRoot === void 0 ? void 0 : _element$shadowRoot.activeElement; 1914 } 1915 return element; 1916 }; 1917 const activeElement = shallowRef(); 1918 const trigger = () => { 1919 activeElement.value = getDeepActiveElement(); 1920 }; 1921 if (window2) { 1922 const listenerOptions = { 1923 capture: true, 1924 passive: true 1925 }; 1926 useEventListener(window2, "blur", (event) => { 1927 if (event.relatedTarget !== null) return; 1928 trigger(); 1929 }, listenerOptions); 1930 useEventListener(window2, "focus", trigger, listenerOptions); 1931 } 1932 if (triggerOnRemoval) onElementRemoval(activeElement, trigger, { document: document2 }); 1933 trigger(); 1934 return activeElement; 1935 } 1936 function useRafFn(fn, options = {}) { 1937 const { immediate = true, fpsLimit = null, window: window2 = defaultWindow, once = false } = options; 1938 const isActive = shallowRef(false); 1939 const intervalLimit = computed(() => { 1940 const limit = toValue(fpsLimit); 1941 return limit ? 1e3 / limit : null; 1942 }); 1943 let previousFrameTimestamp = 0; 1944 let rafId = null; 1945 function loop(timestamp2) { 1946 if (!isActive.value || !window2) return; 1947 if (!previousFrameTimestamp) previousFrameTimestamp = timestamp2; 1948 const delta = timestamp2 - previousFrameTimestamp; 1949 if (intervalLimit.value && delta < intervalLimit.value) { 1950 rafId = window2.requestAnimationFrame(loop); 1951 return; 1952 } 1953 previousFrameTimestamp = timestamp2; 1954 fn({ 1955 delta, 1956 timestamp: timestamp2 1957 }); 1958 if (once) { 1959 isActive.value = false; 1960 rafId = null; 1961 return; 1962 } 1963 rafId = window2.requestAnimationFrame(loop); 1964 } 1965 function resume() { 1966 if (!isActive.value && window2) { 1967 isActive.value = true; 1968 previousFrameTimestamp = 0; 1969 rafId = window2.requestAnimationFrame(loop); 1970 } 1971 } 1972 function pause() { 1973 isActive.value = false; 1974 if (rafId != null && window2) { 1975 window2.cancelAnimationFrame(rafId); 1976 rafId = null; 1977 } 1978 } 1979 if (immediate) resume(); 1980 tryOnScopeDispose(pause); 1981 return { 1982 isActive: shallowReadonly(isActive), 1983 pause, 1984 resume 1985 }; 1986 } 1987 function useAnimate(target, keyframes, options) { 1988 let config; 1989 let animateOptions; 1990 if (isObject(options)) { 1991 config = options; 1992 animateOptions = objectOmit(options, [ 1993 "window", 1994 "immediate", 1995 "commitStyles", 1996 "persist", 1997 "onReady", 1998 "onError" 1999 ]); 2000 } else { 2001 config = { duration: options }; 2002 animateOptions = options; 2003 } 2004 const { window: window2 = defaultWindow, immediate = true, commitStyles, persist, playbackRate: _playbackRate = 1, onReady, onError = (e) => { 2005 console.error(e); 2006 } } = config; 2007 const isSupported = useSupported(() => window2 && HTMLElement && "animate" in HTMLElement.prototype); 2008 const animate = shallowRef(void 0); 2009 const store = shallowReactive({ 2010 startTime: null, 2011 currentTime: null, 2012 timeline: null, 2013 playbackRate: _playbackRate, 2014 pending: false, 2015 playState: immediate ? "idle" : "paused", 2016 replaceState: "active" 2017 }); 2018 const pending = computed(() => store.pending); 2019 const playState = computed(() => store.playState); 2020 const replaceState = computed(() => store.replaceState); 2021 const startTime = computed({ 2022 get() { 2023 return store.startTime; 2024 }, 2025 set(value) { 2026 store.startTime = value; 2027 if (animate.value) animate.value.startTime = value; 2028 } 2029 }); 2030 const currentTime = computed({ 2031 get() { 2032 return store.currentTime; 2033 }, 2034 set(value) { 2035 store.currentTime = value; 2036 if (animate.value) { 2037 animate.value.currentTime = value; 2038 syncResume(); 2039 } 2040 } 2041 }); 2042 const timeline = computed({ 2043 get() { 2044 return store.timeline; 2045 }, 2046 set(value) { 2047 store.timeline = value; 2048 if (animate.value) animate.value.timeline = value; 2049 } 2050 }); 2051 const playbackRate = computed({ 2052 get() { 2053 return store.playbackRate; 2054 }, 2055 set(value) { 2056 store.playbackRate = value; 2057 if (animate.value) animate.value.playbackRate = value; 2058 } 2059 }); 2060 const play = () => { 2061 if (animate.value) try { 2062 animate.value.play(); 2063 syncResume(); 2064 } catch (e) { 2065 syncPause(); 2066 onError(e); 2067 } 2068 else update(); 2069 }; 2070 const pause = () => { 2071 try { 2072 var _animate$value; 2073 (_animate$value = animate.value) === null || _animate$value === void 0 || _animate$value.pause(); 2074 syncPause(); 2075 } catch (e) { 2076 onError(e); 2077 } 2078 }; 2079 const reverse = () => { 2080 if (!animate.value) update(); 2081 try { 2082 var _animate$value2; 2083 (_animate$value2 = animate.value) === null || _animate$value2 === void 0 || _animate$value2.reverse(); 2084 syncResume(); 2085 } catch (e) { 2086 syncPause(); 2087 onError(e); 2088 } 2089 }; 2090 const finish = () => { 2091 try { 2092 var _animate$value3; 2093 (_animate$value3 = animate.value) === null || _animate$value3 === void 0 || _animate$value3.finish(); 2094 syncPause(); 2095 } catch (e) { 2096 onError(e); 2097 } 2098 }; 2099 const cancel = () => { 2100 try { 2101 var _animate$value4; 2102 (_animate$value4 = animate.value) === null || _animate$value4 === void 0 || _animate$value4.cancel(); 2103 syncPause(); 2104 } catch (e) { 2105 onError(e); 2106 } 2107 }; 2108 watch(() => unrefElement(target), (el) => { 2109 if (el) update(true); 2110 else animate.value = void 0; 2111 }); 2112 watch(() => keyframes, (value) => { 2113 if (animate.value) { 2114 update(); 2115 const targetEl = unrefElement(target); 2116 if (targetEl) animate.value.effect = new KeyframeEffect(targetEl, toValue(value), animateOptions); 2117 } 2118 }, { deep: true }); 2119 tryOnMounted(() => update(true), false); 2120 tryOnScopeDispose(cancel); 2121 function update(init) { 2122 const el = unrefElement(target); 2123 if (!isSupported.value || !el) return; 2124 if (!animate.value) animate.value = el.animate(toValue(keyframes), animateOptions); 2125 if (persist) animate.value.persist(); 2126 if (_playbackRate !== 1) animate.value.playbackRate = _playbackRate; 2127 if (init && !immediate) animate.value.pause(); 2128 else syncResume(); 2129 onReady === null || onReady === void 0 || onReady(animate.value); 2130 } 2131 const listenerOptions = { passive: true }; 2132 useEventListener(animate, [ 2133 "cancel", 2134 "finish", 2135 "remove" 2136 ], syncPause, listenerOptions); 2137 useEventListener(animate, "finish", () => { 2138 var _animate$value5; 2139 if (commitStyles) (_animate$value5 = animate.value) === null || _animate$value5 === void 0 || _animate$value5.commitStyles(); 2140 }, listenerOptions); 2141 const { resume: resumeRef, pause: pauseRef } = useRafFn(() => { 2142 if (!animate.value) return; 2143 store.pending = animate.value.pending; 2144 store.playState = animate.value.playState; 2145 store.replaceState = animate.value.replaceState; 2146 store.startTime = animate.value.startTime; 2147 store.currentTime = animate.value.currentTime; 2148 store.timeline = animate.value.timeline; 2149 store.playbackRate = animate.value.playbackRate; 2150 }, { immediate: false }); 2151 function syncResume() { 2152 if (isSupported.value) resumeRef(); 2153 } 2154 function syncPause() { 2155 if (isSupported.value && window2) window2.requestAnimationFrame(pauseRef); 2156 } 2157 return { 2158 isSupported, 2159 animate, 2160 play, 2161 pause, 2162 reverse, 2163 finish, 2164 cancel, 2165 pending, 2166 playState, 2167 replaceState, 2168 startTime, 2169 currentTime, 2170 timeline, 2171 playbackRate 2172 }; 2173 } 2174 function useAsyncQueue(tasks, options) { 2175 const { interrupt = true, onError = noop, onFinished = noop, signal } = options || {}; 2176 const promiseState = { 2177 aborted: "aborted", 2178 fulfilled: "fulfilled", 2179 pending: "pending", 2180 rejected: "rejected" 2181 }; 2182 const result = reactive(Array.from(Array.from({ length: tasks.length }), () => ({ 2183 state: promiseState.pending, 2184 data: null 2185 }))); 2186 const activeIndex = shallowRef(-1); 2187 if (!tasks || tasks.length === 0) { 2188 onFinished(); 2189 return { 2190 activeIndex, 2191 result 2192 }; 2193 } 2194 function updateResult(state, res) { 2195 activeIndex.value++; 2196 result[activeIndex.value].data = res; 2197 result[activeIndex.value].state = state; 2198 } 2199 tasks.reduce((prev, curr) => { 2200 return prev.then((prevRes) => { 2201 var _result$activeIndex$v; 2202 if (signal === null || signal === void 0 ? void 0 : signal.aborted) { 2203 updateResult(promiseState.aborted, new Error("aborted")); 2204 return; 2205 } 2206 if (((_result$activeIndex$v = result[activeIndex.value]) === null || _result$activeIndex$v === void 0 ? void 0 : _result$activeIndex$v.state) === promiseState.rejected && interrupt) { 2207 onFinished(); 2208 return; 2209 } 2210 const done = curr(prevRes).then((currentRes) => { 2211 updateResult(promiseState.fulfilled, currentRes); 2212 if (activeIndex.value === tasks.length - 1) onFinished(); 2213 return currentRes; 2214 }); 2215 if (!signal) return done; 2216 return Promise.race([done, whenAborted(signal)]); 2217 }).catch((e) => { 2218 if (signal === null || signal === void 0 ? void 0 : signal.aborted) { 2219 updateResult(promiseState.aborted, e); 2220 return e; 2221 } 2222 updateResult(promiseState.rejected, e); 2223 onError(); 2224 if (activeIndex.value === tasks.length - 1) onFinished(); 2225 return e; 2226 }); 2227 }, Promise.resolve()); 2228 return { 2229 activeIndex, 2230 result 2231 }; 2232 } 2233 function whenAborted(signal) { 2234 return new Promise((resolve, reject) => { 2235 const error = new Error("aborted"); 2236 if (signal.aborted) reject(error); 2237 else signal.addEventListener("abort", () => reject(error), { once: true }); 2238 }); 2239 } 2240 function useAsyncState(promise, initialState, options) { 2241 var _globalThis$reportErr; 2242 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 : {}; 2243 const state = shallow ? shallowRef(initialState) : ref(initialState); 2244 const isReady = shallowRef(false); 2245 const isLoading = shallowRef(false); 2246 const error = shallowRef(void 0); 2247 let executionsCount = 0; 2248 async function execute(delay2 = 0, ...args) { 2249 const executionId = executionsCount += 1; 2250 if (resetOnExecute) state.value = toValue(initialState); 2251 error.value = void 0; 2252 isReady.value = false; 2253 isLoading.value = true; 2254 if (delay2 > 0) await promiseTimeout(delay2); 2255 const _promise = typeof promise === "function" ? promise(...args) : promise; 2256 try { 2257 const data = await _promise; 2258 if (executionId === executionsCount) { 2259 state.value = data; 2260 isReady.value = true; 2261 } 2262 onSuccess(data); 2263 return data; 2264 } catch (e) { 2265 if (executionId === executionsCount) error.value = e; 2266 onError(e); 2267 if (throwError) throw e; 2268 } finally { 2269 if (executionId === executionsCount) isLoading.value = false; 2270 } 2271 } 2272 if (immediate) execute(delay); 2273 const shell = { 2274 state, 2275 isReady, 2276 isLoading, 2277 error, 2278 execute, 2279 executeImmediate: (...args) => execute(0, ...args) 2280 }; 2281 function waitUntilIsLoaded() { 2282 return new Promise((resolve, reject) => { 2283 until(isLoading).toBe(false).then(() => resolve(shell)).catch(reject); 2284 }); 2285 } 2286 return { 2287 ...shell, 2288 then(onFulfilled, onRejected) { 2289 return waitUntilIsLoaded().then(onFulfilled, onRejected); 2290 } 2291 }; 2292 } 2293 var defaults = { 2294 array: (v) => JSON.stringify(v), 2295 object: (v) => JSON.stringify(v), 2296 set: (v) => JSON.stringify(Array.from(v)), 2297 map: (v) => JSON.stringify(Object.fromEntries(v)), 2298 null: () => "" 2299 }; 2300 function getDefaultSerialization(target) { 2301 if (!target) return defaults.null; 2302 if (target instanceof Map) return defaults.map; 2303 else if (target instanceof Set) return defaults.set; 2304 else if (Array.isArray(target)) return defaults.array; 2305 else return defaults.object; 2306 } 2307 function useBase64(target, options) { 2308 const base64 = shallowRef(""); 2309 const promise = shallowRef(); 2310 function execute() { 2311 if (!isClient) return; 2312 promise.value = new Promise((resolve, reject) => { 2313 try { 2314 const _target = toValue(target); 2315 if (_target == null) resolve(""); 2316 else if (typeof _target === "string") resolve(blobToBase64(new Blob([_target], { type: "text/plain" }))); 2317 else if (_target instanceof Blob) resolve(blobToBase64(_target)); 2318 else if (_target instanceof ArrayBuffer) resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target)))); 2319 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)); 2320 else if (_target instanceof HTMLImageElement) { 2321 const img = _target.cloneNode(false); 2322 img.crossOrigin = "Anonymous"; 2323 imgLoaded(img).then(() => { 2324 const canvas = document.createElement("canvas"); 2325 const ctx = canvas.getContext("2d"); 2326 canvas.width = img.width; 2327 canvas.height = img.height; 2328 ctx.drawImage(img, 0, 0, canvas.width, canvas.height); 2329 resolve(canvas.toDataURL(options === null || options === void 0 ? void 0 : options.type, options === null || options === void 0 ? void 0 : options.quality)); 2330 }).catch(reject); 2331 } else if (typeof _target === "object") { 2332 const serialized = ((options === null || options === void 0 ? void 0 : options.serializer) || getDefaultSerialization(_target))(_target); 2333 return resolve(blobToBase64(new Blob([serialized], { type: "application/json" }))); 2334 } else reject(new Error("target is unsupported types")); 2335 } catch (error) { 2336 reject(error); 2337 } 2338 }); 2339 promise.value.then((res) => { 2340 base64.value = (options === null || options === void 0 ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res; 2341 }); 2342 return promise.value; 2343 } 2344 if (isRef(target) || typeof target === "function") watch(target, execute, { immediate: true }); 2345 else execute(); 2346 return { 2347 base64, 2348 promise, 2349 execute 2350 }; 2351 } 2352 function imgLoaded(img) { 2353 return new Promise((resolve, reject) => { 2354 if (!img.complete) { 2355 img.onload = () => { 2356 resolve(); 2357 }; 2358 img.onerror = reject; 2359 } else resolve(); 2360 }); 2361 } 2362 function blobToBase64(blob) { 2363 return new Promise((resolve, reject) => { 2364 const fr = new FileReader(); 2365 fr.onload = (e) => { 2366 resolve(e.target.result); 2367 }; 2368 fr.onerror = reject; 2369 fr.readAsDataURL(blob); 2370 }); 2371 } 2372 function useBattery(options = {}) { 2373 const { navigator: navigator2 = defaultNavigator } = options; 2374 const events2 = [ 2375 "chargingchange", 2376 "chargingtimechange", 2377 "dischargingtimechange", 2378 "levelchange" 2379 ]; 2380 const isSupported = useSupported(() => navigator2 && "getBattery" in navigator2 && typeof navigator2.getBattery === "function"); 2381 const charging = shallowRef(false); 2382 const chargingTime = shallowRef(0); 2383 const dischargingTime = shallowRef(0); 2384 const level = shallowRef(1); 2385 let battery; 2386 function updateBatteryInfo() { 2387 charging.value = this.charging; 2388 chargingTime.value = this.chargingTime || 0; 2389 dischargingTime.value = this.dischargingTime || 0; 2390 level.value = this.level; 2391 } 2392 if (isSupported.value) navigator2.getBattery().then((_battery) => { 2393 battery = _battery; 2394 updateBatteryInfo.call(battery); 2395 useEventListener(battery, events2, updateBatteryInfo, { passive: true }); 2396 }); 2397 return { 2398 isSupported, 2399 charging, 2400 chargingTime, 2401 dischargingTime, 2402 level 2403 }; 2404 } 2405 function useBluetooth(options) { 2406 let { acceptAllDevices = false } = options || {}; 2407 const { filters = void 0, optionalServices = void 0, navigator: navigator2 = defaultNavigator } = options || {}; 2408 const isSupported = useSupported(() => navigator2 && "bluetooth" in navigator2); 2409 const device = shallowRef(); 2410 const error = shallowRef(null); 2411 watch(device, () => { 2412 connectToBluetoothGATTServer(); 2413 }); 2414 async function requestDevice() { 2415 if (!isSupported.value) return; 2416 error.value = null; 2417 if (filters && filters.length > 0) acceptAllDevices = false; 2418 try { 2419 device.value = await (navigator2 === null || navigator2 === void 0 ? void 0 : navigator2.bluetooth.requestDevice({ 2420 acceptAllDevices, 2421 filters, 2422 optionalServices 2423 })); 2424 } catch (err) { 2425 error.value = err; 2426 } 2427 } 2428 const server = shallowRef(); 2429 const isConnected = shallowRef(false); 2430 function reset() { 2431 isConnected.value = false; 2432 device.value = void 0; 2433 server.value = void 0; 2434 } 2435 async function connectToBluetoothGATTServer() { 2436 error.value = null; 2437 if (device.value && device.value.gatt) { 2438 useEventListener(device, "gattserverdisconnected", reset, { passive: true }); 2439 try { 2440 server.value = await device.value.gatt.connect(); 2441 isConnected.value = server.value.connected; 2442 } catch (err) { 2443 error.value = err; 2444 } 2445 } 2446 } 2447 tryOnMounted(() => { 2448 var _device$value$gatt; 2449 if (device.value) (_device$value$gatt = device.value.gatt) === null || _device$value$gatt === void 0 || _device$value$gatt.connect(); 2450 }); 2451 tryOnScopeDispose(() => { 2452 var _device$value$gatt2; 2453 if (device.value) (_device$value$gatt2 = device.value.gatt) === null || _device$value$gatt2 === void 0 || _device$value$gatt2.disconnect(); 2454 }); 2455 return { 2456 isSupported, 2457 isConnected: shallowReadonly(isConnected), 2458 device, 2459 requestDevice, 2460 server, 2461 error 2462 }; 2463 } 2464 var ssrWidthSymbol = /* @__PURE__ */ Symbol("vueuse-ssr-width"); 2465 function useSSRWidth() { 2466 const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null; 2467 return typeof ssrWidth === "number" ? ssrWidth : void 0; 2468 } 2469 function provideSSRWidth(width, app) { 2470 if (app !== void 0) app.provide(ssrWidthSymbol, width); 2471 else provideLocal(ssrWidthSymbol, width); 2472 } 2473 function useMediaQuery(query, options = {}) { 2474 const { window: window2 = defaultWindow, ssrWidth = useSSRWidth() } = options; 2475 const isSupported = useSupported(() => window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function"); 2476 const ssrSupport = shallowRef(typeof ssrWidth === "number"); 2477 const mediaQuery = shallowRef(); 2478 const matches = shallowRef(false); 2479 const handler = (event) => { 2480 matches.value = event.matches; 2481 }; 2482 watchEffect(() => { 2483 if (ssrSupport.value) { 2484 ssrSupport.value = !isSupported.value; 2485 matches.value = toValue(query).split(",").some((queryString) => { 2486 const not = queryString.includes("not all"); 2487 const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/); 2488 const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/); 2489 let res = Boolean(minWidth || maxWidth); 2490 if (minWidth && res) res = ssrWidth >= pxValue(minWidth[1]); 2491 if (maxWidth && res) res = ssrWidth <= pxValue(maxWidth[1]); 2492 return not ? !res : res; 2493 }); 2494 return; 2495 } 2496 if (!isSupported.value) return; 2497 mediaQuery.value = window2.matchMedia(toValue(query)); 2498 matches.value = mediaQuery.value.matches; 2499 }); 2500 useEventListener(mediaQuery, "change", handler, { passive: true }); 2501 return computed(() => matches.value); 2502 } 2503 var breakpointsTailwind = { 2504 "sm": 640, 2505 "md": 768, 2506 "lg": 1024, 2507 "xl": 1280, 2508 "2xl": 1536 2509 }; 2510 var breakpointsBootstrapV5 = { 2511 xs: 0, 2512 sm: 576, 2513 md: 768, 2514 lg: 992, 2515 xl: 1200, 2516 xxl: 1400 2517 }; 2518 var breakpointsVuetifyV2 = { 2519 xs: 0, 2520 sm: 600, 2521 md: 960, 2522 lg: 1264, 2523 xl: 1904 2524 }; 2525 var breakpointsVuetifyV3 = { 2526 xs: 0, 2527 sm: 600, 2528 md: 960, 2529 lg: 1280, 2530 xl: 1920, 2531 xxl: 2560 2532 }; 2533 var breakpointsVuetify = breakpointsVuetifyV2; 2534 var breakpointsAntDesign = { 2535 xs: 480, 2536 sm: 576, 2537 md: 768, 2538 lg: 992, 2539 xl: 1200, 2540 xxl: 1600 2541 }; 2542 var breakpointsQuasar = { 2543 xs: 0, 2544 sm: 600, 2545 md: 1024, 2546 lg: 1440, 2547 xl: 1920 2548 }; 2549 var breakpointsSematic = { 2550 mobileS: 320, 2551 mobileM: 375, 2552 mobileL: 425, 2553 tablet: 768, 2554 laptop: 1024, 2555 laptopL: 1440, 2556 desktop4K: 2560 2557 }; 2558 var breakpointsMasterCss = { 2559 "3xs": 360, 2560 "2xs": 480, 2561 "xs": 600, 2562 "sm": 768, 2563 "md": 1024, 2564 "lg": 1280, 2565 "xl": 1440, 2566 "2xl": 1600, 2567 "3xl": 1920, 2568 "4xl": 2560 2569 }; 2570 var breakpointsPrimeFlex = { 2571 sm: 576, 2572 md: 768, 2573 lg: 992, 2574 xl: 1200 2575 }; 2576 var breakpointsElement = { 2577 xs: 0, 2578 sm: 768, 2579 md: 992, 2580 lg: 1200, 2581 xl: 1920 2582 }; 2583 function useBreakpoints(breakpoints, options = {}) { 2584 function getValue2(k, delta) { 2585 let v = toValue(breakpoints[toValue(k)]); 2586 if (delta != null) v = increaseWithUnit(v, delta); 2587 if (typeof v === "number") v = `${v}px`; 2588 return v; 2589 } 2590 const { window: window2 = defaultWindow, strategy = "min-width", ssrWidth = useSSRWidth() } = options; 2591 const ssrSupport = typeof ssrWidth === "number"; 2592 const mounted = ssrSupport ? shallowRef(false) : { value: true }; 2593 if (ssrSupport) tryOnMounted(() => mounted.value = !!window2); 2594 function match(query, size) { 2595 if (!mounted.value && ssrSupport) return query === "min" ? ssrWidth >= pxValue(size) : ssrWidth <= pxValue(size); 2596 if (!window2) return false; 2597 return window2.matchMedia(`(${query}-width: ${size})`).matches; 2598 } 2599 const greaterOrEqual = (k) => { 2600 return useMediaQuery(() => `(min-width: ${getValue2(k)})`, options); 2601 }; 2602 const smallerOrEqual = (k) => { 2603 return useMediaQuery(() => `(max-width: ${getValue2(k)})`, options); 2604 }; 2605 const shortcutMethods = Object.keys(breakpoints).reduce((shortcuts, k) => { 2606 Object.defineProperty(shortcuts, k, { 2607 get: () => strategy === "min-width" ? greaterOrEqual(k) : smallerOrEqual(k), 2608 enumerable: true, 2609 configurable: true 2610 }); 2611 return shortcuts; 2612 }, {}); 2613 function current() { 2614 const points = Object.keys(breakpoints).map((k) => [ 2615 k, 2616 shortcutMethods[k], 2617 pxValue(getValue2(k)) 2618 ]).sort((a, b) => a[2] - b[2]); 2619 return computed(() => points.filter(([, v]) => v.value).map(([k]) => k)); 2620 } 2621 return Object.assign(shortcutMethods, { 2622 greaterOrEqual, 2623 smallerOrEqual, 2624 greater(k) { 2625 return useMediaQuery(() => `(min-width: ${getValue2(k, 0.1)})`, options); 2626 }, 2627 smaller(k) { 2628 return useMediaQuery(() => `(max-width: ${getValue2(k, -0.1)})`, options); 2629 }, 2630 between(a, b) { 2631 return useMediaQuery(() => `(min-width: ${getValue2(a)}) and (max-width: ${getValue2(b, -0.1)})`, options); 2632 }, 2633 isGreater(k) { 2634 return match("min", getValue2(k, 0.1)); 2635 }, 2636 isGreaterOrEqual(k) { 2637 return match("min", getValue2(k)); 2638 }, 2639 isSmaller(k) { 2640 return match("max", getValue2(k, -0.1)); 2641 }, 2642 isSmallerOrEqual(k) { 2643 return match("max", getValue2(k)); 2644 }, 2645 isInBetween(a, b) { 2646 return match("min", getValue2(a)) && match("max", getValue2(b, -0.1)); 2647 }, 2648 current, 2649 active() { 2650 const bps = current(); 2651 return computed(() => bps.value.length === 0 ? "" : bps.value.at(strategy === "min-width" ? -1 : 0)); 2652 } 2653 }); 2654 } 2655 function useBroadcastChannel(options) { 2656 const { name, window: window2 = defaultWindow } = options; 2657 const isSupported = useSupported(() => window2 && "BroadcastChannel" in window2); 2658 const isClosed = shallowRef(false); 2659 const channel = shallowRef(); 2660 const data = shallowRef(); 2661 const error = shallowRef(null); 2662 const post = (data2) => { 2663 if (channel.value) channel.value.postMessage(data2); 2664 }; 2665 const close = () => { 2666 if (channel.value) channel.value.close(); 2667 isClosed.value = true; 2668 }; 2669 if (isSupported.value) tryOnMounted(() => { 2670 error.value = null; 2671 channel.value = new BroadcastChannel(name); 2672 const listenerOptions = { passive: true }; 2673 useEventListener(channel, "message", (e) => { 2674 data.value = e.data; 2675 }, listenerOptions); 2676 useEventListener(channel, "messageerror", (e) => { 2677 error.value = e; 2678 }, listenerOptions); 2679 useEventListener(channel, "close", () => { 2680 isClosed.value = true; 2681 }, listenerOptions); 2682 }); 2683 tryOnScopeDispose(() => { 2684 close(); 2685 }); 2686 return { 2687 isSupported, 2688 channel, 2689 data, 2690 post, 2691 close, 2692 error, 2693 isClosed 2694 }; 2695 } 2696 var WRITABLE_PROPERTIES = [ 2697 "hash", 2698 "host", 2699 "hostname", 2700 "href", 2701 "pathname", 2702 "port", 2703 "protocol", 2704 "search" 2705 ]; 2706 function useBrowserLocation(options = {}) { 2707 const { window: window2 = defaultWindow } = options; 2708 const refs = Object.fromEntries(WRITABLE_PROPERTIES.map((key) => [key, ref()])); 2709 for (const [key, ref2] of objectEntries(refs)) watch(ref2, (value) => { 2710 if (!(window2 === null || window2 === void 0 ? void 0 : window2.location) || window2.location[key] === value) return; 2711 window2.location[key] = value; 2712 }); 2713 const buildState = (trigger) => { 2714 var _window$location; 2715 const { state: state2, length } = (window2 === null || window2 === void 0 ? void 0 : window2.history) || {}; 2716 const { origin } = (window2 === null || window2 === void 0 ? void 0 : window2.location) || {}; 2717 for (const key of WRITABLE_PROPERTIES) refs[key].value = window2 === null || window2 === void 0 || (_window$location = window2.location) === null || _window$location === void 0 ? void 0 : _window$location[key]; 2718 return reactive({ 2719 trigger, 2720 state: state2, 2721 length, 2722 origin, 2723 ...refs 2724 }); 2725 }; 2726 const state = ref(buildState("load")); 2727 if (window2) { 2728 const listenerOptions = { passive: true }; 2729 useEventListener(window2, "popstate", () => state.value = buildState("popstate"), listenerOptions); 2730 useEventListener(window2, "hashchange", () => state.value = buildState("hashchange"), listenerOptions); 2731 } 2732 return state; 2733 } 2734 function useCached(refValue, comparator = (newSourceValue, cachedValue) => newSourceValue === cachedValue, options) { 2735 const { deepRefs = true, ...watchOptions } = options || {}; 2736 const cachedValue = createRef(refValue.value, deepRefs); 2737 watch(() => refValue.value, (value) => { 2738 if (!comparator(value, cachedValue.value)) cachedValue.value = value; 2739 }, watchOptions); 2740 return cachedValue; 2741 } 2742 function usePermission(permissionDesc, options = {}) { 2743 const { controls = false, navigator: navigator2 = defaultNavigator } = options; 2744 const isSupported = useSupported(() => navigator2 && "permissions" in navigator2); 2745 const permissionStatus = shallowRef(); 2746 const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc; 2747 const state = shallowRef(); 2748 const update = () => { 2749 var _permissionStatus$val, _permissionStatus$val2; 2750 state.value = (_permissionStatus$val = (_permissionStatus$val2 = permissionStatus.value) === null || _permissionStatus$val2 === void 0 ? void 0 : _permissionStatus$val2.state) !== null && _permissionStatus$val !== void 0 ? _permissionStatus$val : "prompt"; 2751 }; 2752 useEventListener(permissionStatus, "change", update, { passive: true }); 2753 const query = createSingletonPromise(async () => { 2754 if (!isSupported.value) return; 2755 if (!permissionStatus.value) try { 2756 permissionStatus.value = await navigator2.permissions.query(desc); 2757 } catch (_unused) { 2758 permissionStatus.value = void 0; 2759 } finally { 2760 update(); 2761 } 2762 if (controls) return toRaw(permissionStatus.value); 2763 }); 2764 query(); 2765 if (controls) return { 2766 state, 2767 isSupported, 2768 query 2769 }; 2770 else return state; 2771 } 2772 function useClipboard(options = {}) { 2773 const { navigator: navigator2 = defaultNavigator, read = false, source, copiedDuring = 1500, legacy = false } = options; 2774 const isClipboardApiSupported = useSupported(() => navigator2 && "clipboard" in navigator2); 2775 const permissionRead = usePermission("clipboard-read"); 2776 const permissionWrite = usePermission("clipboard-write"); 2777 const isSupported = computed(() => isClipboardApiSupported.value || legacy); 2778 const text = shallowRef(""); 2779 const copied = shallowRef(false); 2780 const copyPending = shallowRef(false); 2781 const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false }); 2782 let lastLegacyId = 0; 2783 async function updateText() { 2784 let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value)); 2785 if (!useLegacy) try { 2786 text.value = await navigator2.clipboard.readText(); 2787 } catch (_unused) { 2788 useLegacy = true; 2789 } 2790 if (useLegacy) text.value = legacyRead(); 2791 } 2792 if (isSupported.value && read) useEventListener(["copy", "cut"], updateText, { passive: true }); 2793 async function copy(value) { 2794 const resolvedValue = value !== null && value !== void 0 ? value : toValue(source); 2795 if (isSupported.value && resolvedValue != null) { 2796 copyPending.value = true; 2797 let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionWrite.value)); 2798 if (!useLegacy) try { 2799 const clipboardItem = createClipboardItem(resolvedValue); 2800 await navigator2.clipboard.write([clipboardItem]); 2801 } catch (_unused2) { 2802 useLegacy = true; 2803 } 2804 if (useLegacy) if (typeof resolvedValue === "string") { 2805 text.value = resolvedValue; 2806 legacyCopy(resolvedValue); 2807 } else { 2808 const currentId = ++lastLegacyId; 2809 const resolvedText = await resolvedValue(); 2810 if (resolvedText != null && currentId === lastLegacyId) { 2811 text.value = resolvedText; 2812 legacyCopy(resolvedText); 2813 } 2814 } 2815 copied.value = true; 2816 timeout.start(); 2817 copyPending.value = false; 2818 } 2819 } 2820 function createClipboardItem(value) { 2821 if (typeof value === "string") { 2822 text.value = value; 2823 return new ClipboardItem({ "text/plain": value }); 2824 } else return new ClipboardItem({ "text/plain": value().then((resolvedText = "") => { 2825 text.value = resolvedText; 2826 return new Blob([resolvedText], { type: "text/plain" }); 2827 }) }); 2828 } 2829 function legacyCopy(value) { 2830 const ta = document.createElement("textarea"); 2831 ta.value = value; 2832 ta.style.position = "absolute"; 2833 ta.style.opacity = "0"; 2834 ta.setAttribute("readonly", ""); 2835 document.body.appendChild(ta); 2836 ta.select(); 2837 document.execCommand("copy"); 2838 ta.remove(); 2839 } 2840 function legacyRead() { 2841 var _document$getSelectio, _document, _document$getSelectio2; 2842 return (_document$getSelectio = (_document = document) === null || _document === void 0 || (_document$getSelectio2 = _document.getSelection) === null || _document$getSelectio2 === void 0 || (_document$getSelectio2 = _document$getSelectio2.call(_document)) === null || _document$getSelectio2 === void 0 ? void 0 : _document$getSelectio2.toString()) !== null && _document$getSelectio !== void 0 ? _document$getSelectio : ""; 2843 } 2844 function isAllowed(status) { 2845 return status === "granted" || status === "prompt"; 2846 } 2847 return { 2848 copyPending: shallowReadonly(copyPending), 2849 isSupported, 2850 text: shallowReadonly(text), 2851 copied: shallowReadonly(copied), 2852 copy 2853 }; 2854 } 2855 function useClipboardItems(options = {}) { 2856 const { navigator: navigator2 = defaultNavigator, read = false, source, copiedDuring = 1500 } = options; 2857 const isSupported = useSupported(() => navigator2 && "clipboard" in navigator2); 2858 const content = shallowRef([]); 2859 const copied = shallowRef(false); 2860 const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false }); 2861 function updateContent() { 2862 if (isSupported.value) navigator2.clipboard.read().then((items) => { 2863 content.value = items; 2864 }); 2865 } 2866 if (isSupported.value && read) useEventListener(["copy", "cut"], updateContent, { passive: true }); 2867 async function copy(value = toValue(source)) { 2868 if (isSupported.value && value != null) { 2869 await navigator2.clipboard.write(value); 2870 content.value = value; 2871 copied.value = true; 2872 timeout.start(); 2873 } 2874 } 2875 return { 2876 isSupported, 2877 content: shallowReadonly(content), 2878 copied: shallowReadonly(copied), 2879 copy, 2880 read: updateContent 2881 }; 2882 } 2883 function cloneFnJSON(source) { 2884 return JSON.parse(JSON.stringify(source)); 2885 } 2886 function useCloned(source, options = {}) { 2887 const cloned = ref({}); 2888 const isModified = shallowRef(false); 2889 let _lastSync = false; 2890 const { manual, clone = cloneFnJSON, deep = true, immediate = true } = options; 2891 watch(cloned, () => { 2892 if (_lastSync) { 2893 _lastSync = false; 2894 return; 2895 } 2896 isModified.value = true; 2897 }, { 2898 deep: true, 2899 flush: "sync" 2900 }); 2901 function sync() { 2902 _lastSync = true; 2903 isModified.value = false; 2904 cloned.value = clone(toValue(source)); 2905 } 2906 if (!manual && (isRef(source) || typeof source === "function")) watch(source, sync, { 2907 ...options, 2908 deep, 2909 immediate 2910 }); 2911 else sync(); 2912 return { 2913 cloned, 2914 isModified, 2915 sync 2916 }; 2917 } 2918 var _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; 2919 var globalKey = "__vueuse_ssr_handlers__"; 2920 var handlers = getHandlers(); 2921 function getHandlers() { 2922 if (!(globalKey in _global)) _global[globalKey] = _global[globalKey] || {}; 2923 return _global[globalKey]; 2924 } 2925 function getSSRHandler(key, fallback) { 2926 return handlers[key] || fallback; 2927 } 2928 function setSSRHandler(key, fn) { 2929 handlers[key] = fn; 2930 } 2931 function usePreferredDark(options) { 2932 return useMediaQuery("(prefers-color-scheme: dark)", options); 2933 } 2934 function guessSerializerType(rawInit) { 2935 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"; 2936 } 2937 var StorageSerializers = { 2938 boolean: { 2939 read: (v) => v === "true", 2940 write: (v) => String(v) 2941 }, 2942 object: { 2943 read: (v) => JSON.parse(v), 2944 write: (v) => JSON.stringify(v) 2945 }, 2946 number: { 2947 read: (v) => Number.parseFloat(v), 2948 write: (v) => String(v) 2949 }, 2950 any: { 2951 read: (v) => v, 2952 write: (v) => String(v) 2953 }, 2954 string: { 2955 read: (v) => v, 2956 write: (v) => String(v) 2957 }, 2958 map: { 2959 read: (v) => new Map(JSON.parse(v)), 2960 write: (v) => JSON.stringify(Array.from(v.entries())) 2961 }, 2962 set: { 2963 read: (v) => new Set(JSON.parse(v)), 2964 write: (v) => JSON.stringify(Array.from(v)) 2965 }, 2966 date: { 2967 read: (v) => new Date(v), 2968 write: (v) => v.toISOString() 2969 } 2970 }; 2971 var customStorageEventName = "vueuse-storage"; 2972 function useStorage(key, defaults2, storage, options = {}) { 2973 var _options$serializer; 2974 const { flush = "pre", deep = true, listenToStorageChanges = true, writeDefaults = true, mergeDefaults = false, shallow, window: window2 = defaultWindow, eventFilter, onError = (e) => { 2975 console.error(e); 2976 }, initOnMounted } = options; 2977 const data = (shallow ? shallowRef : ref)(typeof defaults2 === "function" ? defaults2() : defaults2); 2978 const keyComputed = computed(() => toValue(key)); 2979 if (!storage) try { 2980 storage = getSSRHandler("getDefaultStorage", () => defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.localStorage)(); 2981 } catch (e) { 2982 onError(e); 2983 } 2984 if (!storage) return data; 2985 const rawInit = toValue(defaults2); 2986 const type = guessSerializerType(rawInit); 2987 const serializer = (_options$serializer = options.serializer) !== null && _options$serializer !== void 0 ? _options$serializer : StorageSerializers[type]; 2988 const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, (newValue) => write(newValue), { 2989 flush, 2990 deep, 2991 eventFilter 2992 }); 2993 watch(keyComputed, () => update(), { flush }); 2994 let firstMounted = false; 2995 const onStorageEvent = (ev) => { 2996 if (initOnMounted && !firstMounted) return; 2997 update(ev); 2998 }; 2999 const onStorageCustomEvent = (ev) => { 3000 if (initOnMounted && !firstMounted) return; 3001 updateFromCustomEvent(ev); 3002 }; 3003 if (window2 && listenToStorageChanges) if (storage instanceof Storage) useEventListener(window2, "storage", onStorageEvent, { passive: true }); 3004 else useEventListener(window2, customStorageEventName, onStorageCustomEvent); 3005 if (initOnMounted) tryOnMounted(() => { 3006 firstMounted = true; 3007 update(); 3008 }); 3009 else update(); 3010 function dispatchWriteEvent(oldValue, newValue) { 3011 if (window2) { 3012 const payload = { 3013 key: keyComputed.value, 3014 oldValue, 3015 newValue, 3016 storageArea: storage 3017 }; 3018 window2.dispatchEvent(storage instanceof Storage ? new StorageEvent("storage", payload) : new CustomEvent(customStorageEventName, { detail: payload })); 3019 } 3020 } 3021 function write(v) { 3022 try { 3023 const oldValue = storage.getItem(keyComputed.value); 3024 if (v == null) { 3025 dispatchWriteEvent(oldValue, null); 3026 storage.removeItem(keyComputed.value); 3027 } else { 3028 const serialized = serializer.write(v); 3029 if (oldValue !== serialized) { 3030 storage.setItem(keyComputed.value, serialized); 3031 dispatchWriteEvent(oldValue, serialized); 3032 } 3033 } 3034 } catch (e) { 3035 onError(e); 3036 } 3037 } 3038 function read(event) { 3039 const rawValue = event ? event.newValue : storage.getItem(keyComputed.value); 3040 if (rawValue == null) { 3041 if (writeDefaults && rawInit != null) storage.setItem(keyComputed.value, serializer.write(rawInit)); 3042 return rawInit; 3043 } else if (!event && mergeDefaults) { 3044 const value = serializer.read(rawValue); 3045 if (typeof mergeDefaults === "function") return mergeDefaults(value, rawInit); 3046 else if (type === "object" && !Array.isArray(value)) return { 3047 ...rawInit, 3048 ...value 3049 }; 3050 return value; 3051 } else if (typeof rawValue !== "string") return rawValue; 3052 else return serializer.read(rawValue); 3053 } 3054 function update(event) { 3055 if (event && event.storageArea !== storage) return; 3056 if (event && event.key == null) { 3057 data.value = rawInit; 3058 return; 3059 } 3060 if (event && event.key !== keyComputed.value) return; 3061 pauseWatch(); 3062 try { 3063 const serializedData = serializer.write(data.value); 3064 if (event === void 0 || (event === null || event === void 0 ? void 0 : event.newValue) !== serializedData) data.value = read(event); 3065 } catch (e) { 3066 onError(e); 3067 } finally { 3068 if (event) nextTick(resumeWatch); 3069 else resumeWatch(); 3070 } 3071 } 3072 function updateFromCustomEvent(event) { 3073 update(event.detail); 3074 } 3075 return data; 3076 } 3077 var CSS_DISABLE_TRANS = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"; 3078 function useColorMode(options = {}) { 3079 const { selector = "html", attribute = "class", initialValue = "auto", window: window2 = defaultWindow, storage, storageKey = "vueuse-color-scheme", listenToStorageChanges = true, storageRef, emitAuto, disableTransition = true } = options; 3080 const modes = { 3081 auto: "", 3082 light: "light", 3083 dark: "dark", 3084 ...options.modes || {} 3085 }; 3086 const preferredDark = usePreferredDark({ window: window2 }); 3087 const system = computed(() => preferredDark.value ? "dark" : "light"); 3088 const store = storageRef || (storageKey == null ? toRef2(initialValue) : useStorage(storageKey, initialValue, storage, { 3089 window: window2, 3090 listenToStorageChanges 3091 })); 3092 const state = computed(() => store.value === "auto" ? system.value : store.value); 3093 const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector2, attribute2, value) => { 3094 const el = typeof selector2 === "string" ? window2 === null || window2 === void 0 ? void 0 : window2.document.querySelector(selector2) : unrefElement(selector2); 3095 if (!el) return; 3096 const classesToAdd = /* @__PURE__ */ new Set(); 3097 const classesToRemove = /* @__PURE__ */ new Set(); 3098 let attributeToChange = null; 3099 if (attribute2 === "class") { 3100 const current = value.split(/\s/g); 3101 Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => { 3102 if (current.includes(v)) classesToAdd.add(v); 3103 else classesToRemove.add(v); 3104 }); 3105 } else attributeToChange = { 3106 key: attribute2, 3107 value 3108 }; 3109 if (classesToAdd.size === 0 && classesToRemove.size === 0 && attributeToChange === null) return; 3110 let style; 3111 if (disableTransition) { 3112 style = window2.document.createElement("style"); 3113 style.appendChild(document.createTextNode(CSS_DISABLE_TRANS)); 3114 window2.document.head.appendChild(style); 3115 } 3116 for (const c of classesToAdd) el.classList.add(c); 3117 for (const c of classesToRemove) el.classList.remove(c); 3118 if (attributeToChange) el.setAttribute(attributeToChange.key, attributeToChange.value); 3119 if (disableTransition) { 3120 window2.getComputedStyle(style).opacity; 3121 document.head.removeChild(style); 3122 } 3123 }); 3124 function defaultOnChanged(mode) { 3125 var _modes$mode; 3126 updateHTMLAttrs(selector, attribute, (_modes$mode = modes[mode]) !== null && _modes$mode !== void 0 ? _modes$mode : mode); 3127 } 3128 function onChanged(mode) { 3129 if (options.onChanged) options.onChanged(mode, defaultOnChanged); 3130 else defaultOnChanged(mode); 3131 } 3132 watch(state, onChanged, { 3133 flush: "post", 3134 immediate: true 3135 }); 3136 tryOnMounted(() => onChanged(state.value)); 3137 const auto = computed({ 3138 get() { 3139 return emitAuto ? store.value : state.value; 3140 }, 3141 set(v) { 3142 store.value = v; 3143 } 3144 }); 3145 return Object.assign(auto, { 3146 store, 3147 system, 3148 state 3149 }); 3150 } 3151 function useConfirmDialog(revealed = shallowRef(false)) { 3152 const confirmHook = createEventHook(); 3153 const cancelHook = createEventHook(); 3154 const revealHook = createEventHook(); 3155 let _resolve = noop; 3156 const reveal = (data) => { 3157 revealHook.trigger(data); 3158 revealed.value = true; 3159 return new Promise((resolve) => { 3160 _resolve = resolve; 3161 }); 3162 }; 3163 const confirm = (data) => { 3164 revealed.value = false; 3165 confirmHook.trigger(data); 3166 _resolve({ 3167 data, 3168 isCanceled: false 3169 }); 3170 }; 3171 const cancel = (data) => { 3172 revealed.value = false; 3173 cancelHook.trigger(data); 3174 _resolve({ 3175 data, 3176 isCanceled: true 3177 }); 3178 }; 3179 return { 3180 isRevealed: computed(() => revealed.value), 3181 reveal, 3182 confirm, 3183 cancel, 3184 onReveal: revealHook.on, 3185 onConfirm: confirmHook.on, 3186 onCancel: cancelHook.on 3187 }; 3188 } 3189 function getDefaultScheduler$8(options) { 3190 if ("interval" in options || "immediate" in options) { 3191 const { interval = 1e3, immediate = false } = options; 3192 return (cb) => useIntervalFn(cb, interval, { immediate }); 3193 } 3194 return (cb) => useIntervalFn(cb, 1e3, { immediate: false }); 3195 } 3196 function useCountdown(initialCountdown, options = {}) { 3197 const remaining = shallowRef(toValue(initialCountdown)); 3198 const { scheduler = getDefaultScheduler$8(options), onTick, onComplete } = options; 3199 const controls = scheduler(() => { 3200 const value = remaining.value - 1; 3201 remaining.value = value < 0 ? 0 : value; 3202 onTick === null || onTick === void 0 || onTick(); 3203 if (remaining.value <= 0) { 3204 controls.pause(); 3205 onComplete === null || onComplete === void 0 || onComplete(); 3206 } 3207 }); 3208 const reset = (countdown) => { 3209 var _toValue; 3210 remaining.value = (_toValue = toValue(countdown)) !== null && _toValue !== void 0 ? _toValue : toValue(initialCountdown); 3211 }; 3212 const stop = () => { 3213 controls.pause(); 3214 reset(); 3215 }; 3216 const resume = () => { 3217 if (!controls.isActive.value) { 3218 if (remaining.value > 0) controls.resume(); 3219 } 3220 }; 3221 const start = (countdown) => { 3222 reset(countdown); 3223 controls.resume(); 3224 }; 3225 return { 3226 remaining, 3227 reset, 3228 stop, 3229 start, 3230 pause: controls.pause, 3231 resume, 3232 isActive: controls.isActive 3233 }; 3234 } 3235 function useCssSupports(...args) { 3236 let options = {}; 3237 if (typeof toValue(args.at(-1)) === "object") options = args.pop(); 3238 const [prop, value] = args; 3239 const { window: window2 = defaultWindow, ssrValue = false } = options; 3240 const isMounted = useMounted(); 3241 return { isSupported: computed(() => { 3242 if (!isClient || !isMounted.value) return ssrValue; 3243 return args.length === 2 ? window2 === null || window2 === void 0 ? void 0 : window2.CSS.supports(toValue(prop), toValue(value)) : window2 === null || window2 === void 0 ? void 0 : window2.CSS.supports(toValue(prop)); 3244 }) }; 3245 } 3246 function useCssVar(prop, target, options = {}) { 3247 const { window: window2 = defaultWindow, initialValue, observe = false } = options; 3248 const variable = shallowRef(initialValue); 3249 const elRef = computed(() => { 3250 var _window$document; 3251 return unrefElement(target) || (window2 === null || window2 === void 0 || (_window$document = window2.document) === null || _window$document === void 0 ? void 0 : _window$document.documentElement); 3252 }); 3253 function updateCssVar() { 3254 const key = toValue(prop); 3255 const el = toValue(elRef); 3256 if (el && window2 && key) { 3257 var _window$getComputedSt; 3258 variable.value = ((_window$getComputedSt = window2.getComputedStyle(el).getPropertyValue(key)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.trim()) || variable.value || initialValue; 3259 } 3260 } 3261 if (observe) useMutationObserver(elRef, updateCssVar, { 3262 attributeFilter: ["style", "class"], 3263 window: window2 3264 }); 3265 watch([elRef, () => toValue(prop)], (_, old) => { 3266 if (old[0] && old[1]) old[0].style.removeProperty(old[1]); 3267 updateCssVar(); 3268 }, { immediate: true }); 3269 watch([variable, elRef], ([val, el]) => { 3270 const raw_prop = toValue(prop); 3271 if ((el === null || el === void 0 ? void 0 : el.style) && raw_prop) if (val == null) el.style.removeProperty(raw_prop); 3272 else el.style.setProperty(raw_prop, val); 3273 }, { immediate: true }); 3274 return variable; 3275 } 3276 function useCurrentElement(rootComponent) { 3277 const vm = getCurrentInstance(); 3278 const currentElement = computedWithControl(() => null, () => rootComponent ? unrefElement(rootComponent) : vm.proxy.$el); 3279 onUpdated(currentElement.trigger); 3280 onMounted(currentElement.trigger); 3281 return currentElement; 3282 } 3283 function useCycleList(list, options) { 3284 const state = shallowRef(getInitialValue()); 3285 const listRef = toRef2(list); 3286 const index = computed({ 3287 get() { 3288 var _options$fallbackInde; 3289 const targetList = listRef.value; 3290 let index2 = (options === null || options === void 0 ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value); 3291 if (index2 < 0) index2 = (_options$fallbackInde = options === null || options === void 0 ? void 0 : options.fallbackIndex) !== null && _options$fallbackInde !== void 0 ? _options$fallbackInde : 0; 3292 return index2; 3293 }, 3294 set(v) { 3295 set2(v); 3296 } 3297 }); 3298 function set2(i) { 3299 const targetList = listRef.value; 3300 const length = targetList.length; 3301 const value = targetList[(i % length + length) % length]; 3302 state.value = value; 3303 return value; 3304 } 3305 function shift(delta = 1) { 3306 return set2(index.value + delta); 3307 } 3308 function next(n = 1) { 3309 return shift(n); 3310 } 3311 function prev(n = 1) { 3312 return shift(-n); 3313 } 3314 function getInitialValue() { 3315 var _toValue, _options$initialValue; 3316 return (_toValue = toValue((_options$initialValue = options === null || options === void 0 ? void 0 : options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : toValue(list)[0])) !== null && _toValue !== void 0 ? _toValue : void 0; 3317 } 3318 watch(listRef, () => set2(index.value)); 3319 return { 3320 state, 3321 index, 3322 next, 3323 prev, 3324 go: set2 3325 }; 3326 } 3327 function useDark(options = {}) { 3328 const { valueDark = "dark", valueLight = "" } = options; 3329 const mode = useColorMode({ 3330 ...options, 3331 onChanged: (mode2, defaultHandler) => { 3332 var _options$onChanged; 3333 if (options.onChanged) (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, mode2 === "dark", defaultHandler, mode2); 3334 else defaultHandler(mode2); 3335 }, 3336 modes: { 3337 dark: valueDark, 3338 light: valueLight 3339 } 3340 }); 3341 const system = computed(() => mode.system.value); 3342 return computed({ 3343 get() { 3344 return mode.value === "dark"; 3345 }, 3346 set(v) { 3347 const modeVal = v ? "dark" : "light"; 3348 if (system.value === modeVal) mode.value = "auto"; 3349 else mode.value = modeVal; 3350 } 3351 }); 3352 } 3353 function fnBypass(v) { 3354 return v; 3355 } 3356 function fnSetSource(source, value) { 3357 return source.value = value; 3358 } 3359 function defaultDump(clone) { 3360 return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass; 3361 } 3362 function defaultParse(clone) { 3363 return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass; 3364 } 3365 function useManualRefHistory(source, options = {}) { 3366 const { clone = false, dump = defaultDump(clone), parse = defaultParse(clone), setSource = fnSetSource } = options; 3367 function _createHistoryRecord() { 3368 return markRaw({ 3369 snapshot: dump(source.value), 3370 timestamp: timestamp() 3371 }); 3372 } 3373 const last = ref(_createHistoryRecord()); 3374 const undoStack = ref([]); 3375 const redoStack = ref([]); 3376 const _setSource = (record) => { 3377 setSource(source, parse(record.snapshot)); 3378 last.value = record; 3379 }; 3380 const commit = () => { 3381 undoStack.value.unshift(last.value); 3382 last.value = _createHistoryRecord(); 3383 if (options.capacity && undoStack.value.length > options.capacity) undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY); 3384 if (redoStack.value.length) redoStack.value.splice(0, redoStack.value.length); 3385 }; 3386 const clear = () => { 3387 undoStack.value.splice(0, undoStack.value.length); 3388 redoStack.value.splice(0, redoStack.value.length); 3389 }; 3390 const undo = () => { 3391 const state = undoStack.value.shift(); 3392 if (state) { 3393 redoStack.value.unshift(last.value); 3394 _setSource(state); 3395 } 3396 }; 3397 const redo = () => { 3398 const state = redoStack.value.shift(); 3399 if (state) { 3400 undoStack.value.unshift(last.value); 3401 _setSource(state); 3402 } 3403 }; 3404 const reset = () => { 3405 _setSource(last.value); 3406 }; 3407 return { 3408 source, 3409 undoStack, 3410 redoStack, 3411 last, 3412 history: computed(() => [last.value, ...undoStack.value]), 3413 canUndo: computed(() => undoStack.value.length > 0), 3414 canRedo: computed(() => redoStack.value.length > 0), 3415 clear, 3416 commit, 3417 reset, 3418 undo, 3419 redo 3420 }; 3421 } 3422 function useRefHistory(source, options = {}) { 3423 const { deep = false, flush = "pre", eventFilter, shouldCommit = () => true } = options; 3424 const { eventFilter: composedFilter, pause, resume: resumeTracking, isActive: isTracking } = pausableFilter(eventFilter); 3425 let lastRawValue = source.value; 3426 const { ignoreUpdates, ignorePrevAsyncUpdates, stop } = watchIgnorable(source, commit, { 3427 deep, 3428 flush, 3429 eventFilter: composedFilter 3430 }); 3431 function setSource(source2, value) { 3432 ignorePrevAsyncUpdates(); 3433 ignoreUpdates(() => { 3434 source2.value = value; 3435 lastRawValue = value; 3436 }); 3437 } 3438 const manualHistory = useManualRefHistory(source, { 3439 ...options, 3440 clone: options.clone || deep, 3441 setSource 3442 }); 3443 const { clear, commit: manualCommit } = manualHistory; 3444 function commit() { 3445 ignorePrevAsyncUpdates(); 3446 if (!shouldCommit(lastRawValue, source.value)) return; 3447 lastRawValue = source.value; 3448 manualCommit(); 3449 } 3450 function resume(commitNow) { 3451 resumeTracking(); 3452 if (commitNow) commit(); 3453 } 3454 function batch(fn) { 3455 let canceled = false; 3456 const cancel = () => canceled = true; 3457 ignoreUpdates(() => { 3458 fn(cancel); 3459 }); 3460 if (!canceled) commit(); 3461 } 3462 function dispose() { 3463 stop(); 3464 clear(); 3465 } 3466 return { 3467 ...manualHistory, 3468 isTracking, 3469 pause, 3470 resume, 3471 commit, 3472 batch, 3473 dispose 3474 }; 3475 } 3476 function useDebouncedRefHistory(source, options = {}) { 3477 const filter = options.debounce ? debounceFilter(options.debounce) : void 0; 3478 return { ...useRefHistory(source, { 3479 ...options, 3480 eventFilter: filter 3481 }) }; 3482 } 3483 function useDeviceMotion(options = {}) { 3484 const { window: window2 = defaultWindow, requestPermissions = false, eventFilter = bypassFilter } = options; 3485 const isSupported = useSupported(() => typeof DeviceMotionEvent !== "undefined"); 3486 const requirePermissions = useSupported(() => isSupported.value && "requestPermission" in DeviceMotionEvent && typeof DeviceMotionEvent.requestPermission === "function"); 3487 const permissionGranted = shallowRef(false); 3488 const acceleration = ref({ 3489 x: null, 3490 y: null, 3491 z: null 3492 }); 3493 const rotationRate = ref({ 3494 alpha: null, 3495 beta: null, 3496 gamma: null 3497 }); 3498 const interval = shallowRef(0); 3499 const accelerationIncludingGravity = ref({ 3500 x: null, 3501 y: null, 3502 z: null 3503 }); 3504 function init() { 3505 if (window2) useEventListener(window2, "devicemotion", createFilterWrapper(eventFilter, (event) => { 3506 var _event$acceleration, _event$acceleration2, _event$acceleration3, _event$accelerationIn, _event$accelerationIn2, _event$accelerationIn3, _event$rotationRate, _event$rotationRate2, _event$rotationRate3; 3507 acceleration.value = { 3508 x: ((_event$acceleration = event.acceleration) === null || _event$acceleration === void 0 ? void 0 : _event$acceleration.x) || null, 3509 y: ((_event$acceleration2 = event.acceleration) === null || _event$acceleration2 === void 0 ? void 0 : _event$acceleration2.y) || null, 3510 z: ((_event$acceleration3 = event.acceleration) === null || _event$acceleration3 === void 0 ? void 0 : _event$acceleration3.z) || null 3511 }; 3512 accelerationIncludingGravity.value = { 3513 x: ((_event$accelerationIn = event.accelerationIncludingGravity) === null || _event$accelerationIn === void 0 ? void 0 : _event$accelerationIn.x) || null, 3514 y: ((_event$accelerationIn2 = event.accelerationIncludingGravity) === null || _event$accelerationIn2 === void 0 ? void 0 : _event$accelerationIn2.y) || null, 3515 z: ((_event$accelerationIn3 = event.accelerationIncludingGravity) === null || _event$accelerationIn3 === void 0 ? void 0 : _event$accelerationIn3.z) || null 3516 }; 3517 rotationRate.value = { 3518 alpha: ((_event$rotationRate = event.rotationRate) === null || _event$rotationRate === void 0 ? void 0 : _event$rotationRate.alpha) || null, 3519 beta: ((_event$rotationRate2 = event.rotationRate) === null || _event$rotationRate2 === void 0 ? void 0 : _event$rotationRate2.beta) || null, 3520 gamma: ((_event$rotationRate3 = event.rotationRate) === null || _event$rotationRate3 === void 0 ? void 0 : _event$rotationRate3.gamma) || null 3521 }; 3522 interval.value = event.interval; 3523 }), { passive: true }); 3524 } 3525 const ensurePermissions = async () => { 3526 if (!requirePermissions.value) permissionGranted.value = true; 3527 if (permissionGranted.value) return; 3528 if (requirePermissions.value) { 3529 const requestPermission = DeviceMotionEvent.requestPermission; 3530 try { 3531 if (await requestPermission() === "granted") { 3532 permissionGranted.value = true; 3533 init(); 3534 } 3535 } catch (error) { 3536 console.error(error); 3537 } 3538 } 3539 }; 3540 if (isSupported.value) if (requestPermissions && requirePermissions.value) ensurePermissions().then(() => init()); 3541 else init(); 3542 return { 3543 acceleration, 3544 accelerationIncludingGravity, 3545 rotationRate, 3546 interval, 3547 isSupported, 3548 requirePermissions, 3549 ensurePermissions, 3550 permissionGranted 3551 }; 3552 } 3553 function useDeviceOrientation(options = {}) { 3554 const { window: window2 = defaultWindow } = options; 3555 const isSupported = useSupported(() => window2 && "DeviceOrientationEvent" in window2); 3556 const isAbsolute = shallowRef(false); 3557 const alpha = shallowRef(null); 3558 const beta = shallowRef(null); 3559 const gamma = shallowRef(null); 3560 if (window2 && isSupported.value) useEventListener(window2, "deviceorientation", (event) => { 3561 isAbsolute.value = event.absolute; 3562 alpha.value = event.alpha; 3563 beta.value = event.beta; 3564 gamma.value = event.gamma; 3565 }, { passive: true }); 3566 return { 3567 isSupported, 3568 isAbsolute, 3569 alpha, 3570 beta, 3571 gamma 3572 }; 3573 } 3574 function useDevicePixelRatio(options = {}) { 3575 const { window: window2 = defaultWindow } = options; 3576 const pixelRatio = shallowRef(1); 3577 const query = useMediaQuery(() => `(resolution: ${pixelRatio.value}dppx)`, options); 3578 let stop = noop; 3579 if (window2) stop = watchImmediate(query, () => pixelRatio.value = window2.devicePixelRatio); 3580 return { 3581 pixelRatio: shallowReadonly(pixelRatio), 3582 stop 3583 }; 3584 } 3585 function useDevicesList(options = {}) { 3586 const { navigator: navigator2 = defaultNavigator, requestPermissions = false, constraints = { 3587 audio: true, 3588 video: true 3589 }, onUpdated: onUpdated2 } = options; 3590 const devices = shallowRef([]); 3591 const videoInputs = computed(() => devices.value.filter((i) => i.kind === "videoinput")); 3592 const audioInputs = computed(() => devices.value.filter((i) => i.kind === "audioinput")); 3593 const audioOutputs = computed(() => devices.value.filter((i) => i.kind === "audiooutput")); 3594 const isSupported = useSupported(() => navigator2 && navigator2.mediaDevices && navigator2.mediaDevices.enumerateDevices); 3595 const permissionGranted = shallowRef(false); 3596 let stream; 3597 async function update() { 3598 if (!isSupported.value) return; 3599 devices.value = await navigator2.mediaDevices.enumerateDevices(); 3600 onUpdated2 === null || onUpdated2 === void 0 || onUpdated2(devices.value); 3601 if (stream) { 3602 stream.getTracks().forEach((t) => t.stop()); 3603 stream = null; 3604 } 3605 } 3606 async function ensurePermissions() { 3607 const deviceName = constraints.video ? "camera" : "microphone"; 3608 if (!isSupported.value) return false; 3609 if (permissionGranted.value) return true; 3610 const { state, query } = usePermission(deviceName, { controls: true }); 3611 await query(); 3612 if (state.value !== "granted") { 3613 let granted = true; 3614 try { 3615 const allDevices = await navigator2.mediaDevices.enumerateDevices(); 3616 const hasCamera = allDevices.some((device) => device.kind === "videoinput"); 3617 const hasMicrophone = allDevices.some((device) => device.kind === "audioinput" || device.kind === "audiooutput"); 3618 constraints.video = hasCamera ? constraints.video : false; 3619 constraints.audio = hasMicrophone ? constraints.audio : false; 3620 stream = await navigator2.mediaDevices.getUserMedia(constraints); 3621 } catch (_unused) { 3622 stream = null; 3623 granted = false; 3624 } 3625 update(); 3626 permissionGranted.value = granted; 3627 } else permissionGranted.value = true; 3628 return permissionGranted.value; 3629 } 3630 if (isSupported.value) { 3631 if (requestPermissions) ensurePermissions(); 3632 useEventListener(navigator2.mediaDevices, "devicechange", update, { passive: true }); 3633 update(); 3634 } 3635 return { 3636 devices, 3637 ensurePermissions, 3638 permissionGranted, 3639 videoInputs, 3640 audioInputs, 3641 audioOutputs, 3642 isSupported 3643 }; 3644 } 3645 function useDisplayMedia(options = {}) { 3646 var _options$enabled; 3647 const enabled = shallowRef((_options$enabled = options.enabled) !== null && _options$enabled !== void 0 ? _options$enabled : false); 3648 const video = options.video; 3649 const audio = options.audio; 3650 const { navigator: navigator2 = defaultNavigator } = options; 3651 const isSupported = useSupported(() => { 3652 var _navigator$mediaDevic; 3653 return navigator2 === null || navigator2 === void 0 || (_navigator$mediaDevic = navigator2.mediaDevices) === null || _navigator$mediaDevic === void 0 ? void 0 : _navigator$mediaDevic.getDisplayMedia; 3654 }); 3655 const constraint = { 3656 audio, 3657 video 3658 }; 3659 const stream = shallowRef(); 3660 async function _start() { 3661 var _stream$value; 3662 if (!isSupported.value || stream.value) return; 3663 stream.value = await navigator2.mediaDevices.getDisplayMedia(constraint); 3664 (_stream$value = stream.value) === null || _stream$value === void 0 || _stream$value.getTracks().forEach((t) => useEventListener(t, "ended", stop, { passive: true })); 3665 return stream.value; 3666 } 3667 async function _stop() { 3668 var _stream$value2; 3669 (_stream$value2 = stream.value) === null || _stream$value2 === void 0 || _stream$value2.getTracks().forEach((t) => t.stop()); 3670 stream.value = void 0; 3671 } 3672 function stop() { 3673 _stop(); 3674 enabled.value = false; 3675 } 3676 async function start() { 3677 await _start(); 3678 if (stream.value) enabled.value = true; 3679 return stream.value; 3680 } 3681 watch(enabled, (v) => { 3682 if (v) _start(); 3683 else _stop(); 3684 }, { immediate: true }); 3685 return { 3686 isSupported, 3687 stream, 3688 start, 3689 stop, 3690 enabled 3691 }; 3692 } 3693 function useDocumentVisibility(options = {}) { 3694 const { document: document2 = defaultDocument } = options; 3695 if (!document2) return shallowRef("visible"); 3696 const visibility = shallowRef(document2.visibilityState); 3697 useEventListener(document2, "visibilitychange", () => { 3698 visibility.value = document2.visibilityState; 3699 }, { passive: true }); 3700 return visibility; 3701 } 3702 var defaultScrollConfig = { 3703 speed: 2, 3704 margin: 30, 3705 direction: "both" 3706 }; 3707 function clampContainerScroll(container) { 3708 if (container.scrollLeft > container.scrollWidth - container.clientWidth) container.scrollLeft = Math.max(0, container.scrollWidth - container.clientWidth); 3709 if (container.scrollTop > container.scrollHeight - container.clientHeight) container.scrollTop = Math.max(0, container.scrollHeight - container.clientHeight); 3710 } 3711 function useDraggable(target, options = {}) { 3712 var _toValue, _toValue2, _toValue3, _scrollConfig$directi; 3713 const { pointerTypes, preventDefault: preventDefault2, stopPropagation, exact, onMove, onEnd, onStart, initialValue, axis = "both", draggingElement = defaultWindow, containerElement, handle: draggingHandle = target, buttons = [0], restrictInView, autoScroll = false } = options; 3714 const position = ref((_toValue = toValue(initialValue)) !== null && _toValue !== void 0 ? _toValue : { 3715 x: 0, 3716 y: 0 3717 }); 3718 const pressedDelta = ref(); 3719 const filterEvent = (e) => { 3720 if (pointerTypes) return pointerTypes.includes(e.pointerType); 3721 return true; 3722 }; 3723 const handleEvent = (e) => { 3724 if (toValue(preventDefault2)) e.preventDefault(); 3725 if (toValue(stopPropagation)) e.stopPropagation(); 3726 }; 3727 const scrollConfig = toValue(autoScroll); 3728 const scrollSettings = typeof scrollConfig === "object" ? { 3729 speed: (_toValue2 = toValue(scrollConfig.speed)) !== null && _toValue2 !== void 0 ? _toValue2 : defaultScrollConfig.speed, 3730 margin: (_toValue3 = toValue(scrollConfig.margin)) !== null && _toValue3 !== void 0 ? _toValue3 : defaultScrollConfig.margin, 3731 direction: (_scrollConfig$directi = scrollConfig.direction) !== null && _scrollConfig$directi !== void 0 ? _scrollConfig$directi : defaultScrollConfig.direction 3732 } : defaultScrollConfig; 3733 const getScrollAxisValues = (value) => typeof value === "number" ? [value, value] : [value.x, value.y]; 3734 const handleAutoScroll = (container, targetRect, position2) => { 3735 const { clientWidth, clientHeight, scrollLeft, scrollTop, scrollWidth, scrollHeight } = container; 3736 const [marginX, marginY] = getScrollAxisValues(scrollSettings.margin); 3737 const [speedX, speedY] = getScrollAxisValues(scrollSettings.speed); 3738 let deltaX = 0; 3739 let deltaY = 0; 3740 if (scrollSettings.direction === "x" || scrollSettings.direction === "both") { 3741 if (position2.x < marginX && scrollLeft > 0) deltaX = -speedX; 3742 else if (position2.x + targetRect.width > clientWidth - marginX && scrollLeft < scrollWidth - clientWidth) deltaX = speedX; 3743 } 3744 if (scrollSettings.direction === "y" || scrollSettings.direction === "both") { 3745 if (position2.y < marginY && scrollTop > 0) deltaY = -speedY; 3746 else if (position2.y + targetRect.height > clientHeight - marginY && scrollTop < scrollHeight - clientHeight) deltaY = speedY; 3747 } 3748 if (deltaX || deltaY) container.scrollBy({ 3749 left: deltaX, 3750 top: deltaY, 3751 behavior: "auto" 3752 }); 3753 }; 3754 let autoScrollInterval = null; 3755 const startAutoScroll = () => { 3756 const container = toValue(containerElement); 3757 if (container && !autoScrollInterval) autoScrollInterval = setInterval(() => { 3758 const targetRect = toValue(target).getBoundingClientRect(); 3759 const { x, y } = position.value; 3760 const relativePosition = { 3761 x: x - container.scrollLeft, 3762 y: y - container.scrollTop 3763 }; 3764 if (relativePosition.x >= 0 && relativePosition.y >= 0) { 3765 handleAutoScroll(container, targetRect, relativePosition); 3766 relativePosition.x += container.scrollLeft; 3767 relativePosition.y += container.scrollTop; 3768 position.value = relativePosition; 3769 } 3770 }, 1e3 / 60); 3771 }; 3772 const stopAutoScroll = () => { 3773 if (autoScrollInterval) { 3774 clearInterval(autoScrollInterval); 3775 autoScrollInterval = null; 3776 } 3777 }; 3778 const isPointerNearEdge = (pointer, container, margin, targetRect) => { 3779 const [marginX, marginY] = typeof margin === "number" ? [margin, margin] : [margin.x, margin.y]; 3780 const { clientWidth, clientHeight } = container; 3781 return pointer.x < marginX || pointer.x + targetRect.width > clientWidth - marginX || pointer.y < marginY || pointer.y + targetRect.height > clientHeight - marginY; 3782 }; 3783 const checkAutoScroll = () => { 3784 if (toValue(options.disabled) || !pressedDelta.value) return; 3785 const container = toValue(containerElement); 3786 if (!container) return; 3787 const targetRect = toValue(target).getBoundingClientRect(); 3788 const { x, y } = position.value; 3789 if (isPointerNearEdge({ 3790 x: x - container.scrollLeft, 3791 y: y - container.scrollTop 3792 }, container, scrollSettings.margin, targetRect)) startAutoScroll(); 3793 else stopAutoScroll(); 3794 }; 3795 if (toValue(autoScroll)) watch(position, checkAutoScroll); 3796 const start = (e) => { 3797 var _container$getBoundin; 3798 if (!toValue(buttons).includes(e.button)) return; 3799 if (toValue(options.disabled) || !filterEvent(e)) return; 3800 if (toValue(exact) && e.target !== toValue(target)) return; 3801 const container = toValue(containerElement); 3802 const containerRect = container === null || container === void 0 || (_container$getBoundin = container.getBoundingClientRect) === null || _container$getBoundin === void 0 ? void 0 : _container$getBoundin.call(container); 3803 const targetRect = toValue(target).getBoundingClientRect(); 3804 const pos = { 3805 x: e.clientX - (container ? targetRect.left - containerRect.left + (autoScroll ? 0 : container.scrollLeft) : targetRect.left), 3806 y: e.clientY - (container ? targetRect.top - containerRect.top + (autoScroll ? 0 : container.scrollTop) : targetRect.top) 3807 }; 3808 if ((onStart === null || onStart === void 0 ? void 0 : onStart(pos, e)) === false) return; 3809 pressedDelta.value = pos; 3810 handleEvent(e); 3811 }; 3812 const move = (e) => { 3813 if (toValue(options.disabled) || !filterEvent(e)) return; 3814 if (!pressedDelta.value) return; 3815 const container = toValue(containerElement); 3816 if (container instanceof HTMLElement) clampContainerScroll(container); 3817 const targetRect = toValue(target).getBoundingClientRect(); 3818 let { x, y } = position.value; 3819 if (axis === "x" || axis === "both") { 3820 x = e.clientX - pressedDelta.value.x; 3821 if (container) x = Math.min(Math.max(0, x), container.scrollWidth - targetRect.width); 3822 } 3823 if (axis === "y" || axis === "both") { 3824 y = e.clientY - pressedDelta.value.y; 3825 if (container) y = Math.min(Math.max(0, y), container.scrollHeight - targetRect.height); 3826 } 3827 if (toValue(autoScroll) && container) { 3828 if (autoScrollInterval === null) handleAutoScroll(container, targetRect, { 3829 x, 3830 y 3831 }); 3832 x += container.scrollLeft; 3833 y += container.scrollTop; 3834 } 3835 if (container && (restrictInView || autoScroll)) { 3836 if (axis !== "y") { 3837 const relativeX = x - container.scrollLeft; 3838 if (relativeX < 0) x = container.scrollLeft; 3839 else if (relativeX > container.clientWidth - targetRect.width) x = container.clientWidth - targetRect.width + container.scrollLeft; 3840 } 3841 if (axis !== "x") { 3842 const relativeY = y - container.scrollTop; 3843 if (relativeY < 0) y = container.scrollTop; 3844 else if (relativeY > container.clientHeight - targetRect.height) y = container.clientHeight - targetRect.height + container.scrollTop; 3845 } 3846 } 3847 position.value = { 3848 x, 3849 y 3850 }; 3851 onMove === null || onMove === void 0 || onMove(position.value, e); 3852 handleEvent(e); 3853 }; 3854 const end = (e) => { 3855 if (toValue(options.disabled) || !filterEvent(e)) return; 3856 if (!pressedDelta.value) return; 3857 pressedDelta.value = void 0; 3858 if (autoScroll) stopAutoScroll(); 3859 onEnd === null || onEnd === void 0 || onEnd(position.value, e); 3860 handleEvent(e); 3861 }; 3862 if (isClient) { 3863 const config = () => { 3864 var _options$capture; 3865 return { 3866 capture: (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : true, 3867 passive: !toValue(preventDefault2) 3868 }; 3869 }; 3870 useEventListener(draggingHandle, "pointerdown", start, config); 3871 useEventListener(draggingElement, "pointermove", move, config); 3872 useEventListener(draggingElement, "pointerup", end, config); 3873 } 3874 return { 3875 ...toRefs2(position), 3876 position, 3877 isDragging: computed(() => !!pressedDelta.value), 3878 style: computed(() => ` 3879 left: ${position.value.x}px; 3880 top: ${position.value.y}px; 3881 ${autoScroll ? "text-wrap: nowrap;" : ""} 3882 `) 3883 }; 3884 } 3885 function useDropZone(target, options = {}) { 3886 const isOverDropZone = shallowRef(false); 3887 const files = shallowRef(null); 3888 let counter = 0; 3889 let isValid = true; 3890 if (isClient) { 3891 var _options$multiple, _options$preventDefau; 3892 const _options = typeof options === "function" ? { onDrop: options } : options; 3893 const multiple = (_options$multiple = _options.multiple) !== null && _options$multiple !== void 0 ? _options$multiple : true; 3894 const preventDefaultForUnhandled = (_options$preventDefau = _options.preventDefaultForUnhandled) !== null && _options$preventDefau !== void 0 ? _options$preventDefau : false; 3895 const getFiles = (event) => { 3896 var _event$dataTransfer$f, _event$dataTransfer; 3897 const list = Array.from((_event$dataTransfer$f = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.files) !== null && _event$dataTransfer$f !== void 0 ? _event$dataTransfer$f : []); 3898 return list.length === 0 ? null : multiple ? list : [list[0]]; 3899 }; 3900 const checkDataTypes = (types) => { 3901 const dataTypes = unref(_options.dataTypes); 3902 if (typeof dataTypes === "function") return dataTypes(types); 3903 if (!(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length)) return true; 3904 if (types.length === 0) return false; 3905 return types.every((type) => dataTypes.some((allowedType) => type.includes(allowedType))); 3906 }; 3907 const checkValidity = (items) => { 3908 if (_options.checkValidity) return _options.checkValidity(items); 3909 const dataTypesValid = checkDataTypes(Array.from(items !== null && items !== void 0 ? items : []).map((item) => item.type)); 3910 const multipleFilesValid = multiple || items.length <= 1; 3911 return dataTypesValid && multipleFilesValid; 3912 }; 3913 const isSafari = () => /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in window); 3914 const handleDragEvent = (event, eventType) => { 3915 var _event$dataTransfer2, _ref; 3916 const dataTransferItemList = (_event$dataTransfer2 = event.dataTransfer) === null || _event$dataTransfer2 === void 0 ? void 0 : _event$dataTransfer2.items; 3917 isValid = (_ref = dataTransferItemList && checkValidity(dataTransferItemList)) !== null && _ref !== void 0 ? _ref : false; 3918 if (preventDefaultForUnhandled) event.preventDefault(); 3919 if (!isSafari() && !isValid) { 3920 if (event.dataTransfer) event.dataTransfer.dropEffect = "none"; 3921 return; 3922 } 3923 event.preventDefault(); 3924 if (event.dataTransfer) event.dataTransfer.dropEffect = "copy"; 3925 const currentFiles = getFiles(event); 3926 switch (eventType) { 3927 case "enter": 3928 var _options$onEnter; 3929 counter += 1; 3930 isOverDropZone.value = true; 3931 (_options$onEnter = _options.onEnter) === null || _options$onEnter === void 0 || _options$onEnter.call(_options, null, event); 3932 break; 3933 case "over": 3934 var _options$onOver; 3935 (_options$onOver = _options.onOver) === null || _options$onOver === void 0 || _options$onOver.call(_options, null, event); 3936 break; 3937 case "leave": 3938 var _options$onLeave; 3939 counter -= 1; 3940 if (counter === 0) isOverDropZone.value = false; 3941 (_options$onLeave = _options.onLeave) === null || _options$onLeave === void 0 || _options$onLeave.call(_options, null, event); 3942 break; 3943 case "drop": 3944 counter = 0; 3945 isOverDropZone.value = false; 3946 if (isValid) { 3947 var _options$onDrop; 3948 files.value = currentFiles; 3949 (_options$onDrop = _options.onDrop) === null || _options$onDrop === void 0 || _options$onDrop.call(_options, currentFiles, event); 3950 } 3951 break; 3952 } 3953 }; 3954 useEventListener(target, "dragenter", (event) => handleDragEvent(event, "enter")); 3955 useEventListener(target, "dragover", (event) => handleDragEvent(event, "over")); 3956 useEventListener(target, "dragleave", (event) => handleDragEvent(event, "leave")); 3957 useEventListener(target, "drop", (event) => handleDragEvent(event, "drop")); 3958 } 3959 return { 3960 files, 3961 isOverDropZone 3962 }; 3963 } 3964 function useResizeObserver(target, callback, options = {}) { 3965 const { window: window2 = defaultWindow, ...observerOptions } = options; 3966 let observer; 3967 const isSupported = useSupported(() => window2 && "ResizeObserver" in window2); 3968 const cleanup = () => { 3969 if (observer) { 3970 observer.disconnect(); 3971 observer = void 0; 3972 } 3973 }; 3974 const stopWatch = watch(computed(() => { 3975 const _targets = toValue(target); 3976 return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)]; 3977 }), (els) => { 3978 cleanup(); 3979 if (isSupported.value && window2) { 3980 observer = new ResizeObserver(callback); 3981 for (const _el of els) if (_el) observer.observe(_el, observerOptions); 3982 } 3983 }, { 3984 immediate: true, 3985 flush: "post" 3986 }); 3987 const stop = () => { 3988 cleanup(); 3989 stopWatch(); 3990 }; 3991 tryOnScopeDispose(stop); 3992 return { 3993 isSupported, 3994 stop 3995 }; 3996 } 3997 function useElementBounding(target, options = {}) { 3998 const { reset = true, windowResize = true, windowScroll = true, immediate = true, updateTiming = "sync" } = options; 3999 const height = shallowRef(0); 4000 const bottom = shallowRef(0); 4001 const left = shallowRef(0); 4002 const right = shallowRef(0); 4003 const top = shallowRef(0); 4004 const width = shallowRef(0); 4005 const x = shallowRef(0); 4006 const y = shallowRef(0); 4007 function recalculate() { 4008 const el = unrefElement(target); 4009 if (!el) { 4010 if (reset) { 4011 height.value = 0; 4012 bottom.value = 0; 4013 left.value = 0; 4014 right.value = 0; 4015 top.value = 0; 4016 width.value = 0; 4017 x.value = 0; 4018 y.value = 0; 4019 } 4020 return; 4021 } 4022 const rect = el.getBoundingClientRect(); 4023 height.value = rect.height; 4024 bottom.value = rect.bottom; 4025 left.value = rect.left; 4026 right.value = rect.right; 4027 top.value = rect.top; 4028 width.value = rect.width; 4029 x.value = rect.x; 4030 y.value = rect.y; 4031 } 4032 function update() { 4033 if (updateTiming === "sync") recalculate(); 4034 else if (updateTiming === "next-frame") requestAnimationFrame(() => recalculate()); 4035 } 4036 useResizeObserver(target, update); 4037 watch(() => unrefElement(target), (ele) => !ele && update()); 4038 useMutationObserver(target, update, { attributeFilter: ["style", "class"] }); 4039 if (windowScroll) useEventListener("scroll", update, { 4040 capture: true, 4041 passive: true 4042 }); 4043 if (windowResize) useEventListener("resize", update, { passive: true }); 4044 tryOnMounted(() => { 4045 if (immediate) update(); 4046 }); 4047 return { 4048 height, 4049 bottom, 4050 left, 4051 right, 4052 top, 4053 width, 4054 x, 4055 y, 4056 update 4057 }; 4058 } 4059 function getDefaultScheduler$7(options) { 4060 if ("interval" in options || "immediate" in options) { 4061 const { interval = "requestAnimationFrame", immediate = true } = options; 4062 return interval === "requestAnimationFrame" ? (cb) => useRafFn(cb, { immediate }) : (cb) => useIntervalFn(cb, interval, { immediate }); 4063 } 4064 return useRafFn; 4065 } 4066 function useElementByPoint(options) { 4067 const { x, y, document: document2 = defaultDocument, multiple, scheduler = getDefaultScheduler$7(options) } = options; 4068 const isSupported = useSupported(() => { 4069 if (toValue(multiple)) return document2 && "elementsFromPoint" in document2; 4070 return document2 && "elementFromPoint" in document2; 4071 }); 4072 const element = shallowRef(null); 4073 return { 4074 isSupported, 4075 element, 4076 ...scheduler(() => { 4077 var _document$elementsFro, _document$elementFrom; 4078 element.value = toValue(multiple) ? (_document$elementsFro = document2 === null || document2 === void 0 ? void 0 : document2.elementsFromPoint(toValue(x), toValue(y))) !== null && _document$elementsFro !== void 0 ? _document$elementsFro : [] : (_document$elementFrom = document2 === null || document2 === void 0 ? void 0 : document2.elementFromPoint(toValue(x), toValue(y))) !== null && _document$elementFrom !== void 0 ? _document$elementFrom : null; 4079 }) 4080 }; 4081 } 4082 function useElementHover(el, options = {}) { 4083 const { delayEnter = 0, delayLeave = 0, triggerOnRemoval = false, window: window2 = defaultWindow } = options; 4084 const isHovered = shallowRef(false); 4085 let timer; 4086 const toggle = (entering) => { 4087 const delay = entering ? delayEnter : delayLeave; 4088 if (timer) { 4089 clearTimeout(timer); 4090 timer = void 0; 4091 } 4092 if (delay) timer = setTimeout(() => isHovered.value = entering, delay); 4093 else isHovered.value = entering; 4094 }; 4095 if (!window2) return isHovered; 4096 useEventListener(el, "mouseenter", () => toggle(true), { passive: true }); 4097 useEventListener(el, "mouseleave", () => toggle(false), { passive: true }); 4098 if (triggerOnRemoval) onElementRemoval(computed(() => unrefElement(el)), () => toggle(false)); 4099 return isHovered; 4100 } 4101 function useElementSize(target, initialSize = { 4102 width: 0, 4103 height: 0 4104 }, options = {}) { 4105 const { window: window2 = defaultWindow, box = "content-box" } = options; 4106 const isSVG = computed(() => { 4107 var _unrefElement; 4108 return (_unrefElement = unrefElement(target)) === null || _unrefElement === void 0 || (_unrefElement = _unrefElement.namespaceURI) === null || _unrefElement === void 0 ? void 0 : _unrefElement.includes("svg"); 4109 }); 4110 const width = shallowRef(initialSize.width); 4111 const height = shallowRef(initialSize.height); 4112 const { stop: stop1 } = useResizeObserver(target, ([entry]) => { 4113 const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize; 4114 if (window2 && isSVG.value) { 4115 const $elem = unrefElement(target); 4116 if ($elem) { 4117 const rect = $elem.getBoundingClientRect(); 4118 width.value = rect.width; 4119 height.value = rect.height; 4120 } 4121 } else if (boxSize) { 4122 const formatBoxSize = toArray(boxSize); 4123 width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0); 4124 height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0); 4125 } else { 4126 width.value = entry.contentRect.width; 4127 height.value = entry.contentRect.height; 4128 } 4129 }, options); 4130 tryOnMounted(() => { 4131 const ele = unrefElement(target); 4132 if (ele) { 4133 width.value = "offsetWidth" in ele ? ele.offsetWidth : initialSize.width; 4134 height.value = "offsetHeight" in ele ? ele.offsetHeight : initialSize.height; 4135 } 4136 }); 4137 const stop2 = watch(() => unrefElement(target), (ele) => { 4138 width.value = ele ? initialSize.width : 0; 4139 height.value = ele ? initialSize.height : 0; 4140 }); 4141 function stop() { 4142 stop1(); 4143 stop2(); 4144 } 4145 return { 4146 width, 4147 height, 4148 stop 4149 }; 4150 } 4151 function useIntersectionObserver(target, callback, options = {}) { 4152 const { root, rootMargin, threshold = 0, window: window2 = defaultWindow, immediate = true } = options; 4153 const isSupported = useSupported(() => window2 && "IntersectionObserver" in window2); 4154 const targets = computed(() => { 4155 return toArray(toValue(target)).map(unrefElement).filter(notNullish); 4156 }); 4157 let cleanup = noop; 4158 const isActive = shallowRef(immediate); 4159 const stopWatch = isSupported.value ? watch(() => [ 4160 targets.value, 4161 unrefElement(root), 4162 toValue(rootMargin), 4163 isActive.value 4164 ], ([targets2, root2, rootMargin2]) => { 4165 cleanup(); 4166 if (!isActive.value) return; 4167 if (!targets2.length) return; 4168 const observer = new IntersectionObserver(callback, { 4169 root: unrefElement(root2), 4170 rootMargin: rootMargin2, 4171 threshold 4172 }); 4173 targets2.forEach((el) => el && observer.observe(el)); 4174 cleanup = () => { 4175 observer.disconnect(); 4176 cleanup = noop; 4177 }; 4178 }, { 4179 immediate, 4180 flush: "post" 4181 }) : noop; 4182 const stop = () => { 4183 cleanup(); 4184 stopWatch(); 4185 isActive.value = false; 4186 }; 4187 tryOnScopeDispose(stop); 4188 return { 4189 isSupported, 4190 isActive, 4191 pause() { 4192 cleanup(); 4193 isActive.value = false; 4194 }, 4195 resume() { 4196 isActive.value = true; 4197 }, 4198 stop 4199 }; 4200 } 4201 function useElementVisibility(element, options = {}) { 4202 const { window: window2 = defaultWindow, scrollTarget, threshold = 0, rootMargin, once = false, initialValue = false } = options; 4203 const isVisible = shallowRef(initialValue); 4204 const observerController = useIntersectionObserver(element, (intersectionObserverEntries) => { 4205 let isIntersecting = isVisible.value; 4206 let latestTime = 0; 4207 for (const entry of intersectionObserverEntries) if (entry.time >= latestTime) { 4208 latestTime = entry.time; 4209 isIntersecting = entry.isIntersecting; 4210 } 4211 isVisible.value = isIntersecting; 4212 if (once) watchOnce(isVisible, () => { 4213 observerController.stop(); 4214 }); 4215 }, { 4216 root: scrollTarget, 4217 window: window2, 4218 threshold, 4219 rootMargin 4220 }); 4221 return options.controls ? { 4222 ...observerController, 4223 isVisible 4224 } : isVisible; 4225 } 4226 var events = /* @__PURE__ */ new Map(); 4227 function useEventBus(key) { 4228 const scope = getCurrentScope(); 4229 function on(listener) { 4230 var _scope$cleanups; 4231 const listeners = events.get(key) || /* @__PURE__ */ new Set(); 4232 listeners.add(listener); 4233 events.set(key, listeners); 4234 const _off = () => off(listener); 4235 scope === null || scope === void 0 || (_scope$cleanups = scope.cleanups) === null || _scope$cleanups === void 0 || _scope$cleanups.push(_off); 4236 return _off; 4237 } 4238 function once(listener) { 4239 function _listener(...args) { 4240 off(_listener); 4241 listener(...args); 4242 } 4243 return on(_listener); 4244 } 4245 function off(listener) { 4246 const listeners = events.get(key); 4247 if (!listeners) return; 4248 listeners.delete(listener); 4249 if (!listeners.size) reset(); 4250 } 4251 function reset() { 4252 events.delete(key); 4253 } 4254 function emit(event, payload) { 4255 var _events$get; 4256 (_events$get = events.get(key)) === null || _events$get === void 0 || _events$get.forEach((v) => v(event, payload)); 4257 } 4258 return { 4259 on, 4260 once, 4261 off, 4262 emit, 4263 reset 4264 }; 4265 } 4266 function resolveNestedOptions$1(options) { 4267 if (options === true) return {}; 4268 return options; 4269 } 4270 function useEventSource(url, events2 = [], options = {}) { 4271 const event = shallowRef(null); 4272 const data = shallowRef(null); 4273 const status = shallowRef("CONNECTING"); 4274 const eventSource = shallowRef(null); 4275 const error = shallowRef(null); 4276 const urlRef = toRef2(url); 4277 const lastEventId = shallowRef(null); 4278 let explicitlyClosed = false; 4279 let retried = 0; 4280 const { withCredentials = false, immediate = true, autoConnect = true, autoReconnect, serializer = { read: (v) => v } } = options; 4281 const close = () => { 4282 if (isClient && eventSource.value) { 4283 eventSource.value.close(); 4284 eventSource.value = null; 4285 status.value = "CLOSED"; 4286 explicitlyClosed = true; 4287 } 4288 }; 4289 const _init = () => { 4290 if (explicitlyClosed || typeof urlRef.value === "undefined") return; 4291 const es = new EventSource(urlRef.value, { withCredentials }); 4292 status.value = "CONNECTING"; 4293 eventSource.value = es; 4294 es.onopen = () => { 4295 status.value = "OPEN"; 4296 error.value = null; 4297 }; 4298 es.onerror = (e) => { 4299 status.value = "CLOSED"; 4300 error.value = e; 4301 if (es.readyState === 2 && !explicitlyClosed && autoReconnect) { 4302 es.close(); 4303 const { retries = -1, delay = 1e3, onFailed } = resolveNestedOptions$1(autoReconnect); 4304 retried += 1; 4305 if (typeof retries === "number" && (retries < 0 || retried < retries)) setTimeout(_init, delay); 4306 else if (typeof retries === "function" && retries()) setTimeout(_init, delay); 4307 else onFailed === null || onFailed === void 0 || onFailed(); 4308 } 4309 }; 4310 es.onmessage = (e) => { 4311 var _serializer$read; 4312 event.value = null; 4313 data.value = (_serializer$read = serializer.read(e.data)) !== null && _serializer$read !== void 0 ? _serializer$read : null; 4314 lastEventId.value = e.lastEventId; 4315 }; 4316 for (const event_name of events2) useEventListener(es, event_name, (e) => { 4317 var _serializer$read2, _e$lastEventId; 4318 event.value = event_name; 4319 data.value = (_serializer$read2 = serializer.read(e.data)) !== null && _serializer$read2 !== void 0 ? _serializer$read2 : null; 4320 lastEventId.value = (_e$lastEventId = e.lastEventId) !== null && _e$lastEventId !== void 0 ? _e$lastEventId : null; 4321 }, { passive: true }); 4322 }; 4323 const open = () => { 4324 if (!isClient) return; 4325 close(); 4326 explicitlyClosed = false; 4327 retried = 0; 4328 _init(); 4329 }; 4330 if (immediate) open(); 4331 if (autoConnect) watch(urlRef, open); 4332 tryOnScopeDispose(close); 4333 return { 4334 eventSource, 4335 event, 4336 data, 4337 status, 4338 error, 4339 open, 4340 close, 4341 lastEventId 4342 }; 4343 } 4344 function useEyeDropper(options = {}) { 4345 const { initialValue = "" } = options; 4346 const isSupported = useSupported(() => typeof window !== "undefined" && "EyeDropper" in window); 4347 const sRGBHex = shallowRef(initialValue); 4348 async function open(openOptions) { 4349 if (!isSupported.value) return; 4350 const result = await new window.EyeDropper().open(openOptions); 4351 sRGBHex.value = result.sRGBHex; 4352 return result; 4353 } 4354 return { 4355 isSupported, 4356 sRGBHex, 4357 open 4358 }; 4359 } 4360 function useFavicon(newIcon = null, options = {}) { 4361 const { baseUrl = "", rel = "icon", document: document2 = defaultDocument } = options; 4362 const favicon = toRef2(newIcon); 4363 const applyIcon = (icon) => { 4364 const elements = document2 === null || document2 === void 0 ? void 0 : document2.head.querySelectorAll(`link[rel*="${rel}"]`); 4365 if (!elements || elements.length === 0) { 4366 const link = document2 === null || document2 === void 0 ? void 0 : document2.createElement("link"); 4367 if (link) { 4368 link.rel = rel; 4369 link.href = `${baseUrl}${icon}`; 4370 link.type = `image/${icon.split(".").pop()}`; 4371 document2 === null || document2 === void 0 || document2.head.append(link); 4372 } 4373 return; 4374 } 4375 elements === null || elements === void 0 || elements.forEach((el) => el.href = `${baseUrl}${icon}`); 4376 }; 4377 watch(favicon, (i, o) => { 4378 if (typeof i === "string" && i !== o) applyIcon(i); 4379 }, { immediate: true }); 4380 return favicon; 4381 } 4382 var payloadMapping = { 4383 json: "application/json", 4384 text: "text/plain" 4385 }; 4386 function isFetchOptions(obj) { 4387 return obj && containsProp(obj, "immediate", "refetch", "initialData", "timeout", "beforeFetch", "afterFetch", "onFetchError", "fetch", "updateDataOnError"); 4388 } 4389 var reAbsolute = /^(?:[a-z][a-z\d+\-.]*:)?\/\//i; 4390 function isAbsoluteURL(url) { 4391 return reAbsolute.test(url); 4392 } 4393 function headersToObject(headers) { 4394 if (typeof Headers !== "undefined" && headers instanceof Headers) return Object.fromEntries(headers.entries()); 4395 return headers; 4396 } 4397 function combineCallbacks(combination, ...callbacks) { 4398 if (combination === "overwrite") return async (ctx) => { 4399 let callback; 4400 for (let i = callbacks.length - 1; i >= 0; i--) if (callbacks[i] != null) { 4401 callback = callbacks[i]; 4402 break; 4403 } 4404 if (callback) return { 4405 ...ctx, 4406 ...await callback(ctx) 4407 }; 4408 return ctx; 4409 }; 4410 else return async (ctx) => { 4411 for (const callback of callbacks) if (callback) ctx = { 4412 ...ctx, 4413 ...await callback(ctx) 4414 }; 4415 return ctx; 4416 }; 4417 } 4418 function createFetch(config = {}) { 4419 const _combination = config.combination || "chain"; 4420 const _options = config.options || {}; 4421 const _fetchOptions = config.fetchOptions || {}; 4422 function useFactoryFetch(url, ...args) { 4423 const computedUrl = computed(() => { 4424 const baseUrl = toValue(config.baseUrl); 4425 const targetUrl = toValue(url); 4426 return baseUrl && !isAbsoluteURL(targetUrl) ? joinPaths(baseUrl, targetUrl) : targetUrl; 4427 }); 4428 let options = _options; 4429 let fetchOptions = _fetchOptions; 4430 if (args.length > 0) if (isFetchOptions(args[0])) options = { 4431 ...options, 4432 ...args[0], 4433 beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch), 4434 afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch), 4435 onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError) 4436 }; 4437 else fetchOptions = { 4438 ...fetchOptions, 4439 ...args[0], 4440 headers: { 4441 ...headersToObject(fetchOptions.headers) || {}, 4442 ...headersToObject(args[0].headers) || {} 4443 } 4444 }; 4445 if (args.length > 1 && isFetchOptions(args[1])) options = { 4446 ...options, 4447 ...args[1], 4448 beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch), 4449 afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch), 4450 onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError) 4451 }; 4452 return useFetch(computedUrl, fetchOptions, options); 4453 } 4454 return useFactoryFetch; 4455 } 4456 function useFetch(url, ...args) { 4457 var _defaultWindow$fetch, _globalThis; 4458 const supportsAbort = typeof AbortController === "function"; 4459 let fetchOptions = {}; 4460 let options = { 4461 immediate: true, 4462 refetch: false, 4463 timeout: 0, 4464 updateDataOnError: false 4465 }; 4466 const config = { 4467 method: "GET", 4468 type: "text", 4469 payload: void 0 4470 }; 4471 if (args.length > 0) if (isFetchOptions(args[0])) options = { 4472 ...options, 4473 ...args[0] 4474 }; 4475 else fetchOptions = args[0]; 4476 if (args.length > 1) { 4477 if (isFetchOptions(args[1])) options = { 4478 ...options, 4479 ...args[1] 4480 }; 4481 } 4482 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; 4483 const responseEvent = createEventHook(); 4484 const errorEvent = createEventHook(); 4485 const finallyEvent = createEventHook(); 4486 const isFinished = shallowRef(false); 4487 const isFetching = shallowRef(false); 4488 const aborted = shallowRef(false); 4489 const statusCode = shallowRef(null); 4490 const response = shallowRef(null); 4491 const error = shallowRef(null); 4492 const data = shallowRef(initialData || null); 4493 const canAbort = computed(() => supportsAbort && isFetching.value); 4494 let controller; 4495 let timer; 4496 const abort = (reason) => { 4497 if (supportsAbort) { 4498 controller === null || controller === void 0 || controller.abort(reason); 4499 controller = new AbortController(); 4500 controller.signal.onabort = () => aborted.value = true; 4501 fetchOptions = { 4502 ...fetchOptions, 4503 signal: controller.signal 4504 }; 4505 } 4506 }; 4507 const loading = (isLoading) => { 4508 isFetching.value = isLoading; 4509 isFinished.value = !isLoading; 4510 }; 4511 if (timeout) timer = useTimeoutFn(abort, timeout, { immediate: false }); 4512 let executeCounter = 0; 4513 const execute = async (throwOnFailed = false) => { 4514 var _context$options; 4515 abort(); 4516 loading(true); 4517 error.value = null; 4518 statusCode.value = null; 4519 aborted.value = false; 4520 executeCounter += 1; 4521 const currentExecuteCounter = executeCounter; 4522 const defaultFetchOptions = { 4523 method: config.method, 4524 headers: {} 4525 }; 4526 const payload = toValue(config.payload); 4527 if (payload) { 4528 var _payloadMapping$confi; 4529 const headers = headersToObject(defaultFetchOptions.headers); 4530 const proto = Object.getPrototypeOf(payload); 4531 if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData)) config.payloadType = "json"; 4532 if (config.payloadType) headers["Content-Type"] = (_payloadMapping$confi = payloadMapping[config.payloadType]) !== null && _payloadMapping$confi !== void 0 ? _payloadMapping$confi : config.payloadType; 4533 defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload; 4534 } 4535 let isCanceled = false; 4536 const context = { 4537 url: toValue(url), 4538 options: { 4539 ...defaultFetchOptions, 4540 ...fetchOptions 4541 }, 4542 cancel: () => { 4543 isCanceled = true; 4544 } 4545 }; 4546 if (options.beforeFetch) Object.assign(context, await options.beforeFetch(context)); 4547 if (isCanceled || !fetch) { 4548 loading(false); 4549 return Promise.resolve(null); 4550 } 4551 let responseData = null; 4552 if (timer) timer.start(); 4553 return fetch(context.url, { 4554 ...defaultFetchOptions, 4555 ...context.options, 4556 headers: { 4557 ...headersToObject(defaultFetchOptions.headers), 4558 ...headersToObject((_context$options = context.options) === null || _context$options === void 0 ? void 0 : _context$options.headers) 4559 } 4560 }).then(async (fetchResponse) => { 4561 response.value = fetchResponse; 4562 statusCode.value = fetchResponse.status; 4563 responseData = await fetchResponse.clone()[config.type](); 4564 if (!fetchResponse.ok) { 4565 data.value = initialData || null; 4566 throw new Error(fetchResponse.statusText); 4567 } 4568 if (options.afterFetch) ({ data: responseData } = await options.afterFetch({ 4569 data: responseData, 4570 response: fetchResponse, 4571 context, 4572 execute 4573 })); 4574 data.value = responseData; 4575 responseEvent.trigger(fetchResponse); 4576 return fetchResponse; 4577 }).catch(async (fetchError) => { 4578 let errorData = fetchError.message || fetchError.name; 4579 if (options.onFetchError) ({ error: errorData, data: responseData } = await options.onFetchError({ 4580 data: responseData, 4581 error: fetchError, 4582 response: response.value, 4583 context, 4584 execute 4585 })); 4586 error.value = errorData; 4587 if (options.updateDataOnError) data.value = responseData; 4588 errorEvent.trigger(fetchError); 4589 if (throwOnFailed) throw fetchError; 4590 return null; 4591 }).finally(() => { 4592 if (currentExecuteCounter === executeCounter) loading(false); 4593 if (timer) timer.stop(); 4594 finallyEvent.trigger(null); 4595 }); 4596 }; 4597 const refetch = toRef2(options.refetch); 4598 watch([refetch, toRef2(url)], ([refetch2]) => refetch2 && execute(), { deep: true }); 4599 const shell = { 4600 isFinished: shallowReadonly(isFinished), 4601 isFetching: shallowReadonly(isFetching), 4602 statusCode, 4603 response, 4604 error, 4605 data, 4606 canAbort, 4607 aborted, 4608 abort, 4609 execute, 4610 onFetchResponse: responseEvent.on, 4611 onFetchError: errorEvent.on, 4612 onFetchFinally: finallyEvent.on, 4613 get: setMethod("GET"), 4614 put: setMethod("PUT"), 4615 post: setMethod("POST"), 4616 delete: setMethod("DELETE"), 4617 patch: setMethod("PATCH"), 4618 head: setMethod("HEAD"), 4619 options: setMethod("OPTIONS"), 4620 json: setType("json"), 4621 text: setType("text"), 4622 blob: setType("blob"), 4623 arrayBuffer: setType("arrayBuffer"), 4624 formData: setType("formData") 4625 }; 4626 function setMethod(method) { 4627 return (payload, payloadType) => { 4628 if (!isFetching.value) { 4629 config.method = method; 4630 config.payload = payload; 4631 config.payloadType = payloadType; 4632 if (isRef(config.payload)) watch([refetch, toRef2(config.payload)], ([refetch2]) => refetch2 && execute(), { deep: true }); 4633 return { 4634 ...shell, 4635 then(onFulfilled, onRejected) { 4636 return waitUntilFinished().then(onFulfilled, onRejected); 4637 } 4638 }; 4639 } 4640 }; 4641 } 4642 function waitUntilFinished() { 4643 return new Promise((resolve, reject) => { 4644 until(isFinished).toBe(true).then(() => resolve(shell)).catch(reject); 4645 }); 4646 } 4647 function setType(type) { 4648 return () => { 4649 if (!isFetching.value) { 4650 config.type = type; 4651 return { 4652 ...shell, 4653 then(onFulfilled, onRejected) { 4654 return waitUntilFinished().then(onFulfilled, onRejected); 4655 } 4656 }; 4657 } 4658 }; 4659 } 4660 if (options.immediate) Promise.resolve().then(() => execute()); 4661 return { 4662 ...shell, 4663 then(onFulfilled, onRejected) { 4664 return waitUntilFinished().then(onFulfilled, onRejected); 4665 } 4666 }; 4667 } 4668 function joinPaths(start, end) { 4669 if (!start.endsWith("/") && !end.startsWith("/")) return `${start}/${end}`; 4670 if (start.endsWith("/") && end.startsWith("/")) return `${start.slice(0, -1)}${end}`; 4671 return `${start}${end}`; 4672 } 4673 var DEFAULT_OPTIONS = { 4674 multiple: true, 4675 accept: "*", 4676 reset: false, 4677 directory: false 4678 }; 4679 function prepareInitialFiles(files) { 4680 if (!files) return null; 4681 if (files instanceof FileList) return files; 4682 const dt = new DataTransfer(); 4683 for (const file of files) dt.items.add(file); 4684 return dt.files; 4685 } 4686 function useFileDialog(options = {}) { 4687 const { document: document2 = defaultDocument } = options; 4688 const files = ref(prepareInitialFiles(options.initialFiles)); 4689 const { on: onChange, trigger: changeTrigger } = createEventHook(); 4690 const { on: onCancel, trigger: cancelTrigger } = createEventHook(); 4691 const inputRef = computed(() => { 4692 var _unrefElement; 4693 const input = (_unrefElement = unrefElement(options.input)) !== null && _unrefElement !== void 0 ? _unrefElement : document2 ? document2.createElement("input") : void 0; 4694 if (input) { 4695 input.type = "file"; 4696 input.onchange = (event) => { 4697 files.value = event.target.files; 4698 changeTrigger(files.value); 4699 }; 4700 input.oncancel = () => { 4701 cancelTrigger(); 4702 }; 4703 } 4704 return input; 4705 }); 4706 const reset = () => { 4707 files.value = null; 4708 if (inputRef.value && inputRef.value.value) { 4709 inputRef.value.value = ""; 4710 changeTrigger(null); 4711 } 4712 }; 4713 const applyOptions = (options2) => { 4714 const el = inputRef.value; 4715 if (!el) return; 4716 el.multiple = toValue(options2.multiple); 4717 el.accept = toValue(options2.accept); 4718 el.webkitdirectory = toValue(options2.directory); 4719 if (hasOwn(options2, "capture")) el.capture = toValue(options2.capture); 4720 }; 4721 const open = (localOptions) => { 4722 const el = inputRef.value; 4723 if (!el) return; 4724 const mergedOptions = { 4725 ...DEFAULT_OPTIONS, 4726 ...options, 4727 ...localOptions 4728 }; 4729 applyOptions(mergedOptions); 4730 if (toValue(mergedOptions.reset)) reset(); 4731 el.click(); 4732 }; 4733 watchEffect(() => { 4734 applyOptions(options); 4735 }); 4736 return { 4737 files: readonly(files), 4738 open, 4739 reset, 4740 onCancel, 4741 onChange 4742 }; 4743 } 4744 function useFileSystemAccess(options = {}) { 4745 const { window: _window = defaultWindow, dataType = "Text" } = options; 4746 const window2 = _window; 4747 const isSupported = useSupported(() => window2 && "showSaveFilePicker" in window2 && "showOpenFilePicker" in window2); 4748 const fileHandle = shallowRef(); 4749 const data = shallowRef(); 4750 const file = shallowRef(); 4751 const fileName = computed(() => { 4752 var _file$value$name, _file$value; 4753 return (_file$value$name = (_file$value = file.value) === null || _file$value === void 0 ? void 0 : _file$value.name) !== null && _file$value$name !== void 0 ? _file$value$name : ""; 4754 }); 4755 const fileMIME = computed(() => { 4756 var _file$value$type, _file$value2; 4757 return (_file$value$type = (_file$value2 = file.value) === null || _file$value2 === void 0 ? void 0 : _file$value2.type) !== null && _file$value$type !== void 0 ? _file$value$type : ""; 4758 }); 4759 const fileSize = computed(() => { 4760 var _file$value$size, _file$value3; 4761 return (_file$value$size = (_file$value3 = file.value) === null || _file$value3 === void 0 ? void 0 : _file$value3.size) !== null && _file$value$size !== void 0 ? _file$value$size : 0; 4762 }); 4763 const fileLastModified = computed(() => { 4764 var _file$value$lastModif, _file$value4; 4765 return (_file$value$lastModif = (_file$value4 = file.value) === null || _file$value4 === void 0 ? void 0 : _file$value4.lastModified) !== null && _file$value$lastModif !== void 0 ? _file$value$lastModif : 0; 4766 }); 4767 async function open(_options = {}) { 4768 if (!isSupported.value) return; 4769 const [handle] = await window2.showOpenFilePicker({ 4770 ...toValue(options), 4771 ..._options 4772 }); 4773 fileHandle.value = handle; 4774 await updateData(); 4775 } 4776 async function create(_options = {}) { 4777 if (!isSupported.value) return; 4778 fileHandle.value = await window2.showSaveFilePicker({ 4779 ...options, 4780 ..._options 4781 }); 4782 data.value = void 0; 4783 await updateData(); 4784 } 4785 async function save(_options = {}) { 4786 if (!isSupported.value) return; 4787 if (!fileHandle.value) return saveAs(_options); 4788 if (data.value) { 4789 const writableStream = await fileHandle.value.createWritable(); 4790 await writableStream.write(data.value); 4791 await writableStream.close(); 4792 } 4793 await updateFile(); 4794 } 4795 async function saveAs(_options = {}) { 4796 if (!isSupported.value) return; 4797 fileHandle.value = await window2.showSaveFilePicker({ 4798 ...options, 4799 ..._options 4800 }); 4801 if (data.value) { 4802 const writableStream = await fileHandle.value.createWritable(); 4803 await writableStream.write(data.value); 4804 await writableStream.close(); 4805 } 4806 await updateFile(); 4807 } 4808 async function updateFile() { 4809 var _fileHandle$value; 4810 file.value = await ((_fileHandle$value = fileHandle.value) === null || _fileHandle$value === void 0 ? void 0 : _fileHandle$value.getFile()); 4811 } 4812 async function updateData() { 4813 var _file$value5, _file$value6; 4814 await updateFile(); 4815 const type = toValue(dataType); 4816 if (type === "Text") data.value = await ((_file$value5 = file.value) === null || _file$value5 === void 0 ? void 0 : _file$value5.text()); 4817 else if (type === "ArrayBuffer") data.value = await ((_file$value6 = file.value) === null || _file$value6 === void 0 ? void 0 : _file$value6.arrayBuffer()); 4818 else if (type === "Blob") data.value = file.value; 4819 } 4820 watch(() => toValue(dataType), updateData); 4821 return { 4822 isSupported, 4823 data, 4824 file, 4825 fileName, 4826 fileMIME, 4827 fileSize, 4828 fileLastModified, 4829 open, 4830 create, 4831 save, 4832 saveAs, 4833 updateData 4834 }; 4835 } 4836 function useFocus(target, options = {}) { 4837 const { initialValue = false, focusVisible = false, preventScroll = false } = options; 4838 const innerFocused = shallowRef(false); 4839 const targetElement = computed(() => unrefElement(target)); 4840 const listenerOptions = { passive: true }; 4841 useEventListener(targetElement, "focus", (event) => { 4842 var _matches, _ref; 4843 if (!focusVisible || ((_matches = (_ref = event.target).matches) === null || _matches === void 0 ? void 0 : _matches.call(_ref, ":focus-visible"))) innerFocused.value = true; 4844 }, listenerOptions); 4845 useEventListener(targetElement, "blur", () => innerFocused.value = false, listenerOptions); 4846 const focused = computed({ 4847 get: () => innerFocused.value, 4848 set(value) { 4849 var _targetElement$value, _targetElement$value2; 4850 if (!value && innerFocused.value) (_targetElement$value = targetElement.value) === null || _targetElement$value === void 0 || _targetElement$value.blur(); 4851 else if (value && !innerFocused.value) (_targetElement$value2 = targetElement.value) === null || _targetElement$value2 === void 0 || _targetElement$value2.focus({ preventScroll }); 4852 } 4853 }); 4854 watch(targetElement, () => { 4855 focused.value = initialValue; 4856 }, { 4857 immediate: true, 4858 flush: "post" 4859 }); 4860 return { focused }; 4861 } 4862 var EVENT_FOCUS_IN = "focusin"; 4863 var EVENT_FOCUS_OUT = "focusout"; 4864 var PSEUDO_CLASS_FOCUS_WITHIN = ":focus-within"; 4865 function useFocusWithin(target, options = {}) { 4866 const { window: window2 = defaultWindow } = options; 4867 const targetElement = computed(() => unrefElement(target)); 4868 const _focused = shallowRef(false); 4869 const focused = computed(() => _focused.value); 4870 const activeElement = useActiveElement(options); 4871 if (!window2 || !activeElement.value) return { focused }; 4872 const listenerOptions = { passive: true }; 4873 useEventListener(targetElement, EVENT_FOCUS_IN, () => _focused.value = true, listenerOptions); 4874 useEventListener(targetElement, EVENT_FOCUS_OUT, () => { 4875 var _targetElement$value$, _targetElement$value, _targetElement$value$2; 4876 return _focused.value = (_targetElement$value$ = (_targetElement$value = targetElement.value) === null || _targetElement$value === void 0 || (_targetElement$value$2 = _targetElement$value.matches) === null || _targetElement$value$2 === void 0 ? void 0 : _targetElement$value$2.call(_targetElement$value, PSEUDO_CLASS_FOCUS_WITHIN)) !== null && _targetElement$value$ !== void 0 ? _targetElement$value$ : false; 4877 }, listenerOptions); 4878 return { focused }; 4879 } 4880 function useFps(options) { 4881 var _options$every; 4882 const fps = shallowRef(0); 4883 if (typeof performance === "undefined") return fps; 4884 const every = (_options$every = options === null || options === void 0 ? void 0 : options.every) !== null && _options$every !== void 0 ? _options$every : 10; 4885 let last = performance.now(); 4886 let ticks = 0; 4887 useRafFn(() => { 4888 ticks += 1; 4889 if (ticks >= every) { 4890 const now2 = performance.now(); 4891 const diff = now2 - last; 4892 fps.value = Math.round(1e3 / (diff / ticks)); 4893 last = now2; 4894 ticks = 0; 4895 } 4896 }); 4897 return fps; 4898 } 4899 var eventHandlers = [ 4900 "fullscreenchange", 4901 "webkitfullscreenchange", 4902 "webkitendfullscreen", 4903 "mozfullscreenchange", 4904 "MSFullscreenChange" 4905 ]; 4906 function useFullscreen(target, options = {}) { 4907 const { document: document2 = defaultDocument, autoExit = false } = options; 4908 const targetRef = computed(() => { 4909 var _unrefElement; 4910 return (_unrefElement = unrefElement(target)) !== null && _unrefElement !== void 0 ? _unrefElement : document2 === null || document2 === void 0 ? void 0 : document2.documentElement; 4911 }); 4912 const isFullscreen = shallowRef(false); 4913 const requestMethod = computed(() => { 4914 return [ 4915 "requestFullscreen", 4916 "webkitRequestFullscreen", 4917 "webkitEnterFullscreen", 4918 "webkitEnterFullScreen", 4919 "webkitRequestFullScreen", 4920 "mozRequestFullScreen", 4921 "msRequestFullscreen" 4922 ].find((m) => document2 && m in document2 || targetRef.value && m in targetRef.value); 4923 }); 4924 const exitMethod = computed(() => { 4925 return [ 4926 "exitFullscreen", 4927 "webkitExitFullscreen", 4928 "webkitExitFullScreen", 4929 "webkitCancelFullScreen", 4930 "mozCancelFullScreen", 4931 "msExitFullscreen" 4932 ].find((m) => document2 && m in document2 || targetRef.value && m in targetRef.value); 4933 }); 4934 const fullscreenEnabled = computed(() => { 4935 return [ 4936 "fullScreen", 4937 "webkitIsFullScreen", 4938 "webkitDisplayingFullscreen", 4939 "mozFullScreen", 4940 "msFullscreenElement" 4941 ].find((m) => document2 && m in document2 || targetRef.value && m in targetRef.value); 4942 }); 4943 const fullscreenElementMethod = [ 4944 "fullscreenElement", 4945 "webkitFullscreenElement", 4946 "mozFullScreenElement", 4947 "msFullscreenElement" 4948 ].find((m) => document2 && m in document2); 4949 const isSupported = useSupported(() => targetRef.value && document2 && requestMethod.value !== void 0 && exitMethod.value !== void 0 && fullscreenEnabled.value !== void 0); 4950 const isCurrentElementFullScreen = () => { 4951 if (fullscreenElementMethod) return (document2 === null || document2 === void 0 ? void 0 : document2[fullscreenElementMethod]) === targetRef.value; 4952 return false; 4953 }; 4954 const isElementFullScreen = () => { 4955 if (fullscreenEnabled.value) if (document2 && document2[fullscreenEnabled.value] != null) return document2[fullscreenEnabled.value]; 4956 else { 4957 const target2 = targetRef.value; 4958 if ((target2 === null || target2 === void 0 ? void 0 : target2[fullscreenEnabled.value]) != null) return Boolean(target2[fullscreenEnabled.value]); 4959 } 4960 return false; 4961 }; 4962 async function exit() { 4963 if (!isSupported.value || !isFullscreen.value) return; 4964 if (exitMethod.value) if ((document2 === null || document2 === void 0 ? void 0 : document2[exitMethod.value]) != null) await document2[exitMethod.value](); 4965 else { 4966 const target2 = targetRef.value; 4967 if ((target2 === null || target2 === void 0 ? void 0 : target2[exitMethod.value]) != null) await target2[exitMethod.value](); 4968 } 4969 isFullscreen.value = false; 4970 } 4971 async function enter() { 4972 if (!isSupported.value || isFullscreen.value) return; 4973 if (isElementFullScreen()) await exit(); 4974 const target2 = targetRef.value; 4975 if (requestMethod.value && (target2 === null || target2 === void 0 ? void 0 : target2[requestMethod.value]) != null) { 4976 await target2[requestMethod.value](); 4977 isFullscreen.value = true; 4978 } 4979 } 4980 async function toggle() { 4981 await (isFullscreen.value ? exit() : enter()); 4982 } 4983 const handlerCallback = () => { 4984 const isElementFullScreenValue = isElementFullScreen(); 4985 if (!isElementFullScreenValue || isElementFullScreenValue && isCurrentElementFullScreen()) isFullscreen.value = isElementFullScreenValue; 4986 }; 4987 const listenerOptions = { 4988 capture: false, 4989 passive: true 4990 }; 4991 useEventListener(document2, eventHandlers, handlerCallback, listenerOptions); 4992 useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, listenerOptions); 4993 tryOnMounted(handlerCallback, false); 4994 if (autoExit) tryOnScopeDispose(exit); 4995 return { 4996 isSupported, 4997 isFullscreen, 4998 enter, 4999 exit, 5000 toggle 5001 }; 5002 } 5003 function mapGamepadToXbox360Controller(gamepad) { 5004 return computed(() => { 5005 if (gamepad.value) return { 5006 buttons: { 5007 a: gamepad.value.buttons[0], 5008 b: gamepad.value.buttons[1], 5009 x: gamepad.value.buttons[2], 5010 y: gamepad.value.buttons[3] 5011 }, 5012 bumper: { 5013 left: gamepad.value.buttons[4], 5014 right: gamepad.value.buttons[5] 5015 }, 5016 triggers: { 5017 left: gamepad.value.buttons[6], 5018 right: gamepad.value.buttons[7] 5019 }, 5020 stick: { 5021 left: { 5022 horizontal: gamepad.value.axes[0], 5023 vertical: gamepad.value.axes[1], 5024 button: gamepad.value.buttons[10] 5025 }, 5026 right: { 5027 horizontal: gamepad.value.axes[2], 5028 vertical: gamepad.value.axes[3], 5029 button: gamepad.value.buttons[11] 5030 } 5031 }, 5032 dpad: { 5033 up: gamepad.value.buttons[12], 5034 down: gamepad.value.buttons[13], 5035 left: gamepad.value.buttons[14], 5036 right: gamepad.value.buttons[15] 5037 }, 5038 back: gamepad.value.buttons[8], 5039 start: gamepad.value.buttons[9] 5040 }; 5041 return null; 5042 }); 5043 } 5044 function useGamepad(options = {}) { 5045 const { navigator: navigator2 = defaultNavigator } = options; 5046 const isSupported = useSupported(() => navigator2 && "getGamepads" in navigator2); 5047 const gamepads = ref([]); 5048 const onConnectedHook = createEventHook(); 5049 const onDisconnectedHook = createEventHook(); 5050 const stateFromGamepad = (gamepad) => { 5051 const hapticActuators = []; 5052 const vibrationActuator = "vibrationActuator" in gamepad ? gamepad.vibrationActuator : null; 5053 if (vibrationActuator) hapticActuators.push(vibrationActuator); 5054 if (gamepad.hapticActuators) hapticActuators.push(...gamepad.hapticActuators); 5055 return { 5056 id: gamepad.id, 5057 index: gamepad.index, 5058 connected: gamepad.connected, 5059 mapping: gamepad.mapping, 5060 timestamp: gamepad.timestamp, 5061 vibrationActuator: gamepad.vibrationActuator, 5062 hapticActuators, 5063 axes: gamepad.axes.map((axes) => axes), 5064 buttons: gamepad.buttons.map((button) => ({ 5065 pressed: button.pressed, 5066 touched: button.touched, 5067 value: button.value 5068 })) 5069 }; 5070 }; 5071 const updateGamepadState = () => { 5072 const _gamepads = (navigator2 === null || navigator2 === void 0 ? void 0 : navigator2.getGamepads()) || []; 5073 for (const gamepad of _gamepads) if (gamepad && gamepads.value[gamepad.index]) gamepads.value[gamepad.index] = stateFromGamepad(gamepad); 5074 }; 5075 const { isActive, pause, resume } = useRafFn(updateGamepadState); 5076 const onGamepadConnected = (gamepad) => { 5077 if (!gamepads.value.some(({ index }) => index === gamepad.index)) { 5078 gamepads.value.push(stateFromGamepad(gamepad)); 5079 onConnectedHook.trigger(gamepad.index); 5080 } 5081 resume(); 5082 }; 5083 const onGamepadDisconnected = (gamepad) => { 5084 gamepads.value = gamepads.value.filter((x) => x.index !== gamepad.index); 5085 onDisconnectedHook.trigger(gamepad.index); 5086 }; 5087 const listenerOptions = { passive: true }; 5088 useEventListener("gamepadconnected", (e) => onGamepadConnected(e.gamepad), listenerOptions); 5089 useEventListener("gamepaddisconnected", (e) => onGamepadDisconnected(e.gamepad), listenerOptions); 5090 tryOnMounted(() => { 5091 const _gamepads = (navigator2 === null || navigator2 === void 0 ? void 0 : navigator2.getGamepads()) || []; 5092 for (const gamepad of _gamepads) if (gamepad && gamepads.value[gamepad.index]) onGamepadConnected(gamepad); 5093 }); 5094 pause(); 5095 return { 5096 isSupported, 5097 onConnected: onConnectedHook.on, 5098 onDisconnected: onDisconnectedHook.on, 5099 gamepads, 5100 pause, 5101 resume, 5102 isActive 5103 }; 5104 } 5105 function useGeolocation(options = {}) { 5106 const { enableHighAccuracy = true, maximumAge = 3e4, timeout = 27e3, navigator: navigator2 = defaultNavigator, immediate = true } = options; 5107 const isSupported = useSupported(() => navigator2 && "geolocation" in navigator2); 5108 const locatedAt = shallowRef(null); 5109 const error = shallowRef(null); 5110 const coords = shallowRef({ 5111 accuracy: 0, 5112 latitude: Number.POSITIVE_INFINITY, 5113 longitude: Number.POSITIVE_INFINITY, 5114 altitude: null, 5115 altitudeAccuracy: null, 5116 heading: null, 5117 speed: null 5118 }); 5119 function updatePosition(position) { 5120 locatedAt.value = position.timestamp; 5121 coords.value = position.coords; 5122 error.value = null; 5123 } 5124 let watcher; 5125 function resume() { 5126 if (isSupported.value) watcher = navigator2.geolocation.watchPosition(updatePosition, (err) => error.value = err, { 5127 enableHighAccuracy, 5128 maximumAge, 5129 timeout 5130 }); 5131 } 5132 if (immediate) resume(); 5133 function pause() { 5134 if (watcher && navigator2) navigator2.geolocation.clearWatch(watcher); 5135 } 5136 tryOnScopeDispose(() => { 5137 pause(); 5138 }); 5139 return { 5140 isSupported, 5141 coords, 5142 locatedAt, 5143 error, 5144 resume, 5145 pause 5146 }; 5147 } 5148 var defaultEvents$1 = [ 5149 "mousemove", 5150 "mousedown", 5151 "resize", 5152 "keydown", 5153 "touchstart", 5154 "wheel" 5155 ]; 5156 var oneMinute = 6e4; 5157 function useIdle(timeout = oneMinute, options = {}) { 5158 const { initialState = false, listenForVisibilityChange = true, events: events2 = defaultEvents$1, window: window2 = defaultWindow, eventFilter = throttleFilter(50) } = options; 5159 const idle = shallowRef(initialState); 5160 const lastActive = shallowRef(timestamp()); 5161 const isPending = shallowRef(false); 5162 let timer; 5163 const reset = () => { 5164 idle.value = false; 5165 clearTimeout(timer); 5166 timer = setTimeout(() => idle.value = true, timeout); 5167 }; 5168 const onEvent = createFilterWrapper(eventFilter, () => { 5169 lastActive.value = timestamp(); 5170 reset(); 5171 }); 5172 if (window2) { 5173 const document2 = window2.document; 5174 const listenerOptions = { passive: true }; 5175 for (const event of events2) useEventListener(window2, event, () => { 5176 if (!isPending.value) return; 5177 onEvent(); 5178 }, listenerOptions); 5179 if (listenForVisibilityChange) useEventListener(document2, "visibilitychange", () => { 5180 if (document2.hidden || !isPending.value) return; 5181 onEvent(); 5182 }, listenerOptions); 5183 start(); 5184 } 5185 function start() { 5186 if (isPending.value) return; 5187 isPending.value = true; 5188 if (!initialState) reset(); 5189 } 5190 function stop() { 5191 idle.value = initialState; 5192 clearTimeout(timer); 5193 isPending.value = false; 5194 } 5195 return { 5196 idle, 5197 lastActive, 5198 reset, 5199 stop, 5200 start, 5201 isPending: shallowReadonly(isPending) 5202 }; 5203 } 5204 async function loadImage(options) { 5205 return new Promise((resolve, reject) => { 5206 const img = new Image(); 5207 const { src, srcset, sizes, class: clazz, loading, crossorigin, referrerPolicy, width, height, decoding, fetchPriority, ismap, usemap } = options; 5208 img.src = src; 5209 if (srcset != null) img.srcset = srcset; 5210 if (sizes != null) img.sizes = sizes; 5211 if (clazz != null) img.className = clazz; 5212 if (loading != null) img.loading = loading; 5213 if (crossorigin != null) img.crossOrigin = crossorigin; 5214 if (referrerPolicy != null) img.referrerPolicy = referrerPolicy; 5215 if (width != null) img.width = width; 5216 if (height != null) img.height = height; 5217 if (decoding != null) img.decoding = decoding; 5218 if (fetchPriority != null) img.fetchPriority = fetchPriority; 5219 if (ismap != null) img.isMap = ismap; 5220 if (usemap != null) img.useMap = usemap; 5221 img.onload = () => resolve(img); 5222 img.onerror = reject; 5223 }); 5224 } 5225 function useImage(options, asyncStateOptions = {}) { 5226 const state = useAsyncState(() => loadImage(toValue(options)), void 0, { 5227 resetOnExecute: true, 5228 ...asyncStateOptions 5229 }); 5230 watch(() => toValue(options), () => state.execute(asyncStateOptions.delay), { deep: true }); 5231 return state; 5232 } 5233 function resolveElement(el) { 5234 if (typeof Window !== "undefined" && el instanceof Window) return el.document.documentElement; 5235 if (typeof Document !== "undefined" && el instanceof Document) return el.documentElement; 5236 return el; 5237 } 5238 var ARRIVED_STATE_THRESHOLD_PIXELS = 1; 5239 function useScroll(element, options = {}) { 5240 const { throttle = 0, idle = 200, onStop = noop, onScroll = noop, offset = { 5241 left: 0, 5242 right: 0, 5243 top: 0, 5244 bottom: 0 5245 }, observe: _observe = { mutation: false }, eventListenerOptions = { 5246 capture: false, 5247 passive: true 5248 }, behavior = "auto", window: window2 = defaultWindow, onError = (e) => { 5249 console.error(e); 5250 } } = options; 5251 const observe = typeof _observe === "boolean" ? { mutation: _observe } : _observe; 5252 const internalX = shallowRef(0); 5253 const internalY = shallowRef(0); 5254 const x = computed({ 5255 get() { 5256 return internalX.value; 5257 }, 5258 set(x2) { 5259 scrollTo(x2, void 0); 5260 } 5261 }); 5262 const y = computed({ 5263 get() { 5264 return internalY.value; 5265 }, 5266 set(y2) { 5267 scrollTo(void 0, y2); 5268 } 5269 }); 5270 function scrollTo(_x, _y) { 5271 var _ref, _toValue, _toValue2, _document; 5272 if (!window2) return; 5273 const _element = toValue(element); 5274 if (!_element) return; 5275 (_ref = _element instanceof Document ? window2.document.body : _element) === null || _ref === void 0 || _ref.scrollTo({ 5276 top: (_toValue = toValue(_y)) !== null && _toValue !== void 0 ? _toValue : y.value, 5277 left: (_toValue2 = toValue(_x)) !== null && _toValue2 !== void 0 ? _toValue2 : x.value, 5278 behavior: toValue(behavior) 5279 }); 5280 const scrollContainer = (_element === null || _element === void 0 || (_document = _element.document) === null || _document === void 0 ? void 0 : _document.documentElement) || (_element === null || _element === void 0 ? void 0 : _element.documentElement) || _element; 5281 if (x != null) internalX.value = scrollContainer.scrollLeft; 5282 if (y != null) internalY.value = scrollContainer.scrollTop; 5283 } 5284 const isScrolling = shallowRef(false); 5285 const arrivedState = reactive({ 5286 left: true, 5287 right: false, 5288 top: true, 5289 bottom: false 5290 }); 5291 const directions = reactive({ 5292 left: false, 5293 right: false, 5294 top: false, 5295 bottom: false 5296 }); 5297 const onScrollEnd = (e) => { 5298 if (!isScrolling.value) return; 5299 isScrolling.value = false; 5300 directions.left = false; 5301 directions.right = false; 5302 directions.top = false; 5303 directions.bottom = false; 5304 onStop(e); 5305 }; 5306 const onScrollEndDebounced = useDebounceFn(onScrollEnd, throttle + idle); 5307 const setArrivedState = (target) => { 5308 var _document2; 5309 if (!window2) return; 5310 const el = (target === null || target === void 0 || (_document2 = target.document) === null || _document2 === void 0 ? void 0 : _document2.documentElement) || (target === null || target === void 0 ? void 0 : target.documentElement) || unrefElement(target); 5311 const { display, flexDirection, direction } = window2.getComputedStyle(el); 5312 const directionMultipler = direction === "rtl" ? -1 : 1; 5313 const scrollLeft = el.scrollLeft; 5314 directions.left = scrollLeft < internalX.value; 5315 directions.right = scrollLeft > internalX.value; 5316 const left = Math.abs(scrollLeft * directionMultipler) <= (offset.left || 0); 5317 const right = Math.abs(scrollLeft * directionMultipler) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS; 5318 if (display === "flex" && flexDirection === "row-reverse") { 5319 arrivedState.left = right; 5320 arrivedState.right = left; 5321 } else { 5322 arrivedState.left = left; 5323 arrivedState.right = right; 5324 } 5325 internalX.value = scrollLeft; 5326 let scrollTop = el.scrollTop; 5327 if (target === window2.document && !scrollTop) scrollTop = window2.document.body.scrollTop; 5328 directions.top = scrollTop < internalY.value; 5329 directions.bottom = scrollTop > internalY.value; 5330 const top = Math.abs(scrollTop) <= (offset.top || 0); 5331 const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS; 5332 if (display === "flex" && flexDirection === "column-reverse") { 5333 arrivedState.top = bottom; 5334 arrivedState.bottom = top; 5335 } else { 5336 arrivedState.top = top; 5337 arrivedState.bottom = bottom; 5338 } 5339 internalY.value = scrollTop; 5340 }; 5341 const onScrollHandler = (e) => { 5342 var _documentElement; 5343 if (!window2) return; 5344 setArrivedState((_documentElement = e.target.documentElement) !== null && _documentElement !== void 0 ? _documentElement : e.target); 5345 isScrolling.value = true; 5346 onScrollEndDebounced(e); 5347 onScroll(e); 5348 }; 5349 useEventListener(element, "scroll", throttle ? useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler, eventListenerOptions); 5350 tryOnMounted(() => { 5351 try { 5352 const _element = toValue(element); 5353 if (!_element) return; 5354 setArrivedState(_element); 5355 } catch (e) { 5356 onError(e); 5357 } 5358 }); 5359 if ((observe === null || observe === void 0 ? void 0 : observe.mutation) && element != null && element !== window2 && element !== document) useMutationObserver(element, () => { 5360 const _element = toValue(element); 5361 if (!_element) return; 5362 setArrivedState(_element); 5363 }, { 5364 attributes: true, 5365 childList: true, 5366 subtree: true 5367 }); 5368 useEventListener(element, "scrollend", onScrollEnd, eventListenerOptions); 5369 return { 5370 x, 5371 y, 5372 isScrolling, 5373 arrivedState, 5374 directions, 5375 measure() { 5376 const _element = toValue(element); 5377 if (window2 && _element) setArrivedState(_element); 5378 } 5379 }; 5380 } 5381 function useInfiniteScroll(element, onLoadMore, options = {}) { 5382 var _options$distance; 5383 const { direction = "bottom", interval = 100, canLoadMore = () => true } = options; 5384 const state = reactive(useScroll(element, { 5385 ...options, 5386 offset: { 5387 [direction]: (_options$distance = options.distance) !== null && _options$distance !== void 0 ? _options$distance : 0, 5388 ...options.offset 5389 } 5390 })); 5391 const promise = shallowRef(); 5392 const isLoading = computed(() => !!promise.value); 5393 const observedElement = computed(() => { 5394 return resolveElement(toValue(element)); 5395 }); 5396 const isElementVisible = useElementVisibility(observedElement); 5397 const canLoad = computed(() => { 5398 if (!observedElement.value) return false; 5399 return canLoadMore(observedElement.value); 5400 }); 5401 function checkAndLoad() { 5402 state.measure(); 5403 if (!observedElement.value || !isElementVisible.value || !canLoad.value || promise.value) return; 5404 const { scrollHeight, clientHeight, scrollWidth, clientWidth } = observedElement.value; 5405 const isNarrower = direction === "bottom" || direction === "top" ? scrollHeight <= clientHeight : scrollWidth <= clientWidth; 5406 if (state.arrivedState[direction] || isNarrower) promise.value = Promise.all([onLoadMore(state), new Promise((resolve) => setTimeout(resolve, interval))]).finally(() => { 5407 promise.value = null; 5408 nextTick(() => checkAndLoad()); 5409 }); 5410 } 5411 tryOnUnmounted(watch(() => [ 5412 state.arrivedState[direction], 5413 isElementVisible.value, 5414 canLoad.value 5415 ], checkAndLoad, { 5416 immediate: true, 5417 flush: "post" 5418 })); 5419 return { 5420 isLoading, 5421 reset() { 5422 nextTick(() => checkAndLoad()); 5423 } 5424 }; 5425 } 5426 var defaultEvents = [ 5427 "mousedown", 5428 "mouseup", 5429 "keydown", 5430 "keyup" 5431 ]; 5432 function useKeyModifier(modifier, options = {}) { 5433 const { events: events2 = defaultEvents, document: document2 = defaultDocument, initial = null } = options; 5434 const state = shallowRef(initial); 5435 if (document2) events2.forEach((listenerEvent) => { 5436 useEventListener(document2, listenerEvent, (evt) => { 5437 if (typeof evt.getModifierState === "function") state.value = evt.getModifierState(modifier); 5438 }, { passive: true }); 5439 }); 5440 return state; 5441 } 5442 function useLocalStorage(key, initialValue, options = {}) { 5443 const { window: window2 = defaultWindow } = options; 5444 return useStorage(key, initialValue, window2 === null || window2 === void 0 ? void 0 : window2.localStorage, options); 5445 } 5446 var DefaultMagicKeysAliasMap = { 5447 ctrl: "control", 5448 command: "meta", 5449 cmd: "meta", 5450 option: "alt", 5451 up: "arrowup", 5452 down: "arrowdown", 5453 left: "arrowleft", 5454 right: "arrowright" 5455 }; 5456 function useMagicKeys(options = {}) { 5457 const { reactive: useReactive = false, target = defaultWindow, aliasMap = DefaultMagicKeysAliasMap, passive = true, onEventFired = noop } = options; 5458 const current = reactive(/* @__PURE__ */ new Set()); 5459 const obj = { 5460 toJSON() { 5461 return {}; 5462 }, 5463 current 5464 }; 5465 const refs = useReactive ? reactive(obj) : obj; 5466 const metaDeps = /* @__PURE__ */ new Set(); 5467 const depsMap = /* @__PURE__ */ new Map([ 5468 ["Meta", metaDeps], 5469 ["Shift", /* @__PURE__ */ new Set()], 5470 ["Alt", /* @__PURE__ */ new Set()] 5471 ]); 5472 const usedKeys = /* @__PURE__ */ new Set(); 5473 function setRefs(key, value) { 5474 if (key in refs) if (useReactive) refs[key] = value; 5475 else refs[key].value = value; 5476 } 5477 function reset() { 5478 current.clear(); 5479 for (const key of usedKeys) setRefs(key, false); 5480 } 5481 function updateDeps(value, e, keys2) { 5482 if (!value || typeof e.getModifierState !== "function") return; 5483 for (const [modifier, depsSet] of depsMap) if (e.getModifierState(modifier)) { 5484 keys2.forEach((key) => depsSet.add(key)); 5485 break; 5486 } 5487 } 5488 function clearDeps(value, key) { 5489 if (value) return; 5490 const depsMapKey = `${key[0].toUpperCase()}${key.slice(1)}`; 5491 const deps = depsMap.get(depsMapKey); 5492 if (!["shift", "alt"].includes(key) || !deps) return; 5493 const depsArray = Array.from(deps); 5494 const depsIndex = depsArray.indexOf(key); 5495 depsArray.forEach((key2, index) => { 5496 if (index >= depsIndex) { 5497 current.delete(key2); 5498 setRefs(key2, false); 5499 } 5500 }); 5501 deps.clear(); 5502 } 5503 function updateRefs(e, value) { 5504 var _e$key, _e$code; 5505 const key = (_e$key = e.key) === null || _e$key === void 0 ? void 0 : _e$key.toLowerCase(); 5506 const values = [(_e$code = e.code) === null || _e$code === void 0 ? void 0 : _e$code.toLowerCase(), key].filter(Boolean); 5507 if (!key) return; 5508 if (key) if (value) current.add(key); 5509 else current.delete(key); 5510 for (const key2 of values) { 5511 usedKeys.add(key2); 5512 setRefs(key2, value); 5513 } 5514 updateDeps(value, e, [...current, ...values]); 5515 clearDeps(value, key); 5516 if (key === "meta" && !value) { 5517 metaDeps.forEach((key2) => { 5518 current.delete(key2); 5519 setRefs(key2, false); 5520 }); 5521 metaDeps.clear(); 5522 } 5523 } 5524 useEventListener(target, "keydown", (e) => { 5525 updateRefs(e, true); 5526 return onEventFired(e); 5527 }, { passive }); 5528 useEventListener(target, "keyup", (e) => { 5529 updateRefs(e, false); 5530 return onEventFired(e); 5531 }, { passive }); 5532 useEventListener("blur", reset, { passive }); 5533 useEventListener("focus", reset, { passive }); 5534 const proxy = new Proxy(refs, { get(target2, prop, rec) { 5535 if (typeof prop !== "string") return Reflect.get(target2, prop, rec); 5536 prop = prop.toLowerCase(); 5537 if (prop in aliasMap) prop = aliasMap[prop]; 5538 if (!(prop in refs)) if (/[+_-]/.test(prop)) { 5539 const keys2 = prop.split(/[+_-]/g).map((i) => i.trim()); 5540 refs[prop] = computed(() => keys2.map((key) => toValue(proxy[key])).every(Boolean)); 5541 } else refs[prop] = shallowRef(false); 5542 const r = Reflect.get(target2, prop, rec); 5543 return useReactive ? toValue(r) : r; 5544 } }); 5545 return proxy; 5546 } 5547 function usingElRef(source, cb) { 5548 if (toValue(source)) cb(toValue(source)); 5549 } 5550 function timeRangeToArray(timeRanges) { 5551 let ranges = []; 5552 for (let i = 0; i < timeRanges.length; ++i) ranges = [...ranges, [timeRanges.start(i), timeRanges.end(i)]]; 5553 return ranges; 5554 } 5555 function tracksToArray(tracks) { 5556 return Array.from(tracks).map(({ label, kind, language, mode, activeCues, cues, inBandMetadataTrackDispatchType }, id) => ({ 5557 id, 5558 label, 5559 kind, 5560 language, 5561 mode, 5562 activeCues, 5563 cues, 5564 inBandMetadataTrackDispatchType 5565 })); 5566 } 5567 var defaultOptions = { 5568 src: "", 5569 tracks: [] 5570 }; 5571 function useMediaControls(target, options = {}) { 5572 target = toRef2(target); 5573 options = { 5574 ...defaultOptions, 5575 ...options 5576 }; 5577 const { document: document2 = defaultDocument } = options; 5578 const listenerOptions = { passive: true }; 5579 const currentTime = shallowRef(0); 5580 const duration = shallowRef(0); 5581 const seeking = shallowRef(false); 5582 const volume = shallowRef(1); 5583 const waiting = shallowRef(false); 5584 const ended = shallowRef(false); 5585 const playing = shallowRef(false); 5586 const rate = shallowRef(1); 5587 const stalled = shallowRef(false); 5588 const buffered = shallowRef([]); 5589 const tracks = shallowRef([]); 5590 const selectedTrack = shallowRef(-1); 5591 const isPictureInPicture = shallowRef(false); 5592 const muted = shallowRef(false); 5593 const supportsPictureInPicture = Boolean(document2 && "pictureInPictureEnabled" in document2); 5594 const sourceErrorEvent = createEventHook(); 5595 const playbackErrorEvent = createEventHook(); 5596 const disableTrack = (track) => { 5597 usingElRef(target, (el) => { 5598 if (track) { 5599 const id = typeof track === "number" ? track : track.id; 5600 el.textTracks[id].mode = "disabled"; 5601 } else for (let i = 0; i < el.textTracks.length; ++i) el.textTracks[i].mode = "disabled"; 5602 selectedTrack.value = -1; 5603 }); 5604 }; 5605 const enableTrack = (track, disableTracks = true) => { 5606 usingElRef(target, (el) => { 5607 const id = typeof track === "number" ? track : track.id; 5608 if (disableTracks) disableTrack(); 5609 el.textTracks[id].mode = "showing"; 5610 selectedTrack.value = id; 5611 }); 5612 }; 5613 const togglePictureInPicture = () => { 5614 return new Promise((resolve, reject) => { 5615 usingElRef(target, async (el) => { 5616 if (supportsPictureInPicture) if (!isPictureInPicture.value) el.requestPictureInPicture().then(resolve).catch(reject); 5617 else document2.exitPictureInPicture().then(resolve).catch(reject); 5618 }); 5619 }); 5620 }; 5621 watchEffect(() => { 5622 if (!document2) return; 5623 const el = toValue(target); 5624 if (!el) return; 5625 const src = toValue(options.src); 5626 let sources = []; 5627 if (!src) return; 5628 if (typeof src === "string") sources = [{ src }]; 5629 else if (Array.isArray(src)) sources = src; 5630 else if (isObject(src)) sources = [src]; 5631 el.querySelectorAll("source").forEach((e) => { 5632 e.remove(); 5633 }); 5634 sources.forEach(({ src: src2, type, media }) => { 5635 const source = document2.createElement("source"); 5636 source.setAttribute("src", src2); 5637 source.setAttribute("type", type || ""); 5638 source.setAttribute("media", media || ""); 5639 useEventListener(source, "error", sourceErrorEvent.trigger, listenerOptions); 5640 el.appendChild(source); 5641 }); 5642 el.load(); 5643 }); 5644 watch([target, volume], () => { 5645 const el = toValue(target); 5646 if (!el) return; 5647 el.volume = volume.value; 5648 }); 5649 watch([target, muted], () => { 5650 const el = toValue(target); 5651 if (!el) return; 5652 el.muted = muted.value; 5653 }); 5654 watch([target, rate], () => { 5655 const el = toValue(target); 5656 if (!el) return; 5657 el.playbackRate = rate.value; 5658 }); 5659 watchEffect(() => { 5660 if (!document2) return; 5661 const textTracks = toValue(options.tracks); 5662 const el = toValue(target); 5663 if (!textTracks || !textTracks.length || !el) return; 5664 el.querySelectorAll("track").forEach((e) => e.remove()); 5665 textTracks.forEach(({ default: isDefault, kind, label, src, srcLang }, i) => { 5666 const track = document2.createElement("track"); 5667 track.default = isDefault || false; 5668 track.kind = kind; 5669 track.label = label; 5670 track.src = src; 5671 track.srclang = srcLang; 5672 if (track.default) selectedTrack.value = i; 5673 el.appendChild(track); 5674 }); 5675 }); 5676 const { ignoreUpdates: ignoreCurrentTimeUpdates } = watchIgnorable(currentTime, (time) => { 5677 const el = toValue(target); 5678 if (!el) return; 5679 el.currentTime = time; 5680 }); 5681 const { ignoreUpdates: ignorePlayingUpdates } = watchIgnorable(playing, (isPlaying) => { 5682 const el = toValue(target); 5683 if (!el) return; 5684 if (isPlaying) el.play().catch((e) => { 5685 playbackErrorEvent.trigger(e); 5686 throw e; 5687 }); 5688 else el.pause(); 5689 }); 5690 useEventListener(target, "timeupdate", () => ignoreCurrentTimeUpdates(() => currentTime.value = toValue(target).currentTime), listenerOptions); 5691 useEventListener(target, "durationchange", () => duration.value = toValue(target).duration, listenerOptions); 5692 useEventListener(target, "progress", () => buffered.value = timeRangeToArray(toValue(target).buffered), listenerOptions); 5693 useEventListener(target, "seeking", () => seeking.value = true, listenerOptions); 5694 useEventListener(target, "seeked", () => seeking.value = false, listenerOptions); 5695 useEventListener(target, ["waiting", "loadstart"], () => { 5696 waiting.value = true; 5697 ignorePlayingUpdates(() => playing.value = false); 5698 }, listenerOptions); 5699 useEventListener(target, "loadeddata", () => waiting.value = false, listenerOptions); 5700 useEventListener(target, "playing", () => { 5701 waiting.value = false; 5702 ended.value = false; 5703 ignorePlayingUpdates(() => playing.value = true); 5704 }, listenerOptions); 5705 useEventListener(target, "ratechange", () => rate.value = toValue(target).playbackRate, listenerOptions); 5706 useEventListener(target, "stalled", () => stalled.value = true, listenerOptions); 5707 useEventListener(target, "ended", () => ended.value = true, listenerOptions); 5708 useEventListener(target, "pause", () => ignorePlayingUpdates(() => playing.value = false), listenerOptions); 5709 useEventListener(target, "play", () => ignorePlayingUpdates(() => playing.value = true), listenerOptions); 5710 useEventListener(target, "enterpictureinpicture", () => isPictureInPicture.value = true, listenerOptions); 5711 useEventListener(target, "leavepictureinpicture", () => isPictureInPicture.value = false, listenerOptions); 5712 useEventListener(target, "volumechange", () => { 5713 const el = toValue(target); 5714 if (!el) return; 5715 volume.value = el.volume; 5716 muted.value = el.muted; 5717 }, listenerOptions); 5718 const listeners = []; 5719 const stop = watch([target], () => { 5720 const el = toValue(target); 5721 if (!el) return; 5722 stop(); 5723 listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions); 5724 listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions); 5725 listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks), listenerOptions); 5726 }); 5727 tryOnScopeDispose(() => listeners.forEach((listener) => listener())); 5728 return { 5729 currentTime, 5730 duration, 5731 waiting, 5732 seeking, 5733 ended, 5734 stalled, 5735 buffered, 5736 playing, 5737 rate, 5738 volume, 5739 muted, 5740 tracks, 5741 selectedTrack, 5742 enableTrack, 5743 disableTrack, 5744 supportsPictureInPicture, 5745 togglePictureInPicture, 5746 isPictureInPicture, 5747 onSourceError: sourceErrorEvent.on, 5748 onPlaybackError: playbackErrorEvent.on 5749 }; 5750 } 5751 function useMemoize(resolver, options) { 5752 const initCache = () => { 5753 if (options === null || options === void 0 ? void 0 : options.cache) return shallowReactive(options.cache); 5754 return shallowReactive(/* @__PURE__ */ new Map()); 5755 }; 5756 const cache = initCache(); 5757 const generateKey = (...args) => (options === null || options === void 0 ? void 0 : options.getKey) ? options.getKey(...args) : JSON.stringify(args); 5758 const _loadData = (key, ...args) => { 5759 cache.set(key, resolver(...args)); 5760 return cache.get(key); 5761 }; 5762 const loadData = (...args) => _loadData(generateKey(...args), ...args); 5763 const deleteData = (...args) => { 5764 cache.delete(generateKey(...args)); 5765 }; 5766 const clearData = () => { 5767 cache.clear(); 5768 }; 5769 const memoized = (...args) => { 5770 const key = generateKey(...args); 5771 if (cache.has(key)) return cache.get(key); 5772 return _loadData(key, ...args); 5773 }; 5774 memoized.load = loadData; 5775 memoized.delete = deleteData; 5776 memoized.clear = clearData; 5777 memoized.generateKey = generateKey; 5778 memoized.cache = cache; 5779 return memoized; 5780 } 5781 function getDefaultScheduler$6(options) { 5782 if ("interval" in options || "immediate" in options || "immediateCallback" in options) { 5783 const { interval = 1e3, immediate, immediateCallback } = options; 5784 return (cb) => useIntervalFn(cb, interval, { 5785 immediate, 5786 immediateCallback 5787 }); 5788 } 5789 return useIntervalFn; 5790 } 5791 function useMemory(options = {}) { 5792 const memory = shallowRef(); 5793 const isSupported = useSupported(() => typeof performance !== "undefined" && "memory" in performance); 5794 if (isSupported.value) { 5795 const { scheduler = getDefaultScheduler$6 } = options; 5796 scheduler(() => { 5797 memory.value = performance.memory; 5798 }); 5799 } 5800 return { 5801 isSupported, 5802 memory 5803 }; 5804 } 5805 var UseMouseBuiltinExtractors = { 5806 page: (event) => [event.pageX, event.pageY], 5807 client: (event) => [event.clientX, event.clientY], 5808 screen: (event) => [event.screenX, event.screenY], 5809 movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null 5810 }; 5811 function useMouse(options = {}) { 5812 const { type = "page", touch = true, resetOnTouchEnds = false, initialValue = { 5813 x: 0, 5814 y: 0 5815 }, window: window2 = defaultWindow, target = window2, scroll = true, eventFilter } = options; 5816 let _prevMouseEvent = null; 5817 let _prevScrollX = 0; 5818 let _prevScrollY = 0; 5819 const x = shallowRef(initialValue.x); 5820 const y = shallowRef(initialValue.y); 5821 const sourceType = shallowRef(null); 5822 const extractor = typeof type === "function" ? type : UseMouseBuiltinExtractors[type]; 5823 const mouseHandler = (event) => { 5824 const result = extractor(event); 5825 _prevMouseEvent = event; 5826 if (result) { 5827 [x.value, y.value] = result; 5828 sourceType.value = "mouse"; 5829 } 5830 if (window2) { 5831 _prevScrollX = window2.scrollX; 5832 _prevScrollY = window2.scrollY; 5833 } 5834 }; 5835 const touchHandler = (event) => { 5836 if (event.touches.length > 0) { 5837 const result = extractor(event.touches[0]); 5838 if (result) { 5839 [x.value, y.value] = result; 5840 sourceType.value = "touch"; 5841 } 5842 } 5843 }; 5844 const scrollHandler = () => { 5845 if (!_prevMouseEvent || !window2) return; 5846 const pos = extractor(_prevMouseEvent); 5847 if (_prevMouseEvent instanceof MouseEvent && pos) { 5848 x.value = pos[0] + window2.scrollX - _prevScrollX; 5849 y.value = pos[1] + window2.scrollY - _prevScrollY; 5850 } 5851 }; 5852 const reset = () => { 5853 x.value = initialValue.x; 5854 y.value = initialValue.y; 5855 }; 5856 const mouseHandlerWrapper = eventFilter ? (event) => eventFilter(() => mouseHandler(event), {}) : (event) => mouseHandler(event); 5857 const touchHandlerWrapper = eventFilter ? (event) => eventFilter(() => touchHandler(event), {}) : (event) => touchHandler(event); 5858 const scrollHandlerWrapper = eventFilter ? () => eventFilter(() => scrollHandler(), {}) : () => scrollHandler(); 5859 if (target) { 5860 const listenerOptions = { passive: true }; 5861 useEventListener(target, ["mousemove", "dragover"], mouseHandlerWrapper, listenerOptions); 5862 if (touch && type !== "movement") { 5863 useEventListener(target, ["touchstart", "touchmove"], touchHandlerWrapper, listenerOptions); 5864 if (resetOnTouchEnds) useEventListener(target, "touchend", reset, listenerOptions); 5865 } 5866 if (scroll && type === "page") useEventListener(window2, "scroll", scrollHandlerWrapper, listenerOptions); 5867 } 5868 return { 5869 x, 5870 y, 5871 sourceType 5872 }; 5873 } 5874 function useMouseInElement(target, options = {}) { 5875 const { windowResize = true, windowScroll = true, handleOutside = true, window: window2 = defaultWindow } = options; 5876 const type = options.type || "page"; 5877 const { x, y, sourceType } = useMouse(options); 5878 const targetRef = shallowRef(target !== null && target !== void 0 ? target : window2 === null || window2 === void 0 ? void 0 : window2.document.body); 5879 const elementX = shallowRef(0); 5880 const elementY = shallowRef(0); 5881 const elementPositionX = shallowRef(0); 5882 const elementPositionY = shallowRef(0); 5883 const elementHeight = shallowRef(0); 5884 const elementWidth = shallowRef(0); 5885 const isOutside = shallowRef(true); 5886 function update() { 5887 if (!window2) return; 5888 const el = unrefElement(targetRef); 5889 if (!el || !(el instanceof Element)) return; 5890 for (const rect of el.getClientRects()) { 5891 const { left, top, width, height } = rect; 5892 elementPositionX.value = left + (type === "page" ? window2.pageXOffset : 0); 5893 elementPositionY.value = top + (type === "page" ? window2.pageYOffset : 0); 5894 elementHeight.value = height; 5895 elementWidth.value = width; 5896 const elX = x.value - elementPositionX.value; 5897 const elY = y.value - elementPositionY.value; 5898 isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height; 5899 if (handleOutside || !isOutside.value) { 5900 elementX.value = elX; 5901 elementY.value = elY; 5902 } 5903 if (!isOutside.value) break; 5904 } 5905 } 5906 const stopFnList = []; 5907 function stop() { 5908 stopFnList.forEach((fn) => fn()); 5909 stopFnList.length = 0; 5910 } 5911 tryOnMounted(() => { 5912 update(); 5913 }); 5914 if (window2) { 5915 const { stop: stopResizeObserver } = useResizeObserver(targetRef, update); 5916 const { stop: stopMutationObserver } = useMutationObserver(targetRef, update, { attributeFilter: ["style", "class"] }); 5917 const stopWatch = watch([ 5918 targetRef, 5919 x, 5920 y 5921 ], update); 5922 stopFnList.push(stopResizeObserver, stopMutationObserver, stopWatch); 5923 useEventListener(document, "mouseleave", () => isOutside.value = true, { passive: true }); 5924 if (windowScroll) stopFnList.push(useEventListener("scroll", update, { 5925 capture: true, 5926 passive: true 5927 })); 5928 if (windowResize) stopFnList.push(useEventListener("resize", update, { passive: true })); 5929 } 5930 return { 5931 x, 5932 y, 5933 sourceType, 5934 elementX, 5935 elementY, 5936 elementPositionX, 5937 elementPositionY, 5938 elementHeight, 5939 elementWidth, 5940 isOutside, 5941 stop 5942 }; 5943 } 5944 function useMousePressed(options = {}) { 5945 const { touch = true, drag = true, capture = false, initialValue = false, window: window2 = defaultWindow } = options; 5946 const pressed = shallowRef(initialValue); 5947 const sourceType = shallowRef(null); 5948 if (!window2) return { 5949 pressed, 5950 sourceType 5951 }; 5952 const onPressed = (srcType) => (event) => { 5953 var _options$onPressed; 5954 pressed.value = true; 5955 sourceType.value = srcType; 5956 (_options$onPressed = options.onPressed) === null || _options$onPressed === void 0 || _options$onPressed.call(options, event); 5957 }; 5958 const onReleased = (event) => { 5959 var _options$onReleased; 5960 pressed.value = false; 5961 sourceType.value = null; 5962 (_options$onReleased = options.onReleased) === null || _options$onReleased === void 0 || _options$onReleased.call(options, event); 5963 }; 5964 const target = computed(() => unrefElement(options.target) || window2); 5965 const listenerOptions = { 5966 passive: true, 5967 capture 5968 }; 5969 useEventListener(target, "mousedown", onPressed("mouse"), listenerOptions); 5970 useEventListener(window2, "mouseleave", onReleased, listenerOptions); 5971 useEventListener(window2, "mouseup", onReleased, listenerOptions); 5972 if (drag) { 5973 useEventListener(target, "dragstart", onPressed("mouse"), listenerOptions); 5974 useEventListener(window2, "drop", onReleased, listenerOptions); 5975 useEventListener(window2, "dragend", onReleased, listenerOptions); 5976 } 5977 if (touch) { 5978 useEventListener(target, "touchstart", onPressed("touch"), listenerOptions); 5979 useEventListener(window2, "touchend", onReleased, listenerOptions); 5980 useEventListener(window2, "touchcancel", onReleased, listenerOptions); 5981 } 5982 return { 5983 pressed, 5984 sourceType 5985 }; 5986 } 5987 function useNavigatorLanguage(options = {}) { 5988 const { window: window2 = defaultWindow } = options; 5989 const navigator2 = window2 === null || window2 === void 0 ? void 0 : window2.navigator; 5990 const isSupported = useSupported(() => navigator2 && "language" in navigator2); 5991 const language = shallowRef(navigator2 === null || navigator2 === void 0 ? void 0 : navigator2.language); 5992 useEventListener(window2, "languagechange", () => { 5993 if (navigator2) language.value = navigator2.language; 5994 }, { passive: true }); 5995 return { 5996 isSupported, 5997 language 5998 }; 5999 } 6000 function useNetwork(options = {}) { 6001 const { window: window2 = defaultWindow } = options; 6002 const navigator2 = window2 === null || window2 === void 0 ? void 0 : window2.navigator; 6003 const isSupported = useSupported(() => navigator2 && "connection" in navigator2); 6004 const isOnline = shallowRef(true); 6005 const saveData = shallowRef(false); 6006 const offlineAt = shallowRef(void 0); 6007 const onlineAt = shallowRef(void 0); 6008 const downlink = shallowRef(void 0); 6009 const downlinkMax = shallowRef(void 0); 6010 const rtt = shallowRef(void 0); 6011 const effectiveType = shallowRef(void 0); 6012 const type = shallowRef("unknown"); 6013 const connection = isSupported.value && navigator2.connection; 6014 function updateNetworkInformation() { 6015 if (!navigator2) return; 6016 isOnline.value = navigator2.onLine; 6017 offlineAt.value = isOnline.value ? void 0 : Date.now(); 6018 onlineAt.value = isOnline.value ? Date.now() : void 0; 6019 if (connection) { 6020 downlink.value = connection.downlink; 6021 downlinkMax.value = connection.downlinkMax; 6022 effectiveType.value = connection.effectiveType; 6023 rtt.value = connection.rtt; 6024 saveData.value = connection.saveData; 6025 type.value = connection.type; 6026 } 6027 } 6028 const listenerOptions = { passive: true }; 6029 if (window2) { 6030 useEventListener(window2, "offline", () => { 6031 isOnline.value = false; 6032 offlineAt.value = Date.now(); 6033 }, listenerOptions); 6034 useEventListener(window2, "online", () => { 6035 isOnline.value = true; 6036 onlineAt.value = Date.now(); 6037 }, listenerOptions); 6038 } 6039 if (connection) useEventListener(connection, "change", updateNetworkInformation, listenerOptions); 6040 updateNetworkInformation(); 6041 return { 6042 isSupported, 6043 isOnline: shallowReadonly(isOnline), 6044 saveData: shallowReadonly(saveData), 6045 offlineAt: shallowReadonly(offlineAt), 6046 onlineAt: shallowReadonly(onlineAt), 6047 downlink: shallowReadonly(downlink), 6048 downlinkMax: shallowReadonly(downlinkMax), 6049 effectiveType: shallowReadonly(effectiveType), 6050 rtt: shallowReadonly(rtt), 6051 type: shallowReadonly(type) 6052 }; 6053 } 6054 function getDefaultScheduler$5(options) { 6055 if ("interval" in options || "immediate" in options) { 6056 const { interval = "requestAnimationFrame", immediate = true } = options; 6057 return interval === "requestAnimationFrame" ? (fn) => useRafFn(fn, { immediate }) : (fn) => useIntervalFn(fn, interval, options); 6058 } 6059 return useRafFn; 6060 } 6061 function useNow(options = {}) { 6062 const { controls: exposeControls = false, scheduler = getDefaultScheduler$5(options) } = options; 6063 const now2 = shallowRef(/* @__PURE__ */ new Date()); 6064 const update = () => now2.value = /* @__PURE__ */ new Date(); 6065 const controls = scheduler(update); 6066 if (exposeControls) return { 6067 now: now2, 6068 ...controls 6069 }; 6070 else return now2; 6071 } 6072 function useObjectUrl(object) { 6073 const url = shallowRef(); 6074 const release = () => { 6075 if (url.value) URL.revokeObjectURL(url.value); 6076 url.value = void 0; 6077 }; 6078 watch(() => toValue(object), (newObject) => { 6079 release(); 6080 if (newObject) url.value = URL.createObjectURL(newObject); 6081 }, { immediate: true }); 6082 tryOnScopeDispose(release); 6083 return shallowReadonly(url); 6084 } 6085 function useClamp(value, min, max) { 6086 if (typeof value === "function" || isReadonly(value)) return computed(() => clamp(toValue(value), toValue(min), toValue(max))); 6087 const _value = ref(value); 6088 return computed({ 6089 get() { 6090 return _value.value = clamp(_value.value, toValue(min), toValue(max)); 6091 }, 6092 set(value2) { 6093 _value.value = clamp(value2, toValue(min), toValue(max)); 6094 } 6095 }); 6096 } 6097 function useOffsetPagination(options) { 6098 const { total = Number.POSITIVE_INFINITY, pageSize = 10, page = 1, onPageChange = noop, onPageSizeChange = noop, onPageCountChange = noop } = options; 6099 const currentPageSize = useClamp(pageSize, 1, Number.POSITIVE_INFINITY); 6100 const pageCount = computed(() => Math.max(1, Math.ceil(toValue(total) / toValue(currentPageSize)))); 6101 const currentPage = useClamp(page, 1, pageCount); 6102 const isFirstPage = computed(() => currentPage.value === 1); 6103 const isLastPage = computed(() => currentPage.value === pageCount.value); 6104 if (isRef(page)) syncRef(page, currentPage, { direction: isReadonly(page) ? "ltr" : "both" }); 6105 if (isRef(pageSize)) syncRef(pageSize, currentPageSize, { direction: isReadonly(pageSize) ? "ltr" : "both" }); 6106 function prev() { 6107 currentPage.value--; 6108 } 6109 function next() { 6110 currentPage.value++; 6111 } 6112 const returnValue = { 6113 currentPage, 6114 currentPageSize, 6115 pageCount, 6116 isFirstPage, 6117 isLastPage, 6118 prev, 6119 next 6120 }; 6121 watch(currentPage, () => { 6122 onPageChange(reactive(returnValue)); 6123 }); 6124 watch(currentPageSize, () => { 6125 onPageSizeChange(reactive(returnValue)); 6126 }); 6127 watch(pageCount, () => { 6128 onPageCountChange(reactive(returnValue)); 6129 }); 6130 return returnValue; 6131 } 6132 function useOnline(options = {}) { 6133 const { isOnline } = useNetwork(options); 6134 return isOnline; 6135 } 6136 function usePageLeave(options = {}) { 6137 const { window: window2 = defaultWindow } = options; 6138 const isLeft = shallowRef(false); 6139 const handler = (event) => { 6140 if (!window2) return; 6141 event = event || window2.event; 6142 isLeft.value = !(event.relatedTarget || event.toElement); 6143 }; 6144 if (window2) { 6145 const listenerOptions = { passive: true }; 6146 useEventListener(window2, "mouseout", handler, listenerOptions); 6147 useEventListener(window2.document, "mouseleave", handler, listenerOptions); 6148 useEventListener(window2.document, "mouseenter", handler, listenerOptions); 6149 } 6150 return isLeft; 6151 } 6152 function useScreenOrientation(options = {}) { 6153 const { window: window2 = defaultWindow } = options; 6154 const isSupported = useSupported(() => window2 && "screen" in window2 && "orientation" in window2.screen); 6155 const screenOrientation = isSupported.value ? window2.screen.orientation : {}; 6156 const orientation = shallowRef(screenOrientation.type); 6157 const angle = shallowRef(screenOrientation.angle || 0); 6158 if (isSupported.value) useEventListener(window2, "orientationchange", () => { 6159 orientation.value = screenOrientation.type; 6160 angle.value = screenOrientation.angle; 6161 }, { passive: true }); 6162 const lockOrientation = (type) => { 6163 if (isSupported.value && typeof screenOrientation.lock === "function") return screenOrientation.lock(type); 6164 return Promise.reject(new Error("Not supported")); 6165 }; 6166 const unlockOrientation = () => { 6167 if (isSupported.value && typeof screenOrientation.unlock === "function") screenOrientation.unlock(); 6168 }; 6169 return { 6170 isSupported, 6171 orientation, 6172 angle, 6173 lockOrientation, 6174 unlockOrientation 6175 }; 6176 } 6177 function useParallax(target, options = {}) { 6178 const { deviceOrientationTiltAdjust = (i) => i, deviceOrientationRollAdjust = (i) => i, mouseTiltAdjust = (i) => i, mouseRollAdjust = (i) => i, window: window2 = defaultWindow } = options; 6179 const orientation = reactive(useDeviceOrientation({ window: window2 })); 6180 const screenOrientation = reactive(useScreenOrientation({ window: window2 })); 6181 const { elementX: x, elementY: y, elementWidth: width, elementHeight: height } = useMouseInElement(target, { 6182 handleOutside: false, 6183 window: window2 6184 }); 6185 const source = computed(() => { 6186 if (orientation.isSupported && (orientation.alpha != null && orientation.alpha !== 0 || orientation.gamma != null && orientation.gamma !== 0)) return "deviceOrientation"; 6187 return "mouse"; 6188 }); 6189 return { 6190 roll: computed(() => { 6191 if (source.value === "deviceOrientation") { 6192 let value; 6193 switch (screenOrientation.orientation) { 6194 case "landscape-primary": 6195 value = orientation.gamma / 90; 6196 break; 6197 case "landscape-secondary": 6198 value = -orientation.gamma / 90; 6199 break; 6200 case "portrait-primary": 6201 value = -orientation.beta / 90; 6202 break; 6203 case "portrait-secondary": 6204 value = orientation.beta / 90; 6205 break; 6206 default: 6207 value = -orientation.beta / 90; 6208 } 6209 return deviceOrientationRollAdjust(value); 6210 } else return mouseRollAdjust(-(y.value - height.value / 2) / height.value); 6211 }), 6212 tilt: computed(() => { 6213 if (source.value === "deviceOrientation") { 6214 let value; 6215 switch (screenOrientation.orientation) { 6216 case "landscape-primary": 6217 value = orientation.beta / 90; 6218 break; 6219 case "landscape-secondary": 6220 value = -orientation.beta / 90; 6221 break; 6222 case "portrait-primary": 6223 value = orientation.gamma / 90; 6224 break; 6225 case "portrait-secondary": 6226 value = -orientation.gamma / 90; 6227 break; 6228 default: 6229 value = orientation.gamma / 90; 6230 } 6231 return deviceOrientationTiltAdjust(value); 6232 } else return mouseTiltAdjust((x.value - width.value / 2) / width.value); 6233 }), 6234 source 6235 }; 6236 } 6237 function useParentElement(element = useCurrentElement()) { 6238 const parentElement = shallowRef(); 6239 const update = () => { 6240 const el = unrefElement(element); 6241 if (el) parentElement.value = el.parentElement; 6242 }; 6243 tryOnMounted(update); 6244 watch(() => toValue(element), update); 6245 return parentElement; 6246 } 6247 function usePerformanceObserver(options, callback) { 6248 const { window: window2 = defaultWindow, immediate = true, ...performanceOptions } = options; 6249 const isSupported = useSupported(() => window2 && "PerformanceObserver" in window2); 6250 let observer; 6251 const stop = () => { 6252 observer === null || observer === void 0 || observer.disconnect(); 6253 }; 6254 const start = () => { 6255 if (isSupported.value) { 6256 stop(); 6257 observer = new PerformanceObserver(callback); 6258 observer.observe(performanceOptions); 6259 } 6260 }; 6261 tryOnScopeDispose(stop); 6262 if (immediate) start(); 6263 return { 6264 isSupported, 6265 start, 6266 stop 6267 }; 6268 } 6269 var defaultState = { 6270 x: 0, 6271 y: 0, 6272 pointerId: 0, 6273 pressure: 0, 6274 tiltX: 0, 6275 tiltY: 0, 6276 width: 0, 6277 height: 0, 6278 twist: 0, 6279 pointerType: null 6280 }; 6281 var keys = Object.keys(defaultState); 6282 function usePointer(options = {}) { 6283 const { target = defaultWindow } = options; 6284 const isInside = shallowRef(false); 6285 const state = shallowRef(options.initialValue || {}); 6286 Object.assign(state.value, defaultState, state.value); 6287 const handler = (event) => { 6288 isInside.value = true; 6289 if (options.pointerTypes && !options.pointerTypes.includes(event.pointerType)) return; 6290 state.value = objectPick(event, keys, false); 6291 }; 6292 if (target) { 6293 const listenerOptions = { passive: true }; 6294 useEventListener(target, [ 6295 "pointerdown", 6296 "pointermove", 6297 "pointerup" 6298 ], handler, listenerOptions); 6299 useEventListener(target, "pointerleave", () => isInside.value = false, listenerOptions); 6300 } 6301 return { 6302 ...toRefs2(state), 6303 isInside 6304 }; 6305 } 6306 function usePointerLock(target, options = {}) { 6307 const { document: document2 = defaultDocument } = options; 6308 const isSupported = useSupported(() => document2 && "pointerLockElement" in document2); 6309 const element = shallowRef(); 6310 const triggerElement = shallowRef(); 6311 let targetElement; 6312 if (isSupported.value) { 6313 const listenerOptions = { passive: true }; 6314 useEventListener(document2, "pointerlockchange", () => { 6315 var _pointerLockElement; 6316 const currentElement = (_pointerLockElement = document2.pointerLockElement) !== null && _pointerLockElement !== void 0 ? _pointerLockElement : element.value; 6317 if (targetElement && currentElement === targetElement) { 6318 element.value = document2.pointerLockElement; 6319 if (!element.value) targetElement = triggerElement.value = null; 6320 } 6321 }, listenerOptions); 6322 useEventListener(document2, "pointerlockerror", () => { 6323 var _pointerLockElement2; 6324 const currentElement = (_pointerLockElement2 = document2.pointerLockElement) !== null && _pointerLockElement2 !== void 0 ? _pointerLockElement2 : element.value; 6325 if (targetElement && currentElement === targetElement) { 6326 const action = document2.pointerLockElement ? "release" : "acquire"; 6327 throw new Error(`Failed to ${action} pointer lock.`); 6328 } 6329 }, listenerOptions); 6330 } 6331 async function lock(e) { 6332 var _unrefElement; 6333 if (!isSupported.value) throw new Error("Pointer Lock API is not supported by your browser."); 6334 triggerElement.value = e instanceof Event ? e.currentTarget : null; 6335 targetElement = e instanceof Event ? (_unrefElement = unrefElement(target)) !== null && _unrefElement !== void 0 ? _unrefElement : triggerElement.value : unrefElement(e); 6336 if (!targetElement) throw new Error("Target element undefined."); 6337 targetElement.requestPointerLock(); 6338 return await until(element).toBe(targetElement); 6339 } 6340 async function unlock() { 6341 if (!element.value) return false; 6342 document2.exitPointerLock(); 6343 await until(element).toBeNull(); 6344 return true; 6345 } 6346 return { 6347 isSupported, 6348 element, 6349 triggerElement, 6350 lock, 6351 unlock 6352 }; 6353 } 6354 function usePointerSwipe(target, options = {}) { 6355 const targetRef = toRef2(target); 6356 const { threshold = 50, onSwipe, onSwipeEnd, onSwipeStart, disableTextSelect = false } = options; 6357 const posStart = reactive({ 6358 x: 0, 6359 y: 0 6360 }); 6361 const updatePosStart = (x, y) => { 6362 posStart.x = x; 6363 posStart.y = y; 6364 }; 6365 const posEnd = reactive({ 6366 x: 0, 6367 y: 0 6368 }); 6369 const updatePosEnd = (x, y) => { 6370 posEnd.x = x; 6371 posEnd.y = y; 6372 }; 6373 const distanceX = computed(() => posStart.x - posEnd.x); 6374 const distanceY = computed(() => posStart.y - posEnd.y); 6375 const { max, abs } = Math; 6376 const isThresholdExceeded = computed(() => max(abs(distanceX.value), abs(distanceY.value)) >= threshold); 6377 const isSwiping = shallowRef(false); 6378 const isPointerDown = shallowRef(false); 6379 const direction = computed(() => { 6380 if (!isThresholdExceeded.value) return "none"; 6381 if (abs(distanceX.value) > abs(distanceY.value)) return distanceX.value > 0 ? "left" : "right"; 6382 else return distanceY.value > 0 ? "up" : "down"; 6383 }); 6384 const eventIsAllowed = (e) => { 6385 var _ref, _options$pointerTypes, _options$pointerTypes2; 6386 const isReleasingButton = e.buttons === 0; 6387 const isPrimaryButton = e.buttons === 1; 6388 return (_ref = (_options$pointerTypes = (_options$pointerTypes2 = options.pointerTypes) === null || _options$pointerTypes2 === void 0 ? void 0 : _options$pointerTypes2.includes(e.pointerType)) !== null && _options$pointerTypes !== void 0 ? _options$pointerTypes : isReleasingButton || isPrimaryButton) !== null && _ref !== void 0 ? _ref : true; 6389 }; 6390 const listenerOptions = { passive: true }; 6391 const stops = [ 6392 useEventListener(target, "pointerdown", (e) => { 6393 if (!eventIsAllowed(e)) return; 6394 isPointerDown.value = true; 6395 const eventTarget = e.target; 6396 eventTarget === null || eventTarget === void 0 || eventTarget.setPointerCapture(e.pointerId); 6397 const { clientX: x, clientY: y } = e; 6398 updatePosStart(x, y); 6399 updatePosEnd(x, y); 6400 onSwipeStart === null || onSwipeStart === void 0 || onSwipeStart(e); 6401 }, listenerOptions), 6402 useEventListener(target, "pointermove", (e) => { 6403 if (!eventIsAllowed(e)) return; 6404 if (!isPointerDown.value) return; 6405 const { clientX: x, clientY: y } = e; 6406 updatePosEnd(x, y); 6407 if (!isSwiping.value && isThresholdExceeded.value) isSwiping.value = true; 6408 if (isSwiping.value) onSwipe === null || onSwipe === void 0 || onSwipe(e); 6409 }, listenerOptions), 6410 useEventListener(target, "pointerup", (e) => { 6411 if (!eventIsAllowed(e)) return; 6412 if (isSwiping.value) onSwipeEnd === null || onSwipeEnd === void 0 || onSwipeEnd(e, direction.value); 6413 isPointerDown.value = false; 6414 isSwiping.value = false; 6415 }, listenerOptions) 6416 ]; 6417 tryOnMounted(() => { 6418 var _targetRef$value; 6419 (_targetRef$value = targetRef.value) === null || _targetRef$value === void 0 || (_targetRef$value = _targetRef$value.style) === null || _targetRef$value === void 0 || _targetRef$value.setProperty("touch-action", "pan-y"); 6420 if (disableTextSelect) { 6421 var _targetRef$value2, _targetRef$value3, _targetRef$value4; 6422 (_targetRef$value2 = targetRef.value) === null || _targetRef$value2 === void 0 || (_targetRef$value2 = _targetRef$value2.style) === null || _targetRef$value2 === void 0 || _targetRef$value2.setProperty("-webkit-user-select", "none"); 6423 (_targetRef$value3 = targetRef.value) === null || _targetRef$value3 === void 0 || (_targetRef$value3 = _targetRef$value3.style) === null || _targetRef$value3 === void 0 || _targetRef$value3.setProperty("-ms-user-select", "none"); 6424 (_targetRef$value4 = targetRef.value) === null || _targetRef$value4 === void 0 || (_targetRef$value4 = _targetRef$value4.style) === null || _targetRef$value4 === void 0 || _targetRef$value4.setProperty("user-select", "none"); 6425 } 6426 }); 6427 const stop = () => stops.forEach((s) => s()); 6428 return { 6429 isSwiping: shallowReadonly(isSwiping), 6430 direction: shallowReadonly(direction), 6431 posStart: readonly(posStart), 6432 posEnd: readonly(posEnd), 6433 distanceX, 6434 distanceY, 6435 stop 6436 }; 6437 } 6438 function usePreferredColorScheme(options) { 6439 const isLight = useMediaQuery("(prefers-color-scheme: light)", options); 6440 const isDark = useMediaQuery("(prefers-color-scheme: dark)", options); 6441 return computed(() => { 6442 if (isDark.value) return "dark"; 6443 if (isLight.value) return "light"; 6444 return "no-preference"; 6445 }); 6446 } 6447 function usePreferredContrast(options) { 6448 const isMore = useMediaQuery("(prefers-contrast: more)", options); 6449 const isLess = useMediaQuery("(prefers-contrast: less)", options); 6450 const isCustom = useMediaQuery("(prefers-contrast: custom)", options); 6451 return computed(() => { 6452 if (isMore.value) return "more"; 6453 if (isLess.value) return "less"; 6454 if (isCustom.value) return "custom"; 6455 return "no-preference"; 6456 }); 6457 } 6458 function usePreferredLanguages(options = {}) { 6459 const { window: window2 = defaultWindow } = options; 6460 if (!window2) return shallowRef(["en"]); 6461 const navigator2 = window2.navigator; 6462 const value = shallowRef(navigator2.languages); 6463 useEventListener(window2, "languagechange", () => { 6464 value.value = navigator2.languages; 6465 }, { passive: true }); 6466 return value; 6467 } 6468 function usePreferredReducedMotion(options) { 6469 const isReduced = useMediaQuery("(prefers-reduced-motion: reduce)", options); 6470 return computed(() => { 6471 if (isReduced.value) return "reduce"; 6472 return "no-preference"; 6473 }); 6474 } 6475 function usePreferredReducedTransparency(options) { 6476 const isReduced = useMediaQuery("(prefers-reduced-transparency: reduce)", options); 6477 return computed(() => { 6478 if (isReduced.value) return "reduce"; 6479 return "no-preference"; 6480 }); 6481 } 6482 function usePrevious(value, initialValue) { 6483 const previous = shallowRef(initialValue); 6484 watch(toRef2(value), (_, oldValue) => { 6485 previous.value = oldValue; 6486 }, { flush: "sync" }); 6487 return readonly(previous); 6488 } 6489 var topVarName = "--vueuse-safe-area-top"; 6490 var rightVarName = "--vueuse-safe-area-right"; 6491 var bottomVarName = "--vueuse-safe-area-bottom"; 6492 var leftVarName = "--vueuse-safe-area-left"; 6493 function useScreenSafeArea() { 6494 const top = shallowRef(""); 6495 const right = shallowRef(""); 6496 const bottom = shallowRef(""); 6497 const left = shallowRef(""); 6498 if (isClient) { 6499 const topCssVar = useCssVar(topVarName); 6500 const rightCssVar = useCssVar(rightVarName); 6501 const bottomCssVar = useCssVar(bottomVarName); 6502 const leftCssVar = useCssVar(leftVarName); 6503 topCssVar.value = "env(safe-area-inset-top, 0px)"; 6504 rightCssVar.value = "env(safe-area-inset-right, 0px)"; 6505 bottomCssVar.value = "env(safe-area-inset-bottom, 0px)"; 6506 leftCssVar.value = "env(safe-area-inset-left, 0px)"; 6507 tryOnMounted(update); 6508 useEventListener("resize", useDebounceFn(update), { passive: true }); 6509 } 6510 function update() { 6511 top.value = getValue(topVarName); 6512 right.value = getValue(rightVarName); 6513 bottom.value = getValue(bottomVarName); 6514 left.value = getValue(leftVarName); 6515 } 6516 return { 6517 top, 6518 right, 6519 bottom, 6520 left, 6521 update 6522 }; 6523 } 6524 function getValue(position) { 6525 return getComputedStyle(document.documentElement).getPropertyValue(position); 6526 } 6527 function useScriptTag(src, onLoaded = noop, options = {}) { 6528 const { immediate = true, manual = false, type = "text/javascript", async = true, crossOrigin, referrerPolicy, noModule, defer, document: document2 = defaultDocument, attrs = {}, nonce = void 0 } = options; 6529 const scriptTag = shallowRef(null); 6530 let _promise = null; 6531 const loadScript = (waitForScriptLoad) => new Promise((resolve, reject) => { 6532 const resolveWithElement = (el2) => { 6533 scriptTag.value = el2; 6534 resolve(el2); 6535 return el2; 6536 }; 6537 if (!document2) { 6538 resolve(false); 6539 return; 6540 } 6541 let shouldAppend = false; 6542 let el = document2.querySelector(`script[src="${toValue(src)}"]`); 6543 if (!el) { 6544 el = document2.createElement("script"); 6545 el.type = type; 6546 el.async = async; 6547 el.src = toValue(src); 6548 if (defer) el.defer = defer; 6549 if (crossOrigin) el.crossOrigin = crossOrigin; 6550 if (noModule) el.noModule = noModule; 6551 if (referrerPolicy) el.referrerPolicy = referrerPolicy; 6552 if (nonce) el.nonce = nonce; 6553 Object.entries(attrs).forEach(([name, value]) => el === null || el === void 0 ? void 0 : el.setAttribute(name, value)); 6554 shouldAppend = true; 6555 } else if (el.hasAttribute("data-loaded")) resolveWithElement(el); 6556 const listenerOptions = { passive: true }; 6557 useEventListener(el, "error", (event) => reject(event), listenerOptions); 6558 useEventListener(el, "abort", (event) => reject(event), listenerOptions); 6559 useEventListener(el, "load", () => { 6560 el.setAttribute("data-loaded", "true"); 6561 onLoaded(el); 6562 resolveWithElement(el); 6563 }, listenerOptions); 6564 if (shouldAppend) el = document2.head.appendChild(el); 6565 if (!waitForScriptLoad) resolveWithElement(el); 6566 }); 6567 const load = (waitForScriptLoad = true) => { 6568 if (!_promise) _promise = loadScript(waitForScriptLoad); 6569 return _promise; 6570 }; 6571 const unload = () => { 6572 if (!document2) return; 6573 _promise = null; 6574 if (scriptTag.value) scriptTag.value = null; 6575 const el = document2.querySelector(`script[src="${toValue(src)}"]`); 6576 if (el) document2.head.removeChild(el); 6577 }; 6578 if (immediate && !manual) tryOnMounted(load); 6579 if (!manual) tryOnUnmounted(unload); 6580 return { 6581 scriptTag, 6582 load, 6583 unload 6584 }; 6585 } 6586 function checkOverflowScroll(ele) { 6587 const style = window.getComputedStyle(ele); 6588 if (style.overflowX === "scroll" || style.overflowY === "scroll" || style.overflowX === "auto" && ele.clientWidth < ele.scrollWidth || style.overflowY === "auto" && ele.clientHeight < ele.scrollHeight) return true; 6589 else { 6590 const parent = ele.parentNode; 6591 if (!parent || parent.tagName === "BODY") return false; 6592 return checkOverflowScroll(parent); 6593 } 6594 } 6595 function preventDefault(rawEvent) { 6596 const e = rawEvent || window.event; 6597 const _target = e.target; 6598 if (checkOverflowScroll(_target)) return false; 6599 if (e.touches.length > 1) return true; 6600 if (e.preventDefault) e.preventDefault(); 6601 return false; 6602 } 6603 var elInitialOverflow = /* @__PURE__ */ new WeakMap(); 6604 function useScrollLock(element, initialState = false) { 6605 const isLocked = shallowRef(initialState); 6606 let stopTouchMoveListener = null; 6607 let initialOverflow = ""; 6608 watch(toRef2(element), (el) => { 6609 const target = resolveElement(toValue(el)); 6610 if (target) { 6611 const ele = target; 6612 if (!elInitialOverflow.get(ele)) elInitialOverflow.set(ele, ele.style.overflow); 6613 if (ele.style.overflow !== "hidden") initialOverflow = ele.style.overflow; 6614 if (ele.style.overflow === "hidden") return isLocked.value = true; 6615 if (isLocked.value) return ele.style.overflow = "hidden"; 6616 } 6617 }, { immediate: true }); 6618 const lock = () => { 6619 const el = resolveElement(toValue(element)); 6620 if (!el || isLocked.value) return; 6621 if (isIOS) stopTouchMoveListener = useEventListener(el, "touchmove", (e) => { 6622 preventDefault(e); 6623 }, { passive: false }); 6624 el.style.overflow = "hidden"; 6625 isLocked.value = true; 6626 }; 6627 const unlock = () => { 6628 const el = resolveElement(toValue(element)); 6629 if (!el || !isLocked.value) return; 6630 if (isIOS) stopTouchMoveListener === null || stopTouchMoveListener === void 0 || stopTouchMoveListener(); 6631 el.style.overflow = initialOverflow; 6632 elInitialOverflow.delete(el); 6633 isLocked.value = false; 6634 }; 6635 tryOnScopeDispose(unlock); 6636 return computed({ 6637 get() { 6638 return isLocked.value; 6639 }, 6640 set(v) { 6641 if (v) lock(); 6642 else unlock(); 6643 } 6644 }); 6645 } 6646 function useSessionStorage(key, initialValue, options = {}) { 6647 const { window: window2 = defaultWindow } = options; 6648 return useStorage(key, initialValue, window2 === null || window2 === void 0 ? void 0 : window2.sessionStorage, options); 6649 } 6650 function useShare(shareOptions = {}, options = {}) { 6651 const { navigator: navigator2 = defaultNavigator } = options; 6652 const _navigator = navigator2; 6653 const isSupported = useSupported(() => _navigator && "canShare" in _navigator); 6654 const share = async (overrideOptions = {}) => { 6655 if (isSupported.value) { 6656 const data = { 6657 ...toValue(shareOptions), 6658 ...toValue(overrideOptions) 6659 }; 6660 let granted = false; 6661 if (_navigator.canShare) granted = _navigator.canShare(data); 6662 if (granted) return _navigator.share(data); 6663 } 6664 }; 6665 return { 6666 isSupported, 6667 share 6668 }; 6669 } 6670 var defaultSortFn = (source, compareFn) => source.sort(compareFn); 6671 var defaultCompare = (a, b) => a - b; 6672 function useSorted(...args) { 6673 const [source] = args; 6674 let compareFn = defaultCompare; 6675 let options = {}; 6676 if (args.length === 2) if (typeof args[1] === "object") { 6677 var _options$compareFn; 6678 options = args[1]; 6679 compareFn = (_options$compareFn = options.compareFn) !== null && _options$compareFn !== void 0 ? _options$compareFn : defaultCompare; 6680 } else { 6681 var _args$; 6682 compareFn = (_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : defaultCompare; 6683 } 6684 else if (args.length > 2) { 6685 var _args$2, _args$3; 6686 compareFn = (_args$2 = args[1]) !== null && _args$2 !== void 0 ? _args$2 : defaultCompare; 6687 options = (_args$3 = args[2]) !== null && _args$3 !== void 0 ? _args$3 : {}; 6688 } 6689 const { dirty = false, sortFn = defaultSortFn } = options; 6690 if (!dirty) return computed(() => sortFn([...toValue(source)], compareFn)); 6691 watchEffect(() => { 6692 const result = sortFn(toValue(source), compareFn); 6693 if (isRef(source)) source.value = result; 6694 else source.splice(0, source.length, ...result); 6695 }); 6696 return source; 6697 } 6698 function useSpeechRecognition(options = {}) { 6699 const { interimResults = true, continuous = true, maxAlternatives = 1, window: window2 = defaultWindow } = options; 6700 const lang = toRef2(options.lang || "en-US"); 6701 const isListening = shallowRef(false); 6702 const isFinal = shallowRef(false); 6703 const result = shallowRef(""); 6704 const error = shallowRef(void 0); 6705 let recognition; 6706 const start = () => { 6707 isListening.value = true; 6708 }; 6709 const stop = () => { 6710 isListening.value = false; 6711 }; 6712 const toggle = (value = !isListening.value) => { 6713 if (value) start(); 6714 else stop(); 6715 }; 6716 const SpeechRecognition = window2 && (window2.SpeechRecognition || window2.webkitSpeechRecognition); 6717 const isSupported = useSupported(() => SpeechRecognition); 6718 if (isSupported.value) { 6719 recognition = new SpeechRecognition(); 6720 recognition.continuous = continuous; 6721 recognition.interimResults = interimResults; 6722 recognition.lang = toValue(lang); 6723 recognition.maxAlternatives = maxAlternatives; 6724 recognition.onstart = () => { 6725 isListening.value = true; 6726 isFinal.value = false; 6727 }; 6728 watch(lang, (lang2) => { 6729 if (recognition && !isListening.value) recognition.lang = lang2; 6730 }); 6731 recognition.onresult = (event) => { 6732 const currentResult = event.results[event.resultIndex]; 6733 const { transcript } = currentResult[0]; 6734 isFinal.value = currentResult.isFinal; 6735 result.value = transcript; 6736 error.value = void 0; 6737 }; 6738 recognition.onerror = (event) => { 6739 error.value = event; 6740 }; 6741 recognition.onend = () => { 6742 isListening.value = false; 6743 recognition.lang = toValue(lang); 6744 }; 6745 watch(isListening, (newValue, oldValue) => { 6746 if (newValue === oldValue) return; 6747 try { 6748 if (newValue) recognition.start(); 6749 else recognition.stop(); 6750 } catch (err) { 6751 error.value = err; 6752 } 6753 }); 6754 } 6755 tryOnScopeDispose(() => { 6756 stop(); 6757 }); 6758 return { 6759 isSupported, 6760 isListening, 6761 isFinal, 6762 recognition, 6763 result, 6764 error, 6765 toggle, 6766 start, 6767 stop 6768 }; 6769 } 6770 function useSpeechSynthesis(text, options = {}) { 6771 const { pitch = 1, rate = 1, volume = 1, window: window2 = defaultWindow, onBoundary } = options; 6772 const synth = window2 && window2.speechSynthesis; 6773 const isSupported = useSupported(() => synth); 6774 const isPlaying = shallowRef(false); 6775 const status = shallowRef("init"); 6776 const spokenText = toRef2(text || ""); 6777 const lang = toRef2(options.lang || "en-US"); 6778 const error = shallowRef(void 0); 6779 const toggle = (value = !isPlaying.value) => { 6780 isPlaying.value = value; 6781 }; 6782 const bindEventsForUtterance = (utterance2) => { 6783 utterance2.lang = toValue(lang); 6784 utterance2.voice = toValue(options.voice) || null; 6785 utterance2.pitch = toValue(pitch); 6786 utterance2.rate = toValue(rate); 6787 utterance2.volume = toValue(volume); 6788 utterance2.onstart = () => { 6789 isPlaying.value = true; 6790 status.value = "play"; 6791 }; 6792 utterance2.onpause = () => { 6793 isPlaying.value = false; 6794 status.value = "pause"; 6795 }; 6796 utterance2.onresume = () => { 6797 isPlaying.value = true; 6798 status.value = "play"; 6799 }; 6800 utterance2.onend = () => { 6801 isPlaying.value = false; 6802 status.value = "end"; 6803 }; 6804 utterance2.onerror = (event) => { 6805 error.value = event; 6806 }; 6807 utterance2.onboundary = (event) => { 6808 onBoundary === null || onBoundary === void 0 || onBoundary(event); 6809 }; 6810 }; 6811 const utterance = computed(() => { 6812 isPlaying.value = false; 6813 status.value = "init"; 6814 const newUtterance = new SpeechSynthesisUtterance(spokenText.value); 6815 bindEventsForUtterance(newUtterance); 6816 return newUtterance; 6817 }); 6818 const speak = () => { 6819 synth.cancel(); 6820 if (utterance) synth.speak(utterance.value); 6821 }; 6822 const stop = () => { 6823 synth.cancel(); 6824 isPlaying.value = false; 6825 }; 6826 if (isSupported.value) { 6827 bindEventsForUtterance(utterance.value); 6828 watch(lang, (lang2) => { 6829 if (utterance.value && !isPlaying.value) utterance.value.lang = lang2; 6830 }); 6831 if (options.voice) watch(options.voice, () => { 6832 synth.cancel(); 6833 }); 6834 watch(isPlaying, () => { 6835 if (isPlaying.value) synth.resume(); 6836 else synth.pause(); 6837 }); 6838 } 6839 tryOnScopeDispose(() => { 6840 isPlaying.value = false; 6841 }); 6842 return { 6843 isSupported, 6844 isPlaying, 6845 status, 6846 utterance, 6847 error, 6848 stop, 6849 toggle, 6850 speak 6851 }; 6852 } 6853 function useStepper(steps, initialStep) { 6854 const stepsRef = ref(steps); 6855 const stepNames = computed(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value)); 6856 const index = ref(stepNames.value.indexOf(initialStep !== null && initialStep !== void 0 ? initialStep : stepNames.value[0])); 6857 const current = computed(() => at(index.value)); 6858 const isFirst = computed(() => index.value === 0); 6859 const isLast = computed(() => index.value === stepNames.value.length - 1); 6860 const next = computed(() => stepNames.value[index.value + 1]); 6861 const previous = computed(() => stepNames.value[index.value - 1]); 6862 function at(index2) { 6863 if (Array.isArray(stepsRef.value)) return stepsRef.value[index2]; 6864 return stepsRef.value[stepNames.value[index2]]; 6865 } 6866 function get2(step) { 6867 if (!stepNames.value.includes(step)) return; 6868 return at(stepNames.value.indexOf(step)); 6869 } 6870 function goTo(step) { 6871 if (stepNames.value.includes(step)) index.value = stepNames.value.indexOf(step); 6872 } 6873 function goToNext() { 6874 if (isLast.value) return; 6875 index.value++; 6876 } 6877 function goToPrevious() { 6878 if (isFirst.value) return; 6879 index.value--; 6880 } 6881 function goBackTo(step) { 6882 if (isAfter(step)) goTo(step); 6883 } 6884 function isNext(step) { 6885 return stepNames.value.indexOf(step) === index.value + 1; 6886 } 6887 function isPrevious(step) { 6888 return stepNames.value.indexOf(step) === index.value - 1; 6889 } 6890 function isCurrent(step) { 6891 return stepNames.value.indexOf(step) === index.value; 6892 } 6893 function isBefore(step) { 6894 return index.value < stepNames.value.indexOf(step); 6895 } 6896 function isAfter(step) { 6897 return index.value > stepNames.value.indexOf(step); 6898 } 6899 return { 6900 steps: stepsRef, 6901 stepNames, 6902 index, 6903 current, 6904 next, 6905 previous, 6906 isFirst, 6907 isLast, 6908 at, 6909 get: get2, 6910 goTo, 6911 goToNext, 6912 goToPrevious, 6913 goBackTo, 6914 isNext, 6915 isPrevious, 6916 isCurrent, 6917 isBefore, 6918 isAfter 6919 }; 6920 } 6921 function useStorageAsync(key, initialValue, storage, options = {}) { 6922 var _options$serializer; 6923 const { flush = "pre", deep = true, listenToStorageChanges = true, writeDefaults = true, mergeDefaults = false, shallow, window: window2 = defaultWindow, eventFilter, onError = (e) => { 6924 console.error(e); 6925 }, onReady } = options; 6926 const rawInit = toValue(initialValue); 6927 const type = guessSerializerType(rawInit); 6928 const data = (shallow ? shallowRef : ref)(toValue(initialValue)); 6929 const serializer = (_options$serializer = options.serializer) !== null && _options$serializer !== void 0 ? _options$serializer : StorageSerializers[type]; 6930 if (!storage) try { 6931 storage = getSSRHandler("getDefaultStorageAsync", () => defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.localStorage)(); 6932 } catch (e) { 6933 onError(e); 6934 } 6935 async function read(event) { 6936 if (!storage || event && event.key !== key) return; 6937 try { 6938 const rawValue = event ? event.newValue : await storage.getItem(key); 6939 if (rawValue == null) { 6940 data.value = rawInit; 6941 if (writeDefaults && rawInit !== null) await storage.setItem(key, await serializer.write(rawInit)); 6942 } else if (mergeDefaults) { 6943 const value = await serializer.read(rawValue); 6944 if (typeof mergeDefaults === "function") data.value = mergeDefaults(value, rawInit); 6945 else if (type === "object" && !Array.isArray(value)) data.value = { 6946 ...rawInit, 6947 ...value 6948 }; 6949 else data.value = value; 6950 } else data.value = await serializer.read(rawValue); 6951 } catch (e) { 6952 onError(e); 6953 } 6954 } 6955 const promise = new Promise((resolve) => { 6956 read().then(() => { 6957 onReady === null || onReady === void 0 || onReady(data.value); 6958 resolve(data); 6959 }); 6960 }); 6961 if (window2 && listenToStorageChanges) useEventListener(window2, "storage", (e) => Promise.resolve().then(() => read(e)), { passive: true }); 6962 if (storage) watchWithFilter(data, async () => { 6963 try { 6964 if (data.value == null) await storage.removeItem(key); 6965 else await storage.setItem(key, await serializer.write(data.value)); 6966 } catch (e) { 6967 onError(e); 6968 } 6969 }, { 6970 flush, 6971 deep, 6972 eventFilter 6973 }); 6974 Object.assign(data, { 6975 then: promise.then.bind(promise), 6976 catch: promise.catch.bind(promise) 6977 }); 6978 return data; 6979 } 6980 var _id = 0; 6981 function useStyleTag(css, options = {}) { 6982 const isLoaded = shallowRef(false); 6983 const { document: document2 = defaultDocument, immediate = true, manual = false, id = `vueuse_styletag_${++_id}` } = options; 6984 const cssRef = shallowRef(css); 6985 let stop = () => { 6986 }; 6987 const load = () => { 6988 if (!document2) return; 6989 const el = document2.getElementById(id) || document2.createElement("style"); 6990 if (!el.isConnected) { 6991 el.id = id; 6992 if (options.nonce) el.nonce = options.nonce; 6993 if (options.media) el.media = options.media; 6994 document2.head.appendChild(el); 6995 } 6996 if (isLoaded.value) return; 6997 stop = watch(cssRef, (value) => { 6998 el.textContent = value; 6999 }, { immediate: true }); 7000 isLoaded.value = true; 7001 }; 7002 const unload = () => { 7003 if (!document2 || !isLoaded.value) return; 7004 stop(); 7005 document2.head.removeChild(document2.getElementById(id)); 7006 isLoaded.value = false; 7007 }; 7008 if (immediate && !manual) tryOnMounted(load); 7009 if (!manual) tryOnScopeDispose(unload); 7010 return { 7011 id, 7012 css: cssRef, 7013 unload, 7014 load, 7015 isLoaded: shallowReadonly(isLoaded) 7016 }; 7017 } 7018 function useSwipe(target, options = {}) { 7019 const { threshold = 50, onSwipe, onSwipeEnd, onSwipeStart, passive = true } = options; 7020 const coordsStart = reactive({ 7021 x: 0, 7022 y: 0 7023 }); 7024 const coordsEnd = reactive({ 7025 x: 0, 7026 y: 0 7027 }); 7028 const diffX = computed(() => coordsStart.x - coordsEnd.x); 7029 const diffY = computed(() => coordsStart.y - coordsEnd.y); 7030 const { max, abs } = Math; 7031 const isThresholdExceeded = computed(() => max(abs(diffX.value), abs(diffY.value)) >= threshold); 7032 const isSwiping = shallowRef(false); 7033 const direction = computed(() => { 7034 if (!isThresholdExceeded.value) return "none"; 7035 if (abs(diffX.value) > abs(diffY.value)) return diffX.value > 0 ? "left" : "right"; 7036 else return diffY.value > 0 ? "up" : "down"; 7037 }); 7038 const getTouchEventCoords = (e) => [e.touches[0].clientX, e.touches[0].clientY]; 7039 const updateCoordsStart = (x, y) => { 7040 coordsStart.x = x; 7041 coordsStart.y = y; 7042 }; 7043 const updateCoordsEnd = (x, y) => { 7044 coordsEnd.x = x; 7045 coordsEnd.y = y; 7046 }; 7047 const listenerOptions = { 7048 passive, 7049 capture: !passive 7050 }; 7051 const onTouchEnd = (e) => { 7052 if (isSwiping.value) onSwipeEnd === null || onSwipeEnd === void 0 || onSwipeEnd(e, direction.value); 7053 isSwiping.value = false; 7054 }; 7055 const stops = [ 7056 useEventListener(target, "touchstart", (e) => { 7057 if (e.touches.length !== 1) return; 7058 const [x, y] = getTouchEventCoords(e); 7059 updateCoordsStart(x, y); 7060 updateCoordsEnd(x, y); 7061 onSwipeStart === null || onSwipeStart === void 0 || onSwipeStart(e); 7062 }, listenerOptions), 7063 useEventListener(target, "touchmove", (e) => { 7064 if (e.touches.length !== 1) return; 7065 const [x, y] = getTouchEventCoords(e); 7066 updateCoordsEnd(x, y); 7067 if (listenerOptions.capture && !listenerOptions.passive && Math.abs(diffX.value) > Math.abs(diffY.value)) e.preventDefault(); 7068 if (!isSwiping.value && isThresholdExceeded.value) isSwiping.value = true; 7069 if (isSwiping.value) onSwipe === null || onSwipe === void 0 || onSwipe(e); 7070 }, listenerOptions), 7071 useEventListener(target, ["touchend", "touchcancel"], onTouchEnd, listenerOptions) 7072 ]; 7073 const stop = () => stops.forEach((s) => s()); 7074 return { 7075 isSwiping, 7076 direction, 7077 coordsStart, 7078 coordsEnd, 7079 lengthX: diffX, 7080 lengthY: diffY, 7081 stop 7082 }; 7083 } 7084 function useTemplateRefsList() { 7085 const refs = ref([]); 7086 refs.value.set = (el) => { 7087 if (el) refs.value.push(el); 7088 }; 7089 onBeforeUpdate(() => { 7090 refs.value.length = 0; 7091 }); 7092 return refs; 7093 } 7094 function useTextDirection(options = {}) { 7095 const { document: document2 = defaultDocument, selector = "html", observe = false, initialValue = "ltr" } = options; 7096 function getValue2() { 7097 var _ref, _document$querySelect; 7098 return (_ref = document2 === null || document2 === void 0 || (_document$querySelect = document2.querySelector(selector)) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute("dir")) !== null && _ref !== void 0 ? _ref : initialValue; 7099 } 7100 const dir = shallowRef(getValue2()); 7101 tryOnMounted(() => dir.value = getValue2()); 7102 if (observe && document2) useMutationObserver(document2.querySelector(selector), () => dir.value = getValue2(), { attributes: true }); 7103 return computed({ 7104 get() { 7105 return dir.value; 7106 }, 7107 set(v) { 7108 var _document$querySelect2, _document$querySelect3; 7109 dir.value = v; 7110 if (!document2) return; 7111 if (dir.value) (_document$querySelect2 = document2.querySelector(selector)) === null || _document$querySelect2 === void 0 || _document$querySelect2.setAttribute("dir", dir.value); 7112 else (_document$querySelect3 = document2.querySelector(selector)) === null || _document$querySelect3 === void 0 || _document$querySelect3.removeAttribute("dir"); 7113 } 7114 }); 7115 } 7116 function getRangesFromSelection(selection) { 7117 var _selection$rangeCount; 7118 const rangeCount = (_selection$rangeCount = selection.rangeCount) !== null && _selection$rangeCount !== void 0 ? _selection$rangeCount : 0; 7119 return Array.from({ length: rangeCount }, (_, i) => selection.getRangeAt(i)); 7120 } 7121 function useTextSelection(options = {}) { 7122 var _window$getSelection; 7123 const { window: window2 = defaultWindow } = options; 7124 const selection = shallowRef((_window$getSelection = window2 === null || window2 === void 0 ? void 0 : window2.getSelection()) !== null && _window$getSelection !== void 0 ? _window$getSelection : null); 7125 const text = computed(() => { 7126 var _selection$value$toSt, _selection$value; 7127 return (_selection$value$toSt = (_selection$value = selection.value) === null || _selection$value === void 0 ? void 0 : _selection$value.toString()) !== null && _selection$value$toSt !== void 0 ? _selection$value$toSt : ""; 7128 }); 7129 const ranges = computed(() => selection.value ? getRangesFromSelection(selection.value) : []); 7130 const rects = computed(() => ranges.value.map((range) => range.getBoundingClientRect())); 7131 function onSelectionChange() { 7132 selection.value = null; 7133 if (window2) selection.value = window2.getSelection(); 7134 } 7135 if (window2) useEventListener(window2.document, "selectionchange", onSelectionChange, { passive: true }); 7136 return { 7137 text, 7138 rects, 7139 ranges, 7140 selection 7141 }; 7142 } 7143 function tryRequestAnimationFrame(window2 = defaultWindow, fn) { 7144 if (window2 && typeof window2.requestAnimationFrame === "function") window2.requestAnimationFrame(fn); 7145 else fn(); 7146 } 7147 function useTextareaAutosize(options = {}) { 7148 var _options$input, _options$styleProp; 7149 const { window: window2 = defaultWindow } = options; 7150 const textarea = toRef2(options === null || options === void 0 ? void 0 : options.element); 7151 const input = toRef2((_options$input = options === null || options === void 0 ? void 0 : options.input) !== null && _options$input !== void 0 ? _options$input : ""); 7152 const styleProp = (_options$styleProp = options === null || options === void 0 ? void 0 : options.styleProp) !== null && _options$styleProp !== void 0 ? _options$styleProp : "height"; 7153 const textareaScrollHeight = shallowRef(1); 7154 const textareaOldWidth = shallowRef(0); 7155 function triggerResize() { 7156 var _textarea$value; 7157 if (!textarea.value) return; 7158 let height = ""; 7159 const maxHeight = options === null || options === void 0 ? void 0 : options.maxHeight; 7160 textarea.value.style[styleProp] = "1px"; 7161 textareaScrollHeight.value = (_textarea$value = textarea.value) === null || _textarea$value === void 0 ? void 0 : _textarea$value.scrollHeight; 7162 const _styleTarget = toValue(options === null || options === void 0 ? void 0 : options.styleTarget); 7163 const styleHeight = maxHeight != null ? `${Math.min(textareaScrollHeight.value, maxHeight)}px` : `${textareaScrollHeight.value}px`; 7164 if (_styleTarget) _styleTarget.style[styleProp] = styleHeight; 7165 else height = styleHeight; 7166 textarea.value.style[styleProp] = height; 7167 } 7168 watch([input, textarea], () => nextTick(triggerResize), { immediate: true }); 7169 watch(textareaScrollHeight, () => { 7170 var _options$onResize; 7171 return options === null || options === void 0 || (_options$onResize = options.onResize) === null || _options$onResize === void 0 ? void 0 : _options$onResize.call(options); 7172 }); 7173 useResizeObserver(textarea, ([{ contentRect }]) => { 7174 if (textareaOldWidth.value === contentRect.width) return; 7175 tryRequestAnimationFrame(window2, () => { 7176 textareaOldWidth.value = contentRect.width; 7177 triggerResize(); 7178 }); 7179 }); 7180 if (options === null || options === void 0 ? void 0 : options.watch) watch(options.watch, triggerResize, { 7181 immediate: true, 7182 deep: true 7183 }); 7184 return { 7185 textarea, 7186 input, 7187 triggerResize 7188 }; 7189 } 7190 function useThrottledRefHistory(source, options = {}) { 7191 const { throttle = 200, trailing = true } = options; 7192 const filter = throttleFilter(throttle, trailing); 7193 return { ...useRefHistory(source, { 7194 ...options, 7195 eventFilter: filter 7196 }) }; 7197 } 7198 var DEFAULT_UNITS = [ 7199 { 7200 max: 6e4, 7201 value: 1e3, 7202 name: "second" 7203 }, 7204 { 7205 max: 276e4, 7206 value: 6e4, 7207 name: "minute" 7208 }, 7209 { 7210 max: 72e6, 7211 value: 36e5, 7212 name: "hour" 7213 }, 7214 { 7215 max: 5184e5, 7216 value: 864e5, 7217 name: "day" 7218 }, 7219 { 7220 max: 24192e5, 7221 value: 6048e5, 7222 name: "week" 7223 }, 7224 { 7225 max: 28512e6, 7226 value: 2592e6, 7227 name: "month" 7228 }, 7229 { 7230 max: Number.POSITIVE_INFINITY, 7231 value: 31536e6, 7232 name: "year" 7233 } 7234 ]; 7235 var DEFAULT_MESSAGES = { 7236 justNow: "just now", 7237 past: (n) => /\d/.test(n) ? `${n} ago` : n, 7238 future: (n) => /\d/.test(n) ? `in ${n}` : n, 7239 month: (n, past) => n === 1 ? past ? "last month" : "next month" : `${n} month${n > 1 ? "s" : ""}`, 7240 year: (n, past) => n === 1 ? past ? "last year" : "next year" : `${n} year${n > 1 ? "s" : ""}`, 7241 day: (n, past) => n === 1 ? past ? "yesterday" : "tomorrow" : `${n} day${n > 1 ? "s" : ""}`, 7242 week: (n, past) => n === 1 ? past ? "last week" : "next week" : `${n} week${n > 1 ? "s" : ""}`, 7243 hour: (n) => `${n} hour${n > 1 ? "s" : ""}`, 7244 minute: (n) => `${n} minute${n > 1 ? "s" : ""}`, 7245 second: (n) => `${n} second${n > 1 ? "s" : ""}`, 7246 invalid: "" 7247 }; 7248 function DEFAULT_FORMATTER(date) { 7249 return date.toISOString().slice(0, 10); 7250 } 7251 function getDefaultScheduler$4(options) { 7252 if ("updateInterval" in options) { 7253 const { updateInterval = 3e4 } = options; 7254 return (cb) => useIntervalFn(cb, updateInterval); 7255 } 7256 return (cb) => useIntervalFn(cb, 3e4); 7257 } 7258 function useTimeAgo(time, options = {}) { 7259 const { controls: exposeControls = false, scheduler = getDefaultScheduler$4(options) } = options; 7260 const { now: now2, ...controls } = useNow({ 7261 scheduler, 7262 controls: true 7263 }); 7264 const timeAgo = computed(() => formatTimeAgo(new Date(toValue(time)), options, toValue(now2))); 7265 if (exposeControls) return { 7266 timeAgo, 7267 ...controls 7268 }; 7269 else return timeAgo; 7270 } 7271 function formatTimeAgo(from, options = {}, now2 = Date.now()) { 7272 const { max, messages = DEFAULT_MESSAGES, fullDateFormatter = DEFAULT_FORMATTER, units = DEFAULT_UNITS, showSecond = false, rounding = "round" } = options; 7273 const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding]; 7274 const diff = +now2 - +from; 7275 const absDiff = Math.abs(diff); 7276 function getValue2(diff2, unit) { 7277 return roundFn(Math.abs(diff2) / unit.value); 7278 } 7279 function format(diff2, unit) { 7280 const val = getValue2(diff2, unit); 7281 const past = diff2 > 0; 7282 const str = applyFormat(unit.name, val, past); 7283 return applyFormat(past ? "past" : "future", str, past); 7284 } 7285 function applyFormat(name, val, isPast) { 7286 const formatter = messages[name]; 7287 if (typeof formatter === "function") return formatter(val, isPast); 7288 return formatter.replace("{0}", val.toString()); 7289 } 7290 if (absDiff < 6e4 && !showSecond) return messages.justNow; 7291 if (typeof max === "number" && absDiff > max) return fullDateFormatter(new Date(from)); 7292 if (typeof max === "string") { 7293 var _units$find; 7294 const unitMax = (_units$find = units.find((i) => i.name === max)) === null || _units$find === void 0 ? void 0 : _units$find.max; 7295 if (unitMax && absDiff > unitMax) return fullDateFormatter(new Date(from)); 7296 } 7297 for (const [idx, unit] of units.entries()) { 7298 if (getValue2(diff, unit) <= 0 && units[idx - 1]) return format(diff, units[idx - 1]); 7299 if (absDiff < unit.max) return format(diff, unit); 7300 } 7301 return messages.invalid; 7302 } 7303 var UNITS = [ 7304 { 7305 name: "year", 7306 ms: 31536e6 7307 }, 7308 { 7309 name: "month", 7310 ms: 2592e6 7311 }, 7312 { 7313 name: "week", 7314 ms: 6048e5 7315 }, 7316 { 7317 name: "day", 7318 ms: 864e5 7319 }, 7320 { 7321 name: "hour", 7322 ms: 36e5 7323 }, 7324 { 7325 name: "minute", 7326 ms: 6e4 7327 }, 7328 { 7329 name: "second", 7330 ms: 1e3 7331 } 7332 ]; 7333 function getDefaultScheduler$3(options) { 7334 if ("updateInterval" in options) { 7335 const { updateInterval = 3e4 } = options; 7336 return (cb) => useIntervalFn(cb, updateInterval); 7337 } 7338 return (cb) => useIntervalFn(cb, 3e4); 7339 } 7340 function useTimeAgoIntl(time, options = {}) { 7341 const { controls: exposeControls = false, scheduler = getDefaultScheduler$3(options) } = options; 7342 const { now: now2, ...controls } = useNow({ 7343 scheduler, 7344 controls: true 7345 }); 7346 const result = computed(() => getTimeAgoIntlResult(new Date(toValue(time)), options, toValue(now2))); 7347 const parts = computed(() => result.value.parts); 7348 const timeAgoIntl = computed(() => formatTimeAgoIntlParts(parts.value, { 7349 ...options, 7350 locale: result.value.resolvedLocale 7351 })); 7352 return exposeControls ? { 7353 timeAgoIntl, 7354 parts, 7355 ...controls 7356 } : timeAgoIntl; 7357 } 7358 function formatTimeAgoIntl(from, options = {}, now2 = Date.now()) { 7359 const { parts, resolvedLocale } = getTimeAgoIntlResult(from, options, now2); 7360 return formatTimeAgoIntlParts(parts, { 7361 ...options, 7362 locale: resolvedLocale 7363 }); 7364 } 7365 function getTimeAgoIntlResult(from, options = {}, now2 = Date.now()) { 7366 var _options$units; 7367 const { locale, relativeTimeFormatOptions = { numeric: "auto" } } = options; 7368 const rtf = new Intl.RelativeTimeFormat(locale, relativeTimeFormatOptions); 7369 const { locale: resolvedLocale } = rtf.resolvedOptions(); 7370 const diff = +from - +now2; 7371 const absDiff = Math.abs(diff); 7372 const units = (_options$units = options.units) !== null && _options$units !== void 0 ? _options$units : UNITS; 7373 for (const { name, ms } of units) if (absDiff >= ms) return { 7374 resolvedLocale, 7375 parts: rtf.formatToParts(Math.round(diff / ms), name) 7376 }; 7377 return { 7378 resolvedLocale, 7379 parts: rtf.formatToParts(0, units[units.length - 1].name) 7380 }; 7381 } 7382 function formatTimeAgoIntlParts(parts, options = {}) { 7383 const { insertSpace = true, joinParts, locale } = options; 7384 if (typeof joinParts === "function") return joinParts(parts, locale); 7385 if (!insertSpace) return parts.map((part) => part.value).join(""); 7386 return parts.map((part) => part.value.trim()).join(" "); 7387 } 7388 function useTimeoutPoll(fn, interval, options = {}) { 7389 const { immediate = true, immediateCallback = false } = options; 7390 const { start } = useTimeoutFn(loop, interval, { immediate }); 7391 const isActive = shallowRef(false); 7392 async function loop() { 7393 if (!isActive.value) return; 7394 await fn(); 7395 start(); 7396 } 7397 function resume() { 7398 if (!isActive.value) { 7399 isActive.value = true; 7400 if (immediateCallback) fn(); 7401 start(); 7402 } 7403 } 7404 function pause() { 7405 isActive.value = false; 7406 } 7407 if (immediate && isClient) resume(); 7408 tryOnScopeDispose(pause); 7409 return { 7410 isActive, 7411 pause, 7412 resume 7413 }; 7414 } 7415 function getDefaultScheduler$2(options) { 7416 if ("interval" in options || "immediate" in options) { 7417 const { interval = "requestAnimationFrame", immediate = true } = options; 7418 return interval === "requestAnimationFrame" ? (cb) => useRafFn(cb, { immediate }) : (cb) => useIntervalFn(cb, interval, { immediate }); 7419 } 7420 return useRafFn; 7421 } 7422 function useTimestamp(options = {}) { 7423 const { controls: exposeControls = false, offset = 0, scheduler = getDefaultScheduler$2(options), callback } = options; 7424 const ts = shallowRef(timestamp() + offset); 7425 const update = () => ts.value = timestamp() + offset; 7426 const controls = scheduler(callback ? () => { 7427 update(); 7428 callback(ts.value); 7429 } : update); 7430 if (exposeControls) return { 7431 timestamp: ts, 7432 ...controls 7433 }; 7434 else return ts; 7435 } 7436 function useTitle(newTitle = null, options = {}) { 7437 var _document$title, _ref; 7438 const { document: document2 = defaultDocument, restoreOnUnmount = (t) => t } = options; 7439 const originalTitle = (_document$title = document2 === null || document2 === void 0 ? void 0 : document2.title) !== null && _document$title !== void 0 ? _document$title : ""; 7440 const title = toRef2((_ref = newTitle !== null && newTitle !== void 0 ? newTitle : document2 === null || document2 === void 0 ? void 0 : document2.title) !== null && _ref !== void 0 ? _ref : null); 7441 const isReadonly2 = !!(newTitle && typeof newTitle === "function"); 7442 function format(t) { 7443 if (!("titleTemplate" in options)) return t; 7444 const template = options.titleTemplate || "%s"; 7445 return typeof template === "function" ? template(t) : toValue(template).replace(/%s/g, t); 7446 } 7447 watch(title, (newValue, oldValue) => { 7448 if (newValue !== oldValue && document2) document2.title = format(newValue !== null && newValue !== void 0 ? newValue : ""); 7449 }, { immediate: true }); 7450 if (options.observe && !options.titleTemplate && document2 && !isReadonly2) { 7451 var _document$head; 7452 useMutationObserver((_document$head = document2.head) === null || _document$head === void 0 ? void 0 : _document$head.querySelector("title"), () => { 7453 if (document2 && document2.title !== title.value) title.value = format(document2.title); 7454 }, { childList: true }); 7455 } 7456 tryOnScopeDispose(() => { 7457 if (restoreOnUnmount) { 7458 const restoredTitle = restoreOnUnmount(originalTitle, title.value || ""); 7459 if (restoredTitle != null && document2) document2.title = restoredTitle; 7460 } 7461 }); 7462 return title; 7463 } 7464 var TransitionPresets = Object.assign({}, { linear: identity }, { 7465 easeInSine: [ 7466 0.12, 7467 0, 7468 0.39, 7469 0 7470 ], 7471 easeOutSine: [ 7472 0.61, 7473 1, 7474 0.88, 7475 1 7476 ], 7477 easeInOutSine: [ 7478 0.37, 7479 0, 7480 0.63, 7481 1 7482 ], 7483 easeInQuad: [ 7484 0.11, 7485 0, 7486 0.5, 7487 0 7488 ], 7489 easeOutQuad: [ 7490 0.5, 7491 1, 7492 0.89, 7493 1 7494 ], 7495 easeInOutQuad: [ 7496 0.45, 7497 0, 7498 0.55, 7499 1 7500 ], 7501 easeInCubic: [ 7502 0.32, 7503 0, 7504 0.67, 7505 0 7506 ], 7507 easeOutCubic: [ 7508 0.33, 7509 1, 7510 0.68, 7511 1 7512 ], 7513 easeInOutCubic: [ 7514 0.65, 7515 0, 7516 0.35, 7517 1 7518 ], 7519 easeInQuart: [ 7520 0.5, 7521 0, 7522 0.75, 7523 0 7524 ], 7525 easeOutQuart: [ 7526 0.25, 7527 1, 7528 0.5, 7529 1 7530 ], 7531 easeInOutQuart: [ 7532 0.76, 7533 0, 7534 0.24, 7535 1 7536 ], 7537 easeInQuint: [ 7538 0.64, 7539 0, 7540 0.78, 7541 0 7542 ], 7543 easeOutQuint: [ 7544 0.22, 7545 1, 7546 0.36, 7547 1 7548 ], 7549 easeInOutQuint: [ 7550 0.83, 7551 0, 7552 0.17, 7553 1 7554 ], 7555 easeInExpo: [ 7556 0.7, 7557 0, 7558 0.84, 7559 0 7560 ], 7561 easeOutExpo: [ 7562 0.16, 7563 1, 7564 0.3, 7565 1 7566 ], 7567 easeInOutExpo: [ 7568 0.87, 7569 0, 7570 0.13, 7571 1 7572 ], 7573 easeInCirc: [ 7574 0.55, 7575 0, 7576 1, 7577 0.45 7578 ], 7579 easeOutCirc: [ 7580 0, 7581 0.55, 7582 0.45, 7583 1 7584 ], 7585 easeInOutCirc: [ 7586 0.85, 7587 0, 7588 0.15, 7589 1 7590 ], 7591 easeInBack: [ 7592 0.36, 7593 0, 7594 0.66, 7595 -0.56 7596 ], 7597 easeOutBack: [ 7598 0.34, 7599 1.56, 7600 0.64, 7601 1 7602 ], 7603 easeInOutBack: [ 7604 0.68, 7605 -0.6, 7606 0.32, 7607 1.6 7608 ] 7609 }); 7610 function createEasingFunction([p0, p1, p2, p3]) { 7611 const a = (a1, a2) => 1 - 3 * a2 + 3 * a1; 7612 const b = (a1, a2) => 3 * a2 - 6 * a1; 7613 const c = (a1) => 3 * a1; 7614 const calcBezier = (t, a1, a2) => ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t; 7615 const getSlope = (t, a1, a2) => 3 * a(a1, a2) * t * t + 2 * b(a1, a2) * t + c(a1); 7616 const getTforX = (x) => { 7617 let aGuessT = x; 7618 for (let i = 0; i < 4; ++i) { 7619 const currentSlope = getSlope(aGuessT, p0, p2); 7620 if (currentSlope === 0) return aGuessT; 7621 const currentX = calcBezier(aGuessT, p0, p2) - x; 7622 aGuessT -= currentX / currentSlope; 7623 } 7624 return aGuessT; 7625 }; 7626 return (x) => p0 === p1 && p2 === p3 ? x : calcBezier(getTforX(x), p1, p3); 7627 } 7628 function lerp(a, b, alpha) { 7629 return a + alpha * (b - a); 7630 } 7631 function defaultInterpolation(a, b, t) { 7632 const aVal = toValue(a); 7633 const bVal = toValue(b); 7634 if (typeof aVal === "number" && typeof bVal === "number") return lerp(aVal, bVal, t); 7635 if (Array.isArray(aVal) && Array.isArray(bVal)) return aVal.map((v, i) => lerp(v, toValue(bVal[i]), t)); 7636 throw new TypeError("Unknown transition type, specify an interpolation function."); 7637 } 7638 function normalizeEasing(easing) { 7639 var _toValue; 7640 return typeof easing === "function" ? easing : (_toValue = toValue(easing)) !== null && _toValue !== void 0 ? _toValue : identity; 7641 } 7642 function transition(source, from, to, options = {}) { 7643 var _toValue2; 7644 const { window: window2 = defaultWindow } = options; 7645 const fromVal = toValue(from); 7646 const toVal = toValue(to); 7647 const duration = (_toValue2 = toValue(options.duration)) !== null && _toValue2 !== void 0 ? _toValue2 : 1e3; 7648 const startedAt = Date.now(); 7649 const endAt = Date.now() + duration; 7650 const interpolation = typeof options.interpolation === "function" ? options.interpolation : defaultInterpolation; 7651 const trans = typeof options.easing !== "undefined" ? normalizeEasing(options.easing) : normalizeEasing(options.transition); 7652 const ease = typeof trans === "function" ? trans : createEasingFunction(trans); 7653 return new Promise((resolve) => { 7654 source.value = fromVal; 7655 const tick = () => { 7656 var _options$abort; 7657 if ((_options$abort = options.abort) === null || _options$abort === void 0 ? void 0 : _options$abort.call(options)) { 7658 resolve(); 7659 return; 7660 } 7661 const now2 = Date.now(); 7662 source.value = interpolation(fromVal, toVal, ease((now2 - startedAt) / duration)); 7663 if (now2 < endAt) window2 === null || window2 === void 0 || window2.requestAnimationFrame(tick); 7664 else { 7665 source.value = toVal; 7666 resolve(); 7667 } 7668 }; 7669 tick(); 7670 }); 7671 } 7672 function executeTransition(source, from, to, options = {}) { 7673 return transition(source, from, to, options); 7674 } 7675 function useTransition(source, options = {}) { 7676 let currentId = 0; 7677 const sourceVal = () => { 7678 const v = toValue(source); 7679 return typeof options.interpolation === "undefined" && Array.isArray(v) ? v.map(toValue) : v; 7680 }; 7681 const outputRef = shallowRef(sourceVal()); 7682 watch(sourceVal, async (to) => { 7683 var _options$onStarted, _options$onFinished; 7684 if (toValue(options.disabled)) return; 7685 const id = ++currentId; 7686 if (options.delay) await promiseTimeout(toValue(options.delay)); 7687 if (id !== currentId) return; 7688 (_options$onStarted = options.onStarted) === null || _options$onStarted === void 0 || _options$onStarted.call(options); 7689 await transition(outputRef, outputRef.value, to, { 7690 ...options, 7691 abort: () => { 7692 var _options$abort2; 7693 return id !== currentId || ((_options$abort2 = options.abort) === null || _options$abort2 === void 0 ? void 0 : _options$abort2.call(options)); 7694 } 7695 }); 7696 (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 || _options$onFinished.call(options); 7697 }, { deep: true }); 7698 watch(() => toValue(options.disabled), (disabled) => { 7699 if (disabled) { 7700 currentId++; 7701 outputRef.value = sourceVal(); 7702 } 7703 }); 7704 tryOnScopeDispose(() => { 7705 currentId++; 7706 }); 7707 return computed(() => toValue(options.disabled) ? sourceVal() : outputRef.value); 7708 } 7709 function useUrlSearchParams(mode = "history", options = {}) { 7710 const { initialValue = {}, removeNullishValues = true, removeFalsyValues = false, write: enableWrite = true, writeMode = "replace", window: window2 = defaultWindow, stringify = (params) => params.toString() } = options; 7711 if (!window2) return reactive(initialValue); 7712 const state = reactive({}); 7713 function getRawParams() { 7714 if (mode === "history") return window2.location.search || ""; 7715 else if (mode === "hash") { 7716 const hash = window2.location.hash || ""; 7717 const index = hash.indexOf("?"); 7718 return index > 0 ? hash.slice(index) : ""; 7719 } else return (window2.location.hash || "").replace(/^#/, ""); 7720 } 7721 function constructQuery(params) { 7722 const stringified = stringify(params); 7723 if (mode === "history") return `${stringified ? `?${stringified}` : ""}${window2.location.hash || ""}`; 7724 if (mode === "hash-params") return `${window2.location.search || ""}${stringified ? `#${stringified}` : ""}`; 7725 const hash = window2.location.hash || "#"; 7726 const index = hash.indexOf("?"); 7727 if (index > 0) return `${window2.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`; 7728 return `${window2.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`; 7729 } 7730 function read() { 7731 return new URLSearchParams(getRawParams()); 7732 } 7733 function updateState(params) { 7734 const unusedKeys = new Set(Object.keys(state)); 7735 for (const key of params.keys()) { 7736 const paramsForKey = params.getAll(key); 7737 state[key] = paramsForKey.length > 1 ? paramsForKey : params.get(key) || ""; 7738 unusedKeys.delete(key); 7739 } 7740 Array.from(unusedKeys).forEach((key) => delete state[key]); 7741 } 7742 const { pause, resume } = watchPausable(state, () => { 7743 const params = new URLSearchParams(""); 7744 Object.keys(state).forEach((key) => { 7745 const mapEntry = state[key]; 7746 if (Array.isArray(mapEntry)) mapEntry.forEach((value) => params.append(key, value)); 7747 else if (removeNullishValues && mapEntry == null) params.delete(key); 7748 else if (removeFalsyValues && !mapEntry) params.delete(key); 7749 else params.set(key, mapEntry); 7750 }); 7751 write(params, false); 7752 }, { deep: true }); 7753 function write(params, shouldUpdate, shouldWriteHistory = true) { 7754 pause(); 7755 if (shouldUpdate) updateState(params); 7756 if (writeMode === "replace") window2.history.replaceState(window2.history.state, window2.document.title, window2.location.pathname + constructQuery(params)); 7757 else if (shouldWriteHistory) window2.history.pushState(window2.history.state, window2.document.title, window2.location.pathname + constructQuery(params)); 7758 nextTick(() => resume()); 7759 } 7760 function onChanged() { 7761 if (!enableWrite) return; 7762 write(read(), true, false); 7763 } 7764 const listenerOptions = { passive: true }; 7765 useEventListener(window2, "popstate", onChanged, listenerOptions); 7766 if (mode !== "history") useEventListener(window2, "hashchange", onChanged, listenerOptions); 7767 const initial = read(); 7768 if (initial.keys().next().value) updateState(initial); 7769 else Object.assign(state, initialValue); 7770 return state; 7771 } 7772 function useUserMedia(options = {}) { 7773 var _options$enabled, _options$autoSwitch; 7774 const enabled = shallowRef((_options$enabled = options.enabled) !== null && _options$enabled !== void 0 ? _options$enabled : false); 7775 const autoSwitch = shallowRef((_options$autoSwitch = options.autoSwitch) !== null && _options$autoSwitch !== void 0 ? _options$autoSwitch : true); 7776 const constraints = ref(options.constraints); 7777 const { navigator: navigator2 = defaultNavigator } = options; 7778 const isSupported = useSupported(() => { 7779 var _navigator$mediaDevic; 7780 return navigator2 === null || navigator2 === void 0 || (_navigator$mediaDevic = navigator2.mediaDevices) === null || _navigator$mediaDevic === void 0 ? void 0 : _navigator$mediaDevic.getUserMedia; 7781 }); 7782 const stream = shallowRef(); 7783 function getDeviceOptions(type) { 7784 switch (type) { 7785 case "video": 7786 if (constraints.value) return constraints.value.video || false; 7787 break; 7788 case "audio": 7789 if (constraints.value) return constraints.value.audio || false; 7790 break; 7791 } 7792 } 7793 async function _start() { 7794 if (!isSupported.value || stream.value) return; 7795 stream.value = await navigator2.mediaDevices.getUserMedia({ 7796 video: getDeviceOptions("video"), 7797 audio: getDeviceOptions("audio") 7798 }); 7799 return stream.value; 7800 } 7801 function _stop() { 7802 var _stream$value; 7803 (_stream$value = stream.value) === null || _stream$value === void 0 || _stream$value.getTracks().forEach((t) => t.stop()); 7804 stream.value = void 0; 7805 } 7806 function stop() { 7807 _stop(); 7808 enabled.value = false; 7809 } 7810 async function start() { 7811 await _start(); 7812 if (stream.value) enabled.value = true; 7813 return stream.value; 7814 } 7815 async function restart() { 7816 _stop(); 7817 return await start(); 7818 } 7819 watch(enabled, (v) => { 7820 if (v) _start(); 7821 else _stop(); 7822 }, { immediate: true }); 7823 watch(constraints, () => { 7824 if (autoSwitch.value && stream.value) restart(); 7825 }, { 7826 immediate: true, 7827 deep: true 7828 }); 7829 tryOnScopeDispose(() => { 7830 stop(); 7831 }); 7832 return { 7833 isSupported, 7834 stream, 7835 start, 7836 stop, 7837 restart, 7838 constraints, 7839 enabled, 7840 autoSwitch 7841 }; 7842 } 7843 function useVModel(props, key, emit, options = {}) { 7844 var _vm$$emit, _vm$proxy; 7845 const { clone = false, passive = false, eventName, deep = false, defaultValue, shouldEmit } = options; 7846 const vm = getCurrentInstance(); 7847 const _emit = emit || (vm === null || vm === void 0 ? void 0 : vm.emit) || (vm === null || vm === void 0 || (_vm$$emit = vm.$emit) === null || _vm$$emit === void 0 ? void 0 : _vm$$emit.bind(vm)) || (vm === null || vm === void 0 || (_vm$proxy = vm.proxy) === null || _vm$proxy === void 0 || (_vm$proxy = _vm$proxy.$emit) === null || _vm$proxy === void 0 ? void 0 : _vm$proxy.bind(vm === null || vm === void 0 ? void 0 : vm.proxy)); 7848 let event = eventName; 7849 if (!key) key = "modelValue"; 7850 event = event || `update:${key.toString()}`; 7851 const cloneFn = (val) => !clone ? val : typeof clone === "function" ? clone(val) : cloneFnJSON(val); 7852 const getValue2 = () => isDef(props[key]) ? cloneFn(props[key]) : defaultValue; 7853 const triggerEmit = (value) => { 7854 if (shouldEmit) { 7855 if (shouldEmit(value)) _emit(event, value); 7856 } else _emit(event, value); 7857 }; 7858 if (passive) { 7859 const proxy = ref(getValue2()); 7860 let isUpdating = false; 7861 watch(() => props[key], (v) => { 7862 if (!isUpdating) { 7863 isUpdating = true; 7864 proxy.value = cloneFn(v); 7865 nextTick(() => isUpdating = false); 7866 } 7867 }); 7868 watch(proxy, (v) => { 7869 if (!isUpdating && (v !== props[key] || deep)) triggerEmit(v); 7870 }, { deep }); 7871 return proxy; 7872 } else return computed({ 7873 get() { 7874 return getValue2(); 7875 }, 7876 set(value) { 7877 triggerEmit(value); 7878 } 7879 }); 7880 } 7881 function useVModels(props, emit, options = {}) { 7882 const ret = {}; 7883 for (const key in props) ret[key] = useVModel(props, key, emit, options); 7884 return ret; 7885 } 7886 function getDefaultScheduler$1(options = { interval: 0 }) { 7887 const { interval } = options; 7888 if (interval === 0) return; 7889 return (fn) => useIntervalFn(fn, interval, { 7890 immediate: false, 7891 immediateCallback: false 7892 }); 7893 } 7894 function useVibrate(options) { 7895 const { pattern = [], scheduler = getDefaultScheduler$1(options), navigator: navigator2 = defaultNavigator } = options || {}; 7896 const isSupported = useSupported(() => typeof navigator2 !== "undefined" && "vibrate" in navigator2); 7897 const patternRef = toRef2(pattern); 7898 const vibrate = (pattern2 = patternRef.value) => { 7899 if (isSupported.value) navigator2.vibrate(pattern2); 7900 }; 7901 const intervalControls = scheduler === null || scheduler === void 0 ? void 0 : scheduler(vibrate); 7902 const stop = () => { 7903 if (isSupported.value) navigator2.vibrate(0); 7904 intervalControls === null || intervalControls === void 0 || intervalControls.pause(); 7905 }; 7906 return { 7907 isSupported, 7908 pattern, 7909 intervalControls, 7910 vibrate, 7911 stop 7912 }; 7913 } 7914 function useVirtualList(list, options) { 7915 const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list); 7916 return { 7917 list: currentList, 7918 scrollTo, 7919 containerProps: { 7920 ref: containerRef, 7921 onScroll: () => { 7922 calculateRange(); 7923 }, 7924 style: containerStyle 7925 }, 7926 wrapperProps 7927 }; 7928 } 7929 function useVirtualListResources(list) { 7930 const containerRef = shallowRef(null); 7931 const size = useElementSize(containerRef); 7932 const currentList = ref([]); 7933 const source = shallowRef(list); 7934 return { 7935 state: ref({ 7936 start: 0, 7937 end: 10 7938 }), 7939 source, 7940 currentList, 7941 size, 7942 containerRef 7943 }; 7944 } 7945 function createGetViewCapacity(state, source, itemSize) { 7946 return (containerSize) => { 7947 if (typeof itemSize === "number") return Math.ceil(containerSize / itemSize); 7948 const { start = 0 } = state.value; 7949 let sum = 0; 7950 let capacity = 0; 7951 for (let i = start; i < source.value.length; i++) { 7952 const size = itemSize(i); 7953 sum += size; 7954 capacity = i; 7955 if (sum > containerSize) break; 7956 } 7957 return capacity - start; 7958 }; 7959 } 7960 function createGetOffset(source, itemSize) { 7961 return (scrollDirection) => { 7962 if (typeof itemSize === "number") return Math.floor(scrollDirection / itemSize) + 1; 7963 let sum = 0; 7964 let offset = 0; 7965 for (let i = 0; i < source.value.length; i++) { 7966 const size = itemSize(i); 7967 sum += size; 7968 if (sum >= scrollDirection) { 7969 offset = i; 7970 break; 7971 } 7972 } 7973 return offset + 1; 7974 }; 7975 } 7976 function createCalculateRange(type, overscan, getOffset, getViewCapacity, { containerRef, state, currentList, source }) { 7977 return () => { 7978 const element = containerRef.value; 7979 if (element) { 7980 const offset = getOffset(type === "vertical" ? element.scrollTop : element.scrollLeft); 7981 const viewCapacity = getViewCapacity(type === "vertical" ? element.clientHeight : element.clientWidth); 7982 const from = offset - overscan; 7983 const to = offset + viewCapacity + overscan; 7984 state.value = { 7985 start: from < 0 ? 0 : from, 7986 end: to > source.value.length ? source.value.length : to 7987 }; 7988 currentList.value = source.value.slice(state.value.start, state.value.end).map((ele, index) => ({ 7989 data: ele, 7990 index: index + state.value.start 7991 })); 7992 } 7993 }; 7994 } 7995 function createGetDistance(itemSize, source) { 7996 return (index) => { 7997 if (typeof itemSize === "number") return index * itemSize; 7998 return source.value.slice(0, index).reduce((sum, _, i) => sum + itemSize(i), 0); 7999 }; 8000 } 8001 function useWatchForSizes(size, listRef, containerRef, calculateRange) { 8002 watch([ 8003 size.width, 8004 size.height, 8005 listRef, 8006 containerRef 8007 ], () => { 8008 calculateRange(); 8009 }); 8010 } 8011 function createComputedTotalSize(itemSize, source) { 8012 return computed(() => { 8013 if (typeof itemSize === "number") return source.value.length * itemSize; 8014 return source.value.reduce((sum, _, index) => sum + itemSize(index), 0); 8015 }); 8016 } 8017 var scrollToDictionaryForElementScrollKey = { 8018 horizontal: "scrollLeft", 8019 vertical: "scrollTop" 8020 }; 8021 function createScrollTo(type, calculateRange, getDistance, containerRef) { 8022 return (index) => { 8023 if (containerRef.value) { 8024 containerRef.value[scrollToDictionaryForElementScrollKey[type]] = getDistance(index); 8025 calculateRange(); 8026 } 8027 }; 8028 } 8029 function useHorizontalVirtualList(options, list) { 8030 const resources = useVirtualListResources(list); 8031 const { state, source, currentList, size, containerRef } = resources; 8032 const containerStyle = { overflowX: "auto" }; 8033 const { itemWidth, overscan = 5 } = options; 8034 const getViewCapacity = createGetViewCapacity(state, source, itemWidth); 8035 const calculateRange = createCalculateRange("horizontal", overscan, createGetOffset(source, itemWidth), getViewCapacity, resources); 8036 const getDistanceLeft = createGetDistance(itemWidth, source); 8037 const offsetLeft = computed(() => getDistanceLeft(state.value.start)); 8038 const totalWidth = createComputedTotalSize(itemWidth, source); 8039 useWatchForSizes(size, source, containerRef, calculateRange); 8040 return { 8041 scrollTo: createScrollTo("horizontal", calculateRange, getDistanceLeft, containerRef), 8042 calculateRange, 8043 wrapperProps: computed(() => { 8044 return { style: { 8045 height: "100%", 8046 width: `${totalWidth.value - offsetLeft.value}px`, 8047 marginLeft: `${offsetLeft.value}px`, 8048 display: "flex" 8049 } }; 8050 }), 8051 containerStyle, 8052 currentList, 8053 containerRef 8054 }; 8055 } 8056 function useVerticalVirtualList(options, list) { 8057 const resources = useVirtualListResources(list); 8058 const { state, source, currentList, size, containerRef } = resources; 8059 const containerStyle = { overflowY: "auto" }; 8060 const { itemHeight, overscan = 5 } = options; 8061 const getViewCapacity = createGetViewCapacity(state, source, itemHeight); 8062 const calculateRange = createCalculateRange("vertical", overscan, createGetOffset(source, itemHeight), getViewCapacity, resources); 8063 const getDistanceTop = createGetDistance(itemHeight, source); 8064 const offsetTop = computed(() => getDistanceTop(state.value.start)); 8065 const totalHeight = createComputedTotalSize(itemHeight, source); 8066 useWatchForSizes(size, source, containerRef, calculateRange); 8067 return { 8068 calculateRange, 8069 scrollTo: createScrollTo("vertical", calculateRange, getDistanceTop, containerRef), 8070 containerStyle, 8071 wrapperProps: computed(() => { 8072 return { style: { 8073 width: "100%", 8074 height: `${totalHeight.value - offsetTop.value}px`, 8075 marginTop: `${offsetTop.value}px` 8076 } }; 8077 }), 8078 currentList, 8079 containerRef 8080 }; 8081 } 8082 function useWakeLock(options = {}) { 8083 const { navigator: navigator2 = defaultNavigator, document: document2 = defaultDocument } = options; 8084 const requestedType = shallowRef(false); 8085 const sentinel = shallowRef(null); 8086 const documentVisibility = useDocumentVisibility({ document: document2 }); 8087 const isSupported = useSupported(() => navigator2 && "wakeLock" in navigator2); 8088 const isActive = computed(() => !!sentinel.value && documentVisibility.value === "visible"); 8089 if (isSupported.value) { 8090 useEventListener(sentinel, "release", () => { 8091 var _sentinel$value$type, _sentinel$value; 8092 requestedType.value = (_sentinel$value$type = (_sentinel$value = sentinel.value) === null || _sentinel$value === void 0 ? void 0 : _sentinel$value.type) !== null && _sentinel$value$type !== void 0 ? _sentinel$value$type : false; 8093 }, { passive: true }); 8094 whenever(() => documentVisibility.value === "visible" && (document2 === null || document2 === void 0 ? void 0 : document2.visibilityState) === "visible" && requestedType.value, (type) => { 8095 requestedType.value = false; 8096 forceRequest(type); 8097 }); 8098 } 8099 async function forceRequest(type) { 8100 var _sentinel$value2; 8101 await ((_sentinel$value2 = sentinel.value) === null || _sentinel$value2 === void 0 ? void 0 : _sentinel$value2.release()); 8102 sentinel.value = isSupported.value ? await navigator2.wakeLock.request(type) : null; 8103 } 8104 async function request(type) { 8105 if (documentVisibility.value === "visible") await forceRequest(type); 8106 else requestedType.value = type; 8107 } 8108 async function release() { 8109 requestedType.value = false; 8110 const s = sentinel.value; 8111 sentinel.value = null; 8112 await (s === null || s === void 0 ? void 0 : s.release()); 8113 } 8114 tryOnScopeDispose(() => { 8115 release(); 8116 }); 8117 return { 8118 sentinel, 8119 isSupported, 8120 isActive, 8121 request, 8122 forceRequest, 8123 release 8124 }; 8125 } 8126 function useWebNotification(options = {}) { 8127 const { window: window2 = defaultWindow, requestPermissions: _requestForPermissions = true } = options; 8128 const defaultWebNotificationOptions = options; 8129 const isSupported = useSupported(() => { 8130 if (!window2 || !("Notification" in window2)) return false; 8131 if (Notification.permission === "granted") return true; 8132 try { 8133 const notification2 = new Notification(""); 8134 notification2.onshow = () => { 8135 notification2.close(); 8136 }; 8137 } catch (e) { 8138 if (e.name === "TypeError") return false; 8139 } 8140 return true; 8141 }); 8142 const permissionGranted = shallowRef(isSupported.value && "permission" in Notification && Notification.permission === "granted"); 8143 const notification = shallowRef(null); 8144 const ensurePermissions = async () => { 8145 if (!isSupported.value) return; 8146 if (!permissionGranted.value && Notification.permission !== "denied") { 8147 if (await Notification.requestPermission() === "granted") permissionGranted.value = true; 8148 } 8149 return permissionGranted.value; 8150 }; 8151 const { on: onClick, trigger: clickTrigger } = createEventHook(); 8152 const { on: onShow, trigger: showTrigger } = createEventHook(); 8153 const { on: onError, trigger: errorTrigger } = createEventHook(); 8154 const { on: onClose, trigger: closeTrigger } = createEventHook(); 8155 const show = async (overrides) => { 8156 if (!isSupported.value || !permissionGranted.value) return; 8157 const options2 = Object.assign({}, defaultWebNotificationOptions, overrides); 8158 notification.value = new Notification(options2.title || "", options2); 8159 notification.value.onclick = clickTrigger; 8160 notification.value.onshow = showTrigger; 8161 notification.value.onerror = errorTrigger; 8162 notification.value.onclose = closeTrigger; 8163 return notification.value; 8164 }; 8165 const close = () => { 8166 if (notification.value) notification.value.close(); 8167 notification.value = null; 8168 }; 8169 if (_requestForPermissions) tryOnMounted(ensurePermissions); 8170 tryOnScopeDispose(close); 8171 if (isSupported.value && window2) { 8172 const document2 = window2.document; 8173 useEventListener(document2, "visibilitychange", (e) => { 8174 e.preventDefault(); 8175 if (document2.visibilityState === "visible") close(); 8176 }); 8177 } 8178 return { 8179 isSupported, 8180 notification, 8181 ensurePermissions, 8182 permissionGranted, 8183 show, 8184 close, 8185 onClick, 8186 onShow, 8187 onError, 8188 onClose 8189 }; 8190 } 8191 var DEFAULT_PING_MESSAGE = "ping"; 8192 function resolveNestedOptions(options) { 8193 if (options === true) return {}; 8194 return options; 8195 } 8196 function getDefaultScheduler(options) { 8197 if ("interval" in options) { 8198 const { interval = 1e3 } = options; 8199 return (cb) => useIntervalFn(cb, interval, { immediate: false }); 8200 } 8201 return (cb) => useIntervalFn(cb, 1e3, { immediate: false }); 8202 } 8203 function useWebSocket(url, options = {}) { 8204 const { onConnected, onDisconnected, onError, onMessage, immediate = true, autoConnect = true, autoClose = true, protocols = [] } = options; 8205 const data = shallowRef(null); 8206 const status = shallowRef("CLOSED"); 8207 const wsRef = shallowRef(); 8208 const urlRef = toRef2(url); 8209 let heartbeatPause; 8210 let heartbeatResume; 8211 let explicitlyClosed = false; 8212 let retried = 0; 8213 let bufferedData = []; 8214 let retryTimeout; 8215 let pongTimeoutWait; 8216 const _sendBuffer = () => { 8217 if (bufferedData.length && wsRef.value && status.value === "OPEN") { 8218 for (const buffer of bufferedData) wsRef.value.send(buffer); 8219 bufferedData = []; 8220 } 8221 }; 8222 const resetRetry = () => { 8223 if (retryTimeout != null) { 8224 clearTimeout(retryTimeout); 8225 retryTimeout = void 0; 8226 } 8227 }; 8228 const resetHeartbeat = () => { 8229 clearTimeout(pongTimeoutWait); 8230 pongTimeoutWait = void 0; 8231 }; 8232 const close = (code = 1e3, reason) => { 8233 resetRetry(); 8234 if (!isClient && !isWorker || !wsRef.value) return; 8235 explicitlyClosed = true; 8236 resetHeartbeat(); 8237 heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause(); 8238 wsRef.value.close(code, reason); 8239 wsRef.value = void 0; 8240 }; 8241 const send = (data2, useBuffer = true) => { 8242 if (!wsRef.value || status.value !== "OPEN") { 8243 if (useBuffer) bufferedData.push(data2); 8244 return false; 8245 } 8246 _sendBuffer(); 8247 wsRef.value.send(data2); 8248 return true; 8249 }; 8250 const _init = () => { 8251 if (explicitlyClosed || typeof urlRef.value === "undefined") return; 8252 const ws = new WebSocket(urlRef.value, protocols); 8253 wsRef.value = ws; 8254 status.value = "CONNECTING"; 8255 ws.onopen = () => { 8256 if (wsRef.value !== ws) return; 8257 status.value = "OPEN"; 8258 retried = 0; 8259 onConnected === null || onConnected === void 0 || onConnected(ws); 8260 heartbeatResume === null || heartbeatResume === void 0 || heartbeatResume(); 8261 _sendBuffer(); 8262 }; 8263 ws.onclose = (ev) => { 8264 if (wsRef.value === ws) status.value = "CLOSED"; 8265 resetHeartbeat(); 8266 heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause(); 8267 onDisconnected === null || onDisconnected === void 0 || onDisconnected(ws, ev); 8268 if (!explicitlyClosed && options.autoReconnect && (wsRef.value == null || ws === wsRef.value)) { 8269 const { retries = -1, delay = 1e3, onFailed } = resolveNestedOptions(options.autoReconnect); 8270 if ((typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries))(retried)) { 8271 retried += 1; 8272 const delayTime = typeof delay === "function" ? delay(retried) : delay; 8273 retryTimeout = setTimeout(_init, delayTime); 8274 } else onFailed === null || onFailed === void 0 || onFailed(); 8275 } 8276 }; 8277 ws.onerror = (e) => { 8278 onError === null || onError === void 0 || onError(ws, e); 8279 }; 8280 ws.onmessage = (e) => { 8281 if (options.heartbeat) { 8282 resetHeartbeat(); 8283 const { message = DEFAULT_PING_MESSAGE, responseMessage = message } = resolveNestedOptions(options.heartbeat); 8284 if (e.data === toValue(responseMessage)) return; 8285 } 8286 data.value = e.data; 8287 onMessage === null || onMessage === void 0 || onMessage(ws, e); 8288 }; 8289 }; 8290 if (options.heartbeat) { 8291 const { message = DEFAULT_PING_MESSAGE, scheduler = getDefaultScheduler(resolveNestedOptions(options.heartbeat)), pongTimeout = 1e3 } = resolveNestedOptions(options.heartbeat); 8292 const { pause, resume } = scheduler(() => { 8293 send(toValue(message), false); 8294 if (pongTimeoutWait != null) return; 8295 pongTimeoutWait = setTimeout(() => { 8296 close(); 8297 explicitlyClosed = false; 8298 }, pongTimeout); 8299 }); 8300 heartbeatPause = pause; 8301 heartbeatResume = resume; 8302 } 8303 if (autoClose) { 8304 if (isClient) useEventListener("beforeunload", () => close(), { passive: true }); 8305 tryOnScopeDispose(close); 8306 } 8307 const open = () => { 8308 if (!isClient && !isWorker) return; 8309 close(); 8310 explicitlyClosed = false; 8311 retried = 0; 8312 _init(); 8313 }; 8314 if (immediate) open(); 8315 if (autoConnect) watch(urlRef, open); 8316 return { 8317 data, 8318 status, 8319 close, 8320 send, 8321 open, 8322 ws: wsRef 8323 }; 8324 } 8325 function useWebWorker(arg0, workerOptions, options) { 8326 const { window: window2 = defaultWindow } = options !== null && options !== void 0 ? options : {}; 8327 const data = shallowRef(null); 8328 const worker = shallowRef(); 8329 const post = (...args) => { 8330 if (!worker.value) return; 8331 worker.value.postMessage(...args); 8332 }; 8333 const terminate = function terminate2() { 8334 if (!worker.value) return; 8335 worker.value.terminate(); 8336 }; 8337 if (window2) { 8338 if (typeof arg0 === "string") worker.value = new Worker(arg0, workerOptions); 8339 else if (typeof arg0 === "function") worker.value = arg0(); 8340 else worker.value = arg0; 8341 worker.value.onmessage = (e) => { 8342 data.value = e.data; 8343 }; 8344 tryOnScopeDispose(() => { 8345 if (worker.value) worker.value.terminate(); 8346 }); 8347 } 8348 return { 8349 data, 8350 post, 8351 terminate, 8352 worker 8353 }; 8354 } 8355 function depsParser(deps, localDeps) { 8356 if (deps.length === 0 && localDeps.length === 0) return ""; 8357 const depsString = deps.map((dep) => `'${dep}'`).toString(); 8358 const depsFunctionString = localDeps.filter((dep) => typeof dep === "function").map((fn) => { 8359 const str = fn.toString(); 8360 if (str.trim().startsWith("function")) return str; 8361 else return `const ${fn.name} = ${str}`; 8362 }).join(";"); 8363 const importString = `importScripts(${depsString});`; 8364 return `${depsString.trim() === "" ? "" : importString} ${depsFunctionString}`; 8365 } 8366 function jobRunner(userFunc) { 8367 return (e) => { 8368 const userFuncArgs = e.data[0]; 8369 return Promise.resolve(userFunc.apply(void 0, userFuncArgs)).then((result) => { 8370 postMessage(["SUCCESS", result]); 8371 }).catch((error) => { 8372 postMessage(["ERROR", error]); 8373 }); 8374 }; 8375 } 8376 function createWorkerBlobUrl(fn, deps, localDeps) { 8377 const blobCode = `${depsParser(deps, localDeps)}; onmessage=(${jobRunner})(${fn})`; 8378 const blob = new Blob([blobCode], { type: "text/javascript" }); 8379 return URL.createObjectURL(blob); 8380 } 8381 function useWebWorkerFn(fn, options = {}) { 8382 const { dependencies = [], localDependencies = [], timeout, window: window2 = defaultWindow } = options; 8383 let worker; 8384 const workerStatus = shallowRef("PENDING"); 8385 const promise = shallowRef({}); 8386 const timeoutId = shallowRef(); 8387 const workerTerminate = (status = "PENDING") => { 8388 if (worker && worker._url && window2) { 8389 worker.terminate(); 8390 URL.revokeObjectURL(worker._url); 8391 promise.value = {}; 8392 worker = void 0; 8393 window2.clearTimeout(timeoutId.value); 8394 workerStatus.value = status; 8395 } 8396 }; 8397 workerTerminate(); 8398 tryOnScopeDispose(workerTerminate); 8399 const generateWorker = () => { 8400 const blobUrl = createWorkerBlobUrl(fn, dependencies, localDependencies); 8401 const newWorker = new Worker(blobUrl); 8402 newWorker._url = blobUrl; 8403 newWorker.onmessage = (e) => { 8404 const { resolve = () => { 8405 }, reject = () => { 8406 } } = promise.value; 8407 const [status, result] = e.data; 8408 switch (status) { 8409 case "SUCCESS": 8410 resolve(result); 8411 workerTerminate(status); 8412 break; 8413 default: 8414 reject(result); 8415 workerTerminate("ERROR"); 8416 break; 8417 } 8418 }; 8419 newWorker.onerror = (e) => { 8420 const { reject = () => { 8421 } } = promise.value; 8422 e.preventDefault(); 8423 reject(e); 8424 workerTerminate("ERROR"); 8425 }; 8426 if (timeout) timeoutId.value = setTimeout(workerTerminate, timeout, "TIMEOUT_EXPIRED"); 8427 return newWorker; 8428 }; 8429 const callWorker = (...fnArgs) => new Promise((resolve, reject) => { 8430 promise.value = { 8431 resolve, 8432 reject 8433 }; 8434 worker === null || worker === void 0 || worker.postMessage([[...fnArgs]]); 8435 workerStatus.value = "RUNNING"; 8436 }); 8437 const workerFn = (...fnArgs) => { 8438 if (workerStatus.value === "RUNNING") { 8439 console.error("[useWebWorkerFn] You can only run one instance of the worker at a time."); 8440 return Promise.reject(); 8441 } 8442 worker = generateWorker(); 8443 return callWorker(...fnArgs); 8444 }; 8445 return { 8446 workerFn, 8447 workerStatus, 8448 workerTerminate 8449 }; 8450 } 8451 function useWindowFocus(options = {}) { 8452 const { window: window2 = defaultWindow } = options; 8453 if (!window2) return shallowRef(false); 8454 const focused = shallowRef(window2.document.hasFocus()); 8455 const listenerOptions = { passive: true }; 8456 useEventListener(window2, "blur", () => { 8457 focused.value = false; 8458 }, listenerOptions); 8459 useEventListener(window2, "focus", () => { 8460 focused.value = true; 8461 }, listenerOptions); 8462 return focused; 8463 } 8464 function useWindowScroll(options = {}) { 8465 const { window: window2 = defaultWindow, ...rest } = options; 8466 return useScroll(window2, rest); 8467 } 8468 function useWindowSize(options = {}) { 8469 const { window: window2 = defaultWindow, initialWidth = Number.POSITIVE_INFINITY, initialHeight = Number.POSITIVE_INFINITY, listenOrientation = true, includeScrollbar = true, type = "inner" } = options; 8470 const width = shallowRef(initialWidth); 8471 const height = shallowRef(initialHeight); 8472 const update = () => { 8473 if (window2) if (type === "outer") { 8474 width.value = window2.outerWidth; 8475 height.value = window2.outerHeight; 8476 } else if (type === "visual" && window2.visualViewport) { 8477 const { width: visualViewportWidth, height: visualViewportHeight, scale } = window2.visualViewport; 8478 width.value = Math.round(visualViewportWidth * scale); 8479 height.value = Math.round(visualViewportHeight * scale); 8480 } else if (includeScrollbar) { 8481 width.value = window2.innerWidth; 8482 height.value = window2.innerHeight; 8483 } else { 8484 width.value = window2.document.documentElement.clientWidth; 8485 height.value = window2.document.documentElement.clientHeight; 8486 } 8487 }; 8488 update(); 8489 tryOnMounted(update); 8490 const listenerOptions = { passive: true }; 8491 useEventListener("resize", update, listenerOptions); 8492 if (window2 && type === "visual" && window2.visualViewport) useEventListener(window2.visualViewport, "resize", update, listenerOptions); 8493 if (listenOrientation) watch(useMediaQuery("(orientation: portrait)"), () => update()); 8494 return { 8495 width, 8496 height 8497 }; 8498 } 8499 export { 8500 DefaultMagicKeysAliasMap, 8501 StorageSerializers, 8502 TransitionPresets, 8503 assert, 8504 asyncComputed, 8505 autoResetRef, 8506 breakpointsAntDesign, 8507 breakpointsBootstrapV5, 8508 breakpointsElement, 8509 breakpointsMasterCss, 8510 breakpointsPrimeFlex, 8511 breakpointsQuasar, 8512 breakpointsSematic, 8513 breakpointsTailwind, 8514 breakpointsVuetify, 8515 breakpointsVuetifyV2, 8516 breakpointsVuetifyV3, 8517 bypassFilter, 8518 camelize, 8519 clamp, 8520 cloneFnJSON, 8521 computedAsync, 8522 computedEager, 8523 computedInject, 8524 computedWithControl, 8525 containsProp, 8526 controlledComputed, 8527 controlledRef, 8528 createDisposableDirective, 8529 createEventHook, 8530 createFetch, 8531 createFilterWrapper, 8532 createGlobalState, 8533 createInjectionState, 8534 createReactiveFn, 8535 createRef, 8536 createReusableTemplate, 8537 createSharedComposable, 8538 createSingletonPromise, 8539 createTemplatePromise, 8540 createUnrefFn, 8541 customStorageEventName, 8542 debounceFilter, 8543 debouncedRef, 8544 debouncedWatch, 8545 defaultDocument, 8546 defaultLocation, 8547 defaultNavigator, 8548 defaultWindow, 8549 eagerComputed, 8550 executeTransition, 8551 extendRef, 8552 formatDate, 8553 formatTimeAgo, 8554 formatTimeAgoIntl, 8555 formatTimeAgoIntlParts, 8556 get, 8557 getLifeCycleTarget, 8558 getSSRHandler, 8559 hasOwn, 8560 hyphenate, 8561 identity, 8562 ignorableWatch, 8563 increaseWithUnit, 8564 injectLocal, 8565 invoke, 8566 isClient, 8567 isDef, 8568 isDefined, 8569 isIOS, 8570 isObject, 8571 isWorker, 8572 makeDestructurable, 8573 mapGamepadToXbox360Controller, 8574 noop, 8575 normalizeDate, 8576 notNullish, 8577 now, 8578 objectEntries, 8579 objectOmit, 8580 objectPick, 8581 onClickOutside, 8582 onElementRemoval, 8583 onKeyDown, 8584 onKeyPressed, 8585 onKeyStroke, 8586 onKeyUp, 8587 onLongPress, 8588 onStartTyping, 8589 pausableFilter, 8590 pausableWatch, 8591 promiseTimeout, 8592 provideLocal, 8593 provideSSRWidth, 8594 pxValue, 8595 rand, 8596 reactify, 8597 reactifyObject, 8598 reactiveComputed, 8599 reactiveOmit, 8600 reactivePick, 8601 refAutoReset, 8602 refDebounced, 8603 refDefault, 8604 refManualReset, 8605 refThrottled, 8606 refWithControl, 8607 set, 8608 setSSRHandler, 8609 syncRef, 8610 syncRefs, 8611 templateRef, 8612 throttleFilter, 8613 throttledRef, 8614 throttledWatch, 8615 timestamp, 8616 toArray, 8617 toReactive, 8618 toRef2 as toRef, 8619 toRefs2 as toRefs, 8620 transition, 8621 tryOnBeforeMount, 8622 tryOnBeforeUnmount, 8623 tryOnMounted, 8624 tryOnScopeDispose, 8625 tryOnUnmounted, 8626 unrefElement, 8627 until, 8628 useActiveElement, 8629 useAnimate, 8630 useArrayDifference, 8631 useArrayEvery, 8632 useArrayFilter, 8633 useArrayFind, 8634 useArrayFindIndex, 8635 useArrayFindLast, 8636 useArrayIncludes, 8637 useArrayJoin, 8638 useArrayMap, 8639 useArrayReduce, 8640 useArraySome, 8641 useArrayUnique, 8642 useAsyncQueue, 8643 useAsyncState, 8644 useBase64, 8645 useBattery, 8646 useBluetooth, 8647 useBreakpoints, 8648 useBroadcastChannel, 8649 useBrowserLocation, 8650 useCached, 8651 useClipboard, 8652 useClipboardItems, 8653 useCloned, 8654 useColorMode, 8655 useConfirmDialog, 8656 useCountdown, 8657 useCounter, 8658 useCssSupports, 8659 useCssVar, 8660 useCurrentElement, 8661 useCycleList, 8662 useDark, 8663 useDateFormat, 8664 useDebounce, 8665 useDebounceFn, 8666 useDebouncedRefHistory, 8667 useDeviceMotion, 8668 useDeviceOrientation, 8669 useDevicePixelRatio, 8670 useDevicesList, 8671 useDisplayMedia, 8672 useDocumentVisibility, 8673 useDraggable, 8674 useDropZone, 8675 useElementBounding, 8676 useElementByPoint, 8677 useElementHover, 8678 useElementSize, 8679 useElementVisibility, 8680 useEventBus, 8681 useEventListener, 8682 useEventSource, 8683 useEyeDropper, 8684 useFavicon, 8685 useFetch, 8686 useFileDialog, 8687 useFileSystemAccess, 8688 useFocus, 8689 useFocusWithin, 8690 useFps, 8691 useFullscreen, 8692 useGamepad, 8693 useGeolocation, 8694 useIdle, 8695 useImage, 8696 useInfiniteScroll, 8697 useIntersectionObserver, 8698 useInterval, 8699 useIntervalFn, 8700 useKeyModifier, 8701 useLastChanged, 8702 useLocalStorage, 8703 useMagicKeys, 8704 useManualRefHistory, 8705 useMediaControls, 8706 useMediaQuery, 8707 useMemoize, 8708 useMemory, 8709 useMounted, 8710 useMouse, 8711 useMouseInElement, 8712 useMousePressed, 8713 useMutationObserver, 8714 useNavigatorLanguage, 8715 useNetwork, 8716 useNow, 8717 useObjectUrl, 8718 useOffsetPagination, 8719 useOnline, 8720 usePageLeave, 8721 useParallax, 8722 useParentElement, 8723 usePerformanceObserver, 8724 usePermission, 8725 usePointer, 8726 usePointerLock, 8727 usePointerSwipe, 8728 usePreferredColorScheme, 8729 usePreferredContrast, 8730 usePreferredDark, 8731 usePreferredLanguages, 8732 usePreferredReducedMotion, 8733 usePreferredReducedTransparency, 8734 usePrevious, 8735 useRafFn, 8736 useRefHistory, 8737 useResizeObserver, 8738 useSSRWidth, 8739 useScreenOrientation, 8740 useScreenSafeArea, 8741 useScriptTag, 8742 useScroll, 8743 useScrollLock, 8744 useSessionStorage, 8745 useShare, 8746 useSorted, 8747 useSpeechRecognition, 8748 useSpeechSynthesis, 8749 useStepper, 8750 useStorage, 8751 useStorageAsync, 8752 useStyleTag, 8753 useSupported, 8754 useSwipe, 8755 useTemplateRefsList, 8756 useTextDirection, 8757 useTextSelection, 8758 useTextareaAutosize, 8759 useThrottle, 8760 useThrottleFn, 8761 useThrottledRefHistory, 8762 useTimeAgo, 8763 useTimeAgoIntl, 8764 useTimeout, 8765 useTimeoutFn, 8766 useTimeoutPoll, 8767 useTimestamp, 8768 useTitle, 8769 useToNumber, 8770 useToString, 8771 useToggle, 8772 useTransition, 8773 useUrlSearchParams, 8774 useUserMedia, 8775 useVModel, 8776 useVModels, 8777 useVibrate, 8778 useVirtualList, 8779 useWakeLock, 8780 useWebNotification, 8781 useWebSocket, 8782 useWebWorker, 8783 useWebWorkerFn, 8784 useWindowFocus, 8785 useWindowScroll, 8786 useWindowSize, 8787 watchArray, 8788 watchAtMost, 8789 watchDebounced, 8790 watchDeep, 8791 watchIgnorable, 8792 watchImmediate, 8793 watchOnce, 8794 watchPausable, 8795 watchThrottled, 8796 watchTriggerable, 8797 watchWithFilter, 8798 whenever 8799 }; 8800 //# sourceMappingURL=vitepress___@vueuse_core.js.map