UNPKG

73.5 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5/******************************************************************************
6Copyright (c) Microsoft Corporation.
7
8Permission to use, copy, modify, and/or distribute this software for any
9purpose with or without fee is hereby granted.
10
11THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17PERFORMANCE OF THIS SOFTWARE.
18***************************************************************************** */
19/* global Reflect, Promise */
20
21var extendStatics = function(d, b) {
22 extendStatics = Object.setPrototypeOf ||
23 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
25 return extendStatics(d, b);
26};
27
28function __extends(d, b) {
29 if (typeof b !== "function" && b !== null)
30 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
31 extendStatics(d, b);
32 function __() { this.constructor = d; }
33 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34}
35
36var __assign = function() {
37 __assign = Object.assign || function __assign(t) {
38 for (var s, i = 1, n = arguments.length; i < n; i++) {
39 s = arguments[i];
40 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41 }
42 return t;
43 };
44 return __assign.apply(this, arguments);
45};
46
47function __values(o) {
48 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
49 if (m) return m.call(o);
50 if (o && typeof o.length === "number") return {
51 next: function () {
52 if (o && i >= o.length) o = void 0;
53 return { value: o && o[i++], done: !o };
54 }
55 };
56 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
57}
58
59function __read(o, n) {
60 var m = typeof Symbol === "function" && o[Symbol.iterator];
61 if (!m) return o;
62 var i = m.call(o), r, ar = [], e;
63 try {
64 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
65 }
66 catch (error) { e = { error: error }; }
67 finally {
68 try {
69 if (r && !r.done && (m = i["return"])) m.call(i);
70 }
71 finally { if (e) throw e.error; }
72 }
73 return ar;
74}
75
76function __spreadArray(to, from, pack) {
77 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
78 if (ar || !(i in from)) {
79 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
80 ar[i] = from[i];
81 }
82 }
83 return to.concat(ar || Array.prototype.slice.call(from));
84}
85
86/**
87 * Displays a warning message (using console.error) with a stack trace if the
88 * function is called inside of active component.
89 *
90 * @param message warning message to be displayed
91 */
92function warn$1(message) {
93 var _a;
94 warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy);
95}
96
97var activeEffectScope;
98var effectScopeStack = [];
99var EffectScopeImpl = /** @class */ (function () {
100 function EffectScopeImpl(vm) {
101 this.active = true;
102 this.effects = [];
103 this.cleanups = [];
104 this.vm = vm;
105 }
106 EffectScopeImpl.prototype.run = function (fn) {
107 if (this.active) {
108 try {
109 this.on();
110 return fn();
111 }
112 finally {
113 this.off();
114 }
115 }
116 else {
117 warn$1("cannot run an inactive effect scope.");
118 }
119 return;
120 };
121 EffectScopeImpl.prototype.on = function () {
122 if (this.active) {
123 effectScopeStack.push(this);
124 activeEffectScope = this;
125 }
126 };
127 EffectScopeImpl.prototype.off = function () {
128 if (this.active) {
129 effectScopeStack.pop();
130 activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
131 }
132 };
133 EffectScopeImpl.prototype.stop = function () {
134 if (this.active) {
135 this.vm.$destroy();
136 this.effects.forEach(function (e) { return e.stop(); });
137 this.cleanups.forEach(function (cleanup) { return cleanup(); });
138 this.active = false;
139 }
140 };
141 return EffectScopeImpl;
142}());
143var EffectScope = /** @class */ (function (_super) {
144 __extends(EffectScope, _super);
145 function EffectScope(detached) {
146 if (detached === void 0) { detached = false; }
147 var _this = this;
148 var vm = undefined;
149 withCurrentInstanceTrackingDisabled(function () {
150 vm = defineComponentInstance(getVueConstructor());
151 });
152 _this = _super.call(this, vm) || this;
153 if (!detached) {
154 recordEffectScope(_this);
155 }
156 return _this;
157 }
158 return EffectScope;
159}(EffectScopeImpl));
160function recordEffectScope(effect, scope) {
161 var _a;
162 scope = scope || activeEffectScope;
163 if (scope && scope.active) {
164 scope.effects.push(effect);
165 return;
166 }
167 // destroy on parent component unmounted
168 var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
169 vm && vm.$on('hook:destroyed', function () { return effect.stop(); });
170}
171function effectScope(detached) {
172 return new EffectScope(detached);
173}
174function getCurrentScope() {
175 return activeEffectScope;
176}
177function onScopeDispose(fn) {
178 if (activeEffectScope) {
179 activeEffectScope.cleanups.push(fn);
180 }
181 else {
182 warn$1("onScopeDispose() is called when there is no active effect scope" +
183 " to be associated with.");
184 }
185}
186/**
187 * @internal
188 **/
189function getCurrentScopeVM() {
190 var _a, _b;
191 return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy);
192}
193/**
194 * @internal
195 **/
196function bindCurrentScopeToVM(vm) {
197 if (!vm.scope) {
198 var scope_1 = new EffectScopeImpl(vm.proxy);
199 vm.scope = scope_1;
200 vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); });
201 }
202 return vm.scope;
203}
204
205var vueDependency = undefined;
206try {
207 var requiredVue = require('vue');
208 if (requiredVue && isVue(requiredVue)) {
209 vueDependency = requiredVue;
210 }
211 else if (requiredVue &&
212 'default' in requiredVue &&
213 isVue(requiredVue.default)) {
214 vueDependency = requiredVue.default;
215 }
216}
217catch (_a) {
218 // not available
219}
220var vueConstructor = null;
221var currentInstance = null;
222var currentInstanceTracking = true;
223var PluginInstalledFlag = '__composition_api_installed__';
224function isVue(obj) {
225 return obj && isFunction(obj) && obj.name === 'Vue';
226}
227function isVueRegistered(Vue) {
228 // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365
229 return vueConstructor && hasOwn(Vue, PluginInstalledFlag);
230}
231function getVueConstructor() {
232 {
233 assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function.");
234 }
235 return vueConstructor;
236}
237// returns registered vue or `vue` dependency
238function getRegisteredVueOrDefault() {
239 var constructor = vueConstructor || vueDependency;
240 {
241 assert(constructor, "No vue dependency found.");
242 }
243 return constructor;
244}
245function setVueConstructor(Vue) {
246 // @ts-ignore
247 if (vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) {
248 warn('[vue-composition-api] another instance of Vue installed');
249 }
250 vueConstructor = Vue;
251 Object.defineProperty(Vue, PluginInstalledFlag, {
252 configurable: true,
253 writable: true,
254 value: true,
255 });
256}
257/**
258 * For `effectScope` to create instance without populate the current instance
259 * @internal
260 **/
261function withCurrentInstanceTrackingDisabled(fn) {
262 var prev = currentInstanceTracking;
263 currentInstanceTracking = false;
264 try {
265 fn();
266 }
267 finally {
268 currentInstanceTracking = prev;
269 }
270}
271function setCurrentInstance(instance) {
272 if (!currentInstanceTracking)
273 return;
274 var prev = currentInstance;
275 prev === null || prev === void 0 ? void 0 : prev.scope.off();
276 currentInstance = instance;
277 currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on();
278}
279function getCurrentInstance() {
280 return currentInstance;
281}
282var instanceMapCache = new WeakMap();
283function toVue3ComponentInstance(vm) {
284 if (instanceMapCache.has(vm)) {
285 return instanceMapCache.get(vm);
286 }
287 var instance = {
288 proxy: vm,
289 update: vm.$forceUpdate,
290 type: vm.$options,
291 uid: vm._uid,
292 // $emit is defined on prototype and it expected to be bound
293 emit: vm.$emit.bind(vm),
294 parent: null,
295 root: null, // to be immediately set
296 };
297 bindCurrentScopeToVM(instance);
298 // map vm.$props =
299 var instanceProps = [
300 'data',
301 'props',
302 'attrs',
303 'refs',
304 'vnode',
305 'slots',
306 ];
307 instanceProps.forEach(function (prop) {
308 proxy(instance, prop, {
309 get: function () {
310 return vm["$".concat(prop)];
311 },
312 });
313 });
314 proxy(instance, 'isMounted', {
315 get: function () {
316 // @ts-expect-error private api
317 return vm._isMounted;
318 },
319 });
320 proxy(instance, 'isUnmounted', {
321 get: function () {
322 // @ts-expect-error private api
323 return vm._isDestroyed;
324 },
325 });
326 proxy(instance, 'isDeactivated', {
327 get: function () {
328 // @ts-expect-error private api
329 return vm._inactive;
330 },
331 });
332 proxy(instance, 'emitted', {
333 get: function () {
334 // @ts-expect-error private api
335 return vm._events;
336 },
337 });
338 instanceMapCache.set(vm, instance);
339 if (vm.$parent) {
340 instance.parent = toVue3ComponentInstance(vm.$parent);
341 }
342 if (vm.$root) {
343 instance.root = toVue3ComponentInstance(vm.$root);
344 }
345 return instance;
346}
347
348var toString = function (x) { return Object.prototype.toString.call(x); };
349function isNative(Ctor) {
350 return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
351}
352var hasSymbol = typeof Symbol !== 'undefined' &&
353 isNative(Symbol) &&
354 typeof Reflect !== 'undefined' &&
355 isNative(Reflect.ownKeys);
356var noopFn = function (_) { return _; };
357function proxy(target, key, _a) {
358 var get = _a.get, set = _a.set;
359 Object.defineProperty(target, key, {
360 enumerable: true,
361 configurable: true,
362 get: get || noopFn,
363 set: set || noopFn,
364 });
365}
366function def(obj, key, val, enumerable) {
367 Object.defineProperty(obj, key, {
368 value: val,
369 enumerable: !!enumerable,
370 writable: true,
371 configurable: true,
372 });
373}
374function hasOwn(obj, key) {
375 return Object.hasOwnProperty.call(obj, key);
376}
377function assert(condition, msg) {
378 if (!condition) {
379 throw new Error("[vue-composition-api] ".concat(msg));
380 }
381}
382function isPrimitive(value) {
383 return (typeof value === 'string' ||
384 typeof value === 'number' ||
385 // $flow-disable-line
386 typeof value === 'symbol' ||
387 typeof value === 'boolean');
388}
389function isArray(x) {
390 return Array.isArray(x);
391}
392var objectToString = Object.prototype.toString;
393var toTypeString = function (value) {
394 return objectToString.call(value);
395};
396var isMap = function (val) {
397 return toTypeString(val) === '[object Map]';
398};
399var isSet = function (val) {
400 return toTypeString(val) === '[object Set]';
401};
402var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1
403function isValidArrayIndex(val) {
404 var n = parseFloat(String(val));
405 return (n >= 0 &&
406 Math.floor(n) === n &&
407 isFinite(val) &&
408 n <= MAX_VALID_ARRAY_LENGTH);
409}
410function isObject(val) {
411 return val !== null && typeof val === 'object';
412}
413function isPlainObject(x) {
414 return toString(x) === '[object Object]';
415}
416function isFunction(x) {
417 return typeof x === 'function';
418}
419function isUndef(v) {
420 return v === undefined || v === null;
421}
422function warn(msg, vm) {
423 var Vue = getRegisteredVueOrDefault();
424 if (!Vue || !Vue.util)
425 console.warn("[vue-composition-api] ".concat(msg));
426 else
427 Vue.util.warn(msg, vm);
428}
429function logError(err, vm, info) {
430 {
431 warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm);
432 }
433 if (typeof window !== 'undefined' && typeof console !== 'undefined') {
434 console.error(err);
435 }
436 else {
437 throw err;
438 }
439}
440/**
441 * Object.is polyfill
442 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
443 * */
444function isSame(value1, value2) {
445 if (value1 === value2) {
446 return value1 !== 0 || 1 / value1 === 1 / value2;
447 }
448 else {
449 return value1 !== value1 && value2 !== value2;
450 }
451}
452
453function getCurrentInstanceForFn(hook, target) {
454 target = target || getCurrentInstance();
455 if (!target) {
456 warn("".concat(hook, " is called when there is no active component instance to be ") +
457 "associated with. " +
458 "Lifecycle injection APIs can only be used during execution of setup().");
459 }
460 return target;
461}
462function defineComponentInstance(Ctor, options) {
463 if (options === void 0) { options = {}; }
464 var silent = Ctor.config.silent;
465 Ctor.config.silent = true;
466 var vm = new Ctor(options);
467 Ctor.config.silent = silent;
468 return vm;
469}
470function isComponentInstance(obj) {
471 var Vue = getVueConstructor();
472 return Vue && obj instanceof Vue;
473}
474function createSlotProxy(vm, slotName) {
475 return (function () {
476 var args = [];
477 for (var _i = 0; _i < arguments.length; _i++) {
478 args[_i] = arguments[_i];
479 }
480 if (!vm.$scopedSlots[slotName]) {
481 return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm);
482 }
483 return vm.$scopedSlots[slotName].apply(vm, args);
484 });
485}
486function resolveSlots(slots, normalSlots) {
487 var res;
488 if (!slots) {
489 res = {};
490 }
491 else if (slots._normalized) {
492 // fast path 1: child component re-render only, parent did not change
493 return slots._normalized;
494 }
495 else {
496 res = {};
497 for (var key in slots) {
498 if (slots[key] && key[0] !== '$') {
499 res[key] = true;
500 }
501 }
502 }
503 // expose normal slots on scopedSlots
504 for (var key in normalSlots) {
505 if (!(key in res)) {
506 res[key] = true;
507 }
508 }
509 return res;
510}
511var vueInternalClasses;
512var getVueInternalClasses = function () {
513 if (!vueInternalClasses) {
514 var vm = defineComponentInstance(getVueConstructor(), {
515 computed: {
516 value: function () {
517 return 0;
518 },
519 },
520 });
521 // to get Watcher class
522 var Watcher = vm._computedWatchers.value.constructor;
523 // to get Dep class
524 var Dep = vm._data.__ob__.dep.constructor;
525 vueInternalClasses = {
526 Watcher: Watcher,
527 Dep: Dep,
528 };
529 vm.$destroy();
530 }
531 return vueInternalClasses;
532};
533
534function createSymbol(name) {
535 return hasSymbol ? Symbol.for(name) : name;
536}
537var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue');
538var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue');
539// must be a string, symbol key is ignored in reactive
540var RefKey = 'composition-api.refKey';
541
542var accessModifiedSet = new WeakMap();
543var rawSet = new WeakMap();
544var readonlySet = new WeakMap();
545
546/**
547 * Set a property on an object. Adds the new property, triggers change
548 * notification and intercept it's subsequent access if the property doesn't
549 * already exist.
550 */
551function set$1(target, key, val) {
552 var Vue = getVueConstructor();
553 // @ts-expect-error https://github.com/vuejs/vue/pull/12132
554 var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive;
555 if ((isUndef(target) || isPrimitive(target))) {
556 warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target));
557 }
558 var ob = target.__ob__;
559 function ssrMockReactivity() {
560 // in SSR, there is no __ob__. Mock for reactivity check
561 if (ob && isObject(val) && !hasOwn(val, '__ob__')) {
562 mockReactivityDeep(val);
563 }
564 }
565 if (isArray(target)) {
566 if (isValidArrayIndex(key)) {
567 target.length = Math.max(target.length, key);
568 target.splice(key, 1, val);
569 ssrMockReactivity();
570 return val;
571 }
572 else if (key === 'length' && val !== target.length) {
573 target.length = val;
574 ob === null || ob === void 0 ? void 0 : ob.dep.notify();
575 return val;
576 }
577 }
578 if (key in target && !(key in Object.prototype)) {
579 target[key] = val;
580 ssrMockReactivity();
581 return val;
582 }
583 if (target._isVue || (ob && ob.vmCount)) {
584 warn('Avoid adding reactive properties to a Vue instance or its root $data ' +
585 'at runtime - declare it upfront in the data option.');
586 return val;
587 }
588 if (!ob) {
589 target[key] = val;
590 return val;
591 }
592 defineReactive(ob.value, key, val);
593 // IMPORTANT: define access control before trigger watcher
594 defineAccessControl(target, key, val);
595 ssrMockReactivity();
596 ob.dep.notify();
597 return val;
598}
599
600var _isForceTrigger = false;
601function isForceTrigger() {
602 return _isForceTrigger;
603}
604function setForceTrigger(v) {
605 _isForceTrigger = v;
606}
607
608var RefImpl = /** @class */ (function () {
609 function RefImpl(_a) {
610 var get = _a.get, set = _a.set;
611 proxy(this, 'value', {
612 get: get,
613 set: set,
614 });
615 }
616 return RefImpl;
617}());
618function createRef(options, isReadonly, isComputed) {
619 if (isReadonly === void 0) { isReadonly = false; }
620 if (isComputed === void 0) { isComputed = false; }
621 var r = new RefImpl(options);
622 // add effect to differentiate refs from computed
623 if (isComputed)
624 r.effect = true;
625 // seal the ref, this could prevent ref from being observed
626 // It's safe to seal the ref, since we really shouldn't extend it.
627 // related issues: #79
628 var sealed = Object.seal(r);
629 if (isReadonly)
630 readonlySet.set(sealed, true);
631 return sealed;
632}
633function ref(raw) {
634 var _a;
635 if (isRef(raw)) {
636 return raw;
637 }
638 var value = reactive((_a = {}, _a[RefKey] = raw, _a));
639 return createRef({
640 get: function () { return value[RefKey]; },
641 set: function (v) { return (value[RefKey] = v); },
642 });
643}
644function isRef(value) {
645 return value instanceof RefImpl;
646}
647function unref(ref) {
648 return isRef(ref) ? ref.value : ref;
649}
650function toRefs(obj) {
651 if (!isReactive(obj)) {
652 warn("toRefs() expects a reactive object but received a plain one.");
653 }
654 if (!isPlainObject(obj))
655 return obj;
656 var ret = {};
657 for (var key in obj) {
658 ret[key] = toRef(obj, key);
659 }
660 return ret;
661}
662function customRef(factory) {
663 var version = ref(0);
664 return createRef(factory(function () { return void version.value; }, function () {
665 ++version.value;
666 }));
667}
668function toRef(object, key) {
669 if (!(key in object))
670 set$1(object, key, undefined);
671 var v = object[key];
672 if (isRef(v))
673 return v;
674 return createRef({
675 get: function () { return object[key]; },
676 set: function (v) { return (object[key] = v); },
677 });
678}
679function shallowRef(raw) {
680 var _a;
681 if (isRef(raw)) {
682 return raw;
683 }
684 var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a));
685 return createRef({
686 get: function () { return value[RefKey]; },
687 set: function (v) { return (value[RefKey] = v); },
688 });
689}
690function triggerRef(value) {
691 if (!isRef(value))
692 return;
693 setForceTrigger(true);
694 value.value = value.value;
695 setForceTrigger(false);
696}
697function proxyRefs(objectWithRefs) {
698 var _a, e_1, _b;
699 if (isReactive(objectWithRefs)) {
700 return objectWithRefs;
701 }
702 var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a));
703 def(value, RefKey, value[RefKey], false);
704 var _loop_1 = function (key) {
705 proxy(value, key, {
706 get: function () {
707 if (isRef(value[RefKey][key])) {
708 return value[RefKey][key].value;
709 }
710 return value[RefKey][key];
711 },
712 set: function (v) {
713 if (isRef(value[RefKey][key])) {
714 return (value[RefKey][key].value = unref(v));
715 }
716 value[RefKey][key] = unref(v);
717 },
718 });
719 };
720 try {
721 for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) {
722 var key = _d.value;
723 _loop_1(key);
724 }
725 }
726 catch (e_1_1) { e_1 = { error: e_1_1 }; }
727 finally {
728 try {
729 if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
730 }
731 finally { if (e_1) throw e_1.error; }
732 }
733 return value;
734}
735
736var SKIPFLAG = '__v_skip';
737function isRaw(obj) {
738 var _a;
739 return Boolean(obj &&
740 hasOwn(obj, '__ob__') &&
741 typeof obj.__ob__ === 'object' &&
742 ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG]));
743}
744function isReactive(obj) {
745 var _a;
746 return Boolean(obj &&
747 hasOwn(obj, '__ob__') &&
748 typeof obj.__ob__ === 'object' &&
749 !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG]));
750}
751/**
752 * Proxing property access of target.
753 * We can do unwrapping and other things here.
754 */
755function setupAccessControl(target) {
756 if (!isPlainObject(target) ||
757 isRaw(target) ||
758 isArray(target) ||
759 isRef(target) ||
760 isComponentInstance(target) ||
761 accessModifiedSet.has(target))
762 return;
763 accessModifiedSet.set(target, true);
764 var keys = Object.keys(target);
765 for (var i = 0; i < keys.length; i++) {
766 defineAccessControl(target, keys[i]);
767 }
768}
769/**
770 * Auto unwrapping when access property
771 */
772function defineAccessControl(target, key, val) {
773 if (key === '__ob__')
774 return;
775 if (isRaw(target[key]))
776 return;
777 var getter;
778 var setter;
779 var property = Object.getOwnPropertyDescriptor(target, key);
780 if (property) {
781 if (property.configurable === false) {
782 return;
783 }
784 getter = property.get;
785 setter = property.set;
786 if ((!getter || setter) /* not only have getter */ &&
787 arguments.length === 2) {
788 val = target[key];
789 }
790 }
791 setupAccessControl(val);
792 proxy(target, key, {
793 get: function getterHandler() {
794 var value = getter ? getter.call(target) : val;
795 // if the key is equal to RefKey, skip the unwrap logic
796 if (key !== RefKey && isRef(value)) {
797 return value.value;
798 }
799 else {
800 return value;
801 }
802 },
803 set: function setterHandler(newVal) {
804 if (getter && !setter)
805 return;
806 // If the key is equal to RefKey, skip the unwrap logic
807 // If and only if "value" is ref and "newVal" is not a ref,
808 // the assignment should be proxied to "value" ref.
809 if (key !== RefKey && isRef(val) && !isRef(newVal)) {
810 val.value = newVal;
811 }
812 else if (setter) {
813 setter.call(target, newVal);
814 val = newVal;
815 }
816 else {
817 val = newVal;
818 }
819 setupAccessControl(newVal);
820 },
821 });
822}
823function observe(obj) {
824 var Vue = getRegisteredVueOrDefault();
825 var observed;
826 if (Vue.observable) {
827 observed = Vue.observable(obj);
828 }
829 else {
830 var vm = defineComponentInstance(Vue, {
831 data: {
832 $$state: obj,
833 },
834 });
835 observed = vm._data.$$state;
836 }
837 // in SSR, there is no __ob__. Mock for reactivity check
838 if (!hasOwn(observed, '__ob__')) {
839 mockReactivityDeep(observed);
840 }
841 return observed;
842}
843/**
844 * Mock __ob__ for object recursively
845 */
846function mockReactivityDeep(obj, seen) {
847 var e_1, _a;
848 if (seen === void 0) { seen = new Set(); }
849 if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj))
850 return;
851 def(obj, '__ob__', mockObserver(obj));
852 seen.add(obj);
853 try {
854 for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
855 var key = _c.value;
856 var value = obj[key];
857 if (!(isPlainObject(value) || isArray(value)) ||
858 isRaw(value) ||
859 !Object.isExtensible(value)) {
860 continue;
861 }
862 mockReactivityDeep(value, seen);
863 }
864 }
865 catch (e_1_1) { e_1 = { error: e_1_1 }; }
866 finally {
867 try {
868 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
869 }
870 finally { if (e_1) throw e_1.error; }
871 }
872}
873function mockObserver(value) {
874 if (value === void 0) { value = {}; }
875 return {
876 value: value,
877 dep: {
878 notify: noopFn,
879 depend: noopFn,
880 addSub: noopFn,
881 removeSub: noopFn,
882 },
883 };
884}
885function createObserver() {
886 return observe({}).__ob__;
887}
888function shallowReactive(obj) {
889 var e_2, _a;
890 if (!isObject(obj)) {
891 {
892 warn('"shallowReactive()" must be called on an object.');
893 }
894 return obj;
895 }
896 if (!(isPlainObject(obj) || isArray(obj)) ||
897 isRaw(obj) ||
898 !Object.isExtensible(obj)) {
899 return obj;
900 }
901 var observed = observe(isArray(obj) ? [] : {});
902 var ob = observed.__ob__;
903 var _loop_1 = function (key) {
904 var val = obj[key];
905 var getter;
906 var setter;
907 var property = Object.getOwnPropertyDescriptor(obj, key);
908 if (property) {
909 if (property.configurable === false) {
910 return "continue";
911 }
912 getter = property.get;
913 setter = property.set;
914 }
915 proxy(observed, key, {
916 get: function getterHandler() {
917 var _a;
918 (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend();
919 return val;
920 },
921 set: function setterHandler(newVal) {
922 var _a;
923 if (getter && !setter)
924 return;
925 if (!isForceTrigger() && val === newVal)
926 return;
927 if (setter) {
928 setter.call(obj, newVal);
929 }
930 else {
931 val = newVal;
932 }
933 (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify();
934 },
935 });
936 };
937 try {
938 for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
939 var key = _c.value;
940 _loop_1(key);
941 }
942 }
943 catch (e_2_1) { e_2 = { error: e_2_1 }; }
944 finally {
945 try {
946 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
947 }
948 finally { if (e_2) throw e_2.error; }
949 }
950 return observed;
951}
952/**
953 * Make obj reactivity
954 */
955function reactive(obj) {
956 if (!isObject(obj)) {
957 {
958 warn('"reactive()" must be called on an object.');
959 }
960 return obj;
961 }
962 if (!(isPlainObject(obj) || isArray(obj)) ||
963 isRaw(obj) ||
964 !Object.isExtensible(obj)) {
965 return obj;
966 }
967 var observed = observe(obj);
968 setupAccessControl(observed);
969 return observed;
970}
971/**
972 * Make sure obj can't be a reactive
973 */
974function markRaw(obj) {
975 if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) {
976 return obj;
977 }
978 // set the vue observable flag at obj
979 var ob = createObserver();
980 ob[SKIPFLAG] = true;
981 def(obj, '__ob__', ob);
982 // mark as Raw
983 rawSet.set(obj, true);
984 return obj;
985}
986function toRaw(observed) {
987 var _a;
988 if (isRaw(observed) || !Object.isExtensible(observed)) {
989 return observed;
990 }
991 return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed;
992}
993
994function isReadonly(obj) {
995 return readonlySet.has(obj);
996}
997/**
998 * **In @vue/composition-api, `reactive` only provides type-level readonly check**
999 *
1000 * Creates a readonly copy of the original object. Note the returned copy is not
1001 * made reactive, but `readonly` can be called on an already reactive object.
1002 */
1003function readonly(target) {
1004 if (!isObject(target)) {
1005 warn("value cannot be made reactive: ".concat(String(target)));
1006 }
1007 else {
1008 readonlySet.set(target, true);
1009 }
1010 return target;
1011}
1012function shallowReadonly(obj) {
1013 var e_1, _a;
1014 if (!isObject(obj)) {
1015 {
1016 warn("value cannot be made reactive: ".concat(String(obj)));
1017 }
1018 return obj;
1019 }
1020 if (!(isPlainObject(obj) || isArray(obj)) ||
1021 (!Object.isExtensible(obj) && !isRef(obj))) {
1022 return obj;
1023 }
1024 var readonlyObj = isRef(obj)
1025 ? new RefImpl({})
1026 : isReactive(obj)
1027 ? observe({})
1028 : {};
1029 var source = reactive({});
1030 var ob = source.__ob__;
1031 var _loop_1 = function (key) {
1032 var val = obj[key];
1033 var getter;
1034 var property = Object.getOwnPropertyDescriptor(obj, key);
1035 if (property) {
1036 if (property.configurable === false && !isRef(obj)) {
1037 return "continue";
1038 }
1039 getter = property.get;
1040 }
1041 proxy(readonlyObj, key, {
1042 get: function getterHandler() {
1043 var value = getter ? getter.call(obj) : val;
1044 ob.dep.depend();
1045 return value;
1046 },
1047 set: function (v) {
1048 {
1049 warn("Set operation on key \"".concat(key, "\" failed: target is readonly."));
1050 }
1051 },
1052 });
1053 };
1054 try {
1055 for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
1056 var key = _c.value;
1057 _loop_1(key);
1058 }
1059 }
1060 catch (e_1_1) { e_1 = { error: e_1_1 }; }
1061 finally {
1062 try {
1063 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1064 }
1065 finally { if (e_1) throw e_1.error; }
1066 }
1067 readonlySet.set(readonlyObj, true);
1068 return readonlyObj;
1069}
1070
1071/**
1072 * Delete a property and trigger change if necessary.
1073 */
1074function del(target, key) {
1075 var Vue = getVueConstructor();
1076 var warn = Vue.util.warn;
1077 if ((isUndef(target) || isPrimitive(target))) {
1078 warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target));
1079 }
1080 if (isArray(target) && isValidArrayIndex(key)) {
1081 target.splice(key, 1);
1082 return;
1083 }
1084 var ob = target.__ob__;
1085 if (target._isVue || (ob && ob.vmCount)) {
1086 warn('Avoid deleting properties on a Vue instance or its root $data ' +
1087 '- just set it to null.');
1088 return;
1089 }
1090 if (!hasOwn(target, key)) {
1091 return;
1092 }
1093 delete target[key];
1094 if (!ob) {
1095 return;
1096 }
1097 ob.dep.notify();
1098}
1099
1100var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); };
1101function createLifeCycle(lifeCyclehook) {
1102 return function (callback, target) {
1103 var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target);
1104 return (instance &&
1105 injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback));
1106 };
1107}
1108function injectHookOption(Vue, instance, hook, val) {
1109 var options = instance.proxy.$options;
1110 var mergeFn = Vue.config.optionMergeStrategies[hook];
1111 var wrappedHook = wrapHookCall(instance, val);
1112 options[hook] = mergeFn(options[hook], wrappedHook);
1113 return wrappedHook;
1114}
1115function wrapHookCall(instance, fn) {
1116 return function () {
1117 var args = [];
1118 for (var _i = 0; _i < arguments.length; _i++) {
1119 args[_i] = arguments[_i];
1120 }
1121 var prev = getCurrentInstance();
1122 setCurrentInstance(instance);
1123 try {
1124 return fn.apply(void 0, __spreadArray([], __read(args), false));
1125 }
1126 finally {
1127 setCurrentInstance(prev);
1128 }
1129 };
1130}
1131var onBeforeMount = createLifeCycle('beforeMount');
1132var onMounted = createLifeCycle('mounted');
1133var onBeforeUpdate = createLifeCycle('beforeUpdate');
1134var onUpdated = createLifeCycle('updated');
1135var onBeforeUnmount = createLifeCycle('beforeDestroy');
1136var onUnmounted = createLifeCycle('destroyed');
1137var onErrorCaptured = createLifeCycle('errorCaptured');
1138var onActivated = createLifeCycle('activated');
1139var onDeactivated = createLifeCycle('deactivated');
1140var onServerPrefetch = createLifeCycle('serverPrefetch');
1141
1142var fallbackVM;
1143function flushPreQueue() {
1144 flushQueue(this, WatcherPreFlushQueueKey);
1145}
1146function flushPostQueue() {
1147 flushQueue(this, WatcherPostFlushQueueKey);
1148}
1149function hasWatchEnv(vm) {
1150 return vm[WatcherPreFlushQueueKey] !== undefined;
1151}
1152function installWatchEnv(vm) {
1153 vm[WatcherPreFlushQueueKey] = [];
1154 vm[WatcherPostFlushQueueKey] = [];
1155 vm.$on('hook:beforeUpdate', flushPreQueue);
1156 vm.$on('hook:updated', flushPostQueue);
1157}
1158function getWatcherOption(options) {
1159 return __assign({
1160 immediate: false,
1161 deep: false,
1162 flush: 'pre',
1163 }, options);
1164}
1165function getWatchEffectOption(options) {
1166 return __assign({
1167 flush: 'pre',
1168 }, options);
1169}
1170function getWatcherVM() {
1171 var vm = getCurrentScopeVM();
1172 if (!vm) {
1173 if (!fallbackVM) {
1174 fallbackVM = defineComponentInstance(getVueConstructor());
1175 }
1176 vm = fallbackVM;
1177 }
1178 else if (!hasWatchEnv(vm)) {
1179 installWatchEnv(vm);
1180 }
1181 return vm;
1182}
1183function flushQueue(vm, key) {
1184 var queue = vm[key];
1185 for (var index = 0; index < queue.length; index++) {
1186 queue[index]();
1187 }
1188 queue.length = 0;
1189}
1190function queueFlushJob(vm, fn, mode) {
1191 // flush all when beforeUpdate and updated are not fired
1192 var fallbackFlush = function () {
1193 vm.$nextTick(function () {
1194 if (vm[WatcherPreFlushQueueKey].length) {
1195 flushQueue(vm, WatcherPreFlushQueueKey);
1196 }
1197 if (vm[WatcherPostFlushQueueKey].length) {
1198 flushQueue(vm, WatcherPostFlushQueueKey);
1199 }
1200 });
1201 };
1202 switch (mode) {
1203 case 'pre':
1204 fallbackFlush();
1205 vm[WatcherPreFlushQueueKey].push(fn);
1206 break;
1207 case 'post':
1208 fallbackFlush();
1209 vm[WatcherPostFlushQueueKey].push(fn);
1210 break;
1211 default:
1212 assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode));
1213 break;
1214 }
1215}
1216function createVueWatcher(vm, getter, callback, options) {
1217 var index = vm._watchers.length;
1218 // @ts-ignore: use undocumented options
1219 vm.$watch(getter, callback, {
1220 immediate: options.immediateInvokeCallback,
1221 deep: options.deep,
1222 lazy: options.noRun,
1223 sync: options.sync,
1224 before: options.before,
1225 });
1226 return vm._watchers[index];
1227}
1228// We have to monkeypatch the teardown function so Vue will run
1229// runCleanup() when it tears down the watcher on unmounted.
1230function patchWatcherTeardown(watcher, runCleanup) {
1231 var _teardown = watcher.teardown;
1232 watcher.teardown = function () {
1233 var args = [];
1234 for (var _i = 0; _i < arguments.length; _i++) {
1235 args[_i] = arguments[_i];
1236 }
1237 _teardown.apply(watcher, args);
1238 runCleanup();
1239 };
1240}
1241function createWatcher(vm, source, cb, options) {
1242 var _a;
1243 if (!cb) {
1244 if (options.immediate !== undefined) {
1245 warn("watch() \"immediate\" option is only respected when using the " +
1246 "watch(source, callback, options?) signature.");
1247 }
1248 if (options.deep !== undefined) {
1249 warn("watch() \"deep\" option is only respected when using the " +
1250 "watch(source, callback, options?) signature.");
1251 }
1252 }
1253 var flushMode = options.flush;
1254 var isSync = flushMode === 'sync';
1255 var cleanup;
1256 var registerCleanup = function (fn) {
1257 cleanup = function () {
1258 try {
1259 fn();
1260 }
1261 catch (
1262 // FIXME: remove any
1263 error) {
1264 logError(error, vm, 'onCleanup()');
1265 }
1266 };
1267 };
1268 // cleanup before running getter again
1269 var runCleanup = function () {
1270 if (cleanup) {
1271 cleanup();
1272 cleanup = null;
1273 }
1274 };
1275 var createScheduler = function (fn) {
1276 if (isSync ||
1277 /* without a current active instance, ignore pre|post mode */ vm ===
1278 fallbackVM) {
1279 return fn;
1280 }
1281 return (function () {
1282 var args = [];
1283 for (var _i = 0; _i < arguments.length; _i++) {
1284 args[_i] = arguments[_i];
1285 }
1286 return queueFlushJob(vm, function () {
1287 fn.apply(void 0, __spreadArray([], __read(args), false));
1288 }, flushMode);
1289 });
1290 };
1291 // effect watch
1292 if (cb === null) {
1293 var running_1 = false;
1294 var getter_1 = function () {
1295 // preventing the watch callback being call in the same execution
1296 if (running_1) {
1297 return;
1298 }
1299 try {
1300 running_1 = true;
1301 source(registerCleanup);
1302 }
1303 finally {
1304 running_1 = false;
1305 }
1306 };
1307 var watcher_1 = createVueWatcher(vm, getter_1, noopFn, {
1308 deep: options.deep || false,
1309 sync: isSync,
1310 before: runCleanup,
1311 });
1312 patchWatcherTeardown(watcher_1, runCleanup);
1313 // enable the watcher update
1314 watcher_1.lazy = false;
1315 var originGet = watcher_1.get.bind(watcher_1);
1316 // always run watchEffect
1317 watcher_1.get = createScheduler(originGet);
1318 return function () {
1319 watcher_1.teardown();
1320 };
1321 }
1322 var deep = options.deep;
1323 var isMultiSource = false;
1324 var getter;
1325 if (isRef(source)) {
1326 getter = function () { return source.value; };
1327 }
1328 else if (isReactive(source)) {
1329 getter = function () { return source; };
1330 deep = true;
1331 }
1332 else if (isArray(source)) {
1333 isMultiSource = true;
1334 getter = function () {
1335 return source.map(function (s) {
1336 if (isRef(s)) {
1337 return s.value;
1338 }
1339 else if (isReactive(s)) {
1340 return traverse(s);
1341 }
1342 else if (isFunction(s)) {
1343 return s();
1344 }
1345 else {
1346 warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm);
1347 return noopFn;
1348 }
1349 });
1350 };
1351 }
1352 else if (isFunction(source)) {
1353 getter = source;
1354 }
1355 else {
1356 getter = noopFn;
1357 warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm);
1358 }
1359 if (deep) {
1360 var baseGetter_1 = getter;
1361 getter = function () { return traverse(baseGetter_1()); };
1362 }
1363 var applyCb = function (n, o) {
1364 if (!deep &&
1365 isMultiSource &&
1366 n.every(function (v, i) { return isSame(v, o[i]); }))
1367 return;
1368 // cleanup before running cb again
1369 runCleanup();
1370 return cb(n, o, registerCleanup);
1371 };
1372 var callback = createScheduler(applyCb);
1373 if (options.immediate) {
1374 var originalCallback_1 = callback;
1375 // `shiftCallback` is used to handle the first sync effect run.
1376 // The subsequent callbacks will redirect to `callback`.
1377 var shiftCallback_1 = function (n, o) {
1378 shiftCallback_1 = originalCallback_1;
1379 // o is undefined on the first call
1380 return applyCb(n, isArray(n) ? [] : o);
1381 };
1382 callback = function (n, o) {
1383 return shiftCallback_1(n, o);
1384 };
1385 }
1386 // @ts-ignore: use undocumented option "sync"
1387 var stop = vm.$watch(getter, callback, {
1388 immediate: options.immediate,
1389 deep: deep,
1390 sync: isSync,
1391 });
1392 // Once again, we have to hack the watcher for proper teardown
1393 var watcher = vm._watchers[vm._watchers.length - 1];
1394 // if the return value is reactive and deep:true
1395 // watch for changes, this might happen when new key is added
1396 if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) {
1397 watcher.value.__ob__.dep.addSub({
1398 update: function () {
1399 // this will force the source to be reevaluated and the callback
1400 // executed if needed
1401 watcher.run();
1402 },
1403 });
1404 }
1405 patchWatcherTeardown(watcher, runCleanup);
1406 return function () {
1407 stop();
1408 };
1409}
1410function watchEffect(effect, options) {
1411 var opts = getWatchEffectOption(options);
1412 var vm = getWatcherVM();
1413 return createWatcher(vm, effect, null, opts);
1414}
1415function watchPostEffect(effect) {
1416 return watchEffect(effect, { flush: 'post' });
1417}
1418function watchSyncEffect(effect) {
1419 return watchEffect(effect, { flush: 'sync' });
1420}
1421// implementation
1422function watch(source, cb, options) {
1423 var callback = null;
1424 if (isFunction(cb)) {
1425 // source watch
1426 callback = cb;
1427 }
1428 else {
1429 // effect watch
1430 {
1431 warn("`watch(fn, options?)` signature has been moved to a separate API. " +
1432 "Use `watchEffect(fn, options?)` instead. `watch` now only " +
1433 "supports `watch(source, cb, options?) signature.");
1434 }
1435 options = cb;
1436 callback = null;
1437 }
1438 var opts = getWatcherOption(options);
1439 var vm = getWatcherVM();
1440 return createWatcher(vm, source, callback, opts);
1441}
1442function traverse(value, seen) {
1443 if (seen === void 0) { seen = new Set(); }
1444 if (!isObject(value) || seen.has(value) || rawSet.has(value)) {
1445 return value;
1446 }
1447 seen.add(value);
1448 if (isRef(value)) {
1449 traverse(value.value, seen);
1450 }
1451 else if (isArray(value)) {
1452 for (var i = 0; i < value.length; i++) {
1453 traverse(value[i], seen);
1454 }
1455 }
1456 else if (isSet(value) || isMap(value)) {
1457 value.forEach(function (v) {
1458 traverse(v, seen);
1459 });
1460 }
1461 else if (isPlainObject(value)) {
1462 for (var key in value) {
1463 traverse(value[key], seen);
1464 }
1465 }
1466 return value;
1467}
1468
1469// implement
1470function computed(getterOrOptions) {
1471 var vm = getCurrentScopeVM();
1472 var getter;
1473 var setter;
1474 if (isFunction(getterOrOptions)) {
1475 getter = getterOrOptions;
1476 }
1477 else {
1478 getter = getterOrOptions.get;
1479 setter = getterOrOptions.set;
1480 }
1481 var computedSetter;
1482 var computedGetter;
1483 if (vm && !vm.$isServer) {
1484 var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep;
1485 var watcher_1;
1486 computedGetter = function () {
1487 if (!watcher_1) {
1488 watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true });
1489 }
1490 if (watcher_1.dirty) {
1491 watcher_1.evaluate();
1492 }
1493 if (Dep_1.target) {
1494 watcher_1.depend();
1495 }
1496 return watcher_1.value;
1497 };
1498 computedSetter = function (v) {
1499 if (!setter) {
1500 warn('Write operation failed: computed value is readonly.', vm);
1501 return;
1502 }
1503 if (setter) {
1504 setter(v);
1505 }
1506 };
1507 }
1508 else {
1509 // fallback
1510 var computedHost_1 = defineComponentInstance(getVueConstructor(), {
1511 computed: {
1512 $$state: {
1513 get: getter,
1514 set: setter,
1515 },
1516 },
1517 });
1518 vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); });
1519 computedGetter = function () { return computedHost_1.$$state; };
1520 computedSetter = function (v) {
1521 if (!setter) {
1522 warn('Write operation failed: computed value is readonly.', vm);
1523 return;
1524 }
1525 computedHost_1.$$state = v;
1526 };
1527 }
1528 return createRef({
1529 get: computedGetter,
1530 set: computedSetter,
1531 }, !setter, true);
1532}
1533
1534var NOT_FOUND = {};
1535function resolveInject(provideKey, vm) {
1536 var source = vm;
1537 while (source) {
1538 if (source._provided && hasOwn(source._provided, provideKey)) {
1539 return source._provided[provideKey];
1540 }
1541 source = source.$parent;
1542 }
1543 return NOT_FOUND;
1544}
1545function provide(key, value) {
1546 var _a;
1547 var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy;
1548 if (!vm)
1549 return;
1550 if (!vm._provided) {
1551 var provideCache_1 = {};
1552 proxy(vm, '_provided', {
1553 get: function () { return provideCache_1; },
1554 set: function (v) { return Object.assign(provideCache_1, v); },
1555 });
1556 }
1557 vm._provided[key] = value;
1558}
1559function inject(key, defaultValue, treatDefaultAsFactory) {
1560 var _a;
1561 if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; }
1562 var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
1563 if (!vm) {
1564 warn("inject() can only be used inside setup() or functional components.");
1565 return;
1566 }
1567 if (!key) {
1568 warn("injection \"".concat(String(key), "\" not found."), vm);
1569 return defaultValue;
1570 }
1571 var val = resolveInject(key, vm);
1572 if (val !== NOT_FOUND) {
1573 return val;
1574 }
1575 else if (arguments.length > 1) {
1576 return treatDefaultAsFactory && isFunction(defaultValue)
1577 ? defaultValue()
1578 : defaultValue;
1579 }
1580 else {
1581 warn("Injection \"".concat(String(key), "\" not found."), vm);
1582 }
1583}
1584
1585var EMPTY_OBJ = Object.freeze({})
1586 ;
1587var useCssModule = function (name) {
1588 var _a;
1589 if (name === void 0) { name = '$style'; }
1590 var instance = getCurrentInstance();
1591 if (!instance) {
1592 warn("useCssModule must be called inside setup()");
1593 return EMPTY_OBJ;
1594 }
1595 var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name];
1596 if (!mod) {
1597 warn("Current instance does not have CSS module named \"".concat(name, "\"."));
1598 return EMPTY_OBJ;
1599 }
1600 return mod;
1601};
1602/**
1603 * @deprecated use `useCssModule` instead.
1604 */
1605var useCSSModule = useCssModule;
1606
1607function createApp(rootComponent, rootProps) {
1608 if (rootProps === void 0) { rootProps = undefined; }
1609 var V = getVueConstructor();
1610 var mountedVM = undefined;
1611 var provide = {};
1612 var app = {
1613 config: V.config,
1614 use: V.use.bind(V),
1615 mixin: V.mixin.bind(V),
1616 component: V.component.bind(V),
1617 provide: function (key, value) {
1618 provide[key] = value;
1619 return this;
1620 },
1621 directive: function (name, dir) {
1622 if (dir) {
1623 V.directive(name, dir);
1624 return app;
1625 }
1626 else {
1627 return V.directive(name);
1628 }
1629 },
1630 mount: function (el, hydrating) {
1631 if (!mountedVM) {
1632 mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) }));
1633 mountedVM.$mount(el, hydrating);
1634 return mountedVM;
1635 }
1636 else {
1637 {
1638 warn("App has already been mounted.\n" +
1639 "If you want to remount the same app, move your app creation logic " +
1640 "into a factory function and create fresh app instances for each " +
1641 "mount - e.g. `const createMyApp = () => createApp(App)`");
1642 }
1643 return mountedVM;
1644 }
1645 },
1646 unmount: function () {
1647 if (mountedVM) {
1648 mountedVM.$destroy();
1649 mountedVM = undefined;
1650 }
1651 else {
1652 warn("Cannot unmount an app that is not mounted.");
1653 }
1654 },
1655 };
1656 return app;
1657}
1658
1659var nextTick = function nextTick() {
1660 var _a;
1661 var args = [];
1662 for (var _i = 0; _i < arguments.length; _i++) {
1663 args[_i] = arguments[_i];
1664 }
1665 return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args);
1666};
1667
1668var fallbackCreateElement;
1669var createElement = function createElement() {
1670 var _a;
1671 var args = [];
1672 for (var _i = 0; _i < arguments.length; _i++) {
1673 args[_i] = arguments[_i];
1674 }
1675 var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy);
1676 if (!instance) {
1677 warn('`createElement()` has been called outside of render function.');
1678 if (!fallbackCreateElement) {
1679 fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement;
1680 }
1681 return fallbackCreateElement.apply(fallbackCreateElement, args);
1682 }
1683 return instance.$createElement.apply(instance, args);
1684};
1685
1686function useSlots() {
1687 return getContext().slots;
1688}
1689function useAttrs() {
1690 return getContext().attrs;
1691}
1692function getContext() {
1693 var i = getCurrentInstance();
1694 if (!i) {
1695 warn("useContext() called without active instance.");
1696 }
1697 return i.setupContext;
1698}
1699
1700function set(vm, key, value) {
1701 var state = (vm.__composition_api_state__ =
1702 vm.__composition_api_state__ || {});
1703 state[key] = value;
1704}
1705function get(vm, key) {
1706 return (vm.__composition_api_state__ || {})[key];
1707}
1708var vmStateManager = {
1709 set: set,
1710 get: get,
1711};
1712
1713function asVmProperty(vm, propName, propValue) {
1714 var props = vm.$options.props;
1715 if (!(propName in vm) && !(props && hasOwn(props, propName))) {
1716 if (isRef(propValue)) {
1717 proxy(vm, propName, {
1718 get: function () { return propValue.value; },
1719 set: function (val) {
1720 propValue.value = val;
1721 },
1722 });
1723 }
1724 else {
1725 proxy(vm, propName, {
1726 get: function () {
1727 if (isReactive(propValue)) {
1728 propValue.__ob__.dep.depend();
1729 }
1730 return propValue;
1731 },
1732 set: function (val) {
1733 propValue = val;
1734 },
1735 });
1736 }
1737 {
1738 // expose binding to Vue Devtool as a data property
1739 // delay this until state has been resolved to prevent repeated works
1740 vm.$nextTick(function () {
1741 if (Object.keys(vm._data).indexOf(propName) !== -1) {
1742 return;
1743 }
1744 if (isRef(propValue)) {
1745 proxy(vm._data, propName, {
1746 get: function () { return propValue.value; },
1747 set: function (val) {
1748 propValue.value = val;
1749 },
1750 });
1751 }
1752 else {
1753 proxy(vm._data, propName, {
1754 get: function () { return propValue; },
1755 set: function (val) {
1756 propValue = val;
1757 },
1758 });
1759 }
1760 });
1761 }
1762 }
1763 else {
1764 if (props && hasOwn(props, propName)) {
1765 warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm);
1766 }
1767 else {
1768 warn("The setup binding property \"".concat(propName, "\" is already declared."), vm);
1769 }
1770 }
1771}
1772function updateTemplateRef(vm) {
1773 var rawBindings = vmStateManager.get(vm, 'rawBindings') || {};
1774 if (!rawBindings || !Object.keys(rawBindings).length)
1775 return;
1776 var refs = vm.$refs;
1777 var oldRefKeys = vmStateManager.get(vm, 'refs') || [];
1778 for (var index = 0; index < oldRefKeys.length; index++) {
1779 var key = oldRefKeys[index];
1780 var setupValue = rawBindings[key];
1781 if (!refs[key] && setupValue && isRef(setupValue)) {
1782 setupValue.value = null;
1783 }
1784 }
1785 var newKeys = Object.keys(refs);
1786 var validNewKeys = [];
1787 for (var index = 0; index < newKeys.length; index++) {
1788 var key = newKeys[index];
1789 var setupValue = rawBindings[key];
1790 if (refs[key] && setupValue && isRef(setupValue)) {
1791 setupValue.value = refs[key];
1792 validNewKeys.push(key);
1793 }
1794 }
1795 vmStateManager.set(vm, 'refs', validNewKeys);
1796}
1797function afterRender(vm) {
1798 var stack = [vm._vnode];
1799 while (stack.length) {
1800 var vnode = stack.pop();
1801 if (vnode) {
1802 if (vnode.context)
1803 updateTemplateRef(vnode.context);
1804 if (vnode.children) {
1805 for (var i = 0; i < vnode.children.length; ++i) {
1806 stack.push(vnode.children[i]);
1807 }
1808 }
1809 }
1810 }
1811}
1812function updateVmAttrs(vm, ctx) {
1813 var e_1, _a;
1814 if (!vm) {
1815 return;
1816 }
1817 var attrBindings = vmStateManager.get(vm, 'attrBindings');
1818 if (!attrBindings && !ctx) {
1819 // fix 840
1820 return;
1821 }
1822 if (!attrBindings) {
1823 var observedData = reactive({});
1824 attrBindings = { ctx: ctx, data: observedData };
1825 vmStateManager.set(vm, 'attrBindings', attrBindings);
1826 proxy(ctx, 'attrs', {
1827 get: function () {
1828 return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data;
1829 },
1830 set: function () {
1831 warn("Cannot assign to '$attrs' because it is a read-only property", vm);
1832 },
1833 });
1834 }
1835 var source = vm.$attrs;
1836 var _loop_1 = function (attr) {
1837 if (!hasOwn(attrBindings.data, attr)) {
1838 proxy(attrBindings.data, attr, {
1839 get: function () {
1840 // to ensure it always return the latest value
1841 return vm.$attrs[attr];
1842 },
1843 });
1844 }
1845 };
1846 try {
1847 for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) {
1848 var attr = _c.value;
1849 _loop_1(attr);
1850 }
1851 }
1852 catch (e_1_1) { e_1 = { error: e_1_1 }; }
1853 finally {
1854 try {
1855 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1856 }
1857 finally { if (e_1) throw e_1.error; }
1858 }
1859}
1860function resolveScopedSlots(vm, slotsProxy) {
1861 var parentVNode = vm.$options._parentVnode;
1862 if (!parentVNode)
1863 return;
1864 var prevSlots = vmStateManager.get(vm, 'slots') || [];
1865 var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots);
1866 // remove staled slots
1867 for (var index = 0; index < prevSlots.length; index++) {
1868 var key = prevSlots[index];
1869 if (!curSlots[key]) {
1870 delete slotsProxy[key];
1871 }
1872 }
1873 // proxy fresh slots
1874 var slotNames = Object.keys(curSlots);
1875 for (var index = 0; index < slotNames.length; index++) {
1876 var key = slotNames[index];
1877 if (!slotsProxy[key]) {
1878 slotsProxy[key] = createSlotProxy(vm, key);
1879 }
1880 }
1881 vmStateManager.set(vm, 'slots', slotNames);
1882}
1883function activateCurrentInstance(instance, fn, onError) {
1884 var preVm = getCurrentInstance();
1885 setCurrentInstance(instance);
1886 try {
1887 return fn(instance);
1888 }
1889 catch (
1890 // FIXME: remove any
1891 err) {
1892 if (onError) {
1893 onError(err);
1894 }
1895 else {
1896 throw err;
1897 }
1898 }
1899 finally {
1900 setCurrentInstance(preVm);
1901 }
1902}
1903
1904function mixin(Vue) {
1905 Vue.mixin({
1906 beforeCreate: functionApiInit,
1907 mounted: function () {
1908 afterRender(this);
1909 },
1910 beforeUpdate: function () {
1911 updateVmAttrs(this);
1912 },
1913 updated: function () {
1914 afterRender(this);
1915 },
1916 });
1917 /**
1918 * Vuex init hook, injected into each instances init hooks list.
1919 */
1920 function functionApiInit() {
1921 var vm = this;
1922 var $options = vm.$options;
1923 var setup = $options.setup, render = $options.render;
1924 if (render) {
1925 // keep currentInstance accessible for createElement
1926 $options.render = function () {
1927 var _this = this;
1928 var args = [];
1929 for (var _i = 0; _i < arguments.length; _i++) {
1930 args[_i] = arguments[_i];
1931 }
1932 return activateCurrentInstance(toVue3ComponentInstance(vm), function () {
1933 return render.apply(_this, args);
1934 });
1935 };
1936 }
1937 if (!setup) {
1938 return;
1939 }
1940 if (!isFunction(setup)) {
1941 {
1942 warn('The "setup" option should be a function that returns a object in component definitions.', vm);
1943 }
1944 return;
1945 }
1946 var data = $options.data;
1947 // wrapper the data option, so we can invoke setup before data get resolved
1948 $options.data = function wrappedData() {
1949 initSetup(vm, vm.$props);
1950 return isFunction(data)
1951 ? data.call(vm, vm)
1952 : data || {};
1953 };
1954 }
1955 function initSetup(vm, props) {
1956 if (props === void 0) { props = {}; }
1957 var setup = vm.$options.setup;
1958 var ctx = createSetupContext(vm);
1959 var instance = toVue3ComponentInstance(vm);
1960 instance.setupContext = ctx;
1961 // fake reactive for `toRefs(props)`
1962 def(props, '__ob__', createObserver());
1963 // resolve scopedSlots and slots to functions
1964 resolveScopedSlots(vm, ctx.slots);
1965 var binding;
1966 activateCurrentInstance(instance, function () {
1967 // make props to be fake reactive, this is for `toRefs(props)`
1968 binding = setup(props, ctx);
1969 });
1970 if (!binding)
1971 return;
1972 if (isFunction(binding)) {
1973 // keep typescript happy with the binding type.
1974 var bindingFunc_1 = binding;
1975 // keep currentInstance accessible for createElement
1976 vm.$options.render = function () {
1977 resolveScopedSlots(vm, ctx.slots);
1978 return activateCurrentInstance(instance, function () { return bindingFunc_1(); });
1979 };
1980 return;
1981 }
1982 else if (isObject(binding)) {
1983 if (isReactive(binding)) {
1984 binding = toRefs(binding);
1985 }
1986 vmStateManager.set(vm, 'rawBindings', binding);
1987 var bindingObj_1 = binding;
1988 Object.keys(bindingObj_1).forEach(function (name) {
1989 var bindingValue = bindingObj_1[name];
1990 if (!isRef(bindingValue)) {
1991 if (!isReactive(bindingValue)) {
1992 if (isFunction(bindingValue)) {
1993 var copy_1 = bindingValue;
1994 bindingValue = bindingValue.bind(vm);
1995 Object.keys(copy_1).forEach(function (ele) {
1996 bindingValue[ele] = copy_1[ele];
1997 });
1998 }
1999 else if (!isObject(bindingValue)) {
2000 bindingValue = ref(bindingValue);
2001 }
2002 else if (hasReactiveArrayChild(bindingValue)) {
2003 // creates a custom reactive properties without make the object explicitly reactive
2004 // NOTE we should try to avoid this, better implementation needed
2005 customReactive(bindingValue);
2006 }
2007 }
2008 else if (isArray(bindingValue)) {
2009 bindingValue = ref(bindingValue);
2010 }
2011 }
2012 asVmProperty(vm, name, bindingValue);
2013 });
2014 return;
2015 }
2016 {
2017 assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString
2018 .call(binding)
2019 .slice(8, -1), "\""));
2020 }
2021 }
2022 function customReactive(target, seen) {
2023 if (seen === void 0) { seen = new Set(); }
2024 if (seen.has(target))
2025 return;
2026 if (!isPlainObject(target) ||
2027 isRef(target) ||
2028 isReactive(target) ||
2029 isRaw(target))
2030 return;
2031 var Vue = getVueConstructor();
2032 // @ts-expect-error https://github.com/vuejs/vue/pull/12132
2033 var defineReactive = Vue.util.defineReactive;
2034 Object.keys(target).forEach(function (k) {
2035 var val = target[k];
2036 defineReactive(target, k, val);
2037 if (val) {
2038 seen.add(val);
2039 customReactive(val, seen);
2040 }
2041 return;
2042 });
2043 }
2044 function hasReactiveArrayChild(target, visited) {
2045 if (visited === void 0) { visited = new Map(); }
2046 if (visited.has(target)) {
2047 return visited.get(target);
2048 }
2049 visited.set(target, false);
2050 if (isArray(target) && isReactive(target)) {
2051 visited.set(target, true);
2052 return true;
2053 }
2054 if (!isPlainObject(target) || isRaw(target) || isRef(target)) {
2055 return false;
2056 }
2057 return Object.keys(target).some(function (x) {
2058 return hasReactiveArrayChild(target[x], visited);
2059 });
2060 }
2061 function createSetupContext(vm) {
2062 var ctx = { slots: {} };
2063 var propsPlain = [
2064 'root',
2065 'parent',
2066 'refs',
2067 'listeners',
2068 'isServer',
2069 'ssrContext',
2070 ];
2071 var methodReturnVoid = ['emit'];
2072 propsPlain.forEach(function (key) {
2073 var srcKey = "$".concat(key);
2074 proxy(ctx, key, {
2075 get: function () { return vm[srcKey]; },
2076 set: function () {
2077 warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm);
2078 },
2079 });
2080 });
2081 updateVmAttrs(vm, ctx);
2082 methodReturnVoid.forEach(function (key) {
2083 var srcKey = "$".concat(key);
2084 proxy(ctx, key, {
2085 get: function () {
2086 return function () {
2087 var args = [];
2088 for (var _i = 0; _i < arguments.length; _i++) {
2089 args[_i] = arguments[_i];
2090 }
2091 var fn = vm[srcKey];
2092 fn.apply(vm, args);
2093 };
2094 },
2095 });
2096 });
2097 return ctx;
2098 }
2099}
2100
2101/**
2102 * Helper that recursively merges two data objects together.
2103 */
2104function mergeData(from, to) {
2105 if (!from)
2106 return to;
2107 if (!to)
2108 return from;
2109 var key;
2110 var toVal;
2111 var fromVal;
2112 var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from);
2113 for (var i = 0; i < keys.length; i++) {
2114 key = keys[i];
2115 // in case the object is already observed...
2116 if (key === '__ob__')
2117 continue;
2118 toVal = to[key];
2119 fromVal = from[key];
2120 if (!hasOwn(to, key)) {
2121 to[key] = fromVal;
2122 }
2123 else if (toVal !== fromVal &&
2124 isPlainObject(toVal) &&
2125 !isRef(toVal) &&
2126 isPlainObject(fromVal) &&
2127 !isRef(fromVal)) {
2128 mergeData(fromVal, toVal);
2129 }
2130 }
2131 return to;
2132}
2133function install(Vue) {
2134 if (isVueRegistered(Vue)) {
2135 {
2136 warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.');
2137 }
2138 return;
2139 }
2140 {
2141 if (Vue.version) {
2142 if (Vue.version[0] !== '2' || Vue.version[1] !== '.') {
2143 warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found."));
2144 }
2145 }
2146 else {
2147 warn('[vue-composition-api] no Vue version found');
2148 }
2149 }
2150 Vue.config.optionMergeStrategies.setup = function (parent, child) {
2151 return function mergedSetupFn(props, context) {
2152 return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined);
2153 };
2154 };
2155 setVueConstructor(Vue);
2156 mixin(Vue);
2157}
2158var Plugin = {
2159 install: function (Vue) { return install(Vue); },
2160};
2161
2162// implementation, close to no-op
2163function defineComponent(options) {
2164 return options;
2165}
2166
2167function defineAsyncComponent(source) {
2168 if (isFunction(source)) {
2169 source = { loader: source };
2170 }
2171 var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out
2172 _b = source.suspensible, // undefined = never times out
2173 suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true
2174 userOnError = source.onError;
2175 if (suspensible) {
2176 warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored.");
2177 }
2178 var pendingRequest = null;
2179 var retries = 0;
2180 var retry = function () {
2181 retries++;
2182 pendingRequest = null;
2183 return load();
2184 };
2185 var load = function () {
2186 var thisRequest;
2187 return (pendingRequest ||
2188 (thisRequest = pendingRequest =
2189 loader()
2190 .catch(function (err) {
2191 err = err instanceof Error ? err : new Error(String(err));
2192 if (userOnError) {
2193 return new Promise(function (resolve, reject) {
2194 var userRetry = function () { return resolve(retry()); };
2195 var userFail = function () { return reject(err); };
2196 userOnError(err, userRetry, userFail, retries + 1);
2197 });
2198 }
2199 else {
2200 throw err;
2201 }
2202 })
2203 .then(function (comp) {
2204 if (thisRequest !== pendingRequest && pendingRequest) {
2205 return pendingRequest;
2206 }
2207 if (!comp) {
2208 warn("Async component loader resolved to undefined. " +
2209 "If you are using retry(), make sure to return its return value.");
2210 }
2211 // interop module default
2212 if (comp &&
2213 (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
2214 comp = comp.default;
2215 }
2216 if (comp && !isObject(comp) && !isFunction(comp)) {
2217 throw new Error("Invalid async component load result: ".concat(comp));
2218 }
2219 return comp;
2220 })));
2221 };
2222 return function () {
2223 var component = load();
2224 return {
2225 component: component,
2226 delay: delay,
2227 timeout: timeout,
2228 error: errorComponent,
2229 loading: loadingComponent,
2230 };
2231 };
2232}
2233
2234var version = "1.7.2";
2235// auto install when using CDN
2236if (typeof window !== 'undefined' && window.Vue) {
2237 window.Vue.use(Plugin);
2238}
2239
2240exports.EffectScope = EffectScope;
2241exports.computed = computed;
2242exports.createApp = createApp;
2243exports.createRef = createRef;
2244exports.customRef = customRef;
2245exports["default"] = Plugin;
2246exports.defineAsyncComponent = defineAsyncComponent;
2247exports.defineComponent = defineComponent;
2248exports.del = del;
2249exports.effectScope = effectScope;
2250exports.getCurrentInstance = getCurrentInstance;
2251exports.getCurrentScope = getCurrentScope;
2252exports.h = createElement;
2253exports.inject = inject;
2254exports.isRaw = isRaw;
2255exports.isReactive = isReactive;
2256exports.isReadonly = isReadonly;
2257exports.isRef = isRef;
2258exports.markRaw = markRaw;
2259exports.nextTick = nextTick;
2260exports.onActivated = onActivated;
2261exports.onBeforeMount = onBeforeMount;
2262exports.onBeforeUnmount = onBeforeUnmount;
2263exports.onBeforeUpdate = onBeforeUpdate;
2264exports.onDeactivated = onDeactivated;
2265exports.onErrorCaptured = onErrorCaptured;
2266exports.onMounted = onMounted;
2267exports.onScopeDispose = onScopeDispose;
2268exports.onServerPrefetch = onServerPrefetch;
2269exports.onUnmounted = onUnmounted;
2270exports.onUpdated = onUpdated;
2271exports.provide = provide;
2272exports.proxyRefs = proxyRefs;
2273exports.reactive = reactive;
2274exports.readonly = readonly;
2275exports.ref = ref;
2276exports.set = set$1;
2277exports.shallowReactive = shallowReactive;
2278exports.shallowReadonly = shallowReadonly;
2279exports.shallowRef = shallowRef;
2280exports.toRaw = toRaw;
2281exports.toRef = toRef;
2282exports.toRefs = toRefs;
2283exports.triggerRef = triggerRef;
2284exports.unref = unref;
2285exports.useAttrs = useAttrs;
2286exports.useCSSModule = useCSSModule;
2287exports.useCssModule = useCssModule;
2288exports.useSlots = useSlots;
2289exports.version = version;
2290exports.warn = warn$1;
2291exports.watch = watch;
2292exports.watchEffect = watchEffect;
2293exports.watchPostEffect = watchPostEffect;
2294exports.watchSyncEffect = watchSyncEffect;