index.iife.js 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687
  1. (function (exports, vue) {
  2. 'use strict';
  3. function computedEager(fn, options) {
  4. var _a;
  5. const result = vue.shallowRef();
  6. vue.watchEffect(() => {
  7. result.value = fn();
  8. }, {
  9. ...options,
  10. flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
  11. });
  12. return vue.readonly(result);
  13. }
  14. function computedWithControl(source, fn) {
  15. let v = void 0;
  16. let track;
  17. let trigger;
  18. const dirty = vue.ref(true);
  19. const update = () => {
  20. dirty.value = true;
  21. trigger();
  22. };
  23. vue.watch(source, update, { flush: "sync" });
  24. const get = typeof fn === "function" ? fn : fn.get;
  25. const set = typeof fn === "function" ? void 0 : fn.set;
  26. const result = vue.customRef((_track, _trigger) => {
  27. track = _track;
  28. trigger = _trigger;
  29. return {
  30. get() {
  31. if (dirty.value) {
  32. v = get(v);
  33. dirty.value = false;
  34. }
  35. track();
  36. return v;
  37. },
  38. set(v2) {
  39. set == null ? void 0 : set(v2);
  40. }
  41. };
  42. });
  43. if (Object.isExtensible(result))
  44. result.trigger = update;
  45. return result;
  46. }
  47. function tryOnScopeDispose(fn) {
  48. if (vue.getCurrentScope()) {
  49. vue.onScopeDispose(fn);
  50. return true;
  51. }
  52. return false;
  53. }
  54. function createEventHook() {
  55. const fns = /* @__PURE__ */ new Set();
  56. const off = (fn) => {
  57. fns.delete(fn);
  58. };
  59. const on = (fn) => {
  60. fns.add(fn);
  61. const offFn = () => off(fn);
  62. tryOnScopeDispose(offFn);
  63. return {
  64. off: offFn
  65. };
  66. };
  67. const trigger = (...args) => {
  68. return Promise.all(Array.from(fns).map((fn) => fn(...args)));
  69. };
  70. return {
  71. on,
  72. off,
  73. trigger
  74. };
  75. }
  76. function createGlobalState(stateFactory) {
  77. let initialized = false;
  78. let state;
  79. const scope = vue.effectScope(true);
  80. return (...args) => {
  81. if (!initialized) {
  82. state = scope.run(() => stateFactory(...args));
  83. initialized = true;
  84. }
  85. return state;
  86. };
  87. }
  88. const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
  89. const injectLocal = (...args) => {
  90. var _a;
  91. const key = args[0];
  92. const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
  93. if (instance == null)
  94. throw new Error("injectLocal must be called in setup");
  95. if (localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
  96. return localProvidedStateMap.get(instance)[key];
  97. return vue.inject(...args);
  98. };
  99. const provideLocal = (key, value) => {
  100. var _a;
  101. const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
  102. if (instance == null)
  103. throw new Error("provideLocal must be called in setup");
  104. if (!localProvidedStateMap.has(instance))
  105. localProvidedStateMap.set(instance, /* @__PURE__ */ Object.create(null));
  106. const localProvidedState = localProvidedStateMap.get(instance);
  107. localProvidedState[key] = value;
  108. vue.provide(key, value);
  109. };
  110. function createInjectionState(composable, options) {
  111. const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
  112. const defaultValue = options == null ? void 0 : options.defaultValue;
  113. const useProvidingState = (...args) => {
  114. const state = composable(...args);
  115. provideLocal(key, state);
  116. return state;
  117. };
  118. const useInjectedState = () => injectLocal(key, defaultValue);
  119. return [useProvidingState, useInjectedState];
  120. }
  121. function createSharedComposable(composable) {
  122. let subscribers = 0;
  123. let state;
  124. let scope;
  125. const dispose = () => {
  126. subscribers -= 1;
  127. if (scope && subscribers <= 0) {
  128. scope.stop();
  129. state = void 0;
  130. scope = void 0;
  131. }
  132. };
  133. return (...args) => {
  134. subscribers += 1;
  135. if (!scope) {
  136. scope = vue.effectScope(true);
  137. state = scope.run(() => composable(...args));
  138. }
  139. tryOnScopeDispose(dispose);
  140. return state;
  141. };
  142. }
  143. function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
  144. for (const [key, value] of Object.entries(extend)) {
  145. if (key === "value")
  146. continue;
  147. if (vue.isRef(value) && unwrap) {
  148. Object.defineProperty(ref, key, {
  149. get() {
  150. return value.value;
  151. },
  152. set(v) {
  153. value.value = v;
  154. },
  155. enumerable
  156. });
  157. } else {
  158. Object.defineProperty(ref, key, { value, enumerable });
  159. }
  160. }
  161. return ref;
  162. }
  163. function get(obj, key) {
  164. if (key == null)
  165. return vue.unref(obj);
  166. return vue.unref(obj)[key];
  167. }
  168. function isDefined(v) {
  169. return vue.unref(v) != null;
  170. }
  171. function makeDestructurable(obj, arr) {
  172. if (typeof Symbol !== "undefined") {
  173. const clone = { ...obj };
  174. Object.defineProperty(clone, Symbol.iterator, {
  175. enumerable: false,
  176. value() {
  177. let index = 0;
  178. return {
  179. next: () => ({
  180. value: arr[index++],
  181. done: index > arr.length
  182. })
  183. };
  184. }
  185. });
  186. return clone;
  187. } else {
  188. return Object.assign([...arr], obj);
  189. }
  190. }
  191. function toValue(r) {
  192. return typeof r === "function" ? r() : vue.unref(r);
  193. }
  194. const resolveUnref = toValue;
  195. function reactify(fn, options) {
  196. const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vue.unref : toValue;
  197. return function(...args) {
  198. return vue.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
  199. };
  200. }
  201. function reactifyObject(obj, optionsOrKeys = {}) {
  202. let keys = [];
  203. let options;
  204. if (Array.isArray(optionsOrKeys)) {
  205. keys = optionsOrKeys;
  206. } else {
  207. options = optionsOrKeys;
  208. const { includeOwnProperties = true } = optionsOrKeys;
  209. keys.push(...Object.keys(obj));
  210. if (includeOwnProperties)
  211. keys.push(...Object.getOwnPropertyNames(obj));
  212. }
  213. return Object.fromEntries(
  214. keys.map((key) => {
  215. const value = obj[key];
  216. return [
  217. key,
  218. typeof value === "function" ? reactify(value.bind(obj), options) : value
  219. ];
  220. })
  221. );
  222. }
  223. function toReactive(objectRef) {
  224. if (!vue.isRef(objectRef))
  225. return vue.reactive(objectRef);
  226. const proxy = new Proxy({}, {
  227. get(_, p, receiver) {
  228. return vue.unref(Reflect.get(objectRef.value, p, receiver));
  229. },
  230. set(_, p, value) {
  231. if (vue.isRef(objectRef.value[p]) && !vue.isRef(value))
  232. objectRef.value[p].value = value;
  233. else
  234. objectRef.value[p] = value;
  235. return true;
  236. },
  237. deleteProperty(_, p) {
  238. return Reflect.deleteProperty(objectRef.value, p);
  239. },
  240. has(_, p) {
  241. return Reflect.has(objectRef.value, p);
  242. },
  243. ownKeys() {
  244. return Object.keys(objectRef.value);
  245. },
  246. getOwnPropertyDescriptor() {
  247. return {
  248. enumerable: true,
  249. configurable: true
  250. };
  251. }
  252. });
  253. return vue.reactive(proxy);
  254. }
  255. function reactiveComputed(fn) {
  256. return toReactive(vue.computed(fn));
  257. }
  258. function reactiveOmit(obj, ...keys) {
  259. const flatKeys = keys.flat();
  260. const predicate = flatKeys[0];
  261. return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vue.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
  262. }
  263. const isClient = typeof window !== "undefined" && typeof document !== "undefined";
  264. const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
  265. const isDef = (val) => typeof val !== "undefined";
  266. const notNullish = (val) => val != null;
  267. const assert = (condition, ...infos) => {
  268. if (!condition)
  269. console.warn(...infos);
  270. };
  271. const toString = Object.prototype.toString;
  272. const isObject = (val) => toString.call(val) === "[object Object]";
  273. const now = () => Date.now();
  274. const timestamp = () => +Date.now();
  275. const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
  276. const noop = () => {
  277. };
  278. const rand = (min, max) => {
  279. min = Math.ceil(min);
  280. max = Math.floor(max);
  281. return Math.floor(Math.random() * (max - min + 1)) + min;
  282. };
  283. const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
  284. const isIOS = /* @__PURE__ */ getIsIOS();
  285. function getIsIOS() {
  286. var _a, _b;
  287. 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));
  288. }
  289. function createFilterWrapper(filter, fn) {
  290. function wrapper(...args) {
  291. return new Promise((resolve, reject) => {
  292. Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
  293. });
  294. }
  295. return wrapper;
  296. }
  297. const bypassFilter = (invoke) => {
  298. return invoke();
  299. };
  300. function debounceFilter(ms, options = {}) {
  301. let timer;
  302. let maxTimer;
  303. let lastRejector = noop;
  304. const _clearTimeout = (timer2) => {
  305. clearTimeout(timer2);
  306. lastRejector();
  307. lastRejector = noop;
  308. };
  309. const filter = (invoke) => {
  310. const duration = toValue(ms);
  311. const maxDuration = toValue(options.maxWait);
  312. if (timer)
  313. _clearTimeout(timer);
  314. if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
  315. if (maxTimer) {
  316. _clearTimeout(maxTimer);
  317. maxTimer = null;
  318. }
  319. return Promise.resolve(invoke());
  320. }
  321. return new Promise((resolve, reject) => {
  322. lastRejector = options.rejectOnCancel ? reject : resolve;
  323. if (maxDuration && !maxTimer) {
  324. maxTimer = setTimeout(() => {
  325. if (timer)
  326. _clearTimeout(timer);
  327. maxTimer = null;
  328. resolve(invoke());
  329. }, maxDuration);
  330. }
  331. timer = setTimeout(() => {
  332. if (maxTimer)
  333. _clearTimeout(maxTimer);
  334. maxTimer = null;
  335. resolve(invoke());
  336. }, duration);
  337. });
  338. };
  339. return filter;
  340. }
  341. function throttleFilter(...args) {
  342. let lastExec = 0;
  343. let timer;
  344. let isLeading = true;
  345. let lastRejector = noop;
  346. let lastValue;
  347. let ms;
  348. let trailing;
  349. let leading;
  350. let rejectOnCancel;
  351. if (!vue.isRef(args[0]) && typeof args[0] === "object")
  352. ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
  353. else
  354. [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
  355. const clear = () => {
  356. if (timer) {
  357. clearTimeout(timer);
  358. timer = void 0;
  359. lastRejector();
  360. lastRejector = noop;
  361. }
  362. };
  363. const filter = (_invoke) => {
  364. const duration = toValue(ms);
  365. const elapsed = Date.now() - lastExec;
  366. const invoke = () => {
  367. return lastValue = _invoke();
  368. };
  369. clear();
  370. if (duration <= 0) {
  371. lastExec = Date.now();
  372. return invoke();
  373. }
  374. if (elapsed > duration && (leading || !isLeading)) {
  375. lastExec = Date.now();
  376. invoke();
  377. } else if (trailing) {
  378. lastValue = new Promise((resolve, reject) => {
  379. lastRejector = rejectOnCancel ? reject : resolve;
  380. timer = setTimeout(() => {
  381. lastExec = Date.now();
  382. isLeading = true;
  383. resolve(invoke());
  384. clear();
  385. }, Math.max(0, duration - elapsed));
  386. });
  387. }
  388. if (!leading && !timer)
  389. timer = setTimeout(() => isLeading = true, duration);
  390. isLeading = false;
  391. return lastValue;
  392. };
  393. return filter;
  394. }
  395. function pausableFilter(extendFilter = bypassFilter) {
  396. const isActive = vue.ref(true);
  397. function pause() {
  398. isActive.value = false;
  399. }
  400. function resume() {
  401. isActive.value = true;
  402. }
  403. const eventFilter = (...args) => {
  404. if (isActive.value)
  405. extendFilter(...args);
  406. };
  407. return { isActive: vue.readonly(isActive), pause, resume, eventFilter };
  408. }
  409. function cacheStringFunction(fn) {
  410. const cache = /* @__PURE__ */ Object.create(null);
  411. return (str) => {
  412. const hit = cache[str];
  413. return hit || (cache[str] = fn(str));
  414. };
  415. }
  416. const hyphenateRE = /\B([A-Z])/g;
  417. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
  418. const camelizeRE = /-(\w)/g;
  419. const camelize = cacheStringFunction((str) => {
  420. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  421. });
  422. function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
  423. return new Promise((resolve, reject) => {
  424. if (throwOnTimeout)
  425. setTimeout(() => reject(reason), ms);
  426. else
  427. setTimeout(resolve, ms);
  428. });
  429. }
  430. function identity(arg) {
  431. return arg;
  432. }
  433. function createSingletonPromise(fn) {
  434. let _promise;
  435. function wrapper() {
  436. if (!_promise)
  437. _promise = fn();
  438. return _promise;
  439. }
  440. wrapper.reset = async () => {
  441. const _prev = _promise;
  442. _promise = void 0;
  443. if (_prev)
  444. await _prev;
  445. };
  446. return wrapper;
  447. }
  448. function invoke(fn) {
  449. return fn();
  450. }
  451. function containsProp(obj, ...props) {
  452. return props.some((k) => k in obj);
  453. }
  454. function increaseWithUnit(target, delta) {
  455. var _a;
  456. if (typeof target === "number")
  457. return target + delta;
  458. const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || "";
  459. const unit = target.slice(value.length);
  460. const result = Number.parseFloat(value) + delta;
  461. if (Number.isNaN(result))
  462. return target;
  463. return result + unit;
  464. }
  465. function objectPick(obj, keys, omitUndefined = false) {
  466. return keys.reduce((n, k) => {
  467. if (k in obj) {
  468. if (!omitUndefined || obj[k] !== void 0)
  469. n[k] = obj[k];
  470. }
  471. return n;
  472. }, {});
  473. }
  474. function objectOmit(obj, keys, omitUndefined = false) {
  475. return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
  476. return (!omitUndefined || value !== void 0) && !keys.includes(key);
  477. }));
  478. }
  479. function objectEntries(obj) {
  480. return Object.entries(obj);
  481. }
  482. function getLifeCycleTarget(target) {
  483. return target || vue.getCurrentInstance();
  484. }
  485. function toRef(...args) {
  486. if (args.length !== 1)
  487. return vue.toRef(...args);
  488. const r = args[0];
  489. return typeof r === "function" ? vue.readonly(vue.customRef(() => ({ get: r, set: noop }))) : vue.ref(r);
  490. }
  491. const resolveRef = toRef;
  492. function reactivePick(obj, ...keys) {
  493. const flatKeys = keys.flat();
  494. const predicate = flatKeys[0];
  495. return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
  496. }
  497. function refAutoReset(defaultValue, afterMs = 1e4) {
  498. return vue.customRef((track, trigger) => {
  499. let value = toValue(defaultValue);
  500. let timer;
  501. const resetAfter = () => setTimeout(() => {
  502. value = toValue(defaultValue);
  503. trigger();
  504. }, toValue(afterMs));
  505. tryOnScopeDispose(() => {
  506. clearTimeout(timer);
  507. });
  508. return {
  509. get() {
  510. track();
  511. return value;
  512. },
  513. set(newValue) {
  514. value = newValue;
  515. trigger();
  516. clearTimeout(timer);
  517. timer = resetAfter();
  518. }
  519. };
  520. });
  521. }
  522. function useDebounceFn(fn, ms = 200, options = {}) {
  523. return createFilterWrapper(
  524. debounceFilter(ms, options),
  525. fn
  526. );
  527. }
  528. function refDebounced(value, ms = 200, options = {}) {
  529. const debounced = vue.ref(value.value);
  530. const updater = useDebounceFn(() => {
  531. debounced.value = value.value;
  532. }, ms, options);
  533. vue.watch(value, () => updater());
  534. return debounced;
  535. }
  536. function refDefault(source, defaultValue) {
  537. return vue.computed({
  538. get() {
  539. var _a;
  540. return (_a = source.value) != null ? _a : defaultValue;
  541. },
  542. set(value) {
  543. source.value = value;
  544. }
  545. });
  546. }
  547. function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
  548. return createFilterWrapper(
  549. throttleFilter(ms, trailing, leading, rejectOnCancel),
  550. fn
  551. );
  552. }
  553. function refThrottled(value, delay = 200, trailing = true, leading = true) {
  554. if (delay <= 0)
  555. return value;
  556. const throttled = vue.ref(value.value);
  557. const updater = useThrottleFn(() => {
  558. throttled.value = value.value;
  559. }, delay, trailing, leading);
  560. vue.watch(value, () => updater());
  561. return throttled;
  562. }
  563. function refWithControl(initial, options = {}) {
  564. let source = initial;
  565. let track;
  566. let trigger;
  567. const ref = vue.customRef((_track, _trigger) => {
  568. track = _track;
  569. trigger = _trigger;
  570. return {
  571. get() {
  572. return get();
  573. },
  574. set(v) {
  575. set(v);
  576. }
  577. };
  578. });
  579. function get(tracking = true) {
  580. if (tracking)
  581. track();
  582. return source;
  583. }
  584. function set(value, triggering = true) {
  585. var _a, _b;
  586. if (value === source)
  587. return;
  588. const old = source;
  589. if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
  590. return;
  591. source = value;
  592. (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
  593. if (triggering)
  594. trigger();
  595. }
  596. const untrackedGet = () => get(false);
  597. const silentSet = (v) => set(v, false);
  598. const peek = () => get(false);
  599. const lay = (v) => set(v, false);
  600. return extendRef(
  601. ref,
  602. {
  603. get,
  604. set,
  605. untrackedGet,
  606. silentSet,
  607. peek,
  608. lay
  609. },
  610. { enumerable: true }
  611. );
  612. }
  613. const controlledRef = refWithControl;
  614. function set(...args) {
  615. if (args.length === 2) {
  616. const [ref, value] = args;
  617. ref.value = value;
  618. }
  619. if (args.length === 3) {
  620. const [target, key, value] = args;
  621. target[key] = value;
  622. }
  623. }
  624. function watchWithFilter(source, cb, options = {}) {
  625. const {
  626. eventFilter = bypassFilter,
  627. ...watchOptions
  628. } = options;
  629. return vue.watch(
  630. source,
  631. createFilterWrapper(
  632. eventFilter,
  633. cb
  634. ),
  635. watchOptions
  636. );
  637. }
  638. function watchPausable(source, cb, options = {}) {
  639. const {
  640. eventFilter: filter,
  641. ...watchOptions
  642. } = options;
  643. const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
  644. const stop = watchWithFilter(
  645. source,
  646. cb,
  647. {
  648. ...watchOptions,
  649. eventFilter
  650. }
  651. );
  652. return { stop, pause, resume, isActive };
  653. }
  654. function syncRef(left, right, ...[options]) {
  655. const {
  656. flush = "sync",
  657. deep = false,
  658. immediate = true,
  659. direction = "both",
  660. transform = {}
  661. } = options || {};
  662. const watchers = [];
  663. const transformLTR = "ltr" in transform && transform.ltr || ((v) => v);
  664. const transformRTL = "rtl" in transform && transform.rtl || ((v) => v);
  665. if (direction === "both" || direction === "ltr") {
  666. watchers.push(watchPausable(
  667. left,
  668. (newValue) => {
  669. watchers.forEach((w) => w.pause());
  670. right.value = transformLTR(newValue);
  671. watchers.forEach((w) => w.resume());
  672. },
  673. { flush, deep, immediate }
  674. ));
  675. }
  676. if (direction === "both" || direction === "rtl") {
  677. watchers.push(watchPausable(
  678. right,
  679. (newValue) => {
  680. watchers.forEach((w) => w.pause());
  681. left.value = transformRTL(newValue);
  682. watchers.forEach((w) => w.resume());
  683. },
  684. { flush, deep, immediate }
  685. ));
  686. }
  687. const stop = () => {
  688. watchers.forEach((w) => w.stop());
  689. };
  690. return stop;
  691. }
  692. function syncRefs(source, targets, options = {}) {
  693. const {
  694. flush = "sync",
  695. deep = false,
  696. immediate = true
  697. } = options;
  698. if (!Array.isArray(targets))
  699. targets = [targets];
  700. return vue.watch(
  701. source,
  702. (newValue) => targets.forEach((target) => target.value = newValue),
  703. { flush, deep, immediate }
  704. );
  705. }
  706. function toRefs(objectRef, options = {}) {
  707. if (!vue.isRef(objectRef))
  708. return vue.toRefs(objectRef);
  709. const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
  710. for (const key in objectRef.value) {
  711. result[key] = vue.customRef(() => ({
  712. get() {
  713. return objectRef.value[key];
  714. },
  715. set(v) {
  716. var _a;
  717. const replaceRef = (_a = toValue(options.replaceRef)) != null ? _a : true;
  718. if (replaceRef) {
  719. if (Array.isArray(objectRef.value)) {
  720. const copy = [...objectRef.value];
  721. copy[key] = v;
  722. objectRef.value = copy;
  723. } else {
  724. const newObject = { ...objectRef.value, [key]: v };
  725. Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
  726. objectRef.value = newObject;
  727. }
  728. } else {
  729. objectRef.value[key] = v;
  730. }
  731. }
  732. }));
  733. }
  734. return result;
  735. }
  736. function tryOnBeforeMount(fn, sync = true, target) {
  737. const instance = getLifeCycleTarget(target);
  738. if (instance)
  739. vue.onBeforeMount(fn, target);
  740. else if (sync)
  741. fn();
  742. else
  743. vue.nextTick(fn);
  744. }
  745. function tryOnBeforeUnmount(fn, target) {
  746. const instance = getLifeCycleTarget(target);
  747. if (instance)
  748. vue.onBeforeUnmount(fn, target);
  749. }
  750. function tryOnMounted(fn, sync = true, target) {
  751. const instance = getLifeCycleTarget();
  752. if (instance)
  753. vue.onMounted(fn, target);
  754. else if (sync)
  755. fn();
  756. else
  757. vue.nextTick(fn);
  758. }
  759. function tryOnUnmounted(fn, target) {
  760. const instance = getLifeCycleTarget(target);
  761. if (instance)
  762. vue.onUnmounted(fn, target);
  763. }
  764. function createUntil(r, isNot = false) {
  765. function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
  766. let stop = null;
  767. const watcher = new Promise((resolve) => {
  768. stop = vue.watch(
  769. r,
  770. (v) => {
  771. if (condition(v) !== isNot) {
  772. if (stop)
  773. stop();
  774. else
  775. vue.nextTick(() => stop == null ? void 0 : stop());
  776. resolve(v);
  777. }
  778. },
  779. {
  780. flush,
  781. deep,
  782. immediate: true
  783. }
  784. );
  785. });
  786. const promises = [watcher];
  787. if (timeout != null) {
  788. promises.push(
  789. promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
  790. );
  791. }
  792. return Promise.race(promises);
  793. }
  794. function toBe(value, options) {
  795. if (!vue.isRef(value))
  796. return toMatch((v) => v === value, options);
  797. const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
  798. let stop = null;
  799. const watcher = new Promise((resolve) => {
  800. stop = vue.watch(
  801. [r, value],
  802. ([v1, v2]) => {
  803. if (isNot !== (v1 === v2)) {
  804. if (stop)
  805. stop();
  806. else
  807. vue.nextTick(() => stop == null ? void 0 : stop());
  808. resolve(v1);
  809. }
  810. },
  811. {
  812. flush,
  813. deep,
  814. immediate: true
  815. }
  816. );
  817. });
  818. const promises = [watcher];
  819. if (timeout != null) {
  820. promises.push(
  821. promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
  822. stop == null ? void 0 : stop();
  823. return toValue(r);
  824. })
  825. );
  826. }
  827. return Promise.race(promises);
  828. }
  829. function toBeTruthy(options) {
  830. return toMatch((v) => Boolean(v), options);
  831. }
  832. function toBeNull(options) {
  833. return toBe(null, options);
  834. }
  835. function toBeUndefined(options) {
  836. return toBe(void 0, options);
  837. }
  838. function toBeNaN(options) {
  839. return toMatch(Number.isNaN, options);
  840. }
  841. function toContains(value, options) {
  842. return toMatch((v) => {
  843. const array = Array.from(v);
  844. return array.includes(value) || array.includes(toValue(value));
  845. }, options);
  846. }
  847. function changed(options) {
  848. return changedTimes(1, options);
  849. }
  850. function changedTimes(n = 1, options) {
  851. let count = -1;
  852. return toMatch(() => {
  853. count += 1;
  854. return count >= n;
  855. }, options);
  856. }
  857. if (Array.isArray(toValue(r))) {
  858. const instance = {
  859. toMatch,
  860. toContains,
  861. changed,
  862. changedTimes,
  863. get not() {
  864. return createUntil(r, !isNot);
  865. }
  866. };
  867. return instance;
  868. } else {
  869. const instance = {
  870. toMatch,
  871. toBe,
  872. toBeTruthy,
  873. toBeNull,
  874. toBeNaN,
  875. toBeUndefined,
  876. changed,
  877. changedTimes,
  878. get not() {
  879. return createUntil(r, !isNot);
  880. }
  881. };
  882. return instance;
  883. }
  884. }
  885. function until(r) {
  886. return createUntil(r);
  887. }
  888. function defaultComparator(value, othVal) {
  889. return value === othVal;
  890. }
  891. function useArrayDifference(...args) {
  892. var _a;
  893. const list = args[0];
  894. const values = args[1];
  895. let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
  896. if (typeof compareFn === "string") {
  897. const key = compareFn;
  898. compareFn = (value, othVal) => value[key] === othVal[key];
  899. }
  900. return vue.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
  901. }
  902. function useArrayEvery(list, fn) {
  903. return vue.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
  904. }
  905. function useArrayFilter(list, fn) {
  906. return vue.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
  907. }
  908. function useArrayFind(list, fn) {
  909. return vue.computed(() => toValue(
  910. toValue(list).find((element, index, array) => fn(toValue(element), index, array))
  911. ));
  912. }
  913. function useArrayFindIndex(list, fn) {
  914. return vue.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
  915. }
  916. function findLast(arr, cb) {
  917. let index = arr.length;
  918. while (index-- > 0) {
  919. if (cb(arr[index], index, arr))
  920. return arr[index];
  921. }
  922. return void 0;
  923. }
  924. function useArrayFindLast(list, fn) {
  925. return vue.computed(() => toValue(
  926. !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))
  927. ));
  928. }
  929. function isArrayIncludesOptions(obj) {
  930. return isObject(obj) && containsProp(obj, "formIndex", "comparator");
  931. }
  932. function useArrayIncludes(...args) {
  933. var _a;
  934. const list = args[0];
  935. const value = args[1];
  936. let comparator = args[2];
  937. let formIndex = 0;
  938. if (isArrayIncludesOptions(comparator)) {
  939. formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
  940. comparator = comparator.comparator;
  941. }
  942. if (typeof comparator === "string") {
  943. const key = comparator;
  944. comparator = (element, value2) => element[key] === toValue(value2);
  945. }
  946. comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
  947. return vue.computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
  948. toValue(element),
  949. toValue(value),
  950. index,
  951. toValue(array)
  952. )));
  953. }
  954. function useArrayJoin(list, separator) {
  955. return vue.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
  956. }
  957. function useArrayMap(list, fn) {
  958. return vue.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
  959. }
  960. function useArrayReduce(list, reducer, ...args) {
  961. const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
  962. return vue.computed(() => {
  963. const resolved = toValue(list);
  964. return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback);
  965. });
  966. }
  967. function useArraySome(list, fn) {
  968. return vue.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
  969. }
  970. function uniq(array) {
  971. return Array.from(new Set(array));
  972. }
  973. function uniqueElementsBy(array, fn) {
  974. return array.reduce((acc, v) => {
  975. if (!acc.some((x) => fn(v, x, array)))
  976. acc.push(v);
  977. return acc;
  978. }, []);
  979. }
  980. function useArrayUnique(list, compareFn) {
  981. return vue.computed(() => {
  982. const resolvedList = toValue(list).map((element) => toValue(element));
  983. return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
  984. });
  985. }
  986. function useCounter(initialValue = 0, options = {}) {
  987. let _initialValue = vue.unref(initialValue);
  988. const count = vue.ref(initialValue);
  989. const {
  990. max = Number.POSITIVE_INFINITY,
  991. min = Number.NEGATIVE_INFINITY
  992. } = options;
  993. const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
  994. const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
  995. const get = () => count.value;
  996. const set = (val) => count.value = Math.max(min, Math.min(max, val));
  997. const reset = (val = _initialValue) => {
  998. _initialValue = val;
  999. return set(val);
  1000. };
  1001. return { count, inc, dec, get, set, reset };
  1002. }
  1003. const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
  1004. 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}|SSS/g;
  1005. function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
  1006. let m = hours < 12 ? "AM" : "PM";
  1007. if (hasPeriod)
  1008. m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
  1009. return isLowercase ? m.toLowerCase() : m;
  1010. }
  1011. function formatOrdinal(num) {
  1012. const suffixes = ["th", "st", "nd", "rd"];
  1013. const v = num % 100;
  1014. return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
  1015. }
  1016. function formatDate(date, formatStr, options = {}) {
  1017. var _a;
  1018. const years = date.getFullYear();
  1019. const month = date.getMonth();
  1020. const days = date.getDate();
  1021. const hours = date.getHours();
  1022. const minutes = date.getMinutes();
  1023. const seconds = date.getSeconds();
  1024. const milliseconds = date.getMilliseconds();
  1025. const day = date.getDay();
  1026. const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
  1027. const matches = {
  1028. Yo: () => formatOrdinal(years),
  1029. YY: () => String(years).slice(-2),
  1030. YYYY: () => years,
  1031. M: () => month + 1,
  1032. Mo: () => formatOrdinal(month + 1),
  1033. MM: () => `${month + 1}`.padStart(2, "0"),
  1034. MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }),
  1035. MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }),
  1036. D: () => String(days),
  1037. Do: () => formatOrdinal(days),
  1038. DD: () => `${days}`.padStart(2, "0"),
  1039. H: () => String(hours),
  1040. Ho: () => formatOrdinal(hours),
  1041. HH: () => `${hours}`.padStart(2, "0"),
  1042. h: () => `${hours % 12 || 12}`.padStart(1, "0"),
  1043. ho: () => formatOrdinal(hours % 12 || 12),
  1044. hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
  1045. m: () => String(minutes),
  1046. mo: () => formatOrdinal(minutes),
  1047. mm: () => `${minutes}`.padStart(2, "0"),
  1048. s: () => String(seconds),
  1049. so: () => formatOrdinal(seconds),
  1050. ss: () => `${seconds}`.padStart(2, "0"),
  1051. SSS: () => `${milliseconds}`.padStart(3, "0"),
  1052. d: () => day,
  1053. dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }),
  1054. ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }),
  1055. dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }),
  1056. A: () => meridiem(hours, minutes),
  1057. AA: () => meridiem(hours, minutes, false, true),
  1058. a: () => meridiem(hours, minutes, true),
  1059. aa: () => meridiem(hours, minutes, true, true)
  1060. };
  1061. return formatStr.replace(REGEX_FORMAT, (match, $1) => {
  1062. var _a2, _b;
  1063. return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match;
  1064. });
  1065. }
  1066. function normalizeDate(date) {
  1067. if (date === null)
  1068. return new Date(Number.NaN);
  1069. if (date === void 0)
  1070. return /* @__PURE__ */ new Date();
  1071. if (date instanceof Date)
  1072. return new Date(date);
  1073. if (typeof date === "string" && !/Z$/i.test(date)) {
  1074. const d = date.match(REGEX_PARSE);
  1075. if (d) {
  1076. const m = d[2] - 1 || 0;
  1077. const ms = (d[7] || "0").substring(0, 3);
  1078. return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
  1079. }
  1080. }
  1081. return new Date(date);
  1082. }
  1083. function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
  1084. return vue.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
  1085. }
  1086. function useIntervalFn(cb, interval = 1e3, options = {}) {
  1087. const {
  1088. immediate = true,
  1089. immediateCallback = false
  1090. } = options;
  1091. let timer = null;
  1092. const isActive = vue.ref(false);
  1093. function clean() {
  1094. if (timer) {
  1095. clearInterval(timer);
  1096. timer = null;
  1097. }
  1098. }
  1099. function pause() {
  1100. isActive.value = false;
  1101. clean();
  1102. }
  1103. function resume() {
  1104. const intervalValue = toValue(interval);
  1105. if (intervalValue <= 0)
  1106. return;
  1107. isActive.value = true;
  1108. if (immediateCallback)
  1109. cb();
  1110. clean();
  1111. if (isActive.value)
  1112. timer = setInterval(cb, intervalValue);
  1113. }
  1114. if (immediate && isClient)
  1115. resume();
  1116. if (vue.isRef(interval) || typeof interval === "function") {
  1117. const stopWatch = vue.watch(interval, () => {
  1118. if (isActive.value && isClient)
  1119. resume();
  1120. });
  1121. tryOnScopeDispose(stopWatch);
  1122. }
  1123. tryOnScopeDispose(pause);
  1124. return {
  1125. isActive,
  1126. pause,
  1127. resume
  1128. };
  1129. }
  1130. function useInterval(interval = 1e3, options = {}) {
  1131. const {
  1132. controls: exposeControls = false,
  1133. immediate = true,
  1134. callback
  1135. } = options;
  1136. const counter = vue.ref(0);
  1137. const update = () => counter.value += 1;
  1138. const reset = () => {
  1139. counter.value = 0;
  1140. };
  1141. const controls = useIntervalFn(
  1142. callback ? () => {
  1143. update();
  1144. callback(counter.value);
  1145. } : update,
  1146. interval,
  1147. { immediate }
  1148. );
  1149. if (exposeControls) {
  1150. return {
  1151. counter,
  1152. reset,
  1153. ...controls
  1154. };
  1155. } else {
  1156. return counter;
  1157. }
  1158. }
  1159. function useLastChanged(source, options = {}) {
  1160. var _a;
  1161. const ms = vue.ref((_a = options.initialValue) != null ? _a : null);
  1162. vue.watch(
  1163. source,
  1164. () => ms.value = timestamp(),
  1165. options
  1166. );
  1167. return ms;
  1168. }
  1169. function useTimeoutFn(cb, interval, options = {}) {
  1170. const {
  1171. immediate = true
  1172. } = options;
  1173. const isPending = vue.ref(false);
  1174. let timer = null;
  1175. function clear() {
  1176. if (timer) {
  1177. clearTimeout(timer);
  1178. timer = null;
  1179. }
  1180. }
  1181. function stop() {
  1182. isPending.value = false;
  1183. clear();
  1184. }
  1185. function start(...args) {
  1186. clear();
  1187. isPending.value = true;
  1188. timer = setTimeout(() => {
  1189. isPending.value = false;
  1190. timer = null;
  1191. cb(...args);
  1192. }, toValue(interval));
  1193. }
  1194. if (immediate) {
  1195. isPending.value = true;
  1196. if (isClient)
  1197. start();
  1198. }
  1199. tryOnScopeDispose(stop);
  1200. return {
  1201. isPending: vue.readonly(isPending),
  1202. start,
  1203. stop
  1204. };
  1205. }
  1206. function useTimeout(interval = 1e3, options = {}) {
  1207. const {
  1208. controls: exposeControls = false,
  1209. callback
  1210. } = options;
  1211. const controls = useTimeoutFn(
  1212. callback != null ? callback : noop,
  1213. interval,
  1214. options
  1215. );
  1216. const ready = vue.computed(() => !controls.isPending.value);
  1217. if (exposeControls) {
  1218. return {
  1219. ready,
  1220. ...controls
  1221. };
  1222. } else {
  1223. return ready;
  1224. }
  1225. }
  1226. function useToNumber(value, options = {}) {
  1227. const {
  1228. method = "parseFloat",
  1229. radix,
  1230. nanToZero
  1231. } = options;
  1232. return vue.computed(() => {
  1233. let resolved = toValue(value);
  1234. if (typeof resolved === "string")
  1235. resolved = Number[method](resolved, radix);
  1236. if (nanToZero && Number.isNaN(resolved))
  1237. resolved = 0;
  1238. return resolved;
  1239. });
  1240. }
  1241. function useToString(value) {
  1242. return vue.computed(() => `${toValue(value)}`);
  1243. }
  1244. function useToggle(initialValue = false, options = {}) {
  1245. const {
  1246. truthyValue = true,
  1247. falsyValue = false
  1248. } = options;
  1249. const valueIsRef = vue.isRef(initialValue);
  1250. const _value = vue.ref(initialValue);
  1251. function toggle(value) {
  1252. if (arguments.length) {
  1253. _value.value = value;
  1254. return _value.value;
  1255. } else {
  1256. const truthy = toValue(truthyValue);
  1257. _value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
  1258. return _value.value;
  1259. }
  1260. }
  1261. if (valueIsRef)
  1262. return toggle;
  1263. else
  1264. return [_value, toggle];
  1265. }
  1266. function watchArray(source, cb, options) {
  1267. let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)];
  1268. return vue.watch(source, (newList, _, onCleanup) => {
  1269. const oldListRemains = Array.from({ length: oldList.length });
  1270. const added = [];
  1271. for (const obj of newList) {
  1272. let found = false;
  1273. for (let i = 0; i < oldList.length; i++) {
  1274. if (!oldListRemains[i] && obj === oldList[i]) {
  1275. oldListRemains[i] = true;
  1276. found = true;
  1277. break;
  1278. }
  1279. }
  1280. if (!found)
  1281. added.push(obj);
  1282. }
  1283. const removed = oldList.filter((_2, i) => !oldListRemains[i]);
  1284. cb(newList, oldList, added, removed, onCleanup);
  1285. oldList = [...newList];
  1286. }, options);
  1287. }
  1288. function watchAtMost(source, cb, options) {
  1289. const {
  1290. count,
  1291. ...watchOptions
  1292. } = options;
  1293. const current = vue.ref(0);
  1294. const stop = watchWithFilter(
  1295. source,
  1296. (...args) => {
  1297. current.value += 1;
  1298. if (current.value >= toValue(count))
  1299. vue.nextTick(() => stop());
  1300. cb(...args);
  1301. },
  1302. watchOptions
  1303. );
  1304. return { count: current, stop };
  1305. }
  1306. function watchDebounced(source, cb, options = {}) {
  1307. const {
  1308. debounce = 0,
  1309. maxWait = void 0,
  1310. ...watchOptions
  1311. } = options;
  1312. return watchWithFilter(
  1313. source,
  1314. cb,
  1315. {
  1316. ...watchOptions,
  1317. eventFilter: debounceFilter(debounce, { maxWait })
  1318. }
  1319. );
  1320. }
  1321. function watchDeep(source, cb, options) {
  1322. return vue.watch(
  1323. source,
  1324. cb,
  1325. {
  1326. ...options,
  1327. deep: true
  1328. }
  1329. );
  1330. }
  1331. function watchIgnorable(source, cb, options = {}) {
  1332. const {
  1333. eventFilter = bypassFilter,
  1334. ...watchOptions
  1335. } = options;
  1336. const filteredCb = createFilterWrapper(
  1337. eventFilter,
  1338. cb
  1339. );
  1340. let ignoreUpdates;
  1341. let ignorePrevAsyncUpdates;
  1342. let stop;
  1343. if (watchOptions.flush === "sync") {
  1344. const ignore = vue.ref(false);
  1345. ignorePrevAsyncUpdates = () => {
  1346. };
  1347. ignoreUpdates = (updater) => {
  1348. ignore.value = true;
  1349. updater();
  1350. ignore.value = false;
  1351. };
  1352. stop = vue.watch(
  1353. source,
  1354. (...args) => {
  1355. if (!ignore.value)
  1356. filteredCb(...args);
  1357. },
  1358. watchOptions
  1359. );
  1360. } else {
  1361. const disposables = [];
  1362. const ignoreCounter = vue.ref(0);
  1363. const syncCounter = vue.ref(0);
  1364. ignorePrevAsyncUpdates = () => {
  1365. ignoreCounter.value = syncCounter.value;
  1366. };
  1367. disposables.push(
  1368. vue.watch(
  1369. source,
  1370. () => {
  1371. syncCounter.value++;
  1372. },
  1373. { ...watchOptions, flush: "sync" }
  1374. )
  1375. );
  1376. ignoreUpdates = (updater) => {
  1377. const syncCounterPrev = syncCounter.value;
  1378. updater();
  1379. ignoreCounter.value += syncCounter.value - syncCounterPrev;
  1380. };
  1381. disposables.push(
  1382. vue.watch(
  1383. source,
  1384. (...args) => {
  1385. const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
  1386. ignoreCounter.value = 0;
  1387. syncCounter.value = 0;
  1388. if (ignore)
  1389. return;
  1390. filteredCb(...args);
  1391. },
  1392. watchOptions
  1393. )
  1394. );
  1395. stop = () => {
  1396. disposables.forEach((fn) => fn());
  1397. };
  1398. }
  1399. return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
  1400. }
  1401. function watchImmediate(source, cb, options) {
  1402. return vue.watch(
  1403. source,
  1404. cb,
  1405. {
  1406. ...options,
  1407. immediate: true
  1408. }
  1409. );
  1410. }
  1411. function watchOnce(source, cb, options) {
  1412. const stop = vue.watch(source, (...args) => {
  1413. vue.nextTick(() => stop());
  1414. return cb(...args);
  1415. }, options);
  1416. return stop;
  1417. }
  1418. function watchThrottled(source, cb, options = {}) {
  1419. const {
  1420. throttle = 0,
  1421. trailing = true,
  1422. leading = true,
  1423. ...watchOptions
  1424. } = options;
  1425. return watchWithFilter(
  1426. source,
  1427. cb,
  1428. {
  1429. ...watchOptions,
  1430. eventFilter: throttleFilter(throttle, trailing, leading)
  1431. }
  1432. );
  1433. }
  1434. function watchTriggerable(source, cb, options = {}) {
  1435. let cleanupFn;
  1436. function onEffect() {
  1437. if (!cleanupFn)
  1438. return;
  1439. const fn = cleanupFn;
  1440. cleanupFn = void 0;
  1441. fn();
  1442. }
  1443. function onCleanup(callback) {
  1444. cleanupFn = callback;
  1445. }
  1446. const _cb = (value, oldValue) => {
  1447. onEffect();
  1448. return cb(value, oldValue, onCleanup);
  1449. };
  1450. const res = watchIgnorable(source, _cb, options);
  1451. const { ignoreUpdates } = res;
  1452. const trigger = () => {
  1453. let res2;
  1454. ignoreUpdates(() => {
  1455. res2 = _cb(getWatchSources(source), getOldValue(source));
  1456. });
  1457. return res2;
  1458. };
  1459. return {
  1460. ...res,
  1461. trigger
  1462. };
  1463. }
  1464. function getWatchSources(sources) {
  1465. if (vue.isReactive(sources))
  1466. return sources;
  1467. if (Array.isArray(sources))
  1468. return sources.map((item) => toValue(item));
  1469. return toValue(sources);
  1470. }
  1471. function getOldValue(source) {
  1472. return Array.isArray(source) ? source.map(() => void 0) : void 0;
  1473. }
  1474. function whenever(source, cb, options) {
  1475. const stop = vue.watch(
  1476. source,
  1477. (v, ov, onInvalidate) => {
  1478. if (v) {
  1479. if (options == null ? void 0 : options.once)
  1480. vue.nextTick(() => stop());
  1481. cb(v, ov, onInvalidate);
  1482. }
  1483. },
  1484. {
  1485. ...options,
  1486. once: false
  1487. }
  1488. );
  1489. return stop;
  1490. }
  1491. exports.assert = assert;
  1492. exports.autoResetRef = refAutoReset;
  1493. exports.bypassFilter = bypassFilter;
  1494. exports.camelize = camelize;
  1495. exports.clamp = clamp;
  1496. exports.computedEager = computedEager;
  1497. exports.computedWithControl = computedWithControl;
  1498. exports.containsProp = containsProp;
  1499. exports.controlledComputed = computedWithControl;
  1500. exports.controlledRef = controlledRef;
  1501. exports.createEventHook = createEventHook;
  1502. exports.createFilterWrapper = createFilterWrapper;
  1503. exports.createGlobalState = createGlobalState;
  1504. exports.createInjectionState = createInjectionState;
  1505. exports.createReactiveFn = reactify;
  1506. exports.createSharedComposable = createSharedComposable;
  1507. exports.createSingletonPromise = createSingletonPromise;
  1508. exports.debounceFilter = debounceFilter;
  1509. exports.debouncedRef = refDebounced;
  1510. exports.debouncedWatch = watchDebounced;
  1511. exports.eagerComputed = computedEager;
  1512. exports.extendRef = extendRef;
  1513. exports.formatDate = formatDate;
  1514. exports.get = get;
  1515. exports.getLifeCycleTarget = getLifeCycleTarget;
  1516. exports.hasOwn = hasOwn;
  1517. exports.hyphenate = hyphenate;
  1518. exports.identity = identity;
  1519. exports.ignorableWatch = watchIgnorable;
  1520. exports.increaseWithUnit = increaseWithUnit;
  1521. exports.injectLocal = injectLocal;
  1522. exports.invoke = invoke;
  1523. exports.isClient = isClient;
  1524. exports.isDef = isDef;
  1525. exports.isDefined = isDefined;
  1526. exports.isIOS = isIOS;
  1527. exports.isObject = isObject;
  1528. exports.isWorker = isWorker;
  1529. exports.makeDestructurable = makeDestructurable;
  1530. exports.noop = noop;
  1531. exports.normalizeDate = normalizeDate;
  1532. exports.notNullish = notNullish;
  1533. exports.now = now;
  1534. exports.objectEntries = objectEntries;
  1535. exports.objectOmit = objectOmit;
  1536. exports.objectPick = objectPick;
  1537. exports.pausableFilter = pausableFilter;
  1538. exports.pausableWatch = watchPausable;
  1539. exports.promiseTimeout = promiseTimeout;
  1540. exports.provideLocal = provideLocal;
  1541. exports.rand = rand;
  1542. exports.reactify = reactify;
  1543. exports.reactifyObject = reactifyObject;
  1544. exports.reactiveComputed = reactiveComputed;
  1545. exports.reactiveOmit = reactiveOmit;
  1546. exports.reactivePick = reactivePick;
  1547. exports.refAutoReset = refAutoReset;
  1548. exports.refDebounced = refDebounced;
  1549. exports.refDefault = refDefault;
  1550. exports.refThrottled = refThrottled;
  1551. exports.refWithControl = refWithControl;
  1552. exports.resolveRef = resolveRef;
  1553. exports.resolveUnref = resolveUnref;
  1554. exports.set = set;
  1555. exports.syncRef = syncRef;
  1556. exports.syncRefs = syncRefs;
  1557. exports.throttleFilter = throttleFilter;
  1558. exports.throttledRef = refThrottled;
  1559. exports.throttledWatch = watchThrottled;
  1560. exports.timestamp = timestamp;
  1561. exports.toReactive = toReactive;
  1562. exports.toRef = toRef;
  1563. exports.toRefs = toRefs;
  1564. exports.toValue = toValue;
  1565. exports.tryOnBeforeMount = tryOnBeforeMount;
  1566. exports.tryOnBeforeUnmount = tryOnBeforeUnmount;
  1567. exports.tryOnMounted = tryOnMounted;
  1568. exports.tryOnScopeDispose = tryOnScopeDispose;
  1569. exports.tryOnUnmounted = tryOnUnmounted;
  1570. exports.until = until;
  1571. exports.useArrayDifference = useArrayDifference;
  1572. exports.useArrayEvery = useArrayEvery;
  1573. exports.useArrayFilter = useArrayFilter;
  1574. exports.useArrayFind = useArrayFind;
  1575. exports.useArrayFindIndex = useArrayFindIndex;
  1576. exports.useArrayFindLast = useArrayFindLast;
  1577. exports.useArrayIncludes = useArrayIncludes;
  1578. exports.useArrayJoin = useArrayJoin;
  1579. exports.useArrayMap = useArrayMap;
  1580. exports.useArrayReduce = useArrayReduce;
  1581. exports.useArraySome = useArraySome;
  1582. exports.useArrayUnique = useArrayUnique;
  1583. exports.useCounter = useCounter;
  1584. exports.useDateFormat = useDateFormat;
  1585. exports.useDebounce = refDebounced;
  1586. exports.useDebounceFn = useDebounceFn;
  1587. exports.useInterval = useInterval;
  1588. exports.useIntervalFn = useIntervalFn;
  1589. exports.useLastChanged = useLastChanged;
  1590. exports.useThrottle = refThrottled;
  1591. exports.useThrottleFn = useThrottleFn;
  1592. exports.useTimeout = useTimeout;
  1593. exports.useTimeoutFn = useTimeoutFn;
  1594. exports.useToNumber = useToNumber;
  1595. exports.useToString = useToString;
  1596. exports.useToggle = useToggle;
  1597. exports.watchArray = watchArray;
  1598. exports.watchAtMost = watchAtMost;
  1599. exports.watchDebounced = watchDebounced;
  1600. exports.watchDeep = watchDeep;
  1601. exports.watchIgnorable = watchIgnorable;
  1602. exports.watchImmediate = watchImmediate;
  1603. exports.watchOnce = watchOnce;
  1604. exports.watchPausable = watchPausable;
  1605. exports.watchThrottled = watchThrottled;
  1606. exports.watchTriggerable = watchTriggerable;
  1607. exports.watchWithFilter = watchWithFilter;
  1608. exports.whenever = whenever;
  1609. })(this.VueUse = this.VueUse || {}, Vue);