@vueuse/shared
Advanced tools
+1440
| import * as vue0 from "vue"; | ||
| import { ComputedGetter, ComputedRef, InjectionKey, MaybeRef, MaybeRef as MaybeRef$1, MaybeRefOrGetter, MaybeRefOrGetter as MaybeRefOrGetter$1, Ref, ShallowRef, ShallowUnwrapRef as ShallowUnwrapRef$1, ToRef, ToRefs, UnwrapNestedRefs, UnwrapRef, WatchCallback, WatchOptions, WatchOptionsBase, WatchSource, WatchStopHandle, WritableComputedOptions, WritableComputedRef, inject, toValue as toValue$1 } from "vue"; | ||
| //#region computedEager/index.d.ts | ||
| type ComputedEagerOptions = WatchOptionsBase; | ||
| type ComputedEagerReturn<T = any> = Readonly<ShallowRef<T>>; | ||
| /** | ||
| * Note: If you are using Vue 3.4+, you can straight use computed instead. | ||
| * Because in Vue 3.4+, if computed new value does not change, | ||
| * computed, effect, watch, watchEffect, render dependencies will not be triggered. | ||
| * refer: https://github.com/vuejs/core/pull/5912 | ||
| * | ||
| * @param fn effect function | ||
| * @param options WatchOptionsBase | ||
| * @returns readonly shallowRef | ||
| */ | ||
| declare function computedEager<T>(fn: () => T, options?: ComputedEagerOptions): ComputedEagerReturn<T>; | ||
| //#endregion | ||
| //#region computedWithControl/index.d.ts | ||
| interface ComputedWithControlRefExtra { | ||
| /** | ||
| * Force update the computed value. | ||
| */ | ||
| trigger: () => void; | ||
| } | ||
| interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra {} | ||
| interface WritableComputedRefWithControl<T> extends WritableComputedRef<T>, ComputedWithControlRefExtra {} | ||
| type ComputedWithControlRef<T = any> = ComputedRefWithControl<T> | WritableComputedRefWithControl<T>; | ||
| declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: ComputedGetter<T>, options?: WatchOptions): ComputedRefWithControl<T>; | ||
| declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: WritableComputedOptions<T>, options?: WatchOptions): WritableComputedRefWithControl<T>; | ||
| //#endregion | ||
| //#region utils/types.d.ts | ||
| /** | ||
| * Void function | ||
| */ | ||
| type Fn$1 = () => void; | ||
| /** | ||
| * Any function | ||
| */ | ||
| type AnyFn = (...args: any[]) => any; | ||
| /** | ||
| * A ref that allow to set null or undefined | ||
| */ | ||
| type RemovableRef<T> = Omit<Ref<T>, 'value'> & { | ||
| get value(): T; | ||
| set value(value: T | null | undefined); | ||
| }; | ||
| /** | ||
| * Maybe it's a computed ref, or a readonly value, or a getter function | ||
| */ | ||
| type ReadonlyRefOrGetter<T> = ComputedRef<T> | (() => T); | ||
| /** | ||
| * Make all the nested attributes of an object or array to MaybeRef<T> | ||
| * | ||
| * Good for accepting options that will be wrapped with `reactive` or `ref` | ||
| * | ||
| * ```ts | ||
| * UnwrapRef<DeepMaybeRef<T>> === T | ||
| * ``` | ||
| */ | ||
| type DeepMaybeRef<T> = T extends Ref<infer V> ? MaybeRef<V> : T extends Array<any> | object ? { [K in keyof T]: DeepMaybeRef<T[K]> } : MaybeRef<T>; | ||
| type Arrayable<T> = T[] | T; | ||
| /** | ||
| * Infers the element type of an array | ||
| */ | ||
| type ElementOf<T> = T extends (infer E)[] ? E : never; | ||
| type ShallowUnwrapRef<T> = T extends Ref<infer P> ? P : T; | ||
| type Awaitable<T> = Promise<T> | T; | ||
| type ArgumentsType<T> = T extends ((...args: infer U) => any) ? U : never; | ||
| /** | ||
| * Compatible with versions below TypeScript 4.5 Awaited | ||
| */ | ||
| type Awaited<T> = T extends null | undefined ? T : T extends object & { | ||
| then: (onfulfilled: infer F, ...args: infer _) => any; | ||
| } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T; | ||
| type Promisify<T> = Promise<Awaited<T>>; | ||
| type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>; | ||
| interface Pausable { | ||
| /** | ||
| * A ref indicate whether a pausable instance is active | ||
| */ | ||
| readonly isActive: Readonly<ShallowRef<boolean>>; | ||
| /** | ||
| * Temporary pause the effect from executing | ||
| */ | ||
| pause: Fn$1; | ||
| /** | ||
| * Resume the effects | ||
| */ | ||
| resume: Fn$1; | ||
| } | ||
| interface Stoppable<StartFnArgs extends any[] = any[]> { | ||
| /** | ||
| * A ref indicate whether a stoppable instance is executing | ||
| */ | ||
| readonly isPending: Readonly<Ref<boolean>>; | ||
| /** | ||
| * Stop the effect from executing | ||
| */ | ||
| stop: Fn$1; | ||
| /** | ||
| * Start the effects | ||
| */ | ||
| start: (...args: StartFnArgs) => void; | ||
| } | ||
| interface ConfigurableFlush { | ||
| /** | ||
| * Timing for monitoring changes, refer to WatchOptions for more details | ||
| * | ||
| * @default 'pre' | ||
| */ | ||
| flush?: WatchOptions['flush']; | ||
| } | ||
| interface ConfigurableFlushSync { | ||
| /** | ||
| * Timing for monitoring changes, refer to WatchOptions for more details. | ||
| * Unlike `watch()`, the default is set to `sync` | ||
| * | ||
| * @default 'sync' | ||
| */ | ||
| flush?: WatchOptions['flush']; | ||
| } | ||
| type MultiWatchSources = (WatchSource<unknown> | object)[]; | ||
| type MapSources<T> = { [K in keyof T]: T[K] extends WatchSource<infer V> ? V : never }; | ||
| type MapOldSources<T, Immediate> = { [K in keyof T]: T[K] extends WatchSource<infer V> ? Immediate extends true ? V | undefined : V : never }; | ||
| type Mutable<T> = { -readonly [P in keyof T]: T[P] }; | ||
| type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N; | ||
| /** | ||
| * will return `true` if `T` is `any`, or `false` otherwise | ||
| */ | ||
| type IsAny<T> = IfAny<T, true, false>; | ||
| /** | ||
| * Universal timer handle that works in both browser and Node.js environments | ||
| */ | ||
| type TimerHandle = ReturnType<typeof setTimeout> | undefined; | ||
| //#endregion | ||
| //#region createEventHook/index.d.ts | ||
| type Callback<T> = IsAny<T> extends true ? (...param: any) => void : ([T] extends [void] ? (...param: unknown[]) => void : [T] extends [any[]] ? (...param: T) => void : (...param: [T, ...unknown[]]) => void); | ||
| type EventHookOn<T = any> = (fn: Callback<T>) => { | ||
| off: () => void; | ||
| }; | ||
| type EventHookOff<T = any> = (fn: Callback<T>) => void; | ||
| type EventHookTrigger<T = any> = (...param: Parameters<Callback<T>>) => Promise<unknown[]>; | ||
| interface EventHook<T = any> { | ||
| on: EventHookOn<T>; | ||
| off: EventHookOff<T>; | ||
| trigger: EventHookTrigger<T>; | ||
| clear: () => void; | ||
| } | ||
| type EventHookReturn<T> = EventHook<T>; | ||
| /** | ||
| * Utility for creating event hooks | ||
| * | ||
| * @see https://vueuse.org/createEventHook | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createEventHook<T = any>(): EventHookReturn<T>; | ||
| //#endregion | ||
| //#region utils/filters.d.ts | ||
| type FunctionArgs<Args extends any[] = any[], Return = void> = (...args: Args) => Return; | ||
| interface FunctionWrapperOptions<Args extends any[] = any[], This = any> { | ||
| fn: FunctionArgs<Args, This>; | ||
| args: Args; | ||
| thisArg: This; | ||
| } | ||
| type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> | Promisify<ReturnType<Invoke>>; | ||
| interface ConfigurableEventFilter { | ||
| /** | ||
| * Filter for if events should to be received. | ||
| * | ||
| * @see https://vueuse.org/guide/config.html#event-filters | ||
| */ | ||
| eventFilter?: EventFilter; | ||
| } | ||
| interface DebounceFilterOptions { | ||
| /** | ||
| * The maximum time allowed to be delayed before it's invoked. | ||
| * In milliseconds. | ||
| */ | ||
| maxWait?: MaybeRefOrGetter$1<number>; | ||
| /** | ||
| * Whether to reject the last call if it's been cancel. | ||
| * | ||
| * @default false | ||
| */ | ||
| rejectOnCancel?: boolean; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>; | ||
| declare const bypassFilter: EventFilter; | ||
| /** | ||
| * Create an EventFilter that debounce the events | ||
| */ | ||
| declare function debounceFilter(ms: MaybeRefOrGetter$1<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>; | ||
| interface ThrottleFilterOptions { | ||
| /** | ||
| * The maximum time allowed to be delayed before it's invoked. | ||
| */ | ||
| delay: MaybeRefOrGetter$1<number>; | ||
| /** | ||
| * Whether to invoke on the trailing edge of the timeout. | ||
| */ | ||
| trailing?: boolean; | ||
| /** | ||
| * Whether to invoke on the leading edge of the timeout. | ||
| */ | ||
| leading?: boolean; | ||
| /** | ||
| * Whether to reject the last call if it's been cancel. | ||
| */ | ||
| rejectOnCancel?: boolean; | ||
| } | ||
| /** | ||
| * Create an EventFilter that throttle the events | ||
| */ | ||
| declare function throttleFilter(ms: MaybeRefOrGetter$1<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter; | ||
| declare function throttleFilter(options: ThrottleFilterOptions): EventFilter; | ||
| interface PausableFilterOptions { | ||
| /** | ||
| * The initial state | ||
| * | ||
| * @default 'active' | ||
| */ | ||
| initialState?: 'active' | 'paused'; | ||
| } | ||
| /** | ||
| * EventFilter that gives extra controls to pause and resume the filter | ||
| * | ||
| * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none | ||
| * @param options Options to configure the filter | ||
| */ | ||
| declare function pausableFilter(extendFilter?: EventFilter, options?: PausableFilterOptions): Pausable & { | ||
| eventFilter: EventFilter; | ||
| }; | ||
| //#endregion | ||
| //#region utils/general.d.ts | ||
| declare function promiseTimeout(ms: number, throwOnTimeout?: boolean, reason?: string): Promise<void>; | ||
| declare function identity<T>(arg: T): T; | ||
| interface SingletonPromiseReturn<T> { | ||
| (): Promise<T>; | ||
| /** | ||
| * Reset current staled promise. | ||
| * await it to have proper shutdown. | ||
| */ | ||
| reset: () => Promise<void>; | ||
| } | ||
| /** | ||
| * Create singleton promise function | ||
| * | ||
| * @example | ||
| * ``` | ||
| * const promise = createSingletonPromise(async () => { ... }) | ||
| * | ||
| * await promise() | ||
| * await promise() // all of them will be bind to a single promise instance | ||
| * await promise() // and be resolved together | ||
| * ``` | ||
| */ | ||
| declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>; | ||
| declare function invoke<T>(fn: () => T): T; | ||
| declare function containsProp(obj: object, ...props: string[]): boolean; | ||
| /** | ||
| * Increase string a value with unit | ||
| * | ||
| * @example '2px' + 1 = '3px' | ||
| * @example '15em' + (-2) = '13em' | ||
| */ | ||
| declare function increaseWithUnit(target: number, delta: number): number; | ||
| declare function increaseWithUnit(target: string, delta: number): string; | ||
| declare function increaseWithUnit(target: string | number, delta: number): string | number; | ||
| /** | ||
| * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client | ||
| */ | ||
| declare function pxValue(px: string): number; | ||
| /** | ||
| * Create a new subset object by giving keys | ||
| */ | ||
| declare function objectPick<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Pick<O, T>; | ||
| /** | ||
| * Create a new subset object by omit giving keys | ||
| */ | ||
| declare function objectOmit<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Omit<O, T>; | ||
| declare function objectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>; | ||
| declare function toArray<T>(value: T | readonly T[]): readonly T[]; | ||
| declare function toArray<T>(value: T | T[]): T[]; | ||
| //#endregion | ||
| //#region utils/is.d.ts | ||
| declare const isClient: boolean; | ||
| declare const isWorker: boolean; | ||
| declare const isDef: <T = any>(val?: T) => val is T; | ||
| declare const notNullish: <T = any>(val?: T | null | undefined) => val is T; | ||
| declare const assert: (condition: boolean, ...infos: any[]) => void; | ||
| declare const isObject: (val: any) => val is object; | ||
| declare const now: () => number; | ||
| declare const timestamp: () => number; | ||
| declare const clamp: (n: number, min: number, max: number) => number; | ||
| declare const noop: () => void; | ||
| declare const rand: (min: number, max: number) => number; | ||
| declare const hasOwn: <T extends object, K extends keyof T>(val: T, key: K) => key is K; | ||
| declare const isIOS: boolean | ""; | ||
| //#endregion | ||
| //#region utils/port.d.ts | ||
| declare const hyphenate: (str: string) => string; | ||
| declare const camelize: (str: string) => string; | ||
| //#endregion | ||
| //#region utils/vue.d.ts | ||
| declare function getLifeCycleTarget(target?: any): any; | ||
| //#endregion | ||
| //#region createGlobalState/index.d.ts | ||
| type CreateGlobalStateReturn<Fn extends AnyFn = AnyFn> = Fn; | ||
| /** | ||
| * Keep states in the global scope to be reusable across Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createGlobalState | ||
| * @param stateFactory A factory function to create the state | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createGlobalState<Fn extends AnyFn>(stateFactory: Fn): CreateGlobalStateReturn<Fn>; | ||
| //#endregion | ||
| //#region createInjectionState/index.d.ts | ||
| interface CreateInjectionStateOptions<Return> { | ||
| /** | ||
| * Custom injectionKey for InjectionState | ||
| */ | ||
| injectionKey?: string | InjectionKey<Return>; | ||
| /** | ||
| * Default value for the InjectionState | ||
| */ | ||
| defaultValue?: Return; | ||
| } | ||
| /** | ||
| * Create global state that can be injected into components. | ||
| * | ||
| * @see https://vueuse.org/createInjectionState | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return, options?: CreateInjectionStateOptions<Return>): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined]; | ||
| //#endregion | ||
| //#region createRef/index.d.ts | ||
| type CreateRefReturn<T = any, D extends boolean = false> = ShallowOrDeepRef<T, D>; | ||
| type ShallowOrDeepRef<T = any, D extends boolean = false> = D extends true ? Ref<T> : ShallowRef<T>; | ||
| /** | ||
| * Returns a `deepRef` or `shallowRef` depending on the `deep` param. | ||
| * | ||
| * @example createRef(1) // ShallowRef<number> | ||
| * @example createRef(1, false) // ShallowRef<number> | ||
| * @example createRef(1, true) // Ref<number> | ||
| * @example createRef("string") // ShallowRef<string> | ||
| * @example createRef<"A"|"B">("A", true) // Ref<"A"|"B"> | ||
| * | ||
| * @param value | ||
| * @param deep | ||
| * @returns the `deepRef` or `shallowRef` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createRef<T = any, D extends boolean = false>(value: T, deep?: D): CreateRefReturn<T, D>; | ||
| //#endregion | ||
| //#region createSharedComposable/index.d.ts | ||
| type SharedComposableReturn<T extends AnyFn = AnyFn> = T; | ||
| /** | ||
| * Make a composable function usable with multiple Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createSharedComposable | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createSharedComposable<Fn extends AnyFn>(composable: Fn): SharedComposableReturn<Fn>; | ||
| //#endregion | ||
| //#region extendRef/index.d.ts | ||
| type ExtendRefReturn<T = any> = Ref<T>; | ||
| interface ExtendRefOptions<Unwrap extends boolean = boolean> { | ||
| /** | ||
| * Is the extends properties enumerable | ||
| * | ||
| * @default false | ||
| */ | ||
| enumerable?: boolean; | ||
| /** | ||
| * Unwrap for Ref properties | ||
| * | ||
| * @default true | ||
| */ | ||
| unwrap?: Unwrap; | ||
| } | ||
| /** | ||
| * Overload 1: Unwrap set to false | ||
| */ | ||
| declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions<false>>(ref: R, extend: Extend, options?: Options): ShallowUnwrapRef$1<Extend> & R; | ||
| /** | ||
| * Overload 2: Unwrap unset or set to true | ||
| */ | ||
| declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions>(ref: R, extend: Extend, options?: Options): Extend & R; | ||
| //#endregion | ||
| //#region get/index.d.ts | ||
| /** | ||
| * Shorthand for accessing `ref.value` | ||
| */ | ||
| declare function get<T>(ref: MaybeRef$1<T>): T; | ||
| declare function get<T, K extends keyof T>(ref: MaybeRef$1<T>, key: K): T[K]; | ||
| //#endregion | ||
| //#region injectLocal/index.d.ts | ||
| /** | ||
| * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * injectLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare const injectLocal: typeof inject; | ||
| //#endregion | ||
| //#region isDefined/index.d.ts | ||
| type IsDefinedReturn = boolean; | ||
| declare function isDefined<T>(v: ComputedRef<T>): v is ComputedRef<Exclude<T, null | undefined>>; | ||
| declare function isDefined<T>(v: Ref<T>): v is Ref<Exclude<T, null | undefined>>; | ||
| declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>; | ||
| //#endregion | ||
| //#region makeDestructurable/index.d.ts | ||
| declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A; | ||
| //#endregion | ||
| //#region provideLocal/index.d.ts | ||
| type ProvideLocalReturn = void; | ||
| /** | ||
| * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * provideLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| */ | ||
| declare function provideLocal<T, K = InjectionKey<T> | string | number>(key: K, value: K extends InjectionKey<infer V> ? V : T): ProvideLocalReturn; | ||
| //#endregion | ||
| //#region reactify/index.d.ts | ||
| type Reactified<T, Computed extends boolean> = T extends ((...args: infer A) => infer R) ? (...args: { [K in keyof A]: Computed extends true ? MaybeRefOrGetter$1<A[K]> : MaybeRef$1<A[K]> }) => ComputedRef<R> : never; | ||
| type ReactifyReturn<T extends AnyFn = AnyFn, K extends boolean = true> = Reactified<T, K>; | ||
| interface ReactifyOptions<T extends boolean> { | ||
| /** | ||
| * Accept passing a function as a reactive getter | ||
| * | ||
| * @default true | ||
| */ | ||
| computedGetter?: T; | ||
| } | ||
| /** | ||
| * Converts plain function into a reactive function. | ||
| * The converted function accepts refs as it's arguments | ||
| * and returns a ComputedRef, with proper typing. | ||
| * | ||
| * @param fn - Source function | ||
| * @param options - Options | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function reactify<T extends AnyFn, K extends boolean = true>(fn: T, options?: ReactifyOptions<K>): ReactifyReturn<T, K>; | ||
| //#endregion | ||
| //#region reactifyObject/index.d.ts | ||
| type ReactifyNested<T, Keys extends keyof T = keyof T, S extends boolean = true> = { [K in Keys]: T[K] extends AnyFn ? Reactified<T[K], S> : T[K] }; | ||
| type ReactifyObjectReturn<T, Keys extends keyof T, S extends boolean = true> = ReactifyNested<T, Keys, S>; | ||
| interface ReactifyObjectOptions<T extends boolean> extends ReactifyOptions<T> { | ||
| /** | ||
| * Includes names from Object.getOwnPropertyNames | ||
| * | ||
| * @default true | ||
| */ | ||
| includeOwnProperties?: boolean; | ||
| } | ||
| /** | ||
| * Apply `reactify` to an object | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function reactifyObject<T extends object, Keys extends keyof T>(obj: T, keys?: (keyof T)[]): ReactifyObjectReturn<T, Keys, true>; | ||
| declare function reactifyObject<T extends object, S extends boolean = true>(obj: T, options?: ReactifyObjectOptions<S>): ReactifyObjectReturn<T, keyof T, S>; | ||
| //#endregion | ||
| //#region reactiveComputed/index.d.ts | ||
| type ReactiveComputedReturn<T extends object> = UnwrapNestedRefs<T>; | ||
| /** | ||
| * Computed reactive object. | ||
| */ | ||
| declare function reactiveComputed<T extends object>(fn: ComputedGetter<T>): ReactiveComputedReturn<T>; | ||
| //#endregion | ||
| //#region reactiveOmit/index.d.ts | ||
| type ReactiveOmitReturn<T extends object, K extends keyof T | undefined = undefined> = [K] extends [undefined] ? Partial<T> : Omit<T, Extract<K, keyof T>>; | ||
| type ReactiveOmitPredicate<T> = (value: T[keyof T], key: keyof T) => boolean; | ||
| declare function reactiveOmit<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): ReactiveOmitReturn<T, K>; | ||
| declare function reactiveOmit<T extends object>(obj: T, predicate: ReactiveOmitPredicate<T>): ReactiveOmitReturn<T>; | ||
| //#endregion | ||
| //#region reactivePick/index.d.ts | ||
| type ReactivePickReturn<T extends object, K extends keyof T> = { [S in K]: UnwrapRef<T[S]> }; | ||
| type ReactivePickPredicate<T> = (value: T[keyof T], key: keyof T) => boolean; | ||
| declare function reactivePick<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): ReactivePickReturn<T, K>; | ||
| declare function reactivePick<T extends object>(obj: T, predicate: ReactivePickPredicate<T>): ReactivePickReturn<T, keyof T>; | ||
| //#endregion | ||
| //#region refAutoReset/index.d.ts | ||
| type RefAutoResetReturn<T = any> = Ref<T>; | ||
| /** | ||
| * Create a ref which will be reset to the default value after some time. | ||
| * | ||
| * @see https://vueuse.org/refAutoReset | ||
| * @param defaultValue The value which will be set. | ||
| * @param afterMs A zero-or-greater delay in milliseconds. | ||
| */ | ||
| declare function refAutoReset<T>(defaultValue: MaybeRefOrGetter$1<T>, afterMs?: MaybeRefOrGetter$1<number>): RefAutoResetReturn<T>; | ||
| //#endregion | ||
| //#region refDebounced/index.d.ts | ||
| type RefDebouncedReturn<T = any> = Readonly<Ref<T>>; | ||
| /** | ||
| * Debounce updates of a ref. | ||
| * | ||
| * @return A new debounced ref. | ||
| */ | ||
| declare function refDebounced<T>(value: Ref<T>, ms?: MaybeRefOrGetter$1<number>, options?: DebounceFilterOptions): RefDebouncedReturn<T>; | ||
| //#endregion | ||
| //#region refDefault/index.d.ts | ||
| /** | ||
| * Apply default value to a ref. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue: T): Ref<T>; | ||
| //#endregion | ||
| //#region refThrottled/index.d.ts | ||
| type RefThrottledReturn<T = any> = Ref<T>; | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param value Ref value to be watched with throttle effect | ||
| * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param trailing if true, update the value again after the delay time is up | ||
| * @param leading if true, update the value on the leading edge of the ms timeout | ||
| */ | ||
| declare function refThrottled<T = any>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): RefThrottledReturn<T>; | ||
| //#endregion | ||
| //#region refWithControl/index.d.ts | ||
| interface ControlledRefOptions<T> { | ||
| /** | ||
| * Callback function before the ref changing. | ||
| * | ||
| * Returning `false` to dismiss the change. | ||
| */ | ||
| onBeforeChange?: (value: T, oldValue: T) => void | boolean; | ||
| /** | ||
| * Callback function after the ref changed | ||
| * | ||
| * This happens synchronously, with less overhead compare to `watch` | ||
| */ | ||
| onChanged?: (value: T, oldValue: T) => void; | ||
| } | ||
| /** | ||
| * Fine-grained controls over ref and its reactivity. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function refWithControl<T>(initial: T, options?: ControlledRefOptions<T>): vue0.ShallowUnwrapRef<{ | ||
| get: (tracking?: boolean) => T; | ||
| set: (value: T, triggering?: boolean) => void; | ||
| untrackedGet: () => T; | ||
| silentSet: (v: T) => void; | ||
| peek: () => T; | ||
| lay: (v: T) => void; | ||
| }> & vue0.Ref<T, T>; | ||
| /** | ||
| * Alias for `refWithControl` | ||
| */ | ||
| declare const controlledRef: typeof refWithControl; | ||
| //#endregion | ||
| //#region set/index.d.ts | ||
| declare function set<T>(ref: Ref<T>, value: T): void; | ||
| declare function set<O extends object, K extends keyof O>(target: O, key: K, value: O[K]): void; | ||
| //#endregion | ||
| //#region syncRef/index.d.ts | ||
| type Direction = 'ltr' | 'rtl' | 'both'; | ||
| type SpecificFieldPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>; | ||
| /** | ||
| * A = B | ||
| */ | ||
| type Equal<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false; | ||
| /** | ||
| * A ∩ B ≠ ∅ | ||
| */ | ||
| type IntersectButNotEqual<A, B> = Equal<A, B> extends true ? false : A & B extends never ? false : true; | ||
| /** | ||
| * A ⊆ B | ||
| */ | ||
| type IncludeButNotEqual<A, B> = Equal<A, B> extends true ? false : A extends B ? true : false; | ||
| /** | ||
| * A ∩ B = ∅ | ||
| */ | ||
| type NotIntersect<A, B> = Equal<A, B> extends true ? false : A & B extends never ? true : false; | ||
| interface EqualType<D extends Direction, L, R, O extends keyof Transform<L, R> = (D extends 'both' ? 'ltr' | 'rtl' : D)> { | ||
| transform?: SpecificFieldPartial<Pick<Transform<L, R>, O>, O>; | ||
| } | ||
| type StrictIncludeMap<IncludeType extends 'LR' | 'RL', D extends Exclude<Direction, 'both'>, L, R> = (Equal<[IncludeType, D], ['LR', 'ltr']> & Equal<[IncludeType, D], ['RL', 'rtl']>) extends true ? { | ||
| transform?: SpecificFieldPartial<Pick<Transform<L, R>, D>, D>; | ||
| } : { | ||
| transform: Pick<Transform<L, R>, D>; | ||
| }; | ||
| type StrictIncludeType<IncludeType extends 'LR' | 'RL', D extends Direction, L, R> = D extends 'both' ? { | ||
| transform: SpecificFieldPartial<Transform<L, R>, IncludeType extends 'LR' ? 'ltr' : 'rtl'>; | ||
| } : D extends Exclude<Direction, 'both'> ? StrictIncludeMap<IncludeType, D, L, R> : never; | ||
| type IntersectButNotEqualType<D extends Direction, L, R> = D extends 'both' ? { | ||
| transform: Transform<L, R>; | ||
| } : D extends Exclude<Direction, 'both'> ? { | ||
| transform: Pick<Transform<L, R>, D>; | ||
| } : never; | ||
| type NotIntersectType<D extends Direction, L, R> = IntersectButNotEqualType<D, L, R>; | ||
| interface Transform<L, R> { | ||
| ltr: (left: L) => R; | ||
| rtl: (right: R) => L; | ||
| } | ||
| type TransformType<D extends Direction, L, R> = Equal<L, R> extends true ? EqualType<D, L, R> : IncludeButNotEqual<L, R> extends true ? StrictIncludeType<'LR', D, L, R> : IncludeButNotEqual<R, L> extends true ? StrictIncludeType<'RL', D, L, R> : IntersectButNotEqual<L, R> extends true ? IntersectButNotEqualType<D, L, R> : NotIntersect<L, R> extends true ? NotIntersectType<D, L, R> : never; | ||
| type SyncRefOptions<L, R, D extends Direction> = ConfigurableFlushSync & { | ||
| /** | ||
| * Watch deeply | ||
| * | ||
| * @default false | ||
| */ | ||
| deep?: boolean; | ||
| /** | ||
| * Sync values immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Direction of syncing. Value will be redefined if you define syncConvertors | ||
| * | ||
| * @default 'both' | ||
| */ | ||
| direction?: D; | ||
| } & TransformType<D, L, R>; | ||
| /** | ||
| * Two-way refs synchronization. | ||
| * From the set theory perspective to restrict the option's type | ||
| * Check in the following order: | ||
| * 1. L = R | ||
| * 2. L ∩ R ≠ ∅ | ||
| * 3. L ⊆ R | ||
| * 4. L ∩ R = ∅ | ||
| */ | ||
| declare function syncRef<L, R, D extends Direction = 'both'>(left: Ref<L>, right: Ref<R>, ...[options]: Equal<L, R> extends true ? [options?: SyncRefOptions<L, R, D>] : [options: SyncRefOptions<L, R, D>]): () => void; | ||
| //#endregion | ||
| //#region syncRefs/index.d.ts | ||
| interface SyncRefsOptions extends ConfigurableFlushSync { | ||
| /** | ||
| * Watch deeply | ||
| * | ||
| * @default false | ||
| */ | ||
| deep?: boolean; | ||
| /** | ||
| * Sync values immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| } | ||
| /** | ||
| * Keep target ref(s) in sync with the source ref | ||
| * | ||
| * @param source source ref | ||
| * @param targets | ||
| */ | ||
| declare function syncRefs<T>(source: WatchSource<T>, targets: Ref<T> | Ref<T>[], options?: SyncRefsOptions): vue0.WatchHandle; | ||
| //#endregion | ||
| //#region toReactive/index.d.ts | ||
| /** | ||
| * Converts ref to reactive. | ||
| * | ||
| * @see https://vueuse.org/toReactive | ||
| * @param objectRef A ref of object | ||
| */ | ||
| declare function toReactive<T extends object>(objectRef: MaybeRef$1<T>): UnwrapNestedRefs<T>; | ||
| //#endregion | ||
| //#region toRef/index.d.ts | ||
| /** | ||
| * Normalize value/ref/getter to `ref` or `computed`. | ||
| */ | ||
| declare function toRef<T>(r: () => T): Readonly<Ref<T>>; | ||
| declare function toRef<T>(r: ComputedRef<T>): ComputedRef<T>; | ||
| declare function toRef<T>(r: MaybeRefOrGetter$1<T>): Ref<T>; | ||
| declare function toRef<T>(r: T): Ref<T>; | ||
| declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>; | ||
| declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>; | ||
| /** | ||
| * @deprecated use `toRef` instead | ||
| */ | ||
| declare const resolveRef: typeof toRef; | ||
| //#endregion | ||
| //#region toRefs/index.d.ts | ||
| interface ToRefsOptions { | ||
| /** | ||
| * Replace the original ref with a copy on property update. | ||
| * | ||
| * @default true | ||
| */ | ||
| replaceRef?: MaybeRefOrGetter$1<boolean>; | ||
| } | ||
| /** | ||
| * Extended `toRefs` that also accepts refs of an object. | ||
| * | ||
| * @see https://vueuse.org/toRefs | ||
| * @param objectRef A ref or normal object or array. | ||
| * @param options Options | ||
| */ | ||
| declare function toRefs<T extends object>(objectRef: MaybeRef$1<T>, options?: ToRefsOptions): ToRefs<T>; | ||
| //#endregion | ||
| //#region toValue/index.d.ts | ||
| /** | ||
| * Get the value of value/ref/getter. | ||
| * | ||
| * @deprecated use `toValue` from `vue` instead | ||
| */ | ||
| declare const toValue: typeof toValue$1; | ||
| /** | ||
| * @deprecated use `toValue` instead | ||
| */ | ||
| declare const resolveUnref: typeof toValue$1; | ||
| //#endregion | ||
| //#region tryOnBeforeMount/index.d.ts | ||
| /** | ||
| * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| declare function tryOnBeforeMount(fn: Fn$1, sync?: boolean, target?: any): void; | ||
| //#endregion | ||
| //#region tryOnBeforeUnmount/index.d.ts | ||
| /** | ||
| * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| declare function tryOnBeforeUnmount(fn: Fn$1, target?: any): void; | ||
| //#endregion | ||
| //#region tryOnMounted/index.d.ts | ||
| /** | ||
| * Call onMounted() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| declare function tryOnMounted(fn: Fn$1, sync?: boolean, target?: any): void; | ||
| //#endregion | ||
| //#region tryOnScopeDispose/index.d.ts | ||
| /** | ||
| * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| */ | ||
| declare function tryOnScopeDispose(fn: Fn$1): boolean; | ||
| //#endregion | ||
| //#region tryOnUnmounted/index.d.ts | ||
| /** | ||
| * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| declare function tryOnUnmounted(fn: Fn$1, target?: any): void; | ||
| //#endregion | ||
| //#region until/index.d.ts | ||
| interface UntilToMatchOptions { | ||
| /** | ||
| * Milliseconds timeout for promise to resolve/reject if the when condition does not meet. | ||
| * 0 for never timed out | ||
| * | ||
| * @default 0 | ||
| */ | ||
| timeout?: number; | ||
| /** | ||
| * Reject the promise when timeout | ||
| * | ||
| * @default false | ||
| */ | ||
| throwOnTimeout?: boolean; | ||
| /** | ||
| * `flush` option for internal watch | ||
| * | ||
| * @default 'sync' | ||
| */ | ||
| flush?: WatchOptions['flush']; | ||
| /** | ||
| * `deep` option for internal watch | ||
| * | ||
| * @default 'false' | ||
| */ | ||
| deep?: WatchOptions['deep']; | ||
| } | ||
| interface UntilBaseInstance<T, Not extends boolean = false> { | ||
| toMatch: (<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, U>> : Promise<U>) & ((condition: (v: T) => boolean, options?: UntilToMatchOptions) => Promise<T>); | ||
| changed: (options?: UntilToMatchOptions) => Promise<T>; | ||
| changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise<T>; | ||
| } | ||
| type Falsy$1 = false | void | null | undefined | 0 | 0n | ''; | ||
| interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> { | ||
| readonly not: UntilValueInstance<T, Not extends true ? false : true>; | ||
| toBe: <P = T>(value: MaybeRefOrGetter$1<P>, options?: UntilToMatchOptions) => Not extends true ? Promise<T> : Promise<P>; | ||
| toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise<T & Falsy$1> : Promise<Exclude<T, Falsy$1>>; | ||
| toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, null>> : Promise<null>; | ||
| toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>; | ||
| toBeNaN: (options?: UntilToMatchOptions) => Promise<T>; | ||
| } | ||
| interface UntilArrayInstance<T> extends UntilBaseInstance<T> { | ||
| readonly not: UntilArrayInstance<T>; | ||
| toContains: (value: MaybeRefOrGetter$1<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions) => Promise<T>; | ||
| } | ||
| /** | ||
| * Promised one-time watch for changes | ||
| * | ||
| * @see https://vueuse.org/until | ||
| * @example | ||
| * ``` | ||
| * const { count } = useCounter() | ||
| * | ||
| * await until(count).toMatch(v => v > 7) | ||
| * | ||
| * alert('Counter is now larger than 7!') | ||
| * ``` | ||
| */ | ||
| declare function until<T extends unknown[]>(r: WatchSource<T> | MaybeRefOrGetter$1<T>): UntilArrayInstance<T>; | ||
| declare function until<T>(r: WatchSource<T> | MaybeRefOrGetter$1<T>): UntilValueInstance<T>; | ||
| //#endregion | ||
| //#region useArrayDifference/index.d.ts | ||
| interface UseArrayDifferenceOptions { | ||
| /** | ||
| * Returns asymmetric difference | ||
| * | ||
| * @see https://en.wikipedia.org/wiki/Symmetric_difference | ||
| * @default false | ||
| */ | ||
| symmetric?: boolean; | ||
| } | ||
| type UseArrayDifferenceReturn<T = any> = ComputedRef<T[]>; | ||
| declare function useArrayDifference<T>(list: MaybeRefOrGetter$1<T[]>, values: MaybeRefOrGetter$1<T[]>, key?: keyof T, options?: UseArrayDifferenceOptions): UseArrayDifferenceReturn<T>; | ||
| declare function useArrayDifference<T>(list: MaybeRefOrGetter$1<T[]>, values: MaybeRefOrGetter$1<T[]>, compareFn?: (value: T, othVal: T) => boolean, options?: UseArrayDifferenceOptions): UseArrayDifferenceReturn<T>; | ||
| //#endregion | ||
| //#region useArrayEvery/index.d.ts | ||
| type UseArrayEveryReturn = ComputedRef<boolean>; | ||
| /** | ||
| * Reactive `Array.every` | ||
| * | ||
| * @see https://vueuse.org/useArrayEvery | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayEvery<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter$1<T>[]) => unknown): UseArrayEveryReturn; | ||
| //#endregion | ||
| //#region useArrayFilter/index.d.ts | ||
| type UseArrayFilterReturn<T = any> = ComputedRef<T[]>; | ||
| /** | ||
| * Reactive `Array.filter` | ||
| * | ||
| * @see https://vueuse.org/useArrayFilter | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFilter<T, S extends T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: T[]) => element is S): UseArrayFilterReturn<S>; | ||
| declare function useArrayFilter<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: T[]) => unknown): UseArrayFilterReturn<T>; | ||
| //#endregion | ||
| //#region useArrayFind/index.d.ts | ||
| type UseArrayFindReturn<T = any> = ComputedRef<T | undefined>; | ||
| /** | ||
| * Reactive `Array.find` | ||
| * | ||
| * @see https://vueuse.org/useArrayFind | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFind<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter$1<T>[]) => boolean): UseArrayFindReturn<T>; | ||
| //#endregion | ||
| //#region useArrayFindIndex/index.d.ts | ||
| type UseArrayFindIndexReturn = ComputedRef<number>; | ||
| /** | ||
| * Reactive `Array.findIndex` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindIndex | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the index of the first element in the array that passes the test. Otherwise, "-1". | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFindIndex<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter$1<T>[]) => unknown): UseArrayFindIndexReturn; | ||
| //#endregion | ||
| //#region useArrayFindLast/index.d.ts | ||
| type UseArrayFindLastReturn<T = any> = ComputedRef<T | undefined>; | ||
| /** | ||
| * Reactive `Array.findLast` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindLast | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFindLast<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter$1<T>[]) => boolean): UseArrayFindLastReturn<T>; | ||
| //#endregion | ||
| //#region useArrayIncludes/index.d.ts | ||
| type UseArrayIncludesComparatorFn<T, V> = ((element: T, value: V, index: number, array: MaybeRefOrGetter$1<T>[]) => boolean); | ||
| interface UseArrayIncludesOptions<T, V> { | ||
| fromIndex?: number; | ||
| comparator?: UseArrayIncludesComparatorFn<T, V> | keyof T; | ||
| } | ||
| type UseArrayIncludesReturn = ComputedRef<boolean>; | ||
| /** | ||
| * Reactive `Array.includes` | ||
| * | ||
| * @see https://vueuse.org/useArrayIncludes | ||
| * | ||
| * @returns true if the `value` is found in the array. Otherwise, false. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, value: MaybeRefOrGetter$1<V>, comparator?: UseArrayIncludesComparatorFn<T, V>): UseArrayIncludesReturn; | ||
| declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, value: MaybeRefOrGetter$1<V>, comparator?: keyof T): UseArrayIncludesReturn; | ||
| declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, value: MaybeRefOrGetter$1<V>, options?: UseArrayIncludesOptions<T, V>): UseArrayIncludesReturn; | ||
| //#endregion | ||
| //#region useArrayJoin/index.d.ts | ||
| type UseArrayJoinReturn = ComputedRef<string>; | ||
| /** | ||
| * Reactive `Array.join` | ||
| * | ||
| * @see https://vueuse.org/useArrayJoin | ||
| * @param list - the array was called upon. | ||
| * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (","). | ||
| * | ||
| * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayJoin(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<any>[]>, separator?: MaybeRefOrGetter$1<string>): UseArrayJoinReturn; | ||
| //#endregion | ||
| //#region useArrayMap/index.d.ts | ||
| type UseArrayMapReturn<T = any> = ComputedRef<T[]>; | ||
| /** | ||
| * Reactive `Array.map` | ||
| * | ||
| * @see https://vueuse.org/useArrayMap | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a new array with each element being the result of the callback function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayMap<T, U = T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: T[]) => U): UseArrayMapReturn<U>; | ||
| //#endregion | ||
| //#region useArrayReduce/index.d.ts | ||
| type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentIndex: number) => R; | ||
| /** | ||
| * Reactive `Array.reduce` | ||
| * | ||
| * @see https://vueuse.org/useArrayReduce | ||
| * @param list - the array was called upon. | ||
| * @param reducer - a "reducer" function. | ||
| * | ||
| * @returns the value that results from running the "reducer" callback function to completion over the entire array. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayReduce<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, reducer: UseArrayReducer<T, T, T>): ComputedRef<T>; | ||
| /** | ||
| * Reactive `Array.reduce` | ||
| * | ||
| * @see https://vueuse.org/useArrayReduce | ||
| * @param list - the array was called upon. | ||
| * @param reducer - a "reducer" function. | ||
| * @param initialValue - a value to be initialized the first time when the callback is called. | ||
| * | ||
| * @returns the value that results from running the "reducer" callback function to completion over the entire array. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayReduce<T, U>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, reducer: UseArrayReducer<U, T, U>, initialValue: MaybeRefOrGetter$1<U>): ComputedRef<U>; | ||
| //#endregion | ||
| //#region useArraySome/index.d.ts | ||
| type UseArraySomeReturn = ComputedRef<boolean>; | ||
| /** | ||
| * Reactive `Array.some` | ||
| * | ||
| * @see https://vueuse.org/useArraySome | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArraySome<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter$1<T>[]) => unknown): UseArraySomeReturn; | ||
| //#endregion | ||
| //#region useArrayUnique/index.d.ts | ||
| type UseArrayUniqueReturn<T = any> = ComputedRef<T[]>; | ||
| /** | ||
| * reactive unique array | ||
| * @see https://vueuse.org/useArrayUnique | ||
| * @param list - the array was called upon. | ||
| * @param compareFn | ||
| * @returns A computed ref that returns a unique array of items. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayUnique<T>(list: MaybeRefOrGetter$1<MaybeRefOrGetter$1<T>[]>, compareFn?: (a: T, b: T, array: T[]) => boolean): UseArrayUniqueReturn<T>; | ||
| //#endregion | ||
| //#region useCounter/index.d.ts | ||
| interface UseCounterOptions { | ||
| min?: number; | ||
| max?: number; | ||
| } | ||
| interface UseCounterReturn { | ||
| /** | ||
| * The current value of the counter. | ||
| */ | ||
| readonly count: Readonly<Ref<number>>; | ||
| /** | ||
| * Increment the counter. | ||
| * | ||
| * @param {number} [delta=1] The number to increment. | ||
| */ | ||
| inc: (delta?: number) => void; | ||
| /** | ||
| * Decrement the counter. | ||
| * | ||
| * @param {number} [delta=1] The number to decrement. | ||
| */ | ||
| dec: (delta?: number) => void; | ||
| /** | ||
| * Get the current value of the counter. | ||
| */ | ||
| get: () => number; | ||
| /** | ||
| * Set the counter to a new value. | ||
| * | ||
| * @param val The new value of the counter. | ||
| */ | ||
| set: (val: number) => void; | ||
| /** | ||
| * Reset the counter to an initial value. | ||
| */ | ||
| reset: (val?: number) => number; | ||
| } | ||
| /** | ||
| * Basic counter with utility functions. | ||
| * | ||
| * @see https://vueuse.org/useCounter | ||
| * @param [initialValue] | ||
| * @param options | ||
| */ | ||
| declare function useCounter(initialValue?: MaybeRef$1<number>, options?: UseCounterOptions): { | ||
| count: Readonly<Ref<number, number> | vue0.ShallowRef<number, number> | vue0.WritableComputedRef<number, number>>; | ||
| inc: (delta?: number) => number; | ||
| dec: (delta?: number) => number; | ||
| get: () => number; | ||
| set: (val: number) => number; | ||
| reset: (val?: number) => number; | ||
| }; | ||
| //#endregion | ||
| //#region useDateFormat/index.d.ts | ||
| type DateLike = Date | number | string | undefined; | ||
| interface UseDateFormatOptions { | ||
| /** | ||
| * The locale(s) to used for dd/ddd/dddd/MMM/MMMM format | ||
| * | ||
| * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument). | ||
| */ | ||
| locales?: MaybeRefOrGetter$1<Intl.LocalesArgument>; | ||
| /** | ||
| * A custom function to re-modify the way to display meridiem | ||
| * | ||
| */ | ||
| customMeridiem?: (hours: number, minutes: number, isLowercase?: boolean, hasPeriod?: boolean) => string; | ||
| } | ||
| declare function formatDate(date: Date, formatStr: string, options?: UseDateFormatOptions): string; | ||
| declare function normalizeDate(date: DateLike): Date; | ||
| type UseDateFormatReturn = ComputedRef<string>; | ||
| /** | ||
| * Get the formatted date according to the string of tokens passed in. | ||
| * | ||
| * @see https://vueuse.org/useDateFormat | ||
| * @param date - The date to format, can either be a `Date` object, a timestamp, or a string | ||
| * @param formatStr - The combination of tokens to format the date | ||
| * @param options - UseDateFormatOptions | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useDateFormat(date: MaybeRefOrGetter$1<DateLike>, formatStr?: MaybeRefOrGetter$1<string>, options?: UseDateFormatOptions): UseDateFormatReturn; | ||
| //#endregion | ||
| //#region useDebounceFn/index.d.ts | ||
| type UseDebounceFnReturn<T extends FunctionArgs> = PromisifyFn<T>; | ||
| /** | ||
| * Debounce execution of a function. | ||
| * | ||
| * @see https://vueuse.org/useDebounceFn | ||
| * @param fn A function to be executed after delay milliseconds debounced. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param options Options | ||
| * | ||
| * @return A new, debounce, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter$1<number>, options?: DebounceFilterOptions): UseDebounceFnReturn<T>; | ||
| //#endregion | ||
| //#region useInterval/index.d.ts | ||
| interface UseIntervalOptions<Controls extends boolean> { | ||
| /** | ||
| * Expose more controls | ||
| * | ||
| * @default false | ||
| */ | ||
| controls?: Controls; | ||
| /** | ||
| * Execute the update immediately on calling | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Callback on every interval | ||
| */ | ||
| callback?: (count: number) => void; | ||
| } | ||
| interface UseIntervalControls { | ||
| counter: ShallowRef<number>; | ||
| reset: () => void; | ||
| } | ||
| type UseIntervalReturn = Readonly<ShallowRef<number>> | Readonly<UseIntervalControls & Pausable>; | ||
| /** | ||
| * Reactive counter increases on every interval | ||
| * | ||
| * @see https://vueuse.org/useInterval | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useInterval(interval?: MaybeRefOrGetter$1<number>, options?: UseIntervalOptions<false>): Readonly<ShallowRef<number>>; | ||
| declare function useInterval(interval: MaybeRefOrGetter$1<number>, options: UseIntervalOptions<true>): Readonly<UseIntervalControls & Pausable>; | ||
| //#endregion | ||
| //#region useIntervalFn/index.d.ts | ||
| interface UseIntervalFnOptions { | ||
| /** | ||
| * Start the timer immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Execute the callback immediately after calling `resume` | ||
| * | ||
| * @default false | ||
| */ | ||
| immediateCallback?: boolean; | ||
| } | ||
| type UseIntervalFnReturn = Pausable; | ||
| /** | ||
| * Wrapper for `setInterval` with controls | ||
| * | ||
| * @see https://vueuse.org/useIntervalFn | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useIntervalFn(cb: Fn$1, interval?: MaybeRefOrGetter$1<number>, options?: UseIntervalFnOptions): UseIntervalFnReturn; | ||
| //#endregion | ||
| //#region useLastChanged/index.d.ts | ||
| interface UseLastChangedOptions<Immediate extends boolean, InitialValue extends number | null | undefined = undefined> extends WatchOptions<Immediate> { | ||
| initialValue?: InitialValue; | ||
| } | ||
| type UseLastChangedReturn = Readonly<ShallowRef<number | null>> | Readonly<ShallowRef<number>>; | ||
| /** | ||
| * Records the timestamp of the last change | ||
| * | ||
| * @see https://vueuse.org/useLastChanged | ||
| */ | ||
| declare function useLastChanged(source: WatchSource, options?: UseLastChangedOptions<false>): Readonly<ShallowRef<number | null>>; | ||
| declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true> | UseLastChangedOptions<boolean, number>): Readonly<ShallowRef<number>>; | ||
| //#endregion | ||
| //#region useThrottleFn/index.d.ts | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is, | ||
| * to `callback` when the throttled-function is executed. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * (default value: 200) | ||
| * | ||
| * @param [trailing] if true, call fn again after the time is up (default value: false) | ||
| * | ||
| * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true) | ||
| * | ||
| * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false) | ||
| * | ||
| * @return A new, throttled, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useThrottleFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter$1<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): PromisifyFn<T>; | ||
| //#endregion | ||
| //#region useTimeoutFn/index.d.ts | ||
| interface UseTimeoutFnOptions { | ||
| /** | ||
| * Start the timer immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Execute the callback immediately after calling `start` | ||
| * | ||
| * @default false | ||
| */ | ||
| immediateCallback?: boolean; | ||
| } | ||
| type UseTimeoutFnReturn<CallbackFn extends AnyFn> = Stoppable<Parameters<CallbackFn> | []>; | ||
| /** | ||
| * Wrapper for `setTimeout` with controls. | ||
| * | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useTimeoutFn<CallbackFn extends AnyFn>(cb: CallbackFn, interval: MaybeRefOrGetter$1<number>, options?: UseTimeoutFnOptions): UseTimeoutFnReturn<CallbackFn>; | ||
| //#endregion | ||
| //#region useTimeout/index.d.ts | ||
| interface UseTimeoutOptions<Controls extends boolean> extends UseTimeoutFnOptions { | ||
| /** | ||
| * Expose more controls | ||
| * | ||
| * @default false | ||
| */ | ||
| controls?: Controls; | ||
| /** | ||
| * Callback on timeout | ||
| */ | ||
| callback?: Fn$1; | ||
| } | ||
| type UseTimoutReturn = ComputedRef<boolean> | { | ||
| readonly ready: ComputedRef<boolean>; | ||
| } & Stoppable; | ||
| /** | ||
| * Update value after a given time with controls. | ||
| * | ||
| * @see {@link https://vueuse.org/useTimeout} | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useTimeout(interval?: MaybeRefOrGetter$1<number>, options?: UseTimeoutOptions<false>): ComputedRef<boolean>; | ||
| declare function useTimeout(interval: MaybeRefOrGetter$1<number>, options: UseTimeoutOptions<true>): { | ||
| ready: ComputedRef<boolean>; | ||
| } & Stoppable; | ||
| //#endregion | ||
| //#region useToNumber/index.d.ts | ||
| interface UseToNumberOptions { | ||
| /** | ||
| * Method to use to convert the value to a number. | ||
| * | ||
| * Or a custom function for the conversion. | ||
| * | ||
| * @default 'parseFloat' | ||
| */ | ||
| method?: 'parseFloat' | 'parseInt' | ((value: string | number) => number); | ||
| /** | ||
| * The base in mathematical numeral systems passed to `parseInt`. | ||
| * Only works with `method: 'parseInt'` | ||
| */ | ||
| radix?: number; | ||
| /** | ||
| * Replace NaN with zero | ||
| * | ||
| * @default false | ||
| */ | ||
| nanToZero?: boolean; | ||
| } | ||
| /** | ||
| * Reactively convert a string ref to number. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useToNumber(value: MaybeRefOrGetter$1<number | string>, options?: UseToNumberOptions): ComputedRef<number>; | ||
| //#endregion | ||
| //#region useToString/index.d.ts | ||
| /** | ||
| * Reactively convert a ref to string. | ||
| * | ||
| * @see https://vueuse.org/useToString | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useToString(value: MaybeRefOrGetter$1<unknown>): ComputedRef<string>; | ||
| //#endregion | ||
| //#region useToggle/index.d.ts | ||
| type ToggleFn = (value?: boolean) => void; | ||
| type UseToggleReturn = [ShallowRef<boolean>, ToggleFn] | ToggleFn; | ||
| interface UseToggleOptions<Truthy, Falsy> { | ||
| truthyValue?: MaybeRefOrGetter$1<Truthy>; | ||
| falsyValue?: MaybeRefOrGetter$1<Falsy>; | ||
| } | ||
| declare function useToggle<Truthy, Falsy, T = Truthy | Falsy>(initialValue: Ref<T>, options?: UseToggleOptions<Truthy, Falsy>): (value?: T) => T; | ||
| declare function useToggle<Truthy = true, Falsy = false, T = Truthy | Falsy>(initialValue?: T, options?: UseToggleOptions<Truthy, Falsy>): [ShallowRef<T>, (value?: T) => T]; | ||
| //#endregion | ||
| //#region watchArray/index.d.ts | ||
| declare type WatchArrayCallback<V = any, OV = any> = (value: V, oldValue: OV, added: V, removed: OV, onCleanup: (cleanupFn: () => void) => void) => any; | ||
| /** | ||
| * Watch for an array with additions and removals. | ||
| * | ||
| * @see https://vueuse.org/watchArray | ||
| */ | ||
| declare function watchArray<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T[]> | T[], cb: WatchArrayCallback<T[], Immediate extends true ? T[] | undefined : T[]>, options?: WatchOptions<Immediate>): vue0.WatchHandle; | ||
| //#endregion | ||
| //#region watchWithFilter/index.d.ts | ||
| interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {} | ||
| declare function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle; | ||
| declare function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle; | ||
| declare function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle; | ||
| //#endregion | ||
| //#region watchAtMost/index.d.ts | ||
| interface WatchAtMostOptions<Immediate> extends WatchWithFilterOptions<Immediate> { | ||
| count: MaybeRefOrGetter$1<number>; | ||
| } | ||
| interface WatchAtMostReturn { | ||
| stop: WatchStopHandle; | ||
| count: ShallowRef<number>; | ||
| } | ||
| declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn; | ||
| declare function watchAtMost<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn; | ||
| //#endregion | ||
| //#region watchDebounced/index.d.ts | ||
| interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate>, DebounceFilterOptions { | ||
| debounce?: MaybeRefOrGetter$1<number>; | ||
| } | ||
| declare function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle; | ||
| declare function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle; | ||
| declare function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle; | ||
| //#endregion | ||
| //#region watchDeep/index.d.ts | ||
| declare function watchDeep<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle; | ||
| declare function watchDeep<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle; | ||
| declare function watchDeep<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle; | ||
| //#endregion | ||
| //#region watchIgnorable/index.d.ts | ||
| type IgnoredUpdater = (updater: () => void) => void; | ||
| type IgnoredPrevAsyncUpdates = () => void; | ||
| interface WatchIgnorableReturn { | ||
| ignoreUpdates: IgnoredUpdater; | ||
| ignorePrevAsyncUpdates: IgnoredPrevAsyncUpdates; | ||
| stop: WatchStopHandle; | ||
| } | ||
| declare function watchIgnorable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn; | ||
| declare function watchIgnorable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn; | ||
| declare function watchIgnorable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn; | ||
| //#endregion | ||
| //#region watchImmediate/index.d.ts | ||
| declare function watchImmediate<T extends Readonly<WatchSource<unknown>[]>>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle; | ||
| declare function watchImmediate<T>(source: WatchSource<T>, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle; | ||
| declare function watchImmediate<T extends object>(source: T, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle; | ||
| //#endregion | ||
| //#region watchOnce/index.d.ts | ||
| declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>, options?: Omit<WatchOptions<true>, 'once'>): WatchStopHandle; | ||
| declare function watchOnce<T>(source: WatchSource<T>, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'once'>): WatchStopHandle; | ||
| declare function watchOnce<T extends object>(source: T, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'once'>): WatchStopHandle; | ||
| //#endregion | ||
| //#region watchPausable/index.d.ts | ||
| interface WatchPausableReturn extends Pausable { | ||
| stop: WatchStopHandle; | ||
| } | ||
| type WatchPausableOptions<Immediate> = WatchWithFilterOptions<Immediate> & PausableFilterOptions; | ||
| declare function watchPausable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn; | ||
| declare function watchPausable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn; | ||
| declare function watchPausable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn; | ||
| //#endregion | ||
| //#region watchThrottled/index.d.ts | ||
| interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate> { | ||
| throttle?: MaybeRefOrGetter$1<number>; | ||
| trailing?: boolean; | ||
| leading?: boolean; | ||
| } | ||
| declare function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle; | ||
| declare function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle; | ||
| declare function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle; | ||
| //#endregion | ||
| //#region watchTriggerable/index.d.ts | ||
| interface WatchTriggerableReturn<FnReturnT = void> extends WatchIgnorableReturn { | ||
| /** Execute `WatchCallback` immediately */ | ||
| trigger: () => FnReturnT; | ||
| } | ||
| type OnCleanup = (cleanupFn: () => void) => void; | ||
| type WatchTriggerableCallback<V = any, OV = any, R = void> = (value: V, oldValue: OV, onCleanup: OnCleanup) => R; | ||
| declare function watchTriggerable<T extends Readonly<WatchSource<unknown>[]>, FnReturnT>(sources: [...T], cb: WatchTriggerableCallback<MapSources<T>, MapOldSources<T, true>, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>; | ||
| declare function watchTriggerable<T, FnReturnT>(source: WatchSource<T>, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>; | ||
| declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>; | ||
| //#endregion | ||
| //#region whenever/index.d.ts | ||
| interface WheneverOptions extends WatchOptions { | ||
| /** | ||
| * Only trigger once when the condition is met | ||
| * | ||
| * Override the `once` option in `WatchOptions` | ||
| * | ||
| * @default false | ||
| */ | ||
| once?: boolean; | ||
| } | ||
| /** | ||
| * Shorthand for watching value to be truthy | ||
| * | ||
| * @see https://vueuse.org/whenever | ||
| */ | ||
| declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WheneverOptions): vue0.WatchHandle; | ||
| //#endregion | ||
| export { AnyFn, ArgumentsType, Arrayable, Awaitable, Awaited, ComputedEagerOptions, ComputedEagerReturn, ComputedRefWithControl, ComputedWithControlRef, ComputedWithControlRefExtra, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, CreateInjectionStateOptions, CreateRefReturn, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookReturn, EventHookTrigger, ExtendRefOptions, ExtendRefReturn, Fn$1 as Fn, FunctionArgs, FunctionWrapperOptions, IfAny, IgnoredPrevAsyncUpdates, IgnoredUpdater, IsAny, IsDefinedReturn, MapOldSources, MapSources, type MaybeRef, type MaybeRefOrGetter, MultiWatchSources, Mutable, Pausable, PausableFilterOptions, Promisify, PromisifyFn, ProvideLocalReturn, Reactified, ReactifyNested, ReactifyObjectOptions, ReactifyObjectReturn, ReactifyOptions, ReactifyReturn, ReactiveComputedReturn, ReactiveOmitPredicate, ReactiveOmitReturn, ReactivePickPredicate, ReactivePickReturn, ReadonlyRefOrGetter, RefAutoResetReturn, RefDebouncedReturn, RefThrottledReturn, RemovableRef, ShallowOrDeepRef, ShallowUnwrapRef, SharedComposableReturn, SingletonPromiseReturn, Stoppable, SyncRefOptions, SyncRefsOptions, ThrottleFilterOptions, TimerHandle, ToRefsOptions, ToggleFn, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseArrayDifferenceOptions, UseArrayDifferenceReturn, UseArrayEveryReturn, UseArrayFilterReturn, UseArrayFindIndexReturn, UseArrayFindLastReturn, UseArrayFindReturn, UseArrayIncludesComparatorFn, UseArrayIncludesOptions, UseArrayIncludesReturn, UseArrayJoinReturn, UseArrayMapReturn, UseArrayReducer, UseArraySomeReturn, UseArrayUniqueReturn, UseCounterOptions, UseCounterReturn, UseDateFormatOptions, UseDateFormatReturn, UseDebounceFnReturn, UseIntervalControls, UseIntervalFnOptions, UseIntervalFnReturn, UseIntervalOptions, UseIntervalReturn, UseLastChangedOptions, UseLastChangedReturn, UseTimeoutFnOptions, UseTimeoutFnReturn, UseTimeoutOptions, UseTimoutReturn, UseToNumberOptions, UseToggleOptions, UseToggleReturn, WatchArrayCallback, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableOptions, WatchPausableReturn, WatchThrottledOptions, WatchTriggerableCallback, WatchTriggerableReturn, WatchWithFilterOptions, WheneverOptions, WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, refAutoReset, bypassFilter, camelize, clamp, computedEager, computedEager as eagerComputed, computedWithControl, computedWithControl as controlledComputed, containsProp, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, reactify, createRef, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, refDebounced, refDebounced as useDebounce, watchDebounced as debouncedWatch, watchDebounced, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, watchIgnorable, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, watchPausable, promiseTimeout, provideLocal, pxValue, rand, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refDefault, refThrottled, refThrottled as throttledRef, refThrottled as useThrottle, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, watchThrottled as throttledWatch, watchThrottled, timestamp, toArray, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDeep, watchImmediate, watchOnce, watchTriggerable, watchWithFilter, whenever }; |
+2185
| (function(exports, vue) { | ||
| //#region rolldown:runtime | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| //#endregion | ||
| vue = __toESM(vue); | ||
| //#region computedEager/index.ts | ||
| /** | ||
| * Note: If you are using Vue 3.4+, you can straight use computed instead. | ||
| * Because in Vue 3.4+, if computed new value does not change, | ||
| * computed, effect, watch, watchEffect, render dependencies will not be triggered. | ||
| * refer: https://github.com/vuejs/core/pull/5912 | ||
| * | ||
| * @param fn effect function | ||
| * @param options WatchOptionsBase | ||
| * @returns readonly shallowRef | ||
| */ | ||
| function computedEager(fn, options) { | ||
| var _options$flush; | ||
| const result = (0, vue.shallowRef)(); | ||
| (0, vue.watchEffect)(() => { | ||
| result.value = fn(); | ||
| }, { | ||
| ...options, | ||
| flush: (_options$flush = options === null || options === void 0 ? void 0 : options.flush) !== null && _options$flush !== void 0 ? _options$flush : "sync" | ||
| }); | ||
| return (0, vue.readonly)(result); | ||
| } | ||
| //#endregion | ||
| //#region computedWithControl/index.ts | ||
| /** | ||
| * Explicitly define the deps of computed. | ||
| * | ||
| * @param source | ||
| * @param fn | ||
| */ | ||
| function computedWithControl(source, fn, options = {}) { | ||
| let v = void 0; | ||
| let track; | ||
| let trigger; | ||
| let dirty = true; | ||
| const update = () => { | ||
| dirty = true; | ||
| trigger(); | ||
| }; | ||
| (0, vue.watch)(source, update, { | ||
| flush: "sync", | ||
| ...options | ||
| }); | ||
| const get$1 = typeof fn === "function" ? fn : fn.get; | ||
| const set$1 = typeof fn === "function" ? void 0 : fn.set; | ||
| const result = (0, vue.customRef)((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| if (dirty) { | ||
| v = get$1(v); | ||
| dirty = false; | ||
| } | ||
| track(); | ||
| return v; | ||
| }, | ||
| set(v$1) { | ||
| set$1 === null || set$1 === void 0 || set$1(v$1); | ||
| } | ||
| }; | ||
| }); | ||
| result.trigger = update; | ||
| return result; | ||
| } | ||
| //#endregion | ||
| //#region tryOnScopeDispose/index.ts | ||
| /** | ||
| * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| */ | ||
| function tryOnScopeDispose(fn) { | ||
| if ((0, vue.getCurrentScope)()) { | ||
| (0, vue.onScopeDispose)(fn); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| //#endregion | ||
| //#region createEventHook/index.ts | ||
| /** | ||
| * Utility for creating event hooks | ||
| * | ||
| * @see https://vueuse.org/createEventHook | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createEventHook() { | ||
| const fns = /* @__PURE__ */ new Set(); | ||
| const off = (fn) => { | ||
| fns.delete(fn); | ||
| }; | ||
| const clear = () => { | ||
| fns.clear(); | ||
| }; | ||
| const on = (fn) => { | ||
| fns.add(fn); | ||
| const offFn = () => off(fn); | ||
| tryOnScopeDispose(offFn); | ||
| return { off: offFn }; | ||
| }; | ||
| const trigger = (...args) => { | ||
| return Promise.all(Array.from(fns).map((fn) => fn(...args))); | ||
| }; | ||
| return { | ||
| on, | ||
| off, | ||
| trigger, | ||
| clear | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region createGlobalState/index.ts | ||
| /** | ||
| * Keep states in the global scope to be reusable across Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createGlobalState | ||
| * @param stateFactory A factory function to create the state | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createGlobalState(stateFactory) { | ||
| let initialized = false; | ||
| let state; | ||
| const scope = (0, vue.effectScope)(true); | ||
| return ((...args) => { | ||
| if (!initialized) { | ||
| state = scope.run(() => stateFactory(...args)); | ||
| initialized = true; | ||
| } | ||
| return state; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region provideLocal/map.ts | ||
| const localProvidedStateMap = /* @__PURE__ */ new WeakMap(); | ||
| //#endregion | ||
| //#region injectLocal/index.ts | ||
| /** | ||
| * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * injectLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| const injectLocal = (...args) => { | ||
| var _getCurrentInstance; | ||
| const key = args[0]; | ||
| const instance = (_getCurrentInstance = (0, vue.getCurrentInstance)()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy; | ||
| if (instance == null && !(0, vue.hasInjectionContext)()) throw new Error("injectLocal must be called in setup"); | ||
| if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance)) return localProvidedStateMap.get(instance)[key]; | ||
| return (0, vue.inject)(...args); | ||
| }; | ||
| //#endregion | ||
| //#region provideLocal/index.ts | ||
| /** | ||
| * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * provideLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| */ | ||
| function provideLocal(key, value) { | ||
| var _getCurrentInstance; | ||
| const instance = (_getCurrentInstance = (0, vue.getCurrentInstance)()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy; | ||
| if (instance == null) throw new Error("provideLocal must be called in setup"); | ||
| if (!localProvidedStateMap.has(instance)) localProvidedStateMap.set(instance, Object.create(null)); | ||
| const localProvidedState = localProvidedStateMap.get(instance); | ||
| localProvidedState[key] = value; | ||
| return (0, vue.provide)(key, value); | ||
| } | ||
| //#endregion | ||
| //#region createInjectionState/index.ts | ||
| /** | ||
| * Create global state that can be injected into components. | ||
| * | ||
| * @see https://vueuse.org/createInjectionState | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createInjectionState(composable, options) { | ||
| const key = (options === null || options === void 0 ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState"); | ||
| const defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue; | ||
| const useProvidingState = (...args) => { | ||
| const state = composable(...args); | ||
| provideLocal(key, state); | ||
| return state; | ||
| }; | ||
| const useInjectedState = () => injectLocal(key, defaultValue); | ||
| return [useProvidingState, useInjectedState]; | ||
| } | ||
| //#endregion | ||
| //#region createRef/index.ts | ||
| /** | ||
| * Returns a `deepRef` or `shallowRef` depending on the `deep` param. | ||
| * | ||
| * @example createRef(1) // ShallowRef<number> | ||
| * @example createRef(1, false) // ShallowRef<number> | ||
| * @example createRef(1, true) // Ref<number> | ||
| * @example createRef("string") // ShallowRef<string> | ||
| * @example createRef<"A"|"B">("A", true) // Ref<"A"|"B"> | ||
| * | ||
| * @param value | ||
| * @param deep | ||
| * @returns the `deepRef` or `shallowRef` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createRef(value, deep) { | ||
| if (deep === true) return (0, vue.ref)(value); | ||
| else return (0, vue.shallowRef)(value); | ||
| } | ||
| //#endregion | ||
| //#region createSharedComposable/index.ts | ||
| /** | ||
| * Make a composable function usable with multiple Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createSharedComposable | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createSharedComposable(composable) { | ||
| let subscribers = 0; | ||
| let state; | ||
| let scope; | ||
| const dispose = () => { | ||
| subscribers -= 1; | ||
| if (scope && subscribers <= 0) { | ||
| scope.stop(); | ||
| state = void 0; | ||
| scope = void 0; | ||
| } | ||
| }; | ||
| return ((...args) => { | ||
| subscribers += 1; | ||
| if (!scope) { | ||
| scope = (0, vue.effectScope)(true); | ||
| state = scope.run(() => composable(...args)); | ||
| } | ||
| tryOnScopeDispose(dispose); | ||
| return state; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region extendRef/index.ts | ||
| function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) { | ||
| for (const [key, value] of Object.entries(extend)) { | ||
| if (key === "value") continue; | ||
| if ((0, vue.isRef)(value) && unwrap) Object.defineProperty(ref, key, { | ||
| get() { | ||
| return value.value; | ||
| }, | ||
| set(v) { | ||
| value.value = v; | ||
| }, | ||
| enumerable | ||
| }); | ||
| else Object.defineProperty(ref, key, { | ||
| value, | ||
| enumerable | ||
| }); | ||
| } | ||
| return ref; | ||
| } | ||
| //#endregion | ||
| //#region get/index.ts | ||
| function get(obj, key) { | ||
| if (key == null) return (0, vue.unref)(obj); | ||
| return (0, vue.unref)(obj)[key]; | ||
| } | ||
| //#endregion | ||
| //#region isDefined/index.ts | ||
| function isDefined(v) { | ||
| return (0, vue.unref)(v) != null; | ||
| } | ||
| //#endregion | ||
| //#region makeDestructurable/index.ts | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function makeDestructurable(obj, arr) { | ||
| if (typeof Symbol !== "undefined") { | ||
| const clone = { ...obj }; | ||
| Object.defineProperty(clone, Symbol.iterator, { | ||
| enumerable: false, | ||
| value() { | ||
| let index = 0; | ||
| return { next: () => ({ | ||
| value: arr[index++], | ||
| done: index > arr.length | ||
| }) }; | ||
| } | ||
| }); | ||
| return clone; | ||
| } else return Object.assign([...arr], obj); | ||
| } | ||
| //#endregion | ||
| //#region reactify/index.ts | ||
| /** | ||
| * Converts plain function into a reactive function. | ||
| * The converted function accepts refs as it's arguments | ||
| * and returns a ComputedRef, with proper typing. | ||
| * | ||
| * @param fn - Source function | ||
| * @param options - Options | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function reactify(fn, options) { | ||
| const unrefFn = (options === null || options === void 0 ? void 0 : options.computedGetter) === false ? vue.unref : vue.toValue; | ||
| return function(...args) { | ||
| return (0, vue.computed)(() => fn.apply(this, args.map((i) => unrefFn(i)))); | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region reactifyObject/index.ts | ||
| /** | ||
| * Apply `reactify` to an object | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function reactifyObject(obj, optionsOrKeys = {}) { | ||
| let keys = []; | ||
| let options; | ||
| if (Array.isArray(optionsOrKeys)) keys = optionsOrKeys; | ||
| else { | ||
| options = optionsOrKeys; | ||
| const { includeOwnProperties = true } = optionsOrKeys; | ||
| keys.push(...Object.keys(obj)); | ||
| if (includeOwnProperties) keys.push(...Object.getOwnPropertyNames(obj)); | ||
| } | ||
| return Object.fromEntries(keys.map((key) => { | ||
| const value = obj[key]; | ||
| return [key, typeof value === "function" ? reactify(value.bind(obj), options) : value]; | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region toReactive/index.ts | ||
| /** | ||
| * Converts ref to reactive. | ||
| * | ||
| * @see https://vueuse.org/toReactive | ||
| * @param objectRef A ref of object | ||
| */ | ||
| function toReactive(objectRef) { | ||
| if (!(0, vue.isRef)(objectRef)) return (0, vue.reactive)(objectRef); | ||
| const proxy = new Proxy({}, { | ||
| get(_, p, receiver) { | ||
| return (0, vue.unref)(Reflect.get(objectRef.value, p, receiver)); | ||
| }, | ||
| set(_, p, value) { | ||
| if ((0, vue.isRef)(objectRef.value[p]) && !(0, vue.isRef)(value)) objectRef.value[p].value = value; | ||
| else objectRef.value[p] = value; | ||
| return true; | ||
| }, | ||
| deleteProperty(_, p) { | ||
| return Reflect.deleteProperty(objectRef.value, p); | ||
| }, | ||
| has(_, p) { | ||
| return Reflect.has(objectRef.value, p); | ||
| }, | ||
| ownKeys() { | ||
| return Object.keys(objectRef.value); | ||
| }, | ||
| getOwnPropertyDescriptor() { | ||
| return { | ||
| enumerable: true, | ||
| configurable: true | ||
| }; | ||
| } | ||
| }); | ||
| return (0, vue.reactive)(proxy); | ||
| } | ||
| //#endregion | ||
| //#region reactiveComputed/index.ts | ||
| /** | ||
| * Computed reactive object. | ||
| */ | ||
| function reactiveComputed(fn) { | ||
| return toReactive((0, vue.computed)(fn)); | ||
| } | ||
| //#endregion | ||
| //#region reactiveOmit/index.ts | ||
| /** | ||
| * Reactively omit fields from a reactive object | ||
| * | ||
| * @see https://vueuse.org/reactiveOmit | ||
| */ | ||
| function reactiveOmit(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter(([k, v]) => !predicate((0, vue.toValue)(v), k))) : Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter((e) => !flatKeys.includes(e[0])))); | ||
| } | ||
| //#endregion | ||
| //#region utils/is.ts | ||
| const isClient = typeof window !== "undefined" && typeof document !== "undefined"; | ||
| const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; | ||
| const isDef = (val) => typeof val !== "undefined"; | ||
| const notNullish = (val) => val != null; | ||
| const assert = (condition, ...infos) => { | ||
| if (!condition) console.warn(...infos); | ||
| }; | ||
| const toString = Object.prototype.toString; | ||
| const isObject = (val) => toString.call(val) === "[object Object]"; | ||
| const now = () => Date.now(); | ||
| const timestamp = () => +Date.now(); | ||
| const clamp = (n, min, max) => Math.min(max, Math.max(min, n)); | ||
| const noop = () => {}; | ||
| const rand = (min, max) => { | ||
| min = Math.ceil(min); | ||
| max = Math.floor(max); | ||
| return Math.floor(Math.random() * (max - min + 1)) + min; | ||
| }; | ||
| const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key); | ||
| const isIOS = /* @__PURE__ */ getIsIOS(); | ||
| function getIsIOS() { | ||
| var _window, _window2, _window3; | ||
| return isClient && ((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent)); | ||
| } | ||
| //#endregion | ||
| //#region toRef/index.ts | ||
| function toRef(...args) { | ||
| if (args.length !== 1) return (0, vue.toRef)(...args); | ||
| const r = args[0]; | ||
| return typeof r === "function" ? (0, vue.readonly)((0, vue.customRef)(() => ({ | ||
| get: r, | ||
| set: noop | ||
| }))) : (0, vue.ref)(r); | ||
| } | ||
| /** | ||
| * @deprecated use `toRef` instead | ||
| */ | ||
| const resolveRef = toRef; | ||
| //#endregion | ||
| //#region reactivePick/index.ts | ||
| /** | ||
| * Reactively pick fields from a reactive object | ||
| * | ||
| * @see https://vueuse.org/reactivePick | ||
| */ | ||
| function reactivePick(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter(([k, v]) => predicate((0, vue.toValue)(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)]))); | ||
| } | ||
| //#endregion | ||
| //#region refAutoReset/index.ts | ||
| /** | ||
| * Create a ref which will be reset to the default value after some time. | ||
| * | ||
| * @see https://vueuse.org/refAutoReset | ||
| * @param defaultValue The value which will be set. | ||
| * @param afterMs A zero-or-greater delay in milliseconds. | ||
| */ | ||
| function refAutoReset(defaultValue, afterMs = 1e4) { | ||
| return (0, vue.customRef)((track, trigger) => { | ||
| let value = (0, vue.toValue)(defaultValue); | ||
| let timer; | ||
| const resetAfter = () => setTimeout(() => { | ||
| value = (0, vue.toValue)(defaultValue); | ||
| trigger(); | ||
| }, (0, vue.toValue)(afterMs)); | ||
| tryOnScopeDispose(() => { | ||
| clearTimeout(timer); | ||
| }); | ||
| return { | ||
| get() { | ||
| track(); | ||
| return value; | ||
| }, | ||
| set(newValue) { | ||
| value = newValue; | ||
| trigger(); | ||
| clearTimeout(timer); | ||
| timer = resetAfter(); | ||
| } | ||
| }; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region utils/filters.ts | ||
| /** | ||
| * @internal | ||
| */ | ||
| function createFilterWrapper(filter, fn) { | ||
| function wrapper(...args) { | ||
| return new Promise((resolve, reject) => { | ||
| Promise.resolve(filter(() => fn.apply(this, args), { | ||
| fn, | ||
| thisArg: this, | ||
| args | ||
| })).then(resolve).catch(reject); | ||
| }); | ||
| } | ||
| return wrapper; | ||
| } | ||
| const bypassFilter = (invoke$1) => { | ||
| return invoke$1(); | ||
| }; | ||
| /** | ||
| * Create an EventFilter that debounce the events | ||
| */ | ||
| function debounceFilter(ms, options = {}) { | ||
| let timer; | ||
| let maxTimer; | ||
| let lastRejector = noop; | ||
| const _clearTimeout = (timer$1) => { | ||
| clearTimeout(timer$1); | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| }; | ||
| let lastInvoker; | ||
| const filter = (invoke$1) => { | ||
| const duration = (0, vue.toValue)(ms); | ||
| const maxDuration = (0, vue.toValue)(options.maxWait); | ||
| if (timer) _clearTimeout(timer); | ||
| if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) { | ||
| if (maxTimer) { | ||
| _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| } | ||
| return Promise.resolve(invoke$1()); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| lastRejector = options.rejectOnCancel ? reject : resolve; | ||
| lastInvoker = invoke$1; | ||
| if (maxDuration && !maxTimer) maxTimer = setTimeout(() => { | ||
| if (timer) _clearTimeout(timer); | ||
| maxTimer = void 0; | ||
| resolve(lastInvoker()); | ||
| }, maxDuration); | ||
| timer = setTimeout(() => { | ||
| if (maxTimer) _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| resolve(invoke$1()); | ||
| }, duration); | ||
| }); | ||
| }; | ||
| return filter; | ||
| } | ||
| function throttleFilter(...args) { | ||
| let lastExec = 0; | ||
| let timer; | ||
| let isLeading = true; | ||
| let lastRejector = noop; | ||
| let lastValue; | ||
| let ms; | ||
| let trailing; | ||
| let leading; | ||
| let rejectOnCancel; | ||
| if (!(0, vue.isRef)(args[0]) && typeof args[0] === "object") ({delay: ms, trailing = true, leading = true, rejectOnCancel = false} = args[0]); | ||
| else [ms, trailing = true, leading = true, rejectOnCancel = false] = args; | ||
| const clear = () => { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| } | ||
| }; | ||
| const filter = (_invoke) => { | ||
| const duration = (0, vue.toValue)(ms); | ||
| const elapsed = Date.now() - lastExec; | ||
| const invoke$1 = () => { | ||
| return lastValue = _invoke(); | ||
| }; | ||
| clear(); | ||
| if (duration <= 0) { | ||
| lastExec = Date.now(); | ||
| return invoke$1(); | ||
| } | ||
| if (elapsed > duration) { | ||
| lastExec = Date.now(); | ||
| if (leading || !isLeading) invoke$1(); | ||
| } else if (trailing) lastValue = new Promise((resolve, reject) => { | ||
| lastRejector = rejectOnCancel ? reject : resolve; | ||
| timer = setTimeout(() => { | ||
| lastExec = Date.now(); | ||
| isLeading = true; | ||
| resolve(invoke$1()); | ||
| clear(); | ||
| }, Math.max(0, duration - elapsed)); | ||
| }); | ||
| if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration); | ||
| isLeading = false; | ||
| return lastValue; | ||
| }; | ||
| return filter; | ||
| } | ||
| /** | ||
| * EventFilter that gives extra controls to pause and resume the filter | ||
| * | ||
| * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none | ||
| * @param options Options to configure the filter | ||
| */ | ||
| function pausableFilter(extendFilter = bypassFilter, options = {}) { | ||
| const { initialState = "active" } = options; | ||
| const isActive = toRef(initialState === "active"); | ||
| function pause() { | ||
| isActive.value = false; | ||
| } | ||
| function resume() { | ||
| isActive.value = true; | ||
| } | ||
| const eventFilter = (...args) => { | ||
| if (isActive.value) extendFilter(...args); | ||
| }; | ||
| return { | ||
| isActive: (0, vue.readonly)(isActive), | ||
| pause, | ||
| resume, | ||
| eventFilter | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region utils/general.ts | ||
| function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") { | ||
| return new Promise((resolve, reject) => { | ||
| if (throwOnTimeout) setTimeout(() => reject(reason), ms); | ||
| else setTimeout(resolve, ms); | ||
| }); | ||
| } | ||
| function identity(arg) { | ||
| return arg; | ||
| } | ||
| /** | ||
| * Create singleton promise function | ||
| * | ||
| * @example | ||
| * ``` | ||
| * const promise = createSingletonPromise(async () => { ... }) | ||
| * | ||
| * await promise() | ||
| * await promise() // all of them will be bind to a single promise instance | ||
| * await promise() // and be resolved together | ||
| * ``` | ||
| */ | ||
| function createSingletonPromise(fn) { | ||
| let _promise; | ||
| function wrapper() { | ||
| if (!_promise) _promise = fn(); | ||
| return _promise; | ||
| } | ||
| wrapper.reset = async () => { | ||
| const _prev = _promise; | ||
| _promise = void 0; | ||
| if (_prev) await _prev; | ||
| }; | ||
| return wrapper; | ||
| } | ||
| function invoke(fn) { | ||
| return fn(); | ||
| } | ||
| function containsProp(obj, ...props) { | ||
| return props.some((k) => k in obj); | ||
| } | ||
| function increaseWithUnit(target, delta) { | ||
| var _target$match; | ||
| if (typeof target === "number") return target + delta; | ||
| const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || ""; | ||
| const unit = target.slice(value.length); | ||
| const result = Number.parseFloat(value) + delta; | ||
| if (Number.isNaN(result)) return target; | ||
| return result + unit; | ||
| } | ||
| /** | ||
| * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client | ||
| */ | ||
| function pxValue(px) { | ||
| return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px); | ||
| } | ||
| /** | ||
| * Create a new subset object by giving keys | ||
| */ | ||
| function objectPick(obj, keys, omitUndefined = false) { | ||
| return keys.reduce((n, k) => { | ||
| if (k in obj) { | ||
| if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k]; | ||
| } | ||
| return n; | ||
| }, {}); | ||
| } | ||
| /** | ||
| * Create a new subset object by omit giving keys | ||
| */ | ||
| function objectOmit(obj, keys, omitUndefined = false) { | ||
| return Object.fromEntries(Object.entries(obj).filter(([key, value]) => { | ||
| return (!omitUndefined || value !== void 0) && !keys.includes(key); | ||
| })); | ||
| } | ||
| function objectEntries(obj) { | ||
| return Object.entries(obj); | ||
| } | ||
| function toArray(value) { | ||
| return Array.isArray(value) ? value : [value]; | ||
| } | ||
| //#endregion | ||
| //#region utils/port.ts | ||
| function cacheStringFunction(fn) { | ||
| const cache = Object.create(null); | ||
| return ((str) => { | ||
| const hit = cache[str]; | ||
| return hit || (cache[str] = fn(str)); | ||
| }); | ||
| } | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); | ||
| const camelizeRE = /-(\w)/g; | ||
| const camelize = cacheStringFunction((str) => { | ||
| return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
| }); | ||
| //#endregion | ||
| //#region utils/vue.ts | ||
| function getLifeCycleTarget(target) { | ||
| return target || (0, vue.getCurrentInstance)(); | ||
| } | ||
| //#endregion | ||
| //#region useDebounceFn/index.ts | ||
| /** | ||
| * Debounce execution of a function. | ||
| * | ||
| * @see https://vueuse.org/useDebounceFn | ||
| * @param fn A function to be executed after delay milliseconds debounced. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param options Options | ||
| * | ||
| * @return A new, debounce, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useDebounceFn(fn, ms = 200, options = {}) { | ||
| return createFilterWrapper(debounceFilter(ms, options), fn); | ||
| } | ||
| //#endregion | ||
| //#region refDebounced/index.ts | ||
| /** | ||
| * Debounce updates of a ref. | ||
| * | ||
| * @return A new debounced ref. | ||
| */ | ||
| function refDebounced(value, ms = 200, options = {}) { | ||
| const debounced = (0, vue.ref)((0, vue.toValue)(value)); | ||
| const updater = useDebounceFn(() => { | ||
| debounced.value = value.value; | ||
| }, ms, options); | ||
| (0, vue.watch)(value, () => updater()); | ||
| return (0, vue.shallowReadonly)(debounced); | ||
| } | ||
| //#endregion | ||
| //#region refDefault/index.ts | ||
| /** | ||
| * Apply default value to a ref. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function refDefault(source, defaultValue) { | ||
| return (0, vue.computed)({ | ||
| get() { | ||
| var _source$value; | ||
| return (_source$value = source.value) !== null && _source$value !== void 0 ? _source$value : defaultValue; | ||
| }, | ||
| set(value) { | ||
| source.value = value; | ||
| } | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useThrottleFn/index.ts | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is, | ||
| * to `callback` when the throttled-function is executed. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * (default value: 200) | ||
| * | ||
| * @param [trailing] if true, call fn again after the time is up (default value: false) | ||
| * | ||
| * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true) | ||
| * | ||
| * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false) | ||
| * | ||
| * @return A new, throttled, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) { | ||
| return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn); | ||
| } | ||
| //#endregion | ||
| //#region refThrottled/index.ts | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param value Ref value to be watched with throttle effect | ||
| * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param trailing if true, update the value again after the delay time is up | ||
| * @param leading if true, update the value on the leading edge of the ms timeout | ||
| */ | ||
| function refThrottled(value, delay = 200, trailing = true, leading = true) { | ||
| if (delay <= 0) return value; | ||
| const throttled = (0, vue.ref)((0, vue.toValue)(value)); | ||
| const updater = useThrottleFn(() => { | ||
| throttled.value = value.value; | ||
| }, delay, trailing, leading); | ||
| (0, vue.watch)(value, () => updater()); | ||
| return throttled; | ||
| } | ||
| //#endregion | ||
| //#region refWithControl/index.ts | ||
| /** | ||
| * Fine-grained controls over ref and its reactivity. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function refWithControl(initial, options = {}) { | ||
| let source = initial; | ||
| let track; | ||
| let trigger; | ||
| const ref = (0, vue.customRef)((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| return get$1(); | ||
| }, | ||
| set(v) { | ||
| set$1(v); | ||
| } | ||
| }; | ||
| }); | ||
| function get$1(tracking = true) { | ||
| if (tracking) track(); | ||
| return source; | ||
| } | ||
| function set$1(value, triggering = true) { | ||
| var _options$onBeforeChan, _options$onChanged; | ||
| if (value === source) return; | ||
| const old = source; | ||
| if (((_options$onBeforeChan = options.onBeforeChange) === null || _options$onBeforeChan === void 0 ? void 0 : _options$onBeforeChan.call(options, value, old)) === false) return; | ||
| source = value; | ||
| (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, value, old); | ||
| if (triggering) trigger(); | ||
| } | ||
| /** | ||
| * Get the value without tracked in the reactivity system | ||
| */ | ||
| const untrackedGet = () => get$1(false); | ||
| /** | ||
| * Set the value without triggering the reactivity system | ||
| */ | ||
| const silentSet = (v) => set$1(v, false); | ||
| /** | ||
| * Get the value without tracked in the reactivity system. | ||
| * | ||
| * Alias for `untrackedGet()` | ||
| */ | ||
| const peek = () => get$1(false); | ||
| /** | ||
| * Set the value without triggering the reactivity system | ||
| * | ||
| * Alias for `silentSet(v)` | ||
| */ | ||
| const lay = (v) => set$1(v, false); | ||
| return extendRef(ref, { | ||
| get: get$1, | ||
| set: set$1, | ||
| untrackedGet, | ||
| silentSet, | ||
| peek, | ||
| lay | ||
| }, { enumerable: true }); | ||
| } | ||
| /** | ||
| * Alias for `refWithControl` | ||
| */ | ||
| const controlledRef = refWithControl; | ||
| //#endregion | ||
| //#region set/index.ts | ||
| /** | ||
| * Shorthand for `ref.value = x` | ||
| */ | ||
| function set(...args) { | ||
| if (args.length === 2) { | ||
| const [ref, value] = args; | ||
| ref.value = value; | ||
| } | ||
| if (args.length === 3) { | ||
| const [target, key, value] = args; | ||
| target[key] = value; | ||
| } | ||
| } | ||
| //#endregion | ||
| //#region watchWithFilter/index.ts | ||
| function watchWithFilter(source, cb, options = {}) { | ||
| const { eventFilter = bypassFilter,...watchOptions } = options; | ||
| return (0, vue.watch)(source, createFilterWrapper(eventFilter, cb), watchOptions); | ||
| } | ||
| //#endregion | ||
| //#region watchPausable/index.ts | ||
| function watchPausable(source, cb, options = {}) { | ||
| const { eventFilter: filter, initialState = "active",...watchOptions } = options; | ||
| const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState }); | ||
| const stop = watchWithFilter(source, cb, { | ||
| ...watchOptions, | ||
| eventFilter | ||
| }); | ||
| return { | ||
| stop, | ||
| pause, | ||
| resume, | ||
| isActive | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region syncRef/index.ts | ||
| /** | ||
| * Two-way refs synchronization. | ||
| * From the set theory perspective to restrict the option's type | ||
| * Check in the following order: | ||
| * 1. L = R | ||
| * 2. L ∩ R ≠ ∅ | ||
| * 3. L ⊆ R | ||
| * 4. L ∩ R = ∅ | ||
| */ | ||
| function syncRef(left, right, ...[options]) { | ||
| const { flush = "sync", deep = false, immediate = true, direction = "both", transform = {} } = options || {}; | ||
| const watchers = []; | ||
| const transformLTR = "ltr" in transform && transform.ltr || ((v) => v); | ||
| const transformRTL = "rtl" in transform && transform.rtl || ((v) => v); | ||
| if (direction === "both" || direction === "ltr") watchers.push(watchPausable(left, (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| right.value = transformLTR(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate | ||
| })); | ||
| if (direction === "both" || direction === "rtl") watchers.push(watchPausable(right, (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| left.value = transformRTL(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate | ||
| })); | ||
| const stop = () => { | ||
| watchers.forEach((w) => w.stop()); | ||
| }; | ||
| return stop; | ||
| } | ||
| //#endregion | ||
| //#region syncRefs/index.ts | ||
| /** | ||
| * Keep target ref(s) in sync with the source ref | ||
| * | ||
| * @param source source ref | ||
| * @param targets | ||
| */ | ||
| function syncRefs(source, targets, options = {}) { | ||
| const { flush = "sync", deep = false, immediate = true } = options; | ||
| const targetsArray = toArray(targets); | ||
| return (0, vue.watch)(source, (newValue) => targetsArray.forEach((target) => target.value = newValue), { | ||
| flush, | ||
| deep, | ||
| immediate | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region toRefs/index.ts | ||
| /** | ||
| * Extended `toRefs` that also accepts refs of an object. | ||
| * | ||
| * @see https://vueuse.org/toRefs | ||
| * @param objectRef A ref or normal object or array. | ||
| * @param options Options | ||
| */ | ||
| function toRefs(objectRef, options = {}) { | ||
| if (!(0, vue.isRef)(objectRef)) return (0, vue.toRefs)(objectRef); | ||
| const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {}; | ||
| for (const key in objectRef.value) result[key] = (0, vue.customRef)(() => ({ | ||
| get() { | ||
| return objectRef.value[key]; | ||
| }, | ||
| set(v) { | ||
| var _toValue$1; | ||
| const replaceRef = (_toValue$1 = (0, vue.toValue)(options.replaceRef)) !== null && _toValue$1 !== void 0 ? _toValue$1 : true; | ||
| if (replaceRef) if (Array.isArray(objectRef.value)) { | ||
| const copy = [...objectRef.value]; | ||
| copy[key] = v; | ||
| objectRef.value = copy; | ||
| } else { | ||
| const newObject = { | ||
| ...objectRef.value, | ||
| [key]: v | ||
| }; | ||
| Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value)); | ||
| objectRef.value = newObject; | ||
| } | ||
| else objectRef.value[key] = v; | ||
| } | ||
| })); | ||
| return result; | ||
| } | ||
| //#endregion | ||
| //#region toValue/index.ts | ||
| /** | ||
| * Get the value of value/ref/getter. | ||
| * | ||
| * @deprecated use `toValue` from `vue` instead | ||
| */ | ||
| const toValue = vue.toValue; | ||
| /** | ||
| * @deprecated use `toValue` instead | ||
| */ | ||
| const resolveUnref = vue.toValue; | ||
| //#endregion | ||
| //#region tryOnBeforeMount/index.ts | ||
| /** | ||
| * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| function tryOnBeforeMount(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) (0, vue.onBeforeMount)(fn, target); | ||
| else if (sync) fn(); | ||
| else (0, vue.nextTick)(fn); | ||
| } | ||
| //#endregion | ||
| //#region tryOnBeforeUnmount/index.ts | ||
| /** | ||
| * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| function tryOnBeforeUnmount(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) (0, vue.onBeforeUnmount)(fn, target); | ||
| } | ||
| //#endregion | ||
| //#region tryOnMounted/index.ts | ||
| /** | ||
| * Call onMounted() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| function tryOnMounted(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) (0, vue.onMounted)(fn, target); | ||
| else if (sync) fn(); | ||
| else (0, vue.nextTick)(fn); | ||
| } | ||
| //#endregion | ||
| //#region tryOnUnmounted/index.ts | ||
| /** | ||
| * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| function tryOnUnmounted(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) (0, vue.onUnmounted)(fn, target); | ||
| } | ||
| //#endregion | ||
| //#region until/index.ts | ||
| function createUntil(r, isNot = false) { | ||
| function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) { | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = (0, vue.watch)(r, (v) => { | ||
| if (condition(v) !== isNot) { | ||
| if (stop) stop(); | ||
| else (0, vue.nextTick)(() => stop === null || stop === void 0 ? void 0 : stop()); | ||
| resolve(v); | ||
| } | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| }); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => (0, vue.toValue)(r)).finally(() => stop === null || stop === void 0 ? void 0 : stop())); | ||
| return Promise.race(promises); | ||
| } | ||
| function toBe(value, options) { | ||
| if (!(0, vue.isRef)(value)) return toMatch((v) => v === value, options); | ||
| const { flush = "sync", deep = false, timeout, throwOnTimeout } = options !== null && options !== void 0 ? options : {}; | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = (0, vue.watch)([r, value], ([v1, v2]) => { | ||
| if (isNot !== (v1 === v2)) { | ||
| if (stop) stop(); | ||
| else (0, vue.nextTick)(() => stop === null || stop === void 0 ? void 0 : stop()); | ||
| resolve(v1); | ||
| } | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| }); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => (0, vue.toValue)(r)).finally(() => { | ||
| stop === null || stop === void 0 || stop(); | ||
| return (0, vue.toValue)(r); | ||
| })); | ||
| return Promise.race(promises); | ||
| } | ||
| function toBeTruthy(options) { | ||
| return toMatch((v) => Boolean(v), options); | ||
| } | ||
| function toBeNull(options) { | ||
| return toBe(null, options); | ||
| } | ||
| function toBeUndefined(options) { | ||
| return toBe(void 0, options); | ||
| } | ||
| function toBeNaN(options) { | ||
| return toMatch(Number.isNaN, options); | ||
| } | ||
| function toContains(value, options) { | ||
| return toMatch((v) => { | ||
| const array = Array.from(v); | ||
| return array.includes(value) || array.includes((0, vue.toValue)(value)); | ||
| }, options); | ||
| } | ||
| function changed(options) { | ||
| return changedTimes(1, options); | ||
| } | ||
| function changedTimes(n = 1, options) { | ||
| let count = -1; | ||
| return toMatch(() => { | ||
| count += 1; | ||
| return count >= n; | ||
| }, options); | ||
| } | ||
| if (Array.isArray((0, vue.toValue)(r))) { | ||
| const instance = { | ||
| toMatch, | ||
| toContains, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } else { | ||
| const instance = { | ||
| toMatch, | ||
| toBe, | ||
| toBeTruthy, | ||
| toBeNull, | ||
| toBeNaN, | ||
| toBeUndefined, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } | ||
| } | ||
| function until(r) { | ||
| return createUntil(r); | ||
| } | ||
| //#endregion | ||
| //#region useArrayDifference/index.ts | ||
| function defaultComparator(value, othVal) { | ||
| return value === othVal; | ||
| } | ||
| /** | ||
| * Reactive get array difference of two array | ||
| * @see https://vueuse.org/useArrayDifference | ||
| * @returns - the difference of two array | ||
| * @param args | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayDifference(...args) { | ||
| var _args$, _args$2; | ||
| const list = args[0]; | ||
| const values = args[1]; | ||
| let compareFn = (_args$ = args[2]) !== null && _args$ !== void 0 ? _args$ : defaultComparator; | ||
| const { symmetric = false } = (_args$2 = args[3]) !== null && _args$2 !== void 0 ? _args$2 : {}; | ||
| if (typeof compareFn === "string") { | ||
| const key = compareFn; | ||
| compareFn = (value, othVal) => value[key] === othVal[key]; | ||
| } | ||
| const diff1 = (0, vue.computed)(() => (0, vue.toValue)(list).filter((x) => (0, vue.toValue)(values).findIndex((y) => compareFn(x, y)) === -1)); | ||
| if (symmetric) { | ||
| const diff2 = (0, vue.computed)(() => (0, vue.toValue)(values).filter((x) => (0, vue.toValue)(list).findIndex((y) => compareFn(x, y)) === -1)); | ||
| return (0, vue.computed)(() => symmetric ? [...(0, vue.toValue)(diff1), ...(0, vue.toValue)(diff2)] : (0, vue.toValue)(diff1)); | ||
| } else return diff1; | ||
| } | ||
| //#endregion | ||
| //#region useArrayEvery/index.ts | ||
| /** | ||
| * Reactive `Array.every` | ||
| * | ||
| * @see https://vueuse.org/useArrayEvery | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayEvery(list, fn) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)(list).every((element, index, array) => fn((0, vue.toValue)(element), index, array))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFilter/index.ts | ||
| /** | ||
| * Reactive `Array.filter` | ||
| * | ||
| * @see https://vueuse.org/useArrayFilter | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFilter(list, fn) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).filter(fn)); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFind/index.ts | ||
| /** | ||
| * Reactive `Array.find` | ||
| * | ||
| * @see https://vueuse.org/useArrayFind | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFind(list, fn) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)((0, vue.toValue)(list).find((element, index, array) => fn((0, vue.toValue)(element), index, array)))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFindIndex/index.ts | ||
| /** | ||
| * Reactive `Array.findIndex` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindIndex | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the index of the first element in the array that passes the test. Otherwise, "-1". | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFindIndex(list, fn) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)(list).findIndex((element, index, array) => fn((0, vue.toValue)(element), index, array))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFindLast/index.ts | ||
| function findLast(arr, cb) { | ||
| let index = arr.length; | ||
| while (index-- > 0) if (cb(arr[index], index, arr)) return arr[index]; | ||
| return void 0; | ||
| } | ||
| /** | ||
| * Reactive `Array.findLast` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindLast | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFindLast(list, fn) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)(!Array.prototype.findLast ? findLast((0, vue.toValue)(list), (element, index, array) => fn((0, vue.toValue)(element), index, array)) : (0, vue.toValue)(list).findLast((element, index, array) => fn((0, vue.toValue)(element), index, array)))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayIncludes/index.ts | ||
| function isArrayIncludesOptions(obj) { | ||
| return isObject(obj) && containsProp(obj, "formIndex", "comparator"); | ||
| } | ||
| /** | ||
| * Reactive `Array.includes` | ||
| * | ||
| * @see https://vueuse.org/useArrayIncludes | ||
| * | ||
| * @returns true if the `value` is found in the array. Otherwise, false. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayIncludes(...args) { | ||
| var _comparator; | ||
| const list = args[0]; | ||
| const value = args[1]; | ||
| let comparator = args[2]; | ||
| let formIndex = 0; | ||
| if (isArrayIncludesOptions(comparator)) { | ||
| var _comparator$fromIndex; | ||
| formIndex = (_comparator$fromIndex = comparator.fromIndex) !== null && _comparator$fromIndex !== void 0 ? _comparator$fromIndex : 0; | ||
| comparator = comparator.comparator; | ||
| } | ||
| if (typeof comparator === "string") { | ||
| const key = comparator; | ||
| comparator = (element, value$1) => element[key] === (0, vue.toValue)(value$1); | ||
| } | ||
| comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value$1) => element === (0, vue.toValue)(value$1)); | ||
| return (0, vue.computed)(() => (0, vue.toValue)(list).slice(formIndex).some((element, index, array) => comparator((0, vue.toValue)(element), (0, vue.toValue)(value), index, (0, vue.toValue)(array)))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayJoin/index.ts | ||
| /** | ||
| * Reactive `Array.join` | ||
| * | ||
| * @see https://vueuse.org/useArrayJoin | ||
| * @param list - the array was called upon. | ||
| * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (","). | ||
| * | ||
| * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayJoin(list, separator) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).join((0, vue.toValue)(separator))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayMap/index.ts | ||
| /** | ||
| * Reactive `Array.map` | ||
| * | ||
| * @see https://vueuse.org/useArrayMap | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a new array with each element being the result of the callback function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayMap(list, fn) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).map(fn)); | ||
| } | ||
| //#endregion | ||
| //#region useArrayReduce/index.ts | ||
| /** | ||
| * Reactive `Array.reduce` | ||
| * | ||
| * @see https://vueuse.org/useArrayReduce | ||
| * @param list - the array was called upon. | ||
| * @param reducer - a "reducer" function. | ||
| * @param args | ||
| * | ||
| * @returns the value that results from running the "reducer" callback function to completion over the entire array. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayReduce(list, reducer, ...args) { | ||
| const reduceCallback = (sum, value, index) => reducer((0, vue.toValue)(sum), (0, vue.toValue)(value), index); | ||
| return (0, vue.computed)(() => { | ||
| const resolved = (0, vue.toValue)(list); | ||
| return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? (0, vue.toValue)(args[0]()) : (0, vue.toValue)(args[0])) : resolved.reduce(reduceCallback); | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useArraySome/index.ts | ||
| /** | ||
| * Reactive `Array.some` | ||
| * | ||
| * @see https://vueuse.org/useArraySome | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArraySome(list, fn) { | ||
| return (0, vue.computed)(() => (0, vue.toValue)(list).some((element, index, array) => fn((0, vue.toValue)(element), index, array))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayUnique/index.ts | ||
| function uniq(array) { | ||
| return Array.from(new Set(array)); | ||
| } | ||
| function uniqueElementsBy(array, fn) { | ||
| return array.reduce((acc, v) => { | ||
| if (!acc.some((x) => fn(v, x, array))) acc.push(v); | ||
| return acc; | ||
| }, []); | ||
| } | ||
| /** | ||
| * reactive unique array | ||
| * @see https://vueuse.org/useArrayUnique | ||
| * @param list - the array was called upon. | ||
| * @param compareFn | ||
| * @returns A computed ref that returns a unique array of items. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayUnique(list, compareFn) { | ||
| return (0, vue.computed)(() => { | ||
| const resolvedList = (0, vue.toValue)(list).map((element) => (0, vue.toValue)(element)); | ||
| return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList); | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useCounter/index.ts | ||
| /** | ||
| * Basic counter with utility functions. | ||
| * | ||
| * @see https://vueuse.org/useCounter | ||
| * @param [initialValue] | ||
| * @param options | ||
| */ | ||
| function useCounter(initialValue = 0, options = {}) { | ||
| let _initialValue = (0, vue.unref)(initialValue); | ||
| const count = (0, vue.shallowRef)(initialValue); | ||
| const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options; | ||
| const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min); | ||
| const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max); | ||
| const get$1 = () => count.value; | ||
| const set$1 = (val) => count.value = Math.max(min, Math.min(max, val)); | ||
| const reset = (val = _initialValue) => { | ||
| _initialValue = val; | ||
| return set$1(val); | ||
| }; | ||
| return { | ||
| count: (0, vue.shallowReadonly)(count), | ||
| inc, | ||
| dec, | ||
| get: get$1, | ||
| set: set$1, | ||
| reset | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region useDateFormat/index.ts | ||
| const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i; | ||
| const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g; | ||
| function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) { | ||
| let m = hours < 12 ? "AM" : "PM"; | ||
| if (hasPeriod) m = m.split("").reduce((acc, curr) => acc += `${curr}.`, ""); | ||
| return isLowercase ? m.toLowerCase() : m; | ||
| } | ||
| function formatOrdinal(num) { | ||
| const suffixes = [ | ||
| "th", | ||
| "st", | ||
| "nd", | ||
| "rd" | ||
| ]; | ||
| const v = num % 100; | ||
| return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]); | ||
| } | ||
| function formatDate(date, formatStr, options = {}) { | ||
| var _options$customMeridi; | ||
| const years = date.getFullYear(); | ||
| const month = date.getMonth(); | ||
| const days = date.getDate(); | ||
| const hours = date.getHours(); | ||
| const minutes = date.getMinutes(); | ||
| const seconds = date.getSeconds(); | ||
| const milliseconds = date.getMilliseconds(); | ||
| const day = date.getDay(); | ||
| const meridiem = (_options$customMeridi = options.customMeridiem) !== null && _options$customMeridi !== void 0 ? _options$customMeridi : defaultMeridiem; | ||
| const stripTimeZone = (dateString) => { | ||
| var _dateString$split$; | ||
| return (_dateString$split$ = dateString.split(" ")[1]) !== null && _dateString$split$ !== void 0 ? _dateString$split$ : ""; | ||
| }; | ||
| const matches = { | ||
| Yo: () => formatOrdinal(years), | ||
| YY: () => String(years).slice(-2), | ||
| YYYY: () => years, | ||
| M: () => month + 1, | ||
| Mo: () => formatOrdinal(month + 1), | ||
| MM: () => `${month + 1}`.padStart(2, "0"), | ||
| MMM: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { month: "short" }), | ||
| MMMM: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { month: "long" }), | ||
| D: () => String(days), | ||
| Do: () => formatOrdinal(days), | ||
| DD: () => `${days}`.padStart(2, "0"), | ||
| H: () => String(hours), | ||
| Ho: () => formatOrdinal(hours), | ||
| HH: () => `${hours}`.padStart(2, "0"), | ||
| h: () => `${hours % 12 || 12}`.padStart(1, "0"), | ||
| ho: () => formatOrdinal(hours % 12 || 12), | ||
| hh: () => `${hours % 12 || 12}`.padStart(2, "0"), | ||
| m: () => String(minutes), | ||
| mo: () => formatOrdinal(minutes), | ||
| mm: () => `${minutes}`.padStart(2, "0"), | ||
| s: () => String(seconds), | ||
| so: () => formatOrdinal(seconds), | ||
| ss: () => `${seconds}`.padStart(2, "0"), | ||
| SSS: () => `${milliseconds}`.padStart(3, "0"), | ||
| d: () => day, | ||
| dd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "narrow" }), | ||
| ddd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "short" }), | ||
| dddd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "long" }), | ||
| A: () => meridiem(hours, minutes), | ||
| AA: () => meridiem(hours, minutes, false, true), | ||
| a: () => meridiem(hours, minutes, true), | ||
| aa: () => meridiem(hours, minutes, true, true), | ||
| z: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })), | ||
| zz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzzz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "longOffset" })) | ||
| }; | ||
| return formatStr.replace(REGEX_FORMAT, (match, $1) => { | ||
| var _ref, _matches$match; | ||
| return (_ref = $1 !== null && $1 !== void 0 ? $1 : (_matches$match = matches[match]) === null || _matches$match === void 0 ? void 0 : _matches$match.call(matches)) !== null && _ref !== void 0 ? _ref : match; | ||
| }); | ||
| } | ||
| function normalizeDate(date) { | ||
| if (date === null) return /* @__PURE__ */ new Date(NaN); | ||
| if (date === void 0) return /* @__PURE__ */ new Date(); | ||
| if (date instanceof Date) return new Date(date); | ||
| if (typeof date === "string" && !/Z$/i.test(date)) { | ||
| const d = date.match(REGEX_PARSE); | ||
| if (d) { | ||
| const m = d[2] - 1 || 0; | ||
| const ms = (d[7] || "0").substring(0, 3); | ||
| return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms); | ||
| } | ||
| } | ||
| return new Date(date); | ||
| } | ||
| /** | ||
| * Get the formatted date according to the string of tokens passed in. | ||
| * | ||
| * @see https://vueuse.org/useDateFormat | ||
| * @param date - The date to format, can either be a `Date` object, a timestamp, or a string | ||
| * @param formatStr - The combination of tokens to format the date | ||
| * @param options - UseDateFormatOptions | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) { | ||
| return (0, vue.computed)(() => formatDate(normalizeDate((0, vue.toValue)(date)), (0, vue.toValue)(formatStr), options)); | ||
| } | ||
| //#endregion | ||
| //#region useIntervalFn/index.ts | ||
| /** | ||
| * Wrapper for `setInterval` with controls | ||
| * | ||
| * @see https://vueuse.org/useIntervalFn | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| function useIntervalFn(cb, interval = 1e3, options = {}) { | ||
| const { immediate = true, immediateCallback = false } = options; | ||
| let timer = null; | ||
| const isActive = (0, vue.shallowRef)(false); | ||
| function clean() { | ||
| if (timer) { | ||
| clearInterval(timer); | ||
| timer = null; | ||
| } | ||
| } | ||
| function pause() { | ||
| isActive.value = false; | ||
| clean(); | ||
| } | ||
| function resume() { | ||
| const intervalValue = (0, vue.toValue)(interval); | ||
| if (intervalValue <= 0) return; | ||
| isActive.value = true; | ||
| if (immediateCallback) cb(); | ||
| clean(); | ||
| if (isActive.value) timer = setInterval(cb, intervalValue); | ||
| } | ||
| if (immediate && isClient) resume(); | ||
| if ((0, vue.isRef)(interval) || typeof interval === "function") { | ||
| const stopWatch = (0, vue.watch)(interval, () => { | ||
| if (isActive.value && isClient) resume(); | ||
| }); | ||
| tryOnScopeDispose(stopWatch); | ||
| } | ||
| tryOnScopeDispose(pause); | ||
| return { | ||
| isActive: (0, vue.shallowReadonly)(isActive), | ||
| pause, | ||
| resume | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region useInterval/index.ts | ||
| function useInterval(interval = 1e3, options = {}) { | ||
| const { controls: exposeControls = false, immediate = true, callback } = options; | ||
| const counter = (0, vue.shallowRef)(0); | ||
| const update = () => counter.value += 1; | ||
| const reset = () => { | ||
| counter.value = 0; | ||
| }; | ||
| const controls = useIntervalFn(callback ? () => { | ||
| update(); | ||
| callback(counter.value); | ||
| } : update, interval, { immediate }); | ||
| if (exposeControls) return { | ||
| counter: (0, vue.shallowReadonly)(counter), | ||
| reset, | ||
| ...controls | ||
| }; | ||
| else return (0, vue.shallowReadonly)(counter); | ||
| } | ||
| //#endregion | ||
| //#region useLastChanged/index.ts | ||
| function useLastChanged(source, options = {}) { | ||
| var _options$initialValue; | ||
| const ms = (0, vue.shallowRef)((_options$initialValue = options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : null); | ||
| (0, vue.watch)(source, () => ms.value = timestamp(), options); | ||
| return (0, vue.shallowReadonly)(ms); | ||
| } | ||
| //#endregion | ||
| //#region useTimeoutFn/index.ts | ||
| /** | ||
| * Wrapper for `setTimeout` with controls. | ||
| * | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| function useTimeoutFn(cb, interval, options = {}) { | ||
| const { immediate = true, immediateCallback = false } = options; | ||
| const isPending = (0, vue.shallowRef)(false); | ||
| let timer; | ||
| function clear() { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| } | ||
| } | ||
| function stop() { | ||
| isPending.value = false; | ||
| clear(); | ||
| } | ||
| function start(...args) { | ||
| if (immediateCallback) cb(); | ||
| clear(); | ||
| isPending.value = true; | ||
| timer = setTimeout(() => { | ||
| isPending.value = false; | ||
| timer = void 0; | ||
| cb(...args); | ||
| }, (0, vue.toValue)(interval)); | ||
| } | ||
| if (immediate) { | ||
| isPending.value = true; | ||
| if (isClient) start(); | ||
| } | ||
| tryOnScopeDispose(stop); | ||
| return { | ||
| isPending: (0, vue.shallowReadonly)(isPending), | ||
| start, | ||
| stop | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region useTimeout/index.ts | ||
| function useTimeout(interval = 1e3, options = {}) { | ||
| const { controls: exposeControls = false, callback } = options; | ||
| const controls = useTimeoutFn(callback !== null && callback !== void 0 ? callback : noop, interval, options); | ||
| const ready = (0, vue.computed)(() => !controls.isPending.value); | ||
| if (exposeControls) return { | ||
| ready, | ||
| ...controls | ||
| }; | ||
| else return ready; | ||
| } | ||
| //#endregion | ||
| //#region useToNumber/index.ts | ||
| /** | ||
| * Reactively convert a string ref to number. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useToNumber(value, options = {}) { | ||
| const { method = "parseFloat", radix, nanToZero } = options; | ||
| return (0, vue.computed)(() => { | ||
| let resolved = (0, vue.toValue)(value); | ||
| if (typeof method === "function") resolved = method(resolved); | ||
| else if (typeof resolved === "string") resolved = Number[method](resolved, radix); | ||
| if (nanToZero && Number.isNaN(resolved)) resolved = 0; | ||
| return resolved; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useToString/index.ts | ||
| /** | ||
| * Reactively convert a ref to string. | ||
| * | ||
| * @see https://vueuse.org/useToString | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useToString(value) { | ||
| return (0, vue.computed)(() => `${(0, vue.toValue)(value)}`); | ||
| } | ||
| //#endregion | ||
| //#region useToggle/index.ts | ||
| /** | ||
| * A boolean ref with a toggler | ||
| * | ||
| * @see https://vueuse.org/useToggle | ||
| * @param [initialValue] | ||
| * @param options | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useToggle(initialValue = false, options = {}) { | ||
| const { truthyValue = true, falsyValue = false } = options; | ||
| const valueIsRef = (0, vue.isRef)(initialValue); | ||
| const _value = (0, vue.shallowRef)(initialValue); | ||
| function toggle(value) { | ||
| if (arguments.length) { | ||
| _value.value = value; | ||
| return _value.value; | ||
| } else { | ||
| const truthy = (0, vue.toValue)(truthyValue); | ||
| _value.value = _value.value === truthy ? (0, vue.toValue)(falsyValue) : truthy; | ||
| return _value.value; | ||
| } | ||
| } | ||
| if (valueIsRef) return toggle; | ||
| else return [_value, toggle]; | ||
| } | ||
| //#endregion | ||
| //#region watchArray/index.ts | ||
| /** | ||
| * Watch for an array with additions and removals. | ||
| * | ||
| * @see https://vueuse.org/watchArray | ||
| */ | ||
| function watchArray(source, cb, options) { | ||
| let oldList = (options === null || options === void 0 ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : (0, vue.toValue)(source)]; | ||
| return (0, vue.watch)(source, (newList, _, onCleanup) => { | ||
| const oldListRemains = Array.from({ length: oldList.length }); | ||
| const added = []; | ||
| for (const obj of newList) { | ||
| let found = false; | ||
| for (let i = 0; i < oldList.length; i++) if (!oldListRemains[i] && obj === oldList[i]) { | ||
| oldListRemains[i] = true; | ||
| found = true; | ||
| break; | ||
| } | ||
| if (!found) added.push(obj); | ||
| } | ||
| const removed = oldList.filter((_$1, i) => !oldListRemains[i]); | ||
| cb(newList, oldList, added, removed, onCleanup); | ||
| oldList = [...newList]; | ||
| }, options); | ||
| } | ||
| //#endregion | ||
| //#region watchAtMost/index.ts | ||
| function watchAtMost(source, cb, options) { | ||
| const { count,...watchOptions } = options; | ||
| const current = (0, vue.shallowRef)(0); | ||
| const stop = watchWithFilter(source, (...args) => { | ||
| current.value += 1; | ||
| if (current.value >= (0, vue.toValue)(count)) (0, vue.nextTick)(() => stop()); | ||
| cb(...args); | ||
| }, watchOptions); | ||
| return { | ||
| count: current, | ||
| stop | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region watchDebounced/index.ts | ||
| function watchDebounced(source, cb, options = {}) { | ||
| const { debounce = 0, maxWait = void 0,...watchOptions } = options; | ||
| return watchWithFilter(source, cb, { | ||
| ...watchOptions, | ||
| eventFilter: debounceFilter(debounce, { maxWait }) | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchDeep/index.ts | ||
| /** | ||
| * Shorthand for watching value with {deep: true} | ||
| * | ||
| * @see https://vueuse.org/watchDeep | ||
| */ | ||
| function watchDeep(source, cb, options) { | ||
| return (0, vue.watch)(source, cb, { | ||
| ...options, | ||
| deep: true | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchIgnorable/index.ts | ||
| function watchIgnorable(source, cb, options = {}) { | ||
| const { eventFilter = bypassFilter,...watchOptions } = options; | ||
| const filteredCb = createFilterWrapper(eventFilter, cb); | ||
| let ignoreUpdates; | ||
| let ignorePrevAsyncUpdates; | ||
| let stop; | ||
| if (watchOptions.flush === "sync") { | ||
| let ignore = false; | ||
| ignorePrevAsyncUpdates = () => {}; | ||
| ignoreUpdates = (updater) => { | ||
| ignore = true; | ||
| updater(); | ||
| ignore = false; | ||
| }; | ||
| stop = (0, vue.watch)(source, (...args) => { | ||
| if (!ignore) filteredCb(...args); | ||
| }, watchOptions); | ||
| } else { | ||
| const disposables = []; | ||
| let ignoreCounter = 0; | ||
| let syncCounter = 0; | ||
| ignorePrevAsyncUpdates = () => { | ||
| ignoreCounter = syncCounter; | ||
| }; | ||
| disposables.push((0, vue.watch)(source, () => { | ||
| syncCounter++; | ||
| }, { | ||
| ...watchOptions, | ||
| flush: "sync" | ||
| })); | ||
| ignoreUpdates = (updater) => { | ||
| const syncCounterPrev = syncCounter; | ||
| updater(); | ||
| ignoreCounter += syncCounter - syncCounterPrev; | ||
| }; | ||
| disposables.push((0, vue.watch)(source, (...args) => { | ||
| const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter; | ||
| ignoreCounter = 0; | ||
| syncCounter = 0; | ||
| if (ignore) return; | ||
| filteredCb(...args); | ||
| }, watchOptions)); | ||
| stop = () => { | ||
| disposables.forEach((fn) => fn()); | ||
| }; | ||
| } | ||
| return { | ||
| stop, | ||
| ignoreUpdates, | ||
| ignorePrevAsyncUpdates | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region watchImmediate/index.ts | ||
| /** | ||
| * Shorthand for watching value with {immediate: true} | ||
| * | ||
| * @see https://vueuse.org/watchImmediate | ||
| */ | ||
| function watchImmediate(source, cb, options) { | ||
| return (0, vue.watch)(source, cb, { | ||
| ...options, | ||
| immediate: true | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchOnce/index.ts | ||
| /** | ||
| * Shorthand for watching value with { once: true } | ||
| * | ||
| * @see https://vueuse.org/watchOnce | ||
| */ | ||
| function watchOnce(source, cb, options) { | ||
| return (0, vue.watch)(source, cb, { | ||
| ...options, | ||
| once: true | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchThrottled/index.ts | ||
| function watchThrottled(source, cb, options = {}) { | ||
| const { throttle = 0, trailing = true, leading = true,...watchOptions } = options; | ||
| return watchWithFilter(source, cb, { | ||
| ...watchOptions, | ||
| eventFilter: throttleFilter(throttle, trailing, leading) | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchTriggerable/index.ts | ||
| function watchTriggerable(source, cb, options = {}) { | ||
| let cleanupFn; | ||
| function onEffect() { | ||
| if (!cleanupFn) return; | ||
| const fn = cleanupFn; | ||
| cleanupFn = void 0; | ||
| fn(); | ||
| } | ||
| /** Register the function `cleanupFn` */ | ||
| function onCleanup(callback) { | ||
| cleanupFn = callback; | ||
| } | ||
| const _cb = (value, oldValue) => { | ||
| onEffect(); | ||
| return cb(value, oldValue, onCleanup); | ||
| }; | ||
| const res = watchIgnorable(source, _cb, options); | ||
| const { ignoreUpdates } = res; | ||
| const trigger = () => { | ||
| let res$1; | ||
| ignoreUpdates(() => { | ||
| res$1 = _cb(getWatchSources(source), getOldValue(source)); | ||
| }); | ||
| return res$1; | ||
| }; | ||
| return { | ||
| ...res, | ||
| trigger | ||
| }; | ||
| } | ||
| function getWatchSources(sources) { | ||
| if ((0, vue.isReactive)(sources)) return sources; | ||
| if (Array.isArray(sources)) return sources.map((item) => (0, vue.toValue)(item)); | ||
| return (0, vue.toValue)(sources); | ||
| } | ||
| function getOldValue(source) { | ||
| return Array.isArray(source) ? source.map(() => void 0) : void 0; | ||
| } | ||
| //#endregion | ||
| //#region whenever/index.ts | ||
| /** | ||
| * Shorthand for watching value to be truthy | ||
| * | ||
| * @see https://vueuse.org/whenever | ||
| */ | ||
| function whenever(source, cb, options) { | ||
| const stop = (0, vue.watch)(source, (v, ov, onInvalidate) => { | ||
| if (v) { | ||
| if (options === null || options === void 0 ? void 0 : options.once) (0, vue.nextTick)(() => stop()); | ||
| cb(v, ov, onInvalidate); | ||
| } | ||
| }, { | ||
| ...options, | ||
| once: false | ||
| }); | ||
| return stop; | ||
| } | ||
| //#endregion | ||
| exports.assert = assert; | ||
| exports.autoResetRef = refAutoReset; | ||
| exports.refAutoReset = refAutoReset; | ||
| exports.bypassFilter = bypassFilter; | ||
| exports.camelize = camelize; | ||
| exports.clamp = clamp; | ||
| exports.computedEager = computedEager; | ||
| exports.eagerComputed = computedEager; | ||
| exports.computedWithControl = computedWithControl; | ||
| exports.controlledComputed = computedWithControl; | ||
| exports.containsProp = containsProp; | ||
| exports.controlledRef = controlledRef; | ||
| exports.createEventHook = createEventHook; | ||
| exports.createFilterWrapper = createFilterWrapper; | ||
| exports.createGlobalState = createGlobalState; | ||
| exports.createInjectionState = createInjectionState; | ||
| exports.createReactiveFn = reactify; | ||
| exports.reactify = reactify; | ||
| exports.createRef = createRef; | ||
| exports.createSharedComposable = createSharedComposable; | ||
| exports.createSingletonPromise = createSingletonPromise; | ||
| exports.debounceFilter = debounceFilter; | ||
| exports.debouncedRef = refDebounced; | ||
| exports.refDebounced = refDebounced; | ||
| exports.useDebounce = refDebounced; | ||
| exports.debouncedWatch = watchDebounced; | ||
| exports.watchDebounced = watchDebounced; | ||
| exports.extendRef = extendRef; | ||
| exports.formatDate = formatDate; | ||
| exports.get = get; | ||
| exports.getLifeCycleTarget = getLifeCycleTarget; | ||
| exports.hasOwn = hasOwn; | ||
| exports.hyphenate = hyphenate; | ||
| exports.identity = identity; | ||
| exports.ignorableWatch = watchIgnorable; | ||
| exports.watchIgnorable = watchIgnorable; | ||
| exports.increaseWithUnit = increaseWithUnit; | ||
| exports.injectLocal = injectLocal; | ||
| exports.invoke = invoke; | ||
| exports.isClient = isClient; | ||
| exports.isDef = isDef; | ||
| exports.isDefined = isDefined; | ||
| exports.isIOS = isIOS; | ||
| exports.isObject = isObject; | ||
| exports.isWorker = isWorker; | ||
| exports.makeDestructurable = makeDestructurable; | ||
| exports.noop = noop; | ||
| exports.normalizeDate = normalizeDate; | ||
| exports.notNullish = notNullish; | ||
| exports.now = now; | ||
| exports.objectEntries = objectEntries; | ||
| exports.objectOmit = objectOmit; | ||
| exports.objectPick = objectPick; | ||
| exports.pausableFilter = pausableFilter; | ||
| exports.pausableWatch = watchPausable; | ||
| exports.watchPausable = watchPausable; | ||
| exports.promiseTimeout = promiseTimeout; | ||
| exports.provideLocal = provideLocal; | ||
| exports.pxValue = pxValue; | ||
| exports.rand = rand; | ||
| exports.reactifyObject = reactifyObject; | ||
| exports.reactiveComputed = reactiveComputed; | ||
| exports.reactiveOmit = reactiveOmit; | ||
| exports.reactivePick = reactivePick; | ||
| exports.refDefault = refDefault; | ||
| exports.refThrottled = refThrottled; | ||
| exports.throttledRef = refThrottled; | ||
| exports.useThrottle = refThrottled; | ||
| exports.refWithControl = refWithControl; | ||
| exports.resolveRef = resolveRef; | ||
| exports.resolveUnref = resolveUnref; | ||
| exports.set = set; | ||
| exports.syncRef = syncRef; | ||
| exports.syncRefs = syncRefs; | ||
| exports.throttleFilter = throttleFilter; | ||
| exports.throttledWatch = watchThrottled; | ||
| exports.watchThrottled = watchThrottled; | ||
| exports.timestamp = timestamp; | ||
| exports.toArray = toArray; | ||
| exports.toReactive = toReactive; | ||
| exports.toRef = toRef; | ||
| exports.toRefs = toRefs; | ||
| exports.toValue = toValue; | ||
| exports.tryOnBeforeMount = tryOnBeforeMount; | ||
| exports.tryOnBeforeUnmount = tryOnBeforeUnmount; | ||
| exports.tryOnMounted = tryOnMounted; | ||
| exports.tryOnScopeDispose = tryOnScopeDispose; | ||
| exports.tryOnUnmounted = tryOnUnmounted; | ||
| exports.until = until; | ||
| exports.useArrayDifference = useArrayDifference; | ||
| exports.useArrayEvery = useArrayEvery; | ||
| exports.useArrayFilter = useArrayFilter; | ||
| exports.useArrayFind = useArrayFind; | ||
| exports.useArrayFindIndex = useArrayFindIndex; | ||
| exports.useArrayFindLast = useArrayFindLast; | ||
| exports.useArrayIncludes = useArrayIncludes; | ||
| exports.useArrayJoin = useArrayJoin; | ||
| exports.useArrayMap = useArrayMap; | ||
| exports.useArrayReduce = useArrayReduce; | ||
| exports.useArraySome = useArraySome; | ||
| exports.useArrayUnique = useArrayUnique; | ||
| exports.useCounter = useCounter; | ||
| exports.useDateFormat = useDateFormat; | ||
| exports.useDebounceFn = useDebounceFn; | ||
| exports.useInterval = useInterval; | ||
| exports.useIntervalFn = useIntervalFn; | ||
| exports.useLastChanged = useLastChanged; | ||
| exports.useThrottleFn = useThrottleFn; | ||
| exports.useTimeout = useTimeout; | ||
| exports.useTimeoutFn = useTimeoutFn; | ||
| exports.useToNumber = useToNumber; | ||
| exports.useToString = useToString; | ||
| exports.useToggle = useToggle; | ||
| exports.watchArray = watchArray; | ||
| exports.watchAtMost = watchAtMost; | ||
| exports.watchDeep = watchDeep; | ||
| exports.watchImmediate = watchImmediate; | ||
| exports.watchOnce = watchOnce; | ||
| exports.watchTriggerable = watchTriggerable; | ||
| exports.watchWithFilter = watchWithFilter; | ||
| exports.whenever = whenever; | ||
| })(this.VueUse = this.VueUse || {}, Vue); |
| (function(exports,t){var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},l=(e,t,i)=>(i=e==null?{}:n(o(e)),c(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e));t=l(t);function u(e,n){var r;let i=(0,t.shallowRef)();return(0,t.watchEffect)(()=>{i.value=e()},{...n,flush:(r=n==null?void 0:n.flush)==null?`sync`:r}),(0,t.readonly)(i)}function d(e,n,r={}){let i,a,o,s=!0,c=()=>{s=!0,o()};(0,t.watch)(e,c,{flush:`sync`,...r});let l=typeof n==`function`?n:n.get,u=typeof n==`function`?void 0:n.set,d=(0,t.customRef)((e,t)=>(a=e,o=t,{get(){return s&&(i=l(i),s=!1),a(),i},set(e){u==null||u(e)}}));return d.trigger=c,d}function f(e){return(0,t.getCurrentScope)()?((0,t.onScopeDispose)(e),!0):!1}function p(){let e=new Set,t=t=>{e.delete(t)},n=()=>{e.clear()},r=n=>{e.add(n);let r=()=>t(n);return f(r),{off:r}},i=(...t)=>Promise.all(Array.from(e).map(e=>e(...t)));return{on:r,off:t,trigger:i,clear:n}}function m(e){let n=!1,r,i=(0,t.effectScope)(!0);return((...t)=>(n||(r=i.run(()=>e(...t)),n=!0),r))}let h=new WeakMap,g=(...e)=>{var n;let r=e[0],i=(n=(0,t.getCurrentInstance)())==null?void 0:n.proxy;if(i==null&&!(0,t.hasInjectionContext)())throw Error(`injectLocal must be called in setup`);return i&&h.has(i)&&r in h.get(i)?h.get(i)[r]:(0,t.inject)(...e)};function _(e,n){var r;let i=(r=(0,t.getCurrentInstance)())==null?void 0:r.proxy;if(i==null)throw Error(`provideLocal must be called in setup`);h.has(i)||h.set(i,Object.create(null));let a=h.get(i);return a[e]=n,(0,t.provide)(e,n)}function ee(e,t){let n=(t==null?void 0:t.injectionKey)||Symbol(e.name||`InjectionState`),r=t==null?void 0:t.defaultValue,i=(...t)=>{let r=e(...t);return _(n,r),r},a=()=>g(n,r);return[i,a]}function te(e,n){return n===!0?(0,t.ref)(e):(0,t.shallowRef)(e)}function ne(e){let n=0,r,i,a=()=>{--n,i&&n<=0&&(i.stop(),r=void 0,i=void 0)};return((...o)=>(n+=1,i||(i=(0,t.effectScope)(!0),r=i.run(()=>e(...o))),f(a),r))}function v(e,n,{enumerable:r=!1,unwrap:i=!0}={}){for(let[a,o]of Object.entries(n)){if(a===`value`)continue;(0,t.isRef)(o)&&i?Object.defineProperty(e,a,{get(){return o.value},set(e){o.value=e},enumerable:r}):Object.defineProperty(e,a,{value:o,enumerable:r})}return e}function re(e,n){return n==null?(0,t.unref)(e):(0,t.unref)(e)[n]}function ie(e){return(0,t.unref)(e)!=null}function ae(e,t){if(typeof Symbol<`u`){let n={...e};return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let e=0;return{next:()=>({value:t[e++],done:e>t.length})}}}),n}else return Object.assign([...t],e)}function y(e,n){let r=(n==null?void 0:n.computedGetter)===!1?t.unref:t.toValue;return function(...n){return(0,t.computed)(()=>e.apply(this,n.map(e=>r(e))))}}function oe(e,t={}){let n=[],r;if(Array.isArray(t))n=t;else{r=t;let{includeOwnProperties:i=!0}=t;n.push(...Object.keys(e)),i&&n.push(...Object.getOwnPropertyNames(e))}return Object.fromEntries(n.map(t=>{let n=e[t];return[t,typeof n==`function`?y(n.bind(e),r):n]}))}function b(e){if(!(0,t.isRef)(e))return(0,t.reactive)(e);let n=new Proxy({},{get(n,r,i){return(0,t.unref)(Reflect.get(e.value,r,i))},set(n,r,i){return(0,t.isRef)(e.value[r])&&!(0,t.isRef)(i)?e.value[r].value=i:e.value[r]=i,!0},deleteProperty(t,n){return Reflect.deleteProperty(e.value,n)},has(t,n){return Reflect.has(e.value,n)},ownKeys(){return Object.keys(e.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return(0,t.reactive)(n)}function x(e){return b((0,t.computed)(e))}function se(e,...n){let r=n.flat(),i=r[0];return x(()=>typeof i==`function`?Object.fromEntries(Object.entries((0,t.toRefs)(e)).filter(([e,n])=>!i((0,t.toValue)(n),e))):Object.fromEntries(Object.entries((0,t.toRefs)(e)).filter(e=>!r.includes(e[0]))))}let S=typeof window<`u`&&typeof document<`u`,ce=typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope,le=e=>e!==void 0,ue=e=>e!=null,de=(e,...t)=>{e||console.warn(...t)},fe=Object.prototype.toString,C=e=>fe.call(e)===`[object Object]`,pe=()=>Date.now(),w=()=>+Date.now(),me=(e,t,n)=>Math.min(n,Math.max(t,e)),T=()=>{},he=(e,t)=>(e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e),ge=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_e=ve();function ve(){var e,t,n;return S&&((e=window)==null||(e=e.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window)==null||(t=t.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test((n=window)==null?void 0:n.navigator.userAgent))}function E(...e){if(e.length!==1)return(0,t.toRef)(...e);let n=e[0];return typeof n==`function`?(0,t.readonly)((0,t.customRef)(()=>({get:n,set:T}))):(0,t.ref)(n)}let ye=E;function be(e,...n){let r=n.flat(),i=r[0];return x(()=>typeof i==`function`?Object.fromEntries(Object.entries((0,t.toRefs)(e)).filter(([e,n])=>i((0,t.toValue)(n),e))):Object.fromEntries(r.map(t=>[t,E(e,t)])))}function D(e,n=1e4){return(0,t.customRef)((r,i)=>{let a=(0,t.toValue)(e),o,s=()=>setTimeout(()=>{a=(0,t.toValue)(e),i()},(0,t.toValue)(n));return f(()=>{clearTimeout(o)}),{get(){return r(),a},set(e){a=e,i(),clearTimeout(o),o=s()}}})}function O(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}let k=e=>e();function A(e,n={}){let r,i,a=T,o=e=>{clearTimeout(e),a(),a=T},s,c=c=>{let l=(0,t.toValue)(e),u=(0,t.toValue)(n.maxWait);return r&&o(r),l<=0||u!==void 0&&u<=0?(i&&(o(i),i=void 0),Promise.resolve(c())):new Promise((e,t)=>{a=n.rejectOnCancel?t:e,s=c,u&&!i&&(i=setTimeout(()=>{r&&o(r),i=void 0,e(s())},u)),r=setTimeout(()=>{i&&o(i),i=void 0,e(c())},l)})};return c}function j(...e){let n=0,r,i=!0,a=T,o,s,c,l,u;!(0,t.isRef)(e[0])&&typeof e[0]==`object`?{delay:s,trailing:c=!0,leading:l=!0,rejectOnCancel:u=!1}=e[0]:[s,c=!0,l=!0,u=!1]=e;let d=()=>{r&&(clearTimeout(r),r=void 0,a(),a=T)},f=e=>{let f=(0,t.toValue)(s),p=Date.now()-n,m=()=>o=e();return d(),f<=0?(n=Date.now(),m()):(p>f?(n=Date.now(),(l||!i)&&m()):c&&(o=new Promise((e,t)=>{a=u?t:e,r=setTimeout(()=>{n=Date.now(),i=!0,e(m()),d()},Math.max(0,f-p))})),!l&&!r&&(r=setTimeout(()=>i=!0,f)),i=!1,o)};return f}function M(e=k,n={}){let{initialState:r=`active`}=n,i=E(r===`active`);function a(){i.value=!1}function o(){i.value=!0}let s=(...t)=>{i.value&&e(...t)};return{isActive:(0,t.readonly)(i),pause:a,resume:o,eventFilter:s}}function N(e,t=!1,n=`Timeout`){return new Promise((r,i)=>{t?setTimeout(()=>i(n),e):setTimeout(r,e)})}function xe(e){return e}function Se(e){let t;function n(){return t||(t=e()),t}return n.reset=async()=>{let e=t;t=void 0,e&&await e},n}function Ce(e){return e()}function P(e,...t){return t.some(t=>t in e)}function we(e,t){var n;if(typeof e==`number`)return e+t;let r=((n=e.match(/^-?\d+\.?\d*/))==null?void 0:n[0])||``,i=e.slice(r.length),a=Number.parseFloat(r)+t;return Number.isNaN(a)?e:a+i}function Te(e){return e.endsWith(`rem`)?Number.parseFloat(e)*16:Number.parseFloat(e)}function Ee(e,t,n=!1){return t.reduce((t,r)=>(r in e&&(!n||e[r]!==void 0)&&(t[r]=e[r]),t),{})}function De(e,t,n=!1){return Object.fromEntries(Object.entries(e).filter(([e,r])=>(!n||r!==void 0)&&!t.includes(e)))}function Oe(e){return Object.entries(e)}function F(e){return Array.isArray(e)?e:[e]}function I(e){let t=Object.create(null);return(n=>{let r=t[n];return r||(t[n]=e(n))})}let ke=/\B([A-Z])/g,Ae=I(e=>e.replace(ke,`-$1`).toLowerCase()),je=/-(\w)/g,Me=I(e=>e.replace(je,(e,t)=>t?t.toUpperCase():``));function L(e){return e||(0,t.getCurrentInstance)()}function R(e,t=200,n={}){return O(A(t,n),e)}function z(e,n=200,r={}){let i=(0,t.ref)((0,t.toValue)(e)),a=R(()=>{i.value=e.value},n,r);return(0,t.watch)(e,()=>a()),(0,t.shallowReadonly)(i)}function Ne(e,n){return(0,t.computed)({get(){var t;return(t=e.value)==null?n:t},set(t){e.value=t}})}function B(e,t=200,n=!1,r=!0,i=!1){return O(j(t,n,r,i),e)}function V(e,n=200,r=!0,i=!0){if(n<=0)return e;let a=(0,t.ref)((0,t.toValue)(e)),o=B(()=>{a.value=e.value},n,r,i);return(0,t.watch)(e,()=>o()),a}function H(e,n={}){let r=e,i,a,o=(0,t.customRef)((e,t)=>(i=e,a=t,{get(){return s()},set(e){c(e)}}));function s(e=!0){return e&&i(),r}function c(e,t=!0){var i,o;if(e===r)return;let s=r;((i=n.onBeforeChange)==null?void 0:i.call(n,e,s))!==!1&&(r=e,(o=n.onChanged)==null||o.call(n,e,s),t&&a())}let l=()=>s(!1),u=e=>c(e,!1),d=()=>s(!1),f=e=>c(e,!1);return v(o,{get:s,set:c,untrackedGet:l,silentSet:u,peek:d,lay:f},{enumerable:!0})}let Pe=H;function Fe(...e){if(e.length===2){let[t,n]=e;t.value=n}if(e.length===3){let[t,n,r]=e;t[n]=r}}function U(e,n,r={}){let{eventFilter:i=k,...a}=r;return(0,t.watch)(e,O(i,n),a)}function W(e,t,n={}){let{eventFilter:r,initialState:i=`active`,...a}=n,{eventFilter:o,pause:s,resume:c,isActive:l}=M(r,{initialState:i}),u=U(e,t,{...a,eventFilter:o});return{stop:u,pause:s,resume:c,isActive:l}}function Ie(e,t,...[n]){let{flush:r=`sync`,deep:i=!1,immediate:a=!0,direction:o=`both`,transform:s={}}=n||{},c=[],l=`ltr`in s&&s.ltr||(e=>e),u=`rtl`in s&&s.rtl||(e=>e);(o===`both`||o===`ltr`)&&c.push(W(e,e=>{c.forEach(e=>e.pause()),t.value=l(e),c.forEach(e=>e.resume())},{flush:r,deep:i,immediate:a})),(o===`both`||o===`rtl`)&&c.push(W(t,t=>{c.forEach(e=>e.pause()),e.value=u(t),c.forEach(e=>e.resume())},{flush:r,deep:i,immediate:a}));let d=()=>{c.forEach(e=>e.stop())};return d}function Le(e,n,r={}){let{flush:i=`sync`,deep:a=!1,immediate:o=!0}=r,s=F(n);return(0,t.watch)(e,e=>s.forEach(t=>t.value=e),{flush:i,deep:a,immediate:o})}function Re(e,n={}){if(!(0,t.isRef)(e))return(0,t.toRefs)(e);let r=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(let i in e.value)r[i]=(0,t.customRef)(()=>({get(){return e.value[i]},set(r){var a;let o=(a=(0,t.toValue)(n.replaceRef))==null?!0:a;if(o)if(Array.isArray(e.value)){let t=[...e.value];t[i]=r,e.value=t}else{let t={...e.value,[i]:r};Object.setPrototypeOf(t,Object.getPrototypeOf(e.value)),e.value=t}else e.value[i]=r}}));return r}let ze=t.toValue,Be=t.toValue;function Ve(e,n=!0,r){let i=L(r);i?(0,t.onBeforeMount)(e,r):n?e():(0,t.nextTick)(e)}function He(e,n){let r=L(n);r&&(0,t.onBeforeUnmount)(e,n)}function Ue(e,n=!0,r){let i=L(r);i?(0,t.onMounted)(e,r):n?e():(0,t.nextTick)(e)}function We(e,n){let r=L(n);r&&(0,t.onUnmounted)(e,n)}function G(e,n=!1){function r(r,{flush:i=`sync`,deep:a=!1,timeout:o,throwOnTimeout:s}={}){let c=null,l=new Promise(o=>{c=(0,t.watch)(e,e=>{r(e)!==n&&(c?c():(0,t.nextTick)(()=>c==null?void 0:c()),o(e))},{flush:i,deep:a,immediate:!0})}),u=[l];return o!=null&&u.push(N(o,s).then(()=>(0,t.toValue)(e)).finally(()=>c==null?void 0:c())),Promise.race(u)}function i(i,a){if(!(0,t.isRef)(i))return r(e=>e===i,a);let{flush:o=`sync`,deep:s=!1,timeout:c,throwOnTimeout:l}=a==null?{}:a,u=null,d=new Promise(r=>{u=(0,t.watch)([e,i],([e,i])=>{n!==(e===i)&&(u?u():(0,t.nextTick)(()=>u==null?void 0:u()),r(e))},{flush:o,deep:s,immediate:!0})}),f=[d];return c!=null&&f.push(N(c,l).then(()=>(0,t.toValue)(e)).finally(()=>(u==null||u(),(0,t.toValue)(e)))),Promise.race(f)}function a(e){return r(e=>!!e,e)}function o(e){return i(null,e)}function s(e){return i(void 0,e)}function c(e){return r(Number.isNaN,e)}function l(e,n){return r(n=>{let r=Array.from(n);return r.includes(e)||r.includes((0,t.toValue)(e))},n)}function u(e){return d(1,e)}function d(e=1,t){let n=-1;return r(()=>(n+=1,n>=e),t)}if(Array.isArray((0,t.toValue)(e))){let t={toMatch:r,toContains:l,changed:u,changedTimes:d,get not(){return G(e,!n)}};return t}else{let t={toMatch:r,toBe:i,toBeTruthy:a,toBeNull:o,toBeNaN:c,toBeUndefined:s,changed:u,changedTimes:d,get not(){return G(e,!n)}};return t}}function Ge(e){return G(e)}function Ke(e,t){return e===t}function qe(...e){var n,r;let i=e[0],a=e[1],o=(n=e[2])==null?Ke:n,{symmetric:s=!1}=(r=e[3])==null?{}:r;if(typeof o==`string`){let e=o;o=(t,n)=>t[e]===n[e]}let c=(0,t.computed)(()=>(0,t.toValue)(i).filter(e=>(0,t.toValue)(a).findIndex(t=>o(e,t))===-1));if(s){let e=(0,t.computed)(()=>(0,t.toValue)(a).filter(e=>(0,t.toValue)(i).findIndex(t=>o(e,t))===-1));return(0,t.computed)(()=>s?[...(0,t.toValue)(c),...(0,t.toValue)(e)]:(0,t.toValue)(c))}else return c}function Je(e,n){return(0,t.computed)(()=>(0,t.toValue)(e).every((e,r,i)=>n((0,t.toValue)(e),r,i)))}function Ye(e,n){return(0,t.computed)(()=>(0,t.toValue)(e).map(e=>(0,t.toValue)(e)).filter(n))}function Xe(e,n){return(0,t.computed)(()=>(0,t.toValue)((0,t.toValue)(e).find((e,r,i)=>n((0,t.toValue)(e),r,i))))}function Ze(e,n){return(0,t.computed)(()=>(0,t.toValue)(e).findIndex((e,r,i)=>n((0,t.toValue)(e),r,i)))}function Qe(e,t){let n=e.length;for(;n-- >0;)if(t(e[n],n,e))return e[n]}function $e(e,n){return(0,t.computed)(()=>(0,t.toValue)(Array.prototype.findLast?(0,t.toValue)(e).findLast((e,r,i)=>n((0,t.toValue)(e),r,i)):Qe((0,t.toValue)(e),(e,r,i)=>n((0,t.toValue)(e),r,i))))}function et(e){return C(e)&&P(e,`formIndex`,`comparator`)}function tt(...e){var n;let r=e[0],i=e[1],a=e[2],o=0;if(et(a)){var s;o=(s=a.fromIndex)==null?0:s,a=a.comparator}if(typeof a==`string`){let e=a;a=(n,r)=>n[e]===(0,t.toValue)(r)}return a=(n=a)==null?((e,n)=>e===(0,t.toValue)(n)):n,(0,t.computed)(()=>(0,t.toValue)(r).slice(o).some((e,n,r)=>a((0,t.toValue)(e),(0,t.toValue)(i),n,(0,t.toValue)(r))))}function nt(e,n){return(0,t.computed)(()=>(0,t.toValue)(e).map(e=>(0,t.toValue)(e)).join((0,t.toValue)(n)))}function rt(e,n){return(0,t.computed)(()=>(0,t.toValue)(e).map(e=>(0,t.toValue)(e)).map(n))}function it(e,n,...r){let i=(e,r,i)=>n((0,t.toValue)(e),(0,t.toValue)(r),i);return(0,t.computed)(()=>{let n=(0,t.toValue)(e);return r.length?n.reduce(i,typeof r[0]==`function`?(0,t.toValue)(r[0]()):(0,t.toValue)(r[0])):n.reduce(i)})}function at(e,n){return(0,t.computed)(()=>(0,t.toValue)(e).some((e,r,i)=>n((0,t.toValue)(e),r,i)))}function ot(e){return Array.from(new Set(e))}function st(e,t){return e.reduce((n,r)=>(n.some(n=>t(r,n,e))||n.push(r),n),[])}function ct(e,n){return(0,t.computed)(()=>{let r=(0,t.toValue)(e).map(e=>(0,t.toValue)(e));return n?st(r,n):ot(r)})}function lt(e=0,n={}){let r=(0,t.unref)(e),i=(0,t.shallowRef)(e),{max:a=1/0,min:o=-1/0}=n,s=(e=1)=>i.value=Math.max(Math.min(a,i.value+e),o),c=(e=1)=>i.value=Math.min(Math.max(o,i.value-e),a),l=()=>i.value,u=e=>i.value=Math.max(o,Math.min(a,e)),d=(e=r)=>(r=e,u(e));return{count:(0,t.shallowReadonly)(i),inc:s,dec:c,get:l,set:u,reset:d}}let ut=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i,dt=/[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;function ft(e,t,n,r){let i=e<12?`AM`:`PM`;return r&&(i=i.split(``).reduce((e,t)=>e+=`${t}.`,``)),n?i.toLowerCase():i}function K(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function q(e,n,r={}){var i;let a=e.getFullYear(),o=e.getMonth(),s=e.getDate(),c=e.getHours(),l=e.getMinutes(),u=e.getSeconds(),d=e.getMilliseconds(),f=e.getDay(),p=(i=r.customMeridiem)==null?ft:i,m=e=>{var t;return(t=e.split(` `)[1])==null?``:t},h={Yo:()=>K(a),YY:()=>String(a).slice(-2),YYYY:()=>a,M:()=>o+1,Mo:()=>K(o+1),MM:()=>`${o+1}`.padStart(2,`0`),MMM:()=>e.toLocaleDateString((0,t.toValue)(r.locales),{month:`short`}),MMMM:()=>e.toLocaleDateString((0,t.toValue)(r.locales),{month:`long`}),D:()=>String(s),Do:()=>K(s),DD:()=>`${s}`.padStart(2,`0`),H:()=>String(c),Ho:()=>K(c),HH:()=>`${c}`.padStart(2,`0`),h:()=>`${c%12||12}`.padStart(1,`0`),ho:()=>K(c%12||12),hh:()=>`${c%12||12}`.padStart(2,`0`),m:()=>String(l),mo:()=>K(l),mm:()=>`${l}`.padStart(2,`0`),s:()=>String(u),so:()=>K(u),ss:()=>`${u}`.padStart(2,`0`),SSS:()=>`${d}`.padStart(3,`0`),d:()=>f,dd:()=>e.toLocaleDateString((0,t.toValue)(r.locales),{weekday:`narrow`}),ddd:()=>e.toLocaleDateString((0,t.toValue)(r.locales),{weekday:`short`}),dddd:()=>e.toLocaleDateString((0,t.toValue)(r.locales),{weekday:`long`}),A:()=>p(c,l),AA:()=>p(c,l,!1,!0),a:()=>p(c,l,!0),aa:()=>p(c,l,!0,!0),z:()=>m(e.toLocaleDateString((0,t.toValue)(r.locales),{timeZoneName:`shortOffset`})),zz:()=>m(e.toLocaleDateString((0,t.toValue)(r.locales),{timeZoneName:`shortOffset`})),zzz:()=>m(e.toLocaleDateString((0,t.toValue)(r.locales),{timeZoneName:`shortOffset`})),zzzz:()=>m(e.toLocaleDateString((0,t.toValue)(r.locales),{timeZoneName:`longOffset`}))};return n.replace(dt,(e,t)=>{var n,r;return(n=t==null?(r=h[e])==null?void 0:r.call(h):t)==null?e:n})}function J(e){if(e===null)return new Date(NaN);if(e===void 0)return new Date;if(e instanceof Date)return new Date(e);if(typeof e==`string`&&!/Z$/i.test(e)){let t=e.match(ut);if(t){let e=t[2]-1||0,n=(t[7]||`0`).substring(0,3);return new Date(t[1],e,t[3]||1,t[4]||0,t[5]||0,t[6]||0,n)}}return new Date(e)}function pt(e,n=`HH:mm:ss`,r={}){return(0,t.computed)(()=>q(J((0,t.toValue)(e)),(0,t.toValue)(n),r))}function Y(e,n=1e3,r={}){let{immediate:i=!0,immediateCallback:a=!1}=r,o=null,s=(0,t.shallowRef)(!1);function c(){o&&(clearInterval(o),o=null)}function l(){s.value=!1,c()}function u(){let r=(0,t.toValue)(n);r<=0||(s.value=!0,a&&e(),c(),s.value&&(o=setInterval(e,r)))}if(i&&S&&u(),(0,t.isRef)(n)||typeof n==`function`){let e=(0,t.watch)(n,()=>{s.value&&S&&u()});f(e)}return f(l),{isActive:(0,t.shallowReadonly)(s),pause:l,resume:u}}function mt(e=1e3,n={}){let{controls:r=!1,immediate:i=!0,callback:a}=n,o=(0,t.shallowRef)(0),s=()=>o.value+=1,c=()=>{o.value=0},l=Y(a?()=>{s(),a(o.value)}:s,e,{immediate:i});return r?{counter:(0,t.shallowReadonly)(o),reset:c,...l}:(0,t.shallowReadonly)(o)}function ht(e,n={}){var r;let i=(0,t.shallowRef)((r=n.initialValue)==null?null:r);return(0,t.watch)(e,()=>i.value=w(),n),(0,t.shallowReadonly)(i)}function X(e,n,r={}){let{immediate:i=!0,immediateCallback:a=!1}=r,o=(0,t.shallowRef)(!1),s;function c(){s&&(clearTimeout(s),s=void 0)}function l(){o.value=!1,c()}function u(...r){a&&e(),c(),o.value=!0,s=setTimeout(()=>{o.value=!1,s=void 0,e(...r)},(0,t.toValue)(n))}return i&&(o.value=!0,S&&u()),f(l),{isPending:(0,t.shallowReadonly)(o),start:u,stop:l}}function gt(e=1e3,n={}){let{controls:r=!1,callback:i}=n,a=X(i==null?T:i,e,n),o=(0,t.computed)(()=>!a.isPending.value);return r?{ready:o,...a}:o}function _t(e,n={}){let{method:r=`parseFloat`,radix:i,nanToZero:a}=n;return(0,t.computed)(()=>{let n=(0,t.toValue)(e);return typeof r==`function`?n=r(n):typeof n==`string`&&(n=Number[r](n,i)),a&&Number.isNaN(n)&&(n=0),n})}function vt(e){return(0,t.computed)(()=>`${(0,t.toValue)(e)}`)}function yt(e=!1,n={}){let{truthyValue:r=!0,falsyValue:i=!1}=n,a=(0,t.isRef)(e),o=(0,t.shallowRef)(e);function s(e){if(arguments.length)return o.value=e,o.value;{let e=(0,t.toValue)(r);return o.value=o.value===e?(0,t.toValue)(i):e,o.value}}return a?s:[o,s]}function bt(e,n,r){let i=r!=null&&r.immediate?[]:[...typeof e==`function`?e():Array.isArray(e)?e:(0,t.toValue)(e)];return(0,t.watch)(e,(e,t,r)=>{let a=Array.from({length:i.length}),o=[];for(let t of e){let e=!1;for(let n=0;n<i.length;n++)if(!a[n]&&t===i[n]){a[n]=!0,e=!0;break}e||o.push(t)}let s=i.filter((e,t)=>!a[t]);n(e,i,o,s,r),i=[...e]},r)}function xt(e,n,r){let{count:i,...a}=r,o=(0,t.shallowRef)(0),s=U(e,(...e)=>{o.value+=1,o.value>=(0,t.toValue)(i)&&(0,t.nextTick)(()=>s()),n(...e)},a);return{count:o,stop:s}}function Z(e,t,n={}){let{debounce:r=0,maxWait:i=void 0,...a}=n;return U(e,t,{...a,eventFilter:A(r,{maxWait:i})})}function St(e,n,r){return(0,t.watch)(e,n,{...r,deep:!0})}function Q(e,n,r={}){let{eventFilter:i=k,...a}=r,o=O(i,n),s,c,l;if(a.flush===`sync`){let n=!1;c=()=>{},s=e=>{n=!0,e(),n=!1},l=(0,t.watch)(e,(...e)=>{n||o(...e)},a)}else{let n=[],r=0,i=0;c=()=>{r=i},n.push((0,t.watch)(e,()=>{i++},{...a,flush:`sync`})),s=e=>{let t=i;e(),r+=i-t},n.push((0,t.watch)(e,(...e)=>{let t=r>0&&r===i;r=0,i=0,!t&&o(...e)},a)),l=()=>{n.forEach(e=>e())}}return{stop:l,ignoreUpdates:s,ignorePrevAsyncUpdates:c}}function Ct(e,n,r){return(0,t.watch)(e,n,{...r,immediate:!0})}function wt(e,n,r){return(0,t.watch)(e,n,{...r,once:!0})}function $(e,t,n={}){let{throttle:r=0,trailing:i=!0,leading:a=!0,...o}=n;return U(e,t,{...o,eventFilter:j(r,i,a)})}function Tt(e,t,n={}){let r;function i(){if(!r)return;let e=r;r=void 0,e()}function a(e){r=e}let o=(e,n)=>(i(),t(e,n,a)),s=Q(e,o,n),{ignoreUpdates:c}=s,l=()=>{let t;return c(()=>{t=o(Et(e),Dt(e))}),t};return{...s,trigger:l}}function Et(e){return(0,t.isReactive)(e)?e:Array.isArray(e)?e.map(e=>(0,t.toValue)(e)):(0,t.toValue)(e)}function Dt(e){return Array.isArray(e)?e.map(()=>void 0):void 0}function Ot(e,n,r){let i=(0,t.watch)(e,(e,a,o)=>{e&&(r!=null&&r.once&&(0,t.nextTick)(()=>i()),n(e,a,o))},{...r,once:!1});return i}exports.assert=de,exports.autoResetRef=D,exports.refAutoReset=D,exports.bypassFilter=k,exports.camelize=Me,exports.clamp=me,exports.computedEager=u,exports.eagerComputed=u,exports.computedWithControl=d,exports.controlledComputed=d,exports.containsProp=P,exports.controlledRef=Pe,exports.createEventHook=p,exports.createFilterWrapper=O,exports.createGlobalState=m,exports.createInjectionState=ee,exports.createReactiveFn=y,exports.reactify=y,exports.createRef=te,exports.createSharedComposable=ne,exports.createSingletonPromise=Se,exports.debounceFilter=A,exports.debouncedRef=z,exports.refDebounced=z,exports.useDebounce=z,exports.debouncedWatch=Z,exports.watchDebounced=Z,exports.extendRef=v,exports.formatDate=q,exports.get=re,exports.getLifeCycleTarget=L,exports.hasOwn=ge,exports.hyphenate=Ae,exports.identity=xe,exports.ignorableWatch=Q,exports.watchIgnorable=Q,exports.increaseWithUnit=we,exports.injectLocal=g,exports.invoke=Ce,exports.isClient=S,exports.isDef=le,exports.isDefined=ie,exports.isIOS=_e,exports.isObject=C,exports.isWorker=ce,exports.makeDestructurable=ae,exports.noop=T,exports.normalizeDate=J,exports.notNullish=ue,exports.now=pe,exports.objectEntries=Oe,exports.objectOmit=De,exports.objectPick=Ee,exports.pausableFilter=M,exports.pausableWatch=W,exports.watchPausable=W,exports.promiseTimeout=N,exports.provideLocal=_,exports.pxValue=Te,exports.rand=he,exports.reactifyObject=oe,exports.reactiveComputed=x,exports.reactiveOmit=se,exports.reactivePick=be,exports.refDefault=Ne,exports.refThrottled=V,exports.throttledRef=V,exports.useThrottle=V,exports.refWithControl=H,exports.resolveRef=ye,exports.resolveUnref=Be,exports.set=Fe,exports.syncRef=Ie,exports.syncRefs=Le,exports.throttleFilter=j,exports.throttledWatch=$,exports.watchThrottled=$,exports.timestamp=w,exports.toArray=F,exports.toReactive=b,exports.toRef=E,exports.toRefs=Re,exports.toValue=ze,exports.tryOnBeforeMount=Ve,exports.tryOnBeforeUnmount=He,exports.tryOnMounted=Ue,exports.tryOnScopeDispose=f,exports.tryOnUnmounted=We,exports.until=Ge,exports.useArrayDifference=qe,exports.useArrayEvery=Je,exports.useArrayFilter=Ye,exports.useArrayFind=Xe,exports.useArrayFindIndex=Ze,exports.useArrayFindLast=$e,exports.useArrayIncludes=tt,exports.useArrayJoin=nt,exports.useArrayMap=rt,exports.useArrayReduce=it,exports.useArraySome=at,exports.useArrayUnique=ct,exports.useCounter=lt,exports.useDateFormat=pt,exports.useDebounceFn=R,exports.useInterval=mt,exports.useIntervalFn=Y,exports.useLastChanged=ht,exports.useThrottleFn=B,exports.useTimeout=gt,exports.useTimeoutFn=X,exports.useToNumber=_t,exports.useToString=vt,exports.useToggle=yt,exports.watchArray=bt,exports.watchAtMost=xt,exports.watchDeep=St,exports.watchImmediate=Ct,exports.watchOnce=wt,exports.watchTriggerable=Tt,exports.watchWithFilter=U,exports.whenever=Ot})(this.VueUse=this.VueUse||{},Vue); |
+2039
| import { computed, customRef, effectScope, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isReactive, isRef, nextTick, onBeforeMount, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, provide, reactive, readonly, ref, shallowReadonly, shallowRef, toRef as toRef$1, toRefs as toRefs$1, toValue as toValue$1, unref, watch, watchEffect } from "vue"; | ||
| //#region computedEager/index.ts | ||
| /** | ||
| * Note: If you are using Vue 3.4+, you can straight use computed instead. | ||
| * Because in Vue 3.4+, if computed new value does not change, | ||
| * computed, effect, watch, watchEffect, render dependencies will not be triggered. | ||
| * refer: https://github.com/vuejs/core/pull/5912 | ||
| * | ||
| * @param fn effect function | ||
| * @param options WatchOptionsBase | ||
| * @returns readonly shallowRef | ||
| */ | ||
| function computedEager(fn, options) { | ||
| var _options$flush; | ||
| const result = shallowRef(); | ||
| watchEffect(() => { | ||
| result.value = fn(); | ||
| }, { | ||
| ...options, | ||
| flush: (_options$flush = options === null || options === void 0 ? void 0 : options.flush) !== null && _options$flush !== void 0 ? _options$flush : "sync" | ||
| }); | ||
| return readonly(result); | ||
| } | ||
| //#endregion | ||
| //#region computedWithControl/index.ts | ||
| /** | ||
| * Explicitly define the deps of computed. | ||
| * | ||
| * @param source | ||
| * @param fn | ||
| */ | ||
| function computedWithControl(source, fn, options = {}) { | ||
| let v = void 0; | ||
| let track; | ||
| let trigger; | ||
| let dirty = true; | ||
| const update = () => { | ||
| dirty = true; | ||
| trigger(); | ||
| }; | ||
| watch(source, update, { | ||
| flush: "sync", | ||
| ...options | ||
| }); | ||
| const get$1 = typeof fn === "function" ? fn : fn.get; | ||
| const set$1 = typeof fn === "function" ? void 0 : fn.set; | ||
| const result = customRef((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| if (dirty) { | ||
| v = get$1(v); | ||
| dirty = false; | ||
| } | ||
| track(); | ||
| return v; | ||
| }, | ||
| set(v$1) { | ||
| set$1 === null || set$1 === void 0 || set$1(v$1); | ||
| } | ||
| }; | ||
| }); | ||
| result.trigger = update; | ||
| return result; | ||
| } | ||
| //#endregion | ||
| //#region tryOnScopeDispose/index.ts | ||
| /** | ||
| * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| */ | ||
| function tryOnScopeDispose(fn) { | ||
| if (getCurrentScope()) { | ||
| onScopeDispose(fn); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| //#endregion | ||
| //#region createEventHook/index.ts | ||
| /** | ||
| * Utility for creating event hooks | ||
| * | ||
| * @see https://vueuse.org/createEventHook | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createEventHook() { | ||
| const fns = /* @__PURE__ */ new Set(); | ||
| const off = (fn) => { | ||
| fns.delete(fn); | ||
| }; | ||
| const clear = () => { | ||
| fns.clear(); | ||
| }; | ||
| const on = (fn) => { | ||
| fns.add(fn); | ||
| const offFn = () => off(fn); | ||
| tryOnScopeDispose(offFn); | ||
| return { off: offFn }; | ||
| }; | ||
| const trigger = (...args) => { | ||
| return Promise.all(Array.from(fns).map((fn) => fn(...args))); | ||
| }; | ||
| return { | ||
| on, | ||
| off, | ||
| trigger, | ||
| clear | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region createGlobalState/index.ts | ||
| /** | ||
| * Keep states in the global scope to be reusable across Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createGlobalState | ||
| * @param stateFactory A factory function to create the state | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createGlobalState(stateFactory) { | ||
| let initialized = false; | ||
| let state; | ||
| const scope = effectScope(true); | ||
| return ((...args) => { | ||
| if (!initialized) { | ||
| state = scope.run(() => stateFactory(...args)); | ||
| initialized = true; | ||
| } | ||
| return state; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region provideLocal/map.ts | ||
| const localProvidedStateMap = /* @__PURE__ */ new WeakMap(); | ||
| //#endregion | ||
| //#region injectLocal/index.ts | ||
| /** | ||
| * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * injectLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| const injectLocal = (...args) => { | ||
| var _getCurrentInstance; | ||
| const key = args[0]; | ||
| const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy; | ||
| if (instance == null && !hasInjectionContext()) throw new Error("injectLocal must be called in setup"); | ||
| if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance)) return localProvidedStateMap.get(instance)[key]; | ||
| return inject(...args); | ||
| }; | ||
| //#endregion | ||
| //#region provideLocal/index.ts | ||
| /** | ||
| * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * provideLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| */ | ||
| function provideLocal(key, value) { | ||
| var _getCurrentInstance; | ||
| const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy; | ||
| if (instance == null) throw new Error("provideLocal must be called in setup"); | ||
| if (!localProvidedStateMap.has(instance)) localProvidedStateMap.set(instance, Object.create(null)); | ||
| const localProvidedState = localProvidedStateMap.get(instance); | ||
| localProvidedState[key] = value; | ||
| return provide(key, value); | ||
| } | ||
| //#endregion | ||
| //#region createInjectionState/index.ts | ||
| /** | ||
| * Create global state that can be injected into components. | ||
| * | ||
| * @see https://vueuse.org/createInjectionState | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createInjectionState(composable, options) { | ||
| const key = (options === null || options === void 0 ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState"); | ||
| const defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue; | ||
| const useProvidingState = (...args) => { | ||
| const state = composable(...args); | ||
| provideLocal(key, state); | ||
| return state; | ||
| }; | ||
| const useInjectedState = () => injectLocal(key, defaultValue); | ||
| return [useProvidingState, useInjectedState]; | ||
| } | ||
| //#endregion | ||
| //#region createRef/index.ts | ||
| /** | ||
| * Returns a `deepRef` or `shallowRef` depending on the `deep` param. | ||
| * | ||
| * @example createRef(1) // ShallowRef<number> | ||
| * @example createRef(1, false) // ShallowRef<number> | ||
| * @example createRef(1, true) // Ref<number> | ||
| * @example createRef("string") // ShallowRef<string> | ||
| * @example createRef<"A"|"B">("A", true) // Ref<"A"|"B"> | ||
| * | ||
| * @param value | ||
| * @param deep | ||
| * @returns the `deepRef` or `shallowRef` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createRef(value, deep) { | ||
| if (deep === true) return ref(value); | ||
| else return shallowRef(value); | ||
| } | ||
| //#endregion | ||
| //#region createSharedComposable/index.ts | ||
| /** | ||
| * Make a composable function usable with multiple Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createSharedComposable | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function createSharedComposable(composable) { | ||
| let subscribers = 0; | ||
| let state; | ||
| let scope; | ||
| const dispose = () => { | ||
| subscribers -= 1; | ||
| if (scope && subscribers <= 0) { | ||
| scope.stop(); | ||
| state = void 0; | ||
| scope = void 0; | ||
| } | ||
| }; | ||
| return ((...args) => { | ||
| subscribers += 1; | ||
| if (!scope) { | ||
| scope = effectScope(true); | ||
| state = scope.run(() => composable(...args)); | ||
| } | ||
| tryOnScopeDispose(dispose); | ||
| return state; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region extendRef/index.ts | ||
| function extendRef(ref$1, extend, { enumerable = false, unwrap = true } = {}) { | ||
| for (const [key, value] of Object.entries(extend)) { | ||
| if (key === "value") continue; | ||
| if (isRef(value) && unwrap) Object.defineProperty(ref$1, key, { | ||
| get() { | ||
| return value.value; | ||
| }, | ||
| set(v) { | ||
| value.value = v; | ||
| }, | ||
| enumerable | ||
| }); | ||
| else Object.defineProperty(ref$1, key, { | ||
| value, | ||
| enumerable | ||
| }); | ||
| } | ||
| return ref$1; | ||
| } | ||
| //#endregion | ||
| //#region get/index.ts | ||
| function get(obj, key) { | ||
| if (key == null) return unref(obj); | ||
| return unref(obj)[key]; | ||
| } | ||
| //#endregion | ||
| //#region isDefined/index.ts | ||
| function isDefined(v) { | ||
| return unref(v) != null; | ||
| } | ||
| //#endregion | ||
| //#region makeDestructurable/index.ts | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function makeDestructurable(obj, arr) { | ||
| if (typeof Symbol !== "undefined") { | ||
| const clone = { ...obj }; | ||
| Object.defineProperty(clone, Symbol.iterator, { | ||
| enumerable: false, | ||
| value() { | ||
| let index = 0; | ||
| return { next: () => ({ | ||
| value: arr[index++], | ||
| done: index > arr.length | ||
| }) }; | ||
| } | ||
| }); | ||
| return clone; | ||
| } else return Object.assign([...arr], obj); | ||
| } | ||
| //#endregion | ||
| //#region reactify/index.ts | ||
| /** | ||
| * Converts plain function into a reactive function. | ||
| * The converted function accepts refs as it's arguments | ||
| * and returns a ComputedRef, with proper typing. | ||
| * | ||
| * @param fn - Source function | ||
| * @param options - Options | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function reactify(fn, options) { | ||
| const unrefFn = (options === null || options === void 0 ? void 0 : options.computedGetter) === false ? unref : toValue$1; | ||
| return function(...args) { | ||
| return computed(() => fn.apply(this, args.map((i) => unrefFn(i)))); | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region reactifyObject/index.ts | ||
| /** | ||
| * Apply `reactify` to an object | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function reactifyObject(obj, optionsOrKeys = {}) { | ||
| let keys = []; | ||
| let options; | ||
| if (Array.isArray(optionsOrKeys)) keys = optionsOrKeys; | ||
| else { | ||
| options = optionsOrKeys; | ||
| const { includeOwnProperties = true } = optionsOrKeys; | ||
| keys.push(...Object.keys(obj)); | ||
| if (includeOwnProperties) keys.push(...Object.getOwnPropertyNames(obj)); | ||
| } | ||
| return Object.fromEntries(keys.map((key) => { | ||
| const value = obj[key]; | ||
| return [key, typeof value === "function" ? reactify(value.bind(obj), options) : value]; | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region toReactive/index.ts | ||
| /** | ||
| * Converts ref to reactive. | ||
| * | ||
| * @see https://vueuse.org/toReactive | ||
| * @param objectRef A ref of object | ||
| */ | ||
| function toReactive(objectRef) { | ||
| if (!isRef(objectRef)) return reactive(objectRef); | ||
| const proxy = new Proxy({}, { | ||
| get(_, p, receiver) { | ||
| return unref(Reflect.get(objectRef.value, p, receiver)); | ||
| }, | ||
| set(_, p, value) { | ||
| if (isRef(objectRef.value[p]) && !isRef(value)) objectRef.value[p].value = value; | ||
| else objectRef.value[p] = value; | ||
| return true; | ||
| }, | ||
| deleteProperty(_, p) { | ||
| return Reflect.deleteProperty(objectRef.value, p); | ||
| }, | ||
| has(_, p) { | ||
| return Reflect.has(objectRef.value, p); | ||
| }, | ||
| ownKeys() { | ||
| return Object.keys(objectRef.value); | ||
| }, | ||
| getOwnPropertyDescriptor() { | ||
| return { | ||
| enumerable: true, | ||
| configurable: true | ||
| }; | ||
| } | ||
| }); | ||
| return reactive(proxy); | ||
| } | ||
| //#endregion | ||
| //#region reactiveComputed/index.ts | ||
| /** | ||
| * Computed reactive object. | ||
| */ | ||
| function reactiveComputed(fn) { | ||
| return toReactive(computed(fn)); | ||
| } | ||
| //#endregion | ||
| //#region reactiveOmit/index.ts | ||
| /** | ||
| * Reactively omit fields from a reactive object | ||
| * | ||
| * @see https://vueuse.org/reactiveOmit | ||
| */ | ||
| function reactiveOmit(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => !predicate(toValue$1(v), k))) : Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0])))); | ||
| } | ||
| //#endregion | ||
| //#region utils/is.ts | ||
| const isClient = typeof window !== "undefined" && typeof document !== "undefined"; | ||
| const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; | ||
| const isDef = (val) => typeof val !== "undefined"; | ||
| const notNullish = (val) => val != null; | ||
| const assert = (condition, ...infos) => { | ||
| if (!condition) console.warn(...infos); | ||
| }; | ||
| const toString = Object.prototype.toString; | ||
| const isObject = (val) => toString.call(val) === "[object Object]"; | ||
| const now = () => Date.now(); | ||
| const timestamp = () => +Date.now(); | ||
| const clamp = (n, min, max) => Math.min(max, Math.max(min, n)); | ||
| const noop = () => {}; | ||
| const rand = (min, max) => { | ||
| min = Math.ceil(min); | ||
| max = Math.floor(max); | ||
| return Math.floor(Math.random() * (max - min + 1)) + min; | ||
| }; | ||
| const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key); | ||
| const isIOS = /* @__PURE__ */ getIsIOS(); | ||
| function getIsIOS() { | ||
| var _window, _window2, _window3; | ||
| return isClient && ((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent)); | ||
| } | ||
| //#endregion | ||
| //#region toRef/index.ts | ||
| function toRef(...args) { | ||
| if (args.length !== 1) return toRef$1(...args); | ||
| const r = args[0]; | ||
| return typeof r === "function" ? readonly(customRef(() => ({ | ||
| get: r, | ||
| set: noop | ||
| }))) : ref(r); | ||
| } | ||
| /** | ||
| * @deprecated use `toRef` instead | ||
| */ | ||
| const resolveRef = toRef; | ||
| //#endregion | ||
| //#region reactivePick/index.ts | ||
| /** | ||
| * Reactively pick fields from a reactive object | ||
| * | ||
| * @see https://vueuse.org/reactivePick | ||
| */ | ||
| function reactivePick(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => predicate(toValue$1(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)]))); | ||
| } | ||
| //#endregion | ||
| //#region refAutoReset/index.ts | ||
| /** | ||
| * Create a ref which will be reset to the default value after some time. | ||
| * | ||
| * @see https://vueuse.org/refAutoReset | ||
| * @param defaultValue The value which will be set. | ||
| * @param afterMs A zero-or-greater delay in milliseconds. | ||
| */ | ||
| function refAutoReset(defaultValue, afterMs = 1e4) { | ||
| return customRef((track, trigger) => { | ||
| let value = toValue$1(defaultValue); | ||
| let timer; | ||
| const resetAfter = () => setTimeout(() => { | ||
| value = toValue$1(defaultValue); | ||
| trigger(); | ||
| }, toValue$1(afterMs)); | ||
| tryOnScopeDispose(() => { | ||
| clearTimeout(timer); | ||
| }); | ||
| return { | ||
| get() { | ||
| track(); | ||
| return value; | ||
| }, | ||
| set(newValue) { | ||
| value = newValue; | ||
| trigger(); | ||
| clearTimeout(timer); | ||
| timer = resetAfter(); | ||
| } | ||
| }; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region utils/filters.ts | ||
| /** | ||
| * @internal | ||
| */ | ||
| function createFilterWrapper(filter, fn) { | ||
| function wrapper(...args) { | ||
| return new Promise((resolve, reject) => { | ||
| Promise.resolve(filter(() => fn.apply(this, args), { | ||
| fn, | ||
| thisArg: this, | ||
| args | ||
| })).then(resolve).catch(reject); | ||
| }); | ||
| } | ||
| return wrapper; | ||
| } | ||
| const bypassFilter = (invoke$1) => { | ||
| return invoke$1(); | ||
| }; | ||
| /** | ||
| * Create an EventFilter that debounce the events | ||
| */ | ||
| function debounceFilter(ms, options = {}) { | ||
| let timer; | ||
| let maxTimer; | ||
| let lastRejector = noop; | ||
| const _clearTimeout = (timer$1) => { | ||
| clearTimeout(timer$1); | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| }; | ||
| let lastInvoker; | ||
| const filter = (invoke$1) => { | ||
| const duration = toValue$1(ms); | ||
| const maxDuration = toValue$1(options.maxWait); | ||
| if (timer) _clearTimeout(timer); | ||
| if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) { | ||
| if (maxTimer) { | ||
| _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| } | ||
| return Promise.resolve(invoke$1()); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| lastRejector = options.rejectOnCancel ? reject : resolve; | ||
| lastInvoker = invoke$1; | ||
| if (maxDuration && !maxTimer) maxTimer = setTimeout(() => { | ||
| if (timer) _clearTimeout(timer); | ||
| maxTimer = void 0; | ||
| resolve(lastInvoker()); | ||
| }, maxDuration); | ||
| timer = setTimeout(() => { | ||
| if (maxTimer) _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| resolve(invoke$1()); | ||
| }, duration); | ||
| }); | ||
| }; | ||
| return filter; | ||
| } | ||
| function throttleFilter(...args) { | ||
| let lastExec = 0; | ||
| let timer; | ||
| let isLeading = true; | ||
| let lastRejector = noop; | ||
| let lastValue; | ||
| let ms; | ||
| let trailing; | ||
| let leading; | ||
| let rejectOnCancel; | ||
| if (!isRef(args[0]) && typeof args[0] === "object") ({delay: ms, trailing = true, leading = true, rejectOnCancel = false} = args[0]); | ||
| else [ms, trailing = true, leading = true, rejectOnCancel = false] = args; | ||
| const clear = () => { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| } | ||
| }; | ||
| const filter = (_invoke) => { | ||
| const duration = toValue$1(ms); | ||
| const elapsed = Date.now() - lastExec; | ||
| const invoke$1 = () => { | ||
| return lastValue = _invoke(); | ||
| }; | ||
| clear(); | ||
| if (duration <= 0) { | ||
| lastExec = Date.now(); | ||
| return invoke$1(); | ||
| } | ||
| if (elapsed > duration) { | ||
| lastExec = Date.now(); | ||
| if (leading || !isLeading) invoke$1(); | ||
| } else if (trailing) lastValue = new Promise((resolve, reject) => { | ||
| lastRejector = rejectOnCancel ? reject : resolve; | ||
| timer = setTimeout(() => { | ||
| lastExec = Date.now(); | ||
| isLeading = true; | ||
| resolve(invoke$1()); | ||
| clear(); | ||
| }, Math.max(0, duration - elapsed)); | ||
| }); | ||
| if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration); | ||
| isLeading = false; | ||
| return lastValue; | ||
| }; | ||
| return filter; | ||
| } | ||
| /** | ||
| * EventFilter that gives extra controls to pause and resume the filter | ||
| * | ||
| * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none | ||
| * @param options Options to configure the filter | ||
| */ | ||
| function pausableFilter(extendFilter = bypassFilter, options = {}) { | ||
| const { initialState = "active" } = options; | ||
| const isActive = toRef(initialState === "active"); | ||
| function pause() { | ||
| isActive.value = false; | ||
| } | ||
| function resume() { | ||
| isActive.value = true; | ||
| } | ||
| const eventFilter = (...args) => { | ||
| if (isActive.value) extendFilter(...args); | ||
| }; | ||
| return { | ||
| isActive: readonly(isActive), | ||
| pause, | ||
| resume, | ||
| eventFilter | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region utils/general.ts | ||
| function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") { | ||
| return new Promise((resolve, reject) => { | ||
| if (throwOnTimeout) setTimeout(() => reject(reason), ms); | ||
| else setTimeout(resolve, ms); | ||
| }); | ||
| } | ||
| function identity(arg) { | ||
| return arg; | ||
| } | ||
| /** | ||
| * Create singleton promise function | ||
| * | ||
| * @example | ||
| * ``` | ||
| * const promise = createSingletonPromise(async () => { ... }) | ||
| * | ||
| * await promise() | ||
| * await promise() // all of them will be bind to a single promise instance | ||
| * await promise() // and be resolved together | ||
| * ``` | ||
| */ | ||
| function createSingletonPromise(fn) { | ||
| let _promise; | ||
| function wrapper() { | ||
| if (!_promise) _promise = fn(); | ||
| return _promise; | ||
| } | ||
| wrapper.reset = async () => { | ||
| const _prev = _promise; | ||
| _promise = void 0; | ||
| if (_prev) await _prev; | ||
| }; | ||
| return wrapper; | ||
| } | ||
| function invoke(fn) { | ||
| return fn(); | ||
| } | ||
| function containsProp(obj, ...props) { | ||
| return props.some((k) => k in obj); | ||
| } | ||
| function increaseWithUnit(target, delta) { | ||
| var _target$match; | ||
| if (typeof target === "number") return target + delta; | ||
| const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || ""; | ||
| const unit = target.slice(value.length); | ||
| const result = Number.parseFloat(value) + delta; | ||
| if (Number.isNaN(result)) return target; | ||
| return result + unit; | ||
| } | ||
| /** | ||
| * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client | ||
| */ | ||
| function pxValue(px) { | ||
| return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px); | ||
| } | ||
| /** | ||
| * Create a new subset object by giving keys | ||
| */ | ||
| function objectPick(obj, keys, omitUndefined = false) { | ||
| return keys.reduce((n, k) => { | ||
| if (k in obj) { | ||
| if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k]; | ||
| } | ||
| return n; | ||
| }, {}); | ||
| } | ||
| /** | ||
| * Create a new subset object by omit giving keys | ||
| */ | ||
| function objectOmit(obj, keys, omitUndefined = false) { | ||
| return Object.fromEntries(Object.entries(obj).filter(([key, value]) => { | ||
| return (!omitUndefined || value !== void 0) && !keys.includes(key); | ||
| })); | ||
| } | ||
| function objectEntries(obj) { | ||
| return Object.entries(obj); | ||
| } | ||
| function toArray(value) { | ||
| return Array.isArray(value) ? value : [value]; | ||
| } | ||
| //#endregion | ||
| //#region utils/port.ts | ||
| function cacheStringFunction(fn) { | ||
| const cache = Object.create(null); | ||
| return ((str) => { | ||
| const hit = cache[str]; | ||
| return hit || (cache[str] = fn(str)); | ||
| }); | ||
| } | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); | ||
| const camelizeRE = /-(\w)/g; | ||
| const camelize = cacheStringFunction((str) => { | ||
| return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
| }); | ||
| //#endregion | ||
| //#region utils/vue.ts | ||
| function getLifeCycleTarget(target) { | ||
| return target || getCurrentInstance(); | ||
| } | ||
| //#endregion | ||
| //#region useDebounceFn/index.ts | ||
| /** | ||
| * Debounce execution of a function. | ||
| * | ||
| * @see https://vueuse.org/useDebounceFn | ||
| * @param fn A function to be executed after delay milliseconds debounced. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param options Options | ||
| * | ||
| * @return A new, debounce, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useDebounceFn(fn, ms = 200, options = {}) { | ||
| return createFilterWrapper(debounceFilter(ms, options), fn); | ||
| } | ||
| //#endregion | ||
| //#region refDebounced/index.ts | ||
| /** | ||
| * Debounce updates of a ref. | ||
| * | ||
| * @return A new debounced ref. | ||
| */ | ||
| function refDebounced(value, ms = 200, options = {}) { | ||
| const debounced = ref(toValue$1(value)); | ||
| const updater = useDebounceFn(() => { | ||
| debounced.value = value.value; | ||
| }, ms, options); | ||
| watch(value, () => updater()); | ||
| return shallowReadonly(debounced); | ||
| } | ||
| //#endregion | ||
| //#region refDefault/index.ts | ||
| /** | ||
| * Apply default value to a ref. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function refDefault(source, defaultValue) { | ||
| return computed({ | ||
| get() { | ||
| var _source$value; | ||
| return (_source$value = source.value) !== null && _source$value !== void 0 ? _source$value : defaultValue; | ||
| }, | ||
| set(value) { | ||
| source.value = value; | ||
| } | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useThrottleFn/index.ts | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is, | ||
| * to `callback` when the throttled-function is executed. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * (default value: 200) | ||
| * | ||
| * @param [trailing] if true, call fn again after the time is up (default value: false) | ||
| * | ||
| * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true) | ||
| * | ||
| * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false) | ||
| * | ||
| * @return A new, throttled, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) { | ||
| return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn); | ||
| } | ||
| //#endregion | ||
| //#region refThrottled/index.ts | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param value Ref value to be watched with throttle effect | ||
| * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param trailing if true, update the value again after the delay time is up | ||
| * @param leading if true, update the value on the leading edge of the ms timeout | ||
| */ | ||
| function refThrottled(value, delay = 200, trailing = true, leading = true) { | ||
| if (delay <= 0) return value; | ||
| const throttled = ref(toValue$1(value)); | ||
| const updater = useThrottleFn(() => { | ||
| throttled.value = value.value; | ||
| }, delay, trailing, leading); | ||
| watch(value, () => updater()); | ||
| return throttled; | ||
| } | ||
| //#endregion | ||
| //#region refWithControl/index.ts | ||
| /** | ||
| * Fine-grained controls over ref and its reactivity. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function refWithControl(initial, options = {}) { | ||
| let source = initial; | ||
| let track; | ||
| let trigger; | ||
| const ref$1 = customRef((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| return get$1(); | ||
| }, | ||
| set(v) { | ||
| set$1(v); | ||
| } | ||
| }; | ||
| }); | ||
| function get$1(tracking = true) { | ||
| if (tracking) track(); | ||
| return source; | ||
| } | ||
| function set$1(value, triggering = true) { | ||
| var _options$onBeforeChan, _options$onChanged; | ||
| if (value === source) return; | ||
| const old = source; | ||
| if (((_options$onBeforeChan = options.onBeforeChange) === null || _options$onBeforeChan === void 0 ? void 0 : _options$onBeforeChan.call(options, value, old)) === false) return; | ||
| source = value; | ||
| (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, value, old); | ||
| if (triggering) trigger(); | ||
| } | ||
| /** | ||
| * Get the value without tracked in the reactivity system | ||
| */ | ||
| const untrackedGet = () => get$1(false); | ||
| /** | ||
| * Set the value without triggering the reactivity system | ||
| */ | ||
| const silentSet = (v) => set$1(v, false); | ||
| /** | ||
| * Get the value without tracked in the reactivity system. | ||
| * | ||
| * Alias for `untrackedGet()` | ||
| */ | ||
| const peek = () => get$1(false); | ||
| /** | ||
| * Set the value without triggering the reactivity system | ||
| * | ||
| * Alias for `silentSet(v)` | ||
| */ | ||
| const lay = (v) => set$1(v, false); | ||
| return extendRef(ref$1, { | ||
| get: get$1, | ||
| set: set$1, | ||
| untrackedGet, | ||
| silentSet, | ||
| peek, | ||
| lay | ||
| }, { enumerable: true }); | ||
| } | ||
| /** | ||
| * Alias for `refWithControl` | ||
| */ | ||
| const controlledRef = refWithControl; | ||
| //#endregion | ||
| //#region set/index.ts | ||
| /** | ||
| * Shorthand for `ref.value = x` | ||
| */ | ||
| function set(...args) { | ||
| if (args.length === 2) { | ||
| const [ref$1, value] = args; | ||
| ref$1.value = value; | ||
| } | ||
| if (args.length === 3) { | ||
| const [target, key, value] = args; | ||
| target[key] = value; | ||
| } | ||
| } | ||
| //#endregion | ||
| //#region watchWithFilter/index.ts | ||
| function watchWithFilter(source, cb, options = {}) { | ||
| const { eventFilter = bypassFilter,...watchOptions } = options; | ||
| return watch(source, createFilterWrapper(eventFilter, cb), watchOptions); | ||
| } | ||
| //#endregion | ||
| //#region watchPausable/index.ts | ||
| function watchPausable(source, cb, options = {}) { | ||
| const { eventFilter: filter, initialState = "active",...watchOptions } = options; | ||
| const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState }); | ||
| const stop = watchWithFilter(source, cb, { | ||
| ...watchOptions, | ||
| eventFilter | ||
| }); | ||
| return { | ||
| stop, | ||
| pause, | ||
| resume, | ||
| isActive | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region syncRef/index.ts | ||
| /** | ||
| * Two-way refs synchronization. | ||
| * From the set theory perspective to restrict the option's type | ||
| * Check in the following order: | ||
| * 1. L = R | ||
| * 2. L ∩ R ≠ ∅ | ||
| * 3. L ⊆ R | ||
| * 4. L ∩ R = ∅ | ||
| */ | ||
| function syncRef(left, right, ...[options]) { | ||
| const { flush = "sync", deep = false, immediate = true, direction = "both", transform = {} } = options || {}; | ||
| const watchers = []; | ||
| const transformLTR = "ltr" in transform && transform.ltr || ((v) => v); | ||
| const transformRTL = "rtl" in transform && transform.rtl || ((v) => v); | ||
| if (direction === "both" || direction === "ltr") watchers.push(watchPausable(left, (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| right.value = transformLTR(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate | ||
| })); | ||
| if (direction === "both" || direction === "rtl") watchers.push(watchPausable(right, (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| left.value = transformRTL(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate | ||
| })); | ||
| const stop = () => { | ||
| watchers.forEach((w) => w.stop()); | ||
| }; | ||
| return stop; | ||
| } | ||
| //#endregion | ||
| //#region syncRefs/index.ts | ||
| /** | ||
| * Keep target ref(s) in sync with the source ref | ||
| * | ||
| * @param source source ref | ||
| * @param targets | ||
| */ | ||
| function syncRefs(source, targets, options = {}) { | ||
| const { flush = "sync", deep = false, immediate = true } = options; | ||
| const targetsArray = toArray(targets); | ||
| return watch(source, (newValue) => targetsArray.forEach((target) => target.value = newValue), { | ||
| flush, | ||
| deep, | ||
| immediate | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region toRefs/index.ts | ||
| /** | ||
| * Extended `toRefs` that also accepts refs of an object. | ||
| * | ||
| * @see https://vueuse.org/toRefs | ||
| * @param objectRef A ref or normal object or array. | ||
| * @param options Options | ||
| */ | ||
| function toRefs(objectRef, options = {}) { | ||
| if (!isRef(objectRef)) return toRefs$1(objectRef); | ||
| const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {}; | ||
| for (const key in objectRef.value) result[key] = customRef(() => ({ | ||
| get() { | ||
| return objectRef.value[key]; | ||
| }, | ||
| set(v) { | ||
| var _toValue; | ||
| const replaceRef = (_toValue = toValue$1(options.replaceRef)) !== null && _toValue !== void 0 ? _toValue : true; | ||
| if (replaceRef) if (Array.isArray(objectRef.value)) { | ||
| const copy = [...objectRef.value]; | ||
| copy[key] = v; | ||
| objectRef.value = copy; | ||
| } else { | ||
| const newObject = { | ||
| ...objectRef.value, | ||
| [key]: v | ||
| }; | ||
| Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value)); | ||
| objectRef.value = newObject; | ||
| } | ||
| else objectRef.value[key] = v; | ||
| } | ||
| })); | ||
| return result; | ||
| } | ||
| //#endregion | ||
| //#region toValue/index.ts | ||
| /** | ||
| * Get the value of value/ref/getter. | ||
| * | ||
| * @deprecated use `toValue` from `vue` instead | ||
| */ | ||
| const toValue = toValue$1; | ||
| /** | ||
| * @deprecated use `toValue` instead | ||
| */ | ||
| const resolveUnref = toValue$1; | ||
| //#endregion | ||
| //#region tryOnBeforeMount/index.ts | ||
| /** | ||
| * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| function tryOnBeforeMount(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) onBeforeMount(fn, target); | ||
| else if (sync) fn(); | ||
| else nextTick(fn); | ||
| } | ||
| //#endregion | ||
| //#region tryOnBeforeUnmount/index.ts | ||
| /** | ||
| * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| function tryOnBeforeUnmount(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) onBeforeUnmount(fn, target); | ||
| } | ||
| //#endregion | ||
| //#region tryOnMounted/index.ts | ||
| /** | ||
| * Call onMounted() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| function tryOnMounted(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) onMounted(fn, target); | ||
| else if (sync) fn(); | ||
| else nextTick(fn); | ||
| } | ||
| //#endregion | ||
| //#region tryOnUnmounted/index.ts | ||
| /** | ||
| * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| function tryOnUnmounted(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) onUnmounted(fn, target); | ||
| } | ||
| //#endregion | ||
| //#region until/index.ts | ||
| function createUntil(r, isNot = false) { | ||
| function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) { | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = watch(r, (v) => { | ||
| if (condition(v) !== isNot) { | ||
| if (stop) stop(); | ||
| else nextTick(() => stop === null || stop === void 0 ? void 0 : stop()); | ||
| resolve(v); | ||
| } | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| }); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => stop === null || stop === void 0 ? void 0 : stop())); | ||
| return Promise.race(promises); | ||
| } | ||
| function toBe(value, options) { | ||
| if (!isRef(value)) return toMatch((v) => v === value, options); | ||
| const { flush = "sync", deep = false, timeout, throwOnTimeout } = options !== null && options !== void 0 ? options : {}; | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = watch([r, value], ([v1, v2]) => { | ||
| if (isNot !== (v1 === v2)) { | ||
| if (stop) stop(); | ||
| else nextTick(() => stop === null || stop === void 0 ? void 0 : stop()); | ||
| resolve(v1); | ||
| } | ||
| }, { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| }); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => { | ||
| stop === null || stop === void 0 || stop(); | ||
| return toValue$1(r); | ||
| })); | ||
| return Promise.race(promises); | ||
| } | ||
| function toBeTruthy(options) { | ||
| return toMatch((v) => Boolean(v), options); | ||
| } | ||
| function toBeNull(options) { | ||
| return toBe(null, options); | ||
| } | ||
| function toBeUndefined(options) { | ||
| return toBe(void 0, options); | ||
| } | ||
| function toBeNaN(options) { | ||
| return toMatch(Number.isNaN, options); | ||
| } | ||
| function toContains(value, options) { | ||
| return toMatch((v) => { | ||
| const array = Array.from(v); | ||
| return array.includes(value) || array.includes(toValue$1(value)); | ||
| }, options); | ||
| } | ||
| function changed(options) { | ||
| return changedTimes(1, options); | ||
| } | ||
| function changedTimes(n = 1, options) { | ||
| let count = -1; | ||
| return toMatch(() => { | ||
| count += 1; | ||
| return count >= n; | ||
| }, options); | ||
| } | ||
| if (Array.isArray(toValue$1(r))) { | ||
| const instance = { | ||
| toMatch, | ||
| toContains, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } else { | ||
| const instance = { | ||
| toMatch, | ||
| toBe, | ||
| toBeTruthy, | ||
| toBeNull, | ||
| toBeNaN, | ||
| toBeUndefined, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } | ||
| } | ||
| function until(r) { | ||
| return createUntil(r); | ||
| } | ||
| //#endregion | ||
| //#region useArrayDifference/index.ts | ||
| function defaultComparator(value, othVal) { | ||
| return value === othVal; | ||
| } | ||
| /** | ||
| * Reactive get array difference of two array | ||
| * @see https://vueuse.org/useArrayDifference | ||
| * @returns - the difference of two array | ||
| * @param args | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayDifference(...args) { | ||
| var _args$, _args$2; | ||
| const list = args[0]; | ||
| const values = args[1]; | ||
| let compareFn = (_args$ = args[2]) !== null && _args$ !== void 0 ? _args$ : defaultComparator; | ||
| const { symmetric = false } = (_args$2 = args[3]) !== null && _args$2 !== void 0 ? _args$2 : {}; | ||
| if (typeof compareFn === "string") { | ||
| const key = compareFn; | ||
| compareFn = (value, othVal) => value[key] === othVal[key]; | ||
| } | ||
| const diff1 = computed(() => toValue$1(list).filter((x) => toValue$1(values).findIndex((y) => compareFn(x, y)) === -1)); | ||
| if (symmetric) { | ||
| const diff2 = computed(() => toValue$1(values).filter((x) => toValue$1(list).findIndex((y) => compareFn(x, y)) === -1)); | ||
| return computed(() => symmetric ? [...toValue$1(diff1), ...toValue$1(diff2)] : toValue$1(diff1)); | ||
| } else return diff1; | ||
| } | ||
| //#endregion | ||
| //#region useArrayEvery/index.ts | ||
| /** | ||
| * Reactive `Array.every` | ||
| * | ||
| * @see https://vueuse.org/useArrayEvery | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayEvery(list, fn) { | ||
| return computed(() => toValue$1(list).every((element, index, array) => fn(toValue$1(element), index, array))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFilter/index.ts | ||
| /** | ||
| * Reactive `Array.filter` | ||
| * | ||
| * @see https://vueuse.org/useArrayFilter | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFilter(list, fn) { | ||
| return computed(() => toValue$1(list).map((i) => toValue$1(i)).filter(fn)); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFind/index.ts | ||
| /** | ||
| * Reactive `Array.find` | ||
| * | ||
| * @see https://vueuse.org/useArrayFind | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFind(list, fn) { | ||
| return computed(() => toValue$1(toValue$1(list).find((element, index, array) => fn(toValue$1(element), index, array)))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFindIndex/index.ts | ||
| /** | ||
| * Reactive `Array.findIndex` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindIndex | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the index of the first element in the array that passes the test. Otherwise, "-1". | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFindIndex(list, fn) { | ||
| return computed(() => toValue$1(list).findIndex((element, index, array) => fn(toValue$1(element), index, array))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayFindLast/index.ts | ||
| function findLast(arr, cb) { | ||
| let index = arr.length; | ||
| while (index-- > 0) if (cb(arr[index], index, arr)) return arr[index]; | ||
| return void 0; | ||
| } | ||
| /** | ||
| * Reactive `Array.findLast` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindLast | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayFindLast(list, fn) { | ||
| return computed(() => toValue$1(!Array.prototype.findLast ? findLast(toValue$1(list), (element, index, array) => fn(toValue$1(element), index, array)) : toValue$1(list).findLast((element, index, array) => fn(toValue$1(element), index, array)))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayIncludes/index.ts | ||
| function isArrayIncludesOptions(obj) { | ||
| return isObject(obj) && containsProp(obj, "formIndex", "comparator"); | ||
| } | ||
| /** | ||
| * Reactive `Array.includes` | ||
| * | ||
| * @see https://vueuse.org/useArrayIncludes | ||
| * | ||
| * @returns true if the `value` is found in the array. Otherwise, false. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayIncludes(...args) { | ||
| var _comparator; | ||
| const list = args[0]; | ||
| const value = args[1]; | ||
| let comparator = args[2]; | ||
| let formIndex = 0; | ||
| if (isArrayIncludesOptions(comparator)) { | ||
| var _comparator$fromIndex; | ||
| formIndex = (_comparator$fromIndex = comparator.fromIndex) !== null && _comparator$fromIndex !== void 0 ? _comparator$fromIndex : 0; | ||
| comparator = comparator.comparator; | ||
| } | ||
| if (typeof comparator === "string") { | ||
| const key = comparator; | ||
| comparator = (element, value$1) => element[key] === toValue$1(value$1); | ||
| } | ||
| comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value$1) => element === toValue$1(value$1)); | ||
| return computed(() => toValue$1(list).slice(formIndex).some((element, index, array) => comparator(toValue$1(element), toValue$1(value), index, toValue$1(array)))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayJoin/index.ts | ||
| /** | ||
| * Reactive `Array.join` | ||
| * | ||
| * @see https://vueuse.org/useArrayJoin | ||
| * @param list - the array was called upon. | ||
| * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (","). | ||
| * | ||
| * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayJoin(list, separator) { | ||
| return computed(() => toValue$1(list).map((i) => toValue$1(i)).join(toValue$1(separator))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayMap/index.ts | ||
| /** | ||
| * Reactive `Array.map` | ||
| * | ||
| * @see https://vueuse.org/useArrayMap | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a new array with each element being the result of the callback function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayMap(list, fn) { | ||
| return computed(() => toValue$1(list).map((i) => toValue$1(i)).map(fn)); | ||
| } | ||
| //#endregion | ||
| //#region useArrayReduce/index.ts | ||
| /** | ||
| * Reactive `Array.reduce` | ||
| * | ||
| * @see https://vueuse.org/useArrayReduce | ||
| * @param list - the array was called upon. | ||
| * @param reducer - a "reducer" function. | ||
| * @param args | ||
| * | ||
| * @returns the value that results from running the "reducer" callback function to completion over the entire array. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayReduce(list, reducer, ...args) { | ||
| const reduceCallback = (sum, value, index) => reducer(toValue$1(sum), toValue$1(value), index); | ||
| return computed(() => { | ||
| const resolved = toValue$1(list); | ||
| return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue$1(args[0]()) : toValue$1(args[0])) : resolved.reduce(reduceCallback); | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useArraySome/index.ts | ||
| /** | ||
| * Reactive `Array.some` | ||
| * | ||
| * @see https://vueuse.org/useArraySome | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArraySome(list, fn) { | ||
| return computed(() => toValue$1(list).some((element, index, array) => fn(toValue$1(element), index, array))); | ||
| } | ||
| //#endregion | ||
| //#region useArrayUnique/index.ts | ||
| function uniq(array) { | ||
| return Array.from(new Set(array)); | ||
| } | ||
| function uniqueElementsBy(array, fn) { | ||
| return array.reduce((acc, v) => { | ||
| if (!acc.some((x) => fn(v, x, array))) acc.push(v); | ||
| return acc; | ||
| }, []); | ||
| } | ||
| /** | ||
| * reactive unique array | ||
| * @see https://vueuse.org/useArrayUnique | ||
| * @param list - the array was called upon. | ||
| * @param compareFn | ||
| * @returns A computed ref that returns a unique array of items. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useArrayUnique(list, compareFn) { | ||
| return computed(() => { | ||
| const resolvedList = toValue$1(list).map((element) => toValue$1(element)); | ||
| return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList); | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useCounter/index.ts | ||
| /** | ||
| * Basic counter with utility functions. | ||
| * | ||
| * @see https://vueuse.org/useCounter | ||
| * @param [initialValue] | ||
| * @param options | ||
| */ | ||
| function useCounter(initialValue = 0, options = {}) { | ||
| let _initialValue = unref(initialValue); | ||
| const count = shallowRef(initialValue); | ||
| const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options; | ||
| const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min); | ||
| const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max); | ||
| const get$1 = () => count.value; | ||
| const set$1 = (val) => count.value = Math.max(min, Math.min(max, val)); | ||
| const reset = (val = _initialValue) => { | ||
| _initialValue = val; | ||
| return set$1(val); | ||
| }; | ||
| return { | ||
| count: shallowReadonly(count), | ||
| inc, | ||
| dec, | ||
| get: get$1, | ||
| set: set$1, | ||
| reset | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region useDateFormat/index.ts | ||
| const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i; | ||
| const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g; | ||
| function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) { | ||
| let m = hours < 12 ? "AM" : "PM"; | ||
| if (hasPeriod) m = m.split("").reduce((acc, curr) => acc += `${curr}.`, ""); | ||
| return isLowercase ? m.toLowerCase() : m; | ||
| } | ||
| function formatOrdinal(num) { | ||
| const suffixes = [ | ||
| "th", | ||
| "st", | ||
| "nd", | ||
| "rd" | ||
| ]; | ||
| const v = num % 100; | ||
| return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]); | ||
| } | ||
| function formatDate(date, formatStr, options = {}) { | ||
| var _options$customMeridi; | ||
| const years = date.getFullYear(); | ||
| const month = date.getMonth(); | ||
| const days = date.getDate(); | ||
| const hours = date.getHours(); | ||
| const minutes = date.getMinutes(); | ||
| const seconds = date.getSeconds(); | ||
| const milliseconds = date.getMilliseconds(); | ||
| const day = date.getDay(); | ||
| const meridiem = (_options$customMeridi = options.customMeridiem) !== null && _options$customMeridi !== void 0 ? _options$customMeridi : defaultMeridiem; | ||
| const stripTimeZone = (dateString) => { | ||
| var _dateString$split$; | ||
| return (_dateString$split$ = dateString.split(" ")[1]) !== null && _dateString$split$ !== void 0 ? _dateString$split$ : ""; | ||
| }; | ||
| const matches = { | ||
| Yo: () => formatOrdinal(years), | ||
| YY: () => String(years).slice(-2), | ||
| YYYY: () => years, | ||
| M: () => month + 1, | ||
| Mo: () => formatOrdinal(month + 1), | ||
| MM: () => `${month + 1}`.padStart(2, "0"), | ||
| MMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "short" }), | ||
| MMMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "long" }), | ||
| D: () => String(days), | ||
| Do: () => formatOrdinal(days), | ||
| DD: () => `${days}`.padStart(2, "0"), | ||
| H: () => String(hours), | ||
| Ho: () => formatOrdinal(hours), | ||
| HH: () => `${hours}`.padStart(2, "0"), | ||
| h: () => `${hours % 12 || 12}`.padStart(1, "0"), | ||
| ho: () => formatOrdinal(hours % 12 || 12), | ||
| hh: () => `${hours % 12 || 12}`.padStart(2, "0"), | ||
| m: () => String(minutes), | ||
| mo: () => formatOrdinal(minutes), | ||
| mm: () => `${minutes}`.padStart(2, "0"), | ||
| s: () => String(seconds), | ||
| so: () => formatOrdinal(seconds), | ||
| ss: () => `${seconds}`.padStart(2, "0"), | ||
| SSS: () => `${milliseconds}`.padStart(3, "0"), | ||
| d: () => day, | ||
| dd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "narrow" }), | ||
| ddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "short" }), | ||
| dddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "long" }), | ||
| A: () => meridiem(hours, minutes), | ||
| AA: () => meridiem(hours, minutes, false, true), | ||
| a: () => meridiem(hours, minutes, true), | ||
| aa: () => meridiem(hours, minutes, true, true), | ||
| z: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })), | ||
| zz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "longOffset" })) | ||
| }; | ||
| return formatStr.replace(REGEX_FORMAT, (match, $1) => { | ||
| var _ref, _matches$match; | ||
| return (_ref = $1 !== null && $1 !== void 0 ? $1 : (_matches$match = matches[match]) === null || _matches$match === void 0 ? void 0 : _matches$match.call(matches)) !== null && _ref !== void 0 ? _ref : match; | ||
| }); | ||
| } | ||
| function normalizeDate(date) { | ||
| if (date === null) return /* @__PURE__ */ new Date(NaN); | ||
| if (date === void 0) return /* @__PURE__ */ new Date(); | ||
| if (date instanceof Date) return new Date(date); | ||
| if (typeof date === "string" && !/Z$/i.test(date)) { | ||
| const d = date.match(REGEX_PARSE); | ||
| if (d) { | ||
| const m = d[2] - 1 || 0; | ||
| const ms = (d[7] || "0").substring(0, 3); | ||
| return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms); | ||
| } | ||
| } | ||
| return new Date(date); | ||
| } | ||
| /** | ||
| * Get the formatted date according to the string of tokens passed in. | ||
| * | ||
| * @see https://vueuse.org/useDateFormat | ||
| * @param date - The date to format, can either be a `Date` object, a timestamp, or a string | ||
| * @param formatStr - The combination of tokens to format the date | ||
| * @param options - UseDateFormatOptions | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) { | ||
| return computed(() => formatDate(normalizeDate(toValue$1(date)), toValue$1(formatStr), options)); | ||
| } | ||
| //#endregion | ||
| //#region useIntervalFn/index.ts | ||
| /** | ||
| * Wrapper for `setInterval` with controls | ||
| * | ||
| * @see https://vueuse.org/useIntervalFn | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| function useIntervalFn(cb, interval = 1e3, options = {}) { | ||
| const { immediate = true, immediateCallback = false } = options; | ||
| let timer = null; | ||
| const isActive = shallowRef(false); | ||
| function clean() { | ||
| if (timer) { | ||
| clearInterval(timer); | ||
| timer = null; | ||
| } | ||
| } | ||
| function pause() { | ||
| isActive.value = false; | ||
| clean(); | ||
| } | ||
| function resume() { | ||
| const intervalValue = toValue$1(interval); | ||
| if (intervalValue <= 0) return; | ||
| isActive.value = true; | ||
| if (immediateCallback) cb(); | ||
| clean(); | ||
| if (isActive.value) timer = setInterval(cb, intervalValue); | ||
| } | ||
| if (immediate && isClient) resume(); | ||
| if (isRef(interval) || typeof interval === "function") { | ||
| const stopWatch = watch(interval, () => { | ||
| if (isActive.value && isClient) resume(); | ||
| }); | ||
| tryOnScopeDispose(stopWatch); | ||
| } | ||
| tryOnScopeDispose(pause); | ||
| return { | ||
| isActive: shallowReadonly(isActive), | ||
| pause, | ||
| resume | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region useInterval/index.ts | ||
| function useInterval(interval = 1e3, options = {}) { | ||
| const { controls: exposeControls = false, immediate = true, callback } = options; | ||
| const counter = shallowRef(0); | ||
| const update = () => counter.value += 1; | ||
| const reset = () => { | ||
| counter.value = 0; | ||
| }; | ||
| const controls = useIntervalFn(callback ? () => { | ||
| update(); | ||
| callback(counter.value); | ||
| } : update, interval, { immediate }); | ||
| if (exposeControls) return { | ||
| counter: shallowReadonly(counter), | ||
| reset, | ||
| ...controls | ||
| }; | ||
| else return shallowReadonly(counter); | ||
| } | ||
| //#endregion | ||
| //#region useLastChanged/index.ts | ||
| function useLastChanged(source, options = {}) { | ||
| var _options$initialValue; | ||
| const ms = shallowRef((_options$initialValue = options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : null); | ||
| watch(source, () => ms.value = timestamp(), options); | ||
| return shallowReadonly(ms); | ||
| } | ||
| //#endregion | ||
| //#region useTimeoutFn/index.ts | ||
| /** | ||
| * Wrapper for `setTimeout` with controls. | ||
| * | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| function useTimeoutFn(cb, interval, options = {}) { | ||
| const { immediate = true, immediateCallback = false } = options; | ||
| const isPending = shallowRef(false); | ||
| let timer; | ||
| function clear() { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| } | ||
| } | ||
| function stop() { | ||
| isPending.value = false; | ||
| clear(); | ||
| } | ||
| function start(...args) { | ||
| if (immediateCallback) cb(); | ||
| clear(); | ||
| isPending.value = true; | ||
| timer = setTimeout(() => { | ||
| isPending.value = false; | ||
| timer = void 0; | ||
| cb(...args); | ||
| }, toValue$1(interval)); | ||
| } | ||
| if (immediate) { | ||
| isPending.value = true; | ||
| if (isClient) start(); | ||
| } | ||
| tryOnScopeDispose(stop); | ||
| return { | ||
| isPending: shallowReadonly(isPending), | ||
| start, | ||
| stop | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region useTimeout/index.ts | ||
| function useTimeout(interval = 1e3, options = {}) { | ||
| const { controls: exposeControls = false, callback } = options; | ||
| const controls = useTimeoutFn(callback !== null && callback !== void 0 ? callback : noop, interval, options); | ||
| const ready = computed(() => !controls.isPending.value); | ||
| if (exposeControls) return { | ||
| ready, | ||
| ...controls | ||
| }; | ||
| else return ready; | ||
| } | ||
| //#endregion | ||
| //#region useToNumber/index.ts | ||
| /** | ||
| * Reactively convert a string ref to number. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useToNumber(value, options = {}) { | ||
| const { method = "parseFloat", radix, nanToZero } = options; | ||
| return computed(() => { | ||
| let resolved = toValue$1(value); | ||
| if (typeof method === "function") resolved = method(resolved); | ||
| else if (typeof resolved === "string") resolved = Number[method](resolved, radix); | ||
| if (nanToZero && Number.isNaN(resolved)) resolved = 0; | ||
| return resolved; | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region useToString/index.ts | ||
| /** | ||
| * Reactively convert a ref to string. | ||
| * | ||
| * @see https://vueuse.org/useToString | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useToString(value) { | ||
| return computed(() => `${toValue$1(value)}`); | ||
| } | ||
| //#endregion | ||
| //#region useToggle/index.ts | ||
| /** | ||
| * A boolean ref with a toggler | ||
| * | ||
| * @see https://vueuse.org/useToggle | ||
| * @param [initialValue] | ||
| * @param options | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| function useToggle(initialValue = false, options = {}) { | ||
| const { truthyValue = true, falsyValue = false } = options; | ||
| const valueIsRef = isRef(initialValue); | ||
| const _value = shallowRef(initialValue); | ||
| function toggle(value) { | ||
| if (arguments.length) { | ||
| _value.value = value; | ||
| return _value.value; | ||
| } else { | ||
| const truthy = toValue$1(truthyValue); | ||
| _value.value = _value.value === truthy ? toValue$1(falsyValue) : truthy; | ||
| return _value.value; | ||
| } | ||
| } | ||
| if (valueIsRef) return toggle; | ||
| else return [_value, toggle]; | ||
| } | ||
| //#endregion | ||
| //#region watchArray/index.ts | ||
| /** | ||
| * Watch for an array with additions and removals. | ||
| * | ||
| * @see https://vueuse.org/watchArray | ||
| */ | ||
| function watchArray(source, cb, options) { | ||
| let oldList = (options === null || options === void 0 ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : toValue$1(source)]; | ||
| return watch(source, (newList, _, onCleanup) => { | ||
| const oldListRemains = Array.from({ length: oldList.length }); | ||
| const added = []; | ||
| for (const obj of newList) { | ||
| let found = false; | ||
| for (let i = 0; i < oldList.length; i++) if (!oldListRemains[i] && obj === oldList[i]) { | ||
| oldListRemains[i] = true; | ||
| found = true; | ||
| break; | ||
| } | ||
| if (!found) added.push(obj); | ||
| } | ||
| const removed = oldList.filter((_$1, i) => !oldListRemains[i]); | ||
| cb(newList, oldList, added, removed, onCleanup); | ||
| oldList = [...newList]; | ||
| }, options); | ||
| } | ||
| //#endregion | ||
| //#region watchAtMost/index.ts | ||
| function watchAtMost(source, cb, options) { | ||
| const { count,...watchOptions } = options; | ||
| const current = shallowRef(0); | ||
| const stop = watchWithFilter(source, (...args) => { | ||
| current.value += 1; | ||
| if (current.value >= toValue$1(count)) nextTick(() => stop()); | ||
| cb(...args); | ||
| }, watchOptions); | ||
| return { | ||
| count: current, | ||
| stop | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region watchDebounced/index.ts | ||
| function watchDebounced(source, cb, options = {}) { | ||
| const { debounce = 0, maxWait = void 0,...watchOptions } = options; | ||
| return watchWithFilter(source, cb, { | ||
| ...watchOptions, | ||
| eventFilter: debounceFilter(debounce, { maxWait }) | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchDeep/index.ts | ||
| /** | ||
| * Shorthand for watching value with {deep: true} | ||
| * | ||
| * @see https://vueuse.org/watchDeep | ||
| */ | ||
| function watchDeep(source, cb, options) { | ||
| return watch(source, cb, { | ||
| ...options, | ||
| deep: true | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchIgnorable/index.ts | ||
| function watchIgnorable(source, cb, options = {}) { | ||
| const { eventFilter = bypassFilter,...watchOptions } = options; | ||
| const filteredCb = createFilterWrapper(eventFilter, cb); | ||
| let ignoreUpdates; | ||
| let ignorePrevAsyncUpdates; | ||
| let stop; | ||
| if (watchOptions.flush === "sync") { | ||
| let ignore = false; | ||
| ignorePrevAsyncUpdates = () => {}; | ||
| ignoreUpdates = (updater) => { | ||
| ignore = true; | ||
| updater(); | ||
| ignore = false; | ||
| }; | ||
| stop = watch(source, (...args) => { | ||
| if (!ignore) filteredCb(...args); | ||
| }, watchOptions); | ||
| } else { | ||
| const disposables = []; | ||
| let ignoreCounter = 0; | ||
| let syncCounter = 0; | ||
| ignorePrevAsyncUpdates = () => { | ||
| ignoreCounter = syncCounter; | ||
| }; | ||
| disposables.push(watch(source, () => { | ||
| syncCounter++; | ||
| }, { | ||
| ...watchOptions, | ||
| flush: "sync" | ||
| })); | ||
| ignoreUpdates = (updater) => { | ||
| const syncCounterPrev = syncCounter; | ||
| updater(); | ||
| ignoreCounter += syncCounter - syncCounterPrev; | ||
| }; | ||
| disposables.push(watch(source, (...args) => { | ||
| const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter; | ||
| ignoreCounter = 0; | ||
| syncCounter = 0; | ||
| if (ignore) return; | ||
| filteredCb(...args); | ||
| }, watchOptions)); | ||
| stop = () => { | ||
| disposables.forEach((fn) => fn()); | ||
| }; | ||
| } | ||
| return { | ||
| stop, | ||
| ignoreUpdates, | ||
| ignorePrevAsyncUpdates | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region watchImmediate/index.ts | ||
| /** | ||
| * Shorthand for watching value with {immediate: true} | ||
| * | ||
| * @see https://vueuse.org/watchImmediate | ||
| */ | ||
| function watchImmediate(source, cb, options) { | ||
| return watch(source, cb, { | ||
| ...options, | ||
| immediate: true | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchOnce/index.ts | ||
| /** | ||
| * Shorthand for watching value with { once: true } | ||
| * | ||
| * @see https://vueuse.org/watchOnce | ||
| */ | ||
| function watchOnce(source, cb, options) { | ||
| return watch(source, cb, { | ||
| ...options, | ||
| once: true | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchThrottled/index.ts | ||
| function watchThrottled(source, cb, options = {}) { | ||
| const { throttle = 0, trailing = true, leading = true,...watchOptions } = options; | ||
| return watchWithFilter(source, cb, { | ||
| ...watchOptions, | ||
| eventFilter: throttleFilter(throttle, trailing, leading) | ||
| }); | ||
| } | ||
| //#endregion | ||
| //#region watchTriggerable/index.ts | ||
| function watchTriggerable(source, cb, options = {}) { | ||
| let cleanupFn; | ||
| function onEffect() { | ||
| if (!cleanupFn) return; | ||
| const fn = cleanupFn; | ||
| cleanupFn = void 0; | ||
| fn(); | ||
| } | ||
| /** Register the function `cleanupFn` */ | ||
| function onCleanup(callback) { | ||
| cleanupFn = callback; | ||
| } | ||
| const _cb = (value, oldValue) => { | ||
| onEffect(); | ||
| return cb(value, oldValue, onCleanup); | ||
| }; | ||
| const res = watchIgnorable(source, _cb, options); | ||
| const { ignoreUpdates } = res; | ||
| const trigger = () => { | ||
| let res$1; | ||
| ignoreUpdates(() => { | ||
| res$1 = _cb(getWatchSources(source), getOldValue(source)); | ||
| }); | ||
| return res$1; | ||
| }; | ||
| return { | ||
| ...res, | ||
| trigger | ||
| }; | ||
| } | ||
| function getWatchSources(sources) { | ||
| if (isReactive(sources)) return sources; | ||
| if (Array.isArray(sources)) return sources.map((item) => toValue$1(item)); | ||
| return toValue$1(sources); | ||
| } | ||
| function getOldValue(source) { | ||
| return Array.isArray(source) ? source.map(() => void 0) : void 0; | ||
| } | ||
| //#endregion | ||
| //#region whenever/index.ts | ||
| /** | ||
| * Shorthand for watching value to be truthy | ||
| * | ||
| * @see https://vueuse.org/whenever | ||
| */ | ||
| function whenever(source, cb, options) { | ||
| const stop = watch(source, (v, ov, onInvalidate) => { | ||
| if (v) { | ||
| if (options === null || options === void 0 ? void 0 : options.once) nextTick(() => stop()); | ||
| cb(v, ov, onInvalidate); | ||
| } | ||
| }, { | ||
| ...options, | ||
| once: false | ||
| }); | ||
| return stop; | ||
| } | ||
| //#endregion | ||
| export { assert, refAutoReset as autoResetRef, refAutoReset, bypassFilter, camelize, clamp, computedEager, computedEager as eagerComputed, computedWithControl, computedWithControl as controlledComputed, containsProp, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, reactify, createRef, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, refDebounced, refDebounced as useDebounce, watchDebounced as debouncedWatch, watchDebounced, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, watchIgnorable, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, watchPausable, promiseTimeout, provideLocal, pxValue, rand, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refDefault, refThrottled, refThrottled as throttledRef, refThrottled as useThrottle, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, watchThrottled as throttledWatch, watchThrottled, timestamp, toArray, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDeep, watchImmediate, watchOnce, watchTriggerable, watchWithFilter, whenever }; |
+10
-12
| { | ||
| "name": "@vueuse/shared", | ||
| "type": "module", | ||
| "version": "14.0.0-alpha.0", | ||
| "version": "14.0.0-alpha.1", | ||
| "author": "Anthony Fu <https://github.com/antfu>", | ||
@@ -24,14 +24,12 @@ "license": "MIT", | ||
| "exports": { | ||
| ".": "./index.mjs", | ||
| "./*": "./*" | ||
| ".": "./dist/index.js", | ||
| "./*": "./dist/*" | ||
| }, | ||
| "main": "./index.mjs", | ||
| "module": "./index.mjs", | ||
| "unpkg": "./index.iife.min.js", | ||
| "jsdelivr": "./index.iife.min.js", | ||
| "types": "./index.d.mts", | ||
| "main": "./dist/index.js", | ||
| "module": "./dist/index.js", | ||
| "unpkg": "./dist/index.iife.min.js", | ||
| "jsdelivr": "./dist/index.iife.min.js", | ||
| "types": "./dist/index.d.ts", | ||
| "files": [ | ||
| "*.d.mts", | ||
| "*.js", | ||
| "*.mjs" | ||
| "dist" | ||
| ], | ||
@@ -42,5 +40,5 @@ "peerDependencies": { | ||
| "scripts": { | ||
| "build": "rollup --config=rollup.config.ts --configPlugin=rollup-plugin-esbuild", | ||
| "build": "tsdown", | ||
| "test:attw": "attw --pack --config-path ../../.attw.json ." | ||
| } | ||
| } |
-1388
| import * as vue from 'vue'; | ||
| import { WatchOptionsBase, ShallowRef, WatchSource, ComputedGetter, WatchOptions, ComputedRef, WritableComputedOptions, WritableComputedRef, Ref, MaybeRef, MaybeRefOrGetter, InjectionKey, ShallowUnwrapRef as ShallowUnwrapRef$1, inject, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, toValue as toValue$1, WatchCallback, WatchStopHandle } from 'vue'; | ||
| export { MaybeRef, MaybeRefOrGetter } from 'vue'; | ||
| type ComputedEagerOptions = WatchOptionsBase; | ||
| type ComputedEagerReturn<T = any> = Readonly<ShallowRef<T>>; | ||
| /** | ||
| * Note: If you are using Vue 3.4+, you can straight use computed instead. | ||
| * Because in Vue 3.4+, if computed new value does not change, | ||
| * computed, effect, watch, watchEffect, render dependencies will not be triggered. | ||
| * refer: https://github.com/vuejs/core/pull/5912 | ||
| * | ||
| * @param fn effect function | ||
| * @param options WatchOptionsBase | ||
| * @returns readonly shallowRef | ||
| */ | ||
| declare function computedEager<T>(fn: () => T, options?: ComputedEagerOptions): ComputedEagerReturn<T>; | ||
| interface ComputedWithControlRefExtra { | ||
| /** | ||
| * Force update the computed value. | ||
| */ | ||
| trigger: () => void; | ||
| } | ||
| interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra { | ||
| } | ||
| interface WritableComputedRefWithControl<T> extends WritableComputedRef<T>, ComputedWithControlRefExtra { | ||
| } | ||
| type ComputedWithControlRef<T = any> = ComputedRefWithControl<T> | WritableComputedRefWithControl<T>; | ||
| declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: ComputedGetter<T>, options?: WatchOptions): ComputedRefWithControl<T>; | ||
| declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: WritableComputedOptions<T>, options?: WatchOptions): WritableComputedRefWithControl<T>; | ||
| /** | ||
| * Void function | ||
| */ | ||
| type Fn = () => void; | ||
| /** | ||
| * Any function | ||
| */ | ||
| type AnyFn = (...args: any[]) => any; | ||
| /** | ||
| * A ref that allow to set null or undefined | ||
| */ | ||
| type RemovableRef<T> = Omit<Ref<T>, 'value'> & { | ||
| get value(): T; | ||
| set value(value: T | null | undefined); | ||
| }; | ||
| /** | ||
| * Maybe it's a computed ref, or a readonly value, or a getter function | ||
| */ | ||
| type ReadonlyRefOrGetter<T> = ComputedRef<T> | (() => T); | ||
| /** | ||
| * Make all the nested attributes of an object or array to MaybeRef<T> | ||
| * | ||
| * Good for accepting options that will be wrapped with `reactive` or `ref` | ||
| * | ||
| * ```ts | ||
| * UnwrapRef<DeepMaybeRef<T>> === T | ||
| * ``` | ||
| */ | ||
| type DeepMaybeRef<T> = T extends Ref<infer V> ? MaybeRef<V> : T extends Array<any> | object ? { | ||
| [K in keyof T]: DeepMaybeRef<T[K]>; | ||
| } : MaybeRef<T>; | ||
| type Arrayable<T> = T[] | T; | ||
| /** | ||
| * Infers the element type of an array | ||
| */ | ||
| type ElementOf<T> = T extends (infer E)[] ? E : never; | ||
| type ShallowUnwrapRef<T> = T extends Ref<infer P> ? P : T; | ||
| type Awaitable<T> = Promise<T> | T; | ||
| type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never; | ||
| /** | ||
| * Compatible with versions below TypeScript 4.5 Awaited | ||
| */ | ||
| type Awaited<T> = T extends null | undefined ? T : T extends object & { | ||
| then: (onfulfilled: infer F, ...args: infer _) => any; | ||
| } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T; | ||
| type Promisify<T> = Promise<Awaited<T>>; | ||
| type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>; | ||
| interface Pausable { | ||
| /** | ||
| * A ref indicate whether a pausable instance is active | ||
| */ | ||
| readonly isActive: Readonly<ShallowRef<boolean>>; | ||
| /** | ||
| * Temporary pause the effect from executing | ||
| */ | ||
| pause: Fn; | ||
| /** | ||
| * Resume the effects | ||
| */ | ||
| resume: Fn; | ||
| } | ||
| interface Stoppable<StartFnArgs extends any[] = any[]> { | ||
| /** | ||
| * A ref indicate whether a stoppable instance is executing | ||
| */ | ||
| readonly isPending: Readonly<Ref<boolean>>; | ||
| /** | ||
| * Stop the effect from executing | ||
| */ | ||
| stop: Fn; | ||
| /** | ||
| * Start the effects | ||
| */ | ||
| start: (...args: StartFnArgs) => void; | ||
| } | ||
| interface ConfigurableFlush { | ||
| /** | ||
| * Timing for monitoring changes, refer to WatchOptions for more details | ||
| * | ||
| * @default 'pre' | ||
| */ | ||
| flush?: WatchOptions['flush']; | ||
| } | ||
| interface ConfigurableFlushSync { | ||
| /** | ||
| * Timing for monitoring changes, refer to WatchOptions for more details. | ||
| * Unlike `watch()`, the default is set to `sync` | ||
| * | ||
| * @default 'sync' | ||
| */ | ||
| flush?: WatchOptions['flush']; | ||
| } | ||
| type MultiWatchSources = (WatchSource<unknown> | object)[]; | ||
| type MapSources<T> = { | ||
| [K in keyof T]: T[K] extends WatchSource<infer V> ? V : never; | ||
| }; | ||
| type MapOldSources<T, Immediate> = { | ||
| [K in keyof T]: T[K] extends WatchSource<infer V> ? Immediate extends true ? V | undefined : V : never; | ||
| }; | ||
| type Mutable<T> = { | ||
| -readonly [P in keyof T]: T[P]; | ||
| }; | ||
| type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N; | ||
| /** | ||
| * will return `true` if `T` is `any`, or `false` otherwise | ||
| */ | ||
| type IsAny<T> = IfAny<T, true, false>; | ||
| /** | ||
| * Universal timer handle that works in both browser and Node.js environments | ||
| */ | ||
| type TimerHandle = ReturnType<typeof setTimeout> | undefined; | ||
| /** | ||
| * The source code for this function was inspired by vue-apollo's `useEventHook` util | ||
| * https://github.com/vuejs/vue-apollo/blob/v4/packages/vue-apollo-composable/src/util/useEventHook.ts | ||
| */ | ||
| type Callback<T> = IsAny<T> extends true ? (...param: any) => void : ([ | ||
| T | ||
| ] extends [void] ? (...param: unknown[]) => void : [T] extends [any[]] ? (...param: T) => void : (...param: [T, ...unknown[]]) => void); | ||
| type EventHookOn<T = any> = (fn: Callback<T>) => { | ||
| off: () => void; | ||
| }; | ||
| type EventHookOff<T = any> = (fn: Callback<T>) => void; | ||
| type EventHookTrigger<T = any> = (...param: Parameters<Callback<T>>) => Promise<unknown[]>; | ||
| interface EventHook<T = any> { | ||
| on: EventHookOn<T>; | ||
| off: EventHookOff<T>; | ||
| trigger: EventHookTrigger<T>; | ||
| clear: () => void; | ||
| } | ||
| type EventHookReturn<T> = EventHook<T>; | ||
| /** | ||
| * Utility for creating event hooks | ||
| * | ||
| * @see https://vueuse.org/createEventHook | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createEventHook<T = any>(): EventHookReturn<T>; | ||
| type FunctionArgs<Args extends any[] = any[], Return = void> = (...args: Args) => Return; | ||
| interface FunctionWrapperOptions<Args extends any[] = any[], This = any> { | ||
| fn: FunctionArgs<Args, This>; | ||
| args: Args; | ||
| thisArg: This; | ||
| } | ||
| type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> | Promisify<ReturnType<Invoke>>; | ||
| interface ConfigurableEventFilter { | ||
| /** | ||
| * Filter for if events should to be received. | ||
| * | ||
| * @see https://vueuse.org/guide/config.html#event-filters | ||
| */ | ||
| eventFilter?: EventFilter; | ||
| } | ||
| interface DebounceFilterOptions { | ||
| /** | ||
| * The maximum time allowed to be delayed before it's invoked. | ||
| * In milliseconds. | ||
| */ | ||
| maxWait?: MaybeRefOrGetter<number>; | ||
| /** | ||
| * Whether to reject the last call if it's been cancel. | ||
| * | ||
| * @default false | ||
| */ | ||
| rejectOnCancel?: boolean; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>; | ||
| declare const bypassFilter: EventFilter; | ||
| /** | ||
| * Create an EventFilter that debounce the events | ||
| */ | ||
| declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>; | ||
| interface ThrottleFilterOptions { | ||
| /** | ||
| * The maximum time allowed to be delayed before it's invoked. | ||
| */ | ||
| delay: MaybeRefOrGetter<number>; | ||
| /** | ||
| * Whether to invoke on the trailing edge of the timeout. | ||
| */ | ||
| trailing?: boolean; | ||
| /** | ||
| * Whether to invoke on the leading edge of the timeout. | ||
| */ | ||
| leading?: boolean; | ||
| /** | ||
| * Whether to reject the last call if it's been cancel. | ||
| */ | ||
| rejectOnCancel?: boolean; | ||
| } | ||
| /** | ||
| * Create an EventFilter that throttle the events | ||
| */ | ||
| declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter; | ||
| declare function throttleFilter(options: ThrottleFilterOptions): EventFilter; | ||
| interface PausableFilterOptions { | ||
| /** | ||
| * The initial state | ||
| * | ||
| * @default 'active' | ||
| */ | ||
| initialState?: 'active' | 'paused'; | ||
| } | ||
| /** | ||
| * EventFilter that gives extra controls to pause and resume the filter | ||
| * | ||
| * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none | ||
| * @param options Options to configure the filter | ||
| */ | ||
| declare function pausableFilter(extendFilter?: EventFilter, options?: PausableFilterOptions): Pausable & { | ||
| eventFilter: EventFilter; | ||
| }; | ||
| declare function promiseTimeout(ms: number, throwOnTimeout?: boolean, reason?: string): Promise<void>; | ||
| declare function identity<T>(arg: T): T; | ||
| interface SingletonPromiseReturn<T> { | ||
| (): Promise<T>; | ||
| /** | ||
| * Reset current staled promise. | ||
| * await it to have proper shutdown. | ||
| */ | ||
| reset: () => Promise<void>; | ||
| } | ||
| /** | ||
| * Create singleton promise function | ||
| * | ||
| * @example | ||
| * ``` | ||
| * const promise = createSingletonPromise(async () => { ... }) | ||
| * | ||
| * await promise() | ||
| * await promise() // all of them will be bind to a single promise instance | ||
| * await promise() // and be resolved together | ||
| * ``` | ||
| */ | ||
| declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>; | ||
| declare function invoke<T>(fn: () => T): T; | ||
| declare function containsProp(obj: object, ...props: string[]): boolean; | ||
| /** | ||
| * Increase string a value with unit | ||
| * | ||
| * @example '2px' + 1 = '3px' | ||
| * @example '15em' + (-2) = '13em' | ||
| */ | ||
| declare function increaseWithUnit(target: number, delta: number): number; | ||
| declare function increaseWithUnit(target: string, delta: number): string; | ||
| declare function increaseWithUnit(target: string | number, delta: number): string | number; | ||
| /** | ||
| * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client | ||
| */ | ||
| declare function pxValue(px: string): number; | ||
| /** | ||
| * Create a new subset object by giving keys | ||
| */ | ||
| declare function objectPick<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Pick<O, T>; | ||
| /** | ||
| * Create a new subset object by omit giving keys | ||
| */ | ||
| declare function objectOmit<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Omit<O, T>; | ||
| declare function objectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>; | ||
| declare function toArray<T>(value: T | readonly T[]): readonly T[]; | ||
| declare function toArray<T>(value: T | T[]): T[]; | ||
| declare const isClient: boolean; | ||
| declare const isWorker: boolean; | ||
| declare const isDef: <T = any>(val?: T) => val is T; | ||
| declare const notNullish: <T = any>(val?: T | null | undefined) => val is T; | ||
| declare const assert: (condition: boolean, ...infos: any[]) => void; | ||
| declare const isObject: (val: any) => val is object; | ||
| declare const now: () => number; | ||
| declare const timestamp: () => number; | ||
| declare const clamp: (n: number, min: number, max: number) => number; | ||
| declare const noop: () => void; | ||
| declare const rand: (min: number, max: number) => number; | ||
| declare const hasOwn: <T extends object, K extends keyof T>(val: T, key: K) => key is K; | ||
| declare const isIOS: boolean | ""; | ||
| declare const hyphenate: (str: string) => string; | ||
| declare const camelize: (str: string) => string; | ||
| declare function getLifeCycleTarget(target?: any): any; | ||
| type CreateGlobalStateReturn<Fn extends AnyFn = AnyFn> = Fn; | ||
| /** | ||
| * Keep states in the global scope to be reusable across Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createGlobalState | ||
| * @param stateFactory A factory function to create the state | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createGlobalState<Fn extends AnyFn>(stateFactory: Fn): CreateGlobalStateReturn<Fn>; | ||
| interface CreateInjectionStateOptions<Return> { | ||
| /** | ||
| * Custom injectionKey for InjectionState | ||
| */ | ||
| injectionKey?: string | InjectionKey<Return>; | ||
| /** | ||
| * Default value for the InjectionState | ||
| */ | ||
| defaultValue?: Return; | ||
| } | ||
| /** | ||
| * Create global state that can be injected into components. | ||
| * | ||
| * @see https://vueuse.org/createInjectionState | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return, options?: CreateInjectionStateOptions<Return>): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined]; | ||
| type CreateRefReturn<T = any, D extends boolean = false> = ShallowOrDeepRef<T, D>; | ||
| type ShallowOrDeepRef<T = any, D extends boolean = false> = D extends true ? Ref<T> : ShallowRef<T>; | ||
| /** | ||
| * Returns a `deepRef` or `shallowRef` depending on the `deep` param. | ||
| * | ||
| * @example createRef(1) // ShallowRef<number> | ||
| * @example createRef(1, false) // ShallowRef<number> | ||
| * @example createRef(1, true) // Ref<number> | ||
| * @example createRef("string") // ShallowRef<string> | ||
| * @example createRef<"A"|"B">("A", true) // Ref<"A"|"B"> | ||
| * | ||
| * @param value | ||
| * @param deep | ||
| * @returns the `deepRef` or `shallowRef` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createRef<T = any, D extends boolean = false>(value: T, deep?: D): CreateRefReturn<T, D>; | ||
| type SharedComposableReturn<T extends AnyFn = AnyFn> = T; | ||
| /** | ||
| * Make a composable function usable with multiple Vue instances. | ||
| * | ||
| * @see https://vueuse.org/createSharedComposable | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function createSharedComposable<Fn extends AnyFn>(composable: Fn): SharedComposableReturn<Fn>; | ||
| type ExtendRefReturn<T = any> = Ref<T>; | ||
| interface ExtendRefOptions<Unwrap extends boolean = boolean> { | ||
| /** | ||
| * Is the extends properties enumerable | ||
| * | ||
| * @default false | ||
| */ | ||
| enumerable?: boolean; | ||
| /** | ||
| * Unwrap for Ref properties | ||
| * | ||
| * @default true | ||
| */ | ||
| unwrap?: Unwrap; | ||
| } | ||
| /** | ||
| * Overload 1: Unwrap set to false | ||
| */ | ||
| declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions<false>>(ref: R, extend: Extend, options?: Options): ShallowUnwrapRef$1<Extend> & R; | ||
| /** | ||
| * Overload 2: Unwrap unset or set to true | ||
| */ | ||
| declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions>(ref: R, extend: Extend, options?: Options): Extend & R; | ||
| /** | ||
| * Shorthand for accessing `ref.value` | ||
| */ | ||
| declare function get<T>(ref: MaybeRef<T>): T; | ||
| declare function get<T, K extends keyof T>(ref: MaybeRef<T>, key: K): T[K]; | ||
| /** | ||
| * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * injectLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare const injectLocal: typeof inject; | ||
| type IsDefinedReturn = boolean; | ||
| declare function isDefined<T>(v: ComputedRef<T>): v is ComputedRef<Exclude<T, null | undefined>>; | ||
| declare function isDefined<T>(v: Ref<T>): v is Ref<Exclude<T, null | undefined>>; | ||
| declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>; | ||
| declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A; | ||
| type ProvideLocalReturn = void; | ||
| /** | ||
| * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * provideLocal('MyInjectionKey', 1) | ||
| * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 | ||
| * ``` | ||
| */ | ||
| declare function provideLocal<T, K = InjectionKey<T> | string | number>(key: K, value: K extends InjectionKey<infer V> ? V : T): ProvideLocalReturn; | ||
| type Reactified<T, Computed extends boolean> = T extends (...args: infer A) => infer R ? (...args: { | ||
| [K in keyof A]: Computed extends true ? MaybeRefOrGetter<A[K]> : MaybeRef<A[K]>; | ||
| }) => ComputedRef<R> : never; | ||
| type ReactifyReturn<T extends AnyFn = AnyFn, K extends boolean = true> = Reactified<T, K>; | ||
| interface ReactifyOptions<T extends boolean> { | ||
| /** | ||
| * Accept passing a function as a reactive getter | ||
| * | ||
| * @default true | ||
| */ | ||
| computedGetter?: T; | ||
| } | ||
| /** | ||
| * Converts plain function into a reactive function. | ||
| * The converted function accepts refs as it's arguments | ||
| * and returns a ComputedRef, with proper typing. | ||
| * | ||
| * @param fn - Source function | ||
| * @param options - Options | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function reactify<T extends AnyFn, K extends boolean = true>(fn: T, options?: ReactifyOptions<K>): ReactifyReturn<T, K>; | ||
| type ReactifyNested<T, Keys extends keyof T = keyof T, S extends boolean = true> = { | ||
| [K in Keys]: T[K] extends AnyFn ? Reactified<T[K], S> : T[K]; | ||
| }; | ||
| type ReactifyObjectReturn<T, Keys extends keyof T, S extends boolean = true> = ReactifyNested<T, Keys, S>; | ||
| interface ReactifyObjectOptions<T extends boolean> extends ReactifyOptions<T> { | ||
| /** | ||
| * Includes names from Object.getOwnPropertyNames | ||
| * | ||
| * @default true | ||
| */ | ||
| includeOwnProperties?: boolean; | ||
| } | ||
| /** | ||
| * Apply `reactify` to an object | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function reactifyObject<T extends object, Keys extends keyof T>(obj: T, keys?: (keyof T)[]): ReactifyObjectReturn<T, Keys, true>; | ||
| declare function reactifyObject<T extends object, S extends boolean = true>(obj: T, options?: ReactifyObjectOptions<S>): ReactifyObjectReturn<T, keyof T, S>; | ||
| type ReactiveComputedReturn<T extends object> = UnwrapNestedRefs<T>; | ||
| /** | ||
| * Computed reactive object. | ||
| */ | ||
| declare function reactiveComputed<T extends object>(fn: ComputedGetter<T>): ReactiveComputedReturn<T>; | ||
| type ReactiveOmitReturn<T extends object, K extends keyof T | undefined = undefined> = [K] extends [undefined] ? Partial<T> : Omit<T, Extract<K, keyof T>>; | ||
| type ReactiveOmitPredicate<T> = (value: T[keyof T], key: keyof T) => boolean; | ||
| declare function reactiveOmit<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): ReactiveOmitReturn<T, K>; | ||
| declare function reactiveOmit<T extends object>(obj: T, predicate: ReactiveOmitPredicate<T>): ReactiveOmitReturn<T>; | ||
| type ReactivePickReturn<T extends object, K extends keyof T> = { | ||
| [S in K]: UnwrapRef<T[S]>; | ||
| }; | ||
| type ReactivePickPredicate<T> = (value: T[keyof T], key: keyof T) => boolean; | ||
| declare function reactivePick<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): ReactivePickReturn<T, K>; | ||
| declare function reactivePick<T extends object>(obj: T, predicate: ReactivePickPredicate<T>): ReactivePickReturn<T, keyof T>; | ||
| type RefAutoResetReturn<T = any> = Ref<T>; | ||
| /** | ||
| * Create a ref which will be reset to the default value after some time. | ||
| * | ||
| * @see https://vueuse.org/refAutoReset | ||
| * @param defaultValue The value which will be set. | ||
| * @param afterMs A zero-or-greater delay in milliseconds. | ||
| */ | ||
| declare function refAutoReset<T>(defaultValue: MaybeRefOrGetter<T>, afterMs?: MaybeRefOrGetter<number>): RefAutoResetReturn<T>; | ||
| type RefDebouncedReturn<T = any> = Readonly<Ref<T>>; | ||
| /** | ||
| * Debounce updates of a ref. | ||
| * | ||
| * @return A new debounced ref. | ||
| */ | ||
| declare function refDebounced<T>(value: Ref<T>, ms?: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): RefDebouncedReturn<T>; | ||
| /** | ||
| * Apply default value to a ref. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue: T): Ref<T>; | ||
| type RefThrottledReturn<T = any> = Ref<T>; | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param value Ref value to be watched with throttle effect | ||
| * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param trailing if true, update the value again after the delay time is up | ||
| * @param leading if true, update the value on the leading edge of the ms timeout | ||
| */ | ||
| declare function refThrottled<T = any>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): RefThrottledReturn<T>; | ||
| interface ControlledRefOptions<T> { | ||
| /** | ||
| * Callback function before the ref changing. | ||
| * | ||
| * Returning `false` to dismiss the change. | ||
| */ | ||
| onBeforeChange?: (value: T, oldValue: T) => void | boolean; | ||
| /** | ||
| * Callback function after the ref changed | ||
| * | ||
| * This happens synchronously, with less overhead compare to `watch` | ||
| */ | ||
| onChanged?: (value: T, oldValue: T) => void; | ||
| } | ||
| /** | ||
| * Fine-grained controls over ref and its reactivity. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function refWithControl<T>(initial: T, options?: ControlledRefOptions<T>): vue.ShallowUnwrapRef<{ | ||
| get: (tracking?: boolean) => T; | ||
| set: (value: T, triggering?: boolean) => void; | ||
| untrackedGet: () => T; | ||
| silentSet: (v: T) => void; | ||
| peek: () => T; | ||
| lay: (v: T) => void; | ||
| }> & vue.Ref<T, T>; | ||
| /** | ||
| * Alias for `refWithControl` | ||
| */ | ||
| declare const controlledRef: typeof refWithControl; | ||
| declare function set<T>(ref: Ref<T>, value: T): void; | ||
| declare function set<O extends object, K extends keyof O>(target: O, key: K, value: O[K]): void; | ||
| type Direction = 'ltr' | 'rtl' | 'both'; | ||
| type SpecificFieldPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>; | ||
| /** | ||
| * A = B | ||
| */ | ||
| type Equal<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false; | ||
| /** | ||
| * A ∩ B ≠ ∅ | ||
| */ | ||
| type IntersectButNotEqual<A, B> = Equal<A, B> extends true ? false : A & B extends never ? false : true; | ||
| /** | ||
| * A ⊆ B | ||
| */ | ||
| type IncludeButNotEqual<A, B> = Equal<A, B> extends true ? false : A extends B ? true : false; | ||
| /** | ||
| * A ∩ B = ∅ | ||
| */ | ||
| type NotIntersect<A, B> = Equal<A, B> extends true ? false : A & B extends never ? true : false; | ||
| interface EqualType<D extends Direction, L, R, O extends keyof Transform<L, R> = D extends 'both' ? 'ltr' | 'rtl' : D> { | ||
| transform?: SpecificFieldPartial<Pick<Transform<L, R>, O>, O>; | ||
| } | ||
| type StrictIncludeMap<IncludeType extends 'LR' | 'RL', D extends Exclude<Direction, 'both'>, L, R> = (Equal<[IncludeType, D], ['LR', 'ltr']> & Equal<[IncludeType, D], ['RL', 'rtl']>) extends true ? { | ||
| transform?: SpecificFieldPartial<Pick<Transform<L, R>, D>, D>; | ||
| } : { | ||
| transform: Pick<Transform<L, R>, D>; | ||
| }; | ||
| type StrictIncludeType<IncludeType extends 'LR' | 'RL', D extends Direction, L, R> = D extends 'both' ? { | ||
| transform: SpecificFieldPartial<Transform<L, R>, IncludeType extends 'LR' ? 'ltr' : 'rtl'>; | ||
| } : D extends Exclude<Direction, 'both'> ? StrictIncludeMap<IncludeType, D, L, R> : never; | ||
| type IntersectButNotEqualType<D extends Direction, L, R> = D extends 'both' ? { | ||
| transform: Transform<L, R>; | ||
| } : D extends Exclude<Direction, 'both'> ? { | ||
| transform: Pick<Transform<L, R>, D>; | ||
| } : never; | ||
| type NotIntersectType<D extends Direction, L, R> = IntersectButNotEqualType<D, L, R>; | ||
| interface Transform<L, R> { | ||
| ltr: (left: L) => R; | ||
| rtl: (right: R) => L; | ||
| } | ||
| type TransformType<D extends Direction, L, R> = Equal<L, R> extends true ? EqualType<D, L, R> : IncludeButNotEqual<L, R> extends true ? StrictIncludeType<'LR', D, L, R> : IncludeButNotEqual<R, L> extends true ? StrictIncludeType<'RL', D, L, R> : IntersectButNotEqual<L, R> extends true ? IntersectButNotEqualType<D, L, R> : NotIntersect<L, R> extends true ? NotIntersectType<D, L, R> : never; | ||
| type SyncRefOptions<L, R, D extends Direction> = ConfigurableFlushSync & { | ||
| /** | ||
| * Watch deeply | ||
| * | ||
| * @default false | ||
| */ | ||
| deep?: boolean; | ||
| /** | ||
| * Sync values immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Direction of syncing. Value will be redefined if you define syncConvertors | ||
| * | ||
| * @default 'both' | ||
| */ | ||
| direction?: D; | ||
| } & TransformType<D, L, R>; | ||
| /** | ||
| * Two-way refs synchronization. | ||
| * From the set theory perspective to restrict the option's type | ||
| * Check in the following order: | ||
| * 1. L = R | ||
| * 2. L ∩ R ≠ ∅ | ||
| * 3. L ⊆ R | ||
| * 4. L ∩ R = ∅ | ||
| */ | ||
| declare function syncRef<L, R, D extends Direction = 'both'>(left: Ref<L>, right: Ref<R>, ...[options]: Equal<L, R> extends true ? [options?: SyncRefOptions<L, R, D>] : [options: SyncRefOptions<L, R, D>]): () => void; | ||
| interface SyncRefsOptions extends ConfigurableFlushSync { | ||
| /** | ||
| * Watch deeply | ||
| * | ||
| * @default false | ||
| */ | ||
| deep?: boolean; | ||
| /** | ||
| * Sync values immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| } | ||
| /** | ||
| * Keep target ref(s) in sync with the source ref | ||
| * | ||
| * @param source source ref | ||
| * @param targets | ||
| */ | ||
| declare function syncRefs<T>(source: WatchSource<T>, targets: Ref<T> | Ref<T>[], options?: SyncRefsOptions): vue.WatchHandle; | ||
| /** | ||
| * Converts ref to reactive. | ||
| * | ||
| * @see https://vueuse.org/toReactive | ||
| * @param objectRef A ref of object | ||
| */ | ||
| declare function toReactive<T extends object>(objectRef: MaybeRef<T>): UnwrapNestedRefs<T>; | ||
| /** | ||
| * Normalize value/ref/getter to `ref` or `computed`. | ||
| */ | ||
| declare function toRef<T>(r: () => T): Readonly<Ref<T>>; | ||
| declare function toRef<T>(r: ComputedRef<T>): ComputedRef<T>; | ||
| declare function toRef<T>(r: MaybeRefOrGetter<T>): Ref<T>; | ||
| declare function toRef<T>(r: T): Ref<T>; | ||
| declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>; | ||
| declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>; | ||
| /** | ||
| * @deprecated use `toRef` instead | ||
| */ | ||
| declare const resolveRef: typeof toRef; | ||
| interface ToRefsOptions { | ||
| /** | ||
| * Replace the original ref with a copy on property update. | ||
| * | ||
| * @default true | ||
| */ | ||
| replaceRef?: MaybeRefOrGetter<boolean>; | ||
| } | ||
| /** | ||
| * Extended `toRefs` that also accepts refs of an object. | ||
| * | ||
| * @see https://vueuse.org/toRefs | ||
| * @param objectRef A ref or normal object or array. | ||
| * @param options Options | ||
| */ | ||
| declare function toRefs<T extends object>(objectRef: MaybeRef<T>, options?: ToRefsOptions): ToRefs<T>; | ||
| /** | ||
| * Get the value of value/ref/getter. | ||
| * | ||
| * @deprecated use `toValue` from `vue` instead | ||
| */ | ||
| declare const toValue: typeof toValue$1; | ||
| /** | ||
| * @deprecated use `toValue` instead | ||
| */ | ||
| declare const resolveUnref: typeof toValue$1; | ||
| /** | ||
| * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| declare function tryOnBeforeMount(fn: Fn, sync?: boolean, target?: any): void; | ||
| /** | ||
| * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| declare function tryOnBeforeUnmount(fn: Fn, target?: any): void; | ||
| /** | ||
| * Call onMounted() if it's inside a component lifecycle, if not, just call the function | ||
| * | ||
| * @param fn | ||
| * @param sync if set to false, it will run in the nextTick() of Vue | ||
| * @param target | ||
| */ | ||
| declare function tryOnMounted(fn: Fn, sync?: boolean, target?: any): void; | ||
| /** | ||
| * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| */ | ||
| declare function tryOnScopeDispose(fn: Fn): boolean; | ||
| /** | ||
| * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing | ||
| * | ||
| * @param fn | ||
| * @param target | ||
| */ | ||
| declare function tryOnUnmounted(fn: Fn, target?: any): void; | ||
| interface UntilToMatchOptions { | ||
| /** | ||
| * Milliseconds timeout for promise to resolve/reject if the when condition does not meet. | ||
| * 0 for never timed out | ||
| * | ||
| * @default 0 | ||
| */ | ||
| timeout?: number; | ||
| /** | ||
| * Reject the promise when timeout | ||
| * | ||
| * @default false | ||
| */ | ||
| throwOnTimeout?: boolean; | ||
| /** | ||
| * `flush` option for internal watch | ||
| * | ||
| * @default 'sync' | ||
| */ | ||
| flush?: WatchOptions['flush']; | ||
| /** | ||
| * `deep` option for internal watch | ||
| * | ||
| * @default 'false' | ||
| */ | ||
| deep?: WatchOptions['deep']; | ||
| } | ||
| interface UntilBaseInstance<T, Not extends boolean = false> { | ||
| toMatch: (<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, U>> : Promise<U>) & ((condition: (v: T) => boolean, options?: UntilToMatchOptions) => Promise<T>); | ||
| changed: (options?: UntilToMatchOptions) => Promise<T>; | ||
| changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise<T>; | ||
| } | ||
| type Falsy = false | void | null | undefined | 0 | 0n | ''; | ||
| interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> { | ||
| readonly not: UntilValueInstance<T, Not extends true ? false : true>; | ||
| toBe: <P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions) => Not extends true ? Promise<T> : Promise<P>; | ||
| toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>; | ||
| toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, null>> : Promise<null>; | ||
| toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>; | ||
| toBeNaN: (options?: UntilToMatchOptions) => Promise<T>; | ||
| } | ||
| interface UntilArrayInstance<T> extends UntilBaseInstance<T> { | ||
| readonly not: UntilArrayInstance<T>; | ||
| toContains: (value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions) => Promise<T>; | ||
| } | ||
| /** | ||
| * Promised one-time watch for changes | ||
| * | ||
| * @see https://vueuse.org/until | ||
| * @example | ||
| * ``` | ||
| * const { count } = useCounter() | ||
| * | ||
| * await until(count).toMatch(v => v > 7) | ||
| * | ||
| * alert('Counter is now larger than 7!') | ||
| * ``` | ||
| */ | ||
| declare function until<T extends unknown[]>(r: WatchSource<T> | MaybeRefOrGetter<T>): UntilArrayInstance<T>; | ||
| declare function until<T>(r: WatchSource<T> | MaybeRefOrGetter<T>): UntilValueInstance<T>; | ||
| interface UseArrayDifferenceOptions { | ||
| /** | ||
| * Returns asymmetric difference | ||
| * | ||
| * @see https://en.wikipedia.org/wiki/Symmetric_difference | ||
| * @default false | ||
| */ | ||
| symmetric?: boolean; | ||
| } | ||
| type UseArrayDifferenceReturn<T = any> = ComputedRef<T[]>; | ||
| declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, key?: keyof T, options?: UseArrayDifferenceOptions): UseArrayDifferenceReturn<T>; | ||
| declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, compareFn?: (value: T, othVal: T) => boolean, options?: UseArrayDifferenceOptions): UseArrayDifferenceReturn<T>; | ||
| type UseArrayEveryReturn = ComputedRef<boolean>; | ||
| /** | ||
| * Reactive `Array.every` | ||
| * | ||
| * @see https://vueuse.org/useArrayEvery | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayEvery<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): UseArrayEveryReturn; | ||
| type UseArrayFilterReturn<T = any> = ComputedRef<T[]>; | ||
| /** | ||
| * Reactive `Array.filter` | ||
| * | ||
| * @see https://vueuse.org/useArrayFilter | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFilter<T, S extends T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => element is S): UseArrayFilterReturn<S>; | ||
| declare function useArrayFilter<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => unknown): UseArrayFilterReturn<T>; | ||
| type UseArrayFindReturn<T = any> = ComputedRef<T | undefined>; | ||
| /** | ||
| * Reactive `Array.find` | ||
| * | ||
| * @see https://vueuse.org/useArrayFind | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFind<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean): UseArrayFindReturn<T>; | ||
| type UseArrayFindIndexReturn = ComputedRef<number>; | ||
| /** | ||
| * Reactive `Array.findIndex` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindIndex | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the index of the first element in the array that passes the test. Otherwise, "-1". | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFindIndex<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): UseArrayFindIndexReturn; | ||
| type UseArrayFindLastReturn<T = any> = ComputedRef<T | undefined>; | ||
| /** | ||
| * Reactive `Array.findLast` | ||
| * | ||
| * @see https://vueuse.org/useArrayFindLast | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayFindLast<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean): UseArrayFindLastReturn<T>; | ||
| type UseArrayIncludesComparatorFn<T, V> = ((element: T, value: V, index: number, array: MaybeRefOrGetter<T>[]) => boolean); | ||
| interface UseArrayIncludesOptions<T, V> { | ||
| fromIndex?: number; | ||
| comparator?: UseArrayIncludesComparatorFn<T, V> | keyof T; | ||
| } | ||
| type UseArrayIncludesReturn = ComputedRef<boolean>; | ||
| /** | ||
| * Reactive `Array.includes` | ||
| * | ||
| * @see https://vueuse.org/useArrayIncludes | ||
| * | ||
| * @returns true if the `value` is found in the array. Otherwise, false. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: UseArrayIncludesComparatorFn<T, V>): UseArrayIncludesReturn; | ||
| declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: keyof T): UseArrayIncludesReturn; | ||
| declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, options?: UseArrayIncludesOptions<T, V>): UseArrayIncludesReturn; | ||
| type UseArrayJoinReturn = ComputedRef<string>; | ||
| /** | ||
| * Reactive `Array.join` | ||
| * | ||
| * @see https://vueuse.org/useArrayJoin | ||
| * @param list - the array was called upon. | ||
| * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (","). | ||
| * | ||
| * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayJoin(list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>, separator?: MaybeRefOrGetter<string>): UseArrayJoinReturn; | ||
| type UseArrayMapReturn<T = any> = ComputedRef<T[]>; | ||
| /** | ||
| * Reactive `Array.map` | ||
| * | ||
| * @see https://vueuse.org/useArrayMap | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array. | ||
| * | ||
| * @returns a new array with each element being the result of the callback function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayMap<T, U = T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => U): UseArrayMapReturn<U>; | ||
| type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentIndex: number) => R; | ||
| /** | ||
| * Reactive `Array.reduce` | ||
| * | ||
| * @see https://vueuse.org/useArrayReduce | ||
| * @param list - the array was called upon. | ||
| * @param reducer - a "reducer" function. | ||
| * | ||
| * @returns the value that results from running the "reducer" callback function to completion over the entire array. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayReduce<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, reducer: UseArrayReducer<T, T, T>): ComputedRef<T>; | ||
| /** | ||
| * Reactive `Array.reduce` | ||
| * | ||
| * @see https://vueuse.org/useArrayReduce | ||
| * @param list - the array was called upon. | ||
| * @param reducer - a "reducer" function. | ||
| * @param initialValue - a value to be initialized the first time when the callback is called. | ||
| * | ||
| * @returns the value that results from running the "reducer" callback function to completion over the entire array. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayReduce<T, U>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, reducer: UseArrayReducer<U, T, U>, initialValue: MaybeRefOrGetter<U>): ComputedRef<U>; | ||
| type UseArraySomeReturn = ComputedRef<boolean>; | ||
| /** | ||
| * Reactive `Array.some` | ||
| * | ||
| * @see https://vueuse.org/useArraySome | ||
| * @param list - the array was called upon. | ||
| * @param fn - a function to test each element. | ||
| * | ||
| * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArraySome<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): UseArraySomeReturn; | ||
| type UseArrayUniqueReturn<T = any> = ComputedRef<T[]>; | ||
| /** | ||
| * reactive unique array | ||
| * @see https://vueuse.org/useArrayUnique | ||
| * @param list - the array was called upon. | ||
| * @param compareFn | ||
| * @returns A computed ref that returns a unique array of items. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useArrayUnique<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, compareFn?: (a: T, b: T, array: T[]) => boolean): UseArrayUniqueReturn<T>; | ||
| interface UseCounterOptions { | ||
| min?: number; | ||
| max?: number; | ||
| } | ||
| interface UseCounterReturn { | ||
| /** | ||
| * The current value of the counter. | ||
| */ | ||
| readonly count: Readonly<Ref<number>>; | ||
| /** | ||
| * Increment the counter. | ||
| * | ||
| * @param {number} [delta=1] The number to increment. | ||
| */ | ||
| inc: (delta?: number) => void; | ||
| /** | ||
| * Decrement the counter. | ||
| * | ||
| * @param {number} [delta=1] The number to decrement. | ||
| */ | ||
| dec: (delta?: number) => void; | ||
| /** | ||
| * Get the current value of the counter. | ||
| */ | ||
| get: () => number; | ||
| /** | ||
| * Set the counter to a new value. | ||
| * | ||
| * @param val The new value of the counter. | ||
| */ | ||
| set: (val: number) => void; | ||
| /** | ||
| * Reset the counter to an initial value. | ||
| */ | ||
| reset: (val?: number) => number; | ||
| } | ||
| /** | ||
| * Basic counter with utility functions. | ||
| * | ||
| * @see https://vueuse.org/useCounter | ||
| * @param [initialValue] | ||
| * @param options | ||
| */ | ||
| declare function useCounter(initialValue?: MaybeRef<number>, options?: UseCounterOptions): { | ||
| count: Readonly<Ref<number, number> | vue.ShallowRef<number, number> | vue.WritableComputedRef<number, number>>; | ||
| inc: (delta?: number) => number; | ||
| dec: (delta?: number) => number; | ||
| get: () => number; | ||
| set: (val: number) => number; | ||
| reset: (val?: number) => number; | ||
| }; | ||
| type DateLike = Date | number | string | undefined; | ||
| interface UseDateFormatOptions { | ||
| /** | ||
| * The locale(s) to used for dd/ddd/dddd/MMM/MMMM format | ||
| * | ||
| * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument). | ||
| */ | ||
| locales?: MaybeRefOrGetter<Intl.LocalesArgument>; | ||
| /** | ||
| * A custom function to re-modify the way to display meridiem | ||
| * | ||
| */ | ||
| customMeridiem?: (hours: number, minutes: number, isLowercase?: boolean, hasPeriod?: boolean) => string; | ||
| } | ||
| declare function formatDate(date: Date, formatStr: string, options?: UseDateFormatOptions): string; | ||
| declare function normalizeDate(date: DateLike): Date; | ||
| type UseDateFormatReturn = ComputedRef<string>; | ||
| /** | ||
| * Get the formatted date according to the string of tokens passed in. | ||
| * | ||
| * @see https://vueuse.org/useDateFormat | ||
| * @param date - The date to format, can either be a `Date` object, a timestamp, or a string | ||
| * @param formatStr - The combination of tokens to format the date | ||
| * @param options - UseDateFormatOptions | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useDateFormat(date: MaybeRefOrGetter<DateLike>, formatStr?: MaybeRefOrGetter<string>, options?: UseDateFormatOptions): UseDateFormatReturn; | ||
| type UseDebounceFnReturn<T extends FunctionArgs> = PromisifyFn<T>; | ||
| /** | ||
| * Debounce execution of a function. | ||
| * | ||
| * @see https://vueuse.org/useDebounceFn | ||
| * @param fn A function to be executed after delay milliseconds debounced. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * @param options Options | ||
| * | ||
| * @return A new, debounce, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): UseDebounceFnReturn<T>; | ||
| interface UseIntervalOptions<Controls extends boolean> { | ||
| /** | ||
| * Expose more controls | ||
| * | ||
| * @default false | ||
| */ | ||
| controls?: Controls; | ||
| /** | ||
| * Execute the update immediately on calling | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Callback on every interval | ||
| */ | ||
| callback?: (count: number) => void; | ||
| } | ||
| interface UseIntervalControls { | ||
| counter: ShallowRef<number>; | ||
| reset: () => void; | ||
| } | ||
| type UseIntervalReturn = Readonly<ShallowRef<number>> | Readonly<UseIntervalControls & Pausable>; | ||
| /** | ||
| * Reactive counter increases on every interval | ||
| * | ||
| * @see https://vueuse.org/useInterval | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useInterval(interval?: MaybeRefOrGetter<number>, options?: UseIntervalOptions<false>): Readonly<ShallowRef<number>>; | ||
| declare function useInterval(interval: MaybeRefOrGetter<number>, options: UseIntervalOptions<true>): Readonly<UseIntervalControls & Pausable>; | ||
| interface UseIntervalFnOptions { | ||
| /** | ||
| * Start the timer immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Execute the callback immediately after calling `resume` | ||
| * | ||
| * @default false | ||
| */ | ||
| immediateCallback?: boolean; | ||
| } | ||
| type UseIntervalFnReturn = Pausable; | ||
| /** | ||
| * Wrapper for `setInterval` with controls | ||
| * | ||
| * @see https://vueuse.org/useIntervalFn | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useIntervalFn(cb: Fn, interval?: MaybeRefOrGetter<number>, options?: UseIntervalFnOptions): UseIntervalFnReturn; | ||
| interface UseLastChangedOptions<Immediate extends boolean, InitialValue extends number | null | undefined = undefined> extends WatchOptions<Immediate> { | ||
| initialValue?: InitialValue; | ||
| } | ||
| type UseLastChangedReturn = Readonly<ShallowRef<number | null>> | Readonly<ShallowRef<number>>; | ||
| /** | ||
| * Records the timestamp of the last change | ||
| * | ||
| * @see https://vueuse.org/useLastChanged | ||
| */ | ||
| declare function useLastChanged(source: WatchSource, options?: UseLastChangedOptions<false>): Readonly<ShallowRef<number | null>>; | ||
| declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true> | UseLastChangedOptions<boolean, number>): Readonly<ShallowRef<number>>; | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is, | ||
| * to `callback` when the throttled-function is executed. | ||
| * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. | ||
| * (default value: 200) | ||
| * | ||
| * @param [trailing] if true, call fn again after the time is up (default value: false) | ||
| * | ||
| * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true) | ||
| * | ||
| * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false) | ||
| * | ||
| * @return A new, throttled, function. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useThrottleFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): PromisifyFn<T>; | ||
| interface UseTimeoutFnOptions { | ||
| /** | ||
| * Start the timer immediately | ||
| * | ||
| * @default true | ||
| */ | ||
| immediate?: boolean; | ||
| /** | ||
| * Execute the callback immediately after calling `start` | ||
| * | ||
| * @default false | ||
| */ | ||
| immediateCallback?: boolean; | ||
| } | ||
| type UseTimeoutFnReturn<CallbackFn extends AnyFn> = Stoppable<Parameters<CallbackFn> | []>; | ||
| /** | ||
| * Wrapper for `setTimeout` with controls. | ||
| * | ||
| * @param cb | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useTimeoutFn<CallbackFn extends AnyFn>(cb: CallbackFn, interval: MaybeRefOrGetter<number>, options?: UseTimeoutFnOptions): UseTimeoutFnReturn<CallbackFn>; | ||
| interface UseTimeoutOptions<Controls extends boolean> extends UseTimeoutFnOptions { | ||
| /** | ||
| * Expose more controls | ||
| * | ||
| * @default false | ||
| */ | ||
| controls?: Controls; | ||
| /** | ||
| * Callback on timeout | ||
| */ | ||
| callback?: Fn; | ||
| } | ||
| type UseTimoutReturn = ComputedRef<boolean> | { | ||
| readonly ready: ComputedRef<boolean>; | ||
| } & Stoppable; | ||
| /** | ||
| * Update value after a given time with controls. | ||
| * | ||
| * @see {@link https://vueuse.org/useTimeout} | ||
| * @param interval | ||
| * @param options | ||
| */ | ||
| declare function useTimeout(interval?: MaybeRefOrGetter<number>, options?: UseTimeoutOptions<false>): ComputedRef<boolean>; | ||
| declare function useTimeout(interval: MaybeRefOrGetter<number>, options: UseTimeoutOptions<true>): { | ||
| ready: ComputedRef<boolean>; | ||
| } & Stoppable; | ||
| interface UseToNumberOptions { | ||
| /** | ||
| * Method to use to convert the value to a number. | ||
| * | ||
| * Or a custom function for the conversion. | ||
| * | ||
| * @default 'parseFloat' | ||
| */ | ||
| method?: 'parseFloat' | 'parseInt' | ((value: string | number) => number); | ||
| /** | ||
| * The base in mathematical numeral systems passed to `parseInt`. | ||
| * Only works with `method: 'parseInt'` | ||
| */ | ||
| radix?: number; | ||
| /** | ||
| * Replace NaN with zero | ||
| * | ||
| * @default false | ||
| */ | ||
| nanToZero?: boolean; | ||
| } | ||
| /** | ||
| * Reactively convert a string ref to number. | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useToNumber(value: MaybeRefOrGetter<number | string>, options?: UseToNumberOptions): ComputedRef<number>; | ||
| /** | ||
| * Reactively convert a ref to string. | ||
| * | ||
| * @see https://vueuse.org/useToString | ||
| * | ||
| * @__NO_SIDE_EFFECTS__ | ||
| */ | ||
| declare function useToString(value: MaybeRefOrGetter<unknown>): ComputedRef<string>; | ||
| type ToggleFn = (value?: boolean) => void; | ||
| type UseToggleReturn = [ShallowRef<boolean>, ToggleFn] | ToggleFn; | ||
| interface UseToggleOptions<Truthy, Falsy> { | ||
| truthyValue?: MaybeRefOrGetter<Truthy>; | ||
| falsyValue?: MaybeRefOrGetter<Falsy>; | ||
| } | ||
| declare function useToggle<Truthy, Falsy, T = Truthy | Falsy>(initialValue: Ref<T>, options?: UseToggleOptions<Truthy, Falsy>): (value?: T) => T; | ||
| declare function useToggle<Truthy = true, Falsy = false, T = Truthy | Falsy>(initialValue?: T, options?: UseToggleOptions<Truthy, Falsy>): [ShallowRef<T>, (value?: T) => T]; | ||
| declare type WatchArrayCallback<V = any, OV = any> = (value: V, oldValue: OV, added: V, removed: OV, onCleanup: (cleanupFn: () => void) => void) => any; | ||
| /** | ||
| * Watch for an array with additions and removals. | ||
| * | ||
| * @see https://vueuse.org/watchArray | ||
| */ | ||
| declare function watchArray<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T[]> | T[], cb: WatchArrayCallback<T[], Immediate extends true ? T[] | undefined : T[]>, options?: WatchOptions<Immediate>): vue.WatchHandle; | ||
| interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter { | ||
| } | ||
| declare function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle; | ||
| declare function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle; | ||
| declare function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle; | ||
| interface WatchAtMostOptions<Immediate> extends WatchWithFilterOptions<Immediate> { | ||
| count: MaybeRefOrGetter<number>; | ||
| } | ||
| interface WatchAtMostReturn { | ||
| stop: WatchStopHandle; | ||
| count: ShallowRef<number>; | ||
| } | ||
| declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn; | ||
| declare function watchAtMost<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn; | ||
| interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate>, DebounceFilterOptions { | ||
| debounce?: MaybeRefOrGetter<number>; | ||
| } | ||
| declare function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle; | ||
| declare function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle; | ||
| declare function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle; | ||
| declare function watchDeep<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle; | ||
| declare function watchDeep<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle; | ||
| declare function watchDeep<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle; | ||
| type IgnoredUpdater = (updater: () => void) => void; | ||
| type IgnoredPrevAsyncUpdates = () => void; | ||
| interface WatchIgnorableReturn { | ||
| ignoreUpdates: IgnoredUpdater; | ||
| ignorePrevAsyncUpdates: IgnoredPrevAsyncUpdates; | ||
| stop: WatchStopHandle; | ||
| } | ||
| declare function watchIgnorable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn; | ||
| declare function watchIgnorable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn; | ||
| declare function watchIgnorable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn; | ||
| declare function watchImmediate<T extends Readonly<WatchSource<unknown>[]>>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle; | ||
| declare function watchImmediate<T>(source: WatchSource<T>, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle; | ||
| declare function watchImmediate<T extends object>(source: T, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle; | ||
| declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>, options?: Omit<WatchOptions<true>, 'once'>): WatchStopHandle; | ||
| declare function watchOnce<T>(source: WatchSource<T>, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'once'>): WatchStopHandle; | ||
| declare function watchOnce<T extends object>(source: T, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'once'>): WatchStopHandle; | ||
| interface WatchPausableReturn extends Pausable { | ||
| stop: WatchStopHandle; | ||
| } | ||
| type WatchPausableOptions<Immediate> = WatchWithFilterOptions<Immediate> & PausableFilterOptions; | ||
| declare function watchPausable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn; | ||
| declare function watchPausable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn; | ||
| declare function watchPausable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn; | ||
| interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate> { | ||
| throttle?: MaybeRefOrGetter<number>; | ||
| trailing?: boolean; | ||
| leading?: boolean; | ||
| } | ||
| declare function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle; | ||
| declare function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle; | ||
| declare function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle; | ||
| interface WatchTriggerableReturn<FnReturnT = void> extends WatchIgnorableReturn { | ||
| /** Execute `WatchCallback` immediately */ | ||
| trigger: () => FnReturnT; | ||
| } | ||
| type OnCleanup = (cleanupFn: () => void) => void; | ||
| type WatchTriggerableCallback<V = any, OV = any, R = void> = (value: V, oldValue: OV, onCleanup: OnCleanup) => R; | ||
| declare function watchTriggerable<T extends Readonly<WatchSource<unknown>[]>, FnReturnT>(sources: [...T], cb: WatchTriggerableCallback<MapSources<T>, MapOldSources<T, true>, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>; | ||
| declare function watchTriggerable<T, FnReturnT>(source: WatchSource<T>, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>; | ||
| declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>; | ||
| interface WheneverOptions extends WatchOptions { | ||
| /** | ||
| * Only trigger once when the condition is met | ||
| * | ||
| * Override the `once` option in `WatchOptions` | ||
| * | ||
| * @default false | ||
| */ | ||
| once?: boolean; | ||
| } | ||
| /** | ||
| * Shorthand for watching value to be truthy | ||
| * | ||
| * @see https://vueuse.org/whenever | ||
| */ | ||
| declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WheneverOptions): vue.WatchHandle; | ||
| export { assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createRef, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toArray, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever }; | ||
| export type { AnyFn, ArgumentsType, Arrayable, Awaitable, Awaited, ComputedEagerOptions, ComputedEagerReturn, ComputedRefWithControl, ComputedWithControlRef, ComputedWithControlRefExtra, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, CreateInjectionStateOptions, CreateRefReturn, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookReturn, EventHookTrigger, ExtendRefOptions, ExtendRefReturn, Fn, FunctionArgs, FunctionWrapperOptions, IfAny, IgnoredPrevAsyncUpdates, IgnoredUpdater, IsAny, IsDefinedReturn, MapOldSources, MapSources, MultiWatchSources, Mutable, Pausable, PausableFilterOptions, Promisify, PromisifyFn, ProvideLocalReturn, Reactified, ReactifyNested, ReactifyObjectOptions, ReactifyObjectReturn, ReactifyOptions, ReactifyReturn, ReactiveComputedReturn, ReactiveOmitPredicate, ReactiveOmitReturn, ReactivePickPredicate, ReactivePickReturn, ReadonlyRefOrGetter, RefAutoResetReturn, RefDebouncedReturn, RefThrottledReturn, RemovableRef, ShallowOrDeepRef, ShallowUnwrapRef, SharedComposableReturn, SingletonPromiseReturn, Stoppable, SyncRefOptions, SyncRefsOptions, ThrottleFilterOptions, TimerHandle, ToRefsOptions, ToggleFn, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseArrayDifferenceOptions, UseArrayDifferenceReturn, UseArrayEveryReturn, UseArrayFilterReturn, UseArrayFindIndexReturn, UseArrayFindLastReturn, UseArrayFindReturn, UseArrayIncludesComparatorFn, UseArrayIncludesOptions, UseArrayIncludesReturn, UseArrayJoinReturn, UseArrayMapReturn, UseArrayReducer, UseArraySomeReturn, UseArrayUniqueReturn, UseCounterOptions, UseCounterReturn, UseDateFormatOptions, UseDateFormatReturn, UseDebounceFnReturn, UseIntervalControls, UseIntervalFnOptions, UseIntervalFnReturn, UseIntervalOptions, UseIntervalReturn, UseLastChangedOptions, UseLastChangedReturn, UseTimeoutFnOptions, UseTimeoutFnReturn, UseTimeoutOptions, UseTimoutReturn, UseToNumberOptions, UseToggleOptions, UseToggleReturn, WatchArrayCallback, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableOptions, WatchPausableReturn, WatchThrottledOptions, WatchTriggerableCallback, WatchTriggerableReturn, WatchWithFilterOptions, WheneverOptions, WritableComputedRefWithControl }; |
-1765
| (function (exports, vue) { | ||
| 'use strict'; | ||
| function computedEager(fn, options) { | ||
| var _a; | ||
| const result = vue.shallowRef(); | ||
| vue.watchEffect(() => { | ||
| result.value = fn(); | ||
| }, { | ||
| ...options, | ||
| flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync" | ||
| }); | ||
| return vue.readonly(result); | ||
| } | ||
| function computedWithControl(source, fn, options = {}) { | ||
| let v = void 0; | ||
| let track; | ||
| let trigger; | ||
| let dirty = true; | ||
| const update = () => { | ||
| dirty = true; | ||
| trigger(); | ||
| }; | ||
| vue.watch(source, update, { flush: "sync", ...options }); | ||
| const get = typeof fn === "function" ? fn : fn.get; | ||
| const set = typeof fn === "function" ? void 0 : fn.set; | ||
| const result = vue.customRef((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| if (dirty) { | ||
| v = get(v); | ||
| dirty = false; | ||
| } | ||
| track(); | ||
| return v; | ||
| }, | ||
| set(v2) { | ||
| set == null ? void 0 : set(v2); | ||
| } | ||
| }; | ||
| }); | ||
| result.trigger = update; | ||
| return result; | ||
| } | ||
| function tryOnScopeDispose(fn) { | ||
| if (vue.getCurrentScope()) { | ||
| vue.onScopeDispose(fn); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createEventHook() { | ||
| const fns = /* @__PURE__ */ new Set(); | ||
| const off = (fn) => { | ||
| fns.delete(fn); | ||
| }; | ||
| const clear = () => { | ||
| fns.clear(); | ||
| }; | ||
| const on = (fn) => { | ||
| fns.add(fn); | ||
| const offFn = () => off(fn); | ||
| tryOnScopeDispose(offFn); | ||
| return { | ||
| off: offFn | ||
| }; | ||
| }; | ||
| const trigger = (...args) => { | ||
| return Promise.all(Array.from(fns).map((fn) => fn(...args))); | ||
| }; | ||
| return { | ||
| on, | ||
| off, | ||
| trigger, | ||
| clear | ||
| }; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createGlobalState(stateFactory) { | ||
| let initialized = false; | ||
| let state; | ||
| const scope = vue.effectScope(true); | ||
| return (...args) => { | ||
| if (!initialized) { | ||
| state = scope.run(() => stateFactory(...args)); | ||
| initialized = true; | ||
| } | ||
| return state; | ||
| }; | ||
| } | ||
| const localProvidedStateMap = /* @__PURE__ */ new WeakMap(); | ||
| const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => { | ||
| var _a; | ||
| const key = args[0]; | ||
| const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy; | ||
| if (instance == null && !vue.hasInjectionContext()) | ||
| throw new Error("injectLocal must be called in setup"); | ||
| if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance)) | ||
| return localProvidedStateMap.get(instance)[key]; | ||
| return vue.inject(...args); | ||
| }; | ||
| function provideLocal(key, value) { | ||
| var _a; | ||
| const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy; | ||
| if (instance == null) | ||
| throw new Error("provideLocal must be called in setup"); | ||
| if (!localProvidedStateMap.has(instance)) | ||
| localProvidedStateMap.set(instance, /* @__PURE__ */ Object.create(null)); | ||
| const localProvidedState = localProvidedStateMap.get(instance); | ||
| localProvidedState[key] = value; | ||
| return vue.provide(key, value); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createInjectionState(composable, options) { | ||
| const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState"); | ||
| const defaultValue = options == null ? void 0 : options.defaultValue; | ||
| const useProvidingState = (...args) => { | ||
| const state = composable(...args); | ||
| provideLocal(key, state); | ||
| return state; | ||
| }; | ||
| const useInjectedState = () => injectLocal(key, defaultValue); | ||
| return [useProvidingState, useInjectedState]; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createRef(value, deep) { | ||
| if (deep === true) { | ||
| return vue.ref(value); | ||
| } else { | ||
| return vue.shallowRef(value); | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createSharedComposable(composable) { | ||
| let subscribers = 0; | ||
| let state; | ||
| let scope; | ||
| const dispose = () => { | ||
| subscribers -= 1; | ||
| if (scope && subscribers <= 0) { | ||
| scope.stop(); | ||
| state = void 0; | ||
| scope = void 0; | ||
| } | ||
| }; | ||
| return (...args) => { | ||
| subscribers += 1; | ||
| if (!scope) { | ||
| scope = vue.effectScope(true); | ||
| state = scope.run(() => composable(...args)); | ||
| } | ||
| tryOnScopeDispose(dispose); | ||
| return state; | ||
| }; | ||
| } | ||
| function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) { | ||
| for (const [key, value] of Object.entries(extend)) { | ||
| if (key === "value") | ||
| continue; | ||
| if (vue.isRef(value) && unwrap) { | ||
| Object.defineProperty(ref, key, { | ||
| get() { | ||
| return value.value; | ||
| }, | ||
| set(v) { | ||
| value.value = v; | ||
| }, | ||
| enumerable | ||
| }); | ||
| } else { | ||
| Object.defineProperty(ref, key, { value, enumerable }); | ||
| } | ||
| } | ||
| return ref; | ||
| } | ||
| function get(obj, key) { | ||
| if (key == null) | ||
| return vue.unref(obj); | ||
| return vue.unref(obj)[key]; | ||
| } | ||
| function isDefined(v) { | ||
| return vue.unref(v) != null; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function makeDestructurable(obj, arr) { | ||
| if (typeof Symbol !== "undefined") { | ||
| const clone = { ...obj }; | ||
| Object.defineProperty(clone, Symbol.iterator, { | ||
| enumerable: false, | ||
| value() { | ||
| let index = 0; | ||
| return { | ||
| next: () => ({ | ||
| value: arr[index++], | ||
| done: index > arr.length | ||
| }) | ||
| }; | ||
| } | ||
| }); | ||
| return clone; | ||
| } else { | ||
| return Object.assign([...arr], obj); | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function reactify(fn, options) { | ||
| const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vue.unref : vue.toValue; | ||
| return function(...args) { | ||
| return vue.computed(() => fn.apply(this, args.map((i) => unrefFn(i)))); | ||
| }; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function reactifyObject(obj, optionsOrKeys = {}) { | ||
| let keys = []; | ||
| let options; | ||
| if (Array.isArray(optionsOrKeys)) { | ||
| keys = optionsOrKeys; | ||
| } else { | ||
| options = optionsOrKeys; | ||
| const { includeOwnProperties = true } = optionsOrKeys; | ||
| keys.push(...Object.keys(obj)); | ||
| if (includeOwnProperties) | ||
| keys.push(...Object.getOwnPropertyNames(obj)); | ||
| } | ||
| return Object.fromEntries( | ||
| keys.map((key) => { | ||
| const value = obj[key]; | ||
| return [ | ||
| key, | ||
| typeof value === "function" ? reactify(value.bind(obj), options) : value | ||
| ]; | ||
| }) | ||
| ); | ||
| } | ||
| function toReactive(objectRef) { | ||
| if (!vue.isRef(objectRef)) | ||
| return vue.reactive(objectRef); | ||
| const proxy = new Proxy({}, { | ||
| get(_, p, receiver) { | ||
| return vue.unref(Reflect.get(objectRef.value, p, receiver)); | ||
| }, | ||
| set(_, p, value) { | ||
| if (vue.isRef(objectRef.value[p]) && !vue.isRef(value)) | ||
| objectRef.value[p].value = value; | ||
| else | ||
| objectRef.value[p] = value; | ||
| return true; | ||
| }, | ||
| deleteProperty(_, p) { | ||
| return Reflect.deleteProperty(objectRef.value, p); | ||
| }, | ||
| has(_, p) { | ||
| return Reflect.has(objectRef.value, p); | ||
| }, | ||
| ownKeys() { | ||
| return Object.keys(objectRef.value); | ||
| }, | ||
| getOwnPropertyDescriptor() { | ||
| return { | ||
| enumerable: true, | ||
| configurable: true | ||
| }; | ||
| } | ||
| }); | ||
| return vue.reactive(proxy); | ||
| } | ||
| function reactiveComputed(fn) { | ||
| return toReactive(vue.computed(fn)); | ||
| } | ||
| function reactiveOmit(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => !predicate(vue.toValue(v), k))) : Object.fromEntries(Object.entries(vue.toRefs(obj)).filter((e) => !flatKeys.includes(e[0])))); | ||
| } | ||
| const isClient = typeof window !== "undefined" && typeof document !== "undefined"; | ||
| const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; | ||
| const isDef = (val) => typeof val !== "undefined"; | ||
| const notNullish = (val) => val != null; | ||
| const assert = (condition, ...infos) => { | ||
| if (!condition) | ||
| console.warn(...infos); | ||
| }; | ||
| const toString = Object.prototype.toString; | ||
| const isObject = (val) => toString.call(val) === "[object Object]"; | ||
| const now = () => Date.now(); | ||
| const timestamp = () => +Date.now(); | ||
| const clamp = (n, min, max) => Math.min(max, Math.max(min, n)); | ||
| const noop = () => { | ||
| }; | ||
| const rand = (min, max) => { | ||
| min = Math.ceil(min); | ||
| max = Math.floor(max); | ||
| return Math.floor(Math.random() * (max - min + 1)) + min; | ||
| }; | ||
| const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key); | ||
| const isIOS = /* @__PURE__ */ getIsIOS(); | ||
| function getIsIOS() { | ||
| var _a, _b; | ||
| return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent)); | ||
| } | ||
| function toRef(...args) { | ||
| if (args.length !== 1) | ||
| return vue.toRef(...args); | ||
| const r = args[0]; | ||
| return typeof r === "function" ? vue.readonly(vue.customRef(() => ({ get: r, set: noop }))) : vue.ref(r); | ||
| } | ||
| const resolveRef = toRef; | ||
| function reactivePick(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => predicate(vue.toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)]))); | ||
| } | ||
| function refAutoReset(defaultValue, afterMs = 1e4) { | ||
| return vue.customRef((track, trigger) => { | ||
| let value = vue.toValue(defaultValue); | ||
| let timer; | ||
| const resetAfter = () => setTimeout(() => { | ||
| value = vue.toValue(defaultValue); | ||
| trigger(); | ||
| }, vue.toValue(afterMs)); | ||
| tryOnScopeDispose(() => { | ||
| clearTimeout(timer); | ||
| }); | ||
| return { | ||
| get() { | ||
| track(); | ||
| return value; | ||
| }, | ||
| set(newValue) { | ||
| value = newValue; | ||
| trigger(); | ||
| clearTimeout(timer); | ||
| timer = resetAfter(); | ||
| } | ||
| }; | ||
| }); | ||
| } | ||
| function createFilterWrapper(filter, fn) { | ||
| function wrapper(...args) { | ||
| return new Promise((resolve, reject) => { | ||
| Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject); | ||
| }); | ||
| } | ||
| return wrapper; | ||
| } | ||
| const bypassFilter = (invoke) => { | ||
| return invoke(); | ||
| }; | ||
| function debounceFilter(ms, options = {}) { | ||
| let timer; | ||
| let maxTimer; | ||
| let lastRejector = noop; | ||
| const _clearTimeout = (timer2) => { | ||
| clearTimeout(timer2); | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| }; | ||
| let lastInvoker; | ||
| const filter = (invoke) => { | ||
| const duration = vue.toValue(ms); | ||
| const maxDuration = vue.toValue(options.maxWait); | ||
| if (timer) | ||
| _clearTimeout(timer); | ||
| if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) { | ||
| if (maxTimer) { | ||
| _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| } | ||
| return Promise.resolve(invoke()); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| lastRejector = options.rejectOnCancel ? reject : resolve; | ||
| lastInvoker = invoke; | ||
| if (maxDuration && !maxTimer) { | ||
| maxTimer = setTimeout(() => { | ||
| if (timer) | ||
| _clearTimeout(timer); | ||
| maxTimer = void 0; | ||
| resolve(lastInvoker()); | ||
| }, maxDuration); | ||
| } | ||
| timer = setTimeout(() => { | ||
| if (maxTimer) | ||
| _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| resolve(invoke()); | ||
| }, duration); | ||
| }); | ||
| }; | ||
| return filter; | ||
| } | ||
| function throttleFilter(...args) { | ||
| let lastExec = 0; | ||
| let timer; | ||
| let isLeading = true; | ||
| let lastRejector = noop; | ||
| let lastValue; | ||
| let ms; | ||
| let trailing; | ||
| let leading; | ||
| let rejectOnCancel; | ||
| if (!vue.isRef(args[0]) && typeof args[0] === "object") | ||
| ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]); | ||
| else | ||
| [ms, trailing = true, leading = true, rejectOnCancel = false] = args; | ||
| const clear = () => { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| } | ||
| }; | ||
| const filter = (_invoke) => { | ||
| const duration = vue.toValue(ms); | ||
| const elapsed = Date.now() - lastExec; | ||
| const invoke = () => { | ||
| return lastValue = _invoke(); | ||
| }; | ||
| clear(); | ||
| if (duration <= 0) { | ||
| lastExec = Date.now(); | ||
| return invoke(); | ||
| } | ||
| if (elapsed > duration) { | ||
| lastExec = Date.now(); | ||
| if (leading || !isLeading) | ||
| invoke(); | ||
| } else if (trailing) { | ||
| lastValue = new Promise((resolve, reject) => { | ||
| lastRejector = rejectOnCancel ? reject : resolve; | ||
| timer = setTimeout(() => { | ||
| lastExec = Date.now(); | ||
| isLeading = true; | ||
| resolve(invoke()); | ||
| clear(); | ||
| }, Math.max(0, duration - elapsed)); | ||
| }); | ||
| } | ||
| if (!leading && !timer) | ||
| timer = setTimeout(() => isLeading = true, duration); | ||
| isLeading = false; | ||
| return lastValue; | ||
| }; | ||
| return filter; | ||
| } | ||
| function pausableFilter(extendFilter = bypassFilter, options = {}) { | ||
| const { | ||
| initialState = "active" | ||
| } = options; | ||
| const isActive = toRef(initialState === "active"); | ||
| function pause() { | ||
| isActive.value = false; | ||
| } | ||
| function resume() { | ||
| isActive.value = true; | ||
| } | ||
| const eventFilter = (...args) => { | ||
| if (isActive.value) | ||
| extendFilter(...args); | ||
| }; | ||
| return { isActive: vue.readonly(isActive), pause, resume, eventFilter }; | ||
| } | ||
| function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") { | ||
| return new Promise((resolve, reject) => { | ||
| if (throwOnTimeout) | ||
| setTimeout(() => reject(reason), ms); | ||
| else | ||
| setTimeout(resolve, ms); | ||
| }); | ||
| } | ||
| function identity(arg) { | ||
| return arg; | ||
| } | ||
| function createSingletonPromise(fn) { | ||
| let _promise; | ||
| function wrapper() { | ||
| if (!_promise) | ||
| _promise = fn(); | ||
| return _promise; | ||
| } | ||
| wrapper.reset = async () => { | ||
| const _prev = _promise; | ||
| _promise = void 0; | ||
| if (_prev) | ||
| await _prev; | ||
| }; | ||
| return wrapper; | ||
| } | ||
| function invoke(fn) { | ||
| return fn(); | ||
| } | ||
| function containsProp(obj, ...props) { | ||
| return props.some((k) => k in obj); | ||
| } | ||
| function increaseWithUnit(target, delta) { | ||
| var _a; | ||
| if (typeof target === "number") | ||
| return target + delta; | ||
| const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || ""; | ||
| const unit = target.slice(value.length); | ||
| const result = Number.parseFloat(value) + delta; | ||
| if (Number.isNaN(result)) | ||
| return target; | ||
| return result + unit; | ||
| } | ||
| function pxValue(px) { | ||
| return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px); | ||
| } | ||
| function objectPick(obj, keys, omitUndefined = false) { | ||
| return keys.reduce((n, k) => { | ||
| if (k in obj) { | ||
| if (!omitUndefined || obj[k] !== void 0) | ||
| n[k] = obj[k]; | ||
| } | ||
| return n; | ||
| }, {}); | ||
| } | ||
| function objectOmit(obj, keys, omitUndefined = false) { | ||
| return Object.fromEntries(Object.entries(obj).filter(([key, value]) => { | ||
| return (!omitUndefined || value !== void 0) && !keys.includes(key); | ||
| })); | ||
| } | ||
| function objectEntries(obj) { | ||
| return Object.entries(obj); | ||
| } | ||
| function toArray(value) { | ||
| return Array.isArray(value) ? value : [value]; | ||
| } | ||
| function cacheStringFunction(fn) { | ||
| const cache = /* @__PURE__ */ Object.create(null); | ||
| return (str) => { | ||
| const hit = cache[str]; | ||
| return hit || (cache[str] = fn(str)); | ||
| }; | ||
| } | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); | ||
| const camelizeRE = /-(\w)/g; | ||
| const camelize = cacheStringFunction((str) => { | ||
| return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
| }); | ||
| function getLifeCycleTarget(target) { | ||
| return target || vue.getCurrentInstance(); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useDebounceFn(fn, ms = 200, options = {}) { | ||
| return createFilterWrapper( | ||
| debounceFilter(ms, options), | ||
| fn | ||
| ); | ||
| } | ||
| function refDebounced(value, ms = 200, options = {}) { | ||
| const debounced = vue.ref(vue.toValue(value)); | ||
| const updater = useDebounceFn(() => { | ||
| debounced.value = value.value; | ||
| }, ms, options); | ||
| vue.watch(value, () => updater()); | ||
| return vue.shallowReadonly(debounced); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function refDefault(source, defaultValue) { | ||
| return vue.computed({ | ||
| get() { | ||
| var _a; | ||
| return (_a = source.value) != null ? _a : defaultValue; | ||
| }, | ||
| set(value) { | ||
| source.value = value; | ||
| } | ||
| }); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) { | ||
| return createFilterWrapper( | ||
| throttleFilter(ms, trailing, leading, rejectOnCancel), | ||
| fn | ||
| ); | ||
| } | ||
| function refThrottled(value, delay = 200, trailing = true, leading = true) { | ||
| if (delay <= 0) | ||
| return value; | ||
| const throttled = vue.ref(vue.toValue(value)); | ||
| const updater = useThrottleFn(() => { | ||
| throttled.value = value.value; | ||
| }, delay, trailing, leading); | ||
| vue.watch(value, () => updater()); | ||
| return throttled; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function refWithControl(initial, options = {}) { | ||
| let source = initial; | ||
| let track; | ||
| let trigger; | ||
| const ref = vue.customRef((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| return get(); | ||
| }, | ||
| set(v) { | ||
| set(v); | ||
| } | ||
| }; | ||
| }); | ||
| function get(tracking = true) { | ||
| if (tracking) | ||
| track(); | ||
| return source; | ||
| } | ||
| function set(value, triggering = true) { | ||
| var _a, _b; | ||
| if (value === source) | ||
| return; | ||
| const old = source; | ||
| if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false) | ||
| return; | ||
| source = value; | ||
| (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old); | ||
| if (triggering) | ||
| trigger(); | ||
| } | ||
| const untrackedGet = () => get(false); | ||
| const silentSet = (v) => set(v, false); | ||
| const peek = () => get(false); | ||
| const lay = (v) => set(v, false); | ||
| return extendRef( | ||
| ref, | ||
| { | ||
| get, | ||
| set, | ||
| untrackedGet, | ||
| silentSet, | ||
| peek, | ||
| lay | ||
| }, | ||
| { enumerable: true } | ||
| ); | ||
| } | ||
| const controlledRef = refWithControl; | ||
| function set(...args) { | ||
| if (args.length === 2) { | ||
| const [ref, value] = args; | ||
| ref.value = value; | ||
| } | ||
| if (args.length === 3) { | ||
| const [target, key, value] = args; | ||
| target[key] = value; | ||
| } | ||
| } | ||
| function watchWithFilter(source, cb, options = {}) { | ||
| const { | ||
| eventFilter = bypassFilter, | ||
| ...watchOptions | ||
| } = options; | ||
| return vue.watch( | ||
| source, | ||
| createFilterWrapper( | ||
| eventFilter, | ||
| cb | ||
| ), | ||
| watchOptions | ||
| ); | ||
| } | ||
| function watchPausable(source, cb, options = {}) { | ||
| const { | ||
| eventFilter: filter, | ||
| initialState = "active", | ||
| ...watchOptions | ||
| } = options; | ||
| const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState }); | ||
| const stop = watchWithFilter( | ||
| source, | ||
| cb, | ||
| { | ||
| ...watchOptions, | ||
| eventFilter | ||
| } | ||
| ); | ||
| return { stop, pause, resume, isActive }; | ||
| } | ||
| function syncRef(left, right, ...[options]) { | ||
| const { | ||
| flush = "sync", | ||
| deep = false, | ||
| immediate = true, | ||
| direction = "both", | ||
| transform = {} | ||
| } = options || {}; | ||
| const watchers = []; | ||
| const transformLTR = "ltr" in transform && transform.ltr || ((v) => v); | ||
| const transformRTL = "rtl" in transform && transform.rtl || ((v) => v); | ||
| if (direction === "both" || direction === "ltr") { | ||
| watchers.push(watchPausable( | ||
| left, | ||
| (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| right.value = transformLTR(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, | ||
| { flush, deep, immediate } | ||
| )); | ||
| } | ||
| if (direction === "both" || direction === "rtl") { | ||
| watchers.push(watchPausable( | ||
| right, | ||
| (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| left.value = transformRTL(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, | ||
| { flush, deep, immediate } | ||
| )); | ||
| } | ||
| const stop = () => { | ||
| watchers.forEach((w) => w.stop()); | ||
| }; | ||
| return stop; | ||
| } | ||
| function syncRefs(source, targets, options = {}) { | ||
| const { | ||
| flush = "sync", | ||
| deep = false, | ||
| immediate = true | ||
| } = options; | ||
| const targetsArray = toArray(targets); | ||
| return vue.watch( | ||
| source, | ||
| (newValue) => targetsArray.forEach((target) => target.value = newValue), | ||
| { flush, deep, immediate } | ||
| ); | ||
| } | ||
| function toRefs(objectRef, options = {}) { | ||
| if (!vue.isRef(objectRef)) | ||
| return vue.toRefs(objectRef); | ||
| const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {}; | ||
| for (const key in objectRef.value) { | ||
| result[key] = vue.customRef(() => ({ | ||
| get() { | ||
| return objectRef.value[key]; | ||
| }, | ||
| set(v) { | ||
| var _a; | ||
| const replaceRef = (_a = vue.toValue(options.replaceRef)) != null ? _a : true; | ||
| if (replaceRef) { | ||
| if (Array.isArray(objectRef.value)) { | ||
| const copy = [...objectRef.value]; | ||
| copy[key] = v; | ||
| objectRef.value = copy; | ||
| } else { | ||
| const newObject = { ...objectRef.value, [key]: v }; | ||
| Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value)); | ||
| objectRef.value = newObject; | ||
| } | ||
| } else { | ||
| objectRef.value[key] = v; | ||
| } | ||
| } | ||
| })); | ||
| } | ||
| return result; | ||
| } | ||
| const toValue = vue.toValue; | ||
| const resolveUnref = vue.toValue; | ||
| function tryOnBeforeMount(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| vue.onBeforeMount(fn, target); | ||
| else if (sync) | ||
| fn(); | ||
| else | ||
| vue.nextTick(fn); | ||
| } | ||
| function tryOnBeforeUnmount(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| vue.onBeforeUnmount(fn, target); | ||
| } | ||
| function tryOnMounted(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| vue.onMounted(fn, target); | ||
| else if (sync) | ||
| fn(); | ||
| else | ||
| vue.nextTick(fn); | ||
| } | ||
| function tryOnUnmounted(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| vue.onUnmounted(fn, target); | ||
| } | ||
| function createUntil(r, isNot = false) { | ||
| function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) { | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = vue.watch( | ||
| r, | ||
| (v) => { | ||
| if (condition(v) !== isNot) { | ||
| if (stop) | ||
| stop(); | ||
| else | ||
| vue.nextTick(() => stop == null ? void 0 : stop()); | ||
| resolve(v); | ||
| } | ||
| }, | ||
| { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| } | ||
| ); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) { | ||
| promises.push( | ||
| promiseTimeout(timeout, throwOnTimeout).then(() => vue.toValue(r)).finally(() => stop == null ? void 0 : stop()) | ||
| ); | ||
| } | ||
| return Promise.race(promises); | ||
| } | ||
| function toBe(value, options) { | ||
| if (!vue.isRef(value)) | ||
| return toMatch((v) => v === value, options); | ||
| const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {}; | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = vue.watch( | ||
| [r, value], | ||
| ([v1, v2]) => { | ||
| if (isNot !== (v1 === v2)) { | ||
| if (stop) | ||
| stop(); | ||
| else | ||
| vue.nextTick(() => stop == null ? void 0 : stop()); | ||
| resolve(v1); | ||
| } | ||
| }, | ||
| { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| } | ||
| ); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) { | ||
| promises.push( | ||
| promiseTimeout(timeout, throwOnTimeout).then(() => vue.toValue(r)).finally(() => { | ||
| stop == null ? void 0 : stop(); | ||
| return vue.toValue(r); | ||
| }) | ||
| ); | ||
| } | ||
| return Promise.race(promises); | ||
| } | ||
| function toBeTruthy(options) { | ||
| return toMatch((v) => Boolean(v), options); | ||
| } | ||
| function toBeNull(options) { | ||
| return toBe(null, options); | ||
| } | ||
| function toBeUndefined(options) { | ||
| return toBe(void 0, options); | ||
| } | ||
| function toBeNaN(options) { | ||
| return toMatch(Number.isNaN, options); | ||
| } | ||
| function toContains(value, options) { | ||
| return toMatch((v) => { | ||
| const array = Array.from(v); | ||
| return array.includes(value) || array.includes(vue.toValue(value)); | ||
| }, options); | ||
| } | ||
| function changed(options) { | ||
| return changedTimes(1, options); | ||
| } | ||
| function changedTimes(n = 1, options) { | ||
| let count = -1; | ||
| return toMatch(() => { | ||
| count += 1; | ||
| return count >= n; | ||
| }, options); | ||
| } | ||
| if (Array.isArray(vue.toValue(r))) { | ||
| const instance = { | ||
| toMatch, | ||
| toContains, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } else { | ||
| const instance = { | ||
| toMatch, | ||
| toBe, | ||
| toBeTruthy, | ||
| toBeNull, | ||
| toBeNaN, | ||
| toBeUndefined, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } | ||
| } | ||
| function until(r) { | ||
| return createUntil(r); | ||
| } | ||
| function defaultComparator(value, othVal) { | ||
| return value === othVal; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayDifference(...args) { | ||
| var _a, _b; | ||
| const list = args[0]; | ||
| const values = args[1]; | ||
| let compareFn = (_a = args[2]) != null ? _a : defaultComparator; | ||
| const { | ||
| symmetric = false | ||
| } = (_b = args[3]) != null ? _b : {}; | ||
| if (typeof compareFn === "string") { | ||
| const key = compareFn; | ||
| compareFn = (value, othVal) => value[key] === othVal[key]; | ||
| } | ||
| const diff1 = vue.computed(() => vue.toValue(list).filter((x) => vue.toValue(values).findIndex((y) => compareFn(x, y)) === -1)); | ||
| if (symmetric) { | ||
| const diff2 = vue.computed(() => vue.toValue(values).filter((x) => vue.toValue(list).findIndex((y) => compareFn(x, y)) === -1)); | ||
| return vue.computed(() => symmetric ? [...vue.toValue(diff1), ...vue.toValue(diff2)] : vue.toValue(diff1)); | ||
| } else { | ||
| return diff1; | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayEvery(list, fn) { | ||
| return vue.computed(() => vue.toValue(list).every((element, index, array) => fn(vue.toValue(element), index, array))); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFilter(list, fn) { | ||
| return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).filter(fn)); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFind(list, fn) { | ||
| return vue.computed(() => vue.toValue( | ||
| vue.toValue(list).find((element, index, array) => fn(vue.toValue(element), index, array)) | ||
| )); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFindIndex(list, fn) { | ||
| return vue.computed(() => vue.toValue(list).findIndex((element, index, array) => fn(vue.toValue(element), index, array))); | ||
| } | ||
| function findLast(arr, cb) { | ||
| let index = arr.length; | ||
| while (index-- > 0) { | ||
| if (cb(arr[index], index, arr)) | ||
| return arr[index]; | ||
| } | ||
| return void 0; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFindLast(list, fn) { | ||
| return vue.computed(() => vue.toValue( | ||
| !Array.prototype.findLast ? findLast(vue.toValue(list), (element, index, array) => fn(vue.toValue(element), index, array)) : vue.toValue(list).findLast((element, index, array) => fn(vue.toValue(element), index, array)) | ||
| )); | ||
| } | ||
| function isArrayIncludesOptions(obj) { | ||
| return isObject(obj) && containsProp(obj, "formIndex", "comparator"); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayIncludes(...args) { | ||
| var _a; | ||
| const list = args[0]; | ||
| const value = args[1]; | ||
| let comparator = args[2]; | ||
| let formIndex = 0; | ||
| if (isArrayIncludesOptions(comparator)) { | ||
| formIndex = (_a = comparator.fromIndex) != null ? _a : 0; | ||
| comparator = comparator.comparator; | ||
| } | ||
| if (typeof comparator === "string") { | ||
| const key = comparator; | ||
| comparator = (element, value2) => element[key] === vue.toValue(value2); | ||
| } | ||
| comparator = comparator != null ? comparator : (element, value2) => element === vue.toValue(value2); | ||
| return vue.computed(() => vue.toValue(list).slice(formIndex).some((element, index, array) => comparator( | ||
| vue.toValue(element), | ||
| vue.toValue(value), | ||
| index, | ||
| vue.toValue(array) | ||
| ))); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayJoin(list, separator) { | ||
| return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).join(vue.toValue(separator))); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayMap(list, fn) { | ||
| return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).map(fn)); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayReduce(list, reducer, ...args) { | ||
| const reduceCallback = (sum, value, index) => reducer(vue.toValue(sum), vue.toValue(value), index); | ||
| return vue.computed(() => { | ||
| const resolved = vue.toValue(list); | ||
| return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? vue.toValue(args[0]()) : vue.toValue(args[0])) : resolved.reduce(reduceCallback); | ||
| }); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArraySome(list, fn) { | ||
| return vue.computed(() => vue.toValue(list).some((element, index, array) => fn(vue.toValue(element), index, array))); | ||
| } | ||
| function uniq(array) { | ||
| return Array.from(new Set(array)); | ||
| } | ||
| function uniqueElementsBy(array, fn) { | ||
| return array.reduce((acc, v) => { | ||
| if (!acc.some((x) => fn(v, x, array))) | ||
| acc.push(v); | ||
| return acc; | ||
| }, []); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayUnique(list, compareFn) { | ||
| return vue.computed(() => { | ||
| const resolvedList = vue.toValue(list).map((element) => vue.toValue(element)); | ||
| return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList); | ||
| }); | ||
| } | ||
| function useCounter(initialValue = 0, options = {}) { | ||
| let _initialValue = vue.unref(initialValue); | ||
| const count = vue.shallowRef(initialValue); | ||
| const { | ||
| max = Number.POSITIVE_INFINITY, | ||
| min = Number.NEGATIVE_INFINITY | ||
| } = options; | ||
| const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min); | ||
| const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max); | ||
| const get = () => count.value; | ||
| const set = (val) => count.value = Math.max(min, Math.min(max, val)); | ||
| const reset = (val = _initialValue) => { | ||
| _initialValue = val; | ||
| return set(val); | ||
| }; | ||
| return { count: vue.shallowReadonly(count), inc, dec, get, set, reset }; | ||
| } | ||
| const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i; | ||
| const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g; | ||
| function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) { | ||
| let m = hours < 12 ? "AM" : "PM"; | ||
| if (hasPeriod) | ||
| m = m.split("").reduce((acc, curr) => acc += `${curr}.`, ""); | ||
| return isLowercase ? m.toLowerCase() : m; | ||
| } | ||
| function formatOrdinal(num) { | ||
| const suffixes = ["th", "st", "nd", "rd"]; | ||
| const v = num % 100; | ||
| return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]); | ||
| } | ||
| function formatDate(date, formatStr, options = {}) { | ||
| var _a; | ||
| const years = date.getFullYear(); | ||
| const month = date.getMonth(); | ||
| const days = date.getDate(); | ||
| const hours = date.getHours(); | ||
| const minutes = date.getMinutes(); | ||
| const seconds = date.getSeconds(); | ||
| const milliseconds = date.getMilliseconds(); | ||
| const day = date.getDay(); | ||
| const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem; | ||
| const stripTimeZone = (dateString) => { | ||
| var _a2; | ||
| return (_a2 = dateString.split(" ")[1]) != null ? _a2 : ""; | ||
| }; | ||
| const matches = { | ||
| Yo: () => formatOrdinal(years), | ||
| YY: () => String(years).slice(-2), | ||
| YYYY: () => years, | ||
| M: () => month + 1, | ||
| Mo: () => formatOrdinal(month + 1), | ||
| MM: () => `${month + 1}`.padStart(2, "0"), | ||
| MMM: () => date.toLocaleDateString(vue.toValue(options.locales), { month: "short" }), | ||
| MMMM: () => date.toLocaleDateString(vue.toValue(options.locales), { month: "long" }), | ||
| D: () => String(days), | ||
| Do: () => formatOrdinal(days), | ||
| DD: () => `${days}`.padStart(2, "0"), | ||
| H: () => String(hours), | ||
| Ho: () => formatOrdinal(hours), | ||
| HH: () => `${hours}`.padStart(2, "0"), | ||
| h: () => `${hours % 12 || 12}`.padStart(1, "0"), | ||
| ho: () => formatOrdinal(hours % 12 || 12), | ||
| hh: () => `${hours % 12 || 12}`.padStart(2, "0"), | ||
| m: () => String(minutes), | ||
| mo: () => formatOrdinal(minutes), | ||
| mm: () => `${minutes}`.padStart(2, "0"), | ||
| s: () => String(seconds), | ||
| so: () => formatOrdinal(seconds), | ||
| ss: () => `${seconds}`.padStart(2, "0"), | ||
| SSS: () => `${milliseconds}`.padStart(3, "0"), | ||
| d: () => day, | ||
| dd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "narrow" }), | ||
| ddd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "short" }), | ||
| dddd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "long" }), | ||
| A: () => meridiem(hours, minutes), | ||
| AA: () => meridiem(hours, minutes, false, true), | ||
| a: () => meridiem(hours, minutes, true), | ||
| aa: () => meridiem(hours, minutes, true, true), | ||
| z: () => stripTimeZone(date.toLocaleDateString(vue.toValue(options.locales), { timeZoneName: "shortOffset" })), | ||
| zz: () => stripTimeZone(date.toLocaleDateString(vue.toValue(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzz: () => stripTimeZone(date.toLocaleDateString(vue.toValue(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzzz: () => stripTimeZone(date.toLocaleDateString(vue.toValue(options.locales), { timeZoneName: "longOffset" })) | ||
| }; | ||
| return formatStr.replace(REGEX_FORMAT, (match, $1) => { | ||
| var _a2, _b; | ||
| return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match; | ||
| }); | ||
| } | ||
| function normalizeDate(date) { | ||
| if (date === null) | ||
| return new Date(Number.NaN); | ||
| if (date === void 0) | ||
| return /* @__PURE__ */ new Date(); | ||
| if (date instanceof Date) | ||
| return new Date(date); | ||
| if (typeof date === "string" && !/Z$/i.test(date)) { | ||
| const d = date.match(REGEX_PARSE); | ||
| if (d) { | ||
| const m = d[2] - 1 || 0; | ||
| const ms = (d[7] || "0").substring(0, 3); | ||
| return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms); | ||
| } | ||
| } | ||
| return new Date(date); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) { | ||
| return vue.computed(() => formatDate(normalizeDate(vue.toValue(date)), vue.toValue(formatStr), options)); | ||
| } | ||
| function useIntervalFn(cb, interval = 1e3, options = {}) { | ||
| const { | ||
| immediate = true, | ||
| immediateCallback = false | ||
| } = options; | ||
| let timer = null; | ||
| const isActive = vue.shallowRef(false); | ||
| function clean() { | ||
| if (timer) { | ||
| clearInterval(timer); | ||
| timer = null; | ||
| } | ||
| } | ||
| function pause() { | ||
| isActive.value = false; | ||
| clean(); | ||
| } | ||
| function resume() { | ||
| const intervalValue = vue.toValue(interval); | ||
| if (intervalValue <= 0) | ||
| return; | ||
| isActive.value = true; | ||
| if (immediateCallback) | ||
| cb(); | ||
| clean(); | ||
| if (isActive.value) | ||
| timer = setInterval(cb, intervalValue); | ||
| } | ||
| if (immediate && isClient) | ||
| resume(); | ||
| if (vue.isRef(interval) || typeof interval === "function") { | ||
| const stopWatch = vue.watch(interval, () => { | ||
| if (isActive.value && isClient) | ||
| resume(); | ||
| }); | ||
| tryOnScopeDispose(stopWatch); | ||
| } | ||
| tryOnScopeDispose(pause); | ||
| return { | ||
| isActive: vue.shallowReadonly(isActive), | ||
| pause, | ||
| resume | ||
| }; | ||
| } | ||
| function useInterval(interval = 1e3, options = {}) { | ||
| const { | ||
| controls: exposeControls = false, | ||
| immediate = true, | ||
| callback | ||
| } = options; | ||
| const counter = vue.shallowRef(0); | ||
| const update = () => counter.value += 1; | ||
| const reset = () => { | ||
| counter.value = 0; | ||
| }; | ||
| const controls = useIntervalFn( | ||
| callback ? () => { | ||
| update(); | ||
| callback(counter.value); | ||
| } : update, | ||
| interval, | ||
| { immediate } | ||
| ); | ||
| if (exposeControls) { | ||
| return { | ||
| counter: vue.shallowReadonly(counter), | ||
| reset, | ||
| ...controls | ||
| }; | ||
| } else { | ||
| return vue.shallowReadonly(counter); | ||
| } | ||
| } | ||
| function useLastChanged(source, options = {}) { | ||
| var _a; | ||
| const ms = vue.shallowRef((_a = options.initialValue) != null ? _a : null); | ||
| vue.watch( | ||
| source, | ||
| () => ms.value = timestamp(), | ||
| options | ||
| ); | ||
| return vue.shallowReadonly(ms); | ||
| } | ||
| function useTimeoutFn(cb, interval, options = {}) { | ||
| const { | ||
| immediate = true, | ||
| immediateCallback = false | ||
| } = options; | ||
| const isPending = vue.shallowRef(false); | ||
| let timer; | ||
| function clear() { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| } | ||
| } | ||
| function stop() { | ||
| isPending.value = false; | ||
| clear(); | ||
| } | ||
| function start(...args) { | ||
| if (immediateCallback) | ||
| cb(); | ||
| clear(); | ||
| isPending.value = true; | ||
| timer = setTimeout(() => { | ||
| isPending.value = false; | ||
| timer = void 0; | ||
| cb(...args); | ||
| }, vue.toValue(interval)); | ||
| } | ||
| if (immediate) { | ||
| isPending.value = true; | ||
| if (isClient) | ||
| start(); | ||
| } | ||
| tryOnScopeDispose(stop); | ||
| return { | ||
| isPending: vue.shallowReadonly(isPending), | ||
| start, | ||
| stop | ||
| }; | ||
| } | ||
| function useTimeout(interval = 1e3, options = {}) { | ||
| const { | ||
| controls: exposeControls = false, | ||
| callback | ||
| } = options; | ||
| const controls = useTimeoutFn( | ||
| callback != null ? callback : noop, | ||
| interval, | ||
| options | ||
| ); | ||
| const ready = vue.computed(() => !controls.isPending.value); | ||
| if (exposeControls) { | ||
| return { | ||
| ready, | ||
| ...controls | ||
| }; | ||
| } else { | ||
| return ready; | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useToNumber(value, options = {}) { | ||
| const { | ||
| method = "parseFloat", | ||
| radix, | ||
| nanToZero | ||
| } = options; | ||
| return vue.computed(() => { | ||
| let resolved = vue.toValue(value); | ||
| if (typeof method === "function") | ||
| resolved = method(resolved); | ||
| else if (typeof resolved === "string") | ||
| resolved = Number[method](resolved, radix); | ||
| if (nanToZero && Number.isNaN(resolved)) | ||
| resolved = 0; | ||
| return resolved; | ||
| }); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useToString(value) { | ||
| return vue.computed(() => `${vue.toValue(value)}`); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useToggle(initialValue = false, options = {}) { | ||
| const { | ||
| truthyValue = true, | ||
| falsyValue = false | ||
| } = options; | ||
| const valueIsRef = vue.isRef(initialValue); | ||
| const _value = vue.shallowRef(initialValue); | ||
| function toggle(value) { | ||
| if (arguments.length) { | ||
| _value.value = value; | ||
| return _value.value; | ||
| } else { | ||
| const truthy = vue.toValue(truthyValue); | ||
| _value.value = _value.value === truthy ? vue.toValue(falsyValue) : truthy; | ||
| return _value.value; | ||
| } | ||
| } | ||
| if (valueIsRef) | ||
| return toggle; | ||
| else | ||
| return [_value, toggle]; | ||
| } | ||
| function watchArray(source, cb, options) { | ||
| let oldList = (options == null ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : vue.toValue(source)]; | ||
| return vue.watch(source, (newList, _, onCleanup) => { | ||
| const oldListRemains = Array.from({ length: oldList.length }); | ||
| const added = []; | ||
| for (const obj of newList) { | ||
| let found = false; | ||
| for (let i = 0; i < oldList.length; i++) { | ||
| if (!oldListRemains[i] && obj === oldList[i]) { | ||
| oldListRemains[i] = true; | ||
| found = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!found) | ||
| added.push(obj); | ||
| } | ||
| const removed = oldList.filter((_2, i) => !oldListRemains[i]); | ||
| cb(newList, oldList, added, removed, onCleanup); | ||
| oldList = [...newList]; | ||
| }, options); | ||
| } | ||
| function watchAtMost(source, cb, options) { | ||
| const { | ||
| count, | ||
| ...watchOptions | ||
| } = options; | ||
| const current = vue.shallowRef(0); | ||
| const stop = watchWithFilter( | ||
| source, | ||
| (...args) => { | ||
| current.value += 1; | ||
| if (current.value >= vue.toValue(count)) | ||
| vue.nextTick(() => stop()); | ||
| cb(...args); | ||
| }, | ||
| watchOptions | ||
| ); | ||
| return { count: current, stop }; | ||
| } | ||
| function watchDebounced(source, cb, options = {}) { | ||
| const { | ||
| debounce = 0, | ||
| maxWait = void 0, | ||
| ...watchOptions | ||
| } = options; | ||
| return watchWithFilter( | ||
| source, | ||
| cb, | ||
| { | ||
| ...watchOptions, | ||
| eventFilter: debounceFilter(debounce, { maxWait }) | ||
| } | ||
| ); | ||
| } | ||
| function watchDeep(source, cb, options) { | ||
| return vue.watch( | ||
| source, | ||
| cb, | ||
| { | ||
| ...options, | ||
| deep: true | ||
| } | ||
| ); | ||
| } | ||
| function watchIgnorable(source, cb, options = {}) { | ||
| const { | ||
| eventFilter = bypassFilter, | ||
| ...watchOptions | ||
| } = options; | ||
| const filteredCb = createFilterWrapper( | ||
| eventFilter, | ||
| cb | ||
| ); | ||
| let ignoreUpdates; | ||
| let ignorePrevAsyncUpdates; | ||
| let stop; | ||
| if (watchOptions.flush === "sync") { | ||
| let ignore = false; | ||
| ignorePrevAsyncUpdates = () => { | ||
| }; | ||
| ignoreUpdates = (updater) => { | ||
| ignore = true; | ||
| updater(); | ||
| ignore = false; | ||
| }; | ||
| stop = vue.watch( | ||
| source, | ||
| (...args) => { | ||
| if (!ignore) | ||
| filteredCb(...args); | ||
| }, | ||
| watchOptions | ||
| ); | ||
| } else { | ||
| const disposables = []; | ||
| let ignoreCounter = 0; | ||
| let syncCounter = 0; | ||
| ignorePrevAsyncUpdates = () => { | ||
| ignoreCounter = syncCounter; | ||
| }; | ||
| disposables.push( | ||
| vue.watch( | ||
| source, | ||
| () => { | ||
| syncCounter++; | ||
| }, | ||
| { ...watchOptions, flush: "sync" } | ||
| ) | ||
| ); | ||
| ignoreUpdates = (updater) => { | ||
| const syncCounterPrev = syncCounter; | ||
| updater(); | ||
| ignoreCounter += syncCounter - syncCounterPrev; | ||
| }; | ||
| disposables.push( | ||
| vue.watch( | ||
| source, | ||
| (...args) => { | ||
| const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter; | ||
| ignoreCounter = 0; | ||
| syncCounter = 0; | ||
| if (ignore) | ||
| return; | ||
| filteredCb(...args); | ||
| }, | ||
| watchOptions | ||
| ) | ||
| ); | ||
| stop = () => { | ||
| disposables.forEach((fn) => fn()); | ||
| }; | ||
| } | ||
| return { stop, ignoreUpdates, ignorePrevAsyncUpdates }; | ||
| } | ||
| function watchImmediate(source, cb, options) { | ||
| return vue.watch( | ||
| source, | ||
| cb, | ||
| { | ||
| ...options, | ||
| immediate: true | ||
| } | ||
| ); | ||
| } | ||
| function watchOnce(source, cb, options) { | ||
| return vue.watch( | ||
| source, | ||
| cb, | ||
| { | ||
| ...options, | ||
| once: true | ||
| } | ||
| ); | ||
| } | ||
| function watchThrottled(source, cb, options = {}) { | ||
| const { | ||
| throttle = 0, | ||
| trailing = true, | ||
| leading = true, | ||
| ...watchOptions | ||
| } = options; | ||
| return watchWithFilter( | ||
| source, | ||
| cb, | ||
| { | ||
| ...watchOptions, | ||
| eventFilter: throttleFilter(throttle, trailing, leading) | ||
| } | ||
| ); | ||
| } | ||
| function watchTriggerable(source, cb, options = {}) { | ||
| let cleanupFn; | ||
| function onEffect() { | ||
| if (!cleanupFn) | ||
| return; | ||
| const fn = cleanupFn; | ||
| cleanupFn = void 0; | ||
| fn(); | ||
| } | ||
| function onCleanup(callback) { | ||
| cleanupFn = callback; | ||
| } | ||
| const _cb = (value, oldValue) => { | ||
| onEffect(); | ||
| return cb(value, oldValue, onCleanup); | ||
| }; | ||
| const res = watchIgnorable(source, _cb, options); | ||
| const { ignoreUpdates } = res; | ||
| const trigger = () => { | ||
| let res2; | ||
| ignoreUpdates(() => { | ||
| res2 = _cb(getWatchSources(source), getOldValue(source)); | ||
| }); | ||
| return res2; | ||
| }; | ||
| return { | ||
| ...res, | ||
| trigger | ||
| }; | ||
| } | ||
| function getWatchSources(sources) { | ||
| if (vue.isReactive(sources)) | ||
| return sources; | ||
| if (Array.isArray(sources)) | ||
| return sources.map((item) => vue.toValue(item)); | ||
| return vue.toValue(sources); | ||
| } | ||
| function getOldValue(source) { | ||
| return Array.isArray(source) ? source.map(() => void 0) : void 0; | ||
| } | ||
| function whenever(source, cb, options) { | ||
| const stop = vue.watch( | ||
| source, | ||
| (v, ov, onInvalidate) => { | ||
| if (v) { | ||
| if (options == null ? void 0 : options.once) | ||
| vue.nextTick(() => stop()); | ||
| cb(v, ov, onInvalidate); | ||
| } | ||
| }, | ||
| { | ||
| ...options, | ||
| once: false | ||
| } | ||
| ); | ||
| return stop; | ||
| } | ||
| exports.assert = assert; | ||
| exports.autoResetRef = refAutoReset; | ||
| exports.bypassFilter = bypassFilter; | ||
| exports.camelize = camelize; | ||
| exports.clamp = clamp; | ||
| exports.computedEager = computedEager; | ||
| exports.computedWithControl = computedWithControl; | ||
| exports.containsProp = containsProp; | ||
| exports.controlledComputed = computedWithControl; | ||
| exports.controlledRef = controlledRef; | ||
| exports.createEventHook = createEventHook; | ||
| exports.createFilterWrapper = createFilterWrapper; | ||
| exports.createGlobalState = createGlobalState; | ||
| exports.createInjectionState = createInjectionState; | ||
| exports.createReactiveFn = reactify; | ||
| exports.createRef = createRef; | ||
| exports.createSharedComposable = createSharedComposable; | ||
| exports.createSingletonPromise = createSingletonPromise; | ||
| exports.debounceFilter = debounceFilter; | ||
| exports.debouncedRef = refDebounced; | ||
| exports.debouncedWatch = watchDebounced; | ||
| exports.eagerComputed = computedEager; | ||
| exports.extendRef = extendRef; | ||
| exports.formatDate = formatDate; | ||
| exports.get = get; | ||
| exports.getLifeCycleTarget = getLifeCycleTarget; | ||
| exports.hasOwn = hasOwn; | ||
| exports.hyphenate = hyphenate; | ||
| exports.identity = identity; | ||
| exports.ignorableWatch = watchIgnorable; | ||
| exports.increaseWithUnit = increaseWithUnit; | ||
| exports.injectLocal = injectLocal; | ||
| exports.invoke = invoke; | ||
| exports.isClient = isClient; | ||
| exports.isDef = isDef; | ||
| exports.isDefined = isDefined; | ||
| exports.isIOS = isIOS; | ||
| exports.isObject = isObject; | ||
| exports.isWorker = isWorker; | ||
| exports.makeDestructurable = makeDestructurable; | ||
| exports.noop = noop; | ||
| exports.normalizeDate = normalizeDate; | ||
| exports.notNullish = notNullish; | ||
| exports.now = now; | ||
| exports.objectEntries = objectEntries; | ||
| exports.objectOmit = objectOmit; | ||
| exports.objectPick = objectPick; | ||
| exports.pausableFilter = pausableFilter; | ||
| exports.pausableWatch = watchPausable; | ||
| exports.promiseTimeout = promiseTimeout; | ||
| exports.provideLocal = provideLocal; | ||
| exports.pxValue = pxValue; | ||
| exports.rand = rand; | ||
| exports.reactify = reactify; | ||
| exports.reactifyObject = reactifyObject; | ||
| exports.reactiveComputed = reactiveComputed; | ||
| exports.reactiveOmit = reactiveOmit; | ||
| exports.reactivePick = reactivePick; | ||
| exports.refAutoReset = refAutoReset; | ||
| exports.refDebounced = refDebounced; | ||
| exports.refDefault = refDefault; | ||
| exports.refThrottled = refThrottled; | ||
| exports.refWithControl = refWithControl; | ||
| exports.resolveRef = resolveRef; | ||
| exports.resolveUnref = resolveUnref; | ||
| exports.set = set; | ||
| exports.syncRef = syncRef; | ||
| exports.syncRefs = syncRefs; | ||
| exports.throttleFilter = throttleFilter; | ||
| exports.throttledRef = refThrottled; | ||
| exports.throttledWatch = watchThrottled; | ||
| exports.timestamp = timestamp; | ||
| exports.toArray = toArray; | ||
| exports.toReactive = toReactive; | ||
| exports.toRef = toRef; | ||
| exports.toRefs = toRefs; | ||
| exports.toValue = toValue; | ||
| exports.tryOnBeforeMount = tryOnBeforeMount; | ||
| exports.tryOnBeforeUnmount = tryOnBeforeUnmount; | ||
| exports.tryOnMounted = tryOnMounted; | ||
| exports.tryOnScopeDispose = tryOnScopeDispose; | ||
| exports.tryOnUnmounted = tryOnUnmounted; | ||
| exports.until = until; | ||
| exports.useArrayDifference = useArrayDifference; | ||
| exports.useArrayEvery = useArrayEvery; | ||
| exports.useArrayFilter = useArrayFilter; | ||
| exports.useArrayFind = useArrayFind; | ||
| exports.useArrayFindIndex = useArrayFindIndex; | ||
| exports.useArrayFindLast = useArrayFindLast; | ||
| exports.useArrayIncludes = useArrayIncludes; | ||
| exports.useArrayJoin = useArrayJoin; | ||
| exports.useArrayMap = useArrayMap; | ||
| exports.useArrayReduce = useArrayReduce; | ||
| exports.useArraySome = useArraySome; | ||
| exports.useArrayUnique = useArrayUnique; | ||
| exports.useCounter = useCounter; | ||
| exports.useDateFormat = useDateFormat; | ||
| exports.useDebounce = refDebounced; | ||
| exports.useDebounceFn = useDebounceFn; | ||
| exports.useInterval = useInterval; | ||
| exports.useIntervalFn = useIntervalFn; | ||
| exports.useLastChanged = useLastChanged; | ||
| exports.useThrottle = refThrottled; | ||
| exports.useThrottleFn = useThrottleFn; | ||
| exports.useTimeout = useTimeout; | ||
| exports.useTimeoutFn = useTimeoutFn; | ||
| exports.useToNumber = useToNumber; | ||
| exports.useToString = useToString; | ||
| exports.useToggle = useToggle; | ||
| exports.watchArray = watchArray; | ||
| exports.watchAtMost = watchAtMost; | ||
| exports.watchDebounced = watchDebounced; | ||
| exports.watchDeep = watchDeep; | ||
| exports.watchIgnorable = watchIgnorable; | ||
| exports.watchImmediate = watchImmediate; | ||
| exports.watchOnce = watchOnce; | ||
| exports.watchPausable = watchPausable; | ||
| exports.watchThrottled = watchThrottled; | ||
| exports.watchTriggerable = watchTriggerable; | ||
| exports.watchWithFilter = watchWithFilter; | ||
| exports.whenever = whenever; | ||
| })(this.VueUse = this.VueUse || {}, Vue); |
| (function(l,o){"use strict";function $(t,e){var n;const r=o.shallowRef();return o.watchEffect(()=>{r.value=t()},{...e,flush:(n=e?.flush)!=null?n:"sync"}),o.readonly(r)}function H(t,e,n={}){let r,a,i,c=!0;const u=()=>{c=!0,i()};o.watch(t,u,{flush:"sync",...n});const s=typeof e=="function"?e:e.get,h=typeof e=="function"?void 0:e.set,d=o.customRef((m,f)=>(a=m,i=f,{get(){return c&&(r=s(r),c=!1),a(),r},set(y){h?.(y)}}));return d.trigger=u,d}function p(t){return o.getCurrentScope()?(o.onScopeDispose(t),!0):!1}function dt(){const t=new Set,e=i=>{t.delete(i)};return{on:i=>{t.add(i);const c=()=>e(i);return p(c),{off:c}},off:e,trigger:(...i)=>Promise.all(Array.from(t).map(c=>c(...i))),clear:()=>{t.clear()}}}function mt(t){let e=!1,n;const r=o.effectScope(!0);return(...a)=>(e||(n=r.run(()=>t(...a)),e=!0),n)}const O=new WeakMap,G=(...t)=>{var e;const n=t[0],r=(e=o.getCurrentInstance())==null?void 0:e.proxy;if(r==null&&!o.hasInjectionContext())throw new Error("injectLocal must be called in setup");return r&&O.has(r)&&n in O.get(r)?O.get(r)[n]:o.inject(...t)};function Z(t,e){var n;const r=(n=o.getCurrentInstance())==null?void 0:n.proxy;if(r==null)throw new Error("provideLocal must be called in setup");O.has(r)||O.set(r,Object.create(null));const a=O.get(r);return a[t]=e,o.provide(t,e)}function ht(t,e){const n=e?.injectionKey||Symbol(t.name||"InjectionState"),r=e?.defaultValue;return[(...c)=>{const u=t(...c);return Z(n,u),u},()=>G(n,r)]}function yt(t,e){return e===!0?o.ref(t):o.shallowRef(t)}function wt(t){let e=0,n,r;const a=()=>{e-=1,r&&e<=0&&(r.stop(),n=void 0,r=void 0)};return(...i)=>(e+=1,r||(r=o.effectScope(!0),n=r.run(()=>t(...i))),p(a),n)}function q(t,e,{enumerable:n=!1,unwrap:r=!0}={}){for(const[a,i]of Object.entries(e))a!=="value"&&(o.isRef(i)&&r?Object.defineProperty(t,a,{get(){return i.value},set(c){i.value=c},enumerable:n}):Object.defineProperty(t,a,{value:i,enumerable:n}));return t}function gt(t,e){return e==null?o.unref(t):o.unref(t)[e]}function Vt(t){return o.unref(t)!=null}function bt(t,e){if(typeof Symbol<"u"){const n={...t};return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let r=0;return{next:()=>({value:e[r++],done:r>e.length})}}}),n}else return Object.assign([...e],t)}function _(t,e){const n=e?.computedGetter===!1?o.unref:o.toValue;return function(...r){return o.computed(()=>t.apply(this,r.map(a=>n(a))))}}function pt(t,e={}){let n=[],r;if(Array.isArray(e))n=e;else{r=e;const{includeOwnProperties:a=!0}=e;n.push(...Object.keys(t)),a&&n.push(...Object.getOwnPropertyNames(t))}return Object.fromEntries(n.map(a=>{const i=t[a];return[a,typeof i=="function"?_(i.bind(t),r):i]}))}function J(t){if(!o.isRef(t))return o.reactive(t);const e=new Proxy({},{get(n,r,a){return o.unref(Reflect.get(t.value,r,a))},set(n,r,a){return o.isRef(t.value[r])&&!o.isRef(a)?t.value[r].value=a:t.value[r]=a,!0},deleteProperty(n,r){return Reflect.deleteProperty(t.value,r)},has(n,r){return Reflect.has(t.value,r)},ownKeys(){return Object.keys(t.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return o.reactive(e)}function N(t){return J(o.computed(t))}function At(t,...e){const n=e.flat(),r=n[0];return N(()=>Object.fromEntries(typeof r=="function"?Object.entries(o.toRefs(t)).filter(([a,i])=>!r(o.toValue(i),a)):Object.entries(o.toRefs(t)).filter(a=>!n.includes(a[0]))))}const D=typeof window<"u"&&typeof document<"u",St=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Ot=t=>typeof t<"u",Rt=t=>t!=null,Tt=(t,...e)=>{t||console.warn(...e)},Dt=Object.prototype.toString,X=t=>Dt.call(t)==="[object Object]",Ft=()=>Date.now(),K=()=>+Date.now(),Mt=(t,e,n)=>Math.min(n,Math.max(e,t)),A=()=>{},Pt=(t,e)=>(t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t),It=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ct=kt();function kt(){var t,e;return D&&((t=window?.navigator)==null?void 0:t.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((e=window?.navigator)==null?void 0:e.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function I(...t){if(t.length!==1)return o.toRef(...t);const e=t[0];return typeof e=="function"?o.readonly(o.customRef(()=>({get:e,set:A}))):o.ref(e)}const Et=I;function _t(t,...e){const n=e.flat(),r=n[0];return N(()=>Object.fromEntries(typeof r=="function"?Object.entries(o.toRefs(t)).filter(([a,i])=>r(o.toValue(i),a)):n.map(a=>[a,I(t,a)])))}function Q(t,e=1e4){return o.customRef((n,r)=>{let a=o.toValue(t),i;const c=()=>setTimeout(()=>{a=o.toValue(t),r()},o.toValue(e));return p(()=>{clearTimeout(i)}),{get(){return n(),a},set(u){a=u,r(),clearTimeout(i),i=c()}}})}function F(t,e){function n(...r){return new Promise((a,i)=>{Promise.resolve(t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})).then(a).catch(i)})}return n}const C=t=>t();function L(t,e={}){let n,r,a=A;const i=s=>{clearTimeout(s),a(),a=A};let c;return s=>{const h=o.toValue(t),d=o.toValue(e.maxWait);return n&&i(n),h<=0||d!==void 0&&d<=0?(r&&(i(r),r=void 0),Promise.resolve(s())):new Promise((m,f)=>{a=e.rejectOnCancel?f:m,c=s,d&&!r&&(r=setTimeout(()=>{n&&i(n),r=void 0,m(c())},d)),n=setTimeout(()=>{r&&i(r),r=void 0,m(s())},h)})}}function j(...t){let e=0,n,r=!0,a=A,i,c,u,s,h;!o.isRef(t[0])&&typeof t[0]=="object"?{delay:c,trailing:u=!0,leading:s=!0,rejectOnCancel:h=!1}=t[0]:[c,u=!0,s=!0,h=!1]=t;const d=()=>{n&&(clearTimeout(n),n=void 0,a(),a=A)};return f=>{const y=o.toValue(c),g=Date.now()-e,V=()=>i=f();return d(),y<=0?(e=Date.now(),V()):(g>y?(e=Date.now(),(s||!r)&&V()):u&&(i=new Promise((w,b)=>{a=h?b:w,n=setTimeout(()=>{e=Date.now(),r=!0,w(V()),d()},Math.max(0,y-g))})),!s&&!n&&(n=setTimeout(()=>r=!0,y)),r=!1,i)}}function v(t=C,e={}){const{initialState:n="active"}=e,r=I(n==="active");function a(){r.value=!1}function i(){r.value=!0}const c=(...u)=>{r.value&&t(...u)};return{isActive:o.readonly(r),pause:a,resume:i,eventFilter:c}}function W(t,e=!1,n="Timeout"){return new Promise((r,a)=>{setTimeout(e?()=>a(n):r,t)})}function Nt(t){return t}function Lt(t){let e;function n(){return e||(e=t()),e}return n.reset=async()=>{const r=e;e=void 0,r&&await r},n}function jt(t){return t()}function x(t,...e){return e.some(n=>n in t)}function Wt(t,e){var n;if(typeof t=="number")return t+e;const r=((n=t.match(/^-?\d+\.?\d*/))==null?void 0:n[0])||"",a=t.slice(r.length),i=Number.parseFloat(r)+e;return Number.isNaN(i)?t:i+a}function Ut(t){return t.endsWith("rem")?Number.parseFloat(t)*16:Number.parseFloat(t)}function zt(t,e,n=!1){return e.reduce((r,a)=>(a in t&&(!n||t[a]!==void 0)&&(r[a]=t[a]),r),{})}function Bt(t,e,n=!1){return Object.fromEntries(Object.entries(t).filter(([r,a])=>(!n||a!==void 0)&&!e.includes(r)))}function Yt(t){return Object.entries(t)}function tt(t){return Array.isArray(t)?t:[t]}function et(t){const e=Object.create(null);return n=>e[n]||(e[n]=t(n))}const $t=/\B([A-Z])/g,Ht=et(t=>t.replace($t,"-$1").toLowerCase()),Gt=/-(\w)/g,Zt=et(t=>t.replace(Gt,(e,n)=>n?n.toUpperCase():""));function M(t){return t||o.getCurrentInstance()}function nt(t,e=200,n={}){return F(L(e,n),t)}function U(t,e=200,n={}){const r=o.ref(o.toValue(t)),a=nt(()=>{r.value=t.value},e,n);return o.watch(t,()=>a()),o.shallowReadonly(r)}function qt(t,e){return o.computed({get(){var n;return(n=t.value)!=null?n:e},set(n){t.value=n}})}function rt(t,e=200,n=!1,r=!0,a=!1){return F(j(e,n,r,a),t)}function z(t,e=200,n=!0,r=!0){if(e<=0)return t;const a=o.ref(o.toValue(t)),i=rt(()=>{a.value=t.value},e,n,r);return o.watch(t,()=>i()),a}function ot(t,e={}){let n=t,r,a;const i=o.customRef((f,y)=>(r=f,a=y,{get(){return c()},set(g){u(g)}}));function c(f=!0){return f&&r(),n}function u(f,y=!0){var g,V;if(f===n)return;const w=n;((g=e.onBeforeChange)==null?void 0:g.call(e,f,w))!==!1&&(n=f,(V=e.onChanged)==null||V.call(e,f,w),y&&a())}return q(i,{get:c,set:u,untrackedGet:()=>c(!1),silentSet:f=>u(f,!1),peek:()=>c(!1),lay:f=>u(f,!1)},{enumerable:!0})}const Jt=ot;function Xt(...t){if(t.length===2){const[e,n]=t;e.value=n}if(t.length===3){const[e,n,r]=t;e[n]=r}}function P(t,e,n={}){const{eventFilter:r=C,...a}=n;return o.watch(t,F(r,e),a)}function k(t,e,n={}){const{eventFilter:r,initialState:a="active",...i}=n,{eventFilter:c,pause:u,resume:s,isActive:h}=v(r,{initialState:a});return{stop:P(t,e,{...i,eventFilter:c}),pause:u,resume:s,isActive:h}}function Kt(t,e,...[n]){const{flush:r="sync",deep:a=!1,immediate:i=!0,direction:c="both",transform:u={}}=n||{},s=[],h="ltr"in u&&u.ltr||(f=>f),d="rtl"in u&&u.rtl||(f=>f);return(c==="both"||c==="ltr")&&s.push(k(t,f=>{s.forEach(y=>y.pause()),e.value=h(f),s.forEach(y=>y.resume())},{flush:r,deep:a,immediate:i})),(c==="both"||c==="rtl")&&s.push(k(e,f=>{s.forEach(y=>y.pause()),t.value=d(f),s.forEach(y=>y.resume())},{flush:r,deep:a,immediate:i})),()=>{s.forEach(f=>f.stop())}}function Qt(t,e,n={}){const{flush:r="sync",deep:a=!1,immediate:i=!0}=n,c=tt(e);return o.watch(t,u=>c.forEach(s=>s.value=u),{flush:r,deep:a,immediate:i})}function vt(t,e={}){if(!o.isRef(t))return o.toRefs(t);const n=Array.isArray(t.value)?Array.from({length:t.value.length}):{};for(const r in t.value)n[r]=o.customRef(()=>({get(){return t.value[r]},set(a){var i;if((i=o.toValue(e.replaceRef))!=null?i:!0)if(Array.isArray(t.value)){const u=[...t.value];u[r]=a,t.value=u}else{const u={...t.value,[r]:a};Object.setPrototypeOf(u,Object.getPrototypeOf(t.value)),t.value=u}else t.value[r]=a}}));return n}const xt=o.toValue,te=o.toValue;function ee(t,e=!0,n){M(n)?o.onBeforeMount(t,n):e?t():o.nextTick(t)}function ne(t,e){M(e)&&o.onBeforeUnmount(t,e)}function re(t,e=!0,n){M(n)?o.onMounted(t,n):e?t():o.nextTick(t)}function oe(t,e){M(e)&&o.onUnmounted(t,e)}function B(t,e=!1){function n(m,{flush:f="sync",deep:y=!1,timeout:g,throwOnTimeout:V}={}){let w=null;const R=[new Promise(E=>{w=o.watch(t,T=>{m(T)!==e&&(w?w():o.nextTick(()=>w?.()),E(T))},{flush:f,deep:y,immediate:!0})})];return g!=null&&R.push(W(g,V).then(()=>o.toValue(t)).finally(()=>w?.())),Promise.race(R)}function r(m,f){if(!o.isRef(m))return n(T=>T===m,f);const{flush:y="sync",deep:g=!1,timeout:V,throwOnTimeout:w}=f??{};let b=null;const E=[new Promise(T=>{b=o.watch([t,m],([ft,$e])=>{e!==(ft===$e)&&(b?b():o.nextTick(()=>b?.()),T(ft))},{flush:y,deep:g,immediate:!0})})];return V!=null&&E.push(W(V,w).then(()=>o.toValue(t)).finally(()=>(b?.(),o.toValue(t)))),Promise.race(E)}function a(m){return n(f=>!!f,m)}function i(m){return r(null,m)}function c(m){return r(void 0,m)}function u(m){return n(Number.isNaN,m)}function s(m,f){return n(y=>{const g=Array.from(y);return g.includes(m)||g.includes(o.toValue(m))},f)}function h(m){return d(1,m)}function d(m=1,f){let y=-1;return n(()=>(y+=1,y>=m),f)}return Array.isArray(o.toValue(t))?{toMatch:n,toContains:s,changed:h,changedTimes:d,get not(){return B(t,!e)}}:{toMatch:n,toBe:r,toBeTruthy:a,toBeNull:i,toBeNaN:u,toBeUndefined:c,changed:h,changedTimes:d,get not(){return B(t,!e)}}}function ae(t){return B(t)}function ie(t,e){return t===e}function le(...t){var e,n;const r=t[0],a=t[1];let i=(e=t[2])!=null?e:ie;const{symmetric:c=!1}=(n=t[3])!=null?n:{};if(typeof i=="string"){const s=i;i=(h,d)=>h[s]===d[s]}const u=o.computed(()=>o.toValue(r).filter(s=>o.toValue(a).findIndex(h=>i(s,h))===-1));if(c){const s=o.computed(()=>o.toValue(a).filter(h=>o.toValue(r).findIndex(d=>i(h,d))===-1));return o.computed(()=>c?[...o.toValue(u),...o.toValue(s)]:o.toValue(u))}else return u}function ce(t,e){return o.computed(()=>o.toValue(t).every((n,r,a)=>e(o.toValue(n),r,a)))}function ue(t,e){return o.computed(()=>o.toValue(t).map(n=>o.toValue(n)).filter(e))}function se(t,e){return o.computed(()=>o.toValue(o.toValue(t).find((n,r,a)=>e(o.toValue(n),r,a))))}function fe(t,e){return o.computed(()=>o.toValue(t).findIndex((n,r,a)=>e(o.toValue(n),r,a)))}function de(t,e){let n=t.length;for(;n-- >0;)if(e(t[n],n,t))return t[n]}function me(t,e){return o.computed(()=>o.toValue(Array.prototype.findLast?o.toValue(t).findLast((n,r,a)=>e(o.toValue(n),r,a)):de(o.toValue(t),(n,r,a)=>e(o.toValue(n),r,a))))}function he(t){return X(t)&&x(t,"formIndex","comparator")}function ye(...t){var e;const n=t[0],r=t[1];let a=t[2],i=0;if(he(a)&&(i=(e=a.fromIndex)!=null?e:0,a=a.comparator),typeof a=="string"){const c=a;a=(u,s)=>u[c]===o.toValue(s)}return a=a??((c,u)=>c===o.toValue(u)),o.computed(()=>o.toValue(n).slice(i).some((c,u,s)=>a(o.toValue(c),o.toValue(r),u,o.toValue(s))))}function we(t,e){return o.computed(()=>o.toValue(t).map(n=>o.toValue(n)).join(o.toValue(e)))}function ge(t,e){return o.computed(()=>o.toValue(t).map(n=>o.toValue(n)).map(e))}function Ve(t,e,...n){const r=(a,i,c)=>e(o.toValue(a),o.toValue(i),c);return o.computed(()=>{const a=o.toValue(t);return n.length?a.reduce(r,typeof n[0]=="function"?o.toValue(n[0]()):o.toValue(n[0])):a.reduce(r)})}function be(t,e){return o.computed(()=>o.toValue(t).some((n,r,a)=>e(o.toValue(n),r,a)))}function pe(t){return Array.from(new Set(t))}function Ae(t,e){return t.reduce((n,r)=>(n.some(a=>e(r,a,t))||n.push(r),n),[])}function Se(t,e){return o.computed(()=>{const n=o.toValue(t).map(r=>o.toValue(r));return e?Ae(n,e):pe(n)})}function Oe(t=0,e={}){let n=o.unref(t);const r=o.shallowRef(t),{max:a=Number.POSITIVE_INFINITY,min:i=Number.NEGATIVE_INFINITY}=e,c=(m=1)=>r.value=Math.max(Math.min(a,r.value+m),i),u=(m=1)=>r.value=Math.min(Math.max(i,r.value-m),a),s=()=>r.value,h=m=>r.value=Math.max(i,Math.min(a,m)),d=(m=n)=>(n=m,h(m));return{count:o.shallowReadonly(r),inc:c,dec:u,get:s,set:h,reset:d}}const Re=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i,Te=/[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;function De(t,e,n,r){let a=t<12?"AM":"PM";return r&&(a=a.split("").reduce((i,c)=>i+=`${c}.`,"")),n?a.toLowerCase():a}function S(t){const e=["th","st","nd","rd"],n=t%100;return t+(e[(n-20)%10]||e[n]||e[0])}function at(t,e,n={}){var r;const a=t.getFullYear(),i=t.getMonth(),c=t.getDate(),u=t.getHours(),s=t.getMinutes(),h=t.getSeconds(),d=t.getMilliseconds(),m=t.getDay(),f=(r=n.customMeridiem)!=null?r:De,y=V=>{var w;return(w=V.split(" ")[1])!=null?w:""},g={Yo:()=>S(a),YY:()=>String(a).slice(-2),YYYY:()=>a,M:()=>i+1,Mo:()=>S(i+1),MM:()=>`${i+1}`.padStart(2,"0"),MMM:()=>t.toLocaleDateString(o.toValue(n.locales),{month:"short"}),MMMM:()=>t.toLocaleDateString(o.toValue(n.locales),{month:"long"}),D:()=>String(c),Do:()=>S(c),DD:()=>`${c}`.padStart(2,"0"),H:()=>String(u),Ho:()=>S(u),HH:()=>`${u}`.padStart(2,"0"),h:()=>`${u%12||12}`.padStart(1,"0"),ho:()=>S(u%12||12),hh:()=>`${u%12||12}`.padStart(2,"0"),m:()=>String(s),mo:()=>S(s),mm:()=>`${s}`.padStart(2,"0"),s:()=>String(h),so:()=>S(h),ss:()=>`${h}`.padStart(2,"0"),SSS:()=>`${d}`.padStart(3,"0"),d:()=>m,dd:()=>t.toLocaleDateString(o.toValue(n.locales),{weekday:"narrow"}),ddd:()=>t.toLocaleDateString(o.toValue(n.locales),{weekday:"short"}),dddd:()=>t.toLocaleDateString(o.toValue(n.locales),{weekday:"long"}),A:()=>f(u,s),AA:()=>f(u,s,!1,!0),a:()=>f(u,s,!0),aa:()=>f(u,s,!0,!0),z:()=>y(t.toLocaleDateString(o.toValue(n.locales),{timeZoneName:"shortOffset"})),zz:()=>y(t.toLocaleDateString(o.toValue(n.locales),{timeZoneName:"shortOffset"})),zzz:()=>y(t.toLocaleDateString(o.toValue(n.locales),{timeZoneName:"shortOffset"})),zzzz:()=>y(t.toLocaleDateString(o.toValue(n.locales),{timeZoneName:"longOffset"}))};return e.replace(Te,(V,w)=>{var b,R;return(R=w??((b=g[V])==null?void 0:b.call(g)))!=null?R:V})}function it(t){if(t===null)return new Date(Number.NaN);if(t===void 0)return new Date;if(t instanceof Date)return new Date(t);if(typeof t=="string"&&!/Z$/i.test(t)){const e=t.match(Re);if(e){const n=e[2]-1||0,r=(e[7]||"0").substring(0,3);return new Date(e[1],n,e[3]||1,e[4]||0,e[5]||0,e[6]||0,r)}}return new Date(t)}function Fe(t,e="HH:mm:ss",n={}){return o.computed(()=>at(it(o.toValue(t)),o.toValue(e),n))}function lt(t,e=1e3,n={}){const{immediate:r=!0,immediateCallback:a=!1}=n;let i=null;const c=o.shallowRef(!1);function u(){i&&(clearInterval(i),i=null)}function s(){c.value=!1,u()}function h(){const d=o.toValue(e);d<=0||(c.value=!0,a&&t(),u(),c.value&&(i=setInterval(t,d)))}if(r&&D&&h(),o.isRef(e)||typeof e=="function"){const d=o.watch(e,()=>{c.value&&D&&h()});p(d)}return p(s),{isActive:o.shallowReadonly(c),pause:s,resume:h}}function Me(t=1e3,e={}){const{controls:n=!1,immediate:r=!0,callback:a}=e,i=o.shallowRef(0),c=()=>i.value+=1,u=()=>{i.value=0},s=lt(a?()=>{c(),a(i.value)}:c,t,{immediate:r});return n?{counter:o.shallowReadonly(i),reset:u,...s}:o.shallowReadonly(i)}function Pe(t,e={}){var n;const r=o.shallowRef((n=e.initialValue)!=null?n:null);return o.watch(t,()=>r.value=K(),e),o.shallowReadonly(r)}function ct(t,e,n={}){const{immediate:r=!0,immediateCallback:a=!1}=n,i=o.shallowRef(!1);let c;function u(){c&&(clearTimeout(c),c=void 0)}function s(){i.value=!1,u()}function h(...d){a&&t(),u(),i.value=!0,c=setTimeout(()=>{i.value=!1,c=void 0,t(...d)},o.toValue(e))}return r&&(i.value=!0,D&&h()),p(s),{isPending:o.shallowReadonly(i),start:h,stop:s}}function Ie(t=1e3,e={}){const{controls:n=!1,callback:r}=e,a=ct(r??A,t,e),i=o.computed(()=>!a.isPending.value);return n?{ready:i,...a}:i}function Ce(t,e={}){const{method:n="parseFloat",radix:r,nanToZero:a}=e;return o.computed(()=>{let i=o.toValue(t);return typeof n=="function"?i=n(i):typeof i=="string"&&(i=Number[n](i,r)),a&&Number.isNaN(i)&&(i=0),i})}function ke(t){return o.computed(()=>`${o.toValue(t)}`)}function Ee(t=!1,e={}){const{truthyValue:n=!0,falsyValue:r=!1}=e,a=o.isRef(t),i=o.shallowRef(t);function c(u){if(arguments.length)return i.value=u,i.value;{const s=o.toValue(n);return i.value=i.value===s?o.toValue(r):s,i.value}}return a?c:[i,c]}function _e(t,e,n){let r=n?.immediate?[]:[...typeof t=="function"?t():Array.isArray(t)?t:o.toValue(t)];return o.watch(t,(a,i,c)=>{const u=Array.from({length:r.length}),s=[];for(const d of a){let m=!1;for(let f=0;f<r.length;f++)if(!u[f]&&d===r[f]){u[f]=!0,m=!0;break}m||s.push(d)}const h=r.filter((d,m)=>!u[m]);e(a,r,s,h,c),r=[...a]},n)}function Ne(t,e,n){const{count:r,...a}=n,i=o.shallowRef(0),c=P(t,(...u)=>{i.value+=1,i.value>=o.toValue(r)&&o.nextTick(()=>c()),e(...u)},a);return{count:i,stop:c}}function ut(t,e,n={}){const{debounce:r=0,maxWait:a=void 0,...i}=n;return P(t,e,{...i,eventFilter:L(r,{maxWait:a})})}function Le(t,e,n){return o.watch(t,e,{...n,deep:!0})}function Y(t,e,n={}){const{eventFilter:r=C,...a}=n,i=F(r,e);let c,u,s;if(a.flush==="sync"){let h=!1;u=()=>{},c=d=>{h=!0,d(),h=!1},s=o.watch(t,(...d)=>{h||i(...d)},a)}else{const h=[];let d=0,m=0;u=()=>{d=m},h.push(o.watch(t,()=>{m++},{...a,flush:"sync"})),c=f=>{const y=m;f(),d+=m-y},h.push(o.watch(t,(...f)=>{const y=d>0&&d===m;d=0,m=0,!y&&i(...f)},a)),s=()=>{h.forEach(f=>f())}}return{stop:s,ignoreUpdates:c,ignorePrevAsyncUpdates:u}}function je(t,e,n){return o.watch(t,e,{...n,immediate:!0})}function We(t,e,n){return o.watch(t,e,{...n,once:!0})}function st(t,e,n={}){const{throttle:r=0,trailing:a=!0,leading:i=!0,...c}=n;return P(t,e,{...c,eventFilter:j(r,a,i)})}function Ue(t,e,n={}){let r;function a(){if(!r)return;const d=r;r=void 0,d()}function i(d){r=d}const c=(d,m)=>(a(),e(d,m,i)),u=Y(t,c,n),{ignoreUpdates:s}=u;return{...u,trigger:()=>{let d;return s(()=>{d=c(ze(t),Be(t))}),d}}}function ze(t){return o.isReactive(t)?t:Array.isArray(t)?t.map(e=>o.toValue(e)):o.toValue(t)}function Be(t){return Array.isArray(t)?t.map(()=>{}):void 0}function Ye(t,e,n){const r=o.watch(t,(a,i,c)=>{a&&(n?.once&&o.nextTick(()=>r()),e(a,i,c))},{...n,once:!1});return r}l.assert=Tt,l.autoResetRef=Q,l.bypassFilter=C,l.camelize=Zt,l.clamp=Mt,l.computedEager=$,l.computedWithControl=H,l.containsProp=x,l.controlledComputed=H,l.controlledRef=Jt,l.createEventHook=dt,l.createFilterWrapper=F,l.createGlobalState=mt,l.createInjectionState=ht,l.createReactiveFn=_,l.createRef=yt,l.createSharedComposable=wt,l.createSingletonPromise=Lt,l.debounceFilter=L,l.debouncedRef=U,l.debouncedWatch=ut,l.eagerComputed=$,l.extendRef=q,l.formatDate=at,l.get=gt,l.getLifeCycleTarget=M,l.hasOwn=It,l.hyphenate=Ht,l.identity=Nt,l.ignorableWatch=Y,l.increaseWithUnit=Wt,l.injectLocal=G,l.invoke=jt,l.isClient=D,l.isDef=Ot,l.isDefined=Vt,l.isIOS=Ct,l.isObject=X,l.isWorker=St,l.makeDestructurable=bt,l.noop=A,l.normalizeDate=it,l.notNullish=Rt,l.now=Ft,l.objectEntries=Yt,l.objectOmit=Bt,l.objectPick=zt,l.pausableFilter=v,l.pausableWatch=k,l.promiseTimeout=W,l.provideLocal=Z,l.pxValue=Ut,l.rand=Pt,l.reactify=_,l.reactifyObject=pt,l.reactiveComputed=N,l.reactiveOmit=At,l.reactivePick=_t,l.refAutoReset=Q,l.refDebounced=U,l.refDefault=qt,l.refThrottled=z,l.refWithControl=ot,l.resolveRef=Et,l.resolveUnref=te,l.set=Xt,l.syncRef=Kt,l.syncRefs=Qt,l.throttleFilter=j,l.throttledRef=z,l.throttledWatch=st,l.timestamp=K,l.toArray=tt,l.toReactive=J,l.toRef=I,l.toRefs=vt,l.toValue=xt,l.tryOnBeforeMount=ee,l.tryOnBeforeUnmount=ne,l.tryOnMounted=re,l.tryOnScopeDispose=p,l.tryOnUnmounted=oe,l.until=ae,l.useArrayDifference=le,l.useArrayEvery=ce,l.useArrayFilter=ue,l.useArrayFind=se,l.useArrayFindIndex=fe,l.useArrayFindLast=me,l.useArrayIncludes=ye,l.useArrayJoin=we,l.useArrayMap=ge,l.useArrayReduce=Ve,l.useArraySome=be,l.useArrayUnique=Se,l.useCounter=Oe,l.useDateFormat=Fe,l.useDebounce=U,l.useDebounceFn=nt,l.useInterval=Me,l.useIntervalFn=lt,l.useLastChanged=Pe,l.useThrottle=z,l.useThrottleFn=rt,l.useTimeout=Ie,l.useTimeoutFn=ct,l.useToNumber=Ce,l.useToString=ke,l.useToggle=Ee,l.watchArray=_e,l.watchAtMost=Ne,l.watchDebounced=ut,l.watchDeep=Le,l.watchIgnorable=Y,l.watchImmediate=je,l.watchOnce=We,l.watchPausable=k,l.watchThrottled=st,l.watchTriggerable=Ue,l.watchWithFilter=P,l.whenever=Ye})(this.VueUse=this.VueUse||{},Vue); |
-1642
| import { shallowRef, watchEffect, readonly, watch, customRef, getCurrentScope, onScopeDispose, effectScope, getCurrentInstance, hasInjectionContext, inject, provide, ref, isRef, unref, toValue as toValue$1, computed, reactive, toRefs as toRefs$1, toRef as toRef$1, shallowReadonly, onBeforeMount, nextTick, onBeforeUnmount, onMounted, onUnmounted, isReactive } from 'vue'; | ||
| function computedEager(fn, options) { | ||
| var _a; | ||
| const result = shallowRef(); | ||
| watchEffect(() => { | ||
| result.value = fn(); | ||
| }, { | ||
| ...options, | ||
| flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync" | ||
| }); | ||
| return readonly(result); | ||
| } | ||
| function computedWithControl(source, fn, options = {}) { | ||
| let v = void 0; | ||
| let track; | ||
| let trigger; | ||
| let dirty = true; | ||
| const update = () => { | ||
| dirty = true; | ||
| trigger(); | ||
| }; | ||
| watch(source, update, { flush: "sync", ...options }); | ||
| const get = typeof fn === "function" ? fn : fn.get; | ||
| const set = typeof fn === "function" ? void 0 : fn.set; | ||
| const result = customRef((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| if (dirty) { | ||
| v = get(v); | ||
| dirty = false; | ||
| } | ||
| track(); | ||
| return v; | ||
| }, | ||
| set(v2) { | ||
| set == null ? void 0 : set(v2); | ||
| } | ||
| }; | ||
| }); | ||
| result.trigger = update; | ||
| return result; | ||
| } | ||
| function tryOnScopeDispose(fn) { | ||
| if (getCurrentScope()) { | ||
| onScopeDispose(fn); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createEventHook() { | ||
| const fns = /* @__PURE__ */ new Set(); | ||
| const off = (fn) => { | ||
| fns.delete(fn); | ||
| }; | ||
| const clear = () => { | ||
| fns.clear(); | ||
| }; | ||
| const on = (fn) => { | ||
| fns.add(fn); | ||
| const offFn = () => off(fn); | ||
| tryOnScopeDispose(offFn); | ||
| return { | ||
| off: offFn | ||
| }; | ||
| }; | ||
| const trigger = (...args) => { | ||
| return Promise.all(Array.from(fns).map((fn) => fn(...args))); | ||
| }; | ||
| return { | ||
| on, | ||
| off, | ||
| trigger, | ||
| clear | ||
| }; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createGlobalState(stateFactory) { | ||
| let initialized = false; | ||
| let state; | ||
| const scope = effectScope(true); | ||
| return (...args) => { | ||
| if (!initialized) { | ||
| state = scope.run(() => stateFactory(...args)); | ||
| initialized = true; | ||
| } | ||
| return state; | ||
| }; | ||
| } | ||
| const localProvidedStateMap = /* @__PURE__ */ new WeakMap(); | ||
| const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => { | ||
| var _a; | ||
| const key = args[0]; | ||
| const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy; | ||
| if (instance == null && !hasInjectionContext()) | ||
| throw new Error("injectLocal must be called in setup"); | ||
| if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance)) | ||
| return localProvidedStateMap.get(instance)[key]; | ||
| return inject(...args); | ||
| }; | ||
| function provideLocal(key, value) { | ||
| var _a; | ||
| const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy; | ||
| if (instance == null) | ||
| throw new Error("provideLocal must be called in setup"); | ||
| if (!localProvidedStateMap.has(instance)) | ||
| localProvidedStateMap.set(instance, /* @__PURE__ */ Object.create(null)); | ||
| const localProvidedState = localProvidedStateMap.get(instance); | ||
| localProvidedState[key] = value; | ||
| return provide(key, value); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createInjectionState(composable, options) { | ||
| const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState"); | ||
| const defaultValue = options == null ? void 0 : options.defaultValue; | ||
| const useProvidingState = (...args) => { | ||
| const state = composable(...args); | ||
| provideLocal(key, state); | ||
| return state; | ||
| }; | ||
| const useInjectedState = () => injectLocal(key, defaultValue); | ||
| return [useProvidingState, useInjectedState]; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createRef(value, deep) { | ||
| if (deep === true) { | ||
| return ref(value); | ||
| } else { | ||
| return shallowRef(value); | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function createSharedComposable(composable) { | ||
| let subscribers = 0; | ||
| let state; | ||
| let scope; | ||
| const dispose = () => { | ||
| subscribers -= 1; | ||
| if (scope && subscribers <= 0) { | ||
| scope.stop(); | ||
| state = void 0; | ||
| scope = void 0; | ||
| } | ||
| }; | ||
| return (...args) => { | ||
| subscribers += 1; | ||
| if (!scope) { | ||
| scope = effectScope(true); | ||
| state = scope.run(() => composable(...args)); | ||
| } | ||
| tryOnScopeDispose(dispose); | ||
| return state; | ||
| }; | ||
| } | ||
| function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) { | ||
| for (const [key, value] of Object.entries(extend)) { | ||
| if (key === "value") | ||
| continue; | ||
| if (isRef(value) && unwrap) { | ||
| Object.defineProperty(ref, key, { | ||
| get() { | ||
| return value.value; | ||
| }, | ||
| set(v) { | ||
| value.value = v; | ||
| }, | ||
| enumerable | ||
| }); | ||
| } else { | ||
| Object.defineProperty(ref, key, { value, enumerable }); | ||
| } | ||
| } | ||
| return ref; | ||
| } | ||
| function get(obj, key) { | ||
| if (key == null) | ||
| return unref(obj); | ||
| return unref(obj)[key]; | ||
| } | ||
| function isDefined(v) { | ||
| return unref(v) != null; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function makeDestructurable(obj, arr) { | ||
| if (typeof Symbol !== "undefined") { | ||
| const clone = { ...obj }; | ||
| Object.defineProperty(clone, Symbol.iterator, { | ||
| enumerable: false, | ||
| value() { | ||
| let index = 0; | ||
| return { | ||
| next: () => ({ | ||
| value: arr[index++], | ||
| done: index > arr.length | ||
| }) | ||
| }; | ||
| } | ||
| }); | ||
| return clone; | ||
| } else { | ||
| return Object.assign([...arr], obj); | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function reactify(fn, options) { | ||
| const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue$1; | ||
| return function(...args) { | ||
| return computed(() => fn.apply(this, args.map((i) => unrefFn(i)))); | ||
| }; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function reactifyObject(obj, optionsOrKeys = {}) { | ||
| let keys = []; | ||
| let options; | ||
| if (Array.isArray(optionsOrKeys)) { | ||
| keys = optionsOrKeys; | ||
| } else { | ||
| options = optionsOrKeys; | ||
| const { includeOwnProperties = true } = optionsOrKeys; | ||
| keys.push(...Object.keys(obj)); | ||
| if (includeOwnProperties) | ||
| keys.push(...Object.getOwnPropertyNames(obj)); | ||
| } | ||
| return Object.fromEntries( | ||
| keys.map((key) => { | ||
| const value = obj[key]; | ||
| return [ | ||
| key, | ||
| typeof value === "function" ? reactify(value.bind(obj), options) : value | ||
| ]; | ||
| }) | ||
| ); | ||
| } | ||
| function toReactive(objectRef) { | ||
| if (!isRef(objectRef)) | ||
| return reactive(objectRef); | ||
| const proxy = new Proxy({}, { | ||
| get(_, p, receiver) { | ||
| return unref(Reflect.get(objectRef.value, p, receiver)); | ||
| }, | ||
| set(_, p, value) { | ||
| if (isRef(objectRef.value[p]) && !isRef(value)) | ||
| objectRef.value[p].value = value; | ||
| else | ||
| objectRef.value[p] = value; | ||
| return true; | ||
| }, | ||
| deleteProperty(_, p) { | ||
| return Reflect.deleteProperty(objectRef.value, p); | ||
| }, | ||
| has(_, p) { | ||
| return Reflect.has(objectRef.value, p); | ||
| }, | ||
| ownKeys() { | ||
| return Object.keys(objectRef.value); | ||
| }, | ||
| getOwnPropertyDescriptor() { | ||
| return { | ||
| enumerable: true, | ||
| configurable: true | ||
| }; | ||
| } | ||
| }); | ||
| return reactive(proxy); | ||
| } | ||
| function reactiveComputed(fn) { | ||
| return toReactive(computed(fn)); | ||
| } | ||
| function reactiveOmit(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => !predicate(toValue$1(v), k))) : Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0])))); | ||
| } | ||
| const isClient = typeof window !== "undefined" && typeof document !== "undefined"; | ||
| const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; | ||
| const isDef = (val) => typeof val !== "undefined"; | ||
| const notNullish = (val) => val != null; | ||
| const assert = (condition, ...infos) => { | ||
| if (!condition) | ||
| console.warn(...infos); | ||
| }; | ||
| const toString = Object.prototype.toString; | ||
| const isObject = (val) => toString.call(val) === "[object Object]"; | ||
| const now = () => Date.now(); | ||
| const timestamp = () => +Date.now(); | ||
| const clamp = (n, min, max) => Math.min(max, Math.max(min, n)); | ||
| const noop = () => { | ||
| }; | ||
| const rand = (min, max) => { | ||
| min = Math.ceil(min); | ||
| max = Math.floor(max); | ||
| return Math.floor(Math.random() * (max - min + 1)) + min; | ||
| }; | ||
| const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key); | ||
| const isIOS = /* @__PURE__ */ getIsIOS(); | ||
| function getIsIOS() { | ||
| var _a, _b; | ||
| return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent)); | ||
| } | ||
| function toRef(...args) { | ||
| if (args.length !== 1) | ||
| return toRef$1(...args); | ||
| const r = args[0]; | ||
| return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop }))) : ref(r); | ||
| } | ||
| const resolveRef = toRef; | ||
| function reactivePick(obj, ...keys) { | ||
| const flatKeys = keys.flat(); | ||
| const predicate = flatKeys[0]; | ||
| return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => predicate(toValue$1(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)]))); | ||
| } | ||
| function refAutoReset(defaultValue, afterMs = 1e4) { | ||
| return customRef((track, trigger) => { | ||
| let value = toValue$1(defaultValue); | ||
| let timer; | ||
| const resetAfter = () => setTimeout(() => { | ||
| value = toValue$1(defaultValue); | ||
| trigger(); | ||
| }, toValue$1(afterMs)); | ||
| tryOnScopeDispose(() => { | ||
| clearTimeout(timer); | ||
| }); | ||
| return { | ||
| get() { | ||
| track(); | ||
| return value; | ||
| }, | ||
| set(newValue) { | ||
| value = newValue; | ||
| trigger(); | ||
| clearTimeout(timer); | ||
| timer = resetAfter(); | ||
| } | ||
| }; | ||
| }); | ||
| } | ||
| function createFilterWrapper(filter, fn) { | ||
| function wrapper(...args) { | ||
| return new Promise((resolve, reject) => { | ||
| Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject); | ||
| }); | ||
| } | ||
| return wrapper; | ||
| } | ||
| const bypassFilter = (invoke) => { | ||
| return invoke(); | ||
| }; | ||
| function debounceFilter(ms, options = {}) { | ||
| let timer; | ||
| let maxTimer; | ||
| let lastRejector = noop; | ||
| const _clearTimeout = (timer2) => { | ||
| clearTimeout(timer2); | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| }; | ||
| let lastInvoker; | ||
| const filter = (invoke) => { | ||
| const duration = toValue$1(ms); | ||
| const maxDuration = toValue$1(options.maxWait); | ||
| if (timer) | ||
| _clearTimeout(timer); | ||
| if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) { | ||
| if (maxTimer) { | ||
| _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| } | ||
| return Promise.resolve(invoke()); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| lastRejector = options.rejectOnCancel ? reject : resolve; | ||
| lastInvoker = invoke; | ||
| if (maxDuration && !maxTimer) { | ||
| maxTimer = setTimeout(() => { | ||
| if (timer) | ||
| _clearTimeout(timer); | ||
| maxTimer = void 0; | ||
| resolve(lastInvoker()); | ||
| }, maxDuration); | ||
| } | ||
| timer = setTimeout(() => { | ||
| if (maxTimer) | ||
| _clearTimeout(maxTimer); | ||
| maxTimer = void 0; | ||
| resolve(invoke()); | ||
| }, duration); | ||
| }); | ||
| }; | ||
| return filter; | ||
| } | ||
| function throttleFilter(...args) { | ||
| let lastExec = 0; | ||
| let timer; | ||
| let isLeading = true; | ||
| let lastRejector = noop; | ||
| let lastValue; | ||
| let ms; | ||
| let trailing; | ||
| let leading; | ||
| let rejectOnCancel; | ||
| if (!isRef(args[0]) && typeof args[0] === "object") | ||
| ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]); | ||
| else | ||
| [ms, trailing = true, leading = true, rejectOnCancel = false] = args; | ||
| const clear = () => { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| lastRejector(); | ||
| lastRejector = noop; | ||
| } | ||
| }; | ||
| const filter = (_invoke) => { | ||
| const duration = toValue$1(ms); | ||
| const elapsed = Date.now() - lastExec; | ||
| const invoke = () => { | ||
| return lastValue = _invoke(); | ||
| }; | ||
| clear(); | ||
| if (duration <= 0) { | ||
| lastExec = Date.now(); | ||
| return invoke(); | ||
| } | ||
| if (elapsed > duration) { | ||
| lastExec = Date.now(); | ||
| if (leading || !isLeading) | ||
| invoke(); | ||
| } else if (trailing) { | ||
| lastValue = new Promise((resolve, reject) => { | ||
| lastRejector = rejectOnCancel ? reject : resolve; | ||
| timer = setTimeout(() => { | ||
| lastExec = Date.now(); | ||
| isLeading = true; | ||
| resolve(invoke()); | ||
| clear(); | ||
| }, Math.max(0, duration - elapsed)); | ||
| }); | ||
| } | ||
| if (!leading && !timer) | ||
| timer = setTimeout(() => isLeading = true, duration); | ||
| isLeading = false; | ||
| return lastValue; | ||
| }; | ||
| return filter; | ||
| } | ||
| function pausableFilter(extendFilter = bypassFilter, options = {}) { | ||
| const { | ||
| initialState = "active" | ||
| } = options; | ||
| const isActive = toRef(initialState === "active"); | ||
| function pause() { | ||
| isActive.value = false; | ||
| } | ||
| function resume() { | ||
| isActive.value = true; | ||
| } | ||
| const eventFilter = (...args) => { | ||
| if (isActive.value) | ||
| extendFilter(...args); | ||
| }; | ||
| return { isActive: readonly(isActive), pause, resume, eventFilter }; | ||
| } | ||
| function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") { | ||
| return new Promise((resolve, reject) => { | ||
| if (throwOnTimeout) | ||
| setTimeout(() => reject(reason), ms); | ||
| else | ||
| setTimeout(resolve, ms); | ||
| }); | ||
| } | ||
| function identity(arg) { | ||
| return arg; | ||
| } | ||
| function createSingletonPromise(fn) { | ||
| let _promise; | ||
| function wrapper() { | ||
| if (!_promise) | ||
| _promise = fn(); | ||
| return _promise; | ||
| } | ||
| wrapper.reset = async () => { | ||
| const _prev = _promise; | ||
| _promise = void 0; | ||
| if (_prev) | ||
| await _prev; | ||
| }; | ||
| return wrapper; | ||
| } | ||
| function invoke(fn) { | ||
| return fn(); | ||
| } | ||
| function containsProp(obj, ...props) { | ||
| return props.some((k) => k in obj); | ||
| } | ||
| function increaseWithUnit(target, delta) { | ||
| var _a; | ||
| if (typeof target === "number") | ||
| return target + delta; | ||
| const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || ""; | ||
| const unit = target.slice(value.length); | ||
| const result = Number.parseFloat(value) + delta; | ||
| if (Number.isNaN(result)) | ||
| return target; | ||
| return result + unit; | ||
| } | ||
| function pxValue(px) { | ||
| return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px); | ||
| } | ||
| function objectPick(obj, keys, omitUndefined = false) { | ||
| return keys.reduce((n, k) => { | ||
| if (k in obj) { | ||
| if (!omitUndefined || obj[k] !== void 0) | ||
| n[k] = obj[k]; | ||
| } | ||
| return n; | ||
| }, {}); | ||
| } | ||
| function objectOmit(obj, keys, omitUndefined = false) { | ||
| return Object.fromEntries(Object.entries(obj).filter(([key, value]) => { | ||
| return (!omitUndefined || value !== void 0) && !keys.includes(key); | ||
| })); | ||
| } | ||
| function objectEntries(obj) { | ||
| return Object.entries(obj); | ||
| } | ||
| function toArray(value) { | ||
| return Array.isArray(value) ? value : [value]; | ||
| } | ||
| function cacheStringFunction(fn) { | ||
| const cache = /* @__PURE__ */ Object.create(null); | ||
| return (str) => { | ||
| const hit = cache[str]; | ||
| return hit || (cache[str] = fn(str)); | ||
| }; | ||
| } | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); | ||
| const camelizeRE = /-(\w)/g; | ||
| const camelize = cacheStringFunction((str) => { | ||
| return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
| }); | ||
| function getLifeCycleTarget(target) { | ||
| return target || getCurrentInstance(); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useDebounceFn(fn, ms = 200, options = {}) { | ||
| return createFilterWrapper( | ||
| debounceFilter(ms, options), | ||
| fn | ||
| ); | ||
| } | ||
| function refDebounced(value, ms = 200, options = {}) { | ||
| const debounced = ref(toValue$1(value)); | ||
| const updater = useDebounceFn(() => { | ||
| debounced.value = value.value; | ||
| }, ms, options); | ||
| watch(value, () => updater()); | ||
| return shallowReadonly(debounced); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function refDefault(source, defaultValue) { | ||
| return computed({ | ||
| get() { | ||
| var _a; | ||
| return (_a = source.value) != null ? _a : defaultValue; | ||
| }, | ||
| set(value) { | ||
| source.value = value; | ||
| } | ||
| }); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) { | ||
| return createFilterWrapper( | ||
| throttleFilter(ms, trailing, leading, rejectOnCancel), | ||
| fn | ||
| ); | ||
| } | ||
| function refThrottled(value, delay = 200, trailing = true, leading = true) { | ||
| if (delay <= 0) | ||
| return value; | ||
| const throttled = ref(toValue$1(value)); | ||
| const updater = useThrottleFn(() => { | ||
| throttled.value = value.value; | ||
| }, delay, trailing, leading); | ||
| watch(value, () => updater()); | ||
| return throttled; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function refWithControl(initial, options = {}) { | ||
| let source = initial; | ||
| let track; | ||
| let trigger; | ||
| const ref = customRef((_track, _trigger) => { | ||
| track = _track; | ||
| trigger = _trigger; | ||
| return { | ||
| get() { | ||
| return get(); | ||
| }, | ||
| set(v) { | ||
| set(v); | ||
| } | ||
| }; | ||
| }); | ||
| function get(tracking = true) { | ||
| if (tracking) | ||
| track(); | ||
| return source; | ||
| } | ||
| function set(value, triggering = true) { | ||
| var _a, _b; | ||
| if (value === source) | ||
| return; | ||
| const old = source; | ||
| if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false) | ||
| return; | ||
| source = value; | ||
| (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old); | ||
| if (triggering) | ||
| trigger(); | ||
| } | ||
| const untrackedGet = () => get(false); | ||
| const silentSet = (v) => set(v, false); | ||
| const peek = () => get(false); | ||
| const lay = (v) => set(v, false); | ||
| return extendRef( | ||
| ref, | ||
| { | ||
| get, | ||
| set, | ||
| untrackedGet, | ||
| silentSet, | ||
| peek, | ||
| lay | ||
| }, | ||
| { enumerable: true } | ||
| ); | ||
| } | ||
| const controlledRef = refWithControl; | ||
| function set(...args) { | ||
| if (args.length === 2) { | ||
| const [ref, value] = args; | ||
| ref.value = value; | ||
| } | ||
| if (args.length === 3) { | ||
| const [target, key, value] = args; | ||
| target[key] = value; | ||
| } | ||
| } | ||
| function watchWithFilter(source, cb, options = {}) { | ||
| const { | ||
| eventFilter = bypassFilter, | ||
| ...watchOptions | ||
| } = options; | ||
| return watch( | ||
| source, | ||
| createFilterWrapper( | ||
| eventFilter, | ||
| cb | ||
| ), | ||
| watchOptions | ||
| ); | ||
| } | ||
| function watchPausable(source, cb, options = {}) { | ||
| const { | ||
| eventFilter: filter, | ||
| initialState = "active", | ||
| ...watchOptions | ||
| } = options; | ||
| const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState }); | ||
| const stop = watchWithFilter( | ||
| source, | ||
| cb, | ||
| { | ||
| ...watchOptions, | ||
| eventFilter | ||
| } | ||
| ); | ||
| return { stop, pause, resume, isActive }; | ||
| } | ||
| function syncRef(left, right, ...[options]) { | ||
| const { | ||
| flush = "sync", | ||
| deep = false, | ||
| immediate = true, | ||
| direction = "both", | ||
| transform = {} | ||
| } = options || {}; | ||
| const watchers = []; | ||
| const transformLTR = "ltr" in transform && transform.ltr || ((v) => v); | ||
| const transformRTL = "rtl" in transform && transform.rtl || ((v) => v); | ||
| if (direction === "both" || direction === "ltr") { | ||
| watchers.push(watchPausable( | ||
| left, | ||
| (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| right.value = transformLTR(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, | ||
| { flush, deep, immediate } | ||
| )); | ||
| } | ||
| if (direction === "both" || direction === "rtl") { | ||
| watchers.push(watchPausable( | ||
| right, | ||
| (newValue) => { | ||
| watchers.forEach((w) => w.pause()); | ||
| left.value = transformRTL(newValue); | ||
| watchers.forEach((w) => w.resume()); | ||
| }, | ||
| { flush, deep, immediate } | ||
| )); | ||
| } | ||
| const stop = () => { | ||
| watchers.forEach((w) => w.stop()); | ||
| }; | ||
| return stop; | ||
| } | ||
| function syncRefs(source, targets, options = {}) { | ||
| const { | ||
| flush = "sync", | ||
| deep = false, | ||
| immediate = true | ||
| } = options; | ||
| const targetsArray = toArray(targets); | ||
| return watch( | ||
| source, | ||
| (newValue) => targetsArray.forEach((target) => target.value = newValue), | ||
| { flush, deep, immediate } | ||
| ); | ||
| } | ||
| function toRefs(objectRef, options = {}) { | ||
| if (!isRef(objectRef)) | ||
| return toRefs$1(objectRef); | ||
| const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {}; | ||
| for (const key in objectRef.value) { | ||
| result[key] = customRef(() => ({ | ||
| get() { | ||
| return objectRef.value[key]; | ||
| }, | ||
| set(v) { | ||
| var _a; | ||
| const replaceRef = (_a = toValue$1(options.replaceRef)) != null ? _a : true; | ||
| if (replaceRef) { | ||
| if (Array.isArray(objectRef.value)) { | ||
| const copy = [...objectRef.value]; | ||
| copy[key] = v; | ||
| objectRef.value = copy; | ||
| } else { | ||
| const newObject = { ...objectRef.value, [key]: v }; | ||
| Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value)); | ||
| objectRef.value = newObject; | ||
| } | ||
| } else { | ||
| objectRef.value[key] = v; | ||
| } | ||
| } | ||
| })); | ||
| } | ||
| return result; | ||
| } | ||
| const toValue = toValue$1; | ||
| const resolveUnref = toValue$1; | ||
| function tryOnBeforeMount(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| onBeforeMount(fn, target); | ||
| else if (sync) | ||
| fn(); | ||
| else | ||
| nextTick(fn); | ||
| } | ||
| function tryOnBeforeUnmount(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| onBeforeUnmount(fn, target); | ||
| } | ||
| function tryOnMounted(fn, sync = true, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| onMounted(fn, target); | ||
| else if (sync) | ||
| fn(); | ||
| else | ||
| nextTick(fn); | ||
| } | ||
| function tryOnUnmounted(fn, target) { | ||
| const instance = getLifeCycleTarget(target); | ||
| if (instance) | ||
| onUnmounted(fn, target); | ||
| } | ||
| function createUntil(r, isNot = false) { | ||
| function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) { | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = watch( | ||
| r, | ||
| (v) => { | ||
| if (condition(v) !== isNot) { | ||
| if (stop) | ||
| stop(); | ||
| else | ||
| nextTick(() => stop == null ? void 0 : stop()); | ||
| resolve(v); | ||
| } | ||
| }, | ||
| { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| } | ||
| ); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) { | ||
| promises.push( | ||
| promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => stop == null ? void 0 : stop()) | ||
| ); | ||
| } | ||
| return Promise.race(promises); | ||
| } | ||
| function toBe(value, options) { | ||
| if (!isRef(value)) | ||
| return toMatch((v) => v === value, options); | ||
| const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {}; | ||
| let stop = null; | ||
| const watcher = new Promise((resolve) => { | ||
| stop = watch( | ||
| [r, value], | ||
| ([v1, v2]) => { | ||
| if (isNot !== (v1 === v2)) { | ||
| if (stop) | ||
| stop(); | ||
| else | ||
| nextTick(() => stop == null ? void 0 : stop()); | ||
| resolve(v1); | ||
| } | ||
| }, | ||
| { | ||
| flush, | ||
| deep, | ||
| immediate: true | ||
| } | ||
| ); | ||
| }); | ||
| const promises = [watcher]; | ||
| if (timeout != null) { | ||
| promises.push( | ||
| promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => { | ||
| stop == null ? void 0 : stop(); | ||
| return toValue$1(r); | ||
| }) | ||
| ); | ||
| } | ||
| return Promise.race(promises); | ||
| } | ||
| function toBeTruthy(options) { | ||
| return toMatch((v) => Boolean(v), options); | ||
| } | ||
| function toBeNull(options) { | ||
| return toBe(null, options); | ||
| } | ||
| function toBeUndefined(options) { | ||
| return toBe(void 0, options); | ||
| } | ||
| function toBeNaN(options) { | ||
| return toMatch(Number.isNaN, options); | ||
| } | ||
| function toContains(value, options) { | ||
| return toMatch((v) => { | ||
| const array = Array.from(v); | ||
| return array.includes(value) || array.includes(toValue$1(value)); | ||
| }, options); | ||
| } | ||
| function changed(options) { | ||
| return changedTimes(1, options); | ||
| } | ||
| function changedTimes(n = 1, options) { | ||
| let count = -1; | ||
| return toMatch(() => { | ||
| count += 1; | ||
| return count >= n; | ||
| }, options); | ||
| } | ||
| if (Array.isArray(toValue$1(r))) { | ||
| const instance = { | ||
| toMatch, | ||
| toContains, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } else { | ||
| const instance = { | ||
| toMatch, | ||
| toBe, | ||
| toBeTruthy, | ||
| toBeNull, | ||
| toBeNaN, | ||
| toBeUndefined, | ||
| changed, | ||
| changedTimes, | ||
| get not() { | ||
| return createUntil(r, !isNot); | ||
| } | ||
| }; | ||
| return instance; | ||
| } | ||
| } | ||
| function until(r) { | ||
| return createUntil(r); | ||
| } | ||
| function defaultComparator(value, othVal) { | ||
| return value === othVal; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayDifference(...args) { | ||
| var _a, _b; | ||
| const list = args[0]; | ||
| const values = args[1]; | ||
| let compareFn = (_a = args[2]) != null ? _a : defaultComparator; | ||
| const { | ||
| symmetric = false | ||
| } = (_b = args[3]) != null ? _b : {}; | ||
| if (typeof compareFn === "string") { | ||
| const key = compareFn; | ||
| compareFn = (value, othVal) => value[key] === othVal[key]; | ||
| } | ||
| const diff1 = computed(() => toValue$1(list).filter((x) => toValue$1(values).findIndex((y) => compareFn(x, y)) === -1)); | ||
| if (symmetric) { | ||
| const diff2 = computed(() => toValue$1(values).filter((x) => toValue$1(list).findIndex((y) => compareFn(x, y)) === -1)); | ||
| return computed(() => symmetric ? [...toValue$1(diff1), ...toValue$1(diff2)] : toValue$1(diff1)); | ||
| } else { | ||
| return diff1; | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayEvery(list, fn) { | ||
| return computed(() => toValue$1(list).every((element, index, array) => fn(toValue$1(element), index, array))); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFilter(list, fn) { | ||
| return computed(() => toValue$1(list).map((i) => toValue$1(i)).filter(fn)); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFind(list, fn) { | ||
| return computed(() => toValue$1( | ||
| toValue$1(list).find((element, index, array) => fn(toValue$1(element), index, array)) | ||
| )); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFindIndex(list, fn) { | ||
| return computed(() => toValue$1(list).findIndex((element, index, array) => fn(toValue$1(element), index, array))); | ||
| } | ||
| function findLast(arr, cb) { | ||
| let index = arr.length; | ||
| while (index-- > 0) { | ||
| if (cb(arr[index], index, arr)) | ||
| return arr[index]; | ||
| } | ||
| return void 0; | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayFindLast(list, fn) { | ||
| return computed(() => toValue$1( | ||
| !Array.prototype.findLast ? findLast(toValue$1(list), (element, index, array) => fn(toValue$1(element), index, array)) : toValue$1(list).findLast((element, index, array) => fn(toValue$1(element), index, array)) | ||
| )); | ||
| } | ||
| function isArrayIncludesOptions(obj) { | ||
| return isObject(obj) && containsProp(obj, "formIndex", "comparator"); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayIncludes(...args) { | ||
| var _a; | ||
| const list = args[0]; | ||
| const value = args[1]; | ||
| let comparator = args[2]; | ||
| let formIndex = 0; | ||
| if (isArrayIncludesOptions(comparator)) { | ||
| formIndex = (_a = comparator.fromIndex) != null ? _a : 0; | ||
| comparator = comparator.comparator; | ||
| } | ||
| if (typeof comparator === "string") { | ||
| const key = comparator; | ||
| comparator = (element, value2) => element[key] === toValue$1(value2); | ||
| } | ||
| comparator = comparator != null ? comparator : (element, value2) => element === toValue$1(value2); | ||
| return computed(() => toValue$1(list).slice(formIndex).some((element, index, array) => comparator( | ||
| toValue$1(element), | ||
| toValue$1(value), | ||
| index, | ||
| toValue$1(array) | ||
| ))); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayJoin(list, separator) { | ||
| return computed(() => toValue$1(list).map((i) => toValue$1(i)).join(toValue$1(separator))); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayMap(list, fn) { | ||
| return computed(() => toValue$1(list).map((i) => toValue$1(i)).map(fn)); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayReduce(list, reducer, ...args) { | ||
| const reduceCallback = (sum, value, index) => reducer(toValue$1(sum), toValue$1(value), index); | ||
| return computed(() => { | ||
| const resolved = toValue$1(list); | ||
| return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue$1(args[0]()) : toValue$1(args[0])) : resolved.reduce(reduceCallback); | ||
| }); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArraySome(list, fn) { | ||
| return computed(() => toValue$1(list).some((element, index, array) => fn(toValue$1(element), index, array))); | ||
| } | ||
| function uniq(array) { | ||
| return Array.from(new Set(array)); | ||
| } | ||
| function uniqueElementsBy(array, fn) { | ||
| return array.reduce((acc, v) => { | ||
| if (!acc.some((x) => fn(v, x, array))) | ||
| acc.push(v); | ||
| return acc; | ||
| }, []); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useArrayUnique(list, compareFn) { | ||
| return computed(() => { | ||
| const resolvedList = toValue$1(list).map((element) => toValue$1(element)); | ||
| return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList); | ||
| }); | ||
| } | ||
| function useCounter(initialValue = 0, options = {}) { | ||
| let _initialValue = unref(initialValue); | ||
| const count = shallowRef(initialValue); | ||
| const { | ||
| max = Number.POSITIVE_INFINITY, | ||
| min = Number.NEGATIVE_INFINITY | ||
| } = options; | ||
| const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min); | ||
| const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max); | ||
| const get = () => count.value; | ||
| const set = (val) => count.value = Math.max(min, Math.min(max, val)); | ||
| const reset = (val = _initialValue) => { | ||
| _initialValue = val; | ||
| return set(val); | ||
| }; | ||
| return { count: shallowReadonly(count), inc, dec, get, set, reset }; | ||
| } | ||
| const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i; | ||
| const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g; | ||
| function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) { | ||
| let m = hours < 12 ? "AM" : "PM"; | ||
| if (hasPeriod) | ||
| m = m.split("").reduce((acc, curr) => acc += `${curr}.`, ""); | ||
| return isLowercase ? m.toLowerCase() : m; | ||
| } | ||
| function formatOrdinal(num) { | ||
| const suffixes = ["th", "st", "nd", "rd"]; | ||
| const v = num % 100; | ||
| return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]); | ||
| } | ||
| function formatDate(date, formatStr, options = {}) { | ||
| var _a; | ||
| const years = date.getFullYear(); | ||
| const month = date.getMonth(); | ||
| const days = date.getDate(); | ||
| const hours = date.getHours(); | ||
| const minutes = date.getMinutes(); | ||
| const seconds = date.getSeconds(); | ||
| const milliseconds = date.getMilliseconds(); | ||
| const day = date.getDay(); | ||
| const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem; | ||
| const stripTimeZone = (dateString) => { | ||
| var _a2; | ||
| return (_a2 = dateString.split(" ")[1]) != null ? _a2 : ""; | ||
| }; | ||
| const matches = { | ||
| Yo: () => formatOrdinal(years), | ||
| YY: () => String(years).slice(-2), | ||
| YYYY: () => years, | ||
| M: () => month + 1, | ||
| Mo: () => formatOrdinal(month + 1), | ||
| MM: () => `${month + 1}`.padStart(2, "0"), | ||
| MMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "short" }), | ||
| MMMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "long" }), | ||
| D: () => String(days), | ||
| Do: () => formatOrdinal(days), | ||
| DD: () => `${days}`.padStart(2, "0"), | ||
| H: () => String(hours), | ||
| Ho: () => formatOrdinal(hours), | ||
| HH: () => `${hours}`.padStart(2, "0"), | ||
| h: () => `${hours % 12 || 12}`.padStart(1, "0"), | ||
| ho: () => formatOrdinal(hours % 12 || 12), | ||
| hh: () => `${hours % 12 || 12}`.padStart(2, "0"), | ||
| m: () => String(minutes), | ||
| mo: () => formatOrdinal(minutes), | ||
| mm: () => `${minutes}`.padStart(2, "0"), | ||
| s: () => String(seconds), | ||
| so: () => formatOrdinal(seconds), | ||
| ss: () => `${seconds}`.padStart(2, "0"), | ||
| SSS: () => `${milliseconds}`.padStart(3, "0"), | ||
| d: () => day, | ||
| dd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "narrow" }), | ||
| ddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "short" }), | ||
| dddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "long" }), | ||
| A: () => meridiem(hours, minutes), | ||
| AA: () => meridiem(hours, minutes, false, true), | ||
| a: () => meridiem(hours, minutes, true), | ||
| aa: () => meridiem(hours, minutes, true, true), | ||
| z: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })), | ||
| zz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })), | ||
| zzzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "longOffset" })) | ||
| }; | ||
| return formatStr.replace(REGEX_FORMAT, (match, $1) => { | ||
| var _a2, _b; | ||
| return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match; | ||
| }); | ||
| } | ||
| function normalizeDate(date) { | ||
| if (date === null) | ||
| return new Date(Number.NaN); | ||
| if (date === void 0) | ||
| return /* @__PURE__ */ new Date(); | ||
| if (date instanceof Date) | ||
| return new Date(date); | ||
| if (typeof date === "string" && !/Z$/i.test(date)) { | ||
| const d = date.match(REGEX_PARSE); | ||
| if (d) { | ||
| const m = d[2] - 1 || 0; | ||
| const ms = (d[7] || "0").substring(0, 3); | ||
| return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms); | ||
| } | ||
| } | ||
| return new Date(date); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) { | ||
| return computed(() => formatDate(normalizeDate(toValue$1(date)), toValue$1(formatStr), options)); | ||
| } | ||
| function useIntervalFn(cb, interval = 1e3, options = {}) { | ||
| const { | ||
| immediate = true, | ||
| immediateCallback = false | ||
| } = options; | ||
| let timer = null; | ||
| const isActive = shallowRef(false); | ||
| function clean() { | ||
| if (timer) { | ||
| clearInterval(timer); | ||
| timer = null; | ||
| } | ||
| } | ||
| function pause() { | ||
| isActive.value = false; | ||
| clean(); | ||
| } | ||
| function resume() { | ||
| const intervalValue = toValue$1(interval); | ||
| if (intervalValue <= 0) | ||
| return; | ||
| isActive.value = true; | ||
| if (immediateCallback) | ||
| cb(); | ||
| clean(); | ||
| if (isActive.value) | ||
| timer = setInterval(cb, intervalValue); | ||
| } | ||
| if (immediate && isClient) | ||
| resume(); | ||
| if (isRef(interval) || typeof interval === "function") { | ||
| const stopWatch = watch(interval, () => { | ||
| if (isActive.value && isClient) | ||
| resume(); | ||
| }); | ||
| tryOnScopeDispose(stopWatch); | ||
| } | ||
| tryOnScopeDispose(pause); | ||
| return { | ||
| isActive: shallowReadonly(isActive), | ||
| pause, | ||
| resume | ||
| }; | ||
| } | ||
| function useInterval(interval = 1e3, options = {}) { | ||
| const { | ||
| controls: exposeControls = false, | ||
| immediate = true, | ||
| callback | ||
| } = options; | ||
| const counter = shallowRef(0); | ||
| const update = () => counter.value += 1; | ||
| const reset = () => { | ||
| counter.value = 0; | ||
| }; | ||
| const controls = useIntervalFn( | ||
| callback ? () => { | ||
| update(); | ||
| callback(counter.value); | ||
| } : update, | ||
| interval, | ||
| { immediate } | ||
| ); | ||
| if (exposeControls) { | ||
| return { | ||
| counter: shallowReadonly(counter), | ||
| reset, | ||
| ...controls | ||
| }; | ||
| } else { | ||
| return shallowReadonly(counter); | ||
| } | ||
| } | ||
| function useLastChanged(source, options = {}) { | ||
| var _a; | ||
| const ms = shallowRef((_a = options.initialValue) != null ? _a : null); | ||
| watch( | ||
| source, | ||
| () => ms.value = timestamp(), | ||
| options | ||
| ); | ||
| return shallowReadonly(ms); | ||
| } | ||
| function useTimeoutFn(cb, interval, options = {}) { | ||
| const { | ||
| immediate = true, | ||
| immediateCallback = false | ||
| } = options; | ||
| const isPending = shallowRef(false); | ||
| let timer; | ||
| function clear() { | ||
| if (timer) { | ||
| clearTimeout(timer); | ||
| timer = void 0; | ||
| } | ||
| } | ||
| function stop() { | ||
| isPending.value = false; | ||
| clear(); | ||
| } | ||
| function start(...args) { | ||
| if (immediateCallback) | ||
| cb(); | ||
| clear(); | ||
| isPending.value = true; | ||
| timer = setTimeout(() => { | ||
| isPending.value = false; | ||
| timer = void 0; | ||
| cb(...args); | ||
| }, toValue$1(interval)); | ||
| } | ||
| if (immediate) { | ||
| isPending.value = true; | ||
| if (isClient) | ||
| start(); | ||
| } | ||
| tryOnScopeDispose(stop); | ||
| return { | ||
| isPending: shallowReadonly(isPending), | ||
| start, | ||
| stop | ||
| }; | ||
| } | ||
| function useTimeout(interval = 1e3, options = {}) { | ||
| const { | ||
| controls: exposeControls = false, | ||
| callback | ||
| } = options; | ||
| const controls = useTimeoutFn( | ||
| callback != null ? callback : noop, | ||
| interval, | ||
| options | ||
| ); | ||
| const ready = computed(() => !controls.isPending.value); | ||
| if (exposeControls) { | ||
| return { | ||
| ready, | ||
| ...controls | ||
| }; | ||
| } else { | ||
| return ready; | ||
| } | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useToNumber(value, options = {}) { | ||
| const { | ||
| method = "parseFloat", | ||
| radix, | ||
| nanToZero | ||
| } = options; | ||
| return computed(() => { | ||
| let resolved = toValue$1(value); | ||
| if (typeof method === "function") | ||
| resolved = method(resolved); | ||
| else if (typeof resolved === "string") | ||
| resolved = Number[method](resolved, radix); | ||
| if (nanToZero && Number.isNaN(resolved)) | ||
| resolved = 0; | ||
| return resolved; | ||
| }); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useToString(value) { | ||
| return computed(() => `${toValue$1(value)}`); | ||
| } | ||
| // @__NO_SIDE_EFFECTS__ | ||
| function useToggle(initialValue = false, options = {}) { | ||
| const { | ||
| truthyValue = true, | ||
| falsyValue = false | ||
| } = options; | ||
| const valueIsRef = isRef(initialValue); | ||
| const _value = shallowRef(initialValue); | ||
| function toggle(value) { | ||
| if (arguments.length) { | ||
| _value.value = value; | ||
| return _value.value; | ||
| } else { | ||
| const truthy = toValue$1(truthyValue); | ||
| _value.value = _value.value === truthy ? toValue$1(falsyValue) : truthy; | ||
| return _value.value; | ||
| } | ||
| } | ||
| if (valueIsRef) | ||
| return toggle; | ||
| else | ||
| return [_value, toggle]; | ||
| } | ||
| function watchArray(source, cb, options) { | ||
| let oldList = (options == null ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : toValue$1(source)]; | ||
| return watch(source, (newList, _, onCleanup) => { | ||
| const oldListRemains = Array.from({ length: oldList.length }); | ||
| const added = []; | ||
| for (const obj of newList) { | ||
| let found = false; | ||
| for (let i = 0; i < oldList.length; i++) { | ||
| if (!oldListRemains[i] && obj === oldList[i]) { | ||
| oldListRemains[i] = true; | ||
| found = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!found) | ||
| added.push(obj); | ||
| } | ||
| const removed = oldList.filter((_2, i) => !oldListRemains[i]); | ||
| cb(newList, oldList, added, removed, onCleanup); | ||
| oldList = [...newList]; | ||
| }, options); | ||
| } | ||
| function watchAtMost(source, cb, options) { | ||
| const { | ||
| count, | ||
| ...watchOptions | ||
| } = options; | ||
| const current = shallowRef(0); | ||
| const stop = watchWithFilter( | ||
| source, | ||
| (...args) => { | ||
| current.value += 1; | ||
| if (current.value >= toValue$1(count)) | ||
| nextTick(() => stop()); | ||
| cb(...args); | ||
| }, | ||
| watchOptions | ||
| ); | ||
| return { count: current, stop }; | ||
| } | ||
| function watchDebounced(source, cb, options = {}) { | ||
| const { | ||
| debounce = 0, | ||
| maxWait = void 0, | ||
| ...watchOptions | ||
| } = options; | ||
| return watchWithFilter( | ||
| source, | ||
| cb, | ||
| { | ||
| ...watchOptions, | ||
| eventFilter: debounceFilter(debounce, { maxWait }) | ||
| } | ||
| ); | ||
| } | ||
| function watchDeep(source, cb, options) { | ||
| return watch( | ||
| source, | ||
| cb, | ||
| { | ||
| ...options, | ||
| deep: true | ||
| } | ||
| ); | ||
| } | ||
| function watchIgnorable(source, cb, options = {}) { | ||
| const { | ||
| eventFilter = bypassFilter, | ||
| ...watchOptions | ||
| } = options; | ||
| const filteredCb = createFilterWrapper( | ||
| eventFilter, | ||
| cb | ||
| ); | ||
| let ignoreUpdates; | ||
| let ignorePrevAsyncUpdates; | ||
| let stop; | ||
| if (watchOptions.flush === "sync") { | ||
| let ignore = false; | ||
| ignorePrevAsyncUpdates = () => { | ||
| }; | ||
| ignoreUpdates = (updater) => { | ||
| ignore = true; | ||
| updater(); | ||
| ignore = false; | ||
| }; | ||
| stop = watch( | ||
| source, | ||
| (...args) => { | ||
| if (!ignore) | ||
| filteredCb(...args); | ||
| }, | ||
| watchOptions | ||
| ); | ||
| } else { | ||
| const disposables = []; | ||
| let ignoreCounter = 0; | ||
| let syncCounter = 0; | ||
| ignorePrevAsyncUpdates = () => { | ||
| ignoreCounter = syncCounter; | ||
| }; | ||
| disposables.push( | ||
| watch( | ||
| source, | ||
| () => { | ||
| syncCounter++; | ||
| }, | ||
| { ...watchOptions, flush: "sync" } | ||
| ) | ||
| ); | ||
| ignoreUpdates = (updater) => { | ||
| const syncCounterPrev = syncCounter; | ||
| updater(); | ||
| ignoreCounter += syncCounter - syncCounterPrev; | ||
| }; | ||
| disposables.push( | ||
| watch( | ||
| source, | ||
| (...args) => { | ||
| const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter; | ||
| ignoreCounter = 0; | ||
| syncCounter = 0; | ||
| if (ignore) | ||
| return; | ||
| filteredCb(...args); | ||
| }, | ||
| watchOptions | ||
| ) | ||
| ); | ||
| stop = () => { | ||
| disposables.forEach((fn) => fn()); | ||
| }; | ||
| } | ||
| return { stop, ignoreUpdates, ignorePrevAsyncUpdates }; | ||
| } | ||
| function watchImmediate(source, cb, options) { | ||
| return watch( | ||
| source, | ||
| cb, | ||
| { | ||
| ...options, | ||
| immediate: true | ||
| } | ||
| ); | ||
| } | ||
| function watchOnce(source, cb, options) { | ||
| return watch( | ||
| source, | ||
| cb, | ||
| { | ||
| ...options, | ||
| once: true | ||
| } | ||
| ); | ||
| } | ||
| function watchThrottled(source, cb, options = {}) { | ||
| const { | ||
| throttle = 0, | ||
| trailing = true, | ||
| leading = true, | ||
| ...watchOptions | ||
| } = options; | ||
| return watchWithFilter( | ||
| source, | ||
| cb, | ||
| { | ||
| ...watchOptions, | ||
| eventFilter: throttleFilter(throttle, trailing, leading) | ||
| } | ||
| ); | ||
| } | ||
| function watchTriggerable(source, cb, options = {}) { | ||
| let cleanupFn; | ||
| function onEffect() { | ||
| if (!cleanupFn) | ||
| return; | ||
| const fn = cleanupFn; | ||
| cleanupFn = void 0; | ||
| fn(); | ||
| } | ||
| function onCleanup(callback) { | ||
| cleanupFn = callback; | ||
| } | ||
| const _cb = (value, oldValue) => { | ||
| onEffect(); | ||
| return cb(value, oldValue, onCleanup); | ||
| }; | ||
| const res = watchIgnorable(source, _cb, options); | ||
| const { ignoreUpdates } = res; | ||
| const trigger = () => { | ||
| let res2; | ||
| ignoreUpdates(() => { | ||
| res2 = _cb(getWatchSources(source), getOldValue(source)); | ||
| }); | ||
| return res2; | ||
| }; | ||
| return { | ||
| ...res, | ||
| trigger | ||
| }; | ||
| } | ||
| function getWatchSources(sources) { | ||
| if (isReactive(sources)) | ||
| return sources; | ||
| if (Array.isArray(sources)) | ||
| return sources.map((item) => toValue$1(item)); | ||
| return toValue$1(sources); | ||
| } | ||
| function getOldValue(source) { | ||
| return Array.isArray(source) ? source.map(() => void 0) : void 0; | ||
| } | ||
| function whenever(source, cb, options) { | ||
| const stop = watch( | ||
| source, | ||
| (v, ov, onInvalidate) => { | ||
| if (v) { | ||
| if (options == null ? void 0 : options.once) | ||
| nextTick(() => stop()); | ||
| cb(v, ov, onInvalidate); | ||
| } | ||
| }, | ||
| { | ||
| ...options, | ||
| once: false | ||
| } | ||
| ); | ||
| return stop; | ||
| } | ||
| export { assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createRef, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toArray, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
211801
17.19%5507
64.88%15
200%1
Infinity%