123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647 |
- import {
- computed2 as computed,
- customRef,
- effectScope,
- getCurrentInstance,
- getCurrentScope,
- inject,
- isReactive,
- isRef,
- nextTick,
- onBeforeMount,
- onBeforeUnmount,
- onMounted,
- onScopeDispose,
- onUnmounted,
- provide,
- reactive,
- readonly,
- ref,
- shallowRef,
- toRef,
- toRefs,
- unref,
- version,
- watch,
- watchEffect
- } from "./chunk-RDKJTCL2.js";
- // node_modules/@vueuse/shared/node_modules/vue-demi/lib/index.mjs
- var isVue2 = false;
- var isVue3 = true;
- function set(target, key, val) {
- if (Array.isArray(target)) {
- target.length = Math.max(target.length, key);
- target.splice(key, 1, val);
- return val;
- }
- target[key] = val;
- return val;
- }
- // node_modules/@vueuse/shared/index.mjs
- 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) {
- let v = void 0;
- let track;
- let trigger;
- const dirty = ref(true);
- const update = () => {
- dirty.value = true;
- trigger();
- };
- watch(source, update, { flush: "sync" });
- const get2 = typeof fn === "function" ? fn : fn.get;
- const set3 = typeof fn === "function" ? void 0 : fn.set;
- const result = customRef((_track, _trigger) => {
- track = _track;
- trigger = _trigger;
- return {
- get() {
- if (dirty.value) {
- v = get2();
- dirty.value = false;
- }
- track();
- return v;
- },
- set(v2) {
- set3 == null ? void 0 : set3(v2);
- }
- };
- });
- if (Object.isExtensible(result))
- result.trigger = update;
- return result;
- }
- function tryOnScopeDispose(fn) {
- if (getCurrentScope()) {
- onScopeDispose(fn);
- return true;
- }
- return false;
- }
- function createEventHook() {
- const fns = /* @__PURE__ */ new Set();
- const off = (fn) => {
- fns.delete(fn);
- };
- 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
- };
- }
- 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;
- };
- }
- var localProvidedStateMap = /* @__PURE__ */ new WeakMap();
- var 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;
- provide(key, value);
- };
- var injectLocal = (...args) => {
- var _a;
- const key = args[0];
- const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
- if (instance == null)
- throw new Error("injectLocal must be called in setup");
- if (localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
- return localProvidedStateMap.get(instance)[key];
- return inject(...args);
- };
- function createInjectionState(composable, options) {
- const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
- const useProvidingState = (...args) => {
- const state = composable(...args);
- provideLocal(key, state);
- return state;
- };
- const useInjectedState = () => injectLocal(key);
- return [useProvidingState, useInjectedState];
- }
- 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 (!state) {
- scope = effectScope(true);
- state = scope.run(() => composable(...args));
- }
- tryOnScopeDispose(dispose);
- return state;
- };
- }
- function extendRef(ref2, extend, { enumerable = false, unwrap = true } = {}) {
- if (!isVue3 && !version.startsWith("2.7.")) {
- if (true)
- throw new Error("[VueUse] extendRef only works in Vue 2.7 or above.");
- return;
- }
- for (const [key, value] of Object.entries(extend)) {
- if (key === "value")
- continue;
- if (isRef(value) && unwrap) {
- Object.defineProperty(ref2, key, {
- get() {
- return value.value;
- },
- set(v) {
- value.value = v;
- },
- enumerable
- });
- } else {
- Object.defineProperty(ref2, key, { value, enumerable });
- }
- }
- return ref2;
- }
- function get(obj, key) {
- if (key == null)
- return unref(obj);
- return unref(obj)[key];
- }
- function isDefined(v) {
- return unref(v) != null;
- }
- 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);
- }
- }
- function toValue(r) {
- return typeof r === "function" ? r() : unref(r);
- }
- var resolveUnref = toValue;
- function reactify(fn, options) {
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue;
- return function(...args) {
- return computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
- };
- }
- 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(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
- }
- var isClient = typeof window !== "undefined" && typeof document !== "undefined";
- var isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
- var isDef = (val) => typeof val !== "undefined";
- var notNullish = (val) => val != null;
- var assert = (condition, ...infos) => {
- if (!condition)
- console.warn(...infos);
- };
- var toString = Object.prototype.toString;
- var isObject = (val) => toString.call(val) === "[object Object]";
- var now = () => Date.now();
- var timestamp = () => +Date.now();
- var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
- var noop = () => {
- };
- var rand = (min, max) => {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min + 1)) + min;
- };
- var hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
- var isIOS = 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 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;
- }
- var bypassFilter = (invoke2) => {
- return invoke2();
- };
- function debounceFilter(ms, options = {}) {
- let timer;
- let maxTimer;
- let lastRejector = noop;
- const _clearTimeout = (timer2) => {
- clearTimeout(timer2);
- lastRejector();
- lastRejector = noop;
- };
- const filter = (invoke2) => {
- const duration = toValue(ms);
- const maxDuration = toValue(options.maxWait);
- if (timer)
- _clearTimeout(timer);
- if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
- if (maxTimer) {
- _clearTimeout(maxTimer);
- maxTimer = null;
- }
- return Promise.resolve(invoke2());
- }
- return new Promise((resolve, reject) => {
- lastRejector = options.rejectOnCancel ? reject : resolve;
- if (maxDuration && !maxTimer) {
- maxTimer = setTimeout(() => {
- if (timer)
- _clearTimeout(timer);
- maxTimer = null;
- resolve(invoke2());
- }, maxDuration);
- }
- timer = setTimeout(() => {
- if (maxTimer)
- _clearTimeout(maxTimer);
- maxTimer = null;
- resolve(invoke2());
- }, 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(ms);
- const elapsed = Date.now() - lastExec;
- const invoke2 = () => {
- return lastValue = _invoke();
- };
- clear();
- if (duration <= 0) {
- lastExec = Date.now();
- return invoke2();
- }
- if (elapsed > duration && (leading || !isLeading)) {
- lastExec = Date.now();
- invoke2();
- } else if (trailing) {
- lastValue = new Promise((resolve, reject) => {
- lastRejector = rejectOnCancel ? reject : resolve;
- timer = setTimeout(() => {
- lastExec = Date.now();
- isLeading = true;
- resolve(invoke2());
- clear();
- }, Math.max(0, duration - elapsed));
- });
- }
- if (!leading && !timer)
- timer = setTimeout(() => isLeading = true, duration);
- isLeading = false;
- return lastValue;
- };
- return filter;
- }
- function pausableFilter(extendFilter = bypassFilter) {
- const isActive = ref(true);
- 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 };
- }
- var directiveHooks = {
- mounted: isVue3 ? "mounted" : "inserted",
- updated: isVue3 ? "updated" : "componentUpdated",
- unmounted: isVue3 ? "unmounted" : "unbind"
- };
- function cacheStringFunction(fn) {
- const cache = /* @__PURE__ */ Object.create(null);
- return (str) => {
- const hit = cache[str];
- return hit || (cache[str] = fn(str));
- };
- }
- var hyphenateRE = /\B([A-Z])/g;
- var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
- var camelizeRE = /-(\w)/g;
- var camelize = cacheStringFunction((str) => {
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
- });
- 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(/^-?[0-9]+\.?[0-9]*/)) == 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 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 getLifeCycleTarget(target) {
- return target || getCurrentInstance();
- }
- function toRef2(...args) {
- if (args.length !== 1)
- return toRef(...args);
- const r = args[0];
- return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop }))) : ref(r);
- }
- var resolveRef = toRef2;
- function reactivePick(obj, ...keys) {
- const flatKeys = keys.flat();
- const predicate = flatKeys[0];
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef2(obj, k)])));
- }
- function refAutoReset(defaultValue, afterMs = 1e4) {
- return customRef((track, trigger) => {
- let value = toValue(defaultValue);
- let timer;
- const resetAfter = () => setTimeout(() => {
- value = toValue(defaultValue);
- trigger();
- }, toValue(afterMs));
- tryOnScopeDispose(() => {
- clearTimeout(timer);
- });
- return {
- get() {
- track();
- return value;
- },
- set(newValue) {
- value = newValue;
- trigger();
- clearTimeout(timer);
- timer = resetAfter();
- }
- };
- });
- }
- function useDebounceFn(fn, ms = 200, options = {}) {
- return createFilterWrapper(
- debounceFilter(ms, options),
- fn
- );
- }
- function refDebounced(value, ms = 200, options = {}) {
- const debounced = ref(value.value);
- const updater = useDebounceFn(() => {
- debounced.value = value.value;
- }, ms, options);
- watch(value, () => updater());
- return debounced;
- }
- function refDefault(source, defaultValue) {
- return computed({
- get() {
- var _a;
- return (_a = source.value) != null ? _a : defaultValue;
- },
- set(value) {
- source.value = value;
- }
- });
- }
- 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(value.value);
- const updater = useThrottleFn(() => {
- throttled.value = value.value;
- }, delay, trailing, leading);
- watch(value, () => updater());
- return throttled;
- }
- function refWithControl(initial, options = {}) {
- let source = initial;
- let track;
- let trigger;
- const ref2 = customRef((_track, _trigger) => {
- track = _track;
- trigger = _trigger;
- return {
- get() {
- return get2();
- },
- set(v) {
- set3(v);
- }
- };
- });
- function get2(tracking = true) {
- if (tracking)
- track();
- return source;
- }
- function set3(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 = () => get2(false);
- const silentSet = (v) => set3(v, false);
- const peek = () => get2(false);
- const lay = (v) => set3(v, false);
- return extendRef(
- ref2,
- {
- get: get2,
- set: set3,
- untrackedGet,
- silentSet,
- peek,
- lay
- },
- { enumerable: true }
- );
- }
- var controlledRef = refWithControl;
- function set2(...args) {
- if (args.length === 2) {
- const [ref2, value] = args;
- ref2.value = value;
- }
- if (args.length === 3) {
- if (isVue2) {
- set(...args);
- } else {
- 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,
- ...watchOptions
- } = options;
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
- 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;
- if (!Array.isArray(targets))
- targets = [targets];
- return watch(
- source,
- (newValue) => targets.forEach((target) => target.value = newValue),
- { flush, deep, immediate }
- );
- }
- function toRefs2(objectRef, options = {}) {
- if (!isRef(objectRef))
- return toRefs(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(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;
- }
- 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();
- 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) {
- stop == null ? void 0 : stop();
- resolve(v);
- }
- },
- {
- flush,
- deep,
- immediate: true
- }
- );
- });
- const promises = [watcher];
- if (timeout != null) {
- promises.push(
- promiseTimeout(timeout, throwOnTimeout).then(() => toValue(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)) {
- stop == null ? void 0 : stop();
- resolve(v1);
- }
- },
- {
- flush,
- deep,
- immediate: true
- }
- );
- });
- const promises = [watcher];
- if (timeout != null) {
- promises.push(
- promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
- stop == null ? void 0 : stop();
- return 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(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(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;
- }
- function useArrayDifference(...args) {
- var _a;
- const list = args[0];
- const values = args[1];
- let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
- if (typeof compareFn === "string") {
- const key = compareFn;
- compareFn = (value, othVal) => value[key] === othVal[key];
- }
- return computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
- }
- function useArrayEvery(list, fn) {
- return computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
- }
- function useArrayFilter(list, fn) {
- return computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
- }
- function useArrayFind(list, fn) {
- return computed(() => toValue(
- toValue(list).find((element, index, array) => fn(toValue(element), index, array))
- ));
- }
- function useArrayFindIndex(list, fn) {
- return computed(() => toValue(list).findIndex((element, index, array) => fn(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;
- }
- function useArrayFindLast(list, fn) {
- return computed(() => toValue(
- !Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
- ));
- }
- function isArrayIncludesOptions(obj) {
- return isObject(obj) && containsProp(obj, "formIndex", "comparator");
- }
- 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(value2);
- }
- comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
- return computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
- toValue(element),
- toValue(value),
- index,
- toValue(array)
- )));
- }
- function useArrayJoin(list, separator) {
- return computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
- }
- function useArrayMap(list, fn) {
- return computed(() => toValue(list).map((i) => toValue(i)).map(fn));
- }
- function useArrayReduce(list, reducer, ...args) {
- const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
- return computed(() => {
- const resolved = toValue(list);
- return args.length ? resolved.reduce(reduceCallback, toValue(args[0])) : resolved.reduce(reduceCallback);
- });
- }
- function useArraySome(list, fn) {
- return computed(() => toValue(list).some((element, index, array) => fn(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;
- }, []);
- }
- function useArrayUnique(list, compareFn) {
- return computed(() => {
- const resolvedList = toValue(list).map((element) => toValue(element));
- return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
- });
- }
- function useCounter(initialValue = 0, options = {}) {
- let _initialValue = unref(initialValue);
- const count = ref(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 get2 = () => count.value;
- const set3 = (val) => count.value = Math.max(min, Math.min(max, val));
- const reset = (val = _initialValue) => {
- _initialValue = val;
- return set3(val);
- };
- return { count, inc, dec, get: get2, set: set3, reset };
- }
- var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
- var REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|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 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(options.locales, { month: "short" }),
- MMMM: () => date.toLocaleDateString(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(options.locales, { weekday: "narrow" }),
- ddd: () => date.toLocaleDateString(options.locales, { weekday: "short" }),
- dddd: () => date.toLocaleDateString(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)
- };
- 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);
- }
- function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
- return computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
- }
- function useIntervalFn(cb, interval = 1e3, options = {}) {
- const {
- immediate = true,
- immediateCallback = false
- } = options;
- let timer = null;
- const isActive = ref(false);
- function clean() {
- if (timer) {
- clearInterval(timer);
- timer = null;
- }
- }
- function pause() {
- isActive.value = false;
- clean();
- }
- function resume() {
- const intervalValue = toValue(interval);
- if (intervalValue <= 0)
- return;
- isActive.value = true;
- if (immediateCallback)
- cb();
- clean();
- 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,
- pause,
- resume
- };
- }
- function useInterval(interval = 1e3, options = {}) {
- const {
- controls: exposeControls = false,
- immediate = true,
- callback
- } = options;
- const counter = ref(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,
- reset,
- ...controls
- };
- } else {
- return counter;
- }
- }
- function useLastChanged(source, options = {}) {
- var _a;
- const ms = ref((_a = options.initialValue) != null ? _a : null);
- watch(
- source,
- () => ms.value = timestamp(),
- options
- );
- return ms;
- }
- function useTimeoutFn(cb, interval, options = {}) {
- const {
- immediate = true
- } = options;
- const isPending = ref(false);
- let timer = null;
- function clear() {
- if (timer) {
- clearTimeout(timer);
- timer = null;
- }
- }
- function stop() {
- isPending.value = false;
- clear();
- }
- function start(...args) {
- clear();
- isPending.value = true;
- timer = setTimeout(() => {
- isPending.value = false;
- timer = null;
- cb(...args);
- }, toValue(interval));
- }
- if (immediate) {
- isPending.value = true;
- if (isClient)
- start();
- }
- tryOnScopeDispose(stop);
- return {
- isPending: readonly(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;
- }
- }
- function useToNumber(value, options = {}) {
- const {
- method = "parseFloat",
- radix,
- nanToZero
- } = options;
- return computed(() => {
- let resolved = toValue(value);
- if (typeof resolved === "string")
- resolved = Number[method](resolved, radix);
- if (nanToZero && Number.isNaN(resolved))
- resolved = 0;
- return resolved;
- });
- }
- function useToString(value) {
- return computed(() => `${toValue(value)}`);
- }
- function useToggle(initialValue = false, options = {}) {
- const {
- truthyValue = true,
- falsyValue = false
- } = options;
- const valueIsRef = isRef(initialValue);
- const _value = ref(initialValue);
- function toggle(value) {
- if (arguments.length) {
- _value.value = value;
- return _value.value;
- } else {
- const truthy = toValue(truthyValue);
- _value.value = _value.value === truthy ? 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) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(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 = ref(0);
- const stop = watchWithFilter(
- source,
- (...args) => {
- current.value += 1;
- if (current.value >= toValue(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") {
- const ignore = ref(false);
- ignorePrevAsyncUpdates = () => {
- };
- ignoreUpdates = (updater) => {
- ignore.value = true;
- updater();
- ignore.value = false;
- };
- stop = watch(
- source,
- (...args) => {
- if (!ignore.value)
- filteredCb(...args);
- },
- watchOptions
- );
- } else {
- const disposables = [];
- const ignoreCounter = ref(0);
- const syncCounter = ref(0);
- ignorePrevAsyncUpdates = () => {
- ignoreCounter.value = syncCounter.value;
- };
- disposables.push(
- watch(
- source,
- () => {
- syncCounter.value++;
- },
- { ...watchOptions, flush: "sync" }
- )
- );
- ignoreUpdates = (updater) => {
- const syncCounterPrev = syncCounter.value;
- updater();
- ignoreCounter.value += syncCounter.value - syncCounterPrev;
- };
- disposables.push(
- watch(
- source,
- (...args) => {
- const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
- ignoreCounter.value = 0;
- syncCounter.value = 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) {
- const stop = watch(source, (...args) => {
- nextTick(() => stop());
- return cb(...args);
- }, options);
- return stop;
- }
- 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(item));
- return toValue(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 {
- computedEager,
- computedWithControl,
- tryOnScopeDispose,
- createEventHook,
- createGlobalState,
- provideLocal,
- injectLocal,
- createInjectionState,
- createSharedComposable,
- extendRef,
- get,
- isDefined,
- makeDestructurable,
- toValue,
- resolveUnref,
- reactify,
- reactifyObject,
- toReactive,
- reactiveComputed,
- reactiveOmit,
- isClient,
- isWorker,
- isDef,
- notNullish,
- assert,
- isObject,
- now,
- timestamp,
- clamp,
- noop,
- rand,
- hasOwn,
- isIOS,
- createFilterWrapper,
- bypassFilter,
- debounceFilter,
- throttleFilter,
- pausableFilter,
- directiveHooks,
- hyphenate,
- camelize,
- promiseTimeout,
- identity,
- createSingletonPromise,
- invoke,
- containsProp,
- increaseWithUnit,
- objectPick,
- objectOmit,
- objectEntries,
- getLifeCycleTarget,
- toRef2 as toRef,
- resolveRef,
- reactivePick,
- refAutoReset,
- useDebounceFn,
- refDebounced,
- refDefault,
- useThrottleFn,
- refThrottled,
- refWithControl,
- controlledRef,
- set2 as set,
- watchWithFilter,
- watchPausable,
- syncRef,
- syncRefs,
- toRefs2 as toRefs,
- tryOnBeforeMount,
- tryOnBeforeUnmount,
- tryOnMounted,
- tryOnUnmounted,
- until,
- useArrayDifference,
- useArrayEvery,
- useArrayFilter,
- useArrayFind,
- useArrayFindIndex,
- useArrayFindLast,
- useArrayIncludes,
- useArrayJoin,
- useArrayMap,
- useArrayReduce,
- useArraySome,
- useArrayUnique,
- useCounter,
- formatDate,
- normalizeDate,
- useDateFormat,
- useIntervalFn,
- useInterval,
- useLastChanged,
- useTimeoutFn,
- useTimeout,
- useToNumber,
- useToString,
- useToggle,
- watchArray,
- watchAtMost,
- watchDebounced,
- watchDeep,
- watchIgnorable,
- watchImmediate,
- watchOnce,
- watchThrottled,
- watchTriggerable,
- whenever
- };
- //# sourceMappingURL=chunk-6366KF45.js.map
|