UNPKG

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