UNPKG

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