@halo-dev/components 0.0.0-alpha.1 → 0.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
- import { openBlock, createElementBlock, createElementVNode, defineComponent, computed, normalizeClass, unref, renderSlot, createBlock, resolveDynamicComponent, toDisplayString, createVNode, createCommentVNode, createTextVNode, Fragment, renderList, provide, useSlots, ref, inject, withModifiers, Transition, withCtx, withDirectives, vShow, Teleport, withKeys, normalizeStyle, watch, isRef, reactive } from "vue";
17
+ import { openBlock, createElementBlock, createElementVNode, defineComponent, computed, normalizeClass, unref, renderSlot, createBlock, resolveDynamicComponent, toDisplayString, createVNode, createCommentVNode, createTextVNode, Fragment, renderList, provide, useSlots, ref, inject, withModifiers, Transition, withCtx, withDirectives, vShow, Teleport, withKeys, normalizeStyle, isRef, toRefs as toRefs$1, customRef, getCurrentScope, onScopeDispose, watch, getCurrentInstance, onBeforeMount, nextTick, onMounted, readonly, shallowRef, reactive, h, toRef } from "vue";
18
18
  import { useRouter, useRoute } from "vue-router";
19
19
  var tailwind = "";
20
20
  const _hoisted_1$$ = {
@@ -798,7 +798,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
798
798
  };
799
799
  }
800
800
  });
801
- var Alert = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-3bf3a1a9"]]);
801
+ var Alert = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-bb026962"]]);
802
802
  var Button_vue_vue_type_style_index_0_lang = "";
803
803
  const _hoisted_1$l = ["disabled"];
804
804
  const _hoisted_2$e = {
@@ -829,7 +829,7 @@ const _hoisted_6$2 = [
829
829
  _hoisted_4$8,
830
830
  _hoisted_5$3
831
831
  ];
832
- const _hoisted_7$1 = { class: "btn-content" };
832
+ const _hoisted_7$2 = { class: "btn-content" };
833
833
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
834
834
  __name: "Button",
835
835
  props: {
@@ -891,7 +891,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
891
891
  _ctx.$slots.icon || __props.loading ? (openBlock(), createElementBlock("span", _hoisted_2$e, [
892
892
  __props.loading ? (openBlock(), createElementBlock("svg", _hoisted_3$c, _hoisted_6$2)) : renderSlot(_ctx.$slots, "icon", { key: 1 })
893
893
  ])) : createCommentVNode("", true),
894
- createElementVNode("span", _hoisted_7$1, [
894
+ createElementVNode("span", _hoisted_7$2, [
895
895
  renderSlot(_ctx.$slots, "default")
896
896
  ])
897
897
  ], 10, _hoisted_1$l);
@@ -1913,7 +1913,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1913
1913
  createElementVNode("button", {
1914
1914
  class: normalizeClass([{
1915
1915
  "bg-gray-200": !__props.modelValue,
1916
- "!bg-themeable-primary-600": __props.modelValue
1916
+ "!bg-primary": __props.modelValue
1917
1917
  }, "switch-inner"]),
1918
1918
  "aria-checked": "false",
1919
1919
  role: "switch",
@@ -1940,7 +1940,7 @@ const _hoisted_3$1 = { class: "text-base text-gray-900 font-bold" };
1940
1940
  const _hoisted_4$1 = { class: "flex items-center gap-4" };
1941
1941
  const _hoisted_5$1 = { class: "flex-1 flex items-stretch" };
1942
1942
  const _hoisted_6$1 = { class: "text-sm text-gray-700" };
1943
- const _hoisted_7 = { class: "flex flex-col sm:flex-row gap-[10px]" };
1943
+ const _hoisted_7$1 = { class: "flex flex-col sm:flex-row gap-[10px]" };
1944
1944
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1945
1945
  __name: "Dialog",
1946
1946
  props: {
@@ -2023,7 +2023,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2023
2023
  onClose: _cache[0] || (_cache[0] = ($event) => handleCancel())
2024
2024
  }, {
2025
2025
  footer: withCtx(() => [
2026
- createElementVNode("div", _hoisted_7, [
2026
+ createElementVNode("div", _hoisted_7$1, [
2027
2027
  createVNode(unref(_sfc_main$n), {
2028
2028
  loading: loading.value,
2029
2029
  type: "secondary",
@@ -2114,109 +2114,3709 @@ function useDialog() {
2114
2114
  }
2115
2115
  var _a;
2116
2116
  const isClient = typeof window !== "undefined";
2117
+ const isString = (val) => typeof val === "string";
2118
+ const timestamp = () => +Date.now();
2117
2119
  const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
2118
2120
  const noop = () => {
2119
2121
  };
2120
- isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
2122
+ const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
2123
+ function createFilterWrapper(filter, fn) {
2124
+ function wrapper(...args) {
2125
+ filter(() => fn.apply(this, args), { fn, thisArg: this, args });
2126
+ }
2127
+ return wrapper;
2128
+ }
2129
+ const bypassFilter = (invoke) => {
2130
+ return invoke();
2131
+ };
2132
+ function debounceFilter(ms, options = {}) {
2133
+ let timer;
2134
+ let maxTimer;
2135
+ const filter = (invoke) => {
2136
+ const duration = unref(ms);
2137
+ const maxDuration = unref(options.maxWait);
2138
+ if (timer)
2139
+ clearTimeout(timer);
2140
+ if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
2141
+ if (maxTimer) {
2142
+ clearTimeout(maxTimer);
2143
+ maxTimer = null;
2144
+ }
2145
+ return invoke();
2146
+ }
2147
+ if (maxDuration && !maxTimer) {
2148
+ maxTimer = setTimeout(() => {
2149
+ if (timer)
2150
+ clearTimeout(timer);
2151
+ maxTimer = null;
2152
+ invoke();
2153
+ }, maxDuration);
2154
+ }
2155
+ timer = setTimeout(() => {
2156
+ if (maxTimer)
2157
+ clearTimeout(maxTimer);
2158
+ maxTimer = null;
2159
+ invoke();
2160
+ }, duration);
2161
+ };
2162
+ return filter;
2163
+ }
2164
+ function throttleFilter(ms, trailing = true, leading = true) {
2165
+ let lastExec = 0;
2166
+ let timer;
2167
+ let isLeading = true;
2168
+ const clear = () => {
2169
+ if (timer) {
2170
+ clearTimeout(timer);
2171
+ timer = void 0;
2172
+ }
2173
+ };
2174
+ const filter = (invoke) => {
2175
+ const duration = unref(ms);
2176
+ const elapsed = Date.now() - lastExec;
2177
+ clear();
2178
+ if (duration <= 0) {
2179
+ lastExec = Date.now();
2180
+ return invoke();
2181
+ }
2182
+ if (elapsed > duration && (leading || !isLeading)) {
2183
+ lastExec = Date.now();
2184
+ invoke();
2185
+ } else if (trailing) {
2186
+ timer = setTimeout(() => {
2187
+ lastExec = Date.now();
2188
+ isLeading = true;
2189
+ clear();
2190
+ invoke();
2191
+ }, duration);
2192
+ }
2193
+ if (!leading && !timer)
2194
+ timer = setTimeout(() => isLeading = true, duration);
2195
+ isLeading = false;
2196
+ };
2197
+ return filter;
2198
+ }
2199
+ function pausableFilter(extendFilter = bypassFilter) {
2200
+ const isActive = ref(true);
2201
+ function pause() {
2202
+ isActive.value = false;
2203
+ }
2204
+ function resume() {
2205
+ isActive.value = true;
2206
+ }
2207
+ const eventFilter = (...args) => {
2208
+ if (isActive.value)
2209
+ extendFilter(...args);
2210
+ };
2211
+ return { isActive, pause, resume, eventFilter };
2212
+ }
2213
+ const directiveHooks = {
2214
+ mounted: "mounted",
2215
+ updated: "updated",
2216
+ unmounted: "unmounted"
2217
+ };
2218
+ function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
2219
+ return new Promise((resolve, reject) => {
2220
+ if (throwOnTimeout)
2221
+ setTimeout(() => reject(reason), ms);
2222
+ else
2223
+ setTimeout(resolve, ms);
2224
+ });
2225
+ }
2226
+ function createSingletonPromise(fn) {
2227
+ let _promise;
2228
+ function wrapper() {
2229
+ if (!_promise)
2230
+ _promise = fn();
2231
+ return _promise;
2232
+ }
2233
+ wrapper.reset = async () => {
2234
+ const _prev = _promise;
2235
+ _promise = void 0;
2236
+ if (_prev)
2237
+ await _prev;
2238
+ };
2239
+ return wrapper;
2240
+ }
2241
+ function objectPick(obj, keys2, omitUndefined = false) {
2242
+ return keys2.reduce((n, k) => {
2243
+ if (k in obj) {
2244
+ if (!omitUndefined || obj[k] !== void 0)
2245
+ n[k] = obj[k];
2246
+ }
2247
+ return n;
2248
+ }, {});
2249
+ }
2250
+ function tryOnScopeDispose(fn) {
2251
+ if (getCurrentScope()) {
2252
+ onScopeDispose(fn);
2253
+ return true;
2254
+ }
2255
+ return false;
2256
+ }
2257
+ function useDebounceFn(fn, ms = 200, options = {}) {
2258
+ return createFilterWrapper(debounceFilter(ms, options), fn);
2259
+ }
2260
+ function useThrottleFn(fn, ms = 200, trailing = true, leading = true) {
2261
+ return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
2262
+ }
2121
2263
  function syncRef(left, right, options = {}) {
2122
2264
  const {
2123
- flush = "sync",
2124
- deep = false,
2265
+ flush = "sync",
2266
+ deep = false,
2267
+ immediate = true,
2268
+ direction = "both"
2269
+ } = options;
2270
+ let stop1, stop2;
2271
+ if (direction === "both" || direction === "ltr") {
2272
+ stop1 = watch(left, (newValue) => right.value = newValue, { flush, deep, immediate });
2273
+ }
2274
+ if (direction === "both" || direction === "rtl") {
2275
+ stop2 = watch(right, (newValue) => left.value = newValue, { flush, deep, immediate });
2276
+ }
2277
+ return () => {
2278
+ stop1 == null ? void 0 : stop1();
2279
+ stop2 == null ? void 0 : stop2();
2280
+ };
2281
+ }
2282
+ var __defProp$7$1 = Object.defineProperty;
2283
+ var __defProps$5$1 = Object.defineProperties;
2284
+ var __getOwnPropDescs$5$1 = Object.getOwnPropertyDescriptors;
2285
+ var __getOwnPropSymbols$9$1 = Object.getOwnPropertySymbols;
2286
+ var __hasOwnProp$9$1 = Object.prototype.hasOwnProperty;
2287
+ var __propIsEnum$9$1 = Object.prototype.propertyIsEnumerable;
2288
+ var __defNormalProp$7$1 = (obj, key, value) => key in obj ? __defProp$7$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2289
+ var __spreadValues$7$1 = (a, b) => {
2290
+ for (var prop in b || (b = {}))
2291
+ if (__hasOwnProp$9$1.call(b, prop))
2292
+ __defNormalProp$7$1(a, prop, b[prop]);
2293
+ if (__getOwnPropSymbols$9$1)
2294
+ for (var prop of __getOwnPropSymbols$9$1(b)) {
2295
+ if (__propIsEnum$9$1.call(b, prop))
2296
+ __defNormalProp$7$1(a, prop, b[prop]);
2297
+ }
2298
+ return a;
2299
+ };
2300
+ var __spreadProps$5$1 = (a, b) => __defProps$5$1(a, __getOwnPropDescs$5$1(b));
2301
+ function toRefs(objectRef) {
2302
+ if (!isRef(objectRef))
2303
+ return toRefs$1(objectRef);
2304
+ const result = Array.isArray(objectRef.value) ? new Array(objectRef.value.length) : {};
2305
+ for (const key in objectRef.value) {
2306
+ result[key] = customRef(() => ({
2307
+ get() {
2308
+ return objectRef.value[key];
2309
+ },
2310
+ set(v) {
2311
+ if (Array.isArray(objectRef.value)) {
2312
+ const copy = [...objectRef.value];
2313
+ copy[key] = v;
2314
+ objectRef.value = copy;
2315
+ } else {
2316
+ const newObject = __spreadProps$5$1(__spreadValues$7$1({}, objectRef.value), { [key]: v });
2317
+ Object.setPrototypeOf(newObject, objectRef.value);
2318
+ objectRef.value = newObject;
2319
+ }
2320
+ }
2321
+ }));
2322
+ }
2323
+ return result;
2324
+ }
2325
+ function tryOnBeforeMount(fn, sync = true) {
2326
+ if (getCurrentInstance())
2327
+ onBeforeMount(fn);
2328
+ else if (sync)
2329
+ fn();
2330
+ else
2331
+ nextTick(fn);
2332
+ }
2333
+ function tryOnMounted(fn, sync = true) {
2334
+ if (getCurrentInstance())
2335
+ onMounted(fn);
2336
+ else if (sync)
2337
+ fn();
2338
+ else
2339
+ nextTick(fn);
2340
+ }
2341
+ function useIntervalFn(cb, interval = 1e3, options = {}) {
2342
+ const {
2343
+ immediate = true,
2344
+ immediateCallback = false
2345
+ } = options;
2346
+ let timer = null;
2347
+ const isActive = ref(false);
2348
+ function clean() {
2349
+ if (timer) {
2350
+ clearInterval(timer);
2351
+ timer = null;
2352
+ }
2353
+ }
2354
+ function pause() {
2355
+ isActive.value = false;
2356
+ clean();
2357
+ }
2358
+ function resume() {
2359
+ if (unref(interval) <= 0)
2360
+ return;
2361
+ isActive.value = true;
2362
+ if (immediateCallback)
2363
+ cb();
2364
+ clean();
2365
+ timer = setInterval(cb, unref(interval));
2366
+ }
2367
+ if (immediate && isClient)
2368
+ resume();
2369
+ if (isRef(interval)) {
2370
+ const stopWatch = watch(interval, () => {
2371
+ if (isActive.value && isClient)
2372
+ resume();
2373
+ });
2374
+ tryOnScopeDispose(stopWatch);
2375
+ }
2376
+ tryOnScopeDispose(pause);
2377
+ return {
2378
+ isActive,
2379
+ pause,
2380
+ resume
2381
+ };
2382
+ }
2383
+ function useToggle(initialValue = false, options = {}) {
2384
+ const {
2385
+ truthyValue = true,
2386
+ falsyValue = false
2387
+ } = options;
2388
+ const valueIsRef = isRef(initialValue);
2389
+ const innerValue = ref(initialValue);
2390
+ function toggle(value) {
2391
+ if (arguments.length) {
2392
+ innerValue.value = value;
2393
+ return innerValue.value;
2394
+ } else {
2395
+ innerValue.value = innerValue.value === unref(truthyValue) ? unref(falsyValue) : unref(truthyValue);
2396
+ return innerValue.value;
2397
+ }
2398
+ }
2399
+ if (valueIsRef)
2400
+ return toggle;
2401
+ else
2402
+ return [innerValue, toggle];
2403
+ }
2404
+ var __getOwnPropSymbols$6$1 = Object.getOwnPropertySymbols;
2405
+ var __hasOwnProp$6$1 = Object.prototype.hasOwnProperty;
2406
+ var __propIsEnum$6$1 = Object.prototype.propertyIsEnumerable;
2407
+ var __objRest$5 = (source, exclude) => {
2408
+ var target = {};
2409
+ for (var prop in source)
2410
+ if (__hasOwnProp$6$1.call(source, prop) && exclude.indexOf(prop) < 0)
2411
+ target[prop] = source[prop];
2412
+ if (source != null && __getOwnPropSymbols$6$1)
2413
+ for (var prop of __getOwnPropSymbols$6$1(source)) {
2414
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6$1.call(source, prop))
2415
+ target[prop] = source[prop];
2416
+ }
2417
+ return target;
2418
+ };
2419
+ function watchWithFilter(source, cb, options = {}) {
2420
+ const _a2 = options, {
2421
+ eventFilter = bypassFilter
2422
+ } = _a2, watchOptions = __objRest$5(_a2, [
2423
+ "eventFilter"
2424
+ ]);
2425
+ return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
2426
+ }
2427
+ var __defProp$2$1 = Object.defineProperty;
2428
+ var __defProps$2$1 = Object.defineProperties;
2429
+ var __getOwnPropDescs$2$1 = Object.getOwnPropertyDescriptors;
2430
+ var __getOwnPropSymbols$2$1 = Object.getOwnPropertySymbols;
2431
+ var __hasOwnProp$2$1 = Object.prototype.hasOwnProperty;
2432
+ var __propIsEnum$2$1 = Object.prototype.propertyIsEnumerable;
2433
+ var __defNormalProp$2$1 = (obj, key, value) => key in obj ? __defProp$2$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2434
+ var __spreadValues$2$1 = (a, b) => {
2435
+ for (var prop in b || (b = {}))
2436
+ if (__hasOwnProp$2$1.call(b, prop))
2437
+ __defNormalProp$2$1(a, prop, b[prop]);
2438
+ if (__getOwnPropSymbols$2$1)
2439
+ for (var prop of __getOwnPropSymbols$2$1(b)) {
2440
+ if (__propIsEnum$2$1.call(b, prop))
2441
+ __defNormalProp$2$1(a, prop, b[prop]);
2442
+ }
2443
+ return a;
2444
+ };
2445
+ var __spreadProps$2$1 = (a, b) => __defProps$2$1(a, __getOwnPropDescs$2$1(b));
2446
+ var __objRest$1$1 = (source, exclude) => {
2447
+ var target = {};
2448
+ for (var prop in source)
2449
+ if (__hasOwnProp$2$1.call(source, prop) && exclude.indexOf(prop) < 0)
2450
+ target[prop] = source[prop];
2451
+ if (source != null && __getOwnPropSymbols$2$1)
2452
+ for (var prop of __getOwnPropSymbols$2$1(source)) {
2453
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$2$1.call(source, prop))
2454
+ target[prop] = source[prop];
2455
+ }
2456
+ return target;
2457
+ };
2458
+ function watchPausable(source, cb, options = {}) {
2459
+ const _a2 = options, {
2460
+ eventFilter: filter
2461
+ } = _a2, watchOptions = __objRest$1$1(_a2, [
2462
+ "eventFilter"
2463
+ ]);
2464
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
2465
+ const stop = watchWithFilter(source, cb, __spreadProps$2$1(__spreadValues$2$1({}, watchOptions), {
2466
+ eventFilter
2467
+ }));
2468
+ return { stop, pause, resume, isActive };
2469
+ }
2470
+ function unrefElement$1(elRef) {
2471
+ var _a2;
2472
+ const plain = unref(elRef);
2473
+ return (_a2 = plain == null ? void 0 : plain.$el) != null ? _a2 : plain;
2474
+ }
2475
+ const defaultWindow$1 = isClient ? window : void 0;
2476
+ const defaultDocument = isClient ? window.document : void 0;
2477
+ const defaultNavigator = isClient ? window.navigator : void 0;
2478
+ function useEventListener$1(...args) {
2479
+ let target;
2480
+ let event;
2481
+ let listener;
2482
+ let options;
2483
+ if (isString(args[0])) {
2484
+ [event, listener, options] = args;
2485
+ target = defaultWindow$1;
2486
+ } else {
2487
+ [target, event, listener, options] = args;
2488
+ }
2489
+ if (!target)
2490
+ return noop;
2491
+ let cleanup = noop;
2492
+ const stopWatch = watch(() => unrefElement$1(target), (el) => {
2493
+ cleanup();
2494
+ if (!el)
2495
+ return;
2496
+ el.addEventListener(event, listener, options);
2497
+ cleanup = () => {
2498
+ el.removeEventListener(event, listener, options);
2499
+ cleanup = noop;
2500
+ };
2501
+ }, { immediate: true, flush: "post" });
2502
+ const stop = () => {
2503
+ stopWatch();
2504
+ cleanup();
2505
+ };
2506
+ tryOnScopeDispose(stop);
2507
+ return stop;
2508
+ }
2509
+ function onClickOutside(target, handler, options = {}) {
2510
+ const { window: window2 = defaultWindow$1, ignore, capture = true, detectIframe = false } = options;
2511
+ if (!window2)
2512
+ return;
2513
+ const shouldListen = ref(true);
2514
+ let fallback;
2515
+ const listener = (event) => {
2516
+ window2.clearTimeout(fallback);
2517
+ const el = unrefElement$1(target);
2518
+ const composedPath = event.composedPath();
2519
+ if (!el || el === event.target || composedPath.includes(el) || !shouldListen.value)
2520
+ return;
2521
+ if (ignore && ignore.length > 0) {
2522
+ if (ignore.some((target2) => {
2523
+ const el2 = unrefElement$1(target2);
2524
+ return el2 && (event.target === el2 || composedPath.includes(el2));
2525
+ }))
2526
+ return;
2527
+ }
2528
+ handler(event);
2529
+ };
2530
+ const cleanup = [
2531
+ useEventListener$1(window2, "click", listener, { passive: true, capture }),
2532
+ useEventListener$1(window2, "pointerdown", (e) => {
2533
+ const el = unrefElement$1(target);
2534
+ shouldListen.value = !!el && !e.composedPath().includes(el);
2535
+ }, { passive: true }),
2536
+ useEventListener$1(window2, "pointerup", (e) => {
2537
+ if (e.button === 0) {
2538
+ const path = e.composedPath();
2539
+ e.composedPath = () => path;
2540
+ fallback = window2.setTimeout(() => listener(e), 50);
2541
+ }
2542
+ }, { passive: true }),
2543
+ detectIframe && useEventListener$1(window2, "blur", (event) => {
2544
+ var _a2;
2545
+ const el = unrefElement$1(target);
2546
+ if (((_a2 = document.activeElement) == null ? void 0 : _a2.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(document.activeElement)))
2547
+ handler(event);
2548
+ })
2549
+ ].filter(Boolean);
2550
+ const stop = () => cleanup.forEach((fn) => fn());
2551
+ return stop;
2552
+ }
2553
+ function useActiveElement(options = {}) {
2554
+ const { window: window2 = defaultWindow$1 } = options;
2555
+ const counter = ref(0);
2556
+ if (window2) {
2557
+ useEventListener$1(window2, "blur", () => counter.value += 1, true);
2558
+ useEventListener$1(window2, "focus", () => counter.value += 1, true);
2559
+ }
2560
+ return computed(() => {
2561
+ counter.value;
2562
+ return window2 == null ? void 0 : window2.document.activeElement;
2563
+ });
2564
+ }
2565
+ function useBattery({ navigator = defaultNavigator } = {}) {
2566
+ const events = ["chargingchange", "chargingtimechange", "dischargingtimechange", "levelchange"];
2567
+ const isSupported = navigator && "getBattery" in navigator;
2568
+ const charging = ref(false);
2569
+ const chargingTime = ref(0);
2570
+ const dischargingTime = ref(0);
2571
+ const level = ref(1);
2572
+ let battery;
2573
+ function updateBatteryInfo() {
2574
+ charging.value = this.charging;
2575
+ chargingTime.value = this.chargingTime || 0;
2576
+ dischargingTime.value = this.dischargingTime || 0;
2577
+ level.value = this.level;
2578
+ }
2579
+ if (isSupported) {
2580
+ navigator.getBattery().then((_battery) => {
2581
+ battery = _battery;
2582
+ updateBatteryInfo.call(battery);
2583
+ for (const event of events)
2584
+ useEventListener$1(battery, event, updateBatteryInfo, { passive: true });
2585
+ });
2586
+ }
2587
+ return {
2588
+ isSupported,
2589
+ charging,
2590
+ chargingTime,
2591
+ dischargingTime,
2592
+ level
2593
+ };
2594
+ }
2595
+ function useMediaQuery$1(query, options = {}) {
2596
+ const { window: window2 = defaultWindow$1 } = options;
2597
+ const isSupported = Boolean(window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
2598
+ let mediaQuery;
2599
+ const matches = ref(false);
2600
+ const update = () => {
2601
+ if (!isSupported)
2602
+ return;
2603
+ if (!mediaQuery)
2604
+ mediaQuery = window2.matchMedia(query);
2605
+ matches.value = mediaQuery.matches;
2606
+ };
2607
+ tryOnBeforeMount(() => {
2608
+ update();
2609
+ if (!mediaQuery)
2610
+ return;
2611
+ if ("addEventListener" in mediaQuery)
2612
+ mediaQuery.addEventListener("change", update);
2613
+ else
2614
+ mediaQuery.addListener(update);
2615
+ tryOnScopeDispose(() => {
2616
+ if ("removeEventListener" in mediaQuery)
2617
+ mediaQuery.removeEventListener("change", update);
2618
+ else
2619
+ mediaQuery.removeListener(update);
2620
+ });
2621
+ });
2622
+ return matches;
2623
+ }
2624
+ function useBrowserLocation({ window: window2 = defaultWindow$1 } = {}) {
2625
+ const buildState = (trigger) => {
2626
+ const { state: state2, length } = (window2 == null ? void 0 : window2.history) || {};
2627
+ const { hash, host, hostname, href, origin, pathname, port, protocol, search } = (window2 == null ? void 0 : window2.location) || {};
2628
+ return {
2629
+ trigger,
2630
+ state: state2,
2631
+ length,
2632
+ hash,
2633
+ host,
2634
+ hostname,
2635
+ href,
2636
+ origin,
2637
+ pathname,
2638
+ port,
2639
+ protocol,
2640
+ search
2641
+ };
2642
+ };
2643
+ const state = ref(buildState("load"));
2644
+ if (window2) {
2645
+ useEventListener$1(window2, "popstate", () => state.value = buildState("popstate"), { passive: true });
2646
+ useEventListener$1(window2, "hashchange", () => state.value = buildState("hashchange"), { passive: true });
2647
+ }
2648
+ return state;
2649
+ }
2650
+ function useClamp(value, min, max) {
2651
+ const _value = ref(value);
2652
+ return computed({
2653
+ get() {
2654
+ return _value.value = clamp(_value.value, unref(min), unref(max));
2655
+ },
2656
+ set(value2) {
2657
+ _value.value = clamp(value2, unref(min), unref(max));
2658
+ }
2659
+ });
2660
+ }
2661
+ const _global$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2662
+ const globalKey$1 = "__vueuse_ssr_handlers__";
2663
+ _global$1[globalKey$1] = _global$1[globalKey$1] || {};
2664
+ const handlers$1 = _global$1[globalKey$1];
2665
+ function getSSRHandler$1(key, fallback) {
2666
+ return handlers$1[key] || fallback;
2667
+ }
2668
+ function guessSerializerType$1(rawInit) {
2669
+ 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" : Array.isArray(rawInit) ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
2670
+ }
2671
+ const StorageSerializers$1 = {
2672
+ boolean: {
2673
+ read: (v) => v === "true",
2674
+ write: (v) => String(v)
2675
+ },
2676
+ object: {
2677
+ read: (v) => JSON.parse(v),
2678
+ write: (v) => JSON.stringify(v)
2679
+ },
2680
+ number: {
2681
+ read: (v) => Number.parseFloat(v),
2682
+ write: (v) => String(v)
2683
+ },
2684
+ any: {
2685
+ read: (v) => v,
2686
+ write: (v) => String(v)
2687
+ },
2688
+ string: {
2689
+ read: (v) => v,
2690
+ write: (v) => String(v)
2691
+ },
2692
+ map: {
2693
+ read: (v) => new Map(JSON.parse(v)),
2694
+ write: (v) => JSON.stringify(Array.from(v.entries()))
2695
+ },
2696
+ set: {
2697
+ read: (v) => new Set(JSON.parse(v)),
2698
+ write: (v) => JSON.stringify(Array.from(v))
2699
+ },
2700
+ date: {
2701
+ read: (v) => new Date(v),
2702
+ write: (v) => v.toISOString()
2703
+ }
2704
+ };
2705
+ function useStorage$1(key, initialValue, storage, options = {}) {
2706
+ var _a2;
2707
+ const {
2708
+ flush = "pre",
2709
+ deep = true,
2710
+ listenToStorageChanges = true,
2711
+ writeDefaults = true,
2712
+ shallow,
2713
+ window: window2 = defaultWindow$1,
2714
+ eventFilter,
2715
+ onError = (e) => {
2716
+ console.error(e);
2717
+ }
2718
+ } = options;
2719
+ const data = (shallow ? shallowRef : ref)(initialValue);
2720
+ if (!storage) {
2721
+ try {
2722
+ storage = getSSRHandler$1("getDefaultStorage", () => {
2723
+ var _a22;
2724
+ return (_a22 = defaultWindow$1) == null ? void 0 : _a22.localStorage;
2725
+ })();
2726
+ } catch (e) {
2727
+ onError(e);
2728
+ }
2729
+ }
2730
+ if (!storage)
2731
+ return data;
2732
+ const rawInit = unref(initialValue);
2733
+ const type = guessSerializerType$1(rawInit);
2734
+ const serializer = (_a2 = options.serializer) != null ? _a2 : StorageSerializers$1[type];
2735
+ const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, () => write(data.value), { flush, deep, eventFilter });
2736
+ if (window2 && listenToStorageChanges)
2737
+ useEventListener$1(window2, "storage", update);
2738
+ update();
2739
+ return data;
2740
+ function write(v) {
2741
+ try {
2742
+ if (v == null)
2743
+ storage.removeItem(key);
2744
+ else
2745
+ storage.setItem(key, serializer.write(v));
2746
+ } catch (e) {
2747
+ onError(e);
2748
+ }
2749
+ }
2750
+ function read(event) {
2751
+ if (event && event.key !== key)
2752
+ return;
2753
+ pauseWatch();
2754
+ try {
2755
+ const rawValue = event ? event.newValue : storage.getItem(key);
2756
+ if (rawValue == null) {
2757
+ if (writeDefaults && rawInit !== null)
2758
+ storage.setItem(key, serializer.write(rawInit));
2759
+ return rawInit;
2760
+ } else if (typeof rawValue !== "string") {
2761
+ return rawValue;
2762
+ } else {
2763
+ return serializer.read(rawValue);
2764
+ }
2765
+ } catch (e) {
2766
+ onError(e);
2767
+ } finally {
2768
+ resumeWatch();
2769
+ }
2770
+ }
2771
+ function update(event) {
2772
+ if (event && event.key !== key)
2773
+ return;
2774
+ data.value = read(event);
2775
+ }
2776
+ }
2777
+ function usePreferredDark$1(options) {
2778
+ return useMediaQuery$1("(prefers-color-scheme: dark)", options);
2779
+ }
2780
+ var __defProp$h = Object.defineProperty;
2781
+ var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
2782
+ var __hasOwnProp$j = Object.prototype.hasOwnProperty;
2783
+ var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
2784
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2785
+ var __spreadValues$h = (a, b) => {
2786
+ for (var prop in b || (b = {}))
2787
+ if (__hasOwnProp$j.call(b, prop))
2788
+ __defNormalProp$h(a, prop, b[prop]);
2789
+ if (__getOwnPropSymbols$j)
2790
+ for (var prop of __getOwnPropSymbols$j(b)) {
2791
+ if (__propIsEnum$j.call(b, prop))
2792
+ __defNormalProp$h(a, prop, b[prop]);
2793
+ }
2794
+ return a;
2795
+ };
2796
+ function useColorMode$1(options = {}) {
2797
+ const {
2798
+ selector = "html",
2799
+ attribute = "class",
2800
+ window: window2 = defaultWindow$1,
2801
+ storage,
2802
+ storageKey = "vueuse-color-scheme",
2803
+ listenToStorageChanges = true,
2804
+ storageRef,
2805
+ emitAuto
2806
+ } = options;
2807
+ const modes = __spreadValues$h({
2808
+ auto: "",
2809
+ light: "light",
2810
+ dark: "dark"
2811
+ }, options.modes || {});
2812
+ const preferredDark = usePreferredDark$1({ window: window2 });
2813
+ const preferredMode = computed(() => preferredDark.value ? "dark" : "light");
2814
+ const store = storageRef || (storageKey == null ? ref("auto") : useStorage$1(storageKey, "auto", storage, { window: window2, listenToStorageChanges }));
2815
+ const state = computed({
2816
+ get() {
2817
+ return store.value === "auto" && !emitAuto ? preferredMode.value : store.value;
2818
+ },
2819
+ set(v) {
2820
+ store.value = v;
2821
+ }
2822
+ });
2823
+ const updateHTMLAttrs = getSSRHandler$1("updateHTMLAttrs", (selector2, attribute2, value) => {
2824
+ const el = window2 == null ? void 0 : window2.document.querySelector(selector2);
2825
+ if (!el)
2826
+ return;
2827
+ if (attribute2 === "class") {
2828
+ const current = value.split(/\s/g);
2829
+ Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
2830
+ if (current.includes(v))
2831
+ el.classList.add(v);
2832
+ else
2833
+ el.classList.remove(v);
2834
+ });
2835
+ } else {
2836
+ el.setAttribute(attribute2, value);
2837
+ }
2838
+ });
2839
+ function defaultOnChanged(mode) {
2840
+ var _a2;
2841
+ const resolvedMode = mode === "auto" ? preferredMode.value : mode;
2842
+ updateHTMLAttrs(selector, attribute, (_a2 = modes[resolvedMode]) != null ? _a2 : resolvedMode);
2843
+ }
2844
+ function onChanged(mode) {
2845
+ if (options.onChanged)
2846
+ options.onChanged(mode, defaultOnChanged);
2847
+ else
2848
+ defaultOnChanged(mode);
2849
+ }
2850
+ watch(state, onChanged, { flush: "post", immediate: true });
2851
+ tryOnMounted(() => onChanged(state.value));
2852
+ return state;
2853
+ }
2854
+ var __defProp$g = Object.defineProperty;
2855
+ var __defProps$7$1 = Object.defineProperties;
2856
+ var __getOwnPropDescs$7$1 = Object.getOwnPropertyDescriptors;
2857
+ var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
2858
+ var __hasOwnProp$i = Object.prototype.hasOwnProperty;
2859
+ var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
2860
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2861
+ var __spreadValues$g = (a, b) => {
2862
+ for (var prop in b || (b = {}))
2863
+ if (__hasOwnProp$i.call(b, prop))
2864
+ __defNormalProp$g(a, prop, b[prop]);
2865
+ if (__getOwnPropSymbols$i)
2866
+ for (var prop of __getOwnPropSymbols$i(b)) {
2867
+ if (__propIsEnum$i.call(b, prop))
2868
+ __defNormalProp$g(a, prop, b[prop]);
2869
+ }
2870
+ return a;
2871
+ };
2872
+ var __spreadProps$7$1 = (a, b) => __defProps$7$1(a, __getOwnPropDescs$7$1(b));
2873
+ function useDark(options = {}) {
2874
+ const {
2875
+ valueDark = "dark",
2876
+ valueLight = "",
2877
+ window: window2 = defaultWindow$1
2878
+ } = options;
2879
+ const mode = useColorMode$1(__spreadProps$7$1(__spreadValues$g({}, options), {
2880
+ onChanged: (mode2, defaultHandler) => {
2881
+ var _a2;
2882
+ if (options.onChanged)
2883
+ (_a2 = options.onChanged) == null ? void 0 : _a2.call(options, mode2 === "dark");
2884
+ else
2885
+ defaultHandler(mode2);
2886
+ },
2887
+ modes: {
2888
+ dark: valueDark,
2889
+ light: valueLight
2890
+ }
2891
+ }));
2892
+ const preferredDark = usePreferredDark$1({ window: window2 });
2893
+ const isDark = computed({
2894
+ get() {
2895
+ return mode.value === "dark";
2896
+ },
2897
+ set(v) {
2898
+ if (v === preferredDark.value)
2899
+ mode.value = "auto";
2900
+ else
2901
+ mode.value = v ? "dark" : "light";
2902
+ }
2903
+ });
2904
+ return isDark;
2905
+ }
2906
+ function useDeviceMotion(options = {}) {
2907
+ const {
2908
+ window: window2 = defaultWindow$1,
2909
+ eventFilter = bypassFilter
2910
+ } = options;
2911
+ const acceleration = ref({ x: null, y: null, z: null });
2912
+ const rotationRate = ref({ alpha: null, beta: null, gamma: null });
2913
+ const interval = ref(0);
2914
+ const accelerationIncludingGravity = ref({
2915
+ x: null,
2916
+ y: null,
2917
+ z: null
2918
+ });
2919
+ if (window2) {
2920
+ const onDeviceMotion = createFilterWrapper(eventFilter, (event) => {
2921
+ acceleration.value = event.acceleration;
2922
+ accelerationIncludingGravity.value = event.accelerationIncludingGravity;
2923
+ rotationRate.value = event.rotationRate;
2924
+ interval.value = event.interval;
2925
+ });
2926
+ useEventListener$1(window2, "devicemotion", onDeviceMotion);
2927
+ }
2928
+ return {
2929
+ acceleration,
2930
+ accelerationIncludingGravity,
2931
+ rotationRate,
2932
+ interval
2933
+ };
2934
+ }
2935
+ function useDeviceOrientation(options = {}) {
2936
+ const { window: window2 = defaultWindow$1 } = options;
2937
+ const isSupported = Boolean(window2 && "DeviceOrientationEvent" in window2);
2938
+ const isAbsolute = ref(false);
2939
+ const alpha = ref(null);
2940
+ const beta = ref(null);
2941
+ const gamma = ref(null);
2942
+ if (window2 && isSupported) {
2943
+ useEventListener$1(window2, "deviceorientation", (event) => {
2944
+ isAbsolute.value = event.absolute;
2945
+ alpha.value = event.alpha;
2946
+ beta.value = event.beta;
2947
+ gamma.value = event.gamma;
2948
+ });
2949
+ }
2950
+ return {
2951
+ isSupported,
2952
+ isAbsolute,
2953
+ alpha,
2954
+ beta,
2955
+ gamma
2956
+ };
2957
+ }
2958
+ const DEVICE_PIXEL_RATIO_SCALES = [
2959
+ 1,
2960
+ 1.325,
2961
+ 1.4,
2962
+ 1.5,
2963
+ 1.8,
2964
+ 2,
2965
+ 2.4,
2966
+ 2.5,
2967
+ 2.75,
2968
+ 3,
2969
+ 3.5,
2970
+ 4
2971
+ ];
2972
+ function useDevicePixelRatio({
2973
+ window: window2 = defaultWindow$1
2974
+ } = {}) {
2975
+ if (!window2) {
2976
+ return {
2977
+ pixelRatio: ref(1)
2978
+ };
2979
+ }
2980
+ const pixelRatio = ref(window2.devicePixelRatio);
2981
+ const handleDevicePixelRatio = () => {
2982
+ pixelRatio.value = window2.devicePixelRatio;
2983
+ };
2984
+ useEventListener$1(window2, "resize", handleDevicePixelRatio, { passive: true });
2985
+ DEVICE_PIXEL_RATIO_SCALES.forEach((dppx) => {
2986
+ const mqlMin = useMediaQuery$1(`screen and (min-resolution: ${dppx}dppx)`);
2987
+ const mqlMax = useMediaQuery$1(`screen and (max-resolution: ${dppx}dppx)`);
2988
+ watch([mqlMin, mqlMax], handleDevicePixelRatio);
2989
+ });
2990
+ return { pixelRatio };
2991
+ }
2992
+ function usePermission(permissionDesc, options = {}) {
2993
+ const {
2994
+ controls = false,
2995
+ navigator = defaultNavigator
2996
+ } = options;
2997
+ const isSupported = Boolean(navigator && "permissions" in navigator);
2998
+ let permissionStatus;
2999
+ const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
3000
+ const state = ref();
3001
+ const onChange = () => {
3002
+ if (permissionStatus)
3003
+ state.value = permissionStatus.state;
3004
+ };
3005
+ const query = createSingletonPromise(async () => {
3006
+ if (!isSupported)
3007
+ return;
3008
+ if (!permissionStatus) {
3009
+ try {
3010
+ permissionStatus = await navigator.permissions.query(desc);
3011
+ useEventListener$1(permissionStatus, "change", onChange);
3012
+ onChange();
3013
+ } catch (e) {
3014
+ state.value = "prompt";
3015
+ }
3016
+ }
3017
+ return permissionStatus;
3018
+ });
3019
+ query();
3020
+ if (controls) {
3021
+ return {
3022
+ state,
3023
+ isSupported,
3024
+ query
3025
+ };
3026
+ } else {
3027
+ return state;
3028
+ }
3029
+ }
3030
+ function useDevicesList(options = {}) {
3031
+ const {
3032
+ navigator = defaultNavigator,
3033
+ requestPermissions = false,
3034
+ constraints = { audio: true, video: true },
3035
+ onUpdated
3036
+ } = options;
3037
+ const devices = ref([]);
3038
+ const videoInputs = computed(() => devices.value.filter((i) => i.kind === "videoinput"));
3039
+ const audioInputs = computed(() => devices.value.filter((i) => i.kind === "audioinput"));
3040
+ const audioOutputs = computed(() => devices.value.filter((i) => i.kind === "audiooutput"));
3041
+ let isSupported = false;
3042
+ const permissionGranted = ref(false);
3043
+ async function update() {
3044
+ if (!isSupported)
3045
+ return;
3046
+ devices.value = await navigator.mediaDevices.enumerateDevices();
3047
+ onUpdated == null ? void 0 : onUpdated(devices.value);
3048
+ }
3049
+ async function ensurePermissions() {
3050
+ if (!isSupported)
3051
+ return false;
3052
+ if (permissionGranted.value)
3053
+ return true;
3054
+ const { state, query } = usePermission("camera", { controls: true });
3055
+ await query();
3056
+ if (state.value !== "granted") {
3057
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
3058
+ stream.getTracks().forEach((t) => t.stop());
3059
+ update();
3060
+ permissionGranted.value = true;
3061
+ } else {
3062
+ permissionGranted.value = true;
3063
+ }
3064
+ return permissionGranted.value;
3065
+ }
3066
+ if (navigator) {
3067
+ isSupported = Boolean(navigator.mediaDevices && navigator.mediaDevices.enumerateDevices);
3068
+ if (isSupported) {
3069
+ if (requestPermissions)
3070
+ ensurePermissions();
3071
+ useEventListener$1(navigator.mediaDevices, "devicechange", update);
3072
+ update();
3073
+ }
3074
+ }
3075
+ return {
3076
+ devices,
3077
+ ensurePermissions,
3078
+ permissionGranted,
3079
+ videoInputs,
3080
+ audioInputs,
3081
+ audioOutputs,
3082
+ isSupported
3083
+ };
3084
+ }
3085
+ function useDocumentVisibility({ document: document2 = defaultDocument } = {}) {
3086
+ if (!document2)
3087
+ return ref("visible");
3088
+ const visibility = ref(document2.visibilityState);
3089
+ useEventListener$1(document2, "visibilitychange", () => {
3090
+ visibility.value = document2.visibilityState;
3091
+ });
3092
+ return visibility;
3093
+ }
3094
+ var __defProp$d = Object.defineProperty;
3095
+ var __defProps$4$1 = Object.defineProperties;
3096
+ var __getOwnPropDescs$4$1 = Object.getOwnPropertyDescriptors;
3097
+ var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
3098
+ var __hasOwnProp$f = Object.prototype.hasOwnProperty;
3099
+ var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
3100
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3101
+ var __spreadValues$d = (a, b) => {
3102
+ for (var prop in b || (b = {}))
3103
+ if (__hasOwnProp$f.call(b, prop))
3104
+ __defNormalProp$d(a, prop, b[prop]);
3105
+ if (__getOwnPropSymbols$f)
3106
+ for (var prop of __getOwnPropSymbols$f(b)) {
3107
+ if (__propIsEnum$f.call(b, prop))
3108
+ __defNormalProp$d(a, prop, b[prop]);
3109
+ }
3110
+ return a;
3111
+ };
3112
+ var __spreadProps$4$1 = (a, b) => __defProps$4$1(a, __getOwnPropDescs$4$1(b));
3113
+ function useDraggable(target, options = {}) {
3114
+ var _a2, _b;
3115
+ const draggingElement = (_a2 = options.draggingElement) != null ? _a2 : defaultWindow$1;
3116
+ const position = ref((_b = options.initialValue) != null ? _b : { x: 0, y: 0 });
3117
+ const pressedDelta = ref();
3118
+ const filterEvent = (e) => {
3119
+ if (options.pointerTypes)
3120
+ return options.pointerTypes.includes(e.pointerType);
3121
+ return true;
3122
+ };
3123
+ const handleEvent = (e) => {
3124
+ if (unref(options.preventDefault))
3125
+ e.preventDefault();
3126
+ if (unref(options.stopPropagation))
3127
+ e.stopPropagation();
3128
+ };
3129
+ const start = (e) => {
3130
+ var _a22;
3131
+ if (!filterEvent(e))
3132
+ return;
3133
+ if (unref(options.exact) && e.target !== unref(target))
3134
+ return;
3135
+ const rect = unref(target).getBoundingClientRect();
3136
+ const pos = {
3137
+ x: e.pageX - rect.left,
3138
+ y: e.pageY - rect.top
3139
+ };
3140
+ if (((_a22 = options.onStart) == null ? void 0 : _a22.call(options, pos, e)) === false)
3141
+ return;
3142
+ pressedDelta.value = pos;
3143
+ handleEvent(e);
3144
+ };
3145
+ const move = (e) => {
3146
+ var _a22;
3147
+ if (!filterEvent(e))
3148
+ return;
3149
+ if (!pressedDelta.value)
3150
+ return;
3151
+ position.value = {
3152
+ x: e.pageX - pressedDelta.value.x,
3153
+ y: e.pageY - pressedDelta.value.y
3154
+ };
3155
+ (_a22 = options.onMove) == null ? void 0 : _a22.call(options, position.value, e);
3156
+ handleEvent(e);
3157
+ };
3158
+ const end = (e) => {
3159
+ var _a22;
3160
+ if (!filterEvent(e))
3161
+ return;
3162
+ if (!pressedDelta.value)
3163
+ return;
3164
+ pressedDelta.value = void 0;
3165
+ (_a22 = options.onEnd) == null ? void 0 : _a22.call(options, position.value, e);
3166
+ handleEvent(e);
3167
+ };
3168
+ if (isClient) {
3169
+ useEventListener$1(target, "pointerdown", start, true);
3170
+ useEventListener$1(draggingElement, "pointermove", move, true);
3171
+ useEventListener$1(draggingElement, "pointerup", end, true);
3172
+ }
3173
+ return __spreadProps$4$1(__spreadValues$d({}, toRefs(position)), {
3174
+ position,
3175
+ isDragging: computed(() => !!pressedDelta.value),
3176
+ style: computed(() => `left:${position.value.x}px;top:${position.value.y}px;`)
3177
+ });
3178
+ }
3179
+ var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
3180
+ var __hasOwnProp$e = Object.prototype.hasOwnProperty;
3181
+ var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
3182
+ var __objRest$2 = (source, exclude) => {
3183
+ var target = {};
3184
+ for (var prop in source)
3185
+ if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
3186
+ target[prop] = source[prop];
3187
+ if (source != null && __getOwnPropSymbols$e)
3188
+ for (var prop of __getOwnPropSymbols$e(source)) {
3189
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$e.call(source, prop))
3190
+ target[prop] = source[prop];
3191
+ }
3192
+ return target;
3193
+ };
3194
+ function useResizeObserver$1(target, callback, options = {}) {
3195
+ const _a2 = options, { window: window2 = defaultWindow$1 } = _a2, observerOptions = __objRest$2(_a2, ["window"]);
3196
+ let observer;
3197
+ const isSupported = window2 && "ResizeObserver" in window2;
3198
+ const cleanup = () => {
3199
+ if (observer) {
3200
+ observer.disconnect();
3201
+ observer = void 0;
3202
+ }
3203
+ };
3204
+ const stopWatch = watch(() => unrefElement$1(target), (el) => {
3205
+ cleanup();
3206
+ if (isSupported && window2 && el) {
3207
+ observer = new ResizeObserver(callback);
3208
+ observer.observe(el, observerOptions);
3209
+ }
3210
+ }, { immediate: true, flush: "post" });
3211
+ const stop = () => {
3212
+ cleanup();
3213
+ stopWatch();
3214
+ };
3215
+ tryOnScopeDispose(stop);
3216
+ return {
3217
+ isSupported,
3218
+ stop
3219
+ };
3220
+ }
3221
+ function useElementBounding(target, options = {}) {
3222
+ const {
3223
+ reset = true,
3224
+ windowResize = true,
3225
+ windowScroll = true,
3226
+ immediate = true
3227
+ } = options;
3228
+ const height = ref(0);
3229
+ const bottom = ref(0);
3230
+ const left = ref(0);
3231
+ const right = ref(0);
3232
+ const top = ref(0);
3233
+ const width = ref(0);
3234
+ const x = ref(0);
3235
+ const y = ref(0);
3236
+ function update() {
3237
+ const el = unrefElement$1(target);
3238
+ if (!el) {
3239
+ if (reset) {
3240
+ height.value = 0;
3241
+ bottom.value = 0;
3242
+ left.value = 0;
3243
+ right.value = 0;
3244
+ top.value = 0;
3245
+ width.value = 0;
3246
+ x.value = 0;
3247
+ y.value = 0;
3248
+ }
3249
+ return;
3250
+ }
3251
+ const rect = el.getBoundingClientRect();
3252
+ height.value = rect.height;
3253
+ bottom.value = rect.bottom;
3254
+ left.value = rect.left;
3255
+ right.value = rect.right;
3256
+ top.value = rect.top;
3257
+ width.value = rect.width;
3258
+ x.value = rect.x;
3259
+ y.value = rect.y;
3260
+ }
3261
+ useResizeObserver$1(target, update);
3262
+ watch(() => unrefElement$1(target), (ele) => !ele && update());
3263
+ if (windowScroll)
3264
+ useEventListener$1("scroll", update, { passive: true });
3265
+ if (windowResize)
3266
+ useEventListener$1("resize", update, { passive: true });
3267
+ tryOnMounted(() => {
3268
+ if (immediate)
3269
+ update();
3270
+ });
3271
+ return {
3272
+ height,
3273
+ bottom,
3274
+ left,
3275
+ right,
3276
+ top,
3277
+ width,
3278
+ x,
3279
+ y,
3280
+ update
3281
+ };
3282
+ }
3283
+ function useRafFn(fn, options = {}) {
3284
+ const {
3285
+ immediate = true,
3286
+ window: window2 = defaultWindow$1
3287
+ } = options;
3288
+ const isActive = ref(false);
3289
+ let rafId = null;
3290
+ function loop() {
3291
+ if (!isActive.value || !window2)
3292
+ return;
3293
+ fn();
3294
+ rafId = window2.requestAnimationFrame(loop);
3295
+ }
3296
+ function resume() {
3297
+ if (!isActive.value && window2) {
3298
+ isActive.value = true;
3299
+ loop();
3300
+ }
3301
+ }
3302
+ function pause() {
3303
+ isActive.value = false;
3304
+ if (rafId != null && window2) {
3305
+ window2.cancelAnimationFrame(rafId);
3306
+ rafId = null;
3307
+ }
3308
+ }
3309
+ if (immediate)
3310
+ resume();
3311
+ tryOnScopeDispose(pause);
3312
+ return {
3313
+ isActive,
3314
+ pause,
3315
+ resume
3316
+ };
3317
+ }
3318
+ function useElementSize$1(target, initialSize = { width: 0, height: 0 }, options = {}) {
3319
+ const width = ref(initialSize.width);
3320
+ const height = ref(initialSize.height);
3321
+ useResizeObserver$1(target, ([entry]) => {
3322
+ width.value = entry.contentRect.width;
3323
+ height.value = entry.contentRect.height;
3324
+ }, options);
3325
+ watch(() => unrefElement$1(target), (ele) => {
3326
+ width.value = ele ? initialSize.width : 0;
3327
+ height.value = ele ? initialSize.height : 0;
3328
+ });
3329
+ return {
3330
+ width,
3331
+ height
3332
+ };
3333
+ }
3334
+ function useElementVisibility$1(element, { window: window2 = defaultWindow$1, scrollTarget } = {}) {
3335
+ const elementIsVisible = ref(false);
3336
+ const testBounding = () => {
3337
+ if (!window2)
3338
+ return;
3339
+ const document2 = window2.document;
3340
+ if (!unref(element)) {
3341
+ elementIsVisible.value = false;
3342
+ } else {
3343
+ const rect = unref(element).getBoundingClientRect();
3344
+ elementIsVisible.value = rect.top <= (window2.innerHeight || document2.documentElement.clientHeight) && rect.left <= (window2.innerWidth || document2.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0;
3345
+ }
3346
+ };
3347
+ tryOnMounted(testBounding);
3348
+ if (window2)
3349
+ tryOnMounted(() => useEventListener$1(unref(scrollTarget) || window2, "scroll", testBounding, { capture: false, passive: true }));
3350
+ return elementIsVisible;
3351
+ }
3352
+ function useEyeDropper(options = {}) {
3353
+ const { initialValue = "" } = options;
3354
+ const isSupported = Boolean(typeof window !== "undefined" && "EyeDropper" in window);
3355
+ const sRGBHex = ref(initialValue);
3356
+ async function open(openOptions) {
3357
+ if (!isSupported)
3358
+ return;
3359
+ const eyeDropper = new window.EyeDropper();
3360
+ const result = await eyeDropper.open(openOptions);
3361
+ sRGBHex.value = result.sRGBHex;
3362
+ return result;
3363
+ }
3364
+ return { isSupported, sRGBHex, open };
3365
+ }
3366
+ const functionsMap = [
3367
+ [
3368
+ "requestFullscreen",
3369
+ "exitFullscreen",
3370
+ "fullscreenElement",
3371
+ "fullscreenEnabled",
3372
+ "fullscreenchange",
3373
+ "fullscreenerror"
3374
+ ],
3375
+ [
3376
+ "webkitRequestFullscreen",
3377
+ "webkitExitFullscreen",
3378
+ "webkitFullscreenElement",
3379
+ "webkitFullscreenEnabled",
3380
+ "webkitfullscreenchange",
3381
+ "webkitfullscreenerror"
3382
+ ],
3383
+ [
3384
+ "webkitRequestFullScreen",
3385
+ "webkitCancelFullScreen",
3386
+ "webkitCurrentFullScreenElement",
3387
+ "webkitCancelFullScreen",
3388
+ "webkitfullscreenchange",
3389
+ "webkitfullscreenerror"
3390
+ ],
3391
+ [
3392
+ "mozRequestFullScreen",
3393
+ "mozCancelFullScreen",
3394
+ "mozFullScreenElement",
3395
+ "mozFullScreenEnabled",
3396
+ "mozfullscreenchange",
3397
+ "mozfullscreenerror"
3398
+ ],
3399
+ [
3400
+ "msRequestFullscreen",
3401
+ "msExitFullscreen",
3402
+ "msFullscreenElement",
3403
+ "msFullscreenEnabled",
3404
+ "MSFullscreenChange",
3405
+ "MSFullscreenError"
3406
+ ]
3407
+ ];
3408
+ function useFullscreen(target, options = {}) {
3409
+ const { document: document2 = defaultDocument, autoExit = false } = options;
3410
+ const targetRef = target || (document2 == null ? void 0 : document2.querySelector("html"));
3411
+ const isFullscreen = ref(false);
3412
+ let isSupported = false;
3413
+ let map = functionsMap[0];
3414
+ if (!document2) {
3415
+ isSupported = false;
3416
+ } else {
3417
+ for (const m of functionsMap) {
3418
+ if (m[1] in document2) {
3419
+ map = m;
3420
+ isSupported = true;
3421
+ break;
3422
+ }
3423
+ }
3424
+ }
3425
+ const [REQUEST, EXIT, ELEMENT, , EVENT] = map;
3426
+ async function exit() {
3427
+ if (!isSupported)
3428
+ return;
3429
+ if (document2 == null ? void 0 : document2[ELEMENT])
3430
+ await document2[EXIT]();
3431
+ isFullscreen.value = false;
3432
+ }
3433
+ async function enter() {
3434
+ if (!isSupported)
3435
+ return;
3436
+ await exit();
3437
+ const target2 = unrefElement$1(targetRef);
3438
+ if (target2) {
3439
+ await target2[REQUEST]();
3440
+ isFullscreen.value = true;
3441
+ }
3442
+ }
3443
+ async function toggle() {
3444
+ if (isFullscreen.value)
3445
+ await exit();
3446
+ else
3447
+ await enter();
3448
+ }
3449
+ if (document2) {
3450
+ useEventListener$1(document2, EVENT, () => {
3451
+ isFullscreen.value = !!(document2 == null ? void 0 : document2[ELEMENT]);
3452
+ }, false);
3453
+ }
3454
+ if (autoExit)
3455
+ tryOnScopeDispose(exit);
3456
+ return {
3457
+ isSupported,
3458
+ isFullscreen,
3459
+ enter,
3460
+ exit,
3461
+ toggle
3462
+ };
3463
+ }
3464
+ function useGeolocation(options = {}) {
3465
+ const {
3466
+ enableHighAccuracy = true,
3467
+ maximumAge = 3e4,
3468
+ timeout = 27e3,
3469
+ navigator = defaultNavigator
3470
+ } = options;
3471
+ const isSupported = navigator && "geolocation" in navigator;
3472
+ const locatedAt = ref(null);
3473
+ const error = ref(null);
3474
+ const coords = ref({
3475
+ accuracy: 0,
3476
+ latitude: Infinity,
3477
+ longitude: Infinity,
3478
+ altitude: null,
3479
+ altitudeAccuracy: null,
3480
+ heading: null,
3481
+ speed: null
3482
+ });
3483
+ function updatePosition(position) {
3484
+ locatedAt.value = position.timestamp;
3485
+ coords.value = position.coords;
3486
+ error.value = null;
3487
+ }
3488
+ let watcher;
3489
+ if (isSupported) {
3490
+ watcher = navigator.geolocation.watchPosition(updatePosition, (err) => error.value = err, {
3491
+ enableHighAccuracy,
3492
+ maximumAge,
3493
+ timeout
3494
+ });
3495
+ }
3496
+ tryOnScopeDispose(() => {
3497
+ if (watcher && navigator)
3498
+ navigator.geolocation.clearWatch(watcher);
3499
+ });
3500
+ return {
3501
+ isSupported,
3502
+ coords,
3503
+ locatedAt,
3504
+ error
3505
+ };
3506
+ }
3507
+ const defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
3508
+ const oneMinute = 6e4;
3509
+ function useIdle(timeout = oneMinute, options = {}) {
3510
+ const {
3511
+ initialState = false,
3512
+ listenForVisibilityChange = true,
3513
+ events = defaultEvents$1,
3514
+ window: window2 = defaultWindow$1,
3515
+ eventFilter = throttleFilter(50)
3516
+ } = options;
3517
+ const idle = ref(initialState);
3518
+ const lastActive = ref(timestamp());
3519
+ let timer;
3520
+ const onEvent = createFilterWrapper(eventFilter, () => {
3521
+ idle.value = false;
3522
+ lastActive.value = timestamp();
3523
+ clearTimeout(timer);
3524
+ timer = setTimeout(() => idle.value = true, timeout);
3525
+ });
3526
+ if (window2) {
3527
+ const document2 = window2.document;
3528
+ for (const event of events)
3529
+ useEventListener$1(window2, event, onEvent, { passive: true });
3530
+ if (listenForVisibilityChange) {
3531
+ useEventListener$1(document2, "visibilitychange", () => {
3532
+ if (!document2.hidden)
3533
+ onEvent();
3534
+ });
3535
+ }
3536
+ }
3537
+ timer = setTimeout(() => idle.value = true, timeout);
3538
+ return { idle, lastActive };
3539
+ }
3540
+ function useMouse(options = {}) {
3541
+ const {
3542
+ type = "page",
3543
+ touch = true,
3544
+ resetOnTouchEnds = false,
3545
+ initialValue = { x: 0, y: 0 },
3546
+ window: window2 = defaultWindow$1,
3547
+ eventFilter
3548
+ } = options;
3549
+ const x = ref(initialValue.x);
3550
+ const y = ref(initialValue.y);
3551
+ const sourceType = ref(null);
3552
+ const mouseHandler = (event) => {
3553
+ if (type === "page") {
3554
+ x.value = event.pageX;
3555
+ y.value = event.pageY;
3556
+ } else if (type === "client") {
3557
+ x.value = event.clientX;
3558
+ y.value = event.clientY;
3559
+ }
3560
+ sourceType.value = "mouse";
3561
+ };
3562
+ const reset = () => {
3563
+ x.value = initialValue.x;
3564
+ y.value = initialValue.y;
3565
+ };
3566
+ const touchHandler = (event) => {
3567
+ if (event.touches.length > 0) {
3568
+ const touch2 = event.touches[0];
3569
+ if (type === "page") {
3570
+ x.value = touch2.pageX;
3571
+ y.value = touch2.pageY;
3572
+ } else if (type === "client") {
3573
+ x.value = touch2.clientX;
3574
+ y.value = touch2.clientY;
3575
+ }
3576
+ sourceType.value = "touch";
3577
+ }
3578
+ };
3579
+ const mouseHandlerWrapper = (event) => {
3580
+ return eventFilter === void 0 ? mouseHandler(event) : eventFilter(() => mouseHandler(event), {});
3581
+ };
3582
+ const touchHandlerWrapper = (event) => {
3583
+ return eventFilter === void 0 ? touchHandler(event) : eventFilter(() => touchHandler(event), {});
3584
+ };
3585
+ if (window2) {
3586
+ useEventListener$1(window2, "mousemove", mouseHandlerWrapper, { passive: true });
3587
+ useEventListener$1(window2, "dragover", mouseHandlerWrapper, { passive: true });
3588
+ if (touch) {
3589
+ useEventListener$1(window2, "touchstart", touchHandlerWrapper, { passive: true });
3590
+ useEventListener$1(window2, "touchmove", touchHandlerWrapper, { passive: true });
3591
+ if (resetOnTouchEnds)
3592
+ useEventListener$1(window2, "touchend", reset, { passive: true });
3593
+ }
3594
+ }
3595
+ return {
3596
+ x,
3597
+ y,
3598
+ sourceType
3599
+ };
3600
+ }
3601
+ function useMouseInElement(target, options = {}) {
3602
+ const {
3603
+ handleOutside = true,
3604
+ window: window2 = defaultWindow$1
3605
+ } = options;
3606
+ const { x, y, sourceType } = useMouse(options);
3607
+ const targetRef = ref(target != null ? target : window2 == null ? void 0 : window2.document.body);
3608
+ const elementX = ref(0);
3609
+ const elementY = ref(0);
3610
+ const elementPositionX = ref(0);
3611
+ const elementPositionY = ref(0);
3612
+ const elementHeight = ref(0);
3613
+ const elementWidth = ref(0);
3614
+ const isOutside = ref(true);
3615
+ let stop = () => {
3616
+ };
3617
+ if (window2) {
3618
+ stop = watch([targetRef, x, y], () => {
3619
+ const el = unrefElement$1(targetRef);
3620
+ if (!el)
3621
+ return;
3622
+ const {
3623
+ left,
3624
+ top,
3625
+ width,
3626
+ height
3627
+ } = el.getBoundingClientRect();
3628
+ elementPositionX.value = left + window2.pageXOffset;
3629
+ elementPositionY.value = top + window2.pageYOffset;
3630
+ elementHeight.value = height;
3631
+ elementWidth.value = width;
3632
+ const elX = x.value - elementPositionX.value;
3633
+ const elY = y.value - elementPositionY.value;
3634
+ isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height;
3635
+ if (handleOutside || !isOutside.value) {
3636
+ elementX.value = elX;
3637
+ elementY.value = elY;
3638
+ }
3639
+ }, { immediate: true });
3640
+ }
3641
+ return {
3642
+ x,
3643
+ y,
3644
+ sourceType,
3645
+ elementX,
3646
+ elementY,
3647
+ elementPositionX,
3648
+ elementPositionY,
3649
+ elementHeight,
3650
+ elementWidth,
3651
+ isOutside,
3652
+ stop
3653
+ };
3654
+ }
3655
+ function useMousePressed(options = {}) {
3656
+ const {
3657
+ touch = true,
3658
+ drag = true,
3659
+ initialValue = false,
3660
+ window: window2 = defaultWindow$1
3661
+ } = options;
3662
+ const pressed = ref(initialValue);
3663
+ const sourceType = ref(null);
3664
+ if (!window2) {
3665
+ return {
3666
+ pressed,
3667
+ sourceType
3668
+ };
3669
+ }
3670
+ const onPressed = (srcType) => () => {
3671
+ pressed.value = true;
3672
+ sourceType.value = srcType;
3673
+ };
3674
+ const onReleased = () => {
3675
+ pressed.value = false;
3676
+ sourceType.value = null;
3677
+ };
3678
+ const target = computed(() => unrefElement$1(options.target) || window2);
3679
+ useEventListener$1(target, "mousedown", onPressed("mouse"), { passive: true });
3680
+ useEventListener$1(window2, "mouseleave", onReleased, { passive: true });
3681
+ useEventListener$1(window2, "mouseup", onReleased, { passive: true });
3682
+ if (drag) {
3683
+ useEventListener$1(target, "dragstart", onPressed("mouse"), { passive: true });
3684
+ useEventListener$1(window2, "drop", onReleased, { passive: true });
3685
+ useEventListener$1(window2, "dragend", onReleased, { passive: true });
3686
+ }
3687
+ if (touch) {
3688
+ useEventListener$1(target, "touchstart", onPressed("touch"), { passive: true });
3689
+ useEventListener$1(window2, "touchend", onReleased, { passive: true });
3690
+ useEventListener$1(window2, "touchcancel", onReleased, { passive: true });
3691
+ }
3692
+ return {
3693
+ pressed,
3694
+ sourceType
3695
+ };
3696
+ }
3697
+ function useNetwork(options = {}) {
3698
+ const { window: window2 = defaultWindow$1 } = options;
3699
+ const navigator = window2 == null ? void 0 : window2.navigator;
3700
+ const isSupported = Boolean(navigator && "connection" in navigator);
3701
+ const isOnline = ref(true);
3702
+ const saveData = ref(false);
3703
+ const offlineAt = ref(void 0);
3704
+ const onlineAt = ref(void 0);
3705
+ const downlink = ref(void 0);
3706
+ const downlinkMax = ref(void 0);
3707
+ const rtt = ref(void 0);
3708
+ const effectiveType = ref(void 0);
3709
+ const type = ref("unknown");
3710
+ const connection = isSupported && navigator.connection;
3711
+ function updateNetworkInformation() {
3712
+ if (!navigator)
3713
+ return;
3714
+ isOnline.value = navigator.onLine;
3715
+ offlineAt.value = isOnline.value ? void 0 : Date.now();
3716
+ onlineAt.value = isOnline.value ? Date.now() : void 0;
3717
+ if (connection) {
3718
+ downlink.value = connection.downlink;
3719
+ downlinkMax.value = connection.downlinkMax;
3720
+ effectiveType.value = connection.effectiveType;
3721
+ rtt.value = connection.rtt;
3722
+ saveData.value = connection.saveData;
3723
+ type.value = connection.type;
3724
+ }
3725
+ }
3726
+ if (window2) {
3727
+ useEventListener$1(window2, "offline", () => {
3728
+ isOnline.value = false;
3729
+ offlineAt.value = Date.now();
3730
+ });
3731
+ useEventListener$1(window2, "online", () => {
3732
+ isOnline.value = true;
3733
+ onlineAt.value = Date.now();
3734
+ });
3735
+ }
3736
+ if (connection)
3737
+ useEventListener$1(connection, "change", updateNetworkInformation, false);
3738
+ updateNetworkInformation();
3739
+ return {
3740
+ isSupported,
3741
+ isOnline,
3742
+ saveData,
3743
+ offlineAt,
3744
+ onlineAt,
3745
+ downlink,
3746
+ downlinkMax,
3747
+ effectiveType,
3748
+ rtt,
3749
+ type
3750
+ };
3751
+ }
3752
+ var __defProp$5$1 = Object.defineProperty;
3753
+ var __getOwnPropSymbols$5$1 = Object.getOwnPropertySymbols;
3754
+ var __hasOwnProp$5$1 = Object.prototype.hasOwnProperty;
3755
+ var __propIsEnum$5$1 = Object.prototype.propertyIsEnumerable;
3756
+ var __defNormalProp$5$1 = (obj, key, value) => key in obj ? __defProp$5$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3757
+ var __spreadValues$5$1 = (a, b) => {
3758
+ for (var prop in b || (b = {}))
3759
+ if (__hasOwnProp$5$1.call(b, prop))
3760
+ __defNormalProp$5$1(a, prop, b[prop]);
3761
+ if (__getOwnPropSymbols$5$1)
3762
+ for (var prop of __getOwnPropSymbols$5$1(b)) {
3763
+ if (__propIsEnum$5$1.call(b, prop))
3764
+ __defNormalProp$5$1(a, prop, b[prop]);
3765
+ }
3766
+ return a;
3767
+ };
3768
+ function useNow(options = {}) {
3769
+ const {
3770
+ controls: exposeControls = false,
3771
+ interval = "requestAnimationFrame"
3772
+ } = options;
3773
+ const now = ref(new Date());
3774
+ const update = () => now.value = new Date();
3775
+ const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate: true }) : useIntervalFn(update, interval, { immediate: true });
3776
+ if (exposeControls) {
3777
+ return __spreadValues$5$1({
3778
+ now
3779
+ }, controls);
3780
+ } else {
3781
+ return now;
3782
+ }
3783
+ }
3784
+ function useObjectUrl(object) {
3785
+ const url = ref();
3786
+ const release = () => {
3787
+ if (url.value)
3788
+ URL.revokeObjectURL(url.value);
3789
+ url.value = void 0;
3790
+ };
3791
+ watch(() => unref(object), (newObject) => {
3792
+ release();
3793
+ if (newObject)
3794
+ url.value = URL.createObjectURL(newObject);
3795
+ }, { immediate: true });
3796
+ tryOnScopeDispose(release);
3797
+ return readonly(url);
3798
+ }
3799
+ function useOffsetPagination(options) {
3800
+ const {
3801
+ total = Infinity,
3802
+ pageSize = 10,
3803
+ page = 1,
3804
+ onPageChange = noop,
3805
+ onPageSizeChange = noop,
3806
+ onPageCountChange = noop
3807
+ } = options;
3808
+ const currentPageSize = useClamp(pageSize, 1, Infinity);
3809
+ const pageCount = computed(() => Math.ceil(unref(total) / unref(currentPageSize)));
3810
+ const currentPage = useClamp(page, 1, pageCount);
3811
+ const isFirstPage = computed(() => currentPage.value === 1);
3812
+ const isLastPage = computed(() => currentPage.value === pageCount.value);
3813
+ if (isRef(page))
3814
+ syncRef(page, currentPage);
3815
+ if (isRef(pageSize))
3816
+ syncRef(pageSize, currentPageSize);
3817
+ function prev() {
3818
+ currentPage.value--;
3819
+ }
3820
+ function next() {
3821
+ currentPage.value++;
3822
+ }
3823
+ const returnValue = {
3824
+ currentPage,
3825
+ currentPageSize,
3826
+ pageCount,
3827
+ isFirstPage,
3828
+ isLastPage,
3829
+ prev,
3830
+ next
3831
+ };
3832
+ watch(currentPage, () => {
3833
+ onPageChange(reactive(returnValue));
3834
+ });
3835
+ watch(currentPageSize, () => {
3836
+ onPageSizeChange(reactive(returnValue));
3837
+ });
3838
+ watch(pageCount, () => {
3839
+ onPageCountChange(reactive(returnValue));
3840
+ });
3841
+ return returnValue;
3842
+ }
3843
+ function useOnline(options = {}) {
3844
+ const { isOnline } = useNetwork(options);
3845
+ return isOnline;
3846
+ }
3847
+ function usePageLeave(options = {}) {
3848
+ const { window: window2 = defaultWindow$1 } = options;
3849
+ const isLeft = ref(false);
3850
+ const handler = (event) => {
3851
+ if (!window2)
3852
+ return;
3853
+ event = event || window2.event;
3854
+ const from = event.relatedTarget || event.toElement;
3855
+ isLeft.value = !from;
3856
+ };
3857
+ if (window2) {
3858
+ useEventListener$1(window2, "mouseout", handler, { passive: true });
3859
+ useEventListener$1(window2.document, "mouseleave", handler, { passive: true });
3860
+ useEventListener$1(window2.document, "mouseenter", handler, { passive: true });
3861
+ }
3862
+ return isLeft;
3863
+ }
3864
+ var __defProp$4$1 = Object.defineProperty;
3865
+ var __defProps$1$1 = Object.defineProperties;
3866
+ var __getOwnPropDescs$1$1 = Object.getOwnPropertyDescriptors;
3867
+ var __getOwnPropSymbols$4$1 = Object.getOwnPropertySymbols;
3868
+ var __hasOwnProp$4$1 = Object.prototype.hasOwnProperty;
3869
+ var __propIsEnum$4$1 = Object.prototype.propertyIsEnumerable;
3870
+ var __defNormalProp$4$1 = (obj, key, value) => key in obj ? __defProp$4$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3871
+ var __spreadValues$4$1 = (a, b) => {
3872
+ for (var prop in b || (b = {}))
3873
+ if (__hasOwnProp$4$1.call(b, prop))
3874
+ __defNormalProp$4$1(a, prop, b[prop]);
3875
+ if (__getOwnPropSymbols$4$1)
3876
+ for (var prop of __getOwnPropSymbols$4$1(b)) {
3877
+ if (__propIsEnum$4$1.call(b, prop))
3878
+ __defNormalProp$4$1(a, prop, b[prop]);
3879
+ }
3880
+ return a;
3881
+ };
3882
+ var __spreadProps$1$1 = (a, b) => __defProps$1$1(a, __getOwnPropDescs$1$1(b));
3883
+ const defaultState = {
3884
+ x: 0,
3885
+ y: 0,
3886
+ pointerId: 0,
3887
+ pressure: 0,
3888
+ tiltX: 0,
3889
+ tiltY: 0,
3890
+ width: 0,
3891
+ height: 0,
3892
+ twist: 0,
3893
+ pointerType: null
3894
+ };
3895
+ const keys = /* @__PURE__ */ Object.keys(defaultState);
3896
+ function usePointer(options = {}) {
3897
+ const {
3898
+ target = defaultWindow$1
3899
+ } = options;
3900
+ const isInside = ref(false);
3901
+ const state = ref(options.initialValue || {});
3902
+ Object.assign(state.value, defaultState, state.value);
3903
+ const handler = (event) => {
3904
+ isInside.value = true;
3905
+ if (options.pointerTypes && !options.pointerTypes.includes(event.pointerType))
3906
+ return;
3907
+ state.value = objectPick(event, keys, false);
3908
+ };
3909
+ if (target) {
3910
+ useEventListener$1(target, "pointerdown", handler, { passive: true });
3911
+ useEventListener$1(target, "pointermove", handler, { passive: true });
3912
+ useEventListener$1(target, "pointerleave", () => isInside.value = false, { passive: true });
3913
+ }
3914
+ return __spreadProps$1$1(__spreadValues$4$1({}, toRefs(state)), {
3915
+ isInside
3916
+ });
3917
+ }
3918
+ var SwipeDirection;
3919
+ (function(SwipeDirection2) {
3920
+ SwipeDirection2["UP"] = "UP";
3921
+ SwipeDirection2["RIGHT"] = "RIGHT";
3922
+ SwipeDirection2["DOWN"] = "DOWN";
3923
+ SwipeDirection2["LEFT"] = "LEFT";
3924
+ SwipeDirection2["NONE"] = "NONE";
3925
+ })(SwipeDirection || (SwipeDirection = {}));
3926
+ function usePreferredColorScheme(options) {
3927
+ const isLight = useMediaQuery$1("(prefers-color-scheme: light)", options);
3928
+ const isDark = useMediaQuery$1("(prefers-color-scheme: dark)", options);
3929
+ return computed(() => {
3930
+ if (isDark.value)
3931
+ return "dark";
3932
+ if (isLight.value)
3933
+ return "light";
3934
+ return "no-preference";
3935
+ });
3936
+ }
3937
+ function usePreferredLanguages(options = {}) {
3938
+ const { window: window2 = defaultWindow$1 } = options;
3939
+ if (!window2)
3940
+ return ref(["en"]);
3941
+ const navigator = window2.navigator;
3942
+ const value = ref(navigator.languages);
3943
+ useEventListener$1(window2, "languagechange", () => {
3944
+ value.value = navigator.languages;
3945
+ });
3946
+ return value;
3947
+ }
3948
+ var __defProp$1$1 = Object.defineProperty;
3949
+ var __getOwnPropSymbols$1$1 = Object.getOwnPropertySymbols;
3950
+ var __hasOwnProp$1$1 = Object.prototype.hasOwnProperty;
3951
+ var __propIsEnum$1$1 = Object.prototype.propertyIsEnumerable;
3952
+ var __defNormalProp$1$1 = (obj, key, value) => key in obj ? __defProp$1$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3953
+ var __spreadValues$1$1 = (a, b) => {
3954
+ for (var prop in b || (b = {}))
3955
+ if (__hasOwnProp$1$1.call(b, prop))
3956
+ __defNormalProp$1$1(a, prop, b[prop]);
3957
+ if (__getOwnPropSymbols$1$1)
3958
+ for (var prop of __getOwnPropSymbols$1$1(b)) {
3959
+ if (__propIsEnum$1$1.call(b, prop))
3960
+ __defNormalProp$1$1(a, prop, b[prop]);
3961
+ }
3962
+ return a;
3963
+ };
3964
+ var __objRest$1 = (source, exclude) => {
3965
+ var target = {};
3966
+ for (var prop in source)
3967
+ if (__hasOwnProp$1$1.call(source, prop) && exclude.indexOf(prop) < 0)
3968
+ target[prop] = source[prop];
3969
+ if (source != null && __getOwnPropSymbols$1$1)
3970
+ for (var prop of __getOwnPropSymbols$1$1(source)) {
3971
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1$1.call(source, prop))
3972
+ target[prop] = source[prop];
3973
+ }
3974
+ return target;
3975
+ };
3976
+ const UNITS = [
3977
+ { max: 6e4, value: 1e3, name: "second" },
3978
+ { max: 276e4, value: 6e4, name: "minute" },
3979
+ { max: 72e6, value: 36e5, name: "hour" },
3980
+ { max: 5184e5, value: 864e5, name: "day" },
3981
+ { max: 24192e5, value: 6048e5, name: "week" },
3982
+ { max: 28512e6, value: 2592e6, name: "month" },
3983
+ { max: Infinity, value: 31536e6, name: "year" }
3984
+ ];
3985
+ const DEFAULT_MESSAGES = {
3986
+ justNow: "just now",
3987
+ past: (n) => n.match(/\d/) ? `${n} ago` : n,
3988
+ future: (n) => n.match(/\d/) ? `in ${n}` : n,
3989
+ month: (n, past) => n === 1 ? past ? "last month" : "next month" : `${n} month${n > 1 ? "s" : ""}`,
3990
+ year: (n, past) => n === 1 ? past ? "last year" : "next year" : `${n} year${n > 1 ? "s" : ""}`,
3991
+ day: (n, past) => n === 1 ? past ? "yesterday" : "tomorrow" : `${n} day${n > 1 ? "s" : ""}`,
3992
+ week: (n, past) => n === 1 ? past ? "last week" : "next week" : `${n} week${n > 1 ? "s" : ""}`,
3993
+ hour: (n) => `${n} hour${n > 1 ? "s" : ""}`,
3994
+ minute: (n) => `${n} minute${n > 1 ? "s" : ""}`,
3995
+ second: (n) => `${n} second${n > 1 ? "s" : ""}`
3996
+ };
3997
+ const DEFAULT_FORMATTER = (date) => date.toISOString().slice(0, 10);
3998
+ function useTimeAgo(time, options = {}) {
3999
+ const {
4000
+ controls: exposeControls = false,
4001
+ max,
4002
+ updateInterval = 3e4,
4003
+ messages = DEFAULT_MESSAGES,
4004
+ fullDateFormatter = DEFAULT_FORMATTER
4005
+ } = options;
4006
+ const { abs, round } = Math;
4007
+ const _a2 = useNow({ interval: updateInterval, controls: true }), { now } = _a2, controls = __objRest$1(_a2, ["now"]);
4008
+ function getTimeago(from, now2) {
4009
+ var _a22;
4010
+ const diff = +now2 - +from;
4011
+ const absDiff = abs(diff);
4012
+ if (absDiff < 6e4)
4013
+ return messages.justNow;
4014
+ if (typeof max === "number" && absDiff > max)
4015
+ return fullDateFormatter(new Date(from));
4016
+ if (typeof max === "string") {
4017
+ const unitMax = (_a22 = UNITS.find((i) => i.name === max)) == null ? void 0 : _a22.max;
4018
+ if (unitMax && absDiff > unitMax)
4019
+ return fullDateFormatter(new Date(from));
4020
+ }
4021
+ for (const unit of UNITS) {
4022
+ if (absDiff < unit.max)
4023
+ return format(diff, unit);
4024
+ }
4025
+ }
4026
+ function applyFormat(name, val, isPast) {
4027
+ const formatter = messages[name];
4028
+ if (typeof formatter === "function")
4029
+ return formatter(val, isPast);
4030
+ return formatter.replace("{0}", val.toString());
4031
+ }
4032
+ function format(diff, unit) {
4033
+ const val = round(abs(diff) / unit.value);
4034
+ const past = diff > 0;
4035
+ const str = applyFormat(unit.name, val, past);
4036
+ return applyFormat(past ? "past" : "future", str, past);
4037
+ }
4038
+ const timeAgo = computed(() => getTimeago(new Date(unref(time)), unref(now.value)));
4039
+ if (exposeControls) {
4040
+ return __spreadValues$1$1({
4041
+ timeAgo
4042
+ }, controls);
4043
+ } else {
4044
+ return timeAgo;
4045
+ }
4046
+ }
4047
+ var __defProp$e = Object.defineProperty;
4048
+ var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
4049
+ var __hasOwnProp$g = Object.prototype.hasOwnProperty;
4050
+ var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
4051
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4052
+ var __spreadValues$e = (a, b) => {
4053
+ for (var prop in b || (b = {}))
4054
+ if (__hasOwnProp$g.call(b, prop))
4055
+ __defNormalProp$e(a, prop, b[prop]);
4056
+ if (__getOwnPropSymbols$g)
4057
+ for (var prop of __getOwnPropSymbols$g(b)) {
4058
+ if (__propIsEnum$g.call(b, prop))
4059
+ __defNormalProp$e(a, prop, b[prop]);
4060
+ }
4061
+ return a;
4062
+ };
4063
+ function useTimestamp(options = {}) {
4064
+ const {
4065
+ controls: exposeControls = false,
4066
+ offset = 0,
4067
+ immediate = true,
4068
+ interval = "requestAnimationFrame"
4069
+ } = options;
4070
+ const ts = ref(timestamp() + offset);
4071
+ const update = () => ts.value = timestamp() + offset;
4072
+ const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate }) : useIntervalFn(update, interval, { immediate });
4073
+ if (exposeControls) {
4074
+ return __spreadValues$e({
4075
+ timestamp: ts
4076
+ }, controls);
4077
+ } else {
4078
+ return ts;
4079
+ }
4080
+ }
4081
+ function useVirtualList(list, options) {
4082
+ const containerRef = ref();
4083
+ const size = useElementSize$1(containerRef);
4084
+ const currentList = ref([]);
4085
+ const source = shallowRef(list);
4086
+ const state = ref({ start: 0, end: 10 });
4087
+ const { itemHeight, overscan = 5 } = options;
4088
+ const getViewCapacity = (containerHeight) => {
4089
+ if (typeof itemHeight === "number")
4090
+ return Math.ceil(containerHeight / itemHeight);
4091
+ const { start = 0 } = state.value;
4092
+ let sum = 0;
4093
+ let capacity = 0;
4094
+ for (let i = start; i < source.value.length; i++) {
4095
+ const height = itemHeight(i);
4096
+ sum += height;
4097
+ if (sum >= containerHeight) {
4098
+ capacity = i;
4099
+ break;
4100
+ }
4101
+ }
4102
+ return capacity - start;
4103
+ };
4104
+ const getOffset = (scrollTop) => {
4105
+ if (typeof itemHeight === "number")
4106
+ return Math.floor(scrollTop / itemHeight) + 1;
4107
+ let sum = 0;
4108
+ let offset = 0;
4109
+ for (let i = 0; i < source.value.length; i++) {
4110
+ const height = itemHeight(i);
4111
+ sum += height;
4112
+ if (sum >= scrollTop) {
4113
+ offset = i;
4114
+ break;
4115
+ }
4116
+ }
4117
+ return offset + 1;
4118
+ };
4119
+ const calculateRange = () => {
4120
+ const element = containerRef.value;
4121
+ if (element) {
4122
+ const offset = getOffset(element.scrollTop);
4123
+ const viewCapacity = getViewCapacity(element.clientHeight);
4124
+ const from = offset - overscan;
4125
+ const to = offset + viewCapacity + overscan;
4126
+ state.value = {
4127
+ start: from < 0 ? 0 : from,
4128
+ end: to > source.value.length ? source.value.length : to
4129
+ };
4130
+ currentList.value = source.value.slice(state.value.start, state.value.end).map((ele, index) => ({
4131
+ data: ele,
4132
+ index: index + state.value.start
4133
+ }));
4134
+ }
4135
+ };
4136
+ watch([size.width, size.height, list], () => {
4137
+ calculateRange();
4138
+ });
4139
+ const totalHeight = computed(() => {
4140
+ if (typeof itemHeight === "number")
4141
+ return source.value.length * itemHeight;
4142
+ return source.value.reduce((sum, _, index) => sum + itemHeight(index), 0);
4143
+ });
4144
+ const getDistanceTop = (index) => {
4145
+ if (typeof itemHeight === "number") {
4146
+ const height2 = index * itemHeight;
4147
+ return height2;
4148
+ }
4149
+ const height = source.value.slice(0, index).reduce((sum, _, i) => sum + itemHeight(i), 0);
4150
+ return height;
4151
+ };
4152
+ const scrollTo = (index) => {
4153
+ if (containerRef.value) {
4154
+ containerRef.value.scrollTop = getDistanceTop(index);
4155
+ calculateRange();
4156
+ }
4157
+ };
4158
+ const offsetTop = computed(() => getDistanceTop(state.value.start));
4159
+ const wrapperProps = computed(() => {
4160
+ return {
4161
+ style: {
4162
+ width: "100%",
4163
+ height: `${totalHeight.value - offsetTop.value}px`,
4164
+ marginTop: `${offsetTop.value}px`
4165
+ }
4166
+ };
4167
+ });
4168
+ const containerStyle = { overflowY: "auto" };
4169
+ return {
4170
+ list: currentList,
4171
+ scrollTo,
4172
+ containerProps: {
4173
+ ref: containerRef,
4174
+ onScroll: () => {
4175
+ calculateRange();
4176
+ },
4177
+ style: containerStyle
4178
+ },
4179
+ wrapperProps
4180
+ };
4181
+ }
4182
+ function useWindowFocus({ window: window2 = defaultWindow$1 } = {}) {
4183
+ if (!window2)
4184
+ return ref(false);
4185
+ const focused = ref(window2.document.hasFocus());
4186
+ useEventListener$1(window2, "blur", () => {
4187
+ focused.value = false;
4188
+ });
4189
+ useEventListener$1(window2, "focus", () => {
4190
+ focused.value = true;
4191
+ });
4192
+ return focused;
4193
+ }
4194
+ function useWindowSize(options = {}) {
4195
+ const {
4196
+ window: window2 = defaultWindow$1,
4197
+ initialWidth = Infinity,
4198
+ initialHeight = Infinity,
4199
+ listenOrientation = true
4200
+ } = options;
4201
+ const width = ref(initialWidth);
4202
+ const height = ref(initialHeight);
4203
+ const update = () => {
4204
+ if (window2) {
4205
+ width.value = window2.innerWidth;
4206
+ height.value = window2.innerHeight;
4207
+ }
4208
+ };
4209
+ update();
4210
+ tryOnMounted(update);
4211
+ useEventListener$1("resize", update, { passive: true });
4212
+ if (listenOrientation)
4213
+ useEventListener$1("orientationchange", update, { passive: true });
4214
+ return { width, height };
4215
+ }
4216
+ defineComponent({
4217
+ name: "OnClickOutside",
4218
+ props: ["as"],
4219
+ emits: ["trigger"],
4220
+ setup(props, { slots, emit }) {
4221
+ const target = ref();
4222
+ onClickOutside(target, (e) => {
4223
+ emit("trigger", e);
4224
+ });
4225
+ return () => {
4226
+ if (slots.default)
4227
+ return h(props.as || "div", { ref: target }, slots.default());
4228
+ };
4229
+ }
4230
+ });
4231
+ function unrefElement(elRef) {
4232
+ var _a2;
4233
+ const plain = unref(elRef);
4234
+ return (_a2 = plain == null ? void 0 : plain.$el) != null ? _a2 : plain;
4235
+ }
4236
+ const defaultWindow = isClient ? window : void 0;
4237
+ function useEventListener(...args) {
4238
+ let target;
4239
+ let event;
4240
+ let listener;
4241
+ let options;
4242
+ if (isString(args[0])) {
4243
+ [event, listener, options] = args;
4244
+ target = defaultWindow;
4245
+ } else {
4246
+ [target, event, listener, options] = args;
4247
+ }
4248
+ if (!target)
4249
+ return noop;
4250
+ let cleanup = noop;
4251
+ const stopWatch = watch(() => unrefElement(target), (el) => {
4252
+ cleanup();
4253
+ if (!el)
4254
+ return;
4255
+ el.addEventListener(event, listener, options);
4256
+ cleanup = () => {
4257
+ el.removeEventListener(event, listener, options);
4258
+ cleanup = noop;
4259
+ };
4260
+ }, { immediate: true, flush: "post" });
4261
+ const stop = () => {
4262
+ stopWatch();
4263
+ cleanup();
4264
+ };
4265
+ tryOnScopeDispose(stop);
4266
+ return stop;
4267
+ }
4268
+ const createKeyPredicate = (keyFilter) => {
4269
+ if (typeof keyFilter === "function")
4270
+ return keyFilter;
4271
+ else if (typeof keyFilter === "string")
4272
+ return (event) => event.key === keyFilter;
4273
+ else if (Array.isArray(keyFilter))
4274
+ return (event) => keyFilter.includes(event.key);
4275
+ else if (keyFilter)
4276
+ return () => true;
4277
+ else
4278
+ return () => false;
4279
+ };
4280
+ function onKeyStroke(key, handler, options = {}) {
4281
+ const { target = defaultWindow, eventName = "keydown", passive = false } = options;
4282
+ const predicate = createKeyPredicate(key);
4283
+ const listener = (e) => {
4284
+ if (predicate(e))
4285
+ handler(e);
4286
+ };
4287
+ return useEventListener(target, eventName, listener, passive);
4288
+ }
4289
+ var __defProp$c = Object.defineProperty;
4290
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
4291
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
4292
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
4293
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4294
+ var __spreadValues$c = (a, b) => {
4295
+ for (var prop in b || (b = {}))
4296
+ if (__hasOwnProp$d.call(b, prop))
4297
+ __defNormalProp$c(a, prop, b[prop]);
4298
+ if (__getOwnPropSymbols$d)
4299
+ for (var prop of __getOwnPropSymbols$d(b)) {
4300
+ if (__propIsEnum$d.call(b, prop))
4301
+ __defNormalProp$c(a, prop, b[prop]);
4302
+ }
4303
+ return a;
4304
+ };
4305
+ ({
4306
+ [directiveHooks.mounted](el, binding) {
4307
+ var _a2, _b;
4308
+ const keys2 = (_b = (_a2 = binding.arg) == null ? void 0 : _a2.split(",")) != null ? _b : [];
4309
+ if (typeof binding.value === "function") {
4310
+ onKeyStroke(keys2, binding.value, {
4311
+ target: el
4312
+ });
4313
+ } else {
4314
+ const [handler, options] = binding.value;
4315
+ onKeyStroke(keys2, handler, __spreadValues$c({
4316
+ target: el
4317
+ }, options));
4318
+ }
4319
+ }
4320
+ });
4321
+ const DEFAULT_DELAY = 500;
4322
+ function onLongPress(target, handler, options) {
4323
+ var _a2, _b;
4324
+ const elementRef = computed(() => unrefElement(target));
4325
+ let timeout = null;
4326
+ function clear() {
4327
+ if (timeout != null) {
4328
+ clearTimeout(timeout);
4329
+ timeout = null;
4330
+ }
4331
+ }
4332
+ function onDown(ev) {
4333
+ var _a22, _b2, _c, _d;
4334
+ if (((_a22 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a22.self) && ev.target !== elementRef.value)
4335
+ return;
4336
+ clear();
4337
+ if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
4338
+ ev.preventDefault();
4339
+ if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
4340
+ ev.stopPropagation();
4341
+ timeout = setTimeout(() => handler(ev), (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY);
4342
+ }
4343
+ const listenerOptions = {
4344
+ capture: (_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.capture,
4345
+ once: (_b = options == null ? void 0 : options.modifiers) == null ? void 0 : _b.once
4346
+ };
4347
+ useEventListener(elementRef, "pointerdown", onDown, listenerOptions);
4348
+ useEventListener(elementRef, "pointerup", clear, listenerOptions);
4349
+ useEventListener(elementRef, "pointerleave", clear, listenerOptions);
4350
+ }
4351
+ defineComponent({
4352
+ name: "OnLongPress",
4353
+ props: ["as", "options"],
4354
+ emits: ["trigger"],
4355
+ setup(props, { slots, emit }) {
4356
+ const target = ref();
4357
+ onLongPress(target, (e) => {
4358
+ emit("trigger", e);
4359
+ }, props.options);
4360
+ return () => {
4361
+ if (slots.default)
4362
+ return h(props.as || "div", { ref: target }, slots.default());
4363
+ };
4364
+ }
4365
+ });
4366
+ ({
4367
+ [directiveHooks.mounted](el, binding) {
4368
+ if (typeof binding.value === "function")
4369
+ onLongPress(el, binding.value, { modifiers: binding.modifiers });
4370
+ else
4371
+ onLongPress(el, ...binding.value);
4372
+ }
4373
+ });
4374
+ defineComponent({
4375
+ name: "UseActiveElement",
4376
+ setup(props, { slots }) {
4377
+ const data = reactive({
4378
+ element: useActiveElement()
4379
+ });
4380
+ return () => {
4381
+ if (slots.default)
4382
+ return slots.default(data);
4383
+ };
4384
+ }
4385
+ });
4386
+ defineComponent({
4387
+ name: "UseBattery",
4388
+ setup(props, { slots }) {
4389
+ const data = reactive(useBattery(props));
4390
+ return () => {
4391
+ if (slots.default)
4392
+ return slots.default(data);
4393
+ };
4394
+ }
4395
+ });
4396
+ defineComponent({
4397
+ name: "UseBrowserLocation",
4398
+ setup(props, { slots }) {
4399
+ const data = reactive(useBrowserLocation());
4400
+ return () => {
4401
+ if (slots.default)
4402
+ return slots.default(data);
4403
+ };
4404
+ }
4405
+ });
4406
+ const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4407
+ const globalKey = "__vueuse_ssr_handlers__";
4408
+ _global[globalKey] = _global[globalKey] || {};
4409
+ const handlers = _global[globalKey];
4410
+ function getSSRHandler(key, fallback) {
4411
+ return handlers[key] || fallback;
4412
+ }
4413
+ function guessSerializerType(rawInit) {
4414
+ 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" : Array.isArray(rawInit) ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
4415
+ }
4416
+ const StorageSerializers = {
4417
+ boolean: {
4418
+ read: (v) => v === "true",
4419
+ write: (v) => String(v)
4420
+ },
4421
+ object: {
4422
+ read: (v) => JSON.parse(v),
4423
+ write: (v) => JSON.stringify(v)
4424
+ },
4425
+ number: {
4426
+ read: (v) => Number.parseFloat(v),
4427
+ write: (v) => String(v)
4428
+ },
4429
+ any: {
4430
+ read: (v) => v,
4431
+ write: (v) => String(v)
4432
+ },
4433
+ string: {
4434
+ read: (v) => v,
4435
+ write: (v) => String(v)
4436
+ },
4437
+ map: {
4438
+ read: (v) => new Map(JSON.parse(v)),
4439
+ write: (v) => JSON.stringify(Array.from(v.entries()))
4440
+ },
4441
+ set: {
4442
+ read: (v) => new Set(JSON.parse(v)),
4443
+ write: (v) => JSON.stringify(Array.from(v))
4444
+ },
4445
+ date: {
4446
+ read: (v) => new Date(v),
4447
+ write: (v) => v.toISOString()
4448
+ }
4449
+ };
4450
+ function useStorage(key, initialValue, storage, options = {}) {
4451
+ var _a2;
4452
+ const {
4453
+ flush = "pre",
4454
+ deep = true,
4455
+ listenToStorageChanges = true,
4456
+ writeDefaults = true,
4457
+ shallow,
4458
+ window: window2 = defaultWindow,
4459
+ eventFilter,
4460
+ onError = (e) => {
4461
+ console.error(e);
4462
+ }
4463
+ } = options;
4464
+ const data = (shallow ? shallowRef : ref)(initialValue);
4465
+ if (!storage) {
4466
+ try {
4467
+ storage = getSSRHandler("getDefaultStorage", () => {
4468
+ var _a22;
4469
+ return (_a22 = defaultWindow) == null ? void 0 : _a22.localStorage;
4470
+ })();
4471
+ } catch (e) {
4472
+ onError(e);
4473
+ }
4474
+ }
4475
+ if (!storage)
4476
+ return data;
4477
+ const rawInit = unref(initialValue);
4478
+ const type = guessSerializerType(rawInit);
4479
+ const serializer = (_a2 = options.serializer) != null ? _a2 : StorageSerializers[type];
4480
+ const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, () => write(data.value), { flush, deep, eventFilter });
4481
+ if (window2 && listenToStorageChanges)
4482
+ useEventListener(window2, "storage", update);
4483
+ update();
4484
+ return data;
4485
+ function write(v) {
4486
+ try {
4487
+ if (v == null)
4488
+ storage.removeItem(key);
4489
+ else
4490
+ storage.setItem(key, serializer.write(v));
4491
+ } catch (e) {
4492
+ onError(e);
4493
+ }
4494
+ }
4495
+ function read(event) {
4496
+ if (event && event.key !== key)
4497
+ return;
4498
+ pauseWatch();
4499
+ try {
4500
+ const rawValue = event ? event.newValue : storage.getItem(key);
4501
+ if (rawValue == null) {
4502
+ if (writeDefaults && rawInit !== null)
4503
+ storage.setItem(key, serializer.write(rawInit));
4504
+ return rawInit;
4505
+ } else if (typeof rawValue !== "string") {
4506
+ return rawValue;
4507
+ } else {
4508
+ return serializer.read(rawValue);
4509
+ }
4510
+ } catch (e) {
4511
+ onError(e);
4512
+ } finally {
4513
+ resumeWatch();
4514
+ }
4515
+ }
4516
+ function update(event) {
4517
+ if (event && event.key !== key)
4518
+ return;
4519
+ data.value = read(event);
4520
+ }
4521
+ }
4522
+ function useMediaQuery(query, options = {}) {
4523
+ const { window: window2 = defaultWindow } = options;
4524
+ const isSupported = Boolean(window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
4525
+ let mediaQuery;
4526
+ const matches = ref(false);
4527
+ const update = () => {
4528
+ if (!isSupported)
4529
+ return;
4530
+ if (!mediaQuery)
4531
+ mediaQuery = window2.matchMedia(query);
4532
+ matches.value = mediaQuery.matches;
4533
+ };
4534
+ tryOnBeforeMount(() => {
4535
+ update();
4536
+ if (!mediaQuery)
4537
+ return;
4538
+ if ("addEventListener" in mediaQuery)
4539
+ mediaQuery.addEventListener("change", update);
4540
+ else
4541
+ mediaQuery.addListener(update);
4542
+ tryOnScopeDispose(() => {
4543
+ if ("removeEventListener" in mediaQuery)
4544
+ mediaQuery.removeEventListener("change", update);
4545
+ else
4546
+ mediaQuery.removeListener(update);
4547
+ });
4548
+ });
4549
+ return matches;
4550
+ }
4551
+ function usePreferredDark(options) {
4552
+ return useMediaQuery("(prefers-color-scheme: dark)", options);
4553
+ }
4554
+ var __defProp$b = Object.defineProperty;
4555
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
4556
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
4557
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
4558
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4559
+ var __spreadValues$b = (a, b) => {
4560
+ for (var prop in b || (b = {}))
4561
+ if (__hasOwnProp$c.call(b, prop))
4562
+ __defNormalProp$b(a, prop, b[prop]);
4563
+ if (__getOwnPropSymbols$c)
4564
+ for (var prop of __getOwnPropSymbols$c(b)) {
4565
+ if (__propIsEnum$c.call(b, prop))
4566
+ __defNormalProp$b(a, prop, b[prop]);
4567
+ }
4568
+ return a;
4569
+ };
4570
+ function useColorMode(options = {}) {
4571
+ const {
4572
+ selector = "html",
4573
+ attribute = "class",
4574
+ window: window2 = defaultWindow,
4575
+ storage,
4576
+ storageKey = "vueuse-color-scheme",
4577
+ listenToStorageChanges = true,
4578
+ storageRef,
4579
+ emitAuto
4580
+ } = options;
4581
+ const modes = __spreadValues$b({
4582
+ auto: "",
4583
+ light: "light",
4584
+ dark: "dark"
4585
+ }, options.modes || {});
4586
+ const preferredDark = usePreferredDark({ window: window2 });
4587
+ const preferredMode = computed(() => preferredDark.value ? "dark" : "light");
4588
+ const store = storageRef || (storageKey == null ? ref("auto") : useStorage(storageKey, "auto", storage, { window: window2, listenToStorageChanges }));
4589
+ const state = computed({
4590
+ get() {
4591
+ return store.value === "auto" && !emitAuto ? preferredMode.value : store.value;
4592
+ },
4593
+ set(v) {
4594
+ store.value = v;
4595
+ }
4596
+ });
4597
+ const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector2, attribute2, value) => {
4598
+ const el = window2 == null ? void 0 : window2.document.querySelector(selector2);
4599
+ if (!el)
4600
+ return;
4601
+ if (attribute2 === "class") {
4602
+ const current = value.split(/\s/g);
4603
+ Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
4604
+ if (current.includes(v))
4605
+ el.classList.add(v);
4606
+ else
4607
+ el.classList.remove(v);
4608
+ });
4609
+ } else {
4610
+ el.setAttribute(attribute2, value);
4611
+ }
4612
+ });
4613
+ function defaultOnChanged(mode) {
4614
+ var _a2;
4615
+ const resolvedMode = mode === "auto" ? preferredMode.value : mode;
4616
+ updateHTMLAttrs(selector, attribute, (_a2 = modes[resolvedMode]) != null ? _a2 : resolvedMode);
4617
+ }
4618
+ function onChanged(mode) {
4619
+ if (options.onChanged)
4620
+ options.onChanged(mode, defaultOnChanged);
4621
+ else
4622
+ defaultOnChanged(mode);
4623
+ }
4624
+ watch(state, onChanged, { flush: "post", immediate: true });
4625
+ tryOnMounted(() => onChanged(state.value));
4626
+ return state;
4627
+ }
4628
+ defineComponent({
4629
+ name: "UseColorMode",
4630
+ props: ["selector", "attribute", "modes", "onChanged", "storageKey", "storage", "emitAuto"],
4631
+ setup(props, { slots }) {
4632
+ const mode = useColorMode(props);
4633
+ const data = reactive({
4634
+ mode
4635
+ });
4636
+ return () => {
4637
+ if (slots.default)
4638
+ return slots.default(data);
4639
+ };
4640
+ }
4641
+ });
4642
+ defineComponent({
4643
+ name: "UseDark",
4644
+ props: ["selector", "attribute", "valueDark", "valueLight", "onChanged", "storageKey", "storage"],
4645
+ setup(props, { slots }) {
4646
+ const isDark = useDark(props);
4647
+ const data = reactive({
4648
+ isDark,
4649
+ toggleDark: useToggle(isDark)
4650
+ });
4651
+ return () => {
4652
+ if (slots.default)
4653
+ return slots.default(data);
4654
+ };
4655
+ }
4656
+ });
4657
+ defineComponent({
4658
+ name: "UseDeviceMotion",
4659
+ setup(props, { slots }) {
4660
+ const data = reactive(useDeviceMotion());
4661
+ return () => {
4662
+ if (slots.default)
4663
+ return slots.default(data);
4664
+ };
4665
+ }
4666
+ });
4667
+ defineComponent({
4668
+ name: "UseDeviceOrientation",
4669
+ setup(props, { slots }) {
4670
+ const data = reactive(useDeviceOrientation());
4671
+ return () => {
4672
+ if (slots.default)
4673
+ return slots.default(data);
4674
+ };
4675
+ }
4676
+ });
4677
+ defineComponent({
4678
+ name: "UseDevicePixelRatio",
4679
+ setup(props, { slots }) {
4680
+ const data = reactive({
4681
+ pixelRatio: useDevicePixelRatio()
4682
+ });
4683
+ return () => {
4684
+ if (slots.default)
4685
+ return slots.default(data);
4686
+ };
4687
+ }
4688
+ });
4689
+ defineComponent({
4690
+ name: "UseDevicesList",
4691
+ props: ["onUpdated", "requestPermissions", "constraints"],
4692
+ setup(props, { slots }) {
4693
+ const data = reactive(useDevicesList(props));
4694
+ return () => {
4695
+ if (slots.default)
4696
+ return slots.default(data);
4697
+ };
4698
+ }
4699
+ });
4700
+ defineComponent({
4701
+ name: "UseDocumentVisibility",
4702
+ setup(props, { slots }) {
4703
+ const data = reactive({
4704
+ visibility: useDocumentVisibility()
4705
+ });
4706
+ return () => {
4707
+ if (slots.default)
4708
+ return slots.default(data);
4709
+ };
4710
+ }
4711
+ });
4712
+ var __defProp$a = Object.defineProperty;
4713
+ var __defProps$8 = Object.defineProperties;
4714
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
4715
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
4716
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
4717
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
4718
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4719
+ var __spreadValues$a = (a, b) => {
4720
+ for (var prop in b || (b = {}))
4721
+ if (__hasOwnProp$b.call(b, prop))
4722
+ __defNormalProp$a(a, prop, b[prop]);
4723
+ if (__getOwnPropSymbols$b)
4724
+ for (var prop of __getOwnPropSymbols$b(b)) {
4725
+ if (__propIsEnum$b.call(b, prop))
4726
+ __defNormalProp$a(a, prop, b[prop]);
4727
+ }
4728
+ return a;
4729
+ };
4730
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
4731
+ defineComponent({
4732
+ name: "UseDraggable",
4733
+ props: [
4734
+ "storageKey",
4735
+ "storageType",
4736
+ "initialValue",
4737
+ "exact",
4738
+ "preventDefault",
4739
+ "stopPropagation",
4740
+ "pointerTypes",
4741
+ "as"
4742
+ ],
4743
+ setup(props, { slots }) {
4744
+ const target = ref();
4745
+ const initialValue = props.storageKey ? useStorage$1(props.storageKey, unref(props.initialValue) || { x: 0, y: 0 }, isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0) : props.initialValue || { x: 0, y: 0 };
4746
+ const data = reactive(useDraggable(target, __spreadProps$8(__spreadValues$a({}, props), {
4747
+ initialValue
4748
+ })));
4749
+ return () => {
4750
+ if (slots.default)
4751
+ return h(props.as || "div", { ref: target, style: `touch-action:none;${data.style}` }, slots.default(data));
4752
+ };
4753
+ }
4754
+ });
4755
+ defineComponent({
4756
+ name: "UseElementBounding",
4757
+ props: ["box", "as"],
4758
+ setup(props, { slots }) {
4759
+ const target = ref();
4760
+ const data = reactive(useElementBounding(target));
4761
+ return () => {
4762
+ if (slots.default)
4763
+ return h(props.as || "div", { ref: target }, slots.default(data));
4764
+ };
4765
+ }
4766
+ });
4767
+ function useElementHover(el) {
4768
+ const isHovered = ref(false);
4769
+ useEventListener(el, "mouseenter", () => isHovered.value = true);
4770
+ useEventListener(el, "mouseleave", () => isHovered.value = false);
4771
+ return isHovered;
4772
+ }
4773
+ ({
4774
+ [directiveHooks.mounted](el, binding) {
4775
+ if (typeof binding.value === "function") {
4776
+ const isHovered = useElementHover(el);
4777
+ watch(isHovered, (v) => binding.value(v));
4778
+ }
4779
+ }
4780
+ });
4781
+ defineComponent({
4782
+ name: "UseElementSize",
4783
+ props: ["width", "height", "box"],
4784
+ setup(props, { slots }) {
4785
+ const target = ref();
4786
+ const data = reactive(useElementSize$1(target, { width: props.width, height: props.height }, { box: props.box }));
4787
+ return () => {
4788
+ if (slots.default)
4789
+ return h(props.as || "div", { ref: target }, slots.default(data));
4790
+ };
4791
+ }
4792
+ });
4793
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
4794
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
4795
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
4796
+ var __objRest = (source, exclude) => {
4797
+ var target = {};
4798
+ for (var prop in source)
4799
+ if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
4800
+ target[prop] = source[prop];
4801
+ if (source != null && __getOwnPropSymbols$a)
4802
+ for (var prop of __getOwnPropSymbols$a(source)) {
4803
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
4804
+ target[prop] = source[prop];
4805
+ }
4806
+ return target;
4807
+ };
4808
+ function useResizeObserver(target, callback, options = {}) {
4809
+ const _a2 = options, { window: window2 = defaultWindow } = _a2, observerOptions = __objRest(_a2, ["window"]);
4810
+ let observer;
4811
+ const isSupported = window2 && "ResizeObserver" in window2;
4812
+ const cleanup = () => {
4813
+ if (observer) {
4814
+ observer.disconnect();
4815
+ observer = void 0;
4816
+ }
4817
+ };
4818
+ const stopWatch = watch(() => unrefElement(target), (el) => {
4819
+ cleanup();
4820
+ if (isSupported && window2 && el) {
4821
+ observer = new ResizeObserver(callback);
4822
+ observer.observe(el, observerOptions);
4823
+ }
4824
+ }, { immediate: true, flush: "post" });
4825
+ const stop = () => {
4826
+ cleanup();
4827
+ stopWatch();
4828
+ };
4829
+ tryOnScopeDispose(stop);
4830
+ return {
4831
+ isSupported,
4832
+ stop
4833
+ };
4834
+ }
4835
+ function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
4836
+ const width = ref(initialSize.width);
4837
+ const height = ref(initialSize.height);
4838
+ useResizeObserver(target, ([entry]) => {
4839
+ width.value = entry.contentRect.width;
4840
+ height.value = entry.contentRect.height;
4841
+ }, options);
4842
+ watch(() => unrefElement(target), (ele) => {
4843
+ width.value = ele ? initialSize.width : 0;
4844
+ height.value = ele ? initialSize.height : 0;
4845
+ });
4846
+ return {
4847
+ width,
4848
+ height
4849
+ };
4850
+ }
4851
+ ({
4852
+ [directiveHooks.mounted](el, binding) {
4853
+ var _a2;
4854
+ const handler = typeof binding.value === "function" ? binding.value : (_a2 = binding.value) == null ? void 0 : _a2[0];
4855
+ const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
4856
+ const { width, height } = useElementSize(el, ...options);
4857
+ watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
4858
+ }
4859
+ });
4860
+ defineComponent({
4861
+ name: "UseElementVisibility",
4862
+ props: ["as"],
4863
+ setup(props, { slots }) {
4864
+ const target = ref();
4865
+ const data = reactive({
4866
+ isVisible: useElementVisibility$1(target)
4867
+ });
4868
+ return () => {
4869
+ if (slots.default)
4870
+ return h(props.as || "div", { ref: target }, slots.default(data));
4871
+ };
4872
+ }
4873
+ });
4874
+ function useElementVisibility(element, { window: window2 = defaultWindow, scrollTarget } = {}) {
4875
+ const elementIsVisible = ref(false);
4876
+ const testBounding = () => {
4877
+ if (!window2)
4878
+ return;
4879
+ const document2 = window2.document;
4880
+ if (!unref(element)) {
4881
+ elementIsVisible.value = false;
4882
+ } else {
4883
+ const rect = unref(element).getBoundingClientRect();
4884
+ elementIsVisible.value = rect.top <= (window2.innerHeight || document2.documentElement.clientHeight) && rect.left <= (window2.innerWidth || document2.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0;
4885
+ }
4886
+ };
4887
+ tryOnMounted(testBounding);
4888
+ if (window2)
4889
+ tryOnMounted(() => useEventListener(unref(scrollTarget) || window2, "scroll", testBounding, { capture: false, passive: true }));
4890
+ return elementIsVisible;
4891
+ }
4892
+ ({
4893
+ [directiveHooks.mounted](el, binding) {
4894
+ if (typeof binding.value === "function") {
4895
+ const handler = binding.value;
4896
+ const isVisible = useElementVisibility(el);
4897
+ watch(isVisible, (v) => handler(v), { immediate: true });
4898
+ } else {
4899
+ const [handler, options] = binding.value;
4900
+ const isVisible = useElementVisibility(el, options);
4901
+ watch(isVisible, (v) => handler(v), { immediate: true });
4902
+ }
4903
+ }
4904
+ });
4905
+ defineComponent({
4906
+ name: "UseEyeDropper",
4907
+ props: {
4908
+ sRGBHex: String
4909
+ },
4910
+ setup(props, { slots }) {
4911
+ const data = reactive(useEyeDropper());
4912
+ return () => {
4913
+ if (slots.default)
4914
+ return slots.default(data);
4915
+ };
4916
+ }
4917
+ });
4918
+ defineComponent({
4919
+ name: "UseFullscreen",
4920
+ props: ["as"],
4921
+ setup(props, { slots }) {
4922
+ const target = ref();
4923
+ const data = reactive(useFullscreen(target));
4924
+ return () => {
4925
+ if (slots.default)
4926
+ return h(props.as || "div", { ref: target }, slots.default(data));
4927
+ };
4928
+ }
4929
+ });
4930
+ defineComponent({
4931
+ name: "UseGeolocation",
4932
+ props: ["enableHighAccuracy", "maximumAge", "timeout", "navigator"],
4933
+ setup(props, { slots }) {
4934
+ const data = reactive(useGeolocation(props));
4935
+ return () => {
4936
+ if (slots.default)
4937
+ return slots.default(data);
4938
+ };
4939
+ }
4940
+ });
4941
+ defineComponent({
4942
+ name: "UseIdle",
4943
+ props: ["timeout", "events", "listenForVisibilityChange", "initialState"],
4944
+ setup(props, { slots }) {
4945
+ const data = reactive(useIdle(props.timeout, props));
4946
+ return () => {
4947
+ if (slots.default)
4948
+ return slots.default(data);
4949
+ };
4950
+ }
4951
+ });
4952
+ function useAsyncState(promise, initialState, options) {
4953
+ const {
2125
4954
  immediate = true,
2126
- direction = "both"
2127
- } = options;
2128
- let stop1, stop2;
2129
- if (direction === "both" || direction === "ltr") {
2130
- stop1 = watch(left, (newValue) => right.value = newValue, { flush, deep, immediate });
2131
- }
2132
- if (direction === "both" || direction === "rtl") {
2133
- stop2 = watch(right, (newValue) => left.value = newValue, { flush, deep, immediate });
4955
+ delay = 0,
4956
+ onError = noop,
4957
+ resetOnExecute = true,
4958
+ shallow = true
4959
+ } = options != null ? options : {};
4960
+ const state = shallow ? shallowRef(initialState) : ref(initialState);
4961
+ const isReady = ref(false);
4962
+ const isLoading = ref(false);
4963
+ const error = ref(void 0);
4964
+ async function execute(delay2 = 0, ...args) {
4965
+ if (resetOnExecute)
4966
+ state.value = initialState;
4967
+ error.value = void 0;
4968
+ isReady.value = false;
4969
+ isLoading.value = true;
4970
+ if (delay2 > 0)
4971
+ await promiseTimeout(delay2);
4972
+ const _promise = typeof promise === "function" ? promise(...args) : promise;
4973
+ try {
4974
+ const data = await _promise;
4975
+ state.value = data;
4976
+ isReady.value = true;
4977
+ } catch (e) {
4978
+ error.value = e;
4979
+ onError(e);
4980
+ } finally {
4981
+ isLoading.value = false;
4982
+ }
4983
+ return state.value;
2134
4984
  }
2135
- return () => {
2136
- stop1 == null ? void 0 : stop1();
2137
- stop2 == null ? void 0 : stop2();
4985
+ if (immediate)
4986
+ execute(delay);
4987
+ return {
4988
+ state,
4989
+ isReady,
4990
+ isLoading,
4991
+ error,
4992
+ execute
2138
4993
  };
2139
4994
  }
2140
- isClient ? window : void 0;
2141
- isClient ? window.document : void 0;
2142
- isClient ? window.navigator : void 0;
2143
- isClient ? window.location : void 0;
2144
- function useClamp(value, min, max) {
2145
- const _value = ref(value);
2146
- return computed({
2147
- get() {
2148
- return _value.value = clamp(_value.value, unref(min), unref(max));
2149
- },
2150
- set(value2) {
2151
- _value.value = clamp(value2, unref(min), unref(max));
4995
+ var __defProp$9 = Object.defineProperty;
4996
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
4997
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
4998
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
4999
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5000
+ var __spreadValues$9 = (a, b) => {
5001
+ for (var prop in b || (b = {}))
5002
+ if (__hasOwnProp$9.call(b, prop))
5003
+ __defNormalProp$9(a, prop, b[prop]);
5004
+ if (__getOwnPropSymbols$9)
5005
+ for (var prop of __getOwnPropSymbols$9(b)) {
5006
+ if (__propIsEnum$9.call(b, prop))
5007
+ __defNormalProp$9(a, prop, b[prop]);
2152
5008
  }
5009
+ return a;
5010
+ };
5011
+ async function loadImage(options) {
5012
+ return new Promise((resolve, reject) => {
5013
+ const img = new Image();
5014
+ const { src, srcset, sizes } = options;
5015
+ img.src = src;
5016
+ if (srcset)
5017
+ img.srcset = srcset;
5018
+ if (sizes)
5019
+ img.sizes = sizes;
5020
+ img.onload = () => resolve(img);
5021
+ img.onerror = reject;
2153
5022
  });
2154
5023
  }
2155
- const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2156
- const globalKey = "__vueuse_ssr_handlers__";
2157
- _global[globalKey] = _global[globalKey] || {};
2158
- _global[globalKey];
2159
- function useOffsetPagination(options) {
5024
+ const useImage = (options, asyncStateOptions = {}) => {
5025
+ const state = useAsyncState(() => loadImage(unref(options)), void 0, __spreadValues$9({
5026
+ resetOnExecute: true
5027
+ }, asyncStateOptions));
5028
+ watch(() => unref(options), () => state.execute(asyncStateOptions.delay), { deep: true });
5029
+ return state;
5030
+ };
5031
+ defineComponent({
5032
+ name: "UseImage",
5033
+ props: [
5034
+ "src",
5035
+ "srcset",
5036
+ "sizes",
5037
+ "as"
5038
+ ],
5039
+ setup(props, { slots }) {
5040
+ const data = reactive(useImage(props));
5041
+ return () => {
5042
+ if (data.isLoading && slots.loading)
5043
+ return slots.loading(data);
5044
+ else if (data.error && slots.error)
5045
+ return slots.error(data.error);
5046
+ if (slots.default)
5047
+ return slots.default(data);
5048
+ return h(props.as || "img", props);
5049
+ };
5050
+ }
5051
+ });
5052
+ function useScroll(element, options = {}) {
2160
5053
  const {
2161
- total = Infinity,
2162
- pageSize = 10,
2163
- page = 1,
2164
- onPageChange = noop,
2165
- onPageSizeChange = noop,
2166
- onPageCountChange = noop
5054
+ throttle = 0,
5055
+ idle = 200,
5056
+ onStop = noop,
5057
+ onScroll = noop,
5058
+ offset = {
5059
+ left: 0,
5060
+ right: 0,
5061
+ top: 0,
5062
+ bottom: 0
5063
+ },
5064
+ eventListenerOptions = {
5065
+ capture: false,
5066
+ passive: true
5067
+ }
2167
5068
  } = options;
2168
- const currentPageSize = useClamp(pageSize, 1, Infinity);
2169
- const pageCount = computed(() => Math.ceil(unref(total) / unref(currentPageSize)));
2170
- const currentPage = useClamp(page, 1, pageCount);
2171
- const isFirstPage = computed(() => currentPage.value === 1);
2172
- const isLastPage = computed(() => currentPage.value === pageCount.value);
2173
- if (isRef(page))
2174
- syncRef(page, currentPage);
2175
- if (isRef(pageSize))
2176
- syncRef(pageSize, currentPageSize);
2177
- function prev() {
2178
- currentPage.value--;
5069
+ const x = ref(0);
5070
+ const y = ref(0);
5071
+ const isScrolling = ref(false);
5072
+ const arrivedState = reactive({
5073
+ left: true,
5074
+ right: false,
5075
+ top: true,
5076
+ bottom: false
5077
+ });
5078
+ const directions = reactive({
5079
+ left: false,
5080
+ right: false,
5081
+ top: false,
5082
+ bottom: false
5083
+ });
5084
+ if (element) {
5085
+ const onScrollEnd = useDebounceFn((e) => {
5086
+ isScrolling.value = false;
5087
+ directions.left = false;
5088
+ directions.right = false;
5089
+ directions.top = false;
5090
+ directions.bottom = false;
5091
+ onStop(e);
5092
+ }, throttle + idle);
5093
+ const onScrollHandler = (e) => {
5094
+ const eventTarget = e.target === document ? e.target.documentElement : e.target;
5095
+ const scrollLeft = eventTarget.scrollLeft;
5096
+ directions.left = scrollLeft < x.value;
5097
+ directions.right = scrollLeft > x.value;
5098
+ arrivedState.left = scrollLeft <= 0 + (offset.left || 0);
5099
+ arrivedState.right = scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0);
5100
+ x.value = scrollLeft;
5101
+ let scrollTop = eventTarget.scrollTop;
5102
+ if (e.target === document && !scrollTop)
5103
+ scrollTop = document.body.scrollTop;
5104
+ directions.top = scrollTop < y.value;
5105
+ directions.bottom = scrollTop > y.value;
5106
+ arrivedState.top = scrollTop <= 0 + (offset.top || 0);
5107
+ arrivedState.bottom = scrollTop + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0);
5108
+ y.value = scrollTop;
5109
+ isScrolling.value = true;
5110
+ onScrollEnd(e);
5111
+ onScroll(e);
5112
+ };
5113
+ useEventListener(element, "scroll", throttle ? useThrottleFn(onScrollHandler, throttle) : onScrollHandler, eventListenerOptions);
2179
5114
  }
2180
- function next() {
2181
- currentPage.value++;
5115
+ return {
5116
+ x,
5117
+ y,
5118
+ isScrolling,
5119
+ arrivedState,
5120
+ directions
5121
+ };
5122
+ }
5123
+ var __defProp$8 = Object.defineProperty;
5124
+ var __defProps$7 = Object.defineProperties;
5125
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
5126
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
5127
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
5128
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
5129
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5130
+ var __spreadValues$8 = (a, b) => {
5131
+ for (var prop in b || (b = {}))
5132
+ if (__hasOwnProp$8.call(b, prop))
5133
+ __defNormalProp$8(a, prop, b[prop]);
5134
+ if (__getOwnPropSymbols$8)
5135
+ for (var prop of __getOwnPropSymbols$8(b)) {
5136
+ if (__propIsEnum$8.call(b, prop))
5137
+ __defNormalProp$8(a, prop, b[prop]);
5138
+ }
5139
+ return a;
5140
+ };
5141
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
5142
+ function useInfiniteScroll(element, onLoadMore, options = {}) {
5143
+ var _a2, _b;
5144
+ const direction = (_a2 = options.direction) != null ? _a2 : "bottom";
5145
+ const state = reactive(useScroll(element, __spreadProps$7(__spreadValues$8({}, options), {
5146
+ offset: __spreadValues$8({
5147
+ [direction]: (_b = options.distance) != null ? _b : 0
5148
+ }, options.offset)
5149
+ })));
5150
+ watch(() => state.arrivedState[direction], async (v) => {
5151
+ var _a22, _b2;
5152
+ if (v) {
5153
+ const elem = unref(element);
5154
+ const previous = {
5155
+ height: (_a22 = elem == null ? void 0 : elem.scrollHeight) != null ? _a22 : 0,
5156
+ width: (_b2 = elem == null ? void 0 : elem.scrollWidth) != null ? _b2 : 0
5157
+ };
5158
+ await onLoadMore(state);
5159
+ if (options.preserveScrollPosition && elem) {
5160
+ nextTick(() => {
5161
+ elem.scrollTo({
5162
+ top: elem.scrollHeight - previous.height,
5163
+ left: elem.scrollWidth - previous.width
5164
+ });
5165
+ });
5166
+ }
5167
+ }
5168
+ });
5169
+ }
5170
+ ({
5171
+ [directiveHooks.mounted](el, binding) {
5172
+ if (typeof binding.value === "function")
5173
+ useInfiniteScroll(el, binding.value);
5174
+ else
5175
+ useInfiniteScroll(el, ...binding.value);
2182
5176
  }
2183
- const returnValue = {
2184
- currentPage,
2185
- currentPageSize,
2186
- pageCount,
2187
- isFirstPage,
2188
- isLastPage,
2189
- prev,
2190
- next
5177
+ });
5178
+ function useIntersectionObserver(target, callback, options = {}) {
5179
+ const {
5180
+ root,
5181
+ rootMargin = "0px",
5182
+ threshold = 0.1,
5183
+ window: window2 = defaultWindow
5184
+ } = options;
5185
+ const isSupported = window2 && "IntersectionObserver" in window2;
5186
+ let cleanup = noop;
5187
+ const stopWatch = isSupported ? watch(() => ({
5188
+ el: unrefElement(target),
5189
+ root: unrefElement(root)
5190
+ }), ({ el, root: root2 }) => {
5191
+ cleanup();
5192
+ if (!el)
5193
+ return;
5194
+ const observer = new IntersectionObserver(callback, {
5195
+ root: root2,
5196
+ rootMargin,
5197
+ threshold
5198
+ });
5199
+ observer.observe(el);
5200
+ cleanup = () => {
5201
+ observer.disconnect();
5202
+ cleanup = noop;
5203
+ };
5204
+ }, { immediate: true, flush: "post" }) : noop;
5205
+ const stop = () => {
5206
+ cleanup();
5207
+ stopWatch();
2191
5208
  };
2192
- watch(currentPage, () => {
2193
- onPageChange(reactive(returnValue));
5209
+ tryOnScopeDispose(stop);
5210
+ return {
5211
+ isSupported,
5212
+ stop
5213
+ };
5214
+ }
5215
+ ({
5216
+ [directiveHooks.mounted](el, binding) {
5217
+ if (typeof binding.value === "function")
5218
+ useIntersectionObserver(el, binding.value);
5219
+ else
5220
+ useIntersectionObserver(el, ...binding.value);
5221
+ }
5222
+ });
5223
+ defineComponent({
5224
+ name: "UseMouse",
5225
+ props: ["touch", "resetOnTouchEnds", "initialValue"],
5226
+ setup(props, { slots }) {
5227
+ const data = reactive(useMouse(props));
5228
+ return () => {
5229
+ if (slots.default)
5230
+ return slots.default(data);
5231
+ };
5232
+ }
5233
+ });
5234
+ defineComponent({
5235
+ name: "UseMouseElement",
5236
+ props: ["handleOutside", "as"],
5237
+ setup(props, { slots }) {
5238
+ const target = ref();
5239
+ const data = reactive(useMouseInElement(target, props));
5240
+ return () => {
5241
+ if (slots.default)
5242
+ return h(props.as || "div", { ref: target }, slots.default(data));
5243
+ };
5244
+ }
5245
+ });
5246
+ var __defProp$7 = Object.defineProperty;
5247
+ var __defProps$6 = Object.defineProperties;
5248
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
5249
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
5250
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
5251
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
5252
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5253
+ var __spreadValues$7 = (a, b) => {
5254
+ for (var prop in b || (b = {}))
5255
+ if (__hasOwnProp$7.call(b, prop))
5256
+ __defNormalProp$7(a, prop, b[prop]);
5257
+ if (__getOwnPropSymbols$7)
5258
+ for (var prop of __getOwnPropSymbols$7(b)) {
5259
+ if (__propIsEnum$7.call(b, prop))
5260
+ __defNormalProp$7(a, prop, b[prop]);
5261
+ }
5262
+ return a;
5263
+ };
5264
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
5265
+ defineComponent({
5266
+ name: "UseMousePressed",
5267
+ props: ["touch", "initialValue", "as"],
5268
+ setup(props, { slots }) {
5269
+ const target = ref();
5270
+ const data = reactive(useMousePressed(__spreadProps$6(__spreadValues$7({}, props), { target })));
5271
+ return () => {
5272
+ if (slots.default)
5273
+ return h(props.as || "div", { ref: target }, slots.default(data));
5274
+ };
5275
+ }
5276
+ });
5277
+ defineComponent({
5278
+ name: "UseNetwork",
5279
+ setup(props, { slots }) {
5280
+ const data = reactive(useNetwork());
5281
+ return () => {
5282
+ if (slots.default)
5283
+ return slots.default(data);
5284
+ };
5285
+ }
5286
+ });
5287
+ var __defProp$6 = Object.defineProperty;
5288
+ var __defProps$5 = Object.defineProperties;
5289
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
5290
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
5291
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
5292
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
5293
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5294
+ var __spreadValues$6 = (a, b) => {
5295
+ for (var prop in b || (b = {}))
5296
+ if (__hasOwnProp$6.call(b, prop))
5297
+ __defNormalProp$6(a, prop, b[prop]);
5298
+ if (__getOwnPropSymbols$6)
5299
+ for (var prop of __getOwnPropSymbols$6(b)) {
5300
+ if (__propIsEnum$6.call(b, prop))
5301
+ __defNormalProp$6(a, prop, b[prop]);
5302
+ }
5303
+ return a;
5304
+ };
5305
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
5306
+ defineComponent({
5307
+ name: "UseNow",
5308
+ props: ["interval"],
5309
+ setup(props, { slots }) {
5310
+ const data = reactive(useNow(__spreadProps$5(__spreadValues$6({}, props), { controls: true })));
5311
+ return () => {
5312
+ if (slots.default)
5313
+ return slots.default(data);
5314
+ };
5315
+ }
5316
+ });
5317
+ defineComponent({
5318
+ name: "UseObjectUrl",
5319
+ props: [
5320
+ "object"
5321
+ ],
5322
+ setup(props, { slots }) {
5323
+ const object = toRef(props, "object");
5324
+ const url = useObjectUrl(object);
5325
+ return () => {
5326
+ if (slots.default && url.value)
5327
+ return slots.default(url);
5328
+ };
5329
+ }
5330
+ });
5331
+ var __defProp$5 = Object.defineProperty;
5332
+ var __defProps$4 = Object.defineProperties;
5333
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
5334
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
5335
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
5336
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
5337
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5338
+ var __spreadValues$5 = (a, b) => {
5339
+ for (var prop in b || (b = {}))
5340
+ if (__hasOwnProp$5.call(b, prop))
5341
+ __defNormalProp$5(a, prop, b[prop]);
5342
+ if (__getOwnPropSymbols$5)
5343
+ for (var prop of __getOwnPropSymbols$5(b)) {
5344
+ if (__propIsEnum$5.call(b, prop))
5345
+ __defNormalProp$5(a, prop, b[prop]);
5346
+ }
5347
+ return a;
5348
+ };
5349
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
5350
+ const UseOffsetPagination = defineComponent({
5351
+ name: "UseOffsetPagination",
5352
+ props: [
5353
+ "total",
5354
+ "page",
5355
+ "pageSize",
5356
+ "onPageChange",
5357
+ "onPageSizeChange",
5358
+ "onPageCountChange"
5359
+ ],
5360
+ emits: [
5361
+ "page-change",
5362
+ "page-size-change",
5363
+ "page-count-change"
5364
+ ],
5365
+ setup(props, { slots, emit }) {
5366
+ const data = reactive(useOffsetPagination(__spreadProps$4(__spreadValues$5({}, props), {
5367
+ onPageChange(...args) {
5368
+ var _a2;
5369
+ (_a2 = props.onPageChange) == null ? void 0 : _a2.call(props, ...args);
5370
+ emit("page-change", ...args);
5371
+ },
5372
+ onPageSizeChange(...args) {
5373
+ var _a2;
5374
+ (_a2 = props.onPageSizeChange) == null ? void 0 : _a2.call(props, ...args);
5375
+ emit("page-size-change", ...args);
5376
+ },
5377
+ onPageCountChange(...args) {
5378
+ var _a2;
5379
+ (_a2 = props.onPageCountChange) == null ? void 0 : _a2.call(props, ...args);
5380
+ emit("page-count-change", ...args);
5381
+ }
5382
+ })));
5383
+ return () => {
5384
+ if (slots.default)
5385
+ return slots.default(data);
5386
+ };
5387
+ }
5388
+ });
5389
+ defineComponent({
5390
+ name: "UseOnline",
5391
+ setup(props, { slots }) {
5392
+ const data = reactive({
5393
+ isOnline: useOnline()
5394
+ });
5395
+ return () => {
5396
+ if (slots.default)
5397
+ return slots.default(data);
5398
+ };
5399
+ }
5400
+ });
5401
+ defineComponent({
5402
+ name: "UsePageLeave",
5403
+ setup(props, { slots }) {
5404
+ const data = reactive({
5405
+ isLeft: usePageLeave()
5406
+ });
5407
+ return () => {
5408
+ if (slots.default)
5409
+ return slots.default(data);
5410
+ };
5411
+ }
5412
+ });
5413
+ var __defProp$4 = Object.defineProperty;
5414
+ var __defProps$3 = Object.defineProperties;
5415
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
5416
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
5417
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
5418
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
5419
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5420
+ var __spreadValues$4 = (a, b) => {
5421
+ for (var prop in b || (b = {}))
5422
+ if (__hasOwnProp$4.call(b, prop))
5423
+ __defNormalProp$4(a, prop, b[prop]);
5424
+ if (__getOwnPropSymbols$4)
5425
+ for (var prop of __getOwnPropSymbols$4(b)) {
5426
+ if (__propIsEnum$4.call(b, prop))
5427
+ __defNormalProp$4(a, prop, b[prop]);
5428
+ }
5429
+ return a;
5430
+ };
5431
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
5432
+ defineComponent({
5433
+ name: "UsePointer",
5434
+ props: [
5435
+ "pointerTypes",
5436
+ "initialValue",
5437
+ "target"
5438
+ ],
5439
+ setup(props, { slots }) {
5440
+ const el = ref(null);
5441
+ const data = reactive(usePointer(__spreadProps$3(__spreadValues$4({}, props), {
5442
+ target: props.target === "self" ? el : defaultWindow
5443
+ })));
5444
+ return () => {
5445
+ if (slots.default)
5446
+ return slots.default(data, { ref: el });
5447
+ };
5448
+ }
5449
+ });
5450
+ defineComponent({
5451
+ name: "UsePreferredColorScheme",
5452
+ setup(props, { slots }) {
5453
+ const data = reactive({
5454
+ colorScheme: usePreferredColorScheme()
5455
+ });
5456
+ return () => {
5457
+ if (slots.default)
5458
+ return slots.default(data);
5459
+ };
5460
+ }
5461
+ });
5462
+ defineComponent({
5463
+ name: "UsePreferredDark",
5464
+ setup(props, { slots }) {
5465
+ const data = reactive({
5466
+ prefersDark: usePreferredDark$1()
5467
+ });
5468
+ return () => {
5469
+ if (slots.default)
5470
+ return slots.default(data);
5471
+ };
5472
+ }
5473
+ });
5474
+ defineComponent({
5475
+ name: "UsePreferredLanguages",
5476
+ setup(props, { slots }) {
5477
+ const data = reactive({
5478
+ languages: usePreferredLanguages()
5479
+ });
5480
+ return () => {
5481
+ if (slots.default)
5482
+ return slots.default(data);
5483
+ };
5484
+ }
5485
+ });
5486
+ function useCssVar(prop, target, { window: window2 = defaultWindow, initialValue = "" } = {}) {
5487
+ const variable = ref(initialValue);
5488
+ const elRef = computed(() => {
5489
+ var _a2;
5490
+ return unrefElement(target) || ((_a2 = window2 == null ? void 0 : window2.document) == null ? void 0 : _a2.documentElement);
2194
5491
  });
2195
- watch(currentPageSize, () => {
2196
- onPageSizeChange(reactive(returnValue));
5492
+ watch([elRef, () => unref(prop)], ([el, prop2]) => {
5493
+ var _a2;
5494
+ if (el && window2) {
5495
+ const value = (_a2 = window2.getComputedStyle(el).getPropertyValue(prop2)) == null ? void 0 : _a2.trim();
5496
+ variable.value = value || initialValue;
5497
+ }
5498
+ }, { immediate: true });
5499
+ watch(variable, (val) => {
5500
+ var _a2;
5501
+ if ((_a2 = elRef.value) == null ? void 0 : _a2.style)
5502
+ elRef.value.style.setProperty(unref(prop), val);
2197
5503
  });
2198
- watch(pageCount, () => {
2199
- onPageCountChange(reactive(returnValue));
5504
+ return variable;
5505
+ }
5506
+ const topVarName = "--vueuse-safe-area-top";
5507
+ const rightVarName = "--vueuse-safe-area-right";
5508
+ const bottomVarName = "--vueuse-safe-area-bottom";
5509
+ const leftVarName = "--vueuse-safe-area-left";
5510
+ function useScreenSafeArea() {
5511
+ const top = ref("");
5512
+ const right = ref("");
5513
+ const bottom = ref("");
5514
+ const left = ref("");
5515
+ if (isClient) {
5516
+ const topCssVar = useCssVar(topVarName);
5517
+ const rightCssVar = useCssVar(rightVarName);
5518
+ const bottomCssVar = useCssVar(bottomVarName);
5519
+ const leftCssVar = useCssVar(leftVarName);
5520
+ topCssVar.value = "env(safe-area-inset-top, 0px)";
5521
+ rightCssVar.value = "env(safe-area-inset-right, 0px)";
5522
+ bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
5523
+ leftCssVar.value = "env(safe-area-inset-left, 0px)";
5524
+ update();
5525
+ useEventListener("resize", useDebounceFn(update));
5526
+ }
5527
+ function update() {
5528
+ top.value = getValue(topVarName);
5529
+ right.value = getValue(rightVarName);
5530
+ bottom.value = getValue(bottomVarName);
5531
+ left.value = getValue(leftVarName);
5532
+ }
5533
+ return {
5534
+ top,
5535
+ right,
5536
+ bottom,
5537
+ left,
5538
+ update
5539
+ };
5540
+ }
5541
+ function getValue(position) {
5542
+ return getComputedStyle(document.documentElement).getPropertyValue(position);
5543
+ }
5544
+ defineComponent({
5545
+ name: "UseScreenSafeArea",
5546
+ props: {
5547
+ top: Boolean,
5548
+ right: Boolean,
5549
+ bottom: Boolean,
5550
+ left: Boolean
5551
+ },
5552
+ setup(props, { slots }) {
5553
+ const {
5554
+ top,
5555
+ right,
5556
+ bottom,
5557
+ left
5558
+ } = useScreenSafeArea();
5559
+ return () => {
5560
+ if (slots.default) {
5561
+ return h("div", {
5562
+ style: {
5563
+ paddingTop: props.top ? top.value : "",
5564
+ paddingRight: props.right ? right.value : "",
5565
+ paddingBottom: props.bottom ? bottom.value : "",
5566
+ paddingLeft: props.left ? left.value : "",
5567
+ boxSizing: "border-box",
5568
+ maxHeight: "100vh",
5569
+ maxWidth: "100vw",
5570
+ overflow: "auto"
5571
+ }
5572
+ }, slots.default());
5573
+ }
5574
+ };
5575
+ }
5576
+ });
5577
+ var __defProp$3 = Object.defineProperty;
5578
+ var __defProps$2 = Object.defineProperties;
5579
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
5580
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
5581
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
5582
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
5583
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5584
+ var __spreadValues$3 = (a, b) => {
5585
+ for (var prop in b || (b = {}))
5586
+ if (__hasOwnProp$3.call(b, prop))
5587
+ __defNormalProp$3(a, prop, b[prop]);
5588
+ if (__getOwnPropSymbols$3)
5589
+ for (var prop of __getOwnPropSymbols$3(b)) {
5590
+ if (__propIsEnum$3.call(b, prop))
5591
+ __defNormalProp$3(a, prop, b[prop]);
5592
+ }
5593
+ return a;
5594
+ };
5595
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
5596
+ ({
5597
+ [directiveHooks.mounted](el, binding) {
5598
+ if (typeof binding.value === "function") {
5599
+ const handler = binding.value;
5600
+ const state = useScroll(el, {
5601
+ onScroll() {
5602
+ handler(state);
5603
+ },
5604
+ onStop() {
5605
+ handler(state);
5606
+ }
5607
+ });
5608
+ } else {
5609
+ const [handler, options] = binding.value;
5610
+ const state = useScroll(el, __spreadProps$2(__spreadValues$3({}, options), {
5611
+ onScroll(e) {
5612
+ var _a2;
5613
+ (_a2 = options.onScroll) == null ? void 0 : _a2.call(options, e);
5614
+ handler(state);
5615
+ },
5616
+ onStop(e) {
5617
+ var _a2;
5618
+ (_a2 = options.onStop) == null ? void 0 : _a2.call(options, e);
5619
+ handler(state);
5620
+ }
5621
+ }));
5622
+ }
5623
+ }
5624
+ });
5625
+ function preventDefault(rawEvent) {
5626
+ const e = rawEvent || window.event;
5627
+ if (e.touches.length > 1)
5628
+ return true;
5629
+ if (e.preventDefault)
5630
+ e.preventDefault();
5631
+ return false;
5632
+ }
5633
+ function useScrollLock(element, initialState = false) {
5634
+ const isLocked = ref(initialState);
5635
+ let stopTouchMoveListener = null;
5636
+ let initialOverflow;
5637
+ watch(() => unref(element), (el) => {
5638
+ if (el) {
5639
+ const ele = el;
5640
+ initialOverflow = ele.style.overflow;
5641
+ if (isLocked.value)
5642
+ ele.style.overflow = "hidden";
5643
+ }
5644
+ }, {
5645
+ immediate: true
5646
+ });
5647
+ const lock = () => {
5648
+ const ele = unref(element);
5649
+ if (!ele || isLocked.value)
5650
+ return;
5651
+ if (isIOS) {
5652
+ stopTouchMoveListener = useEventListener(ele, "touchmove", preventDefault, { passive: false });
5653
+ }
5654
+ ele.style.overflow = "hidden";
5655
+ isLocked.value = true;
5656
+ };
5657
+ const unlock = () => {
5658
+ const ele = unref(element);
5659
+ if (!ele || !isLocked.value)
5660
+ return;
5661
+ isIOS && (stopTouchMoveListener == null ? void 0 : stopTouchMoveListener());
5662
+ ele.style.overflow = initialOverflow;
5663
+ isLocked.value = false;
5664
+ };
5665
+ tryOnScopeDispose(unlock);
5666
+ return computed({
5667
+ get() {
5668
+ return isLocked.value;
5669
+ },
5670
+ set(v) {
5671
+ if (v)
5672
+ lock();
5673
+ else
5674
+ unlock();
5675
+ }
2200
5676
  });
2201
- return returnValue;
2202
5677
  }
2203
- var SwipeDirection;
2204
- (function(SwipeDirection2) {
2205
- SwipeDirection2["UP"] = "UP";
2206
- SwipeDirection2["RIGHT"] = "RIGHT";
2207
- SwipeDirection2["DOWN"] = "DOWN";
2208
- SwipeDirection2["LEFT"] = "LEFT";
2209
- SwipeDirection2["NONE"] = "NONE";
2210
- })(SwipeDirection || (SwipeDirection = {}));
5678
+ const onScrollLock = () => {
5679
+ let isMounted = false;
5680
+ const state = ref(false);
5681
+ return (el, binding) => {
5682
+ state.value = binding.value;
5683
+ if (isMounted)
5684
+ return;
5685
+ isMounted = true;
5686
+ const isLocked = useScrollLock(el, binding.value);
5687
+ watch(state, (v) => isLocked.value = v);
5688
+ };
5689
+ };
5690
+ onScrollLock();
5691
+ var __defProp$2 = Object.defineProperty;
5692
+ var __defProps$1 = Object.defineProperties;
5693
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
5694
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
5695
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
5696
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
5697
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5698
+ var __spreadValues$2 = (a, b) => {
5699
+ for (var prop in b || (b = {}))
5700
+ if (__hasOwnProp$2.call(b, prop))
5701
+ __defNormalProp$2(a, prop, b[prop]);
5702
+ if (__getOwnPropSymbols$2)
5703
+ for (var prop of __getOwnPropSymbols$2(b)) {
5704
+ if (__propIsEnum$2.call(b, prop))
5705
+ __defNormalProp$2(a, prop, b[prop]);
5706
+ }
5707
+ return a;
5708
+ };
5709
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
5710
+ defineComponent({
5711
+ name: "UseTimeAgo",
5712
+ props: ["time", "updateInterval", "max", "fullDateFormatter", "messages"],
5713
+ setup(props, { slots }) {
5714
+ const time = toRef(props, "time");
5715
+ const data = reactive(useTimeAgo(time, __spreadProps$1(__spreadValues$2({}, props), { controls: true })));
5716
+ return () => {
5717
+ if (slots.default)
5718
+ return slots.default(data);
5719
+ };
5720
+ }
5721
+ });
5722
+ var __defProp$1 = Object.defineProperty;
5723
+ var __defProps = Object.defineProperties;
5724
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5725
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
5726
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
5727
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
5728
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5729
+ var __spreadValues$1 = (a, b) => {
5730
+ for (var prop in b || (b = {}))
5731
+ if (__hasOwnProp$1.call(b, prop))
5732
+ __defNormalProp$1(a, prop, b[prop]);
5733
+ if (__getOwnPropSymbols$1)
5734
+ for (var prop of __getOwnPropSymbols$1(b)) {
5735
+ if (__propIsEnum$1.call(b, prop))
5736
+ __defNormalProp$1(a, prop, b[prop]);
5737
+ }
5738
+ return a;
5739
+ };
5740
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
5741
+ defineComponent({
5742
+ name: "UseTimestamp",
5743
+ props: ["immediate", "interval", "offset"],
5744
+ setup(props, { slots }) {
5745
+ const data = reactive(useTimestamp(__spreadProps(__spreadValues$1({}, props), { controls: true })));
5746
+ return () => {
5747
+ if (slots.default)
5748
+ return slots.default(data);
5749
+ };
5750
+ }
5751
+ });
5752
+ var __defProp2 = Object.defineProperty;
5753
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
5754
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
5755
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
5756
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5757
+ var __spreadValues2 = (a, b) => {
5758
+ for (var prop in b || (b = {}))
5759
+ if (__hasOwnProp2.call(b, prop))
5760
+ __defNormalProp2(a, prop, b[prop]);
5761
+ if (__getOwnPropSymbols2)
5762
+ for (var prop of __getOwnPropSymbols2(b)) {
5763
+ if (__propIsEnum2.call(b, prop))
5764
+ __defNormalProp2(a, prop, b[prop]);
5765
+ }
5766
+ return a;
5767
+ };
5768
+ defineComponent({
5769
+ name: "UseVirtualList",
5770
+ props: [
5771
+ "list",
5772
+ "options",
5773
+ "height"
5774
+ ],
5775
+ setup(props, { slots }) {
5776
+ const { list: listRef } = toRefs$1(props);
5777
+ const { list, containerProps, wrapperProps } = useVirtualList(listRef, props.options);
5778
+ containerProps.style.height = props.height || "300px";
5779
+ return () => h("div", __spreadValues2({}, containerProps), [
5780
+ h("div", __spreadValues2({}, wrapperProps.value), list.value.map((item) => h("div", { style: { overFlow: "hidden", height: item.height } }, slots.default ? slots.default(item) : "Please set content!")))
5781
+ ]);
5782
+ }
5783
+ });
5784
+ defineComponent({
5785
+ name: "UseWindowFocus",
5786
+ setup(props, { slots }) {
5787
+ const data = reactive({
5788
+ focused: useWindowFocus()
5789
+ });
5790
+ return () => {
5791
+ if (slots.default)
5792
+ return slots.default(data);
5793
+ };
5794
+ }
5795
+ });
5796
+ defineComponent({
5797
+ name: "UseWindowSize",
5798
+ props: ["initialWidth", "initialHeight"],
5799
+ setup(props, { slots }) {
5800
+ const data = reactive(useWindowSize(props));
5801
+ return () => {
5802
+ if (slots.default)
5803
+ return slots.default(data);
5804
+ };
5805
+ }
5806
+ });
2211
5807
  const _hoisted_1 = { class: "bg-white flex items-center justify-between" };
2212
5808
  const _hoisted_2 = { class: "flex-1 flex justify-between sm:hidden items-center" };
2213
- const _hoisted_3 = { class: "text-sm text-gray-500" };
2214
- const _hoisted_4 = { class: "hidden sm:flex-1 sm:flex sm:items-center" };
2215
- const _hoisted_5 = {
5809
+ const _hoisted_3 = ["onClick"];
5810
+ const _hoisted_4 = { class: "text-sm text-gray-500" };
5811
+ const _hoisted_5 = ["onClick"];
5812
+ const _hoisted_6 = { class: "hidden sm:flex-1 sm:flex sm:items-center" };
5813
+ const _hoisted_7 = {
2216
5814
  "aria-label": "Pagination",
2217
- class: "relative z-0 inline-flex rounded-[4px] shadow-sm -space-x-px"
5815
+ class: "relative z-0 inline-flex rounded-base shadow-sm -space-x-px"
2218
5816
  };
2219
- const _hoisted_6 = ["onClick"];
5817
+ const _hoisted_8 = ["onClick"];
5818
+ const _hoisted_9 = ["onClick"];
5819
+ const _hoisted_10 = ["onClick"];
2220
5820
  const _sfc_main = /* @__PURE__ */ defineComponent({
2221
5821
  __name: "Pagination",
2222
5822
  props: {
@@ -2236,69 +5836,77 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2236
5836
  emits: ["update:page", "update:size", "change"],
2237
5837
  setup(__props, { emit }) {
2238
5838
  const props = __props;
5839
+ const { page, size, total } = toRefs$1(props);
5840
+ const key = ref(Math.random());
2239
5841
  const onPageChange = ({
2240
- currentPage: currentPage2,
5842
+ currentPage,
2241
5843
  currentPageSize
2242
5844
  }) => {
2243
- emit("update:size", props.size);
2244
- emit("update:page", props.page);
2245
5845
  emit("change", {
2246
- page: currentPage2,
5846
+ page: currentPage,
2247
5847
  size: currentPageSize
2248
5848
  });
2249
5849
  };
2250
- const { currentPage, pageCount, prev, next } = useOffsetPagination({
2251
- total: props.total,
2252
- page: props.page,
2253
- pageSize: props.size,
2254
- onPageChange,
2255
- onPageSizeChange: onPageChange
5850
+ watch(() => total == null ? void 0 : total.value, () => {
5851
+ key.value = Math.random();
2256
5852
  });
2257
5853
  return (_ctx, _cache) => {
2258
- return openBlock(), createElementBlock("div", _hoisted_1, [
2259
- createElementVNode("div", _hoisted_2, [
2260
- createElementVNode("span", {
2261
- class: "relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 cursor-pointer",
2262
- onClick: _cache[0] || (_cache[0] = (...args) => unref(prev) && unref(prev)(...args))
2263
- }, [
2264
- createVNode(unref(IconArrowLeft))
2265
- ]),
2266
- createElementVNode("span", _hoisted_3, toDisplayString(unref(currentPage)) + " / " + toDisplayString(unref(pageCount)), 1),
2267
- createElementVNode("span", {
2268
- class: "ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 cursor-pointer",
2269
- onClick: _cache[1] || (_cache[1] = (...args) => unref(next) && unref(next)(...args))
2270
- }, [
2271
- createVNode(unref(IconArrowRight))
2272
- ])
2273
- ]),
2274
- createElementVNode("div", _hoisted_4, [
2275
- createElementVNode("nav", _hoisted_5, [
2276
- createElementVNode("span", {
2277
- class: "relative inline-flex items-center px-2 py-2 rounded-l-[4px] border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 cursor-pointer",
2278
- onClick: _cache[2] || (_cache[2] = (...args) => unref(prev) && unref(prev)(...args))
2279
- }, [
2280
- createVNode(unref(IconArrowLeft))
5854
+ return openBlock(), createBlock(unref(UseOffsetPagination), {
5855
+ key: key.value,
5856
+ page: unref(page),
5857
+ pageSize: unref(size),
5858
+ total: unref(total),
5859
+ onPageChange,
5860
+ onPageSizeChange: onPageChange
5861
+ }, {
5862
+ default: withCtx(({ currentPage, next, prev, pageCount }) => [
5863
+ createElementVNode("div", _hoisted_1, [
5864
+ createElementVNode("div", _hoisted_2, [
5865
+ createElementVNode("span", {
5866
+ class: "relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 cursor-pointer",
5867
+ onClick: prev
5868
+ }, [
5869
+ createVNode(unref(IconArrowLeft))
5870
+ ], 8, _hoisted_3),
5871
+ createElementVNode("span", _hoisted_4, toDisplayString(currentPage) + " / " + toDisplayString(pageCount), 1),
5872
+ createElementVNode("span", {
5873
+ class: "ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 cursor-pointer",
5874
+ onClick: next
5875
+ }, [
5876
+ createVNode(unref(IconArrowRight))
5877
+ ], 8, _hoisted_5)
2281
5878
  ]),
2282
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(pageCount), (i) => {
2283
- return openBlock(), createElementBlock("span", {
2284
- key: i,
2285
- class: normalizeClass([{
2286
- "z-10 bg-themeable-primary-50 border-themeable-primary-500 text-themeable-primary-600": i === unref(currentPage),
2287
- "bg-white border-gray-300 text-gray-500 hover:bg-gray-50 ": i !== unref(currentPage)
2288
- }, "relative inline-flex items-center px-4 py-2 border text-sm font-medium cursor-pointer select-none"]),
2289
- "aria-current": "page",
2290
- onClick: ($event) => currentPage.value = i
2291
- }, toDisplayString(i), 11, _hoisted_6);
2292
- }), 128)),
2293
- createElementVNode("span", {
2294
- class: "relative inline-flex items-center px-2 py-2 rounded-r-[4px] border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 cursor-pointer",
2295
- onClick: _cache[3] || (_cache[3] = (...args) => unref(next) && unref(next)(...args))
2296
- }, [
2297
- createVNode(unref(IconArrowRight))
5879
+ createElementVNode("div", _hoisted_6, [
5880
+ createElementVNode("nav", _hoisted_7, [
5881
+ createElementVNode("span", {
5882
+ class: "relative inline-flex items-center px-2 py-2 rounded-l-[4px] border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 cursor-pointer",
5883
+ onClick: prev
5884
+ }, [
5885
+ createVNode(unref(IconArrowLeft))
5886
+ ], 8, _hoisted_8),
5887
+ (openBlock(true), createElementBlock(Fragment, null, renderList(pageCount, (i) => {
5888
+ return openBlock(), createElementBlock("span", {
5889
+ key: i,
5890
+ class: normalizeClass([{
5891
+ "z-10 bg-primary/1 border-primary text-primary": i === currentPage,
5892
+ "bg-white border-gray-300 text-gray-500 hover:bg-gray-50": i !== currentPage
5893
+ }, "relative inline-flex items-center px-4 py-2 border text-sm font-medium cursor-pointer select-none"]),
5894
+ "aria-current": "page",
5895
+ onClick: ($event) => currentPage.value = i
5896
+ }, toDisplayString(i), 11, _hoisted_9);
5897
+ }), 128)),
5898
+ createElementVNode("span", {
5899
+ class: "relative inline-flex items-center px-2 py-2 rounded-r-[4px] border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 cursor-pointer",
5900
+ onClick: next
5901
+ }, [
5902
+ createVNode(unref(IconArrowRight))
5903
+ ], 8, _hoisted_10)
5904
+ ])
2298
5905
  ])
2299
5906
  ])
2300
- ])
2301
- ]);
5907
+ ]),
5908
+ _: 1
5909
+ }, 8, ["page", "pageSize", "total"]);
2302
5910
  };
2303
5911
  }
2304
5912
  });