UNPKG

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