UNPKG

416 kBJavaScriptView Raw
1/**
2 * Make a map and return a function for checking if a key
3 * is in that map.
4 * IMPORTANT: all calls of this function must be prefixed with
5 * \/\*#\_\_PURE\_\_\*\/
6 * So that rollup can tree-shake them if necessary.
7 */
8function makeMap(str, expectsLowerCase) {
9 const map = Object.create(null);
10 const list = str.split(',');
11 for (let i = 0; i < list.length; i++) {
12 map[list[i]] = true;
13 }
14 return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
15}
16
17const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
18 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
19 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
20const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
21
22/**
23 * On the client we only need to offer special cases for boolean attributes that
24 * have different names from their corresponding dom properties:
25 * - itemscope -> N/A
26 * - allowfullscreen -> allowFullscreen
27 * - formnovalidate -> formNoValidate
28 * - ismap -> isMap
29 * - nomodule -> noModule
30 * - novalidate -> noValidate
31 * - readonly -> readOnly
32 */
33const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
34const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
35/**
36 * Boolean attributes should be included if the value is truthy or ''.
37 * e.g. <select multiple> compiles to { multiple: '' }
38 */
39function includeBooleanAttr(value) {
40 return !!value || value === '';
41}
42
43function normalizeStyle(value) {
44 if (isArray(value)) {
45 const res = {};
46 for (let i = 0; i < value.length; i++) {
47 const item = value[i];
48 const normalized = isString(item)
49 ? parseStringStyle(item)
50 : normalizeStyle(item);
51 if (normalized) {
52 for (const key in normalized) {
53 res[key] = normalized[key];
54 }
55 }
56 }
57 return res;
58 }
59 else if (isString(value)) {
60 return value;
61 }
62 else if (isObject(value)) {
63 return value;
64 }
65}
66const listDelimiterRE = /;(?![^(]*\))/g;
67const propertyDelimiterRE = /:(.+)/;
68function parseStringStyle(cssText) {
69 const ret = {};
70 cssText.split(listDelimiterRE).forEach(item => {
71 if (item) {
72 const tmp = item.split(propertyDelimiterRE);
73 tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
74 }
75 });
76 return ret;
77}
78function normalizeClass(value) {
79 let res = '';
80 if (isString(value)) {
81 res = value;
82 }
83 else if (isArray(value)) {
84 for (let i = 0; i < value.length; i++) {
85 const normalized = normalizeClass(value[i]);
86 if (normalized) {
87 res += normalized + ' ';
88 }
89 }
90 }
91 else if (isObject(value)) {
92 for (const name in value) {
93 if (value[name]) {
94 res += name + ' ';
95 }
96 }
97 }
98 return res.trim();
99}
100function normalizeProps(props) {
101 if (!props)
102 return null;
103 let { class: klass, style } = props;
104 if (klass && !isString(klass)) {
105 props.class = normalizeClass(klass);
106 }
107 if (style) {
108 props.style = normalizeStyle(style);
109 }
110 return props;
111}
112
113// These tag configs are shared between compiler-dom and runtime-dom, so they
114// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
115const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
116 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
117 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
118 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
119 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
120 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
121 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
122 'option,output,progress,select,textarea,details,dialog,menu,' +
123 'summary,template,blockquote,iframe,tfoot';
124// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
125const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
126 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
127 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
128 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
129 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
130 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
131 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
132 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
133 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
134 'text,textPath,title,tspan,unknown,use,view';
135const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
136const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
137
138function looseCompareArrays(a, b) {
139 if (a.length !== b.length)
140 return false;
141 let equal = true;
142 for (let i = 0; equal && i < a.length; i++) {
143 equal = looseEqual(a[i], b[i]);
144 }
145 return equal;
146}
147function looseEqual(a, b) {
148 if (a === b)
149 return true;
150 let aValidType = isDate(a);
151 let bValidType = isDate(b);
152 if (aValidType || bValidType) {
153 return aValidType && bValidType ? a.getTime() === b.getTime() : false;
154 }
155 aValidType = isArray(a);
156 bValidType = isArray(b);
157 if (aValidType || bValidType) {
158 return aValidType && bValidType ? looseCompareArrays(a, b) : false;
159 }
160 aValidType = isObject(a);
161 bValidType = isObject(b);
162 if (aValidType || bValidType) {
163 /* istanbul ignore if: this if will probably never be called */
164 if (!aValidType || !bValidType) {
165 return false;
166 }
167 const aKeysCount = Object.keys(a).length;
168 const bKeysCount = Object.keys(b).length;
169 if (aKeysCount !== bKeysCount) {
170 return false;
171 }
172 for (const key in a) {
173 const aHasKey = a.hasOwnProperty(key);
174 const bHasKey = b.hasOwnProperty(key);
175 if ((aHasKey && !bHasKey) ||
176 (!aHasKey && bHasKey) ||
177 !looseEqual(a[key], b[key])) {
178 return false;
179 }
180 }
181 }
182 return String(a) === String(b);
183}
184function looseIndexOf(arr, val) {
185 return arr.findIndex(item => looseEqual(item, val));
186}
187
188/**
189 * For converting {{ interpolation }} values to displayed strings.
190 * @private
191 */
192const toDisplayString = (val) => {
193 return val == null
194 ? ''
195 : isArray(val) ||
196 (isObject(val) &&
197 (val.toString === objectToString || !isFunction(val.toString)))
198 ? JSON.stringify(val, replacer, 2)
199 : String(val);
200};
201const replacer = (_key, val) => {
202 // can't use isRef here since @vue/shared has no deps
203 if (val && val.__v_isRef) {
204 return replacer(_key, val.value);
205 }
206 else if (isMap(val)) {
207 return {
208 [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
209 entries[`${key} =>`] = val;
210 return entries;
211 }, {})
212 };
213 }
214 else if (isSet(val)) {
215 return {
216 [`Set(${val.size})`]: [...val.values()]
217 };
218 }
219 else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
220 return String(val);
221 }
222 return val;
223};
224
225const EMPTY_OBJ = Object.freeze({})
226 ;
227const EMPTY_ARR = Object.freeze([]) ;
228const NOOP = () => { };
229/**
230 * Always return false.
231 */
232const NO = () => false;
233const onRE = /^on[^a-z]/;
234const isOn = (key) => onRE.test(key);
235const isModelListener = (key) => key.startsWith('onUpdate:');
236const extend = Object.assign;
237const remove = (arr, el) => {
238 const i = arr.indexOf(el);
239 if (i > -1) {
240 arr.splice(i, 1);
241 }
242};
243const hasOwnProperty = Object.prototype.hasOwnProperty;
244const hasOwn = (val, key) => hasOwnProperty.call(val, key);
245const isArray = Array.isArray;
246const isMap = (val) => toTypeString(val) === '[object Map]';
247const isSet = (val) => toTypeString(val) === '[object Set]';
248const isDate = (val) => val instanceof Date;
249const isFunction = (val) => typeof val === 'function';
250const isString = (val) => typeof val === 'string';
251const isSymbol = (val) => typeof val === 'symbol';
252const isObject = (val) => val !== null && typeof val === 'object';
253const isPromise = (val) => {
254 return isObject(val) && isFunction(val.then) && isFunction(val.catch);
255};
256const objectToString = Object.prototype.toString;
257const toTypeString = (value) => objectToString.call(value);
258const toRawType = (value) => {
259 // extract "RawType" from strings like "[object RawType]"
260 return toTypeString(value).slice(8, -1);
261};
262const isPlainObject = (val) => toTypeString(val) === '[object Object]';
263const isIntegerKey = (key) => isString(key) &&
264 key !== 'NaN' &&
265 key[0] !== '-' &&
266 '' + parseInt(key, 10) === key;
267const isReservedProp = /*#__PURE__*/ makeMap(
268// the leading comma is intentional so empty string "" is also included
269',key,ref,' +
270 'onVnodeBeforeMount,onVnodeMounted,' +
271 'onVnodeBeforeUpdate,onVnodeUpdated,' +
272 'onVnodeBeforeUnmount,onVnodeUnmounted');
273const cacheStringFunction = (fn) => {
274 const cache = Object.create(null);
275 return ((str) => {
276 const hit = cache[str];
277 return hit || (cache[str] = fn(str));
278 });
279};
280const camelizeRE = /-(\w)/g;
281/**
282 * @private
283 */
284const camelize = cacheStringFunction((str) => {
285 return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
286});
287const hyphenateRE = /\B([A-Z])/g;
288/**
289 * @private
290 */
291const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
292/**
293 * @private
294 */
295const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
296/**
297 * @private
298 */
299const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
300// compare whether a value has changed, accounting for NaN.
301const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
302const invokeArrayFns = (fns, arg) => {
303 for (let i = 0; i < fns.length; i++) {
304 fns[i](arg);
305 }
306};
307const def = (obj, key, value) => {
308 Object.defineProperty(obj, key, {
309 configurable: true,
310 enumerable: false,
311 value
312 });
313};
314const toNumber = (val) => {
315 const n = parseFloat(val);
316 return isNaN(n) ? val : n;
317};
318let _globalThis;
319const getGlobalThis = () => {
320 return (_globalThis ||
321 (_globalThis =
322 typeof globalThis !== 'undefined'
323 ? globalThis
324 : typeof self !== 'undefined'
325 ? self
326 : typeof window !== 'undefined'
327 ? window
328 : typeof global !== 'undefined'
329 ? global
330 : {}));
331};
332
333function warn(msg, ...args) {
334 console.warn(`[Vue warn] ${msg}`, ...args);
335}
336
337let activeEffectScope;
338const effectScopeStack = [];
339class EffectScope {
340 constructor(detached = false) {
341 this.active = true;
342 this.effects = [];
343 this.cleanups = [];
344 if (!detached && activeEffectScope) {
345 this.parent = activeEffectScope;
346 this.index =
347 (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
348 }
349 }
350 run(fn) {
351 if (this.active) {
352 try {
353 this.on();
354 return fn();
355 }
356 finally {
357 this.off();
358 }
359 }
360 else {
361 warn(`cannot run an inactive effect scope.`);
362 }
363 }
364 on() {
365 if (this.active) {
366 effectScopeStack.push(this);
367 activeEffectScope = this;
368 }
369 }
370 off() {
371 if (this.active) {
372 effectScopeStack.pop();
373 activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
374 }
375 }
376 stop(fromParent) {
377 if (this.active) {
378 this.effects.forEach(e => e.stop());
379 this.cleanups.forEach(cleanup => cleanup());
380 if (this.scopes) {
381 this.scopes.forEach(e => e.stop(true));
382 }
383 // nested scope, dereference from parent to avoid memory leaks
384 if (this.parent && !fromParent) {
385 // optimized O(1) removal
386 const last = this.parent.scopes.pop();
387 if (last && last !== this) {
388 this.parent.scopes[this.index] = last;
389 last.index = this.index;
390 }
391 }
392 this.active = false;
393 }
394 }
395}
396function effectScope(detached) {
397 return new EffectScope(detached);
398}
399function recordEffectScope(effect, scope) {
400 scope = scope || activeEffectScope;
401 if (scope && scope.active) {
402 scope.effects.push(effect);
403 }
404}
405function getCurrentScope() {
406 return activeEffectScope;
407}
408function onScopeDispose(fn) {
409 if (activeEffectScope) {
410 activeEffectScope.cleanups.push(fn);
411 }
412 else {
413 warn(`onScopeDispose() is called when there is no active effect scope` +
414 ` to be associated with.`);
415 }
416}
417
418const createDep = (effects) => {
419 const dep = new Set(effects);
420 dep.w = 0;
421 dep.n = 0;
422 return dep;
423};
424const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
425const newTracked = (dep) => (dep.n & trackOpBit) > 0;
426const initDepMarkers = ({ deps }) => {
427 if (deps.length) {
428 for (let i = 0; i < deps.length; i++) {
429 deps[i].w |= trackOpBit; // set was tracked
430 }
431 }
432};
433const finalizeDepMarkers = (effect) => {
434 const { deps } = effect;
435 if (deps.length) {
436 let ptr = 0;
437 for (let i = 0; i < deps.length; i++) {
438 const dep = deps[i];
439 if (wasTracked(dep) && !newTracked(dep)) {
440 dep.delete(effect);
441 }
442 else {
443 deps[ptr++] = dep;
444 }
445 // clear bits
446 dep.w &= ~trackOpBit;
447 dep.n &= ~trackOpBit;
448 }
449 deps.length = ptr;
450 }
451};
452
453const targetMap = new WeakMap();
454// The number of effects currently being tracked recursively.
455let effectTrackDepth = 0;
456let trackOpBit = 1;
457/**
458 * The bitwise track markers support at most 30 levels op recursion.
459 * This value is chosen to enable modern JS engines to use a SMI on all platforms.
460 * When recursion depth is greater, fall back to using a full cleanup.
461 */
462const maxMarkerBits = 30;
463const effectStack = [];
464let activeEffect;
465const ITERATE_KEY = Symbol('iterate' );
466const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
467class ReactiveEffect {
468 constructor(fn, scheduler = null, scope) {
469 this.fn = fn;
470 this.scheduler = scheduler;
471 this.active = true;
472 this.deps = [];
473 recordEffectScope(this, scope);
474 }
475 run() {
476 if (!this.active) {
477 return this.fn();
478 }
479 if (!effectStack.includes(this)) {
480 try {
481 effectStack.push((activeEffect = this));
482 enableTracking();
483 trackOpBit = 1 << ++effectTrackDepth;
484 if (effectTrackDepth <= maxMarkerBits) {
485 initDepMarkers(this);
486 }
487 else {
488 cleanupEffect(this);
489 }
490 return this.fn();
491 }
492 finally {
493 if (effectTrackDepth <= maxMarkerBits) {
494 finalizeDepMarkers(this);
495 }
496 trackOpBit = 1 << --effectTrackDepth;
497 resetTracking();
498 effectStack.pop();
499 const n = effectStack.length;
500 activeEffect = n > 0 ? effectStack[n - 1] : undefined;
501 }
502 }
503 }
504 stop() {
505 if (this.active) {
506 cleanupEffect(this);
507 if (this.onStop) {
508 this.onStop();
509 }
510 this.active = false;
511 }
512 }
513}
514function cleanupEffect(effect) {
515 const { deps } = effect;
516 if (deps.length) {
517 for (let i = 0; i < deps.length; i++) {
518 deps[i].delete(effect);
519 }
520 deps.length = 0;
521 }
522}
523function effect(fn, options) {
524 if (fn.effect) {
525 fn = fn.effect.fn;
526 }
527 const _effect = new ReactiveEffect(fn);
528 if (options) {
529 extend(_effect, options);
530 if (options.scope)
531 recordEffectScope(_effect, options.scope);
532 }
533 if (!options || !options.lazy) {
534 _effect.run();
535 }
536 const runner = _effect.run.bind(_effect);
537 runner.effect = _effect;
538 return runner;
539}
540function stop(runner) {
541 runner.effect.stop();
542}
543let shouldTrack = true;
544const trackStack = [];
545function pauseTracking() {
546 trackStack.push(shouldTrack);
547 shouldTrack = false;
548}
549function enableTracking() {
550 trackStack.push(shouldTrack);
551 shouldTrack = true;
552}
553function resetTracking() {
554 const last = trackStack.pop();
555 shouldTrack = last === undefined ? true : last;
556}
557function track(target, type, key) {
558 if (!isTracking()) {
559 return;
560 }
561 let depsMap = targetMap.get(target);
562 if (!depsMap) {
563 targetMap.set(target, (depsMap = new Map()));
564 }
565 let dep = depsMap.get(key);
566 if (!dep) {
567 depsMap.set(key, (dep = createDep()));
568 }
569 const eventInfo = { effect: activeEffect, target, type, key }
570 ;
571 trackEffects(dep, eventInfo);
572}
573function isTracking() {
574 return shouldTrack && activeEffect !== undefined;
575}
576function trackEffects(dep, debuggerEventExtraInfo) {
577 let shouldTrack = false;
578 if (effectTrackDepth <= maxMarkerBits) {
579 if (!newTracked(dep)) {
580 dep.n |= trackOpBit; // set newly tracked
581 shouldTrack = !wasTracked(dep);
582 }
583 }
584 else {
585 // Full cleanup mode.
586 shouldTrack = !dep.has(activeEffect);
587 }
588 if (shouldTrack) {
589 dep.add(activeEffect);
590 activeEffect.deps.push(dep);
591 if (activeEffect.onTrack) {
592 activeEffect.onTrack(Object.assign({
593 effect: activeEffect
594 }, debuggerEventExtraInfo));
595 }
596 }
597}
598function trigger(target, type, key, newValue, oldValue, oldTarget) {
599 const depsMap = targetMap.get(target);
600 if (!depsMap) {
601 // never been tracked
602 return;
603 }
604 let deps = [];
605 if (type === "clear" /* CLEAR */) {
606 // collection being cleared
607 // trigger all effects for target
608 deps = [...depsMap.values()];
609 }
610 else if (key === 'length' && isArray(target)) {
611 depsMap.forEach((dep, key) => {
612 if (key === 'length' || key >= newValue) {
613 deps.push(dep);
614 }
615 });
616 }
617 else {
618 // schedule runs for SET | ADD | DELETE
619 if (key !== void 0) {
620 deps.push(depsMap.get(key));
621 }
622 // also run for iteration key on ADD | DELETE | Map.SET
623 switch (type) {
624 case "add" /* ADD */:
625 if (!isArray(target)) {
626 deps.push(depsMap.get(ITERATE_KEY));
627 if (isMap(target)) {
628 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
629 }
630 }
631 else if (isIntegerKey(key)) {
632 // new index added to array -> length changes
633 deps.push(depsMap.get('length'));
634 }
635 break;
636 case "delete" /* DELETE */:
637 if (!isArray(target)) {
638 deps.push(depsMap.get(ITERATE_KEY));
639 if (isMap(target)) {
640 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
641 }
642 }
643 break;
644 case "set" /* SET */:
645 if (isMap(target)) {
646 deps.push(depsMap.get(ITERATE_KEY));
647 }
648 break;
649 }
650 }
651 const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
652 ;
653 if (deps.length === 1) {
654 if (deps[0]) {
655 {
656 triggerEffects(deps[0], eventInfo);
657 }
658 }
659 }
660 else {
661 const effects = [];
662 for (const dep of deps) {
663 if (dep) {
664 effects.push(...dep);
665 }
666 }
667 {
668 triggerEffects(createDep(effects), eventInfo);
669 }
670 }
671}
672function triggerEffects(dep, debuggerEventExtraInfo) {
673 // spread into array for stabilization
674 for (const effect of isArray(dep) ? dep : [...dep]) {
675 if (effect !== activeEffect || effect.allowRecurse) {
676 if (effect.onTrigger) {
677 effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
678 }
679 if (effect.scheduler) {
680 effect.scheduler();
681 }
682 else {
683 effect.run();
684 }
685 }
686 }
687}
688
689const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
690const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
691 .map(key => Symbol[key])
692 .filter(isSymbol));
693const get = /*#__PURE__*/ createGetter();
694const shallowGet = /*#__PURE__*/ createGetter(false, true);
695const readonlyGet = /*#__PURE__*/ createGetter(true);
696const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
697const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
698function createArrayInstrumentations() {
699 const instrumentations = {};
700 ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
701 instrumentations[key] = function (...args) {
702 const arr = toRaw(this);
703 for (let i = 0, l = this.length; i < l; i++) {
704 track(arr, "get" /* GET */, i + '');
705 }
706 // we run the method using the original args first (which may be reactive)
707 const res = arr[key](...args);
708 if (res === -1 || res === false) {
709 // if that didn't work, run it again using raw values.
710 return arr[key](...args.map(toRaw));
711 }
712 else {
713 return res;
714 }
715 };
716 });
717 ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
718 instrumentations[key] = function (...args) {
719 pauseTracking();
720 const res = toRaw(this)[key].apply(this, args);
721 resetTracking();
722 return res;
723 };
724 });
725 return instrumentations;
726}
727function createGetter(isReadonly = false, shallow = false) {
728 return function get(target, key, receiver) {
729 if (key === "__v_isReactive" /* IS_REACTIVE */) {
730 return !isReadonly;
731 }
732 else if (key === "__v_isReadonly" /* IS_READONLY */) {
733 return isReadonly;
734 }
735 else if (key === "__v_raw" /* RAW */ &&
736 receiver ===
737 (isReadonly
738 ? shallow
739 ? shallowReadonlyMap
740 : readonlyMap
741 : shallow
742 ? shallowReactiveMap
743 : reactiveMap).get(target)) {
744 return target;
745 }
746 const targetIsArray = isArray(target);
747 if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
748 return Reflect.get(arrayInstrumentations, key, receiver);
749 }
750 const res = Reflect.get(target, key, receiver);
751 if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
752 return res;
753 }
754 if (!isReadonly) {
755 track(target, "get" /* GET */, key);
756 }
757 if (shallow) {
758 return res;
759 }
760 if (isRef(res)) {
761 // ref unwrapping - does not apply for Array + integer key.
762 const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
763 return shouldUnwrap ? res.value : res;
764 }
765 if (isObject(res)) {
766 // Convert returned value into a proxy as well. we do the isObject check
767 // here to avoid invalid value warning. Also need to lazy access readonly
768 // and reactive here to avoid circular dependency.
769 return isReadonly ? readonly(res) : reactive(res);
770 }
771 return res;
772 };
773}
774const set = /*#__PURE__*/ createSetter();
775const shallowSet = /*#__PURE__*/ createSetter(true);
776function createSetter(shallow = false) {
777 return function set(target, key, value, receiver) {
778 let oldValue = target[key];
779 if (!shallow) {
780 value = toRaw(value);
781 oldValue = toRaw(oldValue);
782 if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
783 oldValue.value = value;
784 return true;
785 }
786 }
787 const hadKey = isArray(target) && isIntegerKey(key)
788 ? Number(key) < target.length
789 : hasOwn(target, key);
790 const result = Reflect.set(target, key, value, receiver);
791 // don't trigger if target is something up in the prototype chain of original
792 if (target === toRaw(receiver)) {
793 if (!hadKey) {
794 trigger(target, "add" /* ADD */, key, value);
795 }
796 else if (hasChanged(value, oldValue)) {
797 trigger(target, "set" /* SET */, key, value, oldValue);
798 }
799 }
800 return result;
801 };
802}
803function deleteProperty(target, key) {
804 const hadKey = hasOwn(target, key);
805 const oldValue = target[key];
806 const result = Reflect.deleteProperty(target, key);
807 if (result && hadKey) {
808 trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
809 }
810 return result;
811}
812function has(target, key) {
813 const result = Reflect.has(target, key);
814 if (!isSymbol(key) || !builtInSymbols.has(key)) {
815 track(target, "has" /* HAS */, key);
816 }
817 return result;
818}
819function ownKeys(target) {
820 track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
821 return Reflect.ownKeys(target);
822}
823const mutableHandlers = {
824 get,
825 set,
826 deleteProperty,
827 has,
828 ownKeys
829};
830const readonlyHandlers = {
831 get: readonlyGet,
832 set(target, key) {
833 {
834 console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
835 }
836 return true;
837 },
838 deleteProperty(target, key) {
839 {
840 console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
841 }
842 return true;
843 }
844};
845const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
846 get: shallowGet,
847 set: shallowSet
848});
849// Props handlers are special in the sense that it should not unwrap top-level
850// refs (in order to allow refs to be explicitly passed down), but should
851// retain the reactivity of the normal readonly object.
852const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
853 get: shallowReadonlyGet
854});
855
856const toReactive = (value) => isObject(value) ? reactive(value) : value;
857const toReadonly = (value) => isObject(value) ? readonly(value) : value;
858const toShallow = (value) => value;
859const getProto = (v) => Reflect.getPrototypeOf(v);
860function get$1(target, key, isReadonly = false, isShallow = false) {
861 // #1772: readonly(reactive(Map)) should return readonly + reactive version
862 // of the value
863 target = target["__v_raw" /* RAW */];
864 const rawTarget = toRaw(target);
865 const rawKey = toRaw(key);
866 if (key !== rawKey) {
867 !isReadonly && track(rawTarget, "get" /* GET */, key);
868 }
869 !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
870 const { has } = getProto(rawTarget);
871 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
872 if (has.call(rawTarget, key)) {
873 return wrap(target.get(key));
874 }
875 else if (has.call(rawTarget, rawKey)) {
876 return wrap(target.get(rawKey));
877 }
878 else if (target !== rawTarget) {
879 // #3602 readonly(reactive(Map))
880 // ensure that the nested reactive `Map` can do tracking for itself
881 target.get(key);
882 }
883}
884function has$1(key, isReadonly = false) {
885 const target = this["__v_raw" /* RAW */];
886 const rawTarget = toRaw(target);
887 const rawKey = toRaw(key);
888 if (key !== rawKey) {
889 !isReadonly && track(rawTarget, "has" /* HAS */, key);
890 }
891 !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
892 return key === rawKey
893 ? target.has(key)
894 : target.has(key) || target.has(rawKey);
895}
896function size(target, isReadonly = false) {
897 target = target["__v_raw" /* RAW */];
898 !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY);
899 return Reflect.get(target, 'size', target);
900}
901function add(value) {
902 value = toRaw(value);
903 const target = toRaw(this);
904 const proto = getProto(target);
905 const hadKey = proto.has.call(target, value);
906 if (!hadKey) {
907 target.add(value);
908 trigger(target, "add" /* ADD */, value, value);
909 }
910 return this;
911}
912function set$1(key, value) {
913 value = toRaw(value);
914 const target = toRaw(this);
915 const { has, get } = getProto(target);
916 let hadKey = has.call(target, key);
917 if (!hadKey) {
918 key = toRaw(key);
919 hadKey = has.call(target, key);
920 }
921 else {
922 checkIdentityKeys(target, has, key);
923 }
924 const oldValue = get.call(target, key);
925 target.set(key, value);
926 if (!hadKey) {
927 trigger(target, "add" /* ADD */, key, value);
928 }
929 else if (hasChanged(value, oldValue)) {
930 trigger(target, "set" /* SET */, key, value, oldValue);
931 }
932 return this;
933}
934function deleteEntry(key) {
935 const target = toRaw(this);
936 const { has, get } = getProto(target);
937 let hadKey = has.call(target, key);
938 if (!hadKey) {
939 key = toRaw(key);
940 hadKey = has.call(target, key);
941 }
942 else {
943 checkIdentityKeys(target, has, key);
944 }
945 const oldValue = get ? get.call(target, key) : undefined;
946 // forward the operation before queueing reactions
947 const result = target.delete(key);
948 if (hadKey) {
949 trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
950 }
951 return result;
952}
953function clear() {
954 const target = toRaw(this);
955 const hadItems = target.size !== 0;
956 const oldTarget = isMap(target)
957 ? new Map(target)
958 : new Set(target)
959 ;
960 // forward the operation before queueing reactions
961 const result = target.clear();
962 if (hadItems) {
963 trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
964 }
965 return result;
966}
967function createForEach(isReadonly, isShallow) {
968 return function forEach(callback, thisArg) {
969 const observed = this;
970 const target = observed["__v_raw" /* RAW */];
971 const rawTarget = toRaw(target);
972 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
973 !isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);
974 return target.forEach((value, key) => {
975 // important: make sure the callback is
976 // 1. invoked with the reactive map as `this` and 3rd arg
977 // 2. the value received should be a corresponding reactive/readonly.
978 return callback.call(thisArg, wrap(value), wrap(key), observed);
979 });
980 };
981}
982function createIterableMethod(method, isReadonly, isShallow) {
983 return function (...args) {
984 const target = this["__v_raw" /* RAW */];
985 const rawTarget = toRaw(target);
986 const targetIsMap = isMap(rawTarget);
987 const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
988 const isKeyOnly = method === 'keys' && targetIsMap;
989 const innerIterator = target[method](...args);
990 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
991 !isReadonly &&
992 track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
993 // return a wrapped iterator which returns observed versions of the
994 // values emitted from the real iterator
995 return {
996 // iterator protocol
997 next() {
998 const { value, done } = innerIterator.next();
999 return done
1000 ? { value, done }
1001 : {
1002 value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1003 done
1004 };
1005 },
1006 // iterable protocol
1007 [Symbol.iterator]() {
1008 return this;
1009 }
1010 };
1011 };
1012}
1013function createReadonlyMethod(type) {
1014 return function (...args) {
1015 {
1016 const key = args[0] ? `on key "${args[0]}" ` : ``;
1017 console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
1018 }
1019 return type === "delete" /* DELETE */ ? false : this;
1020 };
1021}
1022function createInstrumentations() {
1023 const mutableInstrumentations = {
1024 get(key) {
1025 return get$1(this, key);
1026 },
1027 get size() {
1028 return size(this);
1029 },
1030 has: has$1,
1031 add,
1032 set: set$1,
1033 delete: deleteEntry,
1034 clear,
1035 forEach: createForEach(false, false)
1036 };
1037 const shallowInstrumentations = {
1038 get(key) {
1039 return get$1(this, key, false, true);
1040 },
1041 get size() {
1042 return size(this);
1043 },
1044 has: has$1,
1045 add,
1046 set: set$1,
1047 delete: deleteEntry,
1048 clear,
1049 forEach: createForEach(false, true)
1050 };
1051 const readonlyInstrumentations = {
1052 get(key) {
1053 return get$1(this, key, true);
1054 },
1055 get size() {
1056 return size(this, true);
1057 },
1058 has(key) {
1059 return has$1.call(this, key, true);
1060 },
1061 add: createReadonlyMethod("add" /* ADD */),
1062 set: createReadonlyMethod("set" /* SET */),
1063 delete: createReadonlyMethod("delete" /* DELETE */),
1064 clear: createReadonlyMethod("clear" /* CLEAR */),
1065 forEach: createForEach(true, false)
1066 };
1067 const shallowReadonlyInstrumentations = {
1068 get(key) {
1069 return get$1(this, key, true, true);
1070 },
1071 get size() {
1072 return size(this, true);
1073 },
1074 has(key) {
1075 return has$1.call(this, key, true);
1076 },
1077 add: createReadonlyMethod("add" /* ADD */),
1078 set: createReadonlyMethod("set" /* SET */),
1079 delete: createReadonlyMethod("delete" /* DELETE */),
1080 clear: createReadonlyMethod("clear" /* CLEAR */),
1081 forEach: createForEach(true, true)
1082 };
1083 const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
1084 iteratorMethods.forEach(method => {
1085 mutableInstrumentations[method] = createIterableMethod(method, false, false);
1086 readonlyInstrumentations[method] = createIterableMethod(method, true, false);
1087 shallowInstrumentations[method] = createIterableMethod(method, false, true);
1088 shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
1089 });
1090 return [
1091 mutableInstrumentations,
1092 readonlyInstrumentations,
1093 shallowInstrumentations,
1094 shallowReadonlyInstrumentations
1095 ];
1096}
1097const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
1098function createInstrumentationGetter(isReadonly, shallow) {
1099 const instrumentations = shallow
1100 ? isReadonly
1101 ? shallowReadonlyInstrumentations
1102 : shallowInstrumentations
1103 : isReadonly
1104 ? readonlyInstrumentations
1105 : mutableInstrumentations;
1106 return (target, key, receiver) => {
1107 if (key === "__v_isReactive" /* IS_REACTIVE */) {
1108 return !isReadonly;
1109 }
1110 else if (key === "__v_isReadonly" /* IS_READONLY */) {
1111 return isReadonly;
1112 }
1113 else if (key === "__v_raw" /* RAW */) {
1114 return target;
1115 }
1116 return Reflect.get(hasOwn(instrumentations, key) && key in target
1117 ? instrumentations
1118 : target, key, receiver);
1119 };
1120}
1121const mutableCollectionHandlers = {
1122 get: /*#__PURE__*/ createInstrumentationGetter(false, false)
1123};
1124const shallowCollectionHandlers = {
1125 get: /*#__PURE__*/ createInstrumentationGetter(false, true)
1126};
1127const readonlyCollectionHandlers = {
1128 get: /*#__PURE__*/ createInstrumentationGetter(true, false)
1129};
1130const shallowReadonlyCollectionHandlers = {
1131 get: /*#__PURE__*/ createInstrumentationGetter(true, true)
1132};
1133function checkIdentityKeys(target, has, key) {
1134 const rawKey = toRaw(key);
1135 if (rawKey !== key && has.call(target, rawKey)) {
1136 const type = toRawType(target);
1137 console.warn(`Reactive ${type} contains both the raw and reactive ` +
1138 `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
1139 `which can lead to inconsistencies. ` +
1140 `Avoid differentiating between the raw and reactive versions ` +
1141 `of an object and only use the reactive version if possible.`);
1142 }
1143}
1144
1145const reactiveMap = new WeakMap();
1146const shallowReactiveMap = new WeakMap();
1147const readonlyMap = new WeakMap();
1148const shallowReadonlyMap = new WeakMap();
1149function targetTypeMap(rawType) {
1150 switch (rawType) {
1151 case 'Object':
1152 case 'Array':
1153 return 1 /* COMMON */;
1154 case 'Map':
1155 case 'Set':
1156 case 'WeakMap':
1157 case 'WeakSet':
1158 return 2 /* COLLECTION */;
1159 default:
1160 return 0 /* INVALID */;
1161 }
1162}
1163function getTargetType(value) {
1164 return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)
1165 ? 0 /* INVALID */
1166 : targetTypeMap(toRawType(value));
1167}
1168function reactive(target) {
1169 // if trying to observe a readonly proxy, return the readonly version.
1170 if (target && target["__v_isReadonly" /* IS_READONLY */]) {
1171 return target;
1172 }
1173 return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1174}
1175/**
1176 * Return a shallowly-reactive copy of the original object, where only the root
1177 * level properties are reactive. It also does not auto-unwrap refs (even at the
1178 * root level).
1179 */
1180function shallowReactive(target) {
1181 return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
1182}
1183/**
1184 * Creates a readonly copy of the original object. Note the returned copy is not
1185 * made reactive, but `readonly` can be called on an already reactive object.
1186 */
1187function readonly(target) {
1188 return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1189}
1190/**
1191 * Returns a reactive-copy of the original object, where only the root level
1192 * properties are readonly, and does NOT unwrap refs nor recursively convert
1193 * returned properties.
1194 * This is used for creating the props proxy object for stateful components.
1195 */
1196function shallowReadonly(target) {
1197 return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1198}
1199function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
1200 if (!isObject(target)) {
1201 {
1202 console.warn(`value cannot be made reactive: ${String(target)}`);
1203 }
1204 return target;
1205 }
1206 // target is already a Proxy, return it.
1207 // exception: calling readonly() on a reactive object
1208 if (target["__v_raw" /* RAW */] &&
1209 !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
1210 return target;
1211 }
1212 // target already has corresponding Proxy
1213 const existingProxy = proxyMap.get(target);
1214 if (existingProxy) {
1215 return existingProxy;
1216 }
1217 // only a whitelist of value types can be observed.
1218 const targetType = getTargetType(target);
1219 if (targetType === 0 /* INVALID */) {
1220 return target;
1221 }
1222 const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);
1223 proxyMap.set(target, proxy);
1224 return proxy;
1225}
1226function isReactive(value) {
1227 if (isReadonly(value)) {
1228 return isReactive(value["__v_raw" /* RAW */]);
1229 }
1230 return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
1231}
1232function isReadonly(value) {
1233 return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
1234}
1235function isProxy(value) {
1236 return isReactive(value) || isReadonly(value);
1237}
1238function toRaw(observed) {
1239 const raw = observed && observed["__v_raw" /* RAW */];
1240 return raw ? toRaw(raw) : observed;
1241}
1242function markRaw(value) {
1243 def(value, "__v_skip" /* SKIP */, true);
1244 return value;
1245}
1246
1247function trackRefValue(ref) {
1248 if (isTracking()) {
1249 ref = toRaw(ref);
1250 if (!ref.dep) {
1251 ref.dep = createDep();
1252 }
1253 {
1254 trackEffects(ref.dep, {
1255 target: ref,
1256 type: "get" /* GET */,
1257 key: 'value'
1258 });
1259 }
1260 }
1261}
1262function triggerRefValue(ref, newVal) {
1263 ref = toRaw(ref);
1264 if (ref.dep) {
1265 {
1266 triggerEffects(ref.dep, {
1267 target: ref,
1268 type: "set" /* SET */,
1269 key: 'value',
1270 newValue: newVal
1271 });
1272 }
1273 }
1274}
1275const convert = (val) => isObject(val) ? reactive(val) : val;
1276function isRef(r) {
1277 return Boolean(r && r.__v_isRef === true);
1278}
1279function ref(value) {
1280 return createRef(value, false);
1281}
1282function shallowRef(value) {
1283 return createRef(value, true);
1284}
1285class RefImpl {
1286 constructor(value, _shallow) {
1287 this._shallow = _shallow;
1288 this.dep = undefined;
1289 this.__v_isRef = true;
1290 this._rawValue = _shallow ? value : toRaw(value);
1291 this._value = _shallow ? value : convert(value);
1292 }
1293 get value() {
1294 trackRefValue(this);
1295 return this._value;
1296 }
1297 set value(newVal) {
1298 newVal = this._shallow ? newVal : toRaw(newVal);
1299 if (hasChanged(newVal, this._rawValue)) {
1300 this._rawValue = newVal;
1301 this._value = this._shallow ? newVal : convert(newVal);
1302 triggerRefValue(this, newVal);
1303 }
1304 }
1305}
1306function createRef(rawValue, shallow) {
1307 if (isRef(rawValue)) {
1308 return rawValue;
1309 }
1310 return new RefImpl(rawValue, shallow);
1311}
1312function triggerRef(ref) {
1313 triggerRefValue(ref, ref.value );
1314}
1315function unref(ref) {
1316 return isRef(ref) ? ref.value : ref;
1317}
1318const shallowUnwrapHandlers = {
1319 get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
1320 set: (target, key, value, receiver) => {
1321 const oldValue = target[key];
1322 if (isRef(oldValue) && !isRef(value)) {
1323 oldValue.value = value;
1324 return true;
1325 }
1326 else {
1327 return Reflect.set(target, key, value, receiver);
1328 }
1329 }
1330};
1331function proxyRefs(objectWithRefs) {
1332 return isReactive(objectWithRefs)
1333 ? objectWithRefs
1334 : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1335}
1336class CustomRefImpl {
1337 constructor(factory) {
1338 this.dep = undefined;
1339 this.__v_isRef = true;
1340 const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
1341 this._get = get;
1342 this._set = set;
1343 }
1344 get value() {
1345 return this._get();
1346 }
1347 set value(newVal) {
1348 this._set(newVal);
1349 }
1350}
1351function customRef(factory) {
1352 return new CustomRefImpl(factory);
1353}
1354function toRefs(object) {
1355 if (!isProxy(object)) {
1356 console.warn(`toRefs() expects a reactive object but received a plain one.`);
1357 }
1358 const ret = isArray(object) ? new Array(object.length) : {};
1359 for (const key in object) {
1360 ret[key] = toRef(object, key);
1361 }
1362 return ret;
1363}
1364class ObjectRefImpl {
1365 constructor(_object, _key) {
1366 this._object = _object;
1367 this._key = _key;
1368 this.__v_isRef = true;
1369 }
1370 get value() {
1371 return this._object[this._key];
1372 }
1373 set value(newVal) {
1374 this._object[this._key] = newVal;
1375 }
1376}
1377function toRef(object, key) {
1378 const val = object[key];
1379 return isRef(val) ? val : new ObjectRefImpl(object, key);
1380}
1381
1382class ComputedRefImpl {
1383 constructor(getter, _setter, isReadonly) {
1384 this._setter = _setter;
1385 this.dep = undefined;
1386 this._dirty = true;
1387 this.__v_isRef = true;
1388 this.effect = new ReactiveEffect(getter, () => {
1389 if (!this._dirty) {
1390 this._dirty = true;
1391 triggerRefValue(this);
1392 }
1393 });
1394 this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
1395 }
1396 get value() {
1397 // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1398 const self = toRaw(this);
1399 trackRefValue(self);
1400 if (self._dirty) {
1401 self._dirty = false;
1402 self._value = self.effect.run();
1403 }
1404 return self._value;
1405 }
1406 set value(newValue) {
1407 this._setter(newValue);
1408 }
1409}
1410function computed(getterOrOptions, debugOptions) {
1411 let getter;
1412 let setter;
1413 if (isFunction(getterOrOptions)) {
1414 getter = getterOrOptions;
1415 setter = () => {
1416 console.warn('Write operation failed: computed value is readonly');
1417 }
1418 ;
1419 }
1420 else {
1421 getter = getterOrOptions.get;
1422 setter = getterOrOptions.set;
1423 }
1424 const cRef = new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
1425 if (debugOptions) {
1426 cRef.effect.onTrack = debugOptions.onTrack;
1427 cRef.effect.onTrigger = debugOptions.onTrigger;
1428 }
1429 return cRef;
1430}
1431
1432/* eslint-disable no-restricted-globals */
1433let isHmrUpdating = false;
1434const hmrDirtyComponents = new Set();
1435// Expose the HMR runtime on the global object
1436// This makes it entirely tree-shakable without polluting the exports and makes
1437// it easier to be used in toolings like vue-loader
1438// Note: for a component to be eligible for HMR it also needs the __hmrId option
1439// to be set so that its instances can be registered / removed.
1440{
1441 const globalObject = typeof global !== 'undefined'
1442 ? global
1443 : typeof self !== 'undefined'
1444 ? self
1445 : typeof window !== 'undefined'
1446 ? window
1447 : {};
1448 globalObject.__VUE_HMR_RUNTIME__ = {
1449 createRecord: tryWrap(createRecord),
1450 rerender: tryWrap(rerender),
1451 reload: tryWrap(reload)
1452 };
1453}
1454const map = new Map();
1455function registerHMR(instance) {
1456 const id = instance.type.__hmrId;
1457 let record = map.get(id);
1458 if (!record) {
1459 createRecord(id, instance.type);
1460 record = map.get(id);
1461 }
1462 record.instances.add(instance);
1463}
1464function unregisterHMR(instance) {
1465 map.get(instance.type.__hmrId).instances.delete(instance);
1466}
1467function createRecord(id, component) {
1468 if (!component) {
1469 warn$1(`HMR API usage is out of date.\n` +
1470 `Please upgrade vue-loader/vite/rollup-plugin-vue or other relevant ` +
1471 `dependency that handles Vue SFC compilation.`);
1472 component = {};
1473 }
1474 if (map.has(id)) {
1475 return false;
1476 }
1477 map.set(id, {
1478 component: isClassComponent(component) ? component.__vccOpts : component,
1479 instances: new Set()
1480 });
1481 return true;
1482}
1483function rerender(id, newRender) {
1484 const record = map.get(id);
1485 if (!record)
1486 return;
1487 if (newRender)
1488 record.component.render = newRender;
1489 // Array.from creates a snapshot which avoids the set being mutated during
1490 // updates
1491 Array.from(record.instances).forEach(instance => {
1492 if (newRender) {
1493 instance.render = newRender;
1494 }
1495 instance.renderCache = [];
1496 // this flag forces child components with slot content to update
1497 isHmrUpdating = true;
1498 instance.update();
1499 isHmrUpdating = false;
1500 });
1501}
1502function reload(id, newComp) {
1503 const record = map.get(id);
1504 if (!record)
1505 return;
1506 // Array.from creates a snapshot which avoids the set being mutated during
1507 // updates
1508 const { component, instances } = record;
1509 if (!hmrDirtyComponents.has(component)) {
1510 // 1. Update existing comp definition to match new one
1511 newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp;
1512 extend(component, newComp);
1513 for (const key in component) {
1514 if (key !== '__file' && !(key in newComp)) {
1515 delete component[key];
1516 }
1517 }
1518 // 2. Mark component dirty. This forces the renderer to replace the component
1519 // on patch.
1520 hmrDirtyComponents.add(component);
1521 // 3. Make sure to unmark the component after the reload.
1522 queuePostFlushCb(() => {
1523 hmrDirtyComponents.delete(component);
1524 });
1525 }
1526 Array.from(instances).forEach(instance => {
1527 // invalidate options resolution cache
1528 instance.appContext.optionsCache.delete(instance.type);
1529 if (instance.ceReload) {
1530 // custom element
1531 hmrDirtyComponents.add(component);
1532 instance.ceReload(newComp.styles);
1533 hmrDirtyComponents.delete(component);
1534 }
1535 else if (instance.parent) {
1536 // 4. Force the parent instance to re-render. This will cause all updated
1537 // components to be unmounted and re-mounted. Queue the update so that we
1538 // don't end up forcing the same parent to re-render multiple times.
1539 queueJob(instance.parent.update);
1540 // instance is the inner component of an async custom element
1541 // invoke to reset styles
1542 if (instance.parent.type.__asyncLoader &&
1543 instance.parent.ceReload) {
1544 instance.parent.ceReload(newComp.styles);
1545 }
1546 }
1547 else if (instance.appContext.reload) {
1548 // root instance mounted via createApp() has a reload method
1549 instance.appContext.reload();
1550 }
1551 else if (typeof window !== 'undefined') {
1552 // root instance inside tree created via raw render(). Force reload.
1553 window.location.reload();
1554 }
1555 else {
1556 console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
1557 }
1558 });
1559}
1560function tryWrap(fn) {
1561 return (id, arg) => {
1562 try {
1563 return fn(id, arg);
1564 }
1565 catch (e) {
1566 console.error(e);
1567 console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
1568 `Full reload required.`);
1569 }
1570 };
1571}
1572
1573let devtools;
1574function setDevtoolsHook(hook) {
1575 devtools = hook;
1576}
1577function devtoolsInitApp(app, version) {
1578 // TODO queue if devtools is undefined
1579 if (!devtools)
1580 return;
1581 devtools.emit("app:init" /* APP_INIT */, app, version, {
1582 Fragment,
1583 Text,
1584 Comment,
1585 Static
1586 });
1587}
1588function devtoolsUnmountApp(app) {
1589 if (!devtools)
1590 return;
1591 devtools.emit("app:unmount" /* APP_UNMOUNT */, app);
1592}
1593const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
1594const devtoolsComponentUpdated =
1595/*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
1596const devtoolsComponentRemoved =
1597/*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
1598function createDevtoolsComponentHook(hook) {
1599 return (component) => {
1600 if (!devtools)
1601 return;
1602 devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
1603 };
1604}
1605const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
1606const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
1607function createDevtoolsPerformanceHook(hook) {
1608 return (component, type, time) => {
1609 if (!devtools)
1610 return;
1611 devtools.emit(hook, component.appContext.app, component.uid, component, type, time);
1612 };
1613}
1614function devtoolsComponentEmit(component, event, params) {
1615 if (!devtools)
1616 return;
1617 devtools.emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
1618}
1619
1620const deprecationData = {
1621 ["GLOBAL_MOUNT" /* GLOBAL_MOUNT */]: {
1622 message: `The global app bootstrapping API has changed: vm.$mount() and the "el" ` +
1623 `option have been removed. Use createApp(RootComponent).mount() instead.`,
1624 link: `https://v3.vuejs.org/guide/migration/global-api.html#mounting-app-instance`
1625 },
1626 ["GLOBAL_MOUNT_CONTAINER" /* GLOBAL_MOUNT_CONTAINER */]: {
1627 message: `Vue detected directives on the mount container. ` +
1628 `In Vue 3, the container is no longer considered part of the template ` +
1629 `and will not be processed/replaced.`,
1630 link: `https://v3.vuejs.org/guide/migration/mount-changes.html`
1631 },
1632 ["GLOBAL_EXTEND" /* GLOBAL_EXTEND */]: {
1633 message: `Vue.extend() has been removed in Vue 3. ` +
1634 `Use defineComponent() instead.`,
1635 link: `https://v3.vuejs.org/api/global-api.html#definecomponent`
1636 },
1637 ["GLOBAL_PROTOTYPE" /* GLOBAL_PROTOTYPE */]: {
1638 message: `Vue.prototype is no longer available in Vue 3. ` +
1639 `Use app.config.globalProperties instead.`,
1640 link: `https://v3.vuejs.org/guide/migration/global-api.html#vue-prototype-replaced-by-config-globalproperties`
1641 },
1642 ["GLOBAL_SET" /* GLOBAL_SET */]: {
1643 message: `Vue.set() has been removed as it is no longer needed in Vue 3. ` +
1644 `Simply use native JavaScript mutations.`
1645 },
1646 ["GLOBAL_DELETE" /* GLOBAL_DELETE */]: {
1647 message: `Vue.delete() has been removed as it is no longer needed in Vue 3. ` +
1648 `Simply use native JavaScript mutations.`
1649 },
1650 ["GLOBAL_OBSERVABLE" /* GLOBAL_OBSERVABLE */]: {
1651 message: `Vue.observable() has been removed. ` +
1652 `Use \`import { reactive } from "vue"\` from Composition API instead.`,
1653 link: `https://v3.vuejs.org/api/basic-reactivity.html`
1654 },
1655 ["GLOBAL_PRIVATE_UTIL" /* GLOBAL_PRIVATE_UTIL */]: {
1656 message: `Vue.util has been removed. Please refactor to avoid its usage ` +
1657 `since it was an internal API even in Vue 2.`
1658 },
1659 ["CONFIG_SILENT" /* CONFIG_SILENT */]: {
1660 message: `config.silent has been removed because it is not good practice to ` +
1661 `intentionally suppress warnings. You can use your browser console's ` +
1662 `filter features to focus on relevant messages.`
1663 },
1664 ["CONFIG_DEVTOOLS" /* CONFIG_DEVTOOLS */]: {
1665 message: `config.devtools has been removed. To enable devtools for ` +
1666 `production, configure the __VUE_PROD_DEVTOOLS__ compile-time flag.`,
1667 link: `https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags`
1668 },
1669 ["CONFIG_KEY_CODES" /* CONFIG_KEY_CODES */]: {
1670 message: `config.keyCodes has been removed. ` +
1671 `In Vue 3, you can directly use the kebab-case key names as v-on modifiers.`,
1672 link: `https://v3.vuejs.org/guide/migration/keycode-modifiers.html`
1673 },
1674 ["CONFIG_PRODUCTION_TIP" /* CONFIG_PRODUCTION_TIP */]: {
1675 message: `config.productionTip has been removed.`,
1676 link: `https://v3.vuejs.org/guide/migration/global-api.html#config-productiontip-removed`
1677 },
1678 ["CONFIG_IGNORED_ELEMENTS" /* CONFIG_IGNORED_ELEMENTS */]: {
1679 message: () => {
1680 let msg = `config.ignoredElements has been removed.`;
1681 if (isRuntimeOnly()) {
1682 msg += ` Pass the "isCustomElement" option to @vue/compiler-dom instead.`;
1683 }
1684 else {
1685 msg += ` Use config.isCustomElement instead.`;
1686 }
1687 return msg;
1688 },
1689 link: `https://v3.vuejs.org/guide/migration/global-api.html#config-ignoredelements-is-now-config-iscustomelement`
1690 },
1691 ["CONFIG_WHITESPACE" /* CONFIG_WHITESPACE */]: {
1692 // this warning is only relevant in the full build when using runtime
1693 // compilation, so it's put in the runtime compatConfig list.
1694 message: `Vue 3 compiler's whitespace option will default to "condense" instead of ` +
1695 `"preserve". To suppress this warning, provide an explicit value for ` +
1696 `\`config.compilerOptions.whitespace\`.`
1697 },
1698 ["CONFIG_OPTION_MERGE_STRATS" /* CONFIG_OPTION_MERGE_STRATS */]: {
1699 message: `config.optionMergeStrategies no longer exposes internal strategies. ` +
1700 `Use custom merge functions instead.`
1701 },
1702 ["INSTANCE_SET" /* INSTANCE_SET */]: {
1703 message: `vm.$set() has been removed as it is no longer needed in Vue 3. ` +
1704 `Simply use native JavaScript mutations.`
1705 },
1706 ["INSTANCE_DELETE" /* INSTANCE_DELETE */]: {
1707 message: `vm.$delete() has been removed as it is no longer needed in Vue 3. ` +
1708 `Simply use native JavaScript mutations.`
1709 },
1710 ["INSTANCE_DESTROY" /* INSTANCE_DESTROY */]: {
1711 message: `vm.$destroy() has been removed. Use app.unmount() instead.`,
1712 link: `https://v3.vuejs.org/api/application-api.html#unmount`
1713 },
1714 ["INSTANCE_EVENT_EMITTER" /* INSTANCE_EVENT_EMITTER */]: {
1715 message: `vm.$on/$once/$off() have been removed. ` +
1716 `Use an external event emitter library instead.`,
1717 link: `https://v3.vuejs.org/guide/migration/events-api.html`
1718 },
1719 ["INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */]: {
1720 message: event => `"${event}" lifecycle events are no longer supported. From templates, ` +
1721 `use the "vnode" prefix instead of "hook:". For example, @${event} ` +
1722 `should be changed to @vnode-${event.slice(5)}. ` +
1723 `From JavaScript, use Composition API to dynamically register lifecycle ` +
1724 `hooks.`,
1725 link: `https://v3.vuejs.org/guide/migration/vnode-lifecycle-events.html`
1726 },
1727 ["INSTANCE_CHILDREN" /* INSTANCE_CHILDREN */]: {
1728 message: `vm.$children has been removed. Consider refactoring your logic ` +
1729 `to avoid relying on direct access to child components.`,
1730 link: `https://v3.vuejs.org/guide/migration/children.html`
1731 },
1732 ["INSTANCE_LISTENERS" /* INSTANCE_LISTENERS */]: {
1733 message: `vm.$listeners has been removed. In Vue 3, parent v-on listeners are ` +
1734 `included in vm.$attrs and it is no longer necessary to separately use ` +
1735 `v-on="$listeners" if you are already using v-bind="$attrs". ` +
1736 `(Note: the Vue 3 behavior only applies if this compat config is disabled)`,
1737 link: `https://v3.vuejs.org/guide/migration/listeners-removed.html`
1738 },
1739 ["INSTANCE_SCOPED_SLOTS" /* INSTANCE_SCOPED_SLOTS */]: {
1740 message: `vm.$scopedSlots has been removed. Use vm.$slots instead.`,
1741 link: `https://v3.vuejs.org/guide/migration/slots-unification.html`
1742 },
1743 ["INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */]: {
1744 message: componentName => `Component <${componentName || 'Anonymous'}> has \`inheritAttrs: false\` but is ` +
1745 `relying on class/style fallthrough from parent. In Vue 3, class/style ` +
1746 `are now included in $attrs and will no longer fallthrough when ` +
1747 `inheritAttrs is false. If you are already using v-bind="$attrs" on ` +
1748 `component root it should render the same end result. ` +
1749 `If you are binding $attrs to a non-root element and expecting ` +
1750 `class/style to fallthrough on root, you will need to now manually bind ` +
1751 `them on root via :class="$attrs.class".`,
1752 link: `https://v3.vuejs.org/guide/migration/attrs-includes-class-style.html`
1753 },
1754 ["OPTIONS_DATA_FN" /* OPTIONS_DATA_FN */]: {
1755 message: `The "data" option can no longer be a plain object. ` +
1756 `Always use a function.`,
1757 link: `https://v3.vuejs.org/guide/migration/data-option.html`
1758 },
1759 ["OPTIONS_DATA_MERGE" /* OPTIONS_DATA_MERGE */]: {
1760 message: (key) => `Detected conflicting key "${key}" when merging data option values. ` +
1761 `In Vue 3, data keys are merged shallowly and will override one another.`,
1762 link: `https://v3.vuejs.org/guide/migration/data-option.html#mixin-merge-behavior-change`
1763 },
1764 ["OPTIONS_BEFORE_DESTROY" /* OPTIONS_BEFORE_DESTROY */]: {
1765 message: `\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`
1766 },
1767 ["OPTIONS_DESTROYED" /* OPTIONS_DESTROYED */]: {
1768 message: `\`destroyed\` has been renamed to \`unmounted\`.`
1769 },
1770 ["WATCH_ARRAY" /* WATCH_ARRAY */]: {
1771 message: `"watch" option or vm.$watch on an array value will no longer ` +
1772 `trigger on array mutation unless the "deep" option is specified. ` +
1773 `If current usage is intended, you can disable the compat behavior and ` +
1774 `suppress this warning with:` +
1775 `\n\n configureCompat({ ${"WATCH_ARRAY" /* WATCH_ARRAY */}: false })\n`,
1776 link: `https://v3.vuejs.org/guide/migration/watch.html`
1777 },
1778 ["PROPS_DEFAULT_THIS" /* PROPS_DEFAULT_THIS */]: {
1779 message: (key) => `props default value function no longer has access to "this". The compat ` +
1780 `build only offers access to this.$options.` +
1781 `(found in prop "${key}")`,
1782 link: `https://v3.vuejs.org/guide/migration/props-default-this.html`
1783 },
1784 ["CUSTOM_DIR" /* CUSTOM_DIR */]: {
1785 message: (legacyHook, newHook) => `Custom directive hook "${legacyHook}" has been removed. ` +
1786 `Use "${newHook}" instead.`,
1787 link: `https://v3.vuejs.org/guide/migration/custom-directives.html`
1788 },
1789 ["V_FOR_REF" /* V_FOR_REF */]: {
1790 message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
1791 `Consider using function refs or refactor to avoid ref usage altogether.`,
1792 link: `https://v3.vuejs.org/guide/migration/array-refs.html`
1793 },
1794 ["V_ON_KEYCODE_MODIFIER" /* V_ON_KEYCODE_MODIFIER */]: {
1795 message: `Using keyCode as v-on modifier is no longer supported. ` +
1796 `Use kebab-case key name modifiers instead.`,
1797 link: `https://v3.vuejs.org/guide/migration/keycode-modifiers.html`
1798 },
1799 ["ATTR_FALSE_VALUE" /* ATTR_FALSE_VALUE */]: {
1800 message: (name) => `Attribute "${name}" with v-bind value \`false\` will render ` +
1801 `${name}="false" instead of removing it in Vue 3. To remove the attribute, ` +
1802 `use \`null\` or \`undefined\` instead. If the usage is intended, ` +
1803 `you can disable the compat behavior and suppress this warning with:` +
1804 `\n\n configureCompat({ ${"ATTR_FALSE_VALUE" /* ATTR_FALSE_VALUE */}: false })\n`,
1805 link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
1806 },
1807 ["ATTR_ENUMERATED_COERCION" /* ATTR_ENUMERATED_COERCION */]: {
1808 message: (name, value, coerced) => `Enumerated attribute "${name}" with v-bind value \`${value}\` will ` +
1809 `${value === null ? `be removed` : `render the value as-is`} instead of coercing the value to "${coerced}" in Vue 3. ` +
1810 `Always use explicit "true" or "false" values for enumerated attributes. ` +
1811 `If the usage is intended, ` +
1812 `you can disable the compat behavior and suppress this warning with:` +
1813 `\n\n configureCompat({ ${"ATTR_ENUMERATED_COERCION" /* ATTR_ENUMERATED_COERCION */}: false })\n`,
1814 link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
1815 },
1816 ["TRANSITION_CLASSES" /* TRANSITION_CLASSES */]: {
1817 message: `` // this feature cannot be runtime-detected
1818 },
1819 ["TRANSITION_GROUP_ROOT" /* TRANSITION_GROUP_ROOT */]: {
1820 message: `<TransitionGroup> no longer renders a root <span> element by ` +
1821 `default if no "tag" prop is specified. If you do not rely on the span ` +
1822 `for styling, you can disable the compat behavior and suppress this ` +
1823 `warning with:` +
1824 `\n\n configureCompat({ ${"TRANSITION_GROUP_ROOT" /* TRANSITION_GROUP_ROOT */}: false })\n`,
1825 link: `https://v3.vuejs.org/guide/migration/transition-group.html`
1826 },
1827 ["COMPONENT_ASYNC" /* COMPONENT_ASYNC */]: {
1828 message: (comp) => {
1829 const name = getComponentName(comp);
1830 return (`Async component${name ? ` <${name}>` : `s`} should be explicitly created via \`defineAsyncComponent()\` ` +
1831 `in Vue 3. Plain functions will be treated as functional components in ` +
1832 `non-compat build. If you have already migrated all async component ` +
1833 `usage and intend to use plain functions for functional components, ` +
1834 `you can disable the compat behavior and suppress this ` +
1835 `warning with:` +
1836 `\n\n configureCompat({ ${"COMPONENT_ASYNC" /* COMPONENT_ASYNC */}: false })\n`);
1837 },
1838 link: `https://v3.vuejs.org/guide/migration/async-components.html`
1839 },
1840 ["COMPONENT_FUNCTIONAL" /* COMPONENT_FUNCTIONAL */]: {
1841 message: (comp) => {
1842 const name = getComponentName(comp);
1843 return (`Functional component${name ? ` <${name}>` : `s`} should be defined as a plain function in Vue 3. The "functional" ` +
1844 `option has been removed. NOTE: Before migrating to use plain ` +
1845 `functions for functional components, first make sure that all async ` +
1846 `components usage have been migrated and its compat behavior has ` +
1847 `been disabled.`);
1848 },
1849 link: `https://v3.vuejs.org/guide/migration/functional-components.html`
1850 },
1851 ["COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */]: {
1852 message: (comp) => {
1853 const configMsg = `opt-in to ` +
1854 `Vue 3 behavior on a per-component basis with \`compatConfig: { ${"COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */}: false }\`.`;
1855 if (comp.props &&
1856 (isArray(comp.props)
1857 ? comp.props.includes('modelValue')
1858 : hasOwn(comp.props, 'modelValue'))) {
1859 return (`Component delcares "modelValue" prop, which is Vue 3 usage, but ` +
1860 `is running under Vue 2 compat v-model behavior. You can ${configMsg}`);
1861 }
1862 return (`v-model usage on component has changed in Vue 3. Component that expects ` +
1863 `to work with v-model should now use the "modelValue" prop and emit the ` +
1864 `"update:modelValue" event. You can update the usage and then ${configMsg}`);
1865 },
1866 link: `https://v3.vuejs.org/guide/migration/v-model.html`
1867 },
1868 ["RENDER_FUNCTION" /* RENDER_FUNCTION */]: {
1869 message: `Vue 3's render function API has changed. ` +
1870 `You can opt-in to the new API with:` +
1871 `\n\n configureCompat({ ${"RENDER_FUNCTION" /* RENDER_FUNCTION */}: false })\n` +
1872 `\n (This can also be done per-component via the "compatConfig" option.)`,
1873 link: `https://v3.vuejs.org/guide/migration/render-function-api.html`
1874 },
1875 ["FILTERS" /* FILTERS */]: {
1876 message: `filters have been removed in Vue 3. ` +
1877 `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
1878 `Use method calls or computed properties instead.`,
1879 link: `https://v3.vuejs.org/guide/migration/filters.html`
1880 },
1881 ["PRIVATE_APIS" /* PRIVATE_APIS */]: {
1882 message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
1883 `If you are seeing this warning only due to a dependency, you can ` +
1884 `suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
1885 }
1886};
1887const instanceWarned = Object.create(null);
1888const warnCount = Object.create(null);
1889function warnDeprecation(key, instance, ...args) {
1890 instance = instance || getCurrentInstance();
1891 // check user config
1892 const config = getCompatConfigForKey(key, instance);
1893 if (config === 'suppress-warning') {
1894 return;
1895 }
1896 const dupKey = key + args.join('');
1897 let compId = instance && formatComponentName(instance, instance.type);
1898 if (compId === 'Anonymous' && instance) {
1899 compId = instance.uid;
1900 }
1901 // skip if the same warning is emitted for the same component type
1902 const componentDupKey = dupKey + compId;
1903 if (componentDupKey in instanceWarned) {
1904 return;
1905 }
1906 instanceWarned[componentDupKey] = true;
1907 // same warning, but different component. skip the long message and just
1908 // log the key and count.
1909 if (dupKey in warnCount) {
1910 warn$1(`(deprecation ${key}) (${++warnCount[dupKey] + 1})`);
1911 return;
1912 }
1913 warnCount[dupKey] = 0;
1914 const { message, link } = deprecationData[key];
1915 warn$1(`(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`);
1916 if (!isCompatEnabled(key, instance, true)) {
1917 console.error(`^ The above deprecation's compat behavior is disabled and will likely ` +
1918 `lead to runtime errors.`);
1919 }
1920}
1921const globalCompatConfig = {
1922 MODE: 2
1923};
1924function getCompatConfigForKey(key, instance) {
1925 const instanceConfig = instance && instance.type.compatConfig;
1926 if (instanceConfig && key in instanceConfig) {
1927 return instanceConfig[key];
1928 }
1929 return globalCompatConfig[key];
1930}
1931function isCompatEnabled(key, instance, enableForBuiltIn = false) {
1932 // skip compat for built-in components
1933 if (!enableForBuiltIn && instance && instance.type.__isBuiltIn) {
1934 return false;
1935 }
1936 const rawMode = getCompatConfigForKey('MODE', instance) || 2;
1937 const val = getCompatConfigForKey(key, instance);
1938 const mode = isFunction(rawMode)
1939 ? rawMode(instance && instance.type)
1940 : rawMode;
1941 if (mode === 2) {
1942 return val !== false;
1943 }
1944 else {
1945 return val === true || val === 'suppress-warning';
1946 }
1947}
1948
1949function emit(instance, event, ...rawArgs) {
1950 const props = instance.vnode.props || EMPTY_OBJ;
1951 {
1952 const { emitsOptions, propsOptions: [propsOptions] } = instance;
1953 if (emitsOptions) {
1954 if (!(event in emitsOptions) &&
1955 !(false )) {
1956 if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
1957 warn$1(`Component emitted event "${event}" but it is neither declared in ` +
1958 `the emits option nor as an "${toHandlerKey(event)}" prop.`);
1959 }
1960 }
1961 else {
1962 const validator = emitsOptions[event];
1963 if (isFunction(validator)) {
1964 const isValid = validator(...rawArgs);
1965 if (!isValid) {
1966 warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
1967 }
1968 }
1969 }
1970 }
1971 }
1972 let args = rawArgs;
1973 const isModelListener = event.startsWith('update:');
1974 // for v-model update:xxx events, apply modifiers on args
1975 const modelArg = isModelListener && event.slice(7);
1976 if (modelArg && modelArg in props) {
1977 const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
1978 const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
1979 if (trim) {
1980 args = rawArgs.map(a => a.trim());
1981 }
1982 else if (number) {
1983 args = rawArgs.map(toNumber);
1984 }
1985 }
1986 {
1987 devtoolsComponentEmit(instance, event, args);
1988 }
1989 {
1990 const lowerCaseEvent = event.toLowerCase();
1991 if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
1992 warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
1993 `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
1994 `Note that HTML attributes are case-insensitive and you cannot use ` +
1995 `v-on to listen to camelCase events when using in-DOM templates. ` +
1996 `You should probably use "${hyphenate(event)}" instead of "${event}".`);
1997 }
1998 }
1999 let handlerName;
2000 let handler = props[(handlerName = toHandlerKey(event))] ||
2001 // also try camelCase event handler (#2249)
2002 props[(handlerName = toHandlerKey(camelize(event)))];
2003 // for v-model update:xxx events, also trigger kebab-case equivalent
2004 // for props passed via kebab-case
2005 if (!handler && isModelListener) {
2006 handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
2007 }
2008 if (handler) {
2009 callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
2010 }
2011 const onceHandler = props[handlerName + `Once`];
2012 if (onceHandler) {
2013 if (!instance.emitted) {
2014 instance.emitted = {};
2015 }
2016 else if (instance.emitted[handlerName]) {
2017 return;
2018 }
2019 instance.emitted[handlerName] = true;
2020 callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
2021 }
2022}
2023function normalizeEmitsOptions(comp, appContext, asMixin = false) {
2024 const cache = appContext.emitsCache;
2025 const cached = cache.get(comp);
2026 if (cached !== undefined) {
2027 return cached;
2028 }
2029 const raw = comp.emits;
2030 let normalized = {};
2031 // apply mixin/extends props
2032 let hasExtends = false;
2033 if (!isFunction(comp)) {
2034 const extendEmits = (raw) => {
2035 const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
2036 if (normalizedFromExtend) {
2037 hasExtends = true;
2038 extend(normalized, normalizedFromExtend);
2039 }
2040 };
2041 if (!asMixin && appContext.mixins.length) {
2042 appContext.mixins.forEach(extendEmits);
2043 }
2044 if (comp.extends) {
2045 extendEmits(comp.extends);
2046 }
2047 if (comp.mixins) {
2048 comp.mixins.forEach(extendEmits);
2049 }
2050 }
2051 if (!raw && !hasExtends) {
2052 cache.set(comp, null);
2053 return null;
2054 }
2055 if (isArray(raw)) {
2056 raw.forEach(key => (normalized[key] = null));
2057 }
2058 else {
2059 extend(normalized, raw);
2060 }
2061 cache.set(comp, normalized);
2062 return normalized;
2063}
2064// Check if an incoming prop key is a declared emit event listener.
2065// e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
2066// both considered matched listeners.
2067function isEmitListener(options, key) {
2068 if (!options || !isOn(key)) {
2069 return false;
2070 }
2071 key = key.slice(2).replace(/Once$/, '');
2072 return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
2073 hasOwn(options, hyphenate(key)) ||
2074 hasOwn(options, key));
2075}
2076
2077/**
2078 * mark the current rendering instance for asset resolution (e.g.
2079 * resolveComponent, resolveDirective) during render
2080 */
2081let currentRenderingInstance = null;
2082let currentScopeId = null;
2083/**
2084 * Note: rendering calls maybe nested. The function returns the parent rendering
2085 * instance if present, which should be restored after the render is done:
2086 *
2087 * ```js
2088 * const prev = setCurrentRenderingInstance(i)
2089 * // ...render
2090 * setCurrentRenderingInstance(prev)
2091 * ```
2092 */
2093function setCurrentRenderingInstance(instance) {
2094 const prev = currentRenderingInstance;
2095 currentRenderingInstance = instance;
2096 currentScopeId = (instance && instance.type.__scopeId) || null;
2097 return prev;
2098}
2099/**
2100 * Set scope id when creating hoisted vnodes.
2101 * @private compiler helper
2102 */
2103function pushScopeId(id) {
2104 currentScopeId = id;
2105}
2106/**
2107 * Technically we no longer need this after 3.0.8 but we need to keep the same
2108 * API for backwards compat w/ code generated by compilers.
2109 * @private
2110 */
2111function popScopeId() {
2112 currentScopeId = null;
2113}
2114/**
2115 * Only for backwards compat
2116 * @private
2117 */
2118const withScopeId = (_id) => withCtx;
2119/**
2120 * Wrap a slot function to memoize current rendering instance
2121 * @private compiler helper
2122 */
2123function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
2124) {
2125 if (!ctx)
2126 return fn;
2127 // already normalized
2128 if (fn._n) {
2129 return fn;
2130 }
2131 const renderFnWithContext = (...args) => {
2132 // If a user calls a compiled slot inside a template expression (#1745), it
2133 // can mess up block tracking, so by default we disable block tracking and
2134 // force bail out when invoking a compiled slot (indicated by the ._d flag).
2135 // This isn't necessary if rendering a compiled `<slot>`, so we flip the
2136 // ._d flag off when invoking the wrapped fn inside `renderSlot`.
2137 if (renderFnWithContext._d) {
2138 setBlockTracking(-1);
2139 }
2140 const prevInstance = setCurrentRenderingInstance(ctx);
2141 const res = fn(...args);
2142 setCurrentRenderingInstance(prevInstance);
2143 if (renderFnWithContext._d) {
2144 setBlockTracking(1);
2145 }
2146 {
2147 devtoolsComponentUpdated(ctx);
2148 }
2149 return res;
2150 };
2151 // mark normalized to avoid duplicated wrapping
2152 renderFnWithContext._n = true;
2153 // mark this as compiled by default
2154 // this is used in vnode.ts -> normalizeChildren() to set the slot
2155 // rendering flag.
2156 renderFnWithContext._c = true;
2157 // disable block tracking by default
2158 renderFnWithContext._d = true;
2159 return renderFnWithContext;
2160}
2161
2162/**
2163 * dev only flag to track whether $attrs was used during render.
2164 * If $attrs was used during render then the warning for failed attrs
2165 * fallthrough can be suppressed.
2166 */
2167let accessedAttrs = false;
2168function markAttrsAccessed() {
2169 accessedAttrs = true;
2170}
2171function renderComponentRoot(instance) {
2172 const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2173 let result;
2174 const prev = setCurrentRenderingInstance(instance);
2175 {
2176 accessedAttrs = false;
2177 }
2178 try {
2179 let fallthroughAttrs;
2180 if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2181 // withProxy is a proxy with a different `has` trap only for
2182 // runtime-compiled render functions using `with` block.
2183 const proxyToUse = withProxy || proxy;
2184 result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
2185 fallthroughAttrs = attrs;
2186 }
2187 else {
2188 // functional
2189 const render = Component;
2190 // in dev, mark attrs accessed if optional props (attrs === props)
2191 if (true && attrs === props) {
2192 markAttrsAccessed();
2193 }
2194 result = normalizeVNode(render.length > 1
2195 ? render(props, true
2196 ? {
2197 get attrs() {
2198 markAttrsAccessed();
2199 return attrs;
2200 },
2201 slots,
2202 emit
2203 }
2204 : { attrs, slots, emit })
2205 : render(props, null /* we know it doesn't need it */));
2206 fallthroughAttrs = Component.props
2207 ? attrs
2208 : getFunctionalFallthrough(attrs);
2209 }
2210 // attr merging
2211 // in dev mode, comments are preserved, and it's possible for a template
2212 // to have comments along side the root element which makes it a fragment
2213 let root = result;
2214 let setRoot = undefined;
2215 if (true &&
2216 result.patchFlag > 0 &&
2217 result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2218 ;
2219 [root, setRoot] = getChildRoot(result);
2220 }
2221 if (fallthroughAttrs && inheritAttrs !== false) {
2222 const keys = Object.keys(fallthroughAttrs);
2223 const { shapeFlag } = root;
2224 if (keys.length) {
2225 if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2226 if (propsOptions && keys.some(isModelListener)) {
2227 // If a v-model listener (onUpdate:xxx) has a corresponding declared
2228 // prop, it indicates this component expects to handle v-model and
2229 // it should not fallthrough.
2230 // related: #1543, #1643, #1989
2231 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2232 }
2233 root = cloneVNode(root, fallthroughAttrs);
2234 }
2235 else if (true && !accessedAttrs && root.type !== Comment) {
2236 const allAttrs = Object.keys(attrs);
2237 const eventAttrs = [];
2238 const extraAttrs = [];
2239 for (let i = 0, l = allAttrs.length; i < l; i++) {
2240 const key = allAttrs[i];
2241 if (isOn(key)) {
2242 // ignore v-model handlers when they fail to fallthrough
2243 if (!isModelListener(key)) {
2244 // remove `on`, lowercase first letter to reflect event casing
2245 // accurately
2246 eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2247 }
2248 }
2249 else {
2250 extraAttrs.push(key);
2251 }
2252 }
2253 if (extraAttrs.length) {
2254 warn$1(`Extraneous non-props attributes (` +
2255 `${extraAttrs.join(', ')}) ` +
2256 `were passed to component but could not be automatically inherited ` +
2257 `because component renders fragment or text root nodes.`);
2258 }
2259 if (eventAttrs.length) {
2260 warn$1(`Extraneous non-emits event listeners (` +
2261 `${eventAttrs.join(', ')}) ` +
2262 `were passed to component but could not be automatically inherited ` +
2263 `because component renders fragment or text root nodes. ` +
2264 `If the listener is intended to be a component custom event listener only, ` +
2265 `declare it using the "emits" option.`);
2266 }
2267 }
2268 }
2269 }
2270 if (false &&
2271 isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2272 vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2273 root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) ;
2274 // inherit directives
2275 if (vnode.dirs) {
2276 if (true && !isElementRoot(root)) {
2277 warn$1(`Runtime directive used on component with non-element root node. ` +
2278 `The directives will not function as intended.`);
2279 }
2280 root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2281 }
2282 // inherit transition data
2283 if (vnode.transition) {
2284 if (true && !isElementRoot(root)) {
2285 warn$1(`Component inside <Transition> renders non-element root node ` +
2286 `that cannot be animated.`);
2287 }
2288 root.transition = vnode.transition;
2289 }
2290 if (true && setRoot) {
2291 setRoot(root);
2292 }
2293 else {
2294 result = root;
2295 }
2296 }
2297 catch (err) {
2298 blockStack.length = 0;
2299 handleError(err, instance, 1 /* RENDER_FUNCTION */);
2300 result = createVNode(Comment);
2301 }
2302 setCurrentRenderingInstance(prev);
2303 return result;
2304}
2305/**
2306 * dev only
2307 * In dev mode, template root level comments are rendered, which turns the
2308 * template into a fragment root, but we need to locate the single element
2309 * root for attrs and scope id processing.
2310 */
2311const getChildRoot = (vnode) => {
2312 const rawChildren = vnode.children;
2313 const dynamicChildren = vnode.dynamicChildren;
2314 const childRoot = filterSingleRoot(rawChildren);
2315 if (!childRoot) {
2316 return [vnode, undefined];
2317 }
2318 const index = rawChildren.indexOf(childRoot);
2319 const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
2320 const setRoot = (updatedRoot) => {
2321 rawChildren[index] = updatedRoot;
2322 if (dynamicChildren) {
2323 if (dynamicIndex > -1) {
2324 dynamicChildren[dynamicIndex] = updatedRoot;
2325 }
2326 else if (updatedRoot.patchFlag > 0) {
2327 vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
2328 }
2329 }
2330 };
2331 return [normalizeVNode(childRoot), setRoot];
2332};
2333function filterSingleRoot(children) {
2334 let singleRoot;
2335 for (let i = 0; i < children.length; i++) {
2336 const child = children[i];
2337 if (isVNode(child)) {
2338 // ignore user comment
2339 if (child.type !== Comment || child.children === 'v-if') {
2340 if (singleRoot) {
2341 // has more than 1 non-comment child, return now
2342 return;
2343 }
2344 else {
2345 singleRoot = child;
2346 }
2347 }
2348 }
2349 else {
2350 return;
2351 }
2352 }
2353 return singleRoot;
2354}
2355const getFunctionalFallthrough = (attrs) => {
2356 let res;
2357 for (const key in attrs) {
2358 if (key === 'class' || key === 'style' || isOn(key)) {
2359 (res || (res = {}))[key] = attrs[key];
2360 }
2361 }
2362 return res;
2363};
2364const filterModelListeners = (attrs, props) => {
2365 const res = {};
2366 for (const key in attrs) {
2367 if (!isModelListener(key) || !(key.slice(9) in props)) {
2368 res[key] = attrs[key];
2369 }
2370 }
2371 return res;
2372};
2373const isElementRoot = (vnode) => {
2374 return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
2375 vnode.type === Comment // potential v-if branch switch
2376 );
2377};
2378function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
2379 const { props: prevProps, children: prevChildren, component } = prevVNode;
2380 const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
2381 const emits = component.emitsOptions;
2382 // Parent component's render function was hot-updated. Since this may have
2383 // caused the child component's slots content to have changed, we need to
2384 // force the child to update as well.
2385 if ((prevChildren || nextChildren) && isHmrUpdating) {
2386 return true;
2387 }
2388 // force child update for runtime directive or transition on component vnode.
2389 if (nextVNode.dirs || nextVNode.transition) {
2390 return true;
2391 }
2392 if (optimized && patchFlag >= 0) {
2393 if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
2394 // slot content that references values that might have changed,
2395 // e.g. in a v-for
2396 return true;
2397 }
2398 if (patchFlag & 16 /* FULL_PROPS */) {
2399 if (!prevProps) {
2400 return !!nextProps;
2401 }
2402 // presence of this flag indicates props are always non-null
2403 return hasPropsChanged(prevProps, nextProps, emits);
2404 }
2405 else if (patchFlag & 8 /* PROPS */) {
2406 const dynamicProps = nextVNode.dynamicProps;
2407 for (let i = 0; i < dynamicProps.length; i++) {
2408 const key = dynamicProps[i];
2409 if (nextProps[key] !== prevProps[key] &&
2410 !isEmitListener(emits, key)) {
2411 return true;
2412 }
2413 }
2414 }
2415 }
2416 else {
2417 // this path is only taken by manually written render functions
2418 // so presence of any children leads to a forced update
2419 if (prevChildren || nextChildren) {
2420 if (!nextChildren || !nextChildren.$stable) {
2421 return true;
2422 }
2423 }
2424 if (prevProps === nextProps) {
2425 return false;
2426 }
2427 if (!prevProps) {
2428 return !!nextProps;
2429 }
2430 if (!nextProps) {
2431 return true;
2432 }
2433 return hasPropsChanged(prevProps, nextProps, emits);
2434 }
2435 return false;
2436}
2437function hasPropsChanged(prevProps, nextProps, emitsOptions) {
2438 const nextKeys = Object.keys(nextProps);
2439 if (nextKeys.length !== Object.keys(prevProps).length) {
2440 return true;
2441 }
2442 for (let i = 0; i < nextKeys.length; i++) {
2443 const key = nextKeys[i];
2444 if (nextProps[key] !== prevProps[key] &&
2445 !isEmitListener(emitsOptions, key)) {
2446 return true;
2447 }
2448 }
2449 return false;
2450}
2451function updateHOCHostEl({ vnode, parent }, el // HostNode
2452) {
2453 while (parent && parent.subTree === vnode) {
2454 (vnode = parent.vnode).el = el;
2455 parent = parent.parent;
2456 }
2457}
2458
2459const isSuspense = (type) => type.__isSuspense;
2460// Suspense exposes a component-like API, and is treated like a component
2461// in the compiler, but internally it's a special built-in type that hooks
2462// directly into the renderer.
2463const SuspenseImpl = {
2464 name: 'Suspense',
2465 // In order to make Suspense tree-shakable, we need to avoid importing it
2466 // directly in the renderer. The renderer checks for the __isSuspense flag
2467 // on a vnode's type and calls the `process` method, passing in renderer
2468 // internals.
2469 __isSuspense: true,
2470 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
2471 // platform-specific impl passed from renderer
2472 rendererInternals) {
2473 if (n1 == null) {
2474 mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
2475 }
2476 else {
2477 patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
2478 }
2479 },
2480 hydrate: hydrateSuspense,
2481 create: createSuspenseBoundary,
2482 normalize: normalizeSuspenseChildren
2483};
2484// Force-casted public typing for h and TSX props inference
2485const Suspense = (SuspenseImpl );
2486function triggerEvent(vnode, name) {
2487 const eventListener = vnode.props && vnode.props[name];
2488 if (isFunction(eventListener)) {
2489 eventListener();
2490 }
2491}
2492function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
2493 const { p: patch, o: { createElement } } = rendererInternals;
2494 const hiddenContainer = createElement('div');
2495 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
2496 // start mounting the content subtree in an off-dom container
2497 patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
2498 // now check if we have encountered any async deps
2499 if (suspense.deps > 0) {
2500 // has async
2501 // invoke @fallback event
2502 triggerEvent(vnode, 'onPending');
2503 triggerEvent(vnode, 'onFallback');
2504 // mount the fallback tree
2505 patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2506 isSVG, slotScopeIds);
2507 setActiveBranch(suspense, vnode.ssFallback);
2508 }
2509 else {
2510 // Suspense has no async deps. Just resolve.
2511 suspense.resolve();
2512 }
2513}
2514function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
2515 const suspense = (n2.suspense = n1.suspense);
2516 suspense.vnode = n2;
2517 n2.el = n1.el;
2518 const newBranch = n2.ssContent;
2519 const newFallback = n2.ssFallback;
2520 const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
2521 if (pendingBranch) {
2522 suspense.pendingBranch = newBranch;
2523 if (isSameVNodeType(newBranch, pendingBranch)) {
2524 // same root type but content may have changed.
2525 patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2526 if (suspense.deps <= 0) {
2527 suspense.resolve();
2528 }
2529 else if (isInFallback) {
2530 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2531 isSVG, slotScopeIds, optimized);
2532 setActiveBranch(suspense, newFallback);
2533 }
2534 }
2535 else {
2536 // toggled before pending tree is resolved
2537 suspense.pendingId++;
2538 if (isHydrating) {
2539 // if toggled before hydration is finished, the current DOM tree is
2540 // no longer valid. set it as the active branch so it will be unmounted
2541 // when resolved
2542 suspense.isHydrating = false;
2543 suspense.activeBranch = pendingBranch;
2544 }
2545 else {
2546 unmount(pendingBranch, parentComponent, suspense);
2547 }
2548 // increment pending ID. this is used to invalidate async callbacks
2549 // reset suspense state
2550 suspense.deps = 0;
2551 // discard effects from pending branch
2552 suspense.effects.length = 0;
2553 // discard previous container
2554 suspense.hiddenContainer = createElement('div');
2555 if (isInFallback) {
2556 // already in fallback state
2557 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2558 if (suspense.deps <= 0) {
2559 suspense.resolve();
2560 }
2561 else {
2562 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2563 isSVG, slotScopeIds, optimized);
2564 setActiveBranch(suspense, newFallback);
2565 }
2566 }
2567 else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
2568 // toggled "back" to current active branch
2569 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2570 // force resolve
2571 suspense.resolve(true);
2572 }
2573 else {
2574 // switched to a 3rd branch
2575 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2576 if (suspense.deps <= 0) {
2577 suspense.resolve();
2578 }
2579 }
2580 }
2581 }
2582 else {
2583 if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
2584 // root did not change, just normal patch
2585 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2586 setActiveBranch(suspense, newBranch);
2587 }
2588 else {
2589 // root node toggled
2590 // invoke @pending event
2591 triggerEvent(n2, 'onPending');
2592 // mount pending branch in off-dom container
2593 suspense.pendingBranch = newBranch;
2594 suspense.pendingId++;
2595 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2596 if (suspense.deps <= 0) {
2597 // incoming branch has no async deps, resolve now.
2598 suspense.resolve();
2599 }
2600 else {
2601 const { timeout, pendingId } = suspense;
2602 if (timeout > 0) {
2603 setTimeout(() => {
2604 if (suspense.pendingId === pendingId) {
2605 suspense.fallback(newFallback);
2606 }
2607 }, timeout);
2608 }
2609 else if (timeout === 0) {
2610 suspense.fallback(newFallback);
2611 }
2612 }
2613 }
2614 }
2615}
2616let hasWarned = false;
2617function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
2618 /* istanbul ignore if */
2619 if (!hasWarned) {
2620 hasWarned = true;
2621 // @ts-ignore `console.info` cannot be null error
2622 console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
2623 }
2624 const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
2625 const timeout = toNumber(vnode.props && vnode.props.timeout);
2626 const suspense = {
2627 vnode,
2628 parent,
2629 parentComponent,
2630 isSVG,
2631 container,
2632 hiddenContainer,
2633 anchor,
2634 deps: 0,
2635 pendingId: 0,
2636 timeout: typeof timeout === 'number' ? timeout : -1,
2637 activeBranch: null,
2638 pendingBranch: null,
2639 isInFallback: true,
2640 isHydrating,
2641 isUnmounted: false,
2642 effects: [],
2643 resolve(resume = false) {
2644 {
2645 if (!resume && !suspense.pendingBranch) {
2646 throw new Error(`suspense.resolve() is called without a pending branch.`);
2647 }
2648 if (suspense.isUnmounted) {
2649 throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
2650 }
2651 }
2652 const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
2653 if (suspense.isHydrating) {
2654 suspense.isHydrating = false;
2655 }
2656 else if (!resume) {
2657 const delayEnter = activeBranch &&
2658 pendingBranch.transition &&
2659 pendingBranch.transition.mode === 'out-in';
2660 if (delayEnter) {
2661 activeBranch.transition.afterLeave = () => {
2662 if (pendingId === suspense.pendingId) {
2663 move(pendingBranch, container, anchor, 0 /* ENTER */);
2664 }
2665 };
2666 }
2667 // this is initial anchor on mount
2668 let { anchor } = suspense;
2669 // unmount current active tree
2670 if (activeBranch) {
2671 // if the fallback tree was mounted, it may have been moved
2672 // as part of a parent suspense. get the latest anchor for insertion
2673 anchor = next(activeBranch);
2674 unmount(activeBranch, parentComponent, suspense, true);
2675 }
2676 if (!delayEnter) {
2677 // move content from off-dom container to actual container
2678 move(pendingBranch, container, anchor, 0 /* ENTER */);
2679 }
2680 }
2681 setActiveBranch(suspense, pendingBranch);
2682 suspense.pendingBranch = null;
2683 suspense.isInFallback = false;
2684 // flush buffered effects
2685 // check if there is a pending parent suspense
2686 let parent = suspense.parent;
2687 let hasUnresolvedAncestor = false;
2688 while (parent) {
2689 if (parent.pendingBranch) {
2690 // found a pending parent suspense, merge buffered post jobs
2691 // into that parent
2692 parent.effects.push(...effects);
2693 hasUnresolvedAncestor = true;
2694 break;
2695 }
2696 parent = parent.parent;
2697 }
2698 // no pending parent suspense, flush all jobs
2699 if (!hasUnresolvedAncestor) {
2700 queuePostFlushCb(effects);
2701 }
2702 suspense.effects = [];
2703 // invoke @resolve event
2704 triggerEvent(vnode, 'onResolve');
2705 },
2706 fallback(fallbackVNode) {
2707 if (!suspense.pendingBranch) {
2708 return;
2709 }
2710 const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
2711 // invoke @fallback event
2712 triggerEvent(vnode, 'onFallback');
2713 const anchor = next(activeBranch);
2714 const mountFallback = () => {
2715 if (!suspense.isInFallback) {
2716 return;
2717 }
2718 // mount the fallback tree
2719 patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2720 isSVG, slotScopeIds, optimized);
2721 setActiveBranch(suspense, fallbackVNode);
2722 };
2723 const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
2724 if (delayEnter) {
2725 activeBranch.transition.afterLeave = mountFallback;
2726 }
2727 suspense.isInFallback = true;
2728 // unmount current active branch
2729 unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
2730 true // shouldRemove
2731 );
2732 if (!delayEnter) {
2733 mountFallback();
2734 }
2735 },
2736 move(container, anchor, type) {
2737 suspense.activeBranch &&
2738 move(suspense.activeBranch, container, anchor, type);
2739 suspense.container = container;
2740 },
2741 next() {
2742 return suspense.activeBranch && next(suspense.activeBranch);
2743 },
2744 registerDep(instance, setupRenderEffect) {
2745 const isInPendingSuspense = !!suspense.pendingBranch;
2746 if (isInPendingSuspense) {
2747 suspense.deps++;
2748 }
2749 const hydratedEl = instance.vnode.el;
2750 instance
2751 .asyncDep.catch(err => {
2752 handleError(err, instance, 0 /* SETUP_FUNCTION */);
2753 })
2754 .then(asyncSetupResult => {
2755 // retry when the setup() promise resolves.
2756 // component may have been unmounted before resolve.
2757 if (instance.isUnmounted ||
2758 suspense.isUnmounted ||
2759 suspense.pendingId !== instance.suspenseId) {
2760 return;
2761 }
2762 // retry from this component
2763 instance.asyncResolved = true;
2764 const { vnode } = instance;
2765 {
2766 pushWarningContext(vnode);
2767 }
2768 handleSetupResult(instance, asyncSetupResult, false);
2769 if (hydratedEl) {
2770 // vnode may have been replaced if an update happened before the
2771 // async dep is resolved.
2772 vnode.el = hydratedEl;
2773 }
2774 const placeholder = !hydratedEl && instance.subTree.el;
2775 setupRenderEffect(instance, vnode,
2776 // component may have been moved before resolve.
2777 // if this is not a hydration, instance.subTree will be the comment
2778 // placeholder.
2779 parentNode(hydratedEl || instance.subTree.el),
2780 // anchor will not be used if this is hydration, so only need to
2781 // consider the comment placeholder case.
2782 hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
2783 if (placeholder) {
2784 remove(placeholder);
2785 }
2786 updateHOCHostEl(instance, vnode.el);
2787 {
2788 popWarningContext();
2789 }
2790 // only decrease deps count if suspense is not already resolved
2791 if (isInPendingSuspense && --suspense.deps === 0) {
2792 suspense.resolve();
2793 }
2794 });
2795 },
2796 unmount(parentSuspense, doRemove) {
2797 suspense.isUnmounted = true;
2798 if (suspense.activeBranch) {
2799 unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
2800 }
2801 if (suspense.pendingBranch) {
2802 unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
2803 }
2804 }
2805 };
2806 return suspense;
2807}
2808function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
2809 /* eslint-disable no-restricted-globals */
2810 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
2811 // there are two possible scenarios for server-rendered suspense:
2812 // - success: ssr content should be fully resolved
2813 // - failure: ssr content should be the fallback branch.
2814 // however, on the client we don't really know if it has failed or not
2815 // attempt to hydrate the DOM assuming it has succeeded, but we still
2816 // need to construct a suspense boundary first
2817 const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
2818 if (suspense.deps === 0) {
2819 suspense.resolve();
2820 }
2821 return result;
2822 /* eslint-enable no-restricted-globals */
2823}
2824function normalizeSuspenseChildren(vnode) {
2825 const { shapeFlag, children } = vnode;
2826 const isSlotChildren = shapeFlag & 32 /* SLOTS_CHILDREN */;
2827 vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
2828 vnode.ssFallback = isSlotChildren
2829 ? normalizeSuspenseSlot(children.fallback)
2830 : createVNode(Comment);
2831}
2832function normalizeSuspenseSlot(s) {
2833 let block;
2834 if (isFunction(s)) {
2835 const isCompiledSlot = s._c;
2836 if (isCompiledSlot) {
2837 // disableTracking: false
2838 // allow block tracking for compiled slots
2839 // (see ./componentRenderContext.ts)
2840 s._d = false;
2841 openBlock();
2842 }
2843 s = s();
2844 if (isCompiledSlot) {
2845 s._d = true;
2846 block = currentBlock;
2847 closeBlock();
2848 }
2849 }
2850 if (isArray(s)) {
2851 const singleChild = filterSingleRoot(s);
2852 if (!singleChild) {
2853 warn$1(`<Suspense> slots expect a single root node.`);
2854 }
2855 s = singleChild;
2856 }
2857 s = normalizeVNode(s);
2858 if (block && !s.dynamicChildren) {
2859 s.dynamicChildren = block.filter(c => c !== s);
2860 }
2861 return s;
2862}
2863function queueEffectWithSuspense(fn, suspense) {
2864 if (suspense && suspense.pendingBranch) {
2865 if (isArray(fn)) {
2866 suspense.effects.push(...fn);
2867 }
2868 else {
2869 suspense.effects.push(fn);
2870 }
2871 }
2872 else {
2873 queuePostFlushCb(fn);
2874 }
2875}
2876function setActiveBranch(suspense, branch) {
2877 suspense.activeBranch = branch;
2878 const { vnode, parentComponent } = suspense;
2879 const el = (vnode.el = branch.el);
2880 // in case suspense is the root node of a component,
2881 // recursively update the HOC el
2882 if (parentComponent && parentComponent.subTree === vnode) {
2883 parentComponent.vnode.el = el;
2884 updateHOCHostEl(parentComponent, el);
2885 }
2886}
2887
2888function provide(key, value) {
2889 if (!currentInstance) {
2890 {
2891 warn$1(`provide() can only be used inside setup().`);
2892 }
2893 }
2894 else {
2895 let provides = currentInstance.provides;
2896 // by default an instance inherits its parent's provides object
2897 // but when it needs to provide values of its own, it creates its
2898 // own provides object using parent provides object as prototype.
2899 // this way in `inject` we can simply look up injections from direct
2900 // parent and let the prototype chain do the work.
2901 const parentProvides = currentInstance.parent && currentInstance.parent.provides;
2902 if (parentProvides === provides) {
2903 provides = currentInstance.provides = Object.create(parentProvides);
2904 }
2905 // TS doesn't allow symbol as index type
2906 provides[key] = value;
2907 }
2908}
2909function inject(key, defaultValue, treatDefaultAsFactory = false) {
2910 // fallback to `currentRenderingInstance` so that this can be called in
2911 // a functional component
2912 const instance = currentInstance || currentRenderingInstance;
2913 if (instance) {
2914 // #2400
2915 // to support `app.use` plugins,
2916 // fallback to appContext's `provides` if the intance is at root
2917 const provides = instance.parent == null
2918 ? instance.vnode.appContext && instance.vnode.appContext.provides
2919 : instance.parent.provides;
2920 if (provides && key in provides) {
2921 // TS doesn't allow symbol as index type
2922 return provides[key];
2923 }
2924 else if (arguments.length > 1) {
2925 return treatDefaultAsFactory && isFunction(defaultValue)
2926 ? defaultValue.call(instance.proxy)
2927 : defaultValue;
2928 }
2929 else {
2930 warn$1(`injection "${String(key)}" not found.`);
2931 }
2932 }
2933 else {
2934 warn$1(`inject() can only be used inside setup() or functional components.`);
2935 }
2936}
2937
2938function useTransitionState() {
2939 const state = {
2940 isMounted: false,
2941 isLeaving: false,
2942 isUnmounting: false,
2943 leavingVNodes: new Map()
2944 };
2945 onMounted(() => {
2946 state.isMounted = true;
2947 });
2948 onBeforeUnmount(() => {
2949 state.isUnmounting = true;
2950 });
2951 return state;
2952}
2953const TransitionHookValidator = [Function, Array];
2954const BaseTransitionImpl = {
2955 name: `BaseTransition`,
2956 props: {
2957 mode: String,
2958 appear: Boolean,
2959 persisted: Boolean,
2960 // enter
2961 onBeforeEnter: TransitionHookValidator,
2962 onEnter: TransitionHookValidator,
2963 onAfterEnter: TransitionHookValidator,
2964 onEnterCancelled: TransitionHookValidator,
2965 // leave
2966 onBeforeLeave: TransitionHookValidator,
2967 onLeave: TransitionHookValidator,
2968 onAfterLeave: TransitionHookValidator,
2969 onLeaveCancelled: TransitionHookValidator,
2970 // appear
2971 onBeforeAppear: TransitionHookValidator,
2972 onAppear: TransitionHookValidator,
2973 onAfterAppear: TransitionHookValidator,
2974 onAppearCancelled: TransitionHookValidator
2975 },
2976 setup(props, { slots }) {
2977 const instance = getCurrentInstance();
2978 const state = useTransitionState();
2979 let prevTransitionKey;
2980 return () => {
2981 const children = slots.default && getTransitionRawChildren(slots.default(), true);
2982 if (!children || !children.length) {
2983 return;
2984 }
2985 // warn multiple elements
2986 if (children.length > 1) {
2987 warn$1('<transition> can only be used on a single element or component. Use ' +
2988 '<transition-group> for lists.');
2989 }
2990 // there's no need to track reactivity for these props so use the raw
2991 // props for a bit better perf
2992 const rawProps = toRaw(props);
2993 const { mode } = rawProps;
2994 // check mode
2995 if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
2996 warn$1(`invalid <transition> mode: ${mode}`);
2997 }
2998 // at this point children has a guaranteed length of 1.
2999 const child = children[0];
3000 if (state.isLeaving) {
3001 return emptyPlaceholder(child);
3002 }
3003 // in the case of <transition><keep-alive/></transition>, we need to
3004 // compare the type of the kept-alive children.
3005 const innerChild = getKeepAliveChild(child);
3006 if (!innerChild) {
3007 return emptyPlaceholder(child);
3008 }
3009 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
3010 setTransitionHooks(innerChild, enterHooks);
3011 const oldChild = instance.subTree;
3012 const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
3013 let transitionKeyChanged = false;
3014 const { getTransitionKey } = innerChild.type;
3015 if (getTransitionKey) {
3016 const key = getTransitionKey();
3017 if (prevTransitionKey === undefined) {
3018 prevTransitionKey = key;
3019 }
3020 else if (key !== prevTransitionKey) {
3021 prevTransitionKey = key;
3022 transitionKeyChanged = true;
3023 }
3024 }
3025 // handle mode
3026 if (oldInnerChild &&
3027 oldInnerChild.type !== Comment &&
3028 (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
3029 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
3030 // update old tree's hooks in case of dynamic transition
3031 setTransitionHooks(oldInnerChild, leavingHooks);
3032 // switching between different views
3033 if (mode === 'out-in') {
3034 state.isLeaving = true;
3035 // return placeholder node and queue update when leave finishes
3036 leavingHooks.afterLeave = () => {
3037 state.isLeaving = false;
3038 instance.update();
3039 };
3040 return emptyPlaceholder(child);
3041 }
3042 else if (mode === 'in-out' && innerChild.type !== Comment) {
3043 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
3044 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
3045 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
3046 // early removal callback
3047 el._leaveCb = () => {
3048 earlyRemove();
3049 el._leaveCb = undefined;
3050 delete enterHooks.delayedLeave;
3051 };
3052 enterHooks.delayedLeave = delayedLeave;
3053 };
3054 }
3055 }
3056 return child;
3057 };
3058 }
3059};
3060// export the public type for h/tsx inference
3061// also to avoid inline import() in generated d.ts files
3062const BaseTransition = BaseTransitionImpl;
3063function getLeavingNodesForType(state, vnode) {
3064 const { leavingVNodes } = state;
3065 let leavingVNodesCache = leavingVNodes.get(vnode.type);
3066 if (!leavingVNodesCache) {
3067 leavingVNodesCache = Object.create(null);
3068 leavingVNodes.set(vnode.type, leavingVNodesCache);
3069 }
3070 return leavingVNodesCache;
3071}
3072// The transition hooks are attached to the vnode as vnode.transition
3073// and will be called at appropriate timing in the renderer.
3074function resolveTransitionHooks(vnode, props, state, instance) {
3075 const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
3076 const key = String(vnode.key);
3077 const leavingVNodesCache = getLeavingNodesForType(state, vnode);
3078 const callHook = (hook, args) => {
3079 hook &&
3080 callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
3081 };
3082 const hooks = {
3083 mode,
3084 persisted,
3085 beforeEnter(el) {
3086 let hook = onBeforeEnter;
3087 if (!state.isMounted) {
3088 if (appear) {
3089 hook = onBeforeAppear || onBeforeEnter;
3090 }
3091 else {
3092 return;
3093 }
3094 }
3095 // for same element (v-show)
3096 if (el._leaveCb) {
3097 el._leaveCb(true /* cancelled */);
3098 }
3099 // for toggled element with same key (v-if)
3100 const leavingVNode = leavingVNodesCache[key];
3101 if (leavingVNode &&
3102 isSameVNodeType(vnode, leavingVNode) &&
3103 leavingVNode.el._leaveCb) {
3104 // force early removal (not cancelled)
3105 leavingVNode.el._leaveCb();
3106 }
3107 callHook(hook, [el]);
3108 },
3109 enter(el) {
3110 let hook = onEnter;
3111 let afterHook = onAfterEnter;
3112 let cancelHook = onEnterCancelled;
3113 if (!state.isMounted) {
3114 if (appear) {
3115 hook = onAppear || onEnter;
3116 afterHook = onAfterAppear || onAfterEnter;
3117 cancelHook = onAppearCancelled || onEnterCancelled;
3118 }
3119 else {
3120 return;
3121 }
3122 }
3123 let called = false;
3124 const done = (el._enterCb = (cancelled) => {
3125 if (called)
3126 return;
3127 called = true;
3128 if (cancelled) {
3129 callHook(cancelHook, [el]);
3130 }
3131 else {
3132 callHook(afterHook, [el]);
3133 }
3134 if (hooks.delayedLeave) {
3135 hooks.delayedLeave();
3136 }
3137 el._enterCb = undefined;
3138 });
3139 if (hook) {
3140 hook(el, done);
3141 if (hook.length <= 1) {
3142 done();
3143 }
3144 }
3145 else {
3146 done();
3147 }
3148 },
3149 leave(el, remove) {
3150 const key = String(vnode.key);
3151 if (el._enterCb) {
3152 el._enterCb(true /* cancelled */);
3153 }
3154 if (state.isUnmounting) {
3155 return remove();
3156 }
3157 callHook(onBeforeLeave, [el]);
3158 let called = false;
3159 const done = (el._leaveCb = (cancelled) => {
3160 if (called)
3161 return;
3162 called = true;
3163 remove();
3164 if (cancelled) {
3165 callHook(onLeaveCancelled, [el]);
3166 }
3167 else {
3168 callHook(onAfterLeave, [el]);
3169 }
3170 el._leaveCb = undefined;
3171 if (leavingVNodesCache[key] === vnode) {
3172 delete leavingVNodesCache[key];
3173 }
3174 });
3175 leavingVNodesCache[key] = vnode;
3176 if (onLeave) {
3177 onLeave(el, done);
3178 if (onLeave.length <= 1) {
3179 done();
3180 }
3181 }
3182 else {
3183 done();
3184 }
3185 },
3186 clone(vnode) {
3187 return resolveTransitionHooks(vnode, props, state, instance);
3188 }
3189 };
3190 return hooks;
3191}
3192// the placeholder really only handles one special case: KeepAlive
3193// in the case of a KeepAlive in a leave phase we need to return a KeepAlive
3194// placeholder with empty content to avoid the KeepAlive instance from being
3195// unmounted.
3196function emptyPlaceholder(vnode) {
3197 if (isKeepAlive(vnode)) {
3198 vnode = cloneVNode(vnode);
3199 vnode.children = null;
3200 return vnode;
3201 }
3202}
3203function getKeepAliveChild(vnode) {
3204 return isKeepAlive(vnode)
3205 ? vnode.children
3206 ? vnode.children[0]
3207 : undefined
3208 : vnode;
3209}
3210function setTransitionHooks(vnode, hooks) {
3211 if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
3212 setTransitionHooks(vnode.component.subTree, hooks);
3213 }
3214 else if (vnode.shapeFlag & 128 /* SUSPENSE */) {
3215 vnode.ssContent.transition = hooks.clone(vnode.ssContent);
3216 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
3217 }
3218 else {
3219 vnode.transition = hooks;
3220 }
3221}
3222function getTransitionRawChildren(children, keepComment = false) {
3223 let ret = [];
3224 let keyedFragmentCount = 0;
3225 for (let i = 0; i < children.length; i++) {
3226 const child = children[i];
3227 // handle fragment children case, e.g. v-for
3228 if (child.type === Fragment) {
3229 if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3230 keyedFragmentCount++;
3231 ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3232 }
3233 // comment placeholders should be skipped, e.g. v-if
3234 else if (keepComment || child.type !== Comment) {
3235 ret.push(child);
3236 }
3237 }
3238 // #1126 if a transition children list contains multiple sub fragments, these
3239 // fragments will be merged into a flat children array. Since each v-for
3240 // fragment may contain different static bindings inside, we need to de-op
3241 // these children to force full diffs to ensure correct behavior.
3242 if (keyedFragmentCount > 1) {
3243 for (let i = 0; i < ret.length; i++) {
3244 ret[i].patchFlag = -2 /* BAIL */;
3245 }
3246 }
3247 return ret;
3248}
3249
3250// implementation, close to no-op
3251function defineComponent(options) {
3252 return isFunction(options) ? { setup: options, name: options.name } : options;
3253}
3254
3255const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
3256function defineAsyncComponent(source) {
3257 if (isFunction(source)) {
3258 source = { loader: source };
3259 }
3260 const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
3261 suspensible = true, onError: userOnError } = source;
3262 let pendingRequest = null;
3263 let resolvedComp;
3264 let retries = 0;
3265 const retry = () => {
3266 retries++;
3267 pendingRequest = null;
3268 return load();
3269 };
3270 const load = () => {
3271 let thisRequest;
3272 return (pendingRequest ||
3273 (thisRequest = pendingRequest =
3274 loader()
3275 .catch(err => {
3276 err = err instanceof Error ? err : new Error(String(err));
3277 if (userOnError) {
3278 return new Promise((resolve, reject) => {
3279 const userRetry = () => resolve(retry());
3280 const userFail = () => reject(err);
3281 userOnError(err, userRetry, userFail, retries + 1);
3282 });
3283 }
3284 else {
3285 throw err;
3286 }
3287 })
3288 .then((comp) => {
3289 if (thisRequest !== pendingRequest && pendingRequest) {
3290 return pendingRequest;
3291 }
3292 if (!comp) {
3293 warn$1(`Async component loader resolved to undefined. ` +
3294 `If you are using retry(), make sure to return its return value.`);
3295 }
3296 // interop module default
3297 if (comp &&
3298 (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
3299 comp = comp.default;
3300 }
3301 if (comp && !isObject(comp) && !isFunction(comp)) {
3302 throw new Error(`Invalid async component load result: ${comp}`);
3303 }
3304 resolvedComp = comp;
3305 return comp;
3306 })));
3307 };
3308 return defineComponent({
3309 name: 'AsyncComponentWrapper',
3310 __asyncLoader: load,
3311 get __asyncResolved() {
3312 return resolvedComp;
3313 },
3314 setup() {
3315 const instance = currentInstance;
3316 // already resolved
3317 if (resolvedComp) {
3318 return () => createInnerComp(resolvedComp, instance);
3319 }
3320 const onError = (err) => {
3321 pendingRequest = null;
3322 handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
3323 };
3324 // suspense-controlled or SSR.
3325 if ((suspensible && instance.suspense) ||
3326 (false )) {
3327 return load()
3328 .then(comp => {
3329 return () => createInnerComp(comp, instance);
3330 })
3331 .catch(err => {
3332 onError(err);
3333 return () => errorComponent
3334 ? createVNode(errorComponent, {
3335 error: err
3336 })
3337 : null;
3338 });
3339 }
3340 const loaded = ref(false);
3341 const error = ref();
3342 const delayed = ref(!!delay);
3343 if (delay) {
3344 setTimeout(() => {
3345 delayed.value = false;
3346 }, delay);
3347 }
3348 if (timeout != null) {
3349 setTimeout(() => {
3350 if (!loaded.value && !error.value) {
3351 const err = new Error(`Async component timed out after ${timeout}ms.`);
3352 onError(err);
3353 error.value = err;
3354 }
3355 }, timeout);
3356 }
3357 load()
3358 .then(() => {
3359 loaded.value = true;
3360 if (instance.parent && isKeepAlive(instance.parent.vnode)) {
3361 // parent is keep-alive, force update so the loaded component's
3362 // name is taken into account
3363 queueJob(instance.parent.update);
3364 }
3365 })
3366 .catch(err => {
3367 onError(err);
3368 error.value = err;
3369 });
3370 return () => {
3371 if (loaded.value && resolvedComp) {
3372 return createInnerComp(resolvedComp, instance);
3373 }
3374 else if (error.value && errorComponent) {
3375 return createVNode(errorComponent, {
3376 error: error.value
3377 });
3378 }
3379 else if (loadingComponent && !delayed.value) {
3380 return createVNode(loadingComponent);
3381 }
3382 };
3383 }
3384 });
3385}
3386function createInnerComp(comp, { vnode: { ref, props, children } }) {
3387 const vnode = createVNode(comp, props, children);
3388 // ensure inner component inherits the async wrapper's ref owner
3389 vnode.ref = ref;
3390 return vnode;
3391}
3392
3393const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
3394const KeepAliveImpl = {
3395 name: `KeepAlive`,
3396 // Marker for special handling inside the renderer. We are not using a ===
3397 // check directly on KeepAlive in the renderer, because importing it directly
3398 // would prevent it from being tree-shaken.
3399 __isKeepAlive: true,
3400 props: {
3401 include: [String, RegExp, Array],
3402 exclude: [String, RegExp, Array],
3403 max: [String, Number]
3404 },
3405 setup(props, { slots }) {
3406 const instance = getCurrentInstance();
3407 // KeepAlive communicates with the instantiated renderer via the
3408 // ctx where the renderer passes in its internals,
3409 // and the KeepAlive instance exposes activate/deactivate implementations.
3410 // The whole point of this is to avoid importing KeepAlive directly in the
3411 // renderer to facilitate tree-shaking.
3412 const sharedContext = instance.ctx;
3413 // if the internal renderer is not registered, it indicates that this is server-side rendering,
3414 // for KeepAlive, we just need to render its children
3415 if (!sharedContext.renderer) {
3416 return slots.default;
3417 }
3418 const cache = new Map();
3419 const keys = new Set();
3420 let current = null;
3421 {
3422 instance.__v_cache = cache;
3423 }
3424 const parentSuspense = instance.suspense;
3425 const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
3426 const storageContainer = createElement('div');
3427 sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
3428 const instance = vnode.component;
3429 move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
3430 // in case props have changed
3431 patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
3432 queuePostRenderEffect(() => {
3433 instance.isDeactivated = false;
3434 if (instance.a) {
3435 invokeArrayFns(instance.a);
3436 }
3437 const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
3438 if (vnodeHook) {
3439 invokeVNodeHook(vnodeHook, instance.parent, vnode);
3440 }
3441 }, parentSuspense);
3442 {
3443 // Update components tree
3444 devtoolsComponentAdded(instance);
3445 }
3446 };
3447 sharedContext.deactivate = (vnode) => {
3448 const instance = vnode.component;
3449 move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
3450 queuePostRenderEffect(() => {
3451 if (instance.da) {
3452 invokeArrayFns(instance.da);
3453 }
3454 const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
3455 if (vnodeHook) {
3456 invokeVNodeHook(vnodeHook, instance.parent, vnode);
3457 }
3458 instance.isDeactivated = true;
3459 }, parentSuspense);
3460 {
3461 // Update components tree
3462 devtoolsComponentAdded(instance);
3463 }
3464 };
3465 function unmount(vnode) {
3466 // reset the shapeFlag so it can be properly unmounted
3467 resetShapeFlag(vnode);
3468 _unmount(vnode, instance, parentSuspense);
3469 }
3470 function pruneCache(filter) {
3471 cache.forEach((vnode, key) => {
3472 const name = getComponentName(vnode.type);
3473 if (name && (!filter || !filter(name))) {
3474 pruneCacheEntry(key);
3475 }
3476 });
3477 }
3478 function pruneCacheEntry(key) {
3479 const cached = cache.get(key);
3480 if (!current || cached.type !== current.type) {
3481 unmount(cached);
3482 }
3483 else if (current) {
3484 // current active instance should no longer be kept-alive.
3485 // we can't unmount it now but it might be later, so reset its flag now.
3486 resetShapeFlag(current);
3487 }
3488 cache.delete(key);
3489 keys.delete(key);
3490 }
3491 // prune cache on include/exclude prop change
3492 watch(() => [props.include, props.exclude], ([include, exclude]) => {
3493 include && pruneCache(name => matches(include, name));
3494 exclude && pruneCache(name => !matches(exclude, name));
3495 },
3496 // prune post-render after `current` has been updated
3497 { flush: 'post', deep: true });
3498 // cache sub tree after render
3499 let pendingCacheKey = null;
3500 const cacheSubtree = () => {
3501 // fix #1621, the pendingCacheKey could be 0
3502 if (pendingCacheKey != null) {
3503 cache.set(pendingCacheKey, getInnerChild(instance.subTree));
3504 }
3505 };
3506 onMounted(cacheSubtree);
3507 onUpdated(cacheSubtree);
3508 onBeforeUnmount(() => {
3509 cache.forEach(cached => {
3510 const { subTree, suspense } = instance;
3511 const vnode = getInnerChild(subTree);
3512 if (cached.type === vnode.type) {
3513 // current instance will be unmounted as part of keep-alive's unmount
3514 resetShapeFlag(vnode);
3515 // but invoke its deactivated hook here
3516 const da = vnode.component.da;
3517 da && queuePostRenderEffect(da, suspense);
3518 return;
3519 }
3520 unmount(cached);
3521 });
3522 });
3523 return () => {
3524 pendingCacheKey = null;
3525 if (!slots.default) {
3526 return null;
3527 }
3528 const children = slots.default();
3529 const rawVNode = children[0];
3530 if (children.length > 1) {
3531 {
3532 warn$1(`KeepAlive should contain exactly one component child.`);
3533 }
3534 current = null;
3535 return children;
3536 }
3537 else if (!isVNode(rawVNode) ||
3538 (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
3539 !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
3540 current = null;
3541 return rawVNode;
3542 }
3543 let vnode = getInnerChild(rawVNode);
3544 const comp = vnode.type;
3545 // for async components, name check should be based in its loaded
3546 // inner component if available
3547 const name = getComponentName(isAsyncWrapper(vnode)
3548 ? vnode.type.__asyncResolved || {}
3549 : comp);
3550 const { include, exclude, max } = props;
3551 if ((include && (!name || !matches(include, name))) ||
3552 (exclude && name && matches(exclude, name))) {
3553 current = vnode;
3554 return rawVNode;
3555 }
3556 const key = vnode.key == null ? comp : vnode.key;
3557 const cachedVNode = cache.get(key);
3558 // clone vnode if it's reused because we are going to mutate it
3559 if (vnode.el) {
3560 vnode = cloneVNode(vnode);
3561 if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
3562 rawVNode.ssContent = vnode;
3563 }
3564 }
3565 // #1513 it's possible for the returned vnode to be cloned due to attr
3566 // fallthrough or scopeId, so the vnode here may not be the final vnode
3567 // that is mounted. Instead of caching it directly, we store the pending
3568 // key and cache `instance.subTree` (the normalized vnode) in
3569 // beforeMount/beforeUpdate hooks.
3570 pendingCacheKey = key;
3571 if (cachedVNode) {
3572 // copy over mounted state
3573 vnode.el = cachedVNode.el;
3574 vnode.component = cachedVNode.component;
3575 if (vnode.transition) {
3576 // recursively update transition hooks on subTree
3577 setTransitionHooks(vnode, vnode.transition);
3578 }
3579 // avoid vnode being mounted as fresh
3580 vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
3581 // make this key the freshest
3582 keys.delete(key);
3583 keys.add(key);
3584 }
3585 else {
3586 keys.add(key);
3587 // prune oldest entry
3588 if (max && keys.size > parseInt(max, 10)) {
3589 pruneCacheEntry(keys.values().next().value);
3590 }
3591 }
3592 // avoid vnode being unmounted
3593 vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
3594 current = vnode;
3595 return rawVNode;
3596 };
3597 }
3598};
3599// export the public type for h/tsx inference
3600// also to avoid inline import() in generated d.ts files
3601const KeepAlive = KeepAliveImpl;
3602function matches(pattern, name) {
3603 if (isArray(pattern)) {
3604 return pattern.some((p) => matches(p, name));
3605 }
3606 else if (isString(pattern)) {
3607 return pattern.split(',').indexOf(name) > -1;
3608 }
3609 else if (pattern.test) {
3610 return pattern.test(name);
3611 }
3612 /* istanbul ignore next */
3613 return false;
3614}
3615function onActivated(hook, target) {
3616 registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
3617}
3618function onDeactivated(hook, target) {
3619 registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
3620}
3621function registerKeepAliveHook(hook, type, target = currentInstance) {
3622 // cache the deactivate branch check wrapper for injected hooks so the same
3623 // hook can be properly deduped by the scheduler. "__wdc" stands for "with
3624 // deactivation check".
3625 const wrappedHook = hook.__wdc ||
3626 (hook.__wdc = () => {
3627 // only fire the hook if the target instance is NOT in a deactivated branch.
3628 let current = target;
3629 while (current) {
3630 if (current.isDeactivated) {
3631 return;
3632 }
3633 current = current.parent;
3634 }
3635 hook();
3636 });
3637 injectHook(type, wrappedHook, target);
3638 // In addition to registering it on the target instance, we walk up the parent
3639 // chain and register it on all ancestor instances that are keep-alive roots.
3640 // This avoids the need to walk the entire component tree when invoking these
3641 // hooks, and more importantly, avoids the need to track child components in
3642 // arrays.
3643 if (target) {
3644 let current = target.parent;
3645 while (current && current.parent) {
3646 if (isKeepAlive(current.parent.vnode)) {
3647 injectToKeepAliveRoot(wrappedHook, type, target, current);
3648 }
3649 current = current.parent;
3650 }
3651 }
3652}
3653function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
3654 // injectHook wraps the original for error handling, so make sure to remove
3655 // the wrapped version.
3656 const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
3657 onUnmounted(() => {
3658 remove(keepAliveRoot[type], injected);
3659 }, target);
3660}
3661function resetShapeFlag(vnode) {
3662 let shapeFlag = vnode.shapeFlag;
3663 if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
3664 shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
3665 }
3666 if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
3667 shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
3668 }
3669 vnode.shapeFlag = shapeFlag;
3670}
3671function getInnerChild(vnode) {
3672 return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
3673}
3674
3675function injectHook(type, hook, target = currentInstance, prepend = false) {
3676 if (target) {
3677 const hooks = target[type] || (target[type] = []);
3678 // cache the error handling wrapper for injected hooks so the same hook
3679 // can be properly deduped by the scheduler. "__weh" stands for "with error
3680 // handling".
3681 const wrappedHook = hook.__weh ||
3682 (hook.__weh = (...args) => {
3683 if (target.isUnmounted) {
3684 return;
3685 }
3686 // disable tracking inside all lifecycle hooks
3687 // since they can potentially be called inside effects.
3688 pauseTracking();
3689 // Set currentInstance during hook invocation.
3690 // This assumes the hook does not synchronously trigger other hooks, which
3691 // can only be false when the user does something really funky.
3692 setCurrentInstance(target);
3693 const res = callWithAsyncErrorHandling(hook, target, type, args);
3694 unsetCurrentInstance();
3695 resetTracking();
3696 return res;
3697 });
3698 if (prepend) {
3699 hooks.unshift(wrappedHook);
3700 }
3701 else {
3702 hooks.push(wrappedHook);
3703 }
3704 return wrappedHook;
3705 }
3706 else {
3707 const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
3708 warn$1(`${apiName} is called when there is no active component instance to be ` +
3709 `associated with. ` +
3710 `Lifecycle injection APIs can only be used during execution of setup().` +
3711 (` If you are using async setup(), make sure to register lifecycle ` +
3712 `hooks before the first await statement.`
3713 ));
3714 }
3715}
3716const createHook = (lifecycle) => (hook, target = currentInstance) =>
3717// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
3718(!isInSSRComponentSetup || lifecycle === "sp" /* SERVER_PREFETCH */) &&
3719 injectHook(lifecycle, hook, target);
3720const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
3721const onMounted = createHook("m" /* MOUNTED */);
3722const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
3723const onUpdated = createHook("u" /* UPDATED */);
3724const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
3725const onUnmounted = createHook("um" /* UNMOUNTED */);
3726const onServerPrefetch = createHook("sp" /* SERVER_PREFETCH */);
3727const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
3728const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
3729function onErrorCaptured(hook, target = currentInstance) {
3730 injectHook("ec" /* ERROR_CAPTURED */, hook, target);
3731}
3732
3733function createDuplicateChecker() {
3734 const cache = Object.create(null);
3735 return (type, key) => {
3736 if (cache[key]) {
3737 warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
3738 }
3739 else {
3740 cache[key] = type;
3741 }
3742 };
3743}
3744let shouldCacheAccess = true;
3745function applyOptions(instance) {
3746 const options = resolveMergedOptions(instance);
3747 const publicThis = instance.proxy;
3748 const ctx = instance.ctx;
3749 // do not cache property access on public proxy during state initialization
3750 shouldCacheAccess = false;
3751 // call beforeCreate first before accessing other options since
3752 // the hook may mutate resolved options (#2791)
3753 if (options.beforeCreate) {
3754 callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
3755 }
3756 const {
3757 // state
3758 data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
3759 // lifecycle
3760 created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
3761 // public API
3762 expose, inheritAttrs,
3763 // assets
3764 components, directives, filters } = options;
3765 const checkDuplicateProperties = createDuplicateChecker() ;
3766 {
3767 const [propsOptions] = instance.propsOptions;
3768 if (propsOptions) {
3769 for (const key in propsOptions) {
3770 checkDuplicateProperties("Props" /* PROPS */, key);
3771 }
3772 }
3773 }
3774 // options initialization order (to be consistent with Vue 2):
3775 // - props (already done outside of this function)
3776 // - inject
3777 // - methods
3778 // - data (deferred since it relies on `this` access)
3779 // - computed
3780 // - watch (deferred since it relies on `this` access)
3781 if (injectOptions) {
3782 resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
3783 }
3784 if (methods) {
3785 for (const key in methods) {
3786 const methodHandler = methods[key];
3787 if (isFunction(methodHandler)) {
3788 // In dev mode, we use the `createRenderContext` function to define
3789 // methods to the proxy target, and those are read-only but
3790 // reconfigurable, so it needs to be redefined here
3791 {
3792 Object.defineProperty(ctx, key, {
3793 value: methodHandler.bind(publicThis),
3794 configurable: true,
3795 enumerable: true,
3796 writable: true
3797 });
3798 }
3799 {
3800 checkDuplicateProperties("Methods" /* METHODS */, key);
3801 }
3802 }
3803 else {
3804 warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
3805 `Did you reference the function correctly?`);
3806 }
3807 }
3808 }
3809 if (dataOptions) {
3810 if (!isFunction(dataOptions)) {
3811 warn$1(`The data option must be a function. ` +
3812 `Plain object usage is no longer supported.`);
3813 }
3814 const data = dataOptions.call(publicThis, publicThis);
3815 if (isPromise(data)) {
3816 warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
3817 `intend to perform data fetching before component renders, use ` +
3818 `async setup() + <Suspense>.`);
3819 }
3820 if (!isObject(data)) {
3821 warn$1(`data() should return an object.`);
3822 }
3823 else {
3824 instance.data = reactive(data);
3825 {
3826 for (const key in data) {
3827 checkDuplicateProperties("Data" /* DATA */, key);
3828 // expose data on ctx during dev
3829 if (key[0] !== '$' && key[0] !== '_') {
3830 Object.defineProperty(ctx, key, {
3831 configurable: true,
3832 enumerable: true,
3833 get: () => data[key],
3834 set: NOOP
3835 });
3836 }
3837 }
3838 }
3839 }
3840 }
3841 // state initialization complete at this point - start caching access
3842 shouldCacheAccess = true;
3843 if (computedOptions) {
3844 for (const key in computedOptions) {
3845 const opt = computedOptions[key];
3846 const get = isFunction(opt)
3847 ? opt.bind(publicThis, publicThis)
3848 : isFunction(opt.get)
3849 ? opt.get.bind(publicThis, publicThis)
3850 : NOOP;
3851 if (get === NOOP) {
3852 warn$1(`Computed property "${key}" has no getter.`);
3853 }
3854 const set = !isFunction(opt) && isFunction(opt.set)
3855 ? opt.set.bind(publicThis)
3856 : () => {
3857 warn$1(`Write operation failed: computed property "${key}" is readonly.`);
3858 }
3859 ;
3860 const c = computed({
3861 get,
3862 set
3863 });
3864 Object.defineProperty(ctx, key, {
3865 enumerable: true,
3866 configurable: true,
3867 get: () => c.value,
3868 set: v => (c.value = v)
3869 });
3870 {
3871 checkDuplicateProperties("Computed" /* COMPUTED */, key);
3872 }
3873 }
3874 }
3875 if (watchOptions) {
3876 for (const key in watchOptions) {
3877 createWatcher(watchOptions[key], ctx, publicThis, key);
3878 }
3879 }
3880 if (provideOptions) {
3881 const provides = isFunction(provideOptions)
3882 ? provideOptions.call(publicThis)
3883 : provideOptions;
3884 Reflect.ownKeys(provides).forEach(key => {
3885 provide(key, provides[key]);
3886 });
3887 }
3888 if (created) {
3889 callHook(created, instance, "c" /* CREATED */);
3890 }
3891 function registerLifecycleHook(register, hook) {
3892 if (isArray(hook)) {
3893 hook.forEach(_hook => register(_hook.bind(publicThis)));
3894 }
3895 else if (hook) {
3896 register(hook.bind(publicThis));
3897 }
3898 }
3899 registerLifecycleHook(onBeforeMount, beforeMount);
3900 registerLifecycleHook(onMounted, mounted);
3901 registerLifecycleHook(onBeforeUpdate, beforeUpdate);
3902 registerLifecycleHook(onUpdated, updated);
3903 registerLifecycleHook(onActivated, activated);
3904 registerLifecycleHook(onDeactivated, deactivated);
3905 registerLifecycleHook(onErrorCaptured, errorCaptured);
3906 registerLifecycleHook(onRenderTracked, renderTracked);
3907 registerLifecycleHook(onRenderTriggered, renderTriggered);
3908 registerLifecycleHook(onBeforeUnmount, beforeUnmount);
3909 registerLifecycleHook(onUnmounted, unmounted);
3910 registerLifecycleHook(onServerPrefetch, serverPrefetch);
3911 if (isArray(expose)) {
3912 if (expose.length) {
3913 const exposed = instance.exposed || (instance.exposed = {});
3914 expose.forEach(key => {
3915 Object.defineProperty(exposed, key, {
3916 get: () => publicThis[key],
3917 set: val => (publicThis[key] = val)
3918 });
3919 });
3920 }
3921 else if (!instance.exposed) {
3922 instance.exposed = {};
3923 }
3924 }
3925 // options that are handled when creating the instance but also need to be
3926 // applied from mixins
3927 if (render && instance.render === NOOP) {
3928 instance.render = render;
3929 }
3930 if (inheritAttrs != null) {
3931 instance.inheritAttrs = inheritAttrs;
3932 }
3933 // asset options.
3934 if (components)
3935 instance.components = components;
3936 if (directives)
3937 instance.directives = directives;
3938}
3939function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
3940 if (isArray(injectOptions)) {
3941 injectOptions = normalizeInject(injectOptions);
3942 }
3943 for (const key in injectOptions) {
3944 const opt = injectOptions[key];
3945 let injected;
3946 if (isObject(opt)) {
3947 if ('default' in opt) {
3948 injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
3949 }
3950 else {
3951 injected = inject(opt.from || key);
3952 }
3953 }
3954 else {
3955 injected = inject(opt);
3956 }
3957 if (isRef(injected)) {
3958 // TODO remove the check in 3.3
3959 if (unwrapRef) {
3960 Object.defineProperty(ctx, key, {
3961 enumerable: true,
3962 configurable: true,
3963 get: () => injected.value,
3964 set: v => (injected.value = v)
3965 });
3966 }
3967 else {
3968 {
3969 warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
3970 `and no longer needs \`.value\` in the next minor release. ` +
3971 `To opt-in to the new behavior now, ` +
3972 `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
3973 `temporary and will not be needed in the future.)`);
3974 }
3975 ctx[key] = injected;
3976 }
3977 }
3978 else {
3979 ctx[key] = injected;
3980 }
3981 {
3982 checkDuplicateProperties("Inject" /* INJECT */, key);
3983 }
3984 }
3985}
3986function callHook(hook, instance, type) {
3987 callWithAsyncErrorHandling(isArray(hook)
3988 ? hook.map(h => h.bind(instance.proxy))
3989 : hook.bind(instance.proxy), instance, type);
3990}
3991function createWatcher(raw, ctx, publicThis, key) {
3992 const getter = key.includes('.')
3993 ? createPathGetter(publicThis, key)
3994 : () => publicThis[key];
3995 if (isString(raw)) {
3996 const handler = ctx[raw];
3997 if (isFunction(handler)) {
3998 watch(getter, handler);
3999 }
4000 else {
4001 warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
4002 }
4003 }
4004 else if (isFunction(raw)) {
4005 watch(getter, raw.bind(publicThis));
4006 }
4007 else if (isObject(raw)) {
4008 if (isArray(raw)) {
4009 raw.forEach(r => createWatcher(r, ctx, publicThis, key));
4010 }
4011 else {
4012 const handler = isFunction(raw.handler)
4013 ? raw.handler.bind(publicThis)
4014 : ctx[raw.handler];
4015 if (isFunction(handler)) {
4016 watch(getter, handler, raw);
4017 }
4018 else {
4019 warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
4020 }
4021 }
4022 }
4023 else {
4024 warn$1(`Invalid watch option: "${key}"`, raw);
4025 }
4026}
4027/**
4028 * Resolve merged options and cache it on the component.
4029 * This is done only once per-component since the merging does not involve
4030 * instances.
4031 */
4032function resolveMergedOptions(instance) {
4033 const base = instance.type;
4034 const { mixins, extends: extendsOptions } = base;
4035 const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4036 const cached = cache.get(base);
4037 let resolved;
4038 if (cached) {
4039 resolved = cached;
4040 }
4041 else if (!globalMixins.length && !mixins && !extendsOptions) {
4042 {
4043 resolved = base;
4044 }
4045 }
4046 else {
4047 resolved = {};
4048 if (globalMixins.length) {
4049 globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4050 }
4051 mergeOptions(resolved, base, optionMergeStrategies);
4052 }
4053 cache.set(base, resolved);
4054 return resolved;
4055}
4056function mergeOptions(to, from, strats, asMixin = false) {
4057 const { mixins, extends: extendsOptions } = from;
4058 if (extendsOptions) {
4059 mergeOptions(to, extendsOptions, strats, true);
4060 }
4061 if (mixins) {
4062 mixins.forEach((m) => mergeOptions(to, m, strats, true));
4063 }
4064 for (const key in from) {
4065 if (asMixin && key === 'expose') {
4066 warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
4067 `It should only be declared in the base component itself.`);
4068 }
4069 else {
4070 const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4071 to[key] = strat ? strat(to[key], from[key]) : from[key];
4072 }
4073 }
4074 return to;
4075}
4076const internalOptionMergeStrats = {
4077 data: mergeDataFn,
4078 props: mergeObjectOptions,
4079 emits: mergeObjectOptions,
4080 // objects
4081 methods: mergeObjectOptions,
4082 computed: mergeObjectOptions,
4083 // lifecycle
4084 beforeCreate: mergeAsArray,
4085 created: mergeAsArray,
4086 beforeMount: mergeAsArray,
4087 mounted: mergeAsArray,
4088 beforeUpdate: mergeAsArray,
4089 updated: mergeAsArray,
4090 beforeDestroy: mergeAsArray,
4091 beforeUnmount: mergeAsArray,
4092 destroyed: mergeAsArray,
4093 unmounted: mergeAsArray,
4094 activated: mergeAsArray,
4095 deactivated: mergeAsArray,
4096 errorCaptured: mergeAsArray,
4097 serverPrefetch: mergeAsArray,
4098 // assets
4099 components: mergeObjectOptions,
4100 directives: mergeObjectOptions,
4101 // watch
4102 watch: mergeWatchOptions,
4103 // provide / inject
4104 provide: mergeDataFn,
4105 inject: mergeInject
4106};
4107function mergeDataFn(to, from) {
4108 if (!from) {
4109 return to;
4110 }
4111 if (!to) {
4112 return from;
4113 }
4114 return function mergedDataFn() {
4115 return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4116 };
4117}
4118function mergeInject(to, from) {
4119 return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4120}
4121function normalizeInject(raw) {
4122 if (isArray(raw)) {
4123 const res = {};
4124 for (let i = 0; i < raw.length; i++) {
4125 res[raw[i]] = raw[i];
4126 }
4127 return res;
4128 }
4129 return raw;
4130}
4131function mergeAsArray(to, from) {
4132 return to ? [...new Set([].concat(to, from))] : from;
4133}
4134function mergeObjectOptions(to, from) {
4135 return to ? extend(extend(Object.create(null), to), from) : from;
4136}
4137function mergeWatchOptions(to, from) {
4138 if (!to)
4139 return from;
4140 if (!from)
4141 return to;
4142 const merged = extend(Object.create(null), to);
4143 for (const key in from) {
4144 merged[key] = mergeAsArray(to[key], from[key]);
4145 }
4146 return merged;
4147}
4148
4149function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
4150isSSR = false) {
4151 const props = {};
4152 const attrs = {};
4153 def(attrs, InternalObjectKey, 1);
4154 instance.propsDefaults = Object.create(null);
4155 setFullProps(instance, rawProps, props, attrs);
4156 // ensure all declared prop keys are present
4157 for (const key in instance.propsOptions[0]) {
4158 if (!(key in props)) {
4159 props[key] = undefined;
4160 }
4161 }
4162 // validation
4163 {
4164 validateProps(rawProps || {}, props, instance);
4165 }
4166 if (isStateful) {
4167 // stateful
4168 instance.props = isSSR ? props : shallowReactive(props);
4169 }
4170 else {
4171 if (!instance.type.props) {
4172 // functional w/ optional props, props === attrs
4173 instance.props = attrs;
4174 }
4175 else {
4176 // functional w/ declared props
4177 instance.props = props;
4178 }
4179 }
4180 instance.attrs = attrs;
4181}
4182function updateProps(instance, rawProps, rawPrevProps, optimized) {
4183 const { props, attrs, vnode: { patchFlag } } = instance;
4184 const rawCurrentProps = toRaw(props);
4185 const [options] = instance.propsOptions;
4186 let hasAttrsChanged = false;
4187 if (
4188 // always force full diff in dev
4189 // - #1942 if hmr is enabled with sfc component
4190 // - vite#872 non-sfc component used by sfc component
4191 !((instance.type.__hmrId ||
4192 (instance.parent && instance.parent.type.__hmrId))) &&
4193 (optimized || patchFlag > 0) &&
4194 !(patchFlag & 16 /* FULL_PROPS */)) {
4195 if (patchFlag & 8 /* PROPS */) {
4196 // Compiler-generated props & no keys change, just set the updated
4197 // the props.
4198 const propsToUpdate = instance.vnode.dynamicProps;
4199 for (let i = 0; i < propsToUpdate.length; i++) {
4200 let key = propsToUpdate[i];
4201 // PROPS flag guarantees rawProps to be non-null
4202 const value = rawProps[key];
4203 if (options) {
4204 // attr / props separation was done on init and will be consistent
4205 // in this code path, so just check if attrs have it.
4206 if (hasOwn(attrs, key)) {
4207 if (value !== attrs[key]) {
4208 attrs[key] = value;
4209 hasAttrsChanged = true;
4210 }
4211 }
4212 else {
4213 const camelizedKey = camelize(key);
4214 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
4215 }
4216 }
4217 else {
4218 if (value !== attrs[key]) {
4219 attrs[key] = value;
4220 hasAttrsChanged = true;
4221 }
4222 }
4223 }
4224 }
4225 }
4226 else {
4227 // full props update.
4228 if (setFullProps(instance, rawProps, props, attrs)) {
4229 hasAttrsChanged = true;
4230 }
4231 // in case of dynamic props, check if we need to delete keys from
4232 // the props object
4233 let kebabKey;
4234 for (const key in rawCurrentProps) {
4235 if (!rawProps ||
4236 // for camelCase
4237 (!hasOwn(rawProps, key) &&
4238 // it's possible the original props was passed in as kebab-case
4239 // and converted to camelCase (#955)
4240 ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
4241 if (options) {
4242 if (rawPrevProps &&
4243 // for camelCase
4244 (rawPrevProps[key] !== undefined ||
4245 // for kebab-case
4246 rawPrevProps[kebabKey] !== undefined)) {
4247 props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
4248 }
4249 }
4250 else {
4251 delete props[key];
4252 }
4253 }
4254 }
4255 // in the case of functional component w/o props declaration, props and
4256 // attrs point to the same object so it should already have been updated.
4257 if (attrs !== rawCurrentProps) {
4258 for (const key in attrs) {
4259 if (!rawProps || !hasOwn(rawProps, key)) {
4260 delete attrs[key];
4261 hasAttrsChanged = true;
4262 }
4263 }
4264 }
4265 }
4266 // trigger updates for $attrs in case it's used in component slots
4267 if (hasAttrsChanged) {
4268 trigger(instance, "set" /* SET */, '$attrs');
4269 }
4270 {
4271 validateProps(rawProps || {}, props, instance);
4272 }
4273}
4274function setFullProps(instance, rawProps, props, attrs) {
4275 const [options, needCastKeys] = instance.propsOptions;
4276 let hasAttrsChanged = false;
4277 let rawCastValues;
4278 if (rawProps) {
4279 for (let key in rawProps) {
4280 // key, ref are reserved and never passed down
4281 if (isReservedProp(key)) {
4282 continue;
4283 }
4284 const value = rawProps[key];
4285 // prop option names are camelized during normalization, so to support
4286 // kebab -> camel conversion here we need to camelize the key.
4287 let camelKey;
4288 if (options && hasOwn(options, (camelKey = camelize(key)))) {
4289 if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4290 props[camelKey] = value;
4291 }
4292 else {
4293 (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4294 }
4295 }
4296 else if (!isEmitListener(instance.emitsOptions, key)) {
4297 if (value !== attrs[key]) {
4298 attrs[key] = value;
4299 hasAttrsChanged = true;
4300 }
4301 }
4302 }
4303 }
4304 if (needCastKeys) {
4305 const rawCurrentProps = toRaw(props);
4306 const castValues = rawCastValues || EMPTY_OBJ;
4307 for (let i = 0; i < needCastKeys.length; i++) {
4308 const key = needCastKeys[i];
4309 props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
4310 }
4311 }
4312 return hasAttrsChanged;
4313}
4314function resolvePropValue(options, props, key, value, instance, isAbsent) {
4315 const opt = options[key];
4316 if (opt != null) {
4317 const hasDefault = hasOwn(opt, 'default');
4318 // default values
4319 if (hasDefault && value === undefined) {
4320 const defaultValue = opt.default;
4321 if (opt.type !== Function && isFunction(defaultValue)) {
4322 const { propsDefaults } = instance;
4323 if (key in propsDefaults) {
4324 value = propsDefaults[key];
4325 }
4326 else {
4327 setCurrentInstance(instance);
4328 value = propsDefaults[key] = defaultValue.call(null, props);
4329 unsetCurrentInstance();
4330 }
4331 }
4332 else {
4333 value = defaultValue;
4334 }
4335 }
4336 // boolean casting
4337 if (opt[0 /* shouldCast */]) {
4338 if (isAbsent && !hasDefault) {
4339 value = false;
4340 }
4341 else if (opt[1 /* shouldCastTrue */] &&
4342 (value === '' || value === hyphenate(key))) {
4343 value = true;
4344 }
4345 }
4346 }
4347 return value;
4348}
4349function normalizePropsOptions(comp, appContext, asMixin = false) {
4350 const cache = appContext.propsCache;
4351 const cached = cache.get(comp);
4352 if (cached) {
4353 return cached;
4354 }
4355 const raw = comp.props;
4356 const normalized = {};
4357 const needCastKeys = [];
4358 // apply mixin/extends props
4359 let hasExtends = false;
4360 if (!isFunction(comp)) {
4361 const extendProps = (raw) => {
4362 hasExtends = true;
4363 const [props, keys] = normalizePropsOptions(raw, appContext, true);
4364 extend(normalized, props);
4365 if (keys)
4366 needCastKeys.push(...keys);
4367 };
4368 if (!asMixin && appContext.mixins.length) {
4369 appContext.mixins.forEach(extendProps);
4370 }
4371 if (comp.extends) {
4372 extendProps(comp.extends);
4373 }
4374 if (comp.mixins) {
4375 comp.mixins.forEach(extendProps);
4376 }
4377 }
4378 if (!raw && !hasExtends) {
4379 cache.set(comp, EMPTY_ARR);
4380 return EMPTY_ARR;
4381 }
4382 if (isArray(raw)) {
4383 for (let i = 0; i < raw.length; i++) {
4384 if (!isString(raw[i])) {
4385 warn$1(`props must be strings when using array syntax.`, raw[i]);
4386 }
4387 const normalizedKey = camelize(raw[i]);
4388 if (validatePropName(normalizedKey)) {
4389 normalized[normalizedKey] = EMPTY_OBJ;
4390 }
4391 }
4392 }
4393 else if (raw) {
4394 if (!isObject(raw)) {
4395 warn$1(`invalid props options`, raw);
4396 }
4397 for (const key in raw) {
4398 const normalizedKey = camelize(key);
4399 if (validatePropName(normalizedKey)) {
4400 const opt = raw[key];
4401 const prop = (normalized[normalizedKey] =
4402 isArray(opt) || isFunction(opt) ? { type: opt } : opt);
4403 if (prop) {
4404 const booleanIndex = getTypeIndex(Boolean, prop.type);
4405 const stringIndex = getTypeIndex(String, prop.type);
4406 prop[0 /* shouldCast */] = booleanIndex > -1;
4407 prop[1 /* shouldCastTrue */] =
4408 stringIndex < 0 || booleanIndex < stringIndex;
4409 // if the prop needs boolean casting or default value
4410 if (booleanIndex > -1 || hasOwn(prop, 'default')) {
4411 needCastKeys.push(normalizedKey);
4412 }
4413 }
4414 }
4415 }
4416 }
4417 const res = [normalized, needCastKeys];
4418 cache.set(comp, res);
4419 return res;
4420}
4421function validatePropName(key) {
4422 if (key[0] !== '$') {
4423 return true;
4424 }
4425 else {
4426 warn$1(`Invalid prop name: "${key}" is a reserved property.`);
4427 }
4428 return false;
4429}
4430// use function string name to check type constructors
4431// so that it works across vms / iframes.
4432function getType(ctor) {
4433 const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
4434 return match ? match[1] : ctor === null ? 'null' : '';
4435}
4436function isSameType(a, b) {
4437 return getType(a) === getType(b);
4438}
4439function getTypeIndex(type, expectedTypes) {
4440 if (isArray(expectedTypes)) {
4441 return expectedTypes.findIndex(t => isSameType(t, type));
4442 }
4443 else if (isFunction(expectedTypes)) {
4444 return isSameType(expectedTypes, type) ? 0 : -1;
4445 }
4446 return -1;
4447}
4448/**
4449 * dev only
4450 */
4451function validateProps(rawProps, props, instance) {
4452 const resolvedValues = toRaw(props);
4453 const options = instance.propsOptions[0];
4454 for (const key in options) {
4455 let opt = options[key];
4456 if (opt == null)
4457 continue;
4458 validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
4459 }
4460}
4461/**
4462 * dev only
4463 */
4464function validateProp(name, value, prop, isAbsent) {
4465 const { type, required, validator } = prop;
4466 // required!
4467 if (required && isAbsent) {
4468 warn$1('Missing required prop: "' + name + '"');
4469 return;
4470 }
4471 // missing but optional
4472 if (value == null && !prop.required) {
4473 return;
4474 }
4475 // type check
4476 if (type != null && type !== true) {
4477 let isValid = false;
4478 const types = isArray(type) ? type : [type];
4479 const expectedTypes = [];
4480 // value is valid as long as one of the specified types match
4481 for (let i = 0; i < types.length && !isValid; i++) {
4482 const { valid, expectedType } = assertType(value, types[i]);
4483 expectedTypes.push(expectedType || '');
4484 isValid = valid;
4485 }
4486 if (!isValid) {
4487 warn$1(getInvalidTypeMessage(name, value, expectedTypes));
4488 return;
4489 }
4490 }
4491 // custom validator
4492 if (validator && !validator(value)) {
4493 warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
4494 }
4495}
4496const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
4497/**
4498 * dev only
4499 */
4500function assertType(value, type) {
4501 let valid;
4502 const expectedType = getType(type);
4503 if (isSimpleType(expectedType)) {
4504 const t = typeof value;
4505 valid = t === expectedType.toLowerCase();
4506 // for primitive wrapper objects
4507 if (!valid && t === 'object') {
4508 valid = value instanceof type;
4509 }
4510 }
4511 else if (expectedType === 'Object') {
4512 valid = isObject(value);
4513 }
4514 else if (expectedType === 'Array') {
4515 valid = isArray(value);
4516 }
4517 else if (expectedType === 'null') {
4518 valid = value === null;
4519 }
4520 else {
4521 valid = value instanceof type;
4522 }
4523 return {
4524 valid,
4525 expectedType
4526 };
4527}
4528/**
4529 * dev only
4530 */
4531function getInvalidTypeMessage(name, value, expectedTypes) {
4532 let message = `Invalid prop: type check failed for prop "${name}".` +
4533 ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
4534 const expectedType = expectedTypes[0];
4535 const receivedType = toRawType(value);
4536 const expectedValue = styleValue(value, expectedType);
4537 const receivedValue = styleValue(value, receivedType);
4538 // check if we need to specify expected value
4539 if (expectedTypes.length === 1 &&
4540 isExplicable(expectedType) &&
4541 !isBoolean(expectedType, receivedType)) {
4542 message += ` with value ${expectedValue}`;
4543 }
4544 message += `, got ${receivedType} `;
4545 // check if we need to specify received value
4546 if (isExplicable(receivedType)) {
4547 message += `with value ${receivedValue}.`;
4548 }
4549 return message;
4550}
4551/**
4552 * dev only
4553 */
4554function styleValue(value, type) {
4555 if (type === 'String') {
4556 return `"${value}"`;
4557 }
4558 else if (type === 'Number') {
4559 return `${Number(value)}`;
4560 }
4561 else {
4562 return `${value}`;
4563 }
4564}
4565/**
4566 * dev only
4567 */
4568function isExplicable(type) {
4569 const explicitTypes = ['string', 'number', 'boolean'];
4570 return explicitTypes.some(elem => type.toLowerCase() === elem);
4571}
4572/**
4573 * dev only
4574 */
4575function isBoolean(...args) {
4576 return args.some(elem => elem.toLowerCase() === 'boolean');
4577}
4578
4579const isInternalKey = (key) => key[0] === '_' || key === '$stable';
4580const normalizeSlotValue = (value) => isArray(value)
4581 ? value.map(normalizeVNode)
4582 : [normalizeVNode(value)];
4583const normalizeSlot = (key, rawSlot, ctx) => {
4584 const normalized = withCtx((...args) => {
4585 if (currentInstance) {
4586 warn$1(`Slot "${key}" invoked outside of the render function: ` +
4587 `this will not track dependencies used in the slot. ` +
4588 `Invoke the slot function inside the render function instead.`);
4589 }
4590 return normalizeSlotValue(rawSlot(...args));
4591 }, ctx);
4592 normalized._c = false;
4593 return normalized;
4594};
4595const normalizeObjectSlots = (rawSlots, slots, instance) => {
4596 const ctx = rawSlots._ctx;
4597 for (const key in rawSlots) {
4598 if (isInternalKey(key))
4599 continue;
4600 const value = rawSlots[key];
4601 if (isFunction(value)) {
4602 slots[key] = normalizeSlot(key, value, ctx);
4603 }
4604 else if (value != null) {
4605 {
4606 warn$1(`Non-function value encountered for slot "${key}". ` +
4607 `Prefer function slots for better performance.`);
4608 }
4609 const normalized = normalizeSlotValue(value);
4610 slots[key] = () => normalized;
4611 }
4612 }
4613};
4614const normalizeVNodeSlots = (instance, children) => {
4615 if (!isKeepAlive(instance.vnode) &&
4616 !(false )) {
4617 warn$1(`Non-function value encountered for default slot. ` +
4618 `Prefer function slots for better performance.`);
4619 }
4620 const normalized = normalizeSlotValue(children);
4621 instance.slots.default = () => normalized;
4622};
4623const initSlots = (instance, children) => {
4624 if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
4625 const type = children._;
4626 if (type) {
4627 // users can get the shallow readonly version of the slots object through `this.$slots`,
4628 // we should avoid the proxy object polluting the slots of the internal instance
4629 instance.slots = toRaw(children);
4630 // make compiler marker non-enumerable
4631 def(children, '_', type);
4632 }
4633 else {
4634 normalizeObjectSlots(children, (instance.slots = {}));
4635 }
4636 }
4637 else {
4638 instance.slots = {};
4639 if (children) {
4640 normalizeVNodeSlots(instance, children);
4641 }
4642 }
4643 def(instance.slots, InternalObjectKey, 1);
4644};
4645const updateSlots = (instance, children, optimized) => {
4646 const { vnode, slots } = instance;
4647 let needDeletionCheck = true;
4648 let deletionComparisonTarget = EMPTY_OBJ;
4649 if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
4650 const type = children._;
4651 if (type) {
4652 // compiled slots.
4653 if (isHmrUpdating) {
4654 // Parent was HMR updated so slot content may have changed.
4655 // force update slots and mark instance for hmr as well
4656 extend(slots, children);
4657 }
4658 else if (optimized && type === 1 /* STABLE */) {
4659 // compiled AND stable.
4660 // no need to update, and skip stale slots removal.
4661 needDeletionCheck = false;
4662 }
4663 else {
4664 // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
4665 // normalization.
4666 extend(slots, children);
4667 // #2893
4668 // when rendering the optimized slots by manually written render function,
4669 // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
4670 // i.e. let the `renderSlot` create the bailed Fragment
4671 if (!optimized && type === 1 /* STABLE */) {
4672 delete slots._;
4673 }
4674 }
4675 }
4676 else {
4677 needDeletionCheck = !children.$stable;
4678 normalizeObjectSlots(children, slots);
4679 }
4680 deletionComparisonTarget = children;
4681 }
4682 else if (children) {
4683 // non slot object children (direct value) passed to a component
4684 normalizeVNodeSlots(instance, children);
4685 deletionComparisonTarget = { default: 1 };
4686 }
4687 // delete stale slots
4688 if (needDeletionCheck) {
4689 for (const key in slots) {
4690 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
4691 delete slots[key];
4692 }
4693 }
4694 }
4695};
4696
4697/**
4698Runtime helper for applying directives to a vnode. Example usage:
4699
4700const comp = resolveComponent('comp')
4701const foo = resolveDirective('foo')
4702const bar = resolveDirective('bar')
4703
4704return withDirectives(h(comp), [
4705 [foo, this.x],
4706 [bar, this.y]
4707])
4708*/
4709const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4710function validateDirectiveName(name) {
4711 if (isBuiltInDirective(name)) {
4712 warn$1('Do not use built-in directive ids as custom directive id: ' + name);
4713 }
4714}
4715/**
4716 * Adds directives to a VNode.
4717 */
4718function withDirectives(vnode, directives) {
4719 const internalInstance = currentRenderingInstance;
4720 if (internalInstance === null) {
4721 warn$1(`withDirectives can only be used inside render functions.`);
4722 return vnode;
4723 }
4724 const instance = internalInstance.proxy;
4725 const bindings = vnode.dirs || (vnode.dirs = []);
4726 for (let i = 0; i < directives.length; i++) {
4727 let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4728 if (isFunction(dir)) {
4729 dir = {
4730 mounted: dir,
4731 updated: dir
4732 };
4733 }
4734 if (dir.deep) {
4735 traverse(value);
4736 }
4737 bindings.push({
4738 dir,
4739 instance,
4740 value,
4741 oldValue: void 0,
4742 arg,
4743 modifiers
4744 });
4745 }
4746 return vnode;
4747}
4748function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4749 const bindings = vnode.dirs;
4750 const oldBindings = prevVNode && prevVNode.dirs;
4751 for (let i = 0; i < bindings.length; i++) {
4752 const binding = bindings[i];
4753 if (oldBindings) {
4754 binding.oldValue = oldBindings[i].value;
4755 }
4756 let hook = binding.dir[name];
4757 if (hook) {
4758 // disable tracking inside all lifecycle hooks
4759 // since they can potentially be called inside effects.
4760 pauseTracking();
4761 callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
4762 vnode.el,
4763 binding,
4764 vnode,
4765 prevVNode
4766 ]);
4767 resetTracking();
4768 }
4769 }
4770}
4771
4772function createAppContext() {
4773 return {
4774 app: null,
4775 config: {
4776 isNativeTag: NO,
4777 performance: false,
4778 globalProperties: {},
4779 optionMergeStrategies: {},
4780 errorHandler: undefined,
4781 warnHandler: undefined,
4782 compilerOptions: {}
4783 },
4784 mixins: [],
4785 components: {},
4786 directives: {},
4787 provides: Object.create(null),
4788 optionsCache: new WeakMap(),
4789 propsCache: new WeakMap(),
4790 emitsCache: new WeakMap()
4791 };
4792}
4793let uid = 0;
4794function createAppAPI(render, hydrate) {
4795 return function createApp(rootComponent, rootProps = null) {
4796 if (rootProps != null && !isObject(rootProps)) {
4797 warn$1(`root props passed to app.mount() must be an object.`);
4798 rootProps = null;
4799 }
4800 const context = createAppContext();
4801 const installedPlugins = new Set();
4802 let isMounted = false;
4803 const app = (context.app = {
4804 _uid: uid++,
4805 _component: rootComponent,
4806 _props: rootProps,
4807 _container: null,
4808 _context: context,
4809 _instance: null,
4810 version,
4811 get config() {
4812 return context.config;
4813 },
4814 set config(v) {
4815 {
4816 warn$1(`app.config cannot be replaced. Modify individual options instead.`);
4817 }
4818 },
4819 use(plugin, ...options) {
4820 if (installedPlugins.has(plugin)) {
4821 warn$1(`Plugin has already been applied to target app.`);
4822 }
4823 else if (plugin && isFunction(plugin.install)) {
4824 installedPlugins.add(plugin);
4825 plugin.install(app, ...options);
4826 }
4827 else if (isFunction(plugin)) {
4828 installedPlugins.add(plugin);
4829 plugin(app, ...options);
4830 }
4831 else {
4832 warn$1(`A plugin must either be a function or an object with an "install" ` +
4833 `function.`);
4834 }
4835 return app;
4836 },
4837 mixin(mixin) {
4838 {
4839 if (!context.mixins.includes(mixin)) {
4840 context.mixins.push(mixin);
4841 }
4842 else {
4843 warn$1('Mixin has already been applied to target app' +
4844 (mixin.name ? `: ${mixin.name}` : ''));
4845 }
4846 }
4847 return app;
4848 },
4849 component(name, component) {
4850 {
4851 validateComponentName(name, context.config);
4852 }
4853 if (!component) {
4854 return context.components[name];
4855 }
4856 if (context.components[name]) {
4857 warn$1(`Component "${name}" has already been registered in target app.`);
4858 }
4859 context.components[name] = component;
4860 return app;
4861 },
4862 directive(name, directive) {
4863 {
4864 validateDirectiveName(name);
4865 }
4866 if (!directive) {
4867 return context.directives[name];
4868 }
4869 if (context.directives[name]) {
4870 warn$1(`Directive "${name}" has already been registered in target app.`);
4871 }
4872 context.directives[name] = directive;
4873 return app;
4874 },
4875 mount(rootContainer, isHydrate, isSVG) {
4876 if (!isMounted) {
4877 const vnode = createVNode(rootComponent, rootProps);
4878 // store app context on the root VNode.
4879 // this will be set on the root instance on initial mount.
4880 vnode.appContext = context;
4881 // HMR root reload
4882 {
4883 context.reload = () => {
4884 render(cloneVNode(vnode), rootContainer, isSVG);
4885 };
4886 }
4887 if (isHydrate && hydrate) {
4888 hydrate(vnode, rootContainer);
4889 }
4890 else {
4891 render(vnode, rootContainer, isSVG);
4892 }
4893 isMounted = true;
4894 app._container = rootContainer;
4895 rootContainer.__vue_app__ = app;
4896 {
4897 app._instance = vnode.component;
4898 devtoolsInitApp(app, version);
4899 }
4900 return vnode.component.proxy;
4901 }
4902 else {
4903 warn$1(`App has already been mounted.\n` +
4904 `If you want to remount the same app, move your app creation logic ` +
4905 `into a factory function and create fresh app instances for each ` +
4906 `mount - e.g. \`const createMyApp = () => createApp(App)\``);
4907 }
4908 },
4909 unmount() {
4910 if (isMounted) {
4911 render(null, app._container);
4912 {
4913 app._instance = null;
4914 devtoolsUnmountApp(app);
4915 }
4916 delete app._container.__vue_app__;
4917 }
4918 else {
4919 warn$1(`Cannot unmount an app that is not mounted.`);
4920 }
4921 },
4922 provide(key, value) {
4923 if (key in context.provides) {
4924 warn$1(`App already provides property with key "${String(key)}". ` +
4925 `It will be overwritten with the new value.`);
4926 }
4927 // TypeScript doesn't allow symbols as index type
4928 // https://github.com/Microsoft/TypeScript/issues/24587
4929 context.provides[key] = value;
4930 return app;
4931 }
4932 });
4933 return app;
4934 };
4935}
4936
4937let hasMismatch = false;
4938const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
4939const isComment = (node) => node.nodeType === 8 /* COMMENT */;
4940// Note: hydration is DOM-specific
4941// But we have to place it in core due to tight coupling with core - splitting
4942// it out creates a ton of unnecessary complexity.
4943// Hydration also depends on some renderer internal logic which needs to be
4944// passed in via arguments.
4945function createHydrationFunctions(rendererInternals) {
4946 const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
4947 const hydrate = (vnode, container) => {
4948 if (!container.hasChildNodes()) {
4949 warn$1(`Attempting to hydrate existing markup but container is empty. ` +
4950 `Performing full mount instead.`);
4951 patch(null, vnode, container);
4952 flushPostFlushCbs();
4953 return;
4954 }
4955 hasMismatch = false;
4956 hydrateNode(container.firstChild, vnode, null, null, null);
4957 flushPostFlushCbs();
4958 if (hasMismatch && !false) {
4959 // this error should show up in production
4960 console.error(`Hydration completed but contains mismatches.`);
4961 }
4962 };
4963 const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
4964 const isFragmentStart = isComment(node) && node.data === '[';
4965 const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
4966 const { type, ref, shapeFlag } = vnode;
4967 const domType = node.nodeType;
4968 vnode.el = node;
4969 let nextNode = null;
4970 switch (type) {
4971 case Text:
4972 if (domType !== 3 /* TEXT */) {
4973 nextNode = onMismatch();
4974 }
4975 else {
4976 if (node.data !== vnode.children) {
4977 hasMismatch = true;
4978 warn$1(`Hydration text mismatch:` +
4979 `\n- Client: ${JSON.stringify(node.data)}` +
4980 `\n- Server: ${JSON.stringify(vnode.children)}`);
4981 node.data = vnode.children;
4982 }
4983 nextNode = nextSibling(node);
4984 }
4985 break;
4986 case Comment:
4987 if (domType !== 8 /* COMMENT */ || isFragmentStart) {
4988 nextNode = onMismatch();
4989 }
4990 else {
4991 nextNode = nextSibling(node);
4992 }
4993 break;
4994 case Static:
4995 if (domType !== 1 /* ELEMENT */) {
4996 nextNode = onMismatch();
4997 }
4998 else {
4999 // determine anchor, adopt content
5000 nextNode = node;
5001 // if the static vnode has its content stripped during build,
5002 // adopt it from the server-rendered HTML.
5003 const needToAdoptContent = !vnode.children.length;
5004 for (let i = 0; i < vnode.staticCount; i++) {
5005 if (needToAdoptContent)
5006 vnode.children += nextNode.outerHTML;
5007 if (i === vnode.staticCount - 1) {
5008 vnode.anchor = nextNode;
5009 }
5010 nextNode = nextSibling(nextNode);
5011 }
5012 return nextNode;
5013 }
5014 break;
5015 case Fragment:
5016 if (!isFragmentStart) {
5017 nextNode = onMismatch();
5018 }
5019 else {
5020 nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
5021 }
5022 break;
5023 default:
5024 if (shapeFlag & 1 /* ELEMENT */) {
5025 if (domType !== 1 /* ELEMENT */ ||
5026 vnode.type.toLowerCase() !==
5027 node.tagName.toLowerCase()) {
5028 nextNode = onMismatch();
5029 }
5030 else {
5031 nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
5032 }
5033 }
5034 else if (shapeFlag & 6 /* COMPONENT */) {
5035 // when setting up the render effect, if the initial vnode already
5036 // has .el set, the component will perform hydration instead of mount
5037 // on its sub-tree.
5038 vnode.slotScopeIds = slotScopeIds;
5039 const container = parentNode(node);
5040 mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
5041 // component may be async, so in the case of fragments we cannot rely
5042 // on component's rendered output to determine the end of the fragment
5043 // instead, we do a lookahead to find the end anchor node.
5044 nextNode = isFragmentStart
5045 ? locateClosingAsyncAnchor(node)
5046 : nextSibling(node);
5047 // #3787
5048 // if component is async, it may get moved / unmounted before its
5049 // inner component is loaded, so we need to give it a placeholder
5050 // vnode that matches its adopted DOM.
5051 if (isAsyncWrapper(vnode)) {
5052 let subTree;
5053 if (isFragmentStart) {
5054 subTree = createVNode(Fragment);
5055 subTree.anchor = nextNode
5056 ? nextNode.previousSibling
5057 : container.lastChild;
5058 }
5059 else {
5060 subTree =
5061 node.nodeType === 3 ? createTextVNode('') : createVNode('div');
5062 }
5063 subTree.el = node;
5064 vnode.component.subTree = subTree;
5065 }
5066 }
5067 else if (shapeFlag & 64 /* TELEPORT */) {
5068 if (domType !== 8 /* COMMENT */) {
5069 nextNode = onMismatch();
5070 }
5071 else {
5072 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
5073 }
5074 }
5075 else if (shapeFlag & 128 /* SUSPENSE */) {
5076 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
5077 }
5078 else {
5079 warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
5080 }
5081 }
5082 if (ref != null) {
5083 setRef(ref, null, parentSuspense, vnode);
5084 }
5085 return nextNode;
5086 };
5087 const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
5088 optimized = optimized || !!vnode.dynamicChildren;
5089 const { type, props, patchFlag, shapeFlag, dirs } = vnode;
5090 // #4006 for form elements with non-string v-model value bindings
5091 // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5092 const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5093 // skip props & children if this is hoisted static nodes
5094 if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5095 if (dirs) {
5096 invokeDirectiveHook(vnode, null, parentComponent, 'created');
5097 }
5098 // props
5099 if (props) {
5100 if (forcePatchValue ||
5101 !optimized ||
5102 patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) {
5103 for (const key in props) {
5104 if ((forcePatchValue && key.endsWith('value')) ||
5105 (isOn(key) && !isReservedProp(key))) {
5106 patchProp(el, key, null, props[key]);
5107 }
5108 }
5109 }
5110 else if (props.onClick) {
5111 // Fast path for click listeners (which is most often) to avoid
5112 // iterating through props.
5113 patchProp(el, 'onClick', null, props.onClick);
5114 }
5115 }
5116 // vnode / directive hooks
5117 let vnodeHooks;
5118 if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
5119 invokeVNodeHook(vnodeHooks, parentComponent, vnode);
5120 }
5121 if (dirs) {
5122 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
5123 }
5124 if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
5125 queueEffectWithSuspense(() => {
5126 vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
5127 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
5128 }, parentSuspense);
5129 }
5130 // children
5131 if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
5132 // skip if element has innerHTML / textContent
5133 !(props && (props.innerHTML || props.textContent))) {
5134 let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
5135 let hasWarned = false;
5136 while (next) {
5137 hasMismatch = true;
5138 if (!hasWarned) {
5139 warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
5140 `server rendered element contains more child nodes than client vdom.`);
5141 hasWarned = true;
5142 }
5143 // The SSRed DOM contains more nodes than it should. Remove them.
5144 const cur = next;
5145 next = next.nextSibling;
5146 remove(cur);
5147 }
5148 }
5149 else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
5150 if (el.textContent !== vnode.children) {
5151 hasMismatch = true;
5152 warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
5153 `- Client: ${el.textContent}\n` +
5154 `- Server: ${vnode.children}`);
5155 el.textContent = vnode.children;
5156 }
5157 }
5158 }
5159 return el.nextSibling;
5160 };
5161 const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
5162 optimized = optimized || !!parentVNode.dynamicChildren;
5163 const children = parentVNode.children;
5164 const l = children.length;
5165 let hasWarned = false;
5166 for (let i = 0; i < l; i++) {
5167 const vnode = optimized
5168 ? children[i]
5169 : (children[i] = normalizeVNode(children[i]));
5170 if (node) {
5171 node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
5172 }
5173 else if (vnode.type === Text && !vnode.children) {
5174 continue;
5175 }
5176 else {
5177 hasMismatch = true;
5178 if (!hasWarned) {
5179 warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
5180 `server rendered element contains fewer child nodes than client vdom.`);
5181 hasWarned = true;
5182 }
5183 // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
5184 patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
5185 }
5186 }
5187 return node;
5188 };
5189 const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
5190 const { slotScopeIds: fragmentSlotScopeIds } = vnode;
5191 if (fragmentSlotScopeIds) {
5192 slotScopeIds = slotScopeIds
5193 ? slotScopeIds.concat(fragmentSlotScopeIds)
5194 : fragmentSlotScopeIds;
5195 }
5196 const container = parentNode(node);
5197 const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
5198 if (next && isComment(next) && next.data === ']') {
5199 return nextSibling((vnode.anchor = next));
5200 }
5201 else {
5202 // fragment didn't hydrate successfully, since we didn't get a end anchor
5203 // back. This should have led to node/children mismatch warnings.
5204 hasMismatch = true;
5205 // since the anchor is missing, we need to create one and insert it
5206 insert((vnode.anchor = createComment(`]`)), container, next);
5207 return next;
5208 }
5209 };
5210 const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
5211 hasMismatch = true;
5212 warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
5213 ? `(text)`
5214 : isComment(node) && node.data === '['
5215 ? `(start of fragment)`
5216 : ``);
5217 vnode.el = null;
5218 if (isFragment) {
5219 // remove excessive fragment nodes
5220 const end = locateClosingAsyncAnchor(node);
5221 while (true) {
5222 const next = nextSibling(node);
5223 if (next && next !== end) {
5224 remove(next);
5225 }
5226 else {
5227 break;
5228 }
5229 }
5230 }
5231 const next = nextSibling(node);
5232 const container = parentNode(node);
5233 remove(node);
5234 patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
5235 return next;
5236 };
5237 const locateClosingAsyncAnchor = (node) => {
5238 let match = 0;
5239 while (node) {
5240 node = nextSibling(node);
5241 if (node && isComment(node)) {
5242 if (node.data === '[')
5243 match++;
5244 if (node.data === ']') {
5245 if (match === 0) {
5246 return nextSibling(node);
5247 }
5248 else {
5249 match--;
5250 }
5251 }
5252 }
5253 }
5254 return node;
5255 };
5256 return [hydrate, hydrateNode];
5257}
5258
5259let supported;
5260let perf;
5261function startMeasure(instance, type) {
5262 if (instance.appContext.config.performance && isSupported()) {
5263 perf.mark(`vue-${type}-${instance.uid}`);
5264 }
5265 {
5266 devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
5267 }
5268}
5269function endMeasure(instance, type) {
5270 if (instance.appContext.config.performance && isSupported()) {
5271 const startTag = `vue-${type}-${instance.uid}`;
5272 const endTag = startTag + `:end`;
5273 perf.mark(endTag);
5274 perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
5275 perf.clearMarks(startTag);
5276 perf.clearMarks(endTag);
5277 }
5278 {
5279 devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
5280 }
5281}
5282function isSupported() {
5283 if (supported !== undefined) {
5284 return supported;
5285 }
5286 /* eslint-disable no-restricted-globals */
5287 if (typeof window !== 'undefined' && window.performance) {
5288 supported = true;
5289 perf = window.performance;
5290 }
5291 else {
5292 supported = false;
5293 }
5294 /* eslint-enable no-restricted-globals */
5295 return supported;
5296}
5297
5298const queuePostRenderEffect = queueEffectWithSuspense
5299 ;
5300/**
5301 * The createRenderer function accepts two generic arguments:
5302 * HostNode and HostElement, corresponding to Node and Element types in the
5303 * host environment. For example, for runtime-dom, HostNode would be the DOM
5304 * `Node` interface and HostElement would be the DOM `Element` interface.
5305 *
5306 * Custom renderers can pass in the platform specific types like this:
5307 *
5308 * ``` js
5309 * const { render, createApp } = createRenderer<Node, Element>({
5310 * patchProp,
5311 * ...nodeOps
5312 * })
5313 * ```
5314 */
5315function createRenderer(options) {
5316 return baseCreateRenderer(options);
5317}
5318// Separate API for creating hydration-enabled renderer.
5319// Hydration logic is only used when calling this function, making it
5320// tree-shakable.
5321function createHydrationRenderer(options) {
5322 return baseCreateRenderer(options, createHydrationFunctions);
5323}
5324// implementation
5325function baseCreateRenderer(options, createHydrationFns) {
5326 {
5327 const target = getGlobalThis();
5328 target.__VUE__ = true;
5329 setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__);
5330 }
5331 const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
5332 // Note: functions inside this closure should use `const xxx = () => {}`
5333 // style in order to prevent being inlined by minifiers.
5334 const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
5335 if (n1 === n2) {
5336 return;
5337 }
5338 // patching & not same type, unmount old tree
5339 if (n1 && !isSameVNodeType(n1, n2)) {
5340 anchor = getNextHostNode(n1);
5341 unmount(n1, parentComponent, parentSuspense, true);
5342 n1 = null;
5343 }
5344 if (n2.patchFlag === -2 /* BAIL */) {
5345 optimized = false;
5346 n2.dynamicChildren = null;
5347 }
5348 const { type, ref, shapeFlag } = n2;
5349 switch (type) {
5350 case Text:
5351 processText(n1, n2, container, anchor);
5352 break;
5353 case Comment:
5354 processCommentNode(n1, n2, container, anchor);
5355 break;
5356 case Static:
5357 if (n1 == null) {
5358 mountStaticNode(n2, container, anchor, isSVG);
5359 }
5360 else {
5361 patchStaticNode(n1, n2, container, isSVG);
5362 }
5363 break;
5364 case Fragment:
5365 processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5366 break;
5367 default:
5368 if (shapeFlag & 1 /* ELEMENT */) {
5369 processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5370 }
5371 else if (shapeFlag & 6 /* COMPONENT */) {
5372 processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5373 }
5374 else if (shapeFlag & 64 /* TELEPORT */) {
5375 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
5376 }
5377 else if (shapeFlag & 128 /* SUSPENSE */) {
5378 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
5379 }
5380 else {
5381 warn$1('Invalid VNode type:', type, `(${typeof type})`);
5382 }
5383 }
5384 // set ref
5385 if (ref != null && parentComponent) {
5386 setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
5387 }
5388 };
5389 const processText = (n1, n2, container, anchor) => {
5390 if (n1 == null) {
5391 hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
5392 }
5393 else {
5394 const el = (n2.el = n1.el);
5395 if (n2.children !== n1.children) {
5396 hostSetText(el, n2.children);
5397 }
5398 }
5399 };
5400 const processCommentNode = (n1, n2, container, anchor) => {
5401 if (n1 == null) {
5402 hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
5403 }
5404 else {
5405 // there's no support for dynamic comments
5406 n2.el = n1.el;
5407 }
5408 };
5409 const mountStaticNode = (n2, container, anchor, isSVG) => {
5410 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
5411 };
5412 /**
5413 * Dev / HMR only
5414 */
5415 const patchStaticNode = (n1, n2, container, isSVG) => {
5416 // static nodes are only patched during dev for HMR
5417 if (n2.children !== n1.children) {
5418 const anchor = hostNextSibling(n1.anchor);
5419 // remove existing
5420 removeStaticNode(n1);
5421 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
5422 }
5423 else {
5424 n2.el = n1.el;
5425 n2.anchor = n1.anchor;
5426 }
5427 };
5428 const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
5429 let next;
5430 while (el && el !== anchor) {
5431 next = hostNextSibling(el);
5432 hostInsert(el, container, nextSibling);
5433 el = next;
5434 }
5435 hostInsert(anchor, container, nextSibling);
5436 };
5437 const removeStaticNode = ({ el, anchor }) => {
5438 let next;
5439 while (el && el !== anchor) {
5440 next = hostNextSibling(el);
5441 hostRemove(el);
5442 el = next;
5443 }
5444 hostRemove(anchor);
5445 };
5446 const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5447 isSVG = isSVG || n2.type === 'svg';
5448 if (n1 == null) {
5449 mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5450 }
5451 else {
5452 patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5453 }
5454 };
5455 const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5456 let el;
5457 let vnodeHook;
5458 const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
5459 {
5460 el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
5461 // mount children first, since some props may rely on child content
5462 // being already rendered, e.g. `<select value>`
5463 if (shapeFlag & 8 /* TEXT_CHILDREN */) {
5464 hostSetElementText(el, vnode.children);
5465 }
5466 else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
5467 mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
5468 }
5469 if (dirs) {
5470 invokeDirectiveHook(vnode, null, parentComponent, 'created');
5471 }
5472 // props
5473 if (props) {
5474 for (const key in props) {
5475 if (key !== 'value' && !isReservedProp(key)) {
5476 hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5477 }
5478 }
5479 /**
5480 * Special case for setting value on DOM elements:
5481 * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
5482 * - it needs to be forced (#1471)
5483 * #2353 proposes adding another renderer option to configure this, but
5484 * the properties affects are so finite it is worth special casing it
5485 * here to reduce the complexity. (Special casing it also should not
5486 * affect non-DOM renderers)
5487 */
5488 if ('value' in props) {
5489 hostPatchProp(el, 'value', null, props.value);
5490 }
5491 if ((vnodeHook = props.onVnodeBeforeMount)) {
5492 invokeVNodeHook(vnodeHook, parentComponent, vnode);
5493 }
5494 }
5495 // scopeId
5496 setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
5497 }
5498 {
5499 Object.defineProperty(el, '__vnode', {
5500 value: vnode,
5501 enumerable: false
5502 });
5503 Object.defineProperty(el, '__vueParentComponent', {
5504 value: parentComponent,
5505 enumerable: false
5506 });
5507 }
5508 if (dirs) {
5509 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
5510 }
5511 // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
5512 // #1689 For inside suspense + suspense resolved case, just call it
5513 const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
5514 transition &&
5515 !transition.persisted;
5516 if (needCallTransitionHooks) {
5517 transition.beforeEnter(el);
5518 }
5519 hostInsert(el, container, anchor);
5520 if ((vnodeHook = props && props.onVnodeMounted) ||
5521 needCallTransitionHooks ||
5522 dirs) {
5523 queuePostRenderEffect(() => {
5524 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
5525 needCallTransitionHooks && transition.enter(el);
5526 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
5527 }, parentSuspense);
5528 }
5529 };
5530 const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
5531 if (scopeId) {
5532 hostSetScopeId(el, scopeId);
5533 }
5534 if (slotScopeIds) {
5535 for (let i = 0; i < slotScopeIds.length; i++) {
5536 hostSetScopeId(el, slotScopeIds[i]);
5537 }
5538 }
5539 if (parentComponent) {
5540 let subTree = parentComponent.subTree;
5541 if (subTree.patchFlag > 0 &&
5542 subTree.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
5543 subTree =
5544 filterSingleRoot(subTree.children) || subTree;
5545 }
5546 if (vnode === subTree) {
5547 const parentVNode = parentComponent.vnode;
5548 setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
5549 }
5550 }
5551 };
5552 const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
5553 for (let i = start; i < children.length; i++) {
5554 const child = (children[i] = optimized
5555 ? cloneIfMounted(children[i])
5556 : normalizeVNode(children[i]));
5557 patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5558 }
5559 };
5560 const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5561 const el = (n2.el = n1.el);
5562 let { patchFlag, dynamicChildren, dirs } = n2;
5563 // #1426 take the old vnode's patch flag into account since user may clone a
5564 // compiler-generated vnode, which de-opts to FULL_PROPS
5565 patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
5566 const oldProps = n1.props || EMPTY_OBJ;
5567 const newProps = n2.props || EMPTY_OBJ;
5568 let vnodeHook;
5569 if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
5570 invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
5571 }
5572 if (dirs) {
5573 invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
5574 }
5575 if (isHmrUpdating) {
5576 // HMR updated, force full diff
5577 patchFlag = 0;
5578 optimized = false;
5579 dynamicChildren = null;
5580 }
5581 const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
5582 if (dynamicChildren) {
5583 patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
5584 if (parentComponent && parentComponent.type.__hmrId) {
5585 traverseStaticChildren(n1, n2);
5586 }
5587 }
5588 else if (!optimized) {
5589 // full diff
5590 patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
5591 }
5592 if (patchFlag > 0) {
5593 // the presence of a patchFlag means this element's render code was
5594 // generated by the compiler and can take the fast path.
5595 // in this path old node and new node are guaranteed to have the same shape
5596 // (i.e. at the exact same position in the source template)
5597 if (patchFlag & 16 /* FULL_PROPS */) {
5598 // element props contain dynamic keys, full diff needed
5599 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
5600 }
5601 else {
5602 // class
5603 // this flag is matched when the element has dynamic class bindings.
5604 if (patchFlag & 2 /* CLASS */) {
5605 if (oldProps.class !== newProps.class) {
5606 hostPatchProp(el, 'class', null, newProps.class, isSVG);
5607 }
5608 }
5609 // style
5610 // this flag is matched when the element has dynamic style bindings
5611 if (patchFlag & 4 /* STYLE */) {
5612 hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
5613 }
5614 // props
5615 // This flag is matched when the element has dynamic prop/attr bindings
5616 // other than class and style. The keys of dynamic prop/attrs are saved for
5617 // faster iteration.
5618 // Note dynamic keys like :[foo]="bar" will cause this optimization to
5619 // bail out and go through a full diff because we need to unset the old key
5620 if (patchFlag & 8 /* PROPS */) {
5621 // if the flag is present then dynamicProps must be non-null
5622 const propsToUpdate = n2.dynamicProps;
5623 for (let i = 0; i < propsToUpdate.length; i++) {
5624 const key = propsToUpdate[i];
5625 const prev = oldProps[key];
5626 const next = newProps[key];
5627 // #1471 force patch value
5628 if (next !== prev || key === 'value') {
5629 hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
5630 }
5631 }
5632 }
5633 }
5634 // text
5635 // This flag is matched when the element has only dynamic text children.
5636 if (patchFlag & 1 /* TEXT */) {
5637 if (n1.children !== n2.children) {
5638 hostSetElementText(el, n2.children);
5639 }
5640 }
5641 }
5642 else if (!optimized && dynamicChildren == null) {
5643 // unoptimized, full diff
5644 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
5645 }
5646 if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
5647 queuePostRenderEffect(() => {
5648 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
5649 dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
5650 }, parentSuspense);
5651 }
5652 };
5653 // The fast path for blocks.
5654 const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
5655 for (let i = 0; i < newChildren.length; i++) {
5656 const oldVNode = oldChildren[i];
5657 const newVNode = newChildren[i];
5658 // Determine the container (parent element) for the patch.
5659 const container =
5660 // oldVNode may be an errored async setup() component inside Suspense
5661 // which will not have a mounted element
5662 oldVNode.el &&
5663 // - In the case of a Fragment, we need to provide the actual parent
5664 // of the Fragment itself so it can move its children.
5665 (oldVNode.type === Fragment ||
5666 // - In the case of different nodes, there is going to be a replacement
5667 // which also requires the correct parent container
5668 !isSameVNodeType(oldVNode, newVNode) ||
5669 // - In the case of a component, it could contain anything.
5670 oldVNode.shapeFlag & (6 /* COMPONENT */ | 64 /* TELEPORT */))
5671 ? hostParentNode(oldVNode.el)
5672 : // In other cases, the parent container is not actually used so we
5673 // just pass the block element here to avoid a DOM parentNode call.
5674 fallbackContainer;
5675 patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
5676 }
5677 };
5678 const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
5679 if (oldProps !== newProps) {
5680 for (const key in newProps) {
5681 // empty string is not valid prop
5682 if (isReservedProp(key))
5683 continue;
5684 const next = newProps[key];
5685 const prev = oldProps[key];
5686 // defer patching value
5687 if (next !== prev && key !== 'value') {
5688 hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5689 }
5690 }
5691 if (oldProps !== EMPTY_OBJ) {
5692 for (const key in oldProps) {
5693 if (!isReservedProp(key) && !(key in newProps)) {
5694 hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5695 }
5696 }
5697 }
5698 if ('value' in newProps) {
5699 hostPatchProp(el, 'value', oldProps.value, newProps.value);
5700 }
5701 }
5702 };
5703 const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5704 const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
5705 const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
5706 let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
5707 if (isHmrUpdating) {
5708 // HMR updated, force full diff
5709 patchFlag = 0;
5710 optimized = false;
5711 dynamicChildren = null;
5712 }
5713 // check if this is a slot fragment with :slotted scope ids
5714 if (fragmentSlotScopeIds) {
5715 slotScopeIds = slotScopeIds
5716 ? slotScopeIds.concat(fragmentSlotScopeIds)
5717 : fragmentSlotScopeIds;
5718 }
5719 if (n1 == null) {
5720 hostInsert(fragmentStartAnchor, container, anchor);
5721 hostInsert(fragmentEndAnchor, container, anchor);
5722 // a fragment can only have array children
5723 // since they are either generated by the compiler, or implicitly created
5724 // from arrays.
5725 mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5726 }
5727 else {
5728 if (patchFlag > 0 &&
5729 patchFlag & 64 /* STABLE_FRAGMENT */ &&
5730 dynamicChildren &&
5731 // #2715 the previous fragment could've been a BAILed one as a result
5732 // of renderSlot() with no valid children
5733 n1.dynamicChildren) {
5734 // a stable fragment (template root or <template v-for>) doesn't need to
5735 // patch children order, but it may contain dynamicChildren.
5736 patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
5737 if (parentComponent && parentComponent.type.__hmrId) {
5738 traverseStaticChildren(n1, n2);
5739 }
5740 else if (
5741 // #2080 if the stable fragment has a key, it's a <template v-for> that may
5742 // get moved around. Make sure all root level vnodes inherit el.
5743 // #2134 or if it's a component root, it may also get moved around
5744 // as the component is being moved.
5745 n2.key != null ||
5746 (parentComponent && n2 === parentComponent.subTree)) {
5747 traverseStaticChildren(n1, n2, true /* shallow */);
5748 }
5749 }
5750 else {
5751 // keyed / unkeyed, or manual fragments.
5752 // for keyed & unkeyed, since they are compiler generated from v-for,
5753 // each child is guaranteed to be a block so the fragment will never
5754 // have dynamicChildren.
5755 patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5756 }
5757 }
5758 };
5759 const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5760 n2.slotScopeIds = slotScopeIds;
5761 if (n1 == null) {
5762 if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
5763 parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
5764 }
5765 else {
5766 mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
5767 }
5768 }
5769 else {
5770 updateComponent(n1, n2, optimized);
5771 }
5772 };
5773 const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
5774 const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
5775 if (instance.type.__hmrId) {
5776 registerHMR(instance);
5777 }
5778 {
5779 pushWarningContext(initialVNode);
5780 startMeasure(instance, `mount`);
5781 }
5782 // inject renderer internals for keepAlive
5783 if (isKeepAlive(initialVNode)) {
5784 instance.ctx.renderer = internals;
5785 }
5786 // resolve props and slots for setup context
5787 {
5788 {
5789 startMeasure(instance, `init`);
5790 }
5791 setupComponent(instance);
5792 {
5793 endMeasure(instance, `init`);
5794 }
5795 }
5796 // setup() is async. This component relies on async logic to be resolved
5797 // before proceeding
5798 if (instance.asyncDep) {
5799 parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
5800 // Give it a placeholder if this is not hydration
5801 // TODO handle self-defined fallback
5802 if (!initialVNode.el) {
5803 const placeholder = (instance.subTree = createVNode(Comment));
5804 processCommentNode(null, placeholder, container, anchor);
5805 }
5806 return;
5807 }
5808 setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
5809 {
5810 popWarningContext();
5811 endMeasure(instance, `mount`);
5812 }
5813 };
5814 const updateComponent = (n1, n2, optimized) => {
5815 const instance = (n2.component = n1.component);
5816 if (shouldUpdateComponent(n1, n2, optimized)) {
5817 if (instance.asyncDep &&
5818 !instance.asyncResolved) {
5819 // async & still pending - just update props and slots
5820 // since the component's reactive effect for render isn't set-up yet
5821 {
5822 pushWarningContext(n2);
5823 }
5824 updateComponentPreRender(instance, n2, optimized);
5825 {
5826 popWarningContext();
5827 }
5828 return;
5829 }
5830 else {
5831 // normal update
5832 instance.next = n2;
5833 // in case the child component is also queued, remove it to avoid
5834 // double updating the same child component in the same flush.
5835 invalidateJob(instance.update);
5836 // instance.update is the reactive effect.
5837 instance.update();
5838 }
5839 }
5840 else {
5841 // no update needed. just copy over properties
5842 n2.component = n1.component;
5843 n2.el = n1.el;
5844 instance.vnode = n2;
5845 }
5846 };
5847 const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
5848 const componentUpdateFn = () => {
5849 if (!instance.isMounted) {
5850 let vnodeHook;
5851 const { el, props } = initialVNode;
5852 const { bm, m, parent } = instance;
5853 const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
5854 effect.allowRecurse = false;
5855 // beforeMount hook
5856 if (bm) {
5857 invokeArrayFns(bm);
5858 }
5859 // onVnodeBeforeMount
5860 if (!isAsyncWrapperVNode &&
5861 (vnodeHook = props && props.onVnodeBeforeMount)) {
5862 invokeVNodeHook(vnodeHook, parent, initialVNode);
5863 }
5864 effect.allowRecurse = true;
5865 if (el && hydrateNode) {
5866 // vnode has adopted host node - perform hydration instead of mount.
5867 const hydrateSubTree = () => {
5868 {
5869 startMeasure(instance, `render`);
5870 }
5871 instance.subTree = renderComponentRoot(instance);
5872 {
5873 endMeasure(instance, `render`);
5874 }
5875 {
5876 startMeasure(instance, `hydrate`);
5877 }
5878 hydrateNode(el, instance.subTree, instance, parentSuspense, null);
5879 {
5880 endMeasure(instance, `hydrate`);
5881 }
5882 };
5883 if (isAsyncWrapperVNode) {
5884 initialVNode.type.__asyncLoader().then(
5885 // note: we are moving the render call into an async callback,
5886 // which means it won't track dependencies - but it's ok because
5887 // a server-rendered async wrapper is already in resolved state
5888 // and it will never need to change.
5889 () => !instance.isUnmounted && hydrateSubTree());
5890 }
5891 else {
5892 hydrateSubTree();
5893 }
5894 }
5895 else {
5896 {
5897 startMeasure(instance, `render`);
5898 }
5899 const subTree = (instance.subTree = renderComponentRoot(instance));
5900 {
5901 endMeasure(instance, `render`);
5902 }
5903 {
5904 startMeasure(instance, `patch`);
5905 }
5906 patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
5907 {
5908 endMeasure(instance, `patch`);
5909 }
5910 initialVNode.el = subTree.el;
5911 }
5912 // mounted hook
5913 if (m) {
5914 queuePostRenderEffect(m, parentSuspense);
5915 }
5916 // onVnodeMounted
5917 if (!isAsyncWrapperVNode &&
5918 (vnodeHook = props && props.onVnodeMounted)) {
5919 const scopedInitialVNode = initialVNode;
5920 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
5921 }
5922 // activated hook for keep-alive roots.
5923 // #1742 activated hook must be accessed after first render
5924 // since the hook may be injected by a child keep-alive
5925 if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
5926 instance.a && queuePostRenderEffect(instance.a, parentSuspense);
5927 }
5928 instance.isMounted = true;
5929 {
5930 devtoolsComponentAdded(instance);
5931 }
5932 // #2458: deference mount-only object parameters to prevent memleaks
5933 initialVNode = container = anchor = null;
5934 }
5935 else {
5936 // updateComponent
5937 // This is triggered by mutation of component's own state (next: null)
5938 // OR parent calling processComponent (next: VNode)
5939 let { next, bu, u, parent, vnode } = instance;
5940 let originNext = next;
5941 let vnodeHook;
5942 {
5943 pushWarningContext(next || instance.vnode);
5944 }
5945 // Disallow component effect recursion during pre-lifecycle hooks.
5946 effect.allowRecurse = false;
5947 if (next) {
5948 next.el = vnode.el;
5949 updateComponentPreRender(instance, next, optimized);
5950 }
5951 else {
5952 next = vnode;
5953 }
5954 // beforeUpdate hook
5955 if (bu) {
5956 invokeArrayFns(bu);
5957 }
5958 // onVnodeBeforeUpdate
5959 if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
5960 invokeVNodeHook(vnodeHook, parent, next, vnode);
5961 }
5962 effect.allowRecurse = true;
5963 // render
5964 {
5965 startMeasure(instance, `render`);
5966 }
5967 const nextTree = renderComponentRoot(instance);
5968 {
5969 endMeasure(instance, `render`);
5970 }
5971 const prevTree = instance.subTree;
5972 instance.subTree = nextTree;
5973 {
5974 startMeasure(instance, `patch`);
5975 }
5976 patch(prevTree, nextTree,
5977 // parent may have changed if it's in a teleport
5978 hostParentNode(prevTree.el),
5979 // anchor may have changed if it's in a fragment
5980 getNextHostNode(prevTree), instance, parentSuspense, isSVG);
5981 {
5982 endMeasure(instance, `patch`);
5983 }
5984 next.el = nextTree.el;
5985 if (originNext === null) {
5986 // self-triggered update. In case of HOC, update parent component
5987 // vnode el. HOC is indicated by parent instance's subTree pointing
5988 // to child component's vnode
5989 updateHOCHostEl(instance, nextTree.el);
5990 }
5991 // updated hook
5992 if (u) {
5993 queuePostRenderEffect(u, parentSuspense);
5994 }
5995 // onVnodeUpdated
5996 if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
5997 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
5998 }
5999 {
6000 devtoolsComponentUpdated(instance);
6001 }
6002 {
6003 popWarningContext();
6004 }
6005 }
6006 };
6007 // create reactive effect for rendering
6008 const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
6009 );
6010 const update = (instance.update = effect.run.bind(effect));
6011 update.id = instance.uid;
6012 // allowRecurse
6013 // #1801, #2043 component render effects should allow recursive updates
6014 effect.allowRecurse = update.allowRecurse = true;
6015 {
6016 effect.onTrack = instance.rtc
6017 ? e => invokeArrayFns(instance.rtc, e)
6018 : void 0;
6019 effect.onTrigger = instance.rtg
6020 ? e => invokeArrayFns(instance.rtg, e)
6021 : void 0;
6022 // @ts-ignore (for scheduler)
6023 update.ownerInstance = instance;
6024 }
6025 update();
6026 };
6027 const updateComponentPreRender = (instance, nextVNode, optimized) => {
6028 nextVNode.component = instance;
6029 const prevProps = instance.vnode.props;
6030 instance.vnode = nextVNode;
6031 instance.next = null;
6032 updateProps(instance, nextVNode.props, prevProps, optimized);
6033 updateSlots(instance, nextVNode.children, optimized);
6034 pauseTracking();
6035 // props update may have triggered pre-flush watchers.
6036 // flush them before the render update.
6037 flushPreFlushCbs(undefined, instance.update);
6038 resetTracking();
6039 };
6040 const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
6041 const c1 = n1 && n1.children;
6042 const prevShapeFlag = n1 ? n1.shapeFlag : 0;
6043 const c2 = n2.children;
6044 const { patchFlag, shapeFlag } = n2;
6045 // fast path
6046 if (patchFlag > 0) {
6047 if (patchFlag & 128 /* KEYED_FRAGMENT */) {
6048 // this could be either fully-keyed or mixed (some keyed some not)
6049 // presence of patchFlag means children are guaranteed to be arrays
6050 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6051 return;
6052 }
6053 else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
6054 // unkeyed
6055 patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6056 return;
6057 }
6058 }
6059 // children has 3 possibilities: text, array or no children.
6060 if (shapeFlag & 8 /* TEXT_CHILDREN */) {
6061 // text children fast path
6062 if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
6063 unmountChildren(c1, parentComponent, parentSuspense);
6064 }
6065 if (c2 !== c1) {
6066 hostSetElementText(container, c2);
6067 }
6068 }
6069 else {
6070 if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
6071 // prev children was array
6072 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6073 // two arrays, cannot assume anything, do full diff
6074 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6075 }
6076 else {
6077 // no new children, just unmount old
6078 unmountChildren(c1, parentComponent, parentSuspense, true);
6079 }
6080 }
6081 else {
6082 // prev children was text OR null
6083 // new children is array OR null
6084 if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
6085 hostSetElementText(container, '');
6086 }
6087 // mount new if array
6088 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6089 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6090 }
6091 }
6092 }
6093 };
6094 const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6095 c1 = c1 || EMPTY_ARR;
6096 c2 = c2 || EMPTY_ARR;
6097 const oldLength = c1.length;
6098 const newLength = c2.length;
6099 const commonLength = Math.min(oldLength, newLength);
6100 let i;
6101 for (i = 0; i < commonLength; i++) {
6102 const nextChild = (c2[i] = optimized
6103 ? cloneIfMounted(c2[i])
6104 : normalizeVNode(c2[i]));
6105 patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6106 }
6107 if (oldLength > newLength) {
6108 // remove old
6109 unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
6110 }
6111 else {
6112 // mount new
6113 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
6114 }
6115 };
6116 // can be all-keyed or mixed
6117 const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6118 let i = 0;
6119 const l2 = c2.length;
6120 let e1 = c1.length - 1; // prev ending index
6121 let e2 = l2 - 1; // next ending index
6122 // 1. sync from start
6123 // (a b) c
6124 // (a b) d e
6125 while (i <= e1 && i <= e2) {
6126 const n1 = c1[i];
6127 const n2 = (c2[i] = optimized
6128 ? cloneIfMounted(c2[i])
6129 : normalizeVNode(c2[i]));
6130 if (isSameVNodeType(n1, n2)) {
6131 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6132 }
6133 else {
6134 break;
6135 }
6136 i++;
6137 }
6138 // 2. sync from end
6139 // a (b c)
6140 // d e (b c)
6141 while (i <= e1 && i <= e2) {
6142 const n1 = c1[e1];
6143 const n2 = (c2[e2] = optimized
6144 ? cloneIfMounted(c2[e2])
6145 : normalizeVNode(c2[e2]));
6146 if (isSameVNodeType(n1, n2)) {
6147 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6148 }
6149 else {
6150 break;
6151 }
6152 e1--;
6153 e2--;
6154 }
6155 // 3. common sequence + mount
6156 // (a b)
6157 // (a b) c
6158 // i = 2, e1 = 1, e2 = 2
6159 // (a b)
6160 // c (a b)
6161 // i = 0, e1 = -1, e2 = 0
6162 if (i > e1) {
6163 if (i <= e2) {
6164 const nextPos = e2 + 1;
6165 const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
6166 while (i <= e2) {
6167 patch(null, (c2[i] = optimized
6168 ? cloneIfMounted(c2[i])
6169 : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6170 i++;
6171 }
6172 }
6173 }
6174 // 4. common sequence + unmount
6175 // (a b) c
6176 // (a b)
6177 // i = 2, e1 = 2, e2 = 1
6178 // a (b c)
6179 // (b c)
6180 // i = 0, e1 = 0, e2 = -1
6181 else if (i > e2) {
6182 while (i <= e1) {
6183 unmount(c1[i], parentComponent, parentSuspense, true);
6184 i++;
6185 }
6186 }
6187 // 5. unknown sequence
6188 // [i ... e1 + 1]: a b [c d e] f g
6189 // [i ... e2 + 1]: a b [e d c h] f g
6190 // i = 2, e1 = 4, e2 = 5
6191 else {
6192 const s1 = i; // prev starting index
6193 const s2 = i; // next starting index
6194 // 5.1 build key:index map for newChildren
6195 const keyToNewIndexMap = new Map();
6196 for (i = s2; i <= e2; i++) {
6197 const nextChild = (c2[i] = optimized
6198 ? cloneIfMounted(c2[i])
6199 : normalizeVNode(c2[i]));
6200 if (nextChild.key != null) {
6201 if (keyToNewIndexMap.has(nextChild.key)) {
6202 warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
6203 }
6204 keyToNewIndexMap.set(nextChild.key, i);
6205 }
6206 }
6207 // 5.2 loop through old children left to be patched and try to patch
6208 // matching nodes & remove nodes that are no longer present
6209 let j;
6210 let patched = 0;
6211 const toBePatched = e2 - s2 + 1;
6212 let moved = false;
6213 // used to track whether any node has moved
6214 let maxNewIndexSoFar = 0;
6215 // works as Map<newIndex, oldIndex>
6216 // Note that oldIndex is offset by +1
6217 // and oldIndex = 0 is a special value indicating the new node has
6218 // no corresponding old node.
6219 // used for determining longest stable subsequence
6220 const newIndexToOldIndexMap = new Array(toBePatched);
6221 for (i = 0; i < toBePatched; i++)
6222 newIndexToOldIndexMap[i] = 0;
6223 for (i = s1; i <= e1; i++) {
6224 const prevChild = c1[i];
6225 if (patched >= toBePatched) {
6226 // all new children have been patched so this can only be a removal
6227 unmount(prevChild, parentComponent, parentSuspense, true);
6228 continue;
6229 }
6230 let newIndex;
6231 if (prevChild.key != null) {
6232 newIndex = keyToNewIndexMap.get(prevChild.key);
6233 }
6234 else {
6235 // key-less node, try to locate a key-less node of the same type
6236 for (j = s2; j <= e2; j++) {
6237 if (newIndexToOldIndexMap[j - s2] === 0 &&
6238 isSameVNodeType(prevChild, c2[j])) {
6239 newIndex = j;
6240 break;
6241 }
6242 }
6243 }
6244 if (newIndex === undefined) {
6245 unmount(prevChild, parentComponent, parentSuspense, true);
6246 }
6247 else {
6248 newIndexToOldIndexMap[newIndex - s2] = i + 1;
6249 if (newIndex >= maxNewIndexSoFar) {
6250 maxNewIndexSoFar = newIndex;
6251 }
6252 else {
6253 moved = true;
6254 }
6255 patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6256 patched++;
6257 }
6258 }
6259 // 5.3 move and mount
6260 // generate longest stable subsequence only when nodes have moved
6261 const increasingNewIndexSequence = moved
6262 ? getSequence(newIndexToOldIndexMap)
6263 : EMPTY_ARR;
6264 j = increasingNewIndexSequence.length - 1;
6265 // looping backwards so that we can use last patched node as anchor
6266 for (i = toBePatched - 1; i >= 0; i--) {
6267 const nextIndex = s2 + i;
6268 const nextChild = c2[nextIndex];
6269 const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
6270 if (newIndexToOldIndexMap[i] === 0) {
6271 // mount new
6272 patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6273 }
6274 else if (moved) {
6275 // move if:
6276 // There is no stable subsequence (e.g. a reverse)
6277 // OR current node is not among the stable sequence
6278 if (j < 0 || i !== increasingNewIndexSequence[j]) {
6279 move(nextChild, container, anchor, 2 /* REORDER */);
6280 }
6281 else {
6282 j--;
6283 }
6284 }
6285 }
6286 }
6287 };
6288 const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
6289 const { el, type, transition, children, shapeFlag } = vnode;
6290 if (shapeFlag & 6 /* COMPONENT */) {
6291 move(vnode.component.subTree, container, anchor, moveType);
6292 return;
6293 }
6294 if (shapeFlag & 128 /* SUSPENSE */) {
6295 vnode.suspense.move(container, anchor, moveType);
6296 return;
6297 }
6298 if (shapeFlag & 64 /* TELEPORT */) {
6299 type.move(vnode, container, anchor, internals);
6300 return;
6301 }
6302 if (type === Fragment) {
6303 hostInsert(el, container, anchor);
6304 for (let i = 0; i < children.length; i++) {
6305 move(children[i], container, anchor, moveType);
6306 }
6307 hostInsert(vnode.anchor, container, anchor);
6308 return;
6309 }
6310 if (type === Static) {
6311 moveStaticNode(vnode, container, anchor);
6312 return;
6313 }
6314 // single nodes
6315 const needTransition = moveType !== 2 /* REORDER */ &&
6316 shapeFlag & 1 /* ELEMENT */ &&
6317 transition;
6318 if (needTransition) {
6319 if (moveType === 0 /* ENTER */) {
6320 transition.beforeEnter(el);
6321 hostInsert(el, container, anchor);
6322 queuePostRenderEffect(() => transition.enter(el), parentSuspense);
6323 }
6324 else {
6325 const { leave, delayLeave, afterLeave } = transition;
6326 const remove = () => hostInsert(el, container, anchor);
6327 const performLeave = () => {
6328 leave(el, () => {
6329 remove();
6330 afterLeave && afterLeave();
6331 });
6332 };
6333 if (delayLeave) {
6334 delayLeave(el, remove, performLeave);
6335 }
6336 else {
6337 performLeave();
6338 }
6339 }
6340 }
6341 else {
6342 hostInsert(el, container, anchor);
6343 }
6344 };
6345 const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
6346 const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
6347 // unset ref
6348 if (ref != null) {
6349 setRef(ref, null, parentSuspense, vnode, true);
6350 }
6351 if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
6352 parentComponent.ctx.deactivate(vnode);
6353 return;
6354 }
6355 const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
6356 const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
6357 let vnodeHook;
6358 if (shouldInvokeVnodeHook &&
6359 (vnodeHook = props && props.onVnodeBeforeUnmount)) {
6360 invokeVNodeHook(vnodeHook, parentComponent, vnode);
6361 }
6362 if (shapeFlag & 6 /* COMPONENT */) {
6363 unmountComponent(vnode.component, parentSuspense, doRemove);
6364 }
6365 else {
6366 if (shapeFlag & 128 /* SUSPENSE */) {
6367 vnode.suspense.unmount(parentSuspense, doRemove);
6368 return;
6369 }
6370 if (shouldInvokeDirs) {
6371 invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
6372 }
6373 if (shapeFlag & 64 /* TELEPORT */) {
6374 vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
6375 }
6376 else if (dynamicChildren &&
6377 // #1153: fast path should not be taken for non-stable (v-for) fragments
6378 (type !== Fragment ||
6379 (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
6380 // fast path for block nodes: only need to unmount dynamic children.
6381 unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
6382 }
6383 else if ((type === Fragment &&
6384 patchFlag &
6385 (128 /* KEYED_FRAGMENT */ | 256 /* UNKEYED_FRAGMENT */)) ||
6386 (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
6387 unmountChildren(children, parentComponent, parentSuspense);
6388 }
6389 if (doRemove) {
6390 remove(vnode);
6391 }
6392 }
6393 if ((shouldInvokeVnodeHook &&
6394 (vnodeHook = props && props.onVnodeUnmounted)) ||
6395 shouldInvokeDirs) {
6396 queuePostRenderEffect(() => {
6397 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
6398 shouldInvokeDirs &&
6399 invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
6400 }, parentSuspense);
6401 }
6402 };
6403 const remove = vnode => {
6404 const { type, el, anchor, transition } = vnode;
6405 if (type === Fragment) {
6406 removeFragment(el, anchor);
6407 return;
6408 }
6409 if (type === Static) {
6410 removeStaticNode(vnode);
6411 return;
6412 }
6413 const performRemove = () => {
6414 hostRemove(el);
6415 if (transition && !transition.persisted && transition.afterLeave) {
6416 transition.afterLeave();
6417 }
6418 };
6419 if (vnode.shapeFlag & 1 /* ELEMENT */ &&
6420 transition &&
6421 !transition.persisted) {
6422 const { leave, delayLeave } = transition;
6423 const performLeave = () => leave(el, performRemove);
6424 if (delayLeave) {
6425 delayLeave(vnode.el, performRemove, performLeave);
6426 }
6427 else {
6428 performLeave();
6429 }
6430 }
6431 else {
6432 performRemove();
6433 }
6434 };
6435 const removeFragment = (cur, end) => {
6436 // For fragments, directly remove all contained DOM nodes.
6437 // (fragment child nodes cannot have transition)
6438 let next;
6439 while (cur !== end) {
6440 next = hostNextSibling(cur);
6441 hostRemove(cur);
6442 cur = next;
6443 }
6444 hostRemove(end);
6445 };
6446 const unmountComponent = (instance, parentSuspense, doRemove) => {
6447 if (instance.type.__hmrId) {
6448 unregisterHMR(instance);
6449 }
6450 const { bum, scope, update, subTree, um } = instance;
6451 // beforeUnmount hook
6452 if (bum) {
6453 invokeArrayFns(bum);
6454 }
6455 // stop effects in component scope
6456 scope.stop();
6457 // update may be null if a component is unmounted before its async
6458 // setup has resolved.
6459 if (update) {
6460 // so that scheduler will no longer invoke it
6461 update.active = false;
6462 unmount(subTree, instance, parentSuspense, doRemove);
6463 }
6464 // unmounted hook
6465 if (um) {
6466 queuePostRenderEffect(um, parentSuspense);
6467 }
6468 queuePostRenderEffect(() => {
6469 instance.isUnmounted = true;
6470 }, parentSuspense);
6471 // A component with async dep inside a pending suspense is unmounted before
6472 // its async dep resolves. This should remove the dep from the suspense, and
6473 // cause the suspense to resolve immediately if that was the last dep.
6474 if (parentSuspense &&
6475 parentSuspense.pendingBranch &&
6476 !parentSuspense.isUnmounted &&
6477 instance.asyncDep &&
6478 !instance.asyncResolved &&
6479 instance.suspenseId === parentSuspense.pendingId) {
6480 parentSuspense.deps--;
6481 if (parentSuspense.deps === 0) {
6482 parentSuspense.resolve();
6483 }
6484 }
6485 {
6486 devtoolsComponentRemoved(instance);
6487 }
6488 };
6489 const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
6490 for (let i = start; i < children.length; i++) {
6491 unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
6492 }
6493 };
6494 const getNextHostNode = vnode => {
6495 if (vnode.shapeFlag & 6 /* COMPONENT */) {
6496 return getNextHostNode(vnode.component.subTree);
6497 }
6498 if (vnode.shapeFlag & 128 /* SUSPENSE */) {
6499 return vnode.suspense.next();
6500 }
6501 return hostNextSibling((vnode.anchor || vnode.el));
6502 };
6503 const render = (vnode, container, isSVG) => {
6504 if (vnode == null) {
6505 if (container._vnode) {
6506 unmount(container._vnode, null, null, true);
6507 }
6508 }
6509 else {
6510 patch(container._vnode || null, vnode, container, null, null, null, isSVG);
6511 }
6512 flushPostFlushCbs();
6513 container._vnode = vnode;
6514 };
6515 const internals = {
6516 p: patch,
6517 um: unmount,
6518 m: move,
6519 r: remove,
6520 mt: mountComponent,
6521 mc: mountChildren,
6522 pc: patchChildren,
6523 pbc: patchBlockChildren,
6524 n: getNextHostNode,
6525 o: options
6526 };
6527 let hydrate;
6528 let hydrateNode;
6529 if (createHydrationFns) {
6530 [hydrate, hydrateNode] = createHydrationFns(internals);
6531 }
6532 return {
6533 render,
6534 hydrate,
6535 createApp: createAppAPI(render, hydrate)
6536 };
6537}
6538function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
6539 if (isArray(rawRef)) {
6540 rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
6541 return;
6542 }
6543 if (isAsyncWrapper(vnode) && !isUnmount) {
6544 // when mounting async components, nothing needs to be done,
6545 // because the template ref is forwarded to inner component
6546 return;
6547 }
6548 const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
6549 ? getExposeProxy(vnode.component) || vnode.component.proxy
6550 : vnode.el;
6551 const value = isUnmount ? null : refValue;
6552 const { i: owner, r: ref } = rawRef;
6553 if (!owner) {
6554 warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
6555 `A vnode with ref must be created inside the render function.`);
6556 return;
6557 }
6558 const oldRef = oldRawRef && oldRawRef.r;
6559 const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
6560 const setupState = owner.setupState;
6561 // dynamic ref changed. unset old ref
6562 if (oldRef != null && oldRef !== ref) {
6563 if (isString(oldRef)) {
6564 refs[oldRef] = null;
6565 if (hasOwn(setupState, oldRef)) {
6566 setupState[oldRef] = null;
6567 }
6568 }
6569 else if (isRef(oldRef)) {
6570 oldRef.value = null;
6571 }
6572 }
6573 if (isString(ref)) {
6574 const doSet = () => {
6575 {
6576 refs[ref] = value;
6577 }
6578 if (hasOwn(setupState, ref)) {
6579 setupState[ref] = value;
6580 }
6581 };
6582 // #1789: for non-null values, set them after render
6583 // null values means this is unmount and it should not overwrite another
6584 // ref with the same key
6585 if (value) {
6586 doSet.id = -1;
6587 queuePostRenderEffect(doSet, parentSuspense);
6588 }
6589 else {
6590 doSet();
6591 }
6592 }
6593 else if (isRef(ref)) {
6594 const doSet = () => {
6595 ref.value = value;
6596 };
6597 if (value) {
6598 doSet.id = -1;
6599 queuePostRenderEffect(doSet, parentSuspense);
6600 }
6601 else {
6602 doSet();
6603 }
6604 }
6605 else if (isFunction(ref)) {
6606 callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
6607 }
6608 else {
6609 warn$1('Invalid template ref type:', value, `(${typeof value})`);
6610 }
6611}
6612function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
6613 callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
6614 vnode,
6615 prevVNode
6616 ]);
6617}
6618/**
6619 * #1156
6620 * When a component is HMR-enabled, we need to make sure that all static nodes
6621 * inside a block also inherit the DOM element from the previous tree so that
6622 * HMR updates (which are full updates) can retrieve the element for patching.
6623 *
6624 * #2080
6625 * Inside keyed `template` fragment static children, if a fragment is moved,
6626 * the children will always moved so that need inherit el form previous nodes
6627 * to ensure correct moved position.
6628 */
6629function traverseStaticChildren(n1, n2, shallow = false) {
6630 const ch1 = n1.children;
6631 const ch2 = n2.children;
6632 if (isArray(ch1) && isArray(ch2)) {
6633 for (let i = 0; i < ch1.length; i++) {
6634 // this is only called in the optimized path so array children are
6635 // guaranteed to be vnodes
6636 const c1 = ch1[i];
6637 let c2 = ch2[i];
6638 if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
6639 if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
6640 c2 = ch2[i] = cloneIfMounted(ch2[i]);
6641 c2.el = c1.el;
6642 }
6643 if (!shallow)
6644 traverseStaticChildren(c1, c2);
6645 }
6646 // also inherit for comment nodes, but not placeholders (e.g. v-if which
6647 // would have received .el during block patch)
6648 if (c2.type === Comment && !c2.el) {
6649 c2.el = c1.el;
6650 }
6651 }
6652 }
6653}
6654// https://en.wikipedia.org/wiki/Longest_increasing_subsequence
6655function getSequence(arr) {
6656 const p = arr.slice();
6657 const result = [0];
6658 let i, j, u, v, c;
6659 const len = arr.length;
6660 for (i = 0; i < len; i++) {
6661 const arrI = arr[i];
6662 if (arrI !== 0) {
6663 j = result[result.length - 1];
6664 if (arr[j] < arrI) {
6665 p[i] = j;
6666 result.push(i);
6667 continue;
6668 }
6669 u = 0;
6670 v = result.length - 1;
6671 while (u < v) {
6672 c = (u + v) >> 1;
6673 if (arr[result[c]] < arrI) {
6674 u = c + 1;
6675 }
6676 else {
6677 v = c;
6678 }
6679 }
6680 if (arrI < arr[result[u]]) {
6681 if (u > 0) {
6682 p[i] = result[u - 1];
6683 }
6684 result[u] = i;
6685 }
6686 }
6687 }
6688 u = result.length;
6689 v = result[u - 1];
6690 while (u-- > 0) {
6691 result[u] = v;
6692 v = p[v];
6693 }
6694 return result;
6695}
6696
6697const isTeleport = (type) => type.__isTeleport;
6698const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
6699const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
6700const resolveTarget = (props, select) => {
6701 const targetSelector = props && props.to;
6702 if (isString(targetSelector)) {
6703 if (!select) {
6704 warn$1(`Current renderer does not support string target for Teleports. ` +
6705 `(missing querySelector renderer option)`);
6706 return null;
6707 }
6708 else {
6709 const target = select(targetSelector);
6710 if (!target) {
6711 warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
6712 `Note the target element must exist before the component is mounted - ` +
6713 `i.e. the target cannot be rendered by the component itself, and ` +
6714 `ideally should be outside of the entire Vue component tree.`);
6715 }
6716 return target;
6717 }
6718 }
6719 else {
6720 if (!targetSelector && !isTeleportDisabled(props)) {
6721 warn$1(`Invalid Teleport target: ${targetSelector}`);
6722 }
6723 return targetSelector;
6724 }
6725};
6726const TeleportImpl = {
6727 __isTeleport: true,
6728 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
6729 const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
6730 const disabled = isTeleportDisabled(n2.props);
6731 let { shapeFlag, children, dynamicChildren } = n2;
6732 // #3302
6733 // HMR updated, force full diff
6734 if (isHmrUpdating) {
6735 optimized = false;
6736 dynamicChildren = null;
6737 }
6738 if (n1 == null) {
6739 // insert anchors in the main view
6740 const placeholder = (n2.el = createComment('teleport start')
6741 );
6742 const mainAnchor = (n2.anchor = createComment('teleport end')
6743 );
6744 insert(placeholder, container, anchor);
6745 insert(mainAnchor, container, anchor);
6746 const target = (n2.target = resolveTarget(n2.props, querySelector));
6747 const targetAnchor = (n2.targetAnchor = createText(''));
6748 if (target) {
6749 insert(targetAnchor, target);
6750 // #2652 we could be teleporting from a non-SVG tree into an SVG tree
6751 isSVG = isSVG || isTargetSVG(target);
6752 }
6753 else if (!disabled) {
6754 warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
6755 }
6756 const mount = (container, anchor) => {
6757 // Teleport *always* has Array children. This is enforced in both the
6758 // compiler and vnode children normalization.
6759 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6760 mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6761 }
6762 };
6763 if (disabled) {
6764 mount(container, mainAnchor);
6765 }
6766 else if (target) {
6767 mount(target, targetAnchor);
6768 }
6769 }
6770 else {
6771 // update content
6772 n2.el = n1.el;
6773 const mainAnchor = (n2.anchor = n1.anchor);
6774 const target = (n2.target = n1.target);
6775 const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
6776 const wasDisabled = isTeleportDisabled(n1.props);
6777 const currentContainer = wasDisabled ? container : target;
6778 const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
6779 isSVG = isSVG || isTargetSVG(target);
6780 if (dynamicChildren) {
6781 // fast path when the teleport happens to be a block root
6782 patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
6783 // even in block tree mode we need to make sure all root-level nodes
6784 // in the teleport inherit previous DOM references so that they can
6785 // be moved in future patches.
6786 traverseStaticChildren(n1, n2, true);
6787 }
6788 else if (!optimized) {
6789 patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
6790 }
6791 if (disabled) {
6792 if (!wasDisabled) {
6793 // enabled -> disabled
6794 // move into main container
6795 moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
6796 }
6797 }
6798 else {
6799 // target changed
6800 if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
6801 const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
6802 if (nextTarget) {
6803 moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
6804 }
6805 else {
6806 warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
6807 }
6808 }
6809 else if (wasDisabled) {
6810 // disabled -> enabled
6811 // move into teleport target
6812 moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
6813 }
6814 }
6815 }
6816 },
6817 remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
6818 const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
6819 if (target) {
6820 hostRemove(targetAnchor);
6821 }
6822 // an unmounted teleport should always remove its children if not disabled
6823 if (doRemove || !isTeleportDisabled(props)) {
6824 hostRemove(anchor);
6825 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6826 for (let i = 0; i < children.length; i++) {
6827 const child = children[i];
6828 unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
6829 }
6830 }
6831 }
6832 },
6833 move: moveTeleport,
6834 hydrate: hydrateTeleport
6835};
6836function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
6837 // move target anchor if this is a target change.
6838 if (moveType === 0 /* TARGET_CHANGE */) {
6839 insert(vnode.targetAnchor, container, parentAnchor);
6840 }
6841 const { el, anchor, shapeFlag, children, props } = vnode;
6842 const isReorder = moveType === 2 /* REORDER */;
6843 // move main view anchor if this is a re-order.
6844 if (isReorder) {
6845 insert(el, container, parentAnchor);
6846 }
6847 // if this is a re-order and teleport is enabled (content is in target)
6848 // do not move children. So the opposite is: only move children if this
6849 // is not a reorder, or the teleport is disabled
6850 if (!isReorder || isTeleportDisabled(props)) {
6851 // Teleport has either Array children or no children.
6852 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6853 for (let i = 0; i < children.length; i++) {
6854 move(children[i], container, parentAnchor, 2 /* REORDER */);
6855 }
6856 }
6857 }
6858 // move main view anchor if this is a re-order.
6859 if (isReorder) {
6860 insert(anchor, container, parentAnchor);
6861 }
6862}
6863function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
6864 const target = (vnode.target = resolveTarget(vnode.props, querySelector));
6865 if (target) {
6866 // if multiple teleports rendered to the same target element, we need to
6867 // pick up from where the last teleport finished instead of the first node
6868 const targetNode = target._lpa || target.firstChild;
6869 if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
6870 if (isTeleportDisabled(vnode.props)) {
6871 vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
6872 vnode.targetAnchor = targetNode;
6873 }
6874 else {
6875 vnode.anchor = nextSibling(node);
6876 vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
6877 }
6878 target._lpa =
6879 vnode.targetAnchor && nextSibling(vnode.targetAnchor);
6880 }
6881 }
6882 return vnode.anchor && nextSibling(vnode.anchor);
6883}
6884// Force-casted public typing for h and TSX props inference
6885const Teleport = TeleportImpl;
6886
6887const COMPONENTS = 'components';
6888const DIRECTIVES = 'directives';
6889/**
6890 * @private
6891 */
6892function resolveComponent(name, maybeSelfReference) {
6893 return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
6894}
6895const NULL_DYNAMIC_COMPONENT = Symbol();
6896/**
6897 * @private
6898 */
6899function resolveDynamicComponent(component) {
6900 if (isString(component)) {
6901 return resolveAsset(COMPONENTS, component, false) || component;
6902 }
6903 else {
6904 // invalid types will fallthrough to createVNode and raise warning
6905 return (component || NULL_DYNAMIC_COMPONENT);
6906 }
6907}
6908/**
6909 * @private
6910 */
6911function resolveDirective(name) {
6912 return resolveAsset(DIRECTIVES, name);
6913}
6914// implementation
6915function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
6916 const instance = currentRenderingInstance || currentInstance;
6917 if (instance) {
6918 const Component = instance.type;
6919 // explicit self name has highest priority
6920 if (type === COMPONENTS) {
6921 const selfName = getComponentName(Component);
6922 if (selfName &&
6923 (selfName === name ||
6924 selfName === camelize(name) ||
6925 selfName === capitalize(camelize(name)))) {
6926 return Component;
6927 }
6928 }
6929 const res =
6930 // local registration
6931 // check instance[type] first which is resolved for options API
6932 resolve(instance[type] || Component[type], name) ||
6933 // global registration
6934 resolve(instance.appContext[type], name);
6935 if (!res && maybeSelfReference) {
6936 // fallback to implicit self-reference
6937 return Component;
6938 }
6939 if (warnMissing && !res) {
6940 warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
6941 }
6942 return res;
6943 }
6944 else {
6945 warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
6946 `can only be used in render() or setup().`);
6947 }
6948}
6949function resolve(registry, name) {
6950 return (registry &&
6951 (registry[name] ||
6952 registry[camelize(name)] ||
6953 registry[capitalize(camelize(name))]));
6954}
6955
6956const Fragment = Symbol('Fragment' );
6957const Text = Symbol('Text' );
6958const Comment = Symbol('Comment' );
6959const Static = Symbol('Static' );
6960// Since v-if and v-for are the two possible ways node structure can dynamically
6961// change, once we consider v-if branches and each v-for fragment a block, we
6962// can divide a template into nested blocks, and within each block the node
6963// structure would be stable. This allows us to skip most children diffing
6964// and only worry about the dynamic nodes (indicated by patch flags).
6965const blockStack = [];
6966let currentBlock = null;
6967/**
6968 * Open a block.
6969 * This must be called before `createBlock`. It cannot be part of `createBlock`
6970 * because the children of the block are evaluated before `createBlock` itself
6971 * is called. The generated code typically looks like this:
6972 *
6973 * ```js
6974 * function render() {
6975 * return (openBlock(),createBlock('div', null, [...]))
6976 * }
6977 * ```
6978 * disableTracking is true when creating a v-for fragment block, since a v-for
6979 * fragment always diffs its children.
6980 *
6981 * @private
6982 */
6983function openBlock(disableTracking = false) {
6984 blockStack.push((currentBlock = disableTracking ? null : []));
6985}
6986function closeBlock() {
6987 blockStack.pop();
6988 currentBlock = blockStack[blockStack.length - 1] || null;
6989}
6990// Whether we should be tracking dynamic child nodes inside a block.
6991// Only tracks when this value is > 0
6992// We are not using a simple boolean because this value may need to be
6993// incremented/decremented by nested usage of v-once (see below)
6994let isBlockTreeEnabled = 1;
6995/**
6996 * Block tracking sometimes needs to be disabled, for example during the
6997 * creation of a tree that needs to be cached by v-once. The compiler generates
6998 * code like this:
6999 *
7000 * ``` js
7001 * _cache[1] || (
7002 * setBlockTracking(-1),
7003 * _cache[1] = createVNode(...),
7004 * setBlockTracking(1),
7005 * _cache[1]
7006 * )
7007 * ```
7008 *
7009 * @private
7010 */
7011function setBlockTracking(value) {
7012 isBlockTreeEnabled += value;
7013}
7014function setupBlock(vnode) {
7015 // save current block children on the block vnode
7016 vnode.dynamicChildren =
7017 isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
7018 // close block
7019 closeBlock();
7020 // a block is always going to be patched, so track it as a child of its
7021 // parent block
7022 if (isBlockTreeEnabled > 0 && currentBlock) {
7023 currentBlock.push(vnode);
7024 }
7025 return vnode;
7026}
7027/**
7028 * @private
7029 */
7030function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
7031 return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
7032}
7033/**
7034 * Create a block root vnode. Takes the same exact arguments as `createVNode`.
7035 * A block root keeps track of dynamic nodes within the block in the
7036 * `dynamicChildren` array.
7037 *
7038 * @private
7039 */
7040function createBlock(type, props, children, patchFlag, dynamicProps) {
7041 return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
7042}
7043function isVNode(value) {
7044 return value ? value.__v_isVNode === true : false;
7045}
7046function isSameVNodeType(n1, n2) {
7047 if (n2.shapeFlag & 6 /* COMPONENT */ &&
7048 hmrDirtyComponents.has(n2.type)) {
7049 // HMR only: if the component has been hot-updated, force a reload.
7050 return false;
7051 }
7052 return n1.type === n2.type && n1.key === n2.key;
7053}
7054let vnodeArgsTransformer;
7055/**
7056 * Internal API for registering an arguments transform for createVNode
7057 * used for creating stubs in the test-utils
7058 * It is *internal* but needs to be exposed for test-utils to pick up proper
7059 * typings
7060 */
7061function transformVNodeArgs(transformer) {
7062 vnodeArgsTransformer = transformer;
7063}
7064const createVNodeWithArgsTransform = (...args) => {
7065 return _createVNode(...(vnodeArgsTransformer
7066 ? vnodeArgsTransformer(args, currentRenderingInstance)
7067 : args));
7068};
7069const InternalObjectKey = `__vInternal`;
7070const normalizeKey = ({ key }) => key != null ? key : null;
7071const normalizeRef = ({ ref }) => {
7072 return (ref != null
7073 ? isString(ref) || isRef(ref) || isFunction(ref)
7074 ? { i: currentRenderingInstance, r: ref }
7075 : ref
7076 : null);
7077};
7078function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
7079 const vnode = {
7080 __v_isVNode: true,
7081 __v_skip: true,
7082 type,
7083 props,
7084 key: props && normalizeKey(props),
7085 ref: props && normalizeRef(props),
7086 scopeId: currentScopeId,
7087 slotScopeIds: null,
7088 children,
7089 component: null,
7090 suspense: null,
7091 ssContent: null,
7092 ssFallback: null,
7093 dirs: null,
7094 transition: null,
7095 el: null,
7096 anchor: null,
7097 target: null,
7098 targetAnchor: null,
7099 staticCount: 0,
7100 shapeFlag,
7101 patchFlag,
7102 dynamicProps,
7103 dynamicChildren: null,
7104 appContext: null
7105 };
7106 if (needFullChildrenNormalization) {
7107 normalizeChildren(vnode, children);
7108 // normalize suspense children
7109 if (shapeFlag & 128 /* SUSPENSE */) {
7110 type.normalize(vnode);
7111 }
7112 }
7113 else if (children) {
7114 // compiled element vnode - if children is passed, only possible types are
7115 // string or Array.
7116 vnode.shapeFlag |= isString(children)
7117 ? 8 /* TEXT_CHILDREN */
7118 : 16 /* ARRAY_CHILDREN */;
7119 }
7120 // validate key
7121 if (vnode.key !== vnode.key) {
7122 warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
7123 }
7124 // track vnode for block tree
7125 if (isBlockTreeEnabled > 0 &&
7126 // avoid a block node from tracking itself
7127 !isBlockNode &&
7128 // has current parent block
7129 currentBlock &&
7130 // presence of a patch flag indicates this node needs patching on updates.
7131 // component nodes also should always be patched, because even if the
7132 // component doesn't need to update, it needs to persist the instance on to
7133 // the next vnode so that it can be properly unmounted later.
7134 (vnode.patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
7135 // the EVENTS flag is only for hydration and if it is the only flag, the
7136 // vnode should not be considered dynamic due to handler caching.
7137 vnode.patchFlag !== 32 /* HYDRATE_EVENTS */) {
7138 currentBlock.push(vnode);
7139 }
7140 return vnode;
7141}
7142const createVNode = (createVNodeWithArgsTransform );
7143function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
7144 if (!type || type === NULL_DYNAMIC_COMPONENT) {
7145 if (!type) {
7146 warn$1(`Invalid vnode type when creating vnode: ${type}.`);
7147 }
7148 type = Comment;
7149 }
7150 if (isVNode(type)) {
7151 // createVNode receiving an existing vnode. This happens in cases like
7152 // <component :is="vnode"/>
7153 // #2078 make sure to merge refs during the clone instead of overwriting it
7154 const cloned = cloneVNode(type, props, true /* mergeRef: true */);
7155 if (children) {
7156 normalizeChildren(cloned, children);
7157 }
7158 return cloned;
7159 }
7160 // class component normalization.
7161 if (isClassComponent(type)) {
7162 type = type.__vccOpts;
7163 }
7164 // class & style normalization.
7165 if (props) {
7166 // for reactive or proxy objects, we need to clone it to enable mutation.
7167 props = guardReactiveProps(props);
7168 let { class: klass, style } = props;
7169 if (klass && !isString(klass)) {
7170 props.class = normalizeClass(klass);
7171 }
7172 if (isObject(style)) {
7173 // reactive state objects need to be cloned since they are likely to be
7174 // mutated
7175 if (isProxy(style) && !isArray(style)) {
7176 style = extend({}, style);
7177 }
7178 props.style = normalizeStyle(style);
7179 }
7180 }
7181 // encode the vnode type information into a bitmap
7182 const shapeFlag = isString(type)
7183 ? 1 /* ELEMENT */
7184 : isSuspense(type)
7185 ? 128 /* SUSPENSE */
7186 : isTeleport(type)
7187 ? 64 /* TELEPORT */
7188 : isObject(type)
7189 ? 4 /* STATEFUL_COMPONENT */
7190 : isFunction(type)
7191 ? 2 /* FUNCTIONAL_COMPONENT */
7192 : 0;
7193 if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
7194 type = toRaw(type);
7195 warn$1(`Vue received a Component which was made a reactive object. This can ` +
7196 `lead to unnecessary performance overhead, and should be avoided by ` +
7197 `marking the component with \`markRaw\` or using \`shallowRef\` ` +
7198 `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
7199 }
7200 return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
7201}
7202function guardReactiveProps(props) {
7203 if (!props)
7204 return null;
7205 return isProxy(props) || InternalObjectKey in props
7206 ? extend({}, props)
7207 : props;
7208}
7209function cloneVNode(vnode, extraProps, mergeRef = false) {
7210 // This is intentionally NOT using spread or extend to avoid the runtime
7211 // key enumeration cost.
7212 const { props, ref, patchFlag, children } = vnode;
7213 const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
7214 const cloned = {
7215 __v_isVNode: true,
7216 __v_skip: true,
7217 type: vnode.type,
7218 props: mergedProps,
7219 key: mergedProps && normalizeKey(mergedProps),
7220 ref: extraProps && extraProps.ref
7221 ? // #2078 in the case of <component :is="vnode" ref="extra"/>
7222 // if the vnode itself already has a ref, cloneVNode will need to merge
7223 // the refs so the single vnode can be set on multiple refs
7224 mergeRef && ref
7225 ? isArray(ref)
7226 ? ref.concat(normalizeRef(extraProps))
7227 : [ref, normalizeRef(extraProps)]
7228 : normalizeRef(extraProps)
7229 : ref,
7230 scopeId: vnode.scopeId,
7231 slotScopeIds: vnode.slotScopeIds,
7232 children: patchFlag === -1 /* HOISTED */ && isArray(children)
7233 ? children.map(deepCloneVNode)
7234 : children,
7235 target: vnode.target,
7236 targetAnchor: vnode.targetAnchor,
7237 staticCount: vnode.staticCount,
7238 shapeFlag: vnode.shapeFlag,
7239 // if the vnode is cloned with extra props, we can no longer assume its
7240 // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7241 // note: perserve flag for fragments since they use the flag for children
7242 // fast paths only.
7243 patchFlag: extraProps && vnode.type !== Fragment
7244 ? patchFlag === -1 // hoisted node
7245 ? 16 /* FULL_PROPS */
7246 : patchFlag | 16 /* FULL_PROPS */
7247 : patchFlag,
7248 dynamicProps: vnode.dynamicProps,
7249 dynamicChildren: vnode.dynamicChildren,
7250 appContext: vnode.appContext,
7251 dirs: vnode.dirs,
7252 transition: vnode.transition,
7253 // These should technically only be non-null on mounted VNodes. However,
7254 // they *should* be copied for kept-alive vnodes. So we just always copy
7255 // them since them being non-null during a mount doesn't affect the logic as
7256 // they will simply be overwritten.
7257 component: vnode.component,
7258 suspense: vnode.suspense,
7259 ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
7260 ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
7261 el: vnode.el,
7262 anchor: vnode.anchor
7263 };
7264 return cloned;
7265}
7266/**
7267 * Dev only, for HMR of hoisted vnodes reused in v-for
7268 * https://github.com/vitejs/vite/issues/2022
7269 */
7270function deepCloneVNode(vnode) {
7271 const cloned = cloneVNode(vnode);
7272 if (isArray(vnode.children)) {
7273 cloned.children = vnode.children.map(deepCloneVNode);
7274 }
7275 return cloned;
7276}
7277/**
7278 * @private
7279 */
7280function createTextVNode(text = ' ', flag = 0) {
7281 return createVNode(Text, null, text, flag);
7282}
7283/**
7284 * @private
7285 */
7286function createStaticVNode(content, numberOfNodes) {
7287 // A static vnode can contain multiple stringified elements, and the number
7288 // of elements is necessary for hydration.
7289 const vnode = createVNode(Static, null, content);
7290 vnode.staticCount = numberOfNodes;
7291 return vnode;
7292}
7293/**
7294 * @private
7295 */
7296function createCommentVNode(text = '',
7297// when used as the v-else branch, the comment node must be created as a
7298// block to ensure correct updates.
7299asBlock = false) {
7300 return asBlock
7301 ? (openBlock(), createBlock(Comment, null, text))
7302 : createVNode(Comment, null, text);
7303}
7304function normalizeVNode(child) {
7305 if (child == null || typeof child === 'boolean') {
7306 // empty placeholder
7307 return createVNode(Comment);
7308 }
7309 else if (isArray(child)) {
7310 // fragment
7311 return createVNode(Fragment, null,
7312 // #3666, avoid reference pollution when reusing vnode
7313 child.slice());
7314 }
7315 else if (typeof child === 'object') {
7316 // already vnode, this should be the most common since compiled templates
7317 // always produce all-vnode children arrays
7318 return cloneIfMounted(child);
7319 }
7320 else {
7321 // strings and numbers
7322 return createVNode(Text, null, String(child));
7323 }
7324}
7325// optimized normalization for template-compiled render fns
7326function cloneIfMounted(child) {
7327 return child.el === null || child.memo ? child : cloneVNode(child);
7328}
7329function normalizeChildren(vnode, children) {
7330 let type = 0;
7331 const { shapeFlag } = vnode;
7332 if (children == null) {
7333 children = null;
7334 }
7335 else if (isArray(children)) {
7336 type = 16 /* ARRAY_CHILDREN */;
7337 }
7338 else if (typeof children === 'object') {
7339 if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7340 // Normalize slot to plain children for plain element and Teleport
7341 const slot = children.default;
7342 if (slot) {
7343 // _c marker is added by withCtx() indicating this is a compiled slot
7344 slot._c && (slot._d = false);
7345 normalizeChildren(vnode, slot());
7346 slot._c && (slot._d = true);
7347 }
7348 return;
7349 }
7350 else {
7351 type = 32 /* SLOTS_CHILDREN */;
7352 const slotFlag = children._;
7353 if (!slotFlag && !(InternalObjectKey in children)) {
7354 children._ctx = currentRenderingInstance;
7355 }
7356 else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
7357 // a child component receives forwarded slots from the parent.
7358 // its slot type is determined by its parent's slot type.
7359 if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
7360 children._ = 1 /* STABLE */;
7361 }
7362 else {
7363 children._ = 2 /* DYNAMIC */;
7364 vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
7365 }
7366 }
7367 }
7368 }
7369 else if (isFunction(children)) {
7370 children = { default: children, _ctx: currentRenderingInstance };
7371 type = 32 /* SLOTS_CHILDREN */;
7372 }
7373 else {
7374 children = String(children);
7375 // force teleport children to array so it can be moved around
7376 if (shapeFlag & 64 /* TELEPORT */) {
7377 type = 16 /* ARRAY_CHILDREN */;
7378 children = [createTextVNode(children)];
7379 }
7380 else {
7381 type = 8 /* TEXT_CHILDREN */;
7382 }
7383 }
7384 vnode.children = children;
7385 vnode.shapeFlag |= type;
7386}
7387function mergeProps(...args) {
7388 const ret = {};
7389 for (let i = 0; i < args.length; i++) {
7390 const toMerge = args[i];
7391 for (const key in toMerge) {
7392 if (key === 'class') {
7393 if (ret.class !== toMerge.class) {
7394 ret.class = normalizeClass([ret.class, toMerge.class]);
7395 }
7396 }
7397 else if (key === 'style') {
7398 ret.style = normalizeStyle([ret.style, toMerge.style]);
7399 }
7400 else if (isOn(key)) {
7401 const existing = ret[key];
7402 const incoming = toMerge[key];
7403 if (existing !== incoming) {
7404 ret[key] = existing
7405 ? [].concat(existing, incoming)
7406 : incoming;
7407 }
7408 }
7409 else if (key !== '') {
7410 ret[key] = toMerge[key];
7411 }
7412 }
7413 }
7414 return ret;
7415}
7416
7417/**
7418 * Actual implementation
7419 */
7420function renderList(source, renderItem, cache, index) {
7421 let ret;
7422 const cached = (cache && cache[index]);
7423 if (isArray(source) || isString(source)) {
7424 ret = new Array(source.length);
7425 for (let i = 0, l = source.length; i < l; i++) {
7426 ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
7427 }
7428 }
7429 else if (typeof source === 'number') {
7430 if (!Number.isInteger(source)) {
7431 warn$1(`The v-for range expect an integer value but got ${source}.`);
7432 return [];
7433 }
7434 ret = new Array(source);
7435 for (let i = 0; i < source; i++) {
7436 ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
7437 }
7438 }
7439 else if (isObject(source)) {
7440 if (source[Symbol.iterator]) {
7441 ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
7442 }
7443 else {
7444 const keys = Object.keys(source);
7445 ret = new Array(keys.length);
7446 for (let i = 0, l = keys.length; i < l; i++) {
7447 const key = keys[i];
7448 ret[i] = renderItem(source[key], key, i, cached && cached[i]);
7449 }
7450 }
7451 }
7452 else {
7453 ret = [];
7454 }
7455 if (cache) {
7456 cache[index] = ret;
7457 }
7458 return ret;
7459}
7460
7461/**
7462 * Compiler runtime helper for creating dynamic slots object
7463 * @private
7464 */
7465function createSlots(slots, dynamicSlots) {
7466 for (let i = 0; i < dynamicSlots.length; i++) {
7467 const slot = dynamicSlots[i];
7468 // array of dynamic slot generated by <template v-for="..." #[...]>
7469 if (isArray(slot)) {
7470 for (let j = 0; j < slot.length; j++) {
7471 slots[slot[j].name] = slot[j].fn;
7472 }
7473 }
7474 else if (slot) {
7475 // conditional single slot generated by <template v-if="..." #foo>
7476 slots[slot.name] = slot.fn;
7477 }
7478 }
7479 return slots;
7480}
7481
7482/**
7483 * Compiler runtime helper for rendering `<slot/>`
7484 * @private
7485 */
7486function renderSlot(slots, name, props = {},
7487// this is not a user-facing function, so the fallback is always generated by
7488// the compiler and guaranteed to be a function returning an array
7489fallback, noSlotted) {
7490 if (currentRenderingInstance.isCE) {
7491 return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
7492 }
7493 let slot = slots[name];
7494 if (slot && slot.length > 1) {
7495 warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
7496 `function. You need to mark this component with $dynamic-slots in the ` +
7497 `parent template.`);
7498 slot = () => [];
7499 }
7500 // a compiled slot disables block tracking by default to avoid manual
7501 // invocation interfering with template-based block tracking, but in
7502 // `renderSlot` we can be sure that it's template-based so we can force
7503 // enable it.
7504 if (slot && slot._c) {
7505 slot._d = false;
7506 }
7507 openBlock();
7508 const validSlotContent = slot && ensureValidVNode(slot(props));
7509 const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
7510 ? 64 /* STABLE_FRAGMENT */
7511 : -2 /* BAIL */);
7512 if (!noSlotted && rendered.scopeId) {
7513 rendered.slotScopeIds = [rendered.scopeId + '-s'];
7514 }
7515 if (slot && slot._c) {
7516 slot._d = true;
7517 }
7518 return rendered;
7519}
7520function ensureValidVNode(vnodes) {
7521 return vnodes.some(child => {
7522 if (!isVNode(child))
7523 return true;
7524 if (child.type === Comment)
7525 return false;
7526 if (child.type === Fragment &&
7527 !ensureValidVNode(child.children))
7528 return false;
7529 return true;
7530 })
7531 ? vnodes
7532 : null;
7533}
7534
7535/**
7536 * For prefixing keys in v-on="obj" with "on"
7537 * @private
7538 */
7539function toHandlers(obj) {
7540 const ret = {};
7541 if (!isObject(obj)) {
7542 warn$1(`v-on with no argument expects an object value.`);
7543 return ret;
7544 }
7545 for (const key in obj) {
7546 ret[toHandlerKey(key)] = obj[key];
7547 }
7548 return ret;
7549}
7550
7551/**
7552 * #2437 In Vue 3, functional components do not have a public instance proxy but
7553 * they exist in the internal parent chain. For code that relies on traversing
7554 * public $parent chains, skip functional ones and go to the parent instead.
7555 */
7556const getPublicInstance = (i) => {
7557 if (!i)
7558 return null;
7559 if (isStatefulComponent(i))
7560 return getExposeProxy(i) || i.proxy;
7561 return getPublicInstance(i.parent);
7562};
7563const publicPropertiesMap = extend(Object.create(null), {
7564 $: i => i,
7565 $el: i => i.vnode.el,
7566 $data: i => i.data,
7567 $props: i => (shallowReadonly(i.props) ),
7568 $attrs: i => (shallowReadonly(i.attrs) ),
7569 $slots: i => (shallowReadonly(i.slots) ),
7570 $refs: i => (shallowReadonly(i.refs) ),
7571 $parent: i => getPublicInstance(i.parent),
7572 $root: i => getPublicInstance(i.root),
7573 $emit: i => i.emit,
7574 $options: i => (resolveMergedOptions(i) ),
7575 $forceUpdate: i => () => queueJob(i.update),
7576 $nextTick: i => nextTick.bind(i.proxy),
7577 $watch: i => (instanceWatch.bind(i) )
7578});
7579const PublicInstanceProxyHandlers = {
7580 get({ _: instance }, key) {
7581 const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
7582 // for internal formatters to know that this is a Vue instance
7583 if (key === '__isVue') {
7584 return true;
7585 }
7586 // prioritize <script setup> bindings during dev.
7587 // this allows even properties that start with _ or $ to be used - so that
7588 // it aligns with the production behavior where the render fn is inlined and
7589 // indeed has access to all declared variables.
7590 if (setupState !== EMPTY_OBJ &&
7591 setupState.__isScriptSetup &&
7592 hasOwn(setupState, key)) {
7593 return setupState[key];
7594 }
7595 // data / props / ctx
7596 // This getter gets called for every property access on the render context
7597 // during render and is a major hotspot. The most expensive part of this
7598 // is the multiple hasOwn() calls. It's much faster to do a simple property
7599 // access on a plain object, so we use an accessCache object (with null
7600 // prototype) to memoize what access type a key corresponds to.
7601 let normalizedProps;
7602 if (key[0] !== '$') {
7603 const n = accessCache[key];
7604 if (n !== undefined) {
7605 switch (n) {
7606 case 0 /* SETUP */:
7607 return setupState[key];
7608 case 1 /* DATA */:
7609 return data[key];
7610 case 3 /* CONTEXT */:
7611 return ctx[key];
7612 case 2 /* PROPS */:
7613 return props[key];
7614 // default: just fallthrough
7615 }
7616 }
7617 else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7618 accessCache[key] = 0 /* SETUP */;
7619 return setupState[key];
7620 }
7621 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7622 accessCache[key] = 1 /* DATA */;
7623 return data[key];
7624 }
7625 else if (
7626 // only cache other properties when instance has declared (thus stable)
7627 // props
7628 (normalizedProps = instance.propsOptions[0]) &&
7629 hasOwn(normalizedProps, key)) {
7630 accessCache[key] = 2 /* PROPS */;
7631 return props[key];
7632 }
7633 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7634 accessCache[key] = 3 /* CONTEXT */;
7635 return ctx[key];
7636 }
7637 else if (shouldCacheAccess) {
7638 accessCache[key] = 4 /* OTHER */;
7639 }
7640 }
7641 const publicGetter = publicPropertiesMap[key];
7642 let cssModule, globalProperties;
7643 // public $xxx properties
7644 if (publicGetter) {
7645 if (key === '$attrs') {
7646 track(instance, "get" /* GET */, key);
7647 markAttrsAccessed();
7648 }
7649 return publicGetter(instance);
7650 }
7651 else if (
7652 // css module (injected by vue-loader)
7653 (cssModule = type.__cssModules) &&
7654 (cssModule = cssModule[key])) {
7655 return cssModule;
7656 }
7657 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7658 // user may set custom properties to `this` that start with `$`
7659 accessCache[key] = 3 /* CONTEXT */;
7660 return ctx[key];
7661 }
7662 else if (
7663 // global properties
7664 ((globalProperties = appContext.config.globalProperties),
7665 hasOwn(globalProperties, key))) {
7666 {
7667 return globalProperties[key];
7668 }
7669 }
7670 else if (currentRenderingInstance &&
7671 (!isString(key) ||
7672 // #1091 avoid internal isRef/isVNode checks on component instance leading
7673 // to infinite warning loop
7674 key.indexOf('__v') !== 0)) {
7675 if (data !== EMPTY_OBJ &&
7676 (key[0] === '$' || key[0] === '_') &&
7677 hasOwn(data, key)) {
7678 warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
7679 `character ("$" or "_") and is not proxied on the render context.`);
7680 }
7681 else if (instance === currentRenderingInstance) {
7682 warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
7683 `but is not defined on instance.`);
7684 }
7685 }
7686 },
7687 set({ _: instance }, key, value) {
7688 const { data, setupState, ctx } = instance;
7689 if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7690 setupState[key] = value;
7691 }
7692 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7693 data[key] = value;
7694 }
7695 else if (hasOwn(instance.props, key)) {
7696 warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
7697 return false;
7698 }
7699 if (key[0] === '$' && key.slice(1) in instance) {
7700 warn$1(`Attempting to mutate public property "${key}". ` +
7701 `Properties starting with $ are reserved and readonly.`, instance);
7702 return false;
7703 }
7704 else {
7705 if (key in instance.appContext.config.globalProperties) {
7706 Object.defineProperty(ctx, key, {
7707 enumerable: true,
7708 configurable: true,
7709 value
7710 });
7711 }
7712 else {
7713 ctx[key] = value;
7714 }
7715 }
7716 return true;
7717 },
7718 has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7719 let normalizedProps;
7720 return (accessCache[key] !== undefined ||
7721 (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7722 (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7723 ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
7724 hasOwn(ctx, key) ||
7725 hasOwn(publicPropertiesMap, key) ||
7726 hasOwn(appContext.config.globalProperties, key));
7727 }
7728};
7729{
7730 PublicInstanceProxyHandlers.ownKeys = (target) => {
7731 warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
7732 `The keys will be empty in production mode to avoid performance overhead.`);
7733 return Reflect.ownKeys(target);
7734 };
7735}
7736const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
7737 get(target, key) {
7738 // fast path for unscopables when using `with` block
7739 if (key === Symbol.unscopables) {
7740 return;
7741 }
7742 return PublicInstanceProxyHandlers.get(target, key, target);
7743 },
7744 has(_, key) {
7745 const has = key[0] !== '_' && !isGloballyWhitelisted(key);
7746 if (!has && PublicInstanceProxyHandlers.has(_, key)) {
7747 warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
7748 }
7749 return has;
7750 }
7751});
7752// dev only
7753// In dev mode, the proxy target exposes the same properties as seen on `this`
7754// for easier console inspection. In prod mode it will be an empty object so
7755// these properties definitions can be skipped.
7756function createDevRenderContext(instance) {
7757 const target = {};
7758 // expose internal instance for proxy handlers
7759 Object.defineProperty(target, `_`, {
7760 configurable: true,
7761 enumerable: false,
7762 get: () => instance
7763 });
7764 // expose public properties
7765 Object.keys(publicPropertiesMap).forEach(key => {
7766 Object.defineProperty(target, key, {
7767 configurable: true,
7768 enumerable: false,
7769 get: () => publicPropertiesMap[key](instance),
7770 // intercepted by the proxy so no need for implementation,
7771 // but needed to prevent set errors
7772 set: NOOP
7773 });
7774 });
7775 return target;
7776}
7777// dev only
7778function exposePropsOnRenderContext(instance) {
7779 const { ctx, propsOptions: [propsOptions] } = instance;
7780 if (propsOptions) {
7781 Object.keys(propsOptions).forEach(key => {
7782 Object.defineProperty(ctx, key, {
7783 enumerable: true,
7784 configurable: true,
7785 get: () => instance.props[key],
7786 set: NOOP
7787 });
7788 });
7789 }
7790}
7791// dev only
7792function exposeSetupStateOnRenderContext(instance) {
7793 const { ctx, setupState } = instance;
7794 Object.keys(toRaw(setupState)).forEach(key => {
7795 if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
7796 warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
7797 `which are reserved prefixes for Vue internals.`);
7798 return;
7799 }
7800 Object.defineProperty(ctx, key, {
7801 enumerable: true,
7802 configurable: true,
7803 get: () => setupState[key],
7804 set: NOOP
7805 });
7806 });
7807}
7808
7809const emptyAppContext = createAppContext();
7810let uid$1 = 0;
7811function createComponentInstance(vnode, parent, suspense) {
7812 const type = vnode.type;
7813 // inherit parent app context - or - if root, adopt from root vnode
7814 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
7815 const instance = {
7816 uid: uid$1++,
7817 vnode,
7818 type,
7819 parent,
7820 appContext,
7821 root: null,
7822 next: null,
7823 subTree: null,
7824 update: null,
7825 scope: new EffectScope(true /* detached */),
7826 render: null,
7827 proxy: null,
7828 exposed: null,
7829 exposeProxy: null,
7830 withProxy: null,
7831 provides: parent ? parent.provides : Object.create(appContext.provides),
7832 accessCache: null,
7833 renderCache: [],
7834 // local resovled assets
7835 components: null,
7836 directives: null,
7837 // resolved props and emits options
7838 propsOptions: normalizePropsOptions(type, appContext),
7839 emitsOptions: normalizeEmitsOptions(type, appContext),
7840 // emit
7841 emit: null,
7842 emitted: null,
7843 // props default value
7844 propsDefaults: EMPTY_OBJ,
7845 // inheritAttrs
7846 inheritAttrs: type.inheritAttrs,
7847 // state
7848 ctx: EMPTY_OBJ,
7849 data: EMPTY_OBJ,
7850 props: EMPTY_OBJ,
7851 attrs: EMPTY_OBJ,
7852 slots: EMPTY_OBJ,
7853 refs: EMPTY_OBJ,
7854 setupState: EMPTY_OBJ,
7855 setupContext: null,
7856 // suspense related
7857 suspense,
7858 suspenseId: suspense ? suspense.pendingId : 0,
7859 asyncDep: null,
7860 asyncResolved: false,
7861 // lifecycle hooks
7862 // not using enums here because it results in computed properties
7863 isMounted: false,
7864 isUnmounted: false,
7865 isDeactivated: false,
7866 bc: null,
7867 c: null,
7868 bm: null,
7869 m: null,
7870 bu: null,
7871 u: null,
7872 um: null,
7873 bum: null,
7874 da: null,
7875 a: null,
7876 rtg: null,
7877 rtc: null,
7878 ec: null,
7879 sp: null
7880 };
7881 {
7882 instance.ctx = createDevRenderContext(instance);
7883 }
7884 instance.root = parent ? parent.root : instance;
7885 instance.emit = emit.bind(null, instance);
7886 // apply custom element special handling
7887 if (vnode.ce) {
7888 vnode.ce(instance);
7889 }
7890 return instance;
7891}
7892let currentInstance = null;
7893const getCurrentInstance = () => currentInstance || currentRenderingInstance;
7894const setCurrentInstance = (instance) => {
7895 currentInstance = instance;
7896 instance.scope.on();
7897};
7898const unsetCurrentInstance = () => {
7899 currentInstance && currentInstance.scope.off();
7900 currentInstance = null;
7901};
7902const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
7903function validateComponentName(name, config) {
7904 const appIsNativeTag = config.isNativeTag || NO;
7905 if (isBuiltInTag(name) || appIsNativeTag(name)) {
7906 warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
7907 }
7908}
7909function isStatefulComponent(instance) {
7910 return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
7911}
7912let isInSSRComponentSetup = false;
7913function setupComponent(instance, isSSR = false) {
7914 isInSSRComponentSetup = isSSR;
7915 const { props, children } = instance.vnode;
7916 const isStateful = isStatefulComponent(instance);
7917 initProps(instance, props, isStateful, isSSR);
7918 initSlots(instance, children);
7919 const setupResult = isStateful
7920 ? setupStatefulComponent(instance, isSSR)
7921 : undefined;
7922 isInSSRComponentSetup = false;
7923 return setupResult;
7924}
7925function setupStatefulComponent(instance, isSSR) {
7926 const Component = instance.type;
7927 {
7928 if (Component.name) {
7929 validateComponentName(Component.name, instance.appContext.config);
7930 }
7931 if (Component.components) {
7932 const names = Object.keys(Component.components);
7933 for (let i = 0; i < names.length; i++) {
7934 validateComponentName(names[i], instance.appContext.config);
7935 }
7936 }
7937 if (Component.directives) {
7938 const names = Object.keys(Component.directives);
7939 for (let i = 0; i < names.length; i++) {
7940 validateDirectiveName(names[i]);
7941 }
7942 }
7943 if (Component.compilerOptions && isRuntimeOnly()) {
7944 warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
7945 `includes the runtime compiler. Since you are using a runtime-only ` +
7946 `build, the options should be passed via your build tool config instead.`);
7947 }
7948 }
7949 // 0. create render proxy property access cache
7950 instance.accessCache = Object.create(null);
7951 // 1. create public instance / render proxy
7952 // also mark it raw so it's never observed
7953 instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
7954 {
7955 exposePropsOnRenderContext(instance);
7956 }
7957 // 2. call setup()
7958 const { setup } = Component;
7959 if (setup) {
7960 const setupContext = (instance.setupContext =
7961 setup.length > 1 ? createSetupContext(instance) : null);
7962 setCurrentInstance(instance);
7963 pauseTracking();
7964 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
7965 resetTracking();
7966 unsetCurrentInstance();
7967 if (isPromise(setupResult)) {
7968 setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
7969 if (isSSR) {
7970 // return the promise so server-renderer can wait on it
7971 return setupResult
7972 .then((resolvedResult) => {
7973 handleSetupResult(instance, resolvedResult, isSSR);
7974 })
7975 .catch(e => {
7976 handleError(e, instance, 0 /* SETUP_FUNCTION */);
7977 });
7978 }
7979 else {
7980 // async setup returned Promise.
7981 // bail here and wait for re-entry.
7982 instance.asyncDep = setupResult;
7983 }
7984 }
7985 else {
7986 handleSetupResult(instance, setupResult, isSSR);
7987 }
7988 }
7989 else {
7990 finishComponentSetup(instance, isSSR);
7991 }
7992}
7993function handleSetupResult(instance, setupResult, isSSR) {
7994 if (isFunction(setupResult)) {
7995 // setup returned an inline render function
7996 {
7997 instance.render = setupResult;
7998 }
7999 }
8000 else if (isObject(setupResult)) {
8001 if (isVNode(setupResult)) {
8002 warn$1(`setup() should not return VNodes directly - ` +
8003 `return a render function instead.`);
8004 }
8005 // setup returned bindings.
8006 // assuming a render function compiled from template is present.
8007 {
8008 instance.devtoolsRawSetupState = setupResult;
8009 }
8010 instance.setupState = proxyRefs(setupResult);
8011 {
8012 exposeSetupStateOnRenderContext(instance);
8013 }
8014 }
8015 else if (setupResult !== undefined) {
8016 warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
8017 }
8018 finishComponentSetup(instance, isSSR);
8019}
8020let compile;
8021let installWithProxy;
8022/**
8023 * For runtime-dom to register the compiler.
8024 * Note the exported method uses any to avoid d.ts relying on the compiler types.
8025 */
8026function registerRuntimeCompiler(_compile) {
8027 compile = _compile;
8028 installWithProxy = i => {
8029 if (i.render._rc) {
8030 i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
8031 }
8032 };
8033}
8034// dev only
8035const isRuntimeOnly = () => !compile;
8036function finishComponentSetup(instance, isSSR, skipOptions) {
8037 const Component = instance.type;
8038 // template / render function normalization
8039 if (!instance.render) {
8040 // could be set from setup()
8041 if (compile && !Component.render) {
8042 const template = Component.template;
8043 if (template) {
8044 {
8045 startMeasure(instance, `compile`);
8046 }
8047 const { isCustomElement, compilerOptions } = instance.appContext.config;
8048 const { delimiters, compilerOptions: componentCompilerOptions } = Component;
8049 const finalCompilerOptions = extend(extend({
8050 isCustomElement,
8051 delimiters
8052 }, compilerOptions), componentCompilerOptions);
8053 Component.render = compile(template, finalCompilerOptions);
8054 {
8055 endMeasure(instance, `compile`);
8056 }
8057 }
8058 }
8059 instance.render = (Component.render || NOOP);
8060 // for runtime-compiled render functions using `with` blocks, the render
8061 // proxy used needs a different `has` handler which is more performant and
8062 // also only allows a whitelist of globals to fallthrough.
8063 if (installWithProxy) {
8064 installWithProxy(instance);
8065 }
8066 }
8067 // support for 2.x options
8068 {
8069 setCurrentInstance(instance);
8070 pauseTracking();
8071 applyOptions(instance);
8072 resetTracking();
8073 unsetCurrentInstance();
8074 }
8075 // warn missing template/render
8076 // the runtime compilation of template in SSR is done by server-render
8077 if (!Component.render && instance.render === NOOP && !isSSR) {
8078 /* istanbul ignore if */
8079 if (!compile && Component.template) {
8080 warn$1(`Component provided template option but ` +
8081 `runtime compilation is not supported in this build of Vue.` +
8082 (` Use "vue.esm-browser.js" instead.`
8083 ) /* should not happen */);
8084 }
8085 else {
8086 warn$1(`Component is missing template or render function.`);
8087 }
8088 }
8089}
8090function createAttrsProxy(instance) {
8091 return new Proxy(instance.attrs, {
8092 get(target, key) {
8093 markAttrsAccessed();
8094 track(instance, "get" /* GET */, '$attrs');
8095 return target[key];
8096 },
8097 set() {
8098 warn$1(`setupContext.attrs is readonly.`);
8099 return false;
8100 },
8101 deleteProperty() {
8102 warn$1(`setupContext.attrs is readonly.`);
8103 return false;
8104 }
8105 }
8106 );
8107}
8108function createSetupContext(instance) {
8109 const expose = exposed => {
8110 if (instance.exposed) {
8111 warn$1(`expose() should be called only once per setup().`);
8112 }
8113 instance.exposed = exposed || {};
8114 };
8115 let attrs;
8116 {
8117 // We use getters in dev in case libs like test-utils overwrite instance
8118 // properties (overwrites should not be done in prod)
8119 return Object.freeze({
8120 get attrs() {
8121 return attrs || (attrs = createAttrsProxy(instance));
8122 },
8123 get slots() {
8124 return shallowReadonly(instance.slots);
8125 },
8126 get emit() {
8127 return (event, ...args) => instance.emit(event, ...args);
8128 },
8129 expose
8130 });
8131 }
8132}
8133function getExposeProxy(instance) {
8134 if (instance.exposed) {
8135 return (instance.exposeProxy ||
8136 (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
8137 get(target, key) {
8138 if (key in target) {
8139 return target[key];
8140 }
8141 else if (key in publicPropertiesMap) {
8142 return publicPropertiesMap[key](instance);
8143 }
8144 }
8145 })));
8146 }
8147}
8148const classifyRE = /(?:^|[-_])(\w)/g;
8149const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
8150function getComponentName(Component) {
8151 return isFunction(Component)
8152 ? Component.displayName || Component.name
8153 : Component.name;
8154}
8155/* istanbul ignore next */
8156function formatComponentName(instance, Component, isRoot = false) {
8157 let name = getComponentName(Component);
8158 if (!name && Component.__file) {
8159 const match = Component.__file.match(/([^/\\]+)\.\w+$/);
8160 if (match) {
8161 name = match[1];
8162 }
8163 }
8164 if (!name && instance && instance.parent) {
8165 // try to infer the name based on reverse resolution
8166 const inferFromRegistry = (registry) => {
8167 for (const key in registry) {
8168 if (registry[key] === Component) {
8169 return key;
8170 }
8171 }
8172 };
8173 name =
8174 inferFromRegistry(instance.components ||
8175 instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
8176 }
8177 return name ? classify(name) : isRoot ? `App` : `Anonymous`;
8178}
8179function isClassComponent(value) {
8180 return isFunction(value) && '__vccOpts' in value;
8181}
8182
8183const stack = [];
8184function pushWarningContext(vnode) {
8185 stack.push(vnode);
8186}
8187function popWarningContext() {
8188 stack.pop();
8189}
8190function warn$1(msg, ...args) {
8191 // avoid props formatting or warn handler tracking deps that might be mutated
8192 // during patch, leading to infinite recursion.
8193 pauseTracking();
8194 const instance = stack.length ? stack[stack.length - 1].component : null;
8195 const appWarnHandler = instance && instance.appContext.config.warnHandler;
8196 const trace = getComponentTrace();
8197 if (appWarnHandler) {
8198 callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
8199 msg + args.join(''),
8200 instance && instance.proxy,
8201 trace
8202 .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
8203 .join('\n'),
8204 trace
8205 ]);
8206 }
8207 else {
8208 const warnArgs = [`[Vue warn]: ${msg}`, ...args];
8209 /* istanbul ignore if */
8210 if (trace.length &&
8211 // avoid spamming console during tests
8212 !false) {
8213 warnArgs.push(`\n`, ...formatTrace(trace));
8214 }
8215 console.warn(...warnArgs);
8216 }
8217 resetTracking();
8218}
8219function getComponentTrace() {
8220 let currentVNode = stack[stack.length - 1];
8221 if (!currentVNode) {
8222 return [];
8223 }
8224 // we can't just use the stack because it will be incomplete during updates
8225 // that did not start from the root. Re-construct the parent chain using
8226 // instance parent pointers.
8227 const normalizedStack = [];
8228 while (currentVNode) {
8229 const last = normalizedStack[0];
8230 if (last && last.vnode === currentVNode) {
8231 last.recurseCount++;
8232 }
8233 else {
8234 normalizedStack.push({
8235 vnode: currentVNode,
8236 recurseCount: 0
8237 });
8238 }
8239 const parentInstance = currentVNode.component && currentVNode.component.parent;
8240 currentVNode = parentInstance && parentInstance.vnode;
8241 }
8242 return normalizedStack;
8243}
8244/* istanbul ignore next */
8245function formatTrace(trace) {
8246 const logs = [];
8247 trace.forEach((entry, i) => {
8248 logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
8249 });
8250 return logs;
8251}
8252function formatTraceEntry({ vnode, recurseCount }) {
8253 const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
8254 const isRoot = vnode.component ? vnode.component.parent == null : false;
8255 const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
8256 const close = `>` + postfix;
8257 return vnode.props
8258 ? [open, ...formatProps(vnode.props), close]
8259 : [open + close];
8260}
8261/* istanbul ignore next */
8262function formatProps(props) {
8263 const res = [];
8264 const keys = Object.keys(props);
8265 keys.slice(0, 3).forEach(key => {
8266 res.push(...formatProp(key, props[key]));
8267 });
8268 if (keys.length > 3) {
8269 res.push(` ...`);
8270 }
8271 return res;
8272}
8273/* istanbul ignore next */
8274function formatProp(key, value, raw) {
8275 if (isString(value)) {
8276 value = JSON.stringify(value);
8277 return raw ? value : [`${key}=${value}`];
8278 }
8279 else if (typeof value === 'number' ||
8280 typeof value === 'boolean' ||
8281 value == null) {
8282 return raw ? value : [`${key}=${value}`];
8283 }
8284 else if (isRef(value)) {
8285 value = formatProp(key, toRaw(value.value), true);
8286 return raw ? value : [`${key}=Ref<`, value, `>`];
8287 }
8288 else if (isFunction(value)) {
8289 return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
8290 }
8291 else {
8292 value = toRaw(value);
8293 return raw ? value : [`${key}=`, value];
8294 }
8295}
8296
8297const ErrorTypeStrings = {
8298 ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
8299 ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
8300 ["c" /* CREATED */]: 'created hook',
8301 ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
8302 ["m" /* MOUNTED */]: 'mounted hook',
8303 ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
8304 ["u" /* UPDATED */]: 'updated',
8305 ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
8306 ["um" /* UNMOUNTED */]: 'unmounted hook',
8307 ["a" /* ACTIVATED */]: 'activated hook',
8308 ["da" /* DEACTIVATED */]: 'deactivated hook',
8309 ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
8310 ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
8311 ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
8312 [0 /* SETUP_FUNCTION */]: 'setup function',
8313 [1 /* RENDER_FUNCTION */]: 'render function',
8314 [2 /* WATCH_GETTER */]: 'watcher getter',
8315 [3 /* WATCH_CALLBACK */]: 'watcher callback',
8316 [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
8317 [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
8318 [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
8319 [7 /* VNODE_HOOK */]: 'vnode hook',
8320 [8 /* DIRECTIVE_HOOK */]: 'directive hook',
8321 [9 /* TRANSITION_HOOK */]: 'transition hook',
8322 [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
8323 [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
8324 [12 /* FUNCTION_REF */]: 'ref function',
8325 [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
8326 [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
8327 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
8328};
8329function callWithErrorHandling(fn, instance, type, args) {
8330 let res;
8331 try {
8332 res = args ? fn(...args) : fn();
8333 }
8334 catch (err) {
8335 handleError(err, instance, type);
8336 }
8337 return res;
8338}
8339function callWithAsyncErrorHandling(fn, instance, type, args) {
8340 if (isFunction(fn)) {
8341 const res = callWithErrorHandling(fn, instance, type, args);
8342 if (res && isPromise(res)) {
8343 res.catch(err => {
8344 handleError(err, instance, type);
8345 });
8346 }
8347 return res;
8348 }
8349 const values = [];
8350 for (let i = 0; i < fn.length; i++) {
8351 values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
8352 }
8353 return values;
8354}
8355function handleError(err, instance, type, throwInDev = true) {
8356 const contextVNode = instance ? instance.vnode : null;
8357 if (instance) {
8358 let cur = instance.parent;
8359 // the exposed instance is the render proxy to keep it consistent with 2.x
8360 const exposedInstance = instance.proxy;
8361 // in production the hook receives only the error code
8362 const errorInfo = ErrorTypeStrings[type] ;
8363 while (cur) {
8364 const errorCapturedHooks = cur.ec;
8365 if (errorCapturedHooks) {
8366 for (let i = 0; i < errorCapturedHooks.length; i++) {
8367 if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
8368 return;
8369 }
8370 }
8371 }
8372 cur = cur.parent;
8373 }
8374 // app-level handling
8375 const appErrorHandler = instance.appContext.config.errorHandler;
8376 if (appErrorHandler) {
8377 callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
8378 return;
8379 }
8380 }
8381 logError(err, type, contextVNode, throwInDev);
8382}
8383function logError(err, type, contextVNode, throwInDev = true) {
8384 {
8385 const info = ErrorTypeStrings[type];
8386 if (contextVNode) {
8387 pushWarningContext(contextVNode);
8388 }
8389 warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
8390 if (contextVNode) {
8391 popWarningContext();
8392 }
8393 // crash in dev by default so it's more noticeable
8394 if (throwInDev) {
8395 throw err;
8396 }
8397 else {
8398 console.error(err);
8399 }
8400 }
8401}
8402
8403let isFlushing = false;
8404let isFlushPending = false;
8405const queue = [];
8406let flushIndex = 0;
8407const pendingPreFlushCbs = [];
8408let activePreFlushCbs = null;
8409let preFlushIndex = 0;
8410const pendingPostFlushCbs = [];
8411let activePostFlushCbs = null;
8412let postFlushIndex = 0;
8413const resolvedPromise = Promise.resolve();
8414let currentFlushPromise = null;
8415let currentPreFlushParentJob = null;
8416const RECURSION_LIMIT = 100;
8417function nextTick(fn) {
8418 const p = currentFlushPromise || resolvedPromise;
8419 return fn ? p.then(this ? fn.bind(this) : fn) : p;
8420}
8421// #2768
8422// Use binary-search to find a suitable position in the queue,
8423// so that the queue maintains the increasing order of job's id,
8424// which can prevent the job from being skipped and also can avoid repeated patching.
8425function findInsertionIndex(id) {
8426 // the start index should be `flushIndex + 1`
8427 let start = flushIndex + 1;
8428 let end = queue.length;
8429 while (start < end) {
8430 const middle = (start + end) >>> 1;
8431 const middleJobId = getId(queue[middle]);
8432 middleJobId < id ? (start = middle + 1) : (end = middle);
8433 }
8434 return start;
8435}
8436function queueJob(job) {
8437 // the dedupe search uses the startIndex argument of Array.includes()
8438 // by default the search index includes the current job that is being run
8439 // so it cannot recursively trigger itself again.
8440 // if the job is a watch() callback, the search will start with a +1 index to
8441 // allow it recursively trigger itself - it is the user's responsibility to
8442 // ensure it doesn't end up in an infinite loop.
8443 if ((!queue.length ||
8444 !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
8445 job !== currentPreFlushParentJob) {
8446 if (job.id == null) {
8447 queue.push(job);
8448 }
8449 else {
8450 queue.splice(findInsertionIndex(job.id), 0, job);
8451 }
8452 queueFlush();
8453 }
8454}
8455function queueFlush() {
8456 if (!isFlushing && !isFlushPending) {
8457 isFlushPending = true;
8458 currentFlushPromise = resolvedPromise.then(flushJobs);
8459 }
8460}
8461function invalidateJob(job) {
8462 const i = queue.indexOf(job);
8463 if (i > flushIndex) {
8464 queue.splice(i, 1);
8465 }
8466}
8467function queueCb(cb, activeQueue, pendingQueue, index) {
8468 if (!isArray(cb)) {
8469 if (!activeQueue ||
8470 !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
8471 pendingQueue.push(cb);
8472 }
8473 }
8474 else {
8475 // if cb is an array, it is a component lifecycle hook which can only be
8476 // triggered by a job, which is already deduped in the main queue, so
8477 // we can skip duplicate check here to improve perf
8478 pendingQueue.push(...cb);
8479 }
8480 queueFlush();
8481}
8482function queuePreFlushCb(cb) {
8483 queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
8484}
8485function queuePostFlushCb(cb) {
8486 queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
8487}
8488function flushPreFlushCbs(seen, parentJob = null) {
8489 if (pendingPreFlushCbs.length) {
8490 currentPreFlushParentJob = parentJob;
8491 activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
8492 pendingPreFlushCbs.length = 0;
8493 {
8494 seen = seen || new Map();
8495 }
8496 for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
8497 if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
8498 continue;
8499 }
8500 activePreFlushCbs[preFlushIndex]();
8501 }
8502 activePreFlushCbs = null;
8503 preFlushIndex = 0;
8504 currentPreFlushParentJob = null;
8505 // recursively flush until it drains
8506 flushPreFlushCbs(seen, parentJob);
8507 }
8508}
8509function flushPostFlushCbs(seen) {
8510 if (pendingPostFlushCbs.length) {
8511 const deduped = [...new Set(pendingPostFlushCbs)];
8512 pendingPostFlushCbs.length = 0;
8513 // #1947 already has active queue, nested flushPostFlushCbs call
8514 if (activePostFlushCbs) {
8515 activePostFlushCbs.push(...deduped);
8516 return;
8517 }
8518 activePostFlushCbs = deduped;
8519 {
8520 seen = seen || new Map();
8521 }
8522 activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
8523 for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
8524 if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
8525 continue;
8526 }
8527 activePostFlushCbs[postFlushIndex]();
8528 }
8529 activePostFlushCbs = null;
8530 postFlushIndex = 0;
8531 }
8532}
8533const getId = (job) => job.id == null ? Infinity : job.id;
8534function flushJobs(seen) {
8535 isFlushPending = false;
8536 isFlushing = true;
8537 {
8538 seen = seen || new Map();
8539 }
8540 flushPreFlushCbs(seen);
8541 // Sort queue before flush.
8542 // This ensures that:
8543 // 1. Components are updated from parent to child. (because parent is always
8544 // created before the child so its render effect will have smaller
8545 // priority number)
8546 // 2. If a component is unmounted during a parent component's update,
8547 // its update can be skipped.
8548 queue.sort((a, b) => getId(a) - getId(b));
8549 try {
8550 for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
8551 const job = queue[flushIndex];
8552 if (job && job.active !== false) {
8553 if (true && checkRecursiveUpdates(seen, job)) {
8554 continue;
8555 }
8556 // console.log(`running:`, job.id)
8557 callWithErrorHandling(job, null, 14 /* SCHEDULER */);
8558 }
8559 }
8560 }
8561 finally {
8562 flushIndex = 0;
8563 queue.length = 0;
8564 flushPostFlushCbs(seen);
8565 isFlushing = false;
8566 currentFlushPromise = null;
8567 // some postFlushCb queued jobs!
8568 // keep flushing until it drains.
8569 if (queue.length ||
8570 pendingPreFlushCbs.length ||
8571 pendingPostFlushCbs.length) {
8572 flushJobs(seen);
8573 }
8574 }
8575}
8576function checkRecursiveUpdates(seen, fn) {
8577 if (!seen.has(fn)) {
8578 seen.set(fn, 1);
8579 }
8580 else {
8581 const count = seen.get(fn);
8582 if (count > RECURSION_LIMIT) {
8583 const instance = fn.ownerInstance;
8584 const componentName = instance && getComponentName(instance.type);
8585 warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
8586 `This means you have a reactive effect that is mutating its own ` +
8587 `dependencies and thus recursively triggering itself. Possible sources ` +
8588 `include component template, render function, updated hook or ` +
8589 `watcher source function.`);
8590 return true;
8591 }
8592 else {
8593 seen.set(fn, count + 1);
8594 }
8595 }
8596}
8597
8598// Simple effect.
8599function watchEffect(effect, options) {
8600 return doWatch(effect, null, options);
8601}
8602function watchPostEffect(effect, options) {
8603 return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
8604 ));
8605}
8606function watchSyncEffect(effect, options) {
8607 return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
8608 ));
8609}
8610// initial value for watchers to trigger on undefined initial values
8611const INITIAL_WATCHER_VALUE = {};
8612// implementation
8613function watch(source, cb, options) {
8614 if (!isFunction(cb)) {
8615 warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
8616 `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
8617 `supports \`watch(source, cb, options?) signature.`);
8618 }
8619 return doWatch(source, cb, options);
8620}
8621function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
8622 if (!cb) {
8623 if (immediate !== undefined) {
8624 warn$1(`watch() "immediate" option is only respected when using the ` +
8625 `watch(source, callback, options?) signature.`);
8626 }
8627 if (deep !== undefined) {
8628 warn$1(`watch() "deep" option is only respected when using the ` +
8629 `watch(source, callback, options?) signature.`);
8630 }
8631 }
8632 const warnInvalidSource = (s) => {
8633 warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
8634 `a reactive object, or an array of these types.`);
8635 };
8636 const instance = currentInstance;
8637 let getter;
8638 let forceTrigger = false;
8639 let isMultiSource = false;
8640 if (isRef(source)) {
8641 getter = () => source.value;
8642 forceTrigger = !!source._shallow;
8643 }
8644 else if (isReactive(source)) {
8645 getter = () => source;
8646 deep = true;
8647 }
8648 else if (isArray(source)) {
8649 isMultiSource = true;
8650 forceTrigger = source.some(isReactive);
8651 getter = () => source.map(s => {
8652 if (isRef(s)) {
8653 return s.value;
8654 }
8655 else if (isReactive(s)) {
8656 return traverse(s);
8657 }
8658 else if (isFunction(s)) {
8659 return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
8660 }
8661 else {
8662 warnInvalidSource(s);
8663 }
8664 });
8665 }
8666 else if (isFunction(source)) {
8667 if (cb) {
8668 // getter with cb
8669 getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
8670 }
8671 else {
8672 // no cb -> simple effect
8673 getter = () => {
8674 if (instance && instance.isUnmounted) {
8675 return;
8676 }
8677 if (cleanup) {
8678 cleanup();
8679 }
8680 return callWithAsyncErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onInvalidate]);
8681 };
8682 }
8683 }
8684 else {
8685 getter = NOOP;
8686 warnInvalidSource(source);
8687 }
8688 if (cb && deep) {
8689 const baseGetter = getter;
8690 getter = () => traverse(baseGetter());
8691 }
8692 let cleanup;
8693 let onInvalidate = (fn) => {
8694 cleanup = effect.onStop = () => {
8695 callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
8696 };
8697 };
8698 let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
8699 const job = () => {
8700 if (!effect.active) {
8701 return;
8702 }
8703 if (cb) {
8704 // watch(source, cb)
8705 const newValue = effect.run();
8706 if (deep ||
8707 forceTrigger ||
8708 (isMultiSource
8709 ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
8710 : hasChanged(newValue, oldValue)) ||
8711 (false )) {
8712 // cleanup before running cb again
8713 if (cleanup) {
8714 cleanup();
8715 }
8716 callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
8717 newValue,
8718 // pass undefined as the old value when it's changed for the first time
8719 oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
8720 onInvalidate
8721 ]);
8722 oldValue = newValue;
8723 }
8724 }
8725 else {
8726 // watchEffect
8727 effect.run();
8728 }
8729 };
8730 // important: mark the job as a watcher callback so that scheduler knows
8731 // it is allowed to self-trigger (#1727)
8732 job.allowRecurse = !!cb;
8733 let scheduler;
8734 if (flush === 'sync') {
8735 scheduler = job; // the scheduler function gets called directly
8736 }
8737 else if (flush === 'post') {
8738 scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
8739 }
8740 else {
8741 // default: 'pre'
8742 scheduler = () => {
8743 if (!instance || instance.isMounted) {
8744 queuePreFlushCb(job);
8745 }
8746 else {
8747 // with 'pre' option, the first call must happen before
8748 // the component is mounted so it is called synchronously.
8749 job();
8750 }
8751 };
8752 }
8753 const effect = new ReactiveEffect(getter, scheduler);
8754 {
8755 effect.onTrack = onTrack;
8756 effect.onTrigger = onTrigger;
8757 }
8758 // initial run
8759 if (cb) {
8760 if (immediate) {
8761 job();
8762 }
8763 else {
8764 oldValue = effect.run();
8765 }
8766 }
8767 else if (flush === 'post') {
8768 queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
8769 }
8770 else {
8771 effect.run();
8772 }
8773 return () => {
8774 effect.stop();
8775 if (instance && instance.scope) {
8776 remove(instance.scope.effects, effect);
8777 }
8778 };
8779}
8780// this.$watch
8781function instanceWatch(source, value, options) {
8782 const publicThis = this.proxy;
8783 const getter = isString(source)
8784 ? source.includes('.')
8785 ? createPathGetter(publicThis, source)
8786 : () => publicThis[source]
8787 : source.bind(publicThis, publicThis);
8788 let cb;
8789 if (isFunction(value)) {
8790 cb = value;
8791 }
8792 else {
8793 cb = value.handler;
8794 options = value;
8795 }
8796 const cur = currentInstance;
8797 setCurrentInstance(this);
8798 const res = doWatch(getter, cb.bind(publicThis), options);
8799 if (cur) {
8800 setCurrentInstance(cur);
8801 }
8802 else {
8803 unsetCurrentInstance();
8804 }
8805 return res;
8806}
8807function createPathGetter(ctx, path) {
8808 const segments = path.split('.');
8809 return () => {
8810 let cur = ctx;
8811 for (let i = 0; i < segments.length && cur; i++) {
8812 cur = cur[segments[i]];
8813 }
8814 return cur;
8815 };
8816}
8817function traverse(value, seen = new Set()) {
8818 if (!isObject(value) || value["__v_skip" /* SKIP */]) {
8819 return value;
8820 }
8821 seen = seen || new Set();
8822 if (seen.has(value)) {
8823 return value;
8824 }
8825 seen.add(value);
8826 if (isRef(value)) {
8827 traverse(value.value, seen);
8828 }
8829 else if (isArray(value)) {
8830 for (let i = 0; i < value.length; i++) {
8831 traverse(value[i], seen);
8832 }
8833 }
8834 else if (isSet(value) || isMap(value)) {
8835 value.forEach((v) => {
8836 traverse(v, seen);
8837 });
8838 }
8839 else if (isPlainObject(value)) {
8840 for (const key in value) {
8841 traverse(value[key], seen);
8842 }
8843 }
8844 return value;
8845}
8846
8847// dev only
8848const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
8849 `<script setup> of a single file component. Its arguments should be ` +
8850 `compiled away and passing it at runtime has no effect.`);
8851// implementation
8852function defineProps() {
8853 {
8854 warnRuntimeUsage(`defineProps`);
8855 }
8856 return null;
8857}
8858// implementation
8859function defineEmits() {
8860 {
8861 warnRuntimeUsage(`defineEmits`);
8862 }
8863 return null;
8864}
8865/**
8866 * Vue `<script setup>` compiler macro for declaring a component's exposed
8867 * instance properties when it is accessed by a parent component via template
8868 * refs.
8869 *
8870 * `<script setup>` components are closed by default - i.e. varaibles inside
8871 * the `<script setup>` scope is not exposed to parent unless explicitly exposed
8872 * via `defineExpose`.
8873 *
8874 * This is only usable inside `<script setup>`, is compiled away in the
8875 * output and should **not** be actually called at runtime.
8876 */
8877function defineExpose(exposed) {
8878 {
8879 warnRuntimeUsage(`defineExpose`);
8880 }
8881}
8882/**
8883 * Vue `<script setup>` compiler macro for providing props default values when
8884 * using type-based `defineProps` declaration.
8885 *
8886 * Example usage:
8887 * ```ts
8888 * withDefaults(defineProps<{
8889 * size?: number
8890 * labels?: string[]
8891 * }>(), {
8892 * size: 3,
8893 * labels: () => ['default label']
8894 * })
8895 * ```
8896 *
8897 * This is only usable inside `<script setup>`, is compiled away in the output
8898 * and should **not** be actually called at runtime.
8899 */
8900function withDefaults(props, defaults) {
8901 {
8902 warnRuntimeUsage(`withDefaults`);
8903 }
8904 return null;
8905}
8906function useSlots() {
8907 return getContext().slots;
8908}
8909function useAttrs() {
8910 return getContext().attrs;
8911}
8912function getContext() {
8913 const i = getCurrentInstance();
8914 if (!i) {
8915 warn$1(`useContext() called without active instance.`);
8916 }
8917 return i.setupContext || (i.setupContext = createSetupContext(i));
8918}
8919/**
8920 * Runtime helper for merging default declarations. Imported by compiled code
8921 * only.
8922 * @internal
8923 */
8924function mergeDefaults(
8925// the base props is compiler-generated and guaranteed to be in this shape.
8926props, defaults) {
8927 for (const key in defaults) {
8928 const val = props[key];
8929 if (val) {
8930 val.default = defaults[key];
8931 }
8932 else if (val === null) {
8933 props[key] = { default: defaults[key] };
8934 }
8935 else {
8936 warn$1(`props default key "${key}" has no corresponding declaration.`);
8937 }
8938 }
8939 return props;
8940}
8941/**
8942 * `<script setup>` helper for persisting the current instance context over
8943 * async/await flows.
8944 *
8945 * `@vue/compiler-sfc` converts the following:
8946 *
8947 * ```ts
8948 * const x = await foo()
8949 * ```
8950 *
8951 * into:
8952 *
8953 * ```ts
8954 * let __temp, __restore
8955 * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
8956 * ```
8957 * @internal
8958 */
8959function withAsyncContext(getAwaitable) {
8960 const ctx = getCurrentInstance();
8961 if (!ctx) {
8962 warn$1(`withAsyncContext called without active current instance. ` +
8963 `This is likely a bug.`);
8964 }
8965 let awaitable = getAwaitable();
8966 unsetCurrentInstance();
8967 if (isPromise(awaitable)) {
8968 awaitable = awaitable.catch(e => {
8969 setCurrentInstance(ctx);
8970 throw e;
8971 });
8972 }
8973 return [awaitable, () => setCurrentInstance(ctx)];
8974}
8975
8976// Actual implementation
8977function h(type, propsOrChildren, children) {
8978 const l = arguments.length;
8979 if (l === 2) {
8980 if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
8981 // single vnode without props
8982 if (isVNode(propsOrChildren)) {
8983 return createVNode(type, null, [propsOrChildren]);
8984 }
8985 // props without children
8986 return createVNode(type, propsOrChildren);
8987 }
8988 else {
8989 // omit props
8990 return createVNode(type, null, propsOrChildren);
8991 }
8992 }
8993 else {
8994 if (l > 3) {
8995 children = Array.prototype.slice.call(arguments, 2);
8996 }
8997 else if (l === 3 && isVNode(children)) {
8998 children = [children];
8999 }
9000 return createVNode(type, propsOrChildren, children);
9001 }
9002}
9003
9004const ssrContextKey = Symbol(`ssrContext` );
9005const useSSRContext = () => {
9006 {
9007 const ctx = inject(ssrContextKey);
9008 if (!ctx) {
9009 warn$1(`Server rendering context not provided. Make sure to only call ` +
9010 `useSSRContext() conditionally in the server build.`);
9011 }
9012 return ctx;
9013 }
9014};
9015
9016function initCustomFormatter() {
9017 /* eslint-disable no-restricted-globals */
9018 if (typeof window === 'undefined') {
9019 return;
9020 }
9021 const vueStyle = { style: 'color:#3ba776' };
9022 const numberStyle = { style: 'color:#0b1bc9' };
9023 const stringStyle = { style: 'color:#b62e24' };
9024 const keywordStyle = { style: 'color:#9d288c' };
9025 // custom formatter for Chrome
9026 // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
9027 const formatter = {
9028 header(obj) {
9029 // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
9030 if (!isObject(obj)) {
9031 return null;
9032 }
9033 if (obj.__isVue) {
9034 return ['div', vueStyle, `VueInstance`];
9035 }
9036 else if (isRef(obj)) {
9037 return [
9038 'div',
9039 {},
9040 ['span', vueStyle, genRefFlag(obj)],
9041 '<',
9042 formatValue(obj.value),
9043 `>`
9044 ];
9045 }
9046 else if (isReactive(obj)) {
9047 return [
9048 'div',
9049 {},
9050 ['span', vueStyle, 'Reactive'],
9051 '<',
9052 formatValue(obj),
9053 `>${isReadonly(obj) ? ` (readonly)` : ``}`
9054 ];
9055 }
9056 else if (isReadonly(obj)) {
9057 return [
9058 'div',
9059 {},
9060 ['span', vueStyle, 'Readonly'],
9061 '<',
9062 formatValue(obj),
9063 '>'
9064 ];
9065 }
9066 return null;
9067 },
9068 hasBody(obj) {
9069 return obj && obj.__isVue;
9070 },
9071 body(obj) {
9072 if (obj && obj.__isVue) {
9073 return [
9074 'div',
9075 {},
9076 ...formatInstance(obj.$)
9077 ];
9078 }
9079 }
9080 };
9081 function formatInstance(instance) {
9082 const blocks = [];
9083 if (instance.type.props && instance.props) {
9084 blocks.push(createInstanceBlock('props', toRaw(instance.props)));
9085 }
9086 if (instance.setupState !== EMPTY_OBJ) {
9087 blocks.push(createInstanceBlock('setup', instance.setupState));
9088 }
9089 if (instance.data !== EMPTY_OBJ) {
9090 blocks.push(createInstanceBlock('data', toRaw(instance.data)));
9091 }
9092 const computed = extractKeys(instance, 'computed');
9093 if (computed) {
9094 blocks.push(createInstanceBlock('computed', computed));
9095 }
9096 const injected = extractKeys(instance, 'inject');
9097 if (injected) {
9098 blocks.push(createInstanceBlock('injected', injected));
9099 }
9100 blocks.push([
9101 'div',
9102 {},
9103 [
9104 'span',
9105 {
9106 style: keywordStyle.style + ';opacity:0.66'
9107 },
9108 '$ (internal): '
9109 ],
9110 ['object', { object: instance }]
9111 ]);
9112 return blocks;
9113 }
9114 function createInstanceBlock(type, target) {
9115 target = extend({}, target);
9116 if (!Object.keys(target).length) {
9117 return ['span', {}];
9118 }
9119 return [
9120 'div',
9121 { style: 'line-height:1.25em;margin-bottom:0.6em' },
9122 [
9123 'div',
9124 {
9125 style: 'color:#476582'
9126 },
9127 type
9128 ],
9129 [
9130 'div',
9131 {
9132 style: 'padding-left:1.25em'
9133 },
9134 ...Object.keys(target).map(key => {
9135 return [
9136 'div',
9137 {},
9138 ['span', keywordStyle, key + ': '],
9139 formatValue(target[key], false)
9140 ];
9141 })
9142 ]
9143 ];
9144 }
9145 function formatValue(v, asRaw = true) {
9146 if (typeof v === 'number') {
9147 return ['span', numberStyle, v];
9148 }
9149 else if (typeof v === 'string') {
9150 return ['span', stringStyle, JSON.stringify(v)];
9151 }
9152 else if (typeof v === 'boolean') {
9153 return ['span', keywordStyle, v];
9154 }
9155 else if (isObject(v)) {
9156 return ['object', { object: asRaw ? toRaw(v) : v }];
9157 }
9158 else {
9159 return ['span', stringStyle, String(v)];
9160 }
9161 }
9162 function extractKeys(instance, type) {
9163 const Comp = instance.type;
9164 if (isFunction(Comp)) {
9165 return;
9166 }
9167 const extracted = {};
9168 for (const key in instance.ctx) {
9169 if (isKeyOfType(Comp, key, type)) {
9170 extracted[key] = instance.ctx[key];
9171 }
9172 }
9173 return extracted;
9174 }
9175 function isKeyOfType(Comp, key, type) {
9176 const opts = Comp[type];
9177 if ((isArray(opts) && opts.includes(key)) ||
9178 (isObject(opts) && key in opts)) {
9179 return true;
9180 }
9181 if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
9182 return true;
9183 }
9184 if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
9185 return true;
9186 }
9187 }
9188 function genRefFlag(v) {
9189 if (v._shallow) {
9190 return `ShallowRef`;
9191 }
9192 if (v.effect) {
9193 return `ComputedRef`;
9194 }
9195 return `Ref`;
9196 }
9197 if (window.devtoolsFormatters) {
9198 window.devtoolsFormatters.push(formatter);
9199 }
9200 else {
9201 window.devtoolsFormatters = [formatter];
9202 }
9203}
9204
9205function withMemo(memo, render, cache, index) {
9206 const cached = cache[index];
9207 if (cached && isMemoSame(cached, memo)) {
9208 return cached;
9209 }
9210 const ret = render();
9211 // shallow clone
9212 ret.memo = memo.slice();
9213 return (cache[index] = ret);
9214}
9215function isMemoSame(cached, memo) {
9216 const prev = cached.memo;
9217 if (prev.length != memo.length) {
9218 return false;
9219 }
9220 for (let i = 0; i < prev.length; i++) {
9221 if (prev[i] !== memo[i]) {
9222 return false;
9223 }
9224 }
9225 // make sure to let parent block track it when returning cached
9226 if (isBlockTreeEnabled > 0 && currentBlock) {
9227 currentBlock.push(cached);
9228 }
9229 return true;
9230}
9231
9232// Core API ------------------------------------------------------------------
9233const version = "3.2.10";
9234/**
9235 * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9236 * @internal
9237 */
9238const ssrUtils = (null);
9239/**
9240 * @internal only exposed in compat builds
9241 */
9242const resolveFilter = null;
9243/**
9244 * @internal only exposed in compat builds.
9245 */
9246const compatUtils = (null);
9247
9248const svgNS = 'http://www.w3.org/2000/svg';
9249const doc = (typeof document !== 'undefined' ? document : null);
9250const staticTemplateCache = new Map();
9251const nodeOps = {
9252 insert: (child, parent, anchor) => {
9253 parent.insertBefore(child, anchor || null);
9254 },
9255 remove: child => {
9256 const parent = child.parentNode;
9257 if (parent) {
9258 parent.removeChild(child);
9259 }
9260 },
9261 createElement: (tag, isSVG, is, props) => {
9262 const el = isSVG
9263 ? doc.createElementNS(svgNS, tag)
9264 : doc.createElement(tag, is ? { is } : undefined);
9265 if (tag === 'select' && props && props.multiple != null) {
9266 el.setAttribute('multiple', props.multiple);
9267 }
9268 return el;
9269 },
9270 createText: text => doc.createTextNode(text),
9271 createComment: text => doc.createComment(text),
9272 setText: (node, text) => {
9273 node.nodeValue = text;
9274 },
9275 setElementText: (el, text) => {
9276 el.textContent = text;
9277 },
9278 parentNode: node => node.parentNode,
9279 nextSibling: node => node.nextSibling,
9280 querySelector: selector => doc.querySelector(selector),
9281 setScopeId(el, id) {
9282 el.setAttribute(id, '');
9283 },
9284 cloneNode(el) {
9285 const cloned = el.cloneNode(true);
9286 // #3072
9287 // - in `patchDOMProp`, we store the actual value in the `el._value` property.
9288 // - normally, elements using `:value` bindings will not be hoisted, but if
9289 // the bound value is a constant, e.g. `:value="true"` - they do get
9290 // hoisted.
9291 // - in production, hoisted nodes are cloned when subsequent inserts, but
9292 // cloneNode() does not copy the custom property we attached.
9293 // - This may need to account for other custom DOM properties we attach to
9294 // elements in addition to `_value` in the future.
9295 if (`_value` in el) {
9296 cloned._value = el._value;
9297 }
9298 return cloned;
9299 },
9300 // __UNSAFE__
9301 // Reason: innerHTML.
9302 // Static content here can only come from compiled templates.
9303 // As long as the user only uses trusted templates, this is safe.
9304 insertStaticContent(content, parent, anchor, isSVG) {
9305 // <parent> before | first ... last | anchor </parent>
9306 const before = anchor ? anchor.previousSibling : parent.lastChild;
9307 let template = staticTemplateCache.get(content);
9308 if (!template) {
9309 const t = doc.createElement('template');
9310 t.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
9311 template = t.content;
9312 if (isSVG) {
9313 // remove outer svg wrapper
9314 const wrapper = template.firstChild;
9315 while (wrapper.firstChild) {
9316 template.appendChild(wrapper.firstChild);
9317 }
9318 template.removeChild(wrapper);
9319 }
9320 staticTemplateCache.set(content, template);
9321 }
9322 parent.insertBefore(template.cloneNode(true), anchor);
9323 return [
9324 // first
9325 before ? before.nextSibling : parent.firstChild,
9326 // last
9327 anchor ? anchor.previousSibling : parent.lastChild
9328 ];
9329 }
9330};
9331
9332// compiler should normalize class + :class bindings on the same element
9333// into a single binding ['staticClass', dynamic]
9334function patchClass(el, value, isSVG) {
9335 // directly setting className should be faster than setAttribute in theory
9336 // if this is an element during a transition, take the temporary transition
9337 // classes into account.
9338 const transitionClasses = el._vtc;
9339 if (transitionClasses) {
9340 value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
9341 }
9342 if (value == null) {
9343 el.removeAttribute('class');
9344 }
9345 else if (isSVG) {
9346 el.setAttribute('class', value);
9347 }
9348 else {
9349 el.className = value;
9350 }
9351}
9352
9353function patchStyle(el, prev, next) {
9354 const style = el.style;
9355 const currentDisplay = style.display;
9356 if (!next) {
9357 el.removeAttribute('style');
9358 }
9359 else if (isString(next)) {
9360 if (prev !== next) {
9361 style.cssText = next;
9362 }
9363 }
9364 else {
9365 for (const key in next) {
9366 setStyle(style, key, next[key]);
9367 }
9368 if (prev && !isString(prev)) {
9369 for (const key in prev) {
9370 if (next[key] == null) {
9371 setStyle(style, key, '');
9372 }
9373 }
9374 }
9375 }
9376 // indicates that the `display` of the element is controlled by `v-show`,
9377 // so we always keep the current `display` value regardless of the `style` value,
9378 // thus handing over control to `v-show`.
9379 if ('_vod' in el) {
9380 style.display = currentDisplay;
9381 }
9382}
9383const importantRE = /\s*!important$/;
9384function setStyle(style, name, val) {
9385 if (isArray(val)) {
9386 val.forEach(v => setStyle(style, name, v));
9387 }
9388 else {
9389 if (name.startsWith('--')) {
9390 // custom property definition
9391 style.setProperty(name, val);
9392 }
9393 else {
9394 const prefixed = autoPrefix(style, name);
9395 if (importantRE.test(val)) {
9396 // !important
9397 style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
9398 }
9399 else {
9400 style[prefixed] = val;
9401 }
9402 }
9403 }
9404}
9405const prefixes = ['Webkit', 'Moz', 'ms'];
9406const prefixCache = {};
9407function autoPrefix(style, rawName) {
9408 const cached = prefixCache[rawName];
9409 if (cached) {
9410 return cached;
9411 }
9412 let name = camelize(rawName);
9413 if (name !== 'filter' && name in style) {
9414 return (prefixCache[rawName] = name);
9415 }
9416 name = capitalize(name);
9417 for (let i = 0; i < prefixes.length; i++) {
9418 const prefixed = prefixes[i] + name;
9419 if (prefixed in style) {
9420 return (prefixCache[rawName] = prefixed);
9421 }
9422 }
9423 return rawName;
9424}
9425
9426const xlinkNS = 'http://www.w3.org/1999/xlink';
9427function patchAttr(el, key, value, isSVG, instance) {
9428 if (isSVG && key.startsWith('xlink:')) {
9429 if (value == null) {
9430 el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
9431 }
9432 else {
9433 el.setAttributeNS(xlinkNS, key, value);
9434 }
9435 }
9436 else {
9437 // note we are only checking boolean attributes that don't have a
9438 // corresponding dom prop of the same name here.
9439 const isBoolean = isSpecialBooleanAttr(key);
9440 if (value == null || (isBoolean && !includeBooleanAttr(value))) {
9441 el.removeAttribute(key);
9442 }
9443 else {
9444 el.setAttribute(key, isBoolean ? '' : value);
9445 }
9446 }
9447}
9448
9449// __UNSAFE__
9450// functions. The user is responsible for using them with only trusted content.
9451function patchDOMProp(el, key, value,
9452// the following args are passed only due to potential innerHTML/textContent
9453// overriding existing VNodes, in which case the old tree must be properly
9454// unmounted.
9455prevChildren, parentComponent, parentSuspense, unmountChildren) {
9456 if (key === 'innerHTML' || key === 'textContent') {
9457 if (prevChildren) {
9458 unmountChildren(prevChildren, parentComponent, parentSuspense);
9459 }
9460 el[key] = value == null ? '' : value;
9461 return;
9462 }
9463 if (key === 'value' && el.tagName !== 'PROGRESS') {
9464 // store value as _value as well since
9465 // non-string values will be stringified.
9466 el._value = value;
9467 const newValue = value == null ? '' : value;
9468 if (el.value !== newValue) {
9469 el.value = newValue;
9470 }
9471 if (value == null) {
9472 el.removeAttribute(key);
9473 }
9474 return;
9475 }
9476 if (value === '' || value == null) {
9477 const type = typeof el[key];
9478 if (type === 'boolean') {
9479 // e.g. <select multiple> compiles to { multiple: '' }
9480 el[key] = includeBooleanAttr(value);
9481 return;
9482 }
9483 else if (value == null && type === 'string') {
9484 // e.g. <div :id="null">
9485 el[key] = '';
9486 el.removeAttribute(key);
9487 return;
9488 }
9489 else if (type === 'number') {
9490 // e.g. <img :width="null">
9491 // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9492 try {
9493 el[key] = 0;
9494 }
9495 catch (_a) { }
9496 el.removeAttribute(key);
9497 return;
9498 }
9499 }
9500 // some properties perform value validation and throw
9501 try {
9502 el[key] = value;
9503 }
9504 catch (e) {
9505 {
9506 warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
9507 `value ${value} is invalid.`, e);
9508 }
9509 }
9510}
9511
9512// Async edge case fix requires storing an event listener's attach timestamp.
9513let _getNow = Date.now;
9514let skipTimestampCheck = false;
9515if (typeof window !== 'undefined') {
9516 // Determine what event timestamp the browser is using. Annoyingly, the
9517 // timestamp can either be hi-res (relative to page load) or low-res
9518 // (relative to UNIX epoch), so in order to compare time we have to use the
9519 // same timestamp type when saving the flush timestamp.
9520 if (_getNow() > document.createEvent('Event').timeStamp) {
9521 // if the low-res timestamp which is bigger than the event timestamp
9522 // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9523 // and we need to use the hi-res version for event listeners as well.
9524 _getNow = () => performance.now();
9525 }
9526 // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9527 // and does not fire microtasks in between event propagation, so safe to exclude.
9528 const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9529 skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9530}
9531// To avoid the overhead of repeatedly calling performance.now(), we cache
9532// and use the same timestamp for all event listeners attached in the same tick.
9533let cachedNow = 0;
9534const p = Promise.resolve();
9535const reset = () => {
9536 cachedNow = 0;
9537};
9538const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
9539function addEventListener(el, event, handler, options) {
9540 el.addEventListener(event, handler, options);
9541}
9542function removeEventListener(el, event, handler, options) {
9543 el.removeEventListener(event, handler, options);
9544}
9545function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
9546 // vei = vue event invokers
9547 const invokers = el._vei || (el._vei = {});
9548 const existingInvoker = invokers[rawName];
9549 if (nextValue && existingInvoker) {
9550 // patch
9551 existingInvoker.value = nextValue;
9552 }
9553 else {
9554 const [name, options] = parseName(rawName);
9555 if (nextValue) {
9556 // add
9557 const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
9558 addEventListener(el, name, invoker, options);
9559 }
9560 else if (existingInvoker) {
9561 // remove
9562 removeEventListener(el, name, existingInvoker, options);
9563 invokers[rawName] = undefined;
9564 }
9565 }
9566}
9567const optionsModifierRE = /(?:Once|Passive|Capture)$/;
9568function parseName(name) {
9569 let options;
9570 if (optionsModifierRE.test(name)) {
9571 options = {};
9572 let m;
9573 while ((m = name.match(optionsModifierRE))) {
9574 name = name.slice(0, name.length - m[0].length);
9575 options[m[0].toLowerCase()] = true;
9576 }
9577 }
9578 return [hyphenate(name.slice(2)), options];
9579}
9580function createInvoker(initialValue, instance) {
9581 const invoker = (e) => {
9582 // async edge case #6566: inner click event triggers patch, event handler
9583 // attached to outer element during patch, and triggered again. This
9584 // happens because browsers fire microtask ticks between event propagation.
9585 // the solution is simple: we save the timestamp when a handler is attached,
9586 // and the handler would only fire if the event passed to it was fired
9587 // AFTER it was attached.
9588 const timeStamp = e.timeStamp || _getNow();
9589 if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
9590 callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
9591 }
9592 };
9593 invoker.value = initialValue;
9594 invoker.attached = getNow();
9595 return invoker;
9596}
9597function patchStopImmediatePropagation(e, value) {
9598 if (isArray(value)) {
9599 const originalStop = e.stopImmediatePropagation;
9600 e.stopImmediatePropagation = () => {
9601 originalStop.call(e);
9602 e._stopped = true;
9603 };
9604 return value.map(fn => (e) => !e._stopped && fn(e));
9605 }
9606 else {
9607 return value;
9608 }
9609}
9610
9611const nativeOnRE = /^on[a-z]/;
9612const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
9613 if (key === 'class') {
9614 patchClass(el, nextValue, isSVG);
9615 }
9616 else if (key === 'style') {
9617 patchStyle(el, prevValue, nextValue);
9618 }
9619 else if (isOn(key)) {
9620 // ignore v-model listeners
9621 if (!isModelListener(key)) {
9622 patchEvent(el, key, prevValue, nextValue, parentComponent);
9623 }
9624 }
9625 else if (key[0] === '.'
9626 ? ((key = key.slice(1)), true)
9627 : key[0] === '^'
9628 ? ((key = key.slice(1)), false)
9629 : shouldSetAsProp(el, key, nextValue, isSVG)) {
9630 patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
9631 }
9632 else {
9633 // special case for <input v-model type="checkbox"> with
9634 // :true-value & :false-value
9635 // store value as dom properties since non-string values will be
9636 // stringified.
9637 if (key === 'true-value') {
9638 el._trueValue = nextValue;
9639 }
9640 else if (key === 'false-value') {
9641 el._falseValue = nextValue;
9642 }
9643 patchAttr(el, key, nextValue, isSVG);
9644 }
9645};
9646function shouldSetAsProp(el, key, value, isSVG) {
9647 if (isSVG) {
9648 // most keys must be set as attribute on svg elements to work
9649 // ...except innerHTML & textContent
9650 if (key === 'innerHTML' || key === 'textContent') {
9651 return true;
9652 }
9653 // or native onclick with function values
9654 if (key in el && nativeOnRE.test(key) && isFunction(value)) {
9655 return true;
9656 }
9657 return false;
9658 }
9659 // spellcheck and draggable are numerated attrs, however their
9660 // corresponding DOM properties are actually booleans - this leads to
9661 // setting it with a string "false" value leading it to be coerced to
9662 // `true`, so we need to always treat them as attributes.
9663 // Note that `contentEditable` doesn't have this problem: its DOM
9664 // property is also enumerated string values.
9665 if (key === 'spellcheck' || key === 'draggable') {
9666 return false;
9667 }
9668 // #1787, #2840 form property on form elements is readonly and must be set as
9669 // attribute.
9670 if (key === 'form') {
9671 return false;
9672 }
9673 // #1526 <input list> must be set as attribute
9674 if (key === 'list' && el.tagName === 'INPUT') {
9675 return false;
9676 }
9677 // #2766 <textarea type> must be set as attribute
9678 if (key === 'type' && el.tagName === 'TEXTAREA') {
9679 return false;
9680 }
9681 // native onclick with string value, must be set as attribute
9682 if (nativeOnRE.test(key) && isString(value)) {
9683 return false;
9684 }
9685 return key in el;
9686}
9687
9688function defineCustomElement(options, hydate) {
9689 const Comp = defineComponent(options);
9690 class VueCustomElement extends VueElement {
9691 constructor(initialProps) {
9692 super(Comp, initialProps, hydate);
9693 }
9694 }
9695 VueCustomElement.def = Comp;
9696 return VueCustomElement;
9697}
9698const defineSSRCustomElement = ((options) => {
9699 // @ts-ignore
9700 return defineCustomElement(options, hydrate);
9701});
9702const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
9703});
9704class VueElement extends BaseClass {
9705 constructor(_def, _props = {}, hydrate) {
9706 super();
9707 this._def = _def;
9708 this._props = _props;
9709 /**
9710 * @internal
9711 */
9712 this._instance = null;
9713 this._connected = false;
9714 this._resolved = false;
9715 if (this.shadowRoot && hydrate) {
9716 hydrate(this._createVNode(), this.shadowRoot);
9717 }
9718 else {
9719 if (this.shadowRoot) {
9720 warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
9721 `defined as hydratable. Use \`defineSSRCustomElement\`.`);
9722 }
9723 this.attachShadow({ mode: 'open' });
9724 }
9725 // set initial attrs
9726 for (let i = 0; i < this.attributes.length; i++) {
9727 this._setAttr(this.attributes[i].name);
9728 }
9729 // watch future attr changes
9730 const observer = new MutationObserver(mutations => {
9731 for (const m of mutations) {
9732 this._setAttr(m.attributeName);
9733 }
9734 });
9735 observer.observe(this, { attributes: true });
9736 }
9737 connectedCallback() {
9738 this._connected = true;
9739 if (!this._instance) {
9740 this._resolveDef();
9741 render(this._createVNode(), this.shadowRoot);
9742 }
9743 }
9744 disconnectedCallback() {
9745 this._connected = false;
9746 nextTick(() => {
9747 if (!this._connected) {
9748 render(null, this.shadowRoot);
9749 this._instance = null;
9750 }
9751 });
9752 }
9753 /**
9754 * resolve inner component definition (handle possible async component)
9755 */
9756 _resolveDef() {
9757 if (this._resolved) {
9758 return;
9759 }
9760 const resolve = (def) => {
9761 this._resolved = true;
9762 // check if there are props set pre-upgrade or connect
9763 for (const key of Object.keys(this)) {
9764 if (key[0] !== '_') {
9765 this._setProp(key, this[key]);
9766 }
9767 }
9768 const { props, styles } = def;
9769 // defining getter/setters on prototype
9770 const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
9771 for (const key of rawKeys.map(camelize)) {
9772 Object.defineProperty(this, key, {
9773 get() {
9774 return this._getProp(key);
9775 },
9776 set(val) {
9777 this._setProp(key, val);
9778 }
9779 });
9780 }
9781 this._applyStyles(styles);
9782 };
9783 const asyncDef = this._def.__asyncLoader;
9784 if (asyncDef) {
9785 asyncDef().then(resolve);
9786 }
9787 else {
9788 resolve(this._def);
9789 }
9790 }
9791 _setAttr(key) {
9792 this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
9793 }
9794 /**
9795 * @internal
9796 */
9797 _getProp(key) {
9798 return this._props[key];
9799 }
9800 /**
9801 * @internal
9802 */
9803 _setProp(key, val, shouldReflect = true) {
9804 if (val !== this._props[key]) {
9805 this._props[key] = val;
9806 if (this._instance) {
9807 render(this._createVNode(), this.shadowRoot);
9808 }
9809 // reflect
9810 if (shouldReflect) {
9811 if (val === true) {
9812 this.setAttribute(hyphenate(key), '');
9813 }
9814 else if (typeof val === 'string' || typeof val === 'number') {
9815 this.setAttribute(hyphenate(key), val + '');
9816 }
9817 else if (!val) {
9818 this.removeAttribute(hyphenate(key));
9819 }
9820 }
9821 }
9822 }
9823 _createVNode() {
9824 const vnode = createVNode(this._def, extend({}, this._props));
9825 if (!this._instance) {
9826 vnode.ce = instance => {
9827 this._instance = instance;
9828 instance.isCE = true;
9829 // HMR
9830 {
9831 instance.ceReload = newStyles => {
9832 // alawys reset styles
9833 if (this._styles) {
9834 this._styles.forEach(s => this.shadowRoot.removeChild(s));
9835 this._styles.length = 0;
9836 }
9837 this._applyStyles(newStyles);
9838 // if this is an async component, ceReload is called from the inner
9839 // component so no need to reload the async wrapper
9840 if (!this._def.__asyncLoader) {
9841 // reload
9842 this._instance = null;
9843 render(this._createVNode(), this.shadowRoot);
9844 }
9845 };
9846 }
9847 // intercept emit
9848 instance.emit = (event, ...args) => {
9849 this.dispatchEvent(new CustomEvent(event, {
9850 detail: args
9851 }));
9852 };
9853 // locate nearest Vue custom element parent for provide/inject
9854 let parent = this;
9855 while ((parent =
9856 parent && (parent.parentNode || parent.host))) {
9857 if (parent instanceof VueElement) {
9858 instance.parent = parent._instance;
9859 break;
9860 }
9861 }
9862 };
9863 }
9864 return vnode;
9865 }
9866 _applyStyles(styles) {
9867 if (styles) {
9868 styles.forEach(css => {
9869 const s = document.createElement('style');
9870 s.textContent = css;
9871 this.shadowRoot.appendChild(s);
9872 // record for HMR
9873 {
9874 (this._styles || (this._styles = [])).push(s);
9875 }
9876 });
9877 }
9878 }
9879}
9880
9881function useCssModule(name = '$style') {
9882 /* istanbul ignore else */
9883 {
9884 const instance = getCurrentInstance();
9885 if (!instance) {
9886 warn$1(`useCssModule must be called inside setup()`);
9887 return EMPTY_OBJ;
9888 }
9889 const modules = instance.type.__cssModules;
9890 if (!modules) {
9891 warn$1(`Current instance does not have CSS modules injected.`);
9892 return EMPTY_OBJ;
9893 }
9894 const mod = modules[name];
9895 if (!mod) {
9896 warn$1(`Current instance does not have CSS module named "${name}".`);
9897 return EMPTY_OBJ;
9898 }
9899 return mod;
9900 }
9901}
9902
9903/**
9904 * Runtime helper for SFC's CSS variable injection feature.
9905 * @private
9906 */
9907function useCssVars(getter) {
9908 const instance = getCurrentInstance();
9909 /* istanbul ignore next */
9910 if (!instance) {
9911 warn$1(`useCssVars is called without current active component instance.`);
9912 return;
9913 }
9914 const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
9915 watchPostEffect(setVars);
9916 onMounted(() => {
9917 const ob = new MutationObserver(setVars);
9918 ob.observe(instance.subTree.el.parentNode, { childList: true });
9919 onUnmounted(() => ob.disconnect());
9920 });
9921}
9922function setVarsOnVNode(vnode, vars) {
9923 if (vnode.shapeFlag & 128 /* SUSPENSE */) {
9924 const suspense = vnode.suspense;
9925 vnode = suspense.activeBranch;
9926 if (suspense.pendingBranch && !suspense.isHydrating) {
9927 suspense.effects.push(() => {
9928 setVarsOnVNode(suspense.activeBranch, vars);
9929 });
9930 }
9931 }
9932 // drill down HOCs until it's a non-component vnode
9933 while (vnode.component) {
9934 vnode = vnode.component.subTree;
9935 }
9936 if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
9937 setVarsOnNode(vnode.el, vars);
9938 }
9939 else if (vnode.type === Fragment) {
9940 vnode.children.forEach(c => setVarsOnVNode(c, vars));
9941 }
9942 else if (vnode.type === Static) {
9943 let { el, anchor } = vnode;
9944 while (el) {
9945 setVarsOnNode(el, vars);
9946 if (el === anchor)
9947 break;
9948 el = el.nextSibling;
9949 }
9950 }
9951}
9952function setVarsOnNode(el, vars) {
9953 if (el.nodeType === 1) {
9954 const style = el.style;
9955 for (const key in vars) {
9956 style.setProperty(`--${key}`, vars[key]);
9957 }
9958 }
9959}
9960
9961const TRANSITION = 'transition';
9962const ANIMATION = 'animation';
9963// DOM Transition is a higher-order-component based on the platform-agnostic
9964// base Transition component, with DOM-specific logic.
9965const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
9966Transition.displayName = 'Transition';
9967const DOMTransitionPropsValidators = {
9968 name: String,
9969 type: String,
9970 css: {
9971 type: Boolean,
9972 default: true
9973 },
9974 duration: [String, Number, Object],
9975 enterFromClass: String,
9976 enterActiveClass: String,
9977 enterToClass: String,
9978 appearFromClass: String,
9979 appearActiveClass: String,
9980 appearToClass: String,
9981 leaveFromClass: String,
9982 leaveActiveClass: String,
9983 leaveToClass: String
9984};
9985const TransitionPropsValidators = (Transition.props =
9986 /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
9987/**
9988 * #3227 Incoming hooks may be merged into arrays when wrapping Transition
9989 * with custom HOCs.
9990 */
9991const callHook$1 = (hook, args = []) => {
9992 if (isArray(hook)) {
9993 hook.forEach(h => h(...args));
9994 }
9995 else if (hook) {
9996 hook(...args);
9997 }
9998};
9999/**
10000 * Check if a hook expects a callback (2nd arg), which means the user
10001 * intends to explicitly control the end of the transition.
10002 */
10003const hasExplicitCallback = (hook) => {
10004 return hook
10005 ? isArray(hook)
10006 ? hook.some(h => h.length > 1)
10007 : hook.length > 1
10008 : false;
10009};
10010function resolveTransitionProps(rawProps) {
10011 const baseProps = {};
10012 for (const key in rawProps) {
10013 if (!(key in DOMTransitionPropsValidators)) {
10014 baseProps[key] = rawProps[key];
10015 }
10016 }
10017 if (rawProps.css === false) {
10018 return baseProps;
10019 }
10020 const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
10021 const durations = normalizeDuration(duration);
10022 const enterDuration = durations && durations[0];
10023 const leaveDuration = durations && durations[1];
10024 const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
10025 const finishEnter = (el, isAppear, done) => {
10026 removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
10027 removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
10028 done && done();
10029 };
10030 const finishLeave = (el, done) => {
10031 removeTransitionClass(el, leaveToClass);
10032 removeTransitionClass(el, leaveActiveClass);
10033 done && done();
10034 };
10035 const makeEnterHook = (isAppear) => {
10036 return (el, done) => {
10037 const hook = isAppear ? onAppear : onEnter;
10038 const resolve = () => finishEnter(el, isAppear, done);
10039 callHook$1(hook, [el, resolve]);
10040 nextFrame(() => {
10041 removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
10042 addTransitionClass(el, isAppear ? appearToClass : enterToClass);
10043 if (!hasExplicitCallback(hook)) {
10044 whenTransitionEnds(el, type, enterDuration, resolve);
10045 }
10046 });
10047 };
10048 };
10049 return extend(baseProps, {
10050 onBeforeEnter(el) {
10051 callHook$1(onBeforeEnter, [el]);
10052 addTransitionClass(el, enterFromClass);
10053 addTransitionClass(el, enterActiveClass);
10054 },
10055 onBeforeAppear(el) {
10056 callHook$1(onBeforeAppear, [el]);
10057 addTransitionClass(el, appearFromClass);
10058 addTransitionClass(el, appearActiveClass);
10059 },
10060 onEnter: makeEnterHook(false),
10061 onAppear: makeEnterHook(true),
10062 onLeave(el, done) {
10063 const resolve = () => finishLeave(el, done);
10064 addTransitionClass(el, leaveFromClass);
10065 // force reflow so *-leave-from classes immediately take effect (#2593)
10066 forceReflow();
10067 addTransitionClass(el, leaveActiveClass);
10068 nextFrame(() => {
10069 removeTransitionClass(el, leaveFromClass);
10070 addTransitionClass(el, leaveToClass);
10071 if (!hasExplicitCallback(onLeave)) {
10072 whenTransitionEnds(el, type, leaveDuration, resolve);
10073 }
10074 });
10075 callHook$1(onLeave, [el, resolve]);
10076 },
10077 onEnterCancelled(el) {
10078 finishEnter(el, false);
10079 callHook$1(onEnterCancelled, [el]);
10080 },
10081 onAppearCancelled(el) {
10082 finishEnter(el, true);
10083 callHook$1(onAppearCancelled, [el]);
10084 },
10085 onLeaveCancelled(el) {
10086 finishLeave(el);
10087 callHook$1(onLeaveCancelled, [el]);
10088 }
10089 });
10090}
10091function normalizeDuration(duration) {
10092 if (duration == null) {
10093 return null;
10094 }
10095 else if (isObject(duration)) {
10096 return [NumberOf(duration.enter), NumberOf(duration.leave)];
10097 }
10098 else {
10099 const n = NumberOf(duration);
10100 return [n, n];
10101 }
10102}
10103function NumberOf(val) {
10104 const res = toNumber(val);
10105 validateDuration(res);
10106 return res;
10107}
10108function validateDuration(val) {
10109 if (typeof val !== 'number') {
10110 warn$1(`<transition> explicit duration is not a valid number - ` +
10111 `got ${JSON.stringify(val)}.`);
10112 }
10113 else if (isNaN(val)) {
10114 warn$1(`<transition> explicit duration is NaN - ` +
10115 'the duration expression might be incorrect.');
10116 }
10117}
10118function addTransitionClass(el, cls) {
10119 cls.split(/\s+/).forEach(c => c && el.classList.add(c));
10120 (el._vtc ||
10121 (el._vtc = new Set())).add(cls);
10122}
10123function removeTransitionClass(el, cls) {
10124 cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
10125 const { _vtc } = el;
10126 if (_vtc) {
10127 _vtc.delete(cls);
10128 if (!_vtc.size) {
10129 el._vtc = undefined;
10130 }
10131 }
10132}
10133function nextFrame(cb) {
10134 requestAnimationFrame(() => {
10135 requestAnimationFrame(cb);
10136 });
10137}
10138let endId = 0;
10139function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
10140 const id = (el._endId = ++endId);
10141 const resolveIfNotStale = () => {
10142 if (id === el._endId) {
10143 resolve();
10144 }
10145 };
10146 if (explicitTimeout) {
10147 return setTimeout(resolveIfNotStale, explicitTimeout);
10148 }
10149 const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
10150 if (!type) {
10151 return resolve();
10152 }
10153 const endEvent = type + 'end';
10154 let ended = 0;
10155 const end = () => {
10156 el.removeEventListener(endEvent, onEnd);
10157 resolveIfNotStale();
10158 };
10159 const onEnd = (e) => {
10160 if (e.target === el && ++ended >= propCount) {
10161 end();
10162 }
10163 };
10164 setTimeout(() => {
10165 if (ended < propCount) {
10166 end();
10167 }
10168 }, timeout + 1);
10169 el.addEventListener(endEvent, onEnd);
10170}
10171function getTransitionInfo(el, expectedType) {
10172 const styles = window.getComputedStyle(el);
10173 // JSDOM may return undefined for transition properties
10174 const getStyleProperties = (key) => (styles[key] || '').split(', ');
10175 const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
10176 const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
10177 const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
10178 const animationDelays = getStyleProperties(ANIMATION + 'Delay');
10179 const animationDurations = getStyleProperties(ANIMATION + 'Duration');
10180 const animationTimeout = getTimeout(animationDelays, animationDurations);
10181 let type = null;
10182 let timeout = 0;
10183 let propCount = 0;
10184 /* istanbul ignore if */
10185 if (expectedType === TRANSITION) {
10186 if (transitionTimeout > 0) {
10187 type = TRANSITION;
10188 timeout = transitionTimeout;
10189 propCount = transitionDurations.length;
10190 }
10191 }
10192 else if (expectedType === ANIMATION) {
10193 if (animationTimeout > 0) {
10194 type = ANIMATION;
10195 timeout = animationTimeout;
10196 propCount = animationDurations.length;
10197 }
10198 }
10199 else {
10200 timeout = Math.max(transitionTimeout, animationTimeout);
10201 type =
10202 timeout > 0
10203 ? transitionTimeout > animationTimeout
10204 ? TRANSITION
10205 : ANIMATION
10206 : null;
10207 propCount = type
10208 ? type === TRANSITION
10209 ? transitionDurations.length
10210 : animationDurations.length
10211 : 0;
10212 }
10213 const hasTransform = type === TRANSITION &&
10214 /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
10215 return {
10216 type,
10217 timeout,
10218 propCount,
10219 hasTransform
10220 };
10221}
10222function getTimeout(delays, durations) {
10223 while (delays.length < durations.length) {
10224 delays = delays.concat(delays);
10225 }
10226 return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
10227}
10228// Old versions of Chromium (below 61.0.3163.100) formats floating pointer
10229// numbers in a locale-dependent way, using a comma instead of a dot.
10230// If comma is not replaced with a dot, the input will be rounded down
10231// (i.e. acting as a floor function) causing unexpected behaviors
10232function toMs(s) {
10233 return Number(s.slice(0, -1).replace(',', '.')) * 1000;
10234}
10235// synchronously force layout to put elements into a certain state
10236function forceReflow() {
10237 return document.body.offsetHeight;
10238}
10239
10240const positionMap = new WeakMap();
10241const newPositionMap = new WeakMap();
10242const TransitionGroupImpl = {
10243 name: 'TransitionGroup',
10244 props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
10245 tag: String,
10246 moveClass: String
10247 }),
10248 setup(props, { slots }) {
10249 const instance = getCurrentInstance();
10250 const state = useTransitionState();
10251 let prevChildren;
10252 let children;
10253 onUpdated(() => {
10254 // children is guaranteed to exist after initial render
10255 if (!prevChildren.length) {
10256 return;
10257 }
10258 const moveClass = props.moveClass || `${props.name || 'v'}-move`;
10259 if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
10260 return;
10261 }
10262 // we divide the work into three loops to avoid mixing DOM reads and writes
10263 // in each iteration - which helps prevent layout thrashing.
10264 prevChildren.forEach(callPendingCbs);
10265 prevChildren.forEach(recordPosition);
10266 const movedChildren = prevChildren.filter(applyTranslation);
10267 // force reflow to put everything in position
10268 forceReflow();
10269 movedChildren.forEach(c => {
10270 const el = c.el;
10271 const style = el.style;
10272 addTransitionClass(el, moveClass);
10273 style.transform = style.webkitTransform = style.transitionDuration = '';
10274 const cb = (el._moveCb = (e) => {
10275 if (e && e.target !== el) {
10276 return;
10277 }
10278 if (!e || /transform$/.test(e.propertyName)) {
10279 el.removeEventListener('transitionend', cb);
10280 el._moveCb = null;
10281 removeTransitionClass(el, moveClass);
10282 }
10283 });
10284 el.addEventListener('transitionend', cb);
10285 });
10286 });
10287 return () => {
10288 const rawProps = toRaw(props);
10289 const cssTransitionProps = resolveTransitionProps(rawProps);
10290 let tag = rawProps.tag || Fragment;
10291 prevChildren = children;
10292 children = slots.default ? getTransitionRawChildren(slots.default()) : [];
10293 for (let i = 0; i < children.length; i++) {
10294 const child = children[i];
10295 if (child.key != null) {
10296 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
10297 }
10298 else {
10299 warn$1(`<TransitionGroup> children must be keyed.`);
10300 }
10301 }
10302 if (prevChildren) {
10303 for (let i = 0; i < prevChildren.length; i++) {
10304 const child = prevChildren[i];
10305 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
10306 positionMap.set(child, child.el.getBoundingClientRect());
10307 }
10308 }
10309 return createVNode(tag, null, children);
10310 };
10311 }
10312};
10313const TransitionGroup = TransitionGroupImpl;
10314function callPendingCbs(c) {
10315 const el = c.el;
10316 if (el._moveCb) {
10317 el._moveCb();
10318 }
10319 if (el._enterCb) {
10320 el._enterCb();
10321 }
10322}
10323function recordPosition(c) {
10324 newPositionMap.set(c, c.el.getBoundingClientRect());
10325}
10326function applyTranslation(c) {
10327 const oldPos = positionMap.get(c);
10328 const newPos = newPositionMap.get(c);
10329 const dx = oldPos.left - newPos.left;
10330 const dy = oldPos.top - newPos.top;
10331 if (dx || dy) {
10332 const s = c.el.style;
10333 s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
10334 s.transitionDuration = '0s';
10335 return c;
10336 }
10337}
10338function hasCSSTransform(el, root, moveClass) {
10339 // Detect whether an element with the move class applied has
10340 // CSS transitions. Since the element may be inside an entering
10341 // transition at this very moment, we make a clone of it and remove
10342 // all other transition classes applied to ensure only the move class
10343 // is applied.
10344 const clone = el.cloneNode();
10345 if (el._vtc) {
10346 el._vtc.forEach(cls => {
10347 cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
10348 });
10349 }
10350 moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
10351 clone.style.display = 'none';
10352 const container = (root.nodeType === 1 ? root : root.parentNode);
10353 container.appendChild(clone);
10354 const { hasTransform } = getTransitionInfo(clone);
10355 container.removeChild(clone);
10356 return hasTransform;
10357}
10358
10359const getModelAssigner = (vnode) => {
10360 const fn = vnode.props['onUpdate:modelValue'];
10361 return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
10362};
10363function onCompositionStart(e) {
10364 e.target.composing = true;
10365}
10366function onCompositionEnd(e) {
10367 const target = e.target;
10368 if (target.composing) {
10369 target.composing = false;
10370 trigger$1(target, 'input');
10371 }
10372}
10373function trigger$1(el, type) {
10374 const e = document.createEvent('HTMLEvents');
10375 e.initEvent(type, true, true);
10376 el.dispatchEvent(e);
10377}
10378// We are exporting the v-model runtime directly as vnode hooks so that it can
10379// be tree-shaken in case v-model is never used.
10380const vModelText = {
10381 created(el, { modifiers: { lazy, trim, number } }, vnode) {
10382 el._assign = getModelAssigner(vnode);
10383 const castToNumber = number || (vnode.props && vnode.props.type === 'number');
10384 addEventListener(el, lazy ? 'change' : 'input', e => {
10385 if (e.target.composing)
10386 return;
10387 let domValue = el.value;
10388 if (trim) {
10389 domValue = domValue.trim();
10390 }
10391 else if (castToNumber) {
10392 domValue = toNumber(domValue);
10393 }
10394 el._assign(domValue);
10395 });
10396 if (trim) {
10397 addEventListener(el, 'change', () => {
10398 el.value = el.value.trim();
10399 });
10400 }
10401 if (!lazy) {
10402 addEventListener(el, 'compositionstart', onCompositionStart);
10403 addEventListener(el, 'compositionend', onCompositionEnd);
10404 // Safari < 10.2 & UIWebView doesn't fire compositionend when
10405 // switching focus before confirming composition choice
10406 // this also fixes the issue where some browsers e.g. iOS Chrome
10407 // fires "change" instead of "input" on autocomplete.
10408 addEventListener(el, 'change', onCompositionEnd);
10409 }
10410 },
10411 // set value on mounted so it's after min/max for type="range"
10412 mounted(el, { value }) {
10413 el.value = value == null ? '' : value;
10414 },
10415 beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
10416 el._assign = getModelAssigner(vnode);
10417 // avoid clearing unresolved text. #2302
10418 if (el.composing)
10419 return;
10420 if (document.activeElement === el) {
10421 if (lazy) {
10422 return;
10423 }
10424 if (trim && el.value.trim() === value) {
10425 return;
10426 }
10427 if ((number || el.type === 'number') && toNumber(el.value) === value) {
10428 return;
10429 }
10430 }
10431 const newValue = value == null ? '' : value;
10432 if (el.value !== newValue) {
10433 el.value = newValue;
10434 }
10435 }
10436};
10437const vModelCheckbox = {
10438 // #4096 array checkboxes need to be deep traversed
10439 deep: true,
10440 created(el, _, vnode) {
10441 el._assign = getModelAssigner(vnode);
10442 addEventListener(el, 'change', () => {
10443 const modelValue = el._modelValue;
10444 const elementValue = getValue(el);
10445 const checked = el.checked;
10446 const assign = el._assign;
10447 if (isArray(modelValue)) {
10448 const index = looseIndexOf(modelValue, elementValue);
10449 const found = index !== -1;
10450 if (checked && !found) {
10451 assign(modelValue.concat(elementValue));
10452 }
10453 else if (!checked && found) {
10454 const filtered = [...modelValue];
10455 filtered.splice(index, 1);
10456 assign(filtered);
10457 }
10458 }
10459 else if (isSet(modelValue)) {
10460 const cloned = new Set(modelValue);
10461 if (checked) {
10462 cloned.add(elementValue);
10463 }
10464 else {
10465 cloned.delete(elementValue);
10466 }
10467 assign(cloned);
10468 }
10469 else {
10470 assign(getCheckboxValue(el, checked));
10471 }
10472 });
10473 },
10474 // set initial checked on mount to wait for true-value/false-value
10475 mounted: setChecked,
10476 beforeUpdate(el, binding, vnode) {
10477 el._assign = getModelAssigner(vnode);
10478 setChecked(el, binding, vnode);
10479 }
10480};
10481function setChecked(el, { value, oldValue }, vnode) {
10482 el._modelValue = value;
10483 if (isArray(value)) {
10484 el.checked = looseIndexOf(value, vnode.props.value) > -1;
10485 }
10486 else if (isSet(value)) {
10487 el.checked = value.has(vnode.props.value);
10488 }
10489 else if (value !== oldValue) {
10490 el.checked = looseEqual(value, getCheckboxValue(el, true));
10491 }
10492}
10493const vModelRadio = {
10494 created(el, { value }, vnode) {
10495 el.checked = looseEqual(value, vnode.props.value);
10496 el._assign = getModelAssigner(vnode);
10497 addEventListener(el, 'change', () => {
10498 el._assign(getValue(el));
10499 });
10500 },
10501 beforeUpdate(el, { value, oldValue }, vnode) {
10502 el._assign = getModelAssigner(vnode);
10503 if (value !== oldValue) {
10504 el.checked = looseEqual(value, vnode.props.value);
10505 }
10506 }
10507};
10508const vModelSelect = {
10509 // <select multiple> value need to be deep traversed
10510 deep: true,
10511 created(el, { value, modifiers: { number } }, vnode) {
10512 const isSetModel = isSet(value);
10513 addEventListener(el, 'change', () => {
10514 const selectedVal = Array.prototype.filter
10515 .call(el.options, (o) => o.selected)
10516 .map((o) => number ? toNumber(getValue(o)) : getValue(o));
10517 el._assign(el.multiple
10518 ? isSetModel
10519 ? new Set(selectedVal)
10520 : selectedVal
10521 : selectedVal[0]);
10522 });
10523 el._assign = getModelAssigner(vnode);
10524 },
10525 // set value in mounted & updated because <select> relies on its children
10526 // <option>s.
10527 mounted(el, { value }) {
10528 setSelected(el, value);
10529 },
10530 beforeUpdate(el, _binding, vnode) {
10531 el._assign = getModelAssigner(vnode);
10532 },
10533 updated(el, { value }) {
10534 setSelected(el, value);
10535 }
10536};
10537function setSelected(el, value) {
10538 const isMultiple = el.multiple;
10539 if (isMultiple && !isArray(value) && !isSet(value)) {
10540 warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
10541 `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
10542 return;
10543 }
10544 for (let i = 0, l = el.options.length; i < l; i++) {
10545 const option = el.options[i];
10546 const optionValue = getValue(option);
10547 if (isMultiple) {
10548 if (isArray(value)) {
10549 option.selected = looseIndexOf(value, optionValue) > -1;
10550 }
10551 else {
10552 option.selected = value.has(optionValue);
10553 }
10554 }
10555 else {
10556 if (looseEqual(getValue(option), value)) {
10557 if (el.selectedIndex !== i)
10558 el.selectedIndex = i;
10559 return;
10560 }
10561 }
10562 }
10563 if (!isMultiple && el.selectedIndex !== -1) {
10564 el.selectedIndex = -1;
10565 }
10566}
10567// retrieve raw value set via :value bindings
10568function getValue(el) {
10569 return '_value' in el ? el._value : el.value;
10570}
10571// retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
10572function getCheckboxValue(el, checked) {
10573 const key = checked ? '_trueValue' : '_falseValue';
10574 return key in el ? el[key] : checked;
10575}
10576const vModelDynamic = {
10577 created(el, binding, vnode) {
10578 callModelHook(el, binding, vnode, null, 'created');
10579 },
10580 mounted(el, binding, vnode) {
10581 callModelHook(el, binding, vnode, null, 'mounted');
10582 },
10583 beforeUpdate(el, binding, vnode, prevVNode) {
10584 callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
10585 },
10586 updated(el, binding, vnode, prevVNode) {
10587 callModelHook(el, binding, vnode, prevVNode, 'updated');
10588 }
10589};
10590function callModelHook(el, binding, vnode, prevVNode, hook) {
10591 let modelToUse;
10592 switch (el.tagName) {
10593 case 'SELECT':
10594 modelToUse = vModelSelect;
10595 break;
10596 case 'TEXTAREA':
10597 modelToUse = vModelText;
10598 break;
10599 default:
10600 switch (vnode.props && vnode.props.type) {
10601 case 'checkbox':
10602 modelToUse = vModelCheckbox;
10603 break;
10604 case 'radio':
10605 modelToUse = vModelRadio;
10606 break;
10607 default:
10608 modelToUse = vModelText;
10609 }
10610 }
10611 const fn = modelToUse[hook];
10612 fn && fn(el, binding, vnode, prevVNode);
10613}
10614
10615const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
10616const modifierGuards = {
10617 stop: e => e.stopPropagation(),
10618 prevent: e => e.preventDefault(),
10619 self: e => e.target !== e.currentTarget,
10620 ctrl: e => !e.ctrlKey,
10621 shift: e => !e.shiftKey,
10622 alt: e => !e.altKey,
10623 meta: e => !e.metaKey,
10624 left: e => 'button' in e && e.button !== 0,
10625 middle: e => 'button' in e && e.button !== 1,
10626 right: e => 'button' in e && e.button !== 2,
10627 exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
10628};
10629/**
10630 * @private
10631 */
10632const withModifiers = (fn, modifiers) => {
10633 return (event, ...args) => {
10634 for (let i = 0; i < modifiers.length; i++) {
10635 const guard = modifierGuards[modifiers[i]];
10636 if (guard && guard(event, modifiers))
10637 return;
10638 }
10639 return fn(event, ...args);
10640 };
10641};
10642// Kept for 2.x compat.
10643// Note: IE11 compat for `spacebar` and `del` is removed for now.
10644const keyNames = {
10645 esc: 'escape',
10646 space: ' ',
10647 up: 'arrow-up',
10648 left: 'arrow-left',
10649 right: 'arrow-right',
10650 down: 'arrow-down',
10651 delete: 'backspace'
10652};
10653/**
10654 * @private
10655 */
10656const withKeys = (fn, modifiers) => {
10657 return (event) => {
10658 if (!('key' in event)) {
10659 return;
10660 }
10661 const eventKey = hyphenate(event.key);
10662 if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
10663 return fn(event);
10664 }
10665 };
10666};
10667
10668const vShow = {
10669 beforeMount(el, { value }, { transition }) {
10670 el._vod = el.style.display === 'none' ? '' : el.style.display;
10671 if (transition && value) {
10672 transition.beforeEnter(el);
10673 }
10674 else {
10675 setDisplay(el, value);
10676 }
10677 },
10678 mounted(el, { value }, { transition }) {
10679 if (transition && value) {
10680 transition.enter(el);
10681 }
10682 },
10683 updated(el, { value, oldValue }, { transition }) {
10684 if (!value === !oldValue)
10685 return;
10686 if (transition) {
10687 if (value) {
10688 transition.beforeEnter(el);
10689 setDisplay(el, true);
10690 transition.enter(el);
10691 }
10692 else {
10693 transition.leave(el, () => {
10694 setDisplay(el, false);
10695 });
10696 }
10697 }
10698 else {
10699 setDisplay(el, value);
10700 }
10701 },
10702 beforeUnmount(el, { value }) {
10703 setDisplay(el, value);
10704 }
10705};
10706function setDisplay(el, value) {
10707 el.style.display = value ? el._vod : 'none';
10708}
10709
10710const rendererOptions = extend({ patchProp }, nodeOps);
10711// lazy create the renderer - this makes core renderer logic tree-shakable
10712// in case the user only imports reactivity utilities from Vue.
10713let renderer;
10714let enabledHydration = false;
10715function ensureRenderer() {
10716 return (renderer ||
10717 (renderer = createRenderer(rendererOptions)));
10718}
10719function ensureHydrationRenderer() {
10720 renderer = enabledHydration
10721 ? renderer
10722 : createHydrationRenderer(rendererOptions);
10723 enabledHydration = true;
10724 return renderer;
10725}
10726// use explicit type casts here to avoid import() calls in rolled-up d.ts
10727const render = ((...args) => {
10728 ensureRenderer().render(...args);
10729});
10730const hydrate = ((...args) => {
10731 ensureHydrationRenderer().hydrate(...args);
10732});
10733const createApp = ((...args) => {
10734 const app = ensureRenderer().createApp(...args);
10735 {
10736 injectNativeTagCheck(app);
10737 injectCompilerOptionsCheck(app);
10738 }
10739 const { mount } = app;
10740 app.mount = (containerOrSelector) => {
10741 const container = normalizeContainer(containerOrSelector);
10742 if (!container)
10743 return;
10744 const component = app._component;
10745 if (!isFunction(component) && !component.render && !component.template) {
10746 // __UNSAFE__
10747 // Reason: potential execution of JS expressions in in-DOM template.
10748 // The user must make sure the in-DOM template is trusted. If it's
10749 // rendered by the server, the template should not contain any user data.
10750 component.template = container.innerHTML;
10751 }
10752 // clear content before mounting
10753 container.innerHTML = '';
10754 const proxy = mount(container, false, container instanceof SVGElement);
10755 if (container instanceof Element) {
10756 container.removeAttribute('v-cloak');
10757 container.setAttribute('data-v-app', '');
10758 }
10759 return proxy;
10760 };
10761 return app;
10762});
10763const createSSRApp = ((...args) => {
10764 const app = ensureHydrationRenderer().createApp(...args);
10765 {
10766 injectNativeTagCheck(app);
10767 injectCompilerOptionsCheck(app);
10768 }
10769 const { mount } = app;
10770 app.mount = (containerOrSelector) => {
10771 const container = normalizeContainer(containerOrSelector);
10772 if (container) {
10773 return mount(container, true, container instanceof SVGElement);
10774 }
10775 };
10776 return app;
10777});
10778function injectNativeTagCheck(app) {
10779 // Inject `isNativeTag`
10780 // this is used for component name validation (dev only)
10781 Object.defineProperty(app.config, 'isNativeTag', {
10782 value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
10783 writable: false
10784 });
10785}
10786// dev only
10787function injectCompilerOptionsCheck(app) {
10788 if (isRuntimeOnly()) {
10789 const isCustomElement = app.config.isCustomElement;
10790 Object.defineProperty(app.config, 'isCustomElement', {
10791 get() {
10792 return isCustomElement;
10793 },
10794 set() {
10795 warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
10796 `\`compilerOptions.isCustomElement\` instead.`);
10797 }
10798 });
10799 const compilerOptions = app.config.compilerOptions;
10800 const msg = `The \`compilerOptions\` config option is only respected when using ` +
10801 `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
10802 `Since you are using the runtime-only build, \`compilerOptions\` ` +
10803 `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
10804 `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
10805 `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
10806 `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
10807 Object.defineProperty(app.config, 'compilerOptions', {
10808 get() {
10809 warn$1(msg);
10810 return compilerOptions;
10811 },
10812 set() {
10813 warn$1(msg);
10814 }
10815 });
10816 }
10817}
10818function normalizeContainer(container) {
10819 if (isString(container)) {
10820 const res = document.querySelector(container);
10821 if (!res) {
10822 warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
10823 }
10824 return res;
10825 }
10826 if (window.ShadowRoot &&
10827 container instanceof window.ShadowRoot &&
10828 container.mode === 'closed') {
10829 warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
10830 }
10831 return container;
10832}
10833
10834function initDev() {
10835 {
10836 {
10837 console.info(`You are running a development build of Vue.\n` +
10838 `Make sure to use the production build (*.prod.js) when deploying for production.`);
10839 }
10840 initCustomFormatter();
10841 }
10842}
10843
10844// This entry exports the runtime only, and is built as
10845{
10846 initDev();
10847}
10848const compile$1 = () => {
10849 {
10850 warn$1(`Runtime compilation is not supported in this build of Vue.` +
10851 (` Use "vue.esm-browser.js" instead.`
10852 ) /* should not happen */);
10853 }
10854};
10855
10856export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compile$1 as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };