UNPKG

818 kBJavaScriptView Raw
1'use strict';
2
3var parser = require('@babel/parser');
4var estreeWalker = require('estree-walker');
5var sourceMap = require('source-map');
6
7/**
8 * Make a map and return a function for checking if a key
9 * is in that map.
10 * IMPORTANT: all calls of this function must be prefixed with
11 * \/\*#\_\_PURE\_\_\*\/
12 * So that rollup can tree-shake them if necessary.
13 */
14function makeMap(str, expectsLowerCase) {
15 const map = Object.create(null);
16 const list = str.split(',');
17 for (let i = 0; i < list.length; i++) {
18 map[list[i]] = true;
19 }
20 return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
21}
22
23/**
24 * dev only flag -> name mapping
25 */
26const PatchFlagNames = {
27 [1 /* PatchFlags.TEXT */]: `TEXT`,
28 [2 /* PatchFlags.CLASS */]: `CLASS`,
29 [4 /* PatchFlags.STYLE */]: `STYLE`,
30 [8 /* PatchFlags.PROPS */]: `PROPS`,
31 [16 /* PatchFlags.FULL_PROPS */]: `FULL_PROPS`,
32 [32 /* PatchFlags.HYDRATE_EVENTS */]: `HYDRATE_EVENTS`,
33 [64 /* PatchFlags.STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
34 [128 /* PatchFlags.KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
35 [256 /* PatchFlags.UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
36 [512 /* PatchFlags.NEED_PATCH */]: `NEED_PATCH`,
37 [1024 /* PatchFlags.DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
38 [2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
39 [-1 /* PatchFlags.HOISTED */]: `HOISTED`,
40 [-2 /* PatchFlags.BAIL */]: `BAIL`
41};
42
43/**
44 * Dev only
45 */
46const slotFlagsText = {
47 [1 /* SlotFlags.STABLE */]: 'STABLE',
48 [2 /* SlotFlags.DYNAMIC */]: 'DYNAMIC',
49 [3 /* SlotFlags.FORWARDED */]: 'FORWARDED'
50};
51
52const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
53 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
54 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
55const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
56
57const range = 2;
58function generateCodeFrame(source, start = 0, end = source.length) {
59 // Split the content into individual lines but capture the newline sequence
60 // that separated each line. This is important because the actual sequence is
61 // needed to properly take into account the full line length for offset
62 // comparison
63 let lines = source.split(/(\r?\n)/);
64 // Separate the lines and newline sequences into separate arrays for easier referencing
65 const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
66 lines = lines.filter((_, idx) => idx % 2 === 0);
67 let count = 0;
68 const res = [];
69 for (let i = 0; i < lines.length; i++) {
70 count +=
71 lines[i].length +
72 ((newlineSequences[i] && newlineSequences[i].length) || 0);
73 if (count >= start) {
74 for (let j = i - range; j <= i + range || end > count; j++) {
75 if (j < 0 || j >= lines.length)
76 continue;
77 const line = j + 1;
78 res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
79 const lineLength = lines[j].length;
80 const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
81 if (j === i) {
82 // push underline
83 const pad = start - (count - (lineLength + newLineSeqLength));
84 const length = Math.max(1, end > count ? lineLength - pad : end - start);
85 res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
86 }
87 else if (j > i) {
88 if (end > count) {
89 const length = Math.max(Math.min(end - count, lineLength), 1);
90 res.push(` | ` + '^'.repeat(length));
91 }
92 count += lineLength + newLineSeqLength;
93 }
94 }
95 break;
96 }
97 }
98 return res.join('\n');
99}
100
101/**
102 * On the client we only need to offer special cases for boolean attributes that
103 * have different names from their corresponding dom properties:
104 * - itemscope -> N/A
105 * - allowfullscreen -> allowFullscreen
106 * - formnovalidate -> formNoValidate
107 * - ismap -> isMap
108 * - nomodule -> noModule
109 * - novalidate -> noValidate
110 * - readonly -> readOnly
111 */
112const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
113const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
114/**
115 * Boolean attributes should be included if the value is truthy or ''.
116 * e.g. `<select multiple>` compiles to `{ multiple: '' }`
117 */
118function includeBooleanAttr(value) {
119 return !!value || value === '';
120}
121/**
122 * CSS properties that accept plain numbers
123 */
124const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` +
125 `border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` +
126 `columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` +
127 `grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` +
128 `grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` +
129 `line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` +
130 // SVG
131 `fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` +
132 `stroke-miterlimit,stroke-opacity,stroke-width`);
133/**
134 * Known attributes, this is used for stringification of runtime static nodes
135 * so that we don't stringify bindings that cannot be set from HTML.
136 * Don't also forget to allow `data-*` and `aria-*`!
137 * Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
138 */
139const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
140 `autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
141 `border,buffered,capture,challenge,charset,checked,cite,class,code,` +
142 `codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
143 `coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
144 `disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
145 `formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
146 `height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
147 `ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
148 `manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
149 `open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
150 `referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
151 `selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
152 `start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
153 `value,width,wrap`);
154/**
155 * Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
156 */
157const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
158 `arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
159 `baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
160 `clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
161 `color-interpolation-filters,color-profile,color-rendering,` +
162 `contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
163 `descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
164 `dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
165 `fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
166 `font-family,font-size,font-size-adjust,font-stretch,font-style,` +
167 `font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
168 `glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
169 `gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
170 `horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
171 `k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
172 `lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
173 `marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
174 `mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
175 `name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
176 `overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
177 `pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
178 `pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
179 `preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
180 `rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
181 `restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
182 `specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
183 `stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
184 `strikethrough-position,strikethrough-thickness,string,stroke,` +
185 `stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
186 `stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
187 `systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
188 `text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
189 `type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
190 `unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
191 `v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
192 `vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
193 `writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
194 `xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
195 `xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
196
197function normalizeStyle(value) {
198 if (isArray(value)) {
199 const res = {};
200 for (let i = 0; i < value.length; i++) {
201 const item = value[i];
202 const normalized = isString(item)
203 ? parseStringStyle(item)
204 : normalizeStyle(item);
205 if (normalized) {
206 for (const key in normalized) {
207 res[key] = normalized[key];
208 }
209 }
210 }
211 return res;
212 }
213 else if (isString(value)) {
214 return value;
215 }
216 else if (isObject(value)) {
217 return value;
218 }
219}
220const listDelimiterRE = /;(?![^(]*\))/g;
221const propertyDelimiterRE = /:(.+)/;
222function parseStringStyle(cssText) {
223 const ret = {};
224 cssText.split(listDelimiterRE).forEach(item => {
225 if (item) {
226 const tmp = item.split(propertyDelimiterRE);
227 tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
228 }
229 });
230 return ret;
231}
232function stringifyStyle(styles) {
233 let ret = '';
234 if (!styles || isString(styles)) {
235 return ret;
236 }
237 for (const key in styles) {
238 const value = styles[key];
239 const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
240 if (isString(value) ||
241 (typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))) {
242 // only render valid values
243 ret += `${normalizedKey}:${value};`;
244 }
245 }
246 return ret;
247}
248function normalizeClass(value) {
249 let res = '';
250 if (isString(value)) {
251 res = value;
252 }
253 else if (isArray(value)) {
254 for (let i = 0; i < value.length; i++) {
255 const normalized = normalizeClass(value[i]);
256 if (normalized) {
257 res += normalized + ' ';
258 }
259 }
260 }
261 else if (isObject(value)) {
262 for (const name in value) {
263 if (value[name]) {
264 res += name + ' ';
265 }
266 }
267 }
268 return res.trim();
269}
270function normalizeProps(props) {
271 if (!props)
272 return null;
273 let { class: klass, style } = props;
274 if (klass && !isString(klass)) {
275 props.class = normalizeClass(klass);
276 }
277 if (style) {
278 props.style = normalizeStyle(style);
279 }
280 return props;
281}
282
283// These tag configs are shared between compiler-dom and runtime-dom, so they
284// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
285const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
286 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
287 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
288 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
289 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
290 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
291 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
292 'option,output,progress,select,textarea,details,dialog,menu,' +
293 'summary,template,blockquote,iframe,tfoot';
294// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
295const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
296 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
297 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
298 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
299 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
300 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
301 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
302 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
303 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
304 'text,textPath,title,tspan,unknown,use,view';
305const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
306/**
307 * Compiler only.
308 * Do NOT use in runtime code paths unless behind `true` flag.
309 */
310const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
311/**
312 * Compiler only.
313 * Do NOT use in runtime code paths unless behind `true` flag.
314 */
315const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
316/**
317 * Compiler only.
318 * Do NOT use in runtime code paths unless behind `true` flag.
319 */
320const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
321
322const escapeRE = /["'&<>]/;
323function escapeHtml(string) {
324 const str = '' + string;
325 const match = escapeRE.exec(str);
326 if (!match) {
327 return str;
328 }
329 let html = '';
330 let escaped;
331 let index;
332 let lastIndex = 0;
333 for (index = match.index; index < str.length; index++) {
334 switch (str.charCodeAt(index)) {
335 case 34: // "
336 escaped = '&quot;';
337 break;
338 case 38: // &
339 escaped = '&amp;';
340 break;
341 case 39: // '
342 escaped = '&#39;';
343 break;
344 case 60: // <
345 escaped = '&lt;';
346 break;
347 case 62: // >
348 escaped = '&gt;';
349 break;
350 default:
351 continue;
352 }
353 if (lastIndex !== index) {
354 html += str.slice(lastIndex, index);
355 }
356 lastIndex = index + 1;
357 html += escaped;
358 }
359 return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
360}
361
362function looseCompareArrays(a, b) {
363 if (a.length !== b.length)
364 return false;
365 let equal = true;
366 for (let i = 0; equal && i < a.length; i++) {
367 equal = looseEqual(a[i], b[i]);
368 }
369 return equal;
370}
371function looseEqual(a, b) {
372 if (a === b)
373 return true;
374 let aValidType = isDate(a);
375 let bValidType = isDate(b);
376 if (aValidType || bValidType) {
377 return aValidType && bValidType ? a.getTime() === b.getTime() : false;
378 }
379 aValidType = isSymbol(a);
380 bValidType = isSymbol(b);
381 if (aValidType || bValidType) {
382 return a === b;
383 }
384 aValidType = isArray(a);
385 bValidType = isArray(b);
386 if (aValidType || bValidType) {
387 return aValidType && bValidType ? looseCompareArrays(a, b) : false;
388 }
389 aValidType = isObject(a);
390 bValidType = isObject(b);
391 if (aValidType || bValidType) {
392 /* istanbul ignore if: this if will probably never be called */
393 if (!aValidType || !bValidType) {
394 return false;
395 }
396 const aKeysCount = Object.keys(a).length;
397 const bKeysCount = Object.keys(b).length;
398 if (aKeysCount !== bKeysCount) {
399 return false;
400 }
401 for (const key in a) {
402 const aHasKey = a.hasOwnProperty(key);
403 const bHasKey = b.hasOwnProperty(key);
404 if ((aHasKey && !bHasKey) ||
405 (!aHasKey && bHasKey) ||
406 !looseEqual(a[key], b[key])) {
407 return false;
408 }
409 }
410 }
411 return String(a) === String(b);
412}
413function looseIndexOf(arr, val) {
414 return arr.findIndex(item => looseEqual(item, val));
415}
416
417/**
418 * For converting {{ interpolation }} values to displayed strings.
419 * @private
420 */
421const toDisplayString = (val) => {
422 return isString(val)
423 ? val
424 : val == null
425 ? ''
426 : isArray(val) ||
427 (isObject(val) &&
428 (val.toString === objectToString || !isFunction(val.toString)))
429 ? JSON.stringify(val, replacer, 2)
430 : String(val);
431};
432const replacer = (_key, val) => {
433 // can't use isRef here since @vue/shared has no deps
434 if (val && val.__v_isRef) {
435 return replacer(_key, val.value);
436 }
437 else if (isMap(val)) {
438 return {
439 [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
440 entries[`${key} =>`] = val;
441 return entries;
442 }, {})
443 };
444 }
445 else if (isSet(val)) {
446 return {
447 [`Set(${val.size})`]: [...val.values()]
448 };
449 }
450 else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
451 return String(val);
452 }
453 return val;
454};
455
456const EMPTY_OBJ = Object.freeze({})
457 ;
458const EMPTY_ARR = Object.freeze([]) ;
459const NOOP = () => { };
460/**
461 * Always return false.
462 */
463const NO = () => false;
464const onRE = /^on[^a-z]/;
465const isOn = (key) => onRE.test(key);
466const isModelListener = (key) => key.startsWith('onUpdate:');
467const extend = Object.assign;
468const remove = (arr, el) => {
469 const i = arr.indexOf(el);
470 if (i > -1) {
471 arr.splice(i, 1);
472 }
473};
474const hasOwnProperty = Object.prototype.hasOwnProperty;
475const hasOwn = (val, key) => hasOwnProperty.call(val, key);
476const isArray = Array.isArray;
477const isMap = (val) => toTypeString(val) === '[object Map]';
478const isSet = (val) => toTypeString(val) === '[object Set]';
479const isDate = (val) => toTypeString(val) === '[object Date]';
480const isFunction = (val) => typeof val === 'function';
481const isString = (val) => typeof val === 'string';
482const isSymbol = (val) => typeof val === 'symbol';
483const isObject = (val) => val !== null && typeof val === 'object';
484const isPromise = (val) => {
485 return isObject(val) && isFunction(val.then) && isFunction(val.catch);
486};
487const objectToString = Object.prototype.toString;
488const toTypeString = (value) => objectToString.call(value);
489const toRawType = (value) => {
490 // extract "RawType" from strings like "[object RawType]"
491 return toTypeString(value).slice(8, -1);
492};
493const isPlainObject = (val) => toTypeString(val) === '[object Object]';
494const isIntegerKey = (key) => isString(key) &&
495 key !== 'NaN' &&
496 key[0] !== '-' &&
497 '' + parseInt(key, 10) === key;
498const isReservedProp = /*#__PURE__*/ makeMap(
499// the leading comma is intentional so empty string "" is also included
500',key,ref,ref_for,ref_key,' +
501 'onVnodeBeforeMount,onVnodeMounted,' +
502 'onVnodeBeforeUpdate,onVnodeUpdated,' +
503 'onVnodeBeforeUnmount,onVnodeUnmounted');
504const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
505const cacheStringFunction = (fn) => {
506 const cache = Object.create(null);
507 return ((str) => {
508 const hit = cache[str];
509 return hit || (cache[str] = fn(str));
510 });
511};
512const camelizeRE = /-(\w)/g;
513/**
514 * @private
515 */
516const camelize = cacheStringFunction((str) => {
517 return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
518});
519const hyphenateRE = /\B([A-Z])/g;
520/**
521 * @private
522 */
523const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
524/**
525 * @private
526 */
527const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
528/**
529 * @private
530 */
531const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
532// compare whether a value has changed, accounting for NaN.
533const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
534const invokeArrayFns = (fns, arg) => {
535 for (let i = 0; i < fns.length; i++) {
536 fns[i](arg);
537 }
538};
539const def = (obj, key, value) => {
540 Object.defineProperty(obj, key, {
541 configurable: true,
542 enumerable: false,
543 value
544 });
545};
546const toNumber = (val) => {
547 const n = parseFloat(val);
548 return isNaN(n) ? val : n;
549};
550let _globalThis;
551const getGlobalThis = () => {
552 return (_globalThis ||
553 (_globalThis =
554 typeof globalThis !== 'undefined'
555 ? globalThis
556 : typeof self !== 'undefined'
557 ? self
558 : typeof window !== 'undefined'
559 ? window
560 : typeof global !== 'undefined'
561 ? global
562 : {}));
563};
564const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
565function genPropsAccessExp(name) {
566 return identRE.test(name)
567 ? `__props.${name}`
568 : `__props[${JSON.stringify(name)}]`;
569}
570
571function warn(msg, ...args) {
572 console.warn(`[Vue warn] ${msg}`, ...args);
573}
574
575let activeEffectScope;
576class EffectScope {
577 constructor(detached = false) {
578 /**
579 * @internal
580 */
581 this.active = true;
582 /**
583 * @internal
584 */
585 this.effects = [];
586 /**
587 * @internal
588 */
589 this.cleanups = [];
590 if (!detached && activeEffectScope) {
591 this.parent = activeEffectScope;
592 this.index =
593 (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
594 }
595 }
596 run(fn) {
597 if (this.active) {
598 const currentEffectScope = activeEffectScope;
599 try {
600 activeEffectScope = this;
601 return fn();
602 }
603 finally {
604 activeEffectScope = currentEffectScope;
605 }
606 }
607 else {
608 warn(`cannot run an inactive effect scope.`);
609 }
610 }
611 /**
612 * This should only be called on non-detached scopes
613 * @internal
614 */
615 on() {
616 activeEffectScope = this;
617 }
618 /**
619 * This should only be called on non-detached scopes
620 * @internal
621 */
622 off() {
623 activeEffectScope = this.parent;
624 }
625 stop(fromParent) {
626 if (this.active) {
627 let i, l;
628 for (i = 0, l = this.effects.length; i < l; i++) {
629 this.effects[i].stop();
630 }
631 for (i = 0, l = this.cleanups.length; i < l; i++) {
632 this.cleanups[i]();
633 }
634 if (this.scopes) {
635 for (i = 0, l = this.scopes.length; i < l; i++) {
636 this.scopes[i].stop(true);
637 }
638 }
639 // nested scope, dereference from parent to avoid memory leaks
640 if (this.parent && !fromParent) {
641 // optimized O(1) removal
642 const last = this.parent.scopes.pop();
643 if (last && last !== this) {
644 this.parent.scopes[this.index] = last;
645 last.index = this.index;
646 }
647 }
648 this.active = false;
649 }
650 }
651}
652function effectScope(detached) {
653 return new EffectScope(detached);
654}
655function recordEffectScope(effect, scope = activeEffectScope) {
656 if (scope && scope.active) {
657 scope.effects.push(effect);
658 }
659}
660function getCurrentScope() {
661 return activeEffectScope;
662}
663function onScopeDispose(fn) {
664 if (activeEffectScope) {
665 activeEffectScope.cleanups.push(fn);
666 }
667 else {
668 warn(`onScopeDispose() is called when there is no active effect scope` +
669 ` to be associated with.`);
670 }
671}
672
673const createDep = (effects) => {
674 const dep = new Set(effects);
675 dep.w = 0;
676 dep.n = 0;
677 return dep;
678};
679const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
680const newTracked = (dep) => (dep.n & trackOpBit) > 0;
681const initDepMarkers = ({ deps }) => {
682 if (deps.length) {
683 for (let i = 0; i < deps.length; i++) {
684 deps[i].w |= trackOpBit; // set was tracked
685 }
686 }
687};
688const finalizeDepMarkers = (effect) => {
689 const { deps } = effect;
690 if (deps.length) {
691 let ptr = 0;
692 for (let i = 0; i < deps.length; i++) {
693 const dep = deps[i];
694 if (wasTracked(dep) && !newTracked(dep)) {
695 dep.delete(effect);
696 }
697 else {
698 deps[ptr++] = dep;
699 }
700 // clear bits
701 dep.w &= ~trackOpBit;
702 dep.n &= ~trackOpBit;
703 }
704 deps.length = ptr;
705 }
706};
707
708const targetMap = new WeakMap();
709// The number of effects currently being tracked recursively.
710let effectTrackDepth = 0;
711let trackOpBit = 1;
712/**
713 * The bitwise track markers support at most 30 levels of recursion.
714 * This value is chosen to enable modern JS engines to use a SMI on all platforms.
715 * When recursion depth is greater, fall back to using a full cleanup.
716 */
717const maxMarkerBits = 30;
718let activeEffect;
719const ITERATE_KEY = Symbol('iterate' );
720const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
721class ReactiveEffect {
722 constructor(fn, scheduler = null, scope) {
723 this.fn = fn;
724 this.scheduler = scheduler;
725 this.active = true;
726 this.deps = [];
727 this.parent = undefined;
728 recordEffectScope(this, scope);
729 }
730 run() {
731 if (!this.active) {
732 return this.fn();
733 }
734 let parent = activeEffect;
735 let lastShouldTrack = shouldTrack;
736 while (parent) {
737 if (parent === this) {
738 return;
739 }
740 parent = parent.parent;
741 }
742 try {
743 this.parent = activeEffect;
744 activeEffect = this;
745 shouldTrack = true;
746 trackOpBit = 1 << ++effectTrackDepth;
747 if (effectTrackDepth <= maxMarkerBits) {
748 initDepMarkers(this);
749 }
750 else {
751 cleanupEffect(this);
752 }
753 return this.fn();
754 }
755 finally {
756 if (effectTrackDepth <= maxMarkerBits) {
757 finalizeDepMarkers(this);
758 }
759 trackOpBit = 1 << --effectTrackDepth;
760 activeEffect = this.parent;
761 shouldTrack = lastShouldTrack;
762 this.parent = undefined;
763 if (this.deferStop) {
764 this.stop();
765 }
766 }
767 }
768 stop() {
769 // stopped while running itself - defer the cleanup
770 if (activeEffect === this) {
771 this.deferStop = true;
772 }
773 else if (this.active) {
774 cleanupEffect(this);
775 if (this.onStop) {
776 this.onStop();
777 }
778 this.active = false;
779 }
780 }
781}
782function cleanupEffect(effect) {
783 const { deps } = effect;
784 if (deps.length) {
785 for (let i = 0; i < deps.length; i++) {
786 deps[i].delete(effect);
787 }
788 deps.length = 0;
789 }
790}
791function effect(fn, options) {
792 if (fn.effect) {
793 fn = fn.effect.fn;
794 }
795 const _effect = new ReactiveEffect(fn);
796 if (options) {
797 extend(_effect, options);
798 if (options.scope)
799 recordEffectScope(_effect, options.scope);
800 }
801 if (!options || !options.lazy) {
802 _effect.run();
803 }
804 const runner = _effect.run.bind(_effect);
805 runner.effect = _effect;
806 return runner;
807}
808function stop(runner) {
809 runner.effect.stop();
810}
811let shouldTrack = true;
812const trackStack = [];
813function pauseTracking() {
814 trackStack.push(shouldTrack);
815 shouldTrack = false;
816}
817function resetTracking() {
818 const last = trackStack.pop();
819 shouldTrack = last === undefined ? true : last;
820}
821function track(target, type, key) {
822 if (shouldTrack && activeEffect) {
823 let depsMap = targetMap.get(target);
824 if (!depsMap) {
825 targetMap.set(target, (depsMap = new Map()));
826 }
827 let dep = depsMap.get(key);
828 if (!dep) {
829 depsMap.set(key, (dep = createDep()));
830 }
831 const eventInfo = { effect: activeEffect, target, type, key }
832 ;
833 trackEffects(dep, eventInfo);
834 }
835}
836function trackEffects(dep, debuggerEventExtraInfo) {
837 let shouldTrack = false;
838 if (effectTrackDepth <= maxMarkerBits) {
839 if (!newTracked(dep)) {
840 dep.n |= trackOpBit; // set newly tracked
841 shouldTrack = !wasTracked(dep);
842 }
843 }
844 else {
845 // Full cleanup mode.
846 shouldTrack = !dep.has(activeEffect);
847 }
848 if (shouldTrack) {
849 dep.add(activeEffect);
850 activeEffect.deps.push(dep);
851 if (activeEffect.onTrack) {
852 activeEffect.onTrack({
853 effect: activeEffect,
854 ...debuggerEventExtraInfo
855 });
856 }
857 }
858}
859function trigger(target, type, key, newValue, oldValue, oldTarget) {
860 const depsMap = targetMap.get(target);
861 if (!depsMap) {
862 // never been tracked
863 return;
864 }
865 let deps = [];
866 if (type === "clear" /* TriggerOpTypes.CLEAR */) {
867 // collection being cleared
868 // trigger all effects for target
869 deps = [...depsMap.values()];
870 }
871 else if (key === 'length' && isArray(target)) {
872 depsMap.forEach((dep, key) => {
873 if (key === 'length' || key >= newValue) {
874 deps.push(dep);
875 }
876 });
877 }
878 else {
879 // schedule runs for SET | ADD | DELETE
880 if (key !== void 0) {
881 deps.push(depsMap.get(key));
882 }
883 // also run for iteration key on ADD | DELETE | Map.SET
884 switch (type) {
885 case "add" /* TriggerOpTypes.ADD */:
886 if (!isArray(target)) {
887 deps.push(depsMap.get(ITERATE_KEY));
888 if (isMap(target)) {
889 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
890 }
891 }
892 else if (isIntegerKey(key)) {
893 // new index added to array -> length changes
894 deps.push(depsMap.get('length'));
895 }
896 break;
897 case "delete" /* TriggerOpTypes.DELETE */:
898 if (!isArray(target)) {
899 deps.push(depsMap.get(ITERATE_KEY));
900 if (isMap(target)) {
901 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
902 }
903 }
904 break;
905 case "set" /* TriggerOpTypes.SET */:
906 if (isMap(target)) {
907 deps.push(depsMap.get(ITERATE_KEY));
908 }
909 break;
910 }
911 }
912 const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
913 ;
914 if (deps.length === 1) {
915 if (deps[0]) {
916 {
917 triggerEffects(deps[0], eventInfo);
918 }
919 }
920 }
921 else {
922 const effects = [];
923 for (const dep of deps) {
924 if (dep) {
925 effects.push(...dep);
926 }
927 }
928 {
929 triggerEffects(createDep(effects), eventInfo);
930 }
931 }
932}
933function triggerEffects(dep, debuggerEventExtraInfo) {
934 // spread into array for stabilization
935 const effects = isArray(dep) ? dep : [...dep];
936 for (const effect of effects) {
937 if (effect.computed) {
938 triggerEffect(effect, debuggerEventExtraInfo);
939 }
940 }
941 for (const effect of effects) {
942 if (!effect.computed) {
943 triggerEffect(effect, debuggerEventExtraInfo);
944 }
945 }
946}
947function triggerEffect(effect, debuggerEventExtraInfo) {
948 if (effect !== activeEffect || effect.allowRecurse) {
949 if (effect.onTrigger) {
950 effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
951 }
952 if (effect.scheduler) {
953 effect.scheduler();
954 }
955 else {
956 effect.run();
957 }
958 }
959}
960
961const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
962const builtInSymbols = new Set(
963/*#__PURE__*/
964Object.getOwnPropertyNames(Symbol)
965 // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
966 // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
967 // function
968 .filter(key => key !== 'arguments' && key !== 'caller')
969 .map(key => Symbol[key])
970 .filter(isSymbol));
971const get = /*#__PURE__*/ createGetter();
972const shallowGet = /*#__PURE__*/ createGetter(false, true);
973const readonlyGet = /*#__PURE__*/ createGetter(true);
974const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
975const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
976function createArrayInstrumentations() {
977 const instrumentations = {};
978 ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
979 instrumentations[key] = function (...args) {
980 const arr = toRaw(this);
981 for (let i = 0, l = this.length; i < l; i++) {
982 track(arr, "get" /* TrackOpTypes.GET */, i + '');
983 }
984 // we run the method using the original args first (which may be reactive)
985 const res = arr[key](...args);
986 if (res === -1 || res === false) {
987 // if that didn't work, run it again using raw values.
988 return arr[key](...args.map(toRaw));
989 }
990 else {
991 return res;
992 }
993 };
994 });
995 ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
996 instrumentations[key] = function (...args) {
997 pauseTracking();
998 const res = toRaw(this)[key].apply(this, args);
999 resetTracking();
1000 return res;
1001 };
1002 });
1003 return instrumentations;
1004}
1005function createGetter(isReadonly = false, shallow = false) {
1006 return function get(target, key, receiver) {
1007 if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
1008 return !isReadonly;
1009 }
1010 else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
1011 return isReadonly;
1012 }
1013 else if (key === "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */) {
1014 return shallow;
1015 }
1016 else if (key === "__v_raw" /* ReactiveFlags.RAW */ &&
1017 receiver ===
1018 (isReadonly
1019 ? shallow
1020 ? shallowReadonlyMap
1021 : readonlyMap
1022 : shallow
1023 ? shallowReactiveMap
1024 : reactiveMap).get(target)) {
1025 return target;
1026 }
1027 const targetIsArray = isArray(target);
1028 if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
1029 return Reflect.get(arrayInstrumentations, key, receiver);
1030 }
1031 const res = Reflect.get(target, key, receiver);
1032 if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
1033 return res;
1034 }
1035 if (!isReadonly) {
1036 track(target, "get" /* TrackOpTypes.GET */, key);
1037 }
1038 if (shallow) {
1039 return res;
1040 }
1041 if (isRef(res)) {
1042 // ref unwrapping - skip unwrap for Array + integer key.
1043 return targetIsArray && isIntegerKey(key) ? res : res.value;
1044 }
1045 if (isObject(res)) {
1046 // Convert returned value into a proxy as well. we do the isObject check
1047 // here to avoid invalid value warning. Also need to lazy access readonly
1048 // and reactive here to avoid circular dependency.
1049 return isReadonly ? readonly(res) : reactive(res);
1050 }
1051 return res;
1052 };
1053}
1054const set = /*#__PURE__*/ createSetter();
1055const shallowSet = /*#__PURE__*/ createSetter(true);
1056function createSetter(shallow = false) {
1057 return function set(target, key, value, receiver) {
1058 let oldValue = target[key];
1059 if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
1060 return false;
1061 }
1062 if (!shallow) {
1063 if (!isShallow(value) && !isReadonly(value)) {
1064 oldValue = toRaw(oldValue);
1065 value = toRaw(value);
1066 }
1067 if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
1068 oldValue.value = value;
1069 return true;
1070 }
1071 }
1072 const hadKey = isArray(target) && isIntegerKey(key)
1073 ? Number(key) < target.length
1074 : hasOwn(target, key);
1075 const result = Reflect.set(target, key, value, receiver);
1076 // don't trigger if target is something up in the prototype chain of original
1077 if (target === toRaw(receiver)) {
1078 if (!hadKey) {
1079 trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
1080 }
1081 else if (hasChanged(value, oldValue)) {
1082 trigger(target, "set" /* TriggerOpTypes.SET */, key, value, oldValue);
1083 }
1084 }
1085 return result;
1086 };
1087}
1088function deleteProperty(target, key) {
1089 const hadKey = hasOwn(target, key);
1090 const oldValue = target[key];
1091 const result = Reflect.deleteProperty(target, key);
1092 if (result && hadKey) {
1093 trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined, oldValue);
1094 }
1095 return result;
1096}
1097function has(target, key) {
1098 const result = Reflect.has(target, key);
1099 if (!isSymbol(key) || !builtInSymbols.has(key)) {
1100 track(target, "has" /* TrackOpTypes.HAS */, key);
1101 }
1102 return result;
1103}
1104function ownKeys(target) {
1105 track(target, "iterate" /* TrackOpTypes.ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
1106 return Reflect.ownKeys(target);
1107}
1108const mutableHandlers = {
1109 get,
1110 set,
1111 deleteProperty,
1112 has,
1113 ownKeys
1114};
1115const readonlyHandlers = {
1116 get: readonlyGet,
1117 set(target, key) {
1118 {
1119 warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
1120 }
1121 return true;
1122 },
1123 deleteProperty(target, key) {
1124 {
1125 warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
1126 }
1127 return true;
1128 }
1129};
1130const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
1131 get: shallowGet,
1132 set: shallowSet
1133});
1134// Props handlers are special in the sense that it should not unwrap top-level
1135// refs (in order to allow refs to be explicitly passed down), but should
1136// retain the reactivity of the normal readonly object.
1137const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
1138 get: shallowReadonlyGet
1139});
1140
1141const toShallow = (value) => value;
1142const getProto = (v) => Reflect.getPrototypeOf(v);
1143function get$1(target, key, isReadonly = false, isShallow = false) {
1144 // #1772: readonly(reactive(Map)) should return readonly + reactive version
1145 // of the value
1146 target = target["__v_raw" /* ReactiveFlags.RAW */];
1147 const rawTarget = toRaw(target);
1148 const rawKey = toRaw(key);
1149 if (!isReadonly) {
1150 if (key !== rawKey) {
1151 track(rawTarget, "get" /* TrackOpTypes.GET */, key);
1152 }
1153 track(rawTarget, "get" /* TrackOpTypes.GET */, rawKey);
1154 }
1155 const { has } = getProto(rawTarget);
1156 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
1157 if (has.call(rawTarget, key)) {
1158 return wrap(target.get(key));
1159 }
1160 else if (has.call(rawTarget, rawKey)) {
1161 return wrap(target.get(rawKey));
1162 }
1163 else if (target !== rawTarget) {
1164 // #3602 readonly(reactive(Map))
1165 // ensure that the nested reactive `Map` can do tracking for itself
1166 target.get(key);
1167 }
1168}
1169function has$1(key, isReadonly = false) {
1170 const target = this["__v_raw" /* ReactiveFlags.RAW */];
1171 const rawTarget = toRaw(target);
1172 const rawKey = toRaw(key);
1173 if (!isReadonly) {
1174 if (key !== rawKey) {
1175 track(rawTarget, "has" /* TrackOpTypes.HAS */, key);
1176 }
1177 track(rawTarget, "has" /* TrackOpTypes.HAS */, rawKey);
1178 }
1179 return key === rawKey
1180 ? target.has(key)
1181 : target.has(key) || target.has(rawKey);
1182}
1183function size(target, isReadonly = false) {
1184 target = target["__v_raw" /* ReactiveFlags.RAW */];
1185 !isReadonly && track(toRaw(target), "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
1186 return Reflect.get(target, 'size', target);
1187}
1188function add(value) {
1189 value = toRaw(value);
1190 const target = toRaw(this);
1191 const proto = getProto(target);
1192 const hadKey = proto.has.call(target, value);
1193 if (!hadKey) {
1194 target.add(value);
1195 trigger(target, "add" /* TriggerOpTypes.ADD */, value, value);
1196 }
1197 return this;
1198}
1199function set$1(key, value) {
1200 value = toRaw(value);
1201 const target = toRaw(this);
1202 const { has, get } = getProto(target);
1203 let hadKey = has.call(target, key);
1204 if (!hadKey) {
1205 key = toRaw(key);
1206 hadKey = has.call(target, key);
1207 }
1208 else {
1209 checkIdentityKeys(target, has, key);
1210 }
1211 const oldValue = get.call(target, key);
1212 target.set(key, value);
1213 if (!hadKey) {
1214 trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
1215 }
1216 else if (hasChanged(value, oldValue)) {
1217 trigger(target, "set" /* TriggerOpTypes.SET */, key, value, oldValue);
1218 }
1219 return this;
1220}
1221function deleteEntry(key) {
1222 const target = toRaw(this);
1223 const { has, get } = getProto(target);
1224 let hadKey = has.call(target, key);
1225 if (!hadKey) {
1226 key = toRaw(key);
1227 hadKey = has.call(target, key);
1228 }
1229 else {
1230 checkIdentityKeys(target, has, key);
1231 }
1232 const oldValue = get ? get.call(target, key) : undefined;
1233 // forward the operation before queueing reactions
1234 const result = target.delete(key);
1235 if (hadKey) {
1236 trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined, oldValue);
1237 }
1238 return result;
1239}
1240function clear() {
1241 const target = toRaw(this);
1242 const hadItems = target.size !== 0;
1243 const oldTarget = isMap(target)
1244 ? new Map(target)
1245 : new Set(target)
1246 ;
1247 // forward the operation before queueing reactions
1248 const result = target.clear();
1249 if (hadItems) {
1250 trigger(target, "clear" /* TriggerOpTypes.CLEAR */, undefined, undefined, oldTarget);
1251 }
1252 return result;
1253}
1254function createForEach(isReadonly, isShallow) {
1255 return function forEach(callback, thisArg) {
1256 const observed = this;
1257 const target = observed["__v_raw" /* ReactiveFlags.RAW */];
1258 const rawTarget = toRaw(target);
1259 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
1260 !isReadonly && track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
1261 return target.forEach((value, key) => {
1262 // important: make sure the callback is
1263 // 1. invoked with the reactive map as `this` and 3rd arg
1264 // 2. the value received should be a corresponding reactive/readonly.
1265 return callback.call(thisArg, wrap(value), wrap(key), observed);
1266 });
1267 };
1268}
1269function createIterableMethod(method, isReadonly, isShallow) {
1270 return function (...args) {
1271 const target = this["__v_raw" /* ReactiveFlags.RAW */];
1272 const rawTarget = toRaw(target);
1273 const targetIsMap = isMap(rawTarget);
1274 const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
1275 const isKeyOnly = method === 'keys' && targetIsMap;
1276 const innerIterator = target[method](...args);
1277 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
1278 !isReadonly &&
1279 track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
1280 // return a wrapped iterator which returns observed versions of the
1281 // values emitted from the real iterator
1282 return {
1283 // iterator protocol
1284 next() {
1285 const { value, done } = innerIterator.next();
1286 return done
1287 ? { value, done }
1288 : {
1289 value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1290 done
1291 };
1292 },
1293 // iterable protocol
1294 [Symbol.iterator]() {
1295 return this;
1296 }
1297 };
1298 };
1299}
1300function createReadonlyMethod(type) {
1301 return function (...args) {
1302 {
1303 const key = args[0] ? `on key "${args[0]}" ` : ``;
1304 console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
1305 }
1306 return type === "delete" /* TriggerOpTypes.DELETE */ ? false : this;
1307 };
1308}
1309function createInstrumentations() {
1310 const mutableInstrumentations = {
1311 get(key) {
1312 return get$1(this, key);
1313 },
1314 get size() {
1315 return size(this);
1316 },
1317 has: has$1,
1318 add,
1319 set: set$1,
1320 delete: deleteEntry,
1321 clear,
1322 forEach: createForEach(false, false)
1323 };
1324 const shallowInstrumentations = {
1325 get(key) {
1326 return get$1(this, key, false, true);
1327 },
1328 get size() {
1329 return size(this);
1330 },
1331 has: has$1,
1332 add,
1333 set: set$1,
1334 delete: deleteEntry,
1335 clear,
1336 forEach: createForEach(false, true)
1337 };
1338 const readonlyInstrumentations = {
1339 get(key) {
1340 return get$1(this, key, true);
1341 },
1342 get size() {
1343 return size(this, true);
1344 },
1345 has(key) {
1346 return has$1.call(this, key, true);
1347 },
1348 add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
1349 set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
1350 delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
1351 clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
1352 forEach: createForEach(true, false)
1353 };
1354 const shallowReadonlyInstrumentations = {
1355 get(key) {
1356 return get$1(this, key, true, true);
1357 },
1358 get size() {
1359 return size(this, true);
1360 },
1361 has(key) {
1362 return has$1.call(this, key, true);
1363 },
1364 add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
1365 set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
1366 delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
1367 clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
1368 forEach: createForEach(true, true)
1369 };
1370 const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
1371 iteratorMethods.forEach(method => {
1372 mutableInstrumentations[method] = createIterableMethod(method, false, false);
1373 readonlyInstrumentations[method] = createIterableMethod(method, true, false);
1374 shallowInstrumentations[method] = createIterableMethod(method, false, true);
1375 shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
1376 });
1377 return [
1378 mutableInstrumentations,
1379 readonlyInstrumentations,
1380 shallowInstrumentations,
1381 shallowReadonlyInstrumentations
1382 ];
1383}
1384const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
1385function createInstrumentationGetter(isReadonly, shallow) {
1386 const instrumentations = shallow
1387 ? isReadonly
1388 ? shallowReadonlyInstrumentations
1389 : shallowInstrumentations
1390 : isReadonly
1391 ? readonlyInstrumentations
1392 : mutableInstrumentations;
1393 return (target, key, receiver) => {
1394 if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
1395 return !isReadonly;
1396 }
1397 else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
1398 return isReadonly;
1399 }
1400 else if (key === "__v_raw" /* ReactiveFlags.RAW */) {
1401 return target;
1402 }
1403 return Reflect.get(hasOwn(instrumentations, key) && key in target
1404 ? instrumentations
1405 : target, key, receiver);
1406 };
1407}
1408const mutableCollectionHandlers = {
1409 get: /*#__PURE__*/ createInstrumentationGetter(false, false)
1410};
1411const shallowCollectionHandlers = {
1412 get: /*#__PURE__*/ createInstrumentationGetter(false, true)
1413};
1414const readonlyCollectionHandlers = {
1415 get: /*#__PURE__*/ createInstrumentationGetter(true, false)
1416};
1417const shallowReadonlyCollectionHandlers = {
1418 get: /*#__PURE__*/ createInstrumentationGetter(true, true)
1419};
1420function checkIdentityKeys(target, has, key) {
1421 const rawKey = toRaw(key);
1422 if (rawKey !== key && has.call(target, rawKey)) {
1423 const type = toRawType(target);
1424 console.warn(`Reactive ${type} contains both the raw and reactive ` +
1425 `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
1426 `which can lead to inconsistencies. ` +
1427 `Avoid differentiating between the raw and reactive versions ` +
1428 `of an object and only use the reactive version if possible.`);
1429 }
1430}
1431
1432const reactiveMap = new WeakMap();
1433const shallowReactiveMap = new WeakMap();
1434const readonlyMap = new WeakMap();
1435const shallowReadonlyMap = new WeakMap();
1436function targetTypeMap(rawType) {
1437 switch (rawType) {
1438 case 'Object':
1439 case 'Array':
1440 return 1 /* TargetType.COMMON */;
1441 case 'Map':
1442 case 'Set':
1443 case 'WeakMap':
1444 case 'WeakSet':
1445 return 2 /* TargetType.COLLECTION */;
1446 default:
1447 return 0 /* TargetType.INVALID */;
1448 }
1449}
1450function getTargetType(value) {
1451 return value["__v_skip" /* ReactiveFlags.SKIP */] || !Object.isExtensible(value)
1452 ? 0 /* TargetType.INVALID */
1453 : targetTypeMap(toRawType(value));
1454}
1455function reactive(target) {
1456 // if trying to observe a readonly proxy, return the readonly version.
1457 if (isReadonly(target)) {
1458 return target;
1459 }
1460 return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1461}
1462/**
1463 * Return a shallowly-reactive copy of the original object, where only the root
1464 * level properties are reactive. It also does not auto-unwrap refs (even at the
1465 * root level).
1466 */
1467function shallowReactive(target) {
1468 return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
1469}
1470/**
1471 * Creates a readonly copy of the original object. Note the returned copy is not
1472 * made reactive, but `readonly` can be called on an already reactive object.
1473 */
1474function readonly(target) {
1475 return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1476}
1477/**
1478 * Returns a reactive-copy of the original object, where only the root level
1479 * properties are readonly, and does NOT unwrap refs nor recursively convert
1480 * returned properties.
1481 * This is used for creating the props proxy object for stateful components.
1482 */
1483function shallowReadonly(target) {
1484 return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1485}
1486function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
1487 if (!isObject(target)) {
1488 {
1489 console.warn(`value cannot be made reactive: ${String(target)}`);
1490 }
1491 return target;
1492 }
1493 // target is already a Proxy, return it.
1494 // exception: calling readonly() on a reactive object
1495 if (target["__v_raw" /* ReactiveFlags.RAW */] &&
1496 !(isReadonly && target["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */])) {
1497 return target;
1498 }
1499 // target already has corresponding Proxy
1500 const existingProxy = proxyMap.get(target);
1501 if (existingProxy) {
1502 return existingProxy;
1503 }
1504 // only specific value types can be observed.
1505 const targetType = getTargetType(target);
1506 if (targetType === 0 /* TargetType.INVALID */) {
1507 return target;
1508 }
1509 const proxy = new Proxy(target, targetType === 2 /* TargetType.COLLECTION */ ? collectionHandlers : baseHandlers);
1510 proxyMap.set(target, proxy);
1511 return proxy;
1512}
1513function isReactive(value) {
1514 if (isReadonly(value)) {
1515 return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
1516 }
1517 return !!(value && value["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */]);
1518}
1519function isReadonly(value) {
1520 return !!(value && value["__v_isReadonly" /* ReactiveFlags.IS_READONLY */]);
1521}
1522function isShallow(value) {
1523 return !!(value && value["__v_isShallow" /* ReactiveFlags.IS_SHALLOW */]);
1524}
1525function isProxy(value) {
1526 return isReactive(value) || isReadonly(value);
1527}
1528function toRaw(observed) {
1529 const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
1530 return raw ? toRaw(raw) : observed;
1531}
1532function markRaw(value) {
1533 def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
1534 return value;
1535}
1536const toReactive = (value) => isObject(value) ? reactive(value) : value;
1537const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1538
1539function trackRefValue(ref) {
1540 if (shouldTrack && activeEffect) {
1541 ref = toRaw(ref);
1542 {
1543 trackEffects(ref.dep || (ref.dep = createDep()), {
1544 target: ref,
1545 type: "get" /* TrackOpTypes.GET */,
1546 key: 'value'
1547 });
1548 }
1549 }
1550}
1551function triggerRefValue(ref, newVal) {
1552 ref = toRaw(ref);
1553 if (ref.dep) {
1554 {
1555 triggerEffects(ref.dep, {
1556 target: ref,
1557 type: "set" /* TriggerOpTypes.SET */,
1558 key: 'value',
1559 newValue: newVal
1560 });
1561 }
1562 }
1563}
1564function isRef(r) {
1565 return !!(r && r.__v_isRef === true);
1566}
1567function ref(value) {
1568 return createRef(value, false);
1569}
1570function shallowRef(value) {
1571 return createRef(value, true);
1572}
1573function createRef(rawValue, shallow) {
1574 if (isRef(rawValue)) {
1575 return rawValue;
1576 }
1577 return new RefImpl(rawValue, shallow);
1578}
1579class RefImpl {
1580 constructor(value, __v_isShallow) {
1581 this.__v_isShallow = __v_isShallow;
1582 this.dep = undefined;
1583 this.__v_isRef = true;
1584 this._rawValue = __v_isShallow ? value : toRaw(value);
1585 this._value = __v_isShallow ? value : toReactive(value);
1586 }
1587 get value() {
1588 trackRefValue(this);
1589 return this._value;
1590 }
1591 set value(newVal) {
1592 const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
1593 newVal = useDirectValue ? newVal : toRaw(newVal);
1594 if (hasChanged(newVal, this._rawValue)) {
1595 this._rawValue = newVal;
1596 this._value = useDirectValue ? newVal : toReactive(newVal);
1597 triggerRefValue(this, newVal);
1598 }
1599 }
1600}
1601function triggerRef(ref) {
1602 triggerRefValue(ref, ref.value );
1603}
1604function unref(ref) {
1605 return isRef(ref) ? ref.value : ref;
1606}
1607const shallowUnwrapHandlers = {
1608 get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
1609 set: (target, key, value, receiver) => {
1610 const oldValue = target[key];
1611 if (isRef(oldValue) && !isRef(value)) {
1612 oldValue.value = value;
1613 return true;
1614 }
1615 else {
1616 return Reflect.set(target, key, value, receiver);
1617 }
1618 }
1619};
1620function proxyRefs(objectWithRefs) {
1621 return isReactive(objectWithRefs)
1622 ? objectWithRefs
1623 : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1624}
1625class CustomRefImpl {
1626 constructor(factory) {
1627 this.dep = undefined;
1628 this.__v_isRef = true;
1629 const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
1630 this._get = get;
1631 this._set = set;
1632 }
1633 get value() {
1634 return this._get();
1635 }
1636 set value(newVal) {
1637 this._set(newVal);
1638 }
1639}
1640function customRef(factory) {
1641 return new CustomRefImpl(factory);
1642}
1643function toRefs(object) {
1644 if (!isProxy(object)) {
1645 console.warn(`toRefs() expects a reactive object but received a plain one.`);
1646 }
1647 const ret = isArray(object) ? new Array(object.length) : {};
1648 for (const key in object) {
1649 ret[key] = toRef(object, key);
1650 }
1651 return ret;
1652}
1653class ObjectRefImpl {
1654 constructor(_object, _key, _defaultValue) {
1655 this._object = _object;
1656 this._key = _key;
1657 this._defaultValue = _defaultValue;
1658 this.__v_isRef = true;
1659 }
1660 get value() {
1661 const val = this._object[this._key];
1662 return val === undefined ? this._defaultValue : val;
1663 }
1664 set value(newVal) {
1665 this._object[this._key] = newVal;
1666 }
1667}
1668function toRef(object, key, defaultValue) {
1669 const val = object[key];
1670 return isRef(val)
1671 ? val
1672 : new ObjectRefImpl(object, key, defaultValue);
1673}
1674
1675var _a;
1676class ComputedRefImpl {
1677 constructor(getter, _setter, isReadonly, isSSR) {
1678 this._setter = _setter;
1679 this.dep = undefined;
1680 this.__v_isRef = true;
1681 this[_a] = false;
1682 this._dirty = true;
1683 this.effect = new ReactiveEffect(getter, () => {
1684 if (!this._dirty) {
1685 this._dirty = true;
1686 triggerRefValue(this);
1687 }
1688 });
1689 this.effect.computed = this;
1690 this.effect.active = this._cacheable = !isSSR;
1691 this["__v_isReadonly" /* ReactiveFlags.IS_READONLY */] = isReadonly;
1692 }
1693 get value() {
1694 // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1695 const self = toRaw(this);
1696 trackRefValue(self);
1697 if (self._dirty || !self._cacheable) {
1698 self._dirty = false;
1699 self._value = self.effect.run();
1700 }
1701 return self._value;
1702 }
1703 set value(newValue) {
1704 this._setter(newValue);
1705 }
1706}
1707_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
1708function computed(getterOrOptions, debugOptions, isSSR = false) {
1709 let getter;
1710 let setter;
1711 const onlyGetter = isFunction(getterOrOptions);
1712 if (onlyGetter) {
1713 getter = getterOrOptions;
1714 setter = () => {
1715 console.warn('Write operation failed: computed value is readonly');
1716 }
1717 ;
1718 }
1719 else {
1720 getter = getterOrOptions.get;
1721 setter = getterOrOptions.set;
1722 }
1723 const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1724 if (debugOptions && !isSSR) {
1725 cRef.effect.onTrack = debugOptions.onTrack;
1726 cRef.effect.onTrigger = debugOptions.onTrigger;
1727 }
1728 return cRef;
1729}
1730
1731const stack = [];
1732function pushWarningContext(vnode) {
1733 stack.push(vnode);
1734}
1735function popWarningContext() {
1736 stack.pop();
1737}
1738function warn$1(msg, ...args) {
1739 // avoid props formatting or warn handler tracking deps that might be mutated
1740 // during patch, leading to infinite recursion.
1741 pauseTracking();
1742 const instance = stack.length ? stack[stack.length - 1].component : null;
1743 const appWarnHandler = instance && instance.appContext.config.warnHandler;
1744 const trace = getComponentTrace();
1745 if (appWarnHandler) {
1746 callWithErrorHandling(appWarnHandler, instance, 11 /* ErrorCodes.APP_WARN_HANDLER */, [
1747 msg + args.join(''),
1748 instance && instance.proxy,
1749 trace
1750 .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
1751 .join('\n'),
1752 trace
1753 ]);
1754 }
1755 else {
1756 const warnArgs = [`[Vue warn]: ${msg}`, ...args];
1757 /* istanbul ignore if */
1758 if (trace.length &&
1759 // avoid spamming console during tests
1760 !false) {
1761 warnArgs.push(`\n`, ...formatTrace(trace));
1762 }
1763 console.warn(...warnArgs);
1764 }
1765 resetTracking();
1766}
1767function getComponentTrace() {
1768 let currentVNode = stack[stack.length - 1];
1769 if (!currentVNode) {
1770 return [];
1771 }
1772 // we can't just use the stack because it will be incomplete during updates
1773 // that did not start from the root. Re-construct the parent chain using
1774 // instance parent pointers.
1775 const normalizedStack = [];
1776 while (currentVNode) {
1777 const last = normalizedStack[0];
1778 if (last && last.vnode === currentVNode) {
1779 last.recurseCount++;
1780 }
1781 else {
1782 normalizedStack.push({
1783 vnode: currentVNode,
1784 recurseCount: 0
1785 });
1786 }
1787 const parentInstance = currentVNode.component && currentVNode.component.parent;
1788 currentVNode = parentInstance && parentInstance.vnode;
1789 }
1790 return normalizedStack;
1791}
1792/* istanbul ignore next */
1793function formatTrace(trace) {
1794 const logs = [];
1795 trace.forEach((entry, i) => {
1796 logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
1797 });
1798 return logs;
1799}
1800function formatTraceEntry({ vnode, recurseCount }) {
1801 const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
1802 const isRoot = vnode.component ? vnode.component.parent == null : false;
1803 const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
1804 const close = `>` + postfix;
1805 return vnode.props
1806 ? [open, ...formatProps(vnode.props), close]
1807 : [open + close];
1808}
1809/* istanbul ignore next */
1810function formatProps(props) {
1811 const res = [];
1812 const keys = Object.keys(props);
1813 keys.slice(0, 3).forEach(key => {
1814 res.push(...formatProp(key, props[key]));
1815 });
1816 if (keys.length > 3) {
1817 res.push(` ...`);
1818 }
1819 return res;
1820}
1821/* istanbul ignore next */
1822function formatProp(key, value, raw) {
1823 if (isString(value)) {
1824 value = JSON.stringify(value);
1825 return raw ? value : [`${key}=${value}`];
1826 }
1827 else if (typeof value === 'number' ||
1828 typeof value === 'boolean' ||
1829 value == null) {
1830 return raw ? value : [`${key}=${value}`];
1831 }
1832 else if (isRef(value)) {
1833 value = formatProp(key, toRaw(value.value), true);
1834 return raw ? value : [`${key}=Ref<`, value, `>`];
1835 }
1836 else if (isFunction(value)) {
1837 return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
1838 }
1839 else {
1840 value = toRaw(value);
1841 return raw ? value : [`${key}=`, value];
1842 }
1843}
1844
1845const ErrorTypeStrings = {
1846 ["sp" /* LifecycleHooks.SERVER_PREFETCH */]: 'serverPrefetch hook',
1847 ["bc" /* LifecycleHooks.BEFORE_CREATE */]: 'beforeCreate hook',
1848 ["c" /* LifecycleHooks.CREATED */]: 'created hook',
1849 ["bm" /* LifecycleHooks.BEFORE_MOUNT */]: 'beforeMount hook',
1850 ["m" /* LifecycleHooks.MOUNTED */]: 'mounted hook',
1851 ["bu" /* LifecycleHooks.BEFORE_UPDATE */]: 'beforeUpdate hook',
1852 ["u" /* LifecycleHooks.UPDATED */]: 'updated',
1853 ["bum" /* LifecycleHooks.BEFORE_UNMOUNT */]: 'beforeUnmount hook',
1854 ["um" /* LifecycleHooks.UNMOUNTED */]: 'unmounted hook',
1855 ["a" /* LifecycleHooks.ACTIVATED */]: 'activated hook',
1856 ["da" /* LifecycleHooks.DEACTIVATED */]: 'deactivated hook',
1857 ["ec" /* LifecycleHooks.ERROR_CAPTURED */]: 'errorCaptured hook',
1858 ["rtc" /* LifecycleHooks.RENDER_TRACKED */]: 'renderTracked hook',
1859 ["rtg" /* LifecycleHooks.RENDER_TRIGGERED */]: 'renderTriggered hook',
1860 [0 /* ErrorCodes.SETUP_FUNCTION */]: 'setup function',
1861 [1 /* ErrorCodes.RENDER_FUNCTION */]: 'render function',
1862 [2 /* ErrorCodes.WATCH_GETTER */]: 'watcher getter',
1863 [3 /* ErrorCodes.WATCH_CALLBACK */]: 'watcher callback',
1864 [4 /* ErrorCodes.WATCH_CLEANUP */]: 'watcher cleanup function',
1865 [5 /* ErrorCodes.NATIVE_EVENT_HANDLER */]: 'native event handler',
1866 [6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */]: 'component event handler',
1867 [7 /* ErrorCodes.VNODE_HOOK */]: 'vnode hook',
1868 [8 /* ErrorCodes.DIRECTIVE_HOOK */]: 'directive hook',
1869 [9 /* ErrorCodes.TRANSITION_HOOK */]: 'transition hook',
1870 [10 /* ErrorCodes.APP_ERROR_HANDLER */]: 'app errorHandler',
1871 [11 /* ErrorCodes.APP_WARN_HANDLER */]: 'app warnHandler',
1872 [12 /* ErrorCodes.FUNCTION_REF */]: 'ref function',
1873 [13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */]: 'async component loader',
1874 [14 /* ErrorCodes.SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
1875 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
1876};
1877function callWithErrorHandling(fn, instance, type, args) {
1878 let res;
1879 try {
1880 res = args ? fn(...args) : fn();
1881 }
1882 catch (err) {
1883 handleError(err, instance, type);
1884 }
1885 return res;
1886}
1887function callWithAsyncErrorHandling(fn, instance, type, args) {
1888 if (isFunction(fn)) {
1889 const res = callWithErrorHandling(fn, instance, type, args);
1890 if (res && isPromise(res)) {
1891 res.catch(err => {
1892 handleError(err, instance, type);
1893 });
1894 }
1895 return res;
1896 }
1897 const values = [];
1898 for (let i = 0; i < fn.length; i++) {
1899 values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
1900 }
1901 return values;
1902}
1903function handleError(err, instance, type, throwInDev = true) {
1904 const contextVNode = instance ? instance.vnode : null;
1905 if (instance) {
1906 let cur = instance.parent;
1907 // the exposed instance is the render proxy to keep it consistent with 2.x
1908 const exposedInstance = instance.proxy;
1909 // in production the hook receives only the error code
1910 const errorInfo = ErrorTypeStrings[type] ;
1911 while (cur) {
1912 const errorCapturedHooks = cur.ec;
1913 if (errorCapturedHooks) {
1914 for (let i = 0; i < errorCapturedHooks.length; i++) {
1915 if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
1916 return;
1917 }
1918 }
1919 }
1920 cur = cur.parent;
1921 }
1922 // app-level handling
1923 const appErrorHandler = instance.appContext.config.errorHandler;
1924 if (appErrorHandler) {
1925 callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
1926 return;
1927 }
1928 }
1929 logError(err, type, contextVNode, throwInDev);
1930}
1931function logError(err, type, contextVNode, throwInDev = true) {
1932 {
1933 const info = ErrorTypeStrings[type];
1934 if (contextVNode) {
1935 pushWarningContext(contextVNode);
1936 }
1937 warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
1938 if (contextVNode) {
1939 popWarningContext();
1940 }
1941 // crash in dev by default so it's more noticeable
1942 if (throwInDev) {
1943 throw err;
1944 }
1945 else {
1946 console.error(err);
1947 }
1948 }
1949}
1950
1951let isFlushing = false;
1952let isFlushPending = false;
1953const queue = [];
1954let flushIndex = 0;
1955const pendingPostFlushCbs = [];
1956let activePostFlushCbs = null;
1957let postFlushIndex = 0;
1958const resolvedPromise = /*#__PURE__*/ Promise.resolve();
1959let currentFlushPromise = null;
1960const RECURSION_LIMIT = 100;
1961function nextTick(fn) {
1962 const p = currentFlushPromise || resolvedPromise;
1963 return fn ? p.then(this ? fn.bind(this) : fn) : p;
1964}
1965// #2768
1966// Use binary-search to find a suitable position in the queue,
1967// so that the queue maintains the increasing order of job's id,
1968// which can prevent the job from being skipped and also can avoid repeated patching.
1969function findInsertionIndex(id) {
1970 // the start index should be `flushIndex + 1`
1971 let start = flushIndex + 1;
1972 let end = queue.length;
1973 while (start < end) {
1974 const middle = (start + end) >>> 1;
1975 const middleJobId = getId(queue[middle]);
1976 middleJobId < id ? (start = middle + 1) : (end = middle);
1977 }
1978 return start;
1979}
1980function queueJob(job) {
1981 // the dedupe search uses the startIndex argument of Array.includes()
1982 // by default the search index includes the current job that is being run
1983 // so it cannot recursively trigger itself again.
1984 // if the job is a watch() callback, the search will start with a +1 index to
1985 // allow it recursively trigger itself - it is the user's responsibility to
1986 // ensure it doesn't end up in an infinite loop.
1987 if (!queue.length ||
1988 !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) {
1989 if (job.id == null) {
1990 queue.push(job);
1991 }
1992 else {
1993 queue.splice(findInsertionIndex(job.id), 0, job);
1994 }
1995 queueFlush();
1996 }
1997}
1998function queueFlush() {
1999 if (!isFlushing && !isFlushPending) {
2000 isFlushPending = true;
2001 currentFlushPromise = resolvedPromise.then(flushJobs);
2002 }
2003}
2004function invalidateJob(job) {
2005 const i = queue.indexOf(job);
2006 if (i > flushIndex) {
2007 queue.splice(i, 1);
2008 }
2009}
2010function queuePostFlushCb(cb) {
2011 if (!isArray(cb)) {
2012 if (!activePostFlushCbs ||
2013 !activePostFlushCbs.includes(cb, cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex)) {
2014 pendingPostFlushCbs.push(cb);
2015 }
2016 }
2017 else {
2018 // if cb is an array, it is a component lifecycle hook which can only be
2019 // triggered by a job, which is already deduped in the main queue, so
2020 // we can skip duplicate check here to improve perf
2021 pendingPostFlushCbs.push(...cb);
2022 }
2023 queueFlush();
2024}
2025function flushPreFlushCbs(seen, i = flushIndex) {
2026 {
2027 seen = seen || new Map();
2028 }
2029 for (; i < queue.length; i++) {
2030 const cb = queue[i];
2031 if (cb && cb.pre) {
2032 if (checkRecursiveUpdates(seen, cb)) {
2033 continue;
2034 }
2035 queue.splice(i, 1);
2036 i--;
2037 cb();
2038 }
2039 }
2040}
2041function flushPostFlushCbs(seen) {
2042 if (pendingPostFlushCbs.length) {
2043 const deduped = [...new Set(pendingPostFlushCbs)];
2044 pendingPostFlushCbs.length = 0;
2045 // #1947 already has active queue, nested flushPostFlushCbs call
2046 if (activePostFlushCbs) {
2047 activePostFlushCbs.push(...deduped);
2048 return;
2049 }
2050 activePostFlushCbs = deduped;
2051 {
2052 seen = seen || new Map();
2053 }
2054 activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
2055 for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
2056 if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
2057 continue;
2058 }
2059 activePostFlushCbs[postFlushIndex]();
2060 }
2061 activePostFlushCbs = null;
2062 postFlushIndex = 0;
2063 }
2064}
2065const getId = (job) => job.id == null ? Infinity : job.id;
2066const comparator = (a, b) => {
2067 const diff = getId(a) - getId(b);
2068 if (diff === 0) {
2069 if (a.pre && !b.pre)
2070 return -1;
2071 if (b.pre && !a.pre)
2072 return 1;
2073 }
2074 return diff;
2075};
2076function flushJobs(seen) {
2077 isFlushPending = false;
2078 isFlushing = true;
2079 {
2080 seen = seen || new Map();
2081 }
2082 // Sort queue before flush.
2083 // This ensures that:
2084 // 1. Components are updated from parent to child. (because parent is always
2085 // created before the child so its render effect will have smaller
2086 // priority number)
2087 // 2. If a component is unmounted during a parent component's update,
2088 // its update can be skipped.
2089 queue.sort(comparator);
2090 // conditional usage of checkRecursiveUpdate must be determined out of
2091 // try ... catch block since Rollup by default de-optimizes treeshaking
2092 // inside try-catch. This can leave all warning code unshaked. Although
2093 // they would get eventually shaken by a minifier like terser, some minifiers
2094 // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
2095 const check = (job) => checkRecursiveUpdates(seen, job)
2096 ;
2097 try {
2098 for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
2099 const job = queue[flushIndex];
2100 if (job && job.active !== false) {
2101 if (true && check(job)) {
2102 continue;
2103 }
2104 // console.log(`running:`, job.id)
2105 callWithErrorHandling(job, null, 14 /* ErrorCodes.SCHEDULER */);
2106 }
2107 }
2108 }
2109 finally {
2110 flushIndex = 0;
2111 queue.length = 0;
2112 flushPostFlushCbs(seen);
2113 isFlushing = false;
2114 currentFlushPromise = null;
2115 // some postFlushCb queued jobs!
2116 // keep flushing until it drains.
2117 if (queue.length || pendingPostFlushCbs.length) {
2118 flushJobs(seen);
2119 }
2120 }
2121}
2122function checkRecursiveUpdates(seen, fn) {
2123 if (!seen.has(fn)) {
2124 seen.set(fn, 1);
2125 }
2126 else {
2127 const count = seen.get(fn);
2128 if (count > RECURSION_LIMIT) {
2129 const instance = fn.ownerInstance;
2130 const componentName = instance && getComponentName(instance.type);
2131 warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
2132 `This means you have a reactive effect that is mutating its own ` +
2133 `dependencies and thus recursively triggering itself. Possible sources ` +
2134 `include component template, render function, updated hook or ` +
2135 `watcher source function.`);
2136 return true;
2137 }
2138 else {
2139 seen.set(fn, count + 1);
2140 }
2141 }
2142}
2143
2144/* eslint-disable no-restricted-globals */
2145let isHmrUpdating = false;
2146const hmrDirtyComponents = new Set();
2147// Expose the HMR runtime on the global object
2148// This makes it entirely tree-shakable without polluting the exports and makes
2149// it easier to be used in toolings like vue-loader
2150// Note: for a component to be eligible for HMR it also needs the __hmrId option
2151// to be set so that its instances can be registered / removed.
2152{
2153 getGlobalThis().__VUE_HMR_RUNTIME__ = {
2154 createRecord: tryWrap(createRecord),
2155 rerender: tryWrap(rerender),
2156 reload: tryWrap(reload)
2157 };
2158}
2159const map = new Map();
2160function registerHMR(instance) {
2161 const id = instance.type.__hmrId;
2162 let record = map.get(id);
2163 if (!record) {
2164 createRecord(id, instance.type);
2165 record = map.get(id);
2166 }
2167 record.instances.add(instance);
2168}
2169function unregisterHMR(instance) {
2170 map.get(instance.type.__hmrId).instances.delete(instance);
2171}
2172function createRecord(id, initialDef) {
2173 if (map.has(id)) {
2174 return false;
2175 }
2176 map.set(id, {
2177 initialDef: normalizeClassComponent(initialDef),
2178 instances: new Set()
2179 });
2180 return true;
2181}
2182function normalizeClassComponent(component) {
2183 return isClassComponent(component) ? component.__vccOpts : component;
2184}
2185function rerender(id, newRender) {
2186 const record = map.get(id);
2187 if (!record) {
2188 return;
2189 }
2190 // update initial record (for not-yet-rendered component)
2191 record.initialDef.render = newRender;
2192 [...record.instances].forEach(instance => {
2193 if (newRender) {
2194 instance.render = newRender;
2195 normalizeClassComponent(instance.type).render = newRender;
2196 }
2197 instance.renderCache = [];
2198 // this flag forces child components with slot content to update
2199 isHmrUpdating = true;
2200 instance.update();
2201 isHmrUpdating = false;
2202 });
2203}
2204function reload(id, newComp) {
2205 const record = map.get(id);
2206 if (!record)
2207 return;
2208 newComp = normalizeClassComponent(newComp);
2209 // update initial def (for not-yet-rendered components)
2210 updateComponentDef(record.initialDef, newComp);
2211 // create a snapshot which avoids the set being mutated during updates
2212 const instances = [...record.instances];
2213 for (const instance of instances) {
2214 const oldComp = normalizeClassComponent(instance.type);
2215 if (!hmrDirtyComponents.has(oldComp)) {
2216 // 1. Update existing comp definition to match new one
2217 if (oldComp !== record.initialDef) {
2218 updateComponentDef(oldComp, newComp);
2219 }
2220 // 2. mark definition dirty. This forces the renderer to replace the
2221 // component on patch.
2222 hmrDirtyComponents.add(oldComp);
2223 }
2224 // 3. invalidate options resolution cache
2225 instance.appContext.optionsCache.delete(instance.type);
2226 // 4. actually update
2227 if (instance.ceReload) {
2228 // custom element
2229 hmrDirtyComponents.add(oldComp);
2230 instance.ceReload(newComp.styles);
2231 hmrDirtyComponents.delete(oldComp);
2232 }
2233 else if (instance.parent) {
2234 // 4. Force the parent instance to re-render. This will cause all updated
2235 // components to be unmounted and re-mounted. Queue the update so that we
2236 // don't end up forcing the same parent to re-render multiple times.
2237 queueJob(instance.parent.update);
2238 // instance is the inner component of an async custom element
2239 // invoke to reset styles
2240 if (instance.parent.type.__asyncLoader &&
2241 instance.parent.ceReload) {
2242 instance.parent.ceReload(newComp.styles);
2243 }
2244 }
2245 else if (instance.appContext.reload) {
2246 // root instance mounted via createApp() has a reload method
2247 instance.appContext.reload();
2248 }
2249 else if (typeof window !== 'undefined') {
2250 // root instance inside tree created via raw render(). Force reload.
2251 window.location.reload();
2252 }
2253 else {
2254 console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
2255 }
2256 }
2257 // 5. make sure to cleanup dirty hmr components after update
2258 queuePostFlushCb(() => {
2259 for (const instance of instances) {
2260 hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
2261 }
2262 });
2263}
2264function updateComponentDef(oldComp, newComp) {
2265 extend(oldComp, newComp);
2266 for (const key in oldComp) {
2267 if (key !== '__file' && !(key in newComp)) {
2268 delete oldComp[key];
2269 }
2270 }
2271}
2272function tryWrap(fn) {
2273 return (id, arg) => {
2274 try {
2275 return fn(id, arg);
2276 }
2277 catch (e) {
2278 console.error(e);
2279 console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
2280 `Full reload required.`);
2281 }
2282 };
2283}
2284
2285let devtools;
2286let buffer = [];
2287let devtoolsNotInstalled = false;
2288function emit(event, ...args) {
2289 if (devtools) {
2290 devtools.emit(event, ...args);
2291 }
2292 else if (!devtoolsNotInstalled) {
2293 buffer.push({ event, args });
2294 }
2295}
2296function setDevtoolsHook(hook, target) {
2297 var _a, _b;
2298 devtools = hook;
2299 if (devtools) {
2300 devtools.enabled = true;
2301 buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
2302 buffer = [];
2303 }
2304 else if (
2305 // handle late devtools injection - only do this if we are in an actual
2306 // browser environment to avoid the timer handle stalling test runner exit
2307 // (#4815)
2308 typeof window !== 'undefined' &&
2309 // some envs mock window but not fully
2310 window.HTMLElement &&
2311 // also exclude jsdom
2312 !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
2313 const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
2314 target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
2315 replay.push((newHook) => {
2316 setDevtoolsHook(newHook, target);
2317 });
2318 // clear buffer after 3s - the user probably doesn't have devtools installed
2319 // at all, and keeping the buffer will cause memory leaks (#4738)
2320 setTimeout(() => {
2321 if (!devtools) {
2322 target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
2323 devtoolsNotInstalled = true;
2324 buffer = [];
2325 }
2326 }, 3000);
2327 }
2328 else {
2329 // non-browser env, assume not installed
2330 devtoolsNotInstalled = true;
2331 buffer = [];
2332 }
2333}
2334function devtoolsInitApp(app, version) {
2335 emit("app:init" /* DevtoolsHooks.APP_INIT */, app, version, {
2336 Fragment,
2337 Text,
2338 Comment,
2339 Static
2340 });
2341}
2342function devtoolsUnmountApp(app) {
2343 emit("app:unmount" /* DevtoolsHooks.APP_UNMOUNT */, app);
2344}
2345const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* DevtoolsHooks.COMPONENT_ADDED */);
2346const devtoolsComponentUpdated =
2347/*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* DevtoolsHooks.COMPONENT_UPDATED */);
2348const devtoolsComponentRemoved =
2349/*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* DevtoolsHooks.COMPONENT_REMOVED */);
2350function createDevtoolsComponentHook(hook) {
2351 return (component) => {
2352 emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
2353 };
2354}
2355const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* DevtoolsHooks.PERFORMANCE_START */);
2356const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* DevtoolsHooks.PERFORMANCE_END */);
2357function createDevtoolsPerformanceHook(hook) {
2358 return (component, type, time) => {
2359 emit(hook, component.appContext.app, component.uid, component, type, time);
2360 };
2361}
2362function devtoolsComponentEmit(component, event, params) {
2363 emit("component:emit" /* DevtoolsHooks.COMPONENT_EMIT */, component.appContext.app, component, event, params);
2364}
2365
2366const deprecationData = {
2367 ["GLOBAL_MOUNT" /* DeprecationTypes.GLOBAL_MOUNT */]: {
2368 message: `The global app bootstrapping API has changed: vm.$mount() and the "el" ` +
2369 `option have been removed. Use createApp(RootComponent).mount() instead.`,
2370 link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#mounting-app-instance`
2371 },
2372 ["GLOBAL_MOUNT_CONTAINER" /* DeprecationTypes.GLOBAL_MOUNT_CONTAINER */]: {
2373 message: `Vue detected directives on the mount container. ` +
2374 `In Vue 3, the container is no longer considered part of the template ` +
2375 `and will not be processed/replaced.`,
2376 link: `https://v3-migration.vuejs.org/breaking-changes/mount-changes.html`
2377 },
2378 ["GLOBAL_EXTEND" /* DeprecationTypes.GLOBAL_EXTEND */]: {
2379 message: `Vue.extend() has been removed in Vue 3. ` +
2380 `Use defineComponent() instead.`,
2381 link: `https://vuejs.org/api/general.html#definecomponent`
2382 },
2383 ["GLOBAL_PROTOTYPE" /* DeprecationTypes.GLOBAL_PROTOTYPE */]: {
2384 message: `Vue.prototype is no longer available in Vue 3. ` +
2385 `Use app.config.globalProperties instead.`,
2386 link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#vue-prototype-replaced-by-config-globalproperties`
2387 },
2388 ["GLOBAL_SET" /* DeprecationTypes.GLOBAL_SET */]: {
2389 message: `Vue.set() has been removed as it is no longer needed in Vue 3. ` +
2390 `Simply use native JavaScript mutations.`
2391 },
2392 ["GLOBAL_DELETE" /* DeprecationTypes.GLOBAL_DELETE */]: {
2393 message: `Vue.delete() has been removed as it is no longer needed in Vue 3. ` +
2394 `Simply use native JavaScript mutations.`
2395 },
2396 ["GLOBAL_OBSERVABLE" /* DeprecationTypes.GLOBAL_OBSERVABLE */]: {
2397 message: `Vue.observable() has been removed. ` +
2398 `Use \`import { reactive } from "vue"\` from Composition API instead.`,
2399 link: `https://vuejs.org/api/reactivity-core.html#reactive`
2400 },
2401 ["GLOBAL_PRIVATE_UTIL" /* DeprecationTypes.GLOBAL_PRIVATE_UTIL */]: {
2402 message: `Vue.util has been removed. Please refactor to avoid its usage ` +
2403 `since it was an internal API even in Vue 2.`
2404 },
2405 ["CONFIG_SILENT" /* DeprecationTypes.CONFIG_SILENT */]: {
2406 message: `config.silent has been removed because it is not good practice to ` +
2407 `intentionally suppress warnings. You can use your browser console's ` +
2408 `filter features to focus on relevant messages.`
2409 },
2410 ["CONFIG_DEVTOOLS" /* DeprecationTypes.CONFIG_DEVTOOLS */]: {
2411 message: `config.devtools has been removed. To enable devtools for ` +
2412 `production, configure the __VUE_PROD_DEVTOOLS__ compile-time flag.`,
2413 link: `https://github.com/vuejs/core/tree/main/packages/vue#bundler-build-feature-flags`
2414 },
2415 ["CONFIG_KEY_CODES" /* DeprecationTypes.CONFIG_KEY_CODES */]: {
2416 message: `config.keyCodes has been removed. ` +
2417 `In Vue 3, you can directly use the kebab-case key names as v-on modifiers.`,
2418 link: `https://v3-migration.vuejs.org/breaking-changes/keycode-modifiers.html`
2419 },
2420 ["CONFIG_PRODUCTION_TIP" /* DeprecationTypes.CONFIG_PRODUCTION_TIP */]: {
2421 message: `config.productionTip has been removed.`,
2422 link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#config-productiontip-removed`
2423 },
2424 ["CONFIG_IGNORED_ELEMENTS" /* DeprecationTypes.CONFIG_IGNORED_ELEMENTS */]: {
2425 message: () => {
2426 let msg = `config.ignoredElements has been removed.`;
2427 if (isRuntimeOnly()) {
2428 msg += ` Pass the "isCustomElement" option to @vue/compiler-dom instead.`;
2429 }
2430 else {
2431 msg += ` Use config.isCustomElement instead.`;
2432 }
2433 return msg;
2434 },
2435 link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#config-ignoredelements-is-now-config-iscustomelement`
2436 },
2437 ["CONFIG_WHITESPACE" /* DeprecationTypes.CONFIG_WHITESPACE */]: {
2438 // this warning is only relevant in the full build when using runtime
2439 // compilation, so it's put in the runtime compatConfig list.
2440 message: `Vue 3 compiler's whitespace option will default to "condense" instead of ` +
2441 `"preserve". To suppress this warning, provide an explicit value for ` +
2442 `\`config.compilerOptions.whitespace\`.`
2443 },
2444 ["CONFIG_OPTION_MERGE_STRATS" /* DeprecationTypes.CONFIG_OPTION_MERGE_STRATS */]: {
2445 message: `config.optionMergeStrategies no longer exposes internal strategies. ` +
2446 `Use custom merge functions instead.`
2447 },
2448 ["INSTANCE_SET" /* DeprecationTypes.INSTANCE_SET */]: {
2449 message: `vm.$set() has been removed as it is no longer needed in Vue 3. ` +
2450 `Simply use native JavaScript mutations.`
2451 },
2452 ["INSTANCE_DELETE" /* DeprecationTypes.INSTANCE_DELETE */]: {
2453 message: `vm.$delete() has been removed as it is no longer needed in Vue 3. ` +
2454 `Simply use native JavaScript mutations.`
2455 },
2456 ["INSTANCE_DESTROY" /* DeprecationTypes.INSTANCE_DESTROY */]: {
2457 message: `vm.$destroy() has been removed. Use app.unmount() instead.`,
2458 link: `https://vuejs.org/api/application.html#app-unmount`
2459 },
2460 ["INSTANCE_EVENT_EMITTER" /* DeprecationTypes.INSTANCE_EVENT_EMITTER */]: {
2461 message: `vm.$on/$once/$off() have been removed. ` +
2462 `Use an external event emitter library instead.`,
2463 link: `https://v3-migration.vuejs.org/breaking-changes/events-api.html`
2464 },
2465 ["INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */]: {
2466 message: event => `"${event}" lifecycle events are no longer supported. From templates, ` +
2467 `use the "vnode" prefix instead of "hook:". For example, @${event} ` +
2468 `should be changed to @vnode-${event.slice(5)}. ` +
2469 `From JavaScript, use Composition API to dynamically register lifecycle ` +
2470 `hooks.`,
2471 link: `https://v3-migration.vuejs.org/breaking-changes/vnode-lifecycle-events.html`
2472 },
2473 ["INSTANCE_CHILDREN" /* DeprecationTypes.INSTANCE_CHILDREN */]: {
2474 message: `vm.$children has been removed. Consider refactoring your logic ` +
2475 `to avoid relying on direct access to child components.`,
2476 link: `https://v3-migration.vuejs.org/breaking-changes/children.html`
2477 },
2478 ["INSTANCE_LISTENERS" /* DeprecationTypes.INSTANCE_LISTENERS */]: {
2479 message: `vm.$listeners has been removed. In Vue 3, parent v-on listeners are ` +
2480 `included in vm.$attrs and it is no longer necessary to separately use ` +
2481 `v-on="$listeners" if you are already using v-bind="$attrs". ` +
2482 `(Note: the Vue 3 behavior only applies if this compat config is disabled)`,
2483 link: `https://v3-migration.vuejs.org/breaking-changes/listeners-removed.html`
2484 },
2485 ["INSTANCE_SCOPED_SLOTS" /* DeprecationTypes.INSTANCE_SCOPED_SLOTS */]: {
2486 message: `vm.$scopedSlots has been removed. Use vm.$slots instead.`,
2487 link: `https://v3-migration.vuejs.org/breaking-changes/slots-unification.html`
2488 },
2489 ["INSTANCE_ATTRS_CLASS_STYLE" /* DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE */]: {
2490 message: componentName => `Component <${componentName || 'Anonymous'}> has \`inheritAttrs: false\` but is ` +
2491 `relying on class/style fallthrough from parent. In Vue 3, class/style ` +
2492 `are now included in $attrs and will no longer fallthrough when ` +
2493 `inheritAttrs is false. If you are already using v-bind="$attrs" on ` +
2494 `component root it should render the same end result. ` +
2495 `If you are binding $attrs to a non-root element and expecting ` +
2496 `class/style to fallthrough on root, you will need to now manually bind ` +
2497 `them on root via :class="$attrs.class".`,
2498 link: `https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style.html`
2499 },
2500 ["OPTIONS_DATA_FN" /* DeprecationTypes.OPTIONS_DATA_FN */]: {
2501 message: `The "data" option can no longer be a plain object. ` +
2502 `Always use a function.`,
2503 link: `https://v3-migration.vuejs.org/breaking-changes/data-option.html`
2504 },
2505 ["OPTIONS_DATA_MERGE" /* DeprecationTypes.OPTIONS_DATA_MERGE */]: {
2506 message: (key) => `Detected conflicting key "${key}" when merging data option values. ` +
2507 `In Vue 3, data keys are merged shallowly and will override one another.`,
2508 link: `https://v3-migration.vuejs.org/breaking-changes/data-option.html#mixin-merge-behavior-change`
2509 },
2510 ["OPTIONS_BEFORE_DESTROY" /* DeprecationTypes.OPTIONS_BEFORE_DESTROY */]: {
2511 message: `\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`
2512 },
2513 ["OPTIONS_DESTROYED" /* DeprecationTypes.OPTIONS_DESTROYED */]: {
2514 message: `\`destroyed\` has been renamed to \`unmounted\`.`
2515 },
2516 ["WATCH_ARRAY" /* DeprecationTypes.WATCH_ARRAY */]: {
2517 message: `"watch" option or vm.$watch on an array value will no longer ` +
2518 `trigger on array mutation unless the "deep" option is specified. ` +
2519 `If current usage is intended, you can disable the compat behavior and ` +
2520 `suppress this warning with:` +
2521 `\n\n configureCompat({ ${"WATCH_ARRAY" /* DeprecationTypes.WATCH_ARRAY */}: false })\n`,
2522 link: `https://v3-migration.vuejs.org/breaking-changes/watch.html`
2523 },
2524 ["PROPS_DEFAULT_THIS" /* DeprecationTypes.PROPS_DEFAULT_THIS */]: {
2525 message: (key) => `props default value function no longer has access to "this". The compat ` +
2526 `build only offers access to this.$options.` +
2527 `(found in prop "${key}")`,
2528 link: `https://v3-migration.vuejs.org/breaking-changes/props-default-this.html`
2529 },
2530 ["CUSTOM_DIR" /* DeprecationTypes.CUSTOM_DIR */]: {
2531 message: (legacyHook, newHook) => `Custom directive hook "${legacyHook}" has been removed. ` +
2532 `Use "${newHook}" instead.`,
2533 link: `https://v3-migration.vuejs.org/breaking-changes/custom-directives.html`
2534 },
2535 ["V_ON_KEYCODE_MODIFIER" /* DeprecationTypes.V_ON_KEYCODE_MODIFIER */]: {
2536 message: `Using keyCode as v-on modifier is no longer supported. ` +
2537 `Use kebab-case key name modifiers instead.`,
2538 link: `https://v3-migration.vuejs.org/breaking-changes/keycode-modifiers.html`
2539 },
2540 ["ATTR_FALSE_VALUE" /* DeprecationTypes.ATTR_FALSE_VALUE */]: {
2541 message: (name) => `Attribute "${name}" with v-bind value \`false\` will render ` +
2542 `${name}="false" instead of removing it in Vue 3. To remove the attribute, ` +
2543 `use \`null\` or \`undefined\` instead. If the usage is intended, ` +
2544 `you can disable the compat behavior and suppress this warning with:` +
2545 `\n\n configureCompat({ ${"ATTR_FALSE_VALUE" /* DeprecationTypes.ATTR_FALSE_VALUE */}: false })\n`,
2546 link: `https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html`
2547 },
2548 ["ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */]: {
2549 message: (name, value, coerced) => `Enumerated attribute "${name}" with v-bind value \`${value}\` will ` +
2550 `${value === null ? `be removed` : `render the value as-is`} instead of coercing the value to "${coerced}" in Vue 3. ` +
2551 `Always use explicit "true" or "false" values for enumerated attributes. ` +
2552 `If the usage is intended, ` +
2553 `you can disable the compat behavior and suppress this warning with:` +
2554 `\n\n configureCompat({ ${"ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */}: false })\n`,
2555 link: `https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html`
2556 },
2557 ["TRANSITION_CLASSES" /* DeprecationTypes.TRANSITION_CLASSES */]: {
2558 message: `` // this feature cannot be runtime-detected
2559 },
2560 ["TRANSITION_GROUP_ROOT" /* DeprecationTypes.TRANSITION_GROUP_ROOT */]: {
2561 message: `<TransitionGroup> no longer renders a root <span> element by ` +
2562 `default if no "tag" prop is specified. If you do not rely on the span ` +
2563 `for styling, you can disable the compat behavior and suppress this ` +
2564 `warning with:` +
2565 `\n\n configureCompat({ ${"TRANSITION_GROUP_ROOT" /* DeprecationTypes.TRANSITION_GROUP_ROOT */}: false })\n`,
2566 link: `https://v3-migration.vuejs.org/breaking-changes/transition-group.html`
2567 },
2568 ["COMPONENT_ASYNC" /* DeprecationTypes.COMPONENT_ASYNC */]: {
2569 message: (comp) => {
2570 const name = getComponentName(comp);
2571 return (`Async component${name ? ` <${name}>` : `s`} should be explicitly created via \`defineAsyncComponent()\` ` +
2572 `in Vue 3. Plain functions will be treated as functional components in ` +
2573 `non-compat build. If you have already migrated all async component ` +
2574 `usage and intend to use plain functions for functional components, ` +
2575 `you can disable the compat behavior and suppress this ` +
2576 `warning with:` +
2577 `\n\n configureCompat({ ${"COMPONENT_ASYNC" /* DeprecationTypes.COMPONENT_ASYNC */}: false })\n`);
2578 },
2579 link: `https://v3-migration.vuejs.org/breaking-changes/async-components.html`
2580 },
2581 ["COMPONENT_FUNCTIONAL" /* DeprecationTypes.COMPONENT_FUNCTIONAL */]: {
2582 message: (comp) => {
2583 const name = getComponentName(comp);
2584 return (`Functional component${name ? ` <${name}>` : `s`} should be defined as a plain function in Vue 3. The "functional" ` +
2585 `option has been removed. NOTE: Before migrating to use plain ` +
2586 `functions for functional components, first make sure that all async ` +
2587 `components usage have been migrated and its compat behavior has ` +
2588 `been disabled.`);
2589 },
2590 link: `https://v3-migration.vuejs.org/breaking-changes/functional-components.html`
2591 },
2592 ["COMPONENT_V_MODEL" /* DeprecationTypes.COMPONENT_V_MODEL */]: {
2593 message: (comp) => {
2594 const configMsg = `opt-in to ` +
2595 `Vue 3 behavior on a per-component basis with \`compatConfig: { ${"COMPONENT_V_MODEL" /* DeprecationTypes.COMPONENT_V_MODEL */}: false }\`.`;
2596 if (comp.props &&
2597 (isArray(comp.props)
2598 ? comp.props.includes('modelValue')
2599 : hasOwn(comp.props, 'modelValue'))) {
2600 return (`Component declares "modelValue" prop, which is Vue 3 usage, but ` +
2601 `is running under Vue 2 compat v-model behavior. You can ${configMsg}`);
2602 }
2603 return (`v-model usage on component has changed in Vue 3. Component that expects ` +
2604 `to work with v-model should now use the "modelValue" prop and emit the ` +
2605 `"update:modelValue" event. You can update the usage and then ${configMsg}`);
2606 },
2607 link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
2608 },
2609 ["RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */]: {
2610 message: `Vue 3's render function API has changed. ` +
2611 `You can opt-in to the new API with:` +
2612 `\n\n configureCompat({ ${"RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */}: false })\n` +
2613 `\n (This can also be done per-component via the "compatConfig" option.)`,
2614 link: `https://v3-migration.vuejs.org/breaking-changes/render-function-api.html`
2615 },
2616 ["FILTERS" /* DeprecationTypes.FILTERS */]: {
2617 message: `filters have been removed in Vue 3. ` +
2618 `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
2619 `Use method calls or computed properties instead.`,
2620 link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
2621 },
2622 ["PRIVATE_APIS" /* DeprecationTypes.PRIVATE_APIS */]: {
2623 message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
2624 `If you are seeing this warning only due to a dependency, you can ` +
2625 `suppress this warning via { PRIVATE_APIS: 'suppress-warning' }.`
2626 }
2627};
2628const instanceWarned = Object.create(null);
2629const warnCount = Object.create(null);
2630function warnDeprecation(key, instance, ...args) {
2631 instance = instance || getCurrentInstance();
2632 // check user config
2633 const config = getCompatConfigForKey(key, instance);
2634 if (config === 'suppress-warning') {
2635 return;
2636 }
2637 const dupKey = key + args.join('');
2638 let compId = instance && formatComponentName(instance, instance.type);
2639 if (compId === 'Anonymous' && instance) {
2640 compId = instance.uid;
2641 }
2642 // skip if the same warning is emitted for the same component type
2643 const componentDupKey = dupKey + compId;
2644 if (componentDupKey in instanceWarned) {
2645 return;
2646 }
2647 instanceWarned[componentDupKey] = true;
2648 // same warning, but different component. skip the long message and just
2649 // log the key and count.
2650 if (dupKey in warnCount) {
2651 warn$1(`(deprecation ${key}) (${++warnCount[dupKey] + 1})`);
2652 return;
2653 }
2654 warnCount[dupKey] = 0;
2655 const { message, link } = deprecationData[key];
2656 warn$1(`(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`);
2657 if (!isCompatEnabled(key, instance, true)) {
2658 console.error(`^ The above deprecation's compat behavior is disabled and will likely ` +
2659 `lead to runtime errors.`);
2660 }
2661}
2662const globalCompatConfig = {
2663 MODE: 2
2664};
2665function configureCompat(config) {
2666 {
2667 validateCompatConfig(config);
2668 }
2669 extend(globalCompatConfig, config);
2670}
2671const seenConfigObjects = /*#__PURE__*/ new WeakSet();
2672const warnedInvalidKeys = {};
2673// dev only
2674function validateCompatConfig(config, instance) {
2675 if (seenConfigObjects.has(config)) {
2676 return;
2677 }
2678 seenConfigObjects.add(config);
2679 for (const key of Object.keys(config)) {
2680 if (key !== 'MODE' &&
2681 !(key in deprecationData) &&
2682 !(key in warnedInvalidKeys)) {
2683 if (key.startsWith('COMPILER_')) {
2684 if (isRuntimeOnly()) {
2685 warn$1(`Deprecation config "${key}" is compiler-specific and you are ` +
2686 `running a runtime-only build of Vue. This deprecation should be ` +
2687 `configured via compiler options in your build setup instead.\n` +
2688 `Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`);
2689 }
2690 }
2691 else {
2692 warn$1(`Invalid deprecation config "${key}".`);
2693 }
2694 warnedInvalidKeys[key] = true;
2695 }
2696 }
2697 if (instance && config["OPTIONS_DATA_MERGE" /* DeprecationTypes.OPTIONS_DATA_MERGE */] != null) {
2698 warn$1(`Deprecation config "${"OPTIONS_DATA_MERGE" /* DeprecationTypes.OPTIONS_DATA_MERGE */}" can only be configured globally.`);
2699 }
2700}
2701function getCompatConfigForKey(key, instance) {
2702 const instanceConfig = instance && instance.type.compatConfig;
2703 if (instanceConfig && key in instanceConfig) {
2704 return instanceConfig[key];
2705 }
2706 return globalCompatConfig[key];
2707}
2708function isCompatEnabled(key, instance, enableForBuiltIn = false) {
2709 // skip compat for built-in components
2710 if (!enableForBuiltIn && instance && instance.type.__isBuiltIn) {
2711 return false;
2712 }
2713 const rawMode = getCompatConfigForKey('MODE', instance) || 2;
2714 const val = getCompatConfigForKey(key, instance);
2715 const mode = isFunction(rawMode)
2716 ? rawMode(instance && instance.type)
2717 : rawMode;
2718 if (mode === 2) {
2719 return val !== false;
2720 }
2721 else {
2722 return val === true || val === 'suppress-warning';
2723 }
2724}
2725/**
2726 * Use this for features that are completely removed in non-compat build.
2727 */
2728function assertCompatEnabled(key, instance, ...args) {
2729 if (!isCompatEnabled(key, instance)) {
2730 throw new Error(`${key} compat has been disabled.`);
2731 }
2732 else {
2733 warnDeprecation(key, instance, ...args);
2734 }
2735}
2736/**
2737 * Use this for features where legacy usage is still possible, but will likely
2738 * lead to runtime error if compat is disabled. (warn in all cases)
2739 */
2740function softAssertCompatEnabled(key, instance, ...args) {
2741 {
2742 warnDeprecation(key, instance, ...args);
2743 }
2744 return isCompatEnabled(key, instance);
2745}
2746/**
2747 * Use this for features with the same syntax but with mutually exclusive
2748 * behavior in 2 vs 3. Only warn if compat is enabled.
2749 * e.g. render function
2750 */
2751function checkCompatEnabled(key, instance, ...args) {
2752 const enabled = isCompatEnabled(key, instance);
2753 if (enabled) {
2754 warnDeprecation(key, instance, ...args);
2755 }
2756 return enabled;
2757}
2758
2759const eventRegistryMap = /*#__PURE__*/ new WeakMap();
2760function getRegistry(instance) {
2761 let events = eventRegistryMap.get(instance);
2762 if (!events) {
2763 eventRegistryMap.set(instance, (events = Object.create(null)));
2764 }
2765 return events;
2766}
2767function on(instance, event, fn) {
2768 if (isArray(event)) {
2769 event.forEach(e => on(instance, e, fn));
2770 }
2771 else {
2772 if (event.startsWith('hook:')) {
2773 assertCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance, event);
2774 }
2775 else {
2776 assertCompatEnabled("INSTANCE_EVENT_EMITTER" /* DeprecationTypes.INSTANCE_EVENT_EMITTER */, instance);
2777 }
2778 const events = getRegistry(instance);
2779 (events[event] || (events[event] = [])).push(fn);
2780 }
2781 return instance.proxy;
2782}
2783function once(instance, event, fn) {
2784 const wrapped = (...args) => {
2785 off(instance, event, wrapped);
2786 fn.call(instance.proxy, ...args);
2787 };
2788 wrapped.fn = fn;
2789 on(instance, event, wrapped);
2790 return instance.proxy;
2791}
2792function off(instance, event, fn) {
2793 assertCompatEnabled("INSTANCE_EVENT_EMITTER" /* DeprecationTypes.INSTANCE_EVENT_EMITTER */, instance);
2794 const vm = instance.proxy;
2795 // all
2796 if (!event) {
2797 eventRegistryMap.set(instance, Object.create(null));
2798 return vm;
2799 }
2800 // array of events
2801 if (isArray(event)) {
2802 event.forEach(e => off(instance, e, fn));
2803 return vm;
2804 }
2805 // specific event
2806 const events = getRegistry(instance);
2807 const cbs = events[event];
2808 if (!cbs) {
2809 return vm;
2810 }
2811 if (!fn) {
2812 events[event] = undefined;
2813 return vm;
2814 }
2815 events[event] = cbs.filter(cb => !(cb === fn || cb.fn === fn));
2816 return vm;
2817}
2818function emit$1(instance, event, args) {
2819 const cbs = getRegistry(instance)[event];
2820 if (cbs) {
2821 callWithAsyncErrorHandling(cbs.map(cb => cb.bind(instance.proxy)), instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
2822 }
2823 return instance.proxy;
2824}
2825
2826const compatModelEventPrefix = `onModelCompat:`;
2827const warnedTypes = new WeakSet();
2828function convertLegacyVModelProps(vnode) {
2829 const { type, shapeFlag, props, dynamicProps } = vnode;
2830 const comp = type;
2831 if (shapeFlag & 6 /* ShapeFlags.COMPONENT */ && props && 'modelValue' in props) {
2832 if (!isCompatEnabled("COMPONENT_V_MODEL" /* DeprecationTypes.COMPONENT_V_MODEL */,
2833 // this is a special case where we want to use the vnode component's
2834 // compat config instead of the current rendering instance (which is the
2835 // parent of the component that exposes v-model)
2836 { type })) {
2837 return;
2838 }
2839 if (!warnedTypes.has(comp)) {
2840 pushWarningContext(vnode);
2841 warnDeprecation("COMPONENT_V_MODEL" /* DeprecationTypes.COMPONENT_V_MODEL */, { type }, comp);
2842 popWarningContext();
2843 warnedTypes.add(comp);
2844 }
2845 // v3 compiled model code -> v2 compat props
2846 // modelValue -> value
2847 // onUpdate:modelValue -> onModelCompat:input
2848 const model = comp.model || {};
2849 applyModelFromMixins(model, comp.mixins);
2850 const { prop = 'value', event = 'input' } = model;
2851 if (prop !== 'modelValue') {
2852 props[prop] = props.modelValue;
2853 delete props.modelValue;
2854 }
2855 // important: update dynamic props
2856 if (dynamicProps) {
2857 dynamicProps[dynamicProps.indexOf('modelValue')] = prop;
2858 }
2859 props[compatModelEventPrefix + event] = props['onUpdate:modelValue'];
2860 delete props['onUpdate:modelValue'];
2861 }
2862}
2863function applyModelFromMixins(model, mixins) {
2864 if (mixins) {
2865 mixins.forEach(m => {
2866 if (m.model)
2867 extend(model, m.model);
2868 if (m.mixins)
2869 applyModelFromMixins(model, m.mixins);
2870 });
2871 }
2872}
2873function compatModelEmit(instance, event, args) {
2874 if (!isCompatEnabled("COMPONENT_V_MODEL" /* DeprecationTypes.COMPONENT_V_MODEL */, instance)) {
2875 return;
2876 }
2877 const props = instance.vnode.props;
2878 const modelHandler = props && props[compatModelEventPrefix + event];
2879 if (modelHandler) {
2880 callWithErrorHandling(modelHandler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
2881 }
2882}
2883
2884function emit$2(instance, event, ...rawArgs) {
2885 if (instance.isUnmounted)
2886 return;
2887 const props = instance.vnode.props || EMPTY_OBJ;
2888 {
2889 const { emitsOptions, propsOptions: [propsOptions] } = instance;
2890 if (emitsOptions) {
2891 if (!(event in emitsOptions) &&
2892 !((event.startsWith('hook:') ||
2893 event.startsWith(compatModelEventPrefix)))) {
2894 if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
2895 warn$1(`Component emitted event "${event}" but it is neither declared in ` +
2896 `the emits option nor as an "${toHandlerKey(event)}" prop.`);
2897 }
2898 }
2899 else {
2900 const validator = emitsOptions[event];
2901 if (isFunction(validator)) {
2902 const isValid = validator(...rawArgs);
2903 if (!isValid) {
2904 warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
2905 }
2906 }
2907 }
2908 }
2909 }
2910 let args = rawArgs;
2911 const isModelListener = event.startsWith('update:');
2912 // for v-model update:xxx events, apply modifiers on args
2913 const modelArg = isModelListener && event.slice(7);
2914 if (modelArg && modelArg in props) {
2915 const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
2916 const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
2917 if (trim) {
2918 args = rawArgs.map(a => a.trim());
2919 }
2920 if (number) {
2921 args = rawArgs.map(toNumber);
2922 }
2923 }
2924 {
2925 devtoolsComponentEmit(instance, event, args);
2926 }
2927 {
2928 const lowerCaseEvent = event.toLowerCase();
2929 if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
2930 warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
2931 `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
2932 `Note that HTML attributes are case-insensitive and you cannot use ` +
2933 `v-on to listen to camelCase events when using in-DOM templates. ` +
2934 `You should probably use "${hyphenate(event)}" instead of "${event}".`);
2935 }
2936 }
2937 let handlerName;
2938 let handler = props[(handlerName = toHandlerKey(event))] ||
2939 // also try camelCase event handler (#2249)
2940 props[(handlerName = toHandlerKey(camelize(event)))];
2941 // for v-model update:xxx events, also trigger kebab-case equivalent
2942 // for props passed via kebab-case
2943 if (!handler && isModelListener) {
2944 handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
2945 }
2946 if (handler) {
2947 callWithAsyncErrorHandling(handler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
2948 }
2949 const onceHandler = props[handlerName + `Once`];
2950 if (onceHandler) {
2951 if (!instance.emitted) {
2952 instance.emitted = {};
2953 }
2954 else if (instance.emitted[handlerName]) {
2955 return;
2956 }
2957 instance.emitted[handlerName] = true;
2958 callWithAsyncErrorHandling(onceHandler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
2959 }
2960 {
2961 compatModelEmit(instance, event, args);
2962 return emit$1(instance, event, args);
2963 }
2964}
2965function normalizeEmitsOptions(comp, appContext, asMixin = false) {
2966 const cache = appContext.emitsCache;
2967 const cached = cache.get(comp);
2968 if (cached !== undefined) {
2969 return cached;
2970 }
2971 const raw = comp.emits;
2972 let normalized = {};
2973 // apply mixin/extends props
2974 let hasExtends = false;
2975 if (!isFunction(comp)) {
2976 const extendEmits = (raw) => {
2977 const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
2978 if (normalizedFromExtend) {
2979 hasExtends = true;
2980 extend(normalized, normalizedFromExtend);
2981 }
2982 };
2983 if (!asMixin && appContext.mixins.length) {
2984 appContext.mixins.forEach(extendEmits);
2985 }
2986 if (comp.extends) {
2987 extendEmits(comp.extends);
2988 }
2989 if (comp.mixins) {
2990 comp.mixins.forEach(extendEmits);
2991 }
2992 }
2993 if (!raw && !hasExtends) {
2994 if (isObject(comp)) {
2995 cache.set(comp, null);
2996 }
2997 return null;
2998 }
2999 if (isArray(raw)) {
3000 raw.forEach(key => (normalized[key] = null));
3001 }
3002 else {
3003 extend(normalized, raw);
3004 }
3005 if (isObject(comp)) {
3006 cache.set(comp, normalized);
3007 }
3008 return normalized;
3009}
3010// Check if an incoming prop key is a declared emit event listener.
3011// e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
3012// both considered matched listeners.
3013function isEmitListener(options, key) {
3014 if (!options || !isOn(key)) {
3015 return false;
3016 }
3017 if (key.startsWith(compatModelEventPrefix)) {
3018 return true;
3019 }
3020 key = key.slice(2).replace(/Once$/, '');
3021 return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
3022 hasOwn(options, hyphenate(key)) ||
3023 hasOwn(options, key));
3024}
3025
3026/**
3027 * mark the current rendering instance for asset resolution (e.g.
3028 * resolveComponent, resolveDirective) during render
3029 */
3030let currentRenderingInstance = null;
3031let currentScopeId = null;
3032/**
3033 * Note: rendering calls maybe nested. The function returns the parent rendering
3034 * instance if present, which should be restored after the render is done:
3035 *
3036 * ```js
3037 * const prev = setCurrentRenderingInstance(i)
3038 * // ...render
3039 * setCurrentRenderingInstance(prev)
3040 * ```
3041 */
3042function setCurrentRenderingInstance(instance) {
3043 const prev = currentRenderingInstance;
3044 currentRenderingInstance = instance;
3045 currentScopeId = (instance && instance.type.__scopeId) || null;
3046 // v2 pre-compiled components uses _scopeId instead of __scopeId
3047 if (!currentScopeId) {
3048 currentScopeId = (instance && instance.type._scopeId) || null;
3049 }
3050 return prev;
3051}
3052/**
3053 * Set scope id when creating hoisted vnodes.
3054 * @private compiler helper
3055 */
3056function pushScopeId(id) {
3057 currentScopeId = id;
3058}
3059/**
3060 * Technically we no longer need this after 3.0.8 but we need to keep the same
3061 * API for backwards compat w/ code generated by compilers.
3062 * @private
3063 */
3064function popScopeId() {
3065 currentScopeId = null;
3066}
3067/**
3068 * Only for backwards compat
3069 * @private
3070 */
3071const withScopeId = (_id) => withCtx;
3072/**
3073 * Wrap a slot function to memoize current rendering instance
3074 * @private compiler helper
3075 */
3076function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // true only
3077) {
3078 if (!ctx)
3079 return fn;
3080 // already normalized
3081 if (fn._n) {
3082 return fn;
3083 }
3084 const renderFnWithContext = (...args) => {
3085 // If a user calls a compiled slot inside a template expression (#1745), it
3086 // can mess up block tracking, so by default we disable block tracking and
3087 // force bail out when invoking a compiled slot (indicated by the ._d flag).
3088 // This isn't necessary if rendering a compiled `<slot>`, so we flip the
3089 // ._d flag off when invoking the wrapped fn inside `renderSlot`.
3090 if (renderFnWithContext._d) {
3091 setBlockTracking(-1);
3092 }
3093 const prevInstance = setCurrentRenderingInstance(ctx);
3094 const res = fn(...args);
3095 setCurrentRenderingInstance(prevInstance);
3096 if (renderFnWithContext._d) {
3097 setBlockTracking(1);
3098 }
3099 {
3100 devtoolsComponentUpdated(ctx);
3101 }
3102 return res;
3103 };
3104 // mark normalized to avoid duplicated wrapping
3105 renderFnWithContext._n = true;
3106 // mark this as compiled by default
3107 // this is used in vnode.ts -> normalizeChildren() to set the slot
3108 // rendering flag.
3109 renderFnWithContext._c = true;
3110 // disable block tracking by default
3111 renderFnWithContext._d = true;
3112 // compat build only flag to distinguish scoped slots from non-scoped ones
3113 if (isNonScopedSlot) {
3114 renderFnWithContext._ns = true;
3115 }
3116 return renderFnWithContext;
3117}
3118
3119/**
3120 * dev only flag to track whether $attrs was used during render.
3121 * If $attrs was used during render then the warning for failed attrs
3122 * fallthrough can be suppressed.
3123 */
3124let accessedAttrs = false;
3125function markAttrsAccessed() {
3126 accessedAttrs = true;
3127}
3128function renderComponentRoot(instance) {
3129 const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
3130 let result;
3131 let fallthroughAttrs;
3132 const prev = setCurrentRenderingInstance(instance);
3133 {
3134 accessedAttrs = false;
3135 }
3136 try {
3137 if (vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) {
3138 // withProxy is a proxy with a different `has` trap only for
3139 // runtime-compiled render functions using `with` block.
3140 const proxyToUse = withProxy || proxy;
3141 result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
3142 fallthroughAttrs = attrs;
3143 }
3144 else {
3145 // functional
3146 const render = Component;
3147 // in dev, mark attrs accessed if optional props (attrs === props)
3148 if (true && attrs === props) {
3149 markAttrsAccessed();
3150 }
3151 result = normalizeVNode(render.length > 1
3152 ? render(props, true
3153 ? {
3154 get attrs() {
3155 markAttrsAccessed();
3156 return attrs;
3157 },
3158 slots,
3159 emit
3160 }
3161 : { attrs, slots, emit })
3162 : render(props, null /* we know it doesn't need it */));
3163 fallthroughAttrs = Component.props
3164 ? attrs
3165 : getFunctionalFallthrough(attrs);
3166 }
3167 }
3168 catch (err) {
3169 blockStack.length = 0;
3170 handleError(err, instance, 1 /* ErrorCodes.RENDER_FUNCTION */);
3171 result = createVNode(Comment);
3172 }
3173 // attr merging
3174 // in dev mode, comments are preserved, and it's possible for a template
3175 // to have comments along side the root element which makes it a fragment
3176 let root = result;
3177 let setRoot = undefined;
3178 if (result.patchFlag > 0 &&
3179 result.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */) {
3180 [root, setRoot] = getChildRoot(result);
3181 }
3182 if (fallthroughAttrs && inheritAttrs !== false) {
3183 const keys = Object.keys(fallthroughAttrs);
3184 const { shapeFlag } = root;
3185 if (keys.length) {
3186 if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 6 /* ShapeFlags.COMPONENT */)) {
3187 if (propsOptions && keys.some(isModelListener)) {
3188 // If a v-model listener (onUpdate:xxx) has a corresponding declared
3189 // prop, it indicates this component expects to handle v-model and
3190 // it should not fallthrough.
3191 // related: #1543, #1643, #1989
3192 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
3193 }
3194 root = cloneVNode(root, fallthroughAttrs);
3195 }
3196 else if (!accessedAttrs && root.type !== Comment) {
3197 const allAttrs = Object.keys(attrs);
3198 const eventAttrs = [];
3199 const extraAttrs = [];
3200 for (let i = 0, l = allAttrs.length; i < l; i++) {
3201 const key = allAttrs[i];
3202 if (isOn(key)) {
3203 // ignore v-model handlers when they fail to fallthrough
3204 if (!isModelListener(key)) {
3205 // remove `on`, lowercase first letter to reflect event casing
3206 // accurately
3207 eventAttrs.push(key[2].toLowerCase() + key.slice(3));
3208 }
3209 }
3210 else {
3211 extraAttrs.push(key);
3212 }
3213 }
3214 if (extraAttrs.length) {
3215 warn$1(`Extraneous non-props attributes (` +
3216 `${extraAttrs.join(', ')}) ` +
3217 `were passed to component but could not be automatically inherited ` +
3218 `because component renders fragment or text root nodes.`);
3219 }
3220 if (eventAttrs.length) {
3221 warn$1(`Extraneous non-emits event listeners (` +
3222 `${eventAttrs.join(', ')}) ` +
3223 `were passed to component but could not be automatically inherited ` +
3224 `because component renders fragment or text root nodes. ` +
3225 `If the listener is intended to be a component custom event listener only, ` +
3226 `declare it using the "emits" option.`);
3227 }
3228 }
3229 }
3230 }
3231 if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
3232 vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */ &&
3233 root.shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 6 /* ShapeFlags.COMPONENT */)) {
3234 const { class: cls, style } = vnode.props || {};
3235 if (cls || style) {
3236 if (inheritAttrs === false) {
3237 warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
3238 }
3239 root = cloneVNode(root, {
3240 class: cls,
3241 style: style
3242 });
3243 }
3244 }
3245 // inherit directives
3246 if (vnode.dirs) {
3247 if (!isElementRoot(root)) {
3248 warn$1(`Runtime directive used on component with non-element root node. ` +
3249 `The directives will not function as intended.`);
3250 }
3251 // clone before mutating since the root may be a hoisted vnode
3252 root = cloneVNode(root);
3253 root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
3254 }
3255 // inherit transition data
3256 if (vnode.transition) {
3257 if (!isElementRoot(root)) {
3258 warn$1(`Component inside <Transition> renders non-element root node ` +
3259 `that cannot be animated.`);
3260 }
3261 root.transition = vnode.transition;
3262 }
3263 if (setRoot) {
3264 setRoot(root);
3265 }
3266 else {
3267 result = root;
3268 }
3269 setCurrentRenderingInstance(prev);
3270 return result;
3271}
3272/**
3273 * dev only
3274 * In dev mode, template root level comments are rendered, which turns the
3275 * template into a fragment root, but we need to locate the single element
3276 * root for attrs and scope id processing.
3277 */
3278const getChildRoot = (vnode) => {
3279 const rawChildren = vnode.children;
3280 const dynamicChildren = vnode.dynamicChildren;
3281 const childRoot = filterSingleRoot(rawChildren);
3282 if (!childRoot) {
3283 return [vnode, undefined];
3284 }
3285 const index = rawChildren.indexOf(childRoot);
3286 const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
3287 const setRoot = (updatedRoot) => {
3288 rawChildren[index] = updatedRoot;
3289 if (dynamicChildren) {
3290 if (dynamicIndex > -1) {
3291 dynamicChildren[dynamicIndex] = updatedRoot;
3292 }
3293 else if (updatedRoot.patchFlag > 0) {
3294 vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
3295 }
3296 }
3297 };
3298 return [normalizeVNode(childRoot), setRoot];
3299};
3300function filterSingleRoot(children) {
3301 let singleRoot;
3302 for (let i = 0; i < children.length; i++) {
3303 const child = children[i];
3304 if (isVNode(child)) {
3305 // ignore user comment
3306 if (child.type !== Comment || child.children === 'v-if') {
3307 if (singleRoot) {
3308 // has more than 1 non-comment child, return now
3309 return;
3310 }
3311 else {
3312 singleRoot = child;
3313 }
3314 }
3315 }
3316 else {
3317 return;
3318 }
3319 }
3320 return singleRoot;
3321}
3322const getFunctionalFallthrough = (attrs) => {
3323 let res;
3324 for (const key in attrs) {
3325 if (key === 'class' || key === 'style' || isOn(key)) {
3326 (res || (res = {}))[key] = attrs[key];
3327 }
3328 }
3329 return res;
3330};
3331const filterModelListeners = (attrs, props) => {
3332 const res = {};
3333 for (const key in attrs) {
3334 if (!isModelListener(key) || !(key.slice(9) in props)) {
3335 res[key] = attrs[key];
3336 }
3337 }
3338 return res;
3339};
3340const isElementRoot = (vnode) => {
3341 return (vnode.shapeFlag & (6 /* ShapeFlags.COMPONENT */ | 1 /* ShapeFlags.ELEMENT */) ||
3342 vnode.type === Comment // potential v-if branch switch
3343 );
3344};
3345function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
3346 const { props: prevProps, children: prevChildren, component } = prevVNode;
3347 const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
3348 const emits = component.emitsOptions;
3349 // Parent component's render function was hot-updated. Since this may have
3350 // caused the child component's slots content to have changed, we need to
3351 // force the child to update as well.
3352 if ((prevChildren || nextChildren) && isHmrUpdating) {
3353 return true;
3354 }
3355 // force child update for runtime directive or transition on component vnode.
3356 if (nextVNode.dirs || nextVNode.transition) {
3357 return true;
3358 }
3359 if (optimized && patchFlag >= 0) {
3360 if (patchFlag & 1024 /* PatchFlags.DYNAMIC_SLOTS */) {
3361 // slot content that references values that might have changed,
3362 // e.g. in a v-for
3363 return true;
3364 }
3365 if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
3366 if (!prevProps) {
3367 return !!nextProps;
3368 }
3369 // presence of this flag indicates props are always non-null
3370 return hasPropsChanged(prevProps, nextProps, emits);
3371 }
3372 else if (patchFlag & 8 /* PatchFlags.PROPS */) {
3373 const dynamicProps = nextVNode.dynamicProps;
3374 for (let i = 0; i < dynamicProps.length; i++) {
3375 const key = dynamicProps[i];
3376 if (nextProps[key] !== prevProps[key] &&
3377 !isEmitListener(emits, key)) {
3378 return true;
3379 }
3380 }
3381 }
3382 }
3383 else {
3384 // this path is only taken by manually written render functions
3385 // so presence of any children leads to a forced update
3386 if (prevChildren || nextChildren) {
3387 if (!nextChildren || !nextChildren.$stable) {
3388 return true;
3389 }
3390 }
3391 if (prevProps === nextProps) {
3392 return false;
3393 }
3394 if (!prevProps) {
3395 return !!nextProps;
3396 }
3397 if (!nextProps) {
3398 return true;
3399 }
3400 return hasPropsChanged(prevProps, nextProps, emits);
3401 }
3402 return false;
3403}
3404function hasPropsChanged(prevProps, nextProps, emitsOptions) {
3405 const nextKeys = Object.keys(nextProps);
3406 if (nextKeys.length !== Object.keys(prevProps).length) {
3407 return true;
3408 }
3409 for (let i = 0; i < nextKeys.length; i++) {
3410 const key = nextKeys[i];
3411 if (nextProps[key] !== prevProps[key] &&
3412 !isEmitListener(emitsOptions, key)) {
3413 return true;
3414 }
3415 }
3416 return false;
3417}
3418function updateHOCHostEl({ vnode, parent }, el // HostNode
3419) {
3420 while (parent && parent.subTree === vnode) {
3421 (vnode = parent.vnode).el = el;
3422 parent = parent.parent;
3423 }
3424}
3425
3426const isSuspense = (type) => type.__isSuspense;
3427// Suspense exposes a component-like API, and is treated like a component
3428// in the compiler, but internally it's a special built-in type that hooks
3429// directly into the renderer.
3430const SuspenseImpl = {
3431 name: 'Suspense',
3432 // In order to make Suspense tree-shakable, we need to avoid importing it
3433 // directly in the renderer. The renderer checks for the __isSuspense flag
3434 // on a vnode's type and calls the `process` method, passing in renderer
3435 // internals.
3436 __isSuspense: true,
3437 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
3438 // platform-specific impl passed from renderer
3439 rendererInternals) {
3440 if (n1 == null) {
3441 mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
3442 }
3443 else {
3444 patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
3445 }
3446 },
3447 hydrate: hydrateSuspense,
3448 create: createSuspenseBoundary,
3449 normalize: normalizeSuspenseChildren
3450};
3451// Force-casted public typing for h and TSX props inference
3452const Suspense = (SuspenseImpl );
3453function triggerEvent(vnode, name) {
3454 const eventListener = vnode.props && vnode.props[name];
3455 if (isFunction(eventListener)) {
3456 eventListener();
3457 }
3458}
3459function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
3460 const { p: patch, o: { createElement } } = rendererInternals;
3461 const hiddenContainer = createElement('div');
3462 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
3463 // start mounting the content subtree in an off-dom container
3464 patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
3465 // now check if we have encountered any async deps
3466 if (suspense.deps > 0) {
3467 // has async
3468 // invoke @fallback event
3469 triggerEvent(vnode, 'onPending');
3470 triggerEvent(vnode, 'onFallback');
3471 // mount the fallback tree
3472 patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
3473 isSVG, slotScopeIds);
3474 setActiveBranch(suspense, vnode.ssFallback);
3475 }
3476 else {
3477 // Suspense has no async deps. Just resolve.
3478 suspense.resolve();
3479 }
3480}
3481function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
3482 const suspense = (n2.suspense = n1.suspense);
3483 suspense.vnode = n2;
3484 n2.el = n1.el;
3485 const newBranch = n2.ssContent;
3486 const newFallback = n2.ssFallback;
3487 const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
3488 if (pendingBranch) {
3489 suspense.pendingBranch = newBranch;
3490 if (isSameVNodeType(newBranch, pendingBranch)) {
3491 // same root type but content may have changed.
3492 patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
3493 if (suspense.deps <= 0) {
3494 suspense.resolve();
3495 }
3496 else if (isInFallback) {
3497 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
3498 isSVG, slotScopeIds, optimized);
3499 setActiveBranch(suspense, newFallback);
3500 }
3501 }
3502 else {
3503 // toggled before pending tree is resolved
3504 suspense.pendingId++;
3505 if (isHydrating) {
3506 // if toggled before hydration is finished, the current DOM tree is
3507 // no longer valid. set it as the active branch so it will be unmounted
3508 // when resolved
3509 suspense.isHydrating = false;
3510 suspense.activeBranch = pendingBranch;
3511 }
3512 else {
3513 unmount(pendingBranch, parentComponent, suspense);
3514 }
3515 // increment pending ID. this is used to invalidate async callbacks
3516 // reset suspense state
3517 suspense.deps = 0;
3518 // discard effects from pending branch
3519 suspense.effects.length = 0;
3520 // discard previous container
3521 suspense.hiddenContainer = createElement('div');
3522 if (isInFallback) {
3523 // already in fallback state
3524 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
3525 if (suspense.deps <= 0) {
3526 suspense.resolve();
3527 }
3528 else {
3529 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
3530 isSVG, slotScopeIds, optimized);
3531 setActiveBranch(suspense, newFallback);
3532 }
3533 }
3534 else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
3535 // toggled "back" to current active branch
3536 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
3537 // force resolve
3538 suspense.resolve(true);
3539 }
3540 else {
3541 // switched to a 3rd branch
3542 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
3543 if (suspense.deps <= 0) {
3544 suspense.resolve();
3545 }
3546 }
3547 }
3548 }
3549 else {
3550 if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
3551 // root did not change, just normal patch
3552 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
3553 setActiveBranch(suspense, newBranch);
3554 }
3555 else {
3556 // root node toggled
3557 // invoke @pending event
3558 triggerEvent(n2, 'onPending');
3559 // mount pending branch in off-dom container
3560 suspense.pendingBranch = newBranch;
3561 suspense.pendingId++;
3562 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
3563 if (suspense.deps <= 0) {
3564 // incoming branch has no async deps, resolve now.
3565 suspense.resolve();
3566 }
3567 else {
3568 const { timeout, pendingId } = suspense;
3569 if (timeout > 0) {
3570 setTimeout(() => {
3571 if (suspense.pendingId === pendingId) {
3572 suspense.fallback(newFallback);
3573 }
3574 }, timeout);
3575 }
3576 else if (timeout === 0) {
3577 suspense.fallback(newFallback);
3578 }
3579 }
3580 }
3581 }
3582}
3583let hasWarned = false;
3584function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
3585 /* istanbul ignore if */
3586 if (!hasWarned) {
3587 hasWarned = true;
3588 // @ts-ignore `console.info` cannot be null error
3589 console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
3590 }
3591 const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
3592 const timeout = toNumber(vnode.props && vnode.props.timeout);
3593 const suspense = {
3594 vnode,
3595 parent,
3596 parentComponent,
3597 isSVG,
3598 container,
3599 hiddenContainer,
3600 anchor,
3601 deps: 0,
3602 pendingId: 0,
3603 timeout: typeof timeout === 'number' ? timeout : -1,
3604 activeBranch: null,
3605 pendingBranch: null,
3606 isInFallback: true,
3607 isHydrating,
3608 isUnmounted: false,
3609 effects: [],
3610 resolve(resume = false) {
3611 {
3612 if (!resume && !suspense.pendingBranch) {
3613 throw new Error(`suspense.resolve() is called without a pending branch.`);
3614 }
3615 if (suspense.isUnmounted) {
3616 throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
3617 }
3618 }
3619 const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
3620 if (suspense.isHydrating) {
3621 suspense.isHydrating = false;
3622 }
3623 else if (!resume) {
3624 const delayEnter = activeBranch &&
3625 pendingBranch.transition &&
3626 pendingBranch.transition.mode === 'out-in';
3627 if (delayEnter) {
3628 activeBranch.transition.afterLeave = () => {
3629 if (pendingId === suspense.pendingId) {
3630 move(pendingBranch, container, anchor, 0 /* MoveType.ENTER */);
3631 }
3632 };
3633 }
3634 // this is initial anchor on mount
3635 let { anchor } = suspense;
3636 // unmount current active tree
3637 if (activeBranch) {
3638 // if the fallback tree was mounted, it may have been moved
3639 // as part of a parent suspense. get the latest anchor for insertion
3640 anchor = next(activeBranch);
3641 unmount(activeBranch, parentComponent, suspense, true);
3642 }
3643 if (!delayEnter) {
3644 // move content from off-dom container to actual container
3645 move(pendingBranch, container, anchor, 0 /* MoveType.ENTER */);
3646 }
3647 }
3648 setActiveBranch(suspense, pendingBranch);
3649 suspense.pendingBranch = null;
3650 suspense.isInFallback = false;
3651 // flush buffered effects
3652 // check if there is a pending parent suspense
3653 let parent = suspense.parent;
3654 let hasUnresolvedAncestor = false;
3655 while (parent) {
3656 if (parent.pendingBranch) {
3657 // found a pending parent suspense, merge buffered post jobs
3658 // into that parent
3659 parent.effects.push(...effects);
3660 hasUnresolvedAncestor = true;
3661 break;
3662 }
3663 parent = parent.parent;
3664 }
3665 // no pending parent suspense, flush all jobs
3666 if (!hasUnresolvedAncestor) {
3667 queuePostFlushCb(effects);
3668 }
3669 suspense.effects = [];
3670 // invoke @resolve event
3671 triggerEvent(vnode, 'onResolve');
3672 },
3673 fallback(fallbackVNode) {
3674 if (!suspense.pendingBranch) {
3675 return;
3676 }
3677 const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
3678 // invoke @fallback event
3679 triggerEvent(vnode, 'onFallback');
3680 const anchor = next(activeBranch);
3681 const mountFallback = () => {
3682 if (!suspense.isInFallback) {
3683 return;
3684 }
3685 // mount the fallback tree
3686 patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
3687 isSVG, slotScopeIds, optimized);
3688 setActiveBranch(suspense, fallbackVNode);
3689 };
3690 const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
3691 if (delayEnter) {
3692 activeBranch.transition.afterLeave = mountFallback;
3693 }
3694 suspense.isInFallback = true;
3695 // unmount current active branch
3696 unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
3697 true // shouldRemove
3698 );
3699 if (!delayEnter) {
3700 mountFallback();
3701 }
3702 },
3703 move(container, anchor, type) {
3704 suspense.activeBranch &&
3705 move(suspense.activeBranch, container, anchor, type);
3706 suspense.container = container;
3707 },
3708 next() {
3709 return suspense.activeBranch && next(suspense.activeBranch);
3710 },
3711 registerDep(instance, setupRenderEffect) {
3712 const isInPendingSuspense = !!suspense.pendingBranch;
3713 if (isInPendingSuspense) {
3714 suspense.deps++;
3715 }
3716 const hydratedEl = instance.vnode.el;
3717 instance
3718 .asyncDep.catch(err => {
3719 handleError(err, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
3720 })
3721 .then(asyncSetupResult => {
3722 // retry when the setup() promise resolves.
3723 // component may have been unmounted before resolve.
3724 if (instance.isUnmounted ||
3725 suspense.isUnmounted ||
3726 suspense.pendingId !== instance.suspenseId) {
3727 return;
3728 }
3729 // retry from this component
3730 instance.asyncResolved = true;
3731 const { vnode } = instance;
3732 {
3733 pushWarningContext(vnode);
3734 }
3735 handleSetupResult(instance, asyncSetupResult, false);
3736 if (hydratedEl) {
3737 // vnode may have been replaced if an update happened before the
3738 // async dep is resolved.
3739 vnode.el = hydratedEl;
3740 }
3741 const placeholder = !hydratedEl && instance.subTree.el;
3742 setupRenderEffect(instance, vnode,
3743 // component may have been moved before resolve.
3744 // if this is not a hydration, instance.subTree will be the comment
3745 // placeholder.
3746 parentNode(hydratedEl || instance.subTree.el),
3747 // anchor will not be used if this is hydration, so only need to
3748 // consider the comment placeholder case.
3749 hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
3750 if (placeholder) {
3751 remove(placeholder);
3752 }
3753 updateHOCHostEl(instance, vnode.el);
3754 {
3755 popWarningContext();
3756 }
3757 // only decrease deps count if suspense is not already resolved
3758 if (isInPendingSuspense && --suspense.deps === 0) {
3759 suspense.resolve();
3760 }
3761 });
3762 },
3763 unmount(parentSuspense, doRemove) {
3764 suspense.isUnmounted = true;
3765 if (suspense.activeBranch) {
3766 unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
3767 }
3768 if (suspense.pendingBranch) {
3769 unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
3770 }
3771 }
3772 };
3773 return suspense;
3774}
3775function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
3776 /* eslint-disable no-restricted-globals */
3777 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
3778 // there are two possible scenarios for server-rendered suspense:
3779 // - success: ssr content should be fully resolved
3780 // - failure: ssr content should be the fallback branch.
3781 // however, on the client we don't really know if it has failed or not
3782 // attempt to hydrate the DOM assuming it has succeeded, but we still
3783 // need to construct a suspense boundary first
3784 const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
3785 if (suspense.deps === 0) {
3786 suspense.resolve();
3787 }
3788 return result;
3789 /* eslint-enable no-restricted-globals */
3790}
3791function normalizeSuspenseChildren(vnode) {
3792 const { shapeFlag, children } = vnode;
3793 const isSlotChildren = shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */;
3794 vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
3795 vnode.ssFallback = isSlotChildren
3796 ? normalizeSuspenseSlot(children.fallback)
3797 : createVNode(Comment);
3798}
3799function normalizeSuspenseSlot(s) {
3800 let block;
3801 if (isFunction(s)) {
3802 const trackBlock = isBlockTreeEnabled && s._c;
3803 if (trackBlock) {
3804 // disableTracking: false
3805 // allow block tracking for compiled slots
3806 // (see ./componentRenderContext.ts)
3807 s._d = false;
3808 openBlock();
3809 }
3810 s = s();
3811 if (trackBlock) {
3812 s._d = true;
3813 block = currentBlock;
3814 closeBlock();
3815 }
3816 }
3817 if (isArray(s)) {
3818 const singleChild = filterSingleRoot(s);
3819 if (!singleChild) {
3820 warn$1(`<Suspense> slots expect a single root node.`);
3821 }
3822 s = singleChild;
3823 }
3824 s = normalizeVNode(s);
3825 if (block && !s.dynamicChildren) {
3826 s.dynamicChildren = block.filter(c => c !== s);
3827 }
3828 return s;
3829}
3830function queueEffectWithSuspense(fn, suspense) {
3831 if (suspense && suspense.pendingBranch) {
3832 if (isArray(fn)) {
3833 suspense.effects.push(...fn);
3834 }
3835 else {
3836 suspense.effects.push(fn);
3837 }
3838 }
3839 else {
3840 queuePostFlushCb(fn);
3841 }
3842}
3843function setActiveBranch(suspense, branch) {
3844 suspense.activeBranch = branch;
3845 const { vnode, parentComponent } = suspense;
3846 const el = (vnode.el = branch.el);
3847 // in case suspense is the root node of a component,
3848 // recursively update the HOC el
3849 if (parentComponent && parentComponent.subTree === vnode) {
3850 parentComponent.vnode.el = el;
3851 updateHOCHostEl(parentComponent, el);
3852 }
3853}
3854
3855function provide(key, value) {
3856 if (!currentInstance) {
3857 {
3858 warn$1(`provide() can only be used inside setup().`);
3859 }
3860 }
3861 else {
3862 let provides = currentInstance.provides;
3863 // by default an instance inherits its parent's provides object
3864 // but when it needs to provide values of its own, it creates its
3865 // own provides object using parent provides object as prototype.
3866 // this way in `inject` we can simply look up injections from direct
3867 // parent and let the prototype chain do the work.
3868 const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3869 if (parentProvides === provides) {
3870 provides = currentInstance.provides = Object.create(parentProvides);
3871 }
3872 // TS doesn't allow symbol as index type
3873 provides[key] = value;
3874 }
3875}
3876function inject(key, defaultValue, treatDefaultAsFactory = false) {
3877 // fallback to `currentRenderingInstance` so that this can be called in
3878 // a functional component
3879 const instance = currentInstance || currentRenderingInstance;
3880 if (instance) {
3881 // #2400
3882 // to support `app.use` plugins,
3883 // fallback to appContext's `provides` if the instance is at root
3884 const provides = instance.parent == null
3885 ? instance.vnode.appContext && instance.vnode.appContext.provides
3886 : instance.parent.provides;
3887 if (provides && key in provides) {
3888 // TS doesn't allow symbol as index type
3889 return provides[key];
3890 }
3891 else if (arguments.length > 1) {
3892 return treatDefaultAsFactory && isFunction(defaultValue)
3893 ? defaultValue.call(instance.proxy)
3894 : defaultValue;
3895 }
3896 else {
3897 warn$1(`injection "${String(key)}" not found.`);
3898 }
3899 }
3900 else {
3901 warn$1(`inject() can only be used inside setup() or functional components.`);
3902 }
3903}
3904
3905// Simple effect.
3906function watchEffect(effect, options) {
3907 return doWatch(effect, null, options);
3908}
3909function watchPostEffect(effect, options) {
3910 return doWatch(effect, null, ({ ...options, flush: 'post' }
3911 ));
3912}
3913function watchSyncEffect(effect, options) {
3914 return doWatch(effect, null, ({ ...options, flush: 'sync' }
3915 ));
3916}
3917// initial value for watchers to trigger on undefined initial values
3918const INITIAL_WATCHER_VALUE = {};
3919// implementation
3920function watch(source, cb, options) {
3921 if (!isFunction(cb)) {
3922 warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
3923 `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
3924 `supports \`watch(source, cb, options?) signature.`);
3925 }
3926 return doWatch(source, cb, options);
3927}
3928function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3929 if (!cb) {
3930 if (immediate !== undefined) {
3931 warn$1(`watch() "immediate" option is only respected when using the ` +
3932 `watch(source, callback, options?) signature.`);
3933 }
3934 if (deep !== undefined) {
3935 warn$1(`watch() "deep" option is only respected when using the ` +
3936 `watch(source, callback, options?) signature.`);
3937 }
3938 }
3939 const warnInvalidSource = (s) => {
3940 warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
3941 `a reactive object, or an array of these types.`);
3942 };
3943 const instance = currentInstance;
3944 let getter;
3945 let forceTrigger = false;
3946 let isMultiSource = false;
3947 if (isRef(source)) {
3948 getter = () => source.value;
3949 forceTrigger = isShallow(source);
3950 }
3951 else if (isReactive(source)) {
3952 getter = () => source;
3953 deep = true;
3954 }
3955 else if (isArray(source)) {
3956 isMultiSource = true;
3957 forceTrigger = source.some(s => isReactive(s) || isShallow(s));
3958 getter = () => source.map(s => {
3959 if (isRef(s)) {
3960 return s.value;
3961 }
3962 else if (isReactive(s)) {
3963 return traverse(s);
3964 }
3965 else if (isFunction(s)) {
3966 return callWithErrorHandling(s, instance, 2 /* ErrorCodes.WATCH_GETTER */);
3967 }
3968 else {
3969 warnInvalidSource(s);
3970 }
3971 });
3972 }
3973 else if (isFunction(source)) {
3974 if (cb) {
3975 // getter with cb
3976 getter = () => callWithErrorHandling(source, instance, 2 /* ErrorCodes.WATCH_GETTER */);
3977 }
3978 else {
3979 // no cb -> simple effect
3980 getter = () => {
3981 if (instance && instance.isUnmounted) {
3982 return;
3983 }
3984 if (cleanup) {
3985 cleanup();
3986 }
3987 return callWithAsyncErrorHandling(source, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [onCleanup]);
3988 };
3989 }
3990 }
3991 else {
3992 getter = NOOP;
3993 warnInvalidSource(source);
3994 }
3995 // 2.x array mutation watch compat
3996 if (cb && !deep) {
3997 const baseGetter = getter;
3998 getter = () => {
3999 const val = baseGetter();
4000 if (isArray(val) &&
4001 checkCompatEnabled("WATCH_ARRAY" /* DeprecationTypes.WATCH_ARRAY */, instance)) {
4002 traverse(val);
4003 }
4004 return val;
4005 };
4006 }
4007 if (cb && deep) {
4008 const baseGetter = getter;
4009 getter = () => traverse(baseGetter());
4010 }
4011 let cleanup;
4012 let onCleanup = (fn) => {
4013 cleanup = effect.onStop = () => {
4014 callWithErrorHandling(fn, instance, 4 /* ErrorCodes.WATCH_CLEANUP */);
4015 };
4016 };
4017 // in SSR there is no need to setup an actual effect, and it should be noop
4018 // unless it's eager
4019 if (isInSSRComponentSetup) {
4020 // we will also not call the invalidate callback (+ runner is not set up)
4021 onCleanup = NOOP;
4022 if (!cb) {
4023 getter();
4024 }
4025 else if (immediate) {
4026 callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
4027 getter(),
4028 isMultiSource ? [] : undefined,
4029 onCleanup
4030 ]);
4031 }
4032 return NOOP;
4033 }
4034 let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
4035 const job = () => {
4036 if (!effect.active) {
4037 return;
4038 }
4039 if (cb) {
4040 // watch(source, cb)
4041 const newValue = effect.run();
4042 if (deep ||
4043 forceTrigger ||
4044 (isMultiSource
4045 ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
4046 : hasChanged(newValue, oldValue)) ||
4047 (isArray(newValue) &&
4048 isCompatEnabled("WATCH_ARRAY" /* DeprecationTypes.WATCH_ARRAY */, instance))) {
4049 // cleanup before running cb again
4050 if (cleanup) {
4051 cleanup();
4052 }
4053 callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
4054 newValue,
4055 // pass undefined as the old value when it's changed for the first time
4056 oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
4057 onCleanup
4058 ]);
4059 oldValue = newValue;
4060 }
4061 }
4062 else {
4063 // watchEffect
4064 effect.run();
4065 }
4066 };
4067 // important: mark the job as a watcher callback so that scheduler knows
4068 // it is allowed to self-trigger (#1727)
4069 job.allowRecurse = !!cb;
4070 let scheduler;
4071 if (flush === 'sync') {
4072 scheduler = job; // the scheduler function gets called directly
4073 }
4074 else if (flush === 'post') {
4075 scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4076 }
4077 else {
4078 // default: 'pre'
4079 job.pre = true;
4080 if (instance)
4081 job.id = instance.uid;
4082 scheduler = () => queueJob(job);
4083 }
4084 const effect = new ReactiveEffect(getter, scheduler);
4085 {
4086 effect.onTrack = onTrack;
4087 effect.onTrigger = onTrigger;
4088 }
4089 // initial run
4090 if (cb) {
4091 if (immediate) {
4092 job();
4093 }
4094 else {
4095 oldValue = effect.run();
4096 }
4097 }
4098 else if (flush === 'post') {
4099 queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
4100 }
4101 else {
4102 effect.run();
4103 }
4104 return () => {
4105 effect.stop();
4106 if (instance && instance.scope) {
4107 remove(instance.scope.effects, effect);
4108 }
4109 };
4110}
4111// this.$watch
4112function instanceWatch(source, value, options) {
4113 const publicThis = this.proxy;
4114 const getter = isString(source)
4115 ? source.includes('.')
4116 ? createPathGetter(publicThis, source)
4117 : () => publicThis[source]
4118 : source.bind(publicThis, publicThis);
4119 let cb;
4120 if (isFunction(value)) {
4121 cb = value;
4122 }
4123 else {
4124 cb = value.handler;
4125 options = value;
4126 }
4127 const cur = currentInstance;
4128 setCurrentInstance(this);
4129 const res = doWatch(getter, cb.bind(publicThis), options);
4130 if (cur) {
4131 setCurrentInstance(cur);
4132 }
4133 else {
4134 unsetCurrentInstance();
4135 }
4136 return res;
4137}
4138function createPathGetter(ctx, path) {
4139 const segments = path.split('.');
4140 return () => {
4141 let cur = ctx;
4142 for (let i = 0; i < segments.length && cur; i++) {
4143 cur = cur[segments[i]];
4144 }
4145 return cur;
4146 };
4147}
4148function traverse(value, seen) {
4149 if (!isObject(value) || value["__v_skip" /* ReactiveFlags.SKIP */]) {
4150 return value;
4151 }
4152 seen = seen || new Set();
4153 if (seen.has(value)) {
4154 return value;
4155 }
4156 seen.add(value);
4157 if (isRef(value)) {
4158 traverse(value.value, seen);
4159 }
4160 else if (isArray(value)) {
4161 for (let i = 0; i < value.length; i++) {
4162 traverse(value[i], seen);
4163 }
4164 }
4165 else if (isSet(value) || isMap(value)) {
4166 value.forEach((v) => {
4167 traverse(v, seen);
4168 });
4169 }
4170 else if (isPlainObject(value)) {
4171 for (const key in value) {
4172 traverse(value[key], seen);
4173 }
4174 }
4175 return value;
4176}
4177
4178function useTransitionState() {
4179 const state = {
4180 isMounted: false,
4181 isLeaving: false,
4182 isUnmounting: false,
4183 leavingVNodes: new Map()
4184 };
4185 onMounted(() => {
4186 state.isMounted = true;
4187 });
4188 onBeforeUnmount(() => {
4189 state.isUnmounting = true;
4190 });
4191 return state;
4192}
4193const TransitionHookValidator = [Function, Array];
4194const BaseTransitionImpl = {
4195 name: `BaseTransition`,
4196 props: {
4197 mode: String,
4198 appear: Boolean,
4199 persisted: Boolean,
4200 // enter
4201 onBeforeEnter: TransitionHookValidator,
4202 onEnter: TransitionHookValidator,
4203 onAfterEnter: TransitionHookValidator,
4204 onEnterCancelled: TransitionHookValidator,
4205 // leave
4206 onBeforeLeave: TransitionHookValidator,
4207 onLeave: TransitionHookValidator,
4208 onAfterLeave: TransitionHookValidator,
4209 onLeaveCancelled: TransitionHookValidator,
4210 // appear
4211 onBeforeAppear: TransitionHookValidator,
4212 onAppear: TransitionHookValidator,
4213 onAfterAppear: TransitionHookValidator,
4214 onAppearCancelled: TransitionHookValidator
4215 },
4216 setup(props, { slots }) {
4217 const instance = getCurrentInstance();
4218 const state = useTransitionState();
4219 let prevTransitionKey;
4220 return () => {
4221 const children = slots.default && getTransitionRawChildren(slots.default(), true);
4222 if (!children || !children.length) {
4223 return;
4224 }
4225 let child = children[0];
4226 if (children.length > 1) {
4227 let hasFound = false;
4228 // locate first non-comment child
4229 for (const c of children) {
4230 if (c.type !== Comment) {
4231 if (hasFound) {
4232 // warn more than one non-comment child
4233 warn$1('<transition> can only be used on a single element or component. ' +
4234 'Use <transition-group> for lists.');
4235 break;
4236 }
4237 child = c;
4238 hasFound = true;
4239 }
4240 }
4241 }
4242 // there's no need to track reactivity for these props so use the raw
4243 // props for a bit better perf
4244 const rawProps = toRaw(props);
4245 const { mode } = rawProps;
4246 // check mode
4247 if (mode &&
4248 mode !== 'in-out' &&
4249 mode !== 'out-in' &&
4250 mode !== 'default') {
4251 warn$1(`invalid <transition> mode: ${mode}`);
4252 }
4253 if (state.isLeaving) {
4254 return emptyPlaceholder(child);
4255 }
4256 // in the case of <transition><keep-alive/></transition>, we need to
4257 // compare the type of the kept-alive children.
4258 const innerChild = getKeepAliveChild(child);
4259 if (!innerChild) {
4260 return emptyPlaceholder(child);
4261 }
4262 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
4263 setTransitionHooks(innerChild, enterHooks);
4264 const oldChild = instance.subTree;
4265 const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4266 let transitionKeyChanged = false;
4267 const { getTransitionKey } = innerChild.type;
4268 if (getTransitionKey) {
4269 const key = getTransitionKey();
4270 if (prevTransitionKey === undefined) {
4271 prevTransitionKey = key;
4272 }
4273 else if (key !== prevTransitionKey) {
4274 prevTransitionKey = key;
4275 transitionKeyChanged = true;
4276 }
4277 }
4278 // handle mode
4279 if (oldInnerChild &&
4280 oldInnerChild.type !== Comment &&
4281 (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
4282 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
4283 // update old tree's hooks in case of dynamic transition
4284 setTransitionHooks(oldInnerChild, leavingHooks);
4285 // switching between different views
4286 if (mode === 'out-in') {
4287 state.isLeaving = true;
4288 // return placeholder node and queue update when leave finishes
4289 leavingHooks.afterLeave = () => {
4290 state.isLeaving = false;
4291 instance.update();
4292 };
4293 return emptyPlaceholder(child);
4294 }
4295 else if (mode === 'in-out' && innerChild.type !== Comment) {
4296 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
4297 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
4298 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
4299 // early removal callback
4300 el._leaveCb = () => {
4301 earlyRemove();
4302 el._leaveCb = undefined;
4303 delete enterHooks.delayedLeave;
4304 };
4305 enterHooks.delayedLeave = delayedLeave;
4306 };
4307 }
4308 }
4309 return child;
4310 };
4311 }
4312};
4313{
4314 BaseTransitionImpl.__isBuiltIn = true;
4315}
4316// export the public type for h/tsx inference
4317// also to avoid inline import() in generated d.ts files
4318const BaseTransition = BaseTransitionImpl;
4319function getLeavingNodesForType(state, vnode) {
4320 const { leavingVNodes } = state;
4321 let leavingVNodesCache = leavingVNodes.get(vnode.type);
4322 if (!leavingVNodesCache) {
4323 leavingVNodesCache = Object.create(null);
4324 leavingVNodes.set(vnode.type, leavingVNodesCache);
4325 }
4326 return leavingVNodesCache;
4327}
4328// The transition hooks are attached to the vnode as vnode.transition
4329// and will be called at appropriate timing in the renderer.
4330function resolveTransitionHooks(vnode, props, state, instance) {
4331 const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
4332 const key = String(vnode.key);
4333 const leavingVNodesCache = getLeavingNodesForType(state, vnode);
4334 const callHook = (hook, args) => {
4335 hook &&
4336 callWithAsyncErrorHandling(hook, instance, 9 /* ErrorCodes.TRANSITION_HOOK */, args);
4337 };
4338 const callAsyncHook = (hook, args) => {
4339 const done = args[1];
4340 callHook(hook, args);
4341 if (isArray(hook)) {
4342 if (hook.every(hook => hook.length <= 1))
4343 done();
4344 }
4345 else if (hook.length <= 1) {
4346 done();
4347 }
4348 };
4349 const hooks = {
4350 mode,
4351 persisted,
4352 beforeEnter(el) {
4353 let hook = onBeforeEnter;
4354 if (!state.isMounted) {
4355 if (appear) {
4356 hook = onBeforeAppear || onBeforeEnter;
4357 }
4358 else {
4359 return;
4360 }
4361 }
4362 // for same element (v-show)
4363 if (el._leaveCb) {
4364 el._leaveCb(true /* cancelled */);
4365 }
4366 // for toggled element with same key (v-if)
4367 const leavingVNode = leavingVNodesCache[key];
4368 if (leavingVNode &&
4369 isSameVNodeType(vnode, leavingVNode) &&
4370 leavingVNode.el._leaveCb) {
4371 // force early removal (not cancelled)
4372 leavingVNode.el._leaveCb();
4373 }
4374 callHook(hook, [el]);
4375 },
4376 enter(el) {
4377 let hook = onEnter;
4378 let afterHook = onAfterEnter;
4379 let cancelHook = onEnterCancelled;
4380 if (!state.isMounted) {
4381 if (appear) {
4382 hook = onAppear || onEnter;
4383 afterHook = onAfterAppear || onAfterEnter;
4384 cancelHook = onAppearCancelled || onEnterCancelled;
4385 }
4386 else {
4387 return;
4388 }
4389 }
4390 let called = false;
4391 const done = (el._enterCb = (cancelled) => {
4392 if (called)
4393 return;
4394 called = true;
4395 if (cancelled) {
4396 callHook(cancelHook, [el]);
4397 }
4398 else {
4399 callHook(afterHook, [el]);
4400 }
4401 if (hooks.delayedLeave) {
4402 hooks.delayedLeave();
4403 }
4404 el._enterCb = undefined;
4405 });
4406 if (hook) {
4407 callAsyncHook(hook, [el, done]);
4408 }
4409 else {
4410 done();
4411 }
4412 },
4413 leave(el, remove) {
4414 const key = String(vnode.key);
4415 if (el._enterCb) {
4416 el._enterCb(true /* cancelled */);
4417 }
4418 if (state.isUnmounting) {
4419 return remove();
4420 }
4421 callHook(onBeforeLeave, [el]);
4422 let called = false;
4423 const done = (el._leaveCb = (cancelled) => {
4424 if (called)
4425 return;
4426 called = true;
4427 remove();
4428 if (cancelled) {
4429 callHook(onLeaveCancelled, [el]);
4430 }
4431 else {
4432 callHook(onAfterLeave, [el]);
4433 }
4434 el._leaveCb = undefined;
4435 if (leavingVNodesCache[key] === vnode) {
4436 delete leavingVNodesCache[key];
4437 }
4438 });
4439 leavingVNodesCache[key] = vnode;
4440 if (onLeave) {
4441 callAsyncHook(onLeave, [el, done]);
4442 }
4443 else {
4444 done();
4445 }
4446 },
4447 clone(vnode) {
4448 return resolveTransitionHooks(vnode, props, state, instance);
4449 }
4450 };
4451 return hooks;
4452}
4453// the placeholder really only handles one special case: KeepAlive
4454// in the case of a KeepAlive in a leave phase we need to return a KeepAlive
4455// placeholder with empty content to avoid the KeepAlive instance from being
4456// unmounted.
4457function emptyPlaceholder(vnode) {
4458 if (isKeepAlive(vnode)) {
4459 vnode = cloneVNode(vnode);
4460 vnode.children = null;
4461 return vnode;
4462 }
4463}
4464function getKeepAliveChild(vnode) {
4465 return isKeepAlive(vnode)
4466 ? vnode.children
4467 ? vnode.children[0]
4468 : undefined
4469 : vnode;
4470}
4471function setTransitionHooks(vnode, hooks) {
4472 if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */ && vnode.component) {
4473 setTransitionHooks(vnode.component.subTree, hooks);
4474 }
4475 else if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
4476 vnode.ssContent.transition = hooks.clone(vnode.ssContent);
4477 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
4478 }
4479 else {
4480 vnode.transition = hooks;
4481 }
4482}
4483function getTransitionRawChildren(children, keepComment = false, parentKey) {
4484 let ret = [];
4485 let keyedFragmentCount = 0;
4486 for (let i = 0; i < children.length; i++) {
4487 let child = children[i];
4488 // #5360 inherit parent key in case of <template v-for>
4489 const key = parentKey == null
4490 ? child.key
4491 : String(parentKey) + String(child.key != null ? child.key : i);
4492 // handle fragment children case, e.g. v-for
4493 if (child.type === Fragment) {
4494 if (child.patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */)
4495 keyedFragmentCount++;
4496 ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
4497 }
4498 // comment placeholders should be skipped, e.g. v-if
4499 else if (keepComment || child.type !== Comment) {
4500 ret.push(key != null ? cloneVNode(child, { key }) : child);
4501 }
4502 }
4503 // #1126 if a transition children list contains multiple sub fragments, these
4504 // fragments will be merged into a flat children array. Since each v-for
4505 // fragment may contain different static bindings inside, we need to de-op
4506 // these children to force full diffs to ensure correct behavior.
4507 if (keyedFragmentCount > 1) {
4508 for (let i = 0; i < ret.length; i++) {
4509 ret[i].patchFlag = -2 /* PatchFlags.BAIL */;
4510 }
4511 }
4512 return ret;
4513}
4514
4515// implementation, close to no-op
4516function defineComponent(options) {
4517 return isFunction(options) ? { setup: options, name: options.name } : options;
4518}
4519
4520const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
4521function defineAsyncComponent(source) {
4522 if (isFunction(source)) {
4523 source = { loader: source };
4524 }
4525 const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
4526 suspensible = true, onError: userOnError } = source;
4527 let pendingRequest = null;
4528 let resolvedComp;
4529 let retries = 0;
4530 const retry = () => {
4531 retries++;
4532 pendingRequest = null;
4533 return load();
4534 };
4535 const load = () => {
4536 let thisRequest;
4537 return (pendingRequest ||
4538 (thisRequest = pendingRequest =
4539 loader()
4540 .catch(err => {
4541 err = err instanceof Error ? err : new Error(String(err));
4542 if (userOnError) {
4543 return new Promise((resolve, reject) => {
4544 const userRetry = () => resolve(retry());
4545 const userFail = () => reject(err);
4546 userOnError(err, userRetry, userFail, retries + 1);
4547 });
4548 }
4549 else {
4550 throw err;
4551 }
4552 })
4553 .then((comp) => {
4554 if (thisRequest !== pendingRequest && pendingRequest) {
4555 return pendingRequest;
4556 }
4557 if (!comp) {
4558 warn$1(`Async component loader resolved to undefined. ` +
4559 `If you are using retry(), make sure to return its return value.`);
4560 }
4561 // interop module default
4562 if (comp &&
4563 (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
4564 comp = comp.default;
4565 }
4566 if (comp && !isObject(comp) && !isFunction(comp)) {
4567 throw new Error(`Invalid async component load result: ${comp}`);
4568 }
4569 resolvedComp = comp;
4570 return comp;
4571 })));
4572 };
4573 return defineComponent({
4574 name: 'AsyncComponentWrapper',
4575 __asyncLoader: load,
4576 get __asyncResolved() {
4577 return resolvedComp;
4578 },
4579 setup() {
4580 const instance = currentInstance;
4581 // already resolved
4582 if (resolvedComp) {
4583 return () => createInnerComp(resolvedComp, instance);
4584 }
4585 const onError = (err) => {
4586 pendingRequest = null;
4587 handleError(err, instance, 13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
4588 };
4589 // suspense-controlled or SSR.
4590 if ((suspensible && instance.suspense) ||
4591 (isInSSRComponentSetup)) {
4592 return load()
4593 .then(comp => {
4594 return () => createInnerComp(comp, instance);
4595 })
4596 .catch(err => {
4597 onError(err);
4598 return () => errorComponent
4599 ? createVNode(errorComponent, {
4600 error: err
4601 })
4602 : null;
4603 });
4604 }
4605 const loaded = ref(false);
4606 const error = ref();
4607 const delayed = ref(!!delay);
4608 if (delay) {
4609 setTimeout(() => {
4610 delayed.value = false;
4611 }, delay);
4612 }
4613 if (timeout != null) {
4614 setTimeout(() => {
4615 if (!loaded.value && !error.value) {
4616 const err = new Error(`Async component timed out after ${timeout}ms.`);
4617 onError(err);
4618 error.value = err;
4619 }
4620 }, timeout);
4621 }
4622 load()
4623 .then(() => {
4624 loaded.value = true;
4625 if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4626 // parent is keep-alive, force update so the loaded component's
4627 // name is taken into account
4628 queueJob(instance.parent.update);
4629 }
4630 })
4631 .catch(err => {
4632 onError(err);
4633 error.value = err;
4634 });
4635 return () => {
4636 if (loaded.value && resolvedComp) {
4637 return createInnerComp(resolvedComp, instance);
4638 }
4639 else if (error.value && errorComponent) {
4640 return createVNode(errorComponent, {
4641 error: error.value
4642 });
4643 }
4644 else if (loadingComponent && !delayed.value) {
4645 return createVNode(loadingComponent);
4646 }
4647 };
4648 }
4649 });
4650}
4651function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
4652 const vnode = createVNode(comp, props, children);
4653 // ensure inner component inherits the async wrapper's ref owner
4654 vnode.ref = ref;
4655 return vnode;
4656}
4657
4658const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
4659const KeepAliveImpl = {
4660 name: `KeepAlive`,
4661 // Marker for special handling inside the renderer. We are not using a ===
4662 // check directly on KeepAlive in the renderer, because importing it directly
4663 // would prevent it from being tree-shaken.
4664 __isKeepAlive: true,
4665 props: {
4666 include: [String, RegExp, Array],
4667 exclude: [String, RegExp, Array],
4668 max: [String, Number]
4669 },
4670 setup(props, { slots }) {
4671 const instance = getCurrentInstance();
4672 // KeepAlive communicates with the instantiated renderer via the
4673 // ctx where the renderer passes in its internals,
4674 // and the KeepAlive instance exposes activate/deactivate implementations.
4675 // The whole point of this is to avoid importing KeepAlive directly in the
4676 // renderer to facilitate tree-shaking.
4677 const sharedContext = instance.ctx;
4678 // if the internal renderer is not registered, it indicates that this is server-side rendering,
4679 // for KeepAlive, we just need to render its children
4680 if (!sharedContext.renderer) {
4681 return () => {
4682 const children = slots.default && slots.default();
4683 return children && children.length === 1 ? children[0] : children;
4684 };
4685 }
4686 const cache = new Map();
4687 const keys = new Set();
4688 let current = null;
4689 {
4690 instance.__v_cache = cache;
4691 }
4692 const parentSuspense = instance.suspense;
4693 const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
4694 const storageContainer = createElement('div');
4695 sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
4696 const instance = vnode.component;
4697 move(vnode, container, anchor, 0 /* MoveType.ENTER */, parentSuspense);
4698 // in case props have changed
4699 patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
4700 queuePostRenderEffect(() => {
4701 instance.isDeactivated = false;
4702 if (instance.a) {
4703 invokeArrayFns(instance.a);
4704 }
4705 const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
4706 if (vnodeHook) {
4707 invokeVNodeHook(vnodeHook, instance.parent, vnode);
4708 }
4709 }, parentSuspense);
4710 {
4711 // Update components tree
4712 devtoolsComponentAdded(instance);
4713 }
4714 };
4715 sharedContext.deactivate = (vnode) => {
4716 const instance = vnode.component;
4717 move(vnode, storageContainer, null, 1 /* MoveType.LEAVE */, parentSuspense);
4718 queuePostRenderEffect(() => {
4719 if (instance.da) {
4720 invokeArrayFns(instance.da);
4721 }
4722 const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
4723 if (vnodeHook) {
4724 invokeVNodeHook(vnodeHook, instance.parent, vnode);
4725 }
4726 instance.isDeactivated = true;
4727 }, parentSuspense);
4728 {
4729 // Update components tree
4730 devtoolsComponentAdded(instance);
4731 }
4732 };
4733 function unmount(vnode) {
4734 // reset the shapeFlag so it can be properly unmounted
4735 resetShapeFlag(vnode);
4736 _unmount(vnode, instance, parentSuspense, true);
4737 }
4738 function pruneCache(filter) {
4739 cache.forEach((vnode, key) => {
4740 const name = getComponentName(vnode.type);
4741 if (name && (!filter || !filter(name))) {
4742 pruneCacheEntry(key);
4743 }
4744 });
4745 }
4746 function pruneCacheEntry(key) {
4747 const cached = cache.get(key);
4748 if (!current || cached.type !== current.type) {
4749 unmount(cached);
4750 }
4751 else if (current) {
4752 // current active instance should no longer be kept-alive.
4753 // we can't unmount it now but it might be later, so reset its flag now.
4754 resetShapeFlag(current);
4755 }
4756 cache.delete(key);
4757 keys.delete(key);
4758 }
4759 // prune cache on include/exclude prop change
4760 watch(() => [props.include, props.exclude], ([include, exclude]) => {
4761 include && pruneCache(name => matches(include, name));
4762 exclude && pruneCache(name => !matches(exclude, name));
4763 },
4764 // prune post-render after `current` has been updated
4765 { flush: 'post', deep: true });
4766 // cache sub tree after render
4767 let pendingCacheKey = null;
4768 const cacheSubtree = () => {
4769 // fix #1621, the pendingCacheKey could be 0
4770 if (pendingCacheKey != null) {
4771 cache.set(pendingCacheKey, getInnerChild(instance.subTree));
4772 }
4773 };
4774 onMounted(cacheSubtree);
4775 onUpdated(cacheSubtree);
4776 onBeforeUnmount(() => {
4777 cache.forEach(cached => {
4778 const { subTree, suspense } = instance;
4779 const vnode = getInnerChild(subTree);
4780 if (cached.type === vnode.type) {
4781 // current instance will be unmounted as part of keep-alive's unmount
4782 resetShapeFlag(vnode);
4783 // but invoke its deactivated hook here
4784 const da = vnode.component.da;
4785 da && queuePostRenderEffect(da, suspense);
4786 return;
4787 }
4788 unmount(cached);
4789 });
4790 });
4791 return () => {
4792 pendingCacheKey = null;
4793 if (!slots.default) {
4794 return null;
4795 }
4796 const children = slots.default();
4797 const rawVNode = children[0];
4798 if (children.length > 1) {
4799 {
4800 warn$1(`KeepAlive should contain exactly one component child.`);
4801 }
4802 current = null;
4803 return children;
4804 }
4805 else if (!isVNode(rawVNode) ||
4806 (!(rawVNode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) &&
4807 !(rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */))) {
4808 current = null;
4809 return rawVNode;
4810 }
4811 let vnode = getInnerChild(rawVNode);
4812 const comp = vnode.type;
4813 // for async components, name check should be based in its loaded
4814 // inner component if available
4815 const name = getComponentName(isAsyncWrapper(vnode)
4816 ? vnode.type.__asyncResolved || {}
4817 : comp);
4818 const { include, exclude, max } = props;
4819 if ((include && (!name || !matches(include, name))) ||
4820 (exclude && name && matches(exclude, name))) {
4821 current = vnode;
4822 return rawVNode;
4823 }
4824 const key = vnode.key == null ? comp : vnode.key;
4825 const cachedVNode = cache.get(key);
4826 // clone vnode if it's reused because we are going to mutate it
4827 if (vnode.el) {
4828 vnode = cloneVNode(vnode);
4829 if (rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
4830 rawVNode.ssContent = vnode;
4831 }
4832 }
4833 // #1513 it's possible for the returned vnode to be cloned due to attr
4834 // fallthrough or scopeId, so the vnode here may not be the final vnode
4835 // that is mounted. Instead of caching it directly, we store the pending
4836 // key and cache `instance.subTree` (the normalized vnode) in
4837 // beforeMount/beforeUpdate hooks.
4838 pendingCacheKey = key;
4839 if (cachedVNode) {
4840 // copy over mounted state
4841 vnode.el = cachedVNode.el;
4842 vnode.component = cachedVNode.component;
4843 if (vnode.transition) {
4844 // recursively update transition hooks on subTree
4845 setTransitionHooks(vnode, vnode.transition);
4846 }
4847 // avoid vnode being mounted as fresh
4848 vnode.shapeFlag |= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4849 // make this key the freshest
4850 keys.delete(key);
4851 keys.add(key);
4852 }
4853 else {
4854 keys.add(key);
4855 // prune oldest entry
4856 if (max && keys.size > parseInt(max, 10)) {
4857 pruneCacheEntry(keys.values().next().value);
4858 }
4859 }
4860 // avoid vnode being unmounted
4861 vnode.shapeFlag |= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4862 current = vnode;
4863 return isSuspense(rawVNode.type) ? rawVNode : vnode;
4864 };
4865 }
4866};
4867{
4868 KeepAliveImpl.__isBuildIn = true;
4869}
4870// export the public type for h/tsx inference
4871// also to avoid inline import() in generated d.ts files
4872const KeepAlive = KeepAliveImpl;
4873function matches(pattern, name) {
4874 if (isArray(pattern)) {
4875 return pattern.some((p) => matches(p, name));
4876 }
4877 else if (isString(pattern)) {
4878 return pattern.split(',').includes(name);
4879 }
4880 else if (pattern.test) {
4881 return pattern.test(name);
4882 }
4883 /* istanbul ignore next */
4884 return false;
4885}
4886function onActivated(hook, target) {
4887 registerKeepAliveHook(hook, "a" /* LifecycleHooks.ACTIVATED */, target);
4888}
4889function onDeactivated(hook, target) {
4890 registerKeepAliveHook(hook, "da" /* LifecycleHooks.DEACTIVATED */, target);
4891}
4892function registerKeepAliveHook(hook, type, target = currentInstance) {
4893 // cache the deactivate branch check wrapper for injected hooks so the same
4894 // hook can be properly deduped by the scheduler. "__wdc" stands for "with
4895 // deactivation check".
4896 const wrappedHook = hook.__wdc ||
4897 (hook.__wdc = () => {
4898 // only fire the hook if the target instance is NOT in a deactivated branch.
4899 let current = target;
4900 while (current) {
4901 if (current.isDeactivated) {
4902 return;
4903 }
4904 current = current.parent;
4905 }
4906 return hook();
4907 });
4908 injectHook(type, wrappedHook, target);
4909 // In addition to registering it on the target instance, we walk up the parent
4910 // chain and register it on all ancestor instances that are keep-alive roots.
4911 // This avoids the need to walk the entire component tree when invoking these
4912 // hooks, and more importantly, avoids the need to track child components in
4913 // arrays.
4914 if (target) {
4915 let current = target.parent;
4916 while (current && current.parent) {
4917 if (isKeepAlive(current.parent.vnode)) {
4918 injectToKeepAliveRoot(wrappedHook, type, target, current);
4919 }
4920 current = current.parent;
4921 }
4922 }
4923}
4924function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4925 // injectHook wraps the original for error handling, so make sure to remove
4926 // the wrapped version.
4927 const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
4928 onUnmounted(() => {
4929 remove(keepAliveRoot[type], injected);
4930 }, target);
4931}
4932function resetShapeFlag(vnode) {
4933 let shapeFlag = vnode.shapeFlag;
4934 if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4935 shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4936 }
4937 if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4938 shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4939 }
4940 vnode.shapeFlag = shapeFlag;
4941}
4942function getInnerChild(vnode) {
4943 return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
4944}
4945
4946function injectHook(type, hook, target = currentInstance, prepend = false) {
4947 if (target) {
4948 const hooks = target[type] || (target[type] = []);
4949 // cache the error handling wrapper for injected hooks so the same hook
4950 // can be properly deduped by the scheduler. "__weh" stands for "with error
4951 // handling".
4952 const wrappedHook = hook.__weh ||
4953 (hook.__weh = (...args) => {
4954 if (target.isUnmounted) {
4955 return;
4956 }
4957 // disable tracking inside all lifecycle hooks
4958 // since they can potentially be called inside effects.
4959 pauseTracking();
4960 // Set currentInstance during hook invocation.
4961 // This assumes the hook does not synchronously trigger other hooks, which
4962 // can only be false when the user does something really funky.
4963 setCurrentInstance(target);
4964 const res = callWithAsyncErrorHandling(hook, target, type, args);
4965 unsetCurrentInstance();
4966 resetTracking();
4967 return res;
4968 });
4969 if (prepend) {
4970 hooks.unshift(wrappedHook);
4971 }
4972 else {
4973 hooks.push(wrappedHook);
4974 }
4975 return wrappedHook;
4976 }
4977 else {
4978 const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
4979 warn$1(`${apiName} is called when there is no active component instance to be ` +
4980 `associated with. ` +
4981 `Lifecycle injection APIs can only be used during execution of setup().` +
4982 (` If you are using async setup(), make sure to register lifecycle ` +
4983 `hooks before the first await statement.`
4984 ));
4985 }
4986}
4987const createHook = (lifecycle) => (hook, target = currentInstance) =>
4988// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4989(!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4990 injectHook(lifecycle, hook, target);
4991const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4992const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4993const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
4994const onUpdated = createHook("u" /* LifecycleHooks.UPDATED */);
4995const onBeforeUnmount = createHook("bum" /* LifecycleHooks.BEFORE_UNMOUNT */);
4996const onUnmounted = createHook("um" /* LifecycleHooks.UNMOUNTED */);
4997const onServerPrefetch = createHook("sp" /* LifecycleHooks.SERVER_PREFETCH */);
4998const onRenderTriggered = createHook("rtg" /* LifecycleHooks.RENDER_TRIGGERED */);
4999const onRenderTracked = createHook("rtc" /* LifecycleHooks.RENDER_TRACKED */);
5000function onErrorCaptured(hook, target = currentInstance) {
5001 injectHook("ec" /* LifecycleHooks.ERROR_CAPTURED */, hook, target);
5002}
5003
5004function getCompatChildren(instance) {
5005 assertCompatEnabled("INSTANCE_CHILDREN" /* DeprecationTypes.INSTANCE_CHILDREN */, instance);
5006 const root = instance.subTree;
5007 const children = [];
5008 if (root) {
5009 walk(root, children);
5010 }
5011 return children;
5012}
5013function walk(vnode, children) {
5014 if (vnode.component) {
5015 children.push(vnode.component.proxy);
5016 }
5017 else if (vnode.shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
5018 const vnodes = vnode.children;
5019 for (let i = 0; i < vnodes.length; i++) {
5020 walk(vnodes[i], children);
5021 }
5022 }
5023}
5024
5025function getCompatListeners(instance) {
5026 assertCompatEnabled("INSTANCE_LISTENERS" /* DeprecationTypes.INSTANCE_LISTENERS */, instance);
5027 const listeners = {};
5028 const rawProps = instance.vnode.props;
5029 if (!rawProps) {
5030 return listeners;
5031 }
5032 for (const key in rawProps) {
5033 if (isOn(key)) {
5034 listeners[key[2].toLowerCase() + key.slice(3)] = rawProps[key];
5035 }
5036 }
5037 return listeners;
5038}
5039
5040const legacyDirectiveHookMap = {
5041 beforeMount: 'bind',
5042 mounted: 'inserted',
5043 updated: ['update', 'componentUpdated'],
5044 unmounted: 'unbind'
5045};
5046function mapCompatDirectiveHook(name, dir, instance) {
5047 const mappedName = legacyDirectiveHookMap[name];
5048 if (mappedName) {
5049 if (isArray(mappedName)) {
5050 const hook = [];
5051 mappedName.forEach(mapped => {
5052 const mappedHook = dir[mapped];
5053 if (mappedHook) {
5054 softAssertCompatEnabled("CUSTOM_DIR" /* DeprecationTypes.CUSTOM_DIR */, instance, mapped, name);
5055 hook.push(mappedHook);
5056 }
5057 });
5058 return hook.length ? hook : undefined;
5059 }
5060 else {
5061 if (dir[mappedName]) {
5062 softAssertCompatEnabled("CUSTOM_DIR" /* DeprecationTypes.CUSTOM_DIR */, instance, mappedName, name);
5063 }
5064 return dir[mappedName];
5065 }
5066 }
5067}
5068
5069/**
5070Runtime helper for applying directives to a vnode. Example usage:
5071
5072const comp = resolveComponent('comp')
5073const foo = resolveDirective('foo')
5074const bar = resolveDirective('bar')
5075
5076return withDirectives(h(comp), [
5077 [foo, this.x],
5078 [bar, this.y]
5079])
5080*/
5081function validateDirectiveName(name) {
5082 if (isBuiltInDirective(name)) {
5083 warn$1('Do not use built-in directive ids as custom directive id: ' + name);
5084 }
5085}
5086/**
5087 * Adds directives to a VNode.
5088 */
5089function withDirectives(vnode, directives) {
5090 const internalInstance = currentRenderingInstance;
5091 if (internalInstance === null) {
5092 warn$1(`withDirectives can only be used inside render functions.`);
5093 return vnode;
5094 }
5095 const instance = getExposeProxy(internalInstance) ||
5096 internalInstance.proxy;
5097 const bindings = vnode.dirs || (vnode.dirs = []);
5098 for (let i = 0; i < directives.length; i++) {
5099 let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5100 if (isFunction(dir)) {
5101 dir = {
5102 mounted: dir,
5103 updated: dir
5104 };
5105 }
5106 if (dir.deep) {
5107 traverse(value);
5108 }
5109 bindings.push({
5110 dir,
5111 instance,
5112 value,
5113 oldValue: void 0,
5114 arg,
5115 modifiers
5116 });
5117 }
5118 return vnode;
5119}
5120function invokeDirectiveHook(vnode, prevVNode, instance, name) {
5121 const bindings = vnode.dirs;
5122 const oldBindings = prevVNode && prevVNode.dirs;
5123 for (let i = 0; i < bindings.length; i++) {
5124 const binding = bindings[i];
5125 if (oldBindings) {
5126 binding.oldValue = oldBindings[i].value;
5127 }
5128 let hook = binding.dir[name];
5129 if (!hook) {
5130 hook = mapCompatDirectiveHook(name, binding.dir, instance);
5131 }
5132 if (hook) {
5133 // disable tracking inside all lifecycle hooks
5134 // since they can potentially be called inside effects.
5135 pauseTracking();
5136 callWithAsyncErrorHandling(hook, instance, 8 /* ErrorCodes.DIRECTIVE_HOOK */, [
5137 vnode.el,
5138 binding,
5139 vnode,
5140 prevVNode
5141 ]);
5142 resetTracking();
5143 }
5144 }
5145}
5146
5147const COMPONENTS = 'components';
5148const DIRECTIVES = 'directives';
5149const FILTERS = 'filters';
5150/**
5151 * @private
5152 */
5153function resolveComponent(name, maybeSelfReference) {
5154 return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
5155}
5156const NULL_DYNAMIC_COMPONENT = Symbol();
5157/**
5158 * @private
5159 */
5160function resolveDynamicComponent(component) {
5161 if (isString(component)) {
5162 return resolveAsset(COMPONENTS, component, false) || component;
5163 }
5164 else {
5165 // invalid types will fallthrough to createVNode and raise warning
5166 return (component || NULL_DYNAMIC_COMPONENT);
5167 }
5168}
5169/**
5170 * @private
5171 */
5172function resolveDirective(name) {
5173 return resolveAsset(DIRECTIVES, name);
5174}
5175/**
5176 * v2 compat only
5177 * @internal
5178 */
5179function resolveFilter(name) {
5180 return resolveAsset(FILTERS, name);
5181}
5182// implementation
5183function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
5184 const instance = currentRenderingInstance || currentInstance;
5185 if (instance) {
5186 const Component = instance.type;
5187 // explicit self name has highest priority
5188 if (type === COMPONENTS) {
5189 const selfName = getComponentName(Component, false /* do not include inferred name to avoid breaking existing code */);
5190 if (selfName &&
5191 (selfName === name ||
5192 selfName === camelize(name) ||
5193 selfName === capitalize(camelize(name)))) {
5194 return Component;
5195 }
5196 }
5197 const res =
5198 // local registration
5199 // check instance[type] first which is resolved for options API
5200 resolve(instance[type] || Component[type], name) ||
5201 // global registration
5202 resolve(instance.appContext[type], name);
5203 if (!res && maybeSelfReference) {
5204 // fallback to implicit self-reference
5205 return Component;
5206 }
5207 if (warnMissing && !res) {
5208 const extra = type === COMPONENTS
5209 ? `\nIf this is a native custom element, make sure to exclude it from ` +
5210 `component resolution via compilerOptions.isCustomElement.`
5211 : ``;
5212 warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
5213 }
5214 return res;
5215 }
5216 else {
5217 warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
5218 `can only be used in render() or setup().`);
5219 }
5220}
5221function resolve(registry, name) {
5222 return (registry &&
5223 (registry[name] ||
5224 registry[camelize(name)] ||
5225 registry[capitalize(camelize(name))]));
5226}
5227
5228function convertLegacyRenderFn(instance) {
5229 const Component = instance.type;
5230 const render = Component.render;
5231 // v3 runtime compiled, or already checked / wrapped
5232 if (!render || render._rc || render._compatChecked || render._compatWrapped) {
5233 return;
5234 }
5235 if (render.length >= 2) {
5236 // v3 pre-compiled function, since v2 render functions never need more than
5237 // 2 arguments, and v2 functional render functions would have already been
5238 // normalized into v3 functional components
5239 render._compatChecked = true;
5240 return;
5241 }
5242 // v2 render function, try to provide compat
5243 if (checkCompatEnabled("RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */, instance)) {
5244 const wrapped = (Component.render = function compatRender() {
5245 // @ts-ignore
5246 return render.call(this, compatH);
5247 });
5248 // @ts-ignore
5249 wrapped._compatWrapped = true;
5250 }
5251}
5252function compatH(type, propsOrChildren, children) {
5253 if (!type) {
5254 type = Comment;
5255 }
5256 // to support v2 string component name look!up
5257 if (typeof type === 'string') {
5258 const t = hyphenate(type);
5259 if (t === 'transition' || t === 'transition-group' || t === 'keep-alive') {
5260 // since transition and transition-group are runtime-dom-specific,
5261 // we cannot import them directly here. Instead they are registered using
5262 // special keys in @vue/compat entry.
5263 type = `__compat__${t}`;
5264 }
5265 type = resolveDynamicComponent(type);
5266 }
5267 const l = arguments.length;
5268 const is2ndArgArrayChildren = isArray(propsOrChildren);
5269 if (l === 2 || is2ndArgArrayChildren) {
5270 if (isObject(propsOrChildren) && !is2ndArgArrayChildren) {
5271 // single vnode without props
5272 if (isVNode(propsOrChildren)) {
5273 return convertLegacySlots(createVNode(type, null, [propsOrChildren]));
5274 }
5275 // props without children
5276 return convertLegacySlots(convertLegacyDirectives(createVNode(type, convertLegacyProps(propsOrChildren, type)), propsOrChildren));
5277 }
5278 else {
5279 // omit props
5280 return convertLegacySlots(createVNode(type, null, propsOrChildren));
5281 }
5282 }
5283 else {
5284 if (isVNode(children)) {
5285 children = [children];
5286 }
5287 return convertLegacySlots(convertLegacyDirectives(createVNode(type, convertLegacyProps(propsOrChildren, type), children), propsOrChildren));
5288 }
5289}
5290const skipLegacyRootLevelProps = /*#__PURE__*/ makeMap('staticStyle,staticClass,directives,model,hook');
5291function convertLegacyProps(legacyProps, type) {
5292 if (!legacyProps) {
5293 return null;
5294 }
5295 const converted = {};
5296 for (const key in legacyProps) {
5297 if (key === 'attrs' || key === 'domProps' || key === 'props') {
5298 extend(converted, legacyProps[key]);
5299 }
5300 else if (key === 'on' || key === 'nativeOn') {
5301 const listeners = legacyProps[key];
5302 for (const event in listeners) {
5303 let handlerKey = convertLegacyEventKey(event);
5304 if (key === 'nativeOn')
5305 handlerKey += `Native`;
5306 const existing = converted[handlerKey];
5307 const incoming = listeners[event];
5308 if (existing !== incoming) {
5309 if (existing) {
5310 converted[handlerKey] = [].concat(existing, incoming);
5311 }
5312 else {
5313 converted[handlerKey] = incoming;
5314 }
5315 }
5316 }
5317 }
5318 else if (!skipLegacyRootLevelProps(key)) {
5319 converted[key] = legacyProps[key];
5320 }
5321 }
5322 if (legacyProps.staticClass) {
5323 converted.class = normalizeClass([legacyProps.staticClass, converted.class]);
5324 }
5325 if (legacyProps.staticStyle) {
5326 converted.style = normalizeStyle([legacyProps.staticStyle, converted.style]);
5327 }
5328 if (legacyProps.model && isObject(type)) {
5329 // v2 compiled component v-model
5330 const { prop = 'value', event = 'input' } = type.model || {};
5331 converted[prop] = legacyProps.model.value;
5332 converted[compatModelEventPrefix + event] = legacyProps.model.callback;
5333 }
5334 return converted;
5335}
5336function convertLegacyEventKey(event) {
5337 // normalize v2 event prefixes
5338 if (event[0] === '&') {
5339 event = event.slice(1) + 'Passive';
5340 }
5341 if (event[0] === '~') {
5342 event = event.slice(1) + 'Once';
5343 }
5344 if (event[0] === '!') {
5345 event = event.slice(1) + 'Capture';
5346 }
5347 return toHandlerKey(event);
5348}
5349function convertLegacyDirectives(vnode, props) {
5350 if (props && props.directives) {
5351 return withDirectives(vnode, props.directives.map(({ name, value, arg, modifiers }) => {
5352 return [
5353 resolveDirective(name),
5354 value,
5355 arg,
5356 modifiers
5357 ];
5358 }));
5359 }
5360 return vnode;
5361}
5362function convertLegacySlots(vnode) {
5363 const { props, children } = vnode;
5364 let slots;
5365 if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */ && isArray(children)) {
5366 slots = {};
5367 // check "slot" property on vnodes and turn them into v3 function slots
5368 for (let i = 0; i < children.length; i++) {
5369 const child = children[i];
5370 const slotName = (isVNode(child) && child.props && child.props.slot) || 'default';
5371 const slot = slots[slotName] || (slots[slotName] = []);
5372 if (isVNode(child) && child.type === 'template') {
5373 slot.push(child.children);
5374 }
5375 else {
5376 slot.push(child);
5377 }
5378 }
5379 if (slots) {
5380 for (const key in slots) {
5381 const slotChildren = slots[key];
5382 slots[key] = () => slotChildren;
5383 slots[key]._ns = true; /* non-scoped slot */
5384 }
5385 }
5386 }
5387 const scopedSlots = props && props.scopedSlots;
5388 if (scopedSlots) {
5389 delete props.scopedSlots;
5390 if (slots) {
5391 extend(slots, scopedSlots);
5392 }
5393 else {
5394 slots = scopedSlots;
5395 }
5396 }
5397 if (slots) {
5398 normalizeChildren(vnode, slots);
5399 }
5400 return vnode;
5401}
5402function defineLegacyVNodeProperties(vnode) {
5403 /* istanbul ignore if */
5404 if (isCompatEnabled("RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */, currentRenderingInstance, true /* enable for built-ins */) &&
5405 isCompatEnabled("PRIVATE_APIS" /* DeprecationTypes.PRIVATE_APIS */, currentRenderingInstance, true /* enable for built-ins */)) {
5406 const context = currentRenderingInstance;
5407 const getInstance = () => vnode.component && vnode.component.proxy;
5408 let componentOptions;
5409 Object.defineProperties(vnode, {
5410 tag: { get: () => vnode.type },
5411 data: { get: () => vnode.props || {}, set: p => (vnode.props = p) },
5412 elm: { get: () => vnode.el },
5413 componentInstance: { get: getInstance },
5414 child: { get: getInstance },
5415 text: { get: () => (isString(vnode.children) ? vnode.children : null) },
5416 context: { get: () => context && context.proxy },
5417 componentOptions: {
5418 get: () => {
5419 if (vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) {
5420 if (componentOptions) {
5421 return componentOptions;
5422 }
5423 return (componentOptions = {
5424 Ctor: vnode.type,
5425 propsData: vnode.props,
5426 children: vnode.children
5427 });
5428 }
5429 }
5430 }
5431 });
5432 }
5433}
5434
5435const normalizedFunctionalComponentMap = new Map();
5436const legacySlotProxyHandlers = {
5437 get(target, key) {
5438 const slot = target[key];
5439 return slot && slot();
5440 }
5441};
5442function convertLegacyFunctionalComponent(comp) {
5443 if (normalizedFunctionalComponentMap.has(comp)) {
5444 return normalizedFunctionalComponentMap.get(comp);
5445 }
5446 const legacyFn = comp.render;
5447 const Func = (props, ctx) => {
5448 const instance = getCurrentInstance();
5449 const legacyCtx = {
5450 props,
5451 children: instance.vnode.children || [],
5452 data: instance.vnode.props || {},
5453 scopedSlots: ctx.slots,
5454 parent: instance.parent && instance.parent.proxy,
5455 slots() {
5456 return new Proxy(ctx.slots, legacySlotProxyHandlers);
5457 },
5458 get listeners() {
5459 return getCompatListeners(instance);
5460 },
5461 get injections() {
5462 if (comp.inject) {
5463 const injections = {};
5464 resolveInjections(comp.inject, injections);
5465 return injections;
5466 }
5467 return {};
5468 }
5469 };
5470 return legacyFn(compatH, legacyCtx);
5471 };
5472 Func.props = comp.props;
5473 Func.displayName = comp.name;
5474 Func.compatConfig = comp.compatConfig;
5475 // v2 functional components do not inherit attrs
5476 Func.inheritAttrs = false;
5477 normalizedFunctionalComponentMap.set(comp, Func);
5478 return Func;
5479}
5480
5481/**
5482 * Actual implementation
5483 */
5484function renderList(source, renderItem, cache, index) {
5485 let ret;
5486 const cached = (cache && cache[index]);
5487 if (isArray(source) || isString(source)) {
5488 ret = new Array(source.length);
5489 for (let i = 0, l = source.length; i < l; i++) {
5490 ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
5491 }
5492 }
5493 else if (typeof source === 'number') {
5494 if (!Number.isInteger(source)) {
5495 warn$1(`The v-for range expect an integer value but got ${source}.`);
5496 }
5497 ret = new Array(source);
5498 for (let i = 0; i < source; i++) {
5499 ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
5500 }
5501 }
5502 else if (isObject(source)) {
5503 if (source[Symbol.iterator]) {
5504 ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
5505 }
5506 else {
5507 const keys = Object.keys(source);
5508 ret = new Array(keys.length);
5509 for (let i = 0, l = keys.length; i < l; i++) {
5510 const key = keys[i];
5511 ret[i] = renderItem(source[key], key, i, cached && cached[i]);
5512 }
5513 }
5514 }
5515 else {
5516 ret = [];
5517 }
5518 if (cache) {
5519 cache[index] = ret;
5520 }
5521 return ret;
5522}
5523
5524/**
5525 * Compiler runtime helper for creating dynamic slots object
5526 * @private
5527 */
5528function createSlots(slots, dynamicSlots) {
5529 for (let i = 0; i < dynamicSlots.length; i++) {
5530 const slot = dynamicSlots[i];
5531 // array of dynamic slot generated by <template v-for="..." #[...]>
5532 if (isArray(slot)) {
5533 for (let j = 0; j < slot.length; j++) {
5534 slots[slot[j].name] = slot[j].fn;
5535 }
5536 }
5537 else if (slot) {
5538 // conditional single slot generated by <template v-if="..." #foo>
5539 slots[slot.name] = slot.key
5540 ? (...args) => {
5541 const res = slot.fn(...args);
5542 res.key = slot.key;
5543 return res;
5544 }
5545 : slot.fn;
5546 }
5547 }
5548 return slots;
5549}
5550
5551/**
5552 * Compiler runtime helper for rendering `<slot/>`
5553 * @private
5554 */
5555function renderSlot(slots, name, props = {},
5556// this is not a user-facing function, so the fallback is always generated by
5557// the compiler and guaranteed to be a function returning an array
5558fallback, noSlotted) {
5559 if (currentRenderingInstance.isCE ||
5560 (currentRenderingInstance.parent &&
5561 isAsyncWrapper(currentRenderingInstance.parent) &&
5562 currentRenderingInstance.parent.isCE)) {
5563 return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5564 }
5565 let slot = slots[name];
5566 if (slot && slot.length > 1) {
5567 warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
5568 `function. You need to mark this component with $dynamic-slots in the ` +
5569 `parent template.`);
5570 slot = () => [];
5571 }
5572 // a compiled slot disables block tracking by default to avoid manual
5573 // invocation interfering with template-based block tracking, but in
5574 // `renderSlot` we can be sure that it's template-based so we can force
5575 // enable it.
5576 if (slot && slot._c) {
5577 slot._d = false;
5578 }
5579 openBlock();
5580 const validSlotContent = slot && ensureValidVNode(slot(props));
5581 const rendered = createBlock(Fragment, {
5582 key: props.key ||
5583 // slot content array of a dynamic conditional slot may have a branch
5584 // key attached in the `createSlots` helper, respect that
5585 (validSlotContent && validSlotContent.key) ||
5586 `_${name}`
5587 }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* SlotFlags.STABLE */
5588 ? 64 /* PatchFlags.STABLE_FRAGMENT */
5589 : -2 /* PatchFlags.BAIL */);
5590 if (!noSlotted && rendered.scopeId) {
5591 rendered.slotScopeIds = [rendered.scopeId + '-s'];
5592 }
5593 if (slot && slot._c) {
5594 slot._d = true;
5595 }
5596 return rendered;
5597}
5598function ensureValidVNode(vnodes) {
5599 return vnodes.some(child => {
5600 if (!isVNode(child))
5601 return true;
5602 if (child.type === Comment)
5603 return false;
5604 if (child.type === Fragment &&
5605 !ensureValidVNode(child.children))
5606 return false;
5607 return true;
5608 })
5609 ? vnodes
5610 : null;
5611}
5612
5613/**
5614 * For prefixing keys in v-on="obj" with "on"
5615 * @private
5616 */
5617function toHandlers(obj, preserveCaseIfNecessary) {
5618 const ret = {};
5619 if (!isObject(obj)) {
5620 warn$1(`v-on with no argument expects an object value.`);
5621 return ret;
5622 }
5623 for (const key in obj) {
5624 ret[preserveCaseIfNecessary && /[A-Z]/.test(key)
5625 ? `on:${key}`
5626 : toHandlerKey(key)] = obj[key];
5627 }
5628 return ret;
5629}
5630
5631function toObject(arr) {
5632 const res = {};
5633 for (let i = 0; i < arr.length; i++) {
5634 if (arr[i]) {
5635 extend(res, arr[i]);
5636 }
5637 }
5638 return res;
5639}
5640function legacyBindObjectProps(data, _tag, value, _asProp, isSync) {
5641 if (value && isObject(value)) {
5642 if (isArray(value)) {
5643 value = toObject(value);
5644 }
5645 for (const key in value) {
5646 if (isReservedProp(key)) {
5647 data[key] = value[key];
5648 }
5649 else if (key === 'class') {
5650 data.class = normalizeClass([data.class, value.class]);
5651 }
5652 else if (key === 'style') {
5653 data.style = normalizeClass([data.style, value.style]);
5654 }
5655 else {
5656 const attrs = data.attrs || (data.attrs = {});
5657 const camelizedKey = camelize(key);
5658 const hyphenatedKey = hyphenate(key);
5659 if (!(camelizedKey in attrs) && !(hyphenatedKey in attrs)) {
5660 attrs[key] = value[key];
5661 if (isSync) {
5662 const on = data.on || (data.on = {});
5663 on[`update:${key}`] = function ($event) {
5664 value[key] = $event;
5665 };
5666 }
5667 }
5668 }
5669 }
5670 }
5671 return data;
5672}
5673function legacyBindObjectListeners(props, listeners) {
5674 return mergeProps(props, toHandlers(listeners));
5675}
5676function legacyRenderSlot(instance, name, fallback, props, bindObject) {
5677 if (bindObject) {
5678 props = mergeProps(props, bindObject);
5679 }
5680 return renderSlot(instance.slots, name, props, fallback && (() => fallback));
5681}
5682function legacyresolveScopedSlots(fns, raw,
5683// the following are added in 2.6
5684hasDynamicKeys) {
5685 // v2 default slot doesn't have name
5686 return createSlots(raw || { $stable: !hasDynamicKeys }, mapKeyToName(fns));
5687}
5688function mapKeyToName(slots) {
5689 for (let i = 0; i < slots.length; i++) {
5690 const fn = slots[i];
5691 if (fn) {
5692 if (isArray(fn)) {
5693 mapKeyToName(fn);
5694 }
5695 else {
5696 fn.name = fn.key || 'default';
5697 }
5698 }
5699 }
5700 return slots;
5701}
5702const staticCacheMap = /*#__PURE__*/ new WeakMap();
5703function legacyRenderStatic(instance, index) {
5704 let cache = staticCacheMap.get(instance);
5705 if (!cache) {
5706 staticCacheMap.set(instance, (cache = []));
5707 }
5708 if (cache[index]) {
5709 return cache[index];
5710 }
5711 const fn = instance.type.staticRenderFns[index];
5712 const ctx = instance.proxy;
5713 return (cache[index] = fn.call(ctx, null, ctx));
5714}
5715function legacyCheckKeyCodes(instance, eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
5716 const config = instance.appContext.config;
5717 const configKeyCodes = config.keyCodes || {};
5718 const mappedKeyCode = configKeyCodes[key] || builtInKeyCode;
5719 if (builtInKeyName && eventKeyName && !configKeyCodes[key]) {
5720 return isKeyNotMatch(builtInKeyName, eventKeyName);
5721 }
5722 else if (mappedKeyCode) {
5723 return isKeyNotMatch(mappedKeyCode, eventKeyCode);
5724 }
5725 else if (eventKeyName) {
5726 return hyphenate(eventKeyName) !== key;
5727 }
5728}
5729function isKeyNotMatch(expect, actual) {
5730 if (isArray(expect)) {
5731 return !expect.includes(actual);
5732 }
5733 else {
5734 return expect !== actual;
5735 }
5736}
5737function legacyMarkOnce(tree) {
5738 return tree;
5739}
5740function legacyBindDynamicKeys(props, values) {
5741 for (let i = 0; i < values.length; i += 2) {
5742 const key = values[i];
5743 if (typeof key === 'string' && key) {
5744 props[values[i]] = values[i + 1];
5745 }
5746 }
5747 return props;
5748}
5749function legacyPrependModifier(value, symbol) {
5750 return typeof value === 'string' ? symbol + value : value;
5751}
5752
5753function installCompatInstanceProperties(map) {
5754 const set = (target, key, val) => {
5755 target[key] = val;
5756 };
5757 const del = (target, key) => {
5758 delete target[key];
5759 };
5760 extend(map, {
5761 $set: i => {
5762 assertCompatEnabled("INSTANCE_SET" /* DeprecationTypes.INSTANCE_SET */, i);
5763 return set;
5764 },
5765 $delete: i => {
5766 assertCompatEnabled("INSTANCE_DELETE" /* DeprecationTypes.INSTANCE_DELETE */, i);
5767 return del;
5768 },
5769 $mount: i => {
5770 assertCompatEnabled("GLOBAL_MOUNT" /* DeprecationTypes.GLOBAL_MOUNT */, null /* this warning is global */);
5771 // root mount override from ./global.ts in installCompatMount
5772 return i.ctx._compat_mount || NOOP;
5773 },
5774 $destroy: i => {
5775 assertCompatEnabled("INSTANCE_DESTROY" /* DeprecationTypes.INSTANCE_DESTROY */, i);
5776 // root destroy override from ./global.ts in installCompatMount
5777 return i.ctx._compat_destroy || NOOP;
5778 },
5779 // overrides existing accessor
5780 $slots: i => {
5781 if (isCompatEnabled("RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */, i) &&
5782 i.render &&
5783 i.render._compatWrapped) {
5784 return new Proxy(i.slots, legacySlotProxyHandlers);
5785 }
5786 return shallowReadonly(i.slots) ;
5787 },
5788 $scopedSlots: i => {
5789 assertCompatEnabled("INSTANCE_SCOPED_SLOTS" /* DeprecationTypes.INSTANCE_SCOPED_SLOTS */, i);
5790 const res = {};
5791 for (const key in i.slots) {
5792 const fn = i.slots[key];
5793 if (!fn._ns /* non-scoped slot */) {
5794 res[key] = fn;
5795 }
5796 }
5797 return res;
5798 },
5799 $on: i => on.bind(null, i),
5800 $once: i => once.bind(null, i),
5801 $off: i => off.bind(null, i),
5802 $children: getCompatChildren,
5803 $listeners: getCompatListeners
5804 });
5805 /* istanbul ignore if */
5806 if (isCompatEnabled("PRIVATE_APIS" /* DeprecationTypes.PRIVATE_APIS */, null)) {
5807 extend(map, {
5808 // needed by many libs / render fns
5809 $vnode: i => i.vnode,
5810 // inject additional properties into $options for compat
5811 // e.g. vuex needs this.$options.parent
5812 $options: i => {
5813 const res = extend({}, resolveMergedOptions(i));
5814 res.parent = i.proxy.$parent;
5815 res.propsData = i.vnode.props;
5816 return res;
5817 },
5818 // some private properties that are likely accessed...
5819 _self: i => i.proxy,
5820 _uid: i => i.uid,
5821 _data: i => i.data,
5822 _isMounted: i => i.isMounted,
5823 _isDestroyed: i => i.isUnmounted,
5824 // v2 render helpers
5825 $createElement: () => compatH,
5826 _c: () => compatH,
5827 _o: () => legacyMarkOnce,
5828 _n: () => toNumber,
5829 _s: () => toDisplayString,
5830 _l: () => renderList,
5831 _t: i => legacyRenderSlot.bind(null, i),
5832 _q: () => looseEqual,
5833 _i: () => looseIndexOf,
5834 _m: i => legacyRenderStatic.bind(null, i),
5835 _f: () => resolveFilter,
5836 _k: i => legacyCheckKeyCodes.bind(null, i),
5837 _b: () => legacyBindObjectProps,
5838 _v: () => createTextVNode,
5839 _e: () => createCommentVNode,
5840 _u: () => legacyresolveScopedSlots,
5841 _g: () => legacyBindObjectListeners,
5842 _d: () => legacyBindDynamicKeys,
5843 _p: () => legacyPrependModifier
5844 });
5845 }
5846}
5847
5848/**
5849 * #2437 In Vue 3, functional components do not have a public instance proxy but
5850 * they exist in the internal parent chain. For code that relies on traversing
5851 * public $parent chains, skip functional ones and go to the parent instead.
5852 */
5853const getPublicInstance = (i) => {
5854 if (!i)
5855 return null;
5856 if (isStatefulComponent(i))
5857 return getExposeProxy(i) || i.proxy;
5858 return getPublicInstance(i.parent);
5859};
5860const publicPropertiesMap =
5861// Move PURE marker to new line to workaround compiler discarding it
5862// due to type annotation
5863/*#__PURE__*/ extend(Object.create(null), {
5864 $: i => i,
5865 $el: i => i.vnode.el,
5866 $data: i => i.data,
5867 $props: i => (shallowReadonly(i.props) ),
5868 $attrs: i => (shallowReadonly(i.attrs) ),
5869 $slots: i => (shallowReadonly(i.slots) ),
5870 $refs: i => (shallowReadonly(i.refs) ),
5871 $parent: i => getPublicInstance(i.parent),
5872 $root: i => getPublicInstance(i.root),
5873 $emit: i => i.emit,
5874 $options: i => (resolveMergedOptions(i) ),
5875 $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
5876 $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
5877 $watch: i => (instanceWatch.bind(i) )
5878});
5879{
5880 installCompatInstanceProperties(publicPropertiesMap);
5881}
5882const isReservedPrefix = (key) => key === '_' || key === '$';
5883const PublicInstanceProxyHandlers = {
5884 get({ _: instance }, key) {
5885 const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
5886 // for internal formatters to know that this is a Vue instance
5887 if (key === '__isVue') {
5888 return true;
5889 }
5890 // prioritize <script setup> bindings during dev.
5891 // this allows even properties that start with _ or $ to be used - so that
5892 // it aligns with the production behavior where the render fn is inlined and
5893 // indeed has access to all declared variables.
5894 if (setupState !== EMPTY_OBJ &&
5895 setupState.__isScriptSetup &&
5896 hasOwn(setupState, key)) {
5897 return setupState[key];
5898 }
5899 // data / props / ctx
5900 // This getter gets called for every property access on the render context
5901 // during render and is a major hotspot. The most expensive part of this
5902 // is the multiple hasOwn() calls. It's much faster to do a simple property
5903 // access on a plain object, so we use an accessCache object (with null
5904 // prototype) to memoize what access type a key corresponds to.
5905 let normalizedProps;
5906 if (key[0] !== '$') {
5907 const n = accessCache[key];
5908 if (n !== undefined) {
5909 switch (n) {
5910 case 1 /* AccessTypes.SETUP */:
5911 return setupState[key];
5912 case 2 /* AccessTypes.DATA */:
5913 return data[key];
5914 case 4 /* AccessTypes.CONTEXT */:
5915 return ctx[key];
5916 case 3 /* AccessTypes.PROPS */:
5917 return props[key];
5918 // default: just fallthrough
5919 }
5920 }
5921 else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5922 accessCache[key] = 1 /* AccessTypes.SETUP */;
5923 return setupState[key];
5924 }
5925 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5926 accessCache[key] = 2 /* AccessTypes.DATA */;
5927 return data[key];
5928 }
5929 else if (
5930 // only cache other properties when instance has declared (thus stable)
5931 // props
5932 (normalizedProps = instance.propsOptions[0]) &&
5933 hasOwn(normalizedProps, key)) {
5934 accessCache[key] = 3 /* AccessTypes.PROPS */;
5935 return props[key];
5936 }
5937 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
5938 accessCache[key] = 4 /* AccessTypes.CONTEXT */;
5939 return ctx[key];
5940 }
5941 else if (shouldCacheAccess) {
5942 accessCache[key] = 0 /* AccessTypes.OTHER */;
5943 }
5944 }
5945 const publicGetter = publicPropertiesMap[key];
5946 let cssModule, globalProperties;
5947 // public $xxx properties
5948 if (publicGetter) {
5949 if (key === '$attrs') {
5950 track(instance, "get" /* TrackOpTypes.GET */, key);
5951 markAttrsAccessed();
5952 }
5953 return publicGetter(instance);
5954 }
5955 else if (
5956 // css module (injected by vue-loader)
5957 (cssModule = type.__cssModules) &&
5958 (cssModule = cssModule[key])) {
5959 return cssModule;
5960 }
5961 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
5962 // user may set custom properties to `this` that start with `$`
5963 accessCache[key] = 4 /* AccessTypes.CONTEXT */;
5964 return ctx[key];
5965 }
5966 else if (
5967 // global properties
5968 ((globalProperties = appContext.config.globalProperties),
5969 hasOwn(globalProperties, key))) {
5970 {
5971 const desc = Object.getOwnPropertyDescriptor(globalProperties, key);
5972 if (desc.get) {
5973 return desc.get.call(instance.proxy);
5974 }
5975 else {
5976 const val = globalProperties[key];
5977 return isFunction(val)
5978 ? Object.assign(val.bind(instance.proxy), val)
5979 : val;
5980 }
5981 }
5982 }
5983 else if (currentRenderingInstance &&
5984 (!isString(key) ||
5985 // #1091 avoid internal isRef/isVNode checks on component instance leading
5986 // to infinite warning loop
5987 key.indexOf('__v') !== 0)) {
5988 if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
5989 warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
5990 `character ("$" or "_") and is not proxied on the render context.`);
5991 }
5992 else if (instance === currentRenderingInstance) {
5993 warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
5994 `but is not defined on instance.`);
5995 }
5996 }
5997 },
5998 set({ _: instance }, key, value) {
5999 const { data, setupState, ctx } = instance;
6000 if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
6001 setupState[key] = value;
6002 return true;
6003 }
6004 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
6005 data[key] = value;
6006 return true;
6007 }
6008 else if (hasOwn(instance.props, key)) {
6009 warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
6010 return false;
6011 }
6012 if (key[0] === '$' && key.slice(1) in instance) {
6013 warn$1(`Attempting to mutate public property "${key}". ` +
6014 `Properties starting with $ are reserved and readonly.`, instance);
6015 return false;
6016 }
6017 else {
6018 if (key in instance.appContext.config.globalProperties) {
6019 Object.defineProperty(ctx, key, {
6020 enumerable: true,
6021 configurable: true,
6022 value
6023 });
6024 }
6025 else {
6026 ctx[key] = value;
6027 }
6028 }
6029 return true;
6030 },
6031 has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
6032 let normalizedProps;
6033 return (!!accessCache[key] ||
6034 (data !== EMPTY_OBJ && hasOwn(data, key)) ||
6035 (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
6036 ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
6037 hasOwn(ctx, key) ||
6038 hasOwn(publicPropertiesMap, key) ||
6039 hasOwn(appContext.config.globalProperties, key));
6040 },
6041 defineProperty(target, key, descriptor) {
6042 if (descriptor.get != null) {
6043 // invalidate key cache of a getter based property #5417
6044 target._.accessCache[key] = 0;
6045 }
6046 else if (hasOwn(descriptor, 'value')) {
6047 this.set(target, key, descriptor.value, null);
6048 }
6049 return Reflect.defineProperty(target, key, descriptor);
6050 }
6051};
6052{
6053 PublicInstanceProxyHandlers.ownKeys = (target) => {
6054 warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
6055 `The keys will be empty in production mode to avoid performance overhead.`);
6056 return Reflect.ownKeys(target);
6057 };
6058}
6059const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
6060 get(target, key) {
6061 // fast path for unscopables when using `with` block
6062 if (key === Symbol.unscopables) {
6063 return;
6064 }
6065 return PublicInstanceProxyHandlers.get(target, key, target);
6066 },
6067 has(_, key) {
6068 const has = key[0] !== '_' && !isGloballyWhitelisted(key);
6069 if (!has && PublicInstanceProxyHandlers.has(_, key)) {
6070 warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
6071 }
6072 return has;
6073 }
6074});
6075// dev only
6076// In dev mode, the proxy target exposes the same properties as seen on `this`
6077// for easier console inspection. In prod mode it will be an empty object so
6078// these properties definitions can be skipped.
6079function createDevRenderContext(instance) {
6080 const target = {};
6081 // expose internal instance for proxy handlers
6082 Object.defineProperty(target, `_`, {
6083 configurable: true,
6084 enumerable: false,
6085 get: () => instance
6086 });
6087 // expose public properties
6088 Object.keys(publicPropertiesMap).forEach(key => {
6089 Object.defineProperty(target, key, {
6090 configurable: true,
6091 enumerable: false,
6092 get: () => publicPropertiesMap[key](instance),
6093 // intercepted by the proxy so no need for implementation,
6094 // but needed to prevent set errors
6095 set: NOOP
6096 });
6097 });
6098 return target;
6099}
6100// dev only
6101function exposePropsOnRenderContext(instance) {
6102 const { ctx, propsOptions: [propsOptions] } = instance;
6103 if (propsOptions) {
6104 Object.keys(propsOptions).forEach(key => {
6105 Object.defineProperty(ctx, key, {
6106 enumerable: true,
6107 configurable: true,
6108 get: () => instance.props[key],
6109 set: NOOP
6110 });
6111 });
6112 }
6113}
6114// dev only
6115function exposeSetupStateOnRenderContext(instance) {
6116 const { ctx, setupState } = instance;
6117 Object.keys(toRaw(setupState)).forEach(key => {
6118 if (!setupState.__isScriptSetup) {
6119 if (isReservedPrefix(key[0])) {
6120 warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
6121 `which are reserved prefixes for Vue internals.`);
6122 return;
6123 }
6124 Object.defineProperty(ctx, key, {
6125 enumerable: true,
6126 configurable: true,
6127 get: () => setupState[key],
6128 set: NOOP
6129 });
6130 }
6131 });
6132}
6133
6134function deepMergeData(to, from) {
6135 for (const key in from) {
6136 const toVal = to[key];
6137 const fromVal = from[key];
6138 if (key in to && isPlainObject(toVal) && isPlainObject(fromVal)) {
6139 warnDeprecation("OPTIONS_DATA_MERGE" /* DeprecationTypes.OPTIONS_DATA_MERGE */, null, key);
6140 deepMergeData(toVal, fromVal);
6141 }
6142 else {
6143 to[key] = fromVal;
6144 }
6145 }
6146 return to;
6147}
6148
6149function createDuplicateChecker() {
6150 const cache = Object.create(null);
6151 return (type, key) => {
6152 if (cache[key]) {
6153 warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
6154 }
6155 else {
6156 cache[key] = type;
6157 }
6158 };
6159}
6160let shouldCacheAccess = true;
6161function applyOptions(instance) {
6162 const options = resolveMergedOptions(instance);
6163 const publicThis = instance.proxy;
6164 const ctx = instance.ctx;
6165 // do not cache property access on public proxy during state initialization
6166 shouldCacheAccess = false;
6167 // call beforeCreate first before accessing other options since
6168 // the hook may mutate resolved options (#2791)
6169 if (options.beforeCreate) {
6170 callHook(options.beforeCreate, instance, "bc" /* LifecycleHooks.BEFORE_CREATE */);
6171 }
6172 const {
6173 // state
6174 data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
6175 // lifecycle
6176 created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
6177 // public API
6178 expose, inheritAttrs,
6179 // assets
6180 components, directives, filters } = options;
6181 const checkDuplicateProperties = createDuplicateChecker() ;
6182 {
6183 const [propsOptions] = instance.propsOptions;
6184 if (propsOptions) {
6185 for (const key in propsOptions) {
6186 checkDuplicateProperties("Props" /* OptionTypes.PROPS */, key);
6187 }
6188 }
6189 }
6190 // options initialization order (to be consistent with Vue 2):
6191 // - props (already done outside of this function)
6192 // - inject
6193 // - methods
6194 // - data (deferred since it relies on `this` access)
6195 // - computed
6196 // - watch (deferred since it relies on `this` access)
6197 if (injectOptions) {
6198 resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
6199 }
6200 if (methods) {
6201 for (const key in methods) {
6202 const methodHandler = methods[key];
6203 if (isFunction(methodHandler)) {
6204 // In dev mode, we use the `createRenderContext` function to define
6205 // methods to the proxy target, and those are read-only but
6206 // reconfigurable, so it needs to be redefined here
6207 {
6208 Object.defineProperty(ctx, key, {
6209 value: methodHandler.bind(publicThis),
6210 configurable: true,
6211 enumerable: true,
6212 writable: true
6213 });
6214 }
6215 {
6216 checkDuplicateProperties("Methods" /* OptionTypes.METHODS */, key);
6217 }
6218 }
6219 else {
6220 warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
6221 `Did you reference the function correctly?`);
6222 }
6223 }
6224 }
6225 if (dataOptions) {
6226 if (!isFunction(dataOptions)) {
6227 warn$1(`The data option must be a function. ` +
6228 `Plain object usage is no longer supported.`);
6229 }
6230 const data = dataOptions.call(publicThis, publicThis);
6231 if (isPromise(data)) {
6232 warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
6233 `intend to perform data fetching before component renders, use ` +
6234 `async setup() + <Suspense>.`);
6235 }
6236 if (!isObject(data)) {
6237 warn$1(`data() should return an object.`);
6238 }
6239 else {
6240 instance.data = reactive(data);
6241 {
6242 for (const key in data) {
6243 checkDuplicateProperties("Data" /* OptionTypes.DATA */, key);
6244 // expose data on ctx during dev
6245 if (!isReservedPrefix(key[0])) {
6246 Object.defineProperty(ctx, key, {
6247 configurable: true,
6248 enumerable: true,
6249 get: () => data[key],
6250 set: NOOP
6251 });
6252 }
6253 }
6254 }
6255 }
6256 }
6257 // state initialization complete at this point - start caching access
6258 shouldCacheAccess = true;
6259 if (computedOptions) {
6260 for (const key in computedOptions) {
6261 const opt = computedOptions[key];
6262 const get = isFunction(opt)
6263 ? opt.bind(publicThis, publicThis)
6264 : isFunction(opt.get)
6265 ? opt.get.bind(publicThis, publicThis)
6266 : NOOP;
6267 if (get === NOOP) {
6268 warn$1(`Computed property "${key}" has no getter.`);
6269 }
6270 const set = !isFunction(opt) && isFunction(opt.set)
6271 ? opt.set.bind(publicThis)
6272 : () => {
6273 warn$1(`Write operation failed: computed property "${key}" is readonly.`);
6274 }
6275 ;
6276 const c = computed$1({
6277 get,
6278 set
6279 });
6280 Object.defineProperty(ctx, key, {
6281 enumerable: true,
6282 configurable: true,
6283 get: () => c.value,
6284 set: v => (c.value = v)
6285 });
6286 {
6287 checkDuplicateProperties("Computed" /* OptionTypes.COMPUTED */, key);
6288 }
6289 }
6290 }
6291 if (watchOptions) {
6292 for (const key in watchOptions) {
6293 createWatcher(watchOptions[key], ctx, publicThis, key);
6294 }
6295 }
6296 if (provideOptions) {
6297 const provides = isFunction(provideOptions)
6298 ? provideOptions.call(publicThis)
6299 : provideOptions;
6300 Reflect.ownKeys(provides).forEach(key => {
6301 provide(key, provides[key]);
6302 });
6303 }
6304 if (created) {
6305 callHook(created, instance, "c" /* LifecycleHooks.CREATED */);
6306 }
6307 function registerLifecycleHook(register, hook) {
6308 if (isArray(hook)) {
6309 hook.forEach(_hook => register(_hook.bind(publicThis)));
6310 }
6311 else if (hook) {
6312 register(hook.bind(publicThis));
6313 }
6314 }
6315 registerLifecycleHook(onBeforeMount, beforeMount);
6316 registerLifecycleHook(onMounted, mounted);
6317 registerLifecycleHook(onBeforeUpdate, beforeUpdate);
6318 registerLifecycleHook(onUpdated, updated);
6319 registerLifecycleHook(onActivated, activated);
6320 registerLifecycleHook(onDeactivated, deactivated);
6321 registerLifecycleHook(onErrorCaptured, errorCaptured);
6322 registerLifecycleHook(onRenderTracked, renderTracked);
6323 registerLifecycleHook(onRenderTriggered, renderTriggered);
6324 registerLifecycleHook(onBeforeUnmount, beforeUnmount);
6325 registerLifecycleHook(onUnmounted, unmounted);
6326 registerLifecycleHook(onServerPrefetch, serverPrefetch);
6327 {
6328 if (beforeDestroy &&
6329 softAssertCompatEnabled("OPTIONS_BEFORE_DESTROY" /* DeprecationTypes.OPTIONS_BEFORE_DESTROY */, instance)) {
6330 registerLifecycleHook(onBeforeUnmount, beforeDestroy);
6331 }
6332 if (destroyed &&
6333 softAssertCompatEnabled("OPTIONS_DESTROYED" /* DeprecationTypes.OPTIONS_DESTROYED */, instance)) {
6334 registerLifecycleHook(onUnmounted, destroyed);
6335 }
6336 }
6337 if (isArray(expose)) {
6338 if (expose.length) {
6339 const exposed = instance.exposed || (instance.exposed = {});
6340 expose.forEach(key => {
6341 Object.defineProperty(exposed, key, {
6342 get: () => publicThis[key],
6343 set: val => (publicThis[key] = val)
6344 });
6345 });
6346 }
6347 else if (!instance.exposed) {
6348 instance.exposed = {};
6349 }
6350 }
6351 // options that are handled when creating the instance but also need to be
6352 // applied from mixins
6353 if (render && instance.render === NOOP) {
6354 instance.render = render;
6355 }
6356 if (inheritAttrs != null) {
6357 instance.inheritAttrs = inheritAttrs;
6358 }
6359 // asset options.
6360 if (components)
6361 instance.components = components;
6362 if (directives)
6363 instance.directives = directives;
6364 if (filters &&
6365 isCompatEnabled("FILTERS" /* DeprecationTypes.FILTERS */, instance)) {
6366 instance.filters = filters;
6367 }
6368}
6369function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
6370 if (isArray(injectOptions)) {
6371 injectOptions = normalizeInject(injectOptions);
6372 }
6373 for (const key in injectOptions) {
6374 const opt = injectOptions[key];
6375 let injected;
6376 if (isObject(opt)) {
6377 if ('default' in opt) {
6378 injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
6379 }
6380 else {
6381 injected = inject(opt.from || key);
6382 }
6383 }
6384 else {
6385 injected = inject(opt);
6386 }
6387 if (isRef(injected)) {
6388 // TODO remove the check in 3.3
6389 if (unwrapRef) {
6390 Object.defineProperty(ctx, key, {
6391 enumerable: true,
6392 configurable: true,
6393 get: () => injected.value,
6394 set: v => (injected.value = v)
6395 });
6396 }
6397 else {
6398 {
6399 warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
6400 `and no longer needs \`.value\` in the next minor release. ` +
6401 `To opt-in to the new behavior now, ` +
6402 `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
6403 `temporary and will not be needed in the future.)`);
6404 }
6405 ctx[key] = injected;
6406 }
6407 }
6408 else {
6409 ctx[key] = injected;
6410 }
6411 {
6412 checkDuplicateProperties("Inject" /* OptionTypes.INJECT */, key);
6413 }
6414 }
6415}
6416function callHook(hook, instance, type) {
6417 callWithAsyncErrorHandling(isArray(hook)
6418 ? hook.map(h => h.bind(instance.proxy))
6419 : hook.bind(instance.proxy), instance, type);
6420}
6421function createWatcher(raw, ctx, publicThis, key) {
6422 const getter = key.includes('.')
6423 ? createPathGetter(publicThis, key)
6424 : () => publicThis[key];
6425 if (isString(raw)) {
6426 const handler = ctx[raw];
6427 if (isFunction(handler)) {
6428 watch(getter, handler);
6429 }
6430 else {
6431 warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6432 }
6433 }
6434 else if (isFunction(raw)) {
6435 watch(getter, raw.bind(publicThis));
6436 }
6437 else if (isObject(raw)) {
6438 if (isArray(raw)) {
6439 raw.forEach(r => createWatcher(r, ctx, publicThis, key));
6440 }
6441 else {
6442 const handler = isFunction(raw.handler)
6443 ? raw.handler.bind(publicThis)
6444 : ctx[raw.handler];
6445 if (isFunction(handler)) {
6446 watch(getter, handler, raw);
6447 }
6448 else {
6449 warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6450 }
6451 }
6452 }
6453 else {
6454 warn$1(`Invalid watch option: "${key}"`, raw);
6455 }
6456}
6457/**
6458 * Resolve merged options and cache it on the component.
6459 * This is done only once per-component since the merging does not involve
6460 * instances.
6461 */
6462function resolveMergedOptions(instance) {
6463 const base = instance.type;
6464 const { mixins, extends: extendsOptions } = base;
6465 const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
6466 const cached = cache.get(base);
6467 let resolved;
6468 if (cached) {
6469 resolved = cached;
6470 }
6471 else if (!globalMixins.length && !mixins && !extendsOptions) {
6472 if (isCompatEnabled("PRIVATE_APIS" /* DeprecationTypes.PRIVATE_APIS */, instance)) {
6473 resolved = extend({}, base);
6474 resolved.parent = instance.parent && instance.parent.proxy;
6475 resolved.propsData = instance.vnode.props;
6476 }
6477 else {
6478 resolved = base;
6479 }
6480 }
6481 else {
6482 resolved = {};
6483 if (globalMixins.length) {
6484 globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
6485 }
6486 mergeOptions(resolved, base, optionMergeStrategies);
6487 }
6488 if (isObject(base)) {
6489 cache.set(base, resolved);
6490 }
6491 return resolved;
6492}
6493function mergeOptions(to, from, strats, asMixin = false) {
6494 if (isFunction(from)) {
6495 from = from.options;
6496 }
6497 const { mixins, extends: extendsOptions } = from;
6498 if (extendsOptions) {
6499 mergeOptions(to, extendsOptions, strats, true);
6500 }
6501 if (mixins) {
6502 mixins.forEach((m) => mergeOptions(to, m, strats, true));
6503 }
6504 for (const key in from) {
6505 if (asMixin && key === 'expose') {
6506 warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
6507 `It should only be declared in the base component itself.`);
6508 }
6509 else {
6510 const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
6511 to[key] = strat ? strat(to[key], from[key]) : from[key];
6512 }
6513 }
6514 return to;
6515}
6516const internalOptionMergeStrats = {
6517 data: mergeDataFn,
6518 props: mergeObjectOptions,
6519 emits: mergeObjectOptions,
6520 // objects
6521 methods: mergeObjectOptions,
6522 computed: mergeObjectOptions,
6523 // lifecycle
6524 beforeCreate: mergeAsArray,
6525 created: mergeAsArray,
6526 beforeMount: mergeAsArray,
6527 mounted: mergeAsArray,
6528 beforeUpdate: mergeAsArray,
6529 updated: mergeAsArray,
6530 beforeDestroy: mergeAsArray,
6531 beforeUnmount: mergeAsArray,
6532 destroyed: mergeAsArray,
6533 unmounted: mergeAsArray,
6534 activated: mergeAsArray,
6535 deactivated: mergeAsArray,
6536 errorCaptured: mergeAsArray,
6537 serverPrefetch: mergeAsArray,
6538 // assets
6539 components: mergeObjectOptions,
6540 directives: mergeObjectOptions,
6541 // watch
6542 watch: mergeWatchOptions,
6543 // provide / inject
6544 provide: mergeDataFn,
6545 inject: mergeInject
6546};
6547{
6548 internalOptionMergeStrats.filters = mergeObjectOptions;
6549}
6550function mergeDataFn(to, from) {
6551 if (!from) {
6552 return to;
6553 }
6554 if (!to) {
6555 return from;
6556 }
6557 return function mergedDataFn() {
6558 return (isCompatEnabled("OPTIONS_DATA_MERGE" /* DeprecationTypes.OPTIONS_DATA_MERGE */, null)
6559 ? deepMergeData
6560 : extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
6561 };
6562}
6563function mergeInject(to, from) {
6564 return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
6565}
6566function normalizeInject(raw) {
6567 if (isArray(raw)) {
6568 const res = {};
6569 for (let i = 0; i < raw.length; i++) {
6570 res[raw[i]] = raw[i];
6571 }
6572 return res;
6573 }
6574 return raw;
6575}
6576function mergeAsArray(to, from) {
6577 return to ? [...new Set([].concat(to, from))] : from;
6578}
6579function mergeObjectOptions(to, from) {
6580 return to ? extend(extend(Object.create(null), to), from) : from;
6581}
6582function mergeWatchOptions(to, from) {
6583 if (!to)
6584 return from;
6585 if (!from)
6586 return to;
6587 const merged = extend(Object.create(null), to);
6588 for (const key in from) {
6589 merged[key] = mergeAsArray(to[key], from[key]);
6590 }
6591 return merged;
6592}
6593
6594function createPropsDefaultThis(instance, rawProps, propKey) {
6595 return new Proxy({}, {
6596 get(_, key) {
6597 warnDeprecation("PROPS_DEFAULT_THIS" /* DeprecationTypes.PROPS_DEFAULT_THIS */, null, propKey);
6598 // $options
6599 if (key === '$options') {
6600 return resolveMergedOptions(instance);
6601 }
6602 // props
6603 if (key in rawProps) {
6604 return rawProps[key];
6605 }
6606 // injections
6607 const injections = instance.type.inject;
6608 if (injections) {
6609 if (isArray(injections)) {
6610 if (injections.includes(key)) {
6611 return inject(key);
6612 }
6613 }
6614 else if (key in injections) {
6615 return inject(key);
6616 }
6617 }
6618 }
6619 });
6620}
6621
6622function shouldSkipAttr(key, instance) {
6623 if (key === 'is') {
6624 return true;
6625 }
6626 if ((key === 'class' || key === 'style') &&
6627 isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE */, instance)) {
6628 return true;
6629 }
6630 if (isOn(key) &&
6631 isCompatEnabled("INSTANCE_LISTENERS" /* DeprecationTypes.INSTANCE_LISTENERS */, instance)) {
6632 return true;
6633 }
6634 // vue-router
6635 if (key.startsWith('routerView') || key === 'registerRouteInstance') {
6636 return true;
6637 }
6638 return false;
6639}
6640
6641function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
6642isSSR = false) {
6643 const props = {};
6644 const attrs = {};
6645 def(attrs, InternalObjectKey, 1);
6646 instance.propsDefaults = Object.create(null);
6647 setFullProps(instance, rawProps, props, attrs);
6648 // ensure all declared prop keys are present
6649 for (const key in instance.propsOptions[0]) {
6650 if (!(key in props)) {
6651 props[key] = undefined;
6652 }
6653 }
6654 // validation
6655 {
6656 validateProps(rawProps || {}, props, instance);
6657 }
6658 if (isStateful) {
6659 // stateful
6660 instance.props = isSSR ? props : shallowReactive(props);
6661 }
6662 else {
6663 if (!instance.type.props) {
6664 // functional w/ optional props, props === attrs
6665 instance.props = attrs;
6666 }
6667 else {
6668 // functional w/ declared props
6669 instance.props = props;
6670 }
6671 }
6672 instance.attrs = attrs;
6673}
6674function isInHmrContext(instance) {
6675 while (instance) {
6676 if (instance.type.__hmrId)
6677 return true;
6678 instance = instance.parent;
6679 }
6680}
6681function updateProps(instance, rawProps, rawPrevProps, optimized) {
6682 const { props, attrs, vnode: { patchFlag } } = instance;
6683 const rawCurrentProps = toRaw(props);
6684 const [options] = instance.propsOptions;
6685 let hasAttrsChanged = false;
6686 if (
6687 // always force full diff in dev
6688 // - #1942 if hmr is enabled with sfc component
6689 // - vite#872 non-sfc component used by sfc component
6690 !(isInHmrContext(instance)) &&
6691 (optimized || patchFlag > 0) &&
6692 !(patchFlag & 16 /* PatchFlags.FULL_PROPS */)) {
6693 if (patchFlag & 8 /* PatchFlags.PROPS */) {
6694 // Compiler-generated props & no keys change, just set the updated
6695 // the props.
6696 const propsToUpdate = instance.vnode.dynamicProps;
6697 for (let i = 0; i < propsToUpdate.length; i++) {
6698 let key = propsToUpdate[i];
6699 // skip if the prop key is a declared emit event listener
6700 if (isEmitListener(instance.emitsOptions, key)) {
6701 continue;
6702 }
6703 // PROPS flag guarantees rawProps to be non-null
6704 const value = rawProps[key];
6705 if (options) {
6706 // attr / props separation was done on init and will be consistent
6707 // in this code path, so just check if attrs have it.
6708 if (hasOwn(attrs, key)) {
6709 if (value !== attrs[key]) {
6710 attrs[key] = value;
6711 hasAttrsChanged = true;
6712 }
6713 }
6714 else {
6715 const camelizedKey = camelize(key);
6716 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
6717 }
6718 }
6719 else {
6720 {
6721 if (isOn(key) && key.endsWith('Native')) {
6722 key = key.slice(0, -6); // remove Native postfix
6723 }
6724 else if (shouldSkipAttr(key, instance)) {
6725 continue;
6726 }
6727 }
6728 if (value !== attrs[key]) {
6729 attrs[key] = value;
6730 hasAttrsChanged = true;
6731 }
6732 }
6733 }
6734 }
6735 }
6736 else {
6737 // full props update.
6738 if (setFullProps(instance, rawProps, props, attrs)) {
6739 hasAttrsChanged = true;
6740 }
6741 // in case of dynamic props, check if we need to delete keys from
6742 // the props object
6743 let kebabKey;
6744 for (const key in rawCurrentProps) {
6745 if (!rawProps ||
6746 // for camelCase
6747 (!hasOwn(rawProps, key) &&
6748 // it's possible the original props was passed in as kebab-case
6749 // and converted to camelCase (#955)
6750 ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
6751 if (options) {
6752 if (rawPrevProps &&
6753 // for camelCase
6754 (rawPrevProps[key] !== undefined ||
6755 // for kebab-case
6756 rawPrevProps[kebabKey] !== undefined)) {
6757 props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
6758 }
6759 }
6760 else {
6761 delete props[key];
6762 }
6763 }
6764 }
6765 // in the case of functional component w/o props declaration, props and
6766 // attrs point to the same object so it should already have been updated.
6767 if (attrs !== rawCurrentProps) {
6768 for (const key in attrs) {
6769 if (!rawProps ||
6770 (!hasOwn(rawProps, key) &&
6771 (!hasOwn(rawProps, key + 'Native')))) {
6772 delete attrs[key];
6773 hasAttrsChanged = true;
6774 }
6775 }
6776 }
6777 }
6778 // trigger updates for $attrs in case it's used in component slots
6779 if (hasAttrsChanged) {
6780 trigger(instance, "set" /* TriggerOpTypes.SET */, '$attrs');
6781 }
6782 {
6783 validateProps(rawProps || {}, props, instance);
6784 }
6785}
6786function setFullProps(instance, rawProps, props, attrs) {
6787 const [options, needCastKeys] = instance.propsOptions;
6788 let hasAttrsChanged = false;
6789 let rawCastValues;
6790 if (rawProps) {
6791 for (let key in rawProps) {
6792 // key, ref are reserved and never passed down
6793 if (isReservedProp(key)) {
6794 continue;
6795 }
6796 {
6797 if (key.startsWith('onHook:')) {
6798 softAssertCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance, key.slice(2).toLowerCase());
6799 }
6800 if (key === 'inline-template') {
6801 continue;
6802 }
6803 }
6804 const value = rawProps[key];
6805 // prop option names are camelized during normalization, so to support
6806 // kebab -> camel conversion here we need to camelize the key.
6807 let camelKey;
6808 if (options && hasOwn(options, (camelKey = camelize(key)))) {
6809 if (!needCastKeys || !needCastKeys.includes(camelKey)) {
6810 props[camelKey] = value;
6811 }
6812 else {
6813 (rawCastValues || (rawCastValues = {}))[camelKey] = value;
6814 }
6815 }
6816 else if (!isEmitListener(instance.emitsOptions, key)) {
6817 // Any non-declared (either as a prop or an emitted event) props are put
6818 // into a separate `attrs` object for spreading. Make sure to preserve
6819 // original key casing
6820 {
6821 if (isOn(key) && key.endsWith('Native')) {
6822 key = key.slice(0, -6); // remove Native postfix
6823 }
6824 else if (shouldSkipAttr(key, instance)) {
6825 continue;
6826 }
6827 }
6828 if (!(key in attrs) || value !== attrs[key]) {
6829 attrs[key] = value;
6830 hasAttrsChanged = true;
6831 }
6832 }
6833 }
6834 }
6835 if (needCastKeys) {
6836 const rawCurrentProps = toRaw(props);
6837 const castValues = rawCastValues || EMPTY_OBJ;
6838 for (let i = 0; i < needCastKeys.length; i++) {
6839 const key = needCastKeys[i];
6840 props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
6841 }
6842 }
6843 return hasAttrsChanged;
6844}
6845function resolvePropValue(options, props, key, value, instance, isAbsent) {
6846 const opt = options[key];
6847 if (opt != null) {
6848 const hasDefault = hasOwn(opt, 'default');
6849 // default values
6850 if (hasDefault && value === undefined) {
6851 const defaultValue = opt.default;
6852 if (opt.type !== Function && isFunction(defaultValue)) {
6853 const { propsDefaults } = instance;
6854 if (key in propsDefaults) {
6855 value = propsDefaults[key];
6856 }
6857 else {
6858 setCurrentInstance(instance);
6859 value = propsDefaults[key] = defaultValue.call(isCompatEnabled("PROPS_DEFAULT_THIS" /* DeprecationTypes.PROPS_DEFAULT_THIS */, instance)
6860 ? createPropsDefaultThis(instance, props, key)
6861 : null, props);
6862 unsetCurrentInstance();
6863 }
6864 }
6865 else {
6866 value = defaultValue;
6867 }
6868 }
6869 // boolean casting
6870 if (opt[0 /* BooleanFlags.shouldCast */]) {
6871 if (isAbsent && !hasDefault) {
6872 value = false;
6873 }
6874 else if (opt[1 /* BooleanFlags.shouldCastTrue */] &&
6875 (value === '' || value === hyphenate(key))) {
6876 value = true;
6877 }
6878 }
6879 }
6880 return value;
6881}
6882function normalizePropsOptions(comp, appContext, asMixin = false) {
6883 const cache = appContext.propsCache;
6884 const cached = cache.get(comp);
6885 if (cached) {
6886 return cached;
6887 }
6888 const raw = comp.props;
6889 const normalized = {};
6890 const needCastKeys = [];
6891 // apply mixin/extends props
6892 let hasExtends = false;
6893 if (!isFunction(comp)) {
6894 const extendProps = (raw) => {
6895 if (isFunction(raw)) {
6896 raw = raw.options;
6897 }
6898 hasExtends = true;
6899 const [props, keys] = normalizePropsOptions(raw, appContext, true);
6900 extend(normalized, props);
6901 if (keys)
6902 needCastKeys.push(...keys);
6903 };
6904 if (!asMixin && appContext.mixins.length) {
6905 appContext.mixins.forEach(extendProps);
6906 }
6907 if (comp.extends) {
6908 extendProps(comp.extends);
6909 }
6910 if (comp.mixins) {
6911 comp.mixins.forEach(extendProps);
6912 }
6913 }
6914 if (!raw && !hasExtends) {
6915 if (isObject(comp)) {
6916 cache.set(comp, EMPTY_ARR);
6917 }
6918 return EMPTY_ARR;
6919 }
6920 if (isArray(raw)) {
6921 for (let i = 0; i < raw.length; i++) {
6922 if (!isString(raw[i])) {
6923 warn$1(`props must be strings when using array syntax.`, raw[i]);
6924 }
6925 const normalizedKey = camelize(raw[i]);
6926 if (validatePropName(normalizedKey)) {
6927 normalized[normalizedKey] = EMPTY_OBJ;
6928 }
6929 }
6930 }
6931 else if (raw) {
6932 if (!isObject(raw)) {
6933 warn$1(`invalid props options`, raw);
6934 }
6935 for (const key in raw) {
6936 const normalizedKey = camelize(key);
6937 if (validatePropName(normalizedKey)) {
6938 const opt = raw[key];
6939 const prop = (normalized[normalizedKey] =
6940 isArray(opt) || isFunction(opt) ? { type: opt } : opt);
6941 if (prop) {
6942 const booleanIndex = getTypeIndex(Boolean, prop.type);
6943 const stringIndex = getTypeIndex(String, prop.type);
6944 prop[0 /* BooleanFlags.shouldCast */] = booleanIndex > -1;
6945 prop[1 /* BooleanFlags.shouldCastTrue */] =
6946 stringIndex < 0 || booleanIndex < stringIndex;
6947 // if the prop needs boolean casting or default value
6948 if (booleanIndex > -1 || hasOwn(prop, 'default')) {
6949 needCastKeys.push(normalizedKey);
6950 }
6951 }
6952 }
6953 }
6954 }
6955 const res = [normalized, needCastKeys];
6956 if (isObject(comp)) {
6957 cache.set(comp, res);
6958 }
6959 return res;
6960}
6961function validatePropName(key) {
6962 if (key[0] !== '$') {
6963 return true;
6964 }
6965 else {
6966 warn$1(`Invalid prop name: "${key}" is a reserved property.`);
6967 }
6968 return false;
6969}
6970// use function string name to check type constructors
6971// so that it works across vms / iframes.
6972function getType(ctor) {
6973 const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
6974 return match ? match[1] : ctor === null ? 'null' : '';
6975}
6976function isSameType(a, b) {
6977 return getType(a) === getType(b);
6978}
6979function getTypeIndex(type, expectedTypes) {
6980 if (isArray(expectedTypes)) {
6981 return expectedTypes.findIndex(t => isSameType(t, type));
6982 }
6983 else if (isFunction(expectedTypes)) {
6984 return isSameType(expectedTypes, type) ? 0 : -1;
6985 }
6986 return -1;
6987}
6988/**
6989 * dev only
6990 */
6991function validateProps(rawProps, props, instance) {
6992 const resolvedValues = toRaw(props);
6993 const options = instance.propsOptions[0];
6994 for (const key in options) {
6995 let opt = options[key];
6996 if (opt == null)
6997 continue;
6998 validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
6999 }
7000}
7001/**
7002 * dev only
7003 */
7004function validateProp(name, value, prop, isAbsent) {
7005 const { type, required, validator } = prop;
7006 // required!
7007 if (required && isAbsent) {
7008 warn$1('Missing required prop: "' + name + '"');
7009 return;
7010 }
7011 // missing but optional
7012 if (value == null && !prop.required) {
7013 return;
7014 }
7015 // type check
7016 if (type != null && type !== true) {
7017 let isValid = false;
7018 const types = isArray(type) ? type : [type];
7019 const expectedTypes = [];
7020 // value is valid as long as one of the specified types match
7021 for (let i = 0; i < types.length && !isValid; i++) {
7022 const { valid, expectedType } = assertType(value, types[i]);
7023 expectedTypes.push(expectedType || '');
7024 isValid = valid;
7025 }
7026 if (!isValid) {
7027 warn$1(getInvalidTypeMessage(name, value, expectedTypes));
7028 return;
7029 }
7030 }
7031 // custom validator
7032 if (validator && !validator(value)) {
7033 warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
7034 }
7035}
7036const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
7037/**
7038 * dev only
7039 */
7040function assertType(value, type) {
7041 let valid;
7042 const expectedType = getType(type);
7043 if (isSimpleType(expectedType)) {
7044 const t = typeof value;
7045 valid = t === expectedType.toLowerCase();
7046 // for primitive wrapper objects
7047 if (!valid && t === 'object') {
7048 valid = value instanceof type;
7049 }
7050 }
7051 else if (expectedType === 'Object') {
7052 valid = isObject(value);
7053 }
7054 else if (expectedType === 'Array') {
7055 valid = isArray(value);
7056 }
7057 else if (expectedType === 'null') {
7058 valid = value === null;
7059 }
7060 else {
7061 valid = value instanceof type;
7062 }
7063 return {
7064 valid,
7065 expectedType
7066 };
7067}
7068/**
7069 * dev only
7070 */
7071function getInvalidTypeMessage(name, value, expectedTypes) {
7072 let message = `Invalid prop: type check failed for prop "${name}".` +
7073 ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
7074 const expectedType = expectedTypes[0];
7075 const receivedType = toRawType(value);
7076 const expectedValue = styleValue(value, expectedType);
7077 const receivedValue = styleValue(value, receivedType);
7078 // check if we need to specify expected value
7079 if (expectedTypes.length === 1 &&
7080 isExplicable(expectedType) &&
7081 !isBoolean(expectedType, receivedType)) {
7082 message += ` with value ${expectedValue}`;
7083 }
7084 message += `, got ${receivedType} `;
7085 // check if we need to specify received value
7086 if (isExplicable(receivedType)) {
7087 message += `with value ${receivedValue}.`;
7088 }
7089 return message;
7090}
7091/**
7092 * dev only
7093 */
7094function styleValue(value, type) {
7095 if (type === 'String') {
7096 return `"${value}"`;
7097 }
7098 else if (type === 'Number') {
7099 return `${Number(value)}`;
7100 }
7101 else {
7102 return `${value}`;
7103 }
7104}
7105/**
7106 * dev only
7107 */
7108function isExplicable(type) {
7109 const explicitTypes = ['string', 'number', 'boolean'];
7110 return explicitTypes.some(elem => type.toLowerCase() === elem);
7111}
7112/**
7113 * dev only
7114 */
7115function isBoolean(...args) {
7116 return args.some(elem => elem.toLowerCase() === 'boolean');
7117}
7118
7119const isInternalKey = (key) => key[0] === '_' || key === '$stable';
7120const normalizeSlotValue = (value) => isArray(value)
7121 ? value.map(normalizeVNode)
7122 : [normalizeVNode(value)];
7123const normalizeSlot = (key, rawSlot, ctx) => {
7124 if (rawSlot._n) {
7125 // already normalized - #5353
7126 return rawSlot;
7127 }
7128 const normalized = withCtx((...args) => {
7129 if (currentInstance) {
7130 warn$1(`Slot "${key}" invoked outside of the render function: ` +
7131 `this will not track dependencies used in the slot. ` +
7132 `Invoke the slot function inside the render function instead.`);
7133 }
7134 return normalizeSlotValue(rawSlot(...args));
7135 }, ctx);
7136 normalized._c = false;
7137 return normalized;
7138};
7139const normalizeObjectSlots = (rawSlots, slots, instance) => {
7140 const ctx = rawSlots._ctx;
7141 for (const key in rawSlots) {
7142 if (isInternalKey(key))
7143 continue;
7144 const value = rawSlots[key];
7145 if (isFunction(value)) {
7146 slots[key] = normalizeSlot(key, value, ctx);
7147 }
7148 else if (value != null) {
7149 if (!(isCompatEnabled("RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */, instance))) {
7150 warn$1(`Non-function value encountered for slot "${key}". ` +
7151 `Prefer function slots for better performance.`);
7152 }
7153 const normalized = normalizeSlotValue(value);
7154 slots[key] = () => normalized;
7155 }
7156 }
7157};
7158const normalizeVNodeSlots = (instance, children) => {
7159 if (!isKeepAlive(instance.vnode) &&
7160 !(isCompatEnabled("RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */, instance))) {
7161 warn$1(`Non-function value encountered for default slot. ` +
7162 `Prefer function slots for better performance.`);
7163 }
7164 const normalized = normalizeSlotValue(children);
7165 instance.slots.default = () => normalized;
7166};
7167const initSlots = (instance, children) => {
7168 if (instance.vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
7169 const type = children._;
7170 if (type) {
7171 // users can get the shallow readonly version of the slots object through `this.$slots`,
7172 // we should avoid the proxy object polluting the slots of the internal instance
7173 instance.slots = toRaw(children);
7174 // make compiler marker non-enumerable
7175 def(children, '_', type);
7176 }
7177 else {
7178 normalizeObjectSlots(children, (instance.slots = {}), instance);
7179 }
7180 }
7181 else {
7182 instance.slots = {};
7183 if (children) {
7184 normalizeVNodeSlots(instance, children);
7185 }
7186 }
7187 def(instance.slots, InternalObjectKey, 1);
7188};
7189const updateSlots = (instance, children, optimized) => {
7190 const { vnode, slots } = instance;
7191 let needDeletionCheck = true;
7192 let deletionComparisonTarget = EMPTY_OBJ;
7193 if (vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
7194 const type = children._;
7195 if (type) {
7196 // compiled slots.
7197 if (isHmrUpdating) {
7198 // Parent was HMR updated so slot content may have changed.
7199 // force update slots and mark instance for hmr as well
7200 extend(slots, children);
7201 }
7202 else if (optimized && type === 1 /* SlotFlags.STABLE */) {
7203 // compiled AND stable.
7204 // no need to update, and skip stale slots removal.
7205 needDeletionCheck = false;
7206 }
7207 else {
7208 // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
7209 // normalization.
7210 extend(slots, children);
7211 // #2893
7212 // when rendering the optimized slots by manually written render function,
7213 // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
7214 // i.e. let the `renderSlot` create the bailed Fragment
7215 if (!optimized && type === 1 /* SlotFlags.STABLE */) {
7216 delete slots._;
7217 }
7218 }
7219 }
7220 else {
7221 needDeletionCheck = !children.$stable;
7222 normalizeObjectSlots(children, slots, instance);
7223 }
7224 deletionComparisonTarget = children;
7225 }
7226 else if (children) {
7227 // non slot object children (direct value) passed to a component
7228 normalizeVNodeSlots(instance, children);
7229 deletionComparisonTarget = { default: 1 };
7230 }
7231 // delete stale slots
7232 if (needDeletionCheck) {
7233 for (const key in slots) {
7234 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
7235 delete slots[key];
7236 }
7237 }
7238 }
7239};
7240
7241// dev only
7242function installLegacyConfigWarnings(config) {
7243 const legacyConfigOptions = {
7244 silent: "CONFIG_SILENT" /* DeprecationTypes.CONFIG_SILENT */,
7245 devtools: "CONFIG_DEVTOOLS" /* DeprecationTypes.CONFIG_DEVTOOLS */,
7246 ignoredElements: "CONFIG_IGNORED_ELEMENTS" /* DeprecationTypes.CONFIG_IGNORED_ELEMENTS */,
7247 keyCodes: "CONFIG_KEY_CODES" /* DeprecationTypes.CONFIG_KEY_CODES */,
7248 productionTip: "CONFIG_PRODUCTION_TIP" /* DeprecationTypes.CONFIG_PRODUCTION_TIP */
7249 };
7250 Object.keys(legacyConfigOptions).forEach(key => {
7251 let val = config[key];
7252 Object.defineProperty(config, key, {
7253 enumerable: true,
7254 get() {
7255 return val;
7256 },
7257 set(newVal) {
7258 if (!isCopyingConfig) {
7259 warnDeprecation(legacyConfigOptions[key], null);
7260 }
7261 val = newVal;
7262 }
7263 });
7264 });
7265}
7266function installLegacyOptionMergeStrats(config) {
7267 config.optionMergeStrategies = new Proxy({}, {
7268 get(target, key) {
7269 if (key in target) {
7270 return target[key];
7271 }
7272 if (key in internalOptionMergeStrats &&
7273 softAssertCompatEnabled("CONFIG_OPTION_MERGE_STRATS" /* DeprecationTypes.CONFIG_OPTION_MERGE_STRATS */, null)) {
7274 return internalOptionMergeStrats[key];
7275 }
7276 }
7277 });
7278}
7279
7280let isCopyingConfig = false;
7281// exported only for test
7282let singletonApp;
7283let singletonCtor;
7284// Legacy global Vue constructor
7285function createCompatVue(createApp, createSingletonApp) {
7286 singletonApp = createSingletonApp({});
7287 const Vue = (singletonCtor = function Vue(options = {}) {
7288 return createCompatApp(options, Vue);
7289 });
7290 function createCompatApp(options = {}, Ctor) {
7291 assertCompatEnabled("GLOBAL_MOUNT" /* DeprecationTypes.GLOBAL_MOUNT */, null);
7292 const { data } = options;
7293 if (data &&
7294 !isFunction(data) &&
7295 softAssertCompatEnabled("OPTIONS_DATA_FN" /* DeprecationTypes.OPTIONS_DATA_FN */, null)) {
7296 options.data = () => data;
7297 }
7298 const app = createApp(options);
7299 if (Ctor !== Vue) {
7300 applySingletonPrototype(app, Ctor);
7301 }
7302 const vm = app._createRoot(options);
7303 if (options.el) {
7304 return vm.$mount(options.el);
7305 }
7306 else {
7307 return vm;
7308 }
7309 }
7310 Vue.version = `2.6.14-compat:${"3.2.38"}`;
7311 Vue.config = singletonApp.config;
7312 Vue.use = (p, ...options) => {
7313 if (p && isFunction(p.install)) {
7314 p.install(Vue, ...options);
7315 }
7316 else if (isFunction(p)) {
7317 p(Vue, ...options);
7318 }
7319 return Vue;
7320 };
7321 Vue.mixin = m => {
7322 singletonApp.mixin(m);
7323 return Vue;
7324 };
7325 Vue.component = ((name, comp) => {
7326 if (comp) {
7327 singletonApp.component(name, comp);
7328 return Vue;
7329 }
7330 else {
7331 return singletonApp.component(name);
7332 }
7333 });
7334 Vue.directive = ((name, dir) => {
7335 if (dir) {
7336 singletonApp.directive(name, dir);
7337 return Vue;
7338 }
7339 else {
7340 return singletonApp.directive(name);
7341 }
7342 });
7343 Vue.options = { _base: Vue };
7344 let cid = 1;
7345 Vue.cid = cid;
7346 Vue.nextTick = nextTick;
7347 const extendCache = new WeakMap();
7348 function extendCtor(extendOptions = {}) {
7349 assertCompatEnabled("GLOBAL_EXTEND" /* DeprecationTypes.GLOBAL_EXTEND */, null);
7350 if (isFunction(extendOptions)) {
7351 extendOptions = extendOptions.options;
7352 }
7353 if (extendCache.has(extendOptions)) {
7354 return extendCache.get(extendOptions);
7355 }
7356 const Super = this;
7357 function SubVue(inlineOptions) {
7358 if (!inlineOptions) {
7359 return createCompatApp(SubVue.options, SubVue);
7360 }
7361 else {
7362 return createCompatApp(mergeOptions(extend({}, SubVue.options), inlineOptions, internalOptionMergeStrats), SubVue);
7363 }
7364 }
7365 SubVue.super = Super;
7366 SubVue.prototype = Object.create(Vue.prototype);
7367 SubVue.prototype.constructor = SubVue;
7368 // clone non-primitive base option values for edge case of mutating
7369 // extended options
7370 const mergeBase = {};
7371 for (const key in Super.options) {
7372 const superValue = Super.options[key];
7373 mergeBase[key] = isArray(superValue)
7374 ? superValue.slice()
7375 : isObject(superValue)
7376 ? extend(Object.create(null), superValue)
7377 : superValue;
7378 }
7379 SubVue.options = mergeOptions(mergeBase, extendOptions, internalOptionMergeStrats);
7380 SubVue.options._base = SubVue;
7381 SubVue.extend = extendCtor.bind(SubVue);
7382 SubVue.mixin = Super.mixin;
7383 SubVue.use = Super.use;
7384 SubVue.cid = ++cid;
7385 extendCache.set(extendOptions, SubVue);
7386 return SubVue;
7387 }
7388 Vue.extend = extendCtor.bind(Vue);
7389 Vue.set = (target, key, value) => {
7390 assertCompatEnabled("GLOBAL_SET" /* DeprecationTypes.GLOBAL_SET */, null);
7391 target[key] = value;
7392 };
7393 Vue.delete = (target, key) => {
7394 assertCompatEnabled("GLOBAL_DELETE" /* DeprecationTypes.GLOBAL_DELETE */, null);
7395 delete target[key];
7396 };
7397 Vue.observable = (target) => {
7398 assertCompatEnabled("GLOBAL_OBSERVABLE" /* DeprecationTypes.GLOBAL_OBSERVABLE */, null);
7399 return reactive(target);
7400 };
7401 Vue.filter = ((name, filter) => {
7402 if (filter) {
7403 singletonApp.filter(name, filter);
7404 return Vue;
7405 }
7406 else {
7407 return singletonApp.filter(name);
7408 }
7409 });
7410 // internal utils - these are technically internal but some plugins use it.
7411 const util = {
7412 warn: warn$1 ,
7413 extend,
7414 mergeOptions: (parent, child, vm) => mergeOptions(parent, child, vm ? undefined : internalOptionMergeStrats),
7415 defineReactive
7416 };
7417 Object.defineProperty(Vue, 'util', {
7418 get() {
7419 assertCompatEnabled("GLOBAL_PRIVATE_UTIL" /* DeprecationTypes.GLOBAL_PRIVATE_UTIL */, null);
7420 return util;
7421 }
7422 });
7423 Vue.configureCompat = configureCompat;
7424 return Vue;
7425}
7426function installAppCompatProperties(app, context, render) {
7427 installFilterMethod(app, context);
7428 installLegacyOptionMergeStrats(app.config);
7429 if (!singletonApp) {
7430 // this is the call of creating the singleton itself so the rest is
7431 // unnecessary
7432 return;
7433 }
7434 installCompatMount(app, context, render);
7435 installLegacyAPIs(app);
7436 applySingletonAppMutations(app);
7437 installLegacyConfigWarnings(app.config);
7438}
7439function installFilterMethod(app, context) {
7440 context.filters = {};
7441 app.filter = (name, filter) => {
7442 assertCompatEnabled("FILTERS" /* DeprecationTypes.FILTERS */, null);
7443 if (!filter) {
7444 return context.filters[name];
7445 }
7446 if (context.filters[name]) {
7447 warn$1(`Filter "${name}" has already been registered.`);
7448 }
7449 context.filters[name] = filter;
7450 return app;
7451 };
7452}
7453function installLegacyAPIs(app) {
7454 // expose global API on app instance for legacy plugins
7455 Object.defineProperties(app, {
7456 // so that app.use() can work with legacy plugins that extend prototypes
7457 prototype: {
7458 get() {
7459 warnDeprecation("GLOBAL_PROTOTYPE" /* DeprecationTypes.GLOBAL_PROTOTYPE */, null);
7460 return app.config.globalProperties;
7461 }
7462 },
7463 nextTick: { value: nextTick },
7464 extend: { value: singletonCtor.extend },
7465 set: { value: singletonCtor.set },
7466 delete: { value: singletonCtor.delete },
7467 observable: { value: singletonCtor.observable },
7468 util: {
7469 get() {
7470 return singletonCtor.util;
7471 }
7472 }
7473 });
7474}
7475function applySingletonAppMutations(app) {
7476 // copy over asset registries and deopt flag
7477 app._context.mixins = [...singletonApp._context.mixins];
7478 ['components', 'directives', 'filters'].forEach(key => {
7479 // @ts-ignore
7480 app._context[key] = Object.create(singletonApp._context[key]);
7481 });
7482 // copy over global config mutations
7483 isCopyingConfig = true;
7484 for (const key in singletonApp.config) {
7485 if (key === 'isNativeTag')
7486 continue;
7487 if (isRuntimeOnly() &&
7488 (key === 'isCustomElement' || key === 'compilerOptions')) {
7489 continue;
7490 }
7491 const val = singletonApp.config[key];
7492 // @ts-ignore
7493 app.config[key] = isObject(val) ? Object.create(val) : val;
7494 // compat for runtime ignoredElements -> isCustomElement
7495 if (key === 'ignoredElements' &&
7496 isCompatEnabled("CONFIG_IGNORED_ELEMENTS" /* DeprecationTypes.CONFIG_IGNORED_ELEMENTS */, null) &&
7497 !isRuntimeOnly() &&
7498 isArray(val)) {
7499 app.config.compilerOptions.isCustomElement = tag => {
7500 return val.some(v => (isString(v) ? v === tag : v.test(tag)));
7501 };
7502 }
7503 }
7504 isCopyingConfig = false;
7505 applySingletonPrototype(app, singletonCtor);
7506}
7507function applySingletonPrototype(app, Ctor) {
7508 // copy prototype augmentations as config.globalProperties
7509 const enabled = isCompatEnabled("GLOBAL_PROTOTYPE" /* DeprecationTypes.GLOBAL_PROTOTYPE */, null);
7510 if (enabled) {
7511 app.config.globalProperties = Object.create(Ctor.prototype);
7512 }
7513 let hasPrototypeAugmentations = false;
7514 const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
7515 for (const key in descriptors) {
7516 if (key !== 'constructor') {
7517 hasPrototypeAugmentations = true;
7518 if (enabled) {
7519 Object.defineProperty(app.config.globalProperties, key, descriptors[key]);
7520 }
7521 }
7522 }
7523 if (hasPrototypeAugmentations) {
7524 warnDeprecation("GLOBAL_PROTOTYPE" /* DeprecationTypes.GLOBAL_PROTOTYPE */, null);
7525 }
7526}
7527function installCompatMount(app, context, render) {
7528 let isMounted = false;
7529 /**
7530 * Vue 2 supports the behavior of creating a component instance but not
7531 * mounting it, which is no longer possible in Vue 3 - this internal
7532 * function simulates that behavior.
7533 */
7534 app._createRoot = options => {
7535 const component = app._component;
7536 const vnode = createVNode(component, options.propsData || null);
7537 vnode.appContext = context;
7538 const hasNoRender = !isFunction(component) && !component.render && !component.template;
7539 const emptyRender = () => { };
7540 // create root instance
7541 const instance = createComponentInstance(vnode, null, null);
7542 // suppress "missing render fn" warning since it can't be determined
7543 // until $mount is called
7544 if (hasNoRender) {
7545 instance.render = emptyRender;
7546 }
7547 setupComponent(instance);
7548 vnode.component = instance;
7549 vnode.isCompatRoot = true;
7550 // $mount & $destroy
7551 // these are defined on ctx and picked up by the $mount/$destroy
7552 // public property getters on the instance proxy.
7553 // Note: the following assumes DOM environment since the compat build
7554 // only targets web. It essentially includes logic for app.mount from
7555 // both runtime-core AND runtime-dom.
7556 instance.ctx._compat_mount = (selectorOrEl) => {
7557 if (isMounted) {
7558 warn$1(`Root instance is already mounted.`);
7559 return;
7560 }
7561 let container;
7562 if (typeof selectorOrEl === 'string') {
7563 // eslint-disable-next-line
7564 const result = document.querySelector(selectorOrEl);
7565 if (!result) {
7566 warn$1(`Failed to mount root instance: selector "${selectorOrEl}" returned null.`);
7567 return;
7568 }
7569 container = result;
7570 }
7571 else {
7572 // eslint-disable-next-line
7573 container = selectorOrEl || document.createElement('div');
7574 }
7575 const isSVG = container instanceof SVGElement;
7576 // HMR root reload
7577 {
7578 context.reload = () => {
7579 const cloned = cloneVNode(vnode);
7580 // compat mode will use instance if not reset to null
7581 cloned.component = null;
7582 render(cloned, container, isSVG);
7583 };
7584 }
7585 // resolve in-DOM template if component did not provide render
7586 // and no setup/mixin render functions are provided (by checking
7587 // that the instance is still using the placeholder render fn)
7588 if (hasNoRender && instance.render === emptyRender) {
7589 // root directives check
7590 {
7591 for (let i = 0; i < container.attributes.length; i++) {
7592 const attr = container.attributes[i];
7593 if (attr.name !== 'v-cloak' && /^(v-|:|@)/.test(attr.name)) {
7594 warnDeprecation("GLOBAL_MOUNT_CONTAINER" /* DeprecationTypes.GLOBAL_MOUNT_CONTAINER */, null);
7595 break;
7596 }
7597 }
7598 }
7599 instance.render = null;
7600 component.template = container.innerHTML;
7601 finishComponentSetup(instance, false, true /* skip options */);
7602 }
7603 // clear content before mounting
7604 container.innerHTML = '';
7605 // TODO hydration
7606 render(vnode, container, isSVG);
7607 if (container instanceof Element) {
7608 container.removeAttribute('v-cloak');
7609 container.setAttribute('data-v-app', '');
7610 }
7611 isMounted = true;
7612 app._container = container;
7613 container.__vue_app__ = app;
7614 {
7615 devtoolsInitApp(app, version);
7616 }
7617 return instance.proxy;
7618 };
7619 instance.ctx._compat_destroy = () => {
7620 if (isMounted) {
7621 render(null, app._container);
7622 {
7623 devtoolsUnmountApp(app);
7624 }
7625 delete app._container.__vue_app__;
7626 }
7627 else {
7628 const { bum, scope, um } = instance;
7629 // beforeDestroy hooks
7630 if (bum) {
7631 invokeArrayFns(bum);
7632 }
7633 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
7634 instance.emit('hook:beforeDestroy');
7635 }
7636 // stop effects
7637 if (scope) {
7638 scope.stop();
7639 }
7640 // unmounted hook
7641 if (um) {
7642 invokeArrayFns(um);
7643 }
7644 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
7645 instance.emit('hook:destroyed');
7646 }
7647 }
7648 };
7649 return instance.proxy;
7650 };
7651}
7652const methodsToPatch = [
7653 'push',
7654 'pop',
7655 'shift',
7656 'unshift',
7657 'splice',
7658 'sort',
7659 'reverse'
7660];
7661const patched = new WeakSet();
7662function defineReactive(obj, key, val) {
7663 // it's possible for the original object to be mutated after being defined
7664 // and expecting reactivity... we are covering it here because this seems to
7665 // be a bit more common.
7666 if (isObject(val) && !isReactive(val) && !patched.has(val)) {
7667 const reactiveVal = reactive(val);
7668 if (isArray(val)) {
7669 methodsToPatch.forEach(m => {
7670 // @ts-ignore
7671 val[m] = (...args) => {
7672 // @ts-ignore
7673 Array.prototype[m].call(reactiveVal, ...args);
7674 };
7675 });
7676 }
7677 else {
7678 Object.keys(val).forEach(key => {
7679 try {
7680 defineReactiveSimple(val, key, val[key]);
7681 }
7682 catch (e) { }
7683 });
7684 }
7685 }
7686 const i = obj.$;
7687 if (i && obj === i.proxy) {
7688 // target is a Vue instance - define on instance.ctx
7689 defineReactiveSimple(i.ctx, key, val);
7690 i.accessCache = Object.create(null);
7691 }
7692 else if (isReactive(obj)) {
7693 obj[key] = val;
7694 }
7695 else {
7696 defineReactiveSimple(obj, key, val);
7697 }
7698}
7699function defineReactiveSimple(obj, key, val) {
7700 val = isObject(val) ? reactive(val) : val;
7701 Object.defineProperty(obj, key, {
7702 enumerable: true,
7703 configurable: true,
7704 get() {
7705 track(obj, "get" /* TrackOpTypes.GET */, key);
7706 return val;
7707 },
7708 set(newVal) {
7709 val = isObject(newVal) ? reactive(newVal) : newVal;
7710 trigger(obj, "set" /* TriggerOpTypes.SET */, key, newVal);
7711 }
7712 });
7713}
7714
7715function createAppContext() {
7716 return {
7717 app: null,
7718 config: {
7719 isNativeTag: NO,
7720 performance: false,
7721 globalProperties: {},
7722 optionMergeStrategies: {},
7723 errorHandler: undefined,
7724 warnHandler: undefined,
7725 compilerOptions: {}
7726 },
7727 mixins: [],
7728 components: {},
7729 directives: {},
7730 provides: Object.create(null),
7731 optionsCache: new WeakMap(),
7732 propsCache: new WeakMap(),
7733 emitsCache: new WeakMap()
7734 };
7735}
7736let uid = 0;
7737function createAppAPI(render, hydrate) {
7738 return function createApp(rootComponent, rootProps = null) {
7739 if (!isFunction(rootComponent)) {
7740 rootComponent = { ...rootComponent };
7741 }
7742 if (rootProps != null && !isObject(rootProps)) {
7743 warn$1(`root props passed to app.mount() must be an object.`);
7744 rootProps = null;
7745 }
7746 const context = createAppContext();
7747 const installedPlugins = new Set();
7748 let isMounted = false;
7749 const app = (context.app = {
7750 _uid: uid++,
7751 _component: rootComponent,
7752 _props: rootProps,
7753 _container: null,
7754 _context: context,
7755 _instance: null,
7756 version,
7757 get config() {
7758 return context.config;
7759 },
7760 set config(v) {
7761 {
7762 warn$1(`app.config cannot be replaced. Modify individual options instead.`);
7763 }
7764 },
7765 use(plugin, ...options) {
7766 if (installedPlugins.has(plugin)) {
7767 warn$1(`Plugin has already been applied to target app.`);
7768 }
7769 else if (plugin && isFunction(plugin.install)) {
7770 installedPlugins.add(plugin);
7771 plugin.install(app, ...options);
7772 }
7773 else if (isFunction(plugin)) {
7774 installedPlugins.add(plugin);
7775 plugin(app, ...options);
7776 }
7777 else {
7778 warn$1(`A plugin must either be a function or an object with an "install" ` +
7779 `function.`);
7780 }
7781 return app;
7782 },
7783 mixin(mixin) {
7784 {
7785 if (!context.mixins.includes(mixin)) {
7786 context.mixins.push(mixin);
7787 }
7788 else {
7789 warn$1('Mixin has already been applied to target app' +
7790 (mixin.name ? `: ${mixin.name}` : ''));
7791 }
7792 }
7793 return app;
7794 },
7795 component(name, component) {
7796 {
7797 validateComponentName(name, context.config);
7798 }
7799 if (!component) {
7800 return context.components[name];
7801 }
7802 if (context.components[name]) {
7803 warn$1(`Component "${name}" has already been registered in target app.`);
7804 }
7805 context.components[name] = component;
7806 return app;
7807 },
7808 directive(name, directive) {
7809 {
7810 validateDirectiveName(name);
7811 }
7812 if (!directive) {
7813 return context.directives[name];
7814 }
7815 if (context.directives[name]) {
7816 warn$1(`Directive "${name}" has already been registered in target app.`);
7817 }
7818 context.directives[name] = directive;
7819 return app;
7820 },
7821 mount(rootContainer, isHydrate, isSVG) {
7822 if (!isMounted) {
7823 // #5571
7824 if (rootContainer.__vue_app__) {
7825 warn$1(`There is already an app instance mounted on the host container.\n` +
7826 ` If you want to mount another app on the same host container,` +
7827 ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
7828 }
7829 const vnode = createVNode(rootComponent, rootProps);
7830 // store app context on the root VNode.
7831 // this will be set on the root instance on initial mount.
7832 vnode.appContext = context;
7833 // HMR root reload
7834 {
7835 context.reload = () => {
7836 render(cloneVNode(vnode), rootContainer, isSVG);
7837 };
7838 }
7839 if (isHydrate && hydrate) {
7840 hydrate(vnode, rootContainer);
7841 }
7842 else {
7843 render(vnode, rootContainer, isSVG);
7844 }
7845 isMounted = true;
7846 app._container = rootContainer;
7847 rootContainer.__vue_app__ = app;
7848 {
7849 app._instance = vnode.component;
7850 devtoolsInitApp(app, version);
7851 }
7852 return getExposeProxy(vnode.component) || vnode.component.proxy;
7853 }
7854 else {
7855 warn$1(`App has already been mounted.\n` +
7856 `If you want to remount the same app, move your app creation logic ` +
7857 `into a factory function and create fresh app instances for each ` +
7858 `mount - e.g. \`const createMyApp = () => createApp(App)\``);
7859 }
7860 },
7861 unmount() {
7862 if (isMounted) {
7863 render(null, app._container);
7864 {
7865 app._instance = null;
7866 devtoolsUnmountApp(app);
7867 }
7868 delete app._container.__vue_app__;
7869 }
7870 else {
7871 warn$1(`Cannot unmount an app that is not mounted.`);
7872 }
7873 },
7874 provide(key, value) {
7875 if (key in context.provides) {
7876 warn$1(`App already provides property with key "${String(key)}". ` +
7877 `It will be overwritten with the new value.`);
7878 }
7879 context.provides[key] = value;
7880 return app;
7881 }
7882 });
7883 {
7884 installAppCompatProperties(app, context, render);
7885 }
7886 return app;
7887 };
7888}
7889
7890/**
7891 * Function for handling a template ref
7892 */
7893function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
7894 if (isArray(rawRef)) {
7895 rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
7896 return;
7897 }
7898 if (isAsyncWrapper(vnode) && !isUnmount) {
7899 // when mounting async components, nothing needs to be done,
7900 // because the template ref is forwarded to inner component
7901 return;
7902 }
7903 const refValue = vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */
7904 ? getExposeProxy(vnode.component) || vnode.component.proxy
7905 : vnode.el;
7906 const value = isUnmount ? null : refValue;
7907 const { i: owner, r: ref } = rawRef;
7908 if (!owner) {
7909 warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
7910 `A vnode with ref must be created inside the render function.`);
7911 return;
7912 }
7913 const oldRef = oldRawRef && oldRawRef.r;
7914 const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
7915 const setupState = owner.setupState;
7916 // dynamic ref changed. unset old ref
7917 if (oldRef != null && oldRef !== ref) {
7918 if (isString(oldRef)) {
7919 refs[oldRef] = null;
7920 if (hasOwn(setupState, oldRef)) {
7921 setupState[oldRef] = null;
7922 }
7923 }
7924 else if (isRef(oldRef)) {
7925 oldRef.value = null;
7926 }
7927 }
7928 if (isFunction(ref)) {
7929 callWithErrorHandling(ref, owner, 12 /* ErrorCodes.FUNCTION_REF */, [value, refs]);
7930 }
7931 else {
7932 const _isString = isString(ref);
7933 const _isRef = isRef(ref);
7934 if (_isString || _isRef) {
7935 const doSet = () => {
7936 if (rawRef.f) {
7937 const existing = _isString ? refs[ref] : ref.value;
7938 if (isUnmount) {
7939 isArray(existing) && remove(existing, refValue);
7940 }
7941 else {
7942 if (!isArray(existing)) {
7943 if (_isString) {
7944 refs[ref] = [refValue];
7945 if (hasOwn(setupState, ref)) {
7946 setupState[ref] = refs[ref];
7947 }
7948 }
7949 else {
7950 ref.value = [refValue];
7951 if (rawRef.k)
7952 refs[rawRef.k] = ref.value;
7953 }
7954 }
7955 else if (!existing.includes(refValue)) {
7956 existing.push(refValue);
7957 }
7958 }
7959 }
7960 else if (_isString) {
7961 refs[ref] = value;
7962 if (hasOwn(setupState, ref)) {
7963 setupState[ref] = value;
7964 }
7965 }
7966 else if (_isRef) {
7967 ref.value = value;
7968 if (rawRef.k)
7969 refs[rawRef.k] = value;
7970 }
7971 else {
7972 warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
7973 }
7974 };
7975 if (value) {
7976 doSet.id = -1;
7977 queuePostRenderEffect(doSet, parentSuspense);
7978 }
7979 else {
7980 doSet();
7981 }
7982 }
7983 else {
7984 warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
7985 }
7986 }
7987}
7988
7989let hasMismatch = false;
7990const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
7991const isComment = (node) => node.nodeType === 8 /* DOMNodeTypes.COMMENT */;
7992// Note: hydration is DOM-specific
7993// But we have to place it in core due to tight coupling with core - splitting
7994// it out creates a ton of unnecessary complexity.
7995// Hydration also depends on some renderer internal logic which needs to be
7996// passed in via arguments.
7997function createHydrationFunctions(rendererInternals) {
7998 const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
7999 const hydrate = (vnode, container) => {
8000 if (!container.hasChildNodes()) {
8001 warn$1(`Attempting to hydrate existing markup but container is empty. ` +
8002 `Performing full mount instead.`);
8003 patch(null, vnode, container);
8004 flushPostFlushCbs();
8005 container._vnode = vnode;
8006 return;
8007 }
8008 hasMismatch = false;
8009 hydrateNode(container.firstChild, vnode, null, null, null);
8010 flushPostFlushCbs();
8011 container._vnode = vnode;
8012 if (hasMismatch && !false) {
8013 // this error should show up in production
8014 console.error(`Hydration completed but contains mismatches.`);
8015 }
8016 };
8017 const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
8018 const isFragmentStart = isComment(node) && node.data === '[';
8019 const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
8020 const { type, ref, shapeFlag, patchFlag } = vnode;
8021 const domType = node.nodeType;
8022 vnode.el = node;
8023 if (patchFlag === -2 /* PatchFlags.BAIL */) {
8024 optimized = false;
8025 vnode.dynamicChildren = null;
8026 }
8027 let nextNode = null;
8028 switch (type) {
8029 case Text:
8030 if (domType !== 3 /* DOMNodeTypes.TEXT */) {
8031 // #5728 empty text node inside a slot can cause hydration failure
8032 // because the server rendered HTML won't contain a text node
8033 if (vnode.children === '') {
8034 insert((vnode.el = createText('')), parentNode(node), node);
8035 nextNode = node;
8036 }
8037 else {
8038 nextNode = onMismatch();
8039 }
8040 }
8041 else {
8042 if (node.data !== vnode.children) {
8043 hasMismatch = true;
8044 warn$1(`Hydration text mismatch:` +
8045 `\n- Client: ${JSON.stringify(node.data)}` +
8046 `\n- Server: ${JSON.stringify(vnode.children)}`);
8047 node.data = vnode.children;
8048 }
8049 nextNode = nextSibling(node);
8050 }
8051 break;
8052 case Comment:
8053 if (domType !== 8 /* DOMNodeTypes.COMMENT */ || isFragmentStart) {
8054 nextNode = onMismatch();
8055 }
8056 else {
8057 nextNode = nextSibling(node);
8058 }
8059 break;
8060 case Static:
8061 if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
8062 nextNode = onMismatch();
8063 }
8064 else {
8065 // determine anchor, adopt content
8066 nextNode = node;
8067 // if the static vnode has its content stripped during build,
8068 // adopt it from the server-rendered HTML.
8069 const needToAdoptContent = !vnode.children.length;
8070 for (let i = 0; i < vnode.staticCount; i++) {
8071 if (needToAdoptContent)
8072 vnode.children +=
8073 nextNode.nodeType === 1 /* DOMNodeTypes.ELEMENT */
8074 ? nextNode.outerHTML
8075 : nextNode.data;
8076 if (i === vnode.staticCount - 1) {
8077 vnode.anchor = nextNode;
8078 }
8079 nextNode = nextSibling(nextNode);
8080 }
8081 return nextNode;
8082 }
8083 break;
8084 case Fragment:
8085 if (!isFragmentStart) {
8086 nextNode = onMismatch();
8087 }
8088 else {
8089 nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
8090 }
8091 break;
8092 default:
8093 if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
8094 if (domType !== 1 /* DOMNodeTypes.ELEMENT */ ||
8095 vnode.type.toLowerCase() !==
8096 node.tagName.toLowerCase()) {
8097 nextNode = onMismatch();
8098 }
8099 else {
8100 nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
8101 }
8102 }
8103 else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
8104 // when setting up the render effect, if the initial vnode already
8105 // has .el set, the component will perform hydration instead of mount
8106 // on its sub-tree.
8107 vnode.slotScopeIds = slotScopeIds;
8108 const container = parentNode(node);
8109 mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
8110 // component may be async, so in the case of fragments we cannot rely
8111 // on component's rendered output to determine the end of the fragment
8112 // instead, we do a lookahead to find the end anchor node.
8113 nextNode = isFragmentStart
8114 ? locateClosingAsyncAnchor(node)
8115 : nextSibling(node);
8116 // #4293 teleport as component root
8117 if (nextNode &&
8118 isComment(nextNode) &&
8119 nextNode.data === 'teleport end') {
8120 nextNode = nextSibling(nextNode);
8121 }
8122 // #3787
8123 // if component is async, it may get moved / unmounted before its
8124 // inner component is loaded, so we need to give it a placeholder
8125 // vnode that matches its adopted DOM.
8126 if (isAsyncWrapper(vnode)) {
8127 let subTree;
8128 if (isFragmentStart) {
8129 subTree = createVNode(Fragment);
8130 subTree.anchor = nextNode
8131 ? nextNode.previousSibling
8132 : container.lastChild;
8133 }
8134 else {
8135 subTree =
8136 node.nodeType === 3 ? createTextVNode('') : createVNode('div');
8137 }
8138 subTree.el = node;
8139 vnode.component.subTree = subTree;
8140 }
8141 }
8142 else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
8143 if (domType !== 8 /* DOMNodeTypes.COMMENT */) {
8144 nextNode = onMismatch();
8145 }
8146 else {
8147 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
8148 }
8149 }
8150 else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
8151 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
8152 }
8153 else {
8154 warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
8155 }
8156 }
8157 if (ref != null) {
8158 setRef(ref, null, parentSuspense, vnode);
8159 }
8160 return nextNode;
8161 };
8162 const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
8163 optimized = optimized || !!vnode.dynamicChildren;
8164 const { type, props, patchFlag, shapeFlag, dirs } = vnode;
8165 // #4006 for form elements with non-string v-model value bindings
8166 // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
8167 const forcePatchValue = (type === 'input' && dirs) || type === 'option';
8168 // skip props & children if this is hoisted static nodes
8169 // #5405 in dev, always hydrate children for HMR
8170 {
8171 if (dirs) {
8172 invokeDirectiveHook(vnode, null, parentComponent, 'created');
8173 }
8174 // props
8175 if (props) {
8176 if (forcePatchValue ||
8177 !optimized ||
8178 patchFlag & (16 /* PatchFlags.FULL_PROPS */ | 32 /* PatchFlags.HYDRATE_EVENTS */)) {
8179 for (const key in props) {
8180 if ((forcePatchValue && key.endsWith('value')) ||
8181 (isOn(key) && !isReservedProp(key))) {
8182 patchProp(el, key, null, props[key], false, undefined, parentComponent);
8183 }
8184 }
8185 }
8186 else if (props.onClick) {
8187 // Fast path for click listeners (which is most often) to avoid
8188 // iterating through props.
8189 patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
8190 }
8191 }
8192 // vnode / directive hooks
8193 let vnodeHooks;
8194 if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
8195 invokeVNodeHook(vnodeHooks, parentComponent, vnode);
8196 }
8197 if (dirs) {
8198 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
8199 }
8200 if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
8201 queueEffectWithSuspense(() => {
8202 vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
8203 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
8204 }, parentSuspense);
8205 }
8206 // children
8207 if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */ &&
8208 // skip if element has innerHTML / textContent
8209 !(props && (props.innerHTML || props.textContent))) {
8210 let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
8211 let hasWarned = false;
8212 while (next) {
8213 hasMismatch = true;
8214 if (!hasWarned) {
8215 warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
8216 `server rendered element contains more child nodes than client vdom.`);
8217 hasWarned = true;
8218 }
8219 // The SSRed DOM contains more nodes than it should. Remove them.
8220 const cur = next;
8221 next = next.nextSibling;
8222 remove(cur);
8223 }
8224 }
8225 else if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8226 if (el.textContent !== vnode.children) {
8227 hasMismatch = true;
8228 warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
8229 `- Client: ${el.textContent}\n` +
8230 `- Server: ${vnode.children}`);
8231 el.textContent = vnode.children;
8232 }
8233 }
8234 }
8235 return el.nextSibling;
8236 };
8237 const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
8238 optimized = optimized || !!parentVNode.dynamicChildren;
8239 const children = parentVNode.children;
8240 const l = children.length;
8241 let hasWarned = false;
8242 for (let i = 0; i < l; i++) {
8243 const vnode = optimized
8244 ? children[i]
8245 : (children[i] = normalizeVNode(children[i]));
8246 if (node) {
8247 node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
8248 }
8249 else if (vnode.type === Text && !vnode.children) {
8250 continue;
8251 }
8252 else {
8253 hasMismatch = true;
8254 if (!hasWarned) {
8255 warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
8256 `server rendered element contains fewer child nodes than client vdom.`);
8257 hasWarned = true;
8258 }
8259 // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
8260 patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
8261 }
8262 }
8263 return node;
8264 };
8265 const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
8266 const { slotScopeIds: fragmentSlotScopeIds } = vnode;
8267 if (fragmentSlotScopeIds) {
8268 slotScopeIds = slotScopeIds
8269 ? slotScopeIds.concat(fragmentSlotScopeIds)
8270 : fragmentSlotScopeIds;
8271 }
8272 const container = parentNode(node);
8273 const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
8274 if (next && isComment(next) && next.data === ']') {
8275 return nextSibling((vnode.anchor = next));
8276 }
8277 else {
8278 // fragment didn't hydrate successfully, since we didn't get a end anchor
8279 // back. This should have led to node/children mismatch warnings.
8280 hasMismatch = true;
8281 // since the anchor is missing, we need to create one and insert it
8282 insert((vnode.anchor = createComment(`]`)), container, next);
8283 return next;
8284 }
8285 };
8286 const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
8287 hasMismatch = true;
8288 warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* DOMNodeTypes.TEXT */
8289 ? `(text)`
8290 : isComment(node) && node.data === '['
8291 ? `(start of fragment)`
8292 : ``);
8293 vnode.el = null;
8294 if (isFragment) {
8295 // remove excessive fragment nodes
8296 const end = locateClosingAsyncAnchor(node);
8297 while (true) {
8298 const next = nextSibling(node);
8299 if (next && next !== end) {
8300 remove(next);
8301 }
8302 else {
8303 break;
8304 }
8305 }
8306 }
8307 const next = nextSibling(node);
8308 const container = parentNode(node);
8309 remove(node);
8310 patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
8311 return next;
8312 };
8313 const locateClosingAsyncAnchor = (node) => {
8314 let match = 0;
8315 while (node) {
8316 node = nextSibling(node);
8317 if (node && isComment(node)) {
8318 if (node.data === '[')
8319 match++;
8320 if (node.data === ']') {
8321 if (match === 0) {
8322 return nextSibling(node);
8323 }
8324 else {
8325 match--;
8326 }
8327 }
8328 }
8329 }
8330 return node;
8331 };
8332 return [hydrate, hydrateNode];
8333}
8334
8335/* eslint-disable no-restricted-globals */
8336let supported;
8337let perf;
8338function startMeasure(instance, type) {
8339 if (instance.appContext.config.performance && isSupported()) {
8340 perf.mark(`vue-${type}-${instance.uid}`);
8341 }
8342 {
8343 devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
8344 }
8345}
8346function endMeasure(instance, type) {
8347 if (instance.appContext.config.performance && isSupported()) {
8348 const startTag = `vue-${type}-${instance.uid}`;
8349 const endTag = startTag + `:end`;
8350 perf.mark(endTag);
8351 perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
8352 perf.clearMarks(startTag);
8353 perf.clearMarks(endTag);
8354 }
8355 {
8356 devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
8357 }
8358}
8359function isSupported() {
8360 if (supported !== undefined) {
8361 return supported;
8362 }
8363 if (typeof window !== 'undefined' && window.performance) {
8364 supported = true;
8365 perf = window.performance;
8366 }
8367 else {
8368 supported = false;
8369 }
8370 return supported;
8371}
8372
8373const queuePostRenderEffect = queueEffectWithSuspense
8374 ;
8375/**
8376 * The createRenderer function accepts two generic arguments:
8377 * HostNode and HostElement, corresponding to Node and Element types in the
8378 * host environment. For example, for runtime-dom, HostNode would be the DOM
8379 * `Node` interface and HostElement would be the DOM `Element` interface.
8380 *
8381 * Custom renderers can pass in the platform specific types like this:
8382 *
8383 * ``` js
8384 * const { render, createApp } = createRenderer<Node, Element>({
8385 * patchProp,
8386 * ...nodeOps
8387 * })
8388 * ```
8389 */
8390function createRenderer(options) {
8391 return baseCreateRenderer(options);
8392}
8393// Separate API for creating hydration-enabled renderer.
8394// Hydration logic is only used when calling this function, making it
8395// tree-shakable.
8396function createHydrationRenderer(options) {
8397 return baseCreateRenderer(options, createHydrationFunctions);
8398}
8399// implementation
8400function baseCreateRenderer(options, createHydrationFns) {
8401 const target = getGlobalThis();
8402 target.__VUE__ = true;
8403 {
8404 setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
8405 }
8406 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;
8407 // Note: functions inside this closure should use `const xxx = () => {}`
8408 // style in order to prevent being inlined by minifiers.
8409 const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
8410 if (n1 === n2) {
8411 return;
8412 }
8413 // patching & not same type, unmount old tree
8414 if (n1 && !isSameVNodeType(n1, n2)) {
8415 anchor = getNextHostNode(n1);
8416 unmount(n1, parentComponent, parentSuspense, true);
8417 n1 = null;
8418 }
8419 if (n2.patchFlag === -2 /* PatchFlags.BAIL */) {
8420 optimized = false;
8421 n2.dynamicChildren = null;
8422 }
8423 const { type, ref, shapeFlag } = n2;
8424 switch (type) {
8425 case Text:
8426 processText(n1, n2, container, anchor);
8427 break;
8428 case Comment:
8429 processCommentNode(n1, n2, container, anchor);
8430 break;
8431 case Static:
8432 if (n1 == null) {
8433 mountStaticNode(n2, container, anchor, isSVG);
8434 }
8435 else {
8436 patchStaticNode(n1, n2, container, isSVG);
8437 }
8438 break;
8439 case Fragment:
8440 processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8441 break;
8442 default:
8443 if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
8444 processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8445 }
8446 else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
8447 processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8448 }
8449 else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
8450 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
8451 }
8452 else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
8453 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
8454 }
8455 else {
8456 warn$1('Invalid VNode type:', type, `(${typeof type})`);
8457 }
8458 }
8459 // set ref
8460 if (ref != null && parentComponent) {
8461 setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
8462 }
8463 };
8464 const processText = (n1, n2, container, anchor) => {
8465 if (n1 == null) {
8466 hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
8467 }
8468 else {
8469 const el = (n2.el = n1.el);
8470 if (n2.children !== n1.children) {
8471 hostSetText(el, n2.children);
8472 }
8473 }
8474 };
8475 const processCommentNode = (n1, n2, container, anchor) => {
8476 if (n1 == null) {
8477 hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
8478 }
8479 else {
8480 // there's no support for dynamic comments
8481 n2.el = n1.el;
8482 }
8483 };
8484 const mountStaticNode = (n2, container, anchor, isSVG) => {
8485 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
8486 };
8487 /**
8488 * Dev / HMR only
8489 */
8490 const patchStaticNode = (n1, n2, container, isSVG) => {
8491 // static nodes are only patched during dev for HMR
8492 if (n2.children !== n1.children) {
8493 const anchor = hostNextSibling(n1.anchor);
8494 // remove existing
8495 removeStaticNode(n1);
8496 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
8497 }
8498 else {
8499 n2.el = n1.el;
8500 n2.anchor = n1.anchor;
8501 }
8502 };
8503 const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
8504 let next;
8505 while (el && el !== anchor) {
8506 next = hostNextSibling(el);
8507 hostInsert(el, container, nextSibling);
8508 el = next;
8509 }
8510 hostInsert(anchor, container, nextSibling);
8511 };
8512 const removeStaticNode = ({ el, anchor }) => {
8513 let next;
8514 while (el && el !== anchor) {
8515 next = hostNextSibling(el);
8516 hostRemove(el);
8517 el = next;
8518 }
8519 hostRemove(anchor);
8520 };
8521 const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8522 isSVG = isSVG || n2.type === 'svg';
8523 if (n1 == null) {
8524 mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8525 }
8526 else {
8527 patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8528 }
8529 };
8530 const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8531 let el;
8532 let vnodeHook;
8533 const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
8534 {
8535 el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8536 // mount children first, since some props may rely on child content
8537 // being already rendered, e.g. `<select value>`
8538 if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8539 hostSetElementText(el, vnode.children);
8540 }
8541 else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8542 mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8543 }
8544 if (dirs) {
8545 invokeDirectiveHook(vnode, null, parentComponent, 'created');
8546 }
8547 // props
8548 if (props) {
8549 for (const key in props) {
8550 if (key !== 'value' && !isReservedProp(key)) {
8551 hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8552 }
8553 }
8554 /**
8555 * Special case for setting value on DOM elements:
8556 * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8557 * - it needs to be forced (#1471)
8558 * #2353 proposes adding another renderer option to configure this, but
8559 * the properties affects are so finite it is worth special casing it
8560 * here to reduce the complexity. (Special casing it also should not
8561 * affect non-DOM renderers)
8562 */
8563 if ('value' in props) {
8564 hostPatchProp(el, 'value', null, props.value);
8565 }
8566 if ((vnodeHook = props.onVnodeBeforeMount)) {
8567 invokeVNodeHook(vnodeHook, parentComponent, vnode);
8568 }
8569 }
8570 // scopeId
8571 setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8572 }
8573 {
8574 Object.defineProperty(el, '__vnode', {
8575 value: vnode,
8576 enumerable: false
8577 });
8578 Object.defineProperty(el, '__vueParentComponent', {
8579 value: parentComponent,
8580 enumerable: false
8581 });
8582 }
8583 if (dirs) {
8584 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
8585 }
8586 // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
8587 // #1689 For inside suspense + suspense resolved case, just call it
8588 const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
8589 transition &&
8590 !transition.persisted;
8591 if (needCallTransitionHooks) {
8592 transition.beforeEnter(el);
8593 }
8594 hostInsert(el, container, anchor);
8595 if ((vnodeHook = props && props.onVnodeMounted) ||
8596 needCallTransitionHooks ||
8597 dirs) {
8598 queuePostRenderEffect(() => {
8599 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
8600 needCallTransitionHooks && transition.enter(el);
8601 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
8602 }, parentSuspense);
8603 }
8604 };
8605 const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
8606 if (scopeId) {
8607 hostSetScopeId(el, scopeId);
8608 }
8609 if (slotScopeIds) {
8610 for (let i = 0; i < slotScopeIds.length; i++) {
8611 hostSetScopeId(el, slotScopeIds[i]);
8612 }
8613 }
8614 if (parentComponent) {
8615 let subTree = parentComponent.subTree;
8616 if (subTree.patchFlag > 0 &&
8617 subTree.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */) {
8618 subTree =
8619 filterSingleRoot(subTree.children) || subTree;
8620 }
8621 if (vnode === subTree) {
8622 const parentVNode = parentComponent.vnode;
8623 setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
8624 }
8625 }
8626 };
8627 const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
8628 for (let i = start; i < children.length; i++) {
8629 const child = (children[i] = optimized
8630 ? cloneIfMounted(children[i])
8631 : normalizeVNode(children[i]));
8632 patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8633 }
8634 };
8635 const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8636 const el = (n2.el = n1.el);
8637 let { patchFlag, dynamicChildren, dirs } = n2;
8638 // #1426 take the old vnode's patch flag into account since user may clone a
8639 // compiler-generated vnode, which de-opts to FULL_PROPS
8640 patchFlag |= n1.patchFlag & 16 /* PatchFlags.FULL_PROPS */;
8641 const oldProps = n1.props || EMPTY_OBJ;
8642 const newProps = n2.props || EMPTY_OBJ;
8643 let vnodeHook;
8644 // disable recurse in beforeUpdate hooks
8645 parentComponent && toggleRecurse(parentComponent, false);
8646 if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
8647 invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
8648 }
8649 if (dirs) {
8650 invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
8651 }
8652 parentComponent && toggleRecurse(parentComponent, true);
8653 if (isHmrUpdating) {
8654 // HMR updated, force full diff
8655 patchFlag = 0;
8656 optimized = false;
8657 dynamicChildren = null;
8658 }
8659 const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
8660 if (dynamicChildren) {
8661 patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
8662 if (parentComponent && parentComponent.type.__hmrId) {
8663 traverseStaticChildren(n1, n2);
8664 }
8665 }
8666 else if (!optimized) {
8667 // full diff
8668 patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
8669 }
8670 if (patchFlag > 0) {
8671 // the presence of a patchFlag means this element's render code was
8672 // generated by the compiler and can take the fast path.
8673 // in this path old node and new node are guaranteed to have the same shape
8674 // (i.e. at the exact same position in the source template)
8675 if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
8676 // element props contain dynamic keys, full diff needed
8677 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
8678 }
8679 else {
8680 // class
8681 // this flag is matched when the element has dynamic class bindings.
8682 if (patchFlag & 2 /* PatchFlags.CLASS */) {
8683 if (oldProps.class !== newProps.class) {
8684 hostPatchProp(el, 'class', null, newProps.class, isSVG);
8685 }
8686 }
8687 // style
8688 // this flag is matched when the element has dynamic style bindings
8689 if (patchFlag & 4 /* PatchFlags.STYLE */) {
8690 hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
8691 }
8692 // props
8693 // This flag is matched when the element has dynamic prop/attr bindings
8694 // other than class and style. The keys of dynamic prop/attrs are saved for
8695 // faster iteration.
8696 // Note dynamic keys like :[foo]="bar" will cause this optimization to
8697 // bail out and go through a full diff because we need to unset the old key
8698 if (patchFlag & 8 /* PatchFlags.PROPS */) {
8699 // if the flag is present then dynamicProps must be non-null
8700 const propsToUpdate = n2.dynamicProps;
8701 for (let i = 0; i < propsToUpdate.length; i++) {
8702 const key = propsToUpdate[i];
8703 const prev = oldProps[key];
8704 const next = newProps[key];
8705 // #1471 force patch value
8706 if (next !== prev || key === 'value') {
8707 hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
8708 }
8709 }
8710 }
8711 }
8712 // text
8713 // This flag is matched when the element has only dynamic text children.
8714 if (patchFlag & 1 /* PatchFlags.TEXT */) {
8715 if (n1.children !== n2.children) {
8716 hostSetElementText(el, n2.children);
8717 }
8718 }
8719 }
8720 else if (!optimized && dynamicChildren == null) {
8721 // unoptimized, full diff
8722 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
8723 }
8724 if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
8725 queuePostRenderEffect(() => {
8726 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
8727 dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
8728 }, parentSuspense);
8729 }
8730 };
8731 // The fast path for blocks.
8732 const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
8733 for (let i = 0; i < newChildren.length; i++) {
8734 const oldVNode = oldChildren[i];
8735 const newVNode = newChildren[i];
8736 // Determine the container (parent element) for the patch.
8737 const container =
8738 // oldVNode may be an errored async setup() component inside Suspense
8739 // which will not have a mounted element
8740 oldVNode.el &&
8741 // - In the case of a Fragment, we need to provide the actual parent
8742 // of the Fragment itself so it can move its children.
8743 (oldVNode.type === Fragment ||
8744 // - In the case of different nodes, there is going to be a replacement
8745 // which also requires the correct parent container
8746 !isSameVNodeType(oldVNode, newVNode) ||
8747 // - In the case of a component, it could contain anything.
8748 oldVNode.shapeFlag & (6 /* ShapeFlags.COMPONENT */ | 64 /* ShapeFlags.TELEPORT */))
8749 ? hostParentNode(oldVNode.el)
8750 : // In other cases, the parent container is not actually used so we
8751 // just pass the block element here to avoid a DOM parentNode call.
8752 fallbackContainer;
8753 patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
8754 }
8755 };
8756 const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
8757 if (oldProps !== newProps) {
8758 for (const key in newProps) {
8759 // empty string is not valid prop
8760 if (isReservedProp(key))
8761 continue;
8762 const next = newProps[key];
8763 const prev = oldProps[key];
8764 // defer patching value
8765 if (next !== prev && key !== 'value') {
8766 hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8767 }
8768 }
8769 if (oldProps !== EMPTY_OBJ) {
8770 for (const key in oldProps) {
8771 if (!isReservedProp(key) && !(key in newProps)) {
8772 hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8773 }
8774 }
8775 }
8776 if ('value' in newProps) {
8777 hostPatchProp(el, 'value', oldProps.value, newProps.value);
8778 }
8779 }
8780 };
8781 const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8782 const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
8783 const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
8784 let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
8785 if (// #5523 dev root fragment may inherit directives
8786 (isHmrUpdating || patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */)) {
8787 // HMR updated / Dev root fragment (w/ comments), force full diff
8788 patchFlag = 0;
8789 optimized = false;
8790 dynamicChildren = null;
8791 }
8792 // check if this is a slot fragment with :slotted scope ids
8793 if (fragmentSlotScopeIds) {
8794 slotScopeIds = slotScopeIds
8795 ? slotScopeIds.concat(fragmentSlotScopeIds)
8796 : fragmentSlotScopeIds;
8797 }
8798 if (n1 == null) {
8799 hostInsert(fragmentStartAnchor, container, anchor);
8800 hostInsert(fragmentEndAnchor, container, anchor);
8801 // a fragment can only have array children
8802 // since they are either generated by the compiler, or implicitly created
8803 // from arrays.
8804 mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8805 }
8806 else {
8807 if (patchFlag > 0 &&
8808 patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */ &&
8809 dynamicChildren &&
8810 // #2715 the previous fragment could've been a BAILed one as a result
8811 // of renderSlot() with no valid children
8812 n1.dynamicChildren) {
8813 // a stable fragment (template root or <template v-for>) doesn't need to
8814 // patch children order, but it may contain dynamicChildren.
8815 patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
8816 if (parentComponent && parentComponent.type.__hmrId) {
8817 traverseStaticChildren(n1, n2);
8818 }
8819 else if (
8820 // #2080 if the stable fragment has a key, it's a <template v-for> that may
8821 // get moved around. Make sure all root level vnodes inherit el.
8822 // #2134 or if it's a component root, it may also get moved around
8823 // as the component is being moved.
8824 n2.key != null ||
8825 (parentComponent && n2 === parentComponent.subTree)) {
8826 traverseStaticChildren(n1, n2, true /* shallow */);
8827 }
8828 }
8829 else {
8830 // keyed / unkeyed, or manual fragments.
8831 // for keyed & unkeyed, since they are compiler generated from v-for,
8832 // each child is guaranteed to be a block so the fragment will never
8833 // have dynamicChildren.
8834 patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
8835 }
8836 }
8837 };
8838 const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8839 n2.slotScopeIds = slotScopeIds;
8840 if (n1 == null) {
8841 if (n2.shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
8842 parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
8843 }
8844 else {
8845 mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
8846 }
8847 }
8848 else {
8849 updateComponent(n1, n2, optimized);
8850 }
8851 };
8852 const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
8853 // 2.x compat may pre-create the component instance before actually
8854 // mounting
8855 const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
8856 const instance = compatMountInstance ||
8857 (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
8858 if (instance.type.__hmrId) {
8859 registerHMR(instance);
8860 }
8861 {
8862 pushWarningContext(initialVNode);
8863 startMeasure(instance, `mount`);
8864 }
8865 // inject renderer internals for keepAlive
8866 if (isKeepAlive(initialVNode)) {
8867 instance.ctx.renderer = internals;
8868 }
8869 // resolve props and slots for setup context
8870 if (!(compatMountInstance)) {
8871 {
8872 startMeasure(instance, `init`);
8873 }
8874 setupComponent(instance);
8875 {
8876 endMeasure(instance, `init`);
8877 }
8878 }
8879 // setup() is async. This component relies on async logic to be resolved
8880 // before proceeding
8881 if (instance.asyncDep) {
8882 parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
8883 // Give it a placeholder if this is not hydration
8884 // TODO handle self-defined fallback
8885 if (!initialVNode.el) {
8886 const placeholder = (instance.subTree = createVNode(Comment));
8887 processCommentNode(null, placeholder, container, anchor);
8888 }
8889 return;
8890 }
8891 setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
8892 {
8893 popWarningContext();
8894 endMeasure(instance, `mount`);
8895 }
8896 };
8897 const updateComponent = (n1, n2, optimized) => {
8898 const instance = (n2.component = n1.component);
8899 if (shouldUpdateComponent(n1, n2, optimized)) {
8900 if (instance.asyncDep &&
8901 !instance.asyncResolved) {
8902 // async & still pending - just update props and slots
8903 // since the component's reactive effect for render isn't set-up yet
8904 {
8905 pushWarningContext(n2);
8906 }
8907 updateComponentPreRender(instance, n2, optimized);
8908 {
8909 popWarningContext();
8910 }
8911 return;
8912 }
8913 else {
8914 // normal update
8915 instance.next = n2;
8916 // in case the child component is also queued, remove it to avoid
8917 // double updating the same child component in the same flush.
8918 invalidateJob(instance.update);
8919 // instance.update is the reactive effect.
8920 instance.update();
8921 }
8922 }
8923 else {
8924 // no update needed. just copy over properties
8925 n2.el = n1.el;
8926 instance.vnode = n2;
8927 }
8928 };
8929 const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
8930 const componentUpdateFn = () => {
8931 if (!instance.isMounted) {
8932 let vnodeHook;
8933 const { el, props } = initialVNode;
8934 const { bm, m, parent } = instance;
8935 const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
8936 toggleRecurse(instance, false);
8937 // beforeMount hook
8938 if (bm) {
8939 invokeArrayFns(bm);
8940 }
8941 // onVnodeBeforeMount
8942 if (!isAsyncWrapperVNode &&
8943 (vnodeHook = props && props.onVnodeBeforeMount)) {
8944 invokeVNodeHook(vnodeHook, parent, initialVNode);
8945 }
8946 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
8947 instance.emit('hook:beforeMount');
8948 }
8949 toggleRecurse(instance, true);
8950 if (el && hydrateNode) {
8951 // vnode has adopted host node - perform hydration instead of mount.
8952 const hydrateSubTree = () => {
8953 {
8954 startMeasure(instance, `render`);
8955 }
8956 instance.subTree = renderComponentRoot(instance);
8957 {
8958 endMeasure(instance, `render`);
8959 }
8960 {
8961 startMeasure(instance, `hydrate`);
8962 }
8963 hydrateNode(el, instance.subTree, instance, parentSuspense, null);
8964 {
8965 endMeasure(instance, `hydrate`);
8966 }
8967 };
8968 if (isAsyncWrapperVNode) {
8969 initialVNode.type.__asyncLoader().then(
8970 // note: we are moving the render call into an async callback,
8971 // which means it won't track dependencies - but it's ok because
8972 // a server-rendered async wrapper is already in resolved state
8973 // and it will never need to change.
8974 () => !instance.isUnmounted && hydrateSubTree());
8975 }
8976 else {
8977 hydrateSubTree();
8978 }
8979 }
8980 else {
8981 {
8982 startMeasure(instance, `render`);
8983 }
8984 const subTree = (instance.subTree = renderComponentRoot(instance));
8985 {
8986 endMeasure(instance, `render`);
8987 }
8988 {
8989 startMeasure(instance, `patch`);
8990 }
8991 patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
8992 {
8993 endMeasure(instance, `patch`);
8994 }
8995 initialVNode.el = subTree.el;
8996 }
8997 // mounted hook
8998 if (m) {
8999 queuePostRenderEffect(m, parentSuspense);
9000 }
9001 // onVnodeMounted
9002 if (!isAsyncWrapperVNode &&
9003 (vnodeHook = props && props.onVnodeMounted)) {
9004 const scopedInitialVNode = initialVNode;
9005 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
9006 }
9007 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
9008 queuePostRenderEffect(() => instance.emit('hook:mounted'), parentSuspense);
9009 }
9010 // activated hook for keep-alive roots.
9011 // #1742 activated hook must be accessed after first render
9012 // since the hook may be injected by a child keep-alive
9013 if (initialVNode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */ ||
9014 (parent &&
9015 isAsyncWrapper(parent.vnode) &&
9016 parent.vnode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */)) {
9017 instance.a && queuePostRenderEffect(instance.a, parentSuspense);
9018 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
9019 queuePostRenderEffect(() => instance.emit('hook:activated'), parentSuspense);
9020 }
9021 }
9022 instance.isMounted = true;
9023 {
9024 devtoolsComponentAdded(instance);
9025 }
9026 // #2458: deference mount-only object parameters to prevent memleaks
9027 initialVNode = container = anchor = null;
9028 }
9029 else {
9030 // updateComponent
9031 // This is triggered by mutation of component's own state (next: null)
9032 // OR parent calling processComponent (next: VNode)
9033 let { next, bu, u, parent, vnode } = instance;
9034 let originNext = next;
9035 let vnodeHook;
9036 {
9037 pushWarningContext(next || instance.vnode);
9038 }
9039 // Disallow component effect recursion during pre-lifecycle hooks.
9040 toggleRecurse(instance, false);
9041 if (next) {
9042 next.el = vnode.el;
9043 updateComponentPreRender(instance, next, optimized);
9044 }
9045 else {
9046 next = vnode;
9047 }
9048 // beforeUpdate hook
9049 if (bu) {
9050 invokeArrayFns(bu);
9051 }
9052 // onVnodeBeforeUpdate
9053 if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
9054 invokeVNodeHook(vnodeHook, parent, next, vnode);
9055 }
9056 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
9057 instance.emit('hook:beforeUpdate');
9058 }
9059 toggleRecurse(instance, true);
9060 // render
9061 {
9062 startMeasure(instance, `render`);
9063 }
9064 const nextTree = renderComponentRoot(instance);
9065 {
9066 endMeasure(instance, `render`);
9067 }
9068 const prevTree = instance.subTree;
9069 instance.subTree = nextTree;
9070 {
9071 startMeasure(instance, `patch`);
9072 }
9073 patch(prevTree, nextTree,
9074 // parent may have changed if it's in a teleport
9075 hostParentNode(prevTree.el),
9076 // anchor may have changed if it's in a fragment
9077 getNextHostNode(prevTree), instance, parentSuspense, isSVG);
9078 {
9079 endMeasure(instance, `patch`);
9080 }
9081 next.el = nextTree.el;
9082 if (originNext === null) {
9083 // self-triggered update. In case of HOC, update parent component
9084 // vnode el. HOC is indicated by parent instance's subTree pointing
9085 // to child component's vnode
9086 updateHOCHostEl(instance, nextTree.el);
9087 }
9088 // updated hook
9089 if (u) {
9090 queuePostRenderEffect(u, parentSuspense);
9091 }
9092 // onVnodeUpdated
9093 if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
9094 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
9095 }
9096 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
9097 queuePostRenderEffect(() => instance.emit('hook:updated'), parentSuspense);
9098 }
9099 {
9100 devtoolsComponentUpdated(instance);
9101 }
9102 {
9103 popWarningContext();
9104 }
9105 }
9106 };
9107 // create reactive effect for rendering
9108 const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
9109 ));
9110 const update = (instance.update = () => effect.run());
9111 update.id = instance.uid;
9112 // allowRecurse
9113 // #1801, #2043 component render effects should allow recursive updates
9114 toggleRecurse(instance, true);
9115 {
9116 effect.onTrack = instance.rtc
9117 ? e => invokeArrayFns(instance.rtc, e)
9118 : void 0;
9119 effect.onTrigger = instance.rtg
9120 ? e => invokeArrayFns(instance.rtg, e)
9121 : void 0;
9122 update.ownerInstance = instance;
9123 }
9124 update();
9125 };
9126 const updateComponentPreRender = (instance, nextVNode, optimized) => {
9127 nextVNode.component = instance;
9128 const prevProps = instance.vnode.props;
9129 instance.vnode = nextVNode;
9130 instance.next = null;
9131 updateProps(instance, nextVNode.props, prevProps, optimized);
9132 updateSlots(instance, nextVNode.children, optimized);
9133 pauseTracking();
9134 // props update may have triggered pre-flush watchers.
9135 // flush them before the render update.
9136 flushPreFlushCbs();
9137 resetTracking();
9138 };
9139 const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
9140 const c1 = n1 && n1.children;
9141 const prevShapeFlag = n1 ? n1.shapeFlag : 0;
9142 const c2 = n2.children;
9143 const { patchFlag, shapeFlag } = n2;
9144 // fast path
9145 if (patchFlag > 0) {
9146 if (patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */) {
9147 // this could be either fully-keyed or mixed (some keyed some not)
9148 // presence of patchFlag means children are guaranteed to be arrays
9149 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9150 return;
9151 }
9152 else if (patchFlag & 256 /* PatchFlags.UNKEYED_FRAGMENT */) {
9153 // unkeyed
9154 patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9155 return;
9156 }
9157 }
9158 // children has 3 possibilities: text, array or no children.
9159 if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
9160 // text children fast path
9161 if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9162 unmountChildren(c1, parentComponent, parentSuspense);
9163 }
9164 if (c2 !== c1) {
9165 hostSetElementText(container, c2);
9166 }
9167 }
9168 else {
9169 if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9170 // prev children was array
9171 if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9172 // two arrays, cannot assume anything, do full diff
9173 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9174 }
9175 else {
9176 // no new children, just unmount old
9177 unmountChildren(c1, parentComponent, parentSuspense, true);
9178 }
9179 }
9180 else {
9181 // prev children was text OR null
9182 // new children is array OR null
9183 if (prevShapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
9184 hostSetElementText(container, '');
9185 }
9186 // mount new if array
9187 if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9188 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9189 }
9190 }
9191 }
9192 };
9193 const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
9194 c1 = c1 || EMPTY_ARR;
9195 c2 = c2 || EMPTY_ARR;
9196 const oldLength = c1.length;
9197 const newLength = c2.length;
9198 const commonLength = Math.min(oldLength, newLength);
9199 let i;
9200 for (i = 0; i < commonLength; i++) {
9201 const nextChild = (c2[i] = optimized
9202 ? cloneIfMounted(c2[i])
9203 : normalizeVNode(c2[i]));
9204 patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9205 }
9206 if (oldLength > newLength) {
9207 // remove old
9208 unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
9209 }
9210 else {
9211 // mount new
9212 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
9213 }
9214 };
9215 // can be all-keyed or mixed
9216 const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
9217 let i = 0;
9218 const l2 = c2.length;
9219 let e1 = c1.length - 1; // prev ending index
9220 let e2 = l2 - 1; // next ending index
9221 // 1. sync from start
9222 // (a b) c
9223 // (a b) d e
9224 while (i <= e1 && i <= e2) {
9225 const n1 = c1[i];
9226 const n2 = (c2[i] = optimized
9227 ? cloneIfMounted(c2[i])
9228 : normalizeVNode(c2[i]));
9229 if (isSameVNodeType(n1, n2)) {
9230 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9231 }
9232 else {
9233 break;
9234 }
9235 i++;
9236 }
9237 // 2. sync from end
9238 // a (b c)
9239 // d e (b c)
9240 while (i <= e1 && i <= e2) {
9241 const n1 = c1[e1];
9242 const n2 = (c2[e2] = optimized
9243 ? cloneIfMounted(c2[e2])
9244 : normalizeVNode(c2[e2]));
9245 if (isSameVNodeType(n1, n2)) {
9246 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9247 }
9248 else {
9249 break;
9250 }
9251 e1--;
9252 e2--;
9253 }
9254 // 3. common sequence + mount
9255 // (a b)
9256 // (a b) c
9257 // i = 2, e1 = 1, e2 = 2
9258 // (a b)
9259 // c (a b)
9260 // i = 0, e1 = -1, e2 = 0
9261 if (i > e1) {
9262 if (i <= e2) {
9263 const nextPos = e2 + 1;
9264 const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
9265 while (i <= e2) {
9266 patch(null, (c2[i] = optimized
9267 ? cloneIfMounted(c2[i])
9268 : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9269 i++;
9270 }
9271 }
9272 }
9273 // 4. common sequence + unmount
9274 // (a b) c
9275 // (a b)
9276 // i = 2, e1 = 2, e2 = 1
9277 // a (b c)
9278 // (b c)
9279 // i = 0, e1 = 0, e2 = -1
9280 else if (i > e2) {
9281 while (i <= e1) {
9282 unmount(c1[i], parentComponent, parentSuspense, true);
9283 i++;
9284 }
9285 }
9286 // 5. unknown sequence
9287 // [i ... e1 + 1]: a b [c d e] f g
9288 // [i ... e2 + 1]: a b [e d c h] f g
9289 // i = 2, e1 = 4, e2 = 5
9290 else {
9291 const s1 = i; // prev starting index
9292 const s2 = i; // next starting index
9293 // 5.1 build key:index map for newChildren
9294 const keyToNewIndexMap = new Map();
9295 for (i = s2; i <= e2; i++) {
9296 const nextChild = (c2[i] = optimized
9297 ? cloneIfMounted(c2[i])
9298 : normalizeVNode(c2[i]));
9299 if (nextChild.key != null) {
9300 if (keyToNewIndexMap.has(nextChild.key)) {
9301 warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
9302 }
9303 keyToNewIndexMap.set(nextChild.key, i);
9304 }
9305 }
9306 // 5.2 loop through old children left to be patched and try to patch
9307 // matching nodes & remove nodes that are no longer present
9308 let j;
9309 let patched = 0;
9310 const toBePatched = e2 - s2 + 1;
9311 let moved = false;
9312 // used to track whether any node has moved
9313 let maxNewIndexSoFar = 0;
9314 // works as Map<newIndex, oldIndex>
9315 // Note that oldIndex is offset by +1
9316 // and oldIndex = 0 is a special value indicating the new node has
9317 // no corresponding old node.
9318 // used for determining longest stable subsequence
9319 const newIndexToOldIndexMap = new Array(toBePatched);
9320 for (i = 0; i < toBePatched; i++)
9321 newIndexToOldIndexMap[i] = 0;
9322 for (i = s1; i <= e1; i++) {
9323 const prevChild = c1[i];
9324 if (patched >= toBePatched) {
9325 // all new children have been patched so this can only be a removal
9326 unmount(prevChild, parentComponent, parentSuspense, true);
9327 continue;
9328 }
9329 let newIndex;
9330 if (prevChild.key != null) {
9331 newIndex = keyToNewIndexMap.get(prevChild.key);
9332 }
9333 else {
9334 // key-less node, try to locate a key-less node of the same type
9335 for (j = s2; j <= e2; j++) {
9336 if (newIndexToOldIndexMap[j - s2] === 0 &&
9337 isSameVNodeType(prevChild, c2[j])) {
9338 newIndex = j;
9339 break;
9340 }
9341 }
9342 }
9343 if (newIndex === undefined) {
9344 unmount(prevChild, parentComponent, parentSuspense, true);
9345 }
9346 else {
9347 newIndexToOldIndexMap[newIndex - s2] = i + 1;
9348 if (newIndex >= maxNewIndexSoFar) {
9349 maxNewIndexSoFar = newIndex;
9350 }
9351 else {
9352 moved = true;
9353 }
9354 patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9355 patched++;
9356 }
9357 }
9358 // 5.3 move and mount
9359 // generate longest stable subsequence only when nodes have moved
9360 const increasingNewIndexSequence = moved
9361 ? getSequence(newIndexToOldIndexMap)
9362 : EMPTY_ARR;
9363 j = increasingNewIndexSequence.length - 1;
9364 // looping backwards so that we can use last patched node as anchor
9365 for (i = toBePatched - 1; i >= 0; i--) {
9366 const nextIndex = s2 + i;
9367 const nextChild = c2[nextIndex];
9368 const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
9369 if (newIndexToOldIndexMap[i] === 0) {
9370 // mount new
9371 patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9372 }
9373 else if (moved) {
9374 // move if:
9375 // There is no stable subsequence (e.g. a reverse)
9376 // OR current node is not among the stable sequence
9377 if (j < 0 || i !== increasingNewIndexSequence[j]) {
9378 move(nextChild, container, anchor, 2 /* MoveType.REORDER */);
9379 }
9380 else {
9381 j--;
9382 }
9383 }
9384 }
9385 }
9386 };
9387 const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
9388 const { el, type, transition, children, shapeFlag } = vnode;
9389 if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
9390 move(vnode.component.subTree, container, anchor, moveType);
9391 return;
9392 }
9393 if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
9394 vnode.suspense.move(container, anchor, moveType);
9395 return;
9396 }
9397 if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
9398 type.move(vnode, container, anchor, internals);
9399 return;
9400 }
9401 if (type === Fragment) {
9402 hostInsert(el, container, anchor);
9403 for (let i = 0; i < children.length; i++) {
9404 move(children[i], container, anchor, moveType);
9405 }
9406 hostInsert(vnode.anchor, container, anchor);
9407 return;
9408 }
9409 if (type === Static) {
9410 moveStaticNode(vnode, container, anchor);
9411 return;
9412 }
9413 // single nodes
9414 const needTransition = moveType !== 2 /* MoveType.REORDER */ &&
9415 shapeFlag & 1 /* ShapeFlags.ELEMENT */ &&
9416 transition;
9417 if (needTransition) {
9418 if (moveType === 0 /* MoveType.ENTER */) {
9419 transition.beforeEnter(el);
9420 hostInsert(el, container, anchor);
9421 queuePostRenderEffect(() => transition.enter(el), parentSuspense);
9422 }
9423 else {
9424 const { leave, delayLeave, afterLeave } = transition;
9425 const remove = () => hostInsert(el, container, anchor);
9426 const performLeave = () => {
9427 leave(el, () => {
9428 remove();
9429 afterLeave && afterLeave();
9430 });
9431 };
9432 if (delayLeave) {
9433 delayLeave(el, remove, performLeave);
9434 }
9435 else {
9436 performLeave();
9437 }
9438 }
9439 }
9440 else {
9441 hostInsert(el, container, anchor);
9442 }
9443 };
9444 const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
9445 const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
9446 // unset ref
9447 if (ref != null) {
9448 setRef(ref, null, parentSuspense, vnode, true);
9449 }
9450 if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
9451 parentComponent.ctx.deactivate(vnode);
9452 return;
9453 }
9454 const shouldInvokeDirs = shapeFlag & 1 /* ShapeFlags.ELEMENT */ && dirs;
9455 const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
9456 let vnodeHook;
9457 if (shouldInvokeVnodeHook &&
9458 (vnodeHook = props && props.onVnodeBeforeUnmount)) {
9459 invokeVNodeHook(vnodeHook, parentComponent, vnode);
9460 }
9461 if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
9462 unmountComponent(vnode.component, parentSuspense, doRemove);
9463 }
9464 else {
9465 if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
9466 vnode.suspense.unmount(parentSuspense, doRemove);
9467 return;
9468 }
9469 if (shouldInvokeDirs) {
9470 invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
9471 }
9472 if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
9473 vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
9474 }
9475 else if (dynamicChildren &&
9476 // #1153: fast path should not be taken for non-stable (v-for) fragments
9477 (type !== Fragment ||
9478 (patchFlag > 0 && patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */))) {
9479 // fast path for block nodes: only need to unmount dynamic children.
9480 unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
9481 }
9482 else if ((type === Fragment &&
9483 patchFlag &
9484 (128 /* PatchFlags.KEYED_FRAGMENT */ | 256 /* PatchFlags.UNKEYED_FRAGMENT */)) ||
9485 (!optimized && shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */)) {
9486 unmountChildren(children, parentComponent, parentSuspense);
9487 }
9488 if (doRemove) {
9489 remove(vnode);
9490 }
9491 }
9492 if ((shouldInvokeVnodeHook &&
9493 (vnodeHook = props && props.onVnodeUnmounted)) ||
9494 shouldInvokeDirs) {
9495 queuePostRenderEffect(() => {
9496 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
9497 shouldInvokeDirs &&
9498 invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
9499 }, parentSuspense);
9500 }
9501 };
9502 const remove = vnode => {
9503 const { type, el, anchor, transition } = vnode;
9504 if (type === Fragment) {
9505 if (vnode.patchFlag > 0 &&
9506 vnode.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */ &&
9507 transition &&
9508 !transition.persisted) {
9509 vnode.children.forEach(child => {
9510 if (child.type === Comment) {
9511 hostRemove(child.el);
9512 }
9513 else {
9514 remove(child);
9515 }
9516 });
9517 }
9518 else {
9519 removeFragment(el, anchor);
9520 }
9521 return;
9522 }
9523 if (type === Static) {
9524 removeStaticNode(vnode);
9525 return;
9526 }
9527 const performRemove = () => {
9528 hostRemove(el);
9529 if (transition && !transition.persisted && transition.afterLeave) {
9530 transition.afterLeave();
9531 }
9532 };
9533 if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ &&
9534 transition &&
9535 !transition.persisted) {
9536 const { leave, delayLeave } = transition;
9537 const performLeave = () => leave(el, performRemove);
9538 if (delayLeave) {
9539 delayLeave(vnode.el, performRemove, performLeave);
9540 }
9541 else {
9542 performLeave();
9543 }
9544 }
9545 else {
9546 performRemove();
9547 }
9548 };
9549 const removeFragment = (cur, end) => {
9550 // For fragments, directly remove all contained DOM nodes.
9551 // (fragment child nodes cannot have transition)
9552 let next;
9553 while (cur !== end) {
9554 next = hostNextSibling(cur);
9555 hostRemove(cur);
9556 cur = next;
9557 }
9558 hostRemove(end);
9559 };
9560 const unmountComponent = (instance, parentSuspense, doRemove) => {
9561 if (instance.type.__hmrId) {
9562 unregisterHMR(instance);
9563 }
9564 const { bum, scope, update, subTree, um } = instance;
9565 // beforeUnmount hook
9566 if (bum) {
9567 invokeArrayFns(bum);
9568 }
9569 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
9570 instance.emit('hook:beforeDestroy');
9571 }
9572 // stop effects in component scope
9573 scope.stop();
9574 // update may be null if a component is unmounted before its async
9575 // setup has resolved.
9576 if (update) {
9577 // so that scheduler will no longer invoke it
9578 update.active = false;
9579 unmount(subTree, instance, parentSuspense, doRemove);
9580 }
9581 // unmounted hook
9582 if (um) {
9583 queuePostRenderEffect(um, parentSuspense);
9584 }
9585 if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */, instance)) {
9586 queuePostRenderEffect(() => instance.emit('hook:destroyed'), parentSuspense);
9587 }
9588 queuePostRenderEffect(() => {
9589 instance.isUnmounted = true;
9590 }, parentSuspense);
9591 // A component with async dep inside a pending suspense is unmounted before
9592 // its async dep resolves. This should remove the dep from the suspense, and
9593 // cause the suspense to resolve immediately if that was the last dep.
9594 if (parentSuspense &&
9595 parentSuspense.pendingBranch &&
9596 !parentSuspense.isUnmounted &&
9597 instance.asyncDep &&
9598 !instance.asyncResolved &&
9599 instance.suspenseId === parentSuspense.pendingId) {
9600 parentSuspense.deps--;
9601 if (parentSuspense.deps === 0) {
9602 parentSuspense.resolve();
9603 }
9604 }
9605 {
9606 devtoolsComponentRemoved(instance);
9607 }
9608 };
9609 const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
9610 for (let i = start; i < children.length; i++) {
9611 unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
9612 }
9613 };
9614 const getNextHostNode = vnode => {
9615 if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
9616 return getNextHostNode(vnode.component.subTree);
9617 }
9618 if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
9619 return vnode.suspense.next();
9620 }
9621 return hostNextSibling((vnode.anchor || vnode.el));
9622 };
9623 const render = (vnode, container, isSVG) => {
9624 if (vnode == null) {
9625 if (container._vnode) {
9626 unmount(container._vnode, null, null, true);
9627 }
9628 }
9629 else {
9630 patch(container._vnode || null, vnode, container, null, null, null, isSVG);
9631 }
9632 flushPreFlushCbs();
9633 flushPostFlushCbs();
9634 container._vnode = vnode;
9635 };
9636 const internals = {
9637 p: patch,
9638 um: unmount,
9639 m: move,
9640 r: remove,
9641 mt: mountComponent,
9642 mc: mountChildren,
9643 pc: patchChildren,
9644 pbc: patchBlockChildren,
9645 n: getNextHostNode,
9646 o: options
9647 };
9648 let hydrate;
9649 let hydrateNode;
9650 if (createHydrationFns) {
9651 [hydrate, hydrateNode] = createHydrationFns(internals);
9652 }
9653 return {
9654 render,
9655 hydrate,
9656 createApp: createAppAPI(render, hydrate)
9657 };
9658}
9659function toggleRecurse({ effect, update }, allowed) {
9660 effect.allowRecurse = update.allowRecurse = allowed;
9661}
9662/**
9663 * #1156
9664 * When a component is HMR-enabled, we need to make sure that all static nodes
9665 * inside a block also inherit the DOM element from the previous tree so that
9666 * HMR updates (which are full updates) can retrieve the element for patching.
9667 *
9668 * #2080
9669 * Inside keyed `template` fragment static children, if a fragment is moved,
9670 * the children will always be moved. Therefore, in order to ensure correct move
9671 * position, el should be inherited from previous nodes.
9672 */
9673function traverseStaticChildren(n1, n2, shallow = false) {
9674 const ch1 = n1.children;
9675 const ch2 = n2.children;
9676 if (isArray(ch1) && isArray(ch2)) {
9677 for (let i = 0; i < ch1.length; i++) {
9678 // this is only called in the optimized path so array children are
9679 // guaranteed to be vnodes
9680 const c1 = ch1[i];
9681 let c2 = ch2[i];
9682 if (c2.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && !c2.dynamicChildren) {
9683 if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) {
9684 c2 = ch2[i] = cloneIfMounted(ch2[i]);
9685 c2.el = c1.el;
9686 }
9687 if (!shallow)
9688 traverseStaticChildren(c1, c2);
9689 }
9690 // also inherit for comment nodes, but not placeholders (e.g. v-if which
9691 // would have received .el during block patch)
9692 if (c2.type === Comment && !c2.el) {
9693 c2.el = c1.el;
9694 }
9695 }
9696 }
9697}
9698// https://en.wikipedia.org/wiki/Longest_increasing_subsequence
9699function getSequence(arr) {
9700 const p = arr.slice();
9701 const result = [0];
9702 let i, j, u, v, c;
9703 const len = arr.length;
9704 for (i = 0; i < len; i++) {
9705 const arrI = arr[i];
9706 if (arrI !== 0) {
9707 j = result[result.length - 1];
9708 if (arr[j] < arrI) {
9709 p[i] = j;
9710 result.push(i);
9711 continue;
9712 }
9713 u = 0;
9714 v = result.length - 1;
9715 while (u < v) {
9716 c = (u + v) >> 1;
9717 if (arr[result[c]] < arrI) {
9718 u = c + 1;
9719 }
9720 else {
9721 v = c;
9722 }
9723 }
9724 if (arrI < arr[result[u]]) {
9725 if (u > 0) {
9726 p[i] = result[u - 1];
9727 }
9728 result[u] = i;
9729 }
9730 }
9731 }
9732 u = result.length;
9733 v = result[u - 1];
9734 while (u-- > 0) {
9735 result[u] = v;
9736 v = p[v];
9737 }
9738 return result;
9739}
9740
9741const isTeleport = (type) => type.__isTeleport;
9742const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
9743const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
9744const resolveTarget = (props, select) => {
9745 const targetSelector = props && props.to;
9746 if (isString(targetSelector)) {
9747 if (!select) {
9748 warn$1(`Current renderer does not support string target for Teleports. ` +
9749 `(missing querySelector renderer option)`);
9750 return null;
9751 }
9752 else {
9753 const target = select(targetSelector);
9754 if (!target) {
9755 warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
9756 `Note the target element must exist before the component is mounted - ` +
9757 `i.e. the target cannot be rendered by the component itself, and ` +
9758 `ideally should be outside of the entire Vue component tree.`);
9759 }
9760 return target;
9761 }
9762 }
9763 else {
9764 if (!targetSelector && !isTeleportDisabled(props)) {
9765 warn$1(`Invalid Teleport target: ${targetSelector}`);
9766 }
9767 return targetSelector;
9768 }
9769};
9770const TeleportImpl = {
9771 __isTeleport: true,
9772 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9773 const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
9774 const disabled = isTeleportDisabled(n2.props);
9775 let { shapeFlag, children, dynamicChildren } = n2;
9776 // #3302
9777 // HMR updated, force full diff
9778 if (isHmrUpdating) {
9779 optimized = false;
9780 dynamicChildren = null;
9781 }
9782 if (n1 == null) {
9783 // insert anchors in the main view
9784 const placeholder = (n2.el = createComment('teleport start')
9785 );
9786 const mainAnchor = (n2.anchor = createComment('teleport end')
9787 );
9788 insert(placeholder, container, anchor);
9789 insert(mainAnchor, container, anchor);
9790 const target = (n2.target = resolveTarget(n2.props, querySelector));
9791 const targetAnchor = (n2.targetAnchor = createText(''));
9792 if (target) {
9793 insert(targetAnchor, target);
9794 // #2652 we could be teleporting from a non-SVG tree into an SVG tree
9795 isSVG = isSVG || isTargetSVG(target);
9796 }
9797 else if (!disabled) {
9798 warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
9799 }
9800 const mount = (container, anchor) => {
9801 // Teleport *always* has Array children. This is enforced in both the
9802 // compiler and vnode children normalization.
9803 if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9804 mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
9805 }
9806 };
9807 if (disabled) {
9808 mount(container, mainAnchor);
9809 }
9810 else if (target) {
9811 mount(target, targetAnchor);
9812 }
9813 }
9814 else {
9815 // update content
9816 n2.el = n1.el;
9817 const mainAnchor = (n2.anchor = n1.anchor);
9818 const target = (n2.target = n1.target);
9819 const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
9820 const wasDisabled = isTeleportDisabled(n1.props);
9821 const currentContainer = wasDisabled ? container : target;
9822 const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
9823 isSVG = isSVG || isTargetSVG(target);
9824 if (dynamicChildren) {
9825 // fast path when the teleport happens to be a block root
9826 patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
9827 // even in block tree mode we need to make sure all root-level nodes
9828 // in the teleport inherit previous DOM references so that they can
9829 // be moved in future patches.
9830 traverseStaticChildren(n1, n2, true);
9831 }
9832 else if (!optimized) {
9833 patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
9834 }
9835 if (disabled) {
9836 if (!wasDisabled) {
9837 // enabled -> disabled
9838 // move into main container
9839 moveTeleport(n2, container, mainAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
9840 }
9841 }
9842 else {
9843 // target changed
9844 if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
9845 const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
9846 if (nextTarget) {
9847 moveTeleport(n2, nextTarget, null, internals, 0 /* TeleportMoveTypes.TARGET_CHANGE */);
9848 }
9849 else {
9850 warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
9851 }
9852 }
9853 else if (wasDisabled) {
9854 // disabled -> enabled
9855 // move into teleport target
9856 moveTeleport(n2, target, targetAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
9857 }
9858 }
9859 }
9860 },
9861 remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
9862 const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
9863 if (target) {
9864 hostRemove(targetAnchor);
9865 }
9866 // an unmounted teleport should always remove its children if not disabled
9867 if (doRemove || !isTeleportDisabled(props)) {
9868 hostRemove(anchor);
9869 if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9870 for (let i = 0; i < children.length; i++) {
9871 const child = children[i];
9872 unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
9873 }
9874 }
9875 }
9876 },
9877 move: moveTeleport,
9878 hydrate: hydrateTeleport
9879};
9880function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* TeleportMoveTypes.REORDER */) {
9881 // move target anchor if this is a target change.
9882 if (moveType === 0 /* TeleportMoveTypes.TARGET_CHANGE */) {
9883 insert(vnode.targetAnchor, container, parentAnchor);
9884 }
9885 const { el, anchor, shapeFlag, children, props } = vnode;
9886 const isReorder = moveType === 2 /* TeleportMoveTypes.REORDER */;
9887 // move main view anchor if this is a re-order.
9888 if (isReorder) {
9889 insert(el, container, parentAnchor);
9890 }
9891 // if this is a re-order and teleport is enabled (content is in target)
9892 // do not move children. So the opposite is: only move children if this
9893 // is not a reorder, or the teleport is disabled
9894 if (!isReorder || isTeleportDisabled(props)) {
9895 // Teleport has either Array children or no children.
9896 if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9897 for (let i = 0; i < children.length; i++) {
9898 move(children[i], container, parentAnchor, 2 /* MoveType.REORDER */);
9899 }
9900 }
9901 }
9902 // move main view anchor if this is a re-order.
9903 if (isReorder) {
9904 insert(anchor, container, parentAnchor);
9905 }
9906}
9907function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
9908 const target = (vnode.target = resolveTarget(vnode.props, querySelector));
9909 if (target) {
9910 // if multiple teleports rendered to the same target element, we need to
9911 // pick up from where the last teleport finished instead of the first node
9912 const targetNode = target._lpa || target.firstChild;
9913 if (vnode.shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
9914 if (isTeleportDisabled(vnode.props)) {
9915 vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
9916 vnode.targetAnchor = targetNode;
9917 }
9918 else {
9919 vnode.anchor = nextSibling(node);
9920 // lookahead until we find the target anchor
9921 // we cannot rely on return value of hydrateChildren() because there
9922 // could be nested teleports
9923 let targetAnchor = targetNode;
9924 while (targetAnchor) {
9925 targetAnchor = nextSibling(targetAnchor);
9926 if (targetAnchor &&
9927 targetAnchor.nodeType === 8 &&
9928 targetAnchor.data === 'teleport anchor') {
9929 vnode.targetAnchor = targetAnchor;
9930 target._lpa =
9931 vnode.targetAnchor && nextSibling(vnode.targetAnchor);
9932 break;
9933 }
9934 }
9935 hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9936 }
9937 }
9938 }
9939 return vnode.anchor && nextSibling(vnode.anchor);
9940}
9941// Force-casted public typing for h and TSX props inference
9942const Teleport = TeleportImpl;
9943
9944const normalizedAsyncComponentMap = new Map();
9945function convertLegacyAsyncComponent(comp) {
9946 if (normalizedAsyncComponentMap.has(comp)) {
9947 return normalizedAsyncComponentMap.get(comp);
9948 }
9949 // we have to call the function here due to how v2's API won't expose the
9950 // options until we call it
9951 let resolve;
9952 let reject;
9953 const fallbackPromise = new Promise((r, rj) => {
9954 (resolve = r), (reject = rj);
9955 });
9956 const res = comp(resolve, reject);
9957 let converted;
9958 if (isPromise(res)) {
9959 converted = defineAsyncComponent(() => res);
9960 }
9961 else if (isObject(res) && !isVNode(res) && !isArray(res)) {
9962 converted = defineAsyncComponent({
9963 loader: () => res.component,
9964 loadingComponent: res.loading,
9965 errorComponent: res.error,
9966 delay: res.delay,
9967 timeout: res.timeout
9968 });
9969 }
9970 else if (res == null) {
9971 converted = defineAsyncComponent(() => fallbackPromise);
9972 }
9973 else {
9974 converted = comp; // probably a v3 functional comp
9975 }
9976 normalizedAsyncComponentMap.set(comp, converted);
9977 return converted;
9978}
9979
9980function convertLegacyComponent(comp, instance) {
9981 if (comp.__isBuiltIn) {
9982 return comp;
9983 }
9984 // 2.x constructor
9985 if (isFunction(comp) && comp.cid) {
9986 comp = comp.options;
9987 }
9988 // 2.x async component
9989 if (isFunction(comp) &&
9990 checkCompatEnabled("COMPONENT_ASYNC" /* DeprecationTypes.COMPONENT_ASYNC */, instance, comp)) {
9991 // since after disabling this, plain functions are still valid usage, do not
9992 // use softAssert here.
9993 return convertLegacyAsyncComponent(comp);
9994 }
9995 // 2.x functional component
9996 if (isObject(comp) &&
9997 comp.functional &&
9998 softAssertCompatEnabled("COMPONENT_FUNCTIONAL" /* DeprecationTypes.COMPONENT_FUNCTIONAL */, instance, comp)) {
9999 return convertLegacyFunctionalComponent(comp);
10000 }
10001 return comp;
10002}
10003
10004const Fragment = Symbol('Fragment' );
10005const Text = Symbol('Text' );
10006const Comment = Symbol('Comment' );
10007const Static = Symbol('Static' );
10008// Since v-if and v-for are the two possible ways node structure can dynamically
10009// change, once we consider v-if branches and each v-for fragment a block, we
10010// can divide a template into nested blocks, and within each block the node
10011// structure would be stable. This allows us to skip most children diffing
10012// and only worry about the dynamic nodes (indicated by patch flags).
10013const blockStack = [];
10014let currentBlock = null;
10015/**
10016 * Open a block.
10017 * This must be called before `createBlock`. It cannot be part of `createBlock`
10018 * because the children of the block are evaluated before `createBlock` itself
10019 * is called. The generated code typically looks like this:
10020 *
10021 * ```js
10022 * function render() {
10023 * return (openBlock(),createBlock('div', null, [...]))
10024 * }
10025 * ```
10026 * disableTracking is true when creating a v-for fragment block, since a v-for
10027 * fragment always diffs its children.
10028 *
10029 * @private
10030 */
10031function openBlock(disableTracking = false) {
10032 blockStack.push((currentBlock = disableTracking ? null : []));
10033}
10034function closeBlock() {
10035 blockStack.pop();
10036 currentBlock = blockStack[blockStack.length - 1] || null;
10037}
10038// Whether we should be tracking dynamic child nodes inside a block.
10039// Only tracks when this value is > 0
10040// We are not using a simple boolean because this value may need to be
10041// incremented/decremented by nested usage of v-once (see below)
10042let isBlockTreeEnabled = 1;
10043/**
10044 * Block tracking sometimes needs to be disabled, for example during the
10045 * creation of a tree that needs to be cached by v-once. The compiler generates
10046 * code like this:
10047 *
10048 * ``` js
10049 * _cache[1] || (
10050 * setBlockTracking(-1),
10051 * _cache[1] = createVNode(...),
10052 * setBlockTracking(1),
10053 * _cache[1]
10054 * )
10055 * ```
10056 *
10057 * @private
10058 */
10059function setBlockTracking(value) {
10060 isBlockTreeEnabled += value;
10061}
10062function setupBlock(vnode) {
10063 // save current block children on the block vnode
10064 vnode.dynamicChildren =
10065 isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
10066 // close block
10067 closeBlock();
10068 // a block is always going to be patched, so track it as a child of its
10069 // parent block
10070 if (isBlockTreeEnabled > 0 && currentBlock) {
10071 currentBlock.push(vnode);
10072 }
10073 return vnode;
10074}
10075/**
10076 * @private
10077 */
10078function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
10079 return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
10080}
10081/**
10082 * Create a block root vnode. Takes the same exact arguments as `createVNode`.
10083 * A block root keeps track of dynamic nodes within the block in the
10084 * `dynamicChildren` array.
10085 *
10086 * @private
10087 */
10088function createBlock(type, props, children, patchFlag, dynamicProps) {
10089 return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
10090}
10091function isVNode(value) {
10092 return value ? value.__v_isVNode === true : false;
10093}
10094function isSameVNodeType(n1, n2) {
10095 if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
10096 hmrDirtyComponents.has(n2.type)) {
10097 // HMR only: if the component has been hot-updated, force a reload.
10098 return false;
10099 }
10100 return n1.type === n2.type && n1.key === n2.key;
10101}
10102let vnodeArgsTransformer;
10103/**
10104 * Internal API for registering an arguments transform for createVNode
10105 * used for creating stubs in the test-utils
10106 * It is *internal* but needs to be exposed for test-utils to pick up proper
10107 * typings
10108 */
10109function transformVNodeArgs(transformer) {
10110 vnodeArgsTransformer = transformer;
10111}
10112const createVNodeWithArgsTransform = (...args) => {
10113 return _createVNode(...(vnodeArgsTransformer
10114 ? vnodeArgsTransformer(args, currentRenderingInstance)
10115 : args));
10116};
10117const InternalObjectKey = `__vInternal`;
10118const normalizeKey = ({ key }) => key != null ? key : null;
10119const normalizeRef = ({ ref, ref_key, ref_for }) => {
10120 return (ref != null
10121 ? isString(ref) || isRef(ref) || isFunction(ref)
10122 ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
10123 : ref
10124 : null);
10125};
10126function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ShapeFlags.ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
10127 const vnode = {
10128 __v_isVNode: true,
10129 __v_skip: true,
10130 type,
10131 props,
10132 key: props && normalizeKey(props),
10133 ref: props && normalizeRef(props),
10134 scopeId: currentScopeId,
10135 slotScopeIds: null,
10136 children,
10137 component: null,
10138 suspense: null,
10139 ssContent: null,
10140 ssFallback: null,
10141 dirs: null,
10142 transition: null,
10143 el: null,
10144 anchor: null,
10145 target: null,
10146 targetAnchor: null,
10147 staticCount: 0,
10148 shapeFlag,
10149 patchFlag,
10150 dynamicProps,
10151 dynamicChildren: null,
10152 appContext: null
10153 };
10154 if (needFullChildrenNormalization) {
10155 normalizeChildren(vnode, children);
10156 // normalize suspense children
10157 if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
10158 type.normalize(vnode);
10159 }
10160 }
10161 else if (children) {
10162 // compiled element vnode - if children is passed, only possible types are
10163 // string or Array.
10164 vnode.shapeFlag |= isString(children)
10165 ? 8 /* ShapeFlags.TEXT_CHILDREN */
10166 : 16 /* ShapeFlags.ARRAY_CHILDREN */;
10167 }
10168 // validate key
10169 if (vnode.key !== vnode.key) {
10170 warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
10171 }
10172 // track vnode for block tree
10173 if (isBlockTreeEnabled > 0 &&
10174 // avoid a block node from tracking itself
10175 !isBlockNode &&
10176 // has current parent block
10177 currentBlock &&
10178 // presence of a patch flag indicates this node needs patching on updates.
10179 // component nodes also should always be patched, because even if the
10180 // component doesn't need to update, it needs to persist the instance on to
10181 // the next vnode so that it can be properly unmounted later.
10182 (vnode.patchFlag > 0 || shapeFlag & 6 /* ShapeFlags.COMPONENT */) &&
10183 // the EVENTS flag is only for hydration and if it is the only flag, the
10184 // vnode should not be considered dynamic due to handler caching.
10185 vnode.patchFlag !== 32 /* PatchFlags.HYDRATE_EVENTS */) {
10186 currentBlock.push(vnode);
10187 }
10188 {
10189 convertLegacyVModelProps(vnode);
10190 defineLegacyVNodeProperties(vnode);
10191 }
10192 return vnode;
10193}
10194const createVNode = (createVNodeWithArgsTransform );
10195function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
10196 if (!type || type === NULL_DYNAMIC_COMPONENT) {
10197 if (!type) {
10198 warn$1(`Invalid vnode type when creating vnode: ${type}.`);
10199 }
10200 type = Comment;
10201 }
10202 if (isVNode(type)) {
10203 // createVNode receiving an existing vnode. This happens in cases like
10204 // <component :is="vnode"/>
10205 // #2078 make sure to merge refs during the clone instead of overwriting it
10206 const cloned = cloneVNode(type, props, true /* mergeRef: true */);
10207 if (children) {
10208 normalizeChildren(cloned, children);
10209 }
10210 if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
10211 if (cloned.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
10212 currentBlock[currentBlock.indexOf(type)] = cloned;
10213 }
10214 else {
10215 currentBlock.push(cloned);
10216 }
10217 }
10218 cloned.patchFlag |= -2 /* PatchFlags.BAIL */;
10219 return cloned;
10220 }
10221 // class component normalization.
10222 if (isClassComponent(type)) {
10223 type = type.__vccOpts;
10224 }
10225 // 2.x async/functional component compat
10226 {
10227 type = convertLegacyComponent(type, currentRenderingInstance);
10228 }
10229 // class & style normalization.
10230 if (props) {
10231 // for reactive or proxy objects, we need to clone it to enable mutation.
10232 props = guardReactiveProps(props);
10233 let { class: klass, style } = props;
10234 if (klass && !isString(klass)) {
10235 props.class = normalizeClass(klass);
10236 }
10237 if (isObject(style)) {
10238 // reactive state objects need to be cloned since they are likely to be
10239 // mutated
10240 if (isProxy(style) && !isArray(style)) {
10241 style = extend({}, style);
10242 }
10243 props.style = normalizeStyle(style);
10244 }
10245 }
10246 // encode the vnode type information into a bitmap
10247 const shapeFlag = isString(type)
10248 ? 1 /* ShapeFlags.ELEMENT */
10249 : isSuspense(type)
10250 ? 128 /* ShapeFlags.SUSPENSE */
10251 : isTeleport(type)
10252 ? 64 /* ShapeFlags.TELEPORT */
10253 : isObject(type)
10254 ? 4 /* ShapeFlags.STATEFUL_COMPONENT */
10255 : isFunction(type)
10256 ? 2 /* ShapeFlags.FUNCTIONAL_COMPONENT */
10257 : 0;
10258 if (shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */ && isProxy(type)) {
10259 type = toRaw(type);
10260 warn$1(`Vue received a Component which was made a reactive object. This can ` +
10261 `lead to unnecessary performance overhead, and should be avoided by ` +
10262 `marking the component with \`markRaw\` or using \`shallowRef\` ` +
10263 `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
10264 }
10265 return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
10266}
10267function guardReactiveProps(props) {
10268 if (!props)
10269 return null;
10270 return isProxy(props) || InternalObjectKey in props
10271 ? extend({}, props)
10272 : props;
10273}
10274function cloneVNode(vnode, extraProps, mergeRef = false) {
10275 // This is intentionally NOT using spread or extend to avoid the runtime
10276 // key enumeration cost.
10277 const { props, ref, patchFlag, children } = vnode;
10278 const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
10279 const cloned = {
10280 __v_isVNode: true,
10281 __v_skip: true,
10282 type: vnode.type,
10283 props: mergedProps,
10284 key: mergedProps && normalizeKey(mergedProps),
10285 ref: extraProps && extraProps.ref
10286 ? // #2078 in the case of <component :is="vnode" ref="extra"/>
10287 // if the vnode itself already has a ref, cloneVNode will need to merge
10288 // the refs so the single vnode can be set on multiple refs
10289 mergeRef && ref
10290 ? isArray(ref)
10291 ? ref.concat(normalizeRef(extraProps))
10292 : [ref, normalizeRef(extraProps)]
10293 : normalizeRef(extraProps)
10294 : ref,
10295 scopeId: vnode.scopeId,
10296 slotScopeIds: vnode.slotScopeIds,
10297 children: patchFlag === -1 /* PatchFlags.HOISTED */ && isArray(children)
10298 ? children.map(deepCloneVNode)
10299 : children,
10300 target: vnode.target,
10301 targetAnchor: vnode.targetAnchor,
10302 staticCount: vnode.staticCount,
10303 shapeFlag: vnode.shapeFlag,
10304 // if the vnode is cloned with extra props, we can no longer assume its
10305 // existing patch flag to be reliable and need to add the FULL_PROPS flag.
10306 // note: preserve flag for fragments since they use the flag for children
10307 // fast paths only.
10308 patchFlag: extraProps && vnode.type !== Fragment
10309 ? patchFlag === -1 // hoisted node
10310 ? 16 /* PatchFlags.FULL_PROPS */
10311 : patchFlag | 16 /* PatchFlags.FULL_PROPS */
10312 : patchFlag,
10313 dynamicProps: vnode.dynamicProps,
10314 dynamicChildren: vnode.dynamicChildren,
10315 appContext: vnode.appContext,
10316 dirs: vnode.dirs,
10317 transition: vnode.transition,
10318 // These should technically only be non-null on mounted VNodes. However,
10319 // they *should* be copied for kept-alive vnodes. So we just always copy
10320 // them since them being non-null during a mount doesn't affect the logic as
10321 // they will simply be overwritten.
10322 component: vnode.component,
10323 suspense: vnode.suspense,
10324 ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
10325 ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
10326 el: vnode.el,
10327 anchor: vnode.anchor
10328 };
10329 {
10330 defineLegacyVNodeProperties(cloned);
10331 }
10332 return cloned;
10333}
10334/**
10335 * Dev only, for HMR of hoisted vnodes reused in v-for
10336 * https://github.com/vitejs/vite/issues/2022
10337 */
10338function deepCloneVNode(vnode) {
10339 const cloned = cloneVNode(vnode);
10340 if (isArray(vnode.children)) {
10341 cloned.children = vnode.children.map(deepCloneVNode);
10342 }
10343 return cloned;
10344}
10345/**
10346 * @private
10347 */
10348function createTextVNode(text = ' ', flag = 0) {
10349 return createVNode(Text, null, text, flag);
10350}
10351/**
10352 * @private
10353 */
10354function createStaticVNode(content, numberOfNodes) {
10355 // A static vnode can contain multiple stringified elements, and the number
10356 // of elements is necessary for hydration.
10357 const vnode = createVNode(Static, null, content);
10358 vnode.staticCount = numberOfNodes;
10359 return vnode;
10360}
10361/**
10362 * @private
10363 */
10364function createCommentVNode(text = '',
10365// when used as the v-else branch, the comment node must be created as a
10366// block to ensure correct updates.
10367asBlock = false) {
10368 return asBlock
10369 ? (openBlock(), createBlock(Comment, null, text))
10370 : createVNode(Comment, null, text);
10371}
10372function normalizeVNode(child) {
10373 if (child == null || typeof child === 'boolean') {
10374 // empty placeholder
10375 return createVNode(Comment);
10376 }
10377 else if (isArray(child)) {
10378 // fragment
10379 return createVNode(Fragment, null,
10380 // #3666, avoid reference pollution when reusing vnode
10381 child.slice());
10382 }
10383 else if (typeof child === 'object') {
10384 // already vnode, this should be the most common since compiled templates
10385 // always produce all-vnode children arrays
10386 return cloneIfMounted(child);
10387 }
10388 else {
10389 // strings and numbers
10390 return createVNode(Text, null, String(child));
10391 }
10392}
10393// optimized normalization for template-compiled render fns
10394function cloneIfMounted(child) {
10395 return child.el === null || child.memo ? child : cloneVNode(child);
10396}
10397function normalizeChildren(vnode, children) {
10398 let type = 0;
10399 const { shapeFlag } = vnode;
10400 if (children == null) {
10401 children = null;
10402 }
10403 else if (isArray(children)) {
10404 type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
10405 }
10406 else if (typeof children === 'object') {
10407 if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 64 /* ShapeFlags.TELEPORT */)) {
10408 // Normalize slot to plain children for plain element and Teleport
10409 const slot = children.default;
10410 if (slot) {
10411 // _c marker is added by withCtx() indicating this is a compiled slot
10412 slot._c && (slot._d = false);
10413 normalizeChildren(vnode, slot());
10414 slot._c && (slot._d = true);
10415 }
10416 return;
10417 }
10418 else {
10419 type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
10420 const slotFlag = children._;
10421 if (!slotFlag && !(InternalObjectKey in children)) {
10422 children._ctx = currentRenderingInstance;
10423 }
10424 else if (slotFlag === 3 /* SlotFlags.FORWARDED */ && currentRenderingInstance) {
10425 // a child component receives forwarded slots from the parent.
10426 // its slot type is determined by its parent's slot type.
10427 if (currentRenderingInstance.slots._ === 1 /* SlotFlags.STABLE */) {
10428 children._ = 1 /* SlotFlags.STABLE */;
10429 }
10430 else {
10431 children._ = 2 /* SlotFlags.DYNAMIC */;
10432 vnode.patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
10433 }
10434 }
10435 }
10436 }
10437 else if (isFunction(children)) {
10438 children = { default: children, _ctx: currentRenderingInstance };
10439 type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
10440 }
10441 else {
10442 children = String(children);
10443 // force teleport children to array so it can be moved around
10444 if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
10445 type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
10446 children = [createTextVNode(children)];
10447 }
10448 else {
10449 type = 8 /* ShapeFlags.TEXT_CHILDREN */;
10450 }
10451 }
10452 vnode.children = children;
10453 vnode.shapeFlag |= type;
10454}
10455function mergeProps(...args) {
10456 const ret = {};
10457 for (let i = 0; i < args.length; i++) {
10458 const toMerge = args[i];
10459 for (const key in toMerge) {
10460 if (key === 'class') {
10461 if (ret.class !== toMerge.class) {
10462 ret.class = normalizeClass([ret.class, toMerge.class]);
10463 }
10464 }
10465 else if (key === 'style') {
10466 ret.style = normalizeStyle([ret.style, toMerge.style]);
10467 }
10468 else if (isOn(key)) {
10469 const existing = ret[key];
10470 const incoming = toMerge[key];
10471 if (incoming &&
10472 existing !== incoming &&
10473 !(isArray(existing) && existing.includes(incoming))) {
10474 ret[key] = existing
10475 ? [].concat(existing, incoming)
10476 : incoming;
10477 }
10478 }
10479 else if (key !== '') {
10480 ret[key] = toMerge[key];
10481 }
10482 }
10483 }
10484 return ret;
10485}
10486function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
10487 callWithAsyncErrorHandling(hook, instance, 7 /* ErrorCodes.VNODE_HOOK */, [
10488 vnode,
10489 prevVNode
10490 ]);
10491}
10492
10493const emptyAppContext = createAppContext();
10494let uid$1 = 0;
10495function createComponentInstance(vnode, parent, suspense) {
10496 const type = vnode.type;
10497 // inherit parent app context - or - if root, adopt from root vnode
10498 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
10499 const instance = {
10500 uid: uid$1++,
10501 vnode,
10502 type,
10503 parent,
10504 appContext,
10505 root: null,
10506 next: null,
10507 subTree: null,
10508 effect: null,
10509 update: null,
10510 scope: new EffectScope(true /* detached */),
10511 render: null,
10512 proxy: null,
10513 exposed: null,
10514 exposeProxy: null,
10515 withProxy: null,
10516 provides: parent ? parent.provides : Object.create(appContext.provides),
10517 accessCache: null,
10518 renderCache: [],
10519 // local resolved assets
10520 components: null,
10521 directives: null,
10522 // resolved props and emits options
10523 propsOptions: normalizePropsOptions(type, appContext),
10524 emitsOptions: normalizeEmitsOptions(type, appContext),
10525 // emit
10526 emit: null,
10527 emitted: null,
10528 // props default value
10529 propsDefaults: EMPTY_OBJ,
10530 // inheritAttrs
10531 inheritAttrs: type.inheritAttrs,
10532 // state
10533 ctx: EMPTY_OBJ,
10534 data: EMPTY_OBJ,
10535 props: EMPTY_OBJ,
10536 attrs: EMPTY_OBJ,
10537 slots: EMPTY_OBJ,
10538 refs: EMPTY_OBJ,
10539 setupState: EMPTY_OBJ,
10540 setupContext: null,
10541 // suspense related
10542 suspense,
10543 suspenseId: suspense ? suspense.pendingId : 0,
10544 asyncDep: null,
10545 asyncResolved: false,
10546 // lifecycle hooks
10547 // not using enums here because it results in computed properties
10548 isMounted: false,
10549 isUnmounted: false,
10550 isDeactivated: false,
10551 bc: null,
10552 c: null,
10553 bm: null,
10554 m: null,
10555 bu: null,
10556 u: null,
10557 um: null,
10558 bum: null,
10559 da: null,
10560 a: null,
10561 rtg: null,
10562 rtc: null,
10563 ec: null,
10564 sp: null
10565 };
10566 {
10567 instance.ctx = createDevRenderContext(instance);
10568 }
10569 instance.root = parent ? parent.root : instance;
10570 instance.emit = emit$2.bind(null, instance);
10571 // apply custom element special handling
10572 if (vnode.ce) {
10573 vnode.ce(instance);
10574 }
10575 return instance;
10576}
10577let currentInstance = null;
10578const getCurrentInstance = () => currentInstance || currentRenderingInstance;
10579const setCurrentInstance = (instance) => {
10580 currentInstance = instance;
10581 instance.scope.on();
10582};
10583const unsetCurrentInstance = () => {
10584 currentInstance && currentInstance.scope.off();
10585 currentInstance = null;
10586};
10587const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
10588function validateComponentName(name, config) {
10589 const appIsNativeTag = config.isNativeTag || NO;
10590 if (isBuiltInTag(name) || appIsNativeTag(name)) {
10591 warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
10592 }
10593}
10594function isStatefulComponent(instance) {
10595 return instance.vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */;
10596}
10597let isInSSRComponentSetup = false;
10598function setupComponent(instance, isSSR = false) {
10599 isInSSRComponentSetup = isSSR;
10600 const { props, children } = instance.vnode;
10601 const isStateful = isStatefulComponent(instance);
10602 initProps(instance, props, isStateful, isSSR);
10603 initSlots(instance, children);
10604 const setupResult = isStateful
10605 ? setupStatefulComponent(instance, isSSR)
10606 : undefined;
10607 isInSSRComponentSetup = false;
10608 return setupResult;
10609}
10610function setupStatefulComponent(instance, isSSR) {
10611 var _a;
10612 const Component = instance.type;
10613 {
10614 if (Component.name) {
10615 validateComponentName(Component.name, instance.appContext.config);
10616 }
10617 if (Component.components) {
10618 const names = Object.keys(Component.components);
10619 for (let i = 0; i < names.length; i++) {
10620 validateComponentName(names[i], instance.appContext.config);
10621 }
10622 }
10623 if (Component.directives) {
10624 const names = Object.keys(Component.directives);
10625 for (let i = 0; i < names.length; i++) {
10626 validateDirectiveName(names[i]);
10627 }
10628 }
10629 if (Component.compilerOptions && isRuntimeOnly()) {
10630 warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
10631 `includes the runtime compiler. Since you are using a runtime-only ` +
10632 `build, the options should be passed via your build tool config instead.`);
10633 }
10634 }
10635 // 0. create render proxy property access cache
10636 instance.accessCache = Object.create(null);
10637 // 1. create public instance / render proxy
10638 // also mark it raw so it's never observed
10639 instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
10640 {
10641 exposePropsOnRenderContext(instance);
10642 }
10643 // 2. call setup()
10644 const { setup } = Component;
10645 if (setup) {
10646 const setupContext = (instance.setupContext =
10647 setup.length > 1 ? createSetupContext(instance) : null);
10648 setCurrentInstance(instance);
10649 pauseTracking();
10650 const setupResult = callWithErrorHandling(setup, instance, 0 /* ErrorCodes.SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
10651 resetTracking();
10652 unsetCurrentInstance();
10653 if (isPromise(setupResult)) {
10654 setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
10655 if (isSSR) {
10656 // return the promise so server-renderer can wait on it
10657 return setupResult
10658 .then((resolvedResult) => {
10659 handleSetupResult(instance, resolvedResult, isSSR);
10660 })
10661 .catch(e => {
10662 handleError(e, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
10663 });
10664 }
10665 else {
10666 // async setup returned Promise.
10667 // bail here and wait for re-entry.
10668 instance.asyncDep = setupResult;
10669 if (!instance.suspense) {
10670 const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
10671 warn$1(`Component <${name}>: setup function returned a promise, but no ` +
10672 `<Suspense> boundary was found in the parent component tree. ` +
10673 `A component with async setup() must be nested in a <Suspense> ` +
10674 `in order to be rendered.`);
10675 }
10676 }
10677 }
10678 else {
10679 handleSetupResult(instance, setupResult, isSSR);
10680 }
10681 }
10682 else {
10683 finishComponentSetup(instance, isSSR);
10684 }
10685}
10686function handleSetupResult(instance, setupResult, isSSR) {
10687 if (isFunction(setupResult)) {
10688 // setup returned an inline render function
10689 if (instance.type.__ssrInlineRender) {
10690 // when the function's name is `ssrRender` (compiled by SFC inline mode),
10691 // set it as ssrRender instead.
10692 instance.ssrRender = setupResult;
10693 }
10694 else {
10695 instance.render = setupResult;
10696 }
10697 }
10698 else if (isObject(setupResult)) {
10699 if (isVNode(setupResult)) {
10700 warn$1(`setup() should not return VNodes directly - ` +
10701 `return a render function instead.`);
10702 }
10703 // setup returned bindings.
10704 // assuming a render function compiled from template is present.
10705 {
10706 instance.devtoolsRawSetupState = setupResult;
10707 }
10708 instance.setupState = proxyRefs(setupResult);
10709 {
10710 exposeSetupStateOnRenderContext(instance);
10711 }
10712 }
10713 else if (setupResult !== undefined) {
10714 warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
10715 }
10716 finishComponentSetup(instance, isSSR);
10717}
10718let compile;
10719let installWithProxy;
10720/**
10721 * For runtime-dom to register the compiler.
10722 * Note the exported method uses any to avoid d.ts relying on the compiler types.
10723 */
10724function registerRuntimeCompiler(_compile) {
10725 compile = _compile;
10726 installWithProxy = i => {
10727 if (i.render._rc) {
10728 i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
10729 }
10730 };
10731}
10732// dev only
10733const isRuntimeOnly = () => !compile;
10734function finishComponentSetup(instance, isSSR, skipOptions) {
10735 const Component = instance.type;
10736 {
10737 convertLegacyRenderFn(instance);
10738 if (Component.compatConfig) {
10739 validateCompatConfig(Component.compatConfig);
10740 }
10741 }
10742 // template / render function normalization
10743 // could be already set when returned from setup()
10744 if (!instance.render) {
10745 // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
10746 // is done by server-renderer
10747 if (!isSSR && compile && !Component.render) {
10748 const template = (instance.vnode.props &&
10749 instance.vnode.props['inline-template']) ||
10750 Component.template;
10751 if (template) {
10752 {
10753 startMeasure(instance, `compile`);
10754 }
10755 const { isCustomElement, compilerOptions } = instance.appContext.config;
10756 const { delimiters, compilerOptions: componentCompilerOptions } = Component;
10757 const finalCompilerOptions = extend(extend({
10758 isCustomElement,
10759 delimiters
10760 }, compilerOptions), componentCompilerOptions);
10761 {
10762 // pass runtime compat config into the compiler
10763 finalCompilerOptions.compatConfig = Object.create(globalCompatConfig);
10764 if (Component.compatConfig) {
10765 // @ts-expect-error types are not compatible
10766 extend(finalCompilerOptions.compatConfig, Component.compatConfig);
10767 }
10768 }
10769 Component.render = compile(template, finalCompilerOptions);
10770 {
10771 endMeasure(instance, `compile`);
10772 }
10773 }
10774 }
10775 instance.render = (Component.render || NOOP);
10776 // for runtime-compiled render functions using `with` blocks, the render
10777 // proxy used needs a different `has` handler which is more performant and
10778 // also only allows a whitelist of globals to fallthrough.
10779 if (installWithProxy) {
10780 installWithProxy(instance);
10781 }
10782 }
10783 // support for 2.x options
10784 if (!(skipOptions)) {
10785 setCurrentInstance(instance);
10786 pauseTracking();
10787 applyOptions(instance);
10788 resetTracking();
10789 unsetCurrentInstance();
10790 }
10791 // warn missing template/render
10792 // the runtime compilation of template in SSR is done by server-render
10793 if (!Component.render && instance.render === NOOP && !isSSR) {
10794 /* istanbul ignore if */
10795 if (!compile && Component.template) {
10796 warn$1(`Component provided template option but ` +
10797 `runtime compilation is not supported in this build of Vue.` +
10798 (``) /* should not happen */);
10799 }
10800 else {
10801 warn$1(`Component is missing template or render function.`);
10802 }
10803 }
10804}
10805function createAttrsProxy(instance) {
10806 return new Proxy(instance.attrs, {
10807 get(target, key) {
10808 markAttrsAccessed();
10809 track(instance, "get" /* TrackOpTypes.GET */, '$attrs');
10810 return target[key];
10811 },
10812 set() {
10813 warn$1(`setupContext.attrs is readonly.`);
10814 return false;
10815 },
10816 deleteProperty() {
10817 warn$1(`setupContext.attrs is readonly.`);
10818 return false;
10819 }
10820 }
10821 );
10822}
10823function createSetupContext(instance) {
10824 const expose = exposed => {
10825 if (instance.exposed) {
10826 warn$1(`expose() should be called only once per setup().`);
10827 }
10828 instance.exposed = exposed || {};
10829 };
10830 let attrs;
10831 {
10832 // We use getters in dev in case libs like test-utils overwrite instance
10833 // properties (overwrites should not be done in prod)
10834 return Object.freeze({
10835 get attrs() {
10836 return attrs || (attrs = createAttrsProxy(instance));
10837 },
10838 get slots() {
10839 return shallowReadonly(instance.slots);
10840 },
10841 get emit() {
10842 return (event, ...args) => instance.emit(event, ...args);
10843 },
10844 expose
10845 });
10846 }
10847}
10848function getExposeProxy(instance) {
10849 if (instance.exposed) {
10850 return (instance.exposeProxy ||
10851 (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
10852 get(target, key) {
10853 if (key in target) {
10854 return target[key];
10855 }
10856 else if (key in publicPropertiesMap) {
10857 return publicPropertiesMap[key](instance);
10858 }
10859 }
10860 })));
10861 }
10862}
10863const classifyRE = /(?:^|[-_])(\w)/g;
10864const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
10865function getComponentName(Component, includeInferred = true) {
10866 return isFunction(Component)
10867 ? Component.displayName || Component.name
10868 : Component.name || (includeInferred && Component.__name);
10869}
10870/* istanbul ignore next */
10871function formatComponentName(instance, Component, isRoot = false) {
10872 let name = getComponentName(Component);
10873 if (!name && Component.__file) {
10874 const match = Component.__file.match(/([^/\\]+)\.\w+$/);
10875 if (match) {
10876 name = match[1];
10877 }
10878 }
10879 if (!name && instance && instance.parent) {
10880 // try to infer the name based on reverse resolution
10881 const inferFromRegistry = (registry) => {
10882 for (const key in registry) {
10883 if (registry[key] === Component) {
10884 return key;
10885 }
10886 }
10887 };
10888 name =
10889 inferFromRegistry(instance.components ||
10890 instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
10891 }
10892 return name ? classify(name) : isRoot ? `App` : `Anonymous`;
10893}
10894function isClassComponent(value) {
10895 return isFunction(value) && '__vccOpts' in value;
10896}
10897
10898const computed$1 = ((getterOrOptions, debugOptions) => {
10899 // @ts-ignore
10900 return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
10901});
10902
10903// dev only
10904const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
10905 `<script setup> of a single file component. Its arguments should be ` +
10906 `compiled away and passing it at runtime has no effect.`);
10907// implementation
10908function defineProps() {
10909 {
10910 warnRuntimeUsage(`defineProps`);
10911 }
10912 return null;
10913}
10914// implementation
10915function defineEmits() {
10916 {
10917 warnRuntimeUsage(`defineEmits`);
10918 }
10919 return null;
10920}
10921/**
10922 * Vue `<script setup>` compiler macro for declaring a component's exposed
10923 * instance properties when it is accessed by a parent component via template
10924 * refs.
10925 *
10926 * `<script setup>` components are closed by default - i.e. variables inside
10927 * the `<script setup>` scope is not exposed to parent unless explicitly exposed
10928 * via `defineExpose`.
10929 *
10930 * This is only usable inside `<script setup>`, is compiled away in the
10931 * output and should **not** be actually called at runtime.
10932 */
10933function defineExpose(exposed) {
10934 {
10935 warnRuntimeUsage(`defineExpose`);
10936 }
10937}
10938/**
10939 * Vue `<script setup>` compiler macro for providing props default values when
10940 * using type-based `defineProps` declaration.
10941 *
10942 * Example usage:
10943 * ```ts
10944 * withDefaults(defineProps<{
10945 * size?: number
10946 * labels?: string[]
10947 * }>(), {
10948 * size: 3,
10949 * labels: () => ['default label']
10950 * })
10951 * ```
10952 *
10953 * This is only usable inside `<script setup>`, is compiled away in the output
10954 * and should **not** be actually called at runtime.
10955 */
10956function withDefaults(props, defaults) {
10957 {
10958 warnRuntimeUsage(`withDefaults`);
10959 }
10960 return null;
10961}
10962function useSlots() {
10963 return getContext().slots;
10964}
10965function useAttrs() {
10966 return getContext().attrs;
10967}
10968function getContext() {
10969 const i = getCurrentInstance();
10970 if (!i) {
10971 warn$1(`useContext() called without active instance.`);
10972 }
10973 return i.setupContext || (i.setupContext = createSetupContext(i));
10974}
10975/**
10976 * Runtime helper for merging default declarations. Imported by compiled code
10977 * only.
10978 * @internal
10979 */
10980function mergeDefaults(raw, defaults) {
10981 const props = isArray(raw)
10982 ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
10983 : raw;
10984 for (const key in defaults) {
10985 const opt = props[key];
10986 if (opt) {
10987 if (isArray(opt) || isFunction(opt)) {
10988 props[key] = { type: opt, default: defaults[key] };
10989 }
10990 else {
10991 opt.default = defaults[key];
10992 }
10993 }
10994 else if (opt === null) {
10995 props[key] = { default: defaults[key] };
10996 }
10997 else {
10998 warn$1(`props default key "${key}" has no corresponding declaration.`);
10999 }
11000 }
11001 return props;
11002}
11003/**
11004 * Used to create a proxy for the rest element when destructuring props with
11005 * defineProps().
11006 * @internal
11007 */
11008function createPropsRestProxy(props, excludedKeys) {
11009 const ret = {};
11010 for (const key in props) {
11011 if (!excludedKeys.includes(key)) {
11012 Object.defineProperty(ret, key, {
11013 enumerable: true,
11014 get: () => props[key]
11015 });
11016 }
11017 }
11018 return ret;
11019}
11020/**
11021 * `<script setup>` helper for persisting the current instance context over
11022 * async/await flows.
11023 *
11024 * `@vue/compiler-sfc` converts the following:
11025 *
11026 * ```ts
11027 * const x = await foo()
11028 * ```
11029 *
11030 * into:
11031 *
11032 * ```ts
11033 * let __temp, __restore
11034 * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
11035 * ```
11036 * @internal
11037 */
11038function withAsyncContext(getAwaitable) {
11039 const ctx = getCurrentInstance();
11040 if (!ctx) {
11041 warn$1(`withAsyncContext called without active current instance. ` +
11042 `This is likely a bug.`);
11043 }
11044 let awaitable = getAwaitable();
11045 unsetCurrentInstance();
11046 if (isPromise(awaitable)) {
11047 awaitable = awaitable.catch(e => {
11048 setCurrentInstance(ctx);
11049 throw e;
11050 });
11051 }
11052 return [awaitable, () => setCurrentInstance(ctx)];
11053}
11054
11055// Actual implementation
11056function h(type, propsOrChildren, children) {
11057 const l = arguments.length;
11058 if (l === 2) {
11059 if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
11060 // single vnode without props
11061 if (isVNode(propsOrChildren)) {
11062 return createVNode(type, null, [propsOrChildren]);
11063 }
11064 // props without children
11065 return createVNode(type, propsOrChildren);
11066 }
11067 else {
11068 // omit props
11069 return createVNode(type, null, propsOrChildren);
11070 }
11071 }
11072 else {
11073 if (l > 3) {
11074 children = Array.prototype.slice.call(arguments, 2);
11075 }
11076 else if (l === 3 && isVNode(children)) {
11077 children = [children];
11078 }
11079 return createVNode(type, propsOrChildren, children);
11080 }
11081}
11082
11083const ssrContextKey = Symbol(`ssrContext` );
11084const useSSRContext = () => {
11085 {
11086 const ctx = inject(ssrContextKey);
11087 if (!ctx) {
11088 warn$1(`Server rendering context not provided. Make sure to only call ` +
11089 `useSSRContext() conditionally in the server build.`);
11090 }
11091 return ctx;
11092 }
11093};
11094
11095function initCustomFormatter() {
11096 /* eslint-disable no-restricted-globals */
11097 if (typeof window === 'undefined') {
11098 return;
11099 }
11100 const vueStyle = { style: 'color:#3ba776' };
11101 const numberStyle = { style: 'color:#0b1bc9' };
11102 const stringStyle = { style: 'color:#b62e24' };
11103 const keywordStyle = { style: 'color:#9d288c' };
11104 // custom formatter for Chrome
11105 // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
11106 const formatter = {
11107 header(obj) {
11108 // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
11109 if (!isObject(obj)) {
11110 return null;
11111 }
11112 if (obj.__isVue) {
11113 return ['div', vueStyle, `VueInstance`];
11114 }
11115 else if (isRef(obj)) {
11116 return [
11117 'div',
11118 {},
11119 ['span', vueStyle, genRefFlag(obj)],
11120 '<',
11121 formatValue(obj.value),
11122 `>`
11123 ];
11124 }
11125 else if (isReactive(obj)) {
11126 return [
11127 'div',
11128 {},
11129 ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
11130 '<',
11131 formatValue(obj),
11132 `>${isReadonly(obj) ? ` (readonly)` : ``}`
11133 ];
11134 }
11135 else if (isReadonly(obj)) {
11136 return [
11137 'div',
11138 {},
11139 ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
11140 '<',
11141 formatValue(obj),
11142 '>'
11143 ];
11144 }
11145 return null;
11146 },
11147 hasBody(obj) {
11148 return obj && obj.__isVue;
11149 },
11150 body(obj) {
11151 if (obj && obj.__isVue) {
11152 return [
11153 'div',
11154 {},
11155 ...formatInstance(obj.$)
11156 ];
11157 }
11158 }
11159 };
11160 function formatInstance(instance) {
11161 const blocks = [];
11162 if (instance.type.props && instance.props) {
11163 blocks.push(createInstanceBlock('props', toRaw(instance.props)));
11164 }
11165 if (instance.setupState !== EMPTY_OBJ) {
11166 blocks.push(createInstanceBlock('setup', instance.setupState));
11167 }
11168 if (instance.data !== EMPTY_OBJ) {
11169 blocks.push(createInstanceBlock('data', toRaw(instance.data)));
11170 }
11171 const computed = extractKeys(instance, 'computed');
11172 if (computed) {
11173 blocks.push(createInstanceBlock('computed', computed));
11174 }
11175 const injected = extractKeys(instance, 'inject');
11176 if (injected) {
11177 blocks.push(createInstanceBlock('injected', injected));
11178 }
11179 blocks.push([
11180 'div',
11181 {},
11182 [
11183 'span',
11184 {
11185 style: keywordStyle.style + ';opacity:0.66'
11186 },
11187 '$ (internal): '
11188 ],
11189 ['object', { object: instance }]
11190 ]);
11191 return blocks;
11192 }
11193 function createInstanceBlock(type, target) {
11194 target = extend({}, target);
11195 if (!Object.keys(target).length) {
11196 return ['span', {}];
11197 }
11198 return [
11199 'div',
11200 { style: 'line-height:1.25em;margin-bottom:0.6em' },
11201 [
11202 'div',
11203 {
11204 style: 'color:#476582'
11205 },
11206 type
11207 ],
11208 [
11209 'div',
11210 {
11211 style: 'padding-left:1.25em'
11212 },
11213 ...Object.keys(target).map(key => {
11214 return [
11215 'div',
11216 {},
11217 ['span', keywordStyle, key + ': '],
11218 formatValue(target[key], false)
11219 ];
11220 })
11221 ]
11222 ];
11223 }
11224 function formatValue(v, asRaw = true) {
11225 if (typeof v === 'number') {
11226 return ['span', numberStyle, v];
11227 }
11228 else if (typeof v === 'string') {
11229 return ['span', stringStyle, JSON.stringify(v)];
11230 }
11231 else if (typeof v === 'boolean') {
11232 return ['span', keywordStyle, v];
11233 }
11234 else if (isObject(v)) {
11235 return ['object', { object: asRaw ? toRaw(v) : v }];
11236 }
11237 else {
11238 return ['span', stringStyle, String(v)];
11239 }
11240 }
11241 function extractKeys(instance, type) {
11242 const Comp = instance.type;
11243 if (isFunction(Comp)) {
11244 return;
11245 }
11246 const extracted = {};
11247 for (const key in instance.ctx) {
11248 if (isKeyOfType(Comp, key, type)) {
11249 extracted[key] = instance.ctx[key];
11250 }
11251 }
11252 return extracted;
11253 }
11254 function isKeyOfType(Comp, key, type) {
11255 const opts = Comp[type];
11256 if ((isArray(opts) && opts.includes(key)) ||
11257 (isObject(opts) && key in opts)) {
11258 return true;
11259 }
11260 if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
11261 return true;
11262 }
11263 if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
11264 return true;
11265 }
11266 }
11267 function genRefFlag(v) {
11268 if (isShallow(v)) {
11269 return `ShallowRef`;
11270 }
11271 if (v.effect) {
11272 return `ComputedRef`;
11273 }
11274 return `Ref`;
11275 }
11276 if (window.devtoolsFormatters) {
11277 window.devtoolsFormatters.push(formatter);
11278 }
11279 else {
11280 window.devtoolsFormatters = [formatter];
11281 }
11282}
11283
11284function withMemo(memo, render, cache, index) {
11285 const cached = cache[index];
11286 if (cached && isMemoSame(cached, memo)) {
11287 return cached;
11288 }
11289 const ret = render();
11290 // shallow clone
11291 ret.memo = memo.slice();
11292 return (cache[index] = ret);
11293}
11294function isMemoSame(cached, memo) {
11295 const prev = cached.memo;
11296 if (prev.length != memo.length) {
11297 return false;
11298 }
11299 for (let i = 0; i < prev.length; i++) {
11300 if (hasChanged(prev[i], memo[i])) {
11301 return false;
11302 }
11303 }
11304 // make sure to let parent block track it when returning cached
11305 if (isBlockTreeEnabled > 0 && currentBlock) {
11306 currentBlock.push(cached);
11307 }
11308 return true;
11309}
11310
11311// Core API ------------------------------------------------------------------
11312const version = "3.2.38";
11313const _ssrUtils = {
11314 createComponentInstance,
11315 setupComponent,
11316 renderComponentRoot,
11317 setCurrentRenderingInstance,
11318 isVNode,
11319 normalizeVNode
11320};
11321/**
11322 * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11323 * @internal
11324 */
11325const ssrUtils = (_ssrUtils );
11326/**
11327 * @internal only exposed in compat builds
11328 */
11329const resolveFilter$1 = resolveFilter ;
11330const _compatUtils = {
11331 warnDeprecation,
11332 createCompatVue,
11333 isCompatEnabled,
11334 checkCompatEnabled,
11335 softAssertCompatEnabled
11336};
11337/**
11338 * @internal only exposed in compat builds.
11339 */
11340const compatUtils = (_compatUtils );
11341
11342const svgNS = 'http://www.w3.org/2000/svg';
11343const doc = (typeof document !== 'undefined' ? document : null);
11344const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
11345const nodeOps = {
11346 insert: (child, parent, anchor) => {
11347 parent.insertBefore(child, anchor || null);
11348 },
11349 remove: child => {
11350 const parent = child.parentNode;
11351 if (parent) {
11352 parent.removeChild(child);
11353 }
11354 },
11355 createElement: (tag, isSVG, is, props) => {
11356 const el = isSVG
11357 ? doc.createElementNS(svgNS, tag)
11358 : doc.createElement(tag, is ? { is } : undefined);
11359 if (tag === 'select' && props && props.multiple != null) {
11360 el.setAttribute('multiple', props.multiple);
11361 }
11362 return el;
11363 },
11364 createText: text => doc.createTextNode(text),
11365 createComment: text => doc.createComment(text),
11366 setText: (node, text) => {
11367 node.nodeValue = text;
11368 },
11369 setElementText: (el, text) => {
11370 el.textContent = text;
11371 },
11372 parentNode: node => node.parentNode,
11373 nextSibling: node => node.nextSibling,
11374 querySelector: selector => doc.querySelector(selector),
11375 setScopeId(el, id) {
11376 el.setAttribute(id, '');
11377 },
11378 cloneNode(el) {
11379 const cloned = el.cloneNode(true);
11380 // #3072
11381 // - in `patchDOMProp`, we store the actual value in the `el._value` property.
11382 // - normally, elements using `:value` bindings will not be hoisted, but if
11383 // the bound value is a constant, e.g. `:value="true"` - they do get
11384 // hoisted.
11385 // - in production, hoisted nodes are cloned when subsequent inserts, but
11386 // cloneNode() does not copy the custom property we attached.
11387 // - This may need to account for other custom DOM properties we attach to
11388 // elements in addition to `_value` in the future.
11389 if (`_value` in el) {
11390 cloned._value = el._value;
11391 }
11392 return cloned;
11393 },
11394 // __UNSAFE__
11395 // Reason: innerHTML.
11396 // Static content here can only come from compiled templates.
11397 // As long as the user only uses trusted templates, this is safe.
11398 insertStaticContent(content, parent, anchor, isSVG, start, end) {
11399 // <parent> before | first ... last | anchor </parent>
11400 const before = anchor ? anchor.previousSibling : parent.lastChild;
11401 // #5308 can only take cached path if:
11402 // - has a single root node
11403 // - nextSibling info is still available
11404 if (start && (start === end || start.nextSibling)) {
11405 // cached
11406 while (true) {
11407 parent.insertBefore(start.cloneNode(true), anchor);
11408 if (start === end || !(start = start.nextSibling))
11409 break;
11410 }
11411 }
11412 else {
11413 // fresh insert
11414 templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
11415 const template = templateContainer.content;
11416 if (isSVG) {
11417 // remove outer svg wrapper
11418 const wrapper = template.firstChild;
11419 while (wrapper.firstChild) {
11420 template.appendChild(wrapper.firstChild);
11421 }
11422 template.removeChild(wrapper);
11423 }
11424 parent.insertBefore(template, anchor);
11425 }
11426 return [
11427 // first
11428 before ? before.nextSibling : parent.firstChild,
11429 // last
11430 anchor ? anchor.previousSibling : parent.lastChild
11431 ];
11432 }
11433};
11434
11435// compiler should normalize class + :class bindings on the same element
11436// into a single binding ['staticClass', dynamic]
11437function patchClass(el, value, isSVG) {
11438 // directly setting className should be faster than setAttribute in theory
11439 // if this is an element during a transition, take the temporary transition
11440 // classes into account.
11441 const transitionClasses = el._vtc;
11442 if (transitionClasses) {
11443 value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
11444 }
11445 if (value == null) {
11446 el.removeAttribute('class');
11447 }
11448 else if (isSVG) {
11449 el.setAttribute('class', value);
11450 }
11451 else {
11452 el.className = value;
11453 }
11454}
11455
11456function patchStyle(el, prev, next) {
11457 const style = el.style;
11458 const isCssString = isString(next);
11459 if (next && !isCssString) {
11460 for (const key in next) {
11461 setStyle(style, key, next[key]);
11462 }
11463 if (prev && !isString(prev)) {
11464 for (const key in prev) {
11465 if (next[key] == null) {
11466 setStyle(style, key, '');
11467 }
11468 }
11469 }
11470 }
11471 else {
11472 const currentDisplay = style.display;
11473 if (isCssString) {
11474 if (prev !== next) {
11475 style.cssText = next;
11476 }
11477 }
11478 else if (prev) {
11479 el.removeAttribute('style');
11480 }
11481 // indicates that the `display` of the element is controlled by `v-show`,
11482 // so we always keep the current `display` value regardless of the `style`
11483 // value, thus handing over control to `v-show`.
11484 if ('_vod' in el) {
11485 style.display = currentDisplay;
11486 }
11487 }
11488}
11489const importantRE = /\s*!important$/;
11490function setStyle(style, name, val) {
11491 if (isArray(val)) {
11492 val.forEach(v => setStyle(style, name, v));
11493 }
11494 else {
11495 if (val == null)
11496 val = '';
11497 if (name.startsWith('--')) {
11498 // custom property definition
11499 style.setProperty(name, val);
11500 }
11501 else {
11502 const prefixed = autoPrefix(style, name);
11503 if (importantRE.test(val)) {
11504 // !important
11505 style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
11506 }
11507 else {
11508 style[prefixed] = val;
11509 }
11510 }
11511 }
11512}
11513const prefixes = ['Webkit', 'Moz', 'ms'];
11514const prefixCache = {};
11515function autoPrefix(style, rawName) {
11516 const cached = prefixCache[rawName];
11517 if (cached) {
11518 return cached;
11519 }
11520 let name = camelize(rawName);
11521 if (name !== 'filter' && name in style) {
11522 return (prefixCache[rawName] = name);
11523 }
11524 name = capitalize(name);
11525 for (let i = 0; i < prefixes.length; i++) {
11526 const prefixed = prefixes[i] + name;
11527 if (prefixed in style) {
11528 return (prefixCache[rawName] = prefixed);
11529 }
11530 }
11531 return rawName;
11532}
11533
11534const xlinkNS = 'http://www.w3.org/1999/xlink';
11535function patchAttr(el, key, value, isSVG, instance) {
11536 if (isSVG && key.startsWith('xlink:')) {
11537 if (value == null) {
11538 el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
11539 }
11540 else {
11541 el.setAttributeNS(xlinkNS, key, value);
11542 }
11543 }
11544 else {
11545 if (compatCoerceAttr(el, key, value, instance)) {
11546 return;
11547 }
11548 // note we are only checking boolean attributes that don't have a
11549 // corresponding dom prop of the same name here.
11550 const isBoolean = isSpecialBooleanAttr(key);
11551 if (value == null || (isBoolean && !includeBooleanAttr(value))) {
11552 el.removeAttribute(key);
11553 }
11554 else {
11555 el.setAttribute(key, isBoolean ? '' : value);
11556 }
11557 }
11558}
11559// 2.x compat
11560const isEnumeratedAttr = /*#__PURE__*/ makeMap('contenteditable,draggable,spellcheck')
11561 ;
11562function compatCoerceAttr(el, key, value, instance = null) {
11563 if (isEnumeratedAttr(key)) {
11564 const v2CocercedValue = value === null
11565 ? 'false'
11566 : typeof value !== 'boolean' && value !== undefined
11567 ? 'true'
11568 : null;
11569 if (v2CocercedValue &&
11570 compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CocercedValue)) {
11571 el.setAttribute(key, v2CocercedValue);
11572 return true;
11573 }
11574 }
11575 else if (value === false &&
11576 !isSpecialBooleanAttr(key) &&
11577 compatUtils.softAssertCompatEnabled("ATTR_FALSE_VALUE" /* DeprecationTypes.ATTR_FALSE_VALUE */, instance, key)) {
11578 el.removeAttribute(key);
11579 return true;
11580 }
11581 return false;
11582}
11583
11584// __UNSAFE__
11585// functions. The user is responsible for using them with only trusted content.
11586function patchDOMProp(el, key, value,
11587// the following args are passed only due to potential innerHTML/textContent
11588// overriding existing VNodes, in which case the old tree must be properly
11589// unmounted.
11590prevChildren, parentComponent, parentSuspense, unmountChildren) {
11591 if (key === 'innerHTML' || key === 'textContent') {
11592 if (prevChildren) {
11593 unmountChildren(prevChildren, parentComponent, parentSuspense);
11594 }
11595 el[key] = value == null ? '' : value;
11596 return;
11597 }
11598 if (key === 'value' &&
11599 el.tagName !== 'PROGRESS' &&
11600 // custom elements may use _value internally
11601 !el.tagName.includes('-')) {
11602 // store value as _value as well since
11603 // non-string values will be stringified.
11604 el._value = value;
11605 const newValue = value == null ? '' : value;
11606 if (el.value !== newValue ||
11607 // #4956: always set for OPTION elements because its value falls back to
11608 // textContent if no value attribute is present. And setting .value for
11609 // OPTION has no side effect
11610 el.tagName === 'OPTION') {
11611 el.value = newValue;
11612 }
11613 if (value == null) {
11614 el.removeAttribute(key);
11615 }
11616 return;
11617 }
11618 let needRemove = false;
11619 if (value === '' || value == null) {
11620 const type = typeof el[key];
11621 if (type === 'boolean') {
11622 // e.g. <select multiple> compiles to { multiple: '' }
11623 value = includeBooleanAttr(value);
11624 }
11625 else if (value == null && type === 'string') {
11626 // e.g. <div :id="null">
11627 value = '';
11628 needRemove = true;
11629 }
11630 else if (type === 'number') {
11631 // e.g. <img :width="null">
11632 // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
11633 value = 0;
11634 needRemove = true;
11635 }
11636 }
11637 else {
11638 if (value === false &&
11639 compatUtils.isCompatEnabled("ATTR_FALSE_VALUE" /* DeprecationTypes.ATTR_FALSE_VALUE */, parentComponent)) {
11640 const type = typeof el[key];
11641 if (type === 'string' || type === 'number') {
11642 compatUtils.warnDeprecation("ATTR_FALSE_VALUE" /* DeprecationTypes.ATTR_FALSE_VALUE */, parentComponent, key);
11643 value = type === 'number' ? 0 : '';
11644 needRemove = true;
11645 }
11646 }
11647 }
11648 // some properties perform value validation and throw,
11649 // some properties has getter, no setter, will error in 'use strict'
11650 // eg. <select :type="null"></select> <select :willValidate="null"></select>
11651 try {
11652 el[key] = value;
11653 }
11654 catch (e) {
11655 {
11656 warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
11657 `value ${value} is invalid.`, e);
11658 }
11659 }
11660 needRemove && el.removeAttribute(key);
11661}
11662
11663// Async edge case fix requires storing an event listener's attach timestamp.
11664const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
11665 let _getNow = Date.now;
11666 let skipTimestampCheck = false;
11667 if (typeof window !== 'undefined') {
11668 // Determine what event timestamp the browser is using. Annoyingly, the
11669 // timestamp can either be hi-res (relative to page load) or low-res
11670 // (relative to UNIX epoch), so in order to compare time we have to use the
11671 // same timestamp type when saving the flush timestamp.
11672 if (Date.now() > document.createEvent('Event').timeStamp) {
11673 // if the low-res timestamp which is bigger than the event timestamp
11674 // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
11675 // and we need to use the hi-res version for event listeners as well.
11676 _getNow = performance.now.bind(performance);
11677 }
11678 // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
11679 // and does not fire microtasks in between event propagation, so safe to exclude.
11680 const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
11681 skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
11682 }
11683 return [_getNow, skipTimestampCheck];
11684})();
11685// To avoid the overhead of repeatedly calling performance.now(), we cache
11686// and use the same timestamp for all event listeners attached in the same tick.
11687let cachedNow = 0;
11688const p = /*#__PURE__*/ Promise.resolve();
11689const reset = () => {
11690 cachedNow = 0;
11691};
11692const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
11693function addEventListener(el, event, handler, options) {
11694 el.addEventListener(event, handler, options);
11695}
11696function removeEventListener(el, event, handler, options) {
11697 el.removeEventListener(event, handler, options);
11698}
11699function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
11700 // vei = vue event invokers
11701 const invokers = el._vei || (el._vei = {});
11702 const existingInvoker = invokers[rawName];
11703 if (nextValue && existingInvoker) {
11704 // patch
11705 existingInvoker.value = nextValue;
11706 }
11707 else {
11708 const [name, options] = parseName(rawName);
11709 if (nextValue) {
11710 // add
11711 const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
11712 addEventListener(el, name, invoker, options);
11713 }
11714 else if (existingInvoker) {
11715 // remove
11716 removeEventListener(el, name, existingInvoker, options);
11717 invokers[rawName] = undefined;
11718 }
11719 }
11720}
11721const optionsModifierRE = /(?:Once|Passive|Capture)$/;
11722function parseName(name) {
11723 let options;
11724 if (optionsModifierRE.test(name)) {
11725 options = {};
11726 let m;
11727 while ((m = name.match(optionsModifierRE))) {
11728 name = name.slice(0, name.length - m[0].length);
11729 options[m[0].toLowerCase()] = true;
11730 }
11731 }
11732 const event = name[2] === ':' ? name.slice(3) : hyphenate(name.slice(2));
11733 return [event, options];
11734}
11735function createInvoker(initialValue, instance) {
11736 const invoker = (e) => {
11737 // async edge case #6566: inner click event triggers patch, event handler
11738 // attached to outer element during patch, and triggered again. This
11739 // happens because browsers fire microtask ticks between event propagation.
11740 // the solution is simple: we save the timestamp when a handler is attached,
11741 // and the handler would only fire if the event passed to it was fired
11742 // AFTER it was attached.
11743 const timeStamp = e.timeStamp || _getNow();
11744 if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
11745 callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* ErrorCodes.NATIVE_EVENT_HANDLER */, [e]);
11746 }
11747 };
11748 invoker.value = initialValue;
11749 invoker.attached = getNow();
11750 return invoker;
11751}
11752function patchStopImmediatePropagation(e, value) {
11753 if (isArray(value)) {
11754 const originalStop = e.stopImmediatePropagation;
11755 e.stopImmediatePropagation = () => {
11756 originalStop.call(e);
11757 e._stopped = true;
11758 };
11759 return value.map(fn => (e) => !e._stopped && fn && fn(e));
11760 }
11761 else {
11762 return value;
11763 }
11764}
11765
11766const nativeOnRE = /^on[a-z]/;
11767const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
11768 if (key === 'class') {
11769 patchClass(el, nextValue, isSVG);
11770 }
11771 else if (key === 'style') {
11772 patchStyle(el, prevValue, nextValue);
11773 }
11774 else if (isOn(key)) {
11775 // ignore v-model listeners
11776 if (!isModelListener(key)) {
11777 patchEvent(el, key, prevValue, nextValue, parentComponent);
11778 }
11779 }
11780 else if (key[0] === '.'
11781 ? ((key = key.slice(1)), true)
11782 : key[0] === '^'
11783 ? ((key = key.slice(1)), false)
11784 : shouldSetAsProp(el, key, nextValue, isSVG)) {
11785 patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
11786 }
11787 else {
11788 // special case for <input v-model type="checkbox"> with
11789 // :true-value & :false-value
11790 // store value as dom properties since non-string values will be
11791 // stringified.
11792 if (key === 'true-value') {
11793 el._trueValue = nextValue;
11794 }
11795 else if (key === 'false-value') {
11796 el._falseValue = nextValue;
11797 }
11798 patchAttr(el, key, nextValue, isSVG, parentComponent);
11799 }
11800};
11801function shouldSetAsProp(el, key, value, isSVG) {
11802 if (isSVG) {
11803 // most keys must be set as attribute on svg elements to work
11804 // ...except innerHTML & textContent
11805 if (key === 'innerHTML' || key === 'textContent') {
11806 return true;
11807 }
11808 // or native onclick with function values
11809 if (key in el && nativeOnRE.test(key) && isFunction(value)) {
11810 return true;
11811 }
11812 return false;
11813 }
11814 // these are enumerated attrs, however their corresponding DOM properties
11815 // are actually booleans - this leads to setting it with a string "false"
11816 // value leading it to be coerced to `true`, so we need to always treat
11817 // them as attributes.
11818 // Note that `contentEditable` doesn't have this problem: its DOM
11819 // property is also enumerated string values.
11820 if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
11821 return false;
11822 }
11823 // #1787, #2840 form property on form elements is readonly and must be set as
11824 // attribute.
11825 if (key === 'form') {
11826 return false;
11827 }
11828 // #1526 <input list> must be set as attribute
11829 if (key === 'list' && el.tagName === 'INPUT') {
11830 return false;
11831 }
11832 // #2766 <textarea type> must be set as attribute
11833 if (key === 'type' && el.tagName === 'TEXTAREA') {
11834 return false;
11835 }
11836 // native onclick with string value, must be set as attribute
11837 if (nativeOnRE.test(key) && isString(value)) {
11838 return false;
11839 }
11840 return key in el;
11841}
11842
11843function defineCustomElement(options, hydrate) {
11844 const Comp = defineComponent(options);
11845 class VueCustomElement extends VueElement {
11846 constructor(initialProps) {
11847 super(Comp, initialProps, hydrate);
11848 }
11849 }
11850 VueCustomElement.def = Comp;
11851 return VueCustomElement;
11852}
11853const defineSSRCustomElement = ((options) => {
11854 // @ts-ignore
11855 return defineCustomElement(options, hydrate);
11856});
11857const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
11858});
11859class VueElement extends BaseClass {
11860 constructor(_def, _props = {}, hydrate) {
11861 super();
11862 this._def = _def;
11863 this._props = _props;
11864 /**
11865 * @internal
11866 */
11867 this._instance = null;
11868 this._connected = false;
11869 this._resolved = false;
11870 this._numberProps = null;
11871 if (this.shadowRoot && hydrate) {
11872 hydrate(this._createVNode(), this.shadowRoot);
11873 }
11874 else {
11875 if (this.shadowRoot) {
11876 warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
11877 `defined as hydratable. Use \`defineSSRCustomElement\`.`);
11878 }
11879 this.attachShadow({ mode: 'open' });
11880 }
11881 }
11882 connectedCallback() {
11883 this._connected = true;
11884 if (!this._instance) {
11885 this._resolveDef();
11886 }
11887 }
11888 disconnectedCallback() {
11889 this._connected = false;
11890 nextTick(() => {
11891 if (!this._connected) {
11892 render(null, this.shadowRoot);
11893 this._instance = null;
11894 }
11895 });
11896 }
11897 /**
11898 * resolve inner component definition (handle possible async component)
11899 */
11900 _resolveDef() {
11901 if (this._resolved) {
11902 return;
11903 }
11904 this._resolved = true;
11905 // set initial attrs
11906 for (let i = 0; i < this.attributes.length; i++) {
11907 this._setAttr(this.attributes[i].name);
11908 }
11909 // watch future attr changes
11910 new MutationObserver(mutations => {
11911 for (const m of mutations) {
11912 this._setAttr(m.attributeName);
11913 }
11914 }).observe(this, { attributes: true });
11915 const resolve = (def) => {
11916 const { props, styles } = def;
11917 const hasOptions = !isArray(props);
11918 const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11919 // cast Number-type props set before resolve
11920 let numberProps;
11921 if (hasOptions) {
11922 for (const key in this._props) {
11923 const opt = props[key];
11924 if (opt === Number || (opt && opt.type === Number)) {
11925 this._props[key] = toNumber(this._props[key]);
11926 (numberProps || (numberProps = Object.create(null)))[key] = true;
11927 }
11928 }
11929 }
11930 this._numberProps = numberProps;
11931 // check if there are props set pre-upgrade or connect
11932 for (const key of Object.keys(this)) {
11933 if (key[0] !== '_') {
11934 this._setProp(key, this[key], true, false);
11935 }
11936 }
11937 // defining getter/setters on prototype
11938 for (const key of rawKeys.map(camelize)) {
11939 Object.defineProperty(this, key, {
11940 get() {
11941 return this._getProp(key);
11942 },
11943 set(val) {
11944 this._setProp(key, val);
11945 }
11946 });
11947 }
11948 // apply CSS
11949 this._applyStyles(styles);
11950 // initial render
11951 this._update();
11952 };
11953 const asyncDef = this._def.__asyncLoader;
11954 if (asyncDef) {
11955 asyncDef().then(resolve);
11956 }
11957 else {
11958 resolve(this._def);
11959 }
11960 }
11961 _setAttr(key) {
11962 let value = this.getAttribute(key);
11963 if (this._numberProps && this._numberProps[key]) {
11964 value = toNumber(value);
11965 }
11966 this._setProp(camelize(key), value, false);
11967 }
11968 /**
11969 * @internal
11970 */
11971 _getProp(key) {
11972 return this._props[key];
11973 }
11974 /**
11975 * @internal
11976 */
11977 _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
11978 if (val !== this._props[key]) {
11979 this._props[key] = val;
11980 if (shouldUpdate && this._instance) {
11981 this._update();
11982 }
11983 // reflect
11984 if (shouldReflect) {
11985 if (val === true) {
11986 this.setAttribute(hyphenate(key), '');
11987 }
11988 else if (typeof val === 'string' || typeof val === 'number') {
11989 this.setAttribute(hyphenate(key), val + '');
11990 }
11991 else if (!val) {
11992 this.removeAttribute(hyphenate(key));
11993 }
11994 }
11995 }
11996 }
11997 _update() {
11998 render(this._createVNode(), this.shadowRoot);
11999 }
12000 _createVNode() {
12001 const vnode = createVNode(this._def, extend({}, this._props));
12002 if (!this._instance) {
12003 vnode.ce = instance => {
12004 this._instance = instance;
12005 instance.isCE = true;
12006 // HMR
12007 {
12008 instance.ceReload = newStyles => {
12009 // always reset styles
12010 if (this._styles) {
12011 this._styles.forEach(s => this.shadowRoot.removeChild(s));
12012 this._styles.length = 0;
12013 }
12014 this._applyStyles(newStyles);
12015 // if this is an async component, ceReload is called from the inner
12016 // component so no need to reload the async wrapper
12017 if (!this._def.__asyncLoader) {
12018 // reload
12019 this._instance = null;
12020 this._update();
12021 }
12022 };
12023 }
12024 // intercept emit
12025 instance.emit = (event, ...args) => {
12026 this.dispatchEvent(new CustomEvent(event, {
12027 detail: args
12028 }));
12029 };
12030 // locate nearest Vue custom element parent for provide/inject
12031 let parent = this;
12032 while ((parent =
12033 parent && (parent.parentNode || parent.host))) {
12034 if (parent instanceof VueElement) {
12035 instance.parent = parent._instance;
12036 break;
12037 }
12038 }
12039 };
12040 }
12041 return vnode;
12042 }
12043 _applyStyles(styles) {
12044 if (styles) {
12045 styles.forEach(css => {
12046 const s = document.createElement('style');
12047 s.textContent = css;
12048 this.shadowRoot.appendChild(s);
12049 // record for HMR
12050 {
12051 (this._styles || (this._styles = [])).push(s);
12052 }
12053 });
12054 }
12055 }
12056}
12057
12058function useCssModule(name = '$style') {
12059 /* istanbul ignore else */
12060 {
12061 const instance = getCurrentInstance();
12062 if (!instance) {
12063 warn$1(`useCssModule must be called inside setup()`);
12064 return EMPTY_OBJ;
12065 }
12066 const modules = instance.type.__cssModules;
12067 if (!modules) {
12068 warn$1(`Current instance does not have CSS modules injected.`);
12069 return EMPTY_OBJ;
12070 }
12071 const mod = modules[name];
12072 if (!mod) {
12073 warn$1(`Current instance does not have CSS module named "${name}".`);
12074 return EMPTY_OBJ;
12075 }
12076 return mod;
12077 }
12078}
12079
12080/**
12081 * Runtime helper for SFC's CSS variable injection feature.
12082 * @private
12083 */
12084function useCssVars(getter) {
12085 return;
12086}
12087
12088const TRANSITION = 'transition';
12089const ANIMATION = 'animation';
12090// DOM Transition is a higher-order-component based on the platform-agnostic
12091// base Transition component, with DOM-specific logic.
12092const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
12093Transition.displayName = 'Transition';
12094{
12095 Transition.__isBuiltIn = true;
12096}
12097const DOMTransitionPropsValidators = {
12098 name: String,
12099 type: String,
12100 css: {
12101 type: Boolean,
12102 default: true
12103 },
12104 duration: [String, Number, Object],
12105 enterFromClass: String,
12106 enterActiveClass: String,
12107 enterToClass: String,
12108 appearFromClass: String,
12109 appearActiveClass: String,
12110 appearToClass: String,
12111 leaveFromClass: String,
12112 leaveActiveClass: String,
12113 leaveToClass: String
12114};
12115const TransitionPropsValidators = (Transition.props =
12116 /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
12117/**
12118 * #3227 Incoming hooks may be merged into arrays when wrapping Transition
12119 * with custom HOCs.
12120 */
12121const callHook$1 = (hook, args = []) => {
12122 if (isArray(hook)) {
12123 hook.forEach(h => h(...args));
12124 }
12125 else if (hook) {
12126 hook(...args);
12127 }
12128};
12129/**
12130 * Check if a hook expects a callback (2nd arg), which means the user
12131 * intends to explicitly control the end of the transition.
12132 */
12133const hasExplicitCallback = (hook) => {
12134 return hook
12135 ? isArray(hook)
12136 ? hook.some(h => h.length > 1)
12137 : hook.length > 1
12138 : false;
12139};
12140function resolveTransitionProps(rawProps) {
12141 const baseProps = {};
12142 for (const key in rawProps) {
12143 if (!(key in DOMTransitionPropsValidators)) {
12144 baseProps[key] = rawProps[key];
12145 }
12146 }
12147 if (rawProps.css === false) {
12148 return baseProps;
12149 }
12150 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;
12151 // legacy transition class compat
12152 const legacyClassEnabled = compatUtils.isCompatEnabled("TRANSITION_CLASSES" /* DeprecationTypes.TRANSITION_CLASSES */, null);
12153 let legacyEnterFromClass;
12154 let legacyAppearFromClass;
12155 let legacyLeaveFromClass;
12156 if (legacyClassEnabled) {
12157 const toLegacyClass = (cls) => cls.replace(/-from$/, '');
12158 if (!rawProps.enterFromClass) {
12159 legacyEnterFromClass = toLegacyClass(enterFromClass);
12160 }
12161 if (!rawProps.appearFromClass) {
12162 legacyAppearFromClass = toLegacyClass(appearFromClass);
12163 }
12164 if (!rawProps.leaveFromClass) {
12165 legacyLeaveFromClass = toLegacyClass(leaveFromClass);
12166 }
12167 }
12168 const durations = normalizeDuration(duration);
12169 const enterDuration = durations && durations[0];
12170 const leaveDuration = durations && durations[1];
12171 const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
12172 const finishEnter = (el, isAppear, done) => {
12173 removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
12174 removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
12175 done && done();
12176 };
12177 const finishLeave = (el, done) => {
12178 el._isLeaving = false;
12179 removeTransitionClass(el, leaveFromClass);
12180 removeTransitionClass(el, leaveToClass);
12181 removeTransitionClass(el, leaveActiveClass);
12182 done && done();
12183 };
12184 const makeEnterHook = (isAppear) => {
12185 return (el, done) => {
12186 const hook = isAppear ? onAppear : onEnter;
12187 const resolve = () => finishEnter(el, isAppear, done);
12188 callHook$1(hook, [el, resolve]);
12189 nextFrame(() => {
12190 removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
12191 if (legacyClassEnabled) {
12192 removeTransitionClass(el, isAppear ? legacyAppearFromClass : legacyEnterFromClass);
12193 }
12194 addTransitionClass(el, isAppear ? appearToClass : enterToClass);
12195 if (!hasExplicitCallback(hook)) {
12196 whenTransitionEnds(el, type, enterDuration, resolve);
12197 }
12198 });
12199 };
12200 };
12201 return extend(baseProps, {
12202 onBeforeEnter(el) {
12203 callHook$1(onBeforeEnter, [el]);
12204 addTransitionClass(el, enterFromClass);
12205 if (legacyClassEnabled) {
12206 addTransitionClass(el, legacyEnterFromClass);
12207 }
12208 addTransitionClass(el, enterActiveClass);
12209 },
12210 onBeforeAppear(el) {
12211 callHook$1(onBeforeAppear, [el]);
12212 addTransitionClass(el, appearFromClass);
12213 if (legacyClassEnabled) {
12214 addTransitionClass(el, legacyAppearFromClass);
12215 }
12216 addTransitionClass(el, appearActiveClass);
12217 },
12218 onEnter: makeEnterHook(false),
12219 onAppear: makeEnterHook(true),
12220 onLeave(el, done) {
12221 el._isLeaving = true;
12222 const resolve = () => finishLeave(el, done);
12223 addTransitionClass(el, leaveFromClass);
12224 if (legacyClassEnabled) {
12225 addTransitionClass(el, legacyLeaveFromClass);
12226 }
12227 // force reflow so *-leave-from classes immediately take effect (#2593)
12228 forceReflow();
12229 addTransitionClass(el, leaveActiveClass);
12230 nextFrame(() => {
12231 if (!el._isLeaving) {
12232 // cancelled
12233 return;
12234 }
12235 removeTransitionClass(el, leaveFromClass);
12236 if (legacyClassEnabled) {
12237 removeTransitionClass(el, legacyLeaveFromClass);
12238 }
12239 addTransitionClass(el, leaveToClass);
12240 if (!hasExplicitCallback(onLeave)) {
12241 whenTransitionEnds(el, type, leaveDuration, resolve);
12242 }
12243 });
12244 callHook$1(onLeave, [el, resolve]);
12245 },
12246 onEnterCancelled(el) {
12247 finishEnter(el, false);
12248 callHook$1(onEnterCancelled, [el]);
12249 },
12250 onAppearCancelled(el) {
12251 finishEnter(el, true);
12252 callHook$1(onAppearCancelled, [el]);
12253 },
12254 onLeaveCancelled(el) {
12255 finishLeave(el);
12256 callHook$1(onLeaveCancelled, [el]);
12257 }
12258 });
12259}
12260function normalizeDuration(duration) {
12261 if (duration == null) {
12262 return null;
12263 }
12264 else if (isObject(duration)) {
12265 return [NumberOf(duration.enter), NumberOf(duration.leave)];
12266 }
12267 else {
12268 const n = NumberOf(duration);
12269 return [n, n];
12270 }
12271}
12272function NumberOf(val) {
12273 const res = toNumber(val);
12274 validateDuration(res);
12275 return res;
12276}
12277function validateDuration(val) {
12278 if (typeof val !== 'number') {
12279 warn$1(`<transition> explicit duration is not a valid number - ` +
12280 `got ${JSON.stringify(val)}.`);
12281 }
12282 else if (isNaN(val)) {
12283 warn$1(`<transition> explicit duration is NaN - ` +
12284 'the duration expression might be incorrect.');
12285 }
12286}
12287function addTransitionClass(el, cls) {
12288 cls.split(/\s+/).forEach(c => c && el.classList.add(c));
12289 (el._vtc ||
12290 (el._vtc = new Set())).add(cls);
12291}
12292function removeTransitionClass(el, cls) {
12293 cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
12294 const { _vtc } = el;
12295 if (_vtc) {
12296 _vtc.delete(cls);
12297 if (!_vtc.size) {
12298 el._vtc = undefined;
12299 }
12300 }
12301}
12302function nextFrame(cb) {
12303 requestAnimationFrame(() => {
12304 requestAnimationFrame(cb);
12305 });
12306}
12307let endId = 0;
12308function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
12309 const id = (el._endId = ++endId);
12310 const resolveIfNotStale = () => {
12311 if (id === el._endId) {
12312 resolve();
12313 }
12314 };
12315 if (explicitTimeout) {
12316 return setTimeout(resolveIfNotStale, explicitTimeout);
12317 }
12318 const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
12319 if (!type) {
12320 return resolve();
12321 }
12322 const endEvent = type + 'end';
12323 let ended = 0;
12324 const end = () => {
12325 el.removeEventListener(endEvent, onEnd);
12326 resolveIfNotStale();
12327 };
12328 const onEnd = (e) => {
12329 if (e.target === el && ++ended >= propCount) {
12330 end();
12331 }
12332 };
12333 setTimeout(() => {
12334 if (ended < propCount) {
12335 end();
12336 }
12337 }, timeout + 1);
12338 el.addEventListener(endEvent, onEnd);
12339}
12340function getTransitionInfo(el, expectedType) {
12341 const styles = window.getComputedStyle(el);
12342 // JSDOM may return undefined for transition properties
12343 const getStyleProperties = (key) => (styles[key] || '').split(', ');
12344 const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
12345 const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
12346 const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
12347 const animationDelays = getStyleProperties(ANIMATION + 'Delay');
12348 const animationDurations = getStyleProperties(ANIMATION + 'Duration');
12349 const animationTimeout = getTimeout(animationDelays, animationDurations);
12350 let type = null;
12351 let timeout = 0;
12352 let propCount = 0;
12353 /* istanbul ignore if */
12354 if (expectedType === TRANSITION) {
12355 if (transitionTimeout > 0) {
12356 type = TRANSITION;
12357 timeout = transitionTimeout;
12358 propCount = transitionDurations.length;
12359 }
12360 }
12361 else if (expectedType === ANIMATION) {
12362 if (animationTimeout > 0) {
12363 type = ANIMATION;
12364 timeout = animationTimeout;
12365 propCount = animationDurations.length;
12366 }
12367 }
12368 else {
12369 timeout = Math.max(transitionTimeout, animationTimeout);
12370 type =
12371 timeout > 0
12372 ? transitionTimeout > animationTimeout
12373 ? TRANSITION
12374 : ANIMATION
12375 : null;
12376 propCount = type
12377 ? type === TRANSITION
12378 ? transitionDurations.length
12379 : animationDurations.length
12380 : 0;
12381 }
12382 const hasTransform = type === TRANSITION &&
12383 /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
12384 return {
12385 type,
12386 timeout,
12387 propCount,
12388 hasTransform
12389 };
12390}
12391function getTimeout(delays, durations) {
12392 while (delays.length < durations.length) {
12393 delays = delays.concat(delays);
12394 }
12395 return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
12396}
12397// Old versions of Chromium (below 61.0.3163.100) formats floating pointer
12398// numbers in a locale-dependent way, using a comma instead of a dot.
12399// If comma is not replaced with a dot, the input will be rounded down
12400// (i.e. acting as a floor function) causing unexpected behaviors
12401function toMs(s) {
12402 return Number(s.slice(0, -1).replace(',', '.')) * 1000;
12403}
12404// synchronously force layout to put elements into a certain state
12405function forceReflow() {
12406 return document.body.offsetHeight;
12407}
12408
12409const positionMap = new WeakMap();
12410const newPositionMap = new WeakMap();
12411const TransitionGroupImpl = {
12412 name: 'TransitionGroup',
12413 props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
12414 tag: String,
12415 moveClass: String
12416 }),
12417 setup(props, { slots }) {
12418 const instance = getCurrentInstance();
12419 const state = useTransitionState();
12420 let prevChildren;
12421 let children;
12422 onUpdated(() => {
12423 // children is guaranteed to exist after initial render
12424 if (!prevChildren.length) {
12425 return;
12426 }
12427 const moveClass = props.moveClass || `${props.name || 'v'}-move`;
12428 if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
12429 return;
12430 }
12431 // we divide the work into three loops to avoid mixing DOM reads and writes
12432 // in each iteration - which helps prevent layout thrashing.
12433 prevChildren.forEach(callPendingCbs);
12434 prevChildren.forEach(recordPosition);
12435 const movedChildren = prevChildren.filter(applyTranslation);
12436 // force reflow to put everything in position
12437 forceReflow();
12438 movedChildren.forEach(c => {
12439 const el = c.el;
12440 const style = el.style;
12441 addTransitionClass(el, moveClass);
12442 style.transform = style.webkitTransform = style.transitionDuration = '';
12443 const cb = (el._moveCb = (e) => {
12444 if (e && e.target !== el) {
12445 return;
12446 }
12447 if (!e || /transform$/.test(e.propertyName)) {
12448 el.removeEventListener('transitionend', cb);
12449 el._moveCb = null;
12450 removeTransitionClass(el, moveClass);
12451 }
12452 });
12453 el.addEventListener('transitionend', cb);
12454 });
12455 });
12456 return () => {
12457 const rawProps = toRaw(props);
12458 const cssTransitionProps = resolveTransitionProps(rawProps);
12459 let tag = rawProps.tag || Fragment;
12460 if (!rawProps.tag &&
12461 compatUtils.checkCompatEnabled("TRANSITION_GROUP_ROOT" /* DeprecationTypes.TRANSITION_GROUP_ROOT */, instance.parent)) {
12462 tag = 'span';
12463 }
12464 prevChildren = children;
12465 children = slots.default ? getTransitionRawChildren(slots.default()) : [];
12466 for (let i = 0; i < children.length; i++) {
12467 const child = children[i];
12468 if (child.key != null) {
12469 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
12470 }
12471 else {
12472 warn$1(`<TransitionGroup> children must be keyed.`);
12473 }
12474 }
12475 if (prevChildren) {
12476 for (let i = 0; i < prevChildren.length; i++) {
12477 const child = prevChildren[i];
12478 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
12479 positionMap.set(child, child.el.getBoundingClientRect());
12480 }
12481 }
12482 return createVNode(tag, null, children);
12483 };
12484 }
12485};
12486{
12487 TransitionGroupImpl.__isBuiltIn = true;
12488}
12489const TransitionGroup = TransitionGroupImpl;
12490function callPendingCbs(c) {
12491 const el = c.el;
12492 if (el._moveCb) {
12493 el._moveCb();
12494 }
12495 if (el._enterCb) {
12496 el._enterCb();
12497 }
12498}
12499function recordPosition(c) {
12500 newPositionMap.set(c, c.el.getBoundingClientRect());
12501}
12502function applyTranslation(c) {
12503 const oldPos = positionMap.get(c);
12504 const newPos = newPositionMap.get(c);
12505 const dx = oldPos.left - newPos.left;
12506 const dy = oldPos.top - newPos.top;
12507 if (dx || dy) {
12508 const s = c.el.style;
12509 s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
12510 s.transitionDuration = '0s';
12511 return c;
12512 }
12513}
12514function hasCSSTransform(el, root, moveClass) {
12515 // Detect whether an element with the move class applied has
12516 // CSS transitions. Since the element may be inside an entering
12517 // transition at this very moment, we make a clone of it and remove
12518 // all other transition classes applied to ensure only the move class
12519 // is applied.
12520 const clone = el.cloneNode();
12521 if (el._vtc) {
12522 el._vtc.forEach(cls => {
12523 cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
12524 });
12525 }
12526 moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
12527 clone.style.display = 'none';
12528 const container = (root.nodeType === 1 ? root : root.parentNode);
12529 container.appendChild(clone);
12530 const { hasTransform } = getTransitionInfo(clone);
12531 container.removeChild(clone);
12532 return hasTransform;
12533}
12534
12535const getModelAssigner = (vnode) => {
12536 const fn = vnode.props['onUpdate:modelValue'] ||
12537 (vnode.props['onModelCompat:input']);
12538 return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
12539};
12540function onCompositionStart(e) {
12541 e.target.composing = true;
12542}
12543function onCompositionEnd(e) {
12544 const target = e.target;
12545 if (target.composing) {
12546 target.composing = false;
12547 target.dispatchEvent(new Event('input'));
12548 }
12549}
12550// We are exporting the v-model runtime directly as vnode hooks so that it can
12551// be tree-shaken in case v-model is never used.
12552const vModelText = {
12553 created(el, { modifiers: { lazy, trim, number } }, vnode) {
12554 el._assign = getModelAssigner(vnode);
12555 const castToNumber = number || (vnode.props && vnode.props.type === 'number');
12556 addEventListener(el, lazy ? 'change' : 'input', e => {
12557 if (e.target.composing)
12558 return;
12559 let domValue = el.value;
12560 if (trim) {
12561 domValue = domValue.trim();
12562 }
12563 if (castToNumber) {
12564 domValue = toNumber(domValue);
12565 }
12566 el._assign(domValue);
12567 });
12568 if (trim) {
12569 addEventListener(el, 'change', () => {
12570 el.value = el.value.trim();
12571 });
12572 }
12573 if (!lazy) {
12574 addEventListener(el, 'compositionstart', onCompositionStart);
12575 addEventListener(el, 'compositionend', onCompositionEnd);
12576 // Safari < 10.2 & UIWebView doesn't fire compositionend when
12577 // switching focus before confirming composition choice
12578 // this also fixes the issue where some browsers e.g. iOS Chrome
12579 // fires "change" instead of "input" on autocomplete.
12580 addEventListener(el, 'change', onCompositionEnd);
12581 }
12582 },
12583 // set value on mounted so it's after min/max for type="range"
12584 mounted(el, { value }) {
12585 el.value = value == null ? '' : value;
12586 },
12587 beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
12588 el._assign = getModelAssigner(vnode);
12589 // avoid clearing unresolved text. #2302
12590 if (el.composing)
12591 return;
12592 if (document.activeElement === el && el.type !== 'range') {
12593 if (lazy) {
12594 return;
12595 }
12596 if (trim && el.value.trim() === value) {
12597 return;
12598 }
12599 if ((number || el.type === 'number') && toNumber(el.value) === value) {
12600 return;
12601 }
12602 }
12603 const newValue = value == null ? '' : value;
12604 if (el.value !== newValue) {
12605 el.value = newValue;
12606 }
12607 }
12608};
12609const vModelCheckbox = {
12610 // #4096 array checkboxes need to be deep traversed
12611 deep: true,
12612 created(el, _, vnode) {
12613 el._assign = getModelAssigner(vnode);
12614 addEventListener(el, 'change', () => {
12615 const modelValue = el._modelValue;
12616 const elementValue = getValue(el);
12617 const checked = el.checked;
12618 const assign = el._assign;
12619 if (isArray(modelValue)) {
12620 const index = looseIndexOf(modelValue, elementValue);
12621 const found = index !== -1;
12622 if (checked && !found) {
12623 assign(modelValue.concat(elementValue));
12624 }
12625 else if (!checked && found) {
12626 const filtered = [...modelValue];
12627 filtered.splice(index, 1);
12628 assign(filtered);
12629 }
12630 }
12631 else if (isSet(modelValue)) {
12632 const cloned = new Set(modelValue);
12633 if (checked) {
12634 cloned.add(elementValue);
12635 }
12636 else {
12637 cloned.delete(elementValue);
12638 }
12639 assign(cloned);
12640 }
12641 else {
12642 assign(getCheckboxValue(el, checked));
12643 }
12644 });
12645 },
12646 // set initial checked on mount to wait for true-value/false-value
12647 mounted: setChecked,
12648 beforeUpdate(el, binding, vnode) {
12649 el._assign = getModelAssigner(vnode);
12650 setChecked(el, binding, vnode);
12651 }
12652};
12653function setChecked(el, { value, oldValue }, vnode) {
12654 el._modelValue = value;
12655 if (isArray(value)) {
12656 el.checked = looseIndexOf(value, vnode.props.value) > -1;
12657 }
12658 else if (isSet(value)) {
12659 el.checked = value.has(vnode.props.value);
12660 }
12661 else if (value !== oldValue) {
12662 el.checked = looseEqual(value, getCheckboxValue(el, true));
12663 }
12664}
12665const vModelRadio = {
12666 created(el, { value }, vnode) {
12667 el.checked = looseEqual(value, vnode.props.value);
12668 el._assign = getModelAssigner(vnode);
12669 addEventListener(el, 'change', () => {
12670 el._assign(getValue(el));
12671 });
12672 },
12673 beforeUpdate(el, { value, oldValue }, vnode) {
12674 el._assign = getModelAssigner(vnode);
12675 if (value !== oldValue) {
12676 el.checked = looseEqual(value, vnode.props.value);
12677 }
12678 }
12679};
12680const vModelSelect = {
12681 // <select multiple> value need to be deep traversed
12682 deep: true,
12683 created(el, { value, modifiers: { number } }, vnode) {
12684 const isSetModel = isSet(value);
12685 addEventListener(el, 'change', () => {
12686 const selectedVal = Array.prototype.filter
12687 .call(el.options, (o) => o.selected)
12688 .map((o) => number ? toNumber(getValue(o)) : getValue(o));
12689 el._assign(el.multiple
12690 ? isSetModel
12691 ? new Set(selectedVal)
12692 : selectedVal
12693 : selectedVal[0]);
12694 });
12695 el._assign = getModelAssigner(vnode);
12696 },
12697 // set value in mounted & updated because <select> relies on its children
12698 // <option>s.
12699 mounted(el, { value }) {
12700 setSelected(el, value);
12701 },
12702 beforeUpdate(el, _binding, vnode) {
12703 el._assign = getModelAssigner(vnode);
12704 },
12705 updated(el, { value }) {
12706 setSelected(el, value);
12707 }
12708};
12709function setSelected(el, value) {
12710 const isMultiple = el.multiple;
12711 if (isMultiple && !isArray(value) && !isSet(value)) {
12712 warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
12713 `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
12714 return;
12715 }
12716 for (let i = 0, l = el.options.length; i < l; i++) {
12717 const option = el.options[i];
12718 const optionValue = getValue(option);
12719 if (isMultiple) {
12720 if (isArray(value)) {
12721 option.selected = looseIndexOf(value, optionValue) > -1;
12722 }
12723 else {
12724 option.selected = value.has(optionValue);
12725 }
12726 }
12727 else {
12728 if (looseEqual(getValue(option), value)) {
12729 if (el.selectedIndex !== i)
12730 el.selectedIndex = i;
12731 return;
12732 }
12733 }
12734 }
12735 if (!isMultiple && el.selectedIndex !== -1) {
12736 el.selectedIndex = -1;
12737 }
12738}
12739// retrieve raw value set via :value bindings
12740function getValue(el) {
12741 return '_value' in el ? el._value : el.value;
12742}
12743// retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
12744function getCheckboxValue(el, checked) {
12745 const key = checked ? '_trueValue' : '_falseValue';
12746 return key in el ? el[key] : checked;
12747}
12748const vModelDynamic = {
12749 created(el, binding, vnode) {
12750 callModelHook(el, binding, vnode, null, 'created');
12751 },
12752 mounted(el, binding, vnode) {
12753 callModelHook(el, binding, vnode, null, 'mounted');
12754 },
12755 beforeUpdate(el, binding, vnode, prevVNode) {
12756 callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
12757 },
12758 updated(el, binding, vnode, prevVNode) {
12759 callModelHook(el, binding, vnode, prevVNode, 'updated');
12760 }
12761};
12762function resolveDynamicModel(tagName, type) {
12763 switch (tagName) {
12764 case 'SELECT':
12765 return vModelSelect;
12766 case 'TEXTAREA':
12767 return vModelText;
12768 default:
12769 switch (type) {
12770 case 'checkbox':
12771 return vModelCheckbox;
12772 case 'radio':
12773 return vModelRadio;
12774 default:
12775 return vModelText;
12776 }
12777 }
12778}
12779function callModelHook(el, binding, vnode, prevVNode, hook) {
12780 const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
12781 const fn = modelToUse[hook];
12782 fn && fn(el, binding, vnode, prevVNode);
12783}
12784// SSR vnode transforms, only used when user includes client-oriented render
12785// function in SSR
12786function initVModelForSSR() {
12787 vModelText.getSSRProps = ({ value }) => ({ value });
12788 vModelRadio.getSSRProps = ({ value }, vnode) => {
12789 if (vnode.props && looseEqual(vnode.props.value, value)) {
12790 return { checked: true };
12791 }
12792 };
12793 vModelCheckbox.getSSRProps = ({ value }, vnode) => {
12794 if (isArray(value)) {
12795 if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
12796 return { checked: true };
12797 }
12798 }
12799 else if (isSet(value)) {
12800 if (vnode.props && value.has(vnode.props.value)) {
12801 return { checked: true };
12802 }
12803 }
12804 else if (value) {
12805 return { checked: true };
12806 }
12807 };
12808 vModelDynamic.getSSRProps = (binding, vnode) => {
12809 if (typeof vnode.type !== 'string') {
12810 return;
12811 }
12812 const modelToUse = resolveDynamicModel(
12813 // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
12814 vnode.type.toUpperCase(), vnode.props && vnode.props.type);
12815 if (modelToUse.getSSRProps) {
12816 return modelToUse.getSSRProps(binding, vnode);
12817 }
12818 };
12819}
12820
12821const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
12822const modifierGuards = {
12823 stop: e => e.stopPropagation(),
12824 prevent: e => e.preventDefault(),
12825 self: e => e.target !== e.currentTarget,
12826 ctrl: e => !e.ctrlKey,
12827 shift: e => !e.shiftKey,
12828 alt: e => !e.altKey,
12829 meta: e => !e.metaKey,
12830 left: e => 'button' in e && e.button !== 0,
12831 middle: e => 'button' in e && e.button !== 1,
12832 right: e => 'button' in e && e.button !== 2,
12833 exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
12834};
12835/**
12836 * @private
12837 */
12838const withModifiers = (fn, modifiers) => {
12839 return (event, ...args) => {
12840 for (let i = 0; i < modifiers.length; i++) {
12841 const guard = modifierGuards[modifiers[i]];
12842 if (guard && guard(event, modifiers))
12843 return;
12844 }
12845 return fn(event, ...args);
12846 };
12847};
12848// Kept for 2.x compat.
12849// Note: IE11 compat for `spacebar` and `del` is removed for now.
12850const keyNames = {
12851 esc: 'escape',
12852 space: ' ',
12853 up: 'arrow-up',
12854 left: 'arrow-left',
12855 right: 'arrow-right',
12856 down: 'arrow-down',
12857 delete: 'backspace'
12858};
12859/**
12860 * @private
12861 */
12862const withKeys = (fn, modifiers) => {
12863 let globalKeyCodes;
12864 let instance = null;
12865 {
12866 instance = getCurrentInstance();
12867 if (compatUtils.isCompatEnabled("CONFIG_KEY_CODES" /* DeprecationTypes.CONFIG_KEY_CODES */, instance)) {
12868 if (instance) {
12869 globalKeyCodes = instance.appContext.config.keyCodes;
12870 }
12871 }
12872 if (modifiers.some(m => /^\d+$/.test(m))) {
12873 compatUtils.warnDeprecation("V_ON_KEYCODE_MODIFIER" /* DeprecationTypes.V_ON_KEYCODE_MODIFIER */, instance);
12874 }
12875 }
12876 return (event) => {
12877 if (!('key' in event)) {
12878 return;
12879 }
12880 const eventKey = hyphenate(event.key);
12881 if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
12882 return fn(event);
12883 }
12884 {
12885 const keyCode = String(event.keyCode);
12886 if (compatUtils.isCompatEnabled("V_ON_KEYCODE_MODIFIER" /* DeprecationTypes.V_ON_KEYCODE_MODIFIER */, instance) &&
12887 modifiers.some(mod => mod == keyCode)) {
12888 return fn(event);
12889 }
12890 if (globalKeyCodes) {
12891 for (const mod of modifiers) {
12892 const codes = globalKeyCodes[mod];
12893 if (codes) {
12894 const matches = isArray(codes)
12895 ? codes.some(code => String(code) === keyCode)
12896 : String(codes) === keyCode;
12897 if (matches) {
12898 return fn(event);
12899 }
12900 }
12901 }
12902 }
12903 }
12904 };
12905};
12906
12907const vShow = {
12908 beforeMount(el, { value }, { transition }) {
12909 el._vod = el.style.display === 'none' ? '' : el.style.display;
12910 if (transition && value) {
12911 transition.beforeEnter(el);
12912 }
12913 else {
12914 setDisplay(el, value);
12915 }
12916 },
12917 mounted(el, { value }, { transition }) {
12918 if (transition && value) {
12919 transition.enter(el);
12920 }
12921 },
12922 updated(el, { value, oldValue }, { transition }) {
12923 if (!value === !oldValue)
12924 return;
12925 if (transition) {
12926 if (value) {
12927 transition.beforeEnter(el);
12928 setDisplay(el, true);
12929 transition.enter(el);
12930 }
12931 else {
12932 transition.leave(el, () => {
12933 setDisplay(el, false);
12934 });
12935 }
12936 }
12937 else {
12938 setDisplay(el, value);
12939 }
12940 },
12941 beforeUnmount(el, { value }) {
12942 setDisplay(el, value);
12943 }
12944};
12945function setDisplay(el, value) {
12946 el.style.display = value ? el._vod : 'none';
12947}
12948// SSR vnode transforms, only used when user includes client-oriented render
12949// function in SSR
12950function initVShowForSSR() {
12951 vShow.getSSRProps = ({ value }) => {
12952 if (!value) {
12953 return { style: { display: 'none' } };
12954 }
12955 };
12956}
12957
12958const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
12959// lazy create the renderer - this makes core renderer logic tree-shakable
12960// in case the user only imports reactivity utilities from Vue.
12961let renderer;
12962let enabledHydration = false;
12963function ensureRenderer() {
12964 return (renderer ||
12965 (renderer = createRenderer(rendererOptions)));
12966}
12967function ensureHydrationRenderer() {
12968 renderer = enabledHydration
12969 ? renderer
12970 : createHydrationRenderer(rendererOptions);
12971 enabledHydration = true;
12972 return renderer;
12973}
12974// use explicit type casts here to avoid import() calls in rolled-up d.ts
12975const render = ((...args) => {
12976 ensureRenderer().render(...args);
12977});
12978const hydrate = ((...args) => {
12979 ensureHydrationRenderer().hydrate(...args);
12980});
12981const createApp = ((...args) => {
12982 const app = ensureRenderer().createApp(...args);
12983 {
12984 injectNativeTagCheck(app);
12985 injectCompilerOptionsCheck(app);
12986 }
12987 const { mount } = app;
12988 app.mount = (containerOrSelector) => {
12989 const container = normalizeContainer(containerOrSelector);
12990 if (!container)
12991 return;
12992 const component = app._component;
12993 if (!isFunction(component) && !component.render && !component.template) {
12994 // __UNSAFE__
12995 // Reason: potential execution of JS expressions in in-DOM template.
12996 // The user must make sure the in-DOM template is trusted. If it's
12997 // rendered by the server, the template should not contain any user data.
12998 component.template = container.innerHTML;
12999 // 2.x compat check
13000 {
13001 for (let i = 0; i < container.attributes.length; i++) {
13002 const attr = container.attributes[i];
13003 if (attr.name !== 'v-cloak' && /^(v-|:|@)/.test(attr.name)) {
13004 compatUtils.warnDeprecation("GLOBAL_MOUNT_CONTAINER" /* DeprecationTypes.GLOBAL_MOUNT_CONTAINER */, null);
13005 break;
13006 }
13007 }
13008 }
13009 }
13010 // clear content before mounting
13011 container.innerHTML = '';
13012 const proxy = mount(container, false, container instanceof SVGElement);
13013 if (container instanceof Element) {
13014 container.removeAttribute('v-cloak');
13015 container.setAttribute('data-v-app', '');
13016 }
13017 return proxy;
13018 };
13019 return app;
13020});
13021const createSSRApp = ((...args) => {
13022 const app = ensureHydrationRenderer().createApp(...args);
13023 {
13024 injectNativeTagCheck(app);
13025 injectCompilerOptionsCheck(app);
13026 }
13027 const { mount } = app;
13028 app.mount = (containerOrSelector) => {
13029 const container = normalizeContainer(containerOrSelector);
13030 if (container) {
13031 return mount(container, true, container instanceof SVGElement);
13032 }
13033 };
13034 return app;
13035});
13036function injectNativeTagCheck(app) {
13037 // Inject `isNativeTag`
13038 // this is used for component name validation (dev only)
13039 Object.defineProperty(app.config, 'isNativeTag', {
13040 value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
13041 writable: false
13042 });
13043}
13044// dev only
13045function injectCompilerOptionsCheck(app) {
13046 if (isRuntimeOnly()) {
13047 const isCustomElement = app.config.isCustomElement;
13048 Object.defineProperty(app.config, 'isCustomElement', {
13049 get() {
13050 return isCustomElement;
13051 },
13052 set() {
13053 warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
13054 `\`compilerOptions.isCustomElement\` instead.`);
13055 }
13056 });
13057 const compilerOptions = app.config.compilerOptions;
13058 const msg = `The \`compilerOptions\` config option is only respected when using ` +
13059 `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
13060 `Since you are using the runtime-only build, \`compilerOptions\` ` +
13061 `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
13062 `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
13063 `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
13064 `- 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`;
13065 Object.defineProperty(app.config, 'compilerOptions', {
13066 get() {
13067 warn$1(msg);
13068 return compilerOptions;
13069 },
13070 set() {
13071 warn$1(msg);
13072 }
13073 });
13074 }
13075}
13076function normalizeContainer(container) {
13077 if (isString(container)) {
13078 const res = document.querySelector(container);
13079 if (!res) {
13080 warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
13081 }
13082 return res;
13083 }
13084 if (window.ShadowRoot &&
13085 container instanceof window.ShadowRoot &&
13086 container.mode === 'closed') {
13087 warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
13088 }
13089 return container;
13090}
13091let ssrDirectiveInitialized = false;
13092/**
13093 * @internal
13094 */
13095const initDirectivesForSSR = () => {
13096 if (!ssrDirectiveInitialized) {
13097 ssrDirectiveInitialized = true;
13098 initVModelForSSR();
13099 initVShowForSSR();
13100 }
13101 }
13102 ;
13103
13104var runtimeDom = /*#__PURE__*/Object.freeze({
13105 __proto__: null,
13106 render: render,
13107 hydrate: hydrate,
13108 createApp: createApp,
13109 createSSRApp: createSSRApp,
13110 initDirectivesForSSR: initDirectivesForSSR,
13111 defineCustomElement: defineCustomElement,
13112 defineSSRCustomElement: defineSSRCustomElement,
13113 VueElement: VueElement,
13114 useCssModule: useCssModule,
13115 useCssVars: useCssVars,
13116 Transition: Transition,
13117 TransitionGroup: TransitionGroup,
13118 vModelText: vModelText,
13119 vModelCheckbox: vModelCheckbox,
13120 vModelRadio: vModelRadio,
13121 vModelSelect: vModelSelect,
13122 vModelDynamic: vModelDynamic,
13123 withModifiers: withModifiers,
13124 withKeys: withKeys,
13125 vShow: vShow,
13126 reactive: reactive,
13127 ref: ref,
13128 readonly: readonly,
13129 unref: unref,
13130 proxyRefs: proxyRefs,
13131 isRef: isRef,
13132 toRef: toRef,
13133 toRefs: toRefs,
13134 isProxy: isProxy,
13135 isReactive: isReactive,
13136 isReadonly: isReadonly,
13137 isShallow: isShallow,
13138 customRef: customRef,
13139 triggerRef: triggerRef,
13140 shallowRef: shallowRef,
13141 shallowReactive: shallowReactive,
13142 shallowReadonly: shallowReadonly,
13143 markRaw: markRaw,
13144 toRaw: toRaw,
13145 effect: effect,
13146 stop: stop,
13147 ReactiveEffect: ReactiveEffect,
13148 effectScope: effectScope,
13149 EffectScope: EffectScope,
13150 getCurrentScope: getCurrentScope,
13151 onScopeDispose: onScopeDispose,
13152 computed: computed$1,
13153 watch: watch,
13154 watchEffect: watchEffect,
13155 watchPostEffect: watchPostEffect,
13156 watchSyncEffect: watchSyncEffect,
13157 onBeforeMount: onBeforeMount,
13158 onMounted: onMounted,
13159 onBeforeUpdate: onBeforeUpdate,
13160 onUpdated: onUpdated,
13161 onBeforeUnmount: onBeforeUnmount,
13162 onUnmounted: onUnmounted,
13163 onActivated: onActivated,
13164 onDeactivated: onDeactivated,
13165 onRenderTracked: onRenderTracked,
13166 onRenderTriggered: onRenderTriggered,
13167 onErrorCaptured: onErrorCaptured,
13168 onServerPrefetch: onServerPrefetch,
13169 provide: provide,
13170 inject: inject,
13171 nextTick: nextTick,
13172 defineComponent: defineComponent,
13173 defineAsyncComponent: defineAsyncComponent,
13174 useAttrs: useAttrs,
13175 useSlots: useSlots,
13176 defineProps: defineProps,
13177 defineEmits: defineEmits,
13178 defineExpose: defineExpose,
13179 withDefaults: withDefaults,
13180 mergeDefaults: mergeDefaults,
13181 createPropsRestProxy: createPropsRestProxy,
13182 withAsyncContext: withAsyncContext,
13183 getCurrentInstance: getCurrentInstance,
13184 h: h,
13185 createVNode: createVNode,
13186 cloneVNode: cloneVNode,
13187 mergeProps: mergeProps,
13188 isVNode: isVNode,
13189 Fragment: Fragment,
13190 Text: Text,
13191 Comment: Comment,
13192 Static: Static,
13193 Teleport: Teleport,
13194 Suspense: Suspense,
13195 KeepAlive: KeepAlive,
13196 BaseTransition: BaseTransition,
13197 withDirectives: withDirectives,
13198 useSSRContext: useSSRContext,
13199 ssrContextKey: ssrContextKey,
13200 createRenderer: createRenderer,
13201 createHydrationRenderer: createHydrationRenderer,
13202 queuePostFlushCb: queuePostFlushCb,
13203 warn: warn$1,
13204 handleError: handleError,
13205 callWithErrorHandling: callWithErrorHandling,
13206 callWithAsyncErrorHandling: callWithAsyncErrorHandling,
13207 resolveComponent: resolveComponent,
13208 resolveDirective: resolveDirective,
13209 resolveDynamicComponent: resolveDynamicComponent,
13210 registerRuntimeCompiler: registerRuntimeCompiler,
13211 isRuntimeOnly: isRuntimeOnly,
13212 useTransitionState: useTransitionState,
13213 resolveTransitionHooks: resolveTransitionHooks,
13214 setTransitionHooks: setTransitionHooks,
13215 getTransitionRawChildren: getTransitionRawChildren,
13216 initCustomFormatter: initCustomFormatter,
13217 get devtools () { return devtools; },
13218 setDevtoolsHook: setDevtoolsHook,
13219 withCtx: withCtx,
13220 pushScopeId: pushScopeId,
13221 popScopeId: popScopeId,
13222 withScopeId: withScopeId,
13223 renderList: renderList,
13224 toHandlers: toHandlers,
13225 renderSlot: renderSlot,
13226 createSlots: createSlots,
13227 withMemo: withMemo,
13228 isMemoSame: isMemoSame,
13229 openBlock: openBlock,
13230 createBlock: createBlock,
13231 setBlockTracking: setBlockTracking,
13232 createTextVNode: createTextVNode,
13233 createCommentVNode: createCommentVNode,
13234 createStaticVNode: createStaticVNode,
13235 createElementVNode: createBaseVNode,
13236 createElementBlock: createElementBlock,
13237 guardReactiveProps: guardReactiveProps,
13238 toDisplayString: toDisplayString,
13239 camelize: camelize,
13240 capitalize: capitalize,
13241 toHandlerKey: toHandlerKey,
13242 normalizeProps: normalizeProps,
13243 normalizeClass: normalizeClass,
13244 normalizeStyle: normalizeStyle,
13245 transformVNodeArgs: transformVNodeArgs,
13246 version: version,
13247 ssrUtils: ssrUtils,
13248 resolveFilter: resolveFilter$1,
13249 compatUtils: compatUtils
13250});
13251
13252// This entry exports the runtime only, and is built as
13253function wrappedCreateApp(...args) {
13254 // @ts-ignore
13255 const app = createApp(...args);
13256 if (compatUtils.isCompatEnabled("RENDER_FUNCTION" /* DeprecationTypes.RENDER_FUNCTION */, null)) {
13257 // register built-in components so that they can be resolved via strings
13258 // in the legacy h() call. The __compat__ prefix is to ensure that v3 h()
13259 // doesn't get affected.
13260 app.component('__compat__transition', Transition);
13261 app.component('__compat__transition-group', TransitionGroup);
13262 app.component('__compat__keep-alive', KeepAlive);
13263 // built-in directives. No need for prefix since there's no render fn API
13264 // for resolving directives via string in v3.
13265 app._context.directives.show = vShow;
13266 app._context.directives.model = vModelDynamic;
13267 }
13268 return app;
13269}
13270function createCompatVue$1() {
13271 const Vue = compatUtils.createCompatVue(createApp, wrappedCreateApp);
13272 extend(Vue, runtimeDom);
13273 return Vue;
13274}
13275
13276function defaultOnError(error) {
13277 throw error;
13278}
13279function defaultOnWarn(msg) {
13280 console.warn(`[Vue warn] ${msg.message}`);
13281}
13282function createCompilerError(code, loc, messages, additionalMessage) {
13283 const msg = (messages || errorMessages)[code] + (additionalMessage || ``)
13284 ;
13285 const error = new SyntaxError(String(msg));
13286 error.code = code;
13287 error.loc = loc;
13288 return error;
13289}
13290const errorMessages = {
13291 // parse errors
13292 [0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
13293 [1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
13294 [2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
13295 [3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
13296 [4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
13297 [5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
13298 [6 /* ErrorCodes.EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
13299 [7 /* ErrorCodes.EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
13300 [8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
13301 [9 /* ErrorCodes.EOF_IN_TAG */]: 'Unexpected EOF in tag.',
13302 [10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
13303 [11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
13304 [12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '&lt;' to print '<'.",
13305 [13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
13306 [14 /* ErrorCodes.MISSING_END_TAG_NAME */]: 'End tag name was expected.',
13307 [15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
13308 [16 /* ErrorCodes.NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
13309 [17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
13310 [18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
13311 [19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
13312 [21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
13313 [20 /* ErrorCodes.UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
13314 [22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
13315 // Vue-specific parse errors
13316 [23 /* ErrorCodes.X_INVALID_END_TAG */]: 'Invalid end tag.',
13317 [24 /* ErrorCodes.X_MISSING_END_TAG */]: 'Element is missing end tag.',
13318 [25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
13319 [27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
13320 'Note that dynamic directive argument cannot contain spaces.',
13321 [26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
13322 // transform errors
13323 [28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
13324 [29 /* ErrorCodes.X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
13325 [30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
13326 [31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
13327 [32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
13328 [33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
13329 [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
13330 [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
13331 [36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
13332 [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
13333 `When there are multiple named slots, all slots should use <template> ` +
13334 `syntax to avoid scope ambiguity.`,
13335 [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
13336 [39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
13337 `default slot. These children will be ignored.`,
13338 [40 /* ErrorCodes.X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
13339 [41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
13340 [42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
13341 [43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
13342 [44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
13343 [45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
13344 // generic errors
13345 [46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
13346 [47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
13347 [48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
13348 [49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
13349 // just to fulfill types
13350 [50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
13351};
13352
13353const FRAGMENT = Symbol(`Fragment` );
13354const TELEPORT = Symbol(`Teleport` );
13355const SUSPENSE = Symbol(`Suspense` );
13356const KEEP_ALIVE = Symbol(`KeepAlive` );
13357const BASE_TRANSITION = Symbol(`BaseTransition` );
13358const OPEN_BLOCK = Symbol(`openBlock` );
13359const CREATE_BLOCK = Symbol(`createBlock` );
13360const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
13361const CREATE_VNODE = Symbol(`createVNode` );
13362const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
13363const CREATE_COMMENT = Symbol(`createCommentVNode` );
13364const CREATE_TEXT = Symbol(`createTextVNode` );
13365const CREATE_STATIC = Symbol(`createStaticVNode` );
13366const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
13367const RESOLVE_DYNAMIC_COMPONENT = Symbol(`resolveDynamicComponent` );
13368const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
13369const RESOLVE_FILTER = Symbol(`resolveFilter` );
13370const WITH_DIRECTIVES = Symbol(`withDirectives` );
13371const RENDER_LIST = Symbol(`renderList` );
13372const RENDER_SLOT = Symbol(`renderSlot` );
13373const CREATE_SLOTS = Symbol(`createSlots` );
13374const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
13375const MERGE_PROPS = Symbol(`mergeProps` );
13376const NORMALIZE_CLASS = Symbol(`normalizeClass` );
13377const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
13378const NORMALIZE_PROPS = Symbol(`normalizeProps` );
13379const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
13380const TO_HANDLERS = Symbol(`toHandlers` );
13381const CAMELIZE = Symbol(`camelize` );
13382const CAPITALIZE = Symbol(`capitalize` );
13383const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
13384const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
13385const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
13386const POP_SCOPE_ID = Symbol(`popScopeId` );
13387const WITH_CTX = Symbol(`withCtx` );
13388const UNREF = Symbol(`unref` );
13389const IS_REF = Symbol(`isRef` );
13390const WITH_MEMO = Symbol(`withMemo` );
13391const IS_MEMO_SAME = Symbol(`isMemoSame` );
13392// Name mapping for runtime helpers that need to be imported from 'vue' in
13393// generated code. Make sure these are correctly exported in the runtime!
13394// Using `any` here because TS doesn't allow symbols as index type.
13395const helperNameMap = {
13396 [FRAGMENT]: `Fragment`,
13397 [TELEPORT]: `Teleport`,
13398 [SUSPENSE]: `Suspense`,
13399 [KEEP_ALIVE]: `KeepAlive`,
13400 [BASE_TRANSITION]: `BaseTransition`,
13401 [OPEN_BLOCK]: `openBlock`,
13402 [CREATE_BLOCK]: `createBlock`,
13403 [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
13404 [CREATE_VNODE]: `createVNode`,
13405 [CREATE_ELEMENT_VNODE]: `createElementVNode`,
13406 [CREATE_COMMENT]: `createCommentVNode`,
13407 [CREATE_TEXT]: `createTextVNode`,
13408 [CREATE_STATIC]: `createStaticVNode`,
13409 [RESOLVE_COMPONENT]: `resolveComponent`,
13410 [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
13411 [RESOLVE_DIRECTIVE]: `resolveDirective`,
13412 [RESOLVE_FILTER]: `resolveFilter`,
13413 [WITH_DIRECTIVES]: `withDirectives`,
13414 [RENDER_LIST]: `renderList`,
13415 [RENDER_SLOT]: `renderSlot`,
13416 [CREATE_SLOTS]: `createSlots`,
13417 [TO_DISPLAY_STRING]: `toDisplayString`,
13418 [MERGE_PROPS]: `mergeProps`,
13419 [NORMALIZE_CLASS]: `normalizeClass`,
13420 [NORMALIZE_STYLE]: `normalizeStyle`,
13421 [NORMALIZE_PROPS]: `normalizeProps`,
13422 [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
13423 [TO_HANDLERS]: `toHandlers`,
13424 [CAMELIZE]: `camelize`,
13425 [CAPITALIZE]: `capitalize`,
13426 [TO_HANDLER_KEY]: `toHandlerKey`,
13427 [SET_BLOCK_TRACKING]: `setBlockTracking`,
13428 [PUSH_SCOPE_ID]: `pushScopeId`,
13429 [POP_SCOPE_ID]: `popScopeId`,
13430 [WITH_CTX]: `withCtx`,
13431 [UNREF]: `unref`,
13432 [IS_REF]: `isRef`,
13433 [WITH_MEMO]: `withMemo`,
13434 [IS_MEMO_SAME]: `isMemoSame`
13435};
13436function registerRuntimeHelpers(helpers) {
13437 Object.getOwnPropertySymbols(helpers).forEach(s => {
13438 helperNameMap[s] = helpers[s];
13439 });
13440}
13441
13442// AST Utilities ---------------------------------------------------------------
13443// Some expressions, e.g. sequence and conditional expressions, are never
13444// associated with template nodes, so their source locations are just a stub.
13445// Container types like CompoundExpression also don't need a real location.
13446const locStub = {
13447 source: '',
13448 start: { line: 1, column: 1, offset: 0 },
13449 end: { line: 1, column: 1, offset: 0 }
13450};
13451function createRoot(children, loc = locStub) {
13452 return {
13453 type: 0 /* NodeTypes.ROOT */,
13454 children,
13455 helpers: [],
13456 components: [],
13457 directives: [],
13458 hoists: [],
13459 imports: [],
13460 cached: 0,
13461 temps: 0,
13462 codegenNode: undefined,
13463 loc
13464 };
13465}
13466function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
13467 if (context) {
13468 if (isBlock) {
13469 context.helper(OPEN_BLOCK);
13470 context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
13471 }
13472 else {
13473 context.helper(getVNodeHelper(context.inSSR, isComponent));
13474 }
13475 if (directives) {
13476 context.helper(WITH_DIRECTIVES);
13477 }
13478 }
13479 return {
13480 type: 13 /* NodeTypes.VNODE_CALL */,
13481 tag,
13482 props,
13483 children,
13484 patchFlag,
13485 dynamicProps,
13486 directives,
13487 isBlock,
13488 disableTracking,
13489 isComponent,
13490 loc
13491 };
13492}
13493function createArrayExpression(elements, loc = locStub) {
13494 return {
13495 type: 17 /* NodeTypes.JS_ARRAY_EXPRESSION */,
13496 loc,
13497 elements
13498 };
13499}
13500function createObjectExpression(properties, loc = locStub) {
13501 return {
13502 type: 15 /* NodeTypes.JS_OBJECT_EXPRESSION */,
13503 loc,
13504 properties
13505 };
13506}
13507function createObjectProperty(key, value) {
13508 return {
13509 type: 16 /* NodeTypes.JS_PROPERTY */,
13510 loc: locStub,
13511 key: isString(key) ? createSimpleExpression(key, true) : key,
13512 value
13513 };
13514}
13515function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* ConstantTypes.NOT_CONSTANT */) {
13516 return {
13517 type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
13518 loc,
13519 content,
13520 isStatic,
13521 constType: isStatic ? 3 /* ConstantTypes.CAN_STRINGIFY */ : constType
13522 };
13523}
13524function createCompoundExpression(children, loc = locStub) {
13525 return {
13526 type: 8 /* NodeTypes.COMPOUND_EXPRESSION */,
13527 loc,
13528 children
13529 };
13530}
13531function createCallExpression(callee, args = [], loc = locStub) {
13532 return {
13533 type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
13534 loc,
13535 callee,
13536 arguments: args
13537 };
13538}
13539function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
13540 return {
13541 type: 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */,
13542 params,
13543 returns,
13544 newline,
13545 isSlot,
13546 loc
13547 };
13548}
13549function createConditionalExpression(test, consequent, alternate, newline = true) {
13550 return {
13551 type: 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */,
13552 test,
13553 consequent,
13554 alternate,
13555 newline,
13556 loc: locStub
13557 };
13558}
13559function createCacheExpression(index, value, isVNode = false) {
13560 return {
13561 type: 20 /* NodeTypes.JS_CACHE_EXPRESSION */,
13562 index,
13563 value,
13564 isVNode,
13565 loc: locStub
13566 };
13567}
13568function createBlockStatement(body) {
13569 return {
13570 type: 21 /* NodeTypes.JS_BLOCK_STATEMENT */,
13571 body,
13572 loc: locStub
13573 };
13574}
13575
13576const isStaticExp = (p) => p.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && p.isStatic;
13577const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
13578function isCoreComponent(tag) {
13579 if (isBuiltInType(tag, 'Teleport')) {
13580 return TELEPORT;
13581 }
13582 else if (isBuiltInType(tag, 'Suspense')) {
13583 return SUSPENSE;
13584 }
13585 else if (isBuiltInType(tag, 'KeepAlive')) {
13586 return KEEP_ALIVE;
13587 }
13588 else if (isBuiltInType(tag, 'BaseTransition')) {
13589 return BASE_TRANSITION;
13590 }
13591}
13592const nonIdentifierRE = /^\d|[^\$\w]/;
13593const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
13594const isMemberExpressionNode = (path, context) => {
13595 try {
13596 let ret = parser.parseExpression(path, {
13597 plugins: context.expressionPlugins
13598 });
13599 if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
13600 ret = ret.expression;
13601 }
13602 return (ret.type === 'MemberExpression' ||
13603 ret.type === 'OptionalMemberExpression' ||
13604 ret.type === 'Identifier');
13605 }
13606 catch (e) {
13607 return false;
13608 }
13609 };
13610const isMemberExpression = isMemberExpressionNode;
13611function getInnerRange(loc, offset, length) {
13612 const source = loc.source.slice(offset, offset + length);
13613 const newLoc = {
13614 source,
13615 start: advancePositionWithClone(loc.start, loc.source, offset),
13616 end: loc.end
13617 };
13618 if (length != null) {
13619 newLoc.end = advancePositionWithClone(loc.start, loc.source, offset + length);
13620 }
13621 return newLoc;
13622}
13623function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
13624 return advancePositionWithMutation(extend({}, pos), source, numberOfCharacters);
13625}
13626// advance by mutation without cloning (for performance reasons), since this
13627// gets called a lot in the parser
13628function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
13629 let linesCount = 0;
13630 let lastNewLinePos = -1;
13631 for (let i = 0; i < numberOfCharacters; i++) {
13632 if (source.charCodeAt(i) === 10 /* newline char code */) {
13633 linesCount++;
13634 lastNewLinePos = i;
13635 }
13636 }
13637 pos.offset += numberOfCharacters;
13638 pos.line += linesCount;
13639 pos.column =
13640 lastNewLinePos === -1
13641 ? pos.column + numberOfCharacters
13642 : numberOfCharacters - lastNewLinePos;
13643 return pos;
13644}
13645function assert(condition, msg) {
13646 /* istanbul ignore if */
13647 if (!condition) {
13648 throw new Error(msg || `unexpected compiler condition`);
13649 }
13650}
13651function findDir(node, name, allowEmpty = false) {
13652 for (let i = 0; i < node.props.length; i++) {
13653 const p = node.props[i];
13654 if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
13655 (allowEmpty || p.exp) &&
13656 (isString(name) ? p.name === name : name.test(p.name))) {
13657 return p;
13658 }
13659 }
13660}
13661function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
13662 for (let i = 0; i < node.props.length; i++) {
13663 const p = node.props[i];
13664 if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
13665 if (dynamicOnly)
13666 continue;
13667 if (p.name === name && (p.value || allowEmpty)) {
13668 return p;
13669 }
13670 }
13671 else if (p.name === 'bind' &&
13672 (p.exp || allowEmpty) &&
13673 isStaticArgOf(p.arg, name)) {
13674 return p;
13675 }
13676 }
13677}
13678function isStaticArgOf(arg, name) {
13679 return !!(arg && isStaticExp(arg) && arg.content === name);
13680}
13681function hasDynamicKeyVBind(node) {
13682 return node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
13683 p.name === 'bind' &&
13684 (!p.arg || // v-bind="obj"
13685 p.arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
13686 !p.arg.isStatic) // v-bind:[foo]
13687 );
13688}
13689function isText(node) {
13690 return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
13691}
13692function isVSlot(p) {
13693 return p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'slot';
13694}
13695function isTemplateNode(node) {
13696 return (node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 3 /* ElementTypes.TEMPLATE */);
13697}
13698function isSlotOutlet(node) {
13699 return node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 2 /* ElementTypes.SLOT */;
13700}
13701function getVNodeHelper(ssr, isComponent) {
13702 return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
13703}
13704function getVNodeBlockHelper(ssr, isComponent) {
13705 return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
13706}
13707const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
13708function getUnnormalizedProps(props, callPath = []) {
13709 if (props &&
13710 !isString(props) &&
13711 props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
13712 const callee = props.callee;
13713 if (!isString(callee) && propsHelperSet.has(callee)) {
13714 return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
13715 }
13716 }
13717 return [props, callPath];
13718}
13719function injectProp(node, prop, context) {
13720 let propsWithInjection;
13721 /**
13722 * 1. mergeProps(...)
13723 * 2. toHandlers(...)
13724 * 3. normalizeProps(...)
13725 * 4. normalizeProps(guardReactiveProps(...))
13726 *
13727 * we need to get the real props before normalization
13728 */
13729 let props = node.type === 13 /* NodeTypes.VNODE_CALL */ ? node.props : node.arguments[2];
13730 let callPath = [];
13731 let parentCall;
13732 if (props &&
13733 !isString(props) &&
13734 props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
13735 const ret = getUnnormalizedProps(props);
13736 props = ret[0];
13737 callPath = ret[1];
13738 parentCall = callPath[callPath.length - 1];
13739 }
13740 if (props == null || isString(props)) {
13741 propsWithInjection = createObjectExpression([prop]);
13742 }
13743 else if (props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
13744 // merged props... add ours
13745 // only inject key to object literal if it's the first argument so that
13746 // if doesn't override user provided keys
13747 const first = props.arguments[0];
13748 if (!isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
13749 first.properties.unshift(prop);
13750 }
13751 else {
13752 if (props.callee === TO_HANDLERS) {
13753 // #2366
13754 propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
13755 createObjectExpression([prop]),
13756 props
13757 ]);
13758 }
13759 else {
13760 props.arguments.unshift(createObjectExpression([prop]));
13761 }
13762 }
13763 !propsWithInjection && (propsWithInjection = props);
13764 }
13765 else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
13766 let alreadyExists = false;
13767 // check existing key to avoid overriding user provided keys
13768 if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
13769 const propKeyName = prop.key.content;
13770 alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
13771 p.key.content === propKeyName);
13772 }
13773 if (!alreadyExists) {
13774 props.properties.unshift(prop);
13775 }
13776 propsWithInjection = props;
13777 }
13778 else {
13779 // single v-bind with expression, return a merged replacement
13780 propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
13781 createObjectExpression([prop]),
13782 props
13783 ]);
13784 // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(props))`,
13785 // it will be rewritten as `normalizeProps(mergeProps({ key: 0 }, props))`,
13786 // the `guardReactiveProps` will no longer be needed
13787 if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
13788 parentCall = callPath[callPath.length - 2];
13789 }
13790 }
13791 if (node.type === 13 /* NodeTypes.VNODE_CALL */) {
13792 if (parentCall) {
13793 parentCall.arguments[0] = propsWithInjection;
13794 }
13795 else {
13796 node.props = propsWithInjection;
13797 }
13798 }
13799 else {
13800 if (parentCall) {
13801 parentCall.arguments[0] = propsWithInjection;
13802 }
13803 else {
13804 node.arguments[2] = propsWithInjection;
13805 }
13806 }
13807}
13808function toValidAssetId(name, type) {
13809 // see issue#4422, we need adding identifier on validAssetId if variable `name` has specific character
13810 return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
13811 return searchValue === '-' ? '_' : name.charCodeAt(replaceValue).toString();
13812 })}`;
13813}
13814// Check if a node contains expressions that reference current context scope ids
13815function hasScopeRef(node, ids) {
13816 if (!node || Object.keys(ids).length === 0) {
13817 return false;
13818 }
13819 switch (node.type) {
13820 case 1 /* NodeTypes.ELEMENT */:
13821 for (let i = 0; i < node.props.length; i++) {
13822 const p = node.props[i];
13823 if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
13824 (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
13825 return true;
13826 }
13827 }
13828 return node.children.some(c => hasScopeRef(c, ids));
13829 case 11 /* NodeTypes.FOR */:
13830 if (hasScopeRef(node.source, ids)) {
13831 return true;
13832 }
13833 return node.children.some(c => hasScopeRef(c, ids));
13834 case 9 /* NodeTypes.IF */:
13835 return node.branches.some(b => hasScopeRef(b, ids));
13836 case 10 /* NodeTypes.IF_BRANCH */:
13837 if (hasScopeRef(node.condition, ids)) {
13838 return true;
13839 }
13840 return node.children.some(c => hasScopeRef(c, ids));
13841 case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
13842 return (!node.isStatic &&
13843 isSimpleIdentifier(node.content) &&
13844 !!ids[node.content]);
13845 case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
13846 return node.children.some(c => isObject(c) && hasScopeRef(c, ids));
13847 case 5 /* NodeTypes.INTERPOLATION */:
13848 case 12 /* NodeTypes.TEXT_CALL */:
13849 return hasScopeRef(node.content, ids);
13850 case 2 /* NodeTypes.TEXT */:
13851 case 3 /* NodeTypes.COMMENT */:
13852 return false;
13853 default:
13854 return false;
13855 }
13856}
13857function getMemoedVNodeCall(node) {
13858 if (node.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
13859 return node.arguments[1].returns;
13860 }
13861 else {
13862 return node;
13863 }
13864}
13865function makeBlock(node, { helper, removeHelper, inSSR }) {
13866 if (!node.isBlock) {
13867 node.isBlock = true;
13868 removeHelper(getVNodeHelper(inSSR, node.isComponent));
13869 helper(OPEN_BLOCK);
13870 helper(getVNodeBlockHelper(inSSR, node.isComponent));
13871 }
13872}
13873
13874const deprecationData$1 = {
13875 ["COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */]: {
13876 message: `Platform-native elements with "is" prop will no longer be ` +
13877 `treated as components in Vue 3 unless the "is" value is explicitly ` +
13878 `prefixed with "vue:".`,
13879 link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
13880 },
13881 ["COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */]: {
13882 message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
13883 `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
13884 `\`v-model:${key}\`.`,
13885 link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
13886 },
13887 ["COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */]: {
13888 message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
13889 `Vue 3 will automatically set a binding as DOM property when appropriate.`
13890 },
13891 ["COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */]: {
13892 message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
13893 `object spread: it will now overwrite an existing non-mergeable attribute ` +
13894 `that appears before v-bind in the case of conflict. ` +
13895 `To retain 2.x behavior, move v-bind to make it the first attribute. ` +
13896 `You can also suppress this warning if the usage is intended.`,
13897 link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
13898 },
13899 ["COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */]: {
13900 message: `.native modifier for v-on has been removed as is no longer necessary.`,
13901 link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
13902 },
13903 ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
13904 message: `v-if / v-for precedence when used on the same element has changed ` +
13905 `in Vue 3: v-if now takes higher precedence and will no longer have ` +
13906 `access to v-for scope variables. It is best to avoid the ambiguity ` +
13907 `with <template> tags or use a computed property that filters v-for ` +
13908 `data source.`,
13909 link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
13910 },
13911 ["COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */]: {
13912 message: `<template> with no special directives will render as a native template ` +
13913 `element instead of its inner content in Vue 3.`
13914 },
13915 ["COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */]: {
13916 message: `"inline-template" has been removed in Vue 3.`,
13917 link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
13918 },
13919 ["COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */]: {
13920 message: `filters have been removed in Vue 3. ` +
13921 `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
13922 `Use method calls or computed properties instead.`,
13923 link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
13924 }
13925};
13926function getCompatValue(key, context) {
13927 const config = context.options
13928 ? context.options.compatConfig
13929 : context.compatConfig;
13930 const value = config && config[key];
13931 if (key === 'MODE') {
13932 return value || 3; // compiler defaults to v3 behavior
13933 }
13934 else {
13935 return value;
13936 }
13937}
13938function isCompatEnabled$1(key, context) {
13939 const mode = getCompatValue('MODE', context);
13940 const value = getCompatValue(key, context);
13941 // in v3 mode, only enable if explicitly set to true
13942 // otherwise enable for any non-false value
13943 return mode === 3 ? value === true : value !== false;
13944}
13945function checkCompatEnabled$1(key, context, loc, ...args) {
13946 const enabled = isCompatEnabled$1(key, context);
13947 if (enabled) {
13948 warnDeprecation$1(key, context, loc, ...args);
13949 }
13950 return enabled;
13951}
13952function warnDeprecation$1(key, context, loc, ...args) {
13953 const val = getCompatValue(key, context);
13954 if (val === 'suppress-warning') {
13955 return;
13956 }
13957 const { message, link } = deprecationData$1[key];
13958 const msg = `(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`;
13959 const err = new SyntaxError(msg);
13960 err.code = key;
13961 if (loc)
13962 err.loc = loc;
13963 context.onWarn(err);
13964}
13965
13966// The default decoder only provides escapes for characters reserved as part of
13967// the template syntax, and is only used if the custom renderer did not provide
13968// a platform-specific decoder.
13969const decodeRE = /&(gt|lt|amp|apos|quot);/g;
13970const decodeMap = {
13971 gt: '>',
13972 lt: '<',
13973 amp: '&',
13974 apos: "'",
13975 quot: '"'
13976};
13977const defaultParserOptions = {
13978 delimiters: [`{{`, `}}`],
13979 getNamespace: () => 0 /* Namespaces.HTML */,
13980 getTextMode: () => 0 /* TextModes.DATA */,
13981 isVoidTag: NO,
13982 isPreTag: NO,
13983 isCustomElement: NO,
13984 decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
13985 onError: defaultOnError,
13986 onWarn: defaultOnWarn,
13987 comments: true
13988};
13989function baseParse(content, options = {}) {
13990 const context = createParserContext(content, options);
13991 const start = getCursor(context);
13992 return createRoot(parseChildren(context, 0 /* TextModes.DATA */, []), getSelection(context, start));
13993}
13994function createParserContext(content, rawOptions) {
13995 const options = extend({}, defaultParserOptions);
13996 let key;
13997 for (key in rawOptions) {
13998 // @ts-ignore
13999 options[key] =
14000 rawOptions[key] === undefined
14001 ? defaultParserOptions[key]
14002 : rawOptions[key];
14003 }
14004 return {
14005 options,
14006 column: 1,
14007 line: 1,
14008 offset: 0,
14009 originalSource: content,
14010 source: content,
14011 inPre: false,
14012 inVPre: false,
14013 onWarn: options.onWarn
14014 };
14015}
14016function parseChildren(context, mode, ancestors) {
14017 const parent = last(ancestors);
14018 const ns = parent ? parent.ns : 0 /* Namespaces.HTML */;
14019 const nodes = [];
14020 while (!isEnd(context, mode, ancestors)) {
14021 const s = context.source;
14022 let node = undefined;
14023 if (mode === 0 /* TextModes.DATA */ || mode === 1 /* TextModes.RCDATA */) {
14024 if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
14025 // '{{'
14026 node = parseInterpolation(context, mode);
14027 }
14028 else if (mode === 0 /* TextModes.DATA */ && s[0] === '<') {
14029 // https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
14030 if (s.length === 1) {
14031 emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 1);
14032 }
14033 else if (s[1] === '!') {
14034 // https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state
14035 if (startsWith(s, '<!--')) {
14036 node = parseComment(context);
14037 }
14038 else if (startsWith(s, '<!DOCTYPE')) {
14039 // Ignore DOCTYPE by a limitation.
14040 node = parseBogusComment(context);
14041 }
14042 else if (startsWith(s, '<![CDATA[')) {
14043 if (ns !== 0 /* Namespaces.HTML */) {
14044 node = parseCDATA(context, ancestors);
14045 }
14046 else {
14047 emitError(context, 1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */);
14048 node = parseBogusComment(context);
14049 }
14050 }
14051 else {
14052 emitError(context, 11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */);
14053 node = parseBogusComment(context);
14054 }
14055 }
14056 else if (s[1] === '/') {
14057 // https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
14058 if (s.length === 2) {
14059 emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 2);
14060 }
14061 else if (s[2] === '>') {
14062 emitError(context, 14 /* ErrorCodes.MISSING_END_TAG_NAME */, 2);
14063 advanceBy(context, 3);
14064 continue;
14065 }
14066 else if (/[a-z]/i.test(s[2])) {
14067 emitError(context, 23 /* ErrorCodes.X_INVALID_END_TAG */);
14068 parseTag(context, 1 /* TagType.End */, parent);
14069 continue;
14070 }
14071 else {
14072 emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
14073 node = parseBogusComment(context);
14074 }
14075 }
14076 else if (/[a-z]/i.test(s[1])) {
14077 node = parseElement(context, ancestors);
14078 // 2.x <template> with no directive compat
14079 if (isCompatEnabled$1("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context) &&
14080 node &&
14081 node.tag === 'template' &&
14082 !node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
14083 isSpecialTemplateDirective(p.name))) {
14084 warnDeprecation$1("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context, node.loc);
14085 node = node.children;
14086 }
14087 }
14088 else if (s[1] === '?') {
14089 emitError(context, 21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
14090 node = parseBogusComment(context);
14091 }
14092 else {
14093 emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
14094 }
14095 }
14096 }
14097 if (!node) {
14098 node = parseText(context, mode);
14099 }
14100 if (isArray(node)) {
14101 for (let i = 0; i < node.length; i++) {
14102 pushNode(nodes, node[i]);
14103 }
14104 }
14105 else {
14106 pushNode(nodes, node);
14107 }
14108 }
14109 // Whitespace handling strategy like v2
14110 let removedWhitespace = false;
14111 if (mode !== 2 /* TextModes.RAWTEXT */ && mode !== 1 /* TextModes.RCDATA */) {
14112 const shouldCondense = context.options.whitespace !== 'preserve';
14113 for (let i = 0; i < nodes.length; i++) {
14114 const node = nodes[i];
14115 if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
14116 if (!/[^\t\r\n\f ]/.test(node.content)) {
14117 const prev = nodes[i - 1];
14118 const next = nodes[i + 1];
14119 // Remove if:
14120 // - the whitespace is the first or last node, or:
14121 // - (condense mode) the whitespace is adjacent to a comment, or:
14122 // - (condense mode) the whitespace is between two elements AND contains newline
14123 if (!prev ||
14124 !next ||
14125 (shouldCondense &&
14126 (prev.type === 3 /* NodeTypes.COMMENT */ ||
14127 next.type === 3 /* NodeTypes.COMMENT */ ||
14128 (prev.type === 1 /* NodeTypes.ELEMENT */ &&
14129 next.type === 1 /* NodeTypes.ELEMENT */ &&
14130 /[\r\n]/.test(node.content))))) {
14131 removedWhitespace = true;
14132 nodes[i] = null;
14133 }
14134 else {
14135 // Otherwise, the whitespace is condensed into a single space
14136 node.content = ' ';
14137 }
14138 }
14139 else if (shouldCondense) {
14140 // in condense mode, consecutive whitespaces in text are condensed
14141 // down to a single space.
14142 node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
14143 }
14144 }
14145 // Remove comment nodes if desired by configuration.
14146 else if (node.type === 3 /* NodeTypes.COMMENT */ && !context.options.comments) {
14147 removedWhitespace = true;
14148 nodes[i] = null;
14149 }
14150 }
14151 if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
14152 // remove leading newline per html spec
14153 // https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element
14154 const first = nodes[0];
14155 if (first && first.type === 2 /* NodeTypes.TEXT */) {
14156 first.content = first.content.replace(/^\r?\n/, '');
14157 }
14158 }
14159 }
14160 return removedWhitespace ? nodes.filter(Boolean) : nodes;
14161}
14162function pushNode(nodes, node) {
14163 if (node.type === 2 /* NodeTypes.TEXT */) {
14164 const prev = last(nodes);
14165 // Merge if both this and the previous node are text and those are
14166 // consecutive. This happens for cases like "a < b".
14167 if (prev &&
14168 prev.type === 2 /* NodeTypes.TEXT */ &&
14169 prev.loc.end.offset === node.loc.start.offset) {
14170 prev.content += node.content;
14171 prev.loc.end = node.loc.end;
14172 prev.loc.source += node.loc.source;
14173 return;
14174 }
14175 }
14176 nodes.push(node);
14177}
14178function parseCDATA(context, ancestors) {
14179 advanceBy(context, 9);
14180 const nodes = parseChildren(context, 3 /* TextModes.CDATA */, ancestors);
14181 if (context.source.length === 0) {
14182 emitError(context, 6 /* ErrorCodes.EOF_IN_CDATA */);
14183 }
14184 else {
14185 advanceBy(context, 3);
14186 }
14187 return nodes;
14188}
14189function parseComment(context) {
14190 const start = getCursor(context);
14191 let content;
14192 // Regular comment.
14193 const match = /--(\!)?>/.exec(context.source);
14194 if (!match) {
14195 content = context.source.slice(4);
14196 advanceBy(context, context.source.length);
14197 emitError(context, 7 /* ErrorCodes.EOF_IN_COMMENT */);
14198 }
14199 else {
14200 if (match.index <= 3) {
14201 emitError(context, 0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
14202 }
14203 if (match[1]) {
14204 emitError(context, 10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */);
14205 }
14206 content = context.source.slice(4, match.index);
14207 // Advancing with reporting nested comments.
14208 const s = context.source.slice(0, match.index);
14209 let prevIndex = 1, nestedIndex = 0;
14210 while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
14211 advanceBy(context, nestedIndex - prevIndex + 1);
14212 if (nestedIndex + 4 < s.length) {
14213 emitError(context, 16 /* ErrorCodes.NESTED_COMMENT */);
14214 }
14215 prevIndex = nestedIndex + 1;
14216 }
14217 advanceBy(context, match.index + match[0].length - prevIndex + 1);
14218 }
14219 return {
14220 type: 3 /* NodeTypes.COMMENT */,
14221 content,
14222 loc: getSelection(context, start)
14223 };
14224}
14225function parseBogusComment(context) {
14226 const start = getCursor(context);
14227 const contentStart = context.source[1] === '?' ? 1 : 2;
14228 let content;
14229 const closeIndex = context.source.indexOf('>');
14230 if (closeIndex === -1) {
14231 content = context.source.slice(contentStart);
14232 advanceBy(context, context.source.length);
14233 }
14234 else {
14235 content = context.source.slice(contentStart, closeIndex);
14236 advanceBy(context, closeIndex + 1);
14237 }
14238 return {
14239 type: 3 /* NodeTypes.COMMENT */,
14240 content,
14241 loc: getSelection(context, start)
14242 };
14243}
14244function parseElement(context, ancestors) {
14245 // Start tag.
14246 const wasInPre = context.inPre;
14247 const wasInVPre = context.inVPre;
14248 const parent = last(ancestors);
14249 const element = parseTag(context, 0 /* TagType.Start */, parent);
14250 const isPreBoundary = context.inPre && !wasInPre;
14251 const isVPreBoundary = context.inVPre && !wasInVPre;
14252 if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
14253 // #4030 self-closing <pre> tag
14254 if (isPreBoundary) {
14255 context.inPre = false;
14256 }
14257 if (isVPreBoundary) {
14258 context.inVPre = false;
14259 }
14260 return element;
14261 }
14262 // Children.
14263 ancestors.push(element);
14264 const mode = context.options.getTextMode(element, parent);
14265 const children = parseChildren(context, mode, ancestors);
14266 ancestors.pop();
14267 // 2.x inline-template compat
14268 {
14269 const inlineTemplateProp = element.props.find(p => p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'inline-template');
14270 if (inlineTemplateProp &&
14271 checkCompatEnabled$1("COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
14272 const loc = getSelection(context, element.loc.end);
14273 inlineTemplateProp.value = {
14274 type: 2 /* NodeTypes.TEXT */,
14275 content: loc.source,
14276 loc
14277 };
14278 }
14279 }
14280 element.children = children;
14281 // End tag.
14282 if (startsWithEndTagOpen(context.source, element.tag)) {
14283 parseTag(context, 1 /* TagType.End */, parent);
14284 }
14285 else {
14286 emitError(context, 24 /* ErrorCodes.X_MISSING_END_TAG */, 0, element.loc.start);
14287 if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
14288 const first = children[0];
14289 if (first && startsWith(first.loc.source, '<!--')) {
14290 emitError(context, 8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
14291 }
14292 }
14293 }
14294 element.loc = getSelection(context, element.loc.start);
14295 if (isPreBoundary) {
14296 context.inPre = false;
14297 }
14298 if (isVPreBoundary) {
14299 context.inVPre = false;
14300 }
14301 return element;
14302}
14303const isSpecialTemplateDirective = /*#__PURE__*/ makeMap(`if,else,else-if,for,slot`);
14304function parseTag(context, type, parent) {
14305 // Tag open.
14306 const start = getCursor(context);
14307 const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
14308 const tag = match[1];
14309 const ns = context.options.getNamespace(tag, parent);
14310 advanceBy(context, match[0].length);
14311 advanceSpaces(context);
14312 // save current state in case we need to re-parse attributes with v-pre
14313 const cursor = getCursor(context);
14314 const currentSource = context.source;
14315 // check <pre> tag
14316 if (context.options.isPreTag(tag)) {
14317 context.inPre = true;
14318 }
14319 // Attributes.
14320 let props = parseAttributes(context, type);
14321 // check v-pre
14322 if (type === 0 /* TagType.Start */ &&
14323 !context.inVPre &&
14324 props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'pre')) {
14325 context.inVPre = true;
14326 // reset context
14327 extend(context, cursor);
14328 context.source = currentSource;
14329 // re-parse attrs and filter out v-pre itself
14330 props = parseAttributes(context, type).filter(p => p.name !== 'v-pre');
14331 }
14332 // Tag close.
14333 let isSelfClosing = false;
14334 if (context.source.length === 0) {
14335 emitError(context, 9 /* ErrorCodes.EOF_IN_TAG */);
14336 }
14337 else {
14338 isSelfClosing = startsWith(context.source, '/>');
14339 if (type === 1 /* TagType.End */ && isSelfClosing) {
14340 emitError(context, 4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */);
14341 }
14342 advanceBy(context, isSelfClosing ? 2 : 1);
14343 }
14344 if (type === 1 /* TagType.End */) {
14345 return;
14346 }
14347 // 2.x deprecation checks
14348 if (isCompatEnabled$1("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context)) {
14349 let hasIf = false;
14350 let hasFor = false;
14351 for (let i = 0; i < props.length; i++) {
14352 const p = props[i];
14353 if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
14354 if (p.name === 'if') {
14355 hasIf = true;
14356 }
14357 else if (p.name === 'for') {
14358 hasFor = true;
14359 }
14360 }
14361 if (hasIf && hasFor) {
14362 warnDeprecation$1("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
14363 break;
14364 }
14365 }
14366 }
14367 let tagType = 0 /* ElementTypes.ELEMENT */;
14368 if (!context.inVPre) {
14369 if (tag === 'slot') {
14370 tagType = 2 /* ElementTypes.SLOT */;
14371 }
14372 else if (tag === 'template') {
14373 if (props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
14374 tagType = 3 /* ElementTypes.TEMPLATE */;
14375 }
14376 }
14377 else if (isComponent(tag, props, context)) {
14378 tagType = 1 /* ElementTypes.COMPONENT */;
14379 }
14380 }
14381 return {
14382 type: 1 /* NodeTypes.ELEMENT */,
14383 ns,
14384 tag,
14385 tagType,
14386 props,
14387 isSelfClosing,
14388 children: [],
14389 loc: getSelection(context, start),
14390 codegenNode: undefined // to be created during transform phase
14391 };
14392}
14393function isComponent(tag, props, context) {
14394 const options = context.options;
14395 if (options.isCustomElement(tag)) {
14396 return false;
14397 }
14398 if (tag === 'component' ||
14399 /^[A-Z]/.test(tag) ||
14400 isCoreComponent(tag) ||
14401 (options.isBuiltInComponent && options.isBuiltInComponent(tag)) ||
14402 (options.isNativeTag && !options.isNativeTag(tag))) {
14403 return true;
14404 }
14405 // at this point the tag should be a native tag, but check for potential "is"
14406 // casting
14407 for (let i = 0; i < props.length; i++) {
14408 const p = props[i];
14409 if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
14410 if (p.name === 'is' && p.value) {
14411 if (p.value.content.startsWith('vue:')) {
14412 return true;
14413 }
14414 else if (checkCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
14415 return true;
14416 }
14417 }
14418 }
14419 else {
14420 // directive
14421 // v-is (TODO Deprecate)
14422 if (p.name === 'is') {
14423 return true;
14424 }
14425 else if (
14426 // :is on plain element - only treat as component in compat mode
14427 p.name === 'bind' &&
14428 isStaticArgOf(p.arg, 'is') &&
14429 true &&
14430 checkCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
14431 return true;
14432 }
14433 }
14434 }
14435}
14436function parseAttributes(context, type) {
14437 const props = [];
14438 const attributeNames = new Set();
14439 while (context.source.length > 0 &&
14440 !startsWith(context.source, '>') &&
14441 !startsWith(context.source, '/>')) {
14442 if (startsWith(context.source, '/')) {
14443 emitError(context, 22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */);
14444 advanceBy(context, 1);
14445 advanceSpaces(context);
14446 continue;
14447 }
14448 if (type === 1 /* TagType.End */) {
14449 emitError(context, 3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */);
14450 }
14451 const attr = parseAttribute(context, attributeNames);
14452 // Trim whitespace between class
14453 // https://github.com/vuejs/core/issues/4251
14454 if (attr.type === 6 /* NodeTypes.ATTRIBUTE */ &&
14455 attr.value &&
14456 attr.name === 'class') {
14457 attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
14458 }
14459 if (type === 0 /* TagType.Start */) {
14460 props.push(attr);
14461 }
14462 if (/^[^\t\r\n\f />]/.test(context.source)) {
14463 emitError(context, 15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
14464 }
14465 advanceSpaces(context);
14466 }
14467 return props;
14468}
14469function parseAttribute(context, nameSet) {
14470 // Name.
14471 const start = getCursor(context);
14472 const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
14473 const name = match[0];
14474 if (nameSet.has(name)) {
14475 emitError(context, 2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */);
14476 }
14477 nameSet.add(name);
14478 if (name[0] === '=') {
14479 emitError(context, 19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
14480 }
14481 {
14482 const pattern = /["'<]/g;
14483 let m;
14484 while ((m = pattern.exec(name))) {
14485 emitError(context, 17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
14486 }
14487 }
14488 advanceBy(context, name.length);
14489 // Value
14490 let value = undefined;
14491 if (/^[\t\r\n\f ]*=/.test(context.source)) {
14492 advanceSpaces(context);
14493 advanceBy(context, 1);
14494 advanceSpaces(context);
14495 value = parseAttributeValue(context);
14496 if (!value) {
14497 emitError(context, 13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */);
14498 }
14499 }
14500 const loc = getSelection(context, start);
14501 if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
14502 const match = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(name);
14503 let isPropShorthand = startsWith(name, '.');
14504 let dirName = match[1] ||
14505 (isPropShorthand || startsWith(name, ':')
14506 ? 'bind'
14507 : startsWith(name, '@')
14508 ? 'on'
14509 : 'slot');
14510 let arg;
14511 if (match[2]) {
14512 const isSlot = dirName === 'slot';
14513 const startOffset = name.lastIndexOf(match[2]);
14514 const loc = getSelection(context, getNewPosition(context, start, startOffset), getNewPosition(context, start, startOffset + match[2].length + ((isSlot && match[3]) || '').length));
14515 let content = match[2];
14516 let isStatic = true;
14517 if (content.startsWith('[')) {
14518 isStatic = false;
14519 if (!content.endsWith(']')) {
14520 emitError(context, 27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
14521 content = content.slice(1);
14522 }
14523 else {
14524 content = content.slice(1, content.length - 1);
14525 }
14526 }
14527 else if (isSlot) {
14528 // #1241 special case for v-slot: vuetify relies extensively on slot
14529 // names containing dots. v-slot doesn't have any modifiers and Vue 2.x
14530 // supports such usage so we are keeping it consistent with 2.x.
14531 content += match[3] || '';
14532 }
14533 arg = {
14534 type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
14535 content,
14536 isStatic,
14537 constType: isStatic
14538 ? 3 /* ConstantTypes.CAN_STRINGIFY */
14539 : 0 /* ConstantTypes.NOT_CONSTANT */,
14540 loc
14541 };
14542 }
14543 if (value && value.isQuoted) {
14544 const valueLoc = value.loc;
14545 valueLoc.start.offset++;
14546 valueLoc.start.column++;
14547 valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
14548 valueLoc.source = valueLoc.source.slice(1, -1);
14549 }
14550 const modifiers = match[3] ? match[3].slice(1).split('.') : [];
14551 if (isPropShorthand)
14552 modifiers.push('prop');
14553 // 2.x compat v-bind:foo.sync -> v-model:foo
14554 if (dirName === 'bind' && arg) {
14555 if (modifiers.includes('sync') &&
14556 checkCompatEnabled$1("COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
14557 dirName = 'model';
14558 modifiers.splice(modifiers.indexOf('sync'), 1);
14559 }
14560 if (modifiers.includes('prop')) {
14561 checkCompatEnabled$1("COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */, context, loc);
14562 }
14563 }
14564 return {
14565 type: 7 /* NodeTypes.DIRECTIVE */,
14566 name: dirName,
14567 exp: value && {
14568 type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
14569 content: value.content,
14570 isStatic: false,
14571 // Treat as non-constant by default. This can be potentially set to
14572 // other values by `transformExpression` to make it eligible for hoisting.
14573 constType: 0 /* ConstantTypes.NOT_CONSTANT */,
14574 loc: value.loc
14575 },
14576 arg,
14577 modifiers,
14578 loc
14579 };
14580 }
14581 // missing directive name or illegal directive name
14582 if (!context.inVPre && startsWith(name, 'v-')) {
14583 emitError(context, 26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */);
14584 }
14585 return {
14586 type: 6 /* NodeTypes.ATTRIBUTE */,
14587 name,
14588 value: value && {
14589 type: 2 /* NodeTypes.TEXT */,
14590 content: value.content,
14591 loc: value.loc
14592 },
14593 loc
14594 };
14595}
14596function parseAttributeValue(context) {
14597 const start = getCursor(context);
14598 let content;
14599 const quote = context.source[0];
14600 const isQuoted = quote === `"` || quote === `'`;
14601 if (isQuoted) {
14602 // Quoted value.
14603 advanceBy(context, 1);
14604 const endIndex = context.source.indexOf(quote);
14605 if (endIndex === -1) {
14606 content = parseTextData(context, context.source.length, 4 /* TextModes.ATTRIBUTE_VALUE */);
14607 }
14608 else {
14609 content = parseTextData(context, endIndex, 4 /* TextModes.ATTRIBUTE_VALUE */);
14610 advanceBy(context, 1);
14611 }
14612 }
14613 else {
14614 // Unquoted
14615 const match = /^[^\t\r\n\f >]+/.exec(context.source);
14616 if (!match) {
14617 return undefined;
14618 }
14619 const unexpectedChars = /["'<=`]/g;
14620 let m;
14621 while ((m = unexpectedChars.exec(match[0]))) {
14622 emitError(context, 18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
14623 }
14624 content = parseTextData(context, match[0].length, 4 /* TextModes.ATTRIBUTE_VALUE */);
14625 }
14626 return { content, isQuoted, loc: getSelection(context, start) };
14627}
14628function parseInterpolation(context, mode) {
14629 const [open, close] = context.options.delimiters;
14630 const closeIndex = context.source.indexOf(close, open.length);
14631 if (closeIndex === -1) {
14632 emitError(context, 25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */);
14633 return undefined;
14634 }
14635 const start = getCursor(context);
14636 advanceBy(context, open.length);
14637 const innerStart = getCursor(context);
14638 const innerEnd = getCursor(context);
14639 const rawContentLength = closeIndex - open.length;
14640 const rawContent = context.source.slice(0, rawContentLength);
14641 const preTrimContent = parseTextData(context, rawContentLength, mode);
14642 const content = preTrimContent.trim();
14643 const startOffset = preTrimContent.indexOf(content);
14644 if (startOffset > 0) {
14645 advancePositionWithMutation(innerStart, rawContent, startOffset);
14646 }
14647 const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
14648 advancePositionWithMutation(innerEnd, rawContent, endOffset);
14649 advanceBy(context, close.length);
14650 return {
14651 type: 5 /* NodeTypes.INTERPOLATION */,
14652 content: {
14653 type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
14654 isStatic: false,
14655 // Set `isConstant` to false by default and will decide in transformExpression
14656 constType: 0 /* ConstantTypes.NOT_CONSTANT */,
14657 content,
14658 loc: getSelection(context, innerStart, innerEnd)
14659 },
14660 loc: getSelection(context, start)
14661 };
14662}
14663function parseText(context, mode) {
14664 const endTokens = mode === 3 /* TextModes.CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
14665 let endIndex = context.source.length;
14666 for (let i = 0; i < endTokens.length; i++) {
14667 const index = context.source.indexOf(endTokens[i], 1);
14668 if (index !== -1 && endIndex > index) {
14669 endIndex = index;
14670 }
14671 }
14672 const start = getCursor(context);
14673 const content = parseTextData(context, endIndex, mode);
14674 return {
14675 type: 2 /* NodeTypes.TEXT */,
14676 content,
14677 loc: getSelection(context, start)
14678 };
14679}
14680/**
14681 * Get text data with a given length from the current location.
14682 * This translates HTML entities in the text data.
14683 */
14684function parseTextData(context, length, mode) {
14685 const rawText = context.source.slice(0, length);
14686 advanceBy(context, length);
14687 if (mode === 2 /* TextModes.RAWTEXT */ ||
14688 mode === 3 /* TextModes.CDATA */ ||
14689 !rawText.includes('&')) {
14690 return rawText;
14691 }
14692 else {
14693 // DATA or RCDATA containing "&"". Entity decoding required.
14694 return context.options.decodeEntities(rawText, mode === 4 /* TextModes.ATTRIBUTE_VALUE */);
14695 }
14696}
14697function getCursor(context) {
14698 const { column, line, offset } = context;
14699 return { column, line, offset };
14700}
14701function getSelection(context, start, end) {
14702 end = end || getCursor(context);
14703 return {
14704 start,
14705 end,
14706 source: context.originalSource.slice(start.offset, end.offset)
14707 };
14708}
14709function last(xs) {
14710 return xs[xs.length - 1];
14711}
14712function startsWith(source, searchString) {
14713 return source.startsWith(searchString);
14714}
14715function advanceBy(context, numberOfCharacters) {
14716 const { source } = context;
14717 advancePositionWithMutation(context, source, numberOfCharacters);
14718 context.source = source.slice(numberOfCharacters);
14719}
14720function advanceSpaces(context) {
14721 const match = /^[\t\r\n\f ]+/.exec(context.source);
14722 if (match) {
14723 advanceBy(context, match[0].length);
14724 }
14725}
14726function getNewPosition(context, start, numberOfCharacters) {
14727 return advancePositionWithClone(start, context.originalSource.slice(start.offset, numberOfCharacters), numberOfCharacters);
14728}
14729function emitError(context, code, offset, loc = getCursor(context)) {
14730 if (offset) {
14731 loc.offset += offset;
14732 loc.column += offset;
14733 }
14734 context.options.onError(createCompilerError(code, {
14735 start: loc,
14736 end: loc,
14737 source: ''
14738 }));
14739}
14740function isEnd(context, mode, ancestors) {
14741 const s = context.source;
14742 switch (mode) {
14743 case 0 /* TextModes.DATA */:
14744 if (startsWith(s, '</')) {
14745 // TODO: probably bad performance
14746 for (let i = ancestors.length - 1; i >= 0; --i) {
14747 if (startsWithEndTagOpen(s, ancestors[i].tag)) {
14748 return true;
14749 }
14750 }
14751 }
14752 break;
14753 case 1 /* TextModes.RCDATA */:
14754 case 2 /* TextModes.RAWTEXT */: {
14755 const parent = last(ancestors);
14756 if (parent && startsWithEndTagOpen(s, parent.tag)) {
14757 return true;
14758 }
14759 break;
14760 }
14761 case 3 /* TextModes.CDATA */:
14762 if (startsWith(s, ']]>')) {
14763 return true;
14764 }
14765 break;
14766 }
14767 return !s;
14768}
14769function startsWithEndTagOpen(source, tag) {
14770 return (startsWith(source, '</') &&
14771 source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
14772 /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
14773}
14774
14775function hoistStatic(root, context) {
14776 walk$1(root, context,
14777 // Root node is unfortunately non-hoistable due to potential parent
14778 // fallthrough attributes.
14779 isSingleElementRoot(root, root.children[0]));
14780}
14781function isSingleElementRoot(root, child) {
14782 const { children } = root;
14783 return (children.length === 1 &&
14784 child.type === 1 /* NodeTypes.ELEMENT */ &&
14785 !isSlotOutlet(child));
14786}
14787function walk$1(node, context, doNotHoistNode = false) {
14788 const { children } = node;
14789 const originalCount = children.length;
14790 let hoistedCount = 0;
14791 for (let i = 0; i < children.length; i++) {
14792 const child = children[i];
14793 // only plain elements & text calls are eligible for hoisting.
14794 if (child.type === 1 /* NodeTypes.ELEMENT */ &&
14795 child.tagType === 0 /* ElementTypes.ELEMENT */) {
14796 const constantType = doNotHoistNode
14797 ? 0 /* ConstantTypes.NOT_CONSTANT */
14798 : getConstantType(child, context);
14799 if (constantType > 0 /* ConstantTypes.NOT_CONSTANT */) {
14800 if (constantType >= 2 /* ConstantTypes.CAN_HOIST */) {
14801 child.codegenNode.patchFlag =
14802 -1 /* PatchFlags.HOISTED */ + (` /* HOISTED */` );
14803 child.codegenNode = context.hoist(child.codegenNode);
14804 hoistedCount++;
14805 continue;
14806 }
14807 }
14808 else {
14809 // node may contain dynamic children, but its props may be eligible for
14810 // hoisting.
14811 const codegenNode = child.codegenNode;
14812 if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
14813 const flag = getPatchFlag(codegenNode);
14814 if ((!flag ||
14815 flag === 512 /* PatchFlags.NEED_PATCH */ ||
14816 flag === 1 /* PatchFlags.TEXT */) &&
14817 getGeneratedPropsConstantType(child, context) >=
14818 2 /* ConstantTypes.CAN_HOIST */) {
14819 const props = getNodeProps(child);
14820 if (props) {
14821 codegenNode.props = context.hoist(props);
14822 }
14823 }
14824 if (codegenNode.dynamicProps) {
14825 codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
14826 }
14827 }
14828 }
14829 }
14830 else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
14831 getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
14832 child.codegenNode = context.hoist(child.codegenNode);
14833 hoistedCount++;
14834 }
14835 // walk further
14836 if (child.type === 1 /* NodeTypes.ELEMENT */) {
14837 const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
14838 if (isComponent) {
14839 context.scopes.vSlot++;
14840 }
14841 walk$1(child, context);
14842 if (isComponent) {
14843 context.scopes.vSlot--;
14844 }
14845 }
14846 else if (child.type === 11 /* NodeTypes.FOR */) {
14847 // Do not hoist v-for single child because it has to be a block
14848 walk$1(child, context, child.children.length === 1);
14849 }
14850 else if (child.type === 9 /* NodeTypes.IF */) {
14851 for (let i = 0; i < child.branches.length; i++) {
14852 // Do not hoist v-if single child because it has to be a block
14853 walk$1(child.branches[i], context, child.branches[i].children.length === 1);
14854 }
14855 }
14856 }
14857 if (hoistedCount && context.transformHoist) {
14858 context.transformHoist(children, context, node);
14859 }
14860 // all children were hoisted - the entire children array is hoistable.
14861 if (hoistedCount &&
14862 hoistedCount === originalCount &&
14863 node.type === 1 /* NodeTypes.ELEMENT */ &&
14864 node.tagType === 0 /* ElementTypes.ELEMENT */ &&
14865 node.codegenNode &&
14866 node.codegenNode.type === 13 /* NodeTypes.VNODE_CALL */ &&
14867 isArray(node.codegenNode.children)) {
14868 node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
14869 }
14870}
14871function getConstantType(node, context) {
14872 const { constantCache } = context;
14873 switch (node.type) {
14874 case 1 /* NodeTypes.ELEMENT */:
14875 if (node.tagType !== 0 /* ElementTypes.ELEMENT */) {
14876 return 0 /* ConstantTypes.NOT_CONSTANT */;
14877 }
14878 const cached = constantCache.get(node);
14879 if (cached !== undefined) {
14880 return cached;
14881 }
14882 const codegenNode = node.codegenNode;
14883 if (codegenNode.type !== 13 /* NodeTypes.VNODE_CALL */) {
14884 return 0 /* ConstantTypes.NOT_CONSTANT */;
14885 }
14886 if (codegenNode.isBlock &&
14887 node.tag !== 'svg' &&
14888 node.tag !== 'foreignObject') {
14889 return 0 /* ConstantTypes.NOT_CONSTANT */;
14890 }
14891 const flag = getPatchFlag(codegenNode);
14892 if (!flag) {
14893 let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
14894 // Element itself has no patch flag. However we still need to check:
14895 // 1. Even for a node with no patch flag, it is possible for it to contain
14896 // non-hoistable expressions that refers to scope variables, e.g. compiler
14897 // injected keys or cached event handlers. Therefore we need to always
14898 // check the codegenNode's props to be sure.
14899 const generatedPropsType = getGeneratedPropsConstantType(node, context);
14900 if (generatedPropsType === 0 /* ConstantTypes.NOT_CONSTANT */) {
14901 constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
14902 return 0 /* ConstantTypes.NOT_CONSTANT */;
14903 }
14904 if (generatedPropsType < returnType) {
14905 returnType = generatedPropsType;
14906 }
14907 // 2. its children.
14908 for (let i = 0; i < node.children.length; i++) {
14909 const childType = getConstantType(node.children[i], context);
14910 if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
14911 constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
14912 return 0 /* ConstantTypes.NOT_CONSTANT */;
14913 }
14914 if (childType < returnType) {
14915 returnType = childType;
14916 }
14917 }
14918 // 3. if the type is not already CAN_SKIP_PATCH which is the lowest non-0
14919 // type, check if any of the props can cause the type to be lowered
14920 // we can skip can_patch because it's guaranteed by the absence of a
14921 // patchFlag.
14922 if (returnType > 1 /* ConstantTypes.CAN_SKIP_PATCH */) {
14923 for (let i = 0; i < node.props.length; i++) {
14924 const p = node.props[i];
14925 if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind' && p.exp) {
14926 const expType = getConstantType(p.exp, context);
14927 if (expType === 0 /* ConstantTypes.NOT_CONSTANT */) {
14928 constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
14929 return 0 /* ConstantTypes.NOT_CONSTANT */;
14930 }
14931 if (expType < returnType) {
14932 returnType = expType;
14933 }
14934 }
14935 }
14936 }
14937 // only svg/foreignObject could be block here, however if they are
14938 // static then they don't need to be blocks since there will be no
14939 // nested updates.
14940 if (codegenNode.isBlock) {
14941 // except set custom directives.
14942 for (let i = 0; i < node.props.length; i++) {
14943 const p = node.props[i];
14944 if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
14945 constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
14946 return 0 /* ConstantTypes.NOT_CONSTANT */;
14947 }
14948 }
14949 context.removeHelper(OPEN_BLOCK);
14950 context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
14951 codegenNode.isBlock = false;
14952 context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
14953 }
14954 constantCache.set(node, returnType);
14955 return returnType;
14956 }
14957 else {
14958 constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
14959 return 0 /* ConstantTypes.NOT_CONSTANT */;
14960 }
14961 case 2 /* NodeTypes.TEXT */:
14962 case 3 /* NodeTypes.COMMENT */:
14963 return 3 /* ConstantTypes.CAN_STRINGIFY */;
14964 case 9 /* NodeTypes.IF */:
14965 case 11 /* NodeTypes.FOR */:
14966 case 10 /* NodeTypes.IF_BRANCH */:
14967 return 0 /* ConstantTypes.NOT_CONSTANT */;
14968 case 5 /* NodeTypes.INTERPOLATION */:
14969 case 12 /* NodeTypes.TEXT_CALL */:
14970 return getConstantType(node.content, context);
14971 case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
14972 return node.constType;
14973 case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
14974 let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
14975 for (let i = 0; i < node.children.length; i++) {
14976 const child = node.children[i];
14977 if (isString(child) || isSymbol(child)) {
14978 continue;
14979 }
14980 const childType = getConstantType(child, context);
14981 if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
14982 return 0 /* ConstantTypes.NOT_CONSTANT */;
14983 }
14984 else if (childType < returnType) {
14985 returnType = childType;
14986 }
14987 }
14988 return returnType;
14989 default:
14990 return 0 /* ConstantTypes.NOT_CONSTANT */;
14991 }
14992}
14993const allowHoistedHelperSet = new Set([
14994 NORMALIZE_CLASS,
14995 NORMALIZE_STYLE,
14996 NORMALIZE_PROPS,
14997 GUARD_REACTIVE_PROPS
14998]);
14999function getConstantTypeOfHelperCall(value, context) {
15000 if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ &&
15001 !isString(value.callee) &&
15002 allowHoistedHelperSet.has(value.callee)) {
15003 const arg = value.arguments[0];
15004 if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
15005 return getConstantType(arg, context);
15006 }
15007 else if (arg.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
15008 // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(exp))`
15009 return getConstantTypeOfHelperCall(arg, context);
15010 }
15011 }
15012 return 0 /* ConstantTypes.NOT_CONSTANT */;
15013}
15014function getGeneratedPropsConstantType(node, context) {
15015 let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
15016 const props = getNodeProps(node);
15017 if (props && props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
15018 const { properties } = props;
15019 for (let i = 0; i < properties.length; i++) {
15020 const { key, value } = properties[i];
15021 const keyType = getConstantType(key, context);
15022 if (keyType === 0 /* ConstantTypes.NOT_CONSTANT */) {
15023 return keyType;
15024 }
15025 if (keyType < returnType) {
15026 returnType = keyType;
15027 }
15028 let valueType;
15029 if (value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
15030 valueType = getConstantType(value, context);
15031 }
15032 else if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
15033 // some helper calls can be hoisted,
15034 // such as the `normalizeProps` generated by the compiler for pre-normalize class,
15035 // in this case we need to respect the ConstantType of the helper's arguments
15036 valueType = getConstantTypeOfHelperCall(value, context);
15037 }
15038 else {
15039 valueType = 0 /* ConstantTypes.NOT_CONSTANT */;
15040 }
15041 if (valueType === 0 /* ConstantTypes.NOT_CONSTANT */) {
15042 return valueType;
15043 }
15044 if (valueType < returnType) {
15045 returnType = valueType;
15046 }
15047 }
15048 }
15049 return returnType;
15050}
15051function getNodeProps(node) {
15052 const codegenNode = node.codegenNode;
15053 if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
15054 return codegenNode.props;
15055 }
15056}
15057function getPatchFlag(node) {
15058 const flag = node.patchFlag;
15059 return flag ? parseInt(flag, 10) : undefined;
15060}
15061
15062function createTransformContext(root, { filename = '', prefixIdentifiers = false, hoistStatic = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
15063 const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/);
15064 const context = {
15065 // options
15066 selfName: nameMatch && capitalize(camelize(nameMatch[1])),
15067 prefixIdentifiers,
15068 hoistStatic,
15069 cacheHandlers,
15070 nodeTransforms,
15071 directiveTransforms,
15072 transformHoist,
15073 isBuiltInComponent,
15074 isCustomElement,
15075 expressionPlugins,
15076 scopeId,
15077 slotted,
15078 ssr,
15079 inSSR,
15080 ssrCssVars,
15081 bindingMetadata,
15082 inline,
15083 isTS,
15084 onError,
15085 onWarn,
15086 compatConfig,
15087 // state
15088 root,
15089 helpers: new Map(),
15090 components: new Set(),
15091 directives: new Set(),
15092 hoists: [],
15093 imports: [],
15094 constantCache: new Map(),
15095 temps: 0,
15096 cached: 0,
15097 identifiers: Object.create(null),
15098 scopes: {
15099 vFor: 0,
15100 vSlot: 0,
15101 vPre: 0,
15102 vOnce: 0
15103 },
15104 parent: null,
15105 currentNode: root,
15106 childIndex: 0,
15107 inVOnce: false,
15108 // methods
15109 helper(name) {
15110 const count = context.helpers.get(name) || 0;
15111 context.helpers.set(name, count + 1);
15112 return name;
15113 },
15114 removeHelper(name) {
15115 const count = context.helpers.get(name);
15116 if (count) {
15117 const currentCount = count - 1;
15118 if (!currentCount) {
15119 context.helpers.delete(name);
15120 }
15121 else {
15122 context.helpers.set(name, currentCount);
15123 }
15124 }
15125 },
15126 helperString(name) {
15127 return `_${helperNameMap[context.helper(name)]}`;
15128 },
15129 replaceNode(node) {
15130 /* istanbul ignore if */
15131 {
15132 if (!context.currentNode) {
15133 throw new Error(`Node being replaced is already removed.`);
15134 }
15135 if (!context.parent) {
15136 throw new Error(`Cannot replace root node.`);
15137 }
15138 }
15139 context.parent.children[context.childIndex] = context.currentNode = node;
15140 },
15141 removeNode(node) {
15142 if (!context.parent) {
15143 throw new Error(`Cannot remove root node.`);
15144 }
15145 const list = context.parent.children;
15146 const removalIndex = node
15147 ? list.indexOf(node)
15148 : context.currentNode
15149 ? context.childIndex
15150 : -1;
15151 /* istanbul ignore if */
15152 if (removalIndex < 0) {
15153 throw new Error(`node being removed is not a child of current parent`);
15154 }
15155 if (!node || node === context.currentNode) {
15156 // current node removed
15157 context.currentNode = null;
15158 context.onNodeRemoved();
15159 }
15160 else {
15161 // sibling node removed
15162 if (context.childIndex > removalIndex) {
15163 context.childIndex--;
15164 context.onNodeRemoved();
15165 }
15166 }
15167 context.parent.children.splice(removalIndex, 1);
15168 },
15169 onNodeRemoved: () => { },
15170 addIdentifiers(exp) {
15171 // identifier tracking only happens in non-browser builds.
15172 {
15173 if (isString(exp)) {
15174 addId(exp);
15175 }
15176 else if (exp.identifiers) {
15177 exp.identifiers.forEach(addId);
15178 }
15179 else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
15180 addId(exp.content);
15181 }
15182 }
15183 },
15184 removeIdentifiers(exp) {
15185 {
15186 if (isString(exp)) {
15187 removeId(exp);
15188 }
15189 else if (exp.identifiers) {
15190 exp.identifiers.forEach(removeId);
15191 }
15192 else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
15193 removeId(exp.content);
15194 }
15195 }
15196 },
15197 hoist(exp) {
15198 if (isString(exp))
15199 exp = createSimpleExpression(exp);
15200 context.hoists.push(exp);
15201 const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* ConstantTypes.CAN_HOIST */);
15202 identifier.hoisted = exp;
15203 return identifier;
15204 },
15205 cache(exp, isVNode = false) {
15206 return createCacheExpression(context.cached++, exp, isVNode);
15207 }
15208 };
15209 {
15210 context.filters = new Set();
15211 }
15212 function addId(id) {
15213 const { identifiers } = context;
15214 if (identifiers[id] === undefined) {
15215 identifiers[id] = 0;
15216 }
15217 identifiers[id]++;
15218 }
15219 function removeId(id) {
15220 context.identifiers[id]--;
15221 }
15222 return context;
15223}
15224function transform(root, options) {
15225 const context = createTransformContext(root, options);
15226 traverseNode(root, context);
15227 if (options.hoistStatic) {
15228 hoistStatic(root, context);
15229 }
15230 if (!options.ssr) {
15231 createRootCodegen(root, context);
15232 }
15233 // finalize meta information
15234 root.helpers = [...context.helpers.keys()];
15235 root.components = [...context.components];
15236 root.directives = [...context.directives];
15237 root.imports = context.imports;
15238 root.hoists = context.hoists;
15239 root.temps = context.temps;
15240 root.cached = context.cached;
15241 {
15242 root.filters = [...context.filters];
15243 }
15244}
15245function createRootCodegen(root, context) {
15246 const { helper } = context;
15247 const { children } = root;
15248 if (children.length === 1) {
15249 const child = children[0];
15250 // if the single child is an element, turn it into a block.
15251 if (isSingleElementRoot(root, child) && child.codegenNode) {
15252 // single element root is never hoisted so codegenNode will never be
15253 // SimpleExpressionNode
15254 const codegenNode = child.codegenNode;
15255 if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
15256 makeBlock(codegenNode, context);
15257 }
15258 root.codegenNode = codegenNode;
15259 }
15260 else {
15261 // - single <slot/>, IfNode, ForNode: already blocks.
15262 // - single text node: always patched.
15263 // root codegen falls through via genNode()
15264 root.codegenNode = child;
15265 }
15266 }
15267 else if (children.length > 1) {
15268 // root has multiple nodes - return a fragment block.
15269 let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
15270 let patchFlagText = PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
15271 // check if the fragment actually contains a single valid child with
15272 // the rest being comments
15273 if (children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
15274 patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
15275 patchFlagText += `, ${PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
15276 }
15277 root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, undefined, false /* isComponent */);
15278 }
15279 else ;
15280}
15281function traverseChildren(parent, context) {
15282 let i = 0;
15283 const nodeRemoved = () => {
15284 i--;
15285 };
15286 for (; i < parent.children.length; i++) {
15287 const child = parent.children[i];
15288 if (isString(child))
15289 continue;
15290 context.parent = parent;
15291 context.childIndex = i;
15292 context.onNodeRemoved = nodeRemoved;
15293 traverseNode(child, context);
15294 }
15295}
15296function traverseNode(node, context) {
15297 context.currentNode = node;
15298 // apply transform plugins
15299 const { nodeTransforms } = context;
15300 const exitFns = [];
15301 for (let i = 0; i < nodeTransforms.length; i++) {
15302 const onExit = nodeTransforms[i](node, context);
15303 if (onExit) {
15304 if (isArray(onExit)) {
15305 exitFns.push(...onExit);
15306 }
15307 else {
15308 exitFns.push(onExit);
15309 }
15310 }
15311 if (!context.currentNode) {
15312 // node was removed
15313 return;
15314 }
15315 else {
15316 // node may have been replaced
15317 node = context.currentNode;
15318 }
15319 }
15320 switch (node.type) {
15321 case 3 /* NodeTypes.COMMENT */:
15322 if (!context.ssr) {
15323 // inject import for the Comment symbol, which is needed for creating
15324 // comment nodes with `createVNode`
15325 context.helper(CREATE_COMMENT);
15326 }
15327 break;
15328 case 5 /* NodeTypes.INTERPOLATION */:
15329 // no need to traverse, but we need to inject toString helper
15330 if (!context.ssr) {
15331 context.helper(TO_DISPLAY_STRING);
15332 }
15333 break;
15334 // for container types, further traverse downwards
15335 case 9 /* NodeTypes.IF */:
15336 for (let i = 0; i < node.branches.length; i++) {
15337 traverseNode(node.branches[i], context);
15338 }
15339 break;
15340 case 10 /* NodeTypes.IF_BRANCH */:
15341 case 11 /* NodeTypes.FOR */:
15342 case 1 /* NodeTypes.ELEMENT */:
15343 case 0 /* NodeTypes.ROOT */:
15344 traverseChildren(node, context);
15345 break;
15346 }
15347 // exit transforms
15348 context.currentNode = node;
15349 let i = exitFns.length;
15350 while (i--) {
15351 exitFns[i]();
15352 }
15353}
15354function createStructuralDirectiveTransform(name, fn) {
15355 const matches = isString(name)
15356 ? (n) => n === name
15357 : (n) => name.test(n);
15358 return (node, context) => {
15359 if (node.type === 1 /* NodeTypes.ELEMENT */) {
15360 const { props } = node;
15361 // structural directive transforms are not concerned with slots
15362 // as they are handled separately in vSlot.ts
15363 if (node.tagType === 3 /* ElementTypes.TEMPLATE */ && props.some(isVSlot)) {
15364 return;
15365 }
15366 const exitFns = [];
15367 for (let i = 0; i < props.length; i++) {
15368 const prop = props[i];
15369 if (prop.type === 7 /* NodeTypes.DIRECTIVE */ && matches(prop.name)) {
15370 // structural directives are removed to avoid infinite recursion
15371 // also we remove them *before* applying so that it can further
15372 // traverse itself in case it moves the node around
15373 props.splice(i, 1);
15374 i--;
15375 const onExit = fn(node, prop, context);
15376 if (onExit)
15377 exitFns.push(onExit);
15378 }
15379 }
15380 return exitFns;
15381 }
15382 };
15383}
15384
15385const PURE_ANNOTATION = `/*#__PURE__*/`;
15386const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
15387function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
15388 const context = {
15389 mode,
15390 prefixIdentifiers,
15391 sourceMap: sourceMap$1,
15392 filename,
15393 scopeId,
15394 optimizeImports,
15395 runtimeGlobalName,
15396 runtimeModuleName,
15397 ssrRuntimeModuleName,
15398 ssr,
15399 isTS,
15400 inSSR,
15401 source: ast.loc.source,
15402 code: ``,
15403 column: 1,
15404 line: 1,
15405 offset: 0,
15406 indentLevel: 0,
15407 pure: false,
15408 map: undefined,
15409 helper(key) {
15410 return `_${helperNameMap[key]}`;
15411 },
15412 push(code, node) {
15413 context.code += code;
15414 if (context.map) {
15415 if (node) {
15416 let name;
15417 if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !node.isStatic) {
15418 const content = node.content.replace(/^_ctx\./, '');
15419 if (content !== node.content && isSimpleIdentifier(content)) {
15420 name = content;
15421 }
15422 }
15423 addMapping(node.loc.start, name);
15424 }
15425 advancePositionWithMutation(context, code);
15426 if (node && node.loc !== locStub) {
15427 addMapping(node.loc.end);
15428 }
15429 }
15430 },
15431 indent() {
15432 newline(++context.indentLevel);
15433 },
15434 deindent(withoutNewLine = false) {
15435 if (withoutNewLine) {
15436 --context.indentLevel;
15437 }
15438 else {
15439 newline(--context.indentLevel);
15440 }
15441 },
15442 newline() {
15443 newline(context.indentLevel);
15444 }
15445 };
15446 function newline(n) {
15447 context.push('\n' + ` `.repeat(n));
15448 }
15449 function addMapping(loc, name) {
15450 context.map.addMapping({
15451 name,
15452 source: context.filename,
15453 original: {
15454 line: loc.line,
15455 column: loc.column - 1 // source-map column is 0 based
15456 },
15457 generated: {
15458 line: context.line,
15459 column: context.column - 1
15460 }
15461 });
15462 }
15463 if (sourceMap$1) {
15464 // lazy require source-map implementation, only in non-browser builds
15465 context.map = new sourceMap.SourceMapGenerator();
15466 context.map.setSourceContent(filename, context.source);
15467 }
15468 return context;
15469}
15470function generate(ast, options = {}) {
15471 const context = createCodegenContext(ast, options);
15472 if (options.onContextCreated)
15473 options.onContextCreated(context);
15474 const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
15475 const hasHelpers = ast.helpers.length > 0;
15476 const useWithBlock = !prefixIdentifiers && mode !== 'module';
15477 const genScopeId = scopeId != null && mode === 'module';
15478 const isSetupInlined = !!options.inline;
15479 // preambles
15480 // in setup() inline mode, the preamble is generated in a sub context
15481 // and returned separately.
15482 const preambleContext = isSetupInlined
15483 ? createCodegenContext(ast, options)
15484 : context;
15485 if (mode === 'module') {
15486 genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
15487 }
15488 else {
15489 genFunctionPreamble(ast, preambleContext);
15490 }
15491 // enter render function
15492 const functionName = ssr ? `ssrRender` : `render`;
15493 const args = ssr ? ['_ctx', '_push', '_parent', '_attrs'] : ['_ctx', '_cache'];
15494 if (options.bindingMetadata && !options.inline) {
15495 // binding optimization args
15496 args.push('$props', '$setup', '$data', '$options');
15497 }
15498 const signature = options.isTS
15499 ? args.map(arg => `${arg}: any`).join(',')
15500 : args.join(', ');
15501 if (isSetupInlined) {
15502 push(`(${signature}) => {`);
15503 }
15504 else {
15505 push(`function ${functionName}(${signature}) {`);
15506 }
15507 indent();
15508 if (useWithBlock) {
15509 push(`with (_ctx) {`);
15510 indent();
15511 // function mode const declarations should be inside with block
15512 // also they should be renamed to avoid collision with user properties
15513 if (hasHelpers) {
15514 push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
15515 push(`\n`);
15516 newline();
15517 }
15518 }
15519 // generate asset resolution statements
15520 if (ast.components.length) {
15521 genAssets(ast.components, 'component', context);
15522 if (ast.directives.length || ast.temps > 0) {
15523 newline();
15524 }
15525 }
15526 if (ast.directives.length) {
15527 genAssets(ast.directives, 'directive', context);
15528 if (ast.temps > 0) {
15529 newline();
15530 }
15531 }
15532 if (ast.filters && ast.filters.length) {
15533 newline();
15534 genAssets(ast.filters, 'filter', context);
15535 newline();
15536 }
15537 if (ast.temps > 0) {
15538 push(`let `);
15539 for (let i = 0; i < ast.temps; i++) {
15540 push(`${i > 0 ? `, ` : ``}_temp${i}`);
15541 }
15542 }
15543 if (ast.components.length || ast.directives.length || ast.temps) {
15544 push(`\n`);
15545 newline();
15546 }
15547 // generate the VNode tree expression
15548 if (!ssr) {
15549 push(`return `);
15550 }
15551 if (ast.codegenNode) {
15552 genNode(ast.codegenNode, context);
15553 }
15554 else {
15555 push(`null`);
15556 }
15557 if (useWithBlock) {
15558 deindent();
15559 push(`}`);
15560 }
15561 deindent();
15562 push(`}`);
15563 return {
15564 ast,
15565 code: context.code,
15566 preamble: isSetupInlined ? preambleContext.code : ``,
15567 // SourceMapGenerator does have toJSON() method but it's not in the types
15568 map: context.map ? context.map.toJSON() : undefined
15569 };
15570}
15571function genFunctionPreamble(ast, context) {
15572 const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
15573 const VueBinding = ssr
15574 ? `require(${JSON.stringify(runtimeModuleName)})`
15575 : runtimeGlobalName;
15576 // Generate const declaration for helpers
15577 // In prefix mode, we place the const declaration at top so it's done
15578 // only once; But if we not prefixing, we place the declaration inside the
15579 // with block so it doesn't incur the `in` check cost for every helper access.
15580 if (ast.helpers.length > 0) {
15581 if (prefixIdentifiers) {
15582 push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
15583 }
15584 else {
15585 // "with" mode.
15586 // save Vue in a separate variable to avoid collision
15587 push(`const _Vue = ${VueBinding}\n`);
15588 // in "with" mode, helpers are declared inside the with block to avoid
15589 // has check cost, but hoists are lifted out of the function - we need
15590 // to provide the helper here.
15591 if (ast.hoists.length) {
15592 const staticHelpers = [
15593 CREATE_VNODE,
15594 CREATE_ELEMENT_VNODE,
15595 CREATE_COMMENT,
15596 CREATE_TEXT,
15597 CREATE_STATIC
15598 ]
15599 .filter(helper => ast.helpers.includes(helper))
15600 .map(aliasHelper)
15601 .join(', ');
15602 push(`const { ${staticHelpers} } = _Vue\n`);
15603 }
15604 }
15605 }
15606 // generate variables for ssr helpers
15607 if (ast.ssrHelpers && ast.ssrHelpers.length) {
15608 // ssr guarantees prefixIdentifier: true
15609 push(`const { ${ast.ssrHelpers
15610 .map(aliasHelper)
15611 .join(', ')} } = require("${ssrRuntimeModuleName}")\n`);
15612 }
15613 genHoists(ast.hoists, context);
15614 newline();
15615 push(`return `);
15616}
15617function genModulePreamble(ast, context, genScopeId, inline) {
15618 const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
15619 if (genScopeId && ast.hoists.length) {
15620 ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
15621 }
15622 // generate import statements for helpers
15623 if (ast.helpers.length) {
15624 if (optimizeImports) {
15625 // when bundled with webpack with code-split, calling an import binding
15626 // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
15627 // incurring both payload size increase and potential perf overhead.
15628 // therefore we assign the imports to variables (which is a constant ~50b
15629 // cost per-component instead of scaling with template size)
15630 push(`import { ${ast.helpers
15631 .map(s => helperNameMap[s])
15632 .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
15633 push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
15634 .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
15635 .join(', ')}\n`);
15636 }
15637 else {
15638 push(`import { ${ast.helpers
15639 .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
15640 .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
15641 }
15642 }
15643 if (ast.ssrHelpers && ast.ssrHelpers.length) {
15644 push(`import { ${ast.ssrHelpers
15645 .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
15646 .join(', ')} } from "${ssrRuntimeModuleName}"\n`);
15647 }
15648 if (ast.imports.length) {
15649 genImports(ast.imports, context);
15650 newline();
15651 }
15652 genHoists(ast.hoists, context);
15653 newline();
15654 if (!inline) {
15655 push(`export `);
15656 }
15657}
15658function genAssets(assets, type, { helper, push, newline, isTS }) {
15659 const resolver = helper(type === 'filter'
15660 ? RESOLVE_FILTER
15661 : type === 'component'
15662 ? RESOLVE_COMPONENT
15663 : RESOLVE_DIRECTIVE);
15664 for (let i = 0; i < assets.length; i++) {
15665 let id = assets[i];
15666 // potential component implicit self-reference inferred from SFC filename
15667 const maybeSelfReference = id.endsWith('__self');
15668 if (maybeSelfReference) {
15669 id = id.slice(0, -6);
15670 }
15671 push(`const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`);
15672 if (i < assets.length - 1) {
15673 newline();
15674 }
15675 }
15676}
15677function genHoists(hoists, context) {
15678 if (!hoists.length) {
15679 return;
15680 }
15681 context.pure = true;
15682 const { push, newline, helper, scopeId, mode } = context;
15683 const genScopeId = scopeId != null && mode !== 'function';
15684 newline();
15685 // generate inlined withScopeId helper
15686 if (genScopeId) {
15687 push(`const _withScopeId = n => (${helper(PUSH_SCOPE_ID)}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`);
15688 newline();
15689 }
15690 for (let i = 0; i < hoists.length; i++) {
15691 const exp = hoists[i];
15692 if (exp) {
15693 const needScopeIdWrapper = genScopeId && exp.type === 13 /* NodeTypes.VNODE_CALL */;
15694 push(`const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`);
15695 genNode(exp, context);
15696 if (needScopeIdWrapper) {
15697 push(`)`);
15698 }
15699 newline();
15700 }
15701 }
15702 context.pure = false;
15703}
15704function genImports(importsOptions, context) {
15705 if (!importsOptions.length) {
15706 return;
15707 }
15708 importsOptions.forEach(imports => {
15709 context.push(`import `);
15710 genNode(imports.exp, context);
15711 context.push(` from '${imports.path}'`);
15712 context.newline();
15713 });
15714}
15715function isText$1(n) {
15716 return (isString(n) ||
15717 n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
15718 n.type === 2 /* NodeTypes.TEXT */ ||
15719 n.type === 5 /* NodeTypes.INTERPOLATION */ ||
15720 n.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */);
15721}
15722function genNodeListAsArray(nodes, context) {
15723 const multilines = nodes.length > 3 ||
15724 (nodes.some(n => isArray(n) || !isText$1(n)));
15725 context.push(`[`);
15726 multilines && context.indent();
15727 genNodeList(nodes, context, multilines);
15728 multilines && context.deindent();
15729 context.push(`]`);
15730}
15731function genNodeList(nodes, context, multilines = false, comma = true) {
15732 const { push, newline } = context;
15733 for (let i = 0; i < nodes.length; i++) {
15734 const node = nodes[i];
15735 if (isString(node)) {
15736 push(node);
15737 }
15738 else if (isArray(node)) {
15739 genNodeListAsArray(node, context);
15740 }
15741 else {
15742 genNode(node, context);
15743 }
15744 if (i < nodes.length - 1) {
15745 if (multilines) {
15746 comma && push(',');
15747 newline();
15748 }
15749 else {
15750 comma && push(', ');
15751 }
15752 }
15753 }
15754}
15755function genNode(node, context) {
15756 if (isString(node)) {
15757 context.push(node);
15758 return;
15759 }
15760 if (isSymbol(node)) {
15761 context.push(context.helper(node));
15762 return;
15763 }
15764 switch (node.type) {
15765 case 1 /* NodeTypes.ELEMENT */:
15766 case 9 /* NodeTypes.IF */:
15767 case 11 /* NodeTypes.FOR */:
15768 assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. ` +
15769 `Apply appropriate transforms first.`);
15770 genNode(node.codegenNode, context);
15771 break;
15772 case 2 /* NodeTypes.TEXT */:
15773 genText(node, context);
15774 break;
15775 case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
15776 genExpression(node, context);
15777 break;
15778 case 5 /* NodeTypes.INTERPOLATION */:
15779 genInterpolation(node, context);
15780 break;
15781 case 12 /* NodeTypes.TEXT_CALL */:
15782 genNode(node.codegenNode, context);
15783 break;
15784 case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
15785 genCompoundExpression(node, context);
15786 break;
15787 case 3 /* NodeTypes.COMMENT */:
15788 genComment(node, context);
15789 break;
15790 case 13 /* NodeTypes.VNODE_CALL */:
15791 genVNodeCall(node, context);
15792 break;
15793 case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
15794 genCallExpression(node, context);
15795 break;
15796 case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
15797 genObjectExpression(node, context);
15798 break;
15799 case 17 /* NodeTypes.JS_ARRAY_EXPRESSION */:
15800 genArrayExpression(node, context);
15801 break;
15802 case 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */:
15803 genFunctionExpression(node, context);
15804 break;
15805 case 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */:
15806 genConditionalExpression(node, context);
15807 break;
15808 case 20 /* NodeTypes.JS_CACHE_EXPRESSION */:
15809 genCacheExpression(node, context);
15810 break;
15811 case 21 /* NodeTypes.JS_BLOCK_STATEMENT */:
15812 genNodeList(node.body, context, true, false);
15813 break;
15814 // SSR only types
15815 case 22 /* NodeTypes.JS_TEMPLATE_LITERAL */:
15816 genTemplateLiteral(node, context);
15817 break;
15818 case 23 /* NodeTypes.JS_IF_STATEMENT */:
15819 genIfStatement(node, context);
15820 break;
15821 case 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */:
15822 genAssignmentExpression(node, context);
15823 break;
15824 case 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */:
15825 genSequenceExpression(node, context);
15826 break;
15827 case 26 /* NodeTypes.JS_RETURN_STATEMENT */:
15828 genReturnStatement(node, context);
15829 break;
15830 /* istanbul ignore next */
15831 case 10 /* NodeTypes.IF_BRANCH */:
15832 // noop
15833 break;
15834 default:
15835 {
15836 assert(false, `unhandled codegen node type: ${node.type}`);
15837 // make sure we exhaust all possible types
15838 const exhaustiveCheck = node;
15839 return exhaustiveCheck;
15840 }
15841 }
15842}
15843function genText(node, context) {
15844 context.push(JSON.stringify(node.content), node);
15845}
15846function genExpression(node, context) {
15847 const { content, isStatic } = node;
15848 context.push(isStatic ? JSON.stringify(content) : content, node);
15849}
15850function genInterpolation(node, context) {
15851 const { push, helper, pure } = context;
15852 if (pure)
15853 push(PURE_ANNOTATION);
15854 push(`${helper(TO_DISPLAY_STRING)}(`);
15855 genNode(node.content, context);
15856 push(`)`);
15857}
15858function genCompoundExpression(node, context) {
15859 for (let i = 0; i < node.children.length; i++) {
15860 const child = node.children[i];
15861 if (isString(child)) {
15862 context.push(child);
15863 }
15864 else {
15865 genNode(child, context);
15866 }
15867 }
15868}
15869function genExpressionAsPropertyKey(node, context) {
15870 const { push } = context;
15871 if (node.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
15872 push(`[`);
15873 genCompoundExpression(node, context);
15874 push(`]`);
15875 }
15876 else if (node.isStatic) {
15877 // only quote keys if necessary
15878 const text = isSimpleIdentifier(node.content)
15879 ? node.content
15880 : JSON.stringify(node.content);
15881 push(text, node);
15882 }
15883 else {
15884 push(`[${node.content}]`, node);
15885 }
15886}
15887function genComment(node, context) {
15888 const { push, helper, pure } = context;
15889 if (pure) {
15890 push(PURE_ANNOTATION);
15891 }
15892 push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
15893}
15894function genVNodeCall(node, context) {
15895 const { push, helper, pure } = context;
15896 const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
15897 if (directives) {
15898 push(helper(WITH_DIRECTIVES) + `(`);
15899 }
15900 if (isBlock) {
15901 push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
15902 }
15903 if (pure) {
15904 push(PURE_ANNOTATION);
15905 }
15906 const callHelper = isBlock
15907 ? getVNodeBlockHelper(context.inSSR, isComponent)
15908 : getVNodeHelper(context.inSSR, isComponent);
15909 push(helper(callHelper) + `(`, node);
15910 genNodeList(genNullableArgs([tag, props, children, patchFlag, dynamicProps]), context);
15911 push(`)`);
15912 if (isBlock) {
15913 push(`)`);
15914 }
15915 if (directives) {
15916 push(`, `);
15917 genNode(directives, context);
15918 push(`)`);
15919 }
15920}
15921function genNullableArgs(args) {
15922 let i = args.length;
15923 while (i--) {
15924 if (args[i] != null)
15925 break;
15926 }
15927 return args.slice(0, i + 1).map(arg => arg || `null`);
15928}
15929// JavaScript
15930function genCallExpression(node, context) {
15931 const { push, helper, pure } = context;
15932 const callee = isString(node.callee) ? node.callee : helper(node.callee);
15933 if (pure) {
15934 push(PURE_ANNOTATION);
15935 }
15936 push(callee + `(`, node);
15937 genNodeList(node.arguments, context);
15938 push(`)`);
15939}
15940function genObjectExpression(node, context) {
15941 const { push, indent, deindent, newline } = context;
15942 const { properties } = node;
15943 if (!properties.length) {
15944 push(`{}`, node);
15945 return;
15946 }
15947 const multilines = properties.length > 1 ||
15948 (properties.some(p => p.value.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */));
15949 push(multilines ? `{` : `{ `);
15950 multilines && indent();
15951 for (let i = 0; i < properties.length; i++) {
15952 const { key, value } = properties[i];
15953 // key
15954 genExpressionAsPropertyKey(key, context);
15955 push(`: `);
15956 // value
15957 genNode(value, context);
15958 if (i < properties.length - 1) {
15959 // will only reach this if it's multilines
15960 push(`,`);
15961 newline();
15962 }
15963 }
15964 multilines && deindent();
15965 push(multilines ? `}` : ` }`);
15966}
15967function genArrayExpression(node, context) {
15968 genNodeListAsArray(node.elements, context);
15969}
15970function genFunctionExpression(node, context) {
15971 const { push, indent, deindent } = context;
15972 const { params, returns, body, newline, isSlot } = node;
15973 if (isSlot) {
15974 // wrap slot functions with owner context
15975 push(`_${helperNameMap[WITH_CTX]}(`);
15976 }
15977 push(`(`, node);
15978 if (isArray(params)) {
15979 genNodeList(params, context);
15980 }
15981 else if (params) {
15982 genNode(params, context);
15983 }
15984 push(`) => `);
15985 if (newline || body) {
15986 push(`{`);
15987 indent();
15988 }
15989 if (returns) {
15990 if (newline) {
15991 push(`return `);
15992 }
15993 if (isArray(returns)) {
15994 genNodeListAsArray(returns, context);
15995 }
15996 else {
15997 genNode(returns, context);
15998 }
15999 }
16000 else if (body) {
16001 genNode(body, context);
16002 }
16003 if (newline || body) {
16004 deindent();
16005 push(`}`);
16006 }
16007 if (isSlot) {
16008 if (node.isNonScopedSlot) {
16009 push(`, undefined, true`);
16010 }
16011 push(`)`);
16012 }
16013}
16014function genConditionalExpression(node, context) {
16015 const { test, consequent, alternate, newline: needNewline } = node;
16016 const { push, indent, deindent, newline } = context;
16017 if (test.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
16018 const needsParens = !isSimpleIdentifier(test.content);
16019 needsParens && push(`(`);
16020 genExpression(test, context);
16021 needsParens && push(`)`);
16022 }
16023 else {
16024 push(`(`);
16025 genNode(test, context);
16026 push(`)`);
16027 }
16028 needNewline && indent();
16029 context.indentLevel++;
16030 needNewline || push(` `);
16031 push(`? `);
16032 genNode(consequent, context);
16033 context.indentLevel--;
16034 needNewline && newline();
16035 needNewline || push(` `);
16036 push(`: `);
16037 const isNested = alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */;
16038 if (!isNested) {
16039 context.indentLevel++;
16040 }
16041 genNode(alternate, context);
16042 if (!isNested) {
16043 context.indentLevel--;
16044 }
16045 needNewline && deindent(true /* without newline */);
16046}
16047function genCacheExpression(node, context) {
16048 const { push, helper, indent, deindent, newline } = context;
16049 push(`_cache[${node.index}] || (`);
16050 if (node.isVNode) {
16051 indent();
16052 push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
16053 newline();
16054 }
16055 push(`_cache[${node.index}] = `);
16056 genNode(node.value, context);
16057 if (node.isVNode) {
16058 push(`,`);
16059 newline();
16060 push(`${helper(SET_BLOCK_TRACKING)}(1),`);
16061 newline();
16062 push(`_cache[${node.index}]`);
16063 deindent();
16064 }
16065 push(`)`);
16066}
16067function genTemplateLiteral(node, context) {
16068 const { push, indent, deindent } = context;
16069 push('`');
16070 const l = node.elements.length;
16071 const multilines = l > 3;
16072 for (let i = 0; i < l; i++) {
16073 const e = node.elements[i];
16074 if (isString(e)) {
16075 push(e.replace(/(`|\$|\\)/g, '\\$1'));
16076 }
16077 else {
16078 push('${');
16079 if (multilines)
16080 indent();
16081 genNode(e, context);
16082 if (multilines)
16083 deindent();
16084 push('}');
16085 }
16086 }
16087 push('`');
16088}
16089function genIfStatement(node, context) {
16090 const { push, indent, deindent } = context;
16091 const { test, consequent, alternate } = node;
16092 push(`if (`);
16093 genNode(test, context);
16094 push(`) {`);
16095 indent();
16096 genNode(consequent, context);
16097 deindent();
16098 push(`}`);
16099 if (alternate) {
16100 push(` else `);
16101 if (alternate.type === 23 /* NodeTypes.JS_IF_STATEMENT */) {
16102 genIfStatement(alternate, context);
16103 }
16104 else {
16105 push(`{`);
16106 indent();
16107 genNode(alternate, context);
16108 deindent();
16109 push(`}`);
16110 }
16111 }
16112}
16113function genAssignmentExpression(node, context) {
16114 genNode(node.left, context);
16115 context.push(` = `);
16116 genNode(node.right, context);
16117}
16118function genSequenceExpression(node, context) {
16119 context.push(`(`);
16120 genNodeList(node.expressions, context);
16121 context.push(`)`);
16122}
16123function genReturnStatement({ returns }, context) {
16124 context.push(`return `);
16125 if (isArray(returns)) {
16126 genNodeListAsArray(returns, context);
16127 }
16128 else {
16129 genNode(returns, context);
16130 }
16131}
16132
16133function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = Object.create(null)) {
16134 const rootExp = root.type === 'Program' &&
16135 root.body[0].type === 'ExpressionStatement' &&
16136 root.body[0].expression;
16137 estreeWalker.walk(root, {
16138 enter(node, parent) {
16139 parent && parentStack.push(parent);
16140 if (parent &&
16141 parent.type.startsWith('TS') &&
16142 parent.type !== 'TSAsExpression' &&
16143 parent.type !== 'TSNonNullExpression' &&
16144 parent.type !== 'TSTypeAssertion') {
16145 return this.skip();
16146 }
16147 if (node.type === 'Identifier') {
16148 const isLocal = !!knownIds[node.name];
16149 const isRefed = isReferencedIdentifier(node, parent, parentStack);
16150 if (includeAll || (isRefed && !isLocal)) {
16151 onIdentifier(node, parent, parentStack, isRefed, isLocal);
16152 }
16153 }
16154 else if (node.type === 'ObjectProperty' &&
16155 parent.type === 'ObjectPattern') {
16156 node.inPattern = true;
16157 }
16158 else if (isFunctionType(node)) {
16159 // walk function expressions and add its arguments to known identifiers
16160 // so that we don't prefix them
16161 walkFunctionParams(node, id => markScopeIdentifier(node, id, knownIds));
16162 }
16163 else if (node.type === 'BlockStatement') {
16164 // #3445 record block-level local variables
16165 walkBlockDeclarations(node, id => markScopeIdentifier(node, id, knownIds));
16166 }
16167 },
16168 leave(node, parent) {
16169 parent && parentStack.pop();
16170 if (node !== rootExp && node.scopeIds) {
16171 for (const id of node.scopeIds) {
16172 knownIds[id]--;
16173 if (knownIds[id] === 0) {
16174 delete knownIds[id];
16175 }
16176 }
16177 }
16178 }
16179 });
16180}
16181function isReferencedIdentifier(id, parent, parentStack) {
16182 if (!parent) {
16183 return true;
16184 }
16185 // is a special keyword but parsed as identifier
16186 if (id.name === 'arguments') {
16187 return false;
16188 }
16189 if (isReferenced(id, parent)) {
16190 return true;
16191 }
16192 // babel's isReferenced check returns false for ids being assigned to, so we
16193 // need to cover those cases here
16194 switch (parent.type) {
16195 case 'AssignmentExpression':
16196 case 'AssignmentPattern':
16197 return true;
16198 case 'ObjectPattern':
16199 case 'ArrayPattern':
16200 return isInDestructureAssignment(parent, parentStack);
16201 }
16202 return false;
16203}
16204function isInDestructureAssignment(parent, parentStack) {
16205 if (parent &&
16206 (parent.type === 'ObjectProperty' || parent.type === 'ArrayPattern')) {
16207 let i = parentStack.length;
16208 while (i--) {
16209 const p = parentStack[i];
16210 if (p.type === 'AssignmentExpression') {
16211 return true;
16212 }
16213 else if (p.type !== 'ObjectProperty' && !p.type.endsWith('Pattern')) {
16214 break;
16215 }
16216 }
16217 }
16218 return false;
16219}
16220function walkFunctionParams(node, onIdent) {
16221 for (const p of node.params) {
16222 for (const id of extractIdentifiers(p)) {
16223 onIdent(id);
16224 }
16225 }
16226}
16227function walkBlockDeclarations(block, onIdent) {
16228 for (const stmt of block.body) {
16229 if (stmt.type === 'VariableDeclaration') {
16230 if (stmt.declare)
16231 continue;
16232 for (const decl of stmt.declarations) {
16233 for (const id of extractIdentifiers(decl.id)) {
16234 onIdent(id);
16235 }
16236 }
16237 }
16238 else if (stmt.type === 'FunctionDeclaration' ||
16239 stmt.type === 'ClassDeclaration') {
16240 if (stmt.declare || !stmt.id)
16241 continue;
16242 onIdent(stmt.id);
16243 }
16244 }
16245}
16246function extractIdentifiers(param, nodes = []) {
16247 switch (param.type) {
16248 case 'Identifier':
16249 nodes.push(param);
16250 break;
16251 case 'MemberExpression':
16252 let object = param;
16253 while (object.type === 'MemberExpression') {
16254 object = object.object;
16255 }
16256 nodes.push(object);
16257 break;
16258 case 'ObjectPattern':
16259 for (const prop of param.properties) {
16260 if (prop.type === 'RestElement') {
16261 extractIdentifiers(prop.argument, nodes);
16262 }
16263 else {
16264 extractIdentifiers(prop.value, nodes);
16265 }
16266 }
16267 break;
16268 case 'ArrayPattern':
16269 param.elements.forEach(element => {
16270 if (element)
16271 extractIdentifiers(element, nodes);
16272 });
16273 break;
16274 case 'RestElement':
16275 extractIdentifiers(param.argument, nodes);
16276 break;
16277 case 'AssignmentPattern':
16278 extractIdentifiers(param.left, nodes);
16279 break;
16280 }
16281 return nodes;
16282}
16283function markScopeIdentifier(node, child, knownIds) {
16284 const { name } = child;
16285 if (node.scopeIds && node.scopeIds.has(name)) {
16286 return;
16287 }
16288 if (name in knownIds) {
16289 knownIds[name]++;
16290 }
16291 else {
16292 knownIds[name] = 1;
16293 }
16294 (node.scopeIds || (node.scopeIds = new Set())).add(name);
16295}
16296const isFunctionType = (node) => {
16297 return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
16298};
16299const isStaticProperty = (node) => node &&
16300 (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
16301 !node.computed;
16302const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
16303/**
16304 * Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
16305 * To avoid runtime dependency on @babel/types (which includes process references)
16306 * This file should not change very often in babel but we may need to keep it
16307 * up-to-date from time to time.
16308 *
16309 * https://github.com/babel/babel/blob/main/LICENSE
16310 *
16311 */
16312function isReferenced(node, parent, grandparent) {
16313 switch (parent.type) {
16314 // yes: PARENT[NODE]
16315 // yes: NODE.child
16316 // no: parent.NODE
16317 case 'MemberExpression':
16318 case 'OptionalMemberExpression':
16319 if (parent.property === node) {
16320 return !!parent.computed;
16321 }
16322 return parent.object === node;
16323 case 'JSXMemberExpression':
16324 return parent.object === node;
16325 // no: let NODE = init;
16326 // yes: let id = NODE;
16327 case 'VariableDeclarator':
16328 return parent.init === node;
16329 // yes: () => NODE
16330 // no: (NODE) => {}
16331 case 'ArrowFunctionExpression':
16332 return parent.body === node;
16333 // no: class { #NODE; }
16334 // no: class { get #NODE() {} }
16335 // no: class { #NODE() {} }
16336 // no: class { fn() { return this.#NODE; } }
16337 case 'PrivateName':
16338 return false;
16339 // no: class { NODE() {} }
16340 // yes: class { [NODE]() {} }
16341 // no: class { foo(NODE) {} }
16342 case 'ClassMethod':
16343 case 'ClassPrivateMethod':
16344 case 'ObjectMethod':
16345 if (parent.key === node) {
16346 return !!parent.computed;
16347 }
16348 return false;
16349 // yes: { [NODE]: "" }
16350 // no: { NODE: "" }
16351 // depends: { NODE }
16352 // depends: { key: NODE }
16353 case 'ObjectProperty':
16354 if (parent.key === node) {
16355 return !!parent.computed;
16356 }
16357 // parent.value === node
16358 return !grandparent || grandparent.type !== 'ObjectPattern';
16359 // no: class { NODE = value; }
16360 // yes: class { [NODE] = value; }
16361 // yes: class { key = NODE; }
16362 case 'ClassProperty':
16363 if (parent.key === node) {
16364 return !!parent.computed;
16365 }
16366 return true;
16367 case 'ClassPrivateProperty':
16368 return parent.key !== node;
16369 // no: class NODE {}
16370 // yes: class Foo extends NODE {}
16371 case 'ClassDeclaration':
16372 case 'ClassExpression':
16373 return parent.superClass === node;
16374 // yes: left = NODE;
16375 // no: NODE = right;
16376 case 'AssignmentExpression':
16377 return parent.right === node;
16378 // no: [NODE = foo] = [];
16379 // yes: [foo = NODE] = [];
16380 case 'AssignmentPattern':
16381 return parent.right === node;
16382 // no: NODE: for (;;) {}
16383 case 'LabeledStatement':
16384 return false;
16385 // no: try {} catch (NODE) {}
16386 case 'CatchClause':
16387 return false;
16388 // no: function foo(...NODE) {}
16389 case 'RestElement':
16390 return false;
16391 case 'BreakStatement':
16392 case 'ContinueStatement':
16393 return false;
16394 // no: function NODE() {}
16395 // no: function foo(NODE) {}
16396 case 'FunctionDeclaration':
16397 case 'FunctionExpression':
16398 return false;
16399 // no: export NODE from "foo";
16400 // no: export * as NODE from "foo";
16401 case 'ExportNamespaceSpecifier':
16402 case 'ExportDefaultSpecifier':
16403 return false;
16404 // no: export { foo as NODE };
16405 // yes: export { NODE as foo };
16406 // no: export { NODE as foo } from "foo";
16407 case 'ExportSpecifier':
16408 // @ts-expect-error
16409 if (grandparent === null || grandparent === void 0 ? void 0 : grandparent.source) {
16410 return false;
16411 }
16412 return parent.local === node;
16413 // no: import NODE from "foo";
16414 // no: import * as NODE from "foo";
16415 // no: import { NODE as foo } from "foo";
16416 // no: import { foo as NODE } from "foo";
16417 // no: import NODE from "bar";
16418 case 'ImportDefaultSpecifier':
16419 case 'ImportNamespaceSpecifier':
16420 case 'ImportSpecifier':
16421 return false;
16422 // no: import "foo" assert { NODE: "json" }
16423 case 'ImportAttribute':
16424 return false;
16425 // no: <div NODE="foo" />
16426 case 'JSXAttribute':
16427 return false;
16428 // no: [NODE] = [];
16429 // no: ({ NODE }) = [];
16430 case 'ObjectPattern':
16431 case 'ArrayPattern':
16432 return false;
16433 // no: new.NODE
16434 // no: NODE.target
16435 case 'MetaProperty':
16436 return false;
16437 // yes: type X = { someProperty: NODE }
16438 // no: type X = { NODE: OtherType }
16439 case 'ObjectTypeProperty':
16440 return parent.key !== node;
16441 // yes: enum X { Foo = NODE }
16442 // no: enum X { NODE }
16443 case 'TSEnumMember':
16444 return parent.id !== node;
16445 // yes: { [NODE]: value }
16446 // no: { NODE: value }
16447 case 'TSPropertySignature':
16448 if (parent.key === node) {
16449 return !!parent.computed;
16450 }
16451 return true;
16452 }
16453 return true;
16454}
16455
16456const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this');
16457const transformExpression = (node, context) => {
16458 if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
16459 node.content = processExpression(node.content, context);
16460 }
16461 else if (node.type === 1 /* NodeTypes.ELEMENT */) {
16462 // handle directives on element
16463 for (let i = 0; i < node.props.length; i++) {
16464 const dir = node.props[i];
16465 // do not process for v-on & v-for since they are special handled
16466 if (dir.type === 7 /* NodeTypes.DIRECTIVE */ && dir.name !== 'for') {
16467 const exp = dir.exp;
16468 const arg = dir.arg;
16469 // do not process exp if this is v-on:arg - we need special handling
16470 // for wrapping inline statements.
16471 if (exp &&
16472 exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
16473 !(dir.name === 'on' && arg)) {
16474 dir.exp = processExpression(exp, context,
16475 // slot args must be processed as function params
16476 dir.name === 'slot');
16477 }
16478 if (arg && arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !arg.isStatic) {
16479 dir.arg = processExpression(arg, context);
16480 }
16481 }
16482 }
16483 }
16484};
16485// Important: since this function uses Node.js only dependencies, it should
16486// always be used with a leading !false check so that it can be
16487// tree-shaken from the browser build.
16488function processExpression(node, context,
16489// some expressions like v-slot props & v-for aliases should be parsed as
16490// function params
16491asParams = false,
16492// v-on handler values may contain multiple statements
16493asRawStatements = false, localVars = Object.create(context.identifiers)) {
16494 if (!context.prefixIdentifiers || !node.content.trim()) {
16495 return node;
16496 }
16497 const { inline, bindingMetadata } = context;
16498 const rewriteIdentifier = (raw, parent, id) => {
16499 const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
16500 if (inline) {
16501 // x = y
16502 const isAssignmentLVal = parent && parent.type === 'AssignmentExpression' && parent.left === id;
16503 // x++
16504 const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
16505 // ({ x } = y)
16506 const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
16507 if (type === "setup-const" /* BindingTypes.SETUP_CONST */ ||
16508 type === "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */ ||
16509 localVars[raw]) {
16510 return raw;
16511 }
16512 else if (type === "setup-ref" /* BindingTypes.SETUP_REF */) {
16513 return `${raw}.value`;
16514 }
16515 else if (type === "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */) {
16516 // const binding that may or may not be ref
16517 // if it's not a ref, then assignments don't make sense -
16518 // so we ignore the non-ref assignment case and generate code
16519 // that assumes the value to be a ref for more efficiency
16520 return isAssignmentLVal || isUpdateArg || isDestructureAssignment
16521 ? `${raw}.value`
16522 : `${context.helperString(UNREF)}(${raw})`;
16523 }
16524 else if (type === "setup-let" /* BindingTypes.SETUP_LET */) {
16525 if (isAssignmentLVal) {
16526 // let binding.
16527 // this is a bit more tricky as we need to cover the case where
16528 // let is a local non-ref value, and we need to replicate the
16529 // right hand side value.
16530 // x = y --> isRef(x) ? x.value = y : x = y
16531 const { right: rVal, operator } = parent;
16532 const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
16533 const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context, false, false, knownIds));
16534 return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore\n` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
16535 }
16536 else if (isUpdateArg) {
16537 // make id replace parent in the code range so the raw update operator
16538 // is removed
16539 id.start = parent.start;
16540 id.end = parent.end;
16541 const { prefix: isPrefix, operator } = parent;
16542 const prefix = isPrefix ? operator : ``;
16543 const postfix = isPrefix ? `` : operator;
16544 // let binding.
16545 // x++ --> isRef(a) ? a.value++ : a++
16546 return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore\n` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
16547 }
16548 else if (isDestructureAssignment) {
16549 // TODO
16550 // let binding in a destructure assignment - it's very tricky to
16551 // handle both possible cases here without altering the original
16552 // structure of the code, so we just assume it's not a ref here
16553 // for now
16554 return raw;
16555 }
16556 else {
16557 return `${context.helperString(UNREF)}(${raw})`;
16558 }
16559 }
16560 else if (type === "props" /* BindingTypes.PROPS */) {
16561 // use __props which is generated by compileScript so in ts mode
16562 // it gets correct type
16563 return genPropsAccessExp(raw);
16564 }
16565 else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
16566 // prop with a different local alias (from defineProps() destructure)
16567 return genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
16568 }
16569 }
16570 else {
16571 if (type && type.startsWith('setup')) {
16572 // setup bindings in non-inline mode
16573 return `$setup.${raw}`;
16574 }
16575 else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
16576 return `$props['${bindingMetadata.__propsAliases[raw]}']`;
16577 }
16578 else if (type) {
16579 return `$${type}.${raw}`;
16580 }
16581 }
16582 // fallback to ctx
16583 return `_ctx.${raw}`;
16584 };
16585 // fast path if expression is a simple identifier.
16586 const rawExp = node.content;
16587 // bail constant on parens (function invocation) and dot (member access)
16588 const bailConstant = rawExp.indexOf(`(`) > -1 || rawExp.indexOf('.') > 0;
16589 if (isSimpleIdentifier(rawExp)) {
16590 const isScopeVarReference = context.identifiers[rawExp];
16591 const isAllowedGlobal = isGloballyWhitelisted(rawExp);
16592 const isLiteral = isLiteralWhitelisted(rawExp);
16593 if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
16594 // const bindings exposed from setup can be skipped for patching but
16595 // cannot be hoisted to module scope
16596 if (bindingMetadata[node.content] === "setup-const" /* BindingTypes.SETUP_CONST */) {
16597 node.constType = 1 /* ConstantTypes.CAN_SKIP_PATCH */;
16598 }
16599 node.content = rewriteIdentifier(rawExp);
16600 }
16601 else if (!isScopeVarReference) {
16602 if (isLiteral) {
16603 node.constType = 3 /* ConstantTypes.CAN_STRINGIFY */;
16604 }
16605 else {
16606 node.constType = 2 /* ConstantTypes.CAN_HOIST */;
16607 }
16608 }
16609 return node;
16610 }
16611 let ast;
16612 // exp needs to be parsed differently:
16613 // 1. Multiple inline statements (v-on, with presence of `;`): parse as raw
16614 // exp, but make sure to pad with spaces for consistent ranges
16615 // 2. Expressions: wrap with parens (for e.g. object expressions)
16616 // 3. Function arguments (v-for, v-slot): place in a function argument position
16617 const source = asRawStatements
16618 ? ` ${rawExp} `
16619 : `(${rawExp})${asParams ? `=>{}` : ``}`;
16620 try {
16621 ast = parser.parse(source, {
16622 plugins: context.expressionPlugins
16623 }).program;
16624 }
16625 catch (e) {
16626 context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
16627 return node;
16628 }
16629 const ids = [];
16630 const parentStack = [];
16631 const knownIds = Object.create(context.identifiers);
16632 walkIdentifiers(ast, (node, parent, _, isReferenced, isLocal) => {
16633 if (isStaticPropertyKey(node, parent)) {
16634 return;
16635 }
16636 // v2 wrapped filter call
16637 if (node.name.startsWith('_filter_')) {
16638 return;
16639 }
16640 const needPrefix = isReferenced && canPrefix(node);
16641 if (needPrefix && !isLocal) {
16642 if (isStaticProperty(parent) && parent.shorthand) {
16643 node.prefix = `${node.name}: `;
16644 }
16645 node.name = rewriteIdentifier(node.name, parent, node);
16646 ids.push(node);
16647 }
16648 else {
16649 // The identifier is considered constant unless it's pointing to a
16650 // local scope variable (a v-for alias, or a v-slot prop)
16651 if (!(needPrefix && isLocal) && !bailConstant) {
16652 node.isConstant = true;
16653 }
16654 // also generate sub-expressions for other identifiers for better
16655 // source map support. (except for property keys which are static)
16656 ids.push(node);
16657 }
16658 }, true, // invoke on ALL identifiers
16659 parentStack, knownIds);
16660 // We break up the compound expression into an array of strings and sub
16661 // expressions (for identifiers that have been prefixed). In codegen, if
16662 // an ExpressionNode has the `.children` property, it will be used instead of
16663 // `.content`.
16664 const children = [];
16665 ids.sort((a, b) => a.start - b.start);
16666 ids.forEach((id, i) => {
16667 // range is offset by -1 due to the wrapping parens when parsed
16668 const start = id.start - 1;
16669 const end = id.end - 1;
16670 const last = ids[i - 1];
16671 const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
16672 if (leadingText.length || id.prefix) {
16673 children.push(leadingText + (id.prefix || ``));
16674 }
16675 const source = rawExp.slice(start, end);
16676 children.push(createSimpleExpression(id.name, false, {
16677 source,
16678 start: advancePositionWithClone(node.loc.start, source, start),
16679 end: advancePositionWithClone(node.loc.start, source, end)
16680 }, id.isConstant ? 3 /* ConstantTypes.CAN_STRINGIFY */ : 0 /* ConstantTypes.NOT_CONSTANT */));
16681 if (i === ids.length - 1 && end < rawExp.length) {
16682 children.push(rawExp.slice(end));
16683 }
16684 });
16685 let ret;
16686 if (children.length) {
16687 ret = createCompoundExpression(children, node.loc);
16688 }
16689 else {
16690 ret = node;
16691 ret.constType = bailConstant
16692 ? 0 /* ConstantTypes.NOT_CONSTANT */
16693 : 3 /* ConstantTypes.CAN_STRINGIFY */;
16694 }
16695 ret.identifiers = Object.keys(knownIds);
16696 return ret;
16697}
16698function canPrefix(id) {
16699 // skip whitelisted globals
16700 if (isGloballyWhitelisted(id.name)) {
16701 return false;
16702 }
16703 // special case for webpack compilation
16704 if (id.name === 'require') {
16705 return false;
16706 }
16707 return true;
16708}
16709function stringifyExpression(exp) {
16710 if (isString(exp)) {
16711 return exp;
16712 }
16713 else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
16714 return exp.content;
16715 }
16716 else {
16717 return exp.children
16718 .map(stringifyExpression)
16719 .join('');
16720 }
16721}
16722
16723const transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (node, dir, context) => {
16724 return processIf(node, dir, context, (ifNode, branch, isRoot) => {
16725 // #1587: We need to dynamically increment the key based on the current
16726 // node's sibling nodes, since chained v-if/else branches are
16727 // rendered at the same depth
16728 const siblings = context.parent.children;
16729 let i = siblings.indexOf(ifNode);
16730 let key = 0;
16731 while (i-- >= 0) {
16732 const sibling = siblings[i];
16733 if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
16734 key += sibling.branches.length;
16735 }
16736 }
16737 // Exit callback. Complete the codegenNode when all children have been
16738 // transformed.
16739 return () => {
16740 if (isRoot) {
16741 ifNode.codegenNode = createCodegenNodeForBranch(branch, key, context);
16742 }
16743 else {
16744 // attach this branch's codegen node to the v-if root.
16745 const parentCondition = getParentCondition(ifNode.codegenNode);
16746 parentCondition.alternate = createCodegenNodeForBranch(branch, key + ifNode.branches.length - 1, context);
16747 }
16748 };
16749 });
16750});
16751// target-agnostic transform used for both Client and SSR
16752function processIf(node, dir, context, processCodegen) {
16753 if (dir.name !== 'else' &&
16754 (!dir.exp || !dir.exp.content.trim())) {
16755 const loc = dir.exp ? dir.exp.loc : node.loc;
16756 context.onError(createCompilerError(28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */, dir.loc));
16757 dir.exp = createSimpleExpression(`true`, false, loc);
16758 }
16759 if (context.prefixIdentifiers && dir.exp) {
16760 // dir.exp can only be simple expression because vIf transform is applied
16761 // before expression transform.
16762 dir.exp = processExpression(dir.exp, context);
16763 }
16764 if (dir.name === 'if') {
16765 const branch = createIfBranch(node, dir);
16766 const ifNode = {
16767 type: 9 /* NodeTypes.IF */,
16768 loc: node.loc,
16769 branches: [branch]
16770 };
16771 context.replaceNode(ifNode);
16772 if (processCodegen) {
16773 return processCodegen(ifNode, branch, true);
16774 }
16775 }
16776 else {
16777 // locate the adjacent v-if
16778 const siblings = context.parent.children;
16779 const comments = [];
16780 let i = siblings.indexOf(node);
16781 while (i-- >= -1) {
16782 const sibling = siblings[i];
16783 if (sibling && sibling.type === 3 /* NodeTypes.COMMENT */) {
16784 context.removeNode(sibling);
16785 comments.unshift(sibling);
16786 continue;
16787 }
16788 if (sibling &&
16789 sibling.type === 2 /* NodeTypes.TEXT */ &&
16790 !sibling.content.trim().length) {
16791 context.removeNode(sibling);
16792 continue;
16793 }
16794 if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
16795 // Check if v-else was followed by v-else-if
16796 if (dir.name === 'else-if' &&
16797 sibling.branches[sibling.branches.length - 1].condition === undefined) {
16798 context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
16799 }
16800 // move the node to the if node's branches
16801 context.removeNode();
16802 const branch = createIfBranch(node, dir);
16803 if (comments.length &&
16804 // #3619 ignore comments if the v-if is direct child of <transition>
16805 !(context.parent &&
16806 context.parent.type === 1 /* NodeTypes.ELEMENT */ &&
16807 isBuiltInType(context.parent.tag, 'transition'))) {
16808 branch.children = [...comments, ...branch.children];
16809 }
16810 // check if user is forcing same key on different branches
16811 {
16812 const key = branch.userKey;
16813 if (key) {
16814 sibling.branches.forEach(({ userKey }) => {
16815 if (isSameKey(userKey, key)) {
16816 context.onError(createCompilerError(29 /* ErrorCodes.X_V_IF_SAME_KEY */, branch.userKey.loc));
16817 }
16818 });
16819 }
16820 }
16821 sibling.branches.push(branch);
16822 const onExit = processCodegen && processCodegen(sibling, branch, false);
16823 // since the branch was removed, it will not be traversed.
16824 // make sure to traverse here.
16825 traverseNode(branch, context);
16826 // call on exit
16827 if (onExit)
16828 onExit();
16829 // make sure to reset currentNode after traversal to indicate this
16830 // node has been removed.
16831 context.currentNode = null;
16832 }
16833 else {
16834 context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
16835 }
16836 break;
16837 }
16838 }
16839}
16840function createIfBranch(node, dir) {
16841 const isTemplateIf = node.tagType === 3 /* ElementTypes.TEMPLATE */;
16842 return {
16843 type: 10 /* NodeTypes.IF_BRANCH */,
16844 loc: node.loc,
16845 condition: dir.name === 'else' ? undefined : dir.exp,
16846 children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
16847 userKey: findProp(node, `key`),
16848 isTemplateIf
16849 };
16850}
16851function createCodegenNodeForBranch(branch, keyIndex, context) {
16852 if (branch.condition) {
16853 return createConditionalExpression(branch.condition, createChildrenCodegenNode(branch, keyIndex, context),
16854 // make sure to pass in asBlock: true so that the comment node call
16855 // closes the current block.
16856 createCallExpression(context.helper(CREATE_COMMENT), [
16857 '"v-if"' ,
16858 'true'
16859 ]));
16860 }
16861 else {
16862 return createChildrenCodegenNode(branch, keyIndex, context);
16863 }
16864}
16865function createChildrenCodegenNode(branch, keyIndex, context) {
16866 const { helper } = context;
16867 const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* ConstantTypes.CAN_HOIST */));
16868 const { children } = branch;
16869 const firstChild = children[0];
16870 const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* NodeTypes.ELEMENT */;
16871 if (needFragmentWrapper) {
16872 if (children.length === 1 && firstChild.type === 11 /* NodeTypes.FOR */) {
16873 // optimize away nested fragments when child is a ForNode
16874 const vnodeCall = firstChild.codegenNode;
16875 injectProp(vnodeCall, keyProperty, context);
16876 return vnodeCall;
16877 }
16878 else {
16879 let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
16880 let patchFlagText = PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
16881 // check if the fragment actually contains a single valid child with
16882 // the rest being comments
16883 if (!branch.isTemplateIf &&
16884 children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
16885 patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
16886 patchFlagText += `, ${PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
16887 }
16888 return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, false, false /* isComponent */, branch.loc);
16889 }
16890 }
16891 else {
16892 const ret = firstChild.codegenNode;
16893 const vnodeCall = getMemoedVNodeCall(ret);
16894 // Change createVNode to createBlock.
16895 if (vnodeCall.type === 13 /* NodeTypes.VNODE_CALL */) {
16896 makeBlock(vnodeCall, context);
16897 }
16898 // inject branch key
16899 injectProp(vnodeCall, keyProperty, context);
16900 return ret;
16901 }
16902}
16903function isSameKey(a, b) {
16904 if (!a || a.type !== b.type) {
16905 return false;
16906 }
16907 if (a.type === 6 /* NodeTypes.ATTRIBUTE */) {
16908 if (a.value.content !== b.value.content) {
16909 return false;
16910 }
16911 }
16912 else {
16913 // directive
16914 const exp = a.exp;
16915 const branchExp = b.exp;
16916 if (exp.type !== branchExp.type) {
16917 return false;
16918 }
16919 if (exp.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
16920 exp.isStatic !== branchExp.isStatic ||
16921 exp.content !== branchExp.content) {
16922 return false;
16923 }
16924 }
16925 return true;
16926}
16927function getParentCondition(node) {
16928 while (true) {
16929 if (node.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
16930 if (node.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
16931 node = node.alternate;
16932 }
16933 else {
16934 return node;
16935 }
16936 }
16937 else if (node.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */) {
16938 node = node.value;
16939 }
16940 }
16941}
16942
16943const transformFor = createStructuralDirectiveTransform('for', (node, dir, context) => {
16944 const { helper, removeHelper } = context;
16945 return processFor(node, dir, context, forNode => {
16946 // create the loop render function expression now, and add the
16947 // iterator on exit after all children have been traversed
16948 const renderExp = createCallExpression(helper(RENDER_LIST), [
16949 forNode.source
16950 ]);
16951 const isTemplate = isTemplateNode(node);
16952 const memo = findDir(node, 'memo');
16953 const keyProp = findProp(node, `key`);
16954 const keyExp = keyProp &&
16955 (keyProp.type === 6 /* NodeTypes.ATTRIBUTE */
16956 ? createSimpleExpression(keyProp.value.content, true)
16957 : keyProp.exp);
16958 const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
16959 if (isTemplate) {
16960 // #2085 / #5288 process :key and v-memo expressions need to be
16961 // processed on `<template v-for>`. In this case the node is discarded
16962 // and never traversed so its binding expressions won't be processed
16963 // by the normal transforms.
16964 if (memo) {
16965 memo.exp = processExpression(memo.exp, context);
16966 }
16967 if (keyProperty && keyProp.type !== 6 /* NodeTypes.ATTRIBUTE */) {
16968 keyProperty.value = processExpression(keyProperty.value, context);
16969 }
16970 }
16971 const isStableFragment = forNode.source.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
16972 forNode.source.constType > 0 /* ConstantTypes.NOT_CONSTANT */;
16973 const fragmentFlag = isStableFragment
16974 ? 64 /* PatchFlags.STABLE_FRAGMENT */
16975 : keyProp
16976 ? 128 /* PatchFlags.KEYED_FRAGMENT */
16977 : 256 /* PatchFlags.UNKEYED_FRAGMENT */;
16978 forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
16979 (` /* ${PatchFlagNames[fragmentFlag]} */` ), undefined, undefined, true /* isBlock */, !isStableFragment /* disableTracking */, false /* isComponent */, node.loc);
16980 return () => {
16981 // finish the codegen now that all children have been traversed
16982 let childBlock;
16983 const { children } = forNode;
16984 // check <template v-for> key placement
16985 if (isTemplate) {
16986 node.children.some(c => {
16987 if (c.type === 1 /* NodeTypes.ELEMENT */) {
16988 const key = findProp(c, 'key');
16989 if (key) {
16990 context.onError(createCompilerError(33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
16991 return true;
16992 }
16993 }
16994 });
16995 }
16996 const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* NodeTypes.ELEMENT */;
16997 const slotOutlet = isSlotOutlet(node)
16998 ? node
16999 : isTemplate &&
17000 node.children.length === 1 &&
17001 isSlotOutlet(node.children[0])
17002 ? node.children[0] // api-extractor somehow fails to infer this
17003 : null;
17004 if (slotOutlet) {
17005 // <slot v-for="..."> or <template v-for="..."><slot/></template>
17006 childBlock = slotOutlet.codegenNode;
17007 if (isTemplate && keyProperty) {
17008 // <template v-for="..." :key="..."><slot/></template>
17009 // we need to inject the key to the renderSlot() call.
17010 // the props for renderSlot is passed as the 3rd argument.
17011 injectProp(childBlock, keyProperty, context);
17012 }
17013 }
17014 else if (needFragmentWrapper) {
17015 // <template v-for="..."> with text or multi-elements
17016 // should generate a fragment block for each loop
17017 childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* PatchFlags.STABLE_FRAGMENT */ +
17018 (` /* ${PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */]} */`
17019 ), undefined, undefined, true, undefined, false /* isComponent */);
17020 }
17021 else {
17022 // Normal element v-for. Directly use the child's codegenNode
17023 // but mark it as a block.
17024 childBlock = children[0]
17025 .codegenNode;
17026 if (isTemplate && keyProperty) {
17027 injectProp(childBlock, keyProperty, context);
17028 }
17029 if (childBlock.isBlock !== !isStableFragment) {
17030 if (childBlock.isBlock) {
17031 // switch from block to vnode
17032 removeHelper(OPEN_BLOCK);
17033 removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
17034 }
17035 else {
17036 // switch from vnode to block
17037 removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
17038 }
17039 }
17040 childBlock.isBlock = !isStableFragment;
17041 if (childBlock.isBlock) {
17042 helper(OPEN_BLOCK);
17043 helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
17044 }
17045 else {
17046 helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
17047 }
17048 }
17049 if (memo) {
17050 const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [
17051 createSimpleExpression(`_cached`)
17052 ]));
17053 loop.body = createBlockStatement([
17054 createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
17055 createCompoundExpression([
17056 `if (_cached`,
17057 ...(keyExp ? [` && _cached.key === `, keyExp] : []),
17058 ` && ${context.helperString(IS_MEMO_SAME)}(_cached, _memo)) return _cached`
17059 ]),
17060 createCompoundExpression([`const _item = `, childBlock]),
17061 createSimpleExpression(`_item.memo = _memo`),
17062 createSimpleExpression(`return _item`)
17063 ]);
17064 renderExp.arguments.push(loop, createSimpleExpression(`_cache`), createSimpleExpression(String(context.cached++)));
17065 }
17066 else {
17067 renderExp.arguments.push(createFunctionExpression(createForLoopParams(forNode.parseResult), childBlock, true /* force newline */));
17068 }
17069 };
17070 });
17071});
17072// target-agnostic transform used for both Client and SSR
17073function processFor(node, dir, context, processCodegen) {
17074 if (!dir.exp) {
17075 context.onError(createCompilerError(31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */, dir.loc));
17076 return;
17077 }
17078 const parseResult = parseForExpression(
17079 // can only be simple expression because vFor transform is applied
17080 // before expression transform.
17081 dir.exp, context);
17082 if (!parseResult) {
17083 context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
17084 return;
17085 }
17086 const { addIdentifiers, removeIdentifiers, scopes } = context;
17087 const { source, value, key, index } = parseResult;
17088 const forNode = {
17089 type: 11 /* NodeTypes.FOR */,
17090 loc: dir.loc,
17091 source,
17092 valueAlias: value,
17093 keyAlias: key,
17094 objectIndexAlias: index,
17095 parseResult,
17096 children: isTemplateNode(node) ? node.children : [node]
17097 };
17098 context.replaceNode(forNode);
17099 // bookkeeping
17100 scopes.vFor++;
17101 if (context.prefixIdentifiers) {
17102 // scope management
17103 // inject identifiers to context
17104 value && addIdentifiers(value);
17105 key && addIdentifiers(key);
17106 index && addIdentifiers(index);
17107 }
17108 const onExit = processCodegen && processCodegen(forNode);
17109 return () => {
17110 scopes.vFor--;
17111 if (context.prefixIdentifiers) {
17112 value && removeIdentifiers(value);
17113 key && removeIdentifiers(key);
17114 index && removeIdentifiers(index);
17115 }
17116 if (onExit)
17117 onExit();
17118 };
17119}
17120const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
17121// This regex doesn't cover the case if key or index aliases have destructuring,
17122// but those do not make sense in the first place, so this works in practice.
17123const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
17124const stripParensRE = /^\(|\)$/g;
17125function parseForExpression(input, context) {
17126 const loc = input.loc;
17127 const exp = input.content;
17128 const inMatch = exp.match(forAliasRE);
17129 if (!inMatch)
17130 return;
17131 const [, LHS, RHS] = inMatch;
17132 const result = {
17133 source: createAliasExpression(loc, RHS.trim(), exp.indexOf(RHS, LHS.length)),
17134 value: undefined,
17135 key: undefined,
17136 index: undefined
17137 };
17138 if (context.prefixIdentifiers) {
17139 result.source = processExpression(result.source, context);
17140 }
17141 let valueContent = LHS.trim().replace(stripParensRE, '').trim();
17142 const trimmedOffset = LHS.indexOf(valueContent);
17143 const iteratorMatch = valueContent.match(forIteratorRE);
17144 if (iteratorMatch) {
17145 valueContent = valueContent.replace(forIteratorRE, '').trim();
17146 const keyContent = iteratorMatch[1].trim();
17147 let keyOffset;
17148 if (keyContent) {
17149 keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
17150 result.key = createAliasExpression(loc, keyContent, keyOffset);
17151 if (context.prefixIdentifiers) {
17152 result.key = processExpression(result.key, context, true);
17153 }
17154 }
17155 if (iteratorMatch[2]) {
17156 const indexContent = iteratorMatch[2].trim();
17157 if (indexContent) {
17158 result.index = createAliasExpression(loc, indexContent, exp.indexOf(indexContent, result.key
17159 ? keyOffset + keyContent.length
17160 : trimmedOffset + valueContent.length));
17161 if (context.prefixIdentifiers) {
17162 result.index = processExpression(result.index, context, true);
17163 }
17164 }
17165 }
17166 }
17167 if (valueContent) {
17168 result.value = createAliasExpression(loc, valueContent, trimmedOffset);
17169 if (context.prefixIdentifiers) {
17170 result.value = processExpression(result.value, context, true);
17171 }
17172 }
17173 return result;
17174}
17175function createAliasExpression(range, content, offset) {
17176 return createSimpleExpression(content, false, getInnerRange(range, offset, content.length));
17177}
17178function createForLoopParams({ value, key, index }, memoArgs = []) {
17179 return createParamsList([value, key, index, ...memoArgs]);
17180}
17181function createParamsList(args) {
17182 let i = args.length;
17183 while (i--) {
17184 if (args[i])
17185 break;
17186 }
17187 return args
17188 .slice(0, i + 1)
17189 .map((arg, i) => arg || createSimpleExpression(`_`.repeat(i + 1), false));
17190}
17191
17192const defaultFallback = createSimpleExpression(`undefined`, false);
17193// A NodeTransform that:
17194// 1. Tracks scope identifiers for scoped slots so that they don't get prefixed
17195// by transformExpression. This is only applied in non-browser builds with
17196// { prefixIdentifiers: true }.
17197// 2. Track v-slot depths so that we know a slot is inside another slot.
17198// Note the exit callback is executed before buildSlots() on the same node,
17199// so only nested slots see positive numbers.
17200const trackSlotScopes = (node, context) => {
17201 if (node.type === 1 /* NodeTypes.ELEMENT */ &&
17202 (node.tagType === 1 /* ElementTypes.COMPONENT */ ||
17203 node.tagType === 3 /* ElementTypes.TEMPLATE */)) {
17204 // We are only checking non-empty v-slot here
17205 // since we only care about slots that introduce scope variables.
17206 const vSlot = findDir(node, 'slot');
17207 if (vSlot) {
17208 const slotProps = vSlot.exp;
17209 if (context.prefixIdentifiers) {
17210 slotProps && context.addIdentifiers(slotProps);
17211 }
17212 context.scopes.vSlot++;
17213 return () => {
17214 if (context.prefixIdentifiers) {
17215 slotProps && context.removeIdentifiers(slotProps);
17216 }
17217 context.scopes.vSlot--;
17218 };
17219 }
17220 }
17221};
17222// A NodeTransform that tracks scope identifiers for scoped slots with v-for.
17223// This transform is only applied in non-browser builds with { prefixIdentifiers: true }
17224const trackVForSlotScopes = (node, context) => {
17225 let vFor;
17226 if (isTemplateNode(node) &&
17227 node.props.some(isVSlot) &&
17228 (vFor = findDir(node, 'for'))) {
17229 const result = (vFor.parseResult = parseForExpression(vFor.exp, context));
17230 if (result) {
17231 const { value, key, index } = result;
17232 const { addIdentifiers, removeIdentifiers } = context;
17233 value && addIdentifiers(value);
17234 key && addIdentifiers(key);
17235 index && addIdentifiers(index);
17236 return () => {
17237 value && removeIdentifiers(value);
17238 key && removeIdentifiers(key);
17239 index && removeIdentifiers(index);
17240 };
17241 }
17242 }
17243};
17244const buildClientSlotFn = (props, children, loc) => createFunctionExpression(props, children, false /* newline */, true /* isSlot */, children.length ? children[0].loc : loc);
17245// Instead of being a DirectiveTransform, v-slot processing is called during
17246// transformElement to build the slots object for a component.
17247function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
17248 context.helper(WITH_CTX);
17249 const { children, loc } = node;
17250 const slotsProperties = [];
17251 const dynamicSlots = [];
17252 // If the slot is inside a v-for or another v-slot, force it to be dynamic
17253 // since it likely uses a scope variable.
17254 let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
17255 // with `prefixIdentifiers: true`, this can be further optimized to make
17256 // it dynamic only when the slot actually uses the scope variables.
17257 if (!context.ssr && context.prefixIdentifiers) {
17258 hasDynamicSlots = hasScopeRef(node, context.identifiers);
17259 }
17260 // 1. Check for slot with slotProps on component itself.
17261 // <Comp v-slot="{ prop }"/>
17262 const onComponentSlot = findDir(node, 'slot', true);
17263 if (onComponentSlot) {
17264 const { arg, exp } = onComponentSlot;
17265 if (arg && !isStaticExp(arg)) {
17266 hasDynamicSlots = true;
17267 }
17268 slotsProperties.push(createObjectProperty(arg || createSimpleExpression('default', true), buildSlotFn(exp, children, loc)));
17269 }
17270 // 2. Iterate through children and check for template slots
17271 // <template v-slot:foo="{ prop }">
17272 let hasTemplateSlots = false;
17273 let hasNamedDefaultSlot = false;
17274 const implicitDefaultChildren = [];
17275 const seenSlotNames = new Set();
17276 let conditionalBranchIndex = 0;
17277 for (let i = 0; i < children.length; i++) {
17278 const slotElement = children[i];
17279 let slotDir;
17280 if (!isTemplateNode(slotElement) ||
17281 !(slotDir = findDir(slotElement, 'slot', true))) {
17282 // not a <template v-slot>, skip.
17283 if (slotElement.type !== 3 /* NodeTypes.COMMENT */) {
17284 implicitDefaultChildren.push(slotElement);
17285 }
17286 continue;
17287 }
17288 if (onComponentSlot) {
17289 // already has on-component slot - this is incorrect usage.
17290 context.onError(createCompilerError(37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
17291 break;
17292 }
17293 hasTemplateSlots = true;
17294 const { children: slotChildren, loc: slotLoc } = slotElement;
17295 const { arg: slotName = createSimpleExpression(`default`, true), exp: slotProps, loc: dirLoc } = slotDir;
17296 // check if name is dynamic.
17297 let staticSlotName;
17298 if (isStaticExp(slotName)) {
17299 staticSlotName = slotName ? slotName.content : `default`;
17300 }
17301 else {
17302 hasDynamicSlots = true;
17303 }
17304 const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
17305 // check if this slot is conditional (v-if/v-for)
17306 let vIf;
17307 let vElse;
17308 let vFor;
17309 if ((vIf = findDir(slotElement, 'if'))) {
17310 hasDynamicSlots = true;
17311 dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback));
17312 }
17313 else if ((vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))) {
17314 // find adjacent v-if
17315 let j = i;
17316 let prev;
17317 while (j--) {
17318 prev = children[j];
17319 if (prev.type !== 3 /* NodeTypes.COMMENT */) {
17320 break;
17321 }
17322 }
17323 if (prev && isTemplateNode(prev) && findDir(prev, 'if')) {
17324 // remove node
17325 children.splice(i, 1);
17326 i--;
17327 // attach this slot to previous conditional
17328 let conditional = dynamicSlots[dynamicSlots.length - 1];
17329 while (conditional.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
17330 conditional = conditional.alternate;
17331 }
17332 conditional.alternate = vElse.exp
17333 ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback)
17334 : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
17335 }
17336 else {
17337 context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
17338 }
17339 }
17340 else if ((vFor = findDir(slotElement, 'for'))) {
17341 hasDynamicSlots = true;
17342 const parseResult = vFor.parseResult ||
17343 parseForExpression(vFor.exp, context);
17344 if (parseResult) {
17345 // Render the dynamic slots as an array and add it to the createSlot()
17346 // args. The runtime knows how to handle it appropriately.
17347 dynamicSlots.push(createCallExpression(context.helper(RENDER_LIST), [
17348 parseResult.source,
17349 createFunctionExpression(createForLoopParams(parseResult), buildDynamicSlot(slotName, slotFunction), true /* force newline */)
17350 ]));
17351 }
17352 else {
17353 context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
17354 }
17355 }
17356 else {
17357 // check duplicate static names
17358 if (staticSlotName) {
17359 if (seenSlotNames.has(staticSlotName)) {
17360 context.onError(createCompilerError(38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
17361 continue;
17362 }
17363 seenSlotNames.add(staticSlotName);
17364 if (staticSlotName === 'default') {
17365 hasNamedDefaultSlot = true;
17366 }
17367 }
17368 slotsProperties.push(createObjectProperty(slotName, slotFunction));
17369 }
17370 }
17371 if (!onComponentSlot) {
17372 const buildDefaultSlotProperty = (props, children) => {
17373 const fn = buildSlotFn(props, children, loc);
17374 if (context.compatConfig) {
17375 fn.isNonScopedSlot = true;
17376 }
17377 return createObjectProperty(`default`, fn);
17378 };
17379 if (!hasTemplateSlots) {
17380 // implicit default slot (on component)
17381 slotsProperties.push(buildDefaultSlotProperty(undefined, children));
17382 }
17383 else if (implicitDefaultChildren.length &&
17384 // #3766
17385 // with whitespace: 'preserve', whitespaces between slots will end up in
17386 // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
17387 implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
17388 // implicit default slot (mixed with named slots)
17389 if (hasNamedDefaultSlot) {
17390 context.onError(createCompilerError(39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
17391 }
17392 else {
17393 slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
17394 }
17395 }
17396 }
17397 const slotFlag = hasDynamicSlots
17398 ? 2 /* SlotFlags.DYNAMIC */
17399 : hasForwardedSlots(node.children)
17400 ? 3 /* SlotFlags.FORWARDED */
17401 : 1 /* SlotFlags.STABLE */;
17402 let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
17403 // 2 = compiled but dynamic = can skip normalization, but must run diff
17404 // 1 = compiled and static = can skip normalization AND diff as optimized
17405 createSimpleExpression(slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ), false))), loc);
17406 if (dynamicSlots.length) {
17407 slots = createCallExpression(context.helper(CREATE_SLOTS), [
17408 slots,
17409 createArrayExpression(dynamicSlots)
17410 ]);
17411 }
17412 return {
17413 slots,
17414 hasDynamicSlots
17415 };
17416}
17417function buildDynamicSlot(name, fn, index) {
17418 const props = [
17419 createObjectProperty(`name`, name),
17420 createObjectProperty(`fn`, fn)
17421 ];
17422 if (index != null) {
17423 props.push(createObjectProperty(`key`, createSimpleExpression(String(index), true)));
17424 }
17425 return createObjectExpression(props);
17426}
17427function hasForwardedSlots(children) {
17428 for (let i = 0; i < children.length; i++) {
17429 const child = children[i];
17430 switch (child.type) {
17431 case 1 /* NodeTypes.ELEMENT */:
17432 if (child.tagType === 2 /* ElementTypes.SLOT */ ||
17433 hasForwardedSlots(child.children)) {
17434 return true;
17435 }
17436 break;
17437 case 9 /* NodeTypes.IF */:
17438 if (hasForwardedSlots(child.branches))
17439 return true;
17440 break;
17441 case 10 /* NodeTypes.IF_BRANCH */:
17442 case 11 /* NodeTypes.FOR */:
17443 if (hasForwardedSlots(child.children))
17444 return true;
17445 break;
17446 }
17447 }
17448 return false;
17449}
17450function isNonWhitespaceContent(node) {
17451 if (node.type !== 2 /* NodeTypes.TEXT */ && node.type !== 12 /* NodeTypes.TEXT_CALL */)
17452 return true;
17453 return node.type === 2 /* NodeTypes.TEXT */
17454 ? !!node.content.trim()
17455 : isNonWhitespaceContent(node.content);
17456}
17457
17458// some directive transforms (e.g. v-model) may return a symbol for runtime
17459// import, which should be used instead of a resolveDirective call.
17460const directiveImportMap = new WeakMap();
17461// generate a JavaScript AST for this element's codegen
17462const transformElement = (node, context) => {
17463 // perform the work on exit, after all child expressions have been
17464 // processed and merged.
17465 return function postTransformElement() {
17466 node = context.currentNode;
17467 if (!(node.type === 1 /* NodeTypes.ELEMENT */ &&
17468 (node.tagType === 0 /* ElementTypes.ELEMENT */ ||
17469 node.tagType === 1 /* ElementTypes.COMPONENT */))) {
17470 return;
17471 }
17472 const { tag, props } = node;
17473 const isComponent = node.tagType === 1 /* ElementTypes.COMPONENT */;
17474 // The goal of the transform is to create a codegenNode implementing the
17475 // VNodeCall interface.
17476 let vnodeTag = isComponent
17477 ? resolveComponentType(node, context)
17478 : `"${tag}"`;
17479 const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
17480 let vnodeProps;
17481 let vnodeChildren;
17482 let vnodePatchFlag;
17483 let patchFlag = 0;
17484 let vnodeDynamicProps;
17485 let dynamicPropNames;
17486 let vnodeDirectives;
17487 let shouldUseBlock =
17488 // dynamic component may resolve to plain elements
17489 isDynamicComponent ||
17490 vnodeTag === TELEPORT ||
17491 vnodeTag === SUSPENSE ||
17492 (!isComponent &&
17493 // <svg> and <foreignObject> must be forced into blocks so that block
17494 // updates inside get proper isSVG flag at runtime. (#639, #643)
17495 // This is technically web-specific, but splitting the logic out of core
17496 // leads to too much unnecessary complexity.
17497 (tag === 'svg' || tag === 'foreignObject'));
17498 // props
17499 if (props.length > 0) {
17500 const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
17501 vnodeProps = propsBuildResult.props;
17502 patchFlag = propsBuildResult.patchFlag;
17503 dynamicPropNames = propsBuildResult.dynamicPropNames;
17504 const directives = propsBuildResult.directives;
17505 vnodeDirectives =
17506 directives && directives.length
17507 ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
17508 : undefined;
17509 if (propsBuildResult.shouldUseBlock) {
17510 shouldUseBlock = true;
17511 }
17512 }
17513 // children
17514 if (node.children.length > 0) {
17515 if (vnodeTag === KEEP_ALIVE) {
17516 // Although a built-in component, we compile KeepAlive with raw children
17517 // instead of slot functions so that it can be used inside Transition
17518 // or other Transition-wrapping HOCs.
17519 // To ensure correct updates with block optimizations, we need to:
17520 // 1. Force keep-alive into a block. This avoids its children being
17521 // collected by a parent block.
17522 shouldUseBlock = true;
17523 // 2. Force keep-alive to always be updated, since it uses raw children.
17524 patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
17525 if (node.children.length > 1) {
17526 context.onError(createCompilerError(45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
17527 start: node.children[0].loc.start,
17528 end: node.children[node.children.length - 1].loc.end,
17529 source: ''
17530 }));
17531 }
17532 }
17533 const shouldBuildAsSlots = isComponent &&
17534 // Teleport is not a real component and has dedicated runtime handling
17535 vnodeTag !== TELEPORT &&
17536 // explained above.
17537 vnodeTag !== KEEP_ALIVE;
17538 if (shouldBuildAsSlots) {
17539 const { slots, hasDynamicSlots } = buildSlots(node, context);
17540 vnodeChildren = slots;
17541 if (hasDynamicSlots) {
17542 patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
17543 }
17544 }
17545 else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
17546 const child = node.children[0];
17547 const type = child.type;
17548 // check for dynamic text children
17549 const hasDynamicTextChild = type === 5 /* NodeTypes.INTERPOLATION */ ||
17550 type === 8 /* NodeTypes.COMPOUND_EXPRESSION */;
17551 if (hasDynamicTextChild &&
17552 getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
17553 patchFlag |= 1 /* PatchFlags.TEXT */;
17554 }
17555 // pass directly if the only child is a text node
17556 // (plain / interpolation / expression)
17557 if (hasDynamicTextChild || type === 2 /* NodeTypes.TEXT */) {
17558 vnodeChildren = child;
17559 }
17560 else {
17561 vnodeChildren = node.children;
17562 }
17563 }
17564 else {
17565 vnodeChildren = node.children;
17566 }
17567 }
17568 // patchFlag & dynamicPropNames
17569 if (patchFlag !== 0) {
17570 {
17571 if (patchFlag < 0) {
17572 // special flags (negative and mutually exclusive)
17573 vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
17574 }
17575 else {
17576 // bitwise flags
17577 const flagNames = Object.keys(PatchFlagNames)
17578 .map(Number)
17579 .filter(n => n > 0 && patchFlag & n)
17580 .map(n => PatchFlagNames[n])
17581 .join(`, `);
17582 vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
17583 }
17584 }
17585 if (dynamicPropNames && dynamicPropNames.length) {
17586 vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
17587 }
17588 }
17589 node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, vnodePatchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false /* disableTracking */, isComponent, node.loc);
17590 };
17591};
17592function resolveComponentType(node, context, ssr = false) {
17593 let { tag } = node;
17594 // 1. dynamic component
17595 const isExplicitDynamic = isComponentTag(tag);
17596 const isProp = findProp(node, 'is');
17597 if (isProp) {
17598 if (isExplicitDynamic ||
17599 (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))) {
17600 const exp = isProp.type === 6 /* NodeTypes.ATTRIBUTE */
17601 ? isProp.value && createSimpleExpression(isProp.value.content, true)
17602 : isProp.exp;
17603 if (exp) {
17604 return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
17605 exp
17606 ]);
17607 }
17608 }
17609 else if (isProp.type === 6 /* NodeTypes.ATTRIBUTE */ &&
17610 isProp.value.content.startsWith('vue:')) {
17611 // <button is="vue:xxx">
17612 // if not <component>, only is value that starts with "vue:" will be
17613 // treated as component by the parse phase and reach here, unless it's
17614 // compat mode where all is values are considered components
17615 tag = isProp.value.content.slice(4);
17616 }
17617 }
17618 // 1.5 v-is (TODO: Deprecate)
17619 const isDir = !isExplicitDynamic && findDir(node, 'is');
17620 if (isDir && isDir.exp) {
17621 return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
17622 isDir.exp
17623 ]);
17624 }
17625 // 2. built-in components (Teleport, Transition, KeepAlive, Suspense...)
17626 const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
17627 if (builtIn) {
17628 // built-ins are simply fallthroughs / have special handling during ssr
17629 // so we don't need to import their runtime equivalents
17630 if (!ssr)
17631 context.helper(builtIn);
17632 return builtIn;
17633 }
17634 // 3. user component (from setup bindings)
17635 // this is skipped in browser build since browser builds do not perform
17636 // binding analysis.
17637 {
17638 const fromSetup = resolveSetupReference(tag, context);
17639 if (fromSetup) {
17640 return fromSetup;
17641 }
17642 const dotIndex = tag.indexOf('.');
17643 if (dotIndex > 0) {
17644 const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
17645 if (ns) {
17646 return ns + tag.slice(dotIndex);
17647 }
17648 }
17649 }
17650 // 4. Self referencing component (inferred from filename)
17651 if (context.selfName &&
17652 capitalize(camelize(tag)) === context.selfName) {
17653 context.helper(RESOLVE_COMPONENT);
17654 // codegen.ts has special check for __self postfix when generating
17655 // component imports, which will pass additional `maybeSelfReference` flag
17656 // to `resolveComponent`.
17657 context.components.add(tag + `__self`);
17658 return toValidAssetId(tag, `component`);
17659 }
17660 // 5. user component (resolve)
17661 context.helper(RESOLVE_COMPONENT);
17662 context.components.add(tag);
17663 return toValidAssetId(tag, `component`);
17664}
17665function resolveSetupReference(name, context) {
17666 const bindings = context.bindingMetadata;
17667 if (!bindings || bindings.__isScriptSetup === false) {
17668 return;
17669 }
17670 const camelName = camelize(name);
17671 const PascalName = capitalize(camelName);
17672 const checkType = (type) => {
17673 if (bindings[name] === type) {
17674 return name;
17675 }
17676 if (bindings[camelName] === type) {
17677 return camelName;
17678 }
17679 if (bindings[PascalName] === type) {
17680 return PascalName;
17681 }
17682 };
17683 const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
17684 checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
17685 if (fromConst) {
17686 return context.inline
17687 ? // in inline mode, const setup bindings (e.g. imports) can be used as-is
17688 fromConst
17689 : `$setup[${JSON.stringify(fromConst)}]`;
17690 }
17691 const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
17692 checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
17693 checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
17694 if (fromMaybeRef) {
17695 return context.inline
17696 ? // setup scope bindings that may be refs need to be unrefed
17697 `${context.helperString(UNREF)}(${fromMaybeRef})`
17698 : `$setup[${JSON.stringify(fromMaybeRef)}]`;
17699 }
17700}
17701function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
17702 const { tag, loc: elementLoc, children } = node;
17703 let properties = [];
17704 const mergeArgs = [];
17705 const runtimeDirectives = [];
17706 const hasChildren = children.length > 0;
17707 let shouldUseBlock = false;
17708 // patchFlag analysis
17709 let patchFlag = 0;
17710 let hasRef = false;
17711 let hasClassBinding = false;
17712 let hasStyleBinding = false;
17713 let hasHydrationEventBinding = false;
17714 let hasDynamicKeys = false;
17715 let hasVnodeHook = false;
17716 const dynamicPropNames = [];
17717 const analyzePatchFlag = ({ key, value }) => {
17718 if (isStaticExp(key)) {
17719 const name = key.content;
17720 const isEventHandler = isOn(name);
17721 if (isEventHandler &&
17722 (!isComponent || isDynamicComponent) &&
17723 // omit the flag for click handlers because hydration gives click
17724 // dedicated fast path.
17725 name.toLowerCase() !== 'onclick' &&
17726 // omit v-model handlers
17727 name !== 'onUpdate:modelValue' &&
17728 // omit onVnodeXXX hooks
17729 !isReservedProp(name)) {
17730 hasHydrationEventBinding = true;
17731 }
17732 if (isEventHandler && isReservedProp(name)) {
17733 hasVnodeHook = true;
17734 }
17735 if (value.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */ ||
17736 ((value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
17737 value.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) &&
17738 getConstantType(value, context) > 0)) {
17739 // skip if the prop is a cached handler or has constant value
17740 return;
17741 }
17742 if (name === 'ref') {
17743 hasRef = true;
17744 }
17745 else if (name === 'class') {
17746 hasClassBinding = true;
17747 }
17748 else if (name === 'style') {
17749 hasStyleBinding = true;
17750 }
17751 else if (name !== 'key' && !dynamicPropNames.includes(name)) {
17752 dynamicPropNames.push(name);
17753 }
17754 // treat the dynamic class and style binding of the component as dynamic props
17755 if (isComponent &&
17756 (name === 'class' || name === 'style') &&
17757 !dynamicPropNames.includes(name)) {
17758 dynamicPropNames.push(name);
17759 }
17760 }
17761 else {
17762 hasDynamicKeys = true;
17763 }
17764 };
17765 for (let i = 0; i < props.length; i++) {
17766 // static attribute
17767 const prop = props[i];
17768 if (prop.type === 6 /* NodeTypes.ATTRIBUTE */) {
17769 const { loc, name, value } = prop;
17770 let isStatic = true;
17771 if (name === 'ref') {
17772 hasRef = true;
17773 if (context.scopes.vFor > 0) {
17774 properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
17775 }
17776 // in inline mode there is no setupState object, so we can't use string
17777 // keys to set the ref. Instead, we need to transform it to pass the
17778 // actual ref instead.
17779 if (value &&
17780 context.inline &&
17781 context.bindingMetadata[value.content]) {
17782 isStatic = false;
17783 properties.push(createObjectProperty(createSimpleExpression('ref_key', true), createSimpleExpression(value.content, true, value.loc)));
17784 }
17785 }
17786 // skip is on <component>, or is="vue:xxx"
17787 if (name === 'is' &&
17788 (isComponentTag(tag) ||
17789 (value && value.content.startsWith('vue:')) ||
17790 (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context)))) {
17791 continue;
17792 }
17793 properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
17794 }
17795 else {
17796 // directives
17797 const { name, arg, exp, loc } = prop;
17798 const isVBind = name === 'bind';
17799 const isVOn = name === 'on';
17800 // skip v-slot - it is handled by its dedicated transform.
17801 if (name === 'slot') {
17802 if (!isComponent) {
17803 context.onError(createCompilerError(40 /* ErrorCodes.X_V_SLOT_MISPLACED */, loc));
17804 }
17805 continue;
17806 }
17807 // skip v-once/v-memo - they are handled by dedicated transforms.
17808 if (name === 'once' || name === 'memo') {
17809 continue;
17810 }
17811 // skip v-is and :is on <component>
17812 if (name === 'is' ||
17813 (isVBind &&
17814 isStaticArgOf(arg, 'is') &&
17815 (isComponentTag(tag) ||
17816 (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))))) {
17817 continue;
17818 }
17819 // skip v-on in SSR compilation
17820 if (isVOn && ssr) {
17821 continue;
17822 }
17823 if (
17824 // #938: elements with dynamic keys should be forced into blocks
17825 (isVBind && isStaticArgOf(arg, 'key')) ||
17826 // inline before-update hooks need to force block so that it is invoked
17827 // before children
17828 (isVOn && hasChildren && isStaticArgOf(arg, 'vue:before-update'))) {
17829 shouldUseBlock = true;
17830 }
17831 if (isVBind && isStaticArgOf(arg, 'ref') && context.scopes.vFor > 0) {
17832 properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
17833 }
17834 // special case for v-bind and v-on with no argument
17835 if (!arg && (isVBind || isVOn)) {
17836 hasDynamicKeys = true;
17837 if (exp) {
17838 if (properties.length) {
17839 mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
17840 properties = [];
17841 }
17842 if (isVBind) {
17843 {
17844 // 2.x v-bind object order compat
17845 {
17846 const hasOverridableKeys = mergeArgs.some(arg => {
17847 if (arg.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
17848 return arg.properties.some(({ key }) => {
17849 if (key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
17850 !key.isStatic) {
17851 return true;
17852 }
17853 return (key.content !== 'class' &&
17854 key.content !== 'style' &&
17855 !isOn(key.content));
17856 });
17857 }
17858 else {
17859 // dynamic expression
17860 return true;
17861 }
17862 });
17863 if (hasOverridableKeys) {
17864 checkCompatEnabled$1("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context, loc);
17865 }
17866 }
17867 if (isCompatEnabled$1("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context)) {
17868 mergeArgs.unshift(exp);
17869 continue;
17870 }
17871 }
17872 mergeArgs.push(exp);
17873 }
17874 else {
17875 // v-on="obj" -> toHandlers(obj)
17876 mergeArgs.push({
17877 type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
17878 loc,
17879 callee: context.helper(TO_HANDLERS),
17880 arguments: isComponent ? [exp] : [exp, `true`]
17881 });
17882 }
17883 }
17884 else {
17885 context.onError(createCompilerError(isVBind
17886 ? 34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */
17887 : 35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
17888 }
17889 continue;
17890 }
17891 const directiveTransform = context.directiveTransforms[name];
17892 if (directiveTransform) {
17893 // has built-in directive transform.
17894 const { props, needRuntime } = directiveTransform(prop, node, context);
17895 !ssr && props.forEach(analyzePatchFlag);
17896 properties.push(...props);
17897 if (needRuntime) {
17898 runtimeDirectives.push(prop);
17899 if (isSymbol(needRuntime)) {
17900 directiveImportMap.set(prop, needRuntime);
17901 }
17902 }
17903 }
17904 else if (!isBuiltInDirective(name)) {
17905 // no built-in transform, this is a user custom directive.
17906 runtimeDirectives.push(prop);
17907 // custom dirs may use beforeUpdate so they need to force blocks
17908 // to ensure before-update gets called before children update
17909 if (hasChildren) {
17910 shouldUseBlock = true;
17911 }
17912 }
17913 }
17914 }
17915 let propsExpression = undefined;
17916 // has v-bind="object" or v-on="object", wrap with mergeProps
17917 if (mergeArgs.length) {
17918 if (properties.length) {
17919 mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
17920 }
17921 if (mergeArgs.length > 1) {
17922 propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
17923 }
17924 else {
17925 // single v-bind with nothing else - no need for a mergeProps call
17926 propsExpression = mergeArgs[0];
17927 }
17928 }
17929 else if (properties.length) {
17930 propsExpression = createObjectExpression(dedupeProperties(properties), elementLoc);
17931 }
17932 // patchFlag analysis
17933 if (hasDynamicKeys) {
17934 patchFlag |= 16 /* PatchFlags.FULL_PROPS */;
17935 }
17936 else {
17937 if (hasClassBinding && !isComponent) {
17938 patchFlag |= 2 /* PatchFlags.CLASS */;
17939 }
17940 if (hasStyleBinding && !isComponent) {
17941 patchFlag |= 4 /* PatchFlags.STYLE */;
17942 }
17943 if (dynamicPropNames.length) {
17944 patchFlag |= 8 /* PatchFlags.PROPS */;
17945 }
17946 if (hasHydrationEventBinding) {
17947 patchFlag |= 32 /* PatchFlags.HYDRATE_EVENTS */;
17948 }
17949 }
17950 if (!shouldUseBlock &&
17951 (patchFlag === 0 || patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) &&
17952 (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
17953 patchFlag |= 512 /* PatchFlags.NEED_PATCH */;
17954 }
17955 // pre-normalize props, SSR is skipped for now
17956 if (!context.inSSR && propsExpression) {
17957 switch (propsExpression.type) {
17958 case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
17959 // means that there is no v-bind,
17960 // but still need to deal with dynamic key binding
17961 let classKeyIndex = -1;
17962 let styleKeyIndex = -1;
17963 let hasDynamicKey = false;
17964 for (let i = 0; i < propsExpression.properties.length; i++) {
17965 const key = propsExpression.properties[i].key;
17966 if (isStaticExp(key)) {
17967 if (key.content === 'class') {
17968 classKeyIndex = i;
17969 }
17970 else if (key.content === 'style') {
17971 styleKeyIndex = i;
17972 }
17973 }
17974 else if (!key.isHandlerKey) {
17975 hasDynamicKey = true;
17976 }
17977 }
17978 const classProp = propsExpression.properties[classKeyIndex];
17979 const styleProp = propsExpression.properties[styleKeyIndex];
17980 // no dynamic key
17981 if (!hasDynamicKey) {
17982 if (classProp && !isStaticExp(classProp.value)) {
17983 classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
17984 }
17985 if (styleProp &&
17986 // the static style is compiled into an object,
17987 // so use `hasStyleBinding` to ensure that it is a dynamic style binding
17988 (hasStyleBinding ||
17989 (styleProp.value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
17990 styleProp.value.content.trim()[0] === `[`) ||
17991 // v-bind:style and style both exist,
17992 // v-bind:style with static literal object
17993 styleProp.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */)) {
17994 styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
17995 }
17996 }
17997 else {
17998 // dynamic key binding, wrap with `normalizeProps`
17999 propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
18000 }
18001 break;
18002 case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
18003 // mergeProps call, do nothing
18004 break;
18005 default:
18006 // single v-bind
18007 propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [
18008 createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
18009 propsExpression
18010 ])
18011 ]);
18012 break;
18013 }
18014 }
18015 return {
18016 props: propsExpression,
18017 directives: runtimeDirectives,
18018 patchFlag,
18019 dynamicPropNames,
18020 shouldUseBlock
18021 };
18022}
18023// Dedupe props in an object literal.
18024// Literal duplicated attributes would have been warned during the parse phase,
18025// however, it's possible to encounter duplicated `onXXX` handlers with different
18026// modifiers. We also need to merge static and dynamic class / style attributes.
18027// - onXXX handlers / style: merge into array
18028// - class: merge into single expression with concatenation
18029function dedupeProperties(properties) {
18030 const knownProps = new Map();
18031 const deduped = [];
18032 for (let i = 0; i < properties.length; i++) {
18033 const prop = properties[i];
18034 // dynamic keys are always allowed
18035 if (prop.key.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
18036 deduped.push(prop);
18037 continue;
18038 }
18039 const name = prop.key.content;
18040 const existing = knownProps.get(name);
18041 if (existing) {
18042 if (name === 'style' || name === 'class' || isOn(name)) {
18043 mergeAsArray$1(existing, prop);
18044 }
18045 // unexpected duplicate, should have emitted error during parse
18046 }
18047 else {
18048 knownProps.set(name, prop);
18049 deduped.push(prop);
18050 }
18051 }
18052 return deduped;
18053}
18054function mergeAsArray$1(existing, incoming) {
18055 if (existing.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */) {
18056 existing.value.elements.push(incoming.value);
18057 }
18058 else {
18059 existing.value = createArrayExpression([existing.value, incoming.value], existing.loc);
18060 }
18061}
18062function buildDirectiveArgs(dir, context) {
18063 const dirArgs = [];
18064 const runtime = directiveImportMap.get(dir);
18065 if (runtime) {
18066 // built-in directive with runtime
18067 dirArgs.push(context.helperString(runtime));
18068 }
18069 else {
18070 // user directive.
18071 // see if we have directives exposed via <script setup>
18072 const fromSetup = resolveSetupReference('v-' + dir.name, context);
18073 if (fromSetup) {
18074 dirArgs.push(fromSetup);
18075 }
18076 else {
18077 // inject statement for resolving directive
18078 context.helper(RESOLVE_DIRECTIVE);
18079 context.directives.add(dir.name);
18080 dirArgs.push(toValidAssetId(dir.name, `directive`));
18081 }
18082 }
18083 const { loc } = dir;
18084 if (dir.exp)
18085 dirArgs.push(dir.exp);
18086 if (dir.arg) {
18087 if (!dir.exp) {
18088 dirArgs.push(`void 0`);
18089 }
18090 dirArgs.push(dir.arg);
18091 }
18092 if (Object.keys(dir.modifiers).length) {
18093 if (!dir.arg) {
18094 if (!dir.exp) {
18095 dirArgs.push(`void 0`);
18096 }
18097 dirArgs.push(`void 0`);
18098 }
18099 const trueExpression = createSimpleExpression(`true`, false, loc);
18100 dirArgs.push(createObjectExpression(dir.modifiers.map(modifier => createObjectProperty(modifier, trueExpression)), loc));
18101 }
18102 return createArrayExpression(dirArgs, dir.loc);
18103}
18104function stringifyDynamicPropNames(props) {
18105 let propsNamesString = `[`;
18106 for (let i = 0, l = props.length; i < l; i++) {
18107 propsNamesString += JSON.stringify(props[i]);
18108 if (i < l - 1)
18109 propsNamesString += ', ';
18110 }
18111 return propsNamesString + `]`;
18112}
18113function isComponentTag(tag) {
18114 return tag === 'component' || tag === 'Component';
18115}
18116
18117const transformSlotOutlet = (node, context) => {
18118 if (isSlotOutlet(node)) {
18119 const { children, loc } = node;
18120 const { slotName, slotProps } = processSlotOutlet(node, context);
18121 const slotArgs = [
18122 context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
18123 slotName,
18124 '{}',
18125 'undefined',
18126 'true'
18127 ];
18128 let expectedLen = 2;
18129 if (slotProps) {
18130 slotArgs[2] = slotProps;
18131 expectedLen = 3;
18132 }
18133 if (children.length) {
18134 slotArgs[3] = createFunctionExpression([], children, false, false, loc);
18135 expectedLen = 4;
18136 }
18137 if (context.scopeId && !context.slotted) {
18138 expectedLen = 5;
18139 }
18140 slotArgs.splice(expectedLen); // remove unused arguments
18141 node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
18142 }
18143};
18144function processSlotOutlet(node, context) {
18145 let slotName = `"default"`;
18146 let slotProps = undefined;
18147 const nonNameProps = [];
18148 for (let i = 0; i < node.props.length; i++) {
18149 const p = node.props[i];
18150 if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
18151 if (p.value) {
18152 if (p.name === 'name') {
18153 slotName = JSON.stringify(p.value.content);
18154 }
18155 else {
18156 p.name = camelize(p.name);
18157 nonNameProps.push(p);
18158 }
18159 }
18160 }
18161 else {
18162 if (p.name === 'bind' && isStaticArgOf(p.arg, 'name')) {
18163 if (p.exp)
18164 slotName = p.exp;
18165 }
18166 else {
18167 if (p.name === 'bind' && p.arg && isStaticExp(p.arg)) {
18168 p.arg.content = camelize(p.arg.content);
18169 }
18170 nonNameProps.push(p);
18171 }
18172 }
18173 }
18174 if (nonNameProps.length > 0) {
18175 const { props, directives } = buildProps(node, context, nonNameProps, false, false);
18176 slotProps = props;
18177 if (directives.length) {
18178 context.onError(createCompilerError(36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
18179 }
18180 }
18181 return {
18182 slotName,
18183 slotProps
18184 };
18185}
18186
18187const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
18188const transformOn = (dir, node, context, augmentor) => {
18189 const { loc, modifiers, arg } = dir;
18190 if (!dir.exp && !modifiers.length) {
18191 context.onError(createCompilerError(35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
18192 }
18193 let eventName;
18194 if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
18195 if (arg.isStatic) {
18196 let rawName = arg.content;
18197 // TODO deprecate @vnodeXXX usage
18198 if (rawName.startsWith('vue:')) {
18199 rawName = `vnode-${rawName.slice(4)}`;
18200 }
18201 const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
18202 rawName.startsWith('vnode') ||
18203 !/[A-Z]/.test(rawName)
18204 ? // for component and vnode lifecycle event listeners, auto convert
18205 // it to camelCase. See issue #2249
18206 toHandlerKey(camelize(rawName))
18207 // preserve case for plain element listeners that have uppercase
18208 // letters, as these may be custom elements' custom events
18209 : `on:${rawName}`;
18210 eventName = createSimpleExpression(eventString, true, arg.loc);
18211 }
18212 else {
18213 // #2388
18214 eventName = createCompoundExpression([
18215 `${context.helperString(TO_HANDLER_KEY)}(`,
18216 arg,
18217 `)`
18218 ]);
18219 }
18220 }
18221 else {
18222 // already a compound expression.
18223 eventName = arg;
18224 eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
18225 eventName.children.push(`)`);
18226 }
18227 // handler processing
18228 let exp = dir.exp;
18229 if (exp && !exp.content.trim()) {
18230 exp = undefined;
18231 }
18232 let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
18233 if (exp) {
18234 const isMemberExp = isMemberExpression(exp.content, context);
18235 const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
18236 const hasMultipleStatements = exp.content.includes(`;`);
18237 // process the expression since it's been skipped
18238 if (context.prefixIdentifiers) {
18239 isInlineStatement && context.addIdentifiers(`$event`);
18240 exp = dir.exp = processExpression(exp, context, false, hasMultipleStatements);
18241 isInlineStatement && context.removeIdentifiers(`$event`);
18242 // with scope analysis, the function is hoistable if it has no reference
18243 // to scope variables.
18244 shouldCache =
18245 context.cacheHandlers &&
18246 // unnecessary to cache inside v-once
18247 !context.inVOnce &&
18248 // runtime constants don't need to be cached
18249 // (this is analyzed by compileScript in SFC <script setup>)
18250 !(exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && exp.constType > 0) &&
18251 // #1541 bail if this is a member exp handler passed to a component -
18252 // we need to use the original function to preserve arity,
18253 // e.g. <transition> relies on checking cb.length to determine
18254 // transition end handling. Inline function is ok since its arity
18255 // is preserved even when cached.
18256 !(isMemberExp && node.tagType === 1 /* ElementTypes.COMPONENT */) &&
18257 // bail if the function references closure variables (v-for, v-slot)
18258 // it must be passed fresh to avoid stale values.
18259 !hasScopeRef(exp, context.identifiers);
18260 // If the expression is optimizable and is a member expression pointing
18261 // to a function, turn it into invocation (and wrap in an arrow function
18262 // below) so that it always accesses the latest value when called - thus
18263 // avoiding the need to be patched.
18264 if (shouldCache && isMemberExp) {
18265 if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
18266 exp.content = `${exp.content} && ${exp.content}(...args)`;
18267 }
18268 else {
18269 exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
18270 }
18271 }
18272 }
18273 if (isInlineStatement || (shouldCache && isMemberExp)) {
18274 // wrap inline statement in a function expression
18275 exp = createCompoundExpression([
18276 `${isInlineStatement
18277 ? context.isTS
18278 ? `($event: any)`
18279 : `$event`
18280 : `${context.isTS ? `\n//@ts-ignore\n` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
18281 exp,
18282 hasMultipleStatements ? `}` : `)`
18283 ]);
18284 }
18285 }
18286 let ret = {
18287 props: [
18288 createObjectProperty(eventName, exp || createSimpleExpression(`() => {}`, false, loc))
18289 ]
18290 };
18291 // apply extended compiler augmentor
18292 if (augmentor) {
18293 ret = augmentor(ret);
18294 }
18295 if (shouldCache) {
18296 // cache handlers so that it's always the same handler being passed down.
18297 // this avoids unnecessary re-renders when users use inline handlers on
18298 // components.
18299 ret.props[0].value = context.cache(ret.props[0].value);
18300 }
18301 // mark the key as handler for props normalization check
18302 ret.props.forEach(p => (p.key.isHandlerKey = true));
18303 return ret;
18304};
18305
18306// v-bind without arg is handled directly in ./transformElements.ts due to it affecting
18307// codegen for the entire props object. This transform here is only for v-bind
18308// *with* args.
18309const transformBind = (dir, _node, context) => {
18310 const { exp, modifiers, loc } = dir;
18311 const arg = dir.arg;
18312 if (arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
18313 arg.children.unshift(`(`);
18314 arg.children.push(`) || ""`);
18315 }
18316 else if (!arg.isStatic) {
18317 arg.content = `${arg.content} || ""`;
18318 }
18319 // .sync is replaced by v-model:arg
18320 if (modifiers.includes('camel')) {
18321 if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
18322 if (arg.isStatic) {
18323 arg.content = camelize(arg.content);
18324 }
18325 else {
18326 arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
18327 }
18328 }
18329 else {
18330 arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
18331 arg.children.push(`)`);
18332 }
18333 }
18334 if (!context.inSSR) {
18335 if (modifiers.includes('prop')) {
18336 injectPrefix(arg, '.');
18337 }
18338 if (modifiers.includes('attr')) {
18339 injectPrefix(arg, '^');
18340 }
18341 }
18342 if (!exp ||
18343 (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !exp.content.trim())) {
18344 context.onError(createCompilerError(34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */, loc));
18345 return {
18346 props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
18347 };
18348 }
18349 return {
18350 props: [createObjectProperty(arg, exp)]
18351 };
18352};
18353const injectPrefix = (arg, prefix) => {
18354 if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
18355 if (arg.isStatic) {
18356 arg.content = prefix + arg.content;
18357 }
18358 else {
18359 arg.content = `\`${prefix}\${${arg.content}}\``;
18360 }
18361 }
18362 else {
18363 arg.children.unshift(`'${prefix}' + (`);
18364 arg.children.push(`)`);
18365 }
18366};
18367
18368// Merge adjacent text nodes and expressions into a single expression
18369// e.g. <div>abc {{ d }} {{ e }}</div> should have a single expression node as child.
18370const transformText = (node, context) => {
18371 if (node.type === 0 /* NodeTypes.ROOT */ ||
18372 node.type === 1 /* NodeTypes.ELEMENT */ ||
18373 node.type === 11 /* NodeTypes.FOR */ ||
18374 node.type === 10 /* NodeTypes.IF_BRANCH */) {
18375 // perform the transform on node exit so that all expressions have already
18376 // been processed.
18377 return () => {
18378 const children = node.children;
18379 let currentContainer = undefined;
18380 let hasText = false;
18381 for (let i = 0; i < children.length; i++) {
18382 const child = children[i];
18383 if (isText(child)) {
18384 hasText = true;
18385 for (let j = i + 1; j < children.length; j++) {
18386 const next = children[j];
18387 if (isText(next)) {
18388 if (!currentContainer) {
18389 currentContainer = children[i] = createCompoundExpression([child], child.loc);
18390 }
18391 // merge adjacent text node into current
18392 currentContainer.children.push(` + `, next);
18393 children.splice(j, 1);
18394 j--;
18395 }
18396 else {
18397 currentContainer = undefined;
18398 break;
18399 }
18400 }
18401 }
18402 }
18403 if (!hasText ||
18404 // if this is a plain element with a single text child, leave it
18405 // as-is since the runtime has dedicated fast path for this by directly
18406 // setting textContent of the element.
18407 // for component root it's always normalized anyway.
18408 (children.length === 1 &&
18409 (node.type === 0 /* NodeTypes.ROOT */ ||
18410 (node.type === 1 /* NodeTypes.ELEMENT */ &&
18411 node.tagType === 0 /* ElementTypes.ELEMENT */ &&
18412 // #3756
18413 // custom directives can potentially add DOM elements arbitrarily,
18414 // we need to avoid setting textContent of the element at runtime
18415 // to avoid accidentally overwriting the DOM elements added
18416 // by the user through custom directives.
18417 !node.props.find(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
18418 !context.directiveTransforms[p.name]) &&
18419 // in compat mode, <template> tags with no special directives
18420 // will be rendered as a fragment so its children must be
18421 // converted into vnodes.
18422 !(node.tag === 'template'))))) {
18423 return;
18424 }
18425 // pre-convert text nodes into createTextVNode(text) calls to avoid
18426 // runtime normalization.
18427 for (let i = 0; i < children.length; i++) {
18428 const child = children[i];
18429 if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
18430 const callArgs = [];
18431 // createTextVNode defaults to single whitespace, so if it is a
18432 // single space the code could be an empty call to save bytes.
18433 if (child.type !== 2 /* NodeTypes.TEXT */ || child.content !== ' ') {
18434 callArgs.push(child);
18435 }
18436 // mark dynamic text with flag so it gets patched inside a block
18437 if (!context.ssr &&
18438 getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
18439 callArgs.push(1 /* PatchFlags.TEXT */ +
18440 (` /* ${PatchFlagNames[1 /* PatchFlags.TEXT */]} */` ));
18441 }
18442 children[i] = {
18443 type: 12 /* NodeTypes.TEXT_CALL */,
18444 content: child,
18445 loc: child.loc,
18446 codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
18447 };
18448 }
18449 }
18450 };
18451 }
18452};
18453
18454const seen = new WeakSet();
18455const transformOnce = (node, context) => {
18456 if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
18457 if (seen.has(node) || context.inVOnce) {
18458 return;
18459 }
18460 seen.add(node);
18461 context.inVOnce = true;
18462 context.helper(SET_BLOCK_TRACKING);
18463 return () => {
18464 context.inVOnce = false;
18465 const cur = context.currentNode;
18466 if (cur.codegenNode) {
18467 cur.codegenNode = context.cache(cur.codegenNode, true /* isVNode */);
18468 }
18469 };
18470 }
18471};
18472
18473const transformModel = (dir, node, context) => {
18474 const { exp, arg } = dir;
18475 if (!exp) {
18476 context.onError(createCompilerError(41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */, dir.loc));
18477 return createTransformProps();
18478 }
18479 const rawExp = exp.loc.source;
18480 const expString = exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ? exp.content : rawExp;
18481 // im SFC <script setup> inline mode, the exp may have been transformed into
18482 // _unref(exp)
18483 const bindingType = context.bindingMetadata[rawExp];
18484 const maybeRef = context.inline &&
18485 bindingType &&
18486 bindingType !== "setup-const" /* BindingTypes.SETUP_CONST */;
18487 if (!expString.trim() ||
18488 (!isMemberExpression(expString, context) && !maybeRef)) {
18489 context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
18490 return createTransformProps();
18491 }
18492 if (context.prefixIdentifiers &&
18493 isSimpleIdentifier(expString) &&
18494 context.identifiers[expString]) {
18495 context.onError(createCompilerError(43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
18496 return createTransformProps();
18497 }
18498 const propName = arg ? arg : createSimpleExpression('modelValue', true);
18499 const eventName = arg
18500 ? isStaticExp(arg)
18501 ? `onUpdate:${arg.content}`
18502 : createCompoundExpression(['"onUpdate:" + ', arg])
18503 : `onUpdate:modelValue`;
18504 let assignmentExp;
18505 const eventArg = context.isTS ? `($event: any)` : `$event`;
18506 if (maybeRef) {
18507 if (bindingType === "setup-ref" /* BindingTypes.SETUP_REF */) {
18508 // v-model used on known ref.
18509 assignmentExp = createCompoundExpression([
18510 `${eventArg} => ((`,
18511 createSimpleExpression(rawExp, false, exp.loc),
18512 `).value = $event)`
18513 ]);
18514 }
18515 else {
18516 // v-model used on a potentially ref binding in <script setup> inline mode.
18517 // the assignment needs to check whether the binding is actually a ref.
18518 const altAssignment = bindingType === "setup-let" /* BindingTypes.SETUP_LET */ ? `${rawExp} = $event` : `null`;
18519 assignmentExp = createCompoundExpression([
18520 `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
18521 createSimpleExpression(rawExp, false, exp.loc),
18522 `).value = $event : ${altAssignment})`
18523 ]);
18524 }
18525 }
18526 else {
18527 assignmentExp = createCompoundExpression([
18528 `${eventArg} => ((`,
18529 exp,
18530 `) = $event)`
18531 ]);
18532 }
18533 const props = [
18534 // modelValue: foo
18535 createObjectProperty(propName, dir.exp),
18536 // "onUpdate:modelValue": $event => (foo = $event)
18537 createObjectProperty(eventName, assignmentExp)
18538 ];
18539 // cache v-model handler if applicable (when it doesn't refer any scope vars)
18540 if (context.prefixIdentifiers &&
18541 !context.inVOnce &&
18542 context.cacheHandlers &&
18543 !hasScopeRef(exp, context.identifiers)) {
18544 props[1].value = context.cache(props[1].value);
18545 }
18546 // modelModifiers: { foo: true, "bar-baz": true }
18547 if (dir.modifiers.length && node.tagType === 1 /* ElementTypes.COMPONENT */) {
18548 const modifiers = dir.modifiers
18549 .map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
18550 .join(`, `);
18551 const modifiersKey = arg
18552 ? isStaticExp(arg)
18553 ? `${arg.content}Modifiers`
18554 : createCompoundExpression([arg, ' + "Modifiers"'])
18555 : `modelModifiers`;
18556 props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* ConstantTypes.CAN_HOIST */)));
18557 }
18558 return createTransformProps(props);
18559};
18560function createTransformProps(props = []) {
18561 return { props };
18562}
18563
18564const validDivisionCharRE = /[\w).+\-_$\]]/;
18565const transformFilter = (node, context) => {
18566 if (!isCompatEnabled$1("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context)) {
18567 return;
18568 }
18569 if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
18570 // filter rewrite is applied before expression transform so only
18571 // simple expressions are possible at this stage
18572 rewriteFilter(node.content, context);
18573 }
18574 if (node.type === 1 /* NodeTypes.ELEMENT */) {
18575 node.props.forEach((prop) => {
18576 if (prop.type === 7 /* NodeTypes.DIRECTIVE */ &&
18577 prop.name !== 'for' &&
18578 prop.exp) {
18579 rewriteFilter(prop.exp, context);
18580 }
18581 });
18582 }
18583};
18584function rewriteFilter(node, context) {
18585 if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
18586 parseFilter(node, context);
18587 }
18588 else {
18589 for (let i = 0; i < node.children.length; i++) {
18590 const child = node.children[i];
18591 if (typeof child !== 'object')
18592 continue;
18593 if (child.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
18594 parseFilter(child, context);
18595 }
18596 else if (child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
18597 rewriteFilter(node, context);
18598 }
18599 else if (child.type === 5 /* NodeTypes.INTERPOLATION */) {
18600 rewriteFilter(child.content, context);
18601 }
18602 }
18603 }
18604}
18605function parseFilter(node, context) {
18606 const exp = node.content;
18607 let inSingle = false;
18608 let inDouble = false;
18609 let inTemplateString = false;
18610 let inRegex = false;
18611 let curly = 0;
18612 let square = 0;
18613 let paren = 0;
18614 let lastFilterIndex = 0;
18615 let c, prev, i, expression, filters = [];
18616 for (i = 0; i < exp.length; i++) {
18617 prev = c;
18618 c = exp.charCodeAt(i);
18619 if (inSingle) {
18620 if (c === 0x27 && prev !== 0x5c)
18621 inSingle = false;
18622 }
18623 else if (inDouble) {
18624 if (c === 0x22 && prev !== 0x5c)
18625 inDouble = false;
18626 }
18627 else if (inTemplateString) {
18628 if (c === 0x60 && prev !== 0x5c)
18629 inTemplateString = false;
18630 }
18631 else if (inRegex) {
18632 if (c === 0x2f && prev !== 0x5c)
18633 inRegex = false;
18634 }
18635 else if (c === 0x7c && // pipe
18636 exp.charCodeAt(i + 1) !== 0x7c &&
18637 exp.charCodeAt(i - 1) !== 0x7c &&
18638 !curly &&
18639 !square &&
18640 !paren) {
18641 if (expression === undefined) {
18642 // first filter, end of expression
18643 lastFilterIndex = i + 1;
18644 expression = exp.slice(0, i).trim();
18645 }
18646 else {
18647 pushFilter();
18648 }
18649 }
18650 else {
18651 switch (c) {
18652 case 0x22:
18653 inDouble = true;
18654 break; // "
18655 case 0x27:
18656 inSingle = true;
18657 break; // '
18658 case 0x60:
18659 inTemplateString = true;
18660 break; // `
18661 case 0x28:
18662 paren++;
18663 break; // (
18664 case 0x29:
18665 paren--;
18666 break; // )
18667 case 0x5b:
18668 square++;
18669 break; // [
18670 case 0x5d:
18671 square--;
18672 break; // ]
18673 case 0x7b:
18674 curly++;
18675 break; // {
18676 case 0x7d:
18677 curly--;
18678 break; // }
18679 }
18680 if (c === 0x2f) {
18681 // /
18682 let j = i - 1;
18683 let p;
18684 // find first non-whitespace prev char
18685 for (; j >= 0; j--) {
18686 p = exp.charAt(j);
18687 if (p !== ' ')
18688 break;
18689 }
18690 if (!p || !validDivisionCharRE.test(p)) {
18691 inRegex = true;
18692 }
18693 }
18694 }
18695 }
18696 if (expression === undefined) {
18697 expression = exp.slice(0, i).trim();
18698 }
18699 else if (lastFilterIndex !== 0) {
18700 pushFilter();
18701 }
18702 function pushFilter() {
18703 filters.push(exp.slice(lastFilterIndex, i).trim());
18704 lastFilterIndex = i + 1;
18705 }
18706 if (filters.length) {
18707 warnDeprecation$1("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context, node.loc);
18708 for (i = 0; i < filters.length; i++) {
18709 expression = wrapFilter(expression, filters[i], context);
18710 }
18711 node.content = expression;
18712 }
18713}
18714function wrapFilter(exp, filter, context) {
18715 context.helper(RESOLVE_FILTER);
18716 const i = filter.indexOf('(');
18717 if (i < 0) {
18718 context.filters.add(filter);
18719 return `${toValidAssetId(filter, 'filter')}(${exp})`;
18720 }
18721 else {
18722 const name = filter.slice(0, i);
18723 const args = filter.slice(i + 1);
18724 context.filters.add(name);
18725 return `${toValidAssetId(name, 'filter')}(${exp}${args !== ')' ? ',' + args : args}`;
18726 }
18727}
18728
18729const seen$1 = new WeakSet();
18730const transformMemo = (node, context) => {
18731 if (node.type === 1 /* NodeTypes.ELEMENT */) {
18732 const dir = findDir(node, 'memo');
18733 if (!dir || seen$1.has(node)) {
18734 return;
18735 }
18736 seen$1.add(node);
18737 return () => {
18738 const codegenNode = node.codegenNode ||
18739 context.currentNode.codegenNode;
18740 if (codegenNode && codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
18741 // non-component sub tree should be turned into a block
18742 if (node.tagType !== 1 /* ElementTypes.COMPONENT */) {
18743 makeBlock(codegenNode, context);
18744 }
18745 node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
18746 dir.exp,
18747 createFunctionExpression(undefined, codegenNode),
18748 `_cache`,
18749 String(context.cached++)
18750 ]);
18751 }
18752 };
18753 }
18754};
18755
18756function getBaseTransformPreset(prefixIdentifiers) {
18757 return [
18758 [
18759 transformOnce,
18760 transformIf,
18761 transformMemo,
18762 transformFor,
18763 ...([transformFilter] ),
18764 ...(prefixIdentifiers
18765 ? [
18766 // order is important
18767 trackVForSlotScopes,
18768 transformExpression
18769 ]
18770 : []),
18771 transformSlotOutlet,
18772 transformElement,
18773 trackSlotScopes,
18774 transformText
18775 ],
18776 {
18777 on: transformOn,
18778 bind: transformBind,
18779 model: transformModel
18780 }
18781 ];
18782}
18783// we name it `baseCompile` so that higher order compilers like
18784// @vue/compiler-dom can export `compile` while re-exporting everything else.
18785function baseCompile(template, options = {}) {
18786 const onError = options.onError || defaultOnError;
18787 const isModuleMode = options.mode === 'module';
18788 const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
18789 if (!prefixIdentifiers && options.cacheHandlers) {
18790 onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
18791 }
18792 if (options.scopeId && !isModuleMode) {
18793 onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
18794 }
18795 const ast = isString(template) ? baseParse(template, options) : template;
18796 const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
18797 if (options.isTS) {
18798 const { expressionPlugins } = options;
18799 if (!expressionPlugins || !expressionPlugins.includes('typescript')) {
18800 options.expressionPlugins = [...(expressionPlugins || []), 'typescript'];
18801 }
18802 }
18803 transform(ast, extend({}, options, {
18804 prefixIdentifiers,
18805 nodeTransforms: [
18806 ...nodeTransforms,
18807 ...(options.nodeTransforms || []) // user transforms
18808 ],
18809 directiveTransforms: extend({}, directiveTransforms, options.directiveTransforms || {} // user transforms
18810 )
18811 }));
18812 return generate(ast, extend({}, options, {
18813 prefixIdentifiers
18814 }));
18815}
18816
18817const noopDirectiveTransform = () => ({ props: [] });
18818
18819const V_MODEL_RADIO = Symbol(`vModelRadio` );
18820const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
18821const V_MODEL_TEXT = Symbol(`vModelText` );
18822const V_MODEL_SELECT = Symbol(`vModelSelect` );
18823const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
18824const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
18825const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
18826const V_SHOW = Symbol(`vShow` );
18827const TRANSITION$1 = Symbol(`Transition` );
18828const TRANSITION_GROUP = Symbol(`TransitionGroup` );
18829registerRuntimeHelpers({
18830 [V_MODEL_RADIO]: `vModelRadio`,
18831 [V_MODEL_CHECKBOX]: `vModelCheckbox`,
18832 [V_MODEL_TEXT]: `vModelText`,
18833 [V_MODEL_SELECT]: `vModelSelect`,
18834 [V_MODEL_DYNAMIC]: `vModelDynamic`,
18835 [V_ON_WITH_MODIFIERS]: `withModifiers`,
18836 [V_ON_WITH_KEYS]: `withKeys`,
18837 [V_SHOW]: `vShow`,
18838 [TRANSITION$1]: `Transition`,
18839 [TRANSITION_GROUP]: `TransitionGroup`
18840});
18841
18842var namedCharacterReferences = {
18843 GT: ">",
18844 gt: ">",
18845 LT: "<",
18846 lt: "<",
18847 "ac;": "∾",
18848 "af;": "⁡",
18849 AMP: "&",
18850 amp: "&",
18851 "ap;": "≈",
18852 "DD;": "ⅅ",
18853 "dd;": "ⅆ",
18854 deg: "°",
18855 "ee;": "ⅇ",
18856 "eg;": "⪚",
18857 "el;": "⪙",
18858 ETH: "Ð",
18859 eth: "ð",
18860 "gE;": "≧",
18861 "ge;": "≥",
18862 "Gg;": "⋙",
18863 "gg;": "≫",
18864 "gl;": "≷",
18865 "GT;": ">",
18866 "Gt;": "≫",
18867 "gt;": ">",
18868 "ic;": "⁣",
18869 "ii;": "ⅈ",
18870 "Im;": "ℑ",
18871 "in;": "∈",
18872 "it;": "⁢",
18873 "lE;": "≦",
18874 "le;": "≤",
18875 "lg;": "≶",
18876 "Ll;": "⋘",
18877 "ll;": "≪",
18878 "LT;": "<",
18879 "Lt;": "≪",
18880 "lt;": "<",
18881 "mp;": "∓",
18882 "Mu;": "Μ",
18883 "mu;": "μ",
18884 "ne;": "≠",
18885 "ni;": "∋",
18886 not: "¬",
18887 "Nu;": "Ν",
18888 "nu;": "ν",
18889 "Or;": "⩔",
18890 "or;": "∨",
18891 "oS;": "Ⓢ",
18892 "Pi;": "Π",
18893 "pi;": "π",
18894 "pm;": "±",
18895 "Pr;": "⪻",
18896 "pr;": "≺",
18897 "Re;": "ℜ",
18898 REG: "®",
18899 reg: "®",
18900 "rx;": "℞",
18901 "Sc;": "⪼",
18902 "sc;": "≻",
18903 shy: "­",
18904 uml: "¨",
18905 "wp;": "℘",
18906 "wr;": "≀",
18907 "Xi;": "Ξ",
18908 "xi;": "ξ",
18909 yen: "¥",
18910 "acd;": "∿",
18911 "acE;": "∾̳",
18912 "Acy;": "А",
18913 "acy;": "а",
18914 "Afr;": "𝔄",
18915 "afr;": "𝔞",
18916 "AMP;": "&",
18917 "amp;": "&",
18918 "And;": "⩓",
18919 "and;": "∧",
18920 "ang;": "∠",
18921 "apE;": "⩰",
18922 "ape;": "≊",
18923 "ast;": "*",
18924 Auml: "Ä",
18925 auml: "ä",
18926 "Bcy;": "Б",
18927 "bcy;": "б",
18928 "Bfr;": "𝔅",
18929 "bfr;": "𝔟",
18930 "bne;": "=⃥",
18931 "bot;": "⊥",
18932 "Cap;": "⋒",
18933 "cap;": "∩",
18934 cent: "¢",
18935 "Cfr;": "ℭ",
18936 "cfr;": "𝔠",
18937 "Chi;": "Χ",
18938 "chi;": "χ",
18939 "cir;": "○",
18940 COPY: "©",
18941 copy: "©",
18942 "Cup;": "⋓",
18943 "cup;": "∪",
18944 "Dcy;": "Д",
18945 "dcy;": "д",
18946 "deg;": "°",
18947 "Del;": "∇",
18948 "Dfr;": "𝔇",
18949 "dfr;": "𝔡",
18950 "die;": "¨",
18951 "div;": "÷",
18952 "Dot;": "¨",
18953 "dot;": "˙",
18954 "Ecy;": "Э",
18955 "ecy;": "э",
18956 "Efr;": "𝔈",
18957 "efr;": "𝔢",
18958 "egs;": "⪖",
18959 "ell;": "ℓ",
18960 "els;": "⪕",
18961 "ENG;": "Ŋ",
18962 "eng;": "ŋ",
18963 "Eta;": "Η",
18964 "eta;": "η",
18965 "ETH;": "Ð",
18966 "eth;": "ð",
18967 Euml: "Ë",
18968 euml: "ë",
18969 "Fcy;": "Ф",
18970 "fcy;": "ф",
18971 "Ffr;": "𝔉",
18972 "ffr;": "𝔣",
18973 "gap;": "⪆",
18974 "Gcy;": "Г",
18975 "gcy;": "г",
18976 "gEl;": "⪌",
18977 "gel;": "⋛",
18978 "geq;": "≥",
18979 "ges;": "⩾",
18980 "Gfr;": "𝔊",
18981 "gfr;": "𝔤",
18982 "ggg;": "⋙",
18983 "gla;": "⪥",
18984 "glE;": "⪒",
18985 "glj;": "⪤",
18986 "gnE;": "≩",
18987 "gne;": "⪈",
18988 "Hat;": "^",
18989 "Hfr;": "ℌ",
18990 "hfr;": "𝔥",
18991 "Icy;": "И",
18992 "icy;": "и",
18993 "iff;": "⇔",
18994 "Ifr;": "ℑ",
18995 "ifr;": "𝔦",
18996 "Int;": "∬",
18997 "int;": "∫",
18998 Iuml: "Ï",
18999 iuml: "ï",
19000 "Jcy;": "Й",
19001 "jcy;": "й",
19002 "Jfr;": "𝔍",
19003 "jfr;": "𝔧",
19004 "Kcy;": "К",
19005 "kcy;": "к",
19006 "Kfr;": "𝔎",
19007 "kfr;": "𝔨",
19008 "lap;": "⪅",
19009 "lat;": "⪫",
19010 "Lcy;": "Л",
19011 "lcy;": "л",
19012 "lEg;": "⪋",
19013 "leg;": "⋚",
19014 "leq;": "≤",
19015 "les;": "⩽",
19016 "Lfr;": "𝔏",
19017 "lfr;": "𝔩",
19018 "lgE;": "⪑",
19019 "lnE;": "≨",
19020 "lne;": "⪇",
19021 "loz;": "◊",
19022 "lrm;": "‎",
19023 "Lsh;": "↰",
19024 "lsh;": "↰",
19025 macr: "¯",
19026 "Map;": "⤅",
19027 "map;": "↦",
19028 "Mcy;": "М",
19029 "mcy;": "м",
19030 "Mfr;": "𝔐",
19031 "mfr;": "𝔪",
19032 "mho;": "℧",
19033 "mid;": "∣",
19034 "nap;": "≉",
19035 nbsp: " ",
19036 "Ncy;": "Н",
19037 "ncy;": "н",
19038 "Nfr;": "𝔑",
19039 "nfr;": "𝔫",
19040 "ngE;": "≧̸",
19041 "nge;": "≱",
19042 "nGg;": "⋙̸",
19043 "nGt;": "≫⃒",
19044 "ngt;": "≯",
19045 "nis;": "⋼",
19046 "niv;": "∋",
19047 "nlE;": "≦̸",
19048 "nle;": "≰",
19049 "nLl;": "⋘̸",
19050 "nLt;": "≪⃒",
19051 "nlt;": "≮",
19052 "Not;": "⫬",
19053 "not;": "¬",
19054 "npr;": "⊀",
19055 "nsc;": "⊁",
19056 "num;": "#",
19057 "Ocy;": "О",
19058 "ocy;": "о",
19059 "Ofr;": "𝔒",
19060 "ofr;": "𝔬",
19061 "ogt;": "⧁",
19062 "ohm;": "Ω",
19063 "olt;": "⧀",
19064 "ord;": "⩝",
19065 ordf: "ª",
19066 ordm: "º",
19067 "orv;": "⩛",
19068 Ouml: "Ö",
19069 ouml: "ö",
19070 "par;": "∥",
19071 para: "¶",
19072 "Pcy;": "П",
19073 "pcy;": "п",
19074 "Pfr;": "𝔓",
19075 "pfr;": "𝔭",
19076 "Phi;": "Φ",
19077 "phi;": "φ",
19078 "piv;": "ϖ",
19079 "prE;": "⪳",
19080 "pre;": "⪯",
19081 "Psi;": "Ψ",
19082 "psi;": "ψ",
19083 "Qfr;": "𝔔",
19084 "qfr;": "𝔮",
19085 QUOT: "\"",
19086 quot: "\"",
19087 "Rcy;": "Р",
19088 "rcy;": "р",
19089 "REG;": "®",
19090 "reg;": "®",
19091 "Rfr;": "ℜ",
19092 "rfr;": "𝔯",
19093 "Rho;": "Ρ",
19094 "rho;": "ρ",
19095 "rlm;": "‏",
19096 "Rsh;": "↱",
19097 "rsh;": "↱",
19098 "scE;": "⪴",
19099 "sce;": "⪰",
19100 "Scy;": "С",
19101 "scy;": "с",
19102 sect: "§",
19103 "Sfr;": "𝔖",
19104 "sfr;": "𝔰",
19105 "shy;": "­",
19106 "sim;": "∼",
19107 "smt;": "⪪",
19108 "sol;": "/",
19109 "squ;": "□",
19110 "Sub;": "⋐",
19111 "sub;": "⊂",
19112 "Sum;": "∑",
19113 "sum;": "∑",
19114 "Sup;": "⋑",
19115 "sup;": "⊃",
19116 sup1: "¹",
19117 sup2: "²",
19118 sup3: "³",
19119 "Tab;": "\t",
19120 "Tau;": "Τ",
19121 "tau;": "τ",
19122 "Tcy;": "Т",
19123 "tcy;": "т",
19124 "Tfr;": "𝔗",
19125 "tfr;": "𝔱",
19126 "top;": "⊤",
19127 "Ucy;": "У",
19128 "ucy;": "у",
19129 "Ufr;": "𝔘",
19130 "ufr;": "𝔲",
19131 "uml;": "¨",
19132 Uuml: "Ü",
19133 uuml: "ü",
19134 "Vcy;": "В",
19135 "vcy;": "в",
19136 "Vee;": "⋁",
19137 "vee;": "∨",
19138 "Vfr;": "𝔙",
19139 "vfr;": "𝔳",
19140 "Wfr;": "𝔚",
19141 "wfr;": "𝔴",
19142 "Xfr;": "𝔛",
19143 "xfr;": "𝔵",
19144 "Ycy;": "Ы",
19145 "ycy;": "ы",
19146 "yen;": "¥",
19147 "Yfr;": "𝔜",
19148 "yfr;": "𝔶",
19149 yuml: "ÿ",
19150 "Zcy;": "З",
19151 "zcy;": "з",
19152 "Zfr;": "ℨ",
19153 "zfr;": "𝔷",
19154 "zwj;": "‍",
19155 Acirc: "Â",
19156 acirc: "â",
19157 acute: "´",
19158 AElig: "Æ",
19159 aelig: "æ",
19160 "andd;": "⩜",
19161 "andv;": "⩚",
19162 "ange;": "⦤",
19163 "Aopf;": "𝔸",
19164 "aopf;": "𝕒",
19165 "apid;": "≋",
19166 "apos;": "'",
19167 Aring: "Å",
19168 aring: "å",
19169 "Ascr;": "𝒜",
19170 "ascr;": "𝒶",
19171 "Auml;": "Ä",
19172 "auml;": "ä",
19173 "Barv;": "⫧",
19174 "bbrk;": "⎵",
19175 "Beta;": "Β",
19176 "beta;": "β",
19177 "beth;": "ℶ",
19178 "bNot;": "⫭",
19179 "bnot;": "⌐",
19180 "Bopf;": "𝔹",
19181 "bopf;": "𝕓",
19182 "boxH;": "═",
19183 "boxh;": "─",
19184 "boxV;": "║",
19185 "boxv;": "│",
19186 "Bscr;": "ℬ",
19187 "bscr;": "𝒷",
19188 "bsim;": "∽",
19189 "bsol;": "\\",
19190 "bull;": "•",
19191 "bump;": "≎",
19192 "caps;": "∩︀",
19193 "Cdot;": "Ċ",
19194 "cdot;": "ċ",
19195 cedil: "¸",
19196 "cent;": "¢",
19197 "CHcy;": "Ч",
19198 "chcy;": "ч",
19199 "circ;": "ˆ",
19200 "cirE;": "⧃",
19201 "cire;": "≗",
19202 "comp;": "∁",
19203 "cong;": "≅",
19204 "Copf;": "ℂ",
19205 "copf;": "𝕔",
19206 "COPY;": "©",
19207 "copy;": "©",
19208 "Cscr;": "𝒞",
19209 "cscr;": "𝒸",
19210 "csub;": "⫏",
19211 "csup;": "⫐",
19212 "cups;": "∪︀",
19213 "Darr;": "↡",
19214 "dArr;": "⇓",
19215 "darr;": "↓",
19216 "dash;": "‐",
19217 "dHar;": "⥥",
19218 "diam;": "⋄",
19219 "DJcy;": "Ђ",
19220 "djcy;": "ђ",
19221 "Dopf;": "𝔻",
19222 "dopf;": "𝕕",
19223 "Dscr;": "𝒟",
19224 "dscr;": "𝒹",
19225 "DScy;": "Ѕ",
19226 "dscy;": "ѕ",
19227 "dsol;": "⧶",
19228 "dtri;": "▿",
19229 "DZcy;": "Џ",
19230 "dzcy;": "џ",
19231 "ecir;": "≖",
19232 Ecirc: "Ê",
19233 ecirc: "ê",
19234 "Edot;": "Ė",
19235 "eDot;": "≑",
19236 "edot;": "ė",
19237 "emsp;": " ",
19238 "ensp;": " ",
19239 "Eopf;": "𝔼",
19240 "eopf;": "𝕖",
19241 "epar;": "⋕",
19242 "epsi;": "ε",
19243 "Escr;": "ℰ",
19244 "escr;": "ℯ",
19245 "Esim;": "⩳",
19246 "esim;": "≂",
19247 "Euml;": "Ë",
19248 "euml;": "ë",
19249 "euro;": "€",
19250 "excl;": "!",
19251 "flat;": "♭",
19252 "fnof;": "ƒ",
19253 "Fopf;": "𝔽",
19254 "fopf;": "𝕗",
19255 "fork;": "⋔",
19256 "Fscr;": "ℱ",
19257 "fscr;": "𝒻",
19258 "Gdot;": "Ġ",
19259 "gdot;": "ġ",
19260 "geqq;": "≧",
19261 "gesl;": "⋛︀",
19262 "GJcy;": "Ѓ",
19263 "gjcy;": "ѓ",
19264 "gnap;": "⪊",
19265 "gneq;": "⪈",
19266 "Gopf;": "𝔾",
19267 "gopf;": "𝕘",
19268 "Gscr;": "𝒢",
19269 "gscr;": "ℊ",
19270 "gsim;": "≳",
19271 "gtcc;": "⪧",
19272 "gvnE;": "≩︀",
19273 "half;": "½",
19274 "hArr;": "⇔",
19275 "harr;": "↔",
19276 "hbar;": "ℏ",
19277 "Hopf;": "ℍ",
19278 "hopf;": "𝕙",
19279 "Hscr;": "ℋ",
19280 "hscr;": "𝒽",
19281 Icirc: "Î",
19282 icirc: "î",
19283 "Idot;": "İ",
19284 "IEcy;": "Е",
19285 "iecy;": "е",
19286 iexcl: "¡",
19287 "imof;": "⊷",
19288 "IOcy;": "Ё",
19289 "iocy;": "ё",
19290 "Iopf;": "𝕀",
19291 "iopf;": "𝕚",
19292 "Iota;": "Ι",
19293 "iota;": "ι",
19294 "Iscr;": "ℐ",
19295 "iscr;": "𝒾",
19296 "isin;": "∈",
19297 "Iuml;": "Ï",
19298 "iuml;": "ï",
19299 "Jopf;": "𝕁",
19300 "jopf;": "𝕛",
19301 "Jscr;": "𝒥",
19302 "jscr;": "𝒿",
19303 "KHcy;": "Х",
19304 "khcy;": "х",
19305 "KJcy;": "Ќ",
19306 "kjcy;": "ќ",
19307 "Kopf;": "𝕂",
19308 "kopf;": "𝕜",
19309 "Kscr;": "𝒦",
19310 "kscr;": "𝓀",
19311 "Lang;": "⟪",
19312 "lang;": "⟨",
19313 laquo: "«",
19314 "Larr;": "↞",
19315 "lArr;": "⇐",
19316 "larr;": "←",
19317 "late;": "⪭",
19318 "lcub;": "{",
19319 "ldca;": "⤶",
19320 "ldsh;": "↲",
19321 "leqq;": "≦",
19322 "lesg;": "⋚︀",
19323 "lHar;": "⥢",
19324 "LJcy;": "Љ",
19325 "ljcy;": "љ",
19326 "lnap;": "⪉",
19327 "lneq;": "⪇",
19328 "Lopf;": "𝕃",
19329 "lopf;": "𝕝",
19330 "lozf;": "⧫",
19331 "lpar;": "(",
19332 "Lscr;": "ℒ",
19333 "lscr;": "𝓁",
19334 "lsim;": "≲",
19335 "lsqb;": "[",
19336 "ltcc;": "⪦",
19337 "ltri;": "◃",
19338 "lvnE;": "≨︀",
19339 "macr;": "¯",
19340 "male;": "♂",
19341 "malt;": "✠",
19342 micro: "µ",
19343 "mlcp;": "⫛",
19344 "mldr;": "…",
19345 "Mopf;": "𝕄",
19346 "mopf;": "𝕞",
19347 "Mscr;": "ℳ",
19348 "mscr;": "𝓂",
19349 "nang;": "∠⃒",
19350 "napE;": "⩰̸",
19351 "nbsp;": " ",
19352 "ncap;": "⩃",
19353 "ncup;": "⩂",
19354 "ngeq;": "≱",
19355 "nges;": "⩾̸",
19356 "ngtr;": "≯",
19357 "nGtv;": "≫̸",
19358 "nisd;": "⋺",
19359 "NJcy;": "Њ",
19360 "njcy;": "њ",
19361 "nldr;": "‥",
19362 "nleq;": "≰",
19363 "nles;": "⩽̸",
19364 "nLtv;": "≪̸",
19365 "nmid;": "∤",
19366 "Nopf;": "ℕ",
19367 "nopf;": "𝕟",
19368 "npar;": "∦",
19369 "npre;": "⪯̸",
19370 "nsce;": "⪰̸",
19371 "Nscr;": "𝒩",
19372 "nscr;": "𝓃",
19373 "nsim;": "≁",
19374 "nsub;": "⊄",
19375 "nsup;": "⊅",
19376 "ntgl;": "≹",
19377 "ntlg;": "≸",
19378 "nvap;": "≍⃒",
19379 "nvge;": "≥⃒",
19380 "nvgt;": ">⃒",
19381 "nvle;": "≤⃒",
19382 "nvlt;": "<⃒",
19383 "oast;": "⊛",
19384 "ocir;": "⊚",
19385 Ocirc: "Ô",
19386 ocirc: "ô",
19387 "odiv;": "⨸",
19388 "odot;": "⊙",
19389 "ogon;": "˛",
19390 "oint;": "∮",
19391 "omid;": "⦶",
19392 "Oopf;": "𝕆",
19393 "oopf;": "𝕠",
19394 "opar;": "⦷",
19395 "ordf;": "ª",
19396 "ordm;": "º",
19397 "oror;": "⩖",
19398 "Oscr;": "𝒪",
19399 "oscr;": "ℴ",
19400 "osol;": "⊘",
19401 "Ouml;": "Ö",
19402 "ouml;": "ö",
19403 "para;": "¶",
19404 "part;": "∂",
19405 "perp;": "⊥",
19406 "phiv;": "ϕ",
19407 "plus;": "+",
19408 "Popf;": "ℙ",
19409 "popf;": "𝕡",
19410 pound: "£",
19411 "prap;": "⪷",
19412 "prec;": "≺",
19413 "prnE;": "⪵",
19414 "prod;": "∏",
19415 "prop;": "∝",
19416 "Pscr;": "𝒫",
19417 "pscr;": "𝓅",
19418 "qint;": "⨌",
19419 "Qopf;": "ℚ",
19420 "qopf;": "𝕢",
19421 "Qscr;": "𝒬",
19422 "qscr;": "𝓆",
19423 "QUOT;": "\"",
19424 "quot;": "\"",
19425 "race;": "∽̱",
19426 "Rang;": "⟫",
19427 "rang;": "⟩",
19428 raquo: "»",
19429 "Rarr;": "↠",
19430 "rArr;": "⇒",
19431 "rarr;": "→",
19432 "rcub;": "}",
19433 "rdca;": "⤷",
19434 "rdsh;": "↳",
19435 "real;": "ℜ",
19436 "rect;": "▭",
19437 "rHar;": "⥤",
19438 "rhov;": "ϱ",
19439 "ring;": "˚",
19440 "Ropf;": "ℝ",
19441 "ropf;": "𝕣",
19442 "rpar;": ")",
19443 "Rscr;": "ℛ",
19444 "rscr;": "𝓇",
19445 "rsqb;": "]",
19446 "rtri;": "▹",
19447 "scap;": "⪸",
19448 "scnE;": "⪶",
19449 "sdot;": "⋅",
19450 "sect;": "§",
19451 "semi;": ";",
19452 "sext;": "✶",
19453 "SHcy;": "Ш",
19454 "shcy;": "ш",
19455 "sime;": "≃",
19456 "simg;": "⪞",
19457 "siml;": "⪝",
19458 "smid;": "∣",
19459 "smte;": "⪬",
19460 "solb;": "⧄",
19461 "Sopf;": "𝕊",
19462 "sopf;": "𝕤",
19463 "spar;": "∥",
19464 "Sqrt;": "√",
19465 "squf;": "▪",
19466 "Sscr;": "𝒮",
19467 "sscr;": "𝓈",
19468 "Star;": "⋆",
19469 "star;": "☆",
19470 "subE;": "⫅",
19471 "sube;": "⊆",
19472 "succ;": "≻",
19473 "sung;": "♪",
19474 "sup1;": "¹",
19475 "sup2;": "²",
19476 "sup3;": "³",
19477 "supE;": "⫆",
19478 "supe;": "⊇",
19479 szlig: "ß",
19480 "tbrk;": "⎴",
19481 "tdot;": "⃛",
19482 THORN: "Þ",
19483 thorn: "þ",
19484 times: "×",
19485 "tint;": "∭",
19486 "toea;": "⤨",
19487 "Topf;": "𝕋",
19488 "topf;": "𝕥",
19489 "tosa;": "⤩",
19490 "trie;": "≜",
19491 "Tscr;": "𝒯",
19492 "tscr;": "𝓉",
19493 "TScy;": "Ц",
19494 "tscy;": "ц",
19495 "Uarr;": "↟",
19496 "uArr;": "⇑",
19497 "uarr;": "↑",
19498 Ucirc: "Û",
19499 ucirc: "û",
19500 "uHar;": "⥣",
19501 "Uopf;": "𝕌",
19502 "uopf;": "𝕦",
19503 "Upsi;": "ϒ",
19504 "upsi;": "υ",
19505 "Uscr;": "𝒰",
19506 "uscr;": "𝓊",
19507 "utri;": "▵",
19508 "Uuml;": "Ü",
19509 "uuml;": "ü",
19510 "vArr;": "⇕",
19511 "varr;": "↕",
19512 "Vbar;": "⫫",
19513 "vBar;": "⫨",
19514 "Vert;": "‖",
19515 "vert;": "|",
19516 "Vopf;": "𝕍",
19517 "vopf;": "𝕧",
19518 "Vscr;": "𝒱",
19519 "vscr;": "𝓋",
19520 "Wopf;": "𝕎",
19521 "wopf;": "𝕨",
19522 "Wscr;": "𝒲",
19523 "wscr;": "𝓌",
19524 "xcap;": "⋂",
19525 "xcup;": "⋃",
19526 "xmap;": "⟼",
19527 "xnis;": "⋻",
19528 "Xopf;": "𝕏",
19529 "xopf;": "𝕩",
19530 "Xscr;": "𝒳",
19531 "xscr;": "𝓍",
19532 "xvee;": "⋁",
19533 "YAcy;": "Я",
19534 "yacy;": "я",
19535 "YIcy;": "Ї",
19536 "yicy;": "ї",
19537 "Yopf;": "𝕐",
19538 "yopf;": "𝕪",
19539 "Yscr;": "𝒴",
19540 "yscr;": "𝓎",
19541 "YUcy;": "Ю",
19542 "yucy;": "ю",
19543 "Yuml;": "Ÿ",
19544 "yuml;": "ÿ",
19545 "Zdot;": "Ż",
19546 "zdot;": "ż",
19547 "Zeta;": "Ζ",
19548 "zeta;": "ζ",
19549 "ZHcy;": "Ж",
19550 "zhcy;": "ж",
19551 "Zopf;": "ℤ",
19552 "zopf;": "𝕫",
19553 "Zscr;": "𝒵",
19554 "zscr;": "𝓏",
19555 "zwnj;": "‌",
19556 Aacute: "Á",
19557 aacute: "á",
19558 "Acirc;": "Â",
19559 "acirc;": "â",
19560 "acute;": "´",
19561 "AElig;": "Æ",
19562 "aelig;": "æ",
19563 Agrave: "À",
19564 agrave: "à",
19565 "aleph;": "ℵ",
19566 "Alpha;": "Α",
19567 "alpha;": "α",
19568 "Amacr;": "Ā",
19569 "amacr;": "ā",
19570 "amalg;": "⨿",
19571 "angle;": "∠",
19572 "angrt;": "∟",
19573 "angst;": "Å",
19574 "Aogon;": "Ą",
19575 "aogon;": "ą",
19576 "Aring;": "Å",
19577 "aring;": "å",
19578 "asymp;": "≈",
19579 Atilde: "Ã",
19580 atilde: "ã",
19581 "awint;": "⨑",
19582 "bcong;": "≌",
19583 "bdquo;": "„",
19584 "bepsi;": "϶",
19585 "blank;": "␣",
19586 "blk12;": "▒",
19587 "blk14;": "░",
19588 "blk34;": "▓",
19589 "block;": "█",
19590 "boxDL;": "╗",
19591 "boxDl;": "╖",
19592 "boxdL;": "╕",
19593 "boxdl;": "┐",
19594 "boxDR;": "╔",
19595 "boxDr;": "╓",
19596 "boxdR;": "╒",
19597 "boxdr;": "┌",
19598 "boxHD;": "╦",
19599 "boxHd;": "╤",
19600 "boxhD;": "╥",
19601 "boxhd;": "┬",
19602 "boxHU;": "╩",
19603 "boxHu;": "╧",
19604 "boxhU;": "╨",
19605 "boxhu;": "┴",
19606 "boxUL;": "╝",
19607 "boxUl;": "╜",
19608 "boxuL;": "╛",
19609 "boxul;": "┘",
19610 "boxUR;": "╚",
19611 "boxUr;": "╙",
19612 "boxuR;": "╘",
19613 "boxur;": "└",
19614 "boxVH;": "╬",
19615 "boxVh;": "╫",
19616 "boxvH;": "╪",
19617 "boxvh;": "┼",
19618 "boxVL;": "╣",
19619 "boxVl;": "╢",
19620 "boxvL;": "╡",
19621 "boxvl;": "┤",
19622 "boxVR;": "╠",
19623 "boxVr;": "╟",
19624 "boxvR;": "╞",
19625 "boxvr;": "├",
19626 "Breve;": "˘",
19627 "breve;": "˘",
19628 brvbar: "¦",
19629 "bsemi;": "⁏",
19630 "bsime;": "⋍",
19631 "bsolb;": "⧅",
19632 "bumpE;": "⪮",
19633 "bumpe;": "≏",
19634 "caret;": "⁁",
19635 "caron;": "ˇ",
19636 "ccaps;": "⩍",
19637 Ccedil: "Ç",
19638 ccedil: "ç",
19639 "Ccirc;": "Ĉ",
19640 "ccirc;": "ĉ",
19641 "ccups;": "⩌",
19642 "cedil;": "¸",
19643 "check;": "✓",
19644 "clubs;": "♣",
19645 "Colon;": "∷",
19646 "colon;": ":",
19647 "comma;": ",",
19648 "crarr;": "↵",
19649 "Cross;": "⨯",
19650 "cross;": "✗",
19651 "csube;": "⫑",
19652 "csupe;": "⫒",
19653 "ctdot;": "⋯",
19654 "cuepr;": "⋞",
19655 "cuesc;": "⋟",
19656 "cupor;": "⩅",
19657 curren: "¤",
19658 "cuvee;": "⋎",
19659 "cuwed;": "⋏",
19660 "cwint;": "∱",
19661 "Dashv;": "⫤",
19662 "dashv;": "⊣",
19663 "dblac;": "˝",
19664 "ddarr;": "⇊",
19665 "Delta;": "Δ",
19666 "delta;": "δ",
19667 "dharl;": "⇃",
19668 "dharr;": "⇂",
19669 "diams;": "♦",
19670 "disin;": "⋲",
19671 divide: "÷",
19672 "doteq;": "≐",
19673 "dtdot;": "⋱",
19674 "dtrif;": "▾",
19675 "duarr;": "⇵",
19676 "duhar;": "⥯",
19677 Eacute: "É",
19678 eacute: "é",
19679 "Ecirc;": "Ê",
19680 "ecirc;": "ê",
19681 "eDDot;": "⩷",
19682 "efDot;": "≒",
19683 Egrave: "È",
19684 egrave: "è",
19685 "Emacr;": "Ē",
19686 "emacr;": "ē",
19687 "empty;": "∅",
19688 "Eogon;": "Ę",
19689 "eogon;": "ę",
19690 "eplus;": "⩱",
19691 "epsiv;": "ϵ",
19692 "eqsim;": "≂",
19693 "Equal;": "⩵",
19694 "equiv;": "≡",
19695 "erarr;": "⥱",
19696 "erDot;": "≓",
19697 "esdot;": "≐",
19698 "exist;": "∃",
19699 "fflig;": "ff",
19700 "filig;": "fi",
19701 "fjlig;": "fj",
19702 "fllig;": "fl",
19703 "fltns;": "▱",
19704 "forkv;": "⫙",
19705 frac12: "½",
19706 frac14: "¼",
19707 frac34: "¾",
19708 "frasl;": "⁄",
19709 "frown;": "⌢",
19710 "Gamma;": "Γ",
19711 "gamma;": "γ",
19712 "Gcirc;": "Ĝ",
19713 "gcirc;": "ĝ",
19714 "gescc;": "⪩",
19715 "gimel;": "ℷ",
19716 "gneqq;": "≩",
19717 "gnsim;": "⋧",
19718 "grave;": "`",
19719 "gsime;": "⪎",
19720 "gsiml;": "⪐",
19721 "gtcir;": "⩺",
19722 "gtdot;": "⋗",
19723 "Hacek;": "ˇ",
19724 "harrw;": "↭",
19725 "Hcirc;": "Ĥ",
19726 "hcirc;": "ĥ",
19727 "hoarr;": "⇿",
19728 Iacute: "Í",
19729 iacute: "í",
19730 "Icirc;": "Î",
19731 "icirc;": "î",
19732 "iexcl;": "¡",
19733 Igrave: "Ì",
19734 igrave: "ì",
19735 "iiint;": "∭",
19736 "iiota;": "℩",
19737 "IJlig;": "IJ",
19738 "ijlig;": "ij",
19739 "Imacr;": "Ī",
19740 "imacr;": "ī",
19741 "image;": "ℑ",
19742 "imath;": "ı",
19743 "imped;": "Ƶ",
19744 "infin;": "∞",
19745 "Iogon;": "Į",
19746 "iogon;": "į",
19747 "iprod;": "⨼",
19748 iquest: "¿",
19749 "isinE;": "⋹",
19750 "isins;": "⋴",
19751 "isinv;": "∈",
19752 "Iukcy;": "І",
19753 "iukcy;": "і",
19754 "Jcirc;": "Ĵ",
19755 "jcirc;": "ĵ",
19756 "jmath;": "ȷ",
19757 "Jukcy;": "Є",
19758 "jukcy;": "є",
19759 "Kappa;": "Κ",
19760 "kappa;": "κ",
19761 "lAarr;": "⇚",
19762 "langd;": "⦑",
19763 "laquo;": "«",
19764 "larrb;": "⇤",
19765 "lates;": "⪭︀",
19766 "lBarr;": "⤎",
19767 "lbarr;": "⤌",
19768 "lbbrk;": "❲",
19769 "lbrke;": "⦋",
19770 "lceil;": "⌈",
19771 "ldquo;": "“",
19772 "lescc;": "⪨",
19773 "lhard;": "↽",
19774 "lharu;": "↼",
19775 "lhblk;": "▄",
19776 "llarr;": "⇇",
19777 "lltri;": "◺",
19778 "lneqq;": "≨",
19779 "lnsim;": "⋦",
19780 "loang;": "⟬",
19781 "loarr;": "⇽",
19782 "lobrk;": "⟦",
19783 "lopar;": "⦅",
19784 "lrarr;": "⇆",
19785 "lrhar;": "⇋",
19786 "lrtri;": "⊿",
19787 "lsime;": "⪍",
19788 "lsimg;": "⪏",
19789 "lsquo;": "‘",
19790 "ltcir;": "⩹",
19791 "ltdot;": "⋖",
19792 "ltrie;": "⊴",
19793 "ltrif;": "◂",
19794 "mdash;": "—",
19795 "mDDot;": "∺",
19796 "micro;": "µ",
19797 middot: "·",
19798 "minus;": "−",
19799 "mumap;": "⊸",
19800 "nabla;": "∇",
19801 "napid;": "≋̸",
19802 "napos;": "ʼn",
19803 "natur;": "♮",
19804 "nbump;": "≎̸",
19805 "ncong;": "≇",
19806 "ndash;": "–",
19807 "neArr;": "⇗",
19808 "nearr;": "↗",
19809 "nedot;": "≐̸",
19810 "nesim;": "≂̸",
19811 "ngeqq;": "≧̸",
19812 "ngsim;": "≵",
19813 "nhArr;": "⇎",
19814 "nharr;": "↮",
19815 "nhpar;": "⫲",
19816 "nlArr;": "⇍",
19817 "nlarr;": "↚",
19818 "nleqq;": "≦̸",
19819 "nless;": "≮",
19820 "nlsim;": "≴",
19821 "nltri;": "⋪",
19822 "notin;": "∉",
19823 "notni;": "∌",
19824 "npart;": "∂̸",
19825 "nprec;": "⊀",
19826 "nrArr;": "⇏",
19827 "nrarr;": "↛",
19828 "nrtri;": "⋫",
19829 "nsime;": "≄",
19830 "nsmid;": "∤",
19831 "nspar;": "∦",
19832 "nsubE;": "⫅̸",
19833 "nsube;": "⊈",
19834 "nsucc;": "⊁",
19835 "nsupE;": "⫆̸",
19836 "nsupe;": "⊉",
19837 Ntilde: "Ñ",
19838 ntilde: "ñ",
19839 "numsp;": " ",
19840 "nvsim;": "∼⃒",
19841 "nwArr;": "⇖",
19842 "nwarr;": "↖",
19843 Oacute: "Ó",
19844 oacute: "ó",
19845 "Ocirc;": "Ô",
19846 "ocirc;": "ô",
19847 "odash;": "⊝",
19848 "OElig;": "Œ",
19849 "oelig;": "œ",
19850 "ofcir;": "⦿",
19851 Ograve: "Ò",
19852 ograve: "ò",
19853 "ohbar;": "⦵",
19854 "olarr;": "↺",
19855 "olcir;": "⦾",
19856 "oline;": "‾",
19857 "Omacr;": "Ō",
19858 "omacr;": "ō",
19859 "Omega;": "Ω",
19860 "omega;": "ω",
19861 "operp;": "⦹",
19862 "oplus;": "⊕",
19863 "orarr;": "↻",
19864 "order;": "ℴ",
19865 Oslash: "Ø",
19866 oslash: "ø",
19867 Otilde: "Õ",
19868 otilde: "õ",
19869 "ovbar;": "⌽",
19870 "parsl;": "⫽",
19871 "phone;": "☎",
19872 "plusb;": "⊞",
19873 "pluse;": "⩲",
19874 plusmn: "±",
19875 "pound;": "£",
19876 "prcue;": "≼",
19877 "Prime;": "″",
19878 "prime;": "′",
19879 "prnap;": "⪹",
19880 "prsim;": "≾",
19881 "quest;": "?",
19882 "rAarr;": "⇛",
19883 "radic;": "√",
19884 "rangd;": "⦒",
19885 "range;": "⦥",
19886 "raquo;": "»",
19887 "rarrb;": "⇥",
19888 "rarrc;": "⤳",
19889 "rarrw;": "↝",
19890 "ratio;": "∶",
19891 "RBarr;": "⤐",
19892 "rBarr;": "⤏",
19893 "rbarr;": "⤍",
19894 "rbbrk;": "❳",
19895 "rbrke;": "⦌",
19896 "rceil;": "⌉",
19897 "rdquo;": "”",
19898 "reals;": "ℝ",
19899 "rhard;": "⇁",
19900 "rharu;": "⇀",
19901 "rlarr;": "⇄",
19902 "rlhar;": "⇌",
19903 "rnmid;": "⫮",
19904 "roang;": "⟭",
19905 "roarr;": "⇾",
19906 "robrk;": "⟧",
19907 "ropar;": "⦆",
19908 "rrarr;": "⇉",
19909 "rsquo;": "’",
19910 "rtrie;": "⊵",
19911 "rtrif;": "▸",
19912 "sbquo;": "‚",
19913 "sccue;": "≽",
19914 "Scirc;": "Ŝ",
19915 "scirc;": "ŝ",
19916 "scnap;": "⪺",
19917 "scsim;": "≿",
19918 "sdotb;": "⊡",
19919 "sdote;": "⩦",
19920 "seArr;": "⇘",
19921 "searr;": "↘",
19922 "setmn;": "∖",
19923 "sharp;": "♯",
19924 "Sigma;": "Σ",
19925 "sigma;": "σ",
19926 "simeq;": "≃",
19927 "simgE;": "⪠",
19928 "simlE;": "⪟",
19929 "simne;": "≆",
19930 "slarr;": "←",
19931 "smile;": "⌣",
19932 "smtes;": "⪬︀",
19933 "sqcap;": "⊓",
19934 "sqcup;": "⊔",
19935 "sqsub;": "⊏",
19936 "sqsup;": "⊐",
19937 "srarr;": "→",
19938 "starf;": "★",
19939 "strns;": "¯",
19940 "subnE;": "⫋",
19941 "subne;": "⊊",
19942 "supnE;": "⫌",
19943 "supne;": "⊋",
19944 "swArr;": "⇙",
19945 "swarr;": "↙",
19946 "szlig;": "ß",
19947 "Theta;": "Θ",
19948 "theta;": "θ",
19949 "thkap;": "≈",
19950 "THORN;": "Þ",
19951 "thorn;": "þ",
19952 "Tilde;": "∼",
19953 "tilde;": "˜",
19954 "times;": "×",
19955 "TRADE;": "™",
19956 "trade;": "™",
19957 "trisb;": "⧍",
19958 "TSHcy;": "Ћ",
19959 "tshcy;": "ћ",
19960 "twixt;": "≬",
19961 Uacute: "Ú",
19962 uacute: "ú",
19963 "Ubrcy;": "Ў",
19964 "ubrcy;": "ў",
19965 "Ucirc;": "Û",
19966 "ucirc;": "û",
19967 "udarr;": "⇅",
19968 "udhar;": "⥮",
19969 Ugrave: "Ù",
19970 ugrave: "ù",
19971 "uharl;": "↿",
19972 "uharr;": "↾",
19973 "uhblk;": "▀",
19974 "ultri;": "◸",
19975 "Umacr;": "Ū",
19976 "umacr;": "ū",
19977 "Union;": "⋃",
19978 "Uogon;": "Ų",
19979 "uogon;": "ų",
19980 "uplus;": "⊎",
19981 "upsih;": "ϒ",
19982 "UpTee;": "⊥",
19983 "Uring;": "Ů",
19984 "uring;": "ů",
19985 "urtri;": "◹",
19986 "utdot;": "⋰",
19987 "utrif;": "▴",
19988 "uuarr;": "⇈",
19989 "varpi;": "ϖ",
19990 "vBarv;": "⫩",
19991 "VDash;": "⊫",
19992 "Vdash;": "⊩",
19993 "vDash;": "⊨",
19994 "vdash;": "⊢",
19995 "veeeq;": "≚",
19996 "vltri;": "⊲",
19997 "vnsub;": "⊂⃒",
19998 "vnsup;": "⊃⃒",
19999 "vprop;": "∝",
20000 "vrtri;": "⊳",
20001 "Wcirc;": "Ŵ",
20002 "wcirc;": "ŵ",
20003 "Wedge;": "⋀",
20004 "wedge;": "∧",
20005 "xcirc;": "◯",
20006 "xdtri;": "▽",
20007 "xhArr;": "⟺",
20008 "xharr;": "⟷",
20009 "xlArr;": "⟸",
20010 "xlarr;": "⟵",
20011 "xodot;": "⨀",
20012 "xrArr;": "⟹",
20013 "xrarr;": "⟶",
20014 "xutri;": "△",
20015 Yacute: "Ý",
20016 yacute: "ý",
20017 "Ycirc;": "Ŷ",
20018 "ycirc;": "ŷ",
20019 "Aacute;": "Á",
20020 "aacute;": "á",
20021 "Abreve;": "Ă",
20022 "abreve;": "ă",
20023 "Agrave;": "À",
20024 "agrave;": "à",
20025 "andand;": "⩕",
20026 "angmsd;": "∡",
20027 "angsph;": "∢",
20028 "apacir;": "⩯",
20029 "approx;": "≈",
20030 "Assign;": "≔",
20031 "Atilde;": "Ã",
20032 "atilde;": "ã",
20033 "barvee;": "⊽",
20034 "Barwed;": "⌆",
20035 "barwed;": "⌅",
20036 "becaus;": "∵",
20037 "bernou;": "ℬ",
20038 "bigcap;": "⋂",
20039 "bigcup;": "⋃",
20040 "bigvee;": "⋁",
20041 "bkarow;": "⤍",
20042 "bottom;": "⊥",
20043 "bowtie;": "⋈",
20044 "boxbox;": "⧉",
20045 "bprime;": "‵",
20046 "brvbar;": "¦",
20047 "bullet;": "•",
20048 "Bumpeq;": "≎",
20049 "bumpeq;": "≏",
20050 "Cacute;": "Ć",
20051 "cacute;": "ć",
20052 "capand;": "⩄",
20053 "capcap;": "⩋",
20054 "capcup;": "⩇",
20055 "capdot;": "⩀",
20056 "Ccaron;": "Č",
20057 "ccaron;": "č",
20058 "Ccedil;": "Ç",
20059 "ccedil;": "ç",
20060 "circeq;": "≗",
20061 "cirmid;": "⫯",
20062 "Colone;": "⩴",
20063 "colone;": "≔",
20064 "commat;": "@",
20065 "compfn;": "∘",
20066 "Conint;": "∯",
20067 "conint;": "∮",
20068 "coprod;": "∐",
20069 "copysr;": "℗",
20070 "cularr;": "↶",
20071 "CupCap;": "≍",
20072 "cupcap;": "⩆",
20073 "cupcup;": "⩊",
20074 "cupdot;": "⊍",
20075 "curarr;": "↷",
20076 "curren;": "¤",
20077 "cylcty;": "⌭",
20078 "Dagger;": "‡",
20079 "dagger;": "†",
20080 "daleth;": "ℸ",
20081 "Dcaron;": "Ď",
20082 "dcaron;": "ď",
20083 "dfisht;": "⥿",
20084 "divide;": "÷",
20085 "divonx;": "⋇",
20086 "dlcorn;": "⌞",
20087 "dlcrop;": "⌍",
20088 "dollar;": "$",
20089 "DotDot;": "⃜",
20090 "drcorn;": "⌟",
20091 "drcrop;": "⌌",
20092 "Dstrok;": "Đ",
20093 "dstrok;": "đ",
20094 "Eacute;": "É",
20095 "eacute;": "é",
20096 "easter;": "⩮",
20097 "Ecaron;": "Ě",
20098 "ecaron;": "ě",
20099 "ecolon;": "≕",
20100 "Egrave;": "È",
20101 "egrave;": "è",
20102 "egsdot;": "⪘",
20103 "elsdot;": "⪗",
20104 "emptyv;": "∅",
20105 "emsp13;": " ",
20106 "emsp14;": " ",
20107 "eparsl;": "⧣",
20108 "eqcirc;": "≖",
20109 "equals;": "=",
20110 "equest;": "≟",
20111 "Exists;": "∃",
20112 "female;": "♀",
20113 "ffilig;": "ffi",
20114 "ffllig;": "ffl",
20115 "ForAll;": "∀",
20116 "forall;": "∀",
20117 "frac12;": "½",
20118 "frac13;": "⅓",
20119 "frac14;": "¼",
20120 "frac15;": "⅕",
20121 "frac16;": "⅙",
20122 "frac18;": "⅛",
20123 "frac23;": "⅔",
20124 "frac25;": "⅖",
20125 "frac34;": "¾",
20126 "frac35;": "⅗",
20127 "frac38;": "⅜",
20128 "frac45;": "⅘",
20129 "frac56;": "⅚",
20130 "frac58;": "⅝",
20131 "frac78;": "⅞",
20132 "gacute;": "ǵ",
20133 "Gammad;": "Ϝ",
20134 "gammad;": "ϝ",
20135 "Gbreve;": "Ğ",
20136 "gbreve;": "ğ",
20137 "Gcedil;": "Ģ",
20138 "gesdot;": "⪀",
20139 "gesles;": "⪔",
20140 "gtlPar;": "⦕",
20141 "gtrarr;": "⥸",
20142 "gtrdot;": "⋗",
20143 "gtrsim;": "≳",
20144 "hairsp;": " ",
20145 "hamilt;": "ℋ",
20146 "HARDcy;": "Ъ",
20147 "hardcy;": "ъ",
20148 "hearts;": "♥",
20149 "hellip;": "…",
20150 "hercon;": "⊹",
20151 "homtht;": "∻",
20152 "horbar;": "―",
20153 "hslash;": "ℏ",
20154 "Hstrok;": "Ħ",
20155 "hstrok;": "ħ",
20156 "hybull;": "⁃",
20157 "hyphen;": "‐",
20158 "Iacute;": "Í",
20159 "iacute;": "í",
20160 "Igrave;": "Ì",
20161 "igrave;": "ì",
20162 "iiiint;": "⨌",
20163 "iinfin;": "⧜",
20164 "incare;": "℅",
20165 "inodot;": "ı",
20166 "intcal;": "⊺",
20167 "iquest;": "¿",
20168 "isinsv;": "⋳",
20169 "Itilde;": "Ĩ",
20170 "itilde;": "ĩ",
20171 "Jsercy;": "Ј",
20172 "jsercy;": "ј",
20173 "kappav;": "ϰ",
20174 "Kcedil;": "Ķ",
20175 "kcedil;": "ķ",
20176 "kgreen;": "ĸ",
20177 "Lacute;": "Ĺ",
20178 "lacute;": "ĺ",
20179 "lagran;": "ℒ",
20180 "Lambda;": "Λ",
20181 "lambda;": "λ",
20182 "langle;": "⟨",
20183 "larrfs;": "⤝",
20184 "larrhk;": "↩",
20185 "larrlp;": "↫",
20186 "larrpl;": "⤹",
20187 "larrtl;": "↢",
20188 "lAtail;": "⤛",
20189 "latail;": "⤙",
20190 "lbrace;": "{",
20191 "lbrack;": "[",
20192 "Lcaron;": "Ľ",
20193 "lcaron;": "ľ",
20194 "Lcedil;": "Ļ",
20195 "lcedil;": "ļ",
20196 "ldquor;": "„",
20197 "lesdot;": "⩿",
20198 "lesges;": "⪓",
20199 "lfisht;": "⥼",
20200 "lfloor;": "⌊",
20201 "lharul;": "⥪",
20202 "llhard;": "⥫",
20203 "Lmidot;": "Ŀ",
20204 "lmidot;": "ŀ",
20205 "lmoust;": "⎰",
20206 "loplus;": "⨭",
20207 "lowast;": "∗",
20208 "lowbar;": "_",
20209 "lparlt;": "⦓",
20210 "lrhard;": "⥭",
20211 "lsaquo;": "‹",
20212 "lsquor;": "‚",
20213 "Lstrok;": "Ł",
20214 "lstrok;": "ł",
20215 "lthree;": "⋋",
20216 "ltimes;": "⋉",
20217 "ltlarr;": "⥶",
20218 "ltrPar;": "⦖",
20219 "mapsto;": "↦",
20220 "marker;": "▮",
20221 "mcomma;": "⨩",
20222 "midast;": "*",
20223 "midcir;": "⫰",
20224 "middot;": "·",
20225 "minusb;": "⊟",
20226 "minusd;": "∸",
20227 "mnplus;": "∓",
20228 "models;": "⊧",
20229 "mstpos;": "∾",
20230 "Nacute;": "Ń",
20231 "nacute;": "ń",
20232 "nbumpe;": "≏̸",
20233 "Ncaron;": "Ň",
20234 "ncaron;": "ň",
20235 "Ncedil;": "Ņ",
20236 "ncedil;": "ņ",
20237 "nearhk;": "⤤",
20238 "nequiv;": "≢",
20239 "nesear;": "⤨",
20240 "nexist;": "∄",
20241 "nltrie;": "⋬",
20242 "notinE;": "⋹̸",
20243 "nparsl;": "⫽⃥",
20244 "nprcue;": "⋠",
20245 "nrarrc;": "⤳̸",
20246 "nrarrw;": "↝̸",
20247 "nrtrie;": "⋭",
20248 "nsccue;": "⋡",
20249 "nsimeq;": "≄",
20250 "Ntilde;": "Ñ",
20251 "ntilde;": "ñ",
20252 "numero;": "№",
20253 "nVDash;": "⊯",
20254 "nVdash;": "⊮",
20255 "nvDash;": "⊭",
20256 "nvdash;": "⊬",
20257 "nvHarr;": "⤄",
20258 "nvlArr;": "⤂",
20259 "nvrArr;": "⤃",
20260 "nwarhk;": "⤣",
20261 "nwnear;": "⤧",
20262 "Oacute;": "Ó",
20263 "oacute;": "ó",
20264 "Odblac;": "Ő",
20265 "odblac;": "ő",
20266 "odsold;": "⦼",
20267 "Ograve;": "Ò",
20268 "ograve;": "ò",
20269 "ominus;": "⊖",
20270 "origof;": "⊶",
20271 "Oslash;": "Ø",
20272 "oslash;": "ø",
20273 "Otilde;": "Õ",
20274 "otilde;": "õ",
20275 "Otimes;": "⨷",
20276 "otimes;": "⊗",
20277 "parsim;": "⫳",
20278 "percnt;": "%",
20279 "period;": ".",
20280 "permil;": "‰",
20281 "phmmat;": "ℳ",
20282 "planck;": "ℏ",
20283 "plankv;": "ℏ",
20284 "plusdo;": "∔",
20285 "plusdu;": "⨥",
20286 "plusmn;": "±",
20287 "preceq;": "⪯",
20288 "primes;": "ℙ",
20289 "prnsim;": "⋨",
20290 "propto;": "∝",
20291 "prurel;": "⊰",
20292 "puncsp;": " ",
20293 "qprime;": "⁗",
20294 "Racute;": "Ŕ",
20295 "racute;": "ŕ",
20296 "rangle;": "⟩",
20297 "rarrap;": "⥵",
20298 "rarrfs;": "⤞",
20299 "rarrhk;": "↪",
20300 "rarrlp;": "↬",
20301 "rarrpl;": "⥅",
20302 "Rarrtl;": "⤖",
20303 "rarrtl;": "↣",
20304 "rAtail;": "⤜",
20305 "ratail;": "⤚",
20306 "rbrace;": "}",
20307 "rbrack;": "]",
20308 "Rcaron;": "Ř",
20309 "rcaron;": "ř",
20310 "Rcedil;": "Ŗ",
20311 "rcedil;": "ŗ",
20312 "rdquor;": "”",
20313 "rfisht;": "⥽",
20314 "rfloor;": "⌋",
20315 "rharul;": "⥬",
20316 "rmoust;": "⎱",
20317 "roplus;": "⨮",
20318 "rpargt;": "⦔",
20319 "rsaquo;": "›",
20320 "rsquor;": "’",
20321 "rthree;": "⋌",
20322 "rtimes;": "⋊",
20323 "Sacute;": "Ś",
20324 "sacute;": "ś",
20325 "Scaron;": "Š",
20326 "scaron;": "š",
20327 "Scedil;": "Ş",
20328 "scedil;": "ş",
20329 "scnsim;": "⋩",
20330 "searhk;": "⤥",
20331 "seswar;": "⤩",
20332 "sfrown;": "⌢",
20333 "SHCHcy;": "Щ",
20334 "shchcy;": "щ",
20335 "sigmaf;": "ς",
20336 "sigmav;": "ς",
20337 "simdot;": "⩪",
20338 "smashp;": "⨳",
20339 "SOFTcy;": "Ь",
20340 "softcy;": "ь",
20341 "solbar;": "⌿",
20342 "spades;": "♠",
20343 "sqcaps;": "⊓︀",
20344 "sqcups;": "⊔︀",
20345 "sqsube;": "⊑",
20346 "sqsupe;": "⊒",
20347 "Square;": "□",
20348 "square;": "□",
20349 "squarf;": "▪",
20350 "ssetmn;": "∖",
20351 "ssmile;": "⌣",
20352 "sstarf;": "⋆",
20353 "subdot;": "⪽",
20354 "Subset;": "⋐",
20355 "subset;": "⊂",
20356 "subsim;": "⫇",
20357 "subsub;": "⫕",
20358 "subsup;": "⫓",
20359 "succeq;": "⪰",
20360 "supdot;": "⪾",
20361 "Supset;": "⋑",
20362 "supset;": "⊃",
20363 "supsim;": "⫈",
20364 "supsub;": "⫔",
20365 "supsup;": "⫖",
20366 "swarhk;": "⤦",
20367 "swnwar;": "⤪",
20368 "target;": "⌖",
20369 "Tcaron;": "Ť",
20370 "tcaron;": "ť",
20371 "Tcedil;": "Ţ",
20372 "tcedil;": "ţ",
20373 "telrec;": "⌕",
20374 "there4;": "∴",
20375 "thetav;": "ϑ",
20376 "thinsp;": " ",
20377 "thksim;": "∼",
20378 "timesb;": "⊠",
20379 "timesd;": "⨰",
20380 "topbot;": "⌶",
20381 "topcir;": "⫱",
20382 "tprime;": "‴",
20383 "tridot;": "◬",
20384 "Tstrok;": "Ŧ",
20385 "tstrok;": "ŧ",
20386 "Uacute;": "Ú",
20387 "uacute;": "ú",
20388 "Ubreve;": "Ŭ",
20389 "ubreve;": "ŭ",
20390 "Udblac;": "Ű",
20391 "udblac;": "ű",
20392 "ufisht;": "⥾",
20393 "Ugrave;": "Ù",
20394 "ugrave;": "ù",
20395 "ulcorn;": "⌜",
20396 "ulcrop;": "⌏",
20397 "urcorn;": "⌝",
20398 "urcrop;": "⌎",
20399 "Utilde;": "Ũ",
20400 "utilde;": "ũ",
20401 "vangrt;": "⦜",
20402 "varphi;": "ϕ",
20403 "varrho;": "ϱ",
20404 "Vdashl;": "⫦",
20405 "veebar;": "⊻",
20406 "vellip;": "⋮",
20407 "Verbar;": "‖",
20408 "verbar;": "|",
20409 "vsubnE;": "⫋︀",
20410 "vsubne;": "⊊︀",
20411 "vsupnE;": "⫌︀",
20412 "vsupne;": "⊋︀",
20413 "Vvdash;": "⊪",
20414 "wedbar;": "⩟",
20415 "wedgeq;": "≙",
20416 "weierp;": "℘",
20417 "wreath;": "≀",
20418 "xoplus;": "⨁",
20419 "xotime;": "⨂",
20420 "xsqcup;": "⨆",
20421 "xuplus;": "⨄",
20422 "xwedge;": "⋀",
20423 "Yacute;": "Ý",
20424 "yacute;": "ý",
20425 "Zacute;": "Ź",
20426 "zacute;": "ź",
20427 "Zcaron;": "Ž",
20428 "zcaron;": "ž",
20429 "zeetrf;": "ℨ",
20430 "alefsym;": "ℵ",
20431 "angrtvb;": "⊾",
20432 "angzarr;": "⍼",
20433 "asympeq;": "≍",
20434 "backsim;": "∽",
20435 "Because;": "∵",
20436 "because;": "∵",
20437 "bemptyv;": "⦰",
20438 "between;": "≬",
20439 "bigcirc;": "◯",
20440 "bigodot;": "⨀",
20441 "bigstar;": "★",
20442 "bnequiv;": "≡⃥",
20443 "boxplus;": "⊞",
20444 "Cayleys;": "ℭ",
20445 "Cconint;": "∰",
20446 "ccupssm;": "⩐",
20447 "Cedilla;": "¸",
20448 "cemptyv;": "⦲",
20449 "cirscir;": "⧂",
20450 "coloneq;": "≔",
20451 "congdot;": "⩭",
20452 "cudarrl;": "⤸",
20453 "cudarrr;": "⤵",
20454 "cularrp;": "⤽",
20455 "curarrm;": "⤼",
20456 "dbkarow;": "⤏",
20457 "ddagger;": "‡",
20458 "ddotseq;": "⩷",
20459 "demptyv;": "⦱",
20460 "Diamond;": "⋄",
20461 "diamond;": "⋄",
20462 "digamma;": "ϝ",
20463 "dotplus;": "∔",
20464 "DownTee;": "⊤",
20465 "dwangle;": "⦦",
20466 "Element;": "∈",
20467 "Epsilon;": "Ε",
20468 "epsilon;": "ε",
20469 "eqcolon;": "≕",
20470 "equivDD;": "⩸",
20471 "gesdoto;": "⪂",
20472 "gtquest;": "⩼",
20473 "gtrless;": "≷",
20474 "harrcir;": "⥈",
20475 "Implies;": "⇒",
20476 "intprod;": "⨼",
20477 "isindot;": "⋵",
20478 "larrbfs;": "⤟",
20479 "larrsim;": "⥳",
20480 "lbrksld;": "⦏",
20481 "lbrkslu;": "⦍",
20482 "ldrdhar;": "⥧",
20483 "LeftTee;": "⊣",
20484 "lesdoto;": "⪁",
20485 "lessdot;": "⋖",
20486 "lessgtr;": "≶",
20487 "lesssim;": "≲",
20488 "lotimes;": "⨴",
20489 "lozenge;": "◊",
20490 "ltquest;": "⩻",
20491 "luruhar;": "⥦",
20492 "maltese;": "✠",
20493 "minusdu;": "⨪",
20494 "napprox;": "≉",
20495 "natural;": "♮",
20496 "nearrow;": "↗",
20497 "NewLine;": "\n",
20498 "nexists;": "∄",
20499 "NoBreak;": "⁠",
20500 "notinva;": "∉",
20501 "notinvb;": "⋷",
20502 "notinvc;": "⋶",
20503 "NotLess;": "≮",
20504 "notniva;": "∌",
20505 "notnivb;": "⋾",
20506 "notnivc;": "⋽",
20507 "npolint;": "⨔",
20508 "npreceq;": "⪯̸",
20509 "nsqsube;": "⋢",
20510 "nsqsupe;": "⋣",
20511 "nsubset;": "⊂⃒",
20512 "nsucceq;": "⪰̸",
20513 "nsupset;": "⊃⃒",
20514 "nvinfin;": "⧞",
20515 "nvltrie;": "⊴⃒",
20516 "nvrtrie;": "⊵⃒",
20517 "nwarrow;": "↖",
20518 "olcross;": "⦻",
20519 "Omicron;": "Ο",
20520 "omicron;": "ο",
20521 "orderof;": "ℴ",
20522 "orslope;": "⩗",
20523 "OverBar;": "‾",
20524 "pertenk;": "‱",
20525 "planckh;": "ℎ",
20526 "pluscir;": "⨢",
20527 "plussim;": "⨦",
20528 "plustwo;": "⨧",
20529 "precsim;": "≾",
20530 "Product;": "∏",
20531 "quatint;": "⨖",
20532 "questeq;": "≟",
20533 "rarrbfs;": "⤠",
20534 "rarrsim;": "⥴",
20535 "rbrksld;": "⦎",
20536 "rbrkslu;": "⦐",
20537 "rdldhar;": "⥩",
20538 "realine;": "ℛ",
20539 "rotimes;": "⨵",
20540 "ruluhar;": "⥨",
20541 "searrow;": "↘",
20542 "simplus;": "⨤",
20543 "simrarr;": "⥲",
20544 "subedot;": "⫃",
20545 "submult;": "⫁",
20546 "subplus;": "⪿",
20547 "subrarr;": "⥹",
20548 "succsim;": "≿",
20549 "supdsub;": "⫘",
20550 "supedot;": "⫄",
20551 "suphsol;": "⟉",
20552 "suphsub;": "⫗",
20553 "suplarr;": "⥻",
20554 "supmult;": "⫂",
20555 "supplus;": "⫀",
20556 "swarrow;": "↙",
20557 "topfork;": "⫚",
20558 "triplus;": "⨹",
20559 "tritime;": "⨻",
20560 "UpArrow;": "↑",
20561 "Uparrow;": "⇑",
20562 "uparrow;": "↑",
20563 "Upsilon;": "Υ",
20564 "upsilon;": "υ",
20565 "uwangle;": "⦧",
20566 "vzigzag;": "⦚",
20567 "zigrarr;": "⇝",
20568 "andslope;": "⩘",
20569 "angmsdaa;": "⦨",
20570 "angmsdab;": "⦩",
20571 "angmsdac;": "⦪",
20572 "angmsdad;": "⦫",
20573 "angmsdae;": "⦬",
20574 "angmsdaf;": "⦭",
20575 "angmsdag;": "⦮",
20576 "angmsdah;": "⦯",
20577 "angrtvbd;": "⦝",
20578 "approxeq;": "≊",
20579 "awconint;": "∳",
20580 "backcong;": "≌",
20581 "barwedge;": "⌅",
20582 "bbrktbrk;": "⎶",
20583 "bigoplus;": "⨁",
20584 "bigsqcup;": "⨆",
20585 "biguplus;": "⨄",
20586 "bigwedge;": "⋀",
20587 "boxminus;": "⊟",
20588 "boxtimes;": "⊠",
20589 "bsolhsub;": "⟈",
20590 "capbrcup;": "⩉",
20591 "circledR;": "®",
20592 "circledS;": "Ⓢ",
20593 "cirfnint;": "⨐",
20594 "clubsuit;": "♣",
20595 "cupbrcap;": "⩈",
20596 "curlyvee;": "⋎",
20597 "cwconint;": "∲",
20598 "DDotrahd;": "⤑",
20599 "doteqdot;": "≑",
20600 "DotEqual;": "≐",
20601 "dotminus;": "∸",
20602 "drbkarow;": "⤐",
20603 "dzigrarr;": "⟿",
20604 "elinters;": "⏧",
20605 "emptyset;": "∅",
20606 "eqvparsl;": "⧥",
20607 "fpartint;": "⨍",
20608 "geqslant;": "⩾",
20609 "gesdotol;": "⪄",
20610 "gnapprox;": "⪊",
20611 "hksearow;": "⤥",
20612 "hkswarow;": "⤦",
20613 "imagline;": "ℐ",
20614 "imagpart;": "ℑ",
20615 "infintie;": "⧝",
20616 "integers;": "ℤ",
20617 "Integral;": "∫",
20618 "intercal;": "⊺",
20619 "intlarhk;": "⨗",
20620 "laemptyv;": "⦴",
20621 "ldrushar;": "⥋",
20622 "leqslant;": "⩽",
20623 "lesdotor;": "⪃",
20624 "LessLess;": "⪡",
20625 "llcorner;": "⌞",
20626 "lnapprox;": "⪉",
20627 "lrcorner;": "⌟",
20628 "lurdshar;": "⥊",
20629 "mapstoup;": "↥",
20630 "multimap;": "⊸",
20631 "naturals;": "ℕ",
20632 "ncongdot;": "⩭̸",
20633 "NotEqual;": "≠",
20634 "notindot;": "⋵̸",
20635 "NotTilde;": "≁",
20636 "otimesas;": "⨶",
20637 "parallel;": "∥",
20638 "PartialD;": "∂",
20639 "plusacir;": "⨣",
20640 "pointint;": "⨕",
20641 "Precedes;": "≺",
20642 "precneqq;": "⪵",
20643 "precnsim;": "⋨",
20644 "profalar;": "⌮",
20645 "profline;": "⌒",
20646 "profsurf;": "⌓",
20647 "raemptyv;": "⦳",
20648 "realpart;": "ℜ",
20649 "RightTee;": "⊢",
20650 "rppolint;": "⨒",
20651 "rtriltri;": "⧎",
20652 "scpolint;": "⨓",
20653 "setminus;": "∖",
20654 "shortmid;": "∣",
20655 "smeparsl;": "⧤",
20656 "sqsubset;": "⊏",
20657 "sqsupset;": "⊐",
20658 "subseteq;": "⊆",
20659 "Succeeds;": "≻",
20660 "succneqq;": "⪶",
20661 "succnsim;": "⋩",
20662 "SuchThat;": "∋",
20663 "Superset;": "⊃",
20664 "supseteq;": "⊇",
20665 "thetasym;": "ϑ",
20666 "thicksim;": "∼",
20667 "timesbar;": "⨱",
20668 "triangle;": "▵",
20669 "triminus;": "⨺",
20670 "trpezium;": "⏢",
20671 "Uarrocir;": "⥉",
20672 "ulcorner;": "⌜",
20673 "UnderBar;": "_",
20674 "urcorner;": "⌝",
20675 "varkappa;": "ϰ",
20676 "varsigma;": "ς",
20677 "vartheta;": "ϑ",
20678 "backprime;": "‵",
20679 "backsimeq;": "⋍",
20680 "Backslash;": "∖",
20681 "bigotimes;": "⨂",
20682 "CenterDot;": "·",
20683 "centerdot;": "·",
20684 "checkmark;": "✓",
20685 "CircleDot;": "⊙",
20686 "complexes;": "ℂ",
20687 "Congruent;": "≡",
20688 "Coproduct;": "∐",
20689 "dotsquare;": "⊡",
20690 "DoubleDot;": "¨",
20691 "DownArrow;": "↓",
20692 "Downarrow;": "⇓",
20693 "downarrow;": "↓",
20694 "DownBreve;": "̑",
20695 "gtrapprox;": "⪆",
20696 "gtreqless;": "⋛",
20697 "gvertneqq;": "≩︀",
20698 "heartsuit;": "♥",
20699 "HumpEqual;": "≏",
20700 "LeftArrow;": "←",
20701 "Leftarrow;": "⇐",
20702 "leftarrow;": "←",
20703 "LeftFloor;": "⌊",
20704 "lesseqgtr;": "⋚",
20705 "LessTilde;": "≲",
20706 "lvertneqq;": "≨︀",
20707 "Mellintrf;": "ℳ",
20708 "MinusPlus;": "∓",
20709 "ngeqslant;": "⩾̸",
20710 "nleqslant;": "⩽̸",
20711 "NotCupCap;": "≭",
20712 "NotExists;": "∄",
20713 "NotSubset;": "⊂⃒",
20714 "nparallel;": "∦",
20715 "nshortmid;": "∤",
20716 "nsubseteq;": "⊈",
20717 "nsupseteq;": "⊉",
20718 "OverBrace;": "⏞",
20719 "pitchfork;": "⋔",
20720 "PlusMinus;": "±",
20721 "rationals;": "ℚ",
20722 "spadesuit;": "♠",
20723 "subseteqq;": "⫅",
20724 "subsetneq;": "⊊",
20725 "supseteqq;": "⫆",
20726 "supsetneq;": "⊋",
20727 "Therefore;": "∴",
20728 "therefore;": "∴",
20729 "ThinSpace;": " ",
20730 "triangleq;": "≜",
20731 "TripleDot;": "⃛",
20732 "UnionPlus;": "⊎",
20733 "varpropto;": "∝",
20734 "Bernoullis;": "ℬ",
20735 "circledast;": "⊛",
20736 "CirclePlus;": "⊕",
20737 "complement;": "∁",
20738 "curlywedge;": "⋏",
20739 "eqslantgtr;": "⪖",
20740 "EqualTilde;": "≂",
20741 "Fouriertrf;": "ℱ",
20742 "gtreqqless;": "⪌",
20743 "ImaginaryI;": "ⅈ",
20744 "Laplacetrf;": "ℒ",
20745 "LeftVector;": "↼",
20746 "lessapprox;": "⪅",
20747 "lesseqqgtr;": "⪋",
20748 "Lleftarrow;": "⇚",
20749 "lmoustache;": "⎰",
20750 "longmapsto;": "⟼",
20751 "mapstodown;": "↧",
20752 "mapstoleft;": "↤",
20753 "nLeftarrow;": "⇍",
20754 "nleftarrow;": "↚",
20755 "NotElement;": "∉",
20756 "NotGreater;": "≯",
20757 "nsubseteqq;": "⫅̸",
20758 "nsupseteqq;": "⫆̸",
20759 "precapprox;": "⪷",
20760 "Proportion;": "∷",
20761 "RightArrow;": "→",
20762 "Rightarrow;": "⇒",
20763 "rightarrow;": "→",
20764 "RightFloor;": "⌋",
20765 "rmoustache;": "⎱",
20766 "sqsubseteq;": "⊑",
20767 "sqsupseteq;": "⊒",
20768 "subsetneqq;": "⫋",
20769 "succapprox;": "⪸",
20770 "supsetneqq;": "⫌",
20771 "ThickSpace;": "  ",
20772 "TildeEqual;": "≃",
20773 "TildeTilde;": "≈",
20774 "UnderBrace;": "⏟",
20775 "UpArrowBar;": "⤒",
20776 "UpTeeArrow;": "↥",
20777 "upuparrows;": "⇈",
20778 "varepsilon;": "ϵ",
20779 "varnothing;": "∅",
20780 "backepsilon;": "϶",
20781 "blacksquare;": "▪",
20782 "circledcirc;": "⊚",
20783 "circleddash;": "⊝",
20784 "CircleMinus;": "⊖",
20785 "CircleTimes;": "⊗",
20786 "curlyeqprec;": "⋞",
20787 "curlyeqsucc;": "⋟",
20788 "diamondsuit;": "♦",
20789 "eqslantless;": "⪕",
20790 "Equilibrium;": "⇌",
20791 "expectation;": "ℰ",
20792 "GreaterLess;": "≷",
20793 "LeftCeiling;": "⌈",
20794 "LessGreater;": "≶",
20795 "MediumSpace;": " ",
20796 "NotLessLess;": "≪̸",
20797 "NotPrecedes;": "⊀",
20798 "NotSucceeds;": "⊁",
20799 "NotSuperset;": "⊃⃒",
20800 "nRightarrow;": "⇏",
20801 "nrightarrow;": "↛",
20802 "OverBracket;": "⎴",
20803 "preccurlyeq;": "≼",
20804 "precnapprox;": "⪹",
20805 "quaternions;": "ℍ",
20806 "RightVector;": "⇀",
20807 "Rrightarrow;": "⇛",
20808 "RuleDelayed;": "⧴",
20809 "SmallCircle;": "∘",
20810 "SquareUnion;": "⊔",
20811 "straightphi;": "ϕ",
20812 "SubsetEqual;": "⊆",
20813 "succcurlyeq;": "≽",
20814 "succnapprox;": "⪺",
20815 "thickapprox;": "≈",
20816 "UpDownArrow;": "↕",
20817 "Updownarrow;": "⇕",
20818 "updownarrow;": "↕",
20819 "VerticalBar;": "∣",
20820 "blacklozenge;": "⧫",
20821 "DownArrowBar;": "⤓",
20822 "DownTeeArrow;": "↧",
20823 "ExponentialE;": "ⅇ",
20824 "exponentiale;": "ⅇ",
20825 "GreaterEqual;": "≥",
20826 "GreaterTilde;": "≳",
20827 "HilbertSpace;": "ℋ",
20828 "HumpDownHump;": "≎",
20829 "Intersection;": "⋂",
20830 "LeftArrowBar;": "⇤",
20831 "LeftTeeArrow;": "↤",
20832 "LeftTriangle;": "⊲",
20833 "LeftUpVector;": "↿",
20834 "NotCongruent;": "≢",
20835 "NotHumpEqual;": "≏̸",
20836 "NotLessEqual;": "≰",
20837 "NotLessTilde;": "≴",
20838 "Proportional;": "∝",
20839 "RightCeiling;": "⌉",
20840 "risingdotseq;": "≓",
20841 "RoundImplies;": "⥰",
20842 "ShortUpArrow;": "↑",
20843 "SquareSubset;": "⊏",
20844 "triangledown;": "▿",
20845 "triangleleft;": "◃",
20846 "UnderBracket;": "⎵",
20847 "varsubsetneq;": "⊊︀",
20848 "varsupsetneq;": "⊋︀",
20849 "VerticalLine;": "|",
20850 "ApplyFunction;": "⁡",
20851 "bigtriangleup;": "△",
20852 "blacktriangle;": "▴",
20853 "DifferentialD;": "ⅆ",
20854 "divideontimes;": "⋇",
20855 "DoubleLeftTee;": "⫤",
20856 "DoubleUpArrow;": "⇑",
20857 "fallingdotseq;": "≒",
20858 "hookleftarrow;": "↩",
20859 "leftarrowtail;": "↢",
20860 "leftharpoonup;": "↼",
20861 "LeftTeeVector;": "⥚",
20862 "LeftVectorBar;": "⥒",
20863 "LessFullEqual;": "≦",
20864 "LongLeftArrow;": "⟵",
20865 "Longleftarrow;": "⟸",
20866 "longleftarrow;": "⟵",
20867 "looparrowleft;": "↫",
20868 "measuredangle;": "∡",
20869 "NotEqualTilde;": "≂̸",
20870 "NotTildeEqual;": "≄",
20871 "NotTildeTilde;": "≉",
20872 "ntriangleleft;": "⋪",
20873 "Poincareplane;": "ℌ",
20874 "PrecedesEqual;": "⪯",
20875 "PrecedesTilde;": "≾",
20876 "RightArrowBar;": "⇥",
20877 "RightTeeArrow;": "↦",
20878 "RightTriangle;": "⊳",
20879 "RightUpVector;": "↾",
20880 "shortparallel;": "∥",
20881 "smallsetminus;": "∖",
20882 "SucceedsEqual;": "⪰",
20883 "SucceedsTilde;": "≿",
20884 "SupersetEqual;": "⊇",
20885 "triangleright;": "▹",
20886 "UpEquilibrium;": "⥮",
20887 "upharpoonleft;": "↿",
20888 "varsubsetneqq;": "⫋︀",
20889 "varsupsetneqq;": "⫌︀",
20890 "VerticalTilde;": "≀",
20891 "VeryThinSpace;": " ",
20892 "curvearrowleft;": "↶",
20893 "DiacriticalDot;": "˙",
20894 "doublebarwedge;": "⌆",
20895 "DoubleRightTee;": "⊨",
20896 "downdownarrows;": "⇊",
20897 "DownLeftVector;": "↽",
20898 "GreaterGreater;": "⪢",
20899 "hookrightarrow;": "↪",
20900 "HorizontalLine;": "─",
20901 "InvisibleComma;": "⁣",
20902 "InvisibleTimes;": "⁢",
20903 "LeftDownVector;": "⇃",
20904 "leftleftarrows;": "⇇",
20905 "LeftRightArrow;": "↔",
20906 "Leftrightarrow;": "⇔",
20907 "leftrightarrow;": "↔",
20908 "leftthreetimes;": "⋋",
20909 "LessSlantEqual;": "⩽",
20910 "LongRightArrow;": "⟶",
20911 "Longrightarrow;": "⟹",
20912 "longrightarrow;": "⟶",
20913 "looparrowright;": "↬",
20914 "LowerLeftArrow;": "↙",
20915 "NestedLessLess;": "≪",
20916 "NotGreaterLess;": "≹",
20917 "NotLessGreater;": "≸",
20918 "NotSubsetEqual;": "⊈",
20919 "NotVerticalBar;": "∤",
20920 "nshortparallel;": "∦",
20921 "ntriangleright;": "⋫",
20922 "OpenCurlyQuote;": "‘",
20923 "ReverseElement;": "∋",
20924 "rightarrowtail;": "↣",
20925 "rightharpoonup;": "⇀",
20926 "RightTeeVector;": "⥛",
20927 "RightVectorBar;": "⥓",
20928 "ShortDownArrow;": "↓",
20929 "ShortLeftArrow;": "←",
20930 "SquareSuperset;": "⊐",
20931 "TildeFullEqual;": "≅",
20932 "trianglelefteq;": "⊴",
20933 "upharpoonright;": "↾",
20934 "UpperLeftArrow;": "↖",
20935 "ZeroWidthSpace;": "​",
20936 "bigtriangledown;": "▽",
20937 "circlearrowleft;": "↺",
20938 "CloseCurlyQuote;": "’",
20939 "ContourIntegral;": "∮",
20940 "curvearrowright;": "↷",
20941 "DoubleDownArrow;": "⇓",
20942 "DoubleLeftArrow;": "⇐",
20943 "downharpoonleft;": "⇃",
20944 "DownRightVector;": "⇁",
20945 "leftharpoondown;": "↽",
20946 "leftrightarrows;": "⇆",
20947 "LeftRightVector;": "⥎",
20948 "LeftTriangleBar;": "⧏",
20949 "LeftUpTeeVector;": "⥠",
20950 "LeftUpVectorBar;": "⥘",
20951 "LowerRightArrow;": "↘",
20952 "nLeftrightarrow;": "⇎",
20953 "nleftrightarrow;": "↮",
20954 "NotGreaterEqual;": "≱",
20955 "NotGreaterTilde;": "≵",
20956 "NotHumpDownHump;": "≎̸",
20957 "NotLeftTriangle;": "⋪",
20958 "NotSquareSubset;": "⊏̸",
20959 "ntrianglelefteq;": "⋬",
20960 "OverParenthesis;": "⏜",
20961 "RightDownVector;": "⇂",
20962 "rightleftarrows;": "⇄",
20963 "rightsquigarrow;": "↝",
20964 "rightthreetimes;": "⋌",
20965 "ShortRightArrow;": "→",
20966 "straightepsilon;": "ϵ",
20967 "trianglerighteq;": "⊵",
20968 "UpperRightArrow;": "↗",
20969 "vartriangleleft;": "⊲",
20970 "circlearrowright;": "↻",
20971 "DiacriticalAcute;": "´",
20972 "DiacriticalGrave;": "`",
20973 "DiacriticalTilde;": "˜",
20974 "DoubleRightArrow;": "⇒",
20975 "DownArrowUpArrow;": "⇵",
20976 "downharpoonright;": "⇂",
20977 "EmptySmallSquare;": "◻",
20978 "GreaterEqualLess;": "⋛",
20979 "GreaterFullEqual;": "≧",
20980 "LeftAngleBracket;": "⟨",
20981 "LeftUpDownVector;": "⥑",
20982 "LessEqualGreater;": "⋚",
20983 "NonBreakingSpace;": " ",
20984 "NotPrecedesEqual;": "⪯̸",
20985 "NotRightTriangle;": "⋫",
20986 "NotSucceedsEqual;": "⪰̸",
20987 "NotSucceedsTilde;": "≿̸",
20988 "NotSupersetEqual;": "⊉",
20989 "ntrianglerighteq;": "⋭",
20990 "rightharpoondown;": "⇁",
20991 "rightrightarrows;": "⇉",
20992 "RightTriangleBar;": "⧐",
20993 "RightUpTeeVector;": "⥜",
20994 "RightUpVectorBar;": "⥔",
20995 "twoheadleftarrow;": "↞",
20996 "UnderParenthesis;": "⏝",
20997 "UpArrowDownArrow;": "⇅",
20998 "vartriangleright;": "⊳",
20999 "blacktriangledown;": "▾",
21000 "blacktriangleleft;": "◂",
21001 "DoubleUpDownArrow;": "⇕",
21002 "DoubleVerticalBar;": "∥",
21003 "DownLeftTeeVector;": "⥞",
21004 "DownLeftVectorBar;": "⥖",
21005 "FilledSmallSquare;": "◼",
21006 "GreaterSlantEqual;": "⩾",
21007 "LeftDoubleBracket;": "⟦",
21008 "LeftDownTeeVector;": "⥡",
21009 "LeftDownVectorBar;": "⥙",
21010 "leftrightharpoons;": "⇋",
21011 "LeftTriangleEqual;": "⊴",
21012 "NegativeThinSpace;": "​",
21013 "NotGreaterGreater;": "≫̸",
21014 "NotLessSlantEqual;": "⩽̸",
21015 "NotNestedLessLess;": "⪡̸",
21016 "NotReverseElement;": "∌",
21017 "NotSquareSuperset;": "⊐̸",
21018 "NotTildeFullEqual;": "≇",
21019 "RightAngleBracket;": "⟩",
21020 "rightleftharpoons;": "⇌",
21021 "RightUpDownVector;": "⥏",
21022 "SquareSubsetEqual;": "⊑",
21023 "twoheadrightarrow;": "↠",
21024 "VerticalSeparator;": "❘",
21025 "blacktriangleright;": "▸",
21026 "DownRightTeeVector;": "⥟",
21027 "DownRightVectorBar;": "⥗",
21028 "LongLeftRightArrow;": "⟷",
21029 "Longleftrightarrow;": "⟺",
21030 "longleftrightarrow;": "⟷",
21031 "NegativeThickSpace;": "​",
21032 "NotLeftTriangleBar;": "⧏̸",
21033 "PrecedesSlantEqual;": "≼",
21034 "ReverseEquilibrium;": "⇋",
21035 "RightDoubleBracket;": "⟧",
21036 "RightDownTeeVector;": "⥝",
21037 "RightDownVectorBar;": "⥕",
21038 "RightTriangleEqual;": "⊵",
21039 "SquareIntersection;": "⊓",
21040 "SucceedsSlantEqual;": "≽",
21041 "DoubleLongLeftArrow;": "⟸",
21042 "DownLeftRightVector;": "⥐",
21043 "LeftArrowRightArrow;": "⇆",
21044 "leftrightsquigarrow;": "↭",
21045 "NegativeMediumSpace;": "​",
21046 "NotGreaterFullEqual;": "≧̸",
21047 "NotRightTriangleBar;": "⧐̸",
21048 "RightArrowLeftArrow;": "⇄",
21049 "SquareSupersetEqual;": "⊒",
21050 "CapitalDifferentialD;": "ⅅ",
21051 "DoubleLeftRightArrow;": "⇔",
21052 "DoubleLongRightArrow;": "⟹",
21053 "EmptyVerySmallSquare;": "▫",
21054 "NestedGreaterGreater;": "≫",
21055 "NotDoubleVerticalBar;": "∦",
21056 "NotGreaterSlantEqual;": "⩾̸",
21057 "NotLeftTriangleEqual;": "⋬",
21058 "NotSquareSubsetEqual;": "⋢",
21059 "OpenCurlyDoubleQuote;": "“",
21060 "ReverseUpEquilibrium;": "⥯",
21061 "CloseCurlyDoubleQuote;": "”",
21062 "DoubleContourIntegral;": "∯",
21063 "FilledVerySmallSquare;": "▪",
21064 "NegativeVeryThinSpace;": "​",
21065 "NotPrecedesSlantEqual;": "⋠",
21066 "NotRightTriangleEqual;": "⋭",
21067 "NotSucceedsSlantEqual;": "⋡",
21068 "DiacriticalDoubleAcute;": "˝",
21069 "NotSquareSupersetEqual;": "⋣",
21070 "NotNestedGreaterGreater;": "⪢̸",
21071 "ClockwiseContourIntegral;": "∲",
21072 "DoubleLongLeftRightArrow;": "⟺",
21073 "CounterClockwiseContourIntegral;": "∳"
21074};
21075
21076// lazy compute this to make this file tree-shakable for browser
21077let maxCRNameLength;
21078const decodeHtml = (rawText, asAttr) => {
21079 let offset = 0;
21080 const end = rawText.length;
21081 let decodedText = '';
21082 function advance(length) {
21083 offset += length;
21084 rawText = rawText.slice(length);
21085 }
21086 while (offset < end) {
21087 const head = /&(?:#x?)?/i.exec(rawText);
21088 if (!head || offset + head.index >= end) {
21089 const remaining = end - offset;
21090 decodedText += rawText.slice(0, remaining);
21091 advance(remaining);
21092 break;
21093 }
21094 // Advance to the "&".
21095 decodedText += rawText.slice(0, head.index);
21096 advance(head.index);
21097 if (head[0] === '&') {
21098 // Named character reference.
21099 let name = '';
21100 let value = undefined;
21101 if (/[0-9a-z]/i.test(rawText[1])) {
21102 if (!maxCRNameLength) {
21103 maxCRNameLength = Object.keys(namedCharacterReferences).reduce((max, name) => Math.max(max, name.length), 0);
21104 }
21105 for (let length = maxCRNameLength; !value && length > 0; --length) {
21106 name = rawText.slice(1, 1 + length);
21107 value = namedCharacterReferences[name];
21108 }
21109 if (value) {
21110 const semi = name.endsWith(';');
21111 if (asAttr &&
21112 !semi &&
21113 /[=a-z0-9]/i.test(rawText[name.length + 1] || '')) {
21114 decodedText += '&' + name;
21115 advance(1 + name.length);
21116 }
21117 else {
21118 decodedText += value;
21119 advance(1 + name.length);
21120 }
21121 }
21122 else {
21123 decodedText += '&' + name;
21124 advance(1 + name.length);
21125 }
21126 }
21127 else {
21128 decodedText += '&';
21129 advance(1);
21130 }
21131 }
21132 else {
21133 // Numeric character reference.
21134 const hex = head[0] === '&#x';
21135 const pattern = hex ? /^&#x([0-9a-f]+);?/i : /^&#([0-9]+);?/;
21136 const body = pattern.exec(rawText);
21137 if (!body) {
21138 decodedText += head[0];
21139 advance(head[0].length);
21140 }
21141 else {
21142 // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
21143 let cp = Number.parseInt(body[1], hex ? 16 : 10);
21144 if (cp === 0) {
21145 cp = 0xfffd;
21146 }
21147 else if (cp > 0x10ffff) {
21148 cp = 0xfffd;
21149 }
21150 else if (cp >= 0xd800 && cp <= 0xdfff) {
21151 cp = 0xfffd;
21152 }
21153 else if ((cp >= 0xfdd0 && cp <= 0xfdef) || (cp & 0xfffe) === 0xfffe) ;
21154 else if ((cp >= 0x01 && cp <= 0x08) ||
21155 cp === 0x0b ||
21156 (cp >= 0x0d && cp <= 0x1f) ||
21157 (cp >= 0x7f && cp <= 0x9f)) {
21158 cp = CCR_REPLACEMENTS[cp] || cp;
21159 }
21160 decodedText += String.fromCodePoint(cp);
21161 advance(body[0].length);
21162 }
21163 }
21164 }
21165 return decodedText;
21166};
21167// https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
21168const CCR_REPLACEMENTS = {
21169 0x80: 0x20ac,
21170 0x82: 0x201a,
21171 0x83: 0x0192,
21172 0x84: 0x201e,
21173 0x85: 0x2026,
21174 0x86: 0x2020,
21175 0x87: 0x2021,
21176 0x88: 0x02c6,
21177 0x89: 0x2030,
21178 0x8a: 0x0160,
21179 0x8b: 0x2039,
21180 0x8c: 0x0152,
21181 0x8e: 0x017d,
21182 0x91: 0x2018,
21183 0x92: 0x2019,
21184 0x93: 0x201c,
21185 0x94: 0x201d,
21186 0x95: 0x2022,
21187 0x96: 0x2013,
21188 0x97: 0x2014,
21189 0x98: 0x02dc,
21190 0x99: 0x2122,
21191 0x9a: 0x0161,
21192 0x9b: 0x203a,
21193 0x9c: 0x0153,
21194 0x9e: 0x017e,
21195 0x9f: 0x0178
21196};
21197
21198const isRawTextContainer = /*#__PURE__*/ makeMap('style,iframe,script,noscript', true);
21199const parserOptions = {
21200 isVoidTag,
21201 isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag),
21202 isPreTag: tag => tag === 'pre',
21203 decodeEntities: decodeHtml,
21204 isBuiltInComponent: (tag) => {
21205 if (isBuiltInType(tag, `Transition`)) {
21206 return TRANSITION$1;
21207 }
21208 else if (isBuiltInType(tag, `TransitionGroup`)) {
21209 return TRANSITION_GROUP;
21210 }
21211 },
21212 // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
21213 getNamespace(tag, parent) {
21214 let ns = parent ? parent.ns : 0 /* DOMNamespaces.HTML */;
21215 if (parent && ns === 2 /* DOMNamespaces.MATH_ML */) {
21216 if (parent.tag === 'annotation-xml') {
21217 if (tag === 'svg') {
21218 return 1 /* DOMNamespaces.SVG */;
21219 }
21220 if (parent.props.some(a => a.type === 6 /* NodeTypes.ATTRIBUTE */ &&
21221 a.name === 'encoding' &&
21222 a.value != null &&
21223 (a.value.content === 'text/html' ||
21224 a.value.content === 'application/xhtml+xml'))) {
21225 ns = 0 /* DOMNamespaces.HTML */;
21226 }
21227 }
21228 else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
21229 tag !== 'mglyph' &&
21230 tag !== 'malignmark') {
21231 ns = 0 /* DOMNamespaces.HTML */;
21232 }
21233 }
21234 else if (parent && ns === 1 /* DOMNamespaces.SVG */) {
21235 if (parent.tag === 'foreignObject' ||
21236 parent.tag === 'desc' ||
21237 parent.tag === 'title') {
21238 ns = 0 /* DOMNamespaces.HTML */;
21239 }
21240 }
21241 if (ns === 0 /* DOMNamespaces.HTML */) {
21242 if (tag === 'svg') {
21243 return 1 /* DOMNamespaces.SVG */;
21244 }
21245 if (tag === 'math') {
21246 return 2 /* DOMNamespaces.MATH_ML */;
21247 }
21248 }
21249 return ns;
21250 },
21251 // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
21252 getTextMode({ tag, ns }) {
21253 if (ns === 0 /* DOMNamespaces.HTML */) {
21254 if (tag === 'textarea' || tag === 'title') {
21255 return 1 /* TextModes.RCDATA */;
21256 }
21257 if (isRawTextContainer(tag)) {
21258 return 2 /* TextModes.RAWTEXT */;
21259 }
21260 }
21261 return 0 /* TextModes.DATA */;
21262 }
21263};
21264
21265// Parse inline CSS strings for static style attributes into an object.
21266// This is a NodeTransform since it works on the static `style` attribute and
21267// converts it into a dynamic equivalent:
21268// style="color: red" -> :style='{ "color": "red" }'
21269// It is then processed by `transformElement` and included in the generated
21270// props.
21271const transformStyle = node => {
21272 if (node.type === 1 /* NodeTypes.ELEMENT */) {
21273 node.props.forEach((p, i) => {
21274 if (p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'style' && p.value) {
21275 // replace p with an expression node
21276 node.props[i] = {
21277 type: 7 /* NodeTypes.DIRECTIVE */,
21278 name: `bind`,
21279 arg: createSimpleExpression(`style`, true, p.loc),
21280 exp: parseInlineCSS(p.value.content, p.loc),
21281 modifiers: [],
21282 loc: p.loc
21283 };
21284 }
21285 });
21286 }
21287};
21288const parseInlineCSS = (cssText, loc) => {
21289 const normalized = parseStringStyle(cssText);
21290 return createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
21291};
21292
21293function createDOMCompilerError(code, loc) {
21294 return createCompilerError(code, loc, DOMErrorMessages );
21295}
21296const DOMErrorMessages = {
21297 [50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
21298 [51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
21299 [52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
21300 [53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
21301 [54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
21302 [55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
21303 [56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
21304 [57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
21305 [58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
21306 [59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
21307 [60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
21308};
21309
21310const transformVHtml = (dir, node, context) => {
21311 const { exp, loc } = dir;
21312 if (!exp) {
21313 context.onError(createDOMCompilerError(50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */, loc));
21314 }
21315 if (node.children.length) {
21316 context.onError(createDOMCompilerError(51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */, loc));
21317 node.children.length = 0;
21318 }
21319 return {
21320 props: [
21321 createObjectProperty(createSimpleExpression(`innerHTML`, true, loc), exp || createSimpleExpression('', true))
21322 ]
21323 };
21324};
21325
21326const transformVText = (dir, node, context) => {
21327 const { exp, loc } = dir;
21328 if (!exp) {
21329 context.onError(createDOMCompilerError(52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */, loc));
21330 }
21331 if (node.children.length) {
21332 context.onError(createDOMCompilerError(53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */, loc));
21333 node.children.length = 0;
21334 }
21335 return {
21336 props: [
21337 createObjectProperty(createSimpleExpression(`textContent`, true), exp
21338 ? getConstantType(exp, context) > 0
21339 ? exp
21340 : createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
21341 : createSimpleExpression('', true))
21342 ]
21343 };
21344};
21345
21346const transformModel$1 = (dir, node, context) => {
21347 const baseResult = transformModel(dir, node, context);
21348 // base transform has errors OR component v-model (only need props)
21349 if (!baseResult.props.length || node.tagType === 1 /* ElementTypes.COMPONENT */) {
21350 return baseResult;
21351 }
21352 if (dir.arg) {
21353 context.onError(createDOMCompilerError(55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
21354 }
21355 function checkDuplicatedValue() {
21356 const value = findProp(node, 'value');
21357 if (value) {
21358 context.onError(createDOMCompilerError(57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
21359 }
21360 }
21361 const { tag } = node;
21362 const isCustomElement = context.isCustomElement(tag);
21363 if (tag === 'input' ||
21364 tag === 'textarea' ||
21365 tag === 'select' ||
21366 isCustomElement) {
21367 let directiveToUse = V_MODEL_TEXT;
21368 let isInvalidType = false;
21369 if (tag === 'input' || isCustomElement) {
21370 const type = findProp(node, `type`);
21371 if (type) {
21372 if (type.type === 7 /* NodeTypes.DIRECTIVE */) {
21373 // :type="foo"
21374 directiveToUse = V_MODEL_DYNAMIC;
21375 }
21376 else if (type.value) {
21377 switch (type.value.content) {
21378 case 'radio':
21379 directiveToUse = V_MODEL_RADIO;
21380 break;
21381 case 'checkbox':
21382 directiveToUse = V_MODEL_CHECKBOX;
21383 break;
21384 case 'file':
21385 isInvalidType = true;
21386 context.onError(createDOMCompilerError(56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
21387 break;
21388 default:
21389 // text type
21390 checkDuplicatedValue();
21391 break;
21392 }
21393 }
21394 }
21395 else if (hasDynamicKeyVBind(node)) {
21396 // element has bindings with dynamic keys, which can possibly contain
21397 // "type".
21398 directiveToUse = V_MODEL_DYNAMIC;
21399 }
21400 else {
21401 // text type
21402 checkDuplicatedValue();
21403 }
21404 }
21405 else if (tag === 'select') {
21406 directiveToUse = V_MODEL_SELECT;
21407 }
21408 else {
21409 // textarea
21410 checkDuplicatedValue();
21411 }
21412 // inject runtime directive
21413 // by returning the helper symbol via needRuntime
21414 // the import will replaced a resolveDirective call.
21415 if (!isInvalidType) {
21416 baseResult.needRuntime = context.helper(directiveToUse);
21417 }
21418 }
21419 else {
21420 context.onError(createDOMCompilerError(54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
21421 }
21422 // native vmodel doesn't need the `modelValue` props since they are also
21423 // passed to the runtime as `binding.value`. removing it reduces code size.
21424 baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
21425 p.key.content === 'modelValue'));
21426 return baseResult;
21427};
21428
21429const isEventOptionModifier = /*#__PURE__*/ makeMap(`passive,once,capture`);
21430const isNonKeyModifier = /*#__PURE__*/ makeMap(
21431// event propagation management
21432`stop,prevent,self,` +
21433 // system modifiers + exact
21434 `ctrl,shift,alt,meta,exact,` +
21435 // mouse
21436 `middle`);
21437// left & right could be mouse or key modifiers based on event type
21438const maybeKeyModifier = /*#__PURE__*/ makeMap('left,right');
21439const isKeyboardEvent = /*#__PURE__*/ makeMap(`onkeyup,onkeydown,onkeypress`, true);
21440const resolveModifiers = (key, modifiers, context, loc) => {
21441 const keyModifiers = [];
21442 const nonKeyModifiers = [];
21443 const eventOptionModifiers = [];
21444 for (let i = 0; i < modifiers.length; i++) {
21445 const modifier = modifiers[i];
21446 if (modifier === 'native' &&
21447 checkCompatEnabled$1("COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */, context, loc)) {
21448 eventOptionModifiers.push(modifier);
21449 }
21450 else if (isEventOptionModifier(modifier)) {
21451 // eventOptionModifiers: modifiers for addEventListener() options,
21452 // e.g. .passive & .capture
21453 eventOptionModifiers.push(modifier);
21454 }
21455 else {
21456 // runtimeModifiers: modifiers that needs runtime guards
21457 if (maybeKeyModifier(modifier)) {
21458 if (isStaticExp(key)) {
21459 if (isKeyboardEvent(key.content)) {
21460 keyModifiers.push(modifier);
21461 }
21462 else {
21463 nonKeyModifiers.push(modifier);
21464 }
21465 }
21466 else {
21467 keyModifiers.push(modifier);
21468 nonKeyModifiers.push(modifier);
21469 }
21470 }
21471 else {
21472 if (isNonKeyModifier(modifier)) {
21473 nonKeyModifiers.push(modifier);
21474 }
21475 else {
21476 keyModifiers.push(modifier);
21477 }
21478 }
21479 }
21480 }
21481 return {
21482 keyModifiers,
21483 nonKeyModifiers,
21484 eventOptionModifiers
21485 };
21486};
21487const transformClick = (key, event) => {
21488 const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === 'onclick';
21489 return isStaticClick
21490 ? createSimpleExpression(event, true)
21491 : key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */
21492 ? createCompoundExpression([
21493 `(`,
21494 key,
21495 `) === "onClick" ? "${event}" : (`,
21496 key,
21497 `)`
21498 ])
21499 : key;
21500};
21501const transformOn$1 = (dir, node, context) => {
21502 return transformOn(dir, node, context, baseResult => {
21503 const { modifiers } = dir;
21504 if (!modifiers.length)
21505 return baseResult;
21506 let { key, value: handlerExp } = baseResult.props[0];
21507 const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
21508 // normalize click.right and click.middle since they don't actually fire
21509 if (nonKeyModifiers.includes('right')) {
21510 key = transformClick(key, `onContextmenu`);
21511 }
21512 if (nonKeyModifiers.includes('middle')) {
21513 key = transformClick(key, `onMouseup`);
21514 }
21515 if (nonKeyModifiers.length) {
21516 handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
21517 handlerExp,
21518 JSON.stringify(nonKeyModifiers)
21519 ]);
21520 }
21521 if (keyModifiers.length &&
21522 // if event name is dynamic, always wrap with keys guard
21523 (!isStaticExp(key) || isKeyboardEvent(key.content))) {
21524 handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
21525 handlerExp,
21526 JSON.stringify(keyModifiers)
21527 ]);
21528 }
21529 if (eventOptionModifiers.length) {
21530 const modifierPostfix = eventOptionModifiers.map(capitalize).join('');
21531 key = isStaticExp(key)
21532 ? createSimpleExpression(`${key.content}${modifierPostfix}`, true)
21533 : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
21534 }
21535 return {
21536 props: [createObjectProperty(key, handlerExp)]
21537 };
21538 });
21539};
21540
21541const transformShow = (dir, node, context) => {
21542 const { exp, loc } = dir;
21543 if (!exp) {
21544 context.onError(createDOMCompilerError(58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */, loc));
21545 }
21546 return {
21547 props: [],
21548 needRuntime: context.helper(V_SHOW)
21549 };
21550};
21551
21552const transformTransition = (node, context) => {
21553 if (node.type === 1 /* NodeTypes.ELEMENT */ &&
21554 node.tagType === 1 /* ElementTypes.COMPONENT */) {
21555 const component = context.isBuiltInComponent(node.tag);
21556 if (component === TRANSITION$1) {
21557 return () => {
21558 if (!node.children.length) {
21559 return;
21560 }
21561 // warn multiple transition children
21562 if (hasMultipleChildren(node)) {
21563 context.onError(createDOMCompilerError(59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */, {
21564 start: node.children[0].loc.start,
21565 end: node.children[node.children.length - 1].loc.end,
21566 source: ''
21567 }));
21568 }
21569 // check if it's s single child w/ v-show
21570 // if yes, inject "persisted: true" to the transition props
21571 const child = node.children[0];
21572 if (child.type === 1 /* NodeTypes.ELEMENT */) {
21573 for (const p of child.props) {
21574 if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'show') {
21575 node.props.push({
21576 type: 6 /* NodeTypes.ATTRIBUTE */,
21577 name: 'persisted',
21578 value: undefined,
21579 loc: node.loc
21580 });
21581 }
21582 }
21583 }
21584 };
21585 }
21586 }
21587};
21588function hasMultipleChildren(node) {
21589 // #1352 filter out potential comment nodes.
21590 const children = (node.children = node.children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */ &&
21591 !(c.type === 2 /* NodeTypes.TEXT */ && !c.content.trim())));
21592 const child = children[0];
21593 return (children.length !== 1 ||
21594 child.type === 11 /* NodeTypes.FOR */ ||
21595 (child.type === 9 /* NodeTypes.IF */ && child.branches.some(hasMultipleChildren)));
21596}
21597
21598/**
21599 * This module is Node-only.
21600 */
21601/**
21602 * Regex for replacing placeholders for embedded constant variables
21603 * (e.g. import URL string constants generated by compiler-sfc)
21604 */
21605const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
21606/**
21607 * Turn eligible hoisted static trees into stringified static nodes, e.g.
21608 *
21609 * ```js
21610 * const _hoisted_1 = createStaticVNode(`<div class="foo">bar</div>`)
21611 * ```
21612 *
21613 * A single static vnode can contain stringified content for **multiple**
21614 * consecutive nodes (element and plain text), called a "chunk".
21615 * `@vue/runtime-dom` will create the content via innerHTML in a hidden
21616 * container element and insert all the nodes in place. The call must also
21617 * provide the number of nodes contained in the chunk so that during hydration
21618 * we can know how many nodes the static vnode should adopt.
21619 *
21620 * The optimization scans a children list that contains hoisted nodes, and
21621 * tries to find the largest chunk of consecutive hoisted nodes before running
21622 * into a non-hoisted node or the end of the list. A chunk is then converted
21623 * into a single static vnode and replaces the hoisted expression of the first
21624 * node in the chunk. Other nodes in the chunk are considered "merged" and
21625 * therefore removed from both the hoist list and the children array.
21626 *
21627 * This optimization is only performed in Node.js.
21628 */
21629const stringifyStatic = (children, context, parent) => {
21630 // bail stringification for slot content
21631 if (context.scopes.vSlot > 0) {
21632 return;
21633 }
21634 let nc = 0; // current node count
21635 let ec = 0; // current element with binding count
21636 const currentChunk = [];
21637 const stringifyCurrentChunk = (currentIndex) => {
21638 if (nc >= 20 /* StringifyThresholds.NODE_COUNT */ ||
21639 ec >= 5 /* StringifyThresholds.ELEMENT_WITH_BINDING_COUNT */) {
21640 // combine all currently eligible nodes into a single static vnode call
21641 const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
21642 JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
21643 // the 2nd argument indicates the number of DOM nodes this static vnode
21644 // will insert / hydrate
21645 String(currentChunk.length)
21646 ]);
21647 // replace the first node's hoisted expression with the static vnode call
21648 replaceHoist(currentChunk[0], staticCall, context);
21649 if (currentChunk.length > 1) {
21650 for (let i = 1; i < currentChunk.length; i++) {
21651 // for the merged nodes, set their hoisted expression to null
21652 replaceHoist(currentChunk[i], null, context);
21653 }
21654 // also remove merged nodes from children
21655 const deleteCount = currentChunk.length - 1;
21656 children.splice(currentIndex - currentChunk.length + 1, deleteCount);
21657 return deleteCount;
21658 }
21659 }
21660 return 0;
21661 };
21662 let i = 0;
21663 for (; i < children.length; i++) {
21664 const child = children[i];
21665 const hoisted = getHoistedNode(child);
21666 if (hoisted) {
21667 // presence of hoisted means child must be a stringifiable node
21668 const node = child;
21669 const result = analyzeNode(node);
21670 if (result) {
21671 // node is stringifiable, record state
21672 nc += result[0];
21673 ec += result[1];
21674 currentChunk.push(node);
21675 continue;
21676 }
21677 }
21678 // we only reach here if we ran into a node that is not stringifiable
21679 // check if currently analyzed nodes meet criteria for stringification.
21680 // adjust iteration index
21681 i -= stringifyCurrentChunk(i);
21682 // reset state
21683 nc = 0;
21684 ec = 0;
21685 currentChunk.length = 0;
21686 }
21687 // in case the last node was also stringifiable
21688 stringifyCurrentChunk(i);
21689};
21690const getHoistedNode = (node) => ((node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 0 /* ElementTypes.ELEMENT */) ||
21691 node.type == 12 /* NodeTypes.TEXT_CALL */) &&
21692 node.codegenNode &&
21693 node.codegenNode.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
21694 node.codegenNode.hoisted;
21695const dataAriaRE = /^(data|aria)-/;
21696const isStringifiableAttr = (name, ns) => {
21697 return ((ns === 0 /* DOMNamespaces.HTML */
21698 ? isKnownHtmlAttr(name)
21699 : ns === 1 /* DOMNamespaces.SVG */
21700 ? isKnownSvgAttr(name)
21701 : false) || dataAriaRE.test(name));
21702};
21703const replaceHoist = (node, replacement, context) => {
21704 const hoistToReplace = node.codegenNode.hoisted;
21705 context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
21706};
21707const isNonStringifiable = /*#__PURE__*/ makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
21708/**
21709 * for a hoisted node, analyze it and return:
21710 * - false: bailed (contains non-stringifiable props or runtime constant)
21711 * - [nc, ec] where
21712 * - nc is the number of nodes inside
21713 * - ec is the number of element with bindings inside
21714 */
21715function analyzeNode(node) {
21716 if (node.type === 1 /* NodeTypes.ELEMENT */ && isNonStringifiable(node.tag)) {
21717 return false;
21718 }
21719 if (node.type === 12 /* NodeTypes.TEXT_CALL */) {
21720 return [1, 0];
21721 }
21722 let nc = 1; // node count
21723 let ec = node.props.length > 0 ? 1 : 0; // element w/ binding count
21724 let bailed = false;
21725 const bail = () => {
21726 bailed = true;
21727 return false;
21728 };
21729 // TODO: check for cases where using innerHTML will result in different
21730 // output compared to imperative node insertions.
21731 // probably only need to check for most common case
21732 // i.e. non-phrasing-content tags inside `<p>`
21733 function walk(node) {
21734 for (let i = 0; i < node.props.length; i++) {
21735 const p = node.props[i];
21736 // bail on non-attr bindings
21737 if (p.type === 6 /* NodeTypes.ATTRIBUTE */ &&
21738 !isStringifiableAttr(p.name, node.ns)) {
21739 return bail();
21740 }
21741 if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind') {
21742 // bail on non-attr bindings
21743 if (p.arg &&
21744 (p.arg.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
21745 (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
21746 return bail();
21747 }
21748 if (p.exp &&
21749 (p.exp.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
21750 p.exp.constType < 3 /* ConstantTypes.CAN_STRINGIFY */)) {
21751 return bail();
21752 }
21753 }
21754 }
21755 for (let i = 0; i < node.children.length; i++) {
21756 nc++;
21757 const child = node.children[i];
21758 if (child.type === 1 /* NodeTypes.ELEMENT */) {
21759 if (child.props.length > 0) {
21760 ec++;
21761 }
21762 walk(child);
21763 if (bailed) {
21764 return false;
21765 }
21766 }
21767 }
21768 return true;
21769 }
21770 return walk(node) ? [nc, ec] : false;
21771}
21772function stringifyNode(node, context) {
21773 if (isString(node)) {
21774 return node;
21775 }
21776 if (isSymbol(node)) {
21777 return ``;
21778 }
21779 switch (node.type) {
21780 case 1 /* NodeTypes.ELEMENT */:
21781 return stringifyElement(node, context);
21782 case 2 /* NodeTypes.TEXT */:
21783 return escapeHtml(node.content);
21784 case 3 /* NodeTypes.COMMENT */:
21785 return `<!--${escapeHtml(node.content)}-->`;
21786 case 5 /* NodeTypes.INTERPOLATION */:
21787 return escapeHtml(toDisplayString(evaluateConstant(node.content)));
21788 case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
21789 return escapeHtml(evaluateConstant(node));
21790 case 12 /* NodeTypes.TEXT_CALL */:
21791 return stringifyNode(node.content, context);
21792 default:
21793 // static trees will not contain if/for nodes
21794 return '';
21795 }
21796}
21797function stringifyElement(node, context) {
21798 let res = `<${node.tag}`;
21799 let innerHTML = '';
21800 for (let i = 0; i < node.props.length; i++) {
21801 const p = node.props[i];
21802 if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
21803 res += ` ${p.name}`;
21804 if (p.value) {
21805 res += `="${escapeHtml(p.value.content)}"`;
21806 }
21807 }
21808 else if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
21809 if (p.name === 'bind') {
21810 const exp = p.exp;
21811 if (exp.content[0] === '_') {
21812 // internally generated string constant references
21813 // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
21814 res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
21815 continue;
21816 }
21817 // constant v-bind, e.g. :foo="1"
21818 let evaluated = evaluateConstant(exp);
21819 if (evaluated != null) {
21820 const arg = p.arg && p.arg.content;
21821 if (arg === 'class') {
21822 evaluated = normalizeClass(evaluated);
21823 }
21824 else if (arg === 'style') {
21825 evaluated = stringifyStyle(normalizeStyle(evaluated));
21826 }
21827 res += ` ${p.arg.content}="${escapeHtml(evaluated)}"`;
21828 }
21829 }
21830 else if (p.name === 'html') {
21831 // #5439 v-html with constant value
21832 // not sure why would anyone do this but it can happen
21833 innerHTML = evaluateConstant(p.exp);
21834 }
21835 else if (p.name === 'text') {
21836 innerHTML = escapeHtml(toDisplayString(evaluateConstant(p.exp)));
21837 }
21838 }
21839 }
21840 if (context.scopeId) {
21841 res += ` ${context.scopeId}`;
21842 }
21843 res += `>`;
21844 if (innerHTML) {
21845 res += innerHTML;
21846 }
21847 else {
21848 for (let i = 0; i < node.children.length; i++) {
21849 res += stringifyNode(node.children[i], context);
21850 }
21851 }
21852 if (!isVoidTag(node.tag)) {
21853 res += `</${node.tag}>`;
21854 }
21855 return res;
21856}
21857// __UNSAFE__
21858// Reason: eval.
21859// It's technically safe to eval because only constant expressions are possible
21860// here, e.g. `{{ 1 }}` or `{{ 'foo' }}`
21861// in addition, constant exps bail on presence of parens so you can't even
21862// run JSFuck in here. But we mark it unsafe for security review purposes.
21863// (see compiler-core/src/transforms/transformExpression)
21864function evaluateConstant(exp) {
21865 if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
21866 return new Function(`return ${exp.content}`)();
21867 }
21868 else {
21869 // compound
21870 let res = ``;
21871 exp.children.forEach(c => {
21872 if (isString(c) || isSymbol(c)) {
21873 return;
21874 }
21875 if (c.type === 2 /* NodeTypes.TEXT */) {
21876 res += c.content;
21877 }
21878 else if (c.type === 5 /* NodeTypes.INTERPOLATION */) {
21879 res += toDisplayString(evaluateConstant(c.content));
21880 }
21881 else {
21882 res += evaluateConstant(c);
21883 }
21884 });
21885 return res;
21886 }
21887}
21888
21889const ignoreSideEffectTags = (node, context) => {
21890 if (node.type === 1 /* NodeTypes.ELEMENT */ &&
21891 node.tagType === 0 /* ElementTypes.ELEMENT */ &&
21892 (node.tag === 'script' || node.tag === 'style')) {
21893 context.onError(createDOMCompilerError(60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
21894 context.removeNode();
21895 }
21896};
21897
21898const DOMNodeTransforms = [
21899 transformStyle,
21900 ...([transformTransition] )
21901];
21902const DOMDirectiveTransforms = {
21903 cloak: noopDirectiveTransform,
21904 html: transformVHtml,
21905 text: transformVText,
21906 model: transformModel$1,
21907 on: transformOn$1,
21908 show: transformShow
21909};
21910function compile$1(template, options = {}) {
21911 return baseCompile(template, extend({}, parserOptions, options, {
21912 nodeTransforms: [
21913 // ignore <script> and <tag>
21914 // this is not put inside DOMNodeTransforms because that list is used
21915 // by compiler-ssr to generate vnode fallback branches
21916 ignoreSideEffectTags,
21917 ...DOMNodeTransforms,
21918 ...(options.nodeTransforms || [])
21919 ],
21920 directiveTransforms: extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
21921 transformHoist: stringifyStatic
21922 }));
21923}
21924
21925// This entry is the "full-build" that includes both the runtime
21926const compileCache = Object.create(null);
21927function compileToFunction(template, options) {
21928 if (!isString(template)) {
21929 if (template.nodeType) {
21930 template = template.innerHTML;
21931 }
21932 else {
21933 warn$1(`invalid template option: `, template);
21934 return NOOP;
21935 }
21936 }
21937 const key = template;
21938 const cached = compileCache[key];
21939 if (cached) {
21940 return cached;
21941 }
21942 if (template[0] === '#') {
21943 const el = document.querySelector(template);
21944 if (!el) {
21945 warn$1(`Template element not found or is empty: ${template}`);
21946 }
21947 // __UNSAFE__
21948 // Reason: potential execution of JS expressions in in-DOM template.
21949 // The user must make sure the in-DOM template is trusted. If it's rendered
21950 // by the server, the template should not contain any user data.
21951 template = el ? el.innerHTML : ``;
21952 }
21953 if ((!options || !options.whitespace)) {
21954 warnDeprecation("CONFIG_WHITESPACE" /* DeprecationTypes.CONFIG_WHITESPACE */, null);
21955 }
21956 const { code } = compile$1(template, extend({
21957 hoistStatic: true,
21958 whitespace: 'preserve',
21959 onError: onError ,
21960 onWarn: e => onError(e, true)
21961 }, options));
21962 function onError(err, asWarning = false) {
21963 const message = asWarning
21964 ? err.message
21965 : `Template compilation error: ${err.message}`;
21966 const codeFrame = err.loc &&
21967 generateCodeFrame(template, err.loc.start.offset, err.loc.end.offset);
21968 warn$1(codeFrame ? `${message}\n${codeFrame}` : message);
21969 }
21970 // The wildcard import results in a huge object with every export
21971 // with keys that cannot be mangled, and can be quite heavy size-wise.
21972 // In the global build we know `Vue` is available globally so we can avoid
21973 // the wildcard object.
21974 const render = (new Function('Vue', code)(runtimeDom));
21975 render._rc = true;
21976 return (compileCache[key] = render);
21977}
21978registerRuntimeCompiler(compileToFunction);
21979const Vue = createCompatVue$1();
21980Vue.compile = compileToFunction;
21981
21982module.exports = Vue;