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 let handlerName;
1810 let handler = props[(handlerName = toHandlerKey(event))] ||
1811 // also try camelCase event handler (#2249)
1812 props[(handlerName = toHandlerKey(camelize(event)))];
1813 // for v-model update:xxx events, also trigger kebab-case equivalent
1814 // for props passed via kebab-case
1815 if (!handler && isModelListener) {
1816 handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
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, optimized) => {
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 (optimized && 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 // #2893
4033 // when rendering the optimized slots by manually written render function,
4034 // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
4035 // i.e. let the `renderSlot` create the bailed Fragment
4036 if (!optimized && type === 1 /* STABLE */) {
4037 delete slots._;
4038 }
4039 }
4040 }
4041 else {
4042 needDeletionCheck = !children.$stable;
4043 normalizeObjectSlots(children, slots);
4044 }
4045 deletionComparisonTarget = children;
4046 }
4047 else if (children) {
4048 // non slot object children (direct value) passed to a component
4049 normalizeVNodeSlots(instance, children);
4050 deletionComparisonTarget = { default: 1 };
4051 }
4052 // delete stale slots
4053 if (needDeletionCheck) {
4054 for (const key in slots) {
4055 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
4056 delete slots[key];
4057 }
4058 }
4059 }
4060};
4061
4062/**
4063Runtime helper for applying directives to a vnode. Example usage:
4064
4065const comp = resolveComponent('comp')
4066const foo = resolveDirective('foo')
4067const bar = resolveDirective('bar')
4068
4069return withDirectives(h(comp), [
4070 [foo, this.x],
4071 [bar, this.y]
4072])
4073*/
4074const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4075function validateDirectiveName(name) {
4076 if (isBuiltInDirective(name)) {
4077 warn('Do not use built-in directive ids as custom directive id: ' + name);
4078 }
4079}
4080/**
4081 * Adds directives to a VNode.
4082 */
4083function withDirectives(vnode, directives) {
4084 const internalInstance = currentRenderingInstance;
4085 if (internalInstance === null) {
4086 warn(`withDirectives can only be used inside render functions.`);
4087 return vnode;
4088 }
4089 const instance = internalInstance.proxy;
4090 const bindings = vnode.dirs || (vnode.dirs = []);
4091 for (let i = 0; i < directives.length; i++) {
4092 let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4093 if (isFunction(dir)) {
4094 dir = {
4095 mounted: dir,
4096 updated: dir
4097 };
4098 }
4099 bindings.push({
4100 dir,
4101 instance,
4102 value,
4103 oldValue: void 0,
4104 arg,
4105 modifiers
4106 });
4107 }
4108 return vnode;
4109}
4110function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4111 const bindings = vnode.dirs;
4112 const oldBindings = prevVNode && prevVNode.dirs;
4113 for (let i = 0; i < bindings.length; i++) {
4114 const binding = bindings[i];
4115 if (oldBindings) {
4116 binding.oldValue = oldBindings[i].value;
4117 }
4118 const hook = binding.dir[name];
4119 if (hook) {
4120 callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
4121 vnode.el,
4122 binding,
4123 vnode,
4124 prevVNode
4125 ]);
4126 }
4127 }
4128}
4129
4130function createAppContext() {
4131 return {
4132 app: null,
4133 config: {
4134 isNativeTag: NO,
4135 performance: false,
4136 globalProperties: {},
4137 optionMergeStrategies: {},
4138 isCustomElement: NO,
4139 errorHandler: undefined,
4140 warnHandler: undefined
4141 },
4142 mixins: [],
4143 components: {},
4144 directives: {},
4145 provides: Object.create(null)
4146 };
4147}
4148let uid$1 = 0;
4149function createAppAPI(render, hydrate) {
4150 return function createApp(rootComponent, rootProps = null) {
4151 if (rootProps != null && !isObject(rootProps)) {
4152 warn(`root props passed to app.mount() must be an object.`);
4153 rootProps = null;
4154 }
4155 const context = createAppContext();
4156 const installedPlugins = new Set();
4157 let isMounted = false;
4158 const app = (context.app = {
4159 _uid: uid$1++,
4160 _component: rootComponent,
4161 _props: rootProps,
4162 _container: null,
4163 _context: context,
4164 version,
4165 get config() {
4166 return context.config;
4167 },
4168 set config(v) {
4169 {
4170 warn(`app.config cannot be replaced. Modify individual options instead.`);
4171 }
4172 },
4173 use(plugin, ...options) {
4174 if (installedPlugins.has(plugin)) {
4175 warn(`Plugin has already been applied to target app.`);
4176 }
4177 else if (plugin && isFunction(plugin.install)) {
4178 installedPlugins.add(plugin);
4179 plugin.install(app, ...options);
4180 }
4181 else if (isFunction(plugin)) {
4182 installedPlugins.add(plugin);
4183 plugin(app, ...options);
4184 }
4185 else {
4186 warn(`A plugin must either be a function or an object with an "install" ` +
4187 `function.`);
4188 }
4189 return app;
4190 },
4191 mixin(mixin) {
4192 {
4193 if (!context.mixins.includes(mixin)) {
4194 context.mixins.push(mixin);
4195 // global mixin with props/emits de-optimizes props/emits
4196 // normalization caching.
4197 if (mixin.props || mixin.emits) {
4198 context.deopt = true;
4199 }
4200 }
4201 else {
4202 warn('Mixin has already been applied to target app' +
4203 (mixin.name ? `: ${mixin.name}` : ''));
4204 }
4205 }
4206 return app;
4207 },
4208 component(name, component) {
4209 {
4210 validateComponentName(name, context.config);
4211 }
4212 if (!component) {
4213 return context.components[name];
4214 }
4215 if (context.components[name]) {
4216 warn(`Component "${name}" has already been registered in target app.`);
4217 }
4218 context.components[name] = component;
4219 return app;
4220 },
4221 directive(name, directive) {
4222 {
4223 validateDirectiveName(name);
4224 }
4225 if (!directive) {
4226 return context.directives[name];
4227 }
4228 if (context.directives[name]) {
4229 warn(`Directive "${name}" has already been registered in target app.`);
4230 }
4231 context.directives[name] = directive;
4232 return app;
4233 },
4234 mount(rootContainer, isHydrate, isSVG) {
4235 if (!isMounted) {
4236 const vnode = createVNode(rootComponent, rootProps);
4237 // store app context on the root VNode.
4238 // this will be set on the root instance on initial mount.
4239 vnode.appContext = context;
4240 // HMR root reload
4241 {
4242 context.reload = () => {
4243 render(cloneVNode(vnode), rootContainer, isSVG);
4244 };
4245 }
4246 if (isHydrate && hydrate) {
4247 hydrate(vnode, rootContainer);
4248 }
4249 else {
4250 render(vnode, rootContainer, isSVG);
4251 }
4252 isMounted = true;
4253 app._container = rootContainer;
4254 rootContainer.__vue_app__ = app;
4255 {
4256 devtoolsInitApp(app, version);
4257 }
4258 return vnode.component.proxy;
4259 }
4260 else {
4261 warn(`App has already been mounted.\n` +
4262 `If you want to remount the same app, move your app creation logic ` +
4263 `into a factory function and create fresh app instances for each ` +
4264 `mount - e.g. \`const createMyApp = () => createApp(App)\``);
4265 }
4266 },
4267 unmount() {
4268 if (isMounted) {
4269 render(null, app._container);
4270 {
4271 devtoolsUnmountApp(app);
4272 }
4273 delete app._container.__vue_app__;
4274 }
4275 else {
4276 warn(`Cannot unmount an app that is not mounted.`);
4277 }
4278 },
4279 provide(key, value) {
4280 if (key in context.provides) {
4281 warn(`App already provides property with key "${String(key)}". ` +
4282 `It will be overwritten with the new value.`);
4283 }
4284 // TypeScript doesn't allow symbols as index type
4285 // https://github.com/Microsoft/TypeScript/issues/24587
4286 context.provides[key] = value;
4287 return app;
4288 }
4289 });
4290 return app;
4291 };
4292}
4293
4294let hasMismatch = false;
4295const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
4296const isComment = (node) => node.nodeType === 8 /* COMMENT */;
4297// Note: hydration is DOM-specific
4298// But we have to place it in core due to tight coupling with core - splitting
4299// it out creates a ton of unnecessary complexity.
4300// Hydration also depends on some renderer internal logic which needs to be
4301// passed in via arguments.
4302function createHydrationFunctions(rendererInternals) {
4303 const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
4304 const hydrate = (vnode, container) => {
4305 if (!container.hasChildNodes()) {
4306 warn(`Attempting to hydrate existing markup but container is empty. ` +
4307 `Performing full mount instead.`);
4308 patch(null, vnode, container);
4309 return;
4310 }
4311 hasMismatch = false;
4312 hydrateNode(container.firstChild, vnode, null, null, null);
4313 flushPostFlushCbs();
4314 if (hasMismatch && !false) {
4315 // this error should show up in production
4316 console.error(`Hydration completed but contains mismatches.`);
4317 }
4318 };
4319 const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
4320 const isFragmentStart = isComment(node) && node.data === '[';
4321 const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
4322 const { type, ref, shapeFlag } = vnode;
4323 const domType = node.nodeType;
4324 vnode.el = node;
4325 let nextNode = null;
4326 switch (type) {
4327 case Text:
4328 if (domType !== 3 /* TEXT */) {
4329 nextNode = onMismatch();
4330 }
4331 else {
4332 if (node.data !== vnode.children) {
4333 hasMismatch = true;
4334 warn(`Hydration text mismatch:` +
4335 `\n- Client: ${JSON.stringify(node.data)}` +
4336 `\n- Server: ${JSON.stringify(vnode.children)}`);
4337 node.data = vnode.children;
4338 }
4339 nextNode = nextSibling(node);
4340 }
4341 break;
4342 case Comment:
4343 if (domType !== 8 /* COMMENT */ || isFragmentStart) {
4344 nextNode = onMismatch();
4345 }
4346 else {
4347 nextNode = nextSibling(node);
4348 }
4349 break;
4350 case Static:
4351 if (domType !== 1 /* ELEMENT */) {
4352 nextNode = onMismatch();
4353 }
4354 else {
4355 // determine anchor, adopt content
4356 nextNode = node;
4357 // if the static vnode has its content stripped during build,
4358 // adopt it from the server-rendered HTML.
4359 const needToAdoptContent = !vnode.children.length;
4360 for (let i = 0; i < vnode.staticCount; i++) {
4361 if (needToAdoptContent)
4362 vnode.children += nextNode.outerHTML;
4363 if (i === vnode.staticCount - 1) {
4364 vnode.anchor = nextNode;
4365 }
4366 nextNode = nextSibling(nextNode);
4367 }
4368 return nextNode;
4369 }
4370 break;
4371 case Fragment:
4372 if (!isFragmentStart) {
4373 nextNode = onMismatch();
4374 }
4375 else {
4376 nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
4377 }
4378 break;
4379 default:
4380 if (shapeFlag & 1 /* ELEMENT */) {
4381 if (domType !== 1 /* ELEMENT */ ||
4382 vnode.type.toLowerCase() !==
4383 node.tagName.toLowerCase()) {
4384 nextNode = onMismatch();
4385 }
4386 else {
4387 nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
4388 }
4389 }
4390 else if (shapeFlag & 6 /* COMPONENT */) {
4391 // when setting up the render effect, if the initial vnode already
4392 // has .el set, the component will perform hydration instead of mount
4393 // on its sub-tree.
4394 vnode.slotScopeIds = slotScopeIds;
4395 const container = parentNode(node);
4396 const hydrateComponent = () => {
4397 mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
4398 };
4399 // async component
4400 const loadAsync = vnode.type.__asyncLoader;
4401 if (loadAsync) {
4402 loadAsync().then(hydrateComponent);
4403 }
4404 else {
4405 hydrateComponent();
4406 }
4407 // component may be async, so in the case of fragments we cannot rely
4408 // on component's rendered output to determine the end of the fragment
4409 // instead, we do a lookahead to find the end anchor node.
4410 nextNode = isFragmentStart
4411 ? locateClosingAsyncAnchor(node)
4412 : nextSibling(node);
4413 }
4414 else if (shapeFlag & 64 /* TELEPORT */) {
4415 if (domType !== 8 /* COMMENT */) {
4416 nextNode = onMismatch();
4417 }
4418 else {
4419 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
4420 }
4421 }
4422 else if (shapeFlag & 128 /* SUSPENSE */) {
4423 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
4424 }
4425 else {
4426 warn('Invalid HostVNode type:', type, `(${typeof type})`);
4427 }
4428 }
4429 if (ref != null) {
4430 setRef(ref, null, parentSuspense, vnode);
4431 }
4432 return nextNode;
4433 };
4434 const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4435 optimized = optimized || !!vnode.dynamicChildren;
4436 const { props, patchFlag, shapeFlag, dirs } = vnode;
4437 // skip props & children if this is hoisted static nodes
4438 if (patchFlag !== -1 /* HOISTED */) {
4439 if (dirs) {
4440 invokeDirectiveHook(vnode, null, parentComponent, 'created');
4441 }
4442 // props
4443 if (props) {
4444 if (!optimized ||
4445 (patchFlag & 16 /* FULL_PROPS */ ||
4446 patchFlag & 32 /* HYDRATE_EVENTS */)) {
4447 for (const key in props) {
4448 if (!isReservedProp(key) && isOn(key)) {
4449 patchProp(el, key, null, props[key]);
4450 }
4451 }
4452 }
4453 else if (props.onClick) {
4454 // Fast path for click listeners (which is most often) to avoid
4455 // iterating through props.
4456 patchProp(el, 'onClick', null, props.onClick);
4457 }
4458 }
4459 // vnode / directive hooks
4460 let vnodeHooks;
4461 if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
4462 invokeVNodeHook(vnodeHooks, parentComponent, vnode);
4463 }
4464 if (dirs) {
4465 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
4466 }
4467 if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
4468 queueEffectWithSuspense(() => {
4469 vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
4470 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
4471 }, parentSuspense);
4472 }
4473 // children
4474 if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
4475 // skip if element has innerHTML / textContent
4476 !(props && (props.innerHTML || props.textContent))) {
4477 let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
4478 let hasWarned = false;
4479 while (next) {
4480 hasMismatch = true;
4481 if (!hasWarned) {
4482 warn(`Hydration children mismatch in <${vnode.type}>: ` +
4483 `server rendered element contains more child nodes than client vdom.`);
4484 hasWarned = true;
4485 }
4486 // The SSRed DOM contains more nodes than it should. Remove them.
4487 const cur = next;
4488 next = next.nextSibling;
4489 remove(cur);
4490 }
4491 }
4492 else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
4493 if (el.textContent !== vnode.children) {
4494 hasMismatch = true;
4495 warn(`Hydration text content mismatch in <${vnode.type}>:\n` +
4496 `- Client: ${el.textContent}\n` +
4497 `- Server: ${vnode.children}`);
4498 el.textContent = vnode.children;
4499 }
4500 }
4501 }
4502 return el.nextSibling;
4503 };
4504 const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4505 optimized = optimized || !!parentVNode.dynamicChildren;
4506 const children = parentVNode.children;
4507 const l = children.length;
4508 let hasWarned = false;
4509 for (let i = 0; i < l; i++) {
4510 const vnode = optimized
4511 ? children[i]
4512 : (children[i] = normalizeVNode(children[i]));
4513 if (node) {
4514 node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
4515 }
4516 else if (vnode.type === Text && !vnode.children) {
4517 continue;
4518 }
4519 else {
4520 hasMismatch = true;
4521 if (!hasWarned) {
4522 warn(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
4523 `server rendered element contains fewer child nodes than client vdom.`);
4524 hasWarned = true;
4525 }
4526 // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
4527 patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
4528 }
4529 }
4530 return node;
4531 };
4532 const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4533 const { slotScopeIds: fragmentSlotScopeIds } = vnode;
4534 if (fragmentSlotScopeIds) {
4535 slotScopeIds = slotScopeIds
4536 ? slotScopeIds.concat(fragmentSlotScopeIds)
4537 : fragmentSlotScopeIds;
4538 }
4539 const container = parentNode(node);
4540 const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
4541 if (next && isComment(next) && next.data === ']') {
4542 return nextSibling((vnode.anchor = next));
4543 }
4544 else {
4545 // fragment didn't hydrate successfully, since we didn't get a end anchor
4546 // back. This should have led to node/children mismatch warnings.
4547 hasMismatch = true;
4548 // since the anchor is missing, we need to create one and insert it
4549 insert((vnode.anchor = createComment(`]`)), container, next);
4550 return next;
4551 }
4552 };
4553 const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
4554 hasMismatch = true;
4555 warn(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
4556 ? `(text)`
4557 : isComment(node) && node.data === '['
4558 ? `(start of fragment)`
4559 : ``);
4560 vnode.el = null;
4561 if (isFragment) {
4562 // remove excessive fragment nodes
4563 const end = locateClosingAsyncAnchor(node);
4564 while (true) {
4565 const next = nextSibling(node);
4566 if (next && next !== end) {
4567 remove(next);
4568 }
4569 else {
4570 break;
4571 }
4572 }
4573 }
4574 const next = nextSibling(node);
4575 const container = parentNode(node);
4576 remove(node);
4577 patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
4578 return next;
4579 };
4580 const locateClosingAsyncAnchor = (node) => {
4581 let match = 0;
4582 while (node) {
4583 node = nextSibling(node);
4584 if (node && isComment(node)) {
4585 if (node.data === '[')
4586 match++;
4587 if (node.data === ']') {
4588 if (match === 0) {
4589 return nextSibling(node);
4590 }
4591 else {
4592 match--;
4593 }
4594 }
4595 }
4596 }
4597 return node;
4598 };
4599 return [hydrate, hydrateNode];
4600}
4601
4602let supported;
4603let perf;
4604function startMeasure(instance, type) {
4605 if (instance.appContext.config.performance && isSupported()) {
4606 perf.mark(`vue-${type}-${instance.uid}`);
4607 }
4608}
4609function endMeasure(instance, type) {
4610 if (instance.appContext.config.performance && isSupported()) {
4611 const startTag = `vue-${type}-${instance.uid}`;
4612 const endTag = startTag + `:end`;
4613 perf.mark(endTag);
4614 perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
4615 perf.clearMarks(startTag);
4616 perf.clearMarks(endTag);
4617 }
4618}
4619function isSupported() {
4620 if (supported !== undefined) {
4621 return supported;
4622 }
4623 /* eslint-disable no-restricted-globals */
4624 if (typeof window !== 'undefined' && window.performance) {
4625 supported = true;
4626 perf = window.performance;
4627 }
4628 else {
4629 supported = false;
4630 }
4631 /* eslint-enable no-restricted-globals */
4632 return supported;
4633}
4634
4635// implementation, close to no-op
4636function defineComponent(options) {
4637 return isFunction(options) ? { setup: options, name: options.name } : options;
4638}
4639
4640const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
4641function defineAsyncComponent(source) {
4642 if (isFunction(source)) {
4643 source = { loader: source };
4644 }
4645 const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
4646 suspensible = true, onError: userOnError } = source;
4647 let pendingRequest = null;
4648 let resolvedComp;
4649 let retries = 0;
4650 const retry = () => {
4651 retries++;
4652 pendingRequest = null;
4653 return load();
4654 };
4655 const load = () => {
4656 let thisRequest;
4657 return (pendingRequest ||
4658 (thisRequest = pendingRequest = loader()
4659 .catch(err => {
4660 err = err instanceof Error ? err : new Error(String(err));
4661 if (userOnError) {
4662 return new Promise((resolve, reject) => {
4663 const userRetry = () => resolve(retry());
4664 const userFail = () => reject(err);
4665 userOnError(err, userRetry, userFail, retries + 1);
4666 });
4667 }
4668 else {
4669 throw err;
4670 }
4671 })
4672 .then((comp) => {
4673 if (thisRequest !== pendingRequest && pendingRequest) {
4674 return pendingRequest;
4675 }
4676 if (!comp) {
4677 warn(`Async component loader resolved to undefined. ` +
4678 `If you are using retry(), make sure to return its return value.`);
4679 }
4680 // interop module default
4681 if (comp &&
4682 (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
4683 comp = comp.default;
4684 }
4685 if (comp && !isObject(comp) && !isFunction(comp)) {
4686 throw new Error(`Invalid async component load result: ${comp}`);
4687 }
4688 resolvedComp = comp;
4689 return comp;
4690 })));
4691 };
4692 return defineComponent({
4693 __asyncLoader: load,
4694 name: 'AsyncComponentWrapper',
4695 setup() {
4696 const instance = currentInstance;
4697 // already resolved
4698 if (resolvedComp) {
4699 return () => createInnerComp(resolvedComp, instance);
4700 }
4701 const onError = (err) => {
4702 pendingRequest = null;
4703 handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
4704 };
4705 // suspense-controlled or SSR.
4706 if ((suspensible && instance.suspense) ||
4707 (false )) {
4708 return load()
4709 .then(comp => {
4710 return () => createInnerComp(comp, instance);
4711 })
4712 .catch(err => {
4713 onError(err);
4714 return () => errorComponent
4715 ? createVNode(errorComponent, {
4716 error: err
4717 })
4718 : null;
4719 });
4720 }
4721 const loaded = ref(false);
4722 const error = ref();
4723 const delayed = ref(!!delay);
4724 if (delay) {
4725 setTimeout(() => {
4726 delayed.value = false;
4727 }, delay);
4728 }
4729 if (timeout != null) {
4730 setTimeout(() => {
4731 if (!loaded.value && !error.value) {
4732 const err = new Error(`Async component timed out after ${timeout}ms.`);
4733 onError(err);
4734 error.value = err;
4735 }
4736 }, timeout);
4737 }
4738 load()
4739 .then(() => {
4740 loaded.value = true;
4741 })
4742 .catch(err => {
4743 onError(err);
4744 error.value = err;
4745 });
4746 return () => {
4747 if (loaded.value && resolvedComp) {
4748 return createInnerComp(resolvedComp, instance);
4749 }
4750 else if (error.value && errorComponent) {
4751 return createVNode(errorComponent, {
4752 error: error.value
4753 });
4754 }
4755 else if (loadingComponent && !delayed.value) {
4756 return createVNode(loadingComponent);
4757 }
4758 };
4759 }
4760 });
4761}
4762function createInnerComp(comp, { vnode: { ref, props, children } }) {
4763 const vnode = createVNode(comp, props, children);
4764 // ensure inner component inherits the async wrapper's ref owner
4765 vnode.ref = ref;
4766 return vnode;
4767}
4768
4769function createDevEffectOptions(instance) {
4770 return {
4771 scheduler: queueJob,
4772 allowRecurse: true,
4773 onTrack: instance.rtc ? e => invokeArrayFns(instance.rtc, e) : void 0,
4774 onTrigger: instance.rtg ? e => invokeArrayFns(instance.rtg, e) : void 0
4775 };
4776}
4777const queuePostRenderEffect = queueEffectWithSuspense
4778 ;
4779const setRef = (rawRef, oldRawRef, parentSuspense, vnode) => {
4780 if (isArray(rawRef)) {
4781 rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode));
4782 return;
4783 }
4784 let value;
4785 if (!vnode) {
4786 // means unmount
4787 value = null;
4788 }
4789 else if (isAsyncWrapper(vnode)) {
4790 // when mounting async components, nothing needs to be done,
4791 // because the template ref is forwarded to inner component
4792 return;
4793 }
4794 else if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
4795 value = vnode.component.exposed || vnode.component.proxy;
4796 }
4797 else {
4798 value = vnode.el;
4799 }
4800 const { i: owner, r: ref } = rawRef;
4801 if (!owner) {
4802 warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
4803 `A vnode with ref must be created inside the render function.`);
4804 return;
4805 }
4806 const oldRef = oldRawRef && oldRawRef.r;
4807 const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
4808 const setupState = owner.setupState;
4809 // unset old ref
4810 if (oldRef != null && oldRef !== ref) {
4811 if (isString(oldRef)) {
4812 refs[oldRef] = null;
4813 if (hasOwn(setupState, oldRef)) {
4814 setupState[oldRef] = null;
4815 }
4816 }
4817 else if (isRef(oldRef)) {
4818 oldRef.value = null;
4819 }
4820 }
4821 if (isString(ref)) {
4822 const doSet = () => {
4823 refs[ref] = value;
4824 if (hasOwn(setupState, ref)) {
4825 setupState[ref] = value;
4826 }
4827 };
4828 // #1789: for non-null values, set them after render
4829 // null values means this is unmount and it should not overwrite another
4830 // ref with the same key
4831 if (value) {
4832 doSet.id = -1;
4833 queuePostRenderEffect(doSet, parentSuspense);
4834 }
4835 else {
4836 doSet();
4837 }
4838 }
4839 else if (isRef(ref)) {
4840 const doSet = () => {
4841 ref.value = value;
4842 };
4843 if (value) {
4844 doSet.id = -1;
4845 queuePostRenderEffect(doSet, parentSuspense);
4846 }
4847 else {
4848 doSet();
4849 }
4850 }
4851 else if (isFunction(ref)) {
4852 callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
4853 }
4854 else {
4855 warn('Invalid template ref type:', value, `(${typeof value})`);
4856 }
4857};
4858/**
4859 * The createRenderer function accepts two generic arguments:
4860 * HostNode and HostElement, corresponding to Node and Element types in the
4861 * host environment. For example, for runtime-dom, HostNode would be the DOM
4862 * `Node` interface and HostElement would be the DOM `Element` interface.
4863 *
4864 * Custom renderers can pass in the platform specific types like this:
4865 *
4866 * ``` js
4867 * const { render, createApp } = createRenderer<Node, Element>({
4868 * patchProp,
4869 * ...nodeOps
4870 * })
4871 * ```
4872 */
4873function createRenderer(options) {
4874 return baseCreateRenderer(options);
4875}
4876// Separate API for creating hydration-enabled renderer.
4877// Hydration logic is only used when calling this function, making it
4878// tree-shakable.
4879function createHydrationRenderer(options) {
4880 return baseCreateRenderer(options, createHydrationFunctions);
4881}
4882// implementation
4883function baseCreateRenderer(options, createHydrationFns) {
4884 {
4885 const target = getGlobalThis();
4886 target.__VUE__ = true;
4887 setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__);
4888 }
4889 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;
4890 // Note: functions inside this closure should use `const xxx = () => {}`
4891 // style in order to prevent being inlined by minifiers.
4892 const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = false) => {
4893 // patching & not same type, unmount old tree
4894 if (n1 && !isSameVNodeType(n1, n2)) {
4895 anchor = getNextHostNode(n1);
4896 unmount(n1, parentComponent, parentSuspense, true);
4897 n1 = null;
4898 }
4899 if (n2.patchFlag === -2 /* BAIL */) {
4900 optimized = false;
4901 n2.dynamicChildren = null;
4902 }
4903 const { type, ref, shapeFlag } = n2;
4904 switch (type) {
4905 case Text:
4906 processText(n1, n2, container, anchor);
4907 break;
4908 case Comment:
4909 processCommentNode(n1, n2, container, anchor);
4910 break;
4911 case Static:
4912 if (n1 == null) {
4913 mountStaticNode(n2, container, anchor, isSVG);
4914 }
4915 else {
4916 patchStaticNode(n1, n2, container, isSVG);
4917 }
4918 break;
4919 case Fragment:
4920 processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
4921 break;
4922 default:
4923 if (shapeFlag & 1 /* ELEMENT */) {
4924 processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
4925 }
4926 else if (shapeFlag & 6 /* COMPONENT */) {
4927 processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
4928 }
4929 else if (shapeFlag & 64 /* TELEPORT */) {
4930 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
4931 }
4932 else if (shapeFlag & 128 /* SUSPENSE */) {
4933 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
4934 }
4935 else {
4936 warn('Invalid VNode type:', type, `(${typeof type})`);
4937 }
4938 }
4939 // set ref
4940 if (ref != null && parentComponent) {
4941 setRef(ref, n1 && n1.ref, parentSuspense, n2);
4942 }
4943 };
4944 const processText = (n1, n2, container, anchor) => {
4945 if (n1 == null) {
4946 hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
4947 }
4948 else {
4949 const el = (n2.el = n1.el);
4950 if (n2.children !== n1.children) {
4951 hostSetText(el, n2.children);
4952 }
4953 }
4954 };
4955 const processCommentNode = (n1, n2, container, anchor) => {
4956 if (n1 == null) {
4957 hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
4958 }
4959 else {
4960 // there's no support for dynamic comments
4961 n2.el = n1.el;
4962 }
4963 };
4964 const mountStaticNode = (n2, container, anchor, isSVG) => {
4965 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
4966 };
4967 /**
4968 * Dev / HMR only
4969 */
4970 const patchStaticNode = (n1, n2, container, isSVG) => {
4971 // static nodes are only patched during dev for HMR
4972 if (n2.children !== n1.children) {
4973 const anchor = hostNextSibling(n1.anchor);
4974 // remove existing
4975 removeStaticNode(n1);
4976 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
4977 }
4978 else {
4979 n2.el = n1.el;
4980 n2.anchor = n1.anchor;
4981 }
4982 };
4983 const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
4984 let next;
4985 while (el && el !== anchor) {
4986 next = hostNextSibling(el);
4987 hostInsert(el, container, nextSibling);
4988 el = next;
4989 }
4990 hostInsert(anchor, container, nextSibling);
4991 };
4992 const removeStaticNode = ({ el, anchor }) => {
4993 let next;
4994 while (el && el !== anchor) {
4995 next = hostNextSibling(el);
4996 hostRemove(el);
4997 el = next;
4998 }
4999 hostRemove(anchor);
5000 };
5001 const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5002 isSVG = isSVG || n2.type === 'svg';
5003 if (n1 == null) {
5004 mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5005 }
5006 else {
5007 patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5008 }
5009 };
5010 const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5011 let el;
5012 let vnodeHook;
5013 const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
5014 {
5015 el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
5016 // mount children first, since some props may rely on child content
5017 // being already rendered, e.g. `<select value>`
5018 if (shapeFlag & 8 /* TEXT_CHILDREN */) {
5019 hostSetElementText(el, vnode.children);
5020 }
5021 else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
5022 mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized || !!vnode.dynamicChildren);
5023 }
5024 if (dirs) {
5025 invokeDirectiveHook(vnode, null, parentComponent, 'created');
5026 }
5027 // props
5028 if (props) {
5029 for (const key in props) {
5030 if (!isReservedProp(key)) {
5031 hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5032 }
5033 }
5034 if ((vnodeHook = props.onVnodeBeforeMount)) {
5035 invokeVNodeHook(vnodeHook, parentComponent, vnode);
5036 }
5037 }
5038 // scopeId
5039 setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
5040 }
5041 {
5042 Object.defineProperty(el, '__vnode', {
5043 value: vnode,
5044 enumerable: false
5045 });
5046 Object.defineProperty(el, '__vueParentComponent', {
5047 value: parentComponent,
5048 enumerable: false
5049 });
5050 }
5051 if (dirs) {
5052 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
5053 }
5054 // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
5055 // #1689 For inside suspense + suspense resolved case, just call it
5056 const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
5057 transition &&
5058 !transition.persisted;
5059 if (needCallTransitionHooks) {
5060 transition.beforeEnter(el);
5061 }
5062 hostInsert(el, container, anchor);
5063 if ((vnodeHook = props && props.onVnodeMounted) ||
5064 needCallTransitionHooks ||
5065 dirs) {
5066 queuePostRenderEffect(() => {
5067 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
5068 needCallTransitionHooks && transition.enter(el);
5069 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
5070 }, parentSuspense);
5071 }
5072 };
5073 const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
5074 if (scopeId) {
5075 hostSetScopeId(el, scopeId);
5076 }
5077 if (slotScopeIds) {
5078 for (let i = 0; i < slotScopeIds.length; i++) {
5079 hostSetScopeId(el, slotScopeIds[i]);
5080 }
5081 }
5082 if (parentComponent) {
5083 let subTree = parentComponent.subTree;
5084 if (subTree.patchFlag > 0 &&
5085 subTree.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
5086 subTree =
5087 filterSingleRoot(subTree.children) || subTree;
5088 }
5089 if (vnode === subTree) {
5090 const parentVNode = parentComponent.vnode;
5091 setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
5092 }
5093 }
5094 };
5095 const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, optimized, slotScopeIds, start = 0) => {
5096 for (let i = start; i < children.length; i++) {
5097 const child = (children[i] = optimized
5098 ? cloneIfMounted(children[i])
5099 : normalizeVNode(children[i]));
5100 patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, optimized, slotScopeIds);
5101 }
5102 };
5103 const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5104 const el = (n2.el = n1.el);
5105 let { patchFlag, dynamicChildren, dirs } = n2;
5106 // #1426 take the old vnode's patch flag into account since user may clone a
5107 // compiler-generated vnode, which de-opts to FULL_PROPS
5108 patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
5109 const oldProps = n1.props || EMPTY_OBJ;
5110 const newProps = n2.props || EMPTY_OBJ;
5111 let vnodeHook;
5112 if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
5113 invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
5114 }
5115 if (dirs) {
5116 invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
5117 }
5118 if (isHmrUpdating) {
5119 // HMR updated, force full diff
5120 patchFlag = 0;
5121 optimized = false;
5122 dynamicChildren = null;
5123 }
5124 if (patchFlag > 0) {
5125 // the presence of a patchFlag means this element's render code was
5126 // generated by the compiler and can take the fast path.
5127 // in this path old node and new node are guaranteed to have the same shape
5128 // (i.e. at the exact same position in the source template)
5129 if (patchFlag & 16 /* FULL_PROPS */) {
5130 // element props contain dynamic keys, full diff needed
5131 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
5132 }
5133 else {
5134 // class
5135 // this flag is matched when the element has dynamic class bindings.
5136 if (patchFlag & 2 /* CLASS */) {
5137 if (oldProps.class !== newProps.class) {
5138 hostPatchProp(el, 'class', null, newProps.class, isSVG);
5139 }
5140 }
5141 // style
5142 // this flag is matched when the element has dynamic style bindings
5143 if (patchFlag & 4 /* STYLE */) {
5144 hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
5145 }
5146 // props
5147 // This flag is matched when the element has dynamic prop/attr bindings
5148 // other than class and style. The keys of dynamic prop/attrs are saved for
5149 // faster iteration.
5150 // Note dynamic keys like :[foo]="bar" will cause this optimization to
5151 // bail out and go through a full diff because we need to unset the old key
5152 if (patchFlag & 8 /* PROPS */) {
5153 // if the flag is present then dynamicProps must be non-null
5154 const propsToUpdate = n2.dynamicProps;
5155 for (let i = 0; i < propsToUpdate.length; i++) {
5156 const key = propsToUpdate[i];
5157 const prev = oldProps[key];
5158 const next = newProps[key];
5159 if (next !== prev ||
5160 (hostForcePatchProp && hostForcePatchProp(el, key))) {
5161 hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
5162 }
5163 }
5164 }
5165 }
5166 // text
5167 // This flag is matched when the element has only dynamic text children.
5168 if (patchFlag & 1 /* TEXT */) {
5169 if (n1.children !== n2.children) {
5170 hostSetElementText(el, n2.children);
5171 }
5172 }
5173 }
5174 else if (!optimized && dynamicChildren == null) {
5175 // unoptimized, full diff
5176 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
5177 }
5178 const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
5179 if (dynamicChildren) {
5180 patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
5181 if (parentComponent && parentComponent.type.__hmrId) {
5182 traverseStaticChildren(n1, n2);
5183 }
5184 }
5185 else if (!optimized) {
5186 // full diff
5187 patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
5188 }
5189 if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
5190 queuePostRenderEffect(() => {
5191 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
5192 dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
5193 }, parentSuspense);
5194 }
5195 };
5196 // The fast path for blocks.
5197 const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
5198 for (let i = 0; i < newChildren.length; i++) {
5199 const oldVNode = oldChildren[i];
5200 const newVNode = newChildren[i];
5201 // Determine the container (parent element) for the patch.
5202 const container =
5203 // - In the case of a Fragment, we need to provide the actual parent
5204 // of the Fragment itself so it can move its children.
5205 oldVNode.type === Fragment ||
5206 // - In the case of different nodes, there is going to be a replacement
5207 // which also requires the correct parent container
5208 !isSameVNodeType(oldVNode, newVNode) ||
5209 // - In the case of a component, it could contain anything.
5210 oldVNode.shapeFlag & 6 /* COMPONENT */ ||
5211 oldVNode.shapeFlag & 64 /* TELEPORT */
5212 ? hostParentNode(oldVNode.el)
5213 : // In other cases, the parent container is not actually used so we
5214 // just pass the block element here to avoid a DOM parentNode call.
5215 fallbackContainer;
5216 patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
5217 }
5218 };
5219 const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
5220 if (oldProps !== newProps) {
5221 for (const key in newProps) {
5222 // empty string is not valid prop
5223 if (isReservedProp(key))
5224 continue;
5225 const next = newProps[key];
5226 const prev = oldProps[key];
5227 if (next !== prev ||
5228 (hostForcePatchProp && hostForcePatchProp(el, key))) {
5229 hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5230 }
5231 }
5232 if (oldProps !== EMPTY_OBJ) {
5233 for (const key in oldProps) {
5234 if (!isReservedProp(key) && !(key in newProps)) {
5235 hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5236 }
5237 }
5238 }
5239 }
5240 };
5241 const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5242 const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
5243 const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
5244 let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
5245 if (patchFlag > 0) {
5246 optimized = true;
5247 }
5248 // check if this is a slot fragment with :slotted scope ids
5249 if (fragmentSlotScopeIds) {
5250 slotScopeIds = slotScopeIds
5251 ? slotScopeIds.concat(fragmentSlotScopeIds)
5252 : fragmentSlotScopeIds;
5253 }
5254 if (isHmrUpdating) {
5255 // HMR updated, force full diff
5256 patchFlag = 0;
5257 optimized = false;
5258 dynamicChildren = null;
5259 }
5260 if (n1 == null) {
5261 hostInsert(fragmentStartAnchor, container, anchor);
5262 hostInsert(fragmentEndAnchor, container, anchor);
5263 // a fragment can only have array children
5264 // since they are either generated by the compiler, or implicitly created
5265 // from arrays.
5266 mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5267 }
5268 else {
5269 if (patchFlag > 0 &&
5270 patchFlag & 64 /* STABLE_FRAGMENT */ &&
5271 dynamicChildren &&
5272 // #2715 the previous fragment could've been a BAILed one as a result
5273 // of renderSlot() with no valid children
5274 n1.dynamicChildren) {
5275 // a stable fragment (template root or <template v-for>) doesn't need to
5276 // patch children order, but it may contain dynamicChildren.
5277 patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
5278 if (parentComponent && parentComponent.type.__hmrId) {
5279 traverseStaticChildren(n1, n2);
5280 }
5281 else if (
5282 // #2080 if the stable fragment has a key, it's a <template v-for> that may
5283 // get moved around. Make sure all root level vnodes inherit el.
5284 // #2134 or if it's a component root, it may also get moved around
5285 // as the component is being moved.
5286 n2.key != null ||
5287 (parentComponent && n2 === parentComponent.subTree)) {
5288 traverseStaticChildren(n1, n2, true /* shallow */);
5289 }
5290 }
5291 else {
5292 // keyed / unkeyed, or manual fragments.
5293 // for keyed & unkeyed, since they are compiler generated from v-for,
5294 // each child is guaranteed to be a block so the fragment will never
5295 // have dynamicChildren.
5296 patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5297 }
5298 }
5299 };
5300 const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5301 n2.slotScopeIds = slotScopeIds;
5302 if (n1 == null) {
5303 if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
5304 parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
5305 }
5306 else {
5307 mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
5308 }
5309 }
5310 else {
5311 updateComponent(n1, n2, optimized);
5312 }
5313 };
5314 const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
5315 const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
5316 if (instance.type.__hmrId) {
5317 registerHMR(instance);
5318 }
5319 {
5320 pushWarningContext(initialVNode);
5321 startMeasure(instance, `mount`);
5322 }
5323 // inject renderer internals for keepAlive
5324 if (isKeepAlive(initialVNode)) {
5325 instance.ctx.renderer = internals;
5326 }
5327 // resolve props and slots for setup context
5328 {
5329 startMeasure(instance, `init`);
5330 }
5331 setupComponent(instance);
5332 {
5333 endMeasure(instance, `init`);
5334 }
5335 // setup() is async. This component relies on async logic to be resolved
5336 // before proceeding
5337 if (instance.asyncDep) {
5338 parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
5339 // Give it a placeholder if this is not hydration
5340 // TODO handle self-defined fallback
5341 if (!initialVNode.el) {
5342 const placeholder = (instance.subTree = createVNode(Comment));
5343 processCommentNode(null, placeholder, container, anchor);
5344 }
5345 return;
5346 }
5347 setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
5348 {
5349 popWarningContext();
5350 endMeasure(instance, `mount`);
5351 }
5352 };
5353 const updateComponent = (n1, n2, optimized) => {
5354 const instance = (n2.component = n1.component);
5355 if (shouldUpdateComponent(n1, n2, optimized)) {
5356 if (instance.asyncDep &&
5357 !instance.asyncResolved) {
5358 // async & still pending - just update props and slots
5359 // since the component's reactive effect for render isn't set-up yet
5360 {
5361 pushWarningContext(n2);
5362 }
5363 updateComponentPreRender(instance, n2, optimized);
5364 {
5365 popWarningContext();
5366 }
5367 return;
5368 }
5369 else {
5370 // normal update
5371 instance.next = n2;
5372 // in case the child component is also queued, remove it to avoid
5373 // double updating the same child component in the same flush.
5374 invalidateJob(instance.update);
5375 // instance.update is the reactive effect runner.
5376 instance.update();
5377 }
5378 }
5379 else {
5380 // no update needed. just copy over properties
5381 n2.component = n1.component;
5382 n2.el = n1.el;
5383 instance.vnode = n2;
5384 }
5385 };
5386 const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
5387 // create reactive effect for rendering
5388 instance.update = effect(function componentEffect() {
5389 if (!instance.isMounted) {
5390 let vnodeHook;
5391 const { el, props } = initialVNode;
5392 const { bm, m, parent } = instance;
5393 // beforeMount hook
5394 if (bm) {
5395 invokeArrayFns(bm);
5396 }
5397 // onVnodeBeforeMount
5398 if ((vnodeHook = props && props.onVnodeBeforeMount)) {
5399 invokeVNodeHook(vnodeHook, parent, initialVNode);
5400 }
5401 // render
5402 {
5403 startMeasure(instance, `render`);
5404 }
5405 const subTree = (instance.subTree = renderComponentRoot(instance));
5406 {
5407 endMeasure(instance, `render`);
5408 }
5409 if (el && hydrateNode) {
5410 {
5411 startMeasure(instance, `hydrate`);
5412 }
5413 // vnode has adopted host node - perform hydration instead of mount.
5414 hydrateNode(initialVNode.el, subTree, instance, parentSuspense, null);
5415 {
5416 endMeasure(instance, `hydrate`);
5417 }
5418 }
5419 else {
5420 {
5421 startMeasure(instance, `patch`);
5422 }
5423 patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
5424 {
5425 endMeasure(instance, `patch`);
5426 }
5427 initialVNode.el = subTree.el;
5428 }
5429 // mounted hook
5430 if (m) {
5431 queuePostRenderEffect(m, parentSuspense);
5432 }
5433 // onVnodeMounted
5434 if ((vnodeHook = props && props.onVnodeMounted)) {
5435 const scopedInitialVNode = initialVNode;
5436 queuePostRenderEffect(() => {
5437 invokeVNodeHook(vnodeHook, parent, scopedInitialVNode);
5438 }, parentSuspense);
5439 }
5440 // activated hook for keep-alive roots.
5441 // #1742 activated hook must be accessed after first render
5442 // since the hook may be injected by a child keep-alive
5443 const { a } = instance;
5444 if (a &&
5445 initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
5446 queuePostRenderEffect(a, parentSuspense);
5447 }
5448 instance.isMounted = true;
5449 {
5450 devtoolsComponentAdded(instance);
5451 }
5452 // #2458: deference mount-only object parameters to prevent memleaks
5453 initialVNode = container = anchor = null;
5454 }
5455 else {
5456 // updateComponent
5457 // This is triggered by mutation of component's own state (next: null)
5458 // OR parent calling processComponent (next: VNode)
5459 let { next, bu, u, parent, vnode } = instance;
5460 let originNext = next;
5461 let vnodeHook;
5462 {
5463 pushWarningContext(next || instance.vnode);
5464 }
5465 if (next) {
5466 next.el = vnode.el;
5467 updateComponentPreRender(instance, next, optimized);
5468 }
5469 else {
5470 next = vnode;
5471 }
5472 // beforeUpdate hook
5473 if (bu) {
5474 invokeArrayFns(bu);
5475 }
5476 // onVnodeBeforeUpdate
5477 if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
5478 invokeVNodeHook(vnodeHook, parent, next, vnode);
5479 }
5480 // render
5481 {
5482 startMeasure(instance, `render`);
5483 }
5484 const nextTree = renderComponentRoot(instance);
5485 {
5486 endMeasure(instance, `render`);
5487 }
5488 const prevTree = instance.subTree;
5489 instance.subTree = nextTree;
5490 {
5491 startMeasure(instance, `patch`);
5492 }
5493 patch(prevTree, nextTree,
5494 // parent may have changed if it's in a teleport
5495 hostParentNode(prevTree.el),
5496 // anchor may have changed if it's in a fragment
5497 getNextHostNode(prevTree), instance, parentSuspense, isSVG);
5498 {
5499 endMeasure(instance, `patch`);
5500 }
5501 next.el = nextTree.el;
5502 if (originNext === null) {
5503 // self-triggered update. In case of HOC, update parent component
5504 // vnode el. HOC is indicated by parent instance's subTree pointing
5505 // to child component's vnode
5506 updateHOCHostEl(instance, nextTree.el);
5507 }
5508 // updated hook
5509 if (u) {
5510 queuePostRenderEffect(u, parentSuspense);
5511 }
5512 // onVnodeUpdated
5513 if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
5514 queuePostRenderEffect(() => {
5515 invokeVNodeHook(vnodeHook, parent, next, vnode);
5516 }, parentSuspense);
5517 }
5518 {
5519 devtoolsComponentUpdated(instance);
5520 }
5521 {
5522 popWarningContext();
5523 }
5524 }
5525 }, createDevEffectOptions(instance) );
5526 };
5527 const updateComponentPreRender = (instance, nextVNode, optimized) => {
5528 nextVNode.component = instance;
5529 const prevProps = instance.vnode.props;
5530 instance.vnode = nextVNode;
5531 instance.next = null;
5532 updateProps(instance, nextVNode.props, prevProps, optimized);
5533 updateSlots(instance, nextVNode.children, optimized);
5534 pauseTracking();
5535 // props update may have triggered pre-flush watchers.
5536 // flush them before the render update.
5537 flushPreFlushCbs(undefined, instance.update);
5538 resetTracking();
5539 };
5540 const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
5541 const c1 = n1 && n1.children;
5542 const prevShapeFlag = n1 ? n1.shapeFlag : 0;
5543 const c2 = n2.children;
5544 const { patchFlag, shapeFlag } = n2;
5545 // fast path
5546 if (patchFlag > 0) {
5547 if (patchFlag & 128 /* KEYED_FRAGMENT */) {
5548 // this could be either fully-keyed or mixed (some keyed some not)
5549 // presence of patchFlag means children are guaranteed to be arrays
5550 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5551 return;
5552 }
5553 else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
5554 // unkeyed
5555 patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5556 return;
5557 }
5558 }
5559 // children has 3 possibilities: text, array or no children.
5560 if (shapeFlag & 8 /* TEXT_CHILDREN */) {
5561 // text children fast path
5562 if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
5563 unmountChildren(c1, parentComponent, parentSuspense);
5564 }
5565 if (c2 !== c1) {
5566 hostSetElementText(container, c2);
5567 }
5568 }
5569 else {
5570 if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
5571 // prev children was array
5572 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
5573 // two arrays, cannot assume anything, do full diff
5574 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5575 }
5576 else {
5577 // no new children, just unmount old
5578 unmountChildren(c1, parentComponent, parentSuspense, true);
5579 }
5580 }
5581 else {
5582 // prev children was text OR null
5583 // new children is array OR null
5584 if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
5585 hostSetElementText(container, '');
5586 }
5587 // mount new if array
5588 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
5589 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5590 }
5591 }
5592 }
5593 };
5594 const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5595 c1 = c1 || EMPTY_ARR;
5596 c2 = c2 || EMPTY_ARR;
5597 const oldLength = c1.length;
5598 const newLength = c2.length;
5599 const commonLength = Math.min(oldLength, newLength);
5600 let i;
5601 for (i = 0; i < commonLength; i++) {
5602 const nextChild = (c2[i] = optimized
5603 ? cloneIfMounted(c2[i])
5604 : normalizeVNode(c2[i]));
5605 patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5606 }
5607 if (oldLength > newLength) {
5608 // remove old
5609 unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
5610 }
5611 else {
5612 // mount new
5613 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
5614 }
5615 };
5616 // can be all-keyed or mixed
5617 const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5618 let i = 0;
5619 const l2 = c2.length;
5620 let e1 = c1.length - 1; // prev ending index
5621 let e2 = l2 - 1; // next ending index
5622 // 1. sync from start
5623 // (a b) c
5624 // (a b) d e
5625 while (i <= e1 && i <= e2) {
5626 const n1 = c1[i];
5627 const n2 = (c2[i] = optimized
5628 ? cloneIfMounted(c2[i])
5629 : normalizeVNode(c2[i]));
5630 if (isSameVNodeType(n1, n2)) {
5631 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5632 }
5633 else {
5634 break;
5635 }
5636 i++;
5637 }
5638 // 2. sync from end
5639 // a (b c)
5640 // d e (b c)
5641 while (i <= e1 && i <= e2) {
5642 const n1 = c1[e1];
5643 const n2 = (c2[e2] = optimized
5644 ? cloneIfMounted(c2[e2])
5645 : normalizeVNode(c2[e2]));
5646 if (isSameVNodeType(n1, n2)) {
5647 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5648 }
5649 else {
5650 break;
5651 }
5652 e1--;
5653 e2--;
5654 }
5655 // 3. common sequence + mount
5656 // (a b)
5657 // (a b) c
5658 // i = 2, e1 = 1, e2 = 2
5659 // (a b)
5660 // c (a b)
5661 // i = 0, e1 = -1, e2 = 0
5662 if (i > e1) {
5663 if (i <= e2) {
5664 const nextPos = e2 + 1;
5665 const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
5666 while (i <= e2) {
5667 patch(null, (c2[i] = optimized
5668 ? cloneIfMounted(c2[i])
5669 : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5670 i++;
5671 }
5672 }
5673 }
5674 // 4. common sequence + unmount
5675 // (a b) c
5676 // (a b)
5677 // i = 2, e1 = 2, e2 = 1
5678 // a (b c)
5679 // (b c)
5680 // i = 0, e1 = 0, e2 = -1
5681 else if (i > e2) {
5682 while (i <= e1) {
5683 unmount(c1[i], parentComponent, parentSuspense, true);
5684 i++;
5685 }
5686 }
5687 // 5. unknown sequence
5688 // [i ... e1 + 1]: a b [c d e] f g
5689 // [i ... e2 + 1]: a b [e d c h] f g
5690 // i = 2, e1 = 4, e2 = 5
5691 else {
5692 const s1 = i; // prev starting index
5693 const s2 = i; // next starting index
5694 // 5.1 build key:index map for newChildren
5695 const keyToNewIndexMap = new Map();
5696 for (i = s2; i <= e2; i++) {
5697 const nextChild = (c2[i] = optimized
5698 ? cloneIfMounted(c2[i])
5699 : normalizeVNode(c2[i]));
5700 if (nextChild.key != null) {
5701 if (keyToNewIndexMap.has(nextChild.key)) {
5702 warn(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
5703 }
5704 keyToNewIndexMap.set(nextChild.key, i);
5705 }
5706 }
5707 // 5.2 loop through old children left to be patched and try to patch
5708 // matching nodes & remove nodes that are no longer present
5709 let j;
5710 let patched = 0;
5711 const toBePatched = e2 - s2 + 1;
5712 let moved = false;
5713 // used to track whether any node has moved
5714 let maxNewIndexSoFar = 0;
5715 // works as Map<newIndex, oldIndex>
5716 // Note that oldIndex is offset by +1
5717 // and oldIndex = 0 is a special value indicating the new node has
5718 // no corresponding old node.
5719 // used for determining longest stable subsequence
5720 const newIndexToOldIndexMap = new Array(toBePatched);
5721 for (i = 0; i < toBePatched; i++)
5722 newIndexToOldIndexMap[i] = 0;
5723 for (i = s1; i <= e1; i++) {
5724 const prevChild = c1[i];
5725 if (patched >= toBePatched) {
5726 // all new children have been patched so this can only be a removal
5727 unmount(prevChild, parentComponent, parentSuspense, true);
5728 continue;
5729 }
5730 let newIndex;
5731 if (prevChild.key != null) {
5732 newIndex = keyToNewIndexMap.get(prevChild.key);
5733 }
5734 else {
5735 // key-less node, try to locate a key-less node of the same type
5736 for (j = s2; j <= e2; j++) {
5737 if (newIndexToOldIndexMap[j - s2] === 0 &&
5738 isSameVNodeType(prevChild, c2[j])) {
5739 newIndex = j;
5740 break;
5741 }
5742 }
5743 }
5744 if (newIndex === undefined) {
5745 unmount(prevChild, parentComponent, parentSuspense, true);
5746 }
5747 else {
5748 newIndexToOldIndexMap[newIndex - s2] = i + 1;
5749 if (newIndex >= maxNewIndexSoFar) {
5750 maxNewIndexSoFar = newIndex;
5751 }
5752 else {
5753 moved = true;
5754 }
5755 patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5756 patched++;
5757 }
5758 }
5759 // 5.3 move and mount
5760 // generate longest stable subsequence only when nodes have moved
5761 const increasingNewIndexSequence = moved
5762 ? getSequence(newIndexToOldIndexMap)
5763 : EMPTY_ARR;
5764 j = increasingNewIndexSequence.length - 1;
5765 // looping backwards so that we can use last patched node as anchor
5766 for (i = toBePatched - 1; i >= 0; i--) {
5767 const nextIndex = s2 + i;
5768 const nextChild = c2[nextIndex];
5769 const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
5770 if (newIndexToOldIndexMap[i] === 0) {
5771 // mount new
5772 patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5773 }
5774 else if (moved) {
5775 // move if:
5776 // There is no stable subsequence (e.g. a reverse)
5777 // OR current node is not among the stable sequence
5778 if (j < 0 || i !== increasingNewIndexSequence[j]) {
5779 move(nextChild, container, anchor, 2 /* REORDER */);
5780 }
5781 else {
5782 j--;
5783 }
5784 }
5785 }
5786 }
5787 };
5788 const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
5789 const { el, type, transition, children, shapeFlag } = vnode;
5790 if (shapeFlag & 6 /* COMPONENT */) {
5791 move(vnode.component.subTree, container, anchor, moveType);
5792 return;
5793 }
5794 if (shapeFlag & 128 /* SUSPENSE */) {
5795 vnode.suspense.move(container, anchor, moveType);
5796 return;
5797 }
5798 if (shapeFlag & 64 /* TELEPORT */) {
5799 type.move(vnode, container, anchor, internals);
5800 return;
5801 }
5802 if (type === Fragment) {
5803 hostInsert(el, container, anchor);
5804 for (let i = 0; i < children.length; i++) {
5805 move(children[i], container, anchor, moveType);
5806 }
5807 hostInsert(vnode.anchor, container, anchor);
5808 return;
5809 }
5810 if (type === Static) {
5811 moveStaticNode(vnode, container, anchor);
5812 return;
5813 }
5814 // single nodes
5815 const needTransition = moveType !== 2 /* REORDER */ &&
5816 shapeFlag & 1 /* ELEMENT */ &&
5817 transition;
5818 if (needTransition) {
5819 if (moveType === 0 /* ENTER */) {
5820 transition.beforeEnter(el);
5821 hostInsert(el, container, anchor);
5822 queuePostRenderEffect(() => transition.enter(el), parentSuspense);
5823 }
5824 else {
5825 const { leave, delayLeave, afterLeave } = transition;
5826 const remove = () => hostInsert(el, container, anchor);
5827 const performLeave = () => {
5828 leave(el, () => {
5829 remove();
5830 afterLeave && afterLeave();
5831 });
5832 };
5833 if (delayLeave) {
5834 delayLeave(el, remove, performLeave);
5835 }
5836 else {
5837 performLeave();
5838 }
5839 }
5840 }
5841 else {
5842 hostInsert(el, container, anchor);
5843 }
5844 };
5845 const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
5846 const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
5847 // unset ref
5848 if (ref != null) {
5849 setRef(ref, null, parentSuspense, null);
5850 }
5851 if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
5852 parentComponent.ctx.deactivate(vnode);
5853 return;
5854 }
5855 const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
5856 let vnodeHook;
5857 if ((vnodeHook = props && props.onVnodeBeforeUnmount)) {
5858 invokeVNodeHook(vnodeHook, parentComponent, vnode);
5859 }
5860 if (shapeFlag & 6 /* COMPONENT */) {
5861 unmountComponent(vnode.component, parentSuspense, doRemove);
5862 }
5863 else {
5864 if (shapeFlag & 128 /* SUSPENSE */) {
5865 vnode.suspense.unmount(parentSuspense, doRemove);
5866 return;
5867 }
5868 if (shouldInvokeDirs) {
5869 invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
5870 }
5871 if (shapeFlag & 64 /* TELEPORT */) {
5872 vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
5873 }
5874 else if (dynamicChildren &&
5875 // #1153: fast path should not be taken for non-stable (v-for) fragments
5876 (type !== Fragment ||
5877 (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
5878 // fast path for block nodes: only need to unmount dynamic children.
5879 unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
5880 }
5881 else if ((type === Fragment &&
5882 (patchFlag & 128 /* KEYED_FRAGMENT */ ||
5883 patchFlag & 256 /* UNKEYED_FRAGMENT */)) ||
5884 (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
5885 unmountChildren(children, parentComponent, parentSuspense);
5886 }
5887 if (doRemove) {
5888 remove(vnode);
5889 }
5890 }
5891 if ((vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
5892 queuePostRenderEffect(() => {
5893 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
5894 shouldInvokeDirs &&
5895 invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
5896 }, parentSuspense);
5897 }
5898 };
5899 const remove = vnode => {
5900 const { type, el, anchor, transition } = vnode;
5901 if (type === Fragment) {
5902 removeFragment(el, anchor);
5903 return;
5904 }
5905 if (type === Static) {
5906 removeStaticNode(vnode);
5907 return;
5908 }
5909 const performRemove = () => {
5910 hostRemove(el);
5911 if (transition && !transition.persisted && transition.afterLeave) {
5912 transition.afterLeave();
5913 }
5914 };
5915 if (vnode.shapeFlag & 1 /* ELEMENT */ &&
5916 transition &&
5917 !transition.persisted) {
5918 const { leave, delayLeave } = transition;
5919 const performLeave = () => leave(el, performRemove);
5920 if (delayLeave) {
5921 delayLeave(vnode.el, performRemove, performLeave);
5922 }
5923 else {
5924 performLeave();
5925 }
5926 }
5927 else {
5928 performRemove();
5929 }
5930 };
5931 const removeFragment = (cur, end) => {
5932 // For fragments, directly remove all contained DOM nodes.
5933 // (fragment child nodes cannot have transition)
5934 let next;
5935 while (cur !== end) {
5936 next = hostNextSibling(cur);
5937 hostRemove(cur);
5938 cur = next;
5939 }
5940 hostRemove(end);
5941 };
5942 const unmountComponent = (instance, parentSuspense, doRemove) => {
5943 if (instance.type.__hmrId) {
5944 unregisterHMR(instance);
5945 }
5946 const { bum, effects, update, subTree, um } = instance;
5947 // beforeUnmount hook
5948 if (bum) {
5949 invokeArrayFns(bum);
5950 }
5951 if (effects) {
5952 for (let i = 0; i < effects.length; i++) {
5953 stop(effects[i]);
5954 }
5955 }
5956 // update may be null if a component is unmounted before its async
5957 // setup has resolved.
5958 if (update) {
5959 stop(update);
5960 unmount(subTree, instance, parentSuspense, doRemove);
5961 }
5962 // unmounted hook
5963 if (um) {
5964 queuePostRenderEffect(um, parentSuspense);
5965 }
5966 queuePostRenderEffect(() => {
5967 instance.isUnmounted = true;
5968 }, parentSuspense);
5969 // A component with async dep inside a pending suspense is unmounted before
5970 // its async dep resolves. This should remove the dep from the suspense, and
5971 // cause the suspense to resolve immediately if that was the last dep.
5972 if (parentSuspense &&
5973 parentSuspense.pendingBranch &&
5974 !parentSuspense.isUnmounted &&
5975 instance.asyncDep &&
5976 !instance.asyncResolved &&
5977 instance.suspenseId === parentSuspense.pendingId) {
5978 parentSuspense.deps--;
5979 if (parentSuspense.deps === 0) {
5980 parentSuspense.resolve();
5981 }
5982 }
5983 {
5984 devtoolsComponentRemoved(instance);
5985 }
5986 };
5987 const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
5988 for (let i = start; i < children.length; i++) {
5989 unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
5990 }
5991 };
5992 const getNextHostNode = vnode => {
5993 if (vnode.shapeFlag & 6 /* COMPONENT */) {
5994 return getNextHostNode(vnode.component.subTree);
5995 }
5996 if (vnode.shapeFlag & 128 /* SUSPENSE */) {
5997 return vnode.suspense.next();
5998 }
5999 return hostNextSibling((vnode.anchor || vnode.el));
6000 };
6001 const render = (vnode, container, isSVG) => {
6002 if (vnode == null) {
6003 if (container._vnode) {
6004 unmount(container._vnode, null, null, true);
6005 }
6006 }
6007 else {
6008 patch(container._vnode || null, vnode, container, null, null, null, isSVG);
6009 }
6010 flushPostFlushCbs();
6011 container._vnode = vnode;
6012 };
6013 const internals = {
6014 p: patch,
6015 um: unmount,
6016 m: move,
6017 r: remove,
6018 mt: mountComponent,
6019 mc: mountChildren,
6020 pc: patchChildren,
6021 pbc: patchBlockChildren,
6022 n: getNextHostNode,
6023 o: options
6024 };
6025 let hydrate;
6026 let hydrateNode;
6027 if (createHydrationFns) {
6028 [hydrate, hydrateNode] = createHydrationFns(internals);
6029 }
6030 return {
6031 render,
6032 hydrate,
6033 createApp: createAppAPI(render, hydrate)
6034 };
6035}
6036function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
6037 callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
6038 vnode,
6039 prevVNode
6040 ]);
6041}
6042/**
6043 * #1156
6044 * When a component is HMR-enabled, we need to make sure that all static nodes
6045 * inside a block also inherit the DOM element from the previous tree so that
6046 * HMR updates (which are full updates) can retrieve the element for patching.
6047 *
6048 * #2080
6049 * Inside keyed `template` fragment static children, if a fragment is moved,
6050 * the children will always moved so that need inherit el form previous nodes
6051 * to ensure correct moved position.
6052 */
6053function traverseStaticChildren(n1, n2, shallow = false) {
6054 const ch1 = n1.children;
6055 const ch2 = n2.children;
6056 if (isArray(ch1) && isArray(ch2)) {
6057 for (let i = 0; i < ch1.length; i++) {
6058 // this is only called in the optimized path so array children are
6059 // guaranteed to be vnodes
6060 const c1 = ch1[i];
6061 let c2 = ch2[i];
6062 if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
6063 if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
6064 c2 = ch2[i] = cloneIfMounted(ch2[i]);
6065 c2.el = c1.el;
6066 }
6067 if (!shallow)
6068 traverseStaticChildren(c1, c2);
6069 }
6070 // also inherit for comment nodes, but not placeholders (e.g. v-if which
6071 // would have received .el during block patch)
6072 if (c2.type === Comment && !c2.el) {
6073 c2.el = c1.el;
6074 }
6075 }
6076 }
6077}
6078// https://en.wikipedia.org/wiki/Longest_increasing_subsequence
6079function getSequence(arr) {
6080 const p = arr.slice();
6081 const result = [0];
6082 let i, j, u, v, c;
6083 const len = arr.length;
6084 for (i = 0; i < len; i++) {
6085 const arrI = arr[i];
6086 if (arrI !== 0) {
6087 j = result[result.length - 1];
6088 if (arr[j] < arrI) {
6089 p[i] = j;
6090 result.push(i);
6091 continue;
6092 }
6093 u = 0;
6094 v = result.length - 1;
6095 while (u < v) {
6096 c = ((u + v) / 2) | 0;
6097 if (arr[result[c]] < arrI) {
6098 u = c + 1;
6099 }
6100 else {
6101 v = c;
6102 }
6103 }
6104 if (arrI < arr[result[u]]) {
6105 if (u > 0) {
6106 p[i] = result[u - 1];
6107 }
6108 result[u] = i;
6109 }
6110 }
6111 }
6112 u = result.length;
6113 v = result[u - 1];
6114 while (u-- > 0) {
6115 result[u] = v;
6116 v = p[v];
6117 }
6118 return result;
6119}
6120
6121const isTeleport = (type) => type.__isTeleport;
6122const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
6123const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
6124const resolveTarget = (props, select) => {
6125 const targetSelector = props && props.to;
6126 if (isString(targetSelector)) {
6127 if (!select) {
6128 warn(`Current renderer does not support string target for Teleports. ` +
6129 `(missing querySelector renderer option)`);
6130 return null;
6131 }
6132 else {
6133 const target = select(targetSelector);
6134 if (!target) {
6135 warn(`Failed to locate Teleport target with selector "${targetSelector}". ` +
6136 `Note the target element must exist before the component is mounted - ` +
6137 `i.e. the target cannot be rendered by the component itself, and ` +
6138 `ideally should be outside of the entire Vue component tree.`);
6139 }
6140 return target;
6141 }
6142 }
6143 else {
6144 if (!targetSelector && !isTeleportDisabled(props)) {
6145 warn(`Invalid Teleport target: ${targetSelector}`);
6146 }
6147 return targetSelector;
6148 }
6149};
6150const TeleportImpl = {
6151 __isTeleport: true,
6152 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
6153 const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
6154 const disabled = isTeleportDisabled(n2.props);
6155 const { shapeFlag, children } = n2;
6156 // #3302
6157 // HMR updated, force full diff
6158 if (isHmrUpdating) {
6159 optimized = false;
6160 n2.dynamicChildren = null;
6161 }
6162 if (n1 == null) {
6163 // insert anchors in the main view
6164 const placeholder = (n2.el = createComment('teleport start')
6165 );
6166 const mainAnchor = (n2.anchor = createComment('teleport end')
6167 );
6168 insert(placeholder, container, anchor);
6169 insert(mainAnchor, container, anchor);
6170 const target = (n2.target = resolveTarget(n2.props, querySelector));
6171 const targetAnchor = (n2.targetAnchor = createText(''));
6172 if (target) {
6173 insert(targetAnchor, target);
6174 // #2652 we could be teleporting from a non-SVG tree into an SVG tree
6175 isSVG = isSVG || isTargetSVG(target);
6176 }
6177 else if (!disabled) {
6178 warn('Invalid Teleport target on mount:', target, `(${typeof target})`);
6179 }
6180 const mount = (container, anchor) => {
6181 // Teleport *always* has Array children. This is enforced in both the
6182 // compiler and vnode children normalization.
6183 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6184 mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6185 }
6186 };
6187 if (disabled) {
6188 mount(container, mainAnchor);
6189 }
6190 else if (target) {
6191 mount(target, targetAnchor);
6192 }
6193 }
6194 else {
6195 // update content
6196 n2.el = n1.el;
6197 const mainAnchor = (n2.anchor = n1.anchor);
6198 const target = (n2.target = n1.target);
6199 const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
6200 const wasDisabled = isTeleportDisabled(n1.props);
6201 const currentContainer = wasDisabled ? container : target;
6202 const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
6203 isSVG = isSVG || isTargetSVG(target);
6204 if (n2.dynamicChildren) {
6205 // fast path when the teleport happens to be a block root
6206 patchBlockChildren(n1.dynamicChildren, n2.dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
6207 // even in block tree mode we need to make sure all root-level nodes
6208 // in the teleport inherit previous DOM references so that they can
6209 // be moved in future patches.
6210 traverseStaticChildren(n1, n2, true);
6211 }
6212 else if (!optimized) {
6213 patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
6214 }
6215 if (disabled) {
6216 if (!wasDisabled) {
6217 // enabled -> disabled
6218 // move into main container
6219 moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
6220 }
6221 }
6222 else {
6223 // target changed
6224 if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
6225 const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
6226 if (nextTarget) {
6227 moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
6228 }
6229 else {
6230 warn('Invalid Teleport target on update:', target, `(${typeof target})`);
6231 }
6232 }
6233 else if (wasDisabled) {
6234 // disabled -> enabled
6235 // move into teleport target
6236 moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
6237 }
6238 }
6239 }
6240 },
6241 remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
6242 const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
6243 if (target) {
6244 hostRemove(targetAnchor);
6245 }
6246 // an unmounted teleport should always remove its children if not disabled
6247 if (doRemove || !isTeleportDisabled(props)) {
6248 hostRemove(anchor);
6249 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6250 for (let i = 0; i < children.length; i++) {
6251 unmount(children[i], parentComponent, parentSuspense, true, optimized);
6252 }
6253 }
6254 }
6255 },
6256 move: moveTeleport,
6257 hydrate: hydrateTeleport
6258};
6259function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
6260 // move target anchor if this is a target change.
6261 if (moveType === 0 /* TARGET_CHANGE */) {
6262 insert(vnode.targetAnchor, container, parentAnchor);
6263 }
6264 const { el, anchor, shapeFlag, children, props } = vnode;
6265 const isReorder = moveType === 2 /* REORDER */;
6266 // move main view anchor if this is a re-order.
6267 if (isReorder) {
6268 insert(el, container, parentAnchor);
6269 }
6270 // if this is a re-order and teleport is enabled (content is in target)
6271 // do not move children. So the opposite is: only move children if this
6272 // is not a reorder, or the teleport is disabled
6273 if (!isReorder || isTeleportDisabled(props)) {
6274 // Teleport has either Array children or no children.
6275 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6276 for (let i = 0; i < children.length; i++) {
6277 move(children[i], container, parentAnchor, 2 /* REORDER */);
6278 }
6279 }
6280 }
6281 // move main view anchor if this is a re-order.
6282 if (isReorder) {
6283 insert(anchor, container, parentAnchor);
6284 }
6285}
6286function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
6287 const target = (vnode.target = resolveTarget(vnode.props, querySelector));
6288 if (target) {
6289 // if multiple teleports rendered to the same target element, we need to
6290 // pick up from where the last teleport finished instead of the first node
6291 const targetNode = target._lpa || target.firstChild;
6292 if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
6293 if (isTeleportDisabled(vnode.props)) {
6294 vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
6295 vnode.targetAnchor = targetNode;
6296 }
6297 else {
6298 vnode.anchor = nextSibling(node);
6299 vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
6300 }
6301 target._lpa =
6302 vnode.targetAnchor && nextSibling(vnode.targetAnchor);
6303 }
6304 }
6305 return vnode.anchor && nextSibling(vnode.anchor);
6306}
6307// Force-casted public typing for h and TSX props inference
6308const Teleport = TeleportImpl;
6309
6310const COMPONENTS = 'components';
6311const DIRECTIVES = 'directives';
6312/**
6313 * @private
6314 */
6315function resolveComponent(name, maybeSelfReference) {
6316 return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
6317}
6318const NULL_DYNAMIC_COMPONENT = Symbol();
6319/**
6320 * @private
6321 */
6322function resolveDynamicComponent(component) {
6323 if (isString(component)) {
6324 return resolveAsset(COMPONENTS, component, false) || component;
6325 }
6326 else {
6327 // invalid types will fallthrough to createVNode and raise warning
6328 return (component || NULL_DYNAMIC_COMPONENT);
6329 }
6330}
6331/**
6332 * @private
6333 */
6334function resolveDirective(name) {
6335 return resolveAsset(DIRECTIVES, name);
6336}
6337// implementation
6338function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
6339 const instance = currentRenderingInstance || currentInstance;
6340 if (instance) {
6341 const Component = instance.type;
6342 // explicit self name has highest priority
6343 if (type === COMPONENTS) {
6344 const selfName = getComponentName(Component);
6345 if (selfName &&
6346 (selfName === name ||
6347 selfName === camelize(name) ||
6348 selfName === capitalize(camelize(name)))) {
6349 return Component;
6350 }
6351 }
6352 const res =
6353 // local registration
6354 // check instance[type] first for components with mixin or extends.
6355 resolve(instance[type] || Component[type], name) ||
6356 // global registration
6357 resolve(instance.appContext[type], name);
6358 if (!res && maybeSelfReference) {
6359 // fallback to implicit self-reference
6360 return Component;
6361 }
6362 if (warnMissing && !res) {
6363 warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
6364 }
6365 return res;
6366 }
6367 else {
6368 warn(`resolve${capitalize(type.slice(0, -1))} ` +
6369 `can only be used in render() or setup().`);
6370 }
6371}
6372function resolve(registry, name) {
6373 return (registry &&
6374 (registry[name] ||
6375 registry[camelize(name)] ||
6376 registry[capitalize(camelize(name))]));
6377}
6378
6379const Fragment = Symbol('Fragment' );
6380const Text = Symbol('Text' );
6381const Comment = Symbol('Comment' );
6382const Static = Symbol('Static' );
6383// Since v-if and v-for are the two possible ways node structure can dynamically
6384// change, once we consider v-if branches and each v-for fragment a block, we
6385// can divide a template into nested blocks, and within each block the node
6386// structure would be stable. This allows us to skip most children diffing
6387// and only worry about the dynamic nodes (indicated by patch flags).
6388const blockStack = [];
6389let currentBlock = null;
6390/**
6391 * Open a block.
6392 * This must be called before `createBlock`. It cannot be part of `createBlock`
6393 * because the children of the block are evaluated before `createBlock` itself
6394 * is called. The generated code typically looks like this:
6395 *
6396 * ```js
6397 * function render() {
6398 * return (openBlock(),createBlock('div', null, [...]))
6399 * }
6400 * ```
6401 * disableTracking is true when creating a v-for fragment block, since a v-for
6402 * fragment always diffs its children.
6403 *
6404 * @private
6405 */
6406function openBlock(disableTracking = false) {
6407 blockStack.push((currentBlock = disableTracking ? null : []));
6408}
6409function closeBlock() {
6410 blockStack.pop();
6411 currentBlock = blockStack[blockStack.length - 1] || null;
6412}
6413// Whether we should be tracking dynamic child nodes inside a block.
6414// Only tracks when this value is > 0
6415// We are not using a simple boolean because this value may need to be
6416// incremented/decremented by nested usage of v-once (see below)
6417let shouldTrack$1 = 1;
6418/**
6419 * Block tracking sometimes needs to be disabled, for example during the
6420 * creation of a tree that needs to be cached by v-once. The compiler generates
6421 * code like this:
6422 *
6423 * ``` js
6424 * _cache[1] || (
6425 * setBlockTracking(-1),
6426 * _cache[1] = createVNode(...),
6427 * setBlockTracking(1),
6428 * _cache[1]
6429 * )
6430 * ```
6431 *
6432 * @private
6433 */
6434function setBlockTracking(value) {
6435 shouldTrack$1 += value;
6436}
6437/**
6438 * Create a block root vnode. Takes the same exact arguments as `createVNode`.
6439 * A block root keeps track of dynamic nodes within the block in the
6440 * `dynamicChildren` array.
6441 *
6442 * @private
6443 */
6444function createBlock(type, props, children, patchFlag, dynamicProps) {
6445 const vnode = createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */);
6446 // save current block children on the block vnode
6447 vnode.dynamicChildren = currentBlock || EMPTY_ARR;
6448 // close block
6449 closeBlock();
6450 // a block is always going to be patched, so track it as a child of its
6451 // parent block
6452 if (shouldTrack$1 > 0 && currentBlock) {
6453 currentBlock.push(vnode);
6454 }
6455 return vnode;
6456}
6457function isVNode(value) {
6458 return value ? value.__v_isVNode === true : false;
6459}
6460function isSameVNodeType(n1, n2) {
6461 if (n2.shapeFlag & 6 /* COMPONENT */ &&
6462 hmrDirtyComponents.has(n2.type)) {
6463 // HMR only: if the component has been hot-updated, force a reload.
6464 return false;
6465 }
6466 return n1.type === n2.type && n1.key === n2.key;
6467}
6468let vnodeArgsTransformer;
6469/**
6470 * Internal API for registering an arguments transform for createVNode
6471 * used for creating stubs in the test-utils
6472 * It is *internal* but needs to be exposed for test-utils to pick up proper
6473 * typings
6474 */
6475function transformVNodeArgs(transformer) {
6476 vnodeArgsTransformer = transformer;
6477}
6478const createVNodeWithArgsTransform = (...args) => {
6479 return _createVNode(...(vnodeArgsTransformer
6480 ? vnodeArgsTransformer(args, currentRenderingInstance)
6481 : args));
6482};
6483const InternalObjectKey = `__vInternal`;
6484const normalizeKey = ({ key }) => key != null ? key : null;
6485const normalizeRef = ({ ref }) => {
6486 return (ref != null
6487 ? isString(ref) || isRef(ref) || isFunction(ref)
6488 ? { i: currentRenderingInstance, r: ref }
6489 : ref
6490 : null);
6491};
6492const createVNode = (createVNodeWithArgsTransform
6493 );
6494function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
6495 if (!type || type === NULL_DYNAMIC_COMPONENT) {
6496 if (!type) {
6497 warn(`Invalid vnode type when creating vnode: ${type}.`);
6498 }
6499 type = Comment;
6500 }
6501 if (isVNode(type)) {
6502 // createVNode receiving an existing vnode. This happens in cases like
6503 // <component :is="vnode"/>
6504 // #2078 make sure to merge refs during the clone instead of overwriting it
6505 const cloned = cloneVNode(type, props, true /* mergeRef: true */);
6506 if (children) {
6507 normalizeChildren(cloned, children);
6508 }
6509 return cloned;
6510 }
6511 // class component normalization.
6512 if (isClassComponent(type)) {
6513 type = type.__vccOpts;
6514 }
6515 // class & style normalization.
6516 if (props) {
6517 // for reactive or proxy objects, we need to clone it to enable mutation.
6518 if (isProxy(props) || InternalObjectKey in props) {
6519 props = extend({}, props);
6520 }
6521 let { class: klass, style } = props;
6522 if (klass && !isString(klass)) {
6523 props.class = normalizeClass(klass);
6524 }
6525 if (isObject(style)) {
6526 // reactive state objects need to be cloned since they are likely to be
6527 // mutated
6528 if (isProxy(style) && !isArray(style)) {
6529 style = extend({}, style);
6530 }
6531 props.style = normalizeStyle(style);
6532 }
6533 }
6534 // encode the vnode type information into a bitmap
6535 const shapeFlag = isString(type)
6536 ? 1 /* ELEMENT */
6537 : isSuspense(type)
6538 ? 128 /* SUSPENSE */
6539 : isTeleport(type)
6540 ? 64 /* TELEPORT */
6541 : isObject(type)
6542 ? 4 /* STATEFUL_COMPONENT */
6543 : isFunction(type)
6544 ? 2 /* FUNCTIONAL_COMPONENT */
6545 : 0;
6546 if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
6547 type = toRaw(type);
6548 warn(`Vue received a Component which was made a reactive object. This can ` +
6549 `lead to unnecessary performance overhead, and should be avoided by ` +
6550 `marking the component with \`markRaw\` or using \`shallowRef\` ` +
6551 `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
6552 }
6553 const vnode = {
6554 __v_isVNode: true,
6555 ["__v_skip" /* SKIP */]: true,
6556 type,
6557 props,
6558 key: props && normalizeKey(props),
6559 ref: props && normalizeRef(props),
6560 scopeId: currentScopeId,
6561 slotScopeIds: null,
6562 children: null,
6563 component: null,
6564 suspense: null,
6565 ssContent: null,
6566 ssFallback: null,
6567 dirs: null,
6568 transition: null,
6569 el: null,
6570 anchor: null,
6571 target: null,
6572 targetAnchor: null,
6573 staticCount: 0,
6574 shapeFlag,
6575 patchFlag,
6576 dynamicProps,
6577 dynamicChildren: null,
6578 appContext: null
6579 };
6580 // validate key
6581 if (vnode.key !== vnode.key) {
6582 warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
6583 }
6584 normalizeChildren(vnode, children);
6585 // normalize suspense children
6586 if (shapeFlag & 128 /* SUSPENSE */) {
6587 const { content, fallback } = normalizeSuspenseChildren(vnode);
6588 vnode.ssContent = content;
6589 vnode.ssFallback = fallback;
6590 }
6591 if (shouldTrack$1 > 0 &&
6592 // avoid a block node from tracking itself
6593 !isBlockNode &&
6594 // has current parent block
6595 currentBlock &&
6596 // presence of a patch flag indicates this node needs patching on updates.
6597 // component nodes also should always be patched, because even if the
6598 // component doesn't need to update, it needs to persist the instance on to
6599 // the next vnode so that it can be properly unmounted later.
6600 (patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
6601 // the EVENTS flag is only for hydration and if it is the only flag, the
6602 // vnode should not be considered dynamic due to handler caching.
6603 patchFlag !== 32 /* HYDRATE_EVENTS */) {
6604 currentBlock.push(vnode);
6605 }
6606 return vnode;
6607}
6608function cloneVNode(vnode, extraProps, mergeRef = false) {
6609 // This is intentionally NOT using spread or extend to avoid the runtime
6610 // key enumeration cost.
6611 const { props, ref, patchFlag, children } = vnode;
6612 const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
6613 return {
6614 __v_isVNode: true,
6615 ["__v_skip" /* SKIP */]: true,
6616 type: vnode.type,
6617 props: mergedProps,
6618 key: mergedProps && normalizeKey(mergedProps),
6619 ref: extraProps && extraProps.ref
6620 ? // #2078 in the case of <component :is="vnode" ref="extra"/>
6621 // if the vnode itself already has a ref, cloneVNode will need to merge
6622 // the refs so the single vnode can be set on multiple refs
6623 mergeRef && ref
6624 ? isArray(ref)
6625 ? ref.concat(normalizeRef(extraProps))
6626 : [ref, normalizeRef(extraProps)]
6627 : normalizeRef(extraProps)
6628 : ref,
6629 scopeId: vnode.scopeId,
6630 slotScopeIds: vnode.slotScopeIds,
6631 children: patchFlag === -1 /* HOISTED */ && isArray(children)
6632 ? children.map(deepCloneVNode)
6633 : children,
6634 target: vnode.target,
6635 targetAnchor: vnode.targetAnchor,
6636 staticCount: vnode.staticCount,
6637 shapeFlag: vnode.shapeFlag,
6638 // if the vnode is cloned with extra props, we can no longer assume its
6639 // existing patch flag to be reliable and need to add the FULL_PROPS flag.
6640 // note: perserve flag for fragments since they use the flag for children
6641 // fast paths only.
6642 patchFlag: extraProps && vnode.type !== Fragment
6643 ? patchFlag === -1 // hoisted node
6644 ? 16 /* FULL_PROPS */
6645 : patchFlag | 16 /* FULL_PROPS */
6646 : patchFlag,
6647 dynamicProps: vnode.dynamicProps,
6648 dynamicChildren: vnode.dynamicChildren,
6649 appContext: vnode.appContext,
6650 dirs: vnode.dirs,
6651 transition: vnode.transition,
6652 // These should technically only be non-null on mounted VNodes. However,
6653 // they *should* be copied for kept-alive vnodes. So we just always copy
6654 // them since them being non-null during a mount doesn't affect the logic as
6655 // they will simply be overwritten.
6656 component: vnode.component,
6657 suspense: vnode.suspense,
6658 ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
6659 ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
6660 el: vnode.el,
6661 anchor: vnode.anchor
6662 };
6663}
6664/**
6665 * Dev only, for HMR of hoisted vnodes reused in v-for
6666 * https://github.com/vitejs/vite/issues/2022
6667 */
6668function deepCloneVNode(vnode) {
6669 const cloned = cloneVNode(vnode);
6670 if (isArray(vnode.children)) {
6671 cloned.children = vnode.children.map(deepCloneVNode);
6672 }
6673 return cloned;
6674}
6675/**
6676 * @private
6677 */
6678function createTextVNode(text = ' ', flag = 0) {
6679 return createVNode(Text, null, text, flag);
6680}
6681/**
6682 * @private
6683 */
6684function createStaticVNode(content, numberOfNodes) {
6685 // A static vnode can contain multiple stringified elements, and the number
6686 // of elements is necessary for hydration.
6687 const vnode = createVNode(Static, null, content);
6688 vnode.staticCount = numberOfNodes;
6689 return vnode;
6690}
6691/**
6692 * @private
6693 */
6694function createCommentVNode(text = '',
6695// when used as the v-else branch, the comment node must be created as a
6696// block to ensure correct updates.
6697asBlock = false) {
6698 return asBlock
6699 ? (openBlock(), createBlock(Comment, null, text))
6700 : createVNode(Comment, null, text);
6701}
6702function normalizeVNode(child) {
6703 if (child == null || typeof child === 'boolean') {
6704 // empty placeholder
6705 return createVNode(Comment);
6706 }
6707 else if (isArray(child)) {
6708 // fragment
6709 return createVNode(Fragment, null, child);
6710 }
6711 else if (typeof child === 'object') {
6712 // already vnode, this should be the most common since compiled templates
6713 // always produce all-vnode children arrays
6714 return child.el === null ? child : cloneVNode(child);
6715 }
6716 else {
6717 // strings and numbers
6718 return createVNode(Text, null, String(child));
6719 }
6720}
6721// optimized normalization for template-compiled render fns
6722function cloneIfMounted(child) {
6723 return child.el === null ? child : cloneVNode(child);
6724}
6725function normalizeChildren(vnode, children) {
6726 let type = 0;
6727 const { shapeFlag } = vnode;
6728 if (children == null) {
6729 children = null;
6730 }
6731 else if (isArray(children)) {
6732 type = 16 /* ARRAY_CHILDREN */;
6733 }
6734 else if (typeof children === 'object') {
6735 if (shapeFlag & 1 /* ELEMENT */ || shapeFlag & 64 /* TELEPORT */) {
6736 // Normalize slot to plain children for plain element and Teleport
6737 const slot = children.default;
6738 if (slot) {
6739 // _c marker is added by withCtx() indicating this is a compiled slot
6740 slot._c && setCompiledSlotRendering(1);
6741 normalizeChildren(vnode, slot());
6742 slot._c && setCompiledSlotRendering(-1);
6743 }
6744 return;
6745 }
6746 else {
6747 type = 32 /* SLOTS_CHILDREN */;
6748 const slotFlag = children._;
6749 if (!slotFlag && !(InternalObjectKey in children)) {
6750 children._ctx = currentRenderingInstance;
6751 }
6752 else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
6753 // a child component receives forwarded slots from the parent.
6754 // its slot type is determined by its parent's slot type.
6755 if (currentRenderingInstance.vnode.patchFlag & 1024 /* DYNAMIC_SLOTS */) {
6756 children._ = 2 /* DYNAMIC */;
6757 vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
6758 }
6759 else {
6760 children._ = 1 /* STABLE */;
6761 }
6762 }
6763 }
6764 }
6765 else if (isFunction(children)) {
6766 children = { default: children, _ctx: currentRenderingInstance };
6767 type = 32 /* SLOTS_CHILDREN */;
6768 }
6769 else {
6770 children = String(children);
6771 // force teleport children to array so it can be moved around
6772 if (shapeFlag & 64 /* TELEPORT */) {
6773 type = 16 /* ARRAY_CHILDREN */;
6774 children = [createTextVNode(children)];
6775 }
6776 else {
6777 type = 8 /* TEXT_CHILDREN */;
6778 }
6779 }
6780 vnode.children = children;
6781 vnode.shapeFlag |= type;
6782}
6783function mergeProps(...args) {
6784 const ret = extend({}, args[0]);
6785 for (let i = 1; i < args.length; i++) {
6786 const toMerge = args[i];
6787 for (const key in toMerge) {
6788 if (key === 'class') {
6789 if (ret.class !== toMerge.class) {
6790 ret.class = normalizeClass([ret.class, toMerge.class]);
6791 }
6792 }
6793 else if (key === 'style') {
6794 ret.style = normalizeStyle([ret.style, toMerge.style]);
6795 }
6796 else if (isOn(key)) {
6797 const existing = ret[key];
6798 const incoming = toMerge[key];
6799 if (existing !== incoming) {
6800 ret[key] = existing
6801 ? [].concat(existing, toMerge[key])
6802 : incoming;
6803 }
6804 }
6805 else if (key !== '') {
6806 ret[key] = toMerge[key];
6807 }
6808 }
6809 }
6810 return ret;
6811}
6812
6813function provide(key, value) {
6814 if (!currentInstance) {
6815 {
6816 warn(`provide() can only be used inside setup().`);
6817 }
6818 }
6819 else {
6820 let provides = currentInstance.provides;
6821 // by default an instance inherits its parent's provides object
6822 // but when it needs to provide values of its own, it creates its
6823 // own provides object using parent provides object as prototype.
6824 // this way in `inject` we can simply look up injections from direct
6825 // parent and let the prototype chain do the work.
6826 const parentProvides = currentInstance.parent && currentInstance.parent.provides;
6827 if (parentProvides === provides) {
6828 provides = currentInstance.provides = Object.create(parentProvides);
6829 }
6830 // TS doesn't allow symbol as index type
6831 provides[key] = value;
6832 }
6833}
6834function inject(key, defaultValue, treatDefaultAsFactory = false) {
6835 // fallback to `currentRenderingInstance` so that this can be called in
6836 // a functional component
6837 const instance = currentInstance || currentRenderingInstance;
6838 if (instance) {
6839 // #2400
6840 // to support `app.use` plugins,
6841 // fallback to appContext's `provides` if the intance is at root
6842 const provides = instance.parent == null
6843 ? instance.vnode.appContext && instance.vnode.appContext.provides
6844 : instance.parent.provides;
6845 if (provides && key in provides) {
6846 // TS doesn't allow symbol as index type
6847 return provides[key];
6848 }
6849 else if (arguments.length > 1) {
6850 return treatDefaultAsFactory && isFunction(defaultValue)
6851 ? defaultValue()
6852 : defaultValue;
6853 }
6854 else {
6855 warn(`injection "${String(key)}" not found.`);
6856 }
6857 }
6858 else {
6859 warn(`inject() can only be used inside setup() or functional components.`);
6860 }
6861}
6862
6863function createDuplicateChecker() {
6864 const cache = Object.create(null);
6865 return (type, key) => {
6866 if (cache[key]) {
6867 warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
6868 }
6869 else {
6870 cache[key] = type;
6871 }
6872 };
6873}
6874let shouldCacheAccess = true;
6875function applyOptions(instance, options, deferredData = [], deferredWatch = [], deferredProvide = [], asMixin = false) {
6876 const {
6877 // composition
6878 mixins, extends: extendsOptions,
6879 // state
6880 data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
6881 // assets
6882 components, directives,
6883 // lifecycle
6884 beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured,
6885 // public API
6886 expose } = options;
6887 const publicThis = instance.proxy;
6888 const ctx = instance.ctx;
6889 const globalMixins = instance.appContext.mixins;
6890 if (asMixin && render && instance.render === NOOP) {
6891 instance.render = render;
6892 }
6893 // applyOptions is called non-as-mixin once per instance
6894 if (!asMixin) {
6895 shouldCacheAccess = false;
6896 callSyncHook('beforeCreate', "bc" /* BEFORE_CREATE */, options, instance, globalMixins);
6897 shouldCacheAccess = true;
6898 // global mixins are applied first
6899 applyMixins(instance, globalMixins, deferredData, deferredWatch, deferredProvide);
6900 }
6901 // extending a base component...
6902 if (extendsOptions) {
6903 applyOptions(instance, extendsOptions, deferredData, deferredWatch, deferredProvide, true);
6904 }
6905 // local mixins
6906 if (mixins) {
6907 applyMixins(instance, mixins, deferredData, deferredWatch, deferredProvide);
6908 }
6909 const checkDuplicateProperties = createDuplicateChecker() ;
6910 {
6911 const [propsOptions] = instance.propsOptions;
6912 if (propsOptions) {
6913 for (const key in propsOptions) {
6914 checkDuplicateProperties("Props" /* PROPS */, key);
6915 }
6916 }
6917 }
6918 // options initialization order (to be consistent with Vue 2):
6919 // - props (already done outside of this function)
6920 // - inject
6921 // - methods
6922 // - data (deferred since it relies on `this` access)
6923 // - computed
6924 // - watch (deferred since it relies on `this` access)
6925 if (injectOptions) {
6926 if (isArray(injectOptions)) {
6927 for (let i = 0; i < injectOptions.length; i++) {
6928 const key = injectOptions[i];
6929 ctx[key] = inject(key);
6930 {
6931 checkDuplicateProperties("Inject" /* INJECT */, key);
6932 }
6933 }
6934 }
6935 else {
6936 for (const key in injectOptions) {
6937 const opt = injectOptions[key];
6938 if (isObject(opt)) {
6939 ctx[key] = inject(opt.from || key, opt.default, true /* treat default function as factory */);
6940 }
6941 else {
6942 ctx[key] = inject(opt);
6943 }
6944 {
6945 checkDuplicateProperties("Inject" /* INJECT */, key);
6946 }
6947 }
6948 }
6949 }
6950 if (methods) {
6951 for (const key in methods) {
6952 const methodHandler = methods[key];
6953 if (isFunction(methodHandler)) {
6954 // In dev mode, we use the `createRenderContext` function to define methods to the proxy target,
6955 // and those are read-only but reconfigurable, so it needs to be redefined here
6956 {
6957 Object.defineProperty(ctx, key, {
6958 value: methodHandler.bind(publicThis),
6959 configurable: true,
6960 enumerable: true,
6961 writable: true
6962 });
6963 }
6964 {
6965 checkDuplicateProperties("Methods" /* METHODS */, key);
6966 }
6967 }
6968 else {
6969 warn(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
6970 `Did you reference the function correctly?`);
6971 }
6972 }
6973 }
6974 if (!asMixin) {
6975 if (deferredData.length) {
6976 deferredData.forEach(dataFn => resolveData(instance, dataFn, publicThis));
6977 }
6978 if (dataOptions) {
6979 // @ts-ignore dataOptions is not fully type safe
6980 resolveData(instance, dataOptions, publicThis);
6981 }
6982 {
6983 const rawData = toRaw(instance.data);
6984 for (const key in rawData) {
6985 checkDuplicateProperties("Data" /* DATA */, key);
6986 // expose data on ctx during dev
6987 if (key[0] !== '$' && key[0] !== '_') {
6988 Object.defineProperty(ctx, key, {
6989 configurable: true,
6990 enumerable: true,
6991 get: () => rawData[key],
6992 set: NOOP
6993 });
6994 }
6995 }
6996 }
6997 }
6998 else if (dataOptions) {
6999 deferredData.push(dataOptions);
7000 }
7001 if (computedOptions) {
7002 for (const key in computedOptions) {
7003 const opt = computedOptions[key];
7004 const get = isFunction(opt)
7005 ? opt.bind(publicThis, publicThis)
7006 : isFunction(opt.get)
7007 ? opt.get.bind(publicThis, publicThis)
7008 : NOOP;
7009 if (get === NOOP) {
7010 warn(`Computed property "${key}" has no getter.`);
7011 }
7012 const set = !isFunction(opt) && isFunction(opt.set)
7013 ? opt.set.bind(publicThis)
7014 : () => {
7015 warn(`Write operation failed: computed property "${key}" is readonly.`);
7016 }
7017 ;
7018 const c = computed$1({
7019 get,
7020 set
7021 });
7022 Object.defineProperty(ctx, key, {
7023 enumerable: true,
7024 configurable: true,
7025 get: () => c.value,
7026 set: v => (c.value = v)
7027 });
7028 {
7029 checkDuplicateProperties("Computed" /* COMPUTED */, key);
7030 }
7031 }
7032 }
7033 if (watchOptions) {
7034 deferredWatch.push(watchOptions);
7035 }
7036 if (!asMixin && deferredWatch.length) {
7037 deferredWatch.forEach(watchOptions => {
7038 for (const key in watchOptions) {
7039 createWatcher(watchOptions[key], ctx, publicThis, key);
7040 }
7041 });
7042 }
7043 if (provideOptions) {
7044 deferredProvide.push(provideOptions);
7045 }
7046 if (!asMixin && deferredProvide.length) {
7047 deferredProvide.forEach(provideOptions => {
7048 const provides = isFunction(provideOptions)
7049 ? provideOptions.call(publicThis)
7050 : provideOptions;
7051 Reflect.ownKeys(provides).forEach(key => {
7052 provide(key, provides[key]);
7053 });
7054 });
7055 }
7056 // asset options.
7057 // To reduce memory usage, only components with mixins or extends will have
7058 // resolved asset registry attached to instance.
7059 if (asMixin) {
7060 if (components) {
7061 extend(instance.components ||
7062 (instance.components = extend({}, instance.type.components)), components);
7063 }
7064 if (directives) {
7065 extend(instance.directives ||
7066 (instance.directives = extend({}, instance.type.directives)), directives);
7067 }
7068 }
7069 // lifecycle options
7070 if (!asMixin) {
7071 callSyncHook('created', "c" /* CREATED */, options, instance, globalMixins);
7072 }
7073 if (beforeMount) {
7074 onBeforeMount(beforeMount.bind(publicThis));
7075 }
7076 if (mounted) {
7077 onMounted(mounted.bind(publicThis));
7078 }
7079 if (beforeUpdate) {
7080 onBeforeUpdate(beforeUpdate.bind(publicThis));
7081 }
7082 if (updated) {
7083 onUpdated(updated.bind(publicThis));
7084 }
7085 if (activated) {
7086 onActivated(activated.bind(publicThis));
7087 }
7088 if (deactivated) {
7089 onDeactivated(deactivated.bind(publicThis));
7090 }
7091 if (errorCaptured) {
7092 onErrorCaptured(errorCaptured.bind(publicThis));
7093 }
7094 if (renderTracked) {
7095 onRenderTracked(renderTracked.bind(publicThis));
7096 }
7097 if (renderTriggered) {
7098 onRenderTriggered(renderTriggered.bind(publicThis));
7099 }
7100 if (beforeDestroy) {
7101 warn(`\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`);
7102 }
7103 if (beforeUnmount) {
7104 onBeforeUnmount(beforeUnmount.bind(publicThis));
7105 }
7106 if (destroyed) {
7107 warn(`\`destroyed\` has been renamed to \`unmounted\`.`);
7108 }
7109 if (unmounted) {
7110 onUnmounted(unmounted.bind(publicThis));
7111 }
7112 if (isArray(expose)) {
7113 if (!asMixin) {
7114 if (expose.length) {
7115 const exposed = instance.exposed || (instance.exposed = proxyRefs({}));
7116 expose.forEach(key => {
7117 exposed[key] = toRef(publicThis, key);
7118 });
7119 }
7120 else if (!instance.exposed) {
7121 instance.exposed = EMPTY_OBJ;
7122 }
7123 }
7124 else {
7125 warn(`The \`expose\` option is ignored when used in mixins.`);
7126 }
7127 }
7128}
7129function callSyncHook(name, type, options, instance, globalMixins) {
7130 for (let i = 0; i < globalMixins.length; i++) {
7131 callHookWithMixinAndExtends(name, type, globalMixins[i], instance);
7132 }
7133 callHookWithMixinAndExtends(name, type, options, instance);
7134}
7135function callHookWithMixinAndExtends(name, type, options, instance) {
7136 const { extends: base, mixins } = options;
7137 const selfHook = options[name];
7138 if (base) {
7139 callHookWithMixinAndExtends(name, type, base, instance);
7140 }
7141 if (mixins) {
7142 for (let i = 0; i < mixins.length; i++) {
7143 callHookWithMixinAndExtends(name, type, mixins[i], instance);
7144 }
7145 }
7146 if (selfHook) {
7147 callWithAsyncErrorHandling(selfHook.bind(instance.proxy), instance, type);
7148 }
7149}
7150function applyMixins(instance, mixins, deferredData, deferredWatch, deferredProvide) {
7151 for (let i = 0; i < mixins.length; i++) {
7152 applyOptions(instance, mixins[i], deferredData, deferredWatch, deferredProvide, true);
7153 }
7154}
7155function resolveData(instance, dataFn, publicThis) {
7156 if (!isFunction(dataFn)) {
7157 warn(`The data option must be a function. ` +
7158 `Plain object usage is no longer supported.`);
7159 }
7160 shouldCacheAccess = false;
7161 const data = dataFn.call(publicThis, publicThis);
7162 shouldCacheAccess = true;
7163 if (isPromise(data)) {
7164 warn(`data() returned a Promise - note data() cannot be async; If you ` +
7165 `intend to perform data fetching before component renders, use ` +
7166 `async setup() + <Suspense>.`);
7167 }
7168 if (!isObject(data)) {
7169 warn(`data() should return an object.`);
7170 }
7171 else if (instance.data === EMPTY_OBJ) {
7172 instance.data = reactive(data);
7173 }
7174 else {
7175 // existing data: this is a mixin or extends.
7176 extend(instance.data, data);
7177 }
7178}
7179function createWatcher(raw, ctx, publicThis, key) {
7180 const getter = key.includes('.')
7181 ? createPathGetter(publicThis, key)
7182 : () => publicThis[key];
7183 if (isString(raw)) {
7184 const handler = ctx[raw];
7185 if (isFunction(handler)) {
7186 watch(getter, handler);
7187 }
7188 else {
7189 warn(`Invalid watch handler specified by key "${raw}"`, handler);
7190 }
7191 }
7192 else if (isFunction(raw)) {
7193 watch(getter, raw.bind(publicThis));
7194 }
7195 else if (isObject(raw)) {
7196 if (isArray(raw)) {
7197 raw.forEach(r => createWatcher(r, ctx, publicThis, key));
7198 }
7199 else {
7200 const handler = isFunction(raw.handler)
7201 ? raw.handler.bind(publicThis)
7202 : ctx[raw.handler];
7203 if (isFunction(handler)) {
7204 watch(getter, handler, raw);
7205 }
7206 else {
7207 warn(`Invalid watch handler specified by key "${raw.handler}"`, handler);
7208 }
7209 }
7210 }
7211 else {
7212 warn(`Invalid watch option: "${key}"`, raw);
7213 }
7214}
7215function createPathGetter(ctx, path) {
7216 const segments = path.split('.');
7217 return () => {
7218 let cur = ctx;
7219 for (let i = 0; i < segments.length && cur; i++) {
7220 cur = cur[segments[i]];
7221 }
7222 return cur;
7223 };
7224}
7225function resolveMergedOptions(instance) {
7226 const raw = instance.type;
7227 const { __merged, mixins, extends: extendsOptions } = raw;
7228 if (__merged)
7229 return __merged;
7230 const globalMixins = instance.appContext.mixins;
7231 if (!globalMixins.length && !mixins && !extendsOptions)
7232 return raw;
7233 const options = {};
7234 globalMixins.forEach(m => mergeOptions(options, m, instance));
7235 mergeOptions(options, raw, instance);
7236 return (raw.__merged = options);
7237}
7238function mergeOptions(to, from, instance) {
7239 const strats = instance.appContext.config.optionMergeStrategies;
7240 const { mixins, extends: extendsOptions } = from;
7241 extendsOptions && mergeOptions(to, extendsOptions, instance);
7242 mixins &&
7243 mixins.forEach((m) => mergeOptions(to, m, instance));
7244 for (const key in from) {
7245 if (strats && hasOwn(strats, key)) {
7246 to[key] = strats[key](to[key], from[key], instance.proxy, key);
7247 }
7248 else {
7249 to[key] = from[key];
7250 }
7251 }
7252}
7253
7254/**
7255 * #2437 In Vue 3, functional components do not have a public instance proxy but
7256 * they exist in the internal parent chain. For code that relies on traversing
7257 * public $parent chains, skip functional ones and go to the parent instead.
7258 */
7259const getPublicInstance = (i) => {
7260 if (!i)
7261 return null;
7262 if (isStatefulComponent(i))
7263 return i.exposed ? i.exposed : i.proxy;
7264 return getPublicInstance(i.parent);
7265};
7266const publicPropertiesMap = extend(Object.create(null), {
7267 $: i => i,
7268 $el: i => i.vnode.el,
7269 $data: i => i.data,
7270 $props: i => (shallowReadonly(i.props) ),
7271 $attrs: i => (shallowReadonly(i.attrs) ),
7272 $slots: i => (shallowReadonly(i.slots) ),
7273 $refs: i => (shallowReadonly(i.refs) ),
7274 $parent: i => getPublicInstance(i.parent),
7275 $root: i => getPublicInstance(i.root),
7276 $emit: i => i.emit,
7277 $options: i => (resolveMergedOptions(i) ),
7278 $forceUpdate: i => () => queueJob(i.update),
7279 $nextTick: i => nextTick.bind(i.proxy),
7280 $watch: i => (instanceWatch.bind(i) )
7281});
7282const PublicInstanceProxyHandlers = {
7283 get({ _: instance }, key) {
7284 const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
7285 // let @vue/reactivity know it should never observe Vue public instances.
7286 if (key === "__v_skip" /* SKIP */) {
7287 return true;
7288 }
7289 // for internal formatters to know that this is a Vue instance
7290 if (key === '__isVue') {
7291 return true;
7292 }
7293 // data / props / ctx
7294 // This getter gets called for every property access on the render context
7295 // during render and is a major hotspot. The most expensive part of this
7296 // is the multiple hasOwn() calls. It's much faster to do a simple property
7297 // access on a plain object, so we use an accessCache object (with null
7298 // prototype) to memoize what access type a key corresponds to.
7299 let normalizedProps;
7300 if (key[0] !== '$') {
7301 const n = accessCache[key];
7302 if (n !== undefined) {
7303 switch (n) {
7304 case 0 /* SETUP */:
7305 return setupState[key];
7306 case 1 /* DATA */:
7307 return data[key];
7308 case 3 /* CONTEXT */:
7309 return ctx[key];
7310 case 2 /* PROPS */:
7311 return props[key];
7312 // default: just fallthrough
7313 }
7314 }
7315 else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7316 accessCache[key] = 0 /* SETUP */;
7317 return setupState[key];
7318 }
7319 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7320 accessCache[key] = 1 /* DATA */;
7321 return data[key];
7322 }
7323 else if (
7324 // only cache other properties when instance has declared (thus stable)
7325 // props
7326 (normalizedProps = instance.propsOptions[0]) &&
7327 hasOwn(normalizedProps, key)) {
7328 accessCache[key] = 2 /* PROPS */;
7329 return props[key];
7330 }
7331 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7332 accessCache[key] = 3 /* CONTEXT */;
7333 return ctx[key];
7334 }
7335 else if (shouldCacheAccess) {
7336 accessCache[key] = 4 /* OTHER */;
7337 }
7338 }
7339 const publicGetter = publicPropertiesMap[key];
7340 let cssModule, globalProperties;
7341 // public $xxx properties
7342 if (publicGetter) {
7343 if (key === '$attrs') {
7344 track(instance, "get" /* GET */, key);
7345 markAttrsAccessed();
7346 }
7347 return publicGetter(instance);
7348 }
7349 else if (
7350 // css module (injected by vue-loader)
7351 (cssModule = type.__cssModules) &&
7352 (cssModule = cssModule[key])) {
7353 return cssModule;
7354 }
7355 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7356 // user may set custom properties to `this` that start with `$`
7357 accessCache[key] = 3 /* CONTEXT */;
7358 return ctx[key];
7359 }
7360 else if (
7361 // global properties
7362 ((globalProperties = appContext.config.globalProperties),
7363 hasOwn(globalProperties, key))) {
7364 return globalProperties[key];
7365 }
7366 else if (currentRenderingInstance &&
7367 (!isString(key) ||
7368 // #1091 avoid internal isRef/isVNode checks on component instance leading
7369 // to infinite warning loop
7370 key.indexOf('__v') !== 0)) {
7371 if (data !== EMPTY_OBJ &&
7372 (key[0] === '$' || key[0] === '_') &&
7373 hasOwn(data, key)) {
7374 warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
7375 `character ("$" or "_") and is not proxied on the render context.`);
7376 }
7377 else if (instance === currentRenderingInstance) {
7378 warn(`Property ${JSON.stringify(key)} was accessed during render ` +
7379 `but is not defined on instance.`);
7380 }
7381 }
7382 },
7383 set({ _: instance }, key, value) {
7384 const { data, setupState, ctx } = instance;
7385 if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7386 setupState[key] = value;
7387 }
7388 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7389 data[key] = value;
7390 }
7391 else if (hasOwn(instance.props, key)) {
7392 warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
7393 return false;
7394 }
7395 if (key[0] === '$' && key.slice(1) in instance) {
7396 warn(`Attempting to mutate public property "${key}". ` +
7397 `Properties starting with $ are reserved and readonly.`, instance);
7398 return false;
7399 }
7400 else {
7401 if (key in instance.appContext.config.globalProperties) {
7402 Object.defineProperty(ctx, key, {
7403 enumerable: true,
7404 configurable: true,
7405 value
7406 });
7407 }
7408 else {
7409 ctx[key] = value;
7410 }
7411 }
7412 return true;
7413 },
7414 has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7415 let normalizedProps;
7416 return (accessCache[key] !== undefined ||
7417 (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7418 (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7419 ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
7420 hasOwn(ctx, key) ||
7421 hasOwn(publicPropertiesMap, key) ||
7422 hasOwn(appContext.config.globalProperties, key));
7423 }
7424};
7425{
7426 PublicInstanceProxyHandlers.ownKeys = (target) => {
7427 warn(`Avoid app logic that relies on enumerating keys on a component instance. ` +
7428 `The keys will be empty in production mode to avoid performance overhead.`);
7429 return Reflect.ownKeys(target);
7430 };
7431}
7432const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, {
7433 get(target, key) {
7434 // fast path for unscopables when using `with` block
7435 if (key === Symbol.unscopables) {
7436 return;
7437 }
7438 return PublicInstanceProxyHandlers.get(target, key, target);
7439 },
7440 has(_, key) {
7441 const has = key[0] !== '_' && !isGloballyWhitelisted(key);
7442 if (!has && PublicInstanceProxyHandlers.has(_, key)) {
7443 warn(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
7444 }
7445 return has;
7446 }
7447});
7448// In dev mode, the proxy target exposes the same properties as seen on `this`
7449// for easier console inspection. In prod mode it will be an empty object so
7450// these properties definitions can be skipped.
7451function createRenderContext(instance) {
7452 const target = {};
7453 // expose internal instance for proxy handlers
7454 Object.defineProperty(target, `_`, {
7455 configurable: true,
7456 enumerable: false,
7457 get: () => instance
7458 });
7459 // expose public properties
7460 Object.keys(publicPropertiesMap).forEach(key => {
7461 Object.defineProperty(target, key, {
7462 configurable: true,
7463 enumerable: false,
7464 get: () => publicPropertiesMap[key](instance),
7465 // intercepted by the proxy so no need for implementation,
7466 // but needed to prevent set errors
7467 set: NOOP
7468 });
7469 });
7470 // expose global properties
7471 const { globalProperties } = instance.appContext.config;
7472 Object.keys(globalProperties).forEach(key => {
7473 Object.defineProperty(target, key, {
7474 configurable: true,
7475 enumerable: false,
7476 get: () => globalProperties[key],
7477 set: NOOP
7478 });
7479 });
7480 return target;
7481}
7482// dev only
7483function exposePropsOnRenderContext(instance) {
7484 const { ctx, propsOptions: [propsOptions] } = instance;
7485 if (propsOptions) {
7486 Object.keys(propsOptions).forEach(key => {
7487 Object.defineProperty(ctx, key, {
7488 enumerable: true,
7489 configurable: true,
7490 get: () => instance.props[key],
7491 set: NOOP
7492 });
7493 });
7494 }
7495}
7496// dev only
7497function exposeSetupStateOnRenderContext(instance) {
7498 const { ctx, setupState } = instance;
7499 Object.keys(toRaw(setupState)).forEach(key => {
7500 if (key[0] === '$' || key[0] === '_') {
7501 warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
7502 `which are reserved prefixes for Vue internals.`);
7503 return;
7504 }
7505 Object.defineProperty(ctx, key, {
7506 enumerable: true,
7507 configurable: true,
7508 get: () => setupState[key],
7509 set: NOOP
7510 });
7511 });
7512}
7513
7514const emptyAppContext = createAppContext();
7515let uid$2 = 0;
7516function createComponentInstance(vnode, parent, suspense) {
7517 const type = vnode.type;
7518 // inherit parent app context - or - if root, adopt from root vnode
7519 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
7520 const instance = {
7521 uid: uid$2++,
7522 vnode,
7523 type,
7524 parent,
7525 appContext,
7526 root: null,
7527 next: null,
7528 subTree: null,
7529 update: null,
7530 render: null,
7531 proxy: null,
7532 exposed: null,
7533 withProxy: null,
7534 effects: null,
7535 provides: parent ? parent.provides : Object.create(appContext.provides),
7536 accessCache: null,
7537 renderCache: [],
7538 // local resovled assets
7539 components: null,
7540 directives: null,
7541 // resolved props and emits options
7542 propsOptions: normalizePropsOptions(type, appContext),
7543 emitsOptions: normalizeEmitsOptions(type, appContext),
7544 // emit
7545 emit: null,
7546 emitted: null,
7547 // props default value
7548 propsDefaults: EMPTY_OBJ,
7549 // state
7550 ctx: EMPTY_OBJ,
7551 data: EMPTY_OBJ,
7552 props: EMPTY_OBJ,
7553 attrs: EMPTY_OBJ,
7554 slots: EMPTY_OBJ,
7555 refs: EMPTY_OBJ,
7556 setupState: EMPTY_OBJ,
7557 setupContext: null,
7558 // suspense related
7559 suspense,
7560 suspenseId: suspense ? suspense.pendingId : 0,
7561 asyncDep: null,
7562 asyncResolved: false,
7563 // lifecycle hooks
7564 // not using enums here because it results in computed properties
7565 isMounted: false,
7566 isUnmounted: false,
7567 isDeactivated: false,
7568 bc: null,
7569 c: null,
7570 bm: null,
7571 m: null,
7572 bu: null,
7573 u: null,
7574 um: null,
7575 bum: null,
7576 da: null,
7577 a: null,
7578 rtg: null,
7579 rtc: null,
7580 ec: null
7581 };
7582 {
7583 instance.ctx = createRenderContext(instance);
7584 }
7585 instance.root = parent ? parent.root : instance;
7586 instance.emit = emit.bind(null, instance);
7587 return instance;
7588}
7589let currentInstance = null;
7590const getCurrentInstance = () => currentInstance || currentRenderingInstance;
7591const setCurrentInstance = (instance) => {
7592 currentInstance = instance;
7593};
7594const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
7595function validateComponentName(name, config) {
7596 const appIsNativeTag = config.isNativeTag || NO;
7597 if (isBuiltInTag(name) || appIsNativeTag(name)) {
7598 warn('Do not use built-in or reserved HTML elements as component id: ' + name);
7599 }
7600}
7601function isStatefulComponent(instance) {
7602 return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
7603}
7604let isInSSRComponentSetup = false;
7605function setupComponent(instance, isSSR = false) {
7606 isInSSRComponentSetup = isSSR;
7607 const { props, children } = instance.vnode;
7608 const isStateful = isStatefulComponent(instance);
7609 initProps(instance, props, isStateful, isSSR);
7610 initSlots(instance, children);
7611 const setupResult = isStateful
7612 ? setupStatefulComponent(instance, isSSR)
7613 : undefined;
7614 isInSSRComponentSetup = false;
7615 return setupResult;
7616}
7617function setupStatefulComponent(instance, isSSR) {
7618 const Component = instance.type;
7619 {
7620 if (Component.name) {
7621 validateComponentName(Component.name, instance.appContext.config);
7622 }
7623 if (Component.components) {
7624 const names = Object.keys(Component.components);
7625 for (let i = 0; i < names.length; i++) {
7626 validateComponentName(names[i], instance.appContext.config);
7627 }
7628 }
7629 if (Component.directives) {
7630 const names = Object.keys(Component.directives);
7631 for (let i = 0; i < names.length; i++) {
7632 validateDirectiveName(names[i]);
7633 }
7634 }
7635 }
7636 // 0. create render proxy property access cache
7637 instance.accessCache = Object.create(null);
7638 // 1. create public instance / render proxy
7639 // also mark it raw so it's never observed
7640 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
7641 {
7642 exposePropsOnRenderContext(instance);
7643 }
7644 // 2. call setup()
7645 const { setup } = Component;
7646 if (setup) {
7647 const setupContext = (instance.setupContext =
7648 setup.length > 1 ? createSetupContext(instance) : null);
7649 currentInstance = instance;
7650 pauseTracking();
7651 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
7652 resetTracking();
7653 currentInstance = null;
7654 if (isPromise(setupResult)) {
7655 if (isSSR) {
7656 // return the promise so server-renderer can wait on it
7657 return setupResult
7658 .then((resolvedResult) => {
7659 handleSetupResult(instance, resolvedResult, isSSR);
7660 })
7661 .catch(e => {
7662 handleError(e, instance, 0 /* SETUP_FUNCTION */);
7663 });
7664 }
7665 else {
7666 // async setup returned Promise.
7667 // bail here and wait for re-entry.
7668 instance.asyncDep = setupResult;
7669 }
7670 }
7671 else {
7672 handleSetupResult(instance, setupResult, isSSR);
7673 }
7674 }
7675 else {
7676 finishComponentSetup(instance, isSSR);
7677 }
7678}
7679function handleSetupResult(instance, setupResult, isSSR) {
7680 if (isFunction(setupResult)) {
7681 // setup returned an inline render function
7682 {
7683 instance.render = setupResult;
7684 }
7685 }
7686 else if (isObject(setupResult)) {
7687 if (isVNode(setupResult)) {
7688 warn(`setup() should not return VNodes directly - ` +
7689 `return a render function instead.`);
7690 }
7691 // setup returned bindings.
7692 // assuming a render function compiled from template is present.
7693 {
7694 instance.devtoolsRawSetupState = setupResult;
7695 }
7696 instance.setupState = proxyRefs(setupResult);
7697 {
7698 exposeSetupStateOnRenderContext(instance);
7699 }
7700 }
7701 else if (setupResult !== undefined) {
7702 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
7703 }
7704 finishComponentSetup(instance, isSSR);
7705}
7706let compile;
7707// dev only
7708const isRuntimeOnly = () => !compile;
7709/**
7710 * For runtime-dom to register the compiler.
7711 * Note the exported method uses any to avoid d.ts relying on the compiler types.
7712 */
7713function registerRuntimeCompiler(_compile) {
7714 compile = _compile;
7715}
7716function finishComponentSetup(instance, isSSR) {
7717 const Component = instance.type;
7718 // template / render function normalization
7719 if (!instance.render) {
7720 // could be set from setup()
7721 if (compile && Component.template && !Component.render) {
7722 {
7723 startMeasure(instance, `compile`);
7724 }
7725 Component.render = compile(Component.template, {
7726 isCustomElement: instance.appContext.config.isCustomElement,
7727 delimiters: Component.delimiters
7728 });
7729 {
7730 endMeasure(instance, `compile`);
7731 }
7732 }
7733 instance.render = (Component.render || NOOP);
7734 // for runtime-compiled render functions using `with` blocks, the render
7735 // proxy used needs a different `has` handler which is more performant and
7736 // also only allows a whitelist of globals to fallthrough.
7737 if (instance.render._rc) {
7738 instance.withProxy = new Proxy(instance.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
7739 }
7740 }
7741 // support for 2.x options
7742 {
7743 currentInstance = instance;
7744 pauseTracking();
7745 applyOptions(instance, Component);
7746 resetTracking();
7747 currentInstance = null;
7748 }
7749 // warn missing template/render
7750 // the runtime compilation of template in SSR is done by server-render
7751 if (!Component.render && instance.render === NOOP && !isSSR) {
7752 /* istanbul ignore if */
7753 if (!compile && Component.template) {
7754 warn(`Component provided template option but ` +
7755 `runtime compilation is not supported in this build of Vue.` +
7756 (` Use "vue.esm-browser.js" instead.`
7757 ) /* should not happen */);
7758 }
7759 else {
7760 warn(`Component is missing template or render function.`);
7761 }
7762 }
7763}
7764const attrHandlers = {
7765 get: (target, key) => {
7766 {
7767 markAttrsAccessed();
7768 }
7769 return target[key];
7770 },
7771 set: () => {
7772 warn(`setupContext.attrs is readonly.`);
7773 return false;
7774 },
7775 deleteProperty: () => {
7776 warn(`setupContext.attrs is readonly.`);
7777 return false;
7778 }
7779};
7780function createSetupContext(instance) {
7781 const expose = exposed => {
7782 if (instance.exposed) {
7783 warn(`expose() should be called only once per setup().`);
7784 }
7785 instance.exposed = proxyRefs(exposed);
7786 };
7787 {
7788 // We use getters in dev in case libs like test-utils overwrite instance
7789 // properties (overwrites should not be done in prod)
7790 return Object.freeze({
7791 get attrs() {
7792 return new Proxy(instance.attrs, attrHandlers);
7793 },
7794 get slots() {
7795 return shallowReadonly(instance.slots);
7796 },
7797 get emit() {
7798 return (event, ...args) => instance.emit(event, ...args);
7799 },
7800 expose
7801 });
7802 }
7803}
7804// record effects created during a component's setup() so that they can be
7805// stopped when the component unmounts
7806function recordInstanceBoundEffect(effect, instance = currentInstance) {
7807 if (instance) {
7808 (instance.effects || (instance.effects = [])).push(effect);
7809 }
7810}
7811const classifyRE = /(?:^|[-_])(\w)/g;
7812const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
7813function getComponentName(Component) {
7814 return isFunction(Component)
7815 ? Component.displayName || Component.name
7816 : Component.name;
7817}
7818/* istanbul ignore next */
7819function formatComponentName(instance, Component, isRoot = false) {
7820 let name = getComponentName(Component);
7821 if (!name && Component.__file) {
7822 const match = Component.__file.match(/([^/\\]+)\.\w+$/);
7823 if (match) {
7824 name = match[1];
7825 }
7826 }
7827 if (!name && instance && instance.parent) {
7828 // try to infer the name based on reverse resolution
7829 const inferFromRegistry = (registry) => {
7830 for (const key in registry) {
7831 if (registry[key] === Component) {
7832 return key;
7833 }
7834 }
7835 };
7836 name =
7837 inferFromRegistry(instance.components ||
7838 instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
7839 }
7840 return name ? classify(name) : isRoot ? `App` : `Anonymous`;
7841}
7842function isClassComponent(value) {
7843 return isFunction(value) && '__vccOpts' in value;
7844}
7845
7846function computed$1(getterOrOptions) {
7847 const c = computed(getterOrOptions);
7848 recordInstanceBoundEffect(c.effect);
7849 return c;
7850}
7851
7852// implementation
7853function defineProps() {
7854 {
7855 warn(`defineProps() is a compiler-hint helper that is only usable inside ` +
7856 `<script setup> of a single file component. Its arguments should be ` +
7857 `compiled away and passing it at runtime has no effect.`);
7858 }
7859 return null;
7860}
7861// implementation
7862function defineEmit() {
7863 {
7864 warn(`defineEmit() is a compiler-hint helper that is only usable inside ` +
7865 `<script setup> of a single file component. Its arguments should be ` +
7866 `compiled away and passing it at runtime has no effect.`);
7867 }
7868 return null;
7869}
7870function useContext() {
7871 const i = getCurrentInstance();
7872 if (!i) {
7873 warn(`useContext() called without active instance.`);
7874 }
7875 return i.setupContext || (i.setupContext = createSetupContext(i));
7876}
7877
7878// Actual implementation
7879function h(type, propsOrChildren, children) {
7880 const l = arguments.length;
7881 if (l === 2) {
7882 if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
7883 // single vnode without props
7884 if (isVNode(propsOrChildren)) {
7885 return createVNode(type, null, [propsOrChildren]);
7886 }
7887 // props without children
7888 return createVNode(type, propsOrChildren);
7889 }
7890 else {
7891 // omit props
7892 return createVNode(type, null, propsOrChildren);
7893 }
7894 }
7895 else {
7896 if (l > 3) {
7897 children = Array.prototype.slice.call(arguments, 2);
7898 }
7899 else if (l === 3 && isVNode(children)) {
7900 children = [children];
7901 }
7902 return createVNode(type, propsOrChildren, children);
7903 }
7904}
7905
7906const ssrContextKey = Symbol(`ssrContext` );
7907const useSSRContext = () => {
7908 {
7909 const ctx = inject(ssrContextKey);
7910 if (!ctx) {
7911 warn(`Server rendering context not provided. Make sure to only call ` +
7912 `useSSRContext() conditionally in the server build.`);
7913 }
7914 return ctx;
7915 }
7916};
7917
7918function initCustomFormatter() {
7919 /* eslint-disable no-restricted-globals */
7920 if (typeof window === 'undefined') {
7921 return;
7922 }
7923 const vueStyle = { style: 'color:#3ba776' };
7924 const numberStyle = { style: 'color:#0b1bc9' };
7925 const stringStyle = { style: 'color:#b62e24' };
7926 const keywordStyle = { style: 'color:#9d288c' };
7927 // custom formatter for Chrome
7928 // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
7929 const formatter = {
7930 header(obj) {
7931 // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
7932 if (!isObject(obj)) {
7933 return null;
7934 }
7935 if (obj.__isVue) {
7936 return ['div', vueStyle, `VueInstance`];
7937 }
7938 else if (isRef(obj)) {
7939 return [
7940 'div',
7941 {},
7942 ['span', vueStyle, genRefFlag(obj)],
7943 '<',
7944 formatValue(obj.value),
7945 `>`
7946 ];
7947 }
7948 else if (isReactive(obj)) {
7949 return [
7950 'div',
7951 {},
7952 ['span', vueStyle, 'Reactive'],
7953 '<',
7954 formatValue(obj),
7955 `>${isReadonly(obj) ? ` (readonly)` : ``}`
7956 ];
7957 }
7958 else if (isReadonly(obj)) {
7959 return [
7960 'div',
7961 {},
7962 ['span', vueStyle, 'Readonly'],
7963 '<',
7964 formatValue(obj),
7965 '>'
7966 ];
7967 }
7968 return null;
7969 },
7970 hasBody(obj) {
7971 return obj && obj.__isVue;
7972 },
7973 body(obj) {
7974 if (obj && obj.__isVue) {
7975 return [
7976 'div',
7977 {},
7978 ...formatInstance(obj.$)
7979 ];
7980 }
7981 }
7982 };
7983 function formatInstance(instance) {
7984 const blocks = [];
7985 if (instance.type.props && instance.props) {
7986 blocks.push(createInstanceBlock('props', toRaw(instance.props)));
7987 }
7988 if (instance.setupState !== EMPTY_OBJ) {
7989 blocks.push(createInstanceBlock('setup', instance.setupState));
7990 }
7991 if (instance.data !== EMPTY_OBJ) {
7992 blocks.push(createInstanceBlock('data', toRaw(instance.data)));
7993 }
7994 const computed = extractKeys(instance, 'computed');
7995 if (computed) {
7996 blocks.push(createInstanceBlock('computed', computed));
7997 }
7998 const injected = extractKeys(instance, 'inject');
7999 if (injected) {
8000 blocks.push(createInstanceBlock('injected', injected));
8001 }
8002 blocks.push([
8003 'div',
8004 {},
8005 [
8006 'span',
8007 {
8008 style: keywordStyle.style + ';opacity:0.66'
8009 },
8010 '$ (internal): '
8011 ],
8012 ['object', { object: instance }]
8013 ]);
8014 return blocks;
8015 }
8016 function createInstanceBlock(type, target) {
8017 target = extend({}, target);
8018 if (!Object.keys(target).length) {
8019 return ['span', {}];
8020 }
8021 return [
8022 'div',
8023 { style: 'line-height:1.25em;margin-bottom:0.6em' },
8024 [
8025 'div',
8026 {
8027 style: 'color:#476582'
8028 },
8029 type
8030 ],
8031 [
8032 'div',
8033 {
8034 style: 'padding-left:1.25em'
8035 },
8036 ...Object.keys(target).map(key => {
8037 return [
8038 'div',
8039 {},
8040 ['span', keywordStyle, key + ': '],
8041 formatValue(target[key], false)
8042 ];
8043 })
8044 ]
8045 ];
8046 }
8047 function formatValue(v, asRaw = true) {
8048 if (typeof v === 'number') {
8049 return ['span', numberStyle, v];
8050 }
8051 else if (typeof v === 'string') {
8052 return ['span', stringStyle, JSON.stringify(v)];
8053 }
8054 else if (typeof v === 'boolean') {
8055 return ['span', keywordStyle, v];
8056 }
8057 else if (isObject(v)) {
8058 return ['object', { object: asRaw ? toRaw(v) : v }];
8059 }
8060 else {
8061 return ['span', stringStyle, String(v)];
8062 }
8063 }
8064 function extractKeys(instance, type) {
8065 const Comp = instance.type;
8066 if (isFunction(Comp)) {
8067 return;
8068 }
8069 const extracted = {};
8070 for (const key in instance.ctx) {
8071 if (isKeyOfType(Comp, key, type)) {
8072 extracted[key] = instance.ctx[key];
8073 }
8074 }
8075 return extracted;
8076 }
8077 function isKeyOfType(Comp, key, type) {
8078 const opts = Comp[type];
8079 if ((isArray(opts) && opts.includes(key)) ||
8080 (isObject(opts) && key in opts)) {
8081 return true;
8082 }
8083 if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
8084 return true;
8085 }
8086 if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
8087 return true;
8088 }
8089 }
8090 function genRefFlag(v) {
8091 if (v._shallow) {
8092 return `ShallowRef`;
8093 }
8094 if (v.effect) {
8095 return `ComputedRef`;
8096 }
8097 return `Ref`;
8098 }
8099 if (window.devtoolsFormatters) {
8100 window.devtoolsFormatters.push(formatter);
8101 }
8102 else {
8103 window.devtoolsFormatters = [formatter];
8104 }
8105}
8106
8107/**
8108 * Actual implementation
8109 */
8110function renderList(source, renderItem) {
8111 let ret;
8112 if (isArray(source) || isString(source)) {
8113 ret = new Array(source.length);
8114 for (let i = 0, l = source.length; i < l; i++) {
8115 ret[i] = renderItem(source[i], i);
8116 }
8117 }
8118 else if (typeof source === 'number') {
8119 if (!Number.isInteger(source)) {
8120 warn(`The v-for range expect an integer value but got ${source}.`);
8121 return [];
8122 }
8123 ret = new Array(source);
8124 for (let i = 0; i < source; i++) {
8125 ret[i] = renderItem(i + 1, i);
8126 }
8127 }
8128 else if (isObject(source)) {
8129 if (source[Symbol.iterator]) {
8130 ret = Array.from(source, renderItem);
8131 }
8132 else {
8133 const keys = Object.keys(source);
8134 ret = new Array(keys.length);
8135 for (let i = 0, l = keys.length; i < l; i++) {
8136 const key = keys[i];
8137 ret[i] = renderItem(source[key], key, i);
8138 }
8139 }
8140 }
8141 else {
8142 ret = [];
8143 }
8144 return ret;
8145}
8146
8147/**
8148 * For prefixing keys in v-on="obj" with "on"
8149 * @private
8150 */
8151function toHandlers(obj) {
8152 const ret = {};
8153 if (!isObject(obj)) {
8154 warn(`v-on with no argument expects an object value.`);
8155 return ret;
8156 }
8157 for (const key in obj) {
8158 ret[toHandlerKey(key)] = obj[key];
8159 }
8160 return ret;
8161}
8162
8163/**
8164 * Compiler runtime helper for creating dynamic slots object
8165 * @private
8166 */
8167function createSlots(slots, dynamicSlots) {
8168 for (let i = 0; i < dynamicSlots.length; i++) {
8169 const slot = dynamicSlots[i];
8170 // array of dynamic slot generated by <template v-for="..." #[...]>
8171 if (isArray(slot)) {
8172 for (let j = 0; j < slot.length; j++) {
8173 slots[slot[j].name] = slot[j].fn;
8174 }
8175 }
8176 else if (slot) {
8177 // conditional single slot generated by <template v-if="..." #foo>
8178 slots[slot.name] = slot.fn;
8179 }
8180 }
8181 return slots;
8182}
8183
8184// Core API ------------------------------------------------------------------
8185const version = "3.0.11";
8186/**
8187 * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8188 * @internal
8189 */
8190const ssrUtils = (null);
8191
8192const svgNS = 'http://www.w3.org/2000/svg';
8193const doc = (typeof document !== 'undefined' ? document : null);
8194let tempContainer;
8195let tempSVGContainer;
8196const nodeOps = {
8197 insert: (child, parent, anchor) => {
8198 parent.insertBefore(child, anchor || null);
8199 },
8200 remove: child => {
8201 const parent = child.parentNode;
8202 if (parent) {
8203 parent.removeChild(child);
8204 }
8205 },
8206 createElement: (tag, isSVG, is, props) => {
8207 const el = isSVG
8208 ? doc.createElementNS(svgNS, tag)
8209 : doc.createElement(tag, is ? { is } : undefined);
8210 if (tag === 'select' && props && props.multiple != null) {
8211 el.setAttribute('multiple', props.multiple);
8212 }
8213 return el;
8214 },
8215 createText: text => doc.createTextNode(text),
8216 createComment: text => doc.createComment(text),
8217 setText: (node, text) => {
8218 node.nodeValue = text;
8219 },
8220 setElementText: (el, text) => {
8221 el.textContent = text;
8222 },
8223 parentNode: node => node.parentNode,
8224 nextSibling: node => node.nextSibling,
8225 querySelector: selector => doc.querySelector(selector),
8226 setScopeId(el, id) {
8227 el.setAttribute(id, '');
8228 },
8229 cloneNode(el) {
8230 const cloned = el.cloneNode(true);
8231 // #3072
8232 // - in `patchDOMProp`, we store the actual value in the `el._value` property.
8233 // - normally, elements using `:value` bindings will not be hoisted, but if
8234 // the bound value is a constant, e.g. `:value="true"` - they do get
8235 // hoisted.
8236 // - in production, hoisted nodes are cloned when subsequent inserts, but
8237 // cloneNode() does not copy the custom property we attached.
8238 // - This may need to account for other custom DOM properties we attach to
8239 // elements in addition to `_value` in the future.
8240 if (`_value` in el) {
8241 cloned._value = el._value;
8242 }
8243 return cloned;
8244 },
8245 // __UNSAFE__
8246 // Reason: innerHTML.
8247 // Static content here can only come from compiled templates.
8248 // As long as the user only uses trusted templates, this is safe.
8249 insertStaticContent(content, parent, anchor, isSVG) {
8250 const temp = isSVG
8251 ? tempSVGContainer ||
8252 (tempSVGContainer = doc.createElementNS(svgNS, 'svg'))
8253 : tempContainer || (tempContainer = doc.createElement('div'));
8254 temp.innerHTML = content;
8255 const first = temp.firstChild;
8256 let node = first;
8257 let last = node;
8258 while (node) {
8259 last = node;
8260 nodeOps.insert(node, parent, anchor);
8261 node = temp.firstChild;
8262 }
8263 return [first, last];
8264 }
8265};
8266
8267// compiler should normalize class + :class bindings on the same element
8268// into a single binding ['staticClass', dynamic]
8269function patchClass(el, value, isSVG) {
8270 if (value == null) {
8271 value = '';
8272 }
8273 if (isSVG) {
8274 el.setAttribute('class', value);
8275 }
8276 else {
8277 // directly setting className should be faster than setAttribute in theory
8278 // if this is an element during a transition, take the temporary transition
8279 // classes into account.
8280 const transitionClasses = el._vtc;
8281 if (transitionClasses) {
8282 value = (value
8283 ? [value, ...transitionClasses]
8284 : [...transitionClasses]).join(' ');
8285 }
8286 el.className = value;
8287 }
8288}
8289
8290function patchStyle(el, prev, next) {
8291 const style = el.style;
8292 if (!next) {
8293 el.removeAttribute('style');
8294 }
8295 else if (isString(next)) {
8296 if (prev !== next) {
8297 const current = style.display;
8298 style.cssText = next;
8299 // indicates that the `display` of the element is controlled by `v-show`,
8300 // so we always keep the current `display` value regardless of the `style` value,
8301 // thus handing over control to `v-show`.
8302 if ('_vod' in el) {
8303 style.display = current;
8304 }
8305 }
8306 }
8307 else {
8308 for (const key in next) {
8309 setStyle(style, key, next[key]);
8310 }
8311 if (prev && !isString(prev)) {
8312 for (const key in prev) {
8313 if (next[key] == null) {
8314 setStyle(style, key, '');
8315 }
8316 }
8317 }
8318 }
8319}
8320const importantRE = /\s*!important$/;
8321function setStyle(style, name, val) {
8322 if (isArray(val)) {
8323 val.forEach(v => setStyle(style, name, v));
8324 }
8325 else {
8326 if (name.startsWith('--')) {
8327 // custom property definition
8328 style.setProperty(name, val);
8329 }
8330 else {
8331 const prefixed = autoPrefix(style, name);
8332 if (importantRE.test(val)) {
8333 // !important
8334 style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
8335 }
8336 else {
8337 style[prefixed] = val;
8338 }
8339 }
8340 }
8341}
8342const prefixes = ['Webkit', 'Moz', 'ms'];
8343const prefixCache = {};
8344function autoPrefix(style, rawName) {
8345 const cached = prefixCache[rawName];
8346 if (cached) {
8347 return cached;
8348 }
8349 let name = camelize(rawName);
8350 if (name !== 'filter' && name in style) {
8351 return (prefixCache[rawName] = name);
8352 }
8353 name = capitalize(name);
8354 for (let i = 0; i < prefixes.length; i++) {
8355 const prefixed = prefixes[i] + name;
8356 if (prefixed in style) {
8357 return (prefixCache[rawName] = prefixed);
8358 }
8359 }
8360 return rawName;
8361}
8362
8363const xlinkNS = 'http://www.w3.org/1999/xlink';
8364function patchAttr(el, key, value, isSVG) {
8365 if (isSVG && key.startsWith('xlink:')) {
8366 if (value == null) {
8367 el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
8368 }
8369 else {
8370 el.setAttributeNS(xlinkNS, key, value);
8371 }
8372 }
8373 else {
8374 // note we are only checking boolean attributes that don't have a
8375 // corresponding dom prop of the same name here.
8376 const isBoolean = isSpecialBooleanAttr(key);
8377 if (value == null || (isBoolean && value === false)) {
8378 el.removeAttribute(key);
8379 }
8380 else {
8381 el.setAttribute(key, isBoolean ? '' : value);
8382 }
8383 }
8384}
8385
8386// __UNSAFE__
8387// functions. The user is responsible for using them with only trusted content.
8388function patchDOMProp(el, key, value,
8389// the following args are passed only due to potential innerHTML/textContent
8390// overriding existing VNodes, in which case the old tree must be properly
8391// unmounted.
8392prevChildren, parentComponent, parentSuspense, unmountChildren) {
8393 if (key === 'innerHTML' || key === 'textContent') {
8394 if (prevChildren) {
8395 unmountChildren(prevChildren, parentComponent, parentSuspense);
8396 }
8397 el[key] = value == null ? '' : value;
8398 return;
8399 }
8400 if (key === 'value' && el.tagName !== 'PROGRESS') {
8401 // store value as _value as well since
8402 // non-string values will be stringified.
8403 el._value = value;
8404 const newValue = value == null ? '' : value;
8405 if (el.value !== newValue) {
8406 el.value = newValue;
8407 }
8408 return;
8409 }
8410 if (value === '' || value == null) {
8411 const type = typeof el[key];
8412 if (value === '' && type === 'boolean') {
8413 // e.g. <select multiple> compiles to { multiple: '' }
8414 el[key] = true;
8415 return;
8416 }
8417 else if (value == null && type === 'string') {
8418 // e.g. <div :id="null">
8419 el[key] = '';
8420 el.removeAttribute(key);
8421 return;
8422 }
8423 else if (type === 'number') {
8424 // e.g. <img :width="null">
8425 el[key] = 0;
8426 el.removeAttribute(key);
8427 return;
8428 }
8429 }
8430 // some properties perform value validation and throw
8431 try {
8432 el[key] = value;
8433 }
8434 catch (e) {
8435 {
8436 warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
8437 `value ${value} is invalid.`, e);
8438 }
8439 }
8440}
8441
8442// Async edge case fix requires storing an event listener's attach timestamp.
8443let _getNow = Date.now;
8444let skipTimestampCheck = false;
8445if (typeof window !== 'undefined') {
8446 // Determine what event timestamp the browser is using. Annoyingly, the
8447 // timestamp can either be hi-res (relative to page load) or low-res
8448 // (relative to UNIX epoch), so in order to compare time we have to use the
8449 // same timestamp type when saving the flush timestamp.
8450 if (_getNow() > document.createEvent('Event').timeStamp) {
8451 // if the low-res timestamp which is bigger than the event timestamp
8452 // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
8453 // and we need to use the hi-res version for event listeners as well.
8454 _getNow = () => performance.now();
8455 }
8456 // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
8457 // and does not fire microtasks in between event propagation, so safe to exclude.
8458 const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
8459 skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
8460}
8461// To avoid the overhead of repeatedly calling performance.now(), we cache
8462// and use the same timestamp for all event listeners attached in the same tick.
8463let cachedNow = 0;
8464const p = Promise.resolve();
8465const reset = () => {
8466 cachedNow = 0;
8467};
8468const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
8469function addEventListener(el, event, handler, options) {
8470 el.addEventListener(event, handler, options);
8471}
8472function removeEventListener(el, event, handler, options) {
8473 el.removeEventListener(event, handler, options);
8474}
8475function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
8476 // vei = vue event invokers
8477 const invokers = el._vei || (el._vei = {});
8478 const existingInvoker = invokers[rawName];
8479 if (nextValue && existingInvoker) {
8480 // patch
8481 existingInvoker.value = nextValue;
8482 }
8483 else {
8484 const [name, options] = parseName(rawName);
8485 if (nextValue) {
8486 // add
8487 const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
8488 addEventListener(el, name, invoker, options);
8489 }
8490 else if (existingInvoker) {
8491 // remove
8492 removeEventListener(el, name, existingInvoker, options);
8493 invokers[rawName] = undefined;
8494 }
8495 }
8496}
8497const optionsModifierRE = /(?:Once|Passive|Capture)$/;
8498function parseName(name) {
8499 let options;
8500 if (optionsModifierRE.test(name)) {
8501 options = {};
8502 let m;
8503 while ((m = name.match(optionsModifierRE))) {
8504 name = name.slice(0, name.length - m[0].length);
8505 options[m[0].toLowerCase()] = true;
8506 }
8507 }
8508 return [hyphenate(name.slice(2)), options];
8509}
8510function createInvoker(initialValue, instance) {
8511 const invoker = (e) => {
8512 // async edge case #6566: inner click event triggers patch, event handler
8513 // attached to outer element during patch, and triggered again. This
8514 // happens because browsers fire microtask ticks between event propagation.
8515 // the solution is simple: we save the timestamp when a handler is attached,
8516 // and the handler would only fire if the event passed to it was fired
8517 // AFTER it was attached.
8518 const timeStamp = e.timeStamp || _getNow();
8519 if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
8520 callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
8521 }
8522 };
8523 invoker.value = initialValue;
8524 invoker.attached = getNow();
8525 return invoker;
8526}
8527function patchStopImmediatePropagation(e, value) {
8528 if (isArray(value)) {
8529 const originalStop = e.stopImmediatePropagation;
8530 e.stopImmediatePropagation = () => {
8531 originalStop.call(e);
8532 e._stopped = true;
8533 };
8534 return value.map(fn => (e) => !e._stopped && fn(e));
8535 }
8536 else {
8537 return value;
8538 }
8539}
8540
8541const nativeOnRE = /^on[a-z]/;
8542const forcePatchProp = (_, key) => key === 'value';
8543const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
8544 switch (key) {
8545 // special
8546 case 'class':
8547 patchClass(el, nextValue, isSVG);
8548 break;
8549 case 'style':
8550 patchStyle(el, prevValue, nextValue);
8551 break;
8552 default:
8553 if (isOn(key)) {
8554 // ignore v-model listeners
8555 if (!isModelListener(key)) {
8556 patchEvent(el, key, prevValue, nextValue, parentComponent);
8557 }
8558 }
8559 else if (shouldSetAsProp(el, key, nextValue, isSVG)) {
8560 patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
8561 }
8562 else {
8563 // special case for <input v-model type="checkbox"> with
8564 // :true-value & :false-value
8565 // store value as dom properties since non-string values will be
8566 // stringified.
8567 if (key === 'true-value') {
8568 el._trueValue = nextValue;
8569 }
8570 else if (key === 'false-value') {
8571 el._falseValue = nextValue;
8572 }
8573 patchAttr(el, key, nextValue, isSVG);
8574 }
8575 break;
8576 }
8577};
8578function shouldSetAsProp(el, key, value, isSVG) {
8579 if (isSVG) {
8580 // most keys must be set as attribute on svg elements to work
8581 // ...except innerHTML
8582 if (key === 'innerHTML') {
8583 return true;
8584 }
8585 // or native onclick with function values
8586 if (key in el && nativeOnRE.test(key) && isFunction(value)) {
8587 return true;
8588 }
8589 return false;
8590 }
8591 // spellcheck and draggable are numerated attrs, however their
8592 // corresponding DOM properties are actually booleans - this leads to
8593 // setting it with a string "false" value leading it to be coerced to
8594 // `true`, so we need to always treat them as attributes.
8595 // Note that `contentEditable` doesn't have this problem: its DOM
8596 // property is also enumerated string values.
8597 if (key === 'spellcheck' || key === 'draggable') {
8598 return false;
8599 }
8600 // #1787, #2840 form property on form elements is readonly and must be set as
8601 // attribute.
8602 if (key === 'form') {
8603 return false;
8604 }
8605 // #1526 <input list> must be set as attribute
8606 if (key === 'list' && el.tagName === 'INPUT') {
8607 return false;
8608 }
8609 // #2766 <textarea type> must be set as attribute
8610 if (key === 'type' && el.tagName === 'TEXTAREA') {
8611 return false;
8612 }
8613 // native onclick with string value, must be set as attribute
8614 if (nativeOnRE.test(key) && isString(value)) {
8615 return false;
8616 }
8617 return key in el;
8618}
8619
8620function useCssModule(name = '$style') {
8621 /* istanbul ignore else */
8622 {
8623 const instance = getCurrentInstance();
8624 if (!instance) {
8625 warn(`useCssModule must be called inside setup()`);
8626 return EMPTY_OBJ;
8627 }
8628 const modules = instance.type.__cssModules;
8629 if (!modules) {
8630 warn(`Current instance does not have CSS modules injected.`);
8631 return EMPTY_OBJ;
8632 }
8633 const mod = modules[name];
8634 if (!mod) {
8635 warn(`Current instance does not have CSS module named "${name}".`);
8636 return EMPTY_OBJ;
8637 }
8638 return mod;
8639 }
8640}
8641
8642/**
8643 * Runtime helper for SFC's CSS variable injection feature.
8644 * @private
8645 */
8646function useCssVars(getter) {
8647 const instance = getCurrentInstance();
8648 /* istanbul ignore next */
8649 if (!instance) {
8650 warn(`useCssVars is called without current active component instance.`);
8651 return;
8652 }
8653 const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
8654 onMounted(() => watchEffect(setVars, { flush: 'post' }));
8655 onUpdated(setVars);
8656}
8657function setVarsOnVNode(vnode, vars) {
8658 if (vnode.shapeFlag & 128 /* SUSPENSE */) {
8659 const suspense = vnode.suspense;
8660 vnode = suspense.activeBranch;
8661 if (suspense.pendingBranch && !suspense.isHydrating) {
8662 suspense.effects.push(() => {
8663 setVarsOnVNode(suspense.activeBranch, vars);
8664 });
8665 }
8666 }
8667 // drill down HOCs until it's a non-component vnode
8668 while (vnode.component) {
8669 vnode = vnode.component.subTree;
8670 }
8671 if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
8672 const style = vnode.el.style;
8673 for (const key in vars) {
8674 style.setProperty(`--${key}`, vars[key]);
8675 }
8676 }
8677 else if (vnode.type === Fragment) {
8678 vnode.children.forEach(c => setVarsOnVNode(c, vars));
8679 }
8680}
8681
8682const TRANSITION = 'transition';
8683const ANIMATION = 'animation';
8684// DOM Transition is a higher-order-component based on the platform-agnostic
8685// base Transition component, with DOM-specific logic.
8686const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
8687Transition.displayName = 'Transition';
8688const DOMTransitionPropsValidators = {
8689 name: String,
8690 type: String,
8691 css: {
8692 type: Boolean,
8693 default: true
8694 },
8695 duration: [String, Number, Object],
8696 enterFromClass: String,
8697 enterActiveClass: String,
8698 enterToClass: String,
8699 appearFromClass: String,
8700 appearActiveClass: String,
8701 appearToClass: String,
8702 leaveFromClass: String,
8703 leaveActiveClass: String,
8704 leaveToClass: String
8705};
8706const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
8707function resolveTransitionProps(rawProps) {
8708 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;
8709 const baseProps = {};
8710 for (const key in rawProps) {
8711 if (!(key in DOMTransitionPropsValidators)) {
8712 baseProps[key] = rawProps[key];
8713 }
8714 }
8715 if (!css) {
8716 return baseProps;
8717 }
8718 const durations = normalizeDuration(duration);
8719 const enterDuration = durations && durations[0];
8720 const leaveDuration = durations && durations[1];
8721 const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
8722 const finishEnter = (el, isAppear, done) => {
8723 removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
8724 removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
8725 done && done();
8726 };
8727 const finishLeave = (el, done) => {
8728 removeTransitionClass(el, leaveToClass);
8729 removeTransitionClass(el, leaveActiveClass);
8730 done && done();
8731 };
8732 const makeEnterHook = (isAppear) => {
8733 return (el, done) => {
8734 const hook = isAppear ? onAppear : onEnter;
8735 const resolve = () => finishEnter(el, isAppear, done);
8736 hook && hook(el, resolve);
8737 nextFrame(() => {
8738 removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
8739 addTransitionClass(el, isAppear ? appearToClass : enterToClass);
8740 if (!(hook && hook.length > 1)) {
8741 whenTransitionEnds(el, type, enterDuration, resolve);
8742 }
8743 });
8744 };
8745 };
8746 return extend(baseProps, {
8747 onBeforeEnter(el) {
8748 onBeforeEnter && onBeforeEnter(el);
8749 addTransitionClass(el, enterFromClass);
8750 addTransitionClass(el, enterActiveClass);
8751 },
8752 onBeforeAppear(el) {
8753 onBeforeAppear && onBeforeAppear(el);
8754 addTransitionClass(el, appearFromClass);
8755 addTransitionClass(el, appearActiveClass);
8756 },
8757 onEnter: makeEnterHook(false),
8758 onAppear: makeEnterHook(true),
8759 onLeave(el, done) {
8760 const resolve = () => finishLeave(el, done);
8761 addTransitionClass(el, leaveFromClass);
8762 // force reflow so *-leave-from classes immediately take effect (#2593)
8763 forceReflow();
8764 addTransitionClass(el, leaveActiveClass);
8765 nextFrame(() => {
8766 removeTransitionClass(el, leaveFromClass);
8767 addTransitionClass(el, leaveToClass);
8768 if (!(onLeave && onLeave.length > 1)) {
8769 whenTransitionEnds(el, type, leaveDuration, resolve);
8770 }
8771 });
8772 onLeave && onLeave(el, resolve);
8773 },
8774 onEnterCancelled(el) {
8775 finishEnter(el, false);
8776 onEnterCancelled && onEnterCancelled(el);
8777 },
8778 onAppearCancelled(el) {
8779 finishEnter(el, true);
8780 onAppearCancelled && onAppearCancelled(el);
8781 },
8782 onLeaveCancelled(el) {
8783 finishLeave(el);
8784 onLeaveCancelled && onLeaveCancelled(el);
8785 }
8786 });
8787}
8788function normalizeDuration(duration) {
8789 if (duration == null) {
8790 return null;
8791 }
8792 else if (isObject(duration)) {
8793 return [NumberOf(duration.enter), NumberOf(duration.leave)];
8794 }
8795 else {
8796 const n = NumberOf(duration);
8797 return [n, n];
8798 }
8799}
8800function NumberOf(val) {
8801 const res = toNumber(val);
8802 validateDuration(res);
8803 return res;
8804}
8805function validateDuration(val) {
8806 if (typeof val !== 'number') {
8807 warn(`<transition> explicit duration is not a valid number - ` +
8808 `got ${JSON.stringify(val)}.`);
8809 }
8810 else if (isNaN(val)) {
8811 warn(`<transition> explicit duration is NaN - ` +
8812 'the duration expression might be incorrect.');
8813 }
8814}
8815function addTransitionClass(el, cls) {
8816 cls.split(/\s+/).forEach(c => c && el.classList.add(c));
8817 (el._vtc ||
8818 (el._vtc = new Set())).add(cls);
8819}
8820function removeTransitionClass(el, cls) {
8821 cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
8822 const { _vtc } = el;
8823 if (_vtc) {
8824 _vtc.delete(cls);
8825 if (!_vtc.size) {
8826 el._vtc = undefined;
8827 }
8828 }
8829}
8830function nextFrame(cb) {
8831 requestAnimationFrame(() => {
8832 requestAnimationFrame(cb);
8833 });
8834}
8835let endId = 0;
8836function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
8837 const id = (el._endId = ++endId);
8838 const resolveIfNotStale = () => {
8839 if (id === el._endId) {
8840 resolve();
8841 }
8842 };
8843 if (explicitTimeout) {
8844 return setTimeout(resolveIfNotStale, explicitTimeout);
8845 }
8846 const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
8847 if (!type) {
8848 return resolve();
8849 }
8850 const endEvent = type + 'end';
8851 let ended = 0;
8852 const end = () => {
8853 el.removeEventListener(endEvent, onEnd);
8854 resolveIfNotStale();
8855 };
8856 const onEnd = (e) => {
8857 if (e.target === el && ++ended >= propCount) {
8858 end();
8859 }
8860 };
8861 setTimeout(() => {
8862 if (ended < propCount) {
8863 end();
8864 }
8865 }, timeout + 1);
8866 el.addEventListener(endEvent, onEnd);
8867}
8868function getTransitionInfo(el, expectedType) {
8869 const styles = window.getComputedStyle(el);
8870 // JSDOM may return undefined for transition properties
8871 const getStyleProperties = (key) => (styles[key] || '').split(', ');
8872 const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
8873 const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
8874 const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
8875 const animationDelays = getStyleProperties(ANIMATION + 'Delay');
8876 const animationDurations = getStyleProperties(ANIMATION + 'Duration');
8877 const animationTimeout = getTimeout(animationDelays, animationDurations);
8878 let type = null;
8879 let timeout = 0;
8880 let propCount = 0;
8881 /* istanbul ignore if */
8882 if (expectedType === TRANSITION) {
8883 if (transitionTimeout > 0) {
8884 type = TRANSITION;
8885 timeout = transitionTimeout;
8886 propCount = transitionDurations.length;
8887 }
8888 }
8889 else if (expectedType === ANIMATION) {
8890 if (animationTimeout > 0) {
8891 type = ANIMATION;
8892 timeout = animationTimeout;
8893 propCount = animationDurations.length;
8894 }
8895 }
8896 else {
8897 timeout = Math.max(transitionTimeout, animationTimeout);
8898 type =
8899 timeout > 0
8900 ? transitionTimeout > animationTimeout
8901 ? TRANSITION
8902 : ANIMATION
8903 : null;
8904 propCount = type
8905 ? type === TRANSITION
8906 ? transitionDurations.length
8907 : animationDurations.length
8908 : 0;
8909 }
8910 const hasTransform = type === TRANSITION &&
8911 /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
8912 return {
8913 type,
8914 timeout,
8915 propCount,
8916 hasTransform
8917 };
8918}
8919function getTimeout(delays, durations) {
8920 while (delays.length < durations.length) {
8921 delays = delays.concat(delays);
8922 }
8923 return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
8924}
8925// Old versions of Chromium (below 61.0.3163.100) formats floating pointer
8926// numbers in a locale-dependent way, using a comma instead of a dot.
8927// If comma is not replaced with a dot, the input will be rounded down
8928// (i.e. acting as a floor function) causing unexpected behaviors
8929function toMs(s) {
8930 return Number(s.slice(0, -1).replace(',', '.')) * 1000;
8931}
8932// synchronously force layout to put elements into a certain state
8933function forceReflow() {
8934 return document.body.offsetHeight;
8935}
8936
8937const positionMap = new WeakMap();
8938const newPositionMap = new WeakMap();
8939const TransitionGroupImpl = {
8940 name: 'TransitionGroup',
8941 props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
8942 tag: String,
8943 moveClass: String
8944 }),
8945 setup(props, { slots }) {
8946 const instance = getCurrentInstance();
8947 const state = useTransitionState();
8948 let prevChildren;
8949 let children;
8950 onUpdated(() => {
8951 // children is guaranteed to exist after initial render
8952 if (!prevChildren.length) {
8953 return;
8954 }
8955 const moveClass = props.moveClass || `${props.name || 'v'}-move`;
8956 if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
8957 return;
8958 }
8959 // we divide the work into three loops to avoid mixing DOM reads and writes
8960 // in each iteration - which helps prevent layout thrashing.
8961 prevChildren.forEach(callPendingCbs);
8962 prevChildren.forEach(recordPosition);
8963 const movedChildren = prevChildren.filter(applyTranslation);
8964 // force reflow to put everything in position
8965 forceReflow();
8966 movedChildren.forEach(c => {
8967 const el = c.el;
8968 const style = el.style;
8969 addTransitionClass(el, moveClass);
8970 style.transform = style.webkitTransform = style.transitionDuration = '';
8971 const cb = (el._moveCb = (e) => {
8972 if (e && e.target !== el) {
8973 return;
8974 }
8975 if (!e || /transform$/.test(e.propertyName)) {
8976 el.removeEventListener('transitionend', cb);
8977 el._moveCb = null;
8978 removeTransitionClass(el, moveClass);
8979 }
8980 });
8981 el.addEventListener('transitionend', cb);
8982 });
8983 });
8984 return () => {
8985 const rawProps = toRaw(props);
8986 const cssTransitionProps = resolveTransitionProps(rawProps);
8987 const tag = rawProps.tag || Fragment;
8988 prevChildren = children;
8989 children = slots.default ? getTransitionRawChildren(slots.default()) : [];
8990 for (let i = 0; i < children.length; i++) {
8991 const child = children[i];
8992 if (child.key != null) {
8993 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
8994 }
8995 else {
8996 warn(`<TransitionGroup> children must be keyed.`);
8997 }
8998 }
8999 if (prevChildren) {
9000 for (let i = 0; i < prevChildren.length; i++) {
9001 const child = prevChildren[i];
9002 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
9003 positionMap.set(child, child.el.getBoundingClientRect());
9004 }
9005 }
9006 return createVNode(tag, null, children);
9007 };
9008 }
9009};
9010const TransitionGroup = TransitionGroupImpl;
9011function callPendingCbs(c) {
9012 const el = c.el;
9013 if (el._moveCb) {
9014 el._moveCb();
9015 }
9016 if (el._enterCb) {
9017 el._enterCb();
9018 }
9019}
9020function recordPosition(c) {
9021 newPositionMap.set(c, c.el.getBoundingClientRect());
9022}
9023function applyTranslation(c) {
9024 const oldPos = positionMap.get(c);
9025 const newPos = newPositionMap.get(c);
9026 const dx = oldPos.left - newPos.left;
9027 const dy = oldPos.top - newPos.top;
9028 if (dx || dy) {
9029 const s = c.el.style;
9030 s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
9031 s.transitionDuration = '0s';
9032 return c;
9033 }
9034}
9035function hasCSSTransform(el, root, moveClass) {
9036 // Detect whether an element with the move class applied has
9037 // CSS transitions. Since the element may be inside an entering
9038 // transition at this very moment, we make a clone of it and remove
9039 // all other transition classes applied to ensure only the move class
9040 // is applied.
9041 const clone = el.cloneNode();
9042 if (el._vtc) {
9043 el._vtc.forEach(cls => {
9044 cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
9045 });
9046 }
9047 moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
9048 clone.style.display = 'none';
9049 const container = (root.nodeType === 1
9050 ? root
9051 : root.parentNode);
9052 container.appendChild(clone);
9053 const { hasTransform } = getTransitionInfo(clone);
9054 container.removeChild(clone);
9055 return hasTransform;
9056}
9057
9058const getModelAssigner = (vnode) => {
9059 const fn = vnode.props['onUpdate:modelValue'];
9060 return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
9061};
9062function onCompositionStart(e) {
9063 e.target.composing = true;
9064}
9065function onCompositionEnd(e) {
9066 const target = e.target;
9067 if (target.composing) {
9068 target.composing = false;
9069 trigger$1(target, 'input');
9070 }
9071}
9072function trigger$1(el, type) {
9073 const e = document.createEvent('HTMLEvents');
9074 e.initEvent(type, true, true);
9075 el.dispatchEvent(e);
9076}
9077// We are exporting the v-model runtime directly as vnode hooks so that it can
9078// be tree-shaken in case v-model is never used.
9079const vModelText = {
9080 created(el, { modifiers: { lazy, trim, number } }, vnode) {
9081 el._assign = getModelAssigner(vnode);
9082 const castToNumber = number || el.type === 'number';
9083 addEventListener(el, lazy ? 'change' : 'input', e => {
9084 if (e.target.composing)
9085 return;
9086 let domValue = el.value;
9087 if (trim) {
9088 domValue = domValue.trim();
9089 }
9090 else if (castToNumber) {
9091 domValue = toNumber(domValue);
9092 }
9093 el._assign(domValue);
9094 });
9095 if (trim) {
9096 addEventListener(el, 'change', () => {
9097 el.value = el.value.trim();
9098 });
9099 }
9100 if (!lazy) {
9101 addEventListener(el, 'compositionstart', onCompositionStart);
9102 addEventListener(el, 'compositionend', onCompositionEnd);
9103 // Safari < 10.2 & UIWebView doesn't fire compositionend when
9104 // switching focus before confirming composition choice
9105 // this also fixes the issue where some browsers e.g. iOS Chrome
9106 // fires "change" instead of "input" on autocomplete.
9107 addEventListener(el, 'change', onCompositionEnd);
9108 }
9109 },
9110 // set value on mounted so it's after min/max for type="range"
9111 mounted(el, { value }) {
9112 el.value = value == null ? '' : value;
9113 },
9114 beforeUpdate(el, { value, modifiers: { trim, number } }, vnode) {
9115 el._assign = getModelAssigner(vnode);
9116 // avoid clearing unresolved text. #2302
9117 if (el.composing)
9118 return;
9119 if (document.activeElement === el) {
9120 if (trim && el.value.trim() === value) {
9121 return;
9122 }
9123 if ((number || el.type === 'number') && toNumber(el.value) === value) {
9124 return;
9125 }
9126 }
9127 const newValue = value == null ? '' : value;
9128 if (el.value !== newValue) {
9129 el.value = newValue;
9130 }
9131 }
9132};
9133const vModelCheckbox = {
9134 created(el, _, vnode) {
9135 el._assign = getModelAssigner(vnode);
9136 addEventListener(el, 'change', () => {
9137 const modelValue = el._modelValue;
9138 const elementValue = getValue(el);
9139 const checked = el.checked;
9140 const assign = el._assign;
9141 if (isArray(modelValue)) {
9142 const index = looseIndexOf(modelValue, elementValue);
9143 const found = index !== -1;
9144 if (checked && !found) {
9145 assign(modelValue.concat(elementValue));
9146 }
9147 else if (!checked && found) {
9148 const filtered = [...modelValue];
9149 filtered.splice(index, 1);
9150 assign(filtered);
9151 }
9152 }
9153 else if (isSet(modelValue)) {
9154 const cloned = new Set(modelValue);
9155 if (checked) {
9156 cloned.add(elementValue);
9157 }
9158 else {
9159 cloned.delete(elementValue);
9160 }
9161 assign(cloned);
9162 }
9163 else {
9164 assign(getCheckboxValue(el, checked));
9165 }
9166 });
9167 },
9168 // set initial checked on mount to wait for true-value/false-value
9169 mounted: setChecked,
9170 beforeUpdate(el, binding, vnode) {
9171 el._assign = getModelAssigner(vnode);
9172 setChecked(el, binding, vnode);
9173 }
9174};
9175function setChecked(el, { value, oldValue }, vnode) {
9176 el._modelValue = value;
9177 if (isArray(value)) {
9178 el.checked = looseIndexOf(value, vnode.props.value) > -1;
9179 }
9180 else if (isSet(value)) {
9181 el.checked = value.has(vnode.props.value);
9182 }
9183 else if (value !== oldValue) {
9184 el.checked = looseEqual(value, getCheckboxValue(el, true));
9185 }
9186}
9187const vModelRadio = {
9188 created(el, { value }, vnode) {
9189 el.checked = looseEqual(value, vnode.props.value);
9190 el._assign = getModelAssigner(vnode);
9191 addEventListener(el, 'change', () => {
9192 el._assign(getValue(el));
9193 });
9194 },
9195 beforeUpdate(el, { value, oldValue }, vnode) {
9196 el._assign = getModelAssigner(vnode);
9197 if (value !== oldValue) {
9198 el.checked = looseEqual(value, vnode.props.value);
9199 }
9200 }
9201};
9202const vModelSelect = {
9203 created(el, { value, modifiers: { number } }, vnode) {
9204 const isSetModel = isSet(value);
9205 addEventListener(el, 'change', () => {
9206 const selectedVal = Array.prototype.filter
9207 .call(el.options, (o) => o.selected)
9208 .map((o) => number ? toNumber(getValue(o)) : getValue(o));
9209 el._assign(el.multiple
9210 ? isSetModel
9211 ? new Set(selectedVal)
9212 : selectedVal
9213 : selectedVal[0]);
9214 });
9215 el._assign = getModelAssigner(vnode);
9216 },
9217 // set value in mounted & updated because <select> relies on its children
9218 // <option>s.
9219 mounted(el, { value }) {
9220 setSelected(el, value);
9221 },
9222 beforeUpdate(el, _binding, vnode) {
9223 el._assign = getModelAssigner(vnode);
9224 },
9225 updated(el, { value }) {
9226 setSelected(el, value);
9227 }
9228};
9229function setSelected(el, value) {
9230 const isMultiple = el.multiple;
9231 if (isMultiple && !isArray(value) && !isSet(value)) {
9232 warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
9233 `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
9234 return;
9235 }
9236 for (let i = 0, l = el.options.length; i < l; i++) {
9237 const option = el.options[i];
9238 const optionValue = getValue(option);
9239 if (isMultiple) {
9240 if (isArray(value)) {
9241 option.selected = looseIndexOf(value, optionValue) > -1;
9242 }
9243 else {
9244 option.selected = value.has(optionValue);
9245 }
9246 }
9247 else {
9248 if (looseEqual(getValue(option), value)) {
9249 el.selectedIndex = i;
9250 return;
9251 }
9252 }
9253 }
9254 if (!isMultiple) {
9255 el.selectedIndex = -1;
9256 }
9257}
9258// retrieve raw value set via :value bindings
9259function getValue(el) {
9260 return '_value' in el ? el._value : el.value;
9261}
9262// retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
9263function getCheckboxValue(el, checked) {
9264 const key = checked ? '_trueValue' : '_falseValue';
9265 return key in el ? el[key] : checked;
9266}
9267const vModelDynamic = {
9268 created(el, binding, vnode) {
9269 callModelHook(el, binding, vnode, null, 'created');
9270 },
9271 mounted(el, binding, vnode) {
9272 callModelHook(el, binding, vnode, null, 'mounted');
9273 },
9274 beforeUpdate(el, binding, vnode, prevVNode) {
9275 callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
9276 },
9277 updated(el, binding, vnode, prevVNode) {
9278 callModelHook(el, binding, vnode, prevVNode, 'updated');
9279 }
9280};
9281function callModelHook(el, binding, vnode, prevVNode, hook) {
9282 let modelToUse;
9283 switch (el.tagName) {
9284 case 'SELECT':
9285 modelToUse = vModelSelect;
9286 break;
9287 case 'TEXTAREA':
9288 modelToUse = vModelText;
9289 break;
9290 default:
9291 switch (vnode.props && vnode.props.type) {
9292 case 'checkbox':
9293 modelToUse = vModelCheckbox;
9294 break;
9295 case 'radio':
9296 modelToUse = vModelRadio;
9297 break;
9298 default:
9299 modelToUse = vModelText;
9300 }
9301 }
9302 const fn = modelToUse[hook];
9303 fn && fn(el, binding, vnode, prevVNode);
9304}
9305
9306const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
9307const modifierGuards = {
9308 stop: e => e.stopPropagation(),
9309 prevent: e => e.preventDefault(),
9310 self: e => e.target !== e.currentTarget,
9311 ctrl: e => !e.ctrlKey,
9312 shift: e => !e.shiftKey,
9313 alt: e => !e.altKey,
9314 meta: e => !e.metaKey,
9315 left: e => 'button' in e && e.button !== 0,
9316 middle: e => 'button' in e && e.button !== 1,
9317 right: e => 'button' in e && e.button !== 2,
9318 exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
9319};
9320/**
9321 * @private
9322 */
9323const withModifiers = (fn, modifiers) => {
9324 return (event, ...args) => {
9325 for (let i = 0; i < modifiers.length; i++) {
9326 const guard = modifierGuards[modifiers[i]];
9327 if (guard && guard(event, modifiers))
9328 return;
9329 }
9330 return fn(event, ...args);
9331 };
9332};
9333// Kept for 2.x compat.
9334// Note: IE11 compat for `spacebar` and `del` is removed for now.
9335const keyNames = {
9336 esc: 'escape',
9337 space: ' ',
9338 up: 'arrow-up',
9339 left: 'arrow-left',
9340 right: 'arrow-right',
9341 down: 'arrow-down',
9342 delete: 'backspace'
9343};
9344/**
9345 * @private
9346 */
9347const withKeys = (fn, modifiers) => {
9348 return (event) => {
9349 if (!('key' in event))
9350 return;
9351 const eventKey = hyphenate(event.key);
9352 if (
9353 // None of the provided key modifiers match the current event key
9354 !modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
9355 return;
9356 }
9357 return fn(event);
9358 };
9359};
9360
9361const vShow = {
9362 beforeMount(el, { value }, { transition }) {
9363 el._vod = el.style.display === 'none' ? '' : el.style.display;
9364 if (transition && value) {
9365 transition.beforeEnter(el);
9366 }
9367 else {
9368 setDisplay(el, value);
9369 }
9370 },
9371 mounted(el, { value }, { transition }) {
9372 if (transition && value) {
9373 transition.enter(el);
9374 }
9375 },
9376 updated(el, { value, oldValue }, { transition }) {
9377 if (!value === !oldValue)
9378 return;
9379 if (transition) {
9380 if (value) {
9381 transition.beforeEnter(el);
9382 setDisplay(el, true);
9383 transition.enter(el);
9384 }
9385 else {
9386 transition.leave(el, () => {
9387 setDisplay(el, false);
9388 });
9389 }
9390 }
9391 else {
9392 setDisplay(el, value);
9393 }
9394 },
9395 beforeUnmount(el, { value }) {
9396 setDisplay(el, value);
9397 }
9398};
9399function setDisplay(el, value) {
9400 el.style.display = value ? el._vod : 'none';
9401}
9402
9403const rendererOptions = extend({ patchProp, forcePatchProp }, nodeOps);
9404// lazy create the renderer - this makes core renderer logic tree-shakable
9405// in case the user only imports reactivity utilities from Vue.
9406let renderer;
9407let enabledHydration = false;
9408function ensureRenderer() {
9409 return renderer || (renderer = createRenderer(rendererOptions));
9410}
9411function ensureHydrationRenderer() {
9412 renderer = enabledHydration
9413 ? renderer
9414 : createHydrationRenderer(rendererOptions);
9415 enabledHydration = true;
9416 return renderer;
9417}
9418// use explicit type casts here to avoid import() calls in rolled-up d.ts
9419const render = ((...args) => {
9420 ensureRenderer().render(...args);
9421});
9422const hydrate = ((...args) => {
9423 ensureHydrationRenderer().hydrate(...args);
9424});
9425const createApp = ((...args) => {
9426 const app = ensureRenderer().createApp(...args);
9427 {
9428 injectNativeTagCheck(app);
9429 injectCustomElementCheck(app);
9430 }
9431 const { mount } = app;
9432 app.mount = (containerOrSelector) => {
9433 const container = normalizeContainer(containerOrSelector);
9434 if (!container)
9435 return;
9436 const component = app._component;
9437 if (!isFunction(component) && !component.render && !component.template) {
9438 component.template = container.innerHTML;
9439 }
9440 // clear content before mounting
9441 container.innerHTML = '';
9442 const proxy = mount(container, false, container instanceof SVGElement);
9443 if (container instanceof Element) {
9444 container.removeAttribute('v-cloak');
9445 container.setAttribute('data-v-app', '');
9446 }
9447 return proxy;
9448 };
9449 return app;
9450});
9451const createSSRApp = ((...args) => {
9452 const app = ensureHydrationRenderer().createApp(...args);
9453 {
9454 injectNativeTagCheck(app);
9455 injectCustomElementCheck(app);
9456 }
9457 const { mount } = app;
9458 app.mount = (containerOrSelector) => {
9459 const container = normalizeContainer(containerOrSelector);
9460 if (container) {
9461 return mount(container, true, container instanceof SVGElement);
9462 }
9463 };
9464 return app;
9465});
9466function injectNativeTagCheck(app) {
9467 // Inject `isNativeTag`
9468 // this is used for component name validation (dev only)
9469 Object.defineProperty(app.config, 'isNativeTag', {
9470 value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
9471 writable: false
9472 });
9473}
9474// dev only
9475function injectCustomElementCheck(app) {
9476 if (isRuntimeOnly()) {
9477 const value = app.config.isCustomElement;
9478 Object.defineProperty(app.config, 'isCustomElement', {
9479 get() {
9480 return value;
9481 },
9482 set() {
9483 warn(`The \`isCustomElement\` config option is only respected when using the runtime compiler.` +
9484 `If you are using the runtime-only build, \`isCustomElement\` must be passed to \`@vue/compiler-dom\` in the build setup instead` +
9485 `- for example, via the \`compilerOptions\` option in vue-loader: https://vue-loader.vuejs.org/options.html#compileroptions.`);
9486 }
9487 });
9488 }
9489}
9490function normalizeContainer(container) {
9491 if (isString(container)) {
9492 const res = document.querySelector(container);
9493 if (!res) {
9494 warn(`Failed to mount app: mount target selector "${container}" returned null.`);
9495 }
9496 return res;
9497 }
9498 if (container instanceof window.ShadowRoot &&
9499 container.mode === 'closed') {
9500 warn(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
9501 }
9502 return container;
9503}
9504
9505function initDev() {
9506 {
9507 {
9508 console.info(`You are running a development build of Vue.\n` +
9509 `Make sure to use the production build (*.prod.js) when deploying for production.`);
9510 }
9511 initCustomFormatter();
9512 }
9513}
9514
9515// This entry exports the runtime only, and is built as
9516{
9517 initDev();
9518}
9519const compile$1 = () => {
9520 {
9521 warn(`Runtime compilation is not supported in this build of Vue.` +
9522 (` Use "vue.esm-browser.js" instead.`
9523 ) /* should not happen */);
9524 }
9525};
9526
9527export { 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 };