UNPKG

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