tmvue

修改的vue

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/476865/1262815/tmvue.js

  1. /**
  2. * 简单修改兼容了油猴require
  3. */
  4. let WinVue = null
  5. try {
  6. WinVue = unsafeWindow
  7. } catch (err) {
  8. WinVue = window
  9.  
  10. }
  11. /**
  12. * Minified by jsDelivr using Terser v5.7.1.
  13. * Original file: /npm/vue@3.2.16/dist/vue.global.js
  14. *
  15. * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
  16. */
  17. WinVue.myVue = (function (exports) {
  18. 'use strict';
  19.  
  20. function makeMap(str, expectsLowerCase) {
  21. const map = /* @__PURE__ */ Object.create(null);
  22. const list = str.split(",");
  23. for (let i = 0; i < list.length; i++) {
  24. map[list[i]] = true;
  25. }
  26. return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
  27. }
  28.  
  29. const EMPTY_OBJ = Object.freeze({}) ;
  30. const EMPTY_ARR = Object.freeze([]) ;
  31. const NOOP = () => {
  32. };
  33. const NO = () => false;
  34. const onRE = /^on[^a-z]/;
  35. const isOn = (key) => onRE.test(key);
  36. const isModelListener = (key) => key.startsWith("onUpdate:");
  37. const extend = Object.assign;
  38. const remove = (arr, el) => {
  39. const i = arr.indexOf(el);
  40. if (i > -1) {
  41. arr.splice(i, 1);
  42. }
  43. };
  44. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  45. const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
  46. const isArray = Array.isArray;
  47. const isMap = (val) => toTypeString(val) === "[object Map]";
  48. const isSet = (val) => toTypeString(val) === "[object Set]";
  49. const isDate = (val) => toTypeString(val) === "[object Date]";
  50. const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
  51. const isFunction = (val) => typeof val === "function";
  52. const isString = (val) => typeof val === "string";
  53. const isSymbol = (val) => typeof val === "symbol";
  54. const isObject = (val) => val !== null && typeof val === "object";
  55. const isPromise = (val) => {
  56. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  57. };
  58. const objectToString = Object.prototype.toString;
  59. const toTypeString = (value) => objectToString.call(value);
  60. const toRawType = (value) => {
  61. return toTypeString(value).slice(8, -1);
  62. };
  63. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  64. const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  65. const isReservedProp = /* @__PURE__ */ makeMap(
  66. // the leading comma is intentional so empty string "" is also included
  67. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  68. );
  69. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  70. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  71. );
  72. const cacheStringFunction = (fn) => {
  73. const cache = /* @__PURE__ */ Object.create(null);
  74. return (str) => {
  75. const hit = cache[str];
  76. return hit || (cache[str] = fn(str));
  77. };
  78. };
  79. const camelizeRE = /-(\w)/g;
  80. const camelize = cacheStringFunction((str) => {
  81. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  82. });
  83. const hyphenateRE = /\B([A-Z])/g;
  84. const hyphenate = cacheStringFunction(
  85. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  86. );
  87. const capitalize = cacheStringFunction(
  88. (str) => str.charAt(0).toUpperCase() + str.slice(1)
  89. );
  90. const toHandlerKey = cacheStringFunction(
  91. (str) => str ? `on${capitalize(str)}` : ``
  92. );
  93. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  94. const invokeArrayFns = (fns, arg) => {
  95. for (let i = 0; i < fns.length; i++) {
  96. fns[i](arg);
  97. }
  98. };
  99. const def = (obj, key, value) => {
  100. Object.defineProperty(obj, key, {
  101. configurable: true,
  102. enumerable: false,
  103. value
  104. });
  105. };
  106. const looseToNumber = (val) => {
  107. const n = parseFloat(val);
  108. return isNaN(n) ? val : n;
  109. };
  110. const toNumber = (val) => {
  111. const n = isString(val) ? Number(val) : NaN;
  112. return isNaN(n) ? val : n;
  113. };
  114. let _globalThis;
  115. const getGlobalThis = () => {
  116. return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
  117. };
  118.  
  119. const PatchFlagNames = {
  120. [1]: `TEXT`,
  121. [2]: `CLASS`,
  122. [4]: `STYLE`,
  123. [8]: `PROPS`,
  124. [16]: `FULL_PROPS`,
  125. [32]: `HYDRATE_EVENTS`,
  126. [64]: `STABLE_FRAGMENT`,
  127. [128]: `KEYED_FRAGMENT`,
  128. [256]: `UNKEYED_FRAGMENT`,
  129. [512]: `NEED_PATCH`,
  130. [1024]: `DYNAMIC_SLOTS`,
  131. [2048]: `DEV_ROOT_FRAGMENT`,
  132. [-1]: `HOISTED`,
  133. [-2]: `BAIL`
  134. };
  135.  
  136. const slotFlagsText = {
  137. [1]: "STABLE",
  138. [2]: "DYNAMIC",
  139. [3]: "FORWARDED"
  140. };
  141.  
  142. const GLOBALS_WHITE_LISTED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console";
  143. const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
  144.  
  145. const range = 2;
  146. function generateCodeFrame(source, start = 0, end = source.length) {
  147. let lines = source.split(/(\r?\n)/);
  148. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  149. lines = lines.filter((_, idx) => idx % 2 === 0);
  150. let count = 0;
  151. const res = [];
  152. for (let i = 0; i < lines.length; i++) {
  153. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  154. if (count >= start) {
  155. for (let j = i - range; j <= i + range || end > count; j++) {
  156. if (j < 0 || j >= lines.length)
  157. continue;
  158. const line = j + 1;
  159. res.push(
  160. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  161. );
  162. const lineLength = lines[j].length;
  163. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  164. if (j === i) {
  165. const pad = start - (count - (lineLength + newLineSeqLength));
  166. const length = Math.max(
  167. 1,
  168. end > count ? lineLength - pad : end - start
  169. );
  170. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  171. } else if (j > i) {
  172. if (end > count) {
  173. const length = Math.max(Math.min(end - count, lineLength), 1);
  174. res.push(` | ` + "^".repeat(length));
  175. }
  176. count += lineLength + newLineSeqLength;
  177. }
  178. }
  179. break;
  180. }
  181. }
  182. return res.join("\n");
  183. }
  184.  
  185. function normalizeStyle(value) {
  186. if (isArray(value)) {
  187. const res = {};
  188. for (let i = 0; i < value.length; i++) {
  189. const item = value[i];
  190. const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
  191. if (normalized) {
  192. for (const key in normalized) {
  193. res[key] = normalized[key];
  194. }
  195. }
  196. }
  197. return res;
  198. } else if (isString(value)) {
  199. return value;
  200. } else if (isObject(value)) {
  201. return value;
  202. }
  203. }
  204. const listDelimiterRE = /;(?![^(]*\))/g;
  205. const propertyDelimiterRE = /:([^]+)/;
  206. const styleCommentRE = /\/\*[^]*?\*\//g;
  207. function parseStringStyle(cssText) {
  208. const ret = {};
  209. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  210. if (item) {
  211. const tmp = item.split(propertyDelimiterRE);
  212. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  213. }
  214. });
  215. return ret;
  216. }
  217. function normalizeClass(value) {
  218. let res = "";
  219. if (isString(value)) {
  220. res = value;
  221. } else if (isArray(value)) {
  222. for (let i = 0; i < value.length; i++) {
  223. const normalized = normalizeClass(value[i]);
  224. if (normalized) {
  225. res += normalized + " ";
  226. }
  227. }
  228. } else if (isObject(value)) {
  229. for (const name in value) {
  230. if (value[name]) {
  231. res += name + " ";
  232. }
  233. }
  234. }
  235. return res.trim();
  236. }
  237. function normalizeProps(props) {
  238. if (!props)
  239. return null;
  240. let { class: klass, style } = props;
  241. if (klass && !isString(klass)) {
  242. props.class = normalizeClass(klass);
  243. }
  244. if (style) {
  245. props.style = normalizeStyle(style);
  246. }
  247. return props;
  248. }
  249.  
  250. const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  251. const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
  252. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  253. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  254. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  255. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  256.  
  257. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  258. const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
  259. function includeBooleanAttr(value) {
  260. return !!value || value === "";
  261. }
  262.  
  263. function looseCompareArrays(a, b) {
  264. if (a.length !== b.length)
  265. return false;
  266. let equal = true;
  267. for (let i = 0; equal && i < a.length; i++) {
  268. equal = looseEqual(a[i], b[i]);
  269. }
  270. return equal;
  271. }
  272. function looseEqual(a, b) {
  273. if (a === b)
  274. return true;
  275. let aValidType = isDate(a);
  276. let bValidType = isDate(b);
  277. if (aValidType || bValidType) {
  278. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  279. }
  280. aValidType = isSymbol(a);
  281. bValidType = isSymbol(b);
  282. if (aValidType || bValidType) {
  283. return a === b;
  284. }
  285. aValidType = isArray(a);
  286. bValidType = isArray(b);
  287. if (aValidType || bValidType) {
  288. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  289. }
  290. aValidType = isObject(a);
  291. bValidType = isObject(b);
  292. if (aValidType || bValidType) {
  293. if (!aValidType || !bValidType) {
  294. return false;
  295. }
  296. const aKeysCount = Object.keys(a).length;
  297. const bKeysCount = Object.keys(b).length;
  298. if (aKeysCount !== bKeysCount) {
  299. return false;
  300. }
  301. for (const key in a) {
  302. const aHasKey = a.hasOwnProperty(key);
  303. const bHasKey = b.hasOwnProperty(key);
  304. if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
  305. return false;
  306. }
  307. }
  308. }
  309. return String(a) === String(b);
  310. }
  311. function looseIndexOf(arr, val) {
  312. return arr.findIndex((item) => looseEqual(item, val));
  313. }
  314.  
  315. const toDisplayString = (val) => {
  316. return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
  317. };
  318. const replacer = (_key, val) => {
  319. if (val && val.__v_isRef) {
  320. return replacer(_key, val.value);
  321. } else if (isMap(val)) {
  322. return {
  323. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2]) => {
  324. entries[`${key} =>`] = val2;
  325. return entries;
  326. }, {})
  327. };
  328. } else if (isSet(val)) {
  329. return {
  330. [`Set(${val.size})`]: [...val.values()]
  331. };
  332. } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  333. return String(val);
  334. }
  335. return val;
  336. };
  337.  
  338. function warn$1(msg, ...args) {
  339. console.warn(`[Vue warn] ${msg}`, ...args);
  340. }
  341.  
  342. let activeEffectScope;
  343. class EffectScope {
  344. constructor(detached = false) {
  345. this.detached = detached;
  346. /**
  347. * @internal
  348. */
  349. this._active = true;
  350. /**
  351. * @internal
  352. */
  353. this.effects = [];
  354. /**
  355. * @internal
  356. */
  357. this.cleanups = [];
  358. this.parent = activeEffectScope;
  359. if (!detached && activeEffectScope) {
  360. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  361. this
  362. ) - 1;
  363. }
  364. }
  365. get active() {
  366. return this._active;
  367. }
  368. run(fn) {
  369. if (this._active) {
  370. const currentEffectScope = activeEffectScope;
  371. try {
  372. activeEffectScope = this;
  373. return fn();
  374. } finally {
  375. activeEffectScope = currentEffectScope;
  376. }
  377. } else {
  378. warn$1(`cannot run an inactive effect scope.`);
  379. }
  380. }
  381. /**
  382. * This should only be called on non-detached scopes
  383. * @internal
  384. */
  385. on() {
  386. activeEffectScope = this;
  387. }
  388. /**
  389. * This should only be called on non-detached scopes
  390. * @internal
  391. */
  392. off() {
  393. activeEffectScope = this.parent;
  394. }
  395. stop(fromParent) {
  396. if (this._active) {
  397. let i, l;
  398. for (i = 0, l = this.effects.length; i < l; i++) {
  399. this.effects[i].stop();
  400. }
  401. for (i = 0, l = this.cleanups.length; i < l; i++) {
  402. this.cleanups[i]();
  403. }
  404. if (this.scopes) {
  405. for (i = 0, l = this.scopes.length; i < l; i++) {
  406. this.scopes[i].stop(true);
  407. }
  408. }
  409. if (!this.detached && this.parent && !fromParent) {
  410. const last = this.parent.scopes.pop();
  411. if (last && last !== this) {
  412. this.parent.scopes[this.index] = last;
  413. last.index = this.index;
  414. }
  415. }
  416. this.parent = void 0;
  417. this._active = false;
  418. }
  419. }
  420. }
  421. function effectScope(detached) {
  422. return new EffectScope(detached);
  423. }
  424. function recordEffectScope(effect, scope = activeEffectScope) {
  425. if (scope && scope.active) {
  426. scope.effects.push(effect);
  427. }
  428. }
  429. function getCurrentScope() {
  430. return activeEffectScope;
  431. }
  432. function onScopeDispose(fn) {
  433. if (activeEffectScope) {
  434. activeEffectScope.cleanups.push(fn);
  435. } else {
  436. warn$1(
  437. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  438. );
  439. }
  440. }
  441.  
  442. const createDep = (effects) => {
  443. const dep = new Set(effects);
  444. dep.w = 0;
  445. dep.n = 0;
  446. return dep;
  447. };
  448. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  449. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  450. const initDepMarkers = ({ deps }) => {
  451. if (deps.length) {
  452. for (let i = 0; i < deps.length; i++) {
  453. deps[i].w |= trackOpBit;
  454. }
  455. }
  456. };
  457. const finalizeDepMarkers = (effect) => {
  458. const { deps } = effect;
  459. if (deps.length) {
  460. let ptr = 0;
  461. for (let i = 0; i < deps.length; i++) {
  462. const dep = deps[i];
  463. if (wasTracked(dep) && !newTracked(dep)) {
  464. dep.delete(effect);
  465. } else {
  466. deps[ptr++] = dep;
  467. }
  468. dep.w &= ~trackOpBit;
  469. dep.n &= ~trackOpBit;
  470. }
  471. deps.length = ptr;
  472. }
  473. };
  474.  
  475. const targetMap = /* @__PURE__ */ new WeakMap();
  476. let effectTrackDepth = 0;
  477. let trackOpBit = 1;
  478. const maxMarkerBits = 30;
  479. let activeEffect;
  480. const ITERATE_KEY = Symbol("iterate" );
  481. const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
  482. class ReactiveEffect {
  483. constructor(fn, scheduler = null, scope) {
  484. this.fn = fn;
  485. this.scheduler = scheduler;
  486. this.active = true;
  487. this.deps = [];
  488. this.parent = void 0;
  489. recordEffectScope(this, scope);
  490. }
  491. run() {
  492. if (!this.active) {
  493. return this.fn();
  494. }
  495. let parent = activeEffect;
  496. let lastShouldTrack = shouldTrack;
  497. while (parent) {
  498. if (parent === this) {
  499. return;
  500. }
  501. parent = parent.parent;
  502. }
  503. try {
  504. this.parent = activeEffect;
  505. activeEffect = this;
  506. shouldTrack = true;
  507. trackOpBit = 1 << ++effectTrackDepth;
  508. if (effectTrackDepth <= maxMarkerBits) {
  509. initDepMarkers(this);
  510. } else {
  511. cleanupEffect(this);
  512. }
  513. return this.fn();
  514. } finally {
  515. if (effectTrackDepth <= maxMarkerBits) {
  516. finalizeDepMarkers(this);
  517. }
  518. trackOpBit = 1 << --effectTrackDepth;
  519. activeEffect = this.parent;
  520. shouldTrack = lastShouldTrack;
  521. this.parent = void 0;
  522. if (this.deferStop) {
  523. this.stop();
  524. }
  525. }
  526. }
  527. stop() {
  528. if (activeEffect === this) {
  529. this.deferStop = true;
  530. } else if (this.active) {
  531. cleanupEffect(this);
  532. if (this.onStop) {
  533. this.onStop();
  534. }
  535. this.active = false;
  536. }
  537. }
  538. }
  539. function cleanupEffect(effect2) {
  540. const { deps } = effect2;
  541. if (deps.length) {
  542. for (let i = 0; i < deps.length; i++) {
  543. deps[i].delete(effect2);
  544. }
  545. deps.length = 0;
  546. }
  547. }
  548. function effect(fn, options) {
  549. if (fn.effect) {
  550. fn = fn.effect.fn;
  551. }
  552. const _effect = new ReactiveEffect(fn);
  553. if (options) {
  554. extend(_effect, options);
  555. if (options.scope)
  556. recordEffectScope(_effect, options.scope);
  557. }
  558. if (!options || !options.lazy) {
  559. _effect.run();
  560. }
  561. const runner = _effect.run.bind(_effect);
  562. runner.effect = _effect;
  563. return runner;
  564. }
  565. function stop(runner) {
  566. runner.effect.stop();
  567. }
  568. let shouldTrack = true;
  569. const trackStack = [];
  570. function pauseTracking() {
  571. trackStack.push(shouldTrack);
  572. shouldTrack = false;
  573. }
  574. function resetTracking() {
  575. const last = trackStack.pop();
  576. shouldTrack = last === void 0 ? true : last;
  577. }
  578. function track(target, type, key) {
  579. if (shouldTrack && activeEffect) {
  580. let depsMap = targetMap.get(target);
  581. if (!depsMap) {
  582. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  583. }
  584. let dep = depsMap.get(key);
  585. if (!dep) {
  586. depsMap.set(key, dep = createDep());
  587. }
  588. const eventInfo = { effect: activeEffect, target, type, key } ;
  589. trackEffects(dep, eventInfo);
  590. }
  591. }
  592. function trackEffects(dep, debuggerEventExtraInfo) {
  593. let shouldTrack2 = false;
  594. if (effectTrackDepth <= maxMarkerBits) {
  595. if (!newTracked(dep)) {
  596. dep.n |= trackOpBit;
  597. shouldTrack2 = !wasTracked(dep);
  598. }
  599. } else {
  600. shouldTrack2 = !dep.has(activeEffect);
  601. }
  602. if (shouldTrack2) {
  603. dep.add(activeEffect);
  604. activeEffect.deps.push(dep);
  605. if (activeEffect.onTrack) {
  606. activeEffect.onTrack(
  607. extend(
  608. {
  609. effect: activeEffect
  610. },
  611. debuggerEventExtraInfo
  612. )
  613. );
  614. }
  615. }
  616. }
  617. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  618. const depsMap = targetMap.get(target);
  619. if (!depsMap) {
  620. return;
  621. }
  622. let deps = [];
  623. if (type === "clear") {
  624. deps = [...depsMap.values()];
  625. } else if (key === "length" && isArray(target)) {
  626. const newLength = Number(newValue);
  627. depsMap.forEach((dep, key2) => {
  628. if (key2 === "length" || key2 >= newLength) {
  629. deps.push(dep);
  630. }
  631. });
  632. } else {
  633. if (key !== void 0) {
  634. deps.push(depsMap.get(key));
  635. }
  636. switch (type) {
  637. case "add":
  638. if (!isArray(target)) {
  639. deps.push(depsMap.get(ITERATE_KEY));
  640. if (isMap(target)) {
  641. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  642. }
  643. } else if (isIntegerKey(key)) {
  644. deps.push(depsMap.get("length"));
  645. }
  646. break;
  647. case "delete":
  648. if (!isArray(target)) {
  649. deps.push(depsMap.get(ITERATE_KEY));
  650. if (isMap(target)) {
  651. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  652. }
  653. }
  654. break;
  655. case "set":
  656. if (isMap(target)) {
  657. deps.push(depsMap.get(ITERATE_KEY));
  658. }
  659. break;
  660. }
  661. }
  662. const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
  663. if (deps.length === 1) {
  664. if (deps[0]) {
  665. {
  666. triggerEffects(deps[0], eventInfo);
  667. }
  668. }
  669. } else {
  670. const effects = [];
  671. for (const dep of deps) {
  672. if (dep) {
  673. effects.push(...dep);
  674. }
  675. }
  676. {
  677. triggerEffects(createDep(effects), eventInfo);
  678. }
  679. }
  680. }
  681. function triggerEffects(dep, debuggerEventExtraInfo) {
  682. const effects = isArray(dep) ? dep : [...dep];
  683. for (const effect2 of effects) {
  684. if (effect2.computed) {
  685. triggerEffect(effect2, debuggerEventExtraInfo);
  686. }
  687. }
  688. for (const effect2 of effects) {
  689. if (!effect2.computed) {
  690. triggerEffect(effect2, debuggerEventExtraInfo);
  691. }
  692. }
  693. }
  694. function triggerEffect(effect2, debuggerEventExtraInfo) {
  695. if (effect2 !== activeEffect || effect2.allowRecurse) {
  696. if (effect2.onTrigger) {
  697. effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
  698. }
  699. if (effect2.scheduler) {
  700. effect2.scheduler();
  701. } else {
  702. effect2.run();
  703. }
  704. }
  705. }
  706. function getDepFromReactive(object, key) {
  707. var _a;
  708. return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
  709. }
  710.  
  711. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  712. const builtInSymbols = new Set(
  713. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  714. );
  715. const get$1 = /* @__PURE__ */ createGetter();
  716. const shallowGet = /* @__PURE__ */ createGetter(false, true);
  717. const readonlyGet = /* @__PURE__ */ createGetter(true);
  718. const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
  719. const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
  720. function createArrayInstrumentations() {
  721. const instrumentations = {};
  722. ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
  723. instrumentations[key] = function(...args) {
  724. const arr = toRaw(this);
  725. for (let i = 0, l = this.length; i < l; i++) {
  726. track(arr, "get", i + "");
  727. }
  728. const res = arr[key](...args);
  729. if (res === -1 || res === false) {
  730. return arr[key](...args.map(toRaw));
  731. } else {
  732. return res;
  733. }
  734. };
  735. });
  736. ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
  737. instrumentations[key] = function(...args) {
  738. pauseTracking();
  739. const res = toRaw(this)[key].apply(this, args);
  740. resetTracking();
  741. return res;
  742. };
  743. });
  744. return instrumentations;
  745. }
  746. function hasOwnProperty(key) {
  747. const obj = toRaw(this);
  748. track(obj, "has", key);
  749. return obj.hasOwnProperty(key);
  750. }
  751. function createGetter(isReadonly2 = false, shallow = false) {
  752. return function get2(target, key, receiver) {
  753. if (key === "__v_isReactive") {
  754. return !isReadonly2;
  755. } else if (key === "__v_isReadonly") {
  756. return isReadonly2;
  757. } else if (key === "__v_isShallow") {
  758. return shallow;
  759. } else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
  760. return target;
  761. }
  762. const targetIsArray = isArray(target);
  763. if (!isReadonly2) {
  764. if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
  765. return Reflect.get(arrayInstrumentations, key, receiver);
  766. }
  767. if (key === "hasOwnProperty") {
  768. return hasOwnProperty;
  769. }
  770. }
  771. const res = Reflect.get(target, key, receiver);
  772. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  773. return res;
  774. }
  775. if (!isReadonly2) {
  776. track(target, "get", key);
  777. }
  778. if (shallow) {
  779. return res;
  780. }
  781. if (isRef(res)) {
  782. return targetIsArray && isIntegerKey(key) ? res : res.value;
  783. }
  784. if (isObject(res)) {
  785. return isReadonly2 ? readonly(res) : reactive(res);
  786. }
  787. return res;
  788. };
  789. }
  790. const set$1 = /* @__PURE__ */ createSetter();
  791. const shallowSet = /* @__PURE__ */ createSetter(true);
  792. function createSetter(shallow = false) {
  793. return function set2(target, key, value, receiver) {
  794. let oldValue = target[key];
  795. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  796. return false;
  797. }
  798. if (!shallow) {
  799. if (!isShallow(value) && !isReadonly(value)) {
  800. oldValue = toRaw(oldValue);
  801. value = toRaw(value);
  802. }
  803. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  804. oldValue.value = value;
  805. return true;
  806. }
  807. }
  808. const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
  809. const result = Reflect.set(target, key, value, receiver);
  810. if (target === toRaw(receiver)) {
  811. if (!hadKey) {
  812. trigger(target, "add", key, value);
  813. } else if (hasChanged(value, oldValue)) {
  814. trigger(target, "set", key, value, oldValue);
  815. }
  816. }
  817. return result;
  818. };
  819. }
  820. function deleteProperty(target, key) {
  821. const hadKey = hasOwn(target, key);
  822. const oldValue = target[key];
  823. const result = Reflect.deleteProperty(target, key);
  824. if (result && hadKey) {
  825. trigger(target, "delete", key, void 0, oldValue);
  826. }
  827. return result;
  828. }
  829. function has$1(target, key) {
  830. const result = Reflect.has(target, key);
  831. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  832. track(target, "has", key);
  833. }
  834. return result;
  835. }
  836. function ownKeys(target) {
  837. track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
  838. return Reflect.ownKeys(target);
  839. }
  840. const mutableHandlers = {
  841. get: get$1,
  842. set: set$1,
  843. deleteProperty,
  844. has: has$1,
  845. ownKeys
  846. };
  847. const readonlyHandlers = {
  848. get: readonlyGet,
  849. set(target, key) {
  850. {
  851. warn$1(
  852. `Set operation on key "${String(key)}" failed: target is readonly.`,
  853. target
  854. );
  855. }
  856. return true;
  857. },
  858. deleteProperty(target, key) {
  859. {
  860. warn$1(
  861. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  862. target
  863. );
  864. }
  865. return true;
  866. }
  867. };
  868. const shallowReactiveHandlers = /* @__PURE__ */ extend(
  869. {},
  870. mutableHandlers,
  871. {
  872. get: shallowGet,
  873. set: shallowSet
  874. }
  875. );
  876. const shallowReadonlyHandlers = /* @__PURE__ */ extend(
  877. {},
  878. readonlyHandlers,
  879. {
  880. get: shallowReadonlyGet
  881. }
  882. );
  883.  
  884. const toShallow = (value) => value;
  885. const getProto = (v) => Reflect.getPrototypeOf(v);
  886. function get(target, key, isReadonly = false, isShallow = false) {
  887. target = target["__v_raw"];
  888. const rawTarget = toRaw(target);
  889. const rawKey = toRaw(key);
  890. if (!isReadonly) {
  891. if (key !== rawKey) {
  892. track(rawTarget, "get", key);
  893. }
  894. track(rawTarget, "get", rawKey);
  895. }
  896. const { has: has2 } = getProto(rawTarget);
  897. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  898. if (has2.call(rawTarget, key)) {
  899. return wrap(target.get(key));
  900. } else if (has2.call(rawTarget, rawKey)) {
  901. return wrap(target.get(rawKey));
  902. } else if (target !== rawTarget) {
  903. target.get(key);
  904. }
  905. }
  906. function has(key, isReadonly = false) {
  907. const target = this["__v_raw"];
  908. const rawTarget = toRaw(target);
  909. const rawKey = toRaw(key);
  910. if (!isReadonly) {
  911. if (key !== rawKey) {
  912. track(rawTarget, "has", key);
  913. }
  914. track(rawTarget, "has", rawKey);
  915. }
  916. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  917. }
  918. function size(target, isReadonly = false) {
  919. target = target["__v_raw"];
  920. !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
  921. return Reflect.get(target, "size", target);
  922. }
  923. function add(value) {
  924. value = toRaw(value);
  925. const target = toRaw(this);
  926. const proto = getProto(target);
  927. const hadKey = proto.has.call(target, value);
  928. if (!hadKey) {
  929. target.add(value);
  930. trigger(target, "add", value, value);
  931. }
  932. return this;
  933. }
  934. function set(key, value) {
  935. value = toRaw(value);
  936. const target = toRaw(this);
  937. const { has: has2, get: get2 } = getProto(target);
  938. let hadKey = has2.call(target, key);
  939. if (!hadKey) {
  940. key = toRaw(key);
  941. hadKey = has2.call(target, key);
  942. } else {
  943. checkIdentityKeys(target, has2, key);
  944. }
  945. const oldValue = get2.call(target, key);
  946. target.set(key, value);
  947. if (!hadKey) {
  948. trigger(target, "add", key, value);
  949. } else if (hasChanged(value, oldValue)) {
  950. trigger(target, "set", key, value, oldValue);
  951. }
  952. return this;
  953. }
  954. function deleteEntry(key) {
  955. const target = toRaw(this);
  956. const { has: has2, get: get2 } = getProto(target);
  957. let hadKey = has2.call(target, key);
  958. if (!hadKey) {
  959. key = toRaw(key);
  960. hadKey = has2.call(target, key);
  961. } else {
  962. checkIdentityKeys(target, has2, key);
  963. }
  964. const oldValue = get2 ? get2.call(target, key) : void 0;
  965. const result = target.delete(key);
  966. if (hadKey) {
  967. trigger(target, "delete", key, void 0, oldValue);
  968. }
  969. return result;
  970. }
  971. function clear() {
  972. const target = toRaw(this);
  973. const hadItems = target.size !== 0;
  974. const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
  975. const result = target.clear();
  976. if (hadItems) {
  977. trigger(target, "clear", void 0, void 0, oldTarget);
  978. }
  979. return result;
  980. }
  981. function createForEach(isReadonly, isShallow) {
  982. return function forEach(callback, thisArg) {
  983. const observed = this;
  984. const target = observed["__v_raw"];
  985. const rawTarget = toRaw(target);
  986. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  987. !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
  988. return target.forEach((value, key) => {
  989. return callback.call(thisArg, wrap(value), wrap(key), observed);
  990. });
  991. };
  992. }
  993. function createIterableMethod(method, isReadonly, isShallow) {
  994. return function(...args) {
  995. const target = this["__v_raw"];
  996. const rawTarget = toRaw(target);
  997. const targetIsMap = isMap(rawTarget);
  998. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  999. const isKeyOnly = method === "keys" && targetIsMap;
  1000. const innerIterator = target[method](...args);
  1001. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1002. !isReadonly && track(
  1003. rawTarget,
  1004. "iterate",
  1005. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  1006. );
  1007. return {
  1008. // iterator protocol
  1009. next() {
  1010. const { value, done } = innerIterator.next();
  1011. return done ? { value, done } : {
  1012. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1013. done
  1014. };
  1015. },
  1016. // iterable protocol
  1017. [Symbol.iterator]() {
  1018. return this;
  1019. }
  1020. };
  1021. };
  1022. }
  1023. function createReadonlyMethod(type) {
  1024. return function(...args) {
  1025. {
  1026. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1027. console.warn(
  1028. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  1029. toRaw(this)
  1030. );
  1031. }
  1032. return type === "delete" ? false : this;
  1033. };
  1034. }
  1035. function createInstrumentations() {
  1036. const mutableInstrumentations2 = {
  1037. get(key) {
  1038. return get(this, key);
  1039. },
  1040. get size() {
  1041. return size(this);
  1042. },
  1043. has,
  1044. add,
  1045. set,
  1046. delete: deleteEntry,
  1047. clear,
  1048. forEach: createForEach(false, false)
  1049. };
  1050. const shallowInstrumentations2 = {
  1051. get(key) {
  1052. return get(this, key, false, true);
  1053. },
  1054. get size() {
  1055. return size(this);
  1056. },
  1057. has,
  1058. add,
  1059. set,
  1060. delete: deleteEntry,
  1061. clear,
  1062. forEach: createForEach(false, true)
  1063. };
  1064. const readonlyInstrumentations2 = {
  1065. get(key) {
  1066. return get(this, key, true);
  1067. },
  1068. get size() {
  1069. return size(this, true);
  1070. },
  1071. has(key) {
  1072. return has.call(this, key, true);
  1073. },
  1074. add: createReadonlyMethod("add"),
  1075. set: createReadonlyMethod("set"),
  1076. delete: createReadonlyMethod("delete"),
  1077. clear: createReadonlyMethod("clear"),
  1078. forEach: createForEach(true, false)
  1079. };
  1080. const shallowReadonlyInstrumentations2 = {
  1081. get(key) {
  1082. return get(this, key, true, true);
  1083. },
  1084. get size() {
  1085. return size(this, true);
  1086. },
  1087. has(key) {
  1088. return has.call(this, key, true);
  1089. },
  1090. add: createReadonlyMethod("add"),
  1091. set: createReadonlyMethod("set"),
  1092. delete: createReadonlyMethod("delete"),
  1093. clear: createReadonlyMethod("clear"),
  1094. forEach: createForEach(true, true)
  1095. };
  1096. const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
  1097. iteratorMethods.forEach((method) => {
  1098. mutableInstrumentations2[method] = createIterableMethod(
  1099. method,
  1100. false,
  1101. false
  1102. );
  1103. readonlyInstrumentations2[method] = createIterableMethod(
  1104. method,
  1105. true,
  1106. false
  1107. );
  1108. shallowInstrumentations2[method] = createIterableMethod(
  1109. method,
  1110. false,
  1111. true
  1112. );
  1113. shallowReadonlyInstrumentations2[method] = createIterableMethod(
  1114. method,
  1115. true,
  1116. true
  1117. );
  1118. });
  1119. return [
  1120. mutableInstrumentations2,
  1121. readonlyInstrumentations2,
  1122. shallowInstrumentations2,
  1123. shallowReadonlyInstrumentations2
  1124. ];
  1125. }
  1126. const [
  1127. mutableInstrumentations,
  1128. readonlyInstrumentations,
  1129. shallowInstrumentations,
  1130. shallowReadonlyInstrumentations
  1131. ] = /* @__PURE__ */ createInstrumentations();
  1132. function createInstrumentationGetter(isReadonly, shallow) {
  1133. const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
  1134. return (target, key, receiver) => {
  1135. if (key === "__v_isReactive") {
  1136. return !isReadonly;
  1137. } else if (key === "__v_isReadonly") {
  1138. return isReadonly;
  1139. } else if (key === "__v_raw") {
  1140. return target;
  1141. }
  1142. return Reflect.get(
  1143. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1144. key,
  1145. receiver
  1146. );
  1147. };
  1148. }
  1149. const mutableCollectionHandlers = {
  1150. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1151. };
  1152. const shallowCollectionHandlers = {
  1153. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1154. };
  1155. const readonlyCollectionHandlers = {
  1156. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1157. };
  1158. const shallowReadonlyCollectionHandlers = {
  1159. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1160. };
  1161. function checkIdentityKeys(target, has2, key) {
  1162. const rawKey = toRaw(key);
  1163. if (rawKey !== key && has2.call(target, rawKey)) {
  1164. const type = toRawType(target);
  1165. console.warn(
  1166. `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
  1167. );
  1168. }
  1169. }
  1170.  
  1171. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1172. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1173. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1174. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1175. function targetTypeMap(rawType) {
  1176. switch (rawType) {
  1177. case "Object":
  1178. case "Array":
  1179. return 1 /* COMMON */;
  1180. case "Map":
  1181. case "Set":
  1182. case "WeakMap":
  1183. case "WeakSet":
  1184. return 2 /* COLLECTION */;
  1185. default:
  1186. return 0 /* INVALID */;
  1187. }
  1188. }
  1189. function getTargetType(value) {
  1190. return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
  1191. }
  1192. function reactive(target) {
  1193. if (isReadonly(target)) {
  1194. return target;
  1195. }
  1196. return createReactiveObject(
  1197. target,
  1198. false,
  1199. mutableHandlers,
  1200. mutableCollectionHandlers,
  1201. reactiveMap
  1202. );
  1203. }
  1204. function shallowReactive(target) {
  1205. return createReactiveObject(
  1206. target,
  1207. false,
  1208. shallowReactiveHandlers,
  1209. shallowCollectionHandlers,
  1210. shallowReactiveMap
  1211. );
  1212. }
  1213. function readonly(target) {
  1214. return createReactiveObject(
  1215. target,
  1216. true,
  1217. readonlyHandlers,
  1218. readonlyCollectionHandlers,
  1219. readonlyMap
  1220. );
  1221. }
  1222. function shallowReadonly(target) {
  1223. return createReactiveObject(
  1224. target,
  1225. true,
  1226. shallowReadonlyHandlers,
  1227. shallowReadonlyCollectionHandlers,
  1228. shallowReadonlyMap
  1229. );
  1230. }
  1231. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1232. if (!isObject(target)) {
  1233. {
  1234. console.warn(`value cannot be made reactive: ${String(target)}`);
  1235. }
  1236. return target;
  1237. }
  1238. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1239. return target;
  1240. }
  1241. const existingProxy = proxyMap.get(target);
  1242. if (existingProxy) {
  1243. return existingProxy;
  1244. }
  1245. const targetType = getTargetType(target);
  1246. if (targetType === 0 /* INVALID */) {
  1247. return target;
  1248. }
  1249. const proxy = new Proxy(
  1250. target,
  1251. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1252. );
  1253. proxyMap.set(target, proxy);
  1254. return proxy;
  1255. }
  1256. function isReactive(value) {
  1257. if (isReadonly(value)) {
  1258. return isReactive(value["__v_raw"]);
  1259. }
  1260. return !!(value && value["__v_isReactive"]);
  1261. }
  1262. function isReadonly(value) {
  1263. return !!(value && value["__v_isReadonly"]);
  1264. }
  1265. function isShallow(value) {
  1266. return !!(value && value["__v_isShallow"]);
  1267. }
  1268. function isProxy(value) {
  1269. return isReactive(value) || isReadonly(value);
  1270. }
  1271. function toRaw(observed) {
  1272. const raw = observed && observed["__v_raw"];
  1273. return raw ? toRaw(raw) : observed;
  1274. }
  1275. function markRaw(value) {
  1276. def(value, "__v_skip", true);
  1277. return value;
  1278. }
  1279. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1280. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1281.  
  1282. function trackRefValue(ref2) {
  1283. if (shouldTrack && activeEffect) {
  1284. ref2 = toRaw(ref2);
  1285. {
  1286. trackEffects(ref2.dep || (ref2.dep = createDep()), {
  1287. target: ref2,
  1288. type: "get",
  1289. key: "value"
  1290. });
  1291. }
  1292. }
  1293. }
  1294. function triggerRefValue(ref2, newVal) {
  1295. ref2 = toRaw(ref2);
  1296. const dep = ref2.dep;
  1297. if (dep) {
  1298. {
  1299. triggerEffects(dep, {
  1300. target: ref2,
  1301. type: "set",
  1302. key: "value",
  1303. newValue: newVal
  1304. });
  1305. }
  1306. }
  1307. }
  1308. function isRef(r) {
  1309. return !!(r && r.__v_isRef === true);
  1310. }
  1311. function ref(value) {
  1312. return createRef(value, false);
  1313. }
  1314. function shallowRef(value) {
  1315. return createRef(value, true);
  1316. }
  1317. function createRef(rawValue, shallow) {
  1318. if (isRef(rawValue)) {
  1319. return rawValue;
  1320. }
  1321. return new RefImpl(rawValue, shallow);
  1322. }
  1323. class RefImpl {
  1324. constructor(value, __v_isShallow) {
  1325. this.__v_isShallow = __v_isShallow;
  1326. this.dep = void 0;
  1327. this.__v_isRef = true;
  1328. this._rawValue = __v_isShallow ? value : toRaw(value);
  1329. this._value = __v_isShallow ? value : toReactive(value);
  1330. }
  1331. get value() {
  1332. trackRefValue(this);
  1333. return this._value;
  1334. }
  1335. set value(newVal) {
  1336. const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
  1337. newVal = useDirectValue ? newVal : toRaw(newVal);
  1338. if (hasChanged(newVal, this._rawValue)) {
  1339. this._rawValue = newVal;
  1340. this._value = useDirectValue ? newVal : toReactive(newVal);
  1341. triggerRefValue(this, newVal);
  1342. }
  1343. }
  1344. }
  1345. function triggerRef(ref2) {
  1346. triggerRefValue(ref2, ref2.value );
  1347. }
  1348. function unref(ref2) {
  1349. return isRef(ref2) ? ref2.value : ref2;
  1350. }
  1351. function toValue(source) {
  1352. return isFunction(source) ? source() : unref(source);
  1353. }
  1354. const shallowUnwrapHandlers = {
  1355. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1356. set: (target, key, value, receiver) => {
  1357. const oldValue = target[key];
  1358. if (isRef(oldValue) && !isRef(value)) {
  1359. oldValue.value = value;
  1360. return true;
  1361. } else {
  1362. return Reflect.set(target, key, value, receiver);
  1363. }
  1364. }
  1365. };
  1366. function proxyRefs(objectWithRefs) {
  1367. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1368. }
  1369. class CustomRefImpl {
  1370. constructor(factory) {
  1371. this.dep = void 0;
  1372. this.__v_isRef = true;
  1373. const { get, set } = factory(
  1374. () => trackRefValue(this),
  1375. () => triggerRefValue(this)
  1376. );
  1377. this._get = get;
  1378. this._set = set;
  1379. }
  1380. get value() {
  1381. return this._get();
  1382. }
  1383. set value(newVal) {
  1384. this._set(newVal);
  1385. }
  1386. }
  1387. function customRef(factory) {
  1388. return new CustomRefImpl(factory);
  1389. }
  1390. function toRefs(object) {
  1391. if (!isProxy(object)) {
  1392. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1393. }
  1394. const ret = isArray(object) ? new Array(object.length) : {};
  1395. for (const key in object) {
  1396. ret[key] = propertyToRef(object, key);
  1397. }
  1398. return ret;
  1399. }
  1400. class ObjectRefImpl {
  1401. constructor(_object, _key, _defaultValue) {
  1402. this._object = _object;
  1403. this._key = _key;
  1404. this._defaultValue = _defaultValue;
  1405. this.__v_isRef = true;
  1406. }
  1407. get value() {
  1408. const val = this._object[this._key];
  1409. return val === void 0 ? this._defaultValue : val;
  1410. }
  1411. set value(newVal) {
  1412. this._object[this._key] = newVal;
  1413. }
  1414. get dep() {
  1415. return getDepFromReactive(toRaw(this._object), this._key);
  1416. }
  1417. }
  1418. class GetterRefImpl {
  1419. constructor(_getter) {
  1420. this._getter = _getter;
  1421. this.__v_isRef = true;
  1422. this.__v_isReadonly = true;
  1423. }
  1424. get value() {
  1425. return this._getter();
  1426. }
  1427. }
  1428. function toRef(source, key, defaultValue) {
  1429. if (isRef(source)) {
  1430. return source;
  1431. } else if (isFunction(source)) {
  1432. return new GetterRefImpl(source);
  1433. } else if (isObject(source) && arguments.length > 1) {
  1434. return propertyToRef(source, key, defaultValue);
  1435. } else {
  1436. return ref(source);
  1437. }
  1438. }
  1439. function propertyToRef(source, key, defaultValue) {
  1440. const val = source[key];
  1441. return isRef(val) ? val : new ObjectRefImpl(
  1442. source,
  1443. key,
  1444. defaultValue
  1445. );
  1446. }
  1447.  
  1448. class ComputedRefImpl {
  1449. constructor(getter, _setter, isReadonly, isSSR) {
  1450. this._setter = _setter;
  1451. this.dep = void 0;
  1452. this.__v_isRef = true;
  1453. this["__v_isReadonly"] = false;
  1454. this._dirty = true;
  1455. this.effect = new ReactiveEffect(getter, () => {
  1456. if (!this._dirty) {
  1457. this._dirty = true;
  1458. triggerRefValue(this);
  1459. }
  1460. });
  1461. this.effect.computed = this;
  1462. this.effect.active = this._cacheable = !isSSR;
  1463. this["__v_isReadonly"] = isReadonly;
  1464. }
  1465. get value() {
  1466. const self = toRaw(this);
  1467. trackRefValue(self);
  1468. if (self._dirty || !self._cacheable) {
  1469. self._dirty = false;
  1470. self._value = self.effect.run();
  1471. }
  1472. return self._value;
  1473. }
  1474. set value(newValue) {
  1475. this._setter(newValue);
  1476. }
  1477. }
  1478. function computed$1(getterOrOptions, debugOptions, isSSR = false) {
  1479. let getter;
  1480. let setter;
  1481. const onlyGetter = isFunction(getterOrOptions);
  1482. if (onlyGetter) {
  1483. getter = getterOrOptions;
  1484. setter = () => {
  1485. console.warn("Write operation failed: computed value is readonly");
  1486. } ;
  1487. } else {
  1488. getter = getterOrOptions.get;
  1489. setter = getterOrOptions.set;
  1490. }
  1491. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1492. if (debugOptions && !isSSR) {
  1493. cRef.effect.onTrack = debugOptions.onTrack;
  1494. cRef.effect.onTrigger = debugOptions.onTrigger;
  1495. }
  1496. return cRef;
  1497. }
  1498.  
  1499. const stack = [];
  1500. function pushWarningContext(vnode) {
  1501. stack.push(vnode);
  1502. }
  1503. function popWarningContext() {
  1504. stack.pop();
  1505. }
  1506. function warn(msg, ...args) {
  1507. pauseTracking();
  1508. const instance = stack.length ? stack[stack.length - 1].component : null;
  1509. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1510. const trace = getComponentTrace();
  1511. if (appWarnHandler) {
  1512. callWithErrorHandling(
  1513. appWarnHandler,
  1514. instance,
  1515. 11,
  1516. [
  1517. msg + args.join(""),
  1518. instance && instance.proxy,
  1519. trace.map(
  1520. ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
  1521. ).join("\n"),
  1522. trace
  1523. ]
  1524. );
  1525. } else {
  1526. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1527. if (trace.length && // avoid spamming console during tests
  1528. true) {
  1529. warnArgs.push(`
  1530. `, ...formatTrace(trace));
  1531. }
  1532. console.warn(...warnArgs);
  1533. }
  1534. resetTracking();
  1535. }
  1536. function getComponentTrace() {
  1537. let currentVNode = stack[stack.length - 1];
  1538. if (!currentVNode) {
  1539. return [];
  1540. }
  1541. const normalizedStack = [];
  1542. while (currentVNode) {
  1543. const last = normalizedStack[0];
  1544. if (last && last.vnode === currentVNode) {
  1545. last.recurseCount++;
  1546. } else {
  1547. normalizedStack.push({
  1548. vnode: currentVNode,
  1549. recurseCount: 0
  1550. });
  1551. }
  1552. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1553. currentVNode = parentInstance && parentInstance.vnode;
  1554. }
  1555. return normalizedStack;
  1556. }
  1557. function formatTrace(trace) {
  1558. const logs = [];
  1559. trace.forEach((entry, i) => {
  1560. logs.push(...i === 0 ? [] : [`
  1561. `], ...formatTraceEntry(entry));
  1562. });
  1563. return logs;
  1564. }
  1565. function formatTraceEntry({ vnode, recurseCount }) {
  1566. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1567. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1568. const open = ` at <${formatComponentName(
  1569. vnode.component,
  1570. vnode.type,
  1571. isRoot
  1572. )}`;
  1573. const close = `>` + postfix;
  1574. return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
  1575. }
  1576. function formatProps(props) {
  1577. const res = [];
  1578. const keys = Object.keys(props);
  1579. keys.slice(0, 3).forEach((key) => {
  1580. res.push(...formatProp(key, props[key]));
  1581. });
  1582. if (keys.length > 3) {
  1583. res.push(` ...`);
  1584. }
  1585. return res;
  1586. }
  1587. function formatProp(key, value, raw) {
  1588. if (isString(value)) {
  1589. value = JSON.stringify(value);
  1590. return raw ? value : [`${key}=${value}`];
  1591. } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
  1592. return raw ? value : [`${key}=${value}`];
  1593. } else if (isRef(value)) {
  1594. value = formatProp(key, toRaw(value.value), true);
  1595. return raw ? value : [`${key}=Ref<`, value, `>`];
  1596. } else if (isFunction(value)) {
  1597. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1598. } else {
  1599. value = toRaw(value);
  1600. return raw ? value : [`${key}=`, value];
  1601. }
  1602. }
  1603. function assertNumber(val, type) {
  1604. if (val === void 0) {
  1605. return;
  1606. } else if (typeof val !== "number") {
  1607. warn(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
  1608. } else if (isNaN(val)) {
  1609. warn(`${type} is NaN - the duration expression might be incorrect.`);
  1610. }
  1611. }
  1612.  
  1613. const ErrorTypeStrings = {
  1614. ["sp"]: "serverPrefetch hook",
  1615. ["bc"]: "beforeCreate hook",
  1616. ["c"]: "created hook",
  1617. ["bm"]: "beforeMount hook",
  1618. ["m"]: "mounted hook",
  1619. ["bu"]: "beforeUpdate hook",
  1620. ["u"]: "updated",
  1621. ["bum"]: "beforeUnmount hook",
  1622. ["um"]: "unmounted hook",
  1623. ["a"]: "activated hook",
  1624. ["da"]: "deactivated hook",
  1625. ["ec"]: "errorCaptured hook",
  1626. ["rtc"]: "renderTracked hook",
  1627. ["rtg"]: "renderTriggered hook",
  1628. [0]: "setup function",
  1629. [1]: "render function",
  1630. [2]: "watcher getter",
  1631. [3]: "watcher callback",
  1632. [4]: "watcher cleanup function",
  1633. [5]: "native event handler",
  1634. [6]: "component event handler",
  1635. [7]: "vnode hook",
  1636. [8]: "directive hook",
  1637. [9]: "transition hook",
  1638. [10]: "app errorHandler",
  1639. [11]: "app warnHandler",
  1640. [12]: "ref function",
  1641. [13]: "async component loader",
  1642. [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
  1643. };
  1644. function callWithErrorHandling(fn, instance, type, args) {
  1645. let res;
  1646. try {
  1647. res = args ? fn(...args) : fn();
  1648. } catch (err) {
  1649. handleError(err, instance, type);
  1650. }
  1651. return res;
  1652. }
  1653. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1654. if (isFunction(fn)) {
  1655. const res = callWithErrorHandling(fn, instance, type, args);
  1656. if (res && isPromise(res)) {
  1657. res.catch((err) => {
  1658. handleError(err, instance, type);
  1659. });
  1660. }
  1661. return res;
  1662. }
  1663. const values = [];
  1664. for (let i = 0; i < fn.length; i++) {
  1665. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1666. }
  1667. return values;
  1668. }
  1669. function handleError(err, instance, type, throwInDev = true) {
  1670. const contextVNode = instance ? instance.vnode : null;
  1671. if (instance) {
  1672. let cur = instance.parent;
  1673. const exposedInstance = instance.proxy;
  1674. const errorInfo = ErrorTypeStrings[type] ;
  1675. while (cur) {
  1676. const errorCapturedHooks = cur.ec;
  1677. if (errorCapturedHooks) {
  1678. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1679. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1680. return;
  1681. }
  1682. }
  1683. }
  1684. cur = cur.parent;
  1685. }
  1686. const appErrorHandler = instance.appContext.config.errorHandler;
  1687. if (appErrorHandler) {
  1688. callWithErrorHandling(
  1689. appErrorHandler,
  1690. null,
  1691. 10,
  1692. [err, exposedInstance, errorInfo]
  1693. );
  1694. return;
  1695. }
  1696. }
  1697. logError(err, type, contextVNode, throwInDev);
  1698. }
  1699. function logError(err, type, contextVNode, throwInDev = true) {
  1700. {
  1701. const info = ErrorTypeStrings[type];
  1702. if (contextVNode) {
  1703. pushWarningContext(contextVNode);
  1704. }
  1705. warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1706. if (contextVNode) {
  1707. popWarningContext();
  1708. }
  1709. if (throwInDev) {
  1710. throw err;
  1711. } else {
  1712. console.error(err);
  1713. }
  1714. }
  1715. }
  1716.  
  1717. let isFlushing = false;
  1718. let isFlushPending = false;
  1719. const queue = [];
  1720. let flushIndex = 0;
  1721. const pendingPostFlushCbs = [];
  1722. let activePostFlushCbs = null;
  1723. let postFlushIndex = 0;
  1724. const resolvedPromise = /* @__PURE__ */ Promise.resolve();
  1725. let currentFlushPromise = null;
  1726. const RECURSION_LIMIT = 100;
  1727. function nextTick(fn) {
  1728. const p = currentFlushPromise || resolvedPromise;
  1729. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1730. }
  1731. function findInsertionIndex(id) {
  1732. let start = flushIndex + 1;
  1733. let end = queue.length;
  1734. while (start < end) {
  1735. const middle = start + end >>> 1;
  1736. const middleJobId = getId(queue[middle]);
  1737. middleJobId < id ? start = middle + 1 : end = middle;
  1738. }
  1739. return start;
  1740. }
  1741. function queueJob(job) {
  1742. if (!queue.length || !queue.includes(
  1743. job,
  1744. isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
  1745. )) {
  1746. if (job.id == null) {
  1747. queue.push(job);
  1748. } else {
  1749. queue.splice(findInsertionIndex(job.id), 0, job);
  1750. }
  1751. queueFlush();
  1752. }
  1753. }
  1754. function queueFlush() {
  1755. if (!isFlushing && !isFlushPending) {
  1756. isFlushPending = true;
  1757. currentFlushPromise = resolvedPromise.then(flushJobs);
  1758. }
  1759. }
  1760. function invalidateJob(job) {
  1761. const i = queue.indexOf(job);
  1762. if (i > flushIndex) {
  1763. queue.splice(i, 1);
  1764. }
  1765. }
  1766. function queuePostFlushCb(cb) {
  1767. if (!isArray(cb)) {
  1768. if (!activePostFlushCbs || !activePostFlushCbs.includes(
  1769. cb,
  1770. cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
  1771. )) {
  1772. pendingPostFlushCbs.push(cb);
  1773. }
  1774. } else {
  1775. pendingPostFlushCbs.push(...cb);
  1776. }
  1777. queueFlush();
  1778. }
  1779. function flushPreFlushCbs(seen, i = isFlushing ? flushIndex + 1 : 0) {
  1780. {
  1781. seen = seen || /* @__PURE__ */ new Map();
  1782. }
  1783. for (; i < queue.length; i++) {
  1784. const cb = queue[i];
  1785. if (cb && cb.pre) {
  1786. if (checkRecursiveUpdates(seen, cb)) {
  1787. continue;
  1788. }
  1789. queue.splice(i, 1);
  1790. i--;
  1791. cb();
  1792. }
  1793. }
  1794. }
  1795. function flushPostFlushCbs(seen) {
  1796. if (pendingPostFlushCbs.length) {
  1797. const deduped = [...new Set(pendingPostFlushCbs)];
  1798. pendingPostFlushCbs.length = 0;
  1799. if (activePostFlushCbs) {
  1800. activePostFlushCbs.push(...deduped);
  1801. return;
  1802. }
  1803. activePostFlushCbs = deduped;
  1804. {
  1805. seen = seen || /* @__PURE__ */ new Map();
  1806. }
  1807. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1808. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1809. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1810. continue;
  1811. }
  1812. activePostFlushCbs[postFlushIndex]();
  1813. }
  1814. activePostFlushCbs = null;
  1815. postFlushIndex = 0;
  1816. }
  1817. }
  1818. const getId = (job) => job.id == null ? Infinity : job.id;
  1819. const comparator = (a, b) => {
  1820. const diff = getId(a) - getId(b);
  1821. if (diff === 0) {
  1822. if (a.pre && !b.pre)
  1823. return -1;
  1824. if (b.pre && !a.pre)
  1825. return 1;
  1826. }
  1827. return diff;
  1828. };
  1829. function flushJobs(seen) {
  1830. isFlushPending = false;
  1831. isFlushing = true;
  1832. {
  1833. seen = seen || /* @__PURE__ */ new Map();
  1834. }
  1835. queue.sort(comparator);
  1836. const check = (job) => checkRecursiveUpdates(seen, job) ;
  1837. try {
  1838. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1839. const job = queue[flushIndex];
  1840. if (job && job.active !== false) {
  1841. if (check(job)) {
  1842. continue;
  1843. }
  1844. callWithErrorHandling(job, null, 14);
  1845. }
  1846. }
  1847. } finally {
  1848. flushIndex = 0;
  1849. queue.length = 0;
  1850. flushPostFlushCbs(seen);
  1851. isFlushing = false;
  1852. currentFlushPromise = null;
  1853. if (queue.length || pendingPostFlushCbs.length) {
  1854. flushJobs(seen);
  1855. }
  1856. }
  1857. }
  1858. function checkRecursiveUpdates(seen, fn) {
  1859. if (!seen.has(fn)) {
  1860. seen.set(fn, 1);
  1861. } else {
  1862. const count = seen.get(fn);
  1863. if (count > RECURSION_LIMIT) {
  1864. const instance = fn.ownerInstance;
  1865. const componentName = instance && getComponentName(instance.type);
  1866. warn(
  1867. `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`
  1868. );
  1869. return true;
  1870. } else {
  1871. seen.set(fn, count + 1);
  1872. }
  1873. }
  1874. }
  1875.  
  1876. let isHmrUpdating = false;
  1877. const hmrDirtyComponents = /* @__PURE__ */ new Set();
  1878. {
  1879. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1880. createRecord: tryWrap(createRecord),
  1881. rerender: tryWrap(rerender),
  1882. reload: tryWrap(reload)
  1883. };
  1884. }
  1885. const map = /* @__PURE__ */ new Map();
  1886. function registerHMR(instance) {
  1887. const id = instance.type.__hmrId;
  1888. let record = map.get(id);
  1889. if (!record) {
  1890. createRecord(id, instance.type);
  1891. record = map.get(id);
  1892. }
  1893. record.instances.add(instance);
  1894. }
  1895. function unregisterHMR(instance) {
  1896. map.get(instance.type.__hmrId).instances.delete(instance);
  1897. }
  1898. function createRecord(id, initialDef) {
  1899. if (map.has(id)) {
  1900. return false;
  1901. }
  1902. map.set(id, {
  1903. initialDef: normalizeClassComponent(initialDef),
  1904. instances: /* @__PURE__ */ new Set()
  1905. });
  1906. return true;
  1907. }
  1908. function normalizeClassComponent(component) {
  1909. return isClassComponent(component) ? component.__vccOpts : component;
  1910. }
  1911. function rerender(id, newRender) {
  1912. const record = map.get(id);
  1913. if (!record) {
  1914. return;
  1915. }
  1916. record.initialDef.render = newRender;
  1917. [...record.instances].forEach((instance) => {
  1918. if (newRender) {
  1919. instance.render = newRender;
  1920. normalizeClassComponent(instance.type).render = newRender;
  1921. }
  1922. instance.renderCache = [];
  1923. isHmrUpdating = true;
  1924. instance.update();
  1925. isHmrUpdating = false;
  1926. });
  1927. }
  1928. function reload(id, newComp) {
  1929. const record = map.get(id);
  1930. if (!record)
  1931. return;
  1932. newComp = normalizeClassComponent(newComp);
  1933. updateComponentDef(record.initialDef, newComp);
  1934. const instances = [...record.instances];
  1935. for (const instance of instances) {
  1936. const oldComp = normalizeClassComponent(instance.type);
  1937. if (!hmrDirtyComponents.has(oldComp)) {
  1938. if (oldComp !== record.initialDef) {
  1939. updateComponentDef(oldComp, newComp);
  1940. }
  1941. hmrDirtyComponents.add(oldComp);
  1942. }
  1943. instance.appContext.propsCache.delete(instance.type);
  1944. instance.appContext.emitsCache.delete(instance.type);
  1945. instance.appContext.optionsCache.delete(instance.type);
  1946. if (instance.ceReload) {
  1947. hmrDirtyComponents.add(oldComp);
  1948. instance.ceReload(newComp.styles);
  1949. hmrDirtyComponents.delete(oldComp);
  1950. } else if (instance.parent) {
  1951. queueJob(instance.parent.update);
  1952. } else if (instance.appContext.reload) {
  1953. instance.appContext.reload();
  1954. } else if (typeof window !== "undefined") {
  1955. window.location.reload();
  1956. } else {
  1957. console.warn(
  1958. "[HMR] Root or manually mounted instance modified. Full reload required."
  1959. );
  1960. }
  1961. }
  1962. queuePostFlushCb(() => {
  1963. for (const instance of instances) {
  1964. hmrDirtyComponents.delete(
  1965. normalizeClassComponent(instance.type)
  1966. );
  1967. }
  1968. });
  1969. }
  1970. function updateComponentDef(oldComp, newComp) {
  1971. extend(oldComp, newComp);
  1972. for (const key in oldComp) {
  1973. if (key !== "__file" && !(key in newComp)) {
  1974. delete oldComp[key];
  1975. }
  1976. }
  1977. }
  1978. function tryWrap(fn) {
  1979. return (id, arg) => {
  1980. try {
  1981. return fn(id, arg);
  1982. } catch (e) {
  1983. console.error(e);
  1984. console.warn(
  1985. `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
  1986. );
  1987. }
  1988. };
  1989. }
  1990.  
  1991. exports.devtools = void 0;
  1992. let buffer = [];
  1993. let devtoolsNotInstalled = false;
  1994. function emit$1(event, ...args) {
  1995. if (exports.devtools) {
  1996. exports.devtools.emit(event, ...args);
  1997. } else if (!devtoolsNotInstalled) {
  1998. buffer.push({ event, args });
  1999. }
  2000. }
  2001. function setDevtoolsHook(hook, target) {
  2002. var _a, _b;
  2003. exports.devtools = hook;
  2004. if (exports.devtools) {
  2005. exports.devtools.enabled = true;
  2006. buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
  2007. buffer = [];
  2008. } else if (
  2009. // handle late devtools injection - only do this if we are in an actual
  2010. // browser environment to avoid the timer handle stalling test runner exit
  2011. // (#4815)
  2012. typeof window !== "undefined" && // some envs mock window but not fully
  2013. window.HTMLElement && // also exclude jsdom
  2014. !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
  2015. ) {
  2016. const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
  2017. replay.push((newHook) => {
  2018. setDevtoolsHook(newHook, target);
  2019. });
  2020. setTimeout(() => {
  2021. if (!exports.devtools) {
  2022. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  2023. devtoolsNotInstalled = true;
  2024. buffer = [];
  2025. }
  2026. }, 3e3);
  2027. } else {
  2028. devtoolsNotInstalled = true;
  2029. buffer = [];
  2030. }
  2031. }
  2032. function devtoolsInitApp(app, version) {
  2033. emit$1("app:init" /* APP_INIT */, app, version, {
  2034. Fragment,
  2035. Text,
  2036. Comment,
  2037. Static
  2038. });
  2039. }
  2040. function devtoolsUnmountApp(app) {
  2041. emit$1("app:unmount" /* APP_UNMOUNT */, app);
  2042. }
  2043. const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
  2044. "component:added" /* COMPONENT_ADDED */
  2045. );
  2046. const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  2047. const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
  2048. "component:removed" /* COMPONENT_REMOVED */
  2049. );
  2050. const devtoolsComponentRemoved = (component) => {
  2051. if (exports.devtools && typeof exports.devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered
  2052. !exports.devtools.cleanupBuffer(component)) {
  2053. _devtoolsComponentRemoved(component);
  2054. }
  2055. };
  2056. function createDevtoolsComponentHook(hook) {
  2057. return (component) => {
  2058. emit$1(
  2059. hook,
  2060. component.appContext.app,
  2061. component.uid,
  2062. component.parent ? component.parent.uid : void 0,
  2063. component
  2064. );
  2065. };
  2066. }
  2067. const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2068. "perf:start" /* PERFORMANCE_START */
  2069. );
  2070. const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2071. "perf:end" /* PERFORMANCE_END */
  2072. );
  2073. function createDevtoolsPerformanceHook(hook) {
  2074. return (component, type, time) => {
  2075. emit$1(hook, component.appContext.app, component.uid, component, type, time);
  2076. };
  2077. }
  2078. function devtoolsComponentEmit(component, event, params) {
  2079. emit$1(
  2080. "component:emit" /* COMPONENT_EMIT */,
  2081. component.appContext.app,
  2082. component,
  2083. event,
  2084. params
  2085. );
  2086. }
  2087.  
  2088. function emit(instance, event, ...rawArgs) {
  2089. if (instance.isUnmounted)
  2090. return;
  2091. const props = instance.vnode.props || EMPTY_OBJ;
  2092. {
  2093. const {
  2094. emitsOptions,
  2095. propsOptions: [propsOptions]
  2096. } = instance;
  2097. if (emitsOptions) {
  2098. if (!(event in emitsOptions) && true) {
  2099. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2100. warn(
  2101. `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
  2102. );
  2103. }
  2104. } else {
  2105. const validator = emitsOptions[event];
  2106. if (isFunction(validator)) {
  2107. const isValid = validator(...rawArgs);
  2108. if (!isValid) {
  2109. warn(
  2110. `Invalid event arguments: event validation failed for event "${event}".`
  2111. );
  2112. }
  2113. }
  2114. }
  2115. }
  2116. }
  2117. let args = rawArgs;
  2118. const isModelListener = event.startsWith("update:");
  2119. const modelArg = isModelListener && event.slice(7);
  2120. if (modelArg && modelArg in props) {
  2121. const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
  2122. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2123. if (trim) {
  2124. args = rawArgs.map((a) => isString(a) ? a.trim() : a);
  2125. }
  2126. if (number) {
  2127. args = rawArgs.map(looseToNumber);
  2128. }
  2129. }
  2130. {
  2131. devtoolsComponentEmit(instance, event, args);
  2132. }
  2133. {
  2134. const lowerCaseEvent = event.toLowerCase();
  2135. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2136. warn(
  2137. `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
  2138. instance,
  2139. instance.type
  2140. )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(event)}" instead of "${event}".`
  2141. );
  2142. }
  2143. }
  2144. let handlerName;
  2145. let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
  2146. props[handlerName = toHandlerKey(camelize(event))];
  2147. if (!handler && isModelListener) {
  2148. handler = props[handlerName = toHandlerKey(hyphenate(event))];
  2149. }
  2150. if (handler) {
  2151. callWithAsyncErrorHandling(
  2152. handler,
  2153. instance,
  2154. 6,
  2155. args
  2156. );
  2157. }
  2158. const onceHandler = props[handlerName + `Once`];
  2159. if (onceHandler) {
  2160. if (!instance.emitted) {
  2161. instance.emitted = {};
  2162. } else if (instance.emitted[handlerName]) {
  2163. return;
  2164. }
  2165. instance.emitted[handlerName] = true;
  2166. callWithAsyncErrorHandling(
  2167. onceHandler,
  2168. instance,
  2169. 6,
  2170. args
  2171. );
  2172. }
  2173. }
  2174. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2175. const cache = appContext.emitsCache;
  2176. const cached = cache.get(comp);
  2177. if (cached !== void 0) {
  2178. return cached;
  2179. }
  2180. const raw = comp.emits;
  2181. let normalized = {};
  2182. let hasExtends = false;
  2183. if (!isFunction(comp)) {
  2184. const extendEmits = (raw2) => {
  2185. const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
  2186. if (normalizedFromExtend) {
  2187. hasExtends = true;
  2188. extend(normalized, normalizedFromExtend);
  2189. }
  2190. };
  2191. if (!asMixin && appContext.mixins.length) {
  2192. appContext.mixins.forEach(extendEmits);
  2193. }
  2194. if (comp.extends) {
  2195. extendEmits(comp.extends);
  2196. }
  2197. if (comp.mixins) {
  2198. comp.mixins.forEach(extendEmits);
  2199. }
  2200. }
  2201. if (!raw && !hasExtends) {
  2202. if (isObject(comp)) {
  2203. cache.set(comp, null);
  2204. }
  2205. return null;
  2206. }
  2207. if (isArray(raw)) {
  2208. raw.forEach((key) => normalized[key] = null);
  2209. } else {
  2210. extend(normalized, raw);
  2211. }
  2212. if (isObject(comp)) {
  2213. cache.set(comp, normalized);
  2214. }
  2215. return normalized;
  2216. }
  2217. function isEmitListener(options, key) {
  2218. if (!options || !isOn(key)) {
  2219. return false;
  2220. }
  2221. key = key.slice(2).replace(/Once$/, "");
  2222. return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
  2223. }
  2224.  
  2225. let currentRenderingInstance = null;
  2226. let currentScopeId = null;
  2227. function setCurrentRenderingInstance(instance) {
  2228. const prev = currentRenderingInstance;
  2229. currentRenderingInstance = instance;
  2230. currentScopeId = instance && instance.type.__scopeId || null;
  2231. return prev;
  2232. }
  2233. function pushScopeId(id) {
  2234. currentScopeId = id;
  2235. }
  2236. function popScopeId() {
  2237. currentScopeId = null;
  2238. }
  2239. const withScopeId = (_id) => withCtx;
  2240. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
  2241. if (!ctx)
  2242. return fn;
  2243. if (fn._n) {
  2244. return fn;
  2245. }
  2246. const renderFnWithContext = (...args) => {
  2247. if (renderFnWithContext._d) {
  2248. setBlockTracking(-1);
  2249. }
  2250. const prevInstance = setCurrentRenderingInstance(ctx);
  2251. let res;
  2252. try {
  2253. res = fn(...args);
  2254. } finally {
  2255. setCurrentRenderingInstance(prevInstance);
  2256. if (renderFnWithContext._d) {
  2257. setBlockTracking(1);
  2258. }
  2259. }
  2260. {
  2261. devtoolsComponentUpdated(ctx);
  2262. }
  2263. return res;
  2264. };
  2265. renderFnWithContext._n = true;
  2266. renderFnWithContext._c = true;
  2267. renderFnWithContext._d = true;
  2268. return renderFnWithContext;
  2269. }
  2270.  
  2271. let accessedAttrs = false;
  2272. function markAttrsAccessed() {
  2273. accessedAttrs = true;
  2274. }
  2275. function renderComponentRoot(instance) {
  2276. const {
  2277. type: Component,
  2278. vnode,
  2279. proxy,
  2280. withProxy,
  2281. props,
  2282. propsOptions: [propsOptions],
  2283. slots,
  2284. attrs,
  2285. emit,
  2286. render,
  2287. renderCache,
  2288. data,
  2289. setupState,
  2290. ctx,
  2291. inheritAttrs
  2292. } = instance;
  2293. let result;
  2294. let fallthroughAttrs;
  2295. const prev = setCurrentRenderingInstance(instance);
  2296. {
  2297. accessedAttrs = false;
  2298. }
  2299. try {
  2300. if (vnode.shapeFlag & 4) {
  2301. const proxyToUse = withProxy || proxy;
  2302. result = normalizeVNode(
  2303. render.call(
  2304. proxyToUse,
  2305. proxyToUse,
  2306. renderCache,
  2307. props,
  2308. setupState,
  2309. data,
  2310. ctx
  2311. )
  2312. );
  2313. fallthroughAttrs = attrs;
  2314. } else {
  2315. const render2 = Component;
  2316. if (attrs === props) {
  2317. markAttrsAccessed();
  2318. }
  2319. result = normalizeVNode(
  2320. render2.length > 1 ? render2(
  2321. props,
  2322. true ? {
  2323. get attrs() {
  2324. markAttrsAccessed();
  2325. return attrs;
  2326. },
  2327. slots,
  2328. emit
  2329. } : { attrs, slots, emit }
  2330. ) : render2(
  2331. props,
  2332. null
  2333. /* we know it doesn't need it */
  2334. )
  2335. );
  2336. fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
  2337. }
  2338. } catch (err) {
  2339. blockStack.length = 0;
  2340. handleError(err, instance, 1);
  2341. result = createVNode(Comment);
  2342. }
  2343. let root = result;
  2344. let setRoot = void 0;
  2345. if (result.patchFlag > 0 && result.patchFlag & 2048) {
  2346. [root, setRoot] = getChildRoot(result);
  2347. }
  2348. if (fallthroughAttrs && inheritAttrs !== false) {
  2349. const keys = Object.keys(fallthroughAttrs);
  2350. const { shapeFlag } = root;
  2351. if (keys.length) {
  2352. if (shapeFlag & (1 | 6)) {
  2353. if (propsOptions && keys.some(isModelListener)) {
  2354. fallthroughAttrs = filterModelListeners(
  2355. fallthroughAttrs,
  2356. propsOptions
  2357. );
  2358. }
  2359. root = cloneVNode(root, fallthroughAttrs);
  2360. } else if (!accessedAttrs && root.type !== Comment) {
  2361. const allAttrs = Object.keys(attrs);
  2362. const eventAttrs = [];
  2363. const extraAttrs = [];
  2364. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2365. const key = allAttrs[i];
  2366. if (isOn(key)) {
  2367. if (!isModelListener(key)) {
  2368. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2369. }
  2370. } else {
  2371. extraAttrs.push(key);
  2372. }
  2373. }
  2374. if (extraAttrs.length) {
  2375. warn(
  2376. `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
  2377. );
  2378. }
  2379. if (eventAttrs.length) {
  2380. warn(
  2381. `Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
  2382. );
  2383. }
  2384. }
  2385. }
  2386. }
  2387. if (vnode.dirs) {
  2388. if (!isElementRoot(root)) {
  2389. warn(
  2390. `Runtime directive used on component with non-element root node. The directives will not function as intended.`
  2391. );
  2392. }
  2393. root = cloneVNode(root);
  2394. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2395. }
  2396. if (vnode.transition) {
  2397. if (!isElementRoot(root)) {
  2398. warn(
  2399. `Component inside <Transition> renders non-element root node that cannot be animated.`
  2400. );
  2401. }
  2402. root.transition = vnode.transition;
  2403. }
  2404. if (setRoot) {
  2405. setRoot(root);
  2406. } else {
  2407. result = root;
  2408. }
  2409. setCurrentRenderingInstance(prev);
  2410. return result;
  2411. }
  2412. const getChildRoot = (vnode) => {
  2413. const rawChildren = vnode.children;
  2414. const dynamicChildren = vnode.dynamicChildren;
  2415. const childRoot = filterSingleRoot(rawChildren);
  2416. if (!childRoot) {
  2417. return [vnode, void 0];
  2418. }
  2419. const index = rawChildren.indexOf(childRoot);
  2420. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2421. const setRoot = (updatedRoot) => {
  2422. rawChildren[index] = updatedRoot;
  2423. if (dynamicChildren) {
  2424. if (dynamicIndex > -1) {
  2425. dynamicChildren[dynamicIndex] = updatedRoot;
  2426. } else if (updatedRoot.patchFlag > 0) {
  2427. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2428. }
  2429. }
  2430. };
  2431. return [normalizeVNode(childRoot), setRoot];
  2432. };
  2433. function filterSingleRoot(children) {
  2434. let singleRoot;
  2435. for (let i = 0; i < children.length; i++) {
  2436. const child = children[i];
  2437. if (isVNode(child)) {
  2438. if (child.type !== Comment || child.children === "v-if") {
  2439. if (singleRoot) {
  2440. return;
  2441. } else {
  2442. singleRoot = child;
  2443. }
  2444. }
  2445. } else {
  2446. return;
  2447. }
  2448. }
  2449. return singleRoot;
  2450. }
  2451. const getFunctionalFallthrough = (attrs) => {
  2452. let res;
  2453. for (const key in attrs) {
  2454. if (key === "class" || key === "style" || isOn(key)) {
  2455. (res || (res = {}))[key] = attrs[key];
  2456. }
  2457. }
  2458. return res;
  2459. };
  2460. const filterModelListeners = (attrs, props) => {
  2461. const res = {};
  2462. for (const key in attrs) {
  2463. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2464. res[key] = attrs[key];
  2465. }
  2466. }
  2467. return res;
  2468. };
  2469. const isElementRoot = (vnode) => {
  2470. return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
  2471. };
  2472. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2473. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2474. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2475. const emits = component.emitsOptions;
  2476. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2477. return true;
  2478. }
  2479. if (nextVNode.dirs || nextVNode.transition) {
  2480. return true;
  2481. }
  2482. if (optimized && patchFlag >= 0) {
  2483. if (patchFlag & 1024) {
  2484. return true;
  2485. }
  2486. if (patchFlag & 16) {
  2487. if (!prevProps) {
  2488. return !!nextProps;
  2489. }
  2490. return hasPropsChanged(prevProps, nextProps, emits);
  2491. } else if (patchFlag & 8) {
  2492. const dynamicProps = nextVNode.dynamicProps;
  2493. for (let i = 0; i < dynamicProps.length; i++) {
  2494. const key = dynamicProps[i];
  2495. if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
  2496. return true;
  2497. }
  2498. }
  2499. }
  2500. } else {
  2501. if (prevChildren || nextChildren) {
  2502. if (!nextChildren || !nextChildren.$stable) {
  2503. return true;
  2504. }
  2505. }
  2506. if (prevProps === nextProps) {
  2507. return false;
  2508. }
  2509. if (!prevProps) {
  2510. return !!nextProps;
  2511. }
  2512. if (!nextProps) {
  2513. return true;
  2514. }
  2515. return hasPropsChanged(prevProps, nextProps, emits);
  2516. }
  2517. return false;
  2518. }
  2519. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2520. const nextKeys = Object.keys(nextProps);
  2521. if (nextKeys.length !== Object.keys(prevProps).length) {
  2522. return true;
  2523. }
  2524. for (let i = 0; i < nextKeys.length; i++) {
  2525. const key = nextKeys[i];
  2526. if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
  2527. return true;
  2528. }
  2529. }
  2530. return false;
  2531. }
  2532. function updateHOCHostEl({ vnode, parent }, el) {
  2533. while (parent && parent.subTree === vnode) {
  2534. (vnode = parent.vnode).el = el;
  2535. parent = parent.parent;
  2536. }
  2537. }
  2538.  
  2539. const isSuspense = (type) => type.__isSuspense;
  2540. const SuspenseImpl = {
  2541. name: "Suspense",
  2542. // In order to make Suspense tree-shakable, we need to avoid importing it
  2543. // directly in the renderer. The renderer checks for the __isSuspense flag
  2544. // on a vnode's type and calls the `process` method, passing in renderer
  2545. // internals.
  2546. __isSuspense: true,
  2547. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2548. if (n1 == null) {
  2549. mountSuspense(
  2550. n2,
  2551. container,
  2552. anchor,
  2553. parentComponent,
  2554. parentSuspense,
  2555. isSVG,
  2556. slotScopeIds,
  2557. optimized,
  2558. rendererInternals
  2559. );
  2560. } else {
  2561. patchSuspense(
  2562. n1,
  2563. n2,
  2564. container,
  2565. anchor,
  2566. parentComponent,
  2567. isSVG,
  2568. slotScopeIds,
  2569. optimized,
  2570. rendererInternals
  2571. );
  2572. }
  2573. },
  2574. hydrate: hydrateSuspense,
  2575. create: createSuspenseBoundary,
  2576. normalize: normalizeSuspenseChildren
  2577. };
  2578. const Suspense = SuspenseImpl ;
  2579. function triggerEvent(vnode, name) {
  2580. const eventListener = vnode.props && vnode.props[name];
  2581. if (isFunction(eventListener)) {
  2582. eventListener();
  2583. }
  2584. }
  2585. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2586. const {
  2587. p: patch,
  2588. o: { createElement }
  2589. } = rendererInternals;
  2590. const hiddenContainer = createElement("div");
  2591. const suspense = vnode.suspense = createSuspenseBoundary(
  2592. vnode,
  2593. parentSuspense,
  2594. parentComponent,
  2595. container,
  2596. hiddenContainer,
  2597. anchor,
  2598. isSVG,
  2599. slotScopeIds,
  2600. optimized,
  2601. rendererInternals
  2602. );
  2603. patch(
  2604. null,
  2605. suspense.pendingBranch = vnode.ssContent,
  2606. hiddenContainer,
  2607. null,
  2608. parentComponent,
  2609. suspense,
  2610. isSVG,
  2611. slotScopeIds
  2612. );
  2613. if (suspense.deps > 0) {
  2614. triggerEvent(vnode, "onPending");
  2615. triggerEvent(vnode, "onFallback");
  2616. patch(
  2617. null,
  2618. vnode.ssFallback,
  2619. container,
  2620. anchor,
  2621. parentComponent,
  2622. null,
  2623. // fallback tree will not have suspense context
  2624. isSVG,
  2625. slotScopeIds
  2626. );
  2627. setActiveBranch(suspense, vnode.ssFallback);
  2628. } else {
  2629. suspense.resolve(false, true);
  2630. }
  2631. }
  2632. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2633. const suspense = n2.suspense = n1.suspense;
  2634. suspense.vnode = n2;
  2635. n2.el = n1.el;
  2636. const newBranch = n2.ssContent;
  2637. const newFallback = n2.ssFallback;
  2638. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2639. if (pendingBranch) {
  2640. suspense.pendingBranch = newBranch;
  2641. if (isSameVNodeType(newBranch, pendingBranch)) {
  2642. patch(
  2643. pendingBranch,
  2644. newBranch,
  2645. suspense.hiddenContainer,
  2646. null,
  2647. parentComponent,
  2648. suspense,
  2649. isSVG,
  2650. slotScopeIds,
  2651. optimized
  2652. );
  2653. if (suspense.deps <= 0) {
  2654. suspense.resolve();
  2655. } else if (isInFallback) {
  2656. patch(
  2657. activeBranch,
  2658. newFallback,
  2659. container,
  2660. anchor,
  2661. parentComponent,
  2662. null,
  2663. // fallback tree will not have suspense context
  2664. isSVG,
  2665. slotScopeIds,
  2666. optimized
  2667. );
  2668. setActiveBranch(suspense, newFallback);
  2669. }
  2670. } else {
  2671. suspense.pendingId++;
  2672. if (isHydrating) {
  2673. suspense.isHydrating = false;
  2674. suspense.activeBranch = pendingBranch;
  2675. } else {
  2676. unmount(pendingBranch, parentComponent, suspense);
  2677. }
  2678. suspense.deps = 0;
  2679. suspense.effects.length = 0;
  2680. suspense.hiddenContainer = createElement("div");
  2681. if (isInFallback) {
  2682. patch(
  2683. null,
  2684. newBranch,
  2685. suspense.hiddenContainer,
  2686. null,
  2687. parentComponent,
  2688. suspense,
  2689. isSVG,
  2690. slotScopeIds,
  2691. optimized
  2692. );
  2693. if (suspense.deps <= 0) {
  2694. suspense.resolve();
  2695. } else {
  2696. patch(
  2697. activeBranch,
  2698. newFallback,
  2699. container,
  2700. anchor,
  2701. parentComponent,
  2702. null,
  2703. // fallback tree will not have suspense context
  2704. isSVG,
  2705. slotScopeIds,
  2706. optimized
  2707. );
  2708. setActiveBranch(suspense, newFallback);
  2709. }
  2710. } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2711. patch(
  2712. activeBranch,
  2713. newBranch,
  2714. container,
  2715. anchor,
  2716. parentComponent,
  2717. suspense,
  2718. isSVG,
  2719. slotScopeIds,
  2720. optimized
  2721. );
  2722. suspense.resolve(true);
  2723. } else {
  2724. patch(
  2725. null,
  2726. newBranch,
  2727. suspense.hiddenContainer,
  2728. null,
  2729. parentComponent,
  2730. suspense,
  2731. isSVG,
  2732. slotScopeIds,
  2733. optimized
  2734. );
  2735. if (suspense.deps <= 0) {
  2736. suspense.resolve();
  2737. }
  2738. }
  2739. }
  2740. } else {
  2741. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2742. patch(
  2743. activeBranch,
  2744. newBranch,
  2745. container,
  2746. anchor,
  2747. parentComponent,
  2748. suspense,
  2749. isSVG,
  2750. slotScopeIds,
  2751. optimized
  2752. );
  2753. setActiveBranch(suspense, newBranch);
  2754. } else {
  2755. triggerEvent(n2, "onPending");
  2756. suspense.pendingBranch = newBranch;
  2757. suspense.pendingId++;
  2758. patch(
  2759. null,
  2760. newBranch,
  2761. suspense.hiddenContainer,
  2762. null,
  2763. parentComponent,
  2764. suspense,
  2765. isSVG,
  2766. slotScopeIds,
  2767. optimized
  2768. );
  2769. if (suspense.deps <= 0) {
  2770. suspense.resolve();
  2771. } else {
  2772. const { timeout, pendingId } = suspense;
  2773. if (timeout > 0) {
  2774. setTimeout(() => {
  2775. if (suspense.pendingId === pendingId) {
  2776. suspense.fallback(newFallback);
  2777. }
  2778. }, timeout);
  2779. } else if (timeout === 0) {
  2780. suspense.fallback(newFallback);
  2781. }
  2782. }
  2783. }
  2784. }
  2785. }
  2786. let hasWarned = false;
  2787. function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2788. if (!hasWarned) {
  2789. hasWarned = true;
  2790. console[console.info ? "info" : "log"](
  2791. `<Suspense> is an experimental feature and its API will likely change.`
  2792. );
  2793. }
  2794. const {
  2795. p: patch,
  2796. m: move,
  2797. um: unmount,
  2798. n: next,
  2799. o: { parentNode, remove }
  2800. } = rendererInternals;
  2801. let parentSuspenseId;
  2802. const isSuspensible = isVNodeSuspensible(vnode);
  2803. if (isSuspensible) {
  2804. if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
  2805. parentSuspenseId = parentSuspense.pendingId;
  2806. parentSuspense.deps++;
  2807. }
  2808. }
  2809. const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
  2810. {
  2811. assertNumber(timeout, `Suspense timeout`);
  2812. }
  2813. const suspense = {
  2814. vnode,
  2815. parent: parentSuspense,
  2816. parentComponent,
  2817. isSVG,
  2818. container,
  2819. hiddenContainer,
  2820. anchor,
  2821. deps: 0,
  2822. pendingId: 0,
  2823. timeout: typeof timeout === "number" ? timeout : -1,
  2824. activeBranch: null,
  2825. pendingBranch: null,
  2826. isInFallback: true,
  2827. isHydrating,
  2828. isUnmounted: false,
  2829. effects: [],
  2830. resolve(resume = false, sync = false) {
  2831. {
  2832. if (!resume && !suspense.pendingBranch) {
  2833. throw new Error(
  2834. `suspense.resolve() is called without a pending branch.`
  2835. );
  2836. }
  2837. if (suspense.isUnmounted) {
  2838. throw new Error(
  2839. `suspense.resolve() is called on an already unmounted suspense boundary.`
  2840. );
  2841. }
  2842. }
  2843. const {
  2844. vnode: vnode2,
  2845. activeBranch,
  2846. pendingBranch,
  2847. pendingId,
  2848. effects,
  2849. parentComponent: parentComponent2,
  2850. container: container2
  2851. } = suspense;
  2852. if (suspense.isHydrating) {
  2853. suspense.isHydrating = false;
  2854. } else if (!resume) {
  2855. const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
  2856. if (delayEnter) {
  2857. activeBranch.transition.afterLeave = () => {
  2858. if (pendingId === suspense.pendingId) {
  2859. move(pendingBranch, container2, anchor2, 0);
  2860. }
  2861. };
  2862. }
  2863. let { anchor: anchor2 } = suspense;
  2864. if (activeBranch) {
  2865. anchor2 = next(activeBranch);
  2866. unmount(activeBranch, parentComponent2, suspense, true);
  2867. }
  2868. if (!delayEnter) {
  2869. move(pendingBranch, container2, anchor2, 0);
  2870. }
  2871. }
  2872. setActiveBranch(suspense, pendingBranch);
  2873. suspense.pendingBranch = null;
  2874. suspense.isInFallback = false;
  2875. let parent = suspense.parent;
  2876. let hasUnresolvedAncestor = false;
  2877. while (parent) {
  2878. if (parent.pendingBranch) {
  2879. parent.effects.push(...effects);
  2880. hasUnresolvedAncestor = true;
  2881. break;
  2882. }
  2883. parent = parent.parent;
  2884. }
  2885. if (!hasUnresolvedAncestor) {
  2886. queuePostFlushCb(effects);
  2887. }
  2888. suspense.effects = [];
  2889. if (isSuspensible) {
  2890. if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
  2891. parentSuspense.deps--;
  2892. if (parentSuspense.deps === 0 && !sync) {
  2893. parentSuspense.resolve();
  2894. }
  2895. }
  2896. }
  2897. triggerEvent(vnode2, "onResolve");
  2898. },
  2899. fallback(fallbackVNode) {
  2900. if (!suspense.pendingBranch) {
  2901. return;
  2902. }
  2903. const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, isSVG: isSVG2 } = suspense;
  2904. triggerEvent(vnode2, "onFallback");
  2905. const anchor2 = next(activeBranch);
  2906. const mountFallback = () => {
  2907. if (!suspense.isInFallback) {
  2908. return;
  2909. }
  2910. patch(
  2911. null,
  2912. fallbackVNode,
  2913. container2,
  2914. anchor2,
  2915. parentComponent2,
  2916. null,
  2917. // fallback tree will not have suspense context
  2918. isSVG2,
  2919. slotScopeIds,
  2920. optimized
  2921. );
  2922. setActiveBranch(suspense, fallbackVNode);
  2923. };
  2924. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
  2925. if (delayEnter) {
  2926. activeBranch.transition.afterLeave = mountFallback;
  2927. }
  2928. suspense.isInFallback = true;
  2929. unmount(
  2930. activeBranch,
  2931. parentComponent2,
  2932. null,
  2933. // no suspense so unmount hooks fire now
  2934. true
  2935. // shouldRemove
  2936. );
  2937. if (!delayEnter) {
  2938. mountFallback();
  2939. }
  2940. },
  2941. move(container2, anchor2, type) {
  2942. suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
  2943. suspense.container = container2;
  2944. },
  2945. next() {
  2946. return suspense.activeBranch && next(suspense.activeBranch);
  2947. },
  2948. registerDep(instance, setupRenderEffect) {
  2949. const isInPendingSuspense = !!suspense.pendingBranch;
  2950. if (isInPendingSuspense) {
  2951. suspense.deps++;
  2952. }
  2953. const hydratedEl = instance.vnode.el;
  2954. instance.asyncDep.catch((err) => {
  2955. handleError(err, instance, 0);
  2956. }).then((asyncSetupResult) => {
  2957. if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
  2958. return;
  2959. }
  2960. instance.asyncResolved = true;
  2961. const { vnode: vnode2 } = instance;
  2962. {
  2963. pushWarningContext(vnode2);
  2964. }
  2965. handleSetupResult(instance, asyncSetupResult, false);
  2966. if (hydratedEl) {
  2967. vnode2.el = hydratedEl;
  2968. }
  2969. const placeholder = !hydratedEl && instance.subTree.el;
  2970. setupRenderEffect(
  2971. instance,
  2972. vnode2,
  2973. // component may have been moved before resolve.
  2974. // if this is not a hydration, instance.subTree will be the comment
  2975. // placeholder.
  2976. parentNode(hydratedEl || instance.subTree.el),
  2977. // anchor will not be used if this is hydration, so only need to
  2978. // consider the comment placeholder case.
  2979. hydratedEl ? null : next(instance.subTree),
  2980. suspense,
  2981. isSVG,
  2982. optimized
  2983. );
  2984. if (placeholder) {
  2985. remove(placeholder);
  2986. }
  2987. updateHOCHostEl(instance, vnode2.el);
  2988. {
  2989. popWarningContext();
  2990. }
  2991. if (isInPendingSuspense && --suspense.deps === 0) {
  2992. suspense.resolve();
  2993. }
  2994. });
  2995. },
  2996. unmount(parentSuspense2, doRemove) {
  2997. suspense.isUnmounted = true;
  2998. if (suspense.activeBranch) {
  2999. unmount(
  3000. suspense.activeBranch,
  3001. parentComponent,
  3002. parentSuspense2,
  3003. doRemove
  3004. );
  3005. }
  3006. if (suspense.pendingBranch) {
  3007. unmount(
  3008. suspense.pendingBranch,
  3009. parentComponent,
  3010. parentSuspense2,
  3011. doRemove
  3012. );
  3013. }
  3014. }
  3015. };
  3016. return suspense;
  3017. }
  3018. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  3019. const suspense = vnode.suspense = createSuspenseBoundary(
  3020. vnode,
  3021. parentSuspense,
  3022. parentComponent,
  3023. node.parentNode,
  3024. document.createElement("div"),
  3025. null,
  3026. isSVG,
  3027. slotScopeIds,
  3028. optimized,
  3029. rendererInternals,
  3030. true
  3031. /* hydrating */
  3032. );
  3033. const result = hydrateNode(
  3034. node,
  3035. suspense.pendingBranch = vnode.ssContent,
  3036. parentComponent,
  3037. suspense,
  3038. slotScopeIds,
  3039. optimized
  3040. );
  3041. if (suspense.deps === 0) {
  3042. suspense.resolve(false, true);
  3043. }
  3044. return result;
  3045. }
  3046. function normalizeSuspenseChildren(vnode) {
  3047. const { shapeFlag, children } = vnode;
  3048. const isSlotChildren = shapeFlag & 32;
  3049. vnode.ssContent = normalizeSuspenseSlot(
  3050. isSlotChildren ? children.default : children
  3051. );
  3052. vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
  3053. }
  3054. function normalizeSuspenseSlot(s) {
  3055. let block;
  3056. if (isFunction(s)) {
  3057. const trackBlock = isBlockTreeEnabled && s._c;
  3058. if (trackBlock) {
  3059. s._d = false;
  3060. openBlock();
  3061. }
  3062. s = s();
  3063. if (trackBlock) {
  3064. s._d = true;
  3065. block = currentBlock;
  3066. closeBlock();
  3067. }
  3068. }
  3069. if (isArray(s)) {
  3070. const singleChild = filterSingleRoot(s);
  3071. if (!singleChild) {
  3072. warn(`<Suspense> slots expect a single root node.`);
  3073. }
  3074. s = singleChild;
  3075. }
  3076. s = normalizeVNode(s);
  3077. if (block && !s.dynamicChildren) {
  3078. s.dynamicChildren = block.filter((c) => c !== s);
  3079. }
  3080. return s;
  3081. }
  3082. function queueEffectWithSuspense(fn, suspense) {
  3083. if (suspense && suspense.pendingBranch) {
  3084. if (isArray(fn)) {
  3085. suspense.effects.push(...fn);
  3086. } else {
  3087. suspense.effects.push(fn);
  3088. }
  3089. } else {
  3090. queuePostFlushCb(fn);
  3091. }
  3092. }
  3093. function setActiveBranch(suspense, branch) {
  3094. suspense.activeBranch = branch;
  3095. const { vnode, parentComponent } = suspense;
  3096. const el = vnode.el = branch.el;
  3097. if (parentComponent && parentComponent.subTree === vnode) {
  3098. parentComponent.vnode.el = el;
  3099. updateHOCHostEl(parentComponent, el);
  3100. }
  3101. }
  3102. function isVNodeSuspensible(vnode) {
  3103. var _a;
  3104. return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
  3105. }
  3106.  
  3107. function watchEffect(effect, options) {
  3108. return doWatch(effect, null, options);
  3109. }
  3110. function watchPostEffect(effect, options) {
  3111. return doWatch(
  3112. effect,
  3113. null,
  3114. extend({}, options, { flush: "post" })
  3115. );
  3116. }
  3117. function watchSyncEffect(effect, options) {
  3118. return doWatch(
  3119. effect,
  3120. null,
  3121. extend({}, options, { flush: "sync" })
  3122. );
  3123. }
  3124. const INITIAL_WATCHER_VALUE = {};
  3125. function watch(source, cb, options) {
  3126. if (!isFunction(cb)) {
  3127. warn(
  3128. `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
  3129. );
  3130. }
  3131. return doWatch(source, cb, options);
  3132. }
  3133. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3134. var _a;
  3135. if (!cb) {
  3136. if (immediate !== void 0) {
  3137. warn(
  3138. `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
  3139. );
  3140. }
  3141. if (deep !== void 0) {
  3142. warn(
  3143. `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
  3144. );
  3145. }
  3146. }
  3147. const warnInvalidSource = (s) => {
  3148. warn(
  3149. `Invalid watch source: `,
  3150. s,
  3151. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  3152. );
  3153. };
  3154. const instance = getCurrentScope() === ((_a = currentInstance) == null ? void 0 : _a.scope) ? currentInstance : null;
  3155. let getter;
  3156. let forceTrigger = false;
  3157. let isMultiSource = false;
  3158. if (isRef(source)) {
  3159. getter = () => source.value;
  3160. forceTrigger = isShallow(source);
  3161. } else if (isReactive(source)) {
  3162. getter = () => source;
  3163. deep = true;
  3164. } else if (isArray(source)) {
  3165. isMultiSource = true;
  3166. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  3167. getter = () => source.map((s) => {
  3168. if (isRef(s)) {
  3169. return s.value;
  3170. } else if (isReactive(s)) {
  3171. return traverse(s);
  3172. } else if (isFunction(s)) {
  3173. return callWithErrorHandling(s, instance, 2);
  3174. } else {
  3175. warnInvalidSource(s);
  3176. }
  3177. });
  3178. } else if (isFunction(source)) {
  3179. if (cb) {
  3180. getter = () => callWithErrorHandling(source, instance, 2);
  3181. } else {
  3182. getter = () => {
  3183. if (instance && instance.isUnmounted) {
  3184. return;
  3185. }
  3186. if (cleanup) {
  3187. cleanup();
  3188. }
  3189. return callWithAsyncErrorHandling(
  3190. source,
  3191. instance,
  3192. 3,
  3193. [onCleanup]
  3194. );
  3195. };
  3196. }
  3197. } else {
  3198. getter = NOOP;
  3199. warnInvalidSource(source);
  3200. }
  3201. if (cb && deep) {
  3202. const baseGetter = getter;
  3203. getter = () => traverse(baseGetter());
  3204. }
  3205. let cleanup;
  3206. let onCleanup = (fn) => {
  3207. cleanup = effect.onStop = () => {
  3208. callWithErrorHandling(fn, instance, 4);
  3209. };
  3210. };
  3211. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  3212. const job = () => {
  3213. if (!effect.active) {
  3214. return;
  3215. }
  3216. if (cb) {
  3217. const newValue = effect.run();
  3218. if (deep || forceTrigger || (isMultiSource ? newValue.some(
  3219. (v, i) => hasChanged(v, oldValue[i])
  3220. ) : hasChanged(newValue, oldValue)) || false) {
  3221. if (cleanup) {
  3222. cleanup();
  3223. }
  3224. callWithAsyncErrorHandling(cb, instance, 3, [
  3225. newValue,
  3226. // pass undefined as the old value when it's changed for the first time
  3227. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  3228. onCleanup
  3229. ]);
  3230. oldValue = newValue;
  3231. }
  3232. } else {
  3233. effect.run();
  3234. }
  3235. };
  3236. job.allowRecurse = !!cb;
  3237. let scheduler;
  3238. if (flush === "sync") {
  3239. scheduler = job;
  3240. } else if (flush === "post") {
  3241. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3242. } else {
  3243. job.pre = true;
  3244. if (instance)
  3245. job.id = instance.uid;
  3246. scheduler = () => queueJob(job);
  3247. }
  3248. const effect = new ReactiveEffect(getter, scheduler);
  3249. {
  3250. effect.onTrack = onTrack;
  3251. effect.onTrigger = onTrigger;
  3252. }
  3253. if (cb) {
  3254. if (immediate) {
  3255. job();
  3256. } else {
  3257. oldValue = effect.run();
  3258. }
  3259. } else if (flush === "post") {
  3260. queuePostRenderEffect(
  3261. effect.run.bind(effect),
  3262. instance && instance.suspense
  3263. );
  3264. } else {
  3265. effect.run();
  3266. }
  3267. const unwatch = () => {
  3268. effect.stop();
  3269. if (instance && instance.scope) {
  3270. remove(instance.scope.effects, effect);
  3271. }
  3272. };
  3273. return unwatch;
  3274. }
  3275. function instanceWatch(source, value, options) {
  3276. const publicThis = this.proxy;
  3277. const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
  3278. let cb;
  3279. if (isFunction(value)) {
  3280. cb = value;
  3281. } else {
  3282. cb = value.handler;
  3283. options = value;
  3284. }
  3285. const cur = currentInstance;
  3286. setCurrentInstance(this);
  3287. const res = doWatch(getter, cb.bind(publicThis), options);
  3288. if (cur) {
  3289. setCurrentInstance(cur);
  3290. } else {
  3291. unsetCurrentInstance();
  3292. }
  3293. return res;
  3294. }
  3295. function createPathGetter(ctx, path) {
  3296. const segments = path.split(".");
  3297. return () => {
  3298. let cur = ctx;
  3299. for (let i = 0; i < segments.length && cur; i++) {
  3300. cur = cur[segments[i]];
  3301. }
  3302. return cur;
  3303. };
  3304. }
  3305. function traverse(value, seen) {
  3306. if (!isObject(value) || value["__v_skip"]) {
  3307. return value;
  3308. }
  3309. seen = seen || /* @__PURE__ */ new Set();
  3310. if (seen.has(value)) {
  3311. return value;
  3312. }
  3313. seen.add(value);
  3314. if (isRef(value)) {
  3315. traverse(value.value, seen);
  3316. } else if (isArray(value)) {
  3317. for (let i = 0; i < value.length; i++) {
  3318. traverse(value[i], seen);
  3319. }
  3320. } else if (isSet(value) || isMap(value)) {
  3321. value.forEach((v) => {
  3322. traverse(v, seen);
  3323. });
  3324. } else if (isPlainObject(value)) {
  3325. for (const key in value) {
  3326. traverse(value[key], seen);
  3327. }
  3328. }
  3329. return value;
  3330. }
  3331.  
  3332. function validateDirectiveName(name) {
  3333. if (isBuiltInDirective(name)) {
  3334. warn("Do not use built-in directive ids as custom directive id: " + name);
  3335. }
  3336. }
  3337. function withDirectives(vnode, directives) {
  3338. const internalInstance = currentRenderingInstance;
  3339. if (internalInstance === null) {
  3340. warn(`withDirectives can only be used inside render functions.`);
  3341. return vnode;
  3342. }
  3343. const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
  3344. const bindings = vnode.dirs || (vnode.dirs = []);
  3345. for (let i = 0; i < directives.length; i++) {
  3346. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  3347. if (dir) {
  3348. if (isFunction(dir)) {
  3349. dir = {
  3350. mounted: dir,
  3351. updated: dir
  3352. };
  3353. }
  3354. if (dir.deep) {
  3355. traverse(value);
  3356. }
  3357. bindings.push({
  3358. dir,
  3359. instance,
  3360. value,
  3361. oldValue: void 0,
  3362. arg,
  3363. modifiers
  3364. });
  3365. }
  3366. }
  3367. return vnode;
  3368. }
  3369. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  3370. const bindings = vnode.dirs;
  3371. const oldBindings = prevVNode && prevVNode.dirs;
  3372. for (let i = 0; i < bindings.length; i++) {
  3373. const binding = bindings[i];
  3374. if (oldBindings) {
  3375. binding.oldValue = oldBindings[i].value;
  3376. }
  3377. let hook = binding.dir[name];
  3378. if (hook) {
  3379. pauseTracking();
  3380. callWithAsyncErrorHandling(hook, instance, 8, [
  3381. vnode.el,
  3382. binding,
  3383. vnode,
  3384. prevVNode
  3385. ]);
  3386. resetTracking();
  3387. }
  3388. }
  3389. }
  3390.  
  3391. function useTransitionState() {
  3392. const state = {
  3393. isMounted: false,
  3394. isLeaving: false,
  3395. isUnmounting: false,
  3396. leavingVNodes: /* @__PURE__ */ new Map()
  3397. };
  3398. onMounted(() => {
  3399. state.isMounted = true;
  3400. });
  3401. onBeforeUnmount(() => {
  3402. state.isUnmounting = true;
  3403. });
  3404. return state;
  3405. }
  3406. const TransitionHookValidator = [Function, Array];
  3407. const BaseTransitionPropsValidators = {
  3408. mode: String,
  3409. appear: Boolean,
  3410. persisted: Boolean,
  3411. // enter
  3412. onBeforeEnter: TransitionHookValidator,
  3413. onEnter: TransitionHookValidator,
  3414. onAfterEnter: TransitionHookValidator,
  3415. onEnterCancelled: TransitionHookValidator,
  3416. // leave
  3417. onBeforeLeave: TransitionHookValidator,
  3418. onLeave: TransitionHookValidator,
  3419. onAfterLeave: TransitionHookValidator,
  3420. onLeaveCancelled: TransitionHookValidator,
  3421. // appear
  3422. onBeforeAppear: TransitionHookValidator,
  3423. onAppear: TransitionHookValidator,
  3424. onAfterAppear: TransitionHookValidator,
  3425. onAppearCancelled: TransitionHookValidator
  3426. };
  3427. const BaseTransitionImpl = {
  3428. name: `BaseTransition`,
  3429. props: BaseTransitionPropsValidators,
  3430. setup(props, { slots }) {
  3431. const instance = getCurrentInstance();
  3432. const state = useTransitionState();
  3433. let prevTransitionKey;
  3434. return () => {
  3435. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3436. if (!children || !children.length) {
  3437. return;
  3438. }
  3439. let child = children[0];
  3440. if (children.length > 1) {
  3441. let hasFound = false;
  3442. for (const c of children) {
  3443. if (c.type !== Comment) {
  3444. if (hasFound) {
  3445. warn(
  3446. "<transition> can only be used on a single element or component. Use <transition-group> for lists."
  3447. );
  3448. break;
  3449. }
  3450. child = c;
  3451. hasFound = true;
  3452. }
  3453. }
  3454. }
  3455. const rawProps = toRaw(props);
  3456. const { mode } = rawProps;
  3457. if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
  3458. warn(`invalid <transition> mode: ${mode}`);
  3459. }
  3460. if (state.isLeaving) {
  3461. return emptyPlaceholder(child);
  3462. }
  3463. const innerChild = getKeepAliveChild(child);
  3464. if (!innerChild) {
  3465. return emptyPlaceholder(child);
  3466. }
  3467. const enterHooks = resolveTransitionHooks(
  3468. innerChild,
  3469. rawProps,
  3470. state,
  3471. instance
  3472. );
  3473. setTransitionHooks(innerChild, enterHooks);
  3474. const oldChild = instance.subTree;
  3475. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3476. let transitionKeyChanged = false;
  3477. const { getTransitionKey } = innerChild.type;
  3478. if (getTransitionKey) {
  3479. const key = getTransitionKey();
  3480. if (prevTransitionKey === void 0) {
  3481. prevTransitionKey = key;
  3482. } else if (key !== prevTransitionKey) {
  3483. prevTransitionKey = key;
  3484. transitionKeyChanged = true;
  3485. }
  3486. }
  3487. if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3488. const leavingHooks = resolveTransitionHooks(
  3489. oldInnerChild,
  3490. rawProps,
  3491. state,
  3492. instance
  3493. );
  3494. setTransitionHooks(oldInnerChild, leavingHooks);
  3495. if (mode === "out-in") {
  3496. state.isLeaving = true;
  3497. leavingHooks.afterLeave = () => {
  3498. state.isLeaving = false;
  3499. if (instance.update.active !== false) {
  3500. instance.update();
  3501. }
  3502. };
  3503. return emptyPlaceholder(child);
  3504. } else if (mode === "in-out" && innerChild.type !== Comment) {
  3505. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3506. const leavingVNodesCache = getLeavingNodesForType(
  3507. state,
  3508. oldInnerChild
  3509. );
  3510. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3511. el._leaveCb = () => {
  3512. earlyRemove();
  3513. el._leaveCb = void 0;
  3514. delete enterHooks.delayedLeave;
  3515. };
  3516. enterHooks.delayedLeave = delayedLeave;
  3517. };
  3518. }
  3519. }
  3520. return child;
  3521. };
  3522. }
  3523. };
  3524. const BaseTransition = BaseTransitionImpl;
  3525. function getLeavingNodesForType(state, vnode) {
  3526. const { leavingVNodes } = state;
  3527. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3528. if (!leavingVNodesCache) {
  3529. leavingVNodesCache = /* @__PURE__ */ Object.create(null);
  3530. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3531. }
  3532. return leavingVNodesCache;
  3533. }
  3534. function resolveTransitionHooks(vnode, props, state, instance) {
  3535. const {
  3536. appear,
  3537. mode,
  3538. persisted = false,
  3539. onBeforeEnter,
  3540. onEnter,
  3541. onAfterEnter,
  3542. onEnterCancelled,
  3543. onBeforeLeave,
  3544. onLeave,
  3545. onAfterLeave,
  3546. onLeaveCancelled,
  3547. onBeforeAppear,
  3548. onAppear,
  3549. onAfterAppear,
  3550. onAppearCancelled
  3551. } = props;
  3552. const key = String(vnode.key);
  3553. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3554. const callHook = (hook, args) => {
  3555. hook && callWithAsyncErrorHandling(
  3556. hook,
  3557. instance,
  3558. 9,
  3559. args
  3560. );
  3561. };
  3562. const callAsyncHook = (hook, args) => {
  3563. const done = args[1];
  3564. callHook(hook, args);
  3565. if (isArray(hook)) {
  3566. if (hook.every((hook2) => hook2.length <= 1))
  3567. done();
  3568. } else if (hook.length <= 1) {
  3569. done();
  3570. }
  3571. };
  3572. const hooks = {
  3573. mode,
  3574. persisted,
  3575. beforeEnter(el) {
  3576. let hook = onBeforeEnter;
  3577. if (!state.isMounted) {
  3578. if (appear) {
  3579. hook = onBeforeAppear || onBeforeEnter;
  3580. } else {
  3581. return;
  3582. }
  3583. }
  3584. if (el._leaveCb) {
  3585. el._leaveCb(
  3586. true
  3587. /* cancelled */
  3588. );
  3589. }
  3590. const leavingVNode = leavingVNodesCache[key];
  3591. if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) {
  3592. leavingVNode.el._leaveCb();
  3593. }
  3594. callHook(hook, [el]);
  3595. },
  3596. enter(el) {
  3597. let hook = onEnter;
  3598. let afterHook = onAfterEnter;
  3599. let cancelHook = onEnterCancelled;
  3600. if (!state.isMounted) {
  3601. if (appear) {
  3602. hook = onAppear || onEnter;
  3603. afterHook = onAfterAppear || onAfterEnter;
  3604. cancelHook = onAppearCancelled || onEnterCancelled;
  3605. } else {
  3606. return;
  3607. }
  3608. }
  3609. let called = false;
  3610. const done = el._enterCb = (cancelled) => {
  3611. if (called)
  3612. return;
  3613. called = true;
  3614. if (cancelled) {
  3615. callHook(cancelHook, [el]);
  3616. } else {
  3617. callHook(afterHook, [el]);
  3618. }
  3619. if (hooks.delayedLeave) {
  3620. hooks.delayedLeave();
  3621. }
  3622. el._enterCb = void 0;
  3623. };
  3624. if (hook) {
  3625. callAsyncHook(hook, [el, done]);
  3626. } else {
  3627. done();
  3628. }
  3629. },
  3630. leave(el, remove) {
  3631. const key2 = String(vnode.key);
  3632. if (el._enterCb) {
  3633. el._enterCb(
  3634. true
  3635. /* cancelled */
  3636. );
  3637. }
  3638. if (state.isUnmounting) {
  3639. return remove();
  3640. }
  3641. callHook(onBeforeLeave, [el]);
  3642. let called = false;
  3643. const done = el._leaveCb = (cancelled) => {
  3644. if (called)
  3645. return;
  3646. called = true;
  3647. remove();
  3648. if (cancelled) {
  3649. callHook(onLeaveCancelled, [el]);
  3650. } else {
  3651. callHook(onAfterLeave, [el]);
  3652. }
  3653. el._leaveCb = void 0;
  3654. if (leavingVNodesCache[key2] === vnode) {
  3655. delete leavingVNodesCache[key2];
  3656. }
  3657. };
  3658. leavingVNodesCache[key2] = vnode;
  3659. if (onLeave) {
  3660. callAsyncHook(onLeave, [el, done]);
  3661. } else {
  3662. done();
  3663. }
  3664. },
  3665. clone(vnode2) {
  3666. return resolveTransitionHooks(vnode2, props, state, instance);
  3667. }
  3668. };
  3669. return hooks;
  3670. }
  3671. function emptyPlaceholder(vnode) {
  3672. if (isKeepAlive(vnode)) {
  3673. vnode = cloneVNode(vnode);
  3674. vnode.children = null;
  3675. return vnode;
  3676. }
  3677. }
  3678. function getKeepAliveChild(vnode) {
  3679. return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
  3680. }
  3681. function setTransitionHooks(vnode, hooks) {
  3682. if (vnode.shapeFlag & 6 && vnode.component) {
  3683. setTransitionHooks(vnode.component.subTree, hooks);
  3684. } else if (vnode.shapeFlag & 128) {
  3685. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3686. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3687. } else {
  3688. vnode.transition = hooks;
  3689. }
  3690. }
  3691. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3692. let ret = [];
  3693. let keyedFragmentCount = 0;
  3694. for (let i = 0; i < children.length; i++) {
  3695. let child = children[i];
  3696. const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
  3697. if (child.type === Fragment) {
  3698. if (child.patchFlag & 128)
  3699. keyedFragmentCount++;
  3700. ret = ret.concat(
  3701. getTransitionRawChildren(child.children, keepComment, key)
  3702. );
  3703. } else if (keepComment || child.type !== Comment) {
  3704. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3705. }
  3706. }
  3707. if (keyedFragmentCount > 1) {
  3708. for (let i = 0; i < ret.length; i++) {
  3709. ret[i].patchFlag = -2;
  3710. }
  3711. }
  3712. return ret;
  3713. }
  3714.  
  3715. function defineComponent(options, extraOptions) {
  3716. return isFunction(options) ? (
  3717. // #8326: extend call and options.name access are considered side-effects
  3718. // by Rollup, so we have to wrap it in a pure-annotated IIFE.
  3719. /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
  3720. ) : options;
  3721. }
  3722.  
  3723. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3724. function defineAsyncComponent(source) {
  3725. if (isFunction(source)) {
  3726. source = { loader: source };
  3727. }
  3728. const {
  3729. loader,
  3730. loadingComponent,
  3731. errorComponent,
  3732. delay = 200,
  3733. timeout,
  3734. // undefined = never times out
  3735. suspensible = true,
  3736. onError: userOnError
  3737. } = source;
  3738. let pendingRequest = null;
  3739. let resolvedComp;
  3740. let retries = 0;
  3741. const retry = () => {
  3742. retries++;
  3743. pendingRequest = null;
  3744. return load();
  3745. };
  3746. const load = () => {
  3747. let thisRequest;
  3748. return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
  3749. err = err instanceof Error ? err : new Error(String(err));
  3750. if (userOnError) {
  3751. return new Promise((resolve, reject) => {
  3752. const userRetry = () => resolve(retry());
  3753. const userFail = () => reject(err);
  3754. userOnError(err, userRetry, userFail, retries + 1);
  3755. });
  3756. } else {
  3757. throw err;
  3758. }
  3759. }).then((comp) => {
  3760. if (thisRequest !== pendingRequest && pendingRequest) {
  3761. return pendingRequest;
  3762. }
  3763. if (!comp) {
  3764. warn(
  3765. `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
  3766. );
  3767. }
  3768. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
  3769. comp = comp.default;
  3770. }
  3771. if (comp && !isObject(comp) && !isFunction(comp)) {
  3772. throw new Error(`Invalid async component load result: ${comp}`);
  3773. }
  3774. resolvedComp = comp;
  3775. return comp;
  3776. }));
  3777. };
  3778. return defineComponent({
  3779. name: "AsyncComponentWrapper",
  3780. __asyncLoader: load,
  3781. get __asyncResolved() {
  3782. return resolvedComp;
  3783. },
  3784. setup() {
  3785. const instance = currentInstance;
  3786. if (resolvedComp) {
  3787. return () => createInnerComp(resolvedComp, instance);
  3788. }
  3789. const onError = (err) => {
  3790. pendingRequest = null;
  3791. handleError(
  3792. err,
  3793. instance,
  3794. 13,
  3795. !errorComponent
  3796. /* do not throw in dev if user provided error component */
  3797. );
  3798. };
  3799. if (suspensible && instance.suspense || false) {
  3800. return load().then((comp) => {
  3801. return () => createInnerComp(comp, instance);
  3802. }).catch((err) => {
  3803. onError(err);
  3804. return () => errorComponent ? createVNode(errorComponent, {
  3805. error: err
  3806. }) : null;
  3807. });
  3808. }
  3809. const loaded = ref(false);
  3810. const error = ref();
  3811. const delayed = ref(!!delay);
  3812. if (delay) {
  3813. setTimeout(() => {
  3814. delayed.value = false;
  3815. }, delay);
  3816. }
  3817. if (timeout != null) {
  3818. setTimeout(() => {
  3819. if (!loaded.value && !error.value) {
  3820. const err = new Error(
  3821. `Async component timed out after ${timeout}ms.`
  3822. );
  3823. onError(err);
  3824. error.value = err;
  3825. }
  3826. }, timeout);
  3827. }
  3828. load().then(() => {
  3829. loaded.value = true;
  3830. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3831. queueJob(instance.parent.update);
  3832. }
  3833. }).catch((err) => {
  3834. onError(err);
  3835. error.value = err;
  3836. });
  3837. return () => {
  3838. if (loaded.value && resolvedComp) {
  3839. return createInnerComp(resolvedComp, instance);
  3840. } else if (error.value && errorComponent) {
  3841. return createVNode(errorComponent, {
  3842. error: error.value
  3843. });
  3844. } else if (loadingComponent && !delayed.value) {
  3845. return createVNode(loadingComponent);
  3846. }
  3847. };
  3848. }
  3849. });
  3850. }
  3851. function createInnerComp(comp, parent) {
  3852. const { ref: ref2, props, children, ce } = parent.vnode;
  3853. const vnode = createVNode(comp, props, children);
  3854. vnode.ref = ref2;
  3855. vnode.ce = ce;
  3856. delete parent.vnode.ce;
  3857. return vnode;
  3858. }
  3859.  
  3860. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3861. const KeepAliveImpl = {
  3862. name: `KeepAlive`,
  3863. // Marker for special handling inside the renderer. We are not using a ===
  3864. // check directly on KeepAlive in the renderer, because importing it directly
  3865. // would prevent it from being tree-shaken.
  3866. __isKeepAlive: true,
  3867. props: {
  3868. include: [String, RegExp, Array],
  3869. exclude: [String, RegExp, Array],
  3870. max: [String, Number]
  3871. },
  3872. setup(props, { slots }) {
  3873. const instance = getCurrentInstance();
  3874. const sharedContext = instance.ctx;
  3875. const cache = /* @__PURE__ */ new Map();
  3876. const keys = /* @__PURE__ */ new Set();
  3877. let current = null;
  3878. {
  3879. instance.__v_cache = cache;
  3880. }
  3881. const parentSuspense = instance.suspense;
  3882. const {
  3883. renderer: {
  3884. p: patch,
  3885. m: move,
  3886. um: _unmount,
  3887. o: { createElement }
  3888. }
  3889. } = sharedContext;
  3890. const storageContainer = createElement("div");
  3891. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3892. const instance2 = vnode.component;
  3893. move(vnode, container, anchor, 0, parentSuspense);
  3894. patch(
  3895. instance2.vnode,
  3896. vnode,
  3897. container,
  3898. anchor,
  3899. instance2,
  3900. parentSuspense,
  3901. isSVG,
  3902. vnode.slotScopeIds,
  3903. optimized
  3904. );
  3905. queuePostRenderEffect(() => {
  3906. instance2.isDeactivated = false;
  3907. if (instance2.a) {
  3908. invokeArrayFns(instance2.a);
  3909. }
  3910. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3911. if (vnodeHook) {
  3912. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  3913. }
  3914. }, parentSuspense);
  3915. {
  3916. devtoolsComponentAdded(instance2);
  3917. }
  3918. };
  3919. sharedContext.deactivate = (vnode) => {
  3920. const instance2 = vnode.component;
  3921. move(vnode, storageContainer, null, 1, parentSuspense);
  3922. queuePostRenderEffect(() => {
  3923. if (instance2.da) {
  3924. invokeArrayFns(instance2.da);
  3925. }
  3926. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3927. if (vnodeHook) {
  3928. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  3929. }
  3930. instance2.isDeactivated = true;
  3931. }, parentSuspense);
  3932. {
  3933. devtoolsComponentAdded(instance2);
  3934. }
  3935. };
  3936. function unmount(vnode) {
  3937. resetShapeFlag(vnode);
  3938. _unmount(vnode, instance, parentSuspense, true);
  3939. }
  3940. function pruneCache(filter) {
  3941. cache.forEach((vnode, key) => {
  3942. const name = getComponentName(vnode.type);
  3943. if (name && (!filter || !filter(name))) {
  3944. pruneCacheEntry(key);
  3945. }
  3946. });
  3947. }
  3948. function pruneCacheEntry(key) {
  3949. const cached = cache.get(key);
  3950. if (!current || !isSameVNodeType(cached, current)) {
  3951. unmount(cached);
  3952. } else if (current) {
  3953. resetShapeFlag(current);
  3954. }
  3955. cache.delete(key);
  3956. keys.delete(key);
  3957. }
  3958. watch(
  3959. () => [props.include, props.exclude],
  3960. ([include, exclude]) => {
  3961. include && pruneCache((name) => matches(include, name));
  3962. exclude && pruneCache((name) => !matches(exclude, name));
  3963. },
  3964. // prune post-render after `current` has been updated
  3965. { flush: "post", deep: true }
  3966. );
  3967. let pendingCacheKey = null;
  3968. const cacheSubtree = () => {
  3969. if (pendingCacheKey != null) {
  3970. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3971. }
  3972. };
  3973. onMounted(cacheSubtree);
  3974. onUpdated(cacheSubtree);
  3975. onBeforeUnmount(() => {
  3976. cache.forEach((cached) => {
  3977. const { subTree, suspense } = instance;
  3978. const vnode = getInnerChild(subTree);
  3979. if (cached.type === vnode.type && cached.key === vnode.key) {
  3980. resetShapeFlag(vnode);
  3981. const da = vnode.component.da;
  3982. da && queuePostRenderEffect(da, suspense);
  3983. return;
  3984. }
  3985. unmount(cached);
  3986. });
  3987. });
  3988. return () => {
  3989. pendingCacheKey = null;
  3990. if (!slots.default) {
  3991. return null;
  3992. }
  3993. const children = slots.default();
  3994. const rawVNode = children[0];
  3995. if (children.length > 1) {
  3996. {
  3997. warn(`KeepAlive should contain exactly one component child.`);
  3998. }
  3999. current = null;
  4000. return children;
  4001. } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
  4002. current = null;
  4003. return rawVNode;
  4004. }
  4005. let vnode = getInnerChild(rawVNode);
  4006. const comp = vnode.type;
  4007. const name = getComponentName(
  4008. isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
  4009. );
  4010. const { include, exclude, max } = props;
  4011. if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
  4012. current = vnode;
  4013. return rawVNode;
  4014. }
  4015. const key = vnode.key == null ? comp : vnode.key;
  4016. const cachedVNode = cache.get(key);
  4017. if (vnode.el) {
  4018. vnode = cloneVNode(vnode);
  4019. if (rawVNode.shapeFlag & 128) {
  4020. rawVNode.ssContent = vnode;
  4021. }
  4022. }
  4023. pendingCacheKey = key;
  4024. if (cachedVNode) {
  4025. vnode.el = cachedVNode.el;
  4026. vnode.component = cachedVNode.component;
  4027. if (vnode.transition) {
  4028. setTransitionHooks(vnode, vnode.transition);
  4029. }
  4030. vnode.shapeFlag |= 512;
  4031. keys.delete(key);
  4032. keys.add(key);
  4033. } else {
  4034. keys.add(key);
  4035. if (max && keys.size > parseInt(max, 10)) {
  4036. pruneCacheEntry(keys.values().next().value);
  4037. }
  4038. }
  4039. vnode.shapeFlag |= 256;
  4040. current = vnode;
  4041. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  4042. };
  4043. }
  4044. };
  4045. const KeepAlive = KeepAliveImpl;
  4046. function matches(pattern, name) {
  4047. if (isArray(pattern)) {
  4048. return pattern.some((p) => matches(p, name));
  4049. } else if (isString(pattern)) {
  4050. return pattern.split(",").includes(name);
  4051. } else if (isRegExp(pattern)) {
  4052. return pattern.test(name);
  4053. }
  4054. return false;
  4055. }
  4056. function onActivated(hook, target) {
  4057. registerKeepAliveHook(hook, "a", target);
  4058. }
  4059. function onDeactivated(hook, target) {
  4060. registerKeepAliveHook(hook, "da", target);
  4061. }
  4062. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4063. const wrappedHook = hook.__wdc || (hook.__wdc = () => {
  4064. let current = target;
  4065. while (current) {
  4066. if (current.isDeactivated) {
  4067. return;
  4068. }
  4069. current = current.parent;
  4070. }
  4071. return hook();
  4072. });
  4073. injectHook(type, wrappedHook, target);
  4074. if (target) {
  4075. let current = target.parent;
  4076. while (current && current.parent) {
  4077. if (isKeepAlive(current.parent.vnode)) {
  4078. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4079. }
  4080. current = current.parent;
  4081. }
  4082. }
  4083. }
  4084. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4085. const injected = injectHook(
  4086. type,
  4087. hook,
  4088. keepAliveRoot,
  4089. true
  4090. /* prepend */
  4091. );
  4092. onUnmounted(() => {
  4093. remove(keepAliveRoot[type], injected);
  4094. }, target);
  4095. }
  4096. function resetShapeFlag(vnode) {
  4097. vnode.shapeFlag &= ~256;
  4098. vnode.shapeFlag &= ~512;
  4099. }
  4100. function getInnerChild(vnode) {
  4101. return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
  4102. }
  4103.  
  4104. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4105. if (target) {
  4106. const hooks = target[type] || (target[type] = []);
  4107. const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
  4108. if (target.isUnmounted) {
  4109. return;
  4110. }
  4111. pauseTracking();
  4112. setCurrentInstance(target);
  4113. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4114. unsetCurrentInstance();
  4115. resetTracking();
  4116. return res;
  4117. });
  4118. if (prepend) {
  4119. hooks.unshift(wrappedHook);
  4120. } else {
  4121. hooks.push(wrappedHook);
  4122. }
  4123. return wrappedHook;
  4124. } else {
  4125. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
  4126. warn(
  4127. `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
  4128. );
  4129. }
  4130. }
  4131. const createHook = (lifecycle) => (hook, target = currentInstance) => (
  4132. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4133. (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
  4134. );
  4135. const onBeforeMount = createHook("bm");
  4136. const onMounted = createHook("m");
  4137. const onBeforeUpdate = createHook("bu");
  4138. const onUpdated = createHook("u");
  4139. const onBeforeUnmount = createHook("bum");
  4140. const onUnmounted = createHook("um");
  4141. const onServerPrefetch = createHook("sp");
  4142. const onRenderTriggered = createHook(
  4143. "rtg"
  4144. );
  4145. const onRenderTracked = createHook(
  4146. "rtc"
  4147. );
  4148. function onErrorCaptured(hook, target = currentInstance) {
  4149. injectHook("ec", hook, target);
  4150. }
  4151.  
  4152. const COMPONENTS = "components";
  4153. const DIRECTIVES = "directives";
  4154. function resolveComponent(name, maybeSelfReference) {
  4155. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  4156. }
  4157. const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
  4158. function resolveDynamicComponent(component) {
  4159. if (isString(component)) {
  4160. return resolveAsset(COMPONENTS, component, false) || component;
  4161. } else {
  4162. return component || NULL_DYNAMIC_COMPONENT;
  4163. }
  4164. }
  4165. function resolveDirective(name) {
  4166. return resolveAsset(DIRECTIVES, name);
  4167. }
  4168. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  4169. const instance = currentRenderingInstance || currentInstance;
  4170. if (instance) {
  4171. const Component = instance.type;
  4172. if (type === COMPONENTS) {
  4173. const selfName = getComponentName(
  4174. Component,
  4175. false
  4176. /* do not include inferred name to avoid breaking existing code */
  4177. );
  4178. if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
  4179. return Component;
  4180. }
  4181. }
  4182. const res = (
  4183. // local registration
  4184. // check instance[type] first which is resolved for options API
  4185. resolve(instance[type] || Component[type], name) || // global registration
  4186. resolve(instance.appContext[type], name)
  4187. );
  4188. if (!res && maybeSelfReference) {
  4189. return Component;
  4190. }
  4191. if (warnMissing && !res) {
  4192. const extra = type === COMPONENTS ? `
  4193. If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
  4194. warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  4195. }
  4196. return res;
  4197. } else {
  4198. warn(
  4199. `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
  4200. );
  4201. }
  4202. }
  4203. function resolve(registry, name) {
  4204. return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
  4205. }
  4206.  
  4207. function renderList(source, renderItem, cache, index) {
  4208. let ret;
  4209. const cached = cache && cache[index];
  4210. if (isArray(source) || isString(source)) {
  4211. ret = new Array(source.length);
  4212. for (let i = 0, l = source.length; i < l; i++) {
  4213. ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
  4214. }
  4215. } else if (typeof source === "number") {
  4216. if (!Number.isInteger(source)) {
  4217. warn(`The v-for range expect an integer value but got ${source}.`);
  4218. }
  4219. ret = new Array(source);
  4220. for (let i = 0; i < source; i++) {
  4221. ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
  4222. }
  4223. } else if (isObject(source)) {
  4224. if (source[Symbol.iterator]) {
  4225. ret = Array.from(
  4226. source,
  4227. (item, i) => renderItem(item, i, void 0, cached && cached[i])
  4228. );
  4229. } else {
  4230. const keys = Object.keys(source);
  4231. ret = new Array(keys.length);
  4232. for (let i = 0, l = keys.length; i < l; i++) {
  4233. const key = keys[i];
  4234. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  4235. }
  4236. }
  4237. } else {
  4238. ret = [];
  4239. }
  4240. if (cache) {
  4241. cache[index] = ret;
  4242. }
  4243. return ret;
  4244. }
  4245.  
  4246. function createSlots(slots, dynamicSlots) {
  4247. for (let i = 0; i < dynamicSlots.length; i++) {
  4248. const slot = dynamicSlots[i];
  4249. if (isArray(slot)) {
  4250. for (let j = 0; j < slot.length; j++) {
  4251. slots[slot[j].name] = slot[j].fn;
  4252. }
  4253. } else if (slot) {
  4254. slots[slot.name] = slot.key ? (...args) => {
  4255. const res = slot.fn(...args);
  4256. if (res)
  4257. res.key = slot.key;
  4258. return res;
  4259. } : slot.fn;
  4260. }
  4261. }
  4262. return slots;
  4263. }
  4264.  
  4265. function renderSlot(slots, name, props = {}, fallback, noSlotted) {
  4266. if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
  4267. if (name !== "default")
  4268. props.name = name;
  4269. return createVNode("slot", props, fallback && fallback());
  4270. }
  4271. let slot = slots[name];
  4272. if (slot && slot.length > 1) {
  4273. warn(
  4274. `SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`
  4275. );
  4276. slot = () => [];
  4277. }
  4278. if (slot && slot._c) {
  4279. slot._d = false;
  4280. }
  4281. openBlock();
  4282. const validSlotContent = slot && ensureValidVNode(slot(props));
  4283. const rendered = createBlock(
  4284. Fragment,
  4285. {
  4286. key: props.key || // slot content array of a dynamic conditional slot may have a branch
  4287. // key attached in the `createSlots` helper, respect that
  4288. validSlotContent && validSlotContent.key || `_${name}`
  4289. },
  4290. validSlotContent || (fallback ? fallback() : []),
  4291. validSlotContent && slots._ === 1 ? 64 : -2
  4292. );
  4293. if (!noSlotted && rendered.scopeId) {
  4294. rendered.slotScopeIds = [rendered.scopeId + "-s"];
  4295. }
  4296. if (slot && slot._c) {
  4297. slot._d = true;
  4298. }
  4299. return rendered;
  4300. }
  4301. function ensureValidVNode(vnodes) {
  4302. return vnodes.some((child) => {
  4303. if (!isVNode(child))
  4304. return true;
  4305. if (child.type === Comment)
  4306. return false;
  4307. if (child.type === Fragment && !ensureValidVNode(child.children))
  4308. return false;
  4309. return true;
  4310. }) ? vnodes : null;
  4311. }
  4312.  
  4313. function toHandlers(obj, preserveCaseIfNecessary) {
  4314. const ret = {};
  4315. if (!isObject(obj)) {
  4316. warn(`v-on with no argument expects an object value.`);
  4317. return ret;
  4318. }
  4319. for (const key in obj) {
  4320. ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
  4321. }
  4322. return ret;
  4323. }
  4324.  
  4325. const getPublicInstance = (i) => {
  4326. if (!i)
  4327. return null;
  4328. if (isStatefulComponent(i))
  4329. return getExposeProxy(i) || i.proxy;
  4330. return getPublicInstance(i.parent);
  4331. };
  4332. const publicPropertiesMap = (
  4333. // Move PURE marker to new line to workaround compiler discarding it
  4334. // due to type annotation
  4335. /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
  4336. $: (i) => i,
  4337. $el: (i) => i.vnode.el,
  4338. $data: (i) => i.data,
  4339. $props: (i) => shallowReadonly(i.props) ,
  4340. $attrs: (i) => shallowReadonly(i.attrs) ,
  4341. $slots: (i) => shallowReadonly(i.slots) ,
  4342. $refs: (i) => shallowReadonly(i.refs) ,
  4343. $parent: (i) => getPublicInstance(i.parent),
  4344. $root: (i) => getPublicInstance(i.root),
  4345. $emit: (i) => i.emit,
  4346. $options: (i) => resolveMergedOptions(i) ,
  4347. $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
  4348. $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
  4349. $watch: (i) => instanceWatch.bind(i)
  4350. })
  4351. );
  4352. const isReservedPrefix = (key) => key === "_" || key === "$";
  4353. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
  4354. const PublicInstanceProxyHandlers = {
  4355. get({ _: instance }, key) {
  4356. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  4357. if (key === "__isVue") {
  4358. return true;
  4359. }
  4360. let normalizedProps;
  4361. if (key[0] !== "$") {
  4362. const n = accessCache[key];
  4363. if (n !== void 0) {
  4364. switch (n) {
  4365. case 1 /* SETUP */:
  4366. return setupState[key];
  4367. case 2 /* DATA */:
  4368. return data[key];
  4369. case 4 /* CONTEXT */:
  4370. return ctx[key];
  4371. case 3 /* PROPS */:
  4372. return props[key];
  4373. }
  4374. } else if (hasSetupBinding(setupState, key)) {
  4375. accessCache[key] = 1 /* SETUP */;
  4376. return setupState[key];
  4377. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4378. accessCache[key] = 2 /* DATA */;
  4379. return data[key];
  4380. } else if (
  4381. // only cache other properties when instance has declared (thus stable)
  4382. // props
  4383. (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
  4384. ) {
  4385. accessCache[key] = 3 /* PROPS */;
  4386. return props[key];
  4387. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4388. accessCache[key] = 4 /* CONTEXT */;
  4389. return ctx[key];
  4390. } else if (shouldCacheAccess) {
  4391. accessCache[key] = 0 /* OTHER */;
  4392. }
  4393. }
  4394. const publicGetter = publicPropertiesMap[key];
  4395. let cssModule, globalProperties;
  4396. if (publicGetter) {
  4397. if (key === "$attrs") {
  4398. track(instance, "get", key);
  4399. markAttrsAccessed();
  4400. } else if (key === "$slots") {
  4401. track(instance, "get", key);
  4402. }
  4403. return publicGetter(instance);
  4404. } else if (
  4405. // css module (injected by vue-loader)
  4406. (cssModule = type.__cssModules) && (cssModule = cssModule[key])
  4407. ) {
  4408. return cssModule;
  4409. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4410. accessCache[key] = 4 /* CONTEXT */;
  4411. return ctx[key];
  4412. } else if (
  4413. // global properties
  4414. globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
  4415. ) {
  4416. {
  4417. return globalProperties[key];
  4418. }
  4419. } else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
  4420. // to infinite warning loop
  4421. key.indexOf("__v") !== 0)) {
  4422. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4423. warn(
  4424. `Property ${JSON.stringify(
  4425. key
  4426. )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
  4427. );
  4428. } else if (instance === currentRenderingInstance) {
  4429. warn(
  4430. `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
  4431. );
  4432. }
  4433. }
  4434. },
  4435. set({ _: instance }, key, value) {
  4436. const { data, setupState, ctx } = instance;
  4437. if (hasSetupBinding(setupState, key)) {
  4438. setupState[key] = value;
  4439. return true;
  4440. } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
  4441. warn(`Cannot mutate <script setup> binding "${key}" from Options API.`);
  4442. return false;
  4443. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4444. data[key] = value;
  4445. return true;
  4446. } else if (hasOwn(instance.props, key)) {
  4447. warn(`Attempting to mutate prop "${key}". Props are readonly.`);
  4448. return false;
  4449. }
  4450. if (key[0] === "$" && key.slice(1) in instance) {
  4451. warn(
  4452. `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
  4453. );
  4454. return false;
  4455. } else {
  4456. if (key in instance.appContext.config.globalProperties) {
  4457. Object.defineProperty(ctx, key, {
  4458. enumerable: true,
  4459. configurable: true,
  4460. value
  4461. });
  4462. } else {
  4463. ctx[key] = value;
  4464. }
  4465. }
  4466. return true;
  4467. },
  4468. has({
  4469. _: { data, setupState, accessCache, ctx, appContext, propsOptions }
  4470. }, key) {
  4471. let normalizedProps;
  4472. return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
  4473. },
  4474. defineProperty(target, key, descriptor) {
  4475. if (descriptor.get != null) {
  4476. target._.accessCache[key] = 0;
  4477. } else if (hasOwn(descriptor, "value")) {
  4478. this.set(target, key, descriptor.value, null);
  4479. }
  4480. return Reflect.defineProperty(target, key, descriptor);
  4481. }
  4482. };
  4483. {
  4484. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4485. warn(
  4486. `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
  4487. );
  4488. return Reflect.ownKeys(target);
  4489. };
  4490. }
  4491. const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend(
  4492. {},
  4493. PublicInstanceProxyHandlers,
  4494. {
  4495. get(target, key) {
  4496. if (key === Symbol.unscopables) {
  4497. return;
  4498. }
  4499. return PublicInstanceProxyHandlers.get(target, key, target);
  4500. },
  4501. has(_, key) {
  4502. const has = key[0] !== "_" && !isGloballyWhitelisted(key);
  4503. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4504. warn(
  4505. `Property ${JSON.stringify(
  4506. key
  4507. )} should not start with _ which is a reserved prefix for Vue internals.`
  4508. );
  4509. }
  4510. return has;
  4511. }
  4512. }
  4513. );
  4514. function createDevRenderContext(instance) {
  4515. const target = {};
  4516. Object.defineProperty(target, `_`, {
  4517. configurable: true,
  4518. enumerable: false,
  4519. get: () => instance
  4520. });
  4521. Object.keys(publicPropertiesMap).forEach((key) => {
  4522. Object.defineProperty(target, key, {
  4523. configurable: true,
  4524. enumerable: false,
  4525. get: () => publicPropertiesMap[key](instance),
  4526. // intercepted by the proxy so no need for implementation,
  4527. // but needed to prevent set errors
  4528. set: NOOP
  4529. });
  4530. });
  4531. return target;
  4532. }
  4533. function exposePropsOnRenderContext(instance) {
  4534. const {
  4535. ctx,
  4536. propsOptions: [propsOptions]
  4537. } = instance;
  4538. if (propsOptions) {
  4539. Object.keys(propsOptions).forEach((key) => {
  4540. Object.defineProperty(ctx, key, {
  4541. enumerable: true,
  4542. configurable: true,
  4543. get: () => instance.props[key],
  4544. set: NOOP
  4545. });
  4546. });
  4547. }
  4548. }
  4549. function exposeSetupStateOnRenderContext(instance) {
  4550. const { ctx, setupState } = instance;
  4551. Object.keys(toRaw(setupState)).forEach((key) => {
  4552. if (!setupState.__isScriptSetup) {
  4553. if (isReservedPrefix(key[0])) {
  4554. warn(
  4555. `setup() return property ${JSON.stringify(
  4556. key
  4557. )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
  4558. );
  4559. return;
  4560. }
  4561. Object.defineProperty(ctx, key, {
  4562. enumerable: true,
  4563. configurable: true,
  4564. get: () => setupState[key],
  4565. set: NOOP
  4566. });
  4567. }
  4568. });
  4569. }
  4570.  
  4571. const warnRuntimeUsage = (method) => warn(
  4572. `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`
  4573. );
  4574. function defineProps() {
  4575. {
  4576. warnRuntimeUsage(`defineProps`);
  4577. }
  4578. return null;
  4579. }
  4580. function defineEmits() {
  4581. {
  4582. warnRuntimeUsage(`defineEmits`);
  4583. }
  4584. return null;
  4585. }
  4586. function defineExpose(exposed) {
  4587. {
  4588. warnRuntimeUsage(`defineExpose`);
  4589. }
  4590. }
  4591. function defineOptions(options) {
  4592. {
  4593. warnRuntimeUsage(`defineOptions`);
  4594. }
  4595. }
  4596. function defineSlots() {
  4597. {
  4598. warnRuntimeUsage(`defineSlots`);
  4599. }
  4600. return null;
  4601. }
  4602. function defineModel() {
  4603. {
  4604. warnRuntimeUsage("defineModel");
  4605. }
  4606. }
  4607. function withDefaults(props, defaults) {
  4608. {
  4609. warnRuntimeUsage(`withDefaults`);
  4610. }
  4611. return null;
  4612. }
  4613. function useSlots() {
  4614. return getContext().slots;
  4615. }
  4616. function useAttrs() {
  4617. return getContext().attrs;
  4618. }
  4619. function useModel(props, name, options) {
  4620. const i = getCurrentInstance();
  4621. if (!i) {
  4622. warn(`useModel() called without active instance.`);
  4623. return ref();
  4624. }
  4625. if (!i.propsOptions[0][name]) {
  4626. warn(`useModel() called with prop "${name}" which is not declared.`);
  4627. return ref();
  4628. }
  4629. if (options && options.local) {
  4630. const proxy = ref(props[name]);
  4631. watch(
  4632. () => props[name],
  4633. (v) => proxy.value = v
  4634. );
  4635. watch(proxy, (value) => {
  4636. if (value !== props[name]) {
  4637. i.emit(`update:${name}`, value);
  4638. }
  4639. });
  4640. return proxy;
  4641. } else {
  4642. return {
  4643. __v_isRef: true,
  4644. get value() {
  4645. return props[name];
  4646. },
  4647. set value(value) {
  4648. i.emit(`update:${name}`, value);
  4649. }
  4650. };
  4651. }
  4652. }
  4653. function getContext() {
  4654. const i = getCurrentInstance();
  4655. if (!i) {
  4656. warn(`useContext() called without active instance.`);
  4657. }
  4658. return i.setupContext || (i.setupContext = createSetupContext(i));
  4659. }
  4660. function normalizePropsOrEmits(props) {
  4661. return isArray(props) ? props.reduce(
  4662. (normalized, p) => (normalized[p] = null, normalized),
  4663. {}
  4664. ) : props;
  4665. }
  4666. function mergeDefaults(raw, defaults) {
  4667. const props = normalizePropsOrEmits(raw);
  4668. for (const key in defaults) {
  4669. if (key.startsWith("__skip"))
  4670. continue;
  4671. let opt = props[key];
  4672. if (opt) {
  4673. if (isArray(opt) || isFunction(opt)) {
  4674. opt = props[key] = { type: opt, default: defaults[key] };
  4675. } else {
  4676. opt.default = defaults[key];
  4677. }
  4678. } else if (opt === null) {
  4679. opt = props[key] = { default: defaults[key] };
  4680. } else {
  4681. warn(`props default key "${key}" has no corresponding declaration.`);
  4682. }
  4683. if (opt && defaults[`__skip_${key}`]) {
  4684. opt.skipFactory = true;
  4685. }
  4686. }
  4687. return props;
  4688. }
  4689. function mergeModels(a, b) {
  4690. if (!a || !b)
  4691. return a || b;
  4692. if (isArray(a) && isArray(b))
  4693. return a.concat(b);
  4694. return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
  4695. }
  4696. function createPropsRestProxy(props, excludedKeys) {
  4697. const ret = {};
  4698. for (const key in props) {
  4699. if (!excludedKeys.includes(key)) {
  4700. Object.defineProperty(ret, key, {
  4701. enumerable: true,
  4702. get: () => props[key]
  4703. });
  4704. }
  4705. }
  4706. return ret;
  4707. }
  4708. function withAsyncContext(getAwaitable) {
  4709. const ctx = getCurrentInstance();
  4710. if (!ctx) {
  4711. warn(
  4712. `withAsyncContext called without active current instance. This is likely a bug.`
  4713. );
  4714. }
  4715. let awaitable = getAwaitable();
  4716. unsetCurrentInstance();
  4717. if (isPromise(awaitable)) {
  4718. awaitable = awaitable.catch((e) => {
  4719. setCurrentInstance(ctx);
  4720. throw e;
  4721. });
  4722. }
  4723. return [awaitable, () => setCurrentInstance(ctx)];
  4724. }
  4725.  
  4726. function createDuplicateChecker() {
  4727. const cache = /* @__PURE__ */ Object.create(null);
  4728. return (type, key) => {
  4729. if (cache[key]) {
  4730. warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4731. } else {
  4732. cache[key] = type;
  4733. }
  4734. };
  4735. }
  4736. let shouldCacheAccess = true;
  4737. function applyOptions(instance) {
  4738. const options = resolveMergedOptions(instance);
  4739. const publicThis = instance.proxy;
  4740. const ctx = instance.ctx;
  4741. shouldCacheAccess = false;
  4742. if (options.beforeCreate) {
  4743. callHook$1(options.beforeCreate, instance, "bc");
  4744. }
  4745. const {
  4746. // state
  4747. data: dataOptions,
  4748. computed: computedOptions,
  4749. methods,
  4750. watch: watchOptions,
  4751. provide: provideOptions,
  4752. inject: injectOptions,
  4753. // lifecycle
  4754. created,
  4755. beforeMount,
  4756. mounted,
  4757. beforeUpdate,
  4758. updated,
  4759. activated,
  4760. deactivated,
  4761. beforeDestroy,
  4762. beforeUnmount,
  4763. destroyed,
  4764. unmounted,
  4765. render,
  4766. renderTracked,
  4767. renderTriggered,
  4768. errorCaptured,
  4769. serverPrefetch,
  4770. // public API
  4771. expose,
  4772. inheritAttrs,
  4773. // assets
  4774. components,
  4775. directives,
  4776. filters
  4777. } = options;
  4778. const checkDuplicateProperties = createDuplicateChecker() ;
  4779. {
  4780. const [propsOptions] = instance.propsOptions;
  4781. if (propsOptions) {
  4782. for (const key in propsOptions) {
  4783. checkDuplicateProperties("Props" /* PROPS */, key);
  4784. }
  4785. }
  4786. }
  4787. if (injectOptions) {
  4788. resolveInjections(injectOptions, ctx, checkDuplicateProperties);
  4789. }
  4790. if (methods) {
  4791. for (const key in methods) {
  4792. const methodHandler = methods[key];
  4793. if (isFunction(methodHandler)) {
  4794. {
  4795. Object.defineProperty(ctx, key, {
  4796. value: methodHandler.bind(publicThis),
  4797. configurable: true,
  4798. enumerable: true,
  4799. writable: true
  4800. });
  4801. }
  4802. {
  4803. checkDuplicateProperties("Methods" /* METHODS */, key);
  4804. }
  4805. } else {
  4806. warn(
  4807. `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
  4808. );
  4809. }
  4810. }
  4811. }
  4812. if (dataOptions) {
  4813. if (!isFunction(dataOptions)) {
  4814. warn(
  4815. `The data option must be a function. Plain object usage is no longer supported.`
  4816. );
  4817. }
  4818. const data = dataOptions.call(publicThis, publicThis);
  4819. if (isPromise(data)) {
  4820. warn(
  4821. `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
  4822. );
  4823. }
  4824. if (!isObject(data)) {
  4825. warn(`data() should return an object.`);
  4826. } else {
  4827. instance.data = reactive(data);
  4828. {
  4829. for (const key in data) {
  4830. checkDuplicateProperties("Data" /* DATA */, key);
  4831. if (!isReservedPrefix(key[0])) {
  4832. Object.defineProperty(ctx, key, {
  4833. configurable: true,
  4834. enumerable: true,
  4835. get: () => data[key],
  4836. set: NOOP
  4837. });
  4838. }
  4839. }
  4840. }
  4841. }
  4842. }
  4843. shouldCacheAccess = true;
  4844. if (computedOptions) {
  4845. for (const key in computedOptions) {
  4846. const opt = computedOptions[key];
  4847. const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
  4848. if (get === NOOP) {
  4849. warn(`Computed property "${key}" has no getter.`);
  4850. }
  4851. const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
  4852. warn(
  4853. `Write operation failed: computed property "${key}" is readonly.`
  4854. );
  4855. } ;
  4856. const c = computed({
  4857. get,
  4858. set
  4859. });
  4860. Object.defineProperty(ctx, key, {
  4861. enumerable: true,
  4862. configurable: true,
  4863. get: () => c.value,
  4864. set: (v) => c.value = v
  4865. });
  4866. {
  4867. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  4868. }
  4869. }
  4870. }
  4871. if (watchOptions) {
  4872. for (const key in watchOptions) {
  4873. createWatcher(watchOptions[key], ctx, publicThis, key);
  4874. }
  4875. }
  4876. if (provideOptions) {
  4877. const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
  4878. Reflect.ownKeys(provides).forEach((key) => {
  4879. provide(key, provides[key]);
  4880. });
  4881. }
  4882. if (created) {
  4883. callHook$1(created, instance, "c");
  4884. }
  4885. function registerLifecycleHook(register, hook) {
  4886. if (isArray(hook)) {
  4887. hook.forEach((_hook) => register(_hook.bind(publicThis)));
  4888. } else if (hook) {
  4889. register(hook.bind(publicThis));
  4890. }
  4891. }
  4892. registerLifecycleHook(onBeforeMount, beforeMount);
  4893. registerLifecycleHook(onMounted, mounted);
  4894. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  4895. registerLifecycleHook(onUpdated, updated);
  4896. registerLifecycleHook(onActivated, activated);
  4897. registerLifecycleHook(onDeactivated, deactivated);
  4898. registerLifecycleHook(onErrorCaptured, errorCaptured);
  4899. registerLifecycleHook(onRenderTracked, renderTracked);
  4900. registerLifecycleHook(onRenderTriggered, renderTriggered);
  4901. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  4902. registerLifecycleHook(onUnmounted, unmounted);
  4903. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  4904. if (isArray(expose)) {
  4905. if (expose.length) {
  4906. const exposed = instance.exposed || (instance.exposed = {});
  4907. expose.forEach((key) => {
  4908. Object.defineProperty(exposed, key, {
  4909. get: () => publicThis[key],
  4910. set: (val) => publicThis[key] = val
  4911. });
  4912. });
  4913. } else if (!instance.exposed) {
  4914. instance.exposed = {};
  4915. }
  4916. }
  4917. if (render && instance.render === NOOP) {
  4918. instance.render = render;
  4919. }
  4920. if (inheritAttrs != null) {
  4921. instance.inheritAttrs = inheritAttrs;
  4922. }
  4923. if (components)
  4924. instance.components = components;
  4925. if (directives)
  4926. instance.directives = directives;
  4927. }
  4928. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
  4929. if (isArray(injectOptions)) {
  4930. injectOptions = normalizeInject(injectOptions);
  4931. }
  4932. for (const key in injectOptions) {
  4933. const opt = injectOptions[key];
  4934. let injected;
  4935. if (isObject(opt)) {
  4936. if ("default" in opt) {
  4937. injected = inject(
  4938. opt.from || key,
  4939. opt.default,
  4940. true
  4941. /* treat default function as factory */
  4942. );
  4943. } else {
  4944. injected = inject(opt.from || key);
  4945. }
  4946. } else {
  4947. injected = inject(opt);
  4948. }
  4949. if (isRef(injected)) {
  4950. Object.defineProperty(ctx, key, {
  4951. enumerable: true,
  4952. configurable: true,
  4953. get: () => injected.value,
  4954. set: (v) => injected.value = v
  4955. });
  4956. } else {
  4957. ctx[key] = injected;
  4958. }
  4959. {
  4960. checkDuplicateProperties("Inject" /* INJECT */, key);
  4961. }
  4962. }
  4963. }
  4964. function callHook$1(hook, instance, type) {
  4965. callWithAsyncErrorHandling(
  4966. isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
  4967. instance,
  4968. type
  4969. );
  4970. }
  4971. function createWatcher(raw, ctx, publicThis, key) {
  4972. const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
  4973. if (isString(raw)) {
  4974. const handler = ctx[raw];
  4975. if (isFunction(handler)) {
  4976. watch(getter, handler);
  4977. } else {
  4978. warn(`Invalid watch handler specified by key "${raw}"`, handler);
  4979. }
  4980. } else if (isFunction(raw)) {
  4981. watch(getter, raw.bind(publicThis));
  4982. } else if (isObject(raw)) {
  4983. if (isArray(raw)) {
  4984. raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
  4985. } else {
  4986. const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
  4987. if (isFunction(handler)) {
  4988. watch(getter, handler, raw);
  4989. } else {
  4990. warn(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  4991. }
  4992. }
  4993. } else {
  4994. warn(`Invalid watch option: "${key}"`, raw);
  4995. }
  4996. }
  4997. function resolveMergedOptions(instance) {
  4998. const base = instance.type;
  4999. const { mixins, extends: extendsOptions } = base;
  5000. const {
  5001. mixins: globalMixins,
  5002. optionsCache: cache,
  5003. config: { optionMergeStrategies }
  5004. } = instance.appContext;
  5005. const cached = cache.get(base);
  5006. let resolved;
  5007. if (cached) {
  5008. resolved = cached;
  5009. } else if (!globalMixins.length && !mixins && !extendsOptions) {
  5010. {
  5011. resolved = base;
  5012. }
  5013. } else {
  5014. resolved = {};
  5015. if (globalMixins.length) {
  5016. globalMixins.forEach(
  5017. (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
  5018. );
  5019. }
  5020. mergeOptions(resolved, base, optionMergeStrategies);
  5021. }
  5022. if (isObject(base)) {
  5023. cache.set(base, resolved);
  5024. }
  5025. return resolved;
  5026. }
  5027. function mergeOptions(to, from, strats, asMixin = false) {
  5028. const { mixins, extends: extendsOptions } = from;
  5029. if (extendsOptions) {
  5030. mergeOptions(to, extendsOptions, strats, true);
  5031. }
  5032. if (mixins) {
  5033. mixins.forEach(
  5034. (m) => mergeOptions(to, m, strats, true)
  5035. );
  5036. }
  5037. for (const key in from) {
  5038. if (asMixin && key === "expose") {
  5039. warn(
  5040. `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
  5041. );
  5042. } else {
  5043. const strat = internalOptionMergeStrats[key] || strats && strats[key];
  5044. to[key] = strat ? strat(to[key], from[key]) : from[key];
  5045. }
  5046. }
  5047. return to;
  5048. }
  5049. const internalOptionMergeStrats = {
  5050. data: mergeDataFn,
  5051. props: mergeEmitsOrPropsOptions,
  5052. emits: mergeEmitsOrPropsOptions,
  5053. // objects
  5054. methods: mergeObjectOptions,
  5055. computed: mergeObjectOptions,
  5056. // lifecycle
  5057. beforeCreate: mergeAsArray$1,
  5058. created: mergeAsArray$1,
  5059. beforeMount: mergeAsArray$1,
  5060. mounted: mergeAsArray$1,
  5061. beforeUpdate: mergeAsArray$1,
  5062. updated: mergeAsArray$1,
  5063. beforeDestroy: mergeAsArray$1,
  5064. beforeUnmount: mergeAsArray$1,
  5065. destroyed: mergeAsArray$1,
  5066. unmounted: mergeAsArray$1,
  5067. activated: mergeAsArray$1,
  5068. deactivated: mergeAsArray$1,
  5069. errorCaptured: mergeAsArray$1,
  5070. serverPrefetch: mergeAsArray$1,
  5071. // assets
  5072. components: mergeObjectOptions,
  5073. directives: mergeObjectOptions,
  5074. // watch
  5075. watch: mergeWatchOptions,
  5076. // provide / inject
  5077. provide: mergeDataFn,
  5078. inject: mergeInject
  5079. };
  5080. function mergeDataFn(to, from) {
  5081. if (!from) {
  5082. return to;
  5083. }
  5084. if (!to) {
  5085. return from;
  5086. }
  5087. return function mergedDataFn() {
  5088. return (extend)(
  5089. isFunction(to) ? to.call(this, this) : to,
  5090. isFunction(from) ? from.call(this, this) : from
  5091. );
  5092. };
  5093. }
  5094. function mergeInject(to, from) {
  5095. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  5096. }
  5097. function normalizeInject(raw) {
  5098. if (isArray(raw)) {
  5099. const res = {};
  5100. for (let i = 0; i < raw.length; i++) {
  5101. res[raw[i]] = raw[i];
  5102. }
  5103. return res;
  5104. }
  5105. return raw;
  5106. }
  5107. function mergeAsArray$1(to, from) {
  5108. return to ? [...new Set([].concat(to, from))] : from;
  5109. }
  5110. function mergeObjectOptions(to, from) {
  5111. return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
  5112. }
  5113. function mergeEmitsOrPropsOptions(to, from) {
  5114. if (to) {
  5115. if (isArray(to) && isArray(from)) {
  5116. return [.../* @__PURE__ */ new Set([...to, ...from])];
  5117. }
  5118. return extend(
  5119. /* @__PURE__ */ Object.create(null),
  5120. normalizePropsOrEmits(to),
  5121. normalizePropsOrEmits(from != null ? from : {})
  5122. );
  5123. } else {
  5124. return from;
  5125. }
  5126. }
  5127. function mergeWatchOptions(to, from) {
  5128. if (!to)
  5129. return from;
  5130. if (!from)
  5131. return to;
  5132. const merged = extend(/* @__PURE__ */ Object.create(null), to);
  5133. for (const key in from) {
  5134. merged[key] = mergeAsArray$1(to[key], from[key]);
  5135. }
  5136. return merged;
  5137. }
  5138.  
  5139. function createAppContext() {
  5140. return {
  5141. app: null,
  5142. config: {
  5143. isNativeTag: NO,
  5144. performance: false,
  5145. globalProperties: {},
  5146. optionMergeStrategies: {},
  5147. errorHandler: void 0,
  5148. warnHandler: void 0,
  5149. compilerOptions: {}
  5150. },
  5151. mixins: [],
  5152. components: {},
  5153. directives: {},
  5154. provides: /* @__PURE__ */ Object.create(null),
  5155. optionsCache: /* @__PURE__ */ new WeakMap(),
  5156. propsCache: /* @__PURE__ */ new WeakMap(),
  5157. emitsCache: /* @__PURE__ */ new WeakMap()
  5158. };
  5159. }
  5160. let uid$1 = 0;
  5161. function createAppAPI(render, hydrate) {
  5162. return function createApp(rootComponent, rootProps = null) {
  5163. if (!isFunction(rootComponent)) {
  5164. rootComponent = extend({}, rootComponent);
  5165. }
  5166. if (rootProps != null && !isObject(rootProps)) {
  5167. warn(`root props passed to app.mount() must be an object.`);
  5168. rootProps = null;
  5169. }
  5170. const context = createAppContext();
  5171. {
  5172. Object.defineProperty(context.config, "unwrapInjectedRef", {
  5173. get() {
  5174. return true;
  5175. },
  5176. set() {
  5177. warn(
  5178. `app.config.unwrapInjectedRef has been deprecated. 3.3 now alawys unwraps injected refs in Options API.`
  5179. );
  5180. }
  5181. });
  5182. }
  5183. const installedPlugins = /* @__PURE__ */ new Set();
  5184. let isMounted = false;
  5185. const app = context.app = {
  5186. _uid: uid$1++,
  5187. _component: rootComponent,
  5188. _props: rootProps,
  5189. _container: null,
  5190. _context: context,
  5191. _instance: null,
  5192. version,
  5193. get config() {
  5194. return context.config;
  5195. },
  5196. set config(v) {
  5197. {
  5198. warn(
  5199. `app.config cannot be replaced. Modify individual options instead.`
  5200. );
  5201. }
  5202. },
  5203. use(plugin, ...options) {
  5204. if (installedPlugins.has(plugin)) {
  5205. warn(`Plugin has already been applied to target app.`);
  5206. } else if (plugin && isFunction(plugin.install)) {
  5207. installedPlugins.add(plugin);
  5208. plugin.install(app, ...options);
  5209. } else if (isFunction(plugin)) {
  5210. installedPlugins.add(plugin);
  5211. plugin(app, ...options);
  5212. } else {
  5213. warn(
  5214. `A plugin must either be a function or an object with an "install" function.`
  5215. );
  5216. }
  5217. return app;
  5218. },
  5219. mixin(mixin) {
  5220. {
  5221. if (!context.mixins.includes(mixin)) {
  5222. context.mixins.push(mixin);
  5223. } else {
  5224. warn(
  5225. "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
  5226. );
  5227. }
  5228. }
  5229. return app;
  5230. },
  5231. component(name, component) {
  5232. {
  5233. validateComponentName(name, context.config);
  5234. }
  5235. if (!component) {
  5236. return context.components[name];
  5237. }
  5238. if (context.components[name]) {
  5239. warn(`Component "${name}" has already been registered in target app.`);
  5240. }
  5241. context.components[name] = component;
  5242. return app;
  5243. },
  5244. directive(name, directive) {
  5245. {
  5246. validateDirectiveName(name);
  5247. }
  5248. if (!directive) {
  5249. return context.directives[name];
  5250. }
  5251. if (context.directives[name]) {
  5252. warn(`Directive "${name}" has already been registered in target app.`);
  5253. }
  5254. context.directives[name] = directive;
  5255. return app;
  5256. },
  5257. mount(rootContainer, isHydrate, isSVG) {
  5258. if (!isMounted) {
  5259. if (rootContainer.__vue_app__) {
  5260. warn(
  5261. `There is already an app instance mounted on the host container.
  5262. If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
  5263. );
  5264. }
  5265. const vnode = createVNode(
  5266. rootComponent,
  5267. rootProps
  5268. );
  5269. vnode.appContext = context;
  5270. {
  5271. context.reload = () => {
  5272. render(cloneVNode(vnode), rootContainer, isSVG);
  5273. };
  5274. }
  5275. if (isHydrate && hydrate) {
  5276. hydrate(vnode, rootContainer);
  5277. } else {
  5278. render(vnode, rootContainer, isSVG);
  5279. }
  5280. isMounted = true;
  5281. app._container = rootContainer;
  5282. rootContainer.__vue_app__ = app;
  5283. {
  5284. app._instance = vnode.component;
  5285. devtoolsInitApp(app, version);
  5286. }
  5287. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5288. } else {
  5289. warn(
  5290. `App has already been mounted.
  5291. If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
  5292. );
  5293. }
  5294. },
  5295. unmount() {
  5296. if (isMounted) {
  5297. render(null, app._container);
  5298. {
  5299. app._instance = null;
  5300. devtoolsUnmountApp(app);
  5301. }
  5302. delete app._container.__vue_app__;
  5303. } else {
  5304. warn(`Cannot unmount an app that is not mounted.`);
  5305. }
  5306. },
  5307. provide(key, value) {
  5308. if (key in context.provides) {
  5309. warn(
  5310. `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
  5311. );
  5312. }
  5313. context.provides[key] = value;
  5314. return app;
  5315. },
  5316. runWithContext(fn) {
  5317. currentApp = app;
  5318. try {
  5319. return fn();
  5320. } finally {
  5321. currentApp = null;
  5322. }
  5323. }
  5324. };
  5325. return app;
  5326. };
  5327. }
  5328. let currentApp = null;
  5329.  
  5330. function provide(key, value) {
  5331. if (!currentInstance) {
  5332. {
  5333. warn(`provide() can only be used inside setup().`);
  5334. }
  5335. } else {
  5336. let provides = currentInstance.provides;
  5337. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  5338. if (parentProvides === provides) {
  5339. provides = currentInstance.provides = Object.create(parentProvides);
  5340. }
  5341. provides[key] = value;
  5342. }
  5343. }
  5344. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  5345. const instance = currentInstance || currentRenderingInstance;
  5346. if (instance || currentApp) {
  5347. const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
  5348. if (provides && key in provides) {
  5349. return provides[key];
  5350. } else if (arguments.length > 1) {
  5351. return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
  5352. } else {
  5353. warn(`injection "${String(key)}" not found.`);
  5354. }
  5355. } else {
  5356. warn(`inject() can only be used inside setup() or functional components.`);
  5357. }
  5358. }
  5359. function hasInjectionContext() {
  5360. return !!(currentInstance || currentRenderingInstance || currentApp);
  5361. }
  5362.  
  5363. function initProps(instance, rawProps, isStateful, isSSR = false) {
  5364. const props = {};
  5365. const attrs = {};
  5366. def(attrs, InternalObjectKey, 1);
  5367. instance.propsDefaults = /* @__PURE__ */ Object.create(null);
  5368. setFullProps(instance, rawProps, props, attrs);
  5369. for (const key in instance.propsOptions[0]) {
  5370. if (!(key in props)) {
  5371. props[key] = void 0;
  5372. }
  5373. }
  5374. {
  5375. validateProps(rawProps || {}, props, instance);
  5376. }
  5377. if (isStateful) {
  5378. instance.props = isSSR ? props : shallowReactive(props);
  5379. } else {
  5380. if (!instance.type.props) {
  5381. instance.props = attrs;
  5382. } else {
  5383. instance.props = props;
  5384. }
  5385. }
  5386. instance.attrs = attrs;
  5387. }
  5388. function isInHmrContext(instance) {
  5389. while (instance) {
  5390. if (instance.type.__hmrId)
  5391. return true;
  5392. instance = instance.parent;
  5393. }
  5394. }
  5395. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5396. const {
  5397. props,
  5398. attrs,
  5399. vnode: { patchFlag }
  5400. } = instance;
  5401. const rawCurrentProps = toRaw(props);
  5402. const [options] = instance.propsOptions;
  5403. let hasAttrsChanged = false;
  5404. if (
  5405. // always force full diff in dev
  5406. // - #1942 if hmr is enabled with sfc component
  5407. // - vite#872 non-sfc component used by sfc component
  5408. !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
  5409. ) {
  5410. if (patchFlag & 8) {
  5411. const propsToUpdate = instance.vnode.dynamicProps;
  5412. for (let i = 0; i < propsToUpdate.length; i++) {
  5413. let key = propsToUpdate[i];
  5414. if (isEmitListener(instance.emitsOptions, key)) {
  5415. continue;
  5416. }
  5417. const value = rawProps[key];
  5418. if (options) {
  5419. if (hasOwn(attrs, key)) {
  5420. if (value !== attrs[key]) {
  5421. attrs[key] = value;
  5422. hasAttrsChanged = true;
  5423. }
  5424. } else {
  5425. const camelizedKey = camelize(key);
  5426. props[camelizedKey] = resolvePropValue(
  5427. options,
  5428. rawCurrentProps,
  5429. camelizedKey,
  5430. value,
  5431. instance,
  5432. false
  5433. /* isAbsent */
  5434. );
  5435. }
  5436. } else {
  5437. if (value !== attrs[key]) {
  5438. attrs[key] = value;
  5439. hasAttrsChanged = true;
  5440. }
  5441. }
  5442. }
  5443. }
  5444. } else {
  5445. if (setFullProps(instance, rawProps, props, attrs)) {
  5446. hasAttrsChanged = true;
  5447. }
  5448. let kebabKey;
  5449. for (const key in rawCurrentProps) {
  5450. if (!rawProps || // for camelCase
  5451. !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
  5452. // and converted to camelCase (#955)
  5453. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
  5454. if (options) {
  5455. if (rawPrevProps && // for camelCase
  5456. (rawPrevProps[key] !== void 0 || // for kebab-case
  5457. rawPrevProps[kebabKey] !== void 0)) {
  5458. props[key] = resolvePropValue(
  5459. options,
  5460. rawCurrentProps,
  5461. key,
  5462. void 0,
  5463. instance,
  5464. true
  5465. /* isAbsent */
  5466. );
  5467. }
  5468. } else {
  5469. delete props[key];
  5470. }
  5471. }
  5472. }
  5473. if (attrs !== rawCurrentProps) {
  5474. for (const key in attrs) {
  5475. if (!rawProps || !hasOwn(rawProps, key) && true) {
  5476. delete attrs[key];
  5477. hasAttrsChanged = true;
  5478. }
  5479. }
  5480. }
  5481. }
  5482. if (hasAttrsChanged) {
  5483. trigger(instance, "set", "$attrs");
  5484. }
  5485. {
  5486. validateProps(rawProps || {}, props, instance);
  5487. }
  5488. }
  5489. function setFullProps(instance, rawProps, props, attrs) {
  5490. const [options, needCastKeys] = instance.propsOptions;
  5491. let hasAttrsChanged = false;
  5492. let rawCastValues;
  5493. if (rawProps) {
  5494. for (let key in rawProps) {
  5495. if (isReservedProp(key)) {
  5496. continue;
  5497. }
  5498. const value = rawProps[key];
  5499. let camelKey;
  5500. if (options && hasOwn(options, camelKey = camelize(key))) {
  5501. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  5502. props[camelKey] = value;
  5503. } else {
  5504. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  5505. }
  5506. } else if (!isEmitListener(instance.emitsOptions, key)) {
  5507. if (!(key in attrs) || value !== attrs[key]) {
  5508. attrs[key] = value;
  5509. hasAttrsChanged = true;
  5510. }
  5511. }
  5512. }
  5513. }
  5514. if (needCastKeys) {
  5515. const rawCurrentProps = toRaw(props);
  5516. const castValues = rawCastValues || EMPTY_OBJ;
  5517. for (let i = 0; i < needCastKeys.length; i++) {
  5518. const key = needCastKeys[i];
  5519. props[key] = resolvePropValue(
  5520. options,
  5521. rawCurrentProps,
  5522. key,
  5523. castValues[key],
  5524. instance,
  5525. !hasOwn(castValues, key)
  5526. );
  5527. }
  5528. }
  5529. return hasAttrsChanged;
  5530. }
  5531. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5532. const opt = options[key];
  5533. if (opt != null) {
  5534. const hasDefault = hasOwn(opt, "default");
  5535. if (hasDefault && value === void 0) {
  5536. const defaultValue = opt.default;
  5537. if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
  5538. const { propsDefaults } = instance;
  5539. if (key in propsDefaults) {
  5540. value = propsDefaults[key];
  5541. } else {
  5542. setCurrentInstance(instance);
  5543. value = propsDefaults[key] = defaultValue.call(
  5544. null,
  5545. props
  5546. );
  5547. unsetCurrentInstance();
  5548. }
  5549. } else {
  5550. value = defaultValue;
  5551. }
  5552. }
  5553. if (opt[0 /* shouldCast */]) {
  5554. if (isAbsent && !hasDefault) {
  5555. value = false;
  5556. } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
  5557. value = true;
  5558. }
  5559. }
  5560. }
  5561. return value;
  5562. }
  5563. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5564. const cache = appContext.propsCache;
  5565. const cached = cache.get(comp);
  5566. if (cached) {
  5567. return cached;
  5568. }
  5569. const raw = comp.props;
  5570. const normalized = {};
  5571. const needCastKeys = [];
  5572. let hasExtends = false;
  5573. if (!isFunction(comp)) {
  5574. const extendProps = (raw2) => {
  5575. hasExtends = true;
  5576. const [props, keys] = normalizePropsOptions(raw2, appContext, true);
  5577. extend(normalized, props);
  5578. if (keys)
  5579. needCastKeys.push(...keys);
  5580. };
  5581. if (!asMixin && appContext.mixins.length) {
  5582. appContext.mixins.forEach(extendProps);
  5583. }
  5584. if (comp.extends) {
  5585. extendProps(comp.extends);
  5586. }
  5587. if (comp.mixins) {
  5588. comp.mixins.forEach(extendProps);
  5589. }
  5590. }
  5591. if (!raw && !hasExtends) {
  5592. if (isObject(comp)) {
  5593. cache.set(comp, EMPTY_ARR);
  5594. }
  5595. return EMPTY_ARR;
  5596. }
  5597. if (isArray(raw)) {
  5598. for (let i = 0; i < raw.length; i++) {
  5599. if (!isString(raw[i])) {
  5600. warn(`props must be strings when using array syntax.`, raw[i]);
  5601. }
  5602. const normalizedKey = camelize(raw[i]);
  5603. if (validatePropName(normalizedKey)) {
  5604. normalized[normalizedKey] = EMPTY_OBJ;
  5605. }
  5606. }
  5607. } else if (raw) {
  5608. if (!isObject(raw)) {
  5609. warn(`invalid props options`, raw);
  5610. }
  5611. for (const key in raw) {
  5612. const normalizedKey = camelize(key);
  5613. if (validatePropName(normalizedKey)) {
  5614. const opt = raw[key];
  5615. const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
  5616. if (prop) {
  5617. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5618. const stringIndex = getTypeIndex(String, prop.type);
  5619. prop[0 /* shouldCast */] = booleanIndex > -1;
  5620. prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
  5621. if (booleanIndex > -1 || hasOwn(prop, "default")) {
  5622. needCastKeys.push(normalizedKey);
  5623. }
  5624. }
  5625. }
  5626. }
  5627. }
  5628. const res = [normalized, needCastKeys];
  5629. if (isObject(comp)) {
  5630. cache.set(comp, res);
  5631. }
  5632. return res;
  5633. }
  5634. function validatePropName(key) {
  5635. if (key[0] !== "$") {
  5636. return true;
  5637. } else {
  5638. warn(`Invalid prop name: "${key}" is a reserved property.`);
  5639. }
  5640. return false;
  5641. }
  5642. function getType(ctor) {
  5643. const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
  5644. return match ? match[2] : ctor === null ? "null" : "";
  5645. }
  5646. function isSameType(a, b) {
  5647. return getType(a) === getType(b);
  5648. }
  5649. function getTypeIndex(type, expectedTypes) {
  5650. if (isArray(expectedTypes)) {
  5651. return expectedTypes.findIndex((t) => isSameType(t, type));
  5652. } else if (isFunction(expectedTypes)) {
  5653. return isSameType(expectedTypes, type) ? 0 : -1;
  5654. }
  5655. return -1;
  5656. }
  5657. function validateProps(rawProps, props, instance) {
  5658. const resolvedValues = toRaw(props);
  5659. const options = instance.propsOptions[0];
  5660. for (const key in options) {
  5661. let opt = options[key];
  5662. if (opt == null)
  5663. continue;
  5664. validateProp(
  5665. key,
  5666. resolvedValues[key],
  5667. opt,
  5668. !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
  5669. );
  5670. }
  5671. }
  5672. function validateProp(name, value, prop, isAbsent) {
  5673. const { type, required, validator, skipCheck } = prop;
  5674. if (required && isAbsent) {
  5675. warn('Missing required prop: "' + name + '"');
  5676. return;
  5677. }
  5678. if (value == null && !required) {
  5679. return;
  5680. }
  5681. if (type != null && type !== true && !skipCheck) {
  5682. let isValid = false;
  5683. const types = isArray(type) ? type : [type];
  5684. const expectedTypes = [];
  5685. for (let i = 0; i < types.length && !isValid; i++) {
  5686. const { valid, expectedType } = assertType(value, types[i]);
  5687. expectedTypes.push(expectedType || "");
  5688. isValid = valid;
  5689. }
  5690. if (!isValid) {
  5691. warn(getInvalidTypeMessage(name, value, expectedTypes));
  5692. return;
  5693. }
  5694. }
  5695. if (validator && !validator(value)) {
  5696. warn('Invalid prop: custom validator check failed for prop "' + name + '".');
  5697. }
  5698. }
  5699. const isSimpleType = /* @__PURE__ */ makeMap(
  5700. "String,Number,Boolean,Function,Symbol,BigInt"
  5701. );
  5702. function assertType(value, type) {
  5703. let valid;
  5704. const expectedType = getType(type);
  5705. if (isSimpleType(expectedType)) {
  5706. const t = typeof value;
  5707. valid = t === expectedType.toLowerCase();
  5708. if (!valid && t === "object") {
  5709. valid = value instanceof type;
  5710. }
  5711. } else if (expectedType === "Object") {
  5712. valid = isObject(value);
  5713. } else if (expectedType === "Array") {
  5714. valid = isArray(value);
  5715. } else if (expectedType === "null") {
  5716. valid = value === null;
  5717. } else {
  5718. valid = value instanceof type;
  5719. }
  5720. return {
  5721. valid,
  5722. expectedType
  5723. };
  5724. }
  5725. function getInvalidTypeMessage(name, value, expectedTypes) {
  5726. let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
  5727. const expectedType = expectedTypes[0];
  5728. const receivedType = toRawType(value);
  5729. const expectedValue = styleValue(value, expectedType);
  5730. const receivedValue = styleValue(value, receivedType);
  5731. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
  5732. message += ` with value ${expectedValue}`;
  5733. }
  5734. message += `, got ${receivedType} `;
  5735. if (isExplicable(receivedType)) {
  5736. message += `with value ${receivedValue}.`;
  5737. }
  5738. return message;
  5739. }
  5740. function styleValue(value, type) {
  5741. if (type === "String") {
  5742. return `"${value}"`;
  5743. } else if (type === "Number") {
  5744. return `${Number(value)}`;
  5745. } else {
  5746. return `${value}`;
  5747. }
  5748. }
  5749. function isExplicable(type) {
  5750. const explicitTypes = ["string", "number", "boolean"];
  5751. return explicitTypes.some((elem) => type.toLowerCase() === elem);
  5752. }
  5753. function isBoolean(...args) {
  5754. return args.some((elem) => elem.toLowerCase() === "boolean");
  5755. }
  5756.  
  5757. const isInternalKey = (key) => key[0] === "_" || key === "$stable";
  5758. const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
  5759. const normalizeSlot = (key, rawSlot, ctx) => {
  5760. if (rawSlot._n) {
  5761. return rawSlot;
  5762. }
  5763. const normalized = withCtx((...args) => {
  5764. if (currentInstance) {
  5765. warn(
  5766. `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
  5767. );
  5768. }
  5769. return normalizeSlotValue(rawSlot(...args));
  5770. }, ctx);
  5771. normalized._c = false;
  5772. return normalized;
  5773. };
  5774. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5775. const ctx = rawSlots._ctx;
  5776. for (const key in rawSlots) {
  5777. if (isInternalKey(key))
  5778. continue;
  5779. const value = rawSlots[key];
  5780. if (isFunction(value)) {
  5781. slots[key] = normalizeSlot(key, value, ctx);
  5782. } else if (value != null) {
  5783. {
  5784. warn(
  5785. `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
  5786. );
  5787. }
  5788. const normalized = normalizeSlotValue(value);
  5789. slots[key] = () => normalized;
  5790. }
  5791. }
  5792. };
  5793. const normalizeVNodeSlots = (instance, children) => {
  5794. if (!isKeepAlive(instance.vnode) && true) {
  5795. warn(
  5796. `Non-function value encountered for default slot. Prefer function slots for better performance.`
  5797. );
  5798. }
  5799. const normalized = normalizeSlotValue(children);
  5800. instance.slots.default = () => normalized;
  5801. };
  5802. const initSlots = (instance, children) => {
  5803. if (instance.vnode.shapeFlag & 32) {
  5804. const type = children._;
  5805. if (type) {
  5806. instance.slots = toRaw(children);
  5807. def(children, "_", type);
  5808. } else {
  5809. normalizeObjectSlots(
  5810. children,
  5811. instance.slots = {});
  5812. }
  5813. } else {
  5814. instance.slots = {};
  5815. if (children) {
  5816. normalizeVNodeSlots(instance, children);
  5817. }
  5818. }
  5819. def(instance.slots, InternalObjectKey, 1);
  5820. };
  5821. const updateSlots = (instance, children, optimized) => {
  5822. const { vnode, slots } = instance;
  5823. let needDeletionCheck = true;
  5824. let deletionComparisonTarget = EMPTY_OBJ;
  5825. if (vnode.shapeFlag & 32) {
  5826. const type = children._;
  5827. if (type) {
  5828. if (isHmrUpdating) {
  5829. extend(slots, children);
  5830. trigger(instance, "set", "$slots");
  5831. } else if (optimized && type === 1) {
  5832. needDeletionCheck = false;
  5833. } else {
  5834. extend(slots, children);
  5835. if (!optimized && type === 1) {
  5836. delete slots._;
  5837. }
  5838. }
  5839. } else {
  5840. needDeletionCheck = !children.$stable;
  5841. normalizeObjectSlots(children, slots);
  5842. }
  5843. deletionComparisonTarget = children;
  5844. } else if (children) {
  5845. normalizeVNodeSlots(instance, children);
  5846. deletionComparisonTarget = { default: 1 };
  5847. }
  5848. if (needDeletionCheck) {
  5849. for (const key in slots) {
  5850. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  5851. delete slots[key];
  5852. }
  5853. }
  5854. }
  5855. };
  5856.  
  5857. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5858. if (isArray(rawRef)) {
  5859. rawRef.forEach(
  5860. (r, i) => setRef(
  5861. r,
  5862. oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
  5863. parentSuspense,
  5864. vnode,
  5865. isUnmount
  5866. )
  5867. );
  5868. return;
  5869. }
  5870. if (isAsyncWrapper(vnode) && !isUnmount) {
  5871. return;
  5872. }
  5873. const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
  5874. const value = isUnmount ? null : refValue;
  5875. const { i: owner, r: ref } = rawRef;
  5876. if (!owner) {
  5877. warn(
  5878. `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
  5879. );
  5880. return;
  5881. }
  5882. const oldRef = oldRawRef && oldRawRef.r;
  5883. const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
  5884. const setupState = owner.setupState;
  5885. if (oldRef != null && oldRef !== ref) {
  5886. if (isString(oldRef)) {
  5887. refs[oldRef] = null;
  5888. if (hasOwn(setupState, oldRef)) {
  5889. setupState[oldRef] = null;
  5890. }
  5891. } else if (isRef(oldRef)) {
  5892. oldRef.value = null;
  5893. }
  5894. }
  5895. if (isFunction(ref)) {
  5896. callWithErrorHandling(ref, owner, 12, [value, refs]);
  5897. } else {
  5898. const _isString = isString(ref);
  5899. const _isRef = isRef(ref);
  5900. if (_isString || _isRef) {
  5901. const doSet = () => {
  5902. if (rawRef.f) {
  5903. const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
  5904. if (isUnmount) {
  5905. isArray(existing) && remove(existing, refValue);
  5906. } else {
  5907. if (!isArray(existing)) {
  5908. if (_isString) {
  5909. refs[ref] = [refValue];
  5910. if (hasOwn(setupState, ref)) {
  5911. setupState[ref] = refs[ref];
  5912. }
  5913. } else {
  5914. ref.value = [refValue];
  5915. if (rawRef.k)
  5916. refs[rawRef.k] = ref.value;
  5917. }
  5918. } else if (!existing.includes(refValue)) {
  5919. existing.push(refValue);
  5920. }
  5921. }
  5922. } else if (_isString) {
  5923. refs[ref] = value;
  5924. if (hasOwn(setupState, ref)) {
  5925. setupState[ref] = value;
  5926. }
  5927. } else if (_isRef) {
  5928. ref.value = value;
  5929. if (rawRef.k)
  5930. refs[rawRef.k] = value;
  5931. } else {
  5932. warn("Invalid template ref type:", ref, `(${typeof ref})`);
  5933. }
  5934. };
  5935. if (value) {
  5936. doSet.id = -1;
  5937. queuePostRenderEffect(doSet, parentSuspense);
  5938. } else {
  5939. doSet();
  5940. }
  5941. } else {
  5942. warn("Invalid template ref type:", ref, `(${typeof ref})`);
  5943. }
  5944. }
  5945. }
  5946.  
  5947. let hasMismatch = false;
  5948. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== "foreignObject";
  5949. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  5950. function createHydrationFunctions(rendererInternals) {
  5951. const {
  5952. mt: mountComponent,
  5953. p: patch,
  5954. o: {
  5955. patchProp,
  5956. createText,
  5957. nextSibling,
  5958. parentNode,
  5959. remove,
  5960. insert,
  5961. createComment
  5962. }
  5963. } = rendererInternals;
  5964. const hydrate = (vnode, container) => {
  5965. if (!container.hasChildNodes()) {
  5966. warn(
  5967. `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
  5968. );
  5969. patch(null, vnode, container);
  5970. flushPostFlushCbs();
  5971. container._vnode = vnode;
  5972. return;
  5973. }
  5974. hasMismatch = false;
  5975. hydrateNode(container.firstChild, vnode, null, null, null);
  5976. flushPostFlushCbs();
  5977. container._vnode = vnode;
  5978. if (hasMismatch && true) {
  5979. console.error(`Hydration completed but contains mismatches.`);
  5980. }
  5981. };
  5982. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  5983. const isFragmentStart = isComment(node) && node.data === "[";
  5984. const onMismatch = () => handleMismatch(
  5985. node,
  5986. vnode,
  5987. parentComponent,
  5988. parentSuspense,
  5989. slotScopeIds,
  5990. isFragmentStart
  5991. );
  5992. const { type, ref, shapeFlag, patchFlag } = vnode;
  5993. let domType = node.nodeType;
  5994. vnode.el = node;
  5995. if (patchFlag === -2) {
  5996. optimized = false;
  5997. vnode.dynamicChildren = null;
  5998. }
  5999. let nextNode = null;
  6000. switch (type) {
  6001. case Text:
  6002. if (domType !== 3 /* TEXT */) {
  6003. if (vnode.children === "") {
  6004. insert(vnode.el = createText(""), parentNode(node), node);
  6005. nextNode = node;
  6006. } else {
  6007. nextNode = onMismatch();
  6008. }
  6009. } else {
  6010. if (node.data !== vnode.children) {
  6011. hasMismatch = true;
  6012. warn(
  6013. `Hydration text mismatch:
  6014. - Client: ${JSON.stringify(node.data)}
  6015. - Server: ${JSON.stringify(vnode.children)}`
  6016. );
  6017. node.data = vnode.children;
  6018. }
  6019. nextNode = nextSibling(node);
  6020. }
  6021. break;
  6022. case Comment:
  6023. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  6024. nextNode = onMismatch();
  6025. } else {
  6026. nextNode = nextSibling(node);
  6027. }
  6028. break;
  6029. case Static:
  6030. if (isFragmentStart) {
  6031. node = nextSibling(node);
  6032. domType = node.nodeType;
  6033. }
  6034. if (domType === 1 /* ELEMENT */ || domType === 3 /* TEXT */) {
  6035. nextNode = node;
  6036. const needToAdoptContent = !vnode.children.length;
  6037. for (let i = 0; i < vnode.staticCount; i++) {
  6038. if (needToAdoptContent)
  6039. vnode.children += nextNode.nodeType === 1 /* ELEMENT */ ? nextNode.outerHTML : nextNode.data;
  6040. if (i === vnode.staticCount - 1) {
  6041. vnode.anchor = nextNode;
  6042. }
  6043. nextNode = nextSibling(nextNode);
  6044. }
  6045. return isFragmentStart ? nextSibling(nextNode) : nextNode;
  6046. } else {
  6047. onMismatch();
  6048. }
  6049. break;
  6050. case Fragment:
  6051. if (!isFragmentStart) {
  6052. nextNode = onMismatch();
  6053. } else {
  6054. nextNode = hydrateFragment(
  6055. node,
  6056. vnode,
  6057. parentComponent,
  6058. parentSuspense,
  6059. slotScopeIds,
  6060. optimized
  6061. );
  6062. }
  6063. break;
  6064. default:
  6065. if (shapeFlag & 1) {
  6066. if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
  6067. nextNode = onMismatch();
  6068. } else {
  6069. nextNode = hydrateElement(
  6070. node,
  6071. vnode,
  6072. parentComponent,
  6073. parentSuspense,
  6074. slotScopeIds,
  6075. optimized
  6076. );
  6077. }
  6078. } else if (shapeFlag & 6) {
  6079. vnode.slotScopeIds = slotScopeIds;
  6080. const container = parentNode(node);
  6081. mountComponent(
  6082. vnode,
  6083. container,
  6084. null,
  6085. parentComponent,
  6086. parentSuspense,
  6087. isSVGContainer(container),
  6088. optimized
  6089. );
  6090. nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
  6091. if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
  6092. nextNode = nextSibling(nextNode);
  6093. }
  6094. if (isAsyncWrapper(vnode)) {
  6095. let subTree;
  6096. if (isFragmentStart) {
  6097. subTree = createVNode(Fragment);
  6098. subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
  6099. } else {
  6100. subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
  6101. }
  6102. subTree.el = node;
  6103. vnode.component.subTree = subTree;
  6104. }
  6105. } else if (shapeFlag & 64) {
  6106. if (domType !== 8 /* COMMENT */) {
  6107. nextNode = onMismatch();
  6108. } else {
  6109. nextNode = vnode.type.hydrate(
  6110. node,
  6111. vnode,
  6112. parentComponent,
  6113. parentSuspense,
  6114. slotScopeIds,
  6115. optimized,
  6116. rendererInternals,
  6117. hydrateChildren
  6118. );
  6119. }
  6120. } else if (shapeFlag & 128) {
  6121. nextNode = vnode.type.hydrate(
  6122. node,
  6123. vnode,
  6124. parentComponent,
  6125. parentSuspense,
  6126. isSVGContainer(parentNode(node)),
  6127. slotScopeIds,
  6128. optimized,
  6129. rendererInternals,
  6130. hydrateNode
  6131. );
  6132. } else {
  6133. warn("Invalid HostVNode type:", type, `(${typeof type})`);
  6134. }
  6135. }
  6136. if (ref != null) {
  6137. setRef(ref, null, parentSuspense, vnode);
  6138. }
  6139. return nextNode;
  6140. };
  6141. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6142. optimized = optimized || !!vnode.dynamicChildren;
  6143. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  6144. const forcePatchValue = type === "input" && dirs || type === "option";
  6145. {
  6146. if (dirs) {
  6147. invokeDirectiveHook(vnode, null, parentComponent, "created");
  6148. }
  6149. if (props) {
  6150. if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
  6151. for (const key in props) {
  6152. if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
  6153. patchProp(
  6154. el,
  6155. key,
  6156. null,
  6157. props[key],
  6158. false,
  6159. void 0,
  6160. parentComponent
  6161. );
  6162. }
  6163. }
  6164. } else if (props.onClick) {
  6165. patchProp(
  6166. el,
  6167. "onClick",
  6168. null,
  6169. props.onClick,
  6170. false,
  6171. void 0,
  6172. parentComponent
  6173. );
  6174. }
  6175. }
  6176. let vnodeHooks;
  6177. if (vnodeHooks = props && props.onVnodeBeforeMount) {
  6178. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6179. }
  6180. if (dirs) {
  6181. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  6182. }
  6183. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  6184. queueEffectWithSuspense(() => {
  6185. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6186. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  6187. }, parentSuspense);
  6188. }
  6189. if (shapeFlag & 16 && // skip if element has innerHTML / textContent
  6190. !(props && (props.innerHTML || props.textContent))) {
  6191. let next = hydrateChildren(
  6192. el.firstChild,
  6193. vnode,
  6194. el,
  6195. parentComponent,
  6196. parentSuspense,
  6197. slotScopeIds,
  6198. optimized
  6199. );
  6200. let hasWarned = false;
  6201. while (next) {
  6202. hasMismatch = true;
  6203. if (!hasWarned) {
  6204. warn(
  6205. `Hydration children mismatch in <${vnode.type}>: server rendered element contains more child nodes than client vdom.`
  6206. );
  6207. hasWarned = true;
  6208. }
  6209. const cur = next;
  6210. next = next.nextSibling;
  6211. remove(cur);
  6212. }
  6213. } else if (shapeFlag & 8) {
  6214. if (el.textContent !== vnode.children) {
  6215. hasMismatch = true;
  6216. warn(
  6217. `Hydration text content mismatch in <${vnode.type}>:
  6218. - Client: ${el.textContent}
  6219. - Server: ${vnode.children}`
  6220. );
  6221. el.textContent = vnode.children;
  6222. }
  6223. }
  6224. }
  6225. return el.nextSibling;
  6226. };
  6227. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6228. optimized = optimized || !!parentVNode.dynamicChildren;
  6229. const children = parentVNode.children;
  6230. const l = children.length;
  6231. let hasWarned = false;
  6232. for (let i = 0; i < l; i++) {
  6233. const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
  6234. if (node) {
  6235. node = hydrateNode(
  6236. node,
  6237. vnode,
  6238. parentComponent,
  6239. parentSuspense,
  6240. slotScopeIds,
  6241. optimized
  6242. );
  6243. } else if (vnode.type === Text && !vnode.children) {
  6244. continue;
  6245. } else {
  6246. hasMismatch = true;
  6247. if (!hasWarned) {
  6248. warn(
  6249. `Hydration children mismatch in <${container.tagName.toLowerCase()}>: server rendered element contains fewer child nodes than client vdom.`
  6250. );
  6251. hasWarned = true;
  6252. }
  6253. patch(
  6254. null,
  6255. vnode,
  6256. container,
  6257. null,
  6258. parentComponent,
  6259. parentSuspense,
  6260. isSVGContainer(container),
  6261. slotScopeIds
  6262. );
  6263. }
  6264. }
  6265. return node;
  6266. };
  6267. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6268. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  6269. if (fragmentSlotScopeIds) {
  6270. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  6271. }
  6272. const container = parentNode(node);
  6273. const next = hydrateChildren(
  6274. nextSibling(node),
  6275. vnode,
  6276. container,
  6277. parentComponent,
  6278. parentSuspense,
  6279. slotScopeIds,
  6280. optimized
  6281. );
  6282. if (next && isComment(next) && next.data === "]") {
  6283. return nextSibling(vnode.anchor = next);
  6284. } else {
  6285. hasMismatch = true;
  6286. insert(vnode.anchor = createComment(`]`), container, next);
  6287. return next;
  6288. }
  6289. };
  6290. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6291. hasMismatch = true;
  6292. warn(
  6293. `Hydration node mismatch:
  6294. - Client vnode:`,
  6295. vnode.type,
  6296. `
  6297. - Server rendered DOM:`,
  6298. node,
  6299. node.nodeType === 3 /* TEXT */ ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``
  6300. );
  6301. vnode.el = null;
  6302. if (isFragment) {
  6303. const end = locateClosingAsyncAnchor(node);
  6304. while (true) {
  6305. const next2 = nextSibling(node);
  6306. if (next2 && next2 !== end) {
  6307. remove(next2);
  6308. } else {
  6309. break;
  6310. }
  6311. }
  6312. }
  6313. const next = nextSibling(node);
  6314. const container = parentNode(node);
  6315. remove(node);
  6316. patch(
  6317. null,
  6318. vnode,
  6319. container,
  6320. next,
  6321. parentComponent,
  6322. parentSuspense,
  6323. isSVGContainer(container),
  6324. slotScopeIds
  6325. );
  6326. return next;
  6327. };
  6328. const locateClosingAsyncAnchor = (node) => {
  6329. let match = 0;
  6330. while (node) {
  6331. node = nextSibling(node);
  6332. if (node && isComment(node)) {
  6333. if (node.data === "[")
  6334. match++;
  6335. if (node.data === "]") {
  6336. if (match === 0) {
  6337. return nextSibling(node);
  6338. } else {
  6339. match--;
  6340. }
  6341. }
  6342. }
  6343. }
  6344. return node;
  6345. };
  6346. return [hydrate, hydrateNode];
  6347. }
  6348.  
  6349. let supported;
  6350. let perf;
  6351. function startMeasure(instance, type) {
  6352. if (instance.appContext.config.performance && isSupported()) {
  6353. perf.mark(`vue-${type}-${instance.uid}`);
  6354. }
  6355. {
  6356. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  6357. }
  6358. }
  6359. function endMeasure(instance, type) {
  6360. if (instance.appContext.config.performance && isSupported()) {
  6361. const startTag = `vue-${type}-${instance.uid}`;
  6362. const endTag = startTag + `:end`;
  6363. perf.mark(endTag);
  6364. perf.measure(
  6365. `<${formatComponentName(instance, instance.type)}> ${type}`,
  6366. startTag,
  6367. endTag
  6368. );
  6369. perf.clearMarks(startTag);
  6370. perf.clearMarks(endTag);
  6371. }
  6372. {
  6373. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  6374. }
  6375. }
  6376. function isSupported() {
  6377. if (supported !== void 0) {
  6378. return supported;
  6379. }
  6380. if (typeof window !== "undefined" && window.performance) {
  6381. supported = true;
  6382. perf = window.performance;
  6383. } else {
  6384. supported = false;
  6385. }
  6386. return supported;
  6387. }
  6388.  
  6389. const queuePostRenderEffect = queueEffectWithSuspense ;
  6390. function createRenderer(options) {
  6391. return baseCreateRenderer(options);
  6392. }
  6393. function createHydrationRenderer(options) {
  6394. return baseCreateRenderer(options, createHydrationFunctions);
  6395. }
  6396. function baseCreateRenderer(options, createHydrationFns) {
  6397. const target = getGlobalThis();
  6398. target.__VUE__ = true;
  6399. {
  6400. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  6401. }
  6402. const {
  6403. insert: hostInsert,
  6404. remove: hostRemove,
  6405. patchProp: hostPatchProp,
  6406. createElement: hostCreateElement,
  6407. createText: hostCreateText,
  6408. createComment: hostCreateComment,
  6409. setText: hostSetText,
  6410. setElementText: hostSetElementText,
  6411. parentNode: hostParentNode,
  6412. nextSibling: hostNextSibling,
  6413. setScopeId: hostSetScopeId = NOOP,
  6414. insertStaticContent: hostInsertStaticContent
  6415. } = options;
  6416. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6417. if (n1 === n2) {
  6418. return;
  6419. }
  6420. if (n1 && !isSameVNodeType(n1, n2)) {
  6421. anchor = getNextHostNode(n1);
  6422. unmount(n1, parentComponent, parentSuspense, true);
  6423. n1 = null;
  6424. }
  6425. if (n2.patchFlag === -2) {
  6426. optimized = false;
  6427. n2.dynamicChildren = null;
  6428. }
  6429. const { type, ref, shapeFlag } = n2;
  6430. switch (type) {
  6431. case Text:
  6432. processText(n1, n2, container, anchor);
  6433. break;
  6434. case Comment:
  6435. processCommentNode(n1, n2, container, anchor);
  6436. break;
  6437. case Static:
  6438. if (n1 == null) {
  6439. mountStaticNode(n2, container, anchor, isSVG);
  6440. } else {
  6441. patchStaticNode(n1, n2, container, isSVG);
  6442. }
  6443. break;
  6444. case Fragment:
  6445. processFragment(
  6446. n1,
  6447. n2,
  6448. container,
  6449. anchor,
  6450. parentComponent,
  6451. parentSuspense,
  6452. isSVG,
  6453. slotScopeIds,
  6454. optimized
  6455. );
  6456. break;
  6457. default:
  6458. if (shapeFlag & 1) {
  6459. processElement(
  6460. n1,
  6461. n2,
  6462. container,
  6463. anchor,
  6464. parentComponent,
  6465. parentSuspense,
  6466. isSVG,
  6467. slotScopeIds,
  6468. optimized
  6469. );
  6470. } else if (shapeFlag & 6) {
  6471. processComponent(
  6472. n1,
  6473. n2,
  6474. container,
  6475. anchor,
  6476. parentComponent,
  6477. parentSuspense,
  6478. isSVG,
  6479. slotScopeIds,
  6480. optimized
  6481. );
  6482. } else if (shapeFlag & 64) {
  6483. type.process(
  6484. n1,
  6485. n2,
  6486. container,
  6487. anchor,
  6488. parentComponent,
  6489. parentSuspense,
  6490. isSVG,
  6491. slotScopeIds,
  6492. optimized,
  6493. internals
  6494. );
  6495. } else if (shapeFlag & 128) {
  6496. type.process(
  6497. n1,
  6498. n2,
  6499. container,
  6500. anchor,
  6501. parentComponent,
  6502. parentSuspense,
  6503. isSVG,
  6504. slotScopeIds,
  6505. optimized,
  6506. internals
  6507. );
  6508. } else {
  6509. warn("Invalid VNode type:", type, `(${typeof type})`);
  6510. }
  6511. }
  6512. if (ref != null && parentComponent) {
  6513. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  6514. }
  6515. };
  6516. const processText = (n1, n2, container, anchor) => {
  6517. if (n1 == null) {
  6518. hostInsert(
  6519. n2.el = hostCreateText(n2.children),
  6520. container,
  6521. anchor
  6522. );
  6523. } else {
  6524. const el = n2.el = n1.el;
  6525. if (n2.children !== n1.children) {
  6526. hostSetText(el, n2.children);
  6527. }
  6528. }
  6529. };
  6530. const processCommentNode = (n1, n2, container, anchor) => {
  6531. if (n1 == null) {
  6532. hostInsert(
  6533. n2.el = hostCreateComment(n2.children || ""),
  6534. container,
  6535. anchor
  6536. );
  6537. } else {
  6538. n2.el = n1.el;
  6539. }
  6540. };
  6541. const mountStaticNode = (n2, container, anchor, isSVG) => {
  6542. [n2.el, n2.anchor] = hostInsertStaticContent(
  6543. n2.children,
  6544. container,
  6545. anchor,
  6546. isSVG,
  6547. n2.el,
  6548. n2.anchor
  6549. );
  6550. };
  6551. const patchStaticNode = (n1, n2, container, isSVG) => {
  6552. if (n2.children !== n1.children) {
  6553. const anchor = hostNextSibling(n1.anchor);
  6554. removeStaticNode(n1);
  6555. [n2.el, n2.anchor] = hostInsertStaticContent(
  6556. n2.children,
  6557. container,
  6558. anchor,
  6559. isSVG
  6560. );
  6561. } else {
  6562. n2.el = n1.el;
  6563. n2.anchor = n1.anchor;
  6564. }
  6565. };
  6566. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6567. let next;
  6568. while (el && el !== anchor) {
  6569. next = hostNextSibling(el);
  6570. hostInsert(el, container, nextSibling);
  6571. el = next;
  6572. }
  6573. hostInsert(anchor, container, nextSibling);
  6574. };
  6575. const removeStaticNode = ({ el, anchor }) => {
  6576. let next;
  6577. while (el && el !== anchor) {
  6578. next = hostNextSibling(el);
  6579. hostRemove(el);
  6580. el = next;
  6581. }
  6582. hostRemove(anchor);
  6583. };
  6584. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6585. isSVG = isSVG || n2.type === "svg";
  6586. if (n1 == null) {
  6587. mountElement(
  6588. n2,
  6589. container,
  6590. anchor,
  6591. parentComponent,
  6592. parentSuspense,
  6593. isSVG,
  6594. slotScopeIds,
  6595. optimized
  6596. );
  6597. } else {
  6598. patchElement(
  6599. n1,
  6600. n2,
  6601. parentComponent,
  6602. parentSuspense,
  6603. isSVG,
  6604. slotScopeIds,
  6605. optimized
  6606. );
  6607. }
  6608. };
  6609. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6610. let el;
  6611. let vnodeHook;
  6612. const { type, props, shapeFlag, transition, dirs } = vnode;
  6613. el = vnode.el = hostCreateElement(
  6614. vnode.type,
  6615. isSVG,
  6616. props && props.is,
  6617. props
  6618. );
  6619. if (shapeFlag & 8) {
  6620. hostSetElementText(el, vnode.children);
  6621. } else if (shapeFlag & 16) {
  6622. mountChildren(
  6623. vnode.children,
  6624. el,
  6625. null,
  6626. parentComponent,
  6627. parentSuspense,
  6628. isSVG && type !== "foreignObject",
  6629. slotScopeIds,
  6630. optimized
  6631. );
  6632. }
  6633. if (dirs) {
  6634. invokeDirectiveHook(vnode, null, parentComponent, "created");
  6635. }
  6636. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  6637. if (props) {
  6638. for (const key in props) {
  6639. if (key !== "value" && !isReservedProp(key)) {
  6640. hostPatchProp(
  6641. el,
  6642. key,
  6643. null,
  6644. props[key],
  6645. isSVG,
  6646. vnode.children,
  6647. parentComponent,
  6648. parentSuspense,
  6649. unmountChildren
  6650. );
  6651. }
  6652. }
  6653. if ("value" in props) {
  6654. hostPatchProp(el, "value", null, props.value);
  6655. }
  6656. if (vnodeHook = props.onVnodeBeforeMount) {
  6657. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6658. }
  6659. }
  6660. {
  6661. Object.defineProperty(el, "__vnode", {
  6662. value: vnode,
  6663. enumerable: false
  6664. });
  6665. Object.defineProperty(el, "__vueParentComponent", {
  6666. value: parentComponent,
  6667. enumerable: false
  6668. });
  6669. }
  6670. if (dirs) {
  6671. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  6672. }
  6673. const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
  6674. if (needCallTransitionHooks) {
  6675. transition.beforeEnter(el);
  6676. }
  6677. hostInsert(el, container, anchor);
  6678. if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
  6679. queuePostRenderEffect(() => {
  6680. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6681. needCallTransitionHooks && transition.enter(el);
  6682. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  6683. }, parentSuspense);
  6684. }
  6685. };
  6686. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6687. if (scopeId) {
  6688. hostSetScopeId(el, scopeId);
  6689. }
  6690. if (slotScopeIds) {
  6691. for (let i = 0; i < slotScopeIds.length; i++) {
  6692. hostSetScopeId(el, slotScopeIds[i]);
  6693. }
  6694. }
  6695. if (parentComponent) {
  6696. let subTree = parentComponent.subTree;
  6697. if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
  6698. subTree = filterSingleRoot(subTree.children) || subTree;
  6699. }
  6700. if (vnode === subTree) {
  6701. const parentVNode = parentComponent.vnode;
  6702. setScopeId(
  6703. el,
  6704. parentVNode,
  6705. parentVNode.scopeId,
  6706. parentVNode.slotScopeIds,
  6707. parentComponent.parent
  6708. );
  6709. }
  6710. }
  6711. };
  6712. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6713. for (let i = start; i < children.length; i++) {
  6714. const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
  6715. patch(
  6716. null,
  6717. child,
  6718. container,
  6719. anchor,
  6720. parentComponent,
  6721. parentSuspense,
  6722. isSVG,
  6723. slotScopeIds,
  6724. optimized
  6725. );
  6726. }
  6727. };
  6728. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6729. const el = n2.el = n1.el;
  6730. let { patchFlag, dynamicChildren, dirs } = n2;
  6731. patchFlag |= n1.patchFlag & 16;
  6732. const oldProps = n1.props || EMPTY_OBJ;
  6733. const newProps = n2.props || EMPTY_OBJ;
  6734. let vnodeHook;
  6735. parentComponent && toggleRecurse(parentComponent, false);
  6736. if (vnodeHook = newProps.onVnodeBeforeUpdate) {
  6737. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6738. }
  6739. if (dirs) {
  6740. invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
  6741. }
  6742. parentComponent && toggleRecurse(parentComponent, true);
  6743. if (isHmrUpdating) {
  6744. patchFlag = 0;
  6745. optimized = false;
  6746. dynamicChildren = null;
  6747. }
  6748. const areChildrenSVG = isSVG && n2.type !== "foreignObject";
  6749. if (dynamicChildren) {
  6750. patchBlockChildren(
  6751. n1.dynamicChildren,
  6752. dynamicChildren,
  6753. el,
  6754. parentComponent,
  6755. parentSuspense,
  6756. areChildrenSVG,
  6757. slotScopeIds
  6758. );
  6759. {
  6760. traverseStaticChildren(n1, n2);
  6761. }
  6762. } else if (!optimized) {
  6763. patchChildren(
  6764. n1,
  6765. n2,
  6766. el,
  6767. null,
  6768. parentComponent,
  6769. parentSuspense,
  6770. areChildrenSVG,
  6771. slotScopeIds,
  6772. false
  6773. );
  6774. }
  6775. if (patchFlag > 0) {
  6776. if (patchFlag & 16) {
  6777. patchProps(
  6778. el,
  6779. n2,
  6780. oldProps,
  6781. newProps,
  6782. parentComponent,
  6783. parentSuspense,
  6784. isSVG
  6785. );
  6786. } else {
  6787. if (patchFlag & 2) {
  6788. if (oldProps.class !== newProps.class) {
  6789. hostPatchProp(el, "class", null, newProps.class, isSVG);
  6790. }
  6791. }
  6792. if (patchFlag & 4) {
  6793. hostPatchProp(el, "style", oldProps.style, newProps.style, isSVG);
  6794. }
  6795. if (patchFlag & 8) {
  6796. const propsToUpdate = n2.dynamicProps;
  6797. for (let i = 0; i < propsToUpdate.length; i++) {
  6798. const key = propsToUpdate[i];
  6799. const prev = oldProps[key];
  6800. const next = newProps[key];
  6801. if (next !== prev || key === "value") {
  6802. hostPatchProp(
  6803. el,
  6804. key,
  6805. prev,
  6806. next,
  6807. isSVG,
  6808. n1.children,
  6809. parentComponent,
  6810. parentSuspense,
  6811. unmountChildren
  6812. );
  6813. }
  6814. }
  6815. }
  6816. }
  6817. if (patchFlag & 1) {
  6818. if (n1.children !== n2.children) {
  6819. hostSetElementText(el, n2.children);
  6820. }
  6821. }
  6822. } else if (!optimized && dynamicChildren == null) {
  6823. patchProps(
  6824. el,
  6825. n2,
  6826. oldProps,
  6827. newProps,
  6828. parentComponent,
  6829. parentSuspense,
  6830. isSVG
  6831. );
  6832. }
  6833. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6834. queuePostRenderEffect(() => {
  6835. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6836. dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
  6837. }, parentSuspense);
  6838. }
  6839. };
  6840. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6841. for (let i = 0; i < newChildren.length; i++) {
  6842. const oldVNode = oldChildren[i];
  6843. const newVNode = newChildren[i];
  6844. const container = (
  6845. // oldVNode may be an errored async setup() component inside Suspense
  6846. // which will not have a mounted element
  6847. oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
  6848. // of the Fragment itself so it can move its children.
  6849. (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
  6850. // which also requires the correct parent container
  6851. !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
  6852. oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
  6853. // In other cases, the parent container is not actually used so we
  6854. // just pass the block element here to avoid a DOM parentNode call.
  6855. fallbackContainer
  6856. )
  6857. );
  6858. patch(
  6859. oldVNode,
  6860. newVNode,
  6861. container,
  6862. null,
  6863. parentComponent,
  6864. parentSuspense,
  6865. isSVG,
  6866. slotScopeIds,
  6867. true
  6868. );
  6869. }
  6870. };
  6871. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6872. if (oldProps !== newProps) {
  6873. if (oldProps !== EMPTY_OBJ) {
  6874. for (const key in oldProps) {
  6875. if (!isReservedProp(key) && !(key in newProps)) {
  6876. hostPatchProp(
  6877. el,
  6878. key,
  6879. oldProps[key],
  6880. null,
  6881. isSVG,
  6882. vnode.children,
  6883. parentComponent,
  6884. parentSuspense,
  6885. unmountChildren
  6886. );
  6887. }
  6888. }
  6889. }
  6890. for (const key in newProps) {
  6891. if (isReservedProp(key))
  6892. continue;
  6893. const next = newProps[key];
  6894. const prev = oldProps[key];
  6895. if (next !== prev && key !== "value") {
  6896. hostPatchProp(
  6897. el,
  6898. key,
  6899. prev,
  6900. next,
  6901. isSVG,
  6902. vnode.children,
  6903. parentComponent,
  6904. parentSuspense,
  6905. unmountChildren
  6906. );
  6907. }
  6908. }
  6909. if ("value" in newProps) {
  6910. hostPatchProp(el, "value", oldProps.value, newProps.value);
  6911. }
  6912. }
  6913. };
  6914. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6915. const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
  6916. const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
  6917. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6918. if (
  6919. // #5523 dev root fragment may inherit directives
  6920. isHmrUpdating || patchFlag & 2048
  6921. ) {
  6922. patchFlag = 0;
  6923. optimized = false;
  6924. dynamicChildren = null;
  6925. }
  6926. if (fragmentSlotScopeIds) {
  6927. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  6928. }
  6929. if (n1 == null) {
  6930. hostInsert(fragmentStartAnchor, container, anchor);
  6931. hostInsert(fragmentEndAnchor, container, anchor);
  6932. mountChildren(
  6933. n2.children,
  6934. container,
  6935. fragmentEndAnchor,
  6936. parentComponent,
  6937. parentSuspense,
  6938. isSVG,
  6939. slotScopeIds,
  6940. optimized
  6941. );
  6942. } else {
  6943. if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
  6944. // of renderSlot() with no valid children
  6945. n1.dynamicChildren) {
  6946. patchBlockChildren(
  6947. n1.dynamicChildren,
  6948. dynamicChildren,
  6949. container,
  6950. parentComponent,
  6951. parentSuspense,
  6952. isSVG,
  6953. slotScopeIds
  6954. );
  6955. {
  6956. traverseStaticChildren(n1, n2);
  6957. }
  6958. } else {
  6959. patchChildren(
  6960. n1,
  6961. n2,
  6962. container,
  6963. fragmentEndAnchor,
  6964. parentComponent,
  6965. parentSuspense,
  6966. isSVG,
  6967. slotScopeIds,
  6968. optimized
  6969. );
  6970. }
  6971. }
  6972. };
  6973. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6974. n2.slotScopeIds = slotScopeIds;
  6975. if (n1 == null) {
  6976. if (n2.shapeFlag & 512) {
  6977. parentComponent.ctx.activate(
  6978. n2,
  6979. container,
  6980. anchor,
  6981. isSVG,
  6982. optimized
  6983. );
  6984. } else {
  6985. mountComponent(
  6986. n2,
  6987. container,
  6988. anchor,
  6989. parentComponent,
  6990. parentSuspense,
  6991. isSVG,
  6992. optimized
  6993. );
  6994. }
  6995. } else {
  6996. updateComponent(n1, n2, optimized);
  6997. }
  6998. };
  6999. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  7000. const instance = (initialVNode.component = createComponentInstance(
  7001. initialVNode,
  7002. parentComponent,
  7003. parentSuspense
  7004. ));
  7005. if (instance.type.__hmrId) {
  7006. registerHMR(instance);
  7007. }
  7008. {
  7009. pushWarningContext(initialVNode);
  7010. startMeasure(instance, `mount`);
  7011. }
  7012. if (isKeepAlive(initialVNode)) {
  7013. instance.ctx.renderer = internals;
  7014. }
  7015. {
  7016. {
  7017. startMeasure(instance, `init`);
  7018. }
  7019. setupComponent(instance);
  7020. {
  7021. endMeasure(instance, `init`);
  7022. }
  7023. }
  7024. if (instance.asyncDep) {
  7025. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  7026. if (!initialVNode.el) {
  7027. const placeholder = instance.subTree = createVNode(Comment);
  7028. processCommentNode(null, placeholder, container, anchor);
  7029. }
  7030. return;
  7031. }
  7032. setupRenderEffect(
  7033. instance,
  7034. initialVNode,
  7035. container,
  7036. anchor,
  7037. parentSuspense,
  7038. isSVG,
  7039. optimized
  7040. );
  7041. {
  7042. popWarningContext();
  7043. endMeasure(instance, `mount`);
  7044. }
  7045. };
  7046. const updateComponent = (n1, n2, optimized) => {
  7047. const instance = n2.component = n1.component;
  7048. if (shouldUpdateComponent(n1, n2, optimized)) {
  7049. if (instance.asyncDep && !instance.asyncResolved) {
  7050. {
  7051. pushWarningContext(n2);
  7052. }
  7053. updateComponentPreRender(instance, n2, optimized);
  7054. {
  7055. popWarningContext();
  7056. }
  7057. return;
  7058. } else {
  7059. instance.next = n2;
  7060. invalidateJob(instance.update);
  7061. instance.update();
  7062. }
  7063. } else {
  7064. n2.el = n1.el;
  7065. instance.vnode = n2;
  7066. }
  7067. };
  7068. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  7069. const componentUpdateFn = () => {
  7070. if (!instance.isMounted) {
  7071. let vnodeHook;
  7072. const { el, props } = initialVNode;
  7073. const { bm, m, parent } = instance;
  7074. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  7075. toggleRecurse(instance, false);
  7076. if (bm) {
  7077. invokeArrayFns(bm);
  7078. }
  7079. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
  7080. invokeVNodeHook(vnodeHook, parent, initialVNode);
  7081. }
  7082. toggleRecurse(instance, true);
  7083. if (el && hydrateNode) {
  7084. const hydrateSubTree = () => {
  7085. {
  7086. startMeasure(instance, `render`);
  7087. }
  7088. instance.subTree = renderComponentRoot(instance);
  7089. {
  7090. endMeasure(instance, `render`);
  7091. }
  7092. {
  7093. startMeasure(instance, `hydrate`);
  7094. }
  7095. hydrateNode(
  7096. el,
  7097. instance.subTree,
  7098. instance,
  7099. parentSuspense,
  7100. null
  7101. );
  7102. {
  7103. endMeasure(instance, `hydrate`);
  7104. }
  7105. };
  7106. if (isAsyncWrapperVNode) {
  7107. initialVNode.type.__asyncLoader().then(
  7108. // note: we are moving the render call into an async callback,
  7109. // which means it won't track dependencies - but it's ok because
  7110. // a server-rendered async wrapper is already in resolved state
  7111. // and it will never need to change.
  7112. () => !instance.isUnmounted && hydrateSubTree()
  7113. );
  7114. } else {
  7115. hydrateSubTree();
  7116. }
  7117. } else {
  7118. {
  7119. startMeasure(instance, `render`);
  7120. }
  7121. const subTree = instance.subTree = renderComponentRoot(instance);
  7122. {
  7123. endMeasure(instance, `render`);
  7124. }
  7125. {
  7126. startMeasure(instance, `patch`);
  7127. }
  7128. patch(
  7129. null,
  7130. subTree,
  7131. container,
  7132. anchor,
  7133. instance,
  7134. parentSuspense,
  7135. isSVG
  7136. );
  7137. {
  7138. endMeasure(instance, `patch`);
  7139. }
  7140. initialVNode.el = subTree.el;
  7141. }
  7142. if (m) {
  7143. queuePostRenderEffect(m, parentSuspense);
  7144. }
  7145. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
  7146. const scopedInitialVNode = initialVNode;
  7147. queuePostRenderEffect(
  7148. () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
  7149. parentSuspense
  7150. );
  7151. }
  7152. if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
  7153. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  7154. }
  7155. instance.isMounted = true;
  7156. {
  7157. devtoolsComponentAdded(instance);
  7158. }
  7159. initialVNode = container = anchor = null;
  7160. } else {
  7161. let { next, bu, u, parent, vnode } = instance;
  7162. let originNext = next;
  7163. let vnodeHook;
  7164. {
  7165. pushWarningContext(next || instance.vnode);
  7166. }
  7167. toggleRecurse(instance, false);
  7168. if (next) {
  7169. next.el = vnode.el;
  7170. updateComponentPreRender(instance, next, optimized);
  7171. } else {
  7172. next = vnode;
  7173. }
  7174. if (bu) {
  7175. invokeArrayFns(bu);
  7176. }
  7177. if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
  7178. invokeVNodeHook(vnodeHook, parent, next, vnode);
  7179. }
  7180. toggleRecurse(instance, true);
  7181. {
  7182. startMeasure(instance, `render`);
  7183. }
  7184. const nextTree = renderComponentRoot(instance);
  7185. {
  7186. endMeasure(instance, `render`);
  7187. }
  7188. const prevTree = instance.subTree;
  7189. instance.subTree = nextTree;
  7190. {
  7191. startMeasure(instance, `patch`);
  7192. }
  7193. patch(
  7194. prevTree,
  7195. nextTree,
  7196. // parent may have changed if it's in a teleport
  7197. hostParentNode(prevTree.el),
  7198. // anchor may have changed if it's in a fragment
  7199. getNextHostNode(prevTree),
  7200. instance,
  7201. parentSuspense,
  7202. isSVG
  7203. );
  7204. {
  7205. endMeasure(instance, `patch`);
  7206. }
  7207. next.el = nextTree.el;
  7208. if (originNext === null) {
  7209. updateHOCHostEl(instance, nextTree.el);
  7210. }
  7211. if (u) {
  7212. queuePostRenderEffect(u, parentSuspense);
  7213. }
  7214. if (vnodeHook = next.props && next.props.onVnodeUpdated) {
  7215. queuePostRenderEffect(
  7216. () => invokeVNodeHook(vnodeHook, parent, next, vnode),
  7217. parentSuspense
  7218. );
  7219. }
  7220. {
  7221. devtoolsComponentUpdated(instance);
  7222. }
  7223. {
  7224. popWarningContext();
  7225. }
  7226. }
  7227. };
  7228. const effect = instance.effect = new ReactiveEffect(
  7229. componentUpdateFn,
  7230. () => queueJob(update),
  7231. instance.scope
  7232. // track it in component's effect scope
  7233. );
  7234. const update = instance.update = () => effect.run();
  7235. update.id = instance.uid;
  7236. toggleRecurse(instance, true);
  7237. {
  7238. effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
  7239. effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
  7240. update.ownerInstance = instance;
  7241. }
  7242. update();
  7243. };
  7244. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7245. nextVNode.component = instance;
  7246. const prevProps = instance.vnode.props;
  7247. instance.vnode = nextVNode;
  7248. instance.next = null;
  7249. updateProps(instance, nextVNode.props, prevProps, optimized);
  7250. updateSlots(instance, nextVNode.children, optimized);
  7251. pauseTracking();
  7252. flushPreFlushCbs();
  7253. resetTracking();
  7254. };
  7255. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  7256. const c1 = n1 && n1.children;
  7257. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  7258. const c2 = n2.children;
  7259. const { patchFlag, shapeFlag } = n2;
  7260. if (patchFlag > 0) {
  7261. if (patchFlag & 128) {
  7262. patchKeyedChildren(
  7263. c1,
  7264. c2,
  7265. container,
  7266. anchor,
  7267. parentComponent,
  7268. parentSuspense,
  7269. isSVG,
  7270. slotScopeIds,
  7271. optimized
  7272. );
  7273. return;
  7274. } else if (patchFlag & 256) {
  7275. patchUnkeyedChildren(
  7276. c1,
  7277. c2,
  7278. container,
  7279. anchor,
  7280. parentComponent,
  7281. parentSuspense,
  7282. isSVG,
  7283. slotScopeIds,
  7284. optimized
  7285. );
  7286. return;
  7287. }
  7288. }
  7289. if (shapeFlag & 8) {
  7290. if (prevShapeFlag & 16) {
  7291. unmountChildren(c1, parentComponent, parentSuspense);
  7292. }
  7293. if (c2 !== c1) {
  7294. hostSetElementText(container, c2);
  7295. }
  7296. } else {
  7297. if (prevShapeFlag & 16) {
  7298. if (shapeFlag & 16) {
  7299. patchKeyedChildren(
  7300. c1,
  7301. c2,
  7302. container,
  7303. anchor,
  7304. parentComponent,
  7305. parentSuspense,
  7306. isSVG,
  7307. slotScopeIds,
  7308. optimized
  7309. );
  7310. } else {
  7311. unmountChildren(c1, parentComponent, parentSuspense, true);
  7312. }
  7313. } else {
  7314. if (prevShapeFlag & 8) {
  7315. hostSetElementText(container, "");
  7316. }
  7317. if (shapeFlag & 16) {
  7318. mountChildren(
  7319. c2,
  7320. container,
  7321. anchor,
  7322. parentComponent,
  7323. parentSuspense,
  7324. isSVG,
  7325. slotScopeIds,
  7326. optimized
  7327. );
  7328. }
  7329. }
  7330. }
  7331. };
  7332. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7333. c1 = c1 || EMPTY_ARR;
  7334. c2 = c2 || EMPTY_ARR;
  7335. const oldLength = c1.length;
  7336. const newLength = c2.length;
  7337. const commonLength = Math.min(oldLength, newLength);
  7338. let i;
  7339. for (i = 0; i < commonLength; i++) {
  7340. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7341. patch(
  7342. c1[i],
  7343. nextChild,
  7344. container,
  7345. null,
  7346. parentComponent,
  7347. parentSuspense,
  7348. isSVG,
  7349. slotScopeIds,
  7350. optimized
  7351. );
  7352. }
  7353. if (oldLength > newLength) {
  7354. unmountChildren(
  7355. c1,
  7356. parentComponent,
  7357. parentSuspense,
  7358. true,
  7359. false,
  7360. commonLength
  7361. );
  7362. } else {
  7363. mountChildren(
  7364. c2,
  7365. container,
  7366. anchor,
  7367. parentComponent,
  7368. parentSuspense,
  7369. isSVG,
  7370. slotScopeIds,
  7371. optimized,
  7372. commonLength
  7373. );
  7374. }
  7375. };
  7376. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7377. let i = 0;
  7378. const l2 = c2.length;
  7379. let e1 = c1.length - 1;
  7380. let e2 = l2 - 1;
  7381. while (i <= e1 && i <= e2) {
  7382. const n1 = c1[i];
  7383. const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7384. if (isSameVNodeType(n1, n2)) {
  7385. patch(
  7386. n1,
  7387. n2,
  7388. container,
  7389. null,
  7390. parentComponent,
  7391. parentSuspense,
  7392. isSVG,
  7393. slotScopeIds,
  7394. optimized
  7395. );
  7396. } else {
  7397. break;
  7398. }
  7399. i++;
  7400. }
  7401. while (i <= e1 && i <= e2) {
  7402. const n1 = c1[e1];
  7403. const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
  7404. if (isSameVNodeType(n1, n2)) {
  7405. patch(
  7406. n1,
  7407. n2,
  7408. container,
  7409. null,
  7410. parentComponent,
  7411. parentSuspense,
  7412. isSVG,
  7413. slotScopeIds,
  7414. optimized
  7415. );
  7416. } else {
  7417. break;
  7418. }
  7419. e1--;
  7420. e2--;
  7421. }
  7422. if (i > e1) {
  7423. if (i <= e2) {
  7424. const nextPos = e2 + 1;
  7425. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  7426. while (i <= e2) {
  7427. patch(
  7428. null,
  7429. c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
  7430. container,
  7431. anchor,
  7432. parentComponent,
  7433. parentSuspense,
  7434. isSVG,
  7435. slotScopeIds,
  7436. optimized
  7437. );
  7438. i++;
  7439. }
  7440. }
  7441. } else if (i > e2) {
  7442. while (i <= e1) {
  7443. unmount(c1[i], parentComponent, parentSuspense, true);
  7444. i++;
  7445. }
  7446. } else {
  7447. const s1 = i;
  7448. const s2 = i;
  7449. const keyToNewIndexMap = /* @__PURE__ */ new Map();
  7450. for (i = s2; i <= e2; i++) {
  7451. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7452. if (nextChild.key != null) {
  7453. if (keyToNewIndexMap.has(nextChild.key)) {
  7454. warn(
  7455. `Duplicate keys found during update:`,
  7456. JSON.stringify(nextChild.key),
  7457. `Make sure keys are unique.`
  7458. );
  7459. }
  7460. keyToNewIndexMap.set(nextChild.key, i);
  7461. }
  7462. }
  7463. let j;
  7464. let patched = 0;
  7465. const toBePatched = e2 - s2 + 1;
  7466. let moved = false;
  7467. let maxNewIndexSoFar = 0;
  7468. const newIndexToOldIndexMap = new Array(toBePatched);
  7469. for (i = 0; i < toBePatched; i++)
  7470. newIndexToOldIndexMap[i] = 0;
  7471. for (i = s1; i <= e1; i++) {
  7472. const prevChild = c1[i];
  7473. if (patched >= toBePatched) {
  7474. unmount(prevChild, parentComponent, parentSuspense, true);
  7475. continue;
  7476. }
  7477. let newIndex;
  7478. if (prevChild.key != null) {
  7479. newIndex = keyToNewIndexMap.get(prevChild.key);
  7480. } else {
  7481. for (j = s2; j <= e2; j++) {
  7482. if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
  7483. newIndex = j;
  7484. break;
  7485. }
  7486. }
  7487. }
  7488. if (newIndex === void 0) {
  7489. unmount(prevChild, parentComponent, parentSuspense, true);
  7490. } else {
  7491. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  7492. if (newIndex >= maxNewIndexSoFar) {
  7493. maxNewIndexSoFar = newIndex;
  7494. } else {
  7495. moved = true;
  7496. }
  7497. patch(
  7498. prevChild,
  7499. c2[newIndex],
  7500. container,
  7501. null,
  7502. parentComponent,
  7503. parentSuspense,
  7504. isSVG,
  7505. slotScopeIds,
  7506. optimized
  7507. );
  7508. patched++;
  7509. }
  7510. }
  7511. const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
  7512. j = increasingNewIndexSequence.length - 1;
  7513. for (i = toBePatched - 1; i >= 0; i--) {
  7514. const nextIndex = s2 + i;
  7515. const nextChild = c2[nextIndex];
  7516. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  7517. if (newIndexToOldIndexMap[i] === 0) {
  7518. patch(
  7519. null,
  7520. nextChild,
  7521. container,
  7522. anchor,
  7523. parentComponent,
  7524. parentSuspense,
  7525. isSVG,
  7526. slotScopeIds,
  7527. optimized
  7528. );
  7529. } else if (moved) {
  7530. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  7531. move(nextChild, container, anchor, 2);
  7532. } else {
  7533. j--;
  7534. }
  7535. }
  7536. }
  7537. }
  7538. };
  7539. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7540. const { el, type, transition, children, shapeFlag } = vnode;
  7541. if (shapeFlag & 6) {
  7542. move(vnode.component.subTree, container, anchor, moveType);
  7543. return;
  7544. }
  7545. if (shapeFlag & 128) {
  7546. vnode.suspense.move(container, anchor, moveType);
  7547. return;
  7548. }
  7549. if (shapeFlag & 64) {
  7550. type.move(vnode, container, anchor, internals);
  7551. return;
  7552. }
  7553. if (type === Fragment) {
  7554. hostInsert(el, container, anchor);
  7555. for (let i = 0; i < children.length; i++) {
  7556. move(children[i], container, anchor, moveType);
  7557. }
  7558. hostInsert(vnode.anchor, container, anchor);
  7559. return;
  7560. }
  7561. if (type === Static) {
  7562. moveStaticNode(vnode, container, anchor);
  7563. return;
  7564. }
  7565. const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
  7566. if (needTransition) {
  7567. if (moveType === 0) {
  7568. transition.beforeEnter(el);
  7569. hostInsert(el, container, anchor);
  7570. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  7571. } else {
  7572. const { leave, delayLeave, afterLeave } = transition;
  7573. const remove2 = () => hostInsert(el, container, anchor);
  7574. const performLeave = () => {
  7575. leave(el, () => {
  7576. remove2();
  7577. afterLeave && afterLeave();
  7578. });
  7579. };
  7580. if (delayLeave) {
  7581. delayLeave(el, remove2, performLeave);
  7582. } else {
  7583. performLeave();
  7584. }
  7585. }
  7586. } else {
  7587. hostInsert(el, container, anchor);
  7588. }
  7589. };
  7590. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7591. const {
  7592. type,
  7593. props,
  7594. ref,
  7595. children,
  7596. dynamicChildren,
  7597. shapeFlag,
  7598. patchFlag,
  7599. dirs
  7600. } = vnode;
  7601. if (ref != null) {
  7602. setRef(ref, null, parentSuspense, vnode, true);
  7603. }
  7604. if (shapeFlag & 256) {
  7605. parentComponent.ctx.deactivate(vnode);
  7606. return;
  7607. }
  7608. const shouldInvokeDirs = shapeFlag & 1 && dirs;
  7609. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  7610. let vnodeHook;
  7611. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  7612. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7613. }
  7614. if (shapeFlag & 6) {
  7615. unmountComponent(vnode.component, parentSuspense, doRemove);
  7616. } else {
  7617. if (shapeFlag & 128) {
  7618. vnode.suspense.unmount(parentSuspense, doRemove);
  7619. return;
  7620. }
  7621. if (shouldInvokeDirs) {
  7622. invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
  7623. }
  7624. if (shapeFlag & 64) {
  7625. vnode.type.remove(
  7626. vnode,
  7627. parentComponent,
  7628. parentSuspense,
  7629. optimized,
  7630. internals,
  7631. doRemove
  7632. );
  7633. } else if (dynamicChildren && // #1153: fast path should not be taken for non-stable (v-for) fragments
  7634. (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
  7635. unmountChildren(
  7636. dynamicChildren,
  7637. parentComponent,
  7638. parentSuspense,
  7639. false,
  7640. true
  7641. );
  7642. } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
  7643. unmountChildren(children, parentComponent, parentSuspense);
  7644. }
  7645. if (doRemove) {
  7646. remove(vnode);
  7647. }
  7648. }
  7649. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  7650. queuePostRenderEffect(() => {
  7651. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7652. shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
  7653. }, parentSuspense);
  7654. }
  7655. };
  7656. const remove = (vnode) => {
  7657. const { type, el, anchor, transition } = vnode;
  7658. if (type === Fragment) {
  7659. if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
  7660. vnode.children.forEach((child) => {
  7661. if (child.type === Comment) {
  7662. hostRemove(child.el);
  7663. } else {
  7664. remove(child);
  7665. }
  7666. });
  7667. } else {
  7668. removeFragment(el, anchor);
  7669. }
  7670. return;
  7671. }
  7672. if (type === Static) {
  7673. removeStaticNode(vnode);
  7674. return;
  7675. }
  7676. const performRemove = () => {
  7677. hostRemove(el);
  7678. if (transition && !transition.persisted && transition.afterLeave) {
  7679. transition.afterLeave();
  7680. }
  7681. };
  7682. if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
  7683. const { leave, delayLeave } = transition;
  7684. const performLeave = () => leave(el, performRemove);
  7685. if (delayLeave) {
  7686. delayLeave(vnode.el, performRemove, performLeave);
  7687. } else {
  7688. performLeave();
  7689. }
  7690. } else {
  7691. performRemove();
  7692. }
  7693. };
  7694. const removeFragment = (cur, end) => {
  7695. let next;
  7696. while (cur !== end) {
  7697. next = hostNextSibling(cur);
  7698. hostRemove(cur);
  7699. cur = next;
  7700. }
  7701. hostRemove(end);
  7702. };
  7703. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7704. if (instance.type.__hmrId) {
  7705. unregisterHMR(instance);
  7706. }
  7707. const { bum, scope, update, subTree, um } = instance;
  7708. if (bum) {
  7709. invokeArrayFns(bum);
  7710. }
  7711. scope.stop();
  7712. if (update) {
  7713. update.active = false;
  7714. unmount(subTree, instance, parentSuspense, doRemove);
  7715. }
  7716. if (um) {
  7717. queuePostRenderEffect(um, parentSuspense);
  7718. }
  7719. queuePostRenderEffect(() => {
  7720. instance.isUnmounted = true;
  7721. }, parentSuspense);
  7722. if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
  7723. parentSuspense.deps--;
  7724. if (parentSuspense.deps === 0) {
  7725. parentSuspense.resolve();
  7726. }
  7727. }
  7728. {
  7729. devtoolsComponentRemoved(instance);
  7730. }
  7731. };
  7732. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7733. for (let i = start; i < children.length; i++) {
  7734. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7735. }
  7736. };
  7737. const getNextHostNode = (vnode) => {
  7738. if (vnode.shapeFlag & 6) {
  7739. return getNextHostNode(vnode.component.subTree);
  7740. }
  7741. if (vnode.shapeFlag & 128) {
  7742. return vnode.suspense.next();
  7743. }
  7744. return hostNextSibling(vnode.anchor || vnode.el);
  7745. };
  7746. const render = (vnode, container, isSVG) => {
  7747. if (vnode == null) {
  7748. if (container._vnode) {
  7749. unmount(container._vnode, null, null, true);
  7750. }
  7751. } else {
  7752. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7753. }
  7754. flushPreFlushCbs();
  7755. flushPostFlushCbs();
  7756. container._vnode = vnode;
  7757. };
  7758. const internals = {
  7759. p: patch,
  7760. um: unmount,
  7761. m: move,
  7762. r: remove,
  7763. mt: mountComponent,
  7764. mc: mountChildren,
  7765. pc: patchChildren,
  7766. pbc: patchBlockChildren,
  7767. n: getNextHostNode,
  7768. o: options
  7769. };
  7770. let hydrate;
  7771. let hydrateNode;
  7772. if (createHydrationFns) {
  7773. [hydrate, hydrateNode] = createHydrationFns(
  7774. internals
  7775. );
  7776. }
  7777. return {
  7778. render,
  7779. hydrate,
  7780. createApp: createAppAPI(render, hydrate)
  7781. };
  7782. }
  7783. function toggleRecurse({ effect, update }, allowed) {
  7784. effect.allowRecurse = update.allowRecurse = allowed;
  7785. }
  7786. function traverseStaticChildren(n1, n2, shallow = false) {
  7787. const ch1 = n1.children;
  7788. const ch2 = n2.children;
  7789. if (isArray(ch1) && isArray(ch2)) {
  7790. for (let i = 0; i < ch1.length; i++) {
  7791. const c1 = ch1[i];
  7792. let c2 = ch2[i];
  7793. if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
  7794. if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
  7795. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7796. c2.el = c1.el;
  7797. }
  7798. if (!shallow)
  7799. traverseStaticChildren(c1, c2);
  7800. }
  7801. if (c2.type === Text) {
  7802. c2.el = c1.el;
  7803. }
  7804. if (c2.type === Comment && !c2.el) {
  7805. c2.el = c1.el;
  7806. }
  7807. }
  7808. }
  7809. }
  7810. function getSequence(arr) {
  7811. const p = arr.slice();
  7812. const result = [0];
  7813. let i, j, u, v, c;
  7814. const len = arr.length;
  7815. for (i = 0; i < len; i++) {
  7816. const arrI = arr[i];
  7817. if (arrI !== 0) {
  7818. j = result[result.length - 1];
  7819. if (arr[j] < arrI) {
  7820. p[i] = j;
  7821. result.push(i);
  7822. continue;
  7823. }
  7824. u = 0;
  7825. v = result.length - 1;
  7826. while (u < v) {
  7827. c = u + v >> 1;
  7828. if (arr[result[c]] < arrI) {
  7829. u = c + 1;
  7830. } else {
  7831. v = c;
  7832. }
  7833. }
  7834. if (arrI < arr[result[u]]) {
  7835. if (u > 0) {
  7836. p[i] = result[u - 1];
  7837. }
  7838. result[u] = i;
  7839. }
  7840. }
  7841. }
  7842. u = result.length;
  7843. v = result[u - 1];
  7844. while (u-- > 0) {
  7845. result[u] = v;
  7846. v = p[v];
  7847. }
  7848. return result;
  7849. }
  7850.  
  7851. const isTeleport = (type) => type.__isTeleport;
  7852. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
  7853. const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
  7854. const resolveTarget = (props, select) => {
  7855. const targetSelector = props && props.to;
  7856. if (isString(targetSelector)) {
  7857. if (!select) {
  7858. warn(
  7859. `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
  7860. );
  7861. return null;
  7862. } else {
  7863. const target = select(targetSelector);
  7864. if (!target) {
  7865. warn(
  7866. `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`
  7867. );
  7868. }
  7869. return target;
  7870. }
  7871. } else {
  7872. if (!targetSelector && !isTeleportDisabled(props)) {
  7873. warn(`Invalid Teleport target: ${targetSelector}`);
  7874. }
  7875. return targetSelector;
  7876. }
  7877. };
  7878. const TeleportImpl = {
  7879. __isTeleport: true,
  7880. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7881. const {
  7882. mc: mountChildren,
  7883. pc: patchChildren,
  7884. pbc: patchBlockChildren,
  7885. o: { insert, querySelector, createText, createComment }
  7886. } = internals;
  7887. const disabled = isTeleportDisabled(n2.props);
  7888. let { shapeFlag, children, dynamicChildren } = n2;
  7889. if (isHmrUpdating) {
  7890. optimized = false;
  7891. dynamicChildren = null;
  7892. }
  7893. if (n1 == null) {
  7894. const placeholder = n2.el = createComment("teleport start") ;
  7895. const mainAnchor = n2.anchor = createComment("teleport end") ;
  7896. insert(placeholder, container, anchor);
  7897. insert(mainAnchor, container, anchor);
  7898. const target = n2.target = resolveTarget(n2.props, querySelector);
  7899. const targetAnchor = n2.targetAnchor = createText("");
  7900. if (target) {
  7901. insert(targetAnchor, target);
  7902. isSVG = isSVG || isTargetSVG(target);
  7903. } else if (!disabled) {
  7904. warn("Invalid Teleport target on mount:", target, `(${typeof target})`);
  7905. }
  7906. const mount = (container2, anchor2) => {
  7907. if (shapeFlag & 16) {
  7908. mountChildren(
  7909. children,
  7910. container2,
  7911. anchor2,
  7912. parentComponent,
  7913. parentSuspense,
  7914. isSVG,
  7915. slotScopeIds,
  7916. optimized
  7917. );
  7918. }
  7919. };
  7920. if (disabled) {
  7921. mount(container, mainAnchor);
  7922. } else if (target) {
  7923. mount(target, targetAnchor);
  7924. }
  7925. } else {
  7926. n2.el = n1.el;
  7927. const mainAnchor = n2.anchor = n1.anchor;
  7928. const target = n2.target = n1.target;
  7929. const targetAnchor = n2.targetAnchor = n1.targetAnchor;
  7930. const wasDisabled = isTeleportDisabled(n1.props);
  7931. const currentContainer = wasDisabled ? container : target;
  7932. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7933. isSVG = isSVG || isTargetSVG(target);
  7934. if (dynamicChildren) {
  7935. patchBlockChildren(
  7936. n1.dynamicChildren,
  7937. dynamicChildren,
  7938. currentContainer,
  7939. parentComponent,
  7940. parentSuspense,
  7941. isSVG,
  7942. slotScopeIds
  7943. );
  7944. traverseStaticChildren(n1, n2, true);
  7945. } else if (!optimized) {
  7946. patchChildren(
  7947. n1,
  7948. n2,
  7949. currentContainer,
  7950. currentAnchor,
  7951. parentComponent,
  7952. parentSuspense,
  7953. isSVG,
  7954. slotScopeIds,
  7955. false
  7956. );
  7957. }
  7958. if (disabled) {
  7959. if (!wasDisabled) {
  7960. moveTeleport(
  7961. n2,
  7962. container,
  7963. mainAnchor,
  7964. internals,
  7965. 1
  7966. );
  7967. }
  7968. } else {
  7969. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7970. const nextTarget = n2.target = resolveTarget(
  7971. n2.props,
  7972. querySelector
  7973. );
  7974. if (nextTarget) {
  7975. moveTeleport(
  7976. n2,
  7977. nextTarget,
  7978. null,
  7979. internals,
  7980. 0
  7981. );
  7982. } else {
  7983. warn(
  7984. "Invalid Teleport target on update:",
  7985. target,
  7986. `(${typeof target})`
  7987. );
  7988. }
  7989. } else if (wasDisabled) {
  7990. moveTeleport(
  7991. n2,
  7992. target,
  7993. targetAnchor,
  7994. internals,
  7995. 1
  7996. );
  7997. }
  7998. }
  7999. }
  8000. updateCssVars(n2);
  8001. },
  8002. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  8003. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  8004. if (target) {
  8005. hostRemove(targetAnchor);
  8006. }
  8007. if (doRemove || !isTeleportDisabled(props)) {
  8008. hostRemove(anchor);
  8009. if (shapeFlag & 16) {
  8010. for (let i = 0; i < children.length; i++) {
  8011. const child = children[i];
  8012. unmount(
  8013. child,
  8014. parentComponent,
  8015. parentSuspense,
  8016. true,
  8017. !!child.dynamicChildren
  8018. );
  8019. }
  8020. }
  8021. }
  8022. },
  8023. move: moveTeleport,
  8024. hydrate: hydrateTeleport
  8025. };
  8026. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
  8027. if (moveType === 0) {
  8028. insert(vnode.targetAnchor, container, parentAnchor);
  8029. }
  8030. const { el, anchor, shapeFlag, children, props } = vnode;
  8031. const isReorder = moveType === 2;
  8032. if (isReorder) {
  8033. insert(el, container, parentAnchor);
  8034. }
  8035. if (!isReorder || isTeleportDisabled(props)) {
  8036. if (shapeFlag & 16) {
  8037. for (let i = 0; i < children.length; i++) {
  8038. move(
  8039. children[i],
  8040. container,
  8041. parentAnchor,
  8042. 2
  8043. );
  8044. }
  8045. }
  8046. }
  8047. if (isReorder) {
  8048. insert(anchor, container, parentAnchor);
  8049. }
  8050. }
  8051. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
  8052. o: { nextSibling, parentNode, querySelector }
  8053. }, hydrateChildren) {
  8054. const target = vnode.target = resolveTarget(
  8055. vnode.props,
  8056. querySelector
  8057. );
  8058. if (target) {
  8059. const targetNode = target._lpa || target.firstChild;
  8060. if (vnode.shapeFlag & 16) {
  8061. if (isTeleportDisabled(vnode.props)) {
  8062. vnode.anchor = hydrateChildren(
  8063. nextSibling(node),
  8064. vnode,
  8065. parentNode(node),
  8066. parentComponent,
  8067. parentSuspense,
  8068. slotScopeIds,
  8069. optimized
  8070. );
  8071. vnode.targetAnchor = targetNode;
  8072. } else {
  8073. vnode.anchor = nextSibling(node);
  8074. let targetAnchor = targetNode;
  8075. while (targetAnchor) {
  8076. targetAnchor = nextSibling(targetAnchor);
  8077. if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
  8078. vnode.targetAnchor = targetAnchor;
  8079. target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  8080. break;
  8081. }
  8082. }
  8083. hydrateChildren(
  8084. targetNode,
  8085. vnode,
  8086. target,
  8087. parentComponent,
  8088. parentSuspense,
  8089. slotScopeIds,
  8090. optimized
  8091. );
  8092. }
  8093. }
  8094. updateCssVars(vnode);
  8095. }
  8096. return vnode.anchor && nextSibling(vnode.anchor);
  8097. }
  8098. const Teleport = TeleportImpl;
  8099. function updateCssVars(vnode) {
  8100. const ctx = vnode.ctx;
  8101. if (ctx && ctx.ut) {
  8102. let node = vnode.children[0].el;
  8103. while (node !== vnode.targetAnchor) {
  8104. if (node.nodeType === 1)
  8105. node.setAttribute("data-v-owner", ctx.uid);
  8106. node = node.nextSibling;
  8107. }
  8108. ctx.ut();
  8109. }
  8110. }
  8111.  
  8112. const Fragment = Symbol.for("v-fgt");
  8113. const Text = Symbol.for("v-txt");
  8114. const Comment = Symbol.for("v-cmt");
  8115. const Static = Symbol.for("v-stc");
  8116. const blockStack = [];
  8117. let currentBlock = null;
  8118. function openBlock(disableTracking = false) {
  8119. blockStack.push(currentBlock = disableTracking ? null : []);
  8120. }
  8121. function closeBlock() {
  8122. blockStack.pop();
  8123. currentBlock = blockStack[blockStack.length - 1] || null;
  8124. }
  8125. let isBlockTreeEnabled = 1;
  8126. function setBlockTracking(value) {
  8127. isBlockTreeEnabled += value;
  8128. }
  8129. function setupBlock(vnode) {
  8130. vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  8131. closeBlock();
  8132. if (isBlockTreeEnabled > 0 && currentBlock) {
  8133. currentBlock.push(vnode);
  8134. }
  8135. return vnode;
  8136. }
  8137. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  8138. return setupBlock(
  8139. createBaseVNode(
  8140. type,
  8141. props,
  8142. children,
  8143. patchFlag,
  8144. dynamicProps,
  8145. shapeFlag,
  8146. true
  8147. /* isBlock */
  8148. )
  8149. );
  8150. }
  8151. function createBlock(type, props, children, patchFlag, dynamicProps) {
  8152. return setupBlock(
  8153. createVNode(
  8154. type,
  8155. props,
  8156. children,
  8157. patchFlag,
  8158. dynamicProps,
  8159. true
  8160. /* isBlock: prevent a block from tracking itself */
  8161. )
  8162. );
  8163. }
  8164. function isVNode(value) {
  8165. return value ? value.__v_isVNode === true : false;
  8166. }
  8167. function isSameVNodeType(n1, n2) {
  8168. if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
  8169. n1.shapeFlag &= ~256;
  8170. n2.shapeFlag &= ~512;
  8171. return false;
  8172. }
  8173. return n1.type === n2.type && n1.key === n2.key;
  8174. }
  8175. let vnodeArgsTransformer;
  8176. function transformVNodeArgs(transformer) {
  8177. vnodeArgsTransformer = transformer;
  8178. }
  8179. const createVNodeWithArgsTransform = (...args) => {
  8180. return _createVNode(
  8181. ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
  8182. );
  8183. };
  8184. const InternalObjectKey = `__vInternal`;
  8185. const normalizeKey = ({ key }) => key != null ? key : null;
  8186. const normalizeRef = ({
  8187. ref,
  8188. ref_key,
  8189. ref_for
  8190. }) => {
  8191. if (typeof ref === "number") {
  8192. ref = "" + ref;
  8193. }
  8194. return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
  8195. };
  8196. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
  8197. const vnode = {
  8198. __v_isVNode: true,
  8199. __v_skip: true,
  8200. type,
  8201. props,
  8202. key: props && normalizeKey(props),
  8203. ref: props && normalizeRef(props),
  8204. scopeId: currentScopeId,
  8205. slotScopeIds: null,
  8206. children,
  8207. component: null,
  8208. suspense: null,
  8209. ssContent: null,
  8210. ssFallback: null,
  8211. dirs: null,
  8212. transition: null,
  8213. el: null,
  8214. anchor: null,
  8215. target: null,
  8216. targetAnchor: null,
  8217. staticCount: 0,
  8218. shapeFlag,
  8219. patchFlag,
  8220. dynamicProps,
  8221. dynamicChildren: null,
  8222. appContext: null,
  8223. ctx: currentRenderingInstance
  8224. };
  8225. if (needFullChildrenNormalization) {
  8226. normalizeChildren(vnode, children);
  8227. if (shapeFlag & 128) {
  8228. type.normalize(vnode);
  8229. }
  8230. } else if (children) {
  8231. vnode.shapeFlag |= isString(children) ? 8 : 16;
  8232. }
  8233. if (vnode.key !== vnode.key) {
  8234. warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  8235. }
  8236. if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
  8237. !isBlockNode && // has current parent block
  8238. currentBlock && // presence of a patch flag indicates this node needs patching on updates.
  8239. // component nodes also should always be patched, because even if the
  8240. // component doesn't need to update, it needs to persist the instance on to
  8241. // the next vnode so that it can be properly unmounted later.
  8242. (vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
  8243. // vnode should not be considered dynamic due to handler caching.
  8244. vnode.patchFlag !== 32) {
  8245. currentBlock.push(vnode);
  8246. }
  8247. return vnode;
  8248. }
  8249. const createVNode = createVNodeWithArgsTransform ;
  8250. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8251. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8252. if (!type) {
  8253. warn(`Invalid vnode type when creating vnode: ${type}.`);
  8254. }
  8255. type = Comment;
  8256. }
  8257. if (isVNode(type)) {
  8258. const cloned = cloneVNode(
  8259. type,
  8260. props,
  8261. true
  8262. /* mergeRef: true */
  8263. );
  8264. if (children) {
  8265. normalizeChildren(cloned, children);
  8266. }
  8267. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8268. if (cloned.shapeFlag & 6) {
  8269. currentBlock[currentBlock.indexOf(type)] = cloned;
  8270. } else {
  8271. currentBlock.push(cloned);
  8272. }
  8273. }
  8274. cloned.patchFlag |= -2;
  8275. return cloned;
  8276. }
  8277. if (isClassComponent(type)) {
  8278. type = type.__vccOpts;
  8279. }
  8280. if (props) {
  8281. props = guardReactiveProps(props);
  8282. let { class: klass, style } = props;
  8283. if (klass && !isString(klass)) {
  8284. props.class = normalizeClass(klass);
  8285. }
  8286. if (isObject(style)) {
  8287. if (isProxy(style) && !isArray(style)) {
  8288. style = extend({}, style);
  8289. }
  8290. props.style = normalizeStyle(style);
  8291. }
  8292. }
  8293. const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
  8294. if (shapeFlag & 4 && isProxy(type)) {
  8295. type = toRaw(type);
  8296. warn(
  8297. `Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
  8298. `
  8299. Component that was made reactive: `,
  8300. type
  8301. );
  8302. }
  8303. return createBaseVNode(
  8304. type,
  8305. props,
  8306. children,
  8307. patchFlag,
  8308. dynamicProps,
  8309. shapeFlag,
  8310. isBlockNode,
  8311. true
  8312. );
  8313. }
  8314. function guardReactiveProps(props) {
  8315. if (!props)
  8316. return null;
  8317. return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
  8318. }
  8319. function cloneVNode(vnode, extraProps, mergeRef = false) {
  8320. const { props, ref, patchFlag, children } = vnode;
  8321. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  8322. const cloned = {
  8323. __v_isVNode: true,
  8324. __v_skip: true,
  8325. type: vnode.type,
  8326. props: mergedProps,
  8327. key: mergedProps && normalizeKey(mergedProps),
  8328. ref: extraProps && extraProps.ref ? (
  8329. // #2078 in the case of <component :is="vnode" ref="extra"/>
  8330. // if the vnode itself already has a ref, cloneVNode will need to merge
  8331. // the refs so the single vnode can be set on multiple refs
  8332. mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
  8333. ) : ref,
  8334. scopeId: vnode.scopeId,
  8335. slotScopeIds: vnode.slotScopeIds,
  8336. children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
  8337. target: vnode.target,
  8338. targetAnchor: vnode.targetAnchor,
  8339. staticCount: vnode.staticCount,
  8340. shapeFlag: vnode.shapeFlag,
  8341. // if the vnode is cloned with extra props, we can no longer assume its
  8342. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8343. // note: preserve flag for fragments since they use the flag for children
  8344. // fast paths only.
  8345. patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
  8346. dynamicProps: vnode.dynamicProps,
  8347. dynamicChildren: vnode.dynamicChildren,
  8348. appContext: vnode.appContext,
  8349. dirs: vnode.dirs,
  8350. transition: vnode.transition,
  8351. // These should technically only be non-null on mounted VNodes. However,
  8352. // they *should* be copied for kept-alive vnodes. So we just always copy
  8353. // them since them being non-null during a mount doesn't affect the logic as
  8354. // they will simply be overwritten.
  8355. component: vnode.component,
  8356. suspense: vnode.suspense,
  8357. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8358. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8359. el: vnode.el,
  8360. anchor: vnode.anchor,
  8361. ctx: vnode.ctx,
  8362. ce: vnode.ce
  8363. };
  8364. return cloned;
  8365. }
  8366. function deepCloneVNode(vnode) {
  8367. const cloned = cloneVNode(vnode);
  8368. if (isArray(vnode.children)) {
  8369. cloned.children = vnode.children.map(deepCloneVNode);
  8370. }
  8371. return cloned;
  8372. }
  8373. function createTextVNode(text = " ", flag = 0) {
  8374. return createVNode(Text, null, text, flag);
  8375. }
  8376. function createStaticVNode(content, numberOfNodes) {
  8377. const vnode = createVNode(Static, null, content);
  8378. vnode.staticCount = numberOfNodes;
  8379. return vnode;
  8380. }
  8381. function createCommentVNode(text = "", asBlock = false) {
  8382. return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
  8383. }
  8384. function normalizeVNode(child) {
  8385. if (child == null || typeof child === "boolean") {
  8386. return createVNode(Comment);
  8387. } else if (isArray(child)) {
  8388. return createVNode(
  8389. Fragment,
  8390. null,
  8391. // #3666, avoid reference pollution when reusing vnode
  8392. child.slice()
  8393. );
  8394. } else if (typeof child === "object") {
  8395. return cloneIfMounted(child);
  8396. } else {
  8397. return createVNode(Text, null, String(child));
  8398. }
  8399. }
  8400. function cloneIfMounted(child) {
  8401. return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
  8402. }
  8403. function normalizeChildren(vnode, children) {
  8404. let type = 0;
  8405. const { shapeFlag } = vnode;
  8406. if (children == null) {
  8407. children = null;
  8408. } else if (isArray(children)) {
  8409. type = 16;
  8410. } else if (typeof children === "object") {
  8411. if (shapeFlag & (1 | 64)) {
  8412. const slot = children.default;
  8413. if (slot) {
  8414. slot._c && (slot._d = false);
  8415. normalizeChildren(vnode, slot());
  8416. slot._c && (slot._d = true);
  8417. }
  8418. return;
  8419. } else {
  8420. type = 32;
  8421. const slotFlag = children._;
  8422. if (!slotFlag && !(InternalObjectKey in children)) {
  8423. children._ctx = currentRenderingInstance;
  8424. } else if (slotFlag === 3 && currentRenderingInstance) {
  8425. if (currentRenderingInstance.slots._ === 1) {
  8426. children._ = 1;
  8427. } else {
  8428. children._ = 2;
  8429. vnode.patchFlag |= 1024;
  8430. }
  8431. }
  8432. }
  8433. } else if (isFunction(children)) {
  8434. children = { default: children, _ctx: currentRenderingInstance };
  8435. type = 32;
  8436. } else {
  8437. children = String(children);
  8438. if (shapeFlag & 64) {
  8439. type = 16;
  8440. children = [createTextVNode(children)];
  8441. } else {
  8442. type = 8;
  8443. }
  8444. }
  8445. vnode.children = children;
  8446. vnode.shapeFlag |= type;
  8447. }
  8448. function mergeProps(...args) {
  8449. const ret = {};
  8450. for (let i = 0; i < args.length; i++) {
  8451. const toMerge = args[i];
  8452. for (const key in toMerge) {
  8453. if (key === "class") {
  8454. if (ret.class !== toMerge.class) {
  8455. ret.class = normalizeClass([ret.class, toMerge.class]);
  8456. }
  8457. } else if (key === "style") {
  8458. ret.style = normalizeStyle([ret.style, toMerge.style]);
  8459. } else if (isOn(key)) {
  8460. const existing = ret[key];
  8461. const incoming = toMerge[key];
  8462. if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
  8463. ret[key] = existing ? [].concat(existing, incoming) : incoming;
  8464. }
  8465. } else if (key !== "") {
  8466. ret[key] = toMerge[key];
  8467. }
  8468. }
  8469. }
  8470. return ret;
  8471. }
  8472. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8473. callWithAsyncErrorHandling(hook, instance, 7, [
  8474. vnode,
  8475. prevVNode
  8476. ]);
  8477. }
  8478.  
  8479. const emptyAppContext = createAppContext();
  8480. let uid = 0;
  8481. function createComponentInstance(vnode, parent, suspense) {
  8482. const type = vnode.type;
  8483. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8484. const instance = {
  8485. uid: uid++,
  8486. vnode,
  8487. type,
  8488. parent,
  8489. appContext,
  8490. root: null,
  8491. // to be immediately set
  8492. next: null,
  8493. subTree: null,
  8494. // will be set synchronously right after creation
  8495. effect: null,
  8496. update: null,
  8497. // will be set synchronously right after creation
  8498. scope: new EffectScope(
  8499. true
  8500. /* detached */
  8501. ),
  8502. render: null,
  8503. proxy: null,
  8504. exposed: null,
  8505. exposeProxy: null,
  8506. withProxy: null,
  8507. provides: parent ? parent.provides : Object.create(appContext.provides),
  8508. accessCache: null,
  8509. renderCache: [],
  8510. // local resolved assets
  8511. components: null,
  8512. directives: null,
  8513. // resolved props and emits options
  8514. propsOptions: normalizePropsOptions(type, appContext),
  8515. emitsOptions: normalizeEmitsOptions(type, appContext),
  8516. // emit
  8517. emit: null,
  8518. // to be set immediately
  8519. emitted: null,
  8520. // props default value
  8521. propsDefaults: EMPTY_OBJ,
  8522. // inheritAttrs
  8523. inheritAttrs: type.inheritAttrs,
  8524. // state
  8525. ctx: EMPTY_OBJ,
  8526. data: EMPTY_OBJ,
  8527. props: EMPTY_OBJ,
  8528. attrs: EMPTY_OBJ,
  8529. slots: EMPTY_OBJ,
  8530. refs: EMPTY_OBJ,
  8531. setupState: EMPTY_OBJ,
  8532. setupContext: null,
  8533. attrsProxy: null,
  8534. slotsProxy: null,
  8535. // suspense related
  8536. suspense,
  8537. suspenseId: suspense ? suspense.pendingId : 0,
  8538. asyncDep: null,
  8539. asyncResolved: false,
  8540. // lifecycle hooks
  8541. // not using enums here because it results in computed properties
  8542. isMounted: false,
  8543. isUnmounted: false,
  8544. isDeactivated: false,
  8545. bc: null,
  8546. c: null,
  8547. bm: null,
  8548. m: null,
  8549. bu: null,
  8550. u: null,
  8551. um: null,
  8552. bum: null,
  8553. da: null,
  8554. a: null,
  8555. rtg: null,
  8556. rtc: null,
  8557. ec: null,
  8558. sp: null
  8559. };
  8560. {
  8561. instance.ctx = createDevRenderContext(instance);
  8562. }
  8563. instance.root = parent ? parent.root : instance;
  8564. instance.emit = emit.bind(null, instance);
  8565. if (vnode.ce) {
  8566. vnode.ce(instance);
  8567. }
  8568. return instance;
  8569. }
  8570. let currentInstance = null;
  8571. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8572. let internalSetCurrentInstance;
  8573. {
  8574. internalSetCurrentInstance = (i) => {
  8575. currentInstance = i;
  8576. };
  8577. }
  8578. const setCurrentInstance = (instance) => {
  8579. internalSetCurrentInstance(instance);
  8580. instance.scope.on();
  8581. };
  8582. const unsetCurrentInstance = () => {
  8583. currentInstance && currentInstance.scope.off();
  8584. internalSetCurrentInstance(null);
  8585. };
  8586. const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
  8587. function validateComponentName(name, config) {
  8588. const appIsNativeTag = config.isNativeTag || NO;
  8589. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8590. warn(
  8591. "Do not use built-in or reserved HTML elements as component id: " + name
  8592. );
  8593. }
  8594. }
  8595. function isStatefulComponent(instance) {
  8596. return instance.vnode.shapeFlag & 4;
  8597. }
  8598. let isInSSRComponentSetup = false;
  8599. function setupComponent(instance, isSSR = false) {
  8600. isInSSRComponentSetup = isSSR;
  8601. const { props, children } = instance.vnode;
  8602. const isStateful = isStatefulComponent(instance);
  8603. initProps(instance, props, isStateful, isSSR);
  8604. initSlots(instance, children);
  8605. const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
  8606. isInSSRComponentSetup = false;
  8607. return setupResult;
  8608. }
  8609. function setupStatefulComponent(instance, isSSR) {
  8610. var _a;
  8611. const Component = instance.type;
  8612. {
  8613. if (Component.name) {
  8614. validateComponentName(Component.name, instance.appContext.config);
  8615. }
  8616. if (Component.components) {
  8617. const names = Object.keys(Component.components);
  8618. for (let i = 0; i < names.length; i++) {
  8619. validateComponentName(names[i], instance.appContext.config);
  8620. }
  8621. }
  8622. if (Component.directives) {
  8623. const names = Object.keys(Component.directives);
  8624. for (let i = 0; i < names.length; i++) {
  8625. validateDirectiveName(names[i]);
  8626. }
  8627. }
  8628. if (Component.compilerOptions && isRuntimeOnly()) {
  8629. warn(
  8630. `"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`
  8631. );
  8632. }
  8633. }
  8634. instance.accessCache = /* @__PURE__ */ Object.create(null);
  8635. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8636. {
  8637. exposePropsOnRenderContext(instance);
  8638. }
  8639. const { setup } = Component;
  8640. if (setup) {
  8641. const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
  8642. setCurrentInstance(instance);
  8643. pauseTracking();
  8644. const setupResult = callWithErrorHandling(
  8645. setup,
  8646. instance,
  8647. 0,
  8648. [shallowReadonly(instance.props) , setupContext]
  8649. );
  8650. resetTracking();
  8651. unsetCurrentInstance();
  8652. if (isPromise(setupResult)) {
  8653. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8654. if (isSSR) {
  8655. return setupResult.then((resolvedResult) => {
  8656. handleSetupResult(instance, resolvedResult, isSSR);
  8657. }).catch((e) => {
  8658. handleError(e, instance, 0);
  8659. });
  8660. } else {
  8661. instance.asyncDep = setupResult;
  8662. if (!instance.suspense) {
  8663. const name = (_a = Component.name) != null ? _a : "Anonymous";
  8664. warn(
  8665. `Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`
  8666. );
  8667. }
  8668. }
  8669. } else {
  8670. handleSetupResult(instance, setupResult, isSSR);
  8671. }
  8672. } else {
  8673. finishComponentSetup(instance, isSSR);
  8674. }
  8675. }
  8676. function handleSetupResult(instance, setupResult, isSSR) {
  8677. if (isFunction(setupResult)) {
  8678. {
  8679. instance.render = setupResult;
  8680. }
  8681. } else if (isObject(setupResult)) {
  8682. if (isVNode(setupResult)) {
  8683. warn(
  8684. `setup() should not return VNodes directly - return a render function instead.`
  8685. );
  8686. }
  8687. {
  8688. instance.devtoolsRawSetupState = setupResult;
  8689. }
  8690. instance.setupState = proxyRefs(setupResult);
  8691. {
  8692. exposeSetupStateOnRenderContext(instance);
  8693. }
  8694. } else if (setupResult !== void 0) {
  8695. warn(
  8696. `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
  8697. );
  8698. }
  8699. finishComponentSetup(instance, isSSR);
  8700. }
  8701. let compile$1;
  8702. let installWithProxy;
  8703. function registerRuntimeCompiler(_compile) {
  8704. compile$1 = _compile;
  8705. installWithProxy = (i) => {
  8706. if (i.render._rc) {
  8707. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8708. }
  8709. };
  8710. }
  8711. const isRuntimeOnly = () => !compile$1;
  8712. function finishComponentSetup(instance, isSSR, skipOptions) {
  8713. const Component = instance.type;
  8714. if (!instance.render) {
  8715. if (!isSSR && compile$1 && !Component.render) {
  8716. const template = Component.template || resolveMergedOptions(instance).template;
  8717. if (template) {
  8718. {
  8719. startMeasure(instance, `compile`);
  8720. }
  8721. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8722. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8723. const finalCompilerOptions = extend(
  8724. extend(
  8725. {
  8726. isCustomElement,
  8727. delimiters
  8728. },
  8729. compilerOptions
  8730. ),
  8731. componentCompilerOptions
  8732. );
  8733. Component.render = compile$1(template, finalCompilerOptions);
  8734. {
  8735. endMeasure(instance, `compile`);
  8736. }
  8737. }
  8738. }
  8739. instance.render = Component.render || NOOP;
  8740. if (installWithProxy) {
  8741. installWithProxy(instance);
  8742. }
  8743. }
  8744. {
  8745. setCurrentInstance(instance);
  8746. pauseTracking();
  8747. applyOptions(instance);
  8748. resetTracking();
  8749. unsetCurrentInstance();
  8750. }
  8751. if (!Component.render && instance.render === NOOP && !isSSR) {
  8752. if (!compile$1 && Component.template) {
  8753. warn(
  8754. `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.global.js" instead.` )
  8755. /* should not happen */
  8756. );
  8757. } else {
  8758. warn(`Component is missing template or render function.`);
  8759. }
  8760. }
  8761. }
  8762. function getAttrsProxy(instance) {
  8763. return instance.attrsProxy || (instance.attrsProxy = new Proxy(
  8764. instance.attrs,
  8765. {
  8766. get(target, key) {
  8767. markAttrsAccessed();
  8768. track(instance, "get", "$attrs");
  8769. return target[key];
  8770. },
  8771. set() {
  8772. warn(`setupContext.attrs is readonly.`);
  8773. return false;
  8774. },
  8775. deleteProperty() {
  8776. warn(`setupContext.attrs is readonly.`);
  8777. return false;
  8778. }
  8779. }
  8780. ));
  8781. }
  8782. function getSlotsProxy(instance) {
  8783. return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
  8784. get(target, key) {
  8785. track(instance, "get", "$slots");
  8786. return target[key];
  8787. }
  8788. }));
  8789. }
  8790. function createSetupContext(instance) {
  8791. const expose = (exposed) => {
  8792. {
  8793. if (instance.exposed) {
  8794. warn(`expose() should be called only once per setup().`);
  8795. }
  8796. if (exposed != null) {
  8797. let exposedType = typeof exposed;
  8798. if (exposedType === "object") {
  8799. if (isArray(exposed)) {
  8800. exposedType = "array";
  8801. } else if (isRef(exposed)) {
  8802. exposedType = "ref";
  8803. }
  8804. }
  8805. if (exposedType !== "object") {
  8806. warn(
  8807. `expose() should be passed a plain object, received ${exposedType}.`
  8808. );
  8809. }
  8810. }
  8811. }
  8812. instance.exposed = exposed || {};
  8813. };
  8814. {
  8815. return Object.freeze({
  8816. get attrs() {
  8817. return getAttrsProxy(instance);
  8818. },
  8819. get slots() {
  8820. return getSlotsProxy(instance);
  8821. },
  8822. get emit() {
  8823. return (event, ...args) => instance.emit(event, ...args);
  8824. },
  8825. expose
  8826. });
  8827. }
  8828. }
  8829. function getExposeProxy(instance) {
  8830. if (instance.exposed) {
  8831. return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8832. get(target, key) {
  8833. if (key in target) {
  8834. return target[key];
  8835. } else if (key in publicPropertiesMap) {
  8836. return publicPropertiesMap[key](instance);
  8837. }
  8838. },
  8839. has(target, key) {
  8840. return key in target || key in publicPropertiesMap;
  8841. }
  8842. }));
  8843. }
  8844. }
  8845. const classifyRE = /(?:^|[-_])(\w)/g;
  8846. const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
  8847. function getComponentName(Component, includeInferred = true) {
  8848. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
  8849. }
  8850. function formatComponentName(instance, Component, isRoot = false) {
  8851. let name = getComponentName(Component);
  8852. if (!name && Component.__file) {
  8853. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8854. if (match) {
  8855. name = match[1];
  8856. }
  8857. }
  8858. if (!name && instance && instance.parent) {
  8859. const inferFromRegistry = (registry) => {
  8860. for (const key in registry) {
  8861. if (registry[key] === Component) {
  8862. return key;
  8863. }
  8864. }
  8865. };
  8866. name = inferFromRegistry(
  8867. instance.components || instance.parent.type.components
  8868. ) || inferFromRegistry(instance.appContext.components);
  8869. }
  8870. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8871. }
  8872. function isClassComponent(value) {
  8873. return isFunction(value) && "__vccOpts" in value;
  8874. }
  8875.  
  8876. const computed = (getterOrOptions, debugOptions) => {
  8877. return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8878. };
  8879.  
  8880. function h(type, propsOrChildren, children) {
  8881. const l = arguments.length;
  8882. if (l === 2) {
  8883. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8884. if (isVNode(propsOrChildren)) {
  8885. return createVNode(type, null, [propsOrChildren]);
  8886. }
  8887. return createVNode(type, propsOrChildren);
  8888. } else {
  8889. return createVNode(type, null, propsOrChildren);
  8890. }
  8891. } else {
  8892. if (l > 3) {
  8893. children = Array.prototype.slice.call(arguments, 2);
  8894. } else if (l === 3 && isVNode(children)) {
  8895. children = [children];
  8896. }
  8897. return createVNode(type, propsOrChildren, children);
  8898. }
  8899. }
  8900.  
  8901. const ssrContextKey = Symbol.for("v-scx");
  8902. const useSSRContext = () => {
  8903. {
  8904. warn(`useSSRContext() is not supported in the global build.`);
  8905. }
  8906. };
  8907.  
  8908. function initCustomFormatter() {
  8909. if (typeof window === "undefined") {
  8910. return;
  8911. }
  8912. const vueStyle = { style: "color:#3ba776" };
  8913. const numberStyle = { style: "color:#0b1bc9" };
  8914. const stringStyle = { style: "color:#b62e24" };
  8915. const keywordStyle = { style: "color:#9d288c" };
  8916. const formatter = {
  8917. header(obj) {
  8918. if (!isObject(obj)) {
  8919. return null;
  8920. }
  8921. if (obj.__isVue) {
  8922. return ["div", vueStyle, `VueInstance`];
  8923. } else if (isRef(obj)) {
  8924. return [
  8925. "div",
  8926. {},
  8927. ["span", vueStyle, genRefFlag(obj)],
  8928. "<",
  8929. formatValue(obj.value),
  8930. `>`
  8931. ];
  8932. } else if (isReactive(obj)) {
  8933. return [
  8934. "div",
  8935. {},
  8936. ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
  8937. "<",
  8938. formatValue(obj),
  8939. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  8940. ];
  8941. } else if (isReadonly(obj)) {
  8942. return [
  8943. "div",
  8944. {},
  8945. ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
  8946. "<",
  8947. formatValue(obj),
  8948. ">"
  8949. ];
  8950. }
  8951. return null;
  8952. },
  8953. hasBody(obj) {
  8954. return obj && obj.__isVue;
  8955. },
  8956. body(obj) {
  8957. if (obj && obj.__isVue) {
  8958. return [
  8959. "div",
  8960. {},
  8961. ...formatInstance(obj.$)
  8962. ];
  8963. }
  8964. }
  8965. };
  8966. function formatInstance(instance) {
  8967. const blocks = [];
  8968. if (instance.type.props && instance.props) {
  8969. blocks.push(createInstanceBlock("props", toRaw(instance.props)));
  8970. }
  8971. if (instance.setupState !== EMPTY_OBJ) {
  8972. blocks.push(createInstanceBlock("setup", instance.setupState));
  8973. }
  8974. if (instance.data !== EMPTY_OBJ) {
  8975. blocks.push(createInstanceBlock("data", toRaw(instance.data)));
  8976. }
  8977. const computed = extractKeys(instance, "computed");
  8978. if (computed) {
  8979. blocks.push(createInstanceBlock("computed", computed));
  8980. }
  8981. const injected = extractKeys(instance, "inject");
  8982. if (injected) {
  8983. blocks.push(createInstanceBlock("injected", injected));
  8984. }
  8985. blocks.push([
  8986. "div",
  8987. {},
  8988. [
  8989. "span",
  8990. {
  8991. style: keywordStyle.style + ";opacity:0.66"
  8992. },
  8993. "$ (internal): "
  8994. ],
  8995. ["object", { object: instance }]
  8996. ]);
  8997. return blocks;
  8998. }
  8999. function createInstanceBlock(type, target) {
  9000. target = extend({}, target);
  9001. if (!Object.keys(target).length) {
  9002. return ["span", {}];
  9003. }
  9004. return [
  9005. "div",
  9006. { style: "line-height:1.25em;margin-bottom:0.6em" },
  9007. [
  9008. "div",
  9009. {
  9010. style: "color:#476582"
  9011. },
  9012. type
  9013. ],
  9014. [
  9015. "div",
  9016. {
  9017. style: "padding-left:1.25em"
  9018. },
  9019. ...Object.keys(target).map((key) => {
  9020. return [
  9021. "div",
  9022. {},
  9023. ["span", keywordStyle, key + ": "],
  9024. formatValue(target[key], false)
  9025. ];
  9026. })
  9027. ]
  9028. ];
  9029. }
  9030. function formatValue(v, asRaw = true) {
  9031. if (typeof v === "number") {
  9032. return ["span", numberStyle, v];
  9033. } else if (typeof v === "string") {
  9034. return ["span", stringStyle, JSON.stringify(v)];
  9035. } else if (typeof v === "boolean") {
  9036. return ["span", keywordStyle, v];
  9037. } else if (isObject(v)) {
  9038. return ["object", { object: asRaw ? toRaw(v) : v }];
  9039. } else {
  9040. return ["span", stringStyle, String(v)];
  9041. }
  9042. }
  9043. function extractKeys(instance, type) {
  9044. const Comp = instance.type;
  9045. if (isFunction(Comp)) {
  9046. return;
  9047. }
  9048. const extracted = {};
  9049. for (const key in instance.ctx) {
  9050. if (isKeyOfType(Comp, key, type)) {
  9051. extracted[key] = instance.ctx[key];
  9052. }
  9053. }
  9054. return extracted;
  9055. }
  9056. function isKeyOfType(Comp, key, type) {
  9057. const opts = Comp[type];
  9058. if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
  9059. return true;
  9060. }
  9061. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  9062. return true;
  9063. }
  9064. if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
  9065. return true;
  9066. }
  9067. }
  9068. function genRefFlag(v) {
  9069. if (isShallow(v)) {
  9070. return `ShallowRef`;
  9071. }
  9072. if (v.effect) {
  9073. return `ComputedRef`;
  9074. }
  9075. return `Ref`;
  9076. }
  9077. if (window.devtoolsFormatters) {
  9078. window.devtoolsFormatters.push(formatter);
  9079. } else {
  9080. window.devtoolsFormatters = [formatter];
  9081. }
  9082. }
  9083.  
  9084. function withMemo(memo, render, cache, index) {
  9085. const cached = cache[index];
  9086. if (cached && isMemoSame(cached, memo)) {
  9087. return cached;
  9088. }
  9089. const ret = render();
  9090. ret.memo = memo.slice();
  9091. return cache[index] = ret;
  9092. }
  9093. function isMemoSame(cached, memo) {
  9094. const prev = cached.memo;
  9095. if (prev.length != memo.length) {
  9096. return false;
  9097. }
  9098. for (let i = 0; i < prev.length; i++) {
  9099. if (hasChanged(prev[i], memo[i])) {
  9100. return false;
  9101. }
  9102. }
  9103. if (isBlockTreeEnabled > 0 && currentBlock) {
  9104. currentBlock.push(cached);
  9105. }
  9106. return true;
  9107. }
  9108.  
  9109. const version = "3.3.4";
  9110. const ssrUtils = null;
  9111. const resolveFilter = null;
  9112. const compatUtils = null;
  9113.  
  9114. const svgNS = "http://www.w3.org/2000/svg";
  9115. const doc = typeof document !== "undefined" ? document : null;
  9116. const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
  9117. const nodeOps = {
  9118. insert: (child, parent, anchor) => {
  9119. parent.insertBefore(child, anchor || null);
  9120. },
  9121. remove: (child) => {
  9122. const parent = child.parentNode;
  9123. if (parent) {
  9124. parent.removeChild(child);
  9125. }
  9126. },
  9127. createElement: (tag, isSVG, is, props) => {
  9128. const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
  9129. if (tag === "select" && props && props.multiple != null) {
  9130. el.setAttribute("multiple", props.multiple);
  9131. }
  9132. return el;
  9133. },
  9134. createText: (text) => doc.createTextNode(text),
  9135. createComment: (text) => doc.createComment(text),
  9136. setText: (node, text) => {
  9137. node.nodeValue = text;
  9138. },
  9139. setElementText: (el, text) => {
  9140. el.textContent = text;
  9141. },
  9142. parentNode: (node) => node.parentNode,
  9143. nextSibling: (node) => node.nextSibling,
  9144. querySelector: (selector) => doc.querySelector(selector),
  9145. setScopeId(el, id) {
  9146. el.setAttribute(id, "");
  9147. },
  9148. // __UNSAFE__
  9149. // Reason: innerHTML.
  9150. // Static content here can only come from compiled templates.
  9151. // As long as the user only uses trusted templates, this is safe.
  9152. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9153. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9154. if (start && (start === end || start.nextSibling)) {
  9155. while (true) {
  9156. parent.insertBefore(start.cloneNode(true), anchor);
  9157. if (start === end || !(start = start.nextSibling))
  9158. break;
  9159. }
  9160. } else {
  9161. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9162. const template = templateContainer.content;
  9163. if (isSVG) {
  9164. const wrapper = template.firstChild;
  9165. while (wrapper.firstChild) {
  9166. template.appendChild(wrapper.firstChild);
  9167. }
  9168. template.removeChild(wrapper);
  9169. }
  9170. parent.insertBefore(template, anchor);
  9171. }
  9172. return [
  9173. // first
  9174. before ? before.nextSibling : parent.firstChild,
  9175. // last
  9176. anchor ? anchor.previousSibling : parent.lastChild
  9177. ];
  9178. }
  9179. };
  9180.  
  9181. function patchClass(el, value, isSVG) {
  9182. const transitionClasses = el._vtc;
  9183. if (transitionClasses) {
  9184. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  9185. }
  9186. if (value == null) {
  9187. el.removeAttribute("class");
  9188. } else if (isSVG) {
  9189. el.setAttribute("class", value);
  9190. } else {
  9191. el.className = value;
  9192. }
  9193. }
  9194.  
  9195. function patchStyle(el, prev, next) {
  9196. const style = el.style;
  9197. const isCssString = isString(next);
  9198. if (next && !isCssString) {
  9199. if (prev && !isString(prev)) {
  9200. for (const key in prev) {
  9201. if (next[key] == null) {
  9202. setStyle(style, key, "");
  9203. }
  9204. }
  9205. }
  9206. for (const key in next) {
  9207. setStyle(style, key, next[key]);
  9208. }
  9209. } else {
  9210. const currentDisplay = style.display;
  9211. if (isCssString) {
  9212. if (prev !== next) {
  9213. style.cssText = next;
  9214. }
  9215. } else if (prev) {
  9216. el.removeAttribute("style");
  9217. }
  9218. if ("_vod" in el) {
  9219. style.display = currentDisplay;
  9220. }
  9221. }
  9222. }
  9223. const semicolonRE = /[^\\];\s*$/;
  9224. const importantRE = /\s*!important$/;
  9225. function setStyle(style, name, val) {
  9226. if (isArray(val)) {
  9227. val.forEach((v) => setStyle(style, name, v));
  9228. } else {
  9229. if (val == null)
  9230. val = "";
  9231. {
  9232. if (semicolonRE.test(val)) {
  9233. warn(
  9234. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  9235. );
  9236. }
  9237. }
  9238. if (name.startsWith("--")) {
  9239. style.setProperty(name, val);
  9240. } else {
  9241. const prefixed = autoPrefix(style, name);
  9242. if (importantRE.test(val)) {
  9243. style.setProperty(
  9244. hyphenate(prefixed),
  9245. val.replace(importantRE, ""),
  9246. "important"
  9247. );
  9248. } else {
  9249. style[prefixed] = val;
  9250. }
  9251. }
  9252. }
  9253. }
  9254. const prefixes = ["Webkit", "Moz", "ms"];
  9255. const prefixCache = {};
  9256. function autoPrefix(style, rawName) {
  9257. const cached = prefixCache[rawName];
  9258. if (cached) {
  9259. return cached;
  9260. }
  9261. let name = camelize(rawName);
  9262. if (name !== "filter" && name in style) {
  9263. return prefixCache[rawName] = name;
  9264. }
  9265. name = capitalize(name);
  9266. for (let i = 0; i < prefixes.length; i++) {
  9267. const prefixed = prefixes[i] + name;
  9268. if (prefixed in style) {
  9269. return prefixCache[rawName] = prefixed;
  9270. }
  9271. }
  9272. return rawName;
  9273. }
  9274.  
  9275. const xlinkNS = "http://www.w3.org/1999/xlink";
  9276. function patchAttr(el, key, value, isSVG, instance) {
  9277. if (isSVG && key.startsWith("xlink:")) {
  9278. if (value == null) {
  9279. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9280. } else {
  9281. el.setAttributeNS(xlinkNS, key, value);
  9282. }
  9283. } else {
  9284. const isBoolean = isSpecialBooleanAttr(key);
  9285. if (value == null || isBoolean && !includeBooleanAttr(value)) {
  9286. el.removeAttribute(key);
  9287. } else {
  9288. el.setAttribute(key, isBoolean ? "" : value);
  9289. }
  9290. }
  9291. }
  9292.  
  9293. function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9294. if (key === "innerHTML" || key === "textContent") {
  9295. if (prevChildren) {
  9296. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9297. }
  9298. el[key] = value == null ? "" : value;
  9299. return;
  9300. }
  9301. const tag = el.tagName;
  9302. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  9303. !tag.includes("-")) {
  9304. el._value = value;
  9305. const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value;
  9306. const newValue = value == null ? "" : value;
  9307. if (oldValue !== newValue) {
  9308. el.value = newValue;
  9309. }
  9310. if (value == null) {
  9311. el.removeAttribute(key);
  9312. }
  9313. return;
  9314. }
  9315. let needRemove = false;
  9316. if (value === "" || value == null) {
  9317. const type = typeof el[key];
  9318. if (type === "boolean") {
  9319. value = includeBooleanAttr(value);
  9320. } else if (value == null && type === "string") {
  9321. value = "";
  9322. needRemove = true;
  9323. } else if (type === "number") {
  9324. value = 0;
  9325. needRemove = true;
  9326. }
  9327. }
  9328. try {
  9329. el[key] = value;
  9330. } catch (e) {
  9331. if (!needRemove) {
  9332. warn(
  9333. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  9334. e
  9335. );
  9336. }
  9337. }
  9338. needRemove && el.removeAttribute(key);
  9339. }
  9340.  
  9341. function addEventListener(el, event, handler, options) {
  9342. el.addEventListener(event, handler, options);
  9343. }
  9344. function removeEventListener(el, event, handler, options) {
  9345. el.removeEventListener(event, handler, options);
  9346. }
  9347. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9348. const invokers = el._vei || (el._vei = {});
  9349. const existingInvoker = invokers[rawName];
  9350. if (nextValue && existingInvoker) {
  9351. existingInvoker.value = nextValue;
  9352. } else {
  9353. const [name, options] = parseName(rawName);
  9354. if (nextValue) {
  9355. const invoker = invokers[rawName] = createInvoker(nextValue, instance);
  9356. addEventListener(el, name, invoker, options);
  9357. } else if (existingInvoker) {
  9358. removeEventListener(el, name, existingInvoker, options);
  9359. invokers[rawName] = void 0;
  9360. }
  9361. }
  9362. }
  9363. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9364. function parseName(name) {
  9365. let options;
  9366. if (optionsModifierRE.test(name)) {
  9367. options = {};
  9368. let m;
  9369. while (m = name.match(optionsModifierRE)) {
  9370. name = name.slice(0, name.length - m[0].length);
  9371. options[m[0].toLowerCase()] = true;
  9372. }
  9373. }
  9374. const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
  9375. return [event, options];
  9376. }
  9377. let cachedNow = 0;
  9378. const p = /* @__PURE__ */ Promise.resolve();
  9379. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  9380. function createInvoker(initialValue, instance) {
  9381. const invoker = (e) => {
  9382. if (!e._vts) {
  9383. e._vts = Date.now();
  9384. } else if (e._vts <= invoker.attached) {
  9385. return;
  9386. }
  9387. callWithAsyncErrorHandling(
  9388. patchStopImmediatePropagation(e, invoker.value),
  9389. instance,
  9390. 5,
  9391. [e]
  9392. );
  9393. };
  9394. invoker.value = initialValue;
  9395. invoker.attached = getNow();
  9396. return invoker;
  9397. }
  9398. function patchStopImmediatePropagation(e, value) {
  9399. if (isArray(value)) {
  9400. const originalStop = e.stopImmediatePropagation;
  9401. e.stopImmediatePropagation = () => {
  9402. originalStop.call(e);
  9403. e._stopped = true;
  9404. };
  9405. return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2));
  9406. } else {
  9407. return value;
  9408. }
  9409. }
  9410.  
  9411. const nativeOnRE = /^on[a-z]/;
  9412. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9413. if (key === "class") {
  9414. patchClass(el, nextValue, isSVG);
  9415. } else if (key === "style") {
  9416. patchStyle(el, prevValue, nextValue);
  9417. } else if (isOn(key)) {
  9418. if (!isModelListener(key)) {
  9419. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9420. }
  9421. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9422. patchDOMProp(
  9423. el,
  9424. key,
  9425. nextValue,
  9426. prevChildren,
  9427. parentComponent,
  9428. parentSuspense,
  9429. unmountChildren
  9430. );
  9431. } else {
  9432. if (key === "true-value") {
  9433. el._trueValue = nextValue;
  9434. } else if (key === "false-value") {
  9435. el._falseValue = nextValue;
  9436. }
  9437. patchAttr(el, key, nextValue, isSVG);
  9438. }
  9439. };
  9440. function shouldSetAsProp(el, key, value, isSVG) {
  9441. if (isSVG) {
  9442. if (key === "innerHTML" || key === "textContent") {
  9443. return true;
  9444. }
  9445. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9446. return true;
  9447. }
  9448. return false;
  9449. }
  9450. if (key === "spellcheck" || key === "draggable" || key === "translate") {
  9451. return false;
  9452. }
  9453. if (key === "form") {
  9454. return false;
  9455. }
  9456. if (key === "list" && el.tagName === "INPUT") {
  9457. return false;
  9458. }
  9459. if (key === "type" && el.tagName === "TEXTAREA") {
  9460. return false;
  9461. }
  9462. if (nativeOnRE.test(key) && isString(value)) {
  9463. return false;
  9464. }
  9465. return key in el;
  9466. }
  9467.  
  9468. function defineCustomElement(options, hydrate2) {
  9469. const Comp = defineComponent(options);
  9470. class VueCustomElement extends VueElement {
  9471. constructor(initialProps) {
  9472. super(Comp, initialProps, hydrate2);
  9473. }
  9474. }
  9475. VueCustomElement.def = Comp;
  9476. return VueCustomElement;
  9477. }
  9478. const defineSSRCustomElement = (options) => {
  9479. return defineCustomElement(options, hydrate);
  9480. };
  9481. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  9482. };
  9483. class VueElement extends BaseClass {
  9484. constructor(_def, _props = {}, hydrate2) {
  9485. super();
  9486. this._def = _def;
  9487. this._props = _props;
  9488. /**
  9489. * @internal
  9490. */
  9491. this._instance = null;
  9492. this._connected = false;
  9493. this._resolved = false;
  9494. this._numberProps = null;
  9495. if (this.shadowRoot && hydrate2) {
  9496. hydrate2(this._createVNode(), this.shadowRoot);
  9497. } else {
  9498. if (this.shadowRoot) {
  9499. warn(
  9500. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  9501. );
  9502. }
  9503. this.attachShadow({ mode: "open" });
  9504. if (!this._def.__asyncLoader) {
  9505. this._resolveProps(this._def);
  9506. }
  9507. }
  9508. }
  9509. connectedCallback() {
  9510. this._connected = true;
  9511. if (!this._instance) {
  9512. if (this._resolved) {
  9513. this._update();
  9514. } else {
  9515. this._resolveDef();
  9516. }
  9517. }
  9518. }
  9519. disconnectedCallback() {
  9520. this._connected = false;
  9521. nextTick(() => {
  9522. if (!this._connected) {
  9523. render(null, this.shadowRoot);
  9524. this._instance = null;
  9525. }
  9526. });
  9527. }
  9528. /**
  9529. * resolve inner component definition (handle possible async component)
  9530. */
  9531. _resolveDef() {
  9532. this._resolved = true;
  9533. for (let i = 0; i < this.attributes.length; i++) {
  9534. this._setAttr(this.attributes[i].name);
  9535. }
  9536. new MutationObserver((mutations) => {
  9537. for (const m of mutations) {
  9538. this._setAttr(m.attributeName);
  9539. }
  9540. }).observe(this, { attributes: true });
  9541. const resolve = (def, isAsync = false) => {
  9542. const { props, styles } = def;
  9543. let numberProps;
  9544. if (props && !isArray(props)) {
  9545. for (const key in props) {
  9546. const opt = props[key];
  9547. if (opt === Number || opt && opt.type === Number) {
  9548. if (key in this._props) {
  9549. this._props[key] = toNumber(this._props[key]);
  9550. }
  9551. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize(key)] = true;
  9552. }
  9553. }
  9554. }
  9555. this._numberProps = numberProps;
  9556. if (isAsync) {
  9557. this._resolveProps(def);
  9558. }
  9559. this._applyStyles(styles);
  9560. this._update();
  9561. };
  9562. const asyncDef = this._def.__asyncLoader;
  9563. if (asyncDef) {
  9564. asyncDef().then((def) => resolve(def, true));
  9565. } else {
  9566. resolve(this._def);
  9567. }
  9568. }
  9569. _resolveProps(def) {
  9570. const { props } = def;
  9571. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  9572. for (const key of Object.keys(this)) {
  9573. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  9574. this._setProp(key, this[key], true, false);
  9575. }
  9576. }
  9577. for (const key of declaredPropKeys.map(camelize)) {
  9578. Object.defineProperty(this, key, {
  9579. get() {
  9580. return this._getProp(key);
  9581. },
  9582. set(val) {
  9583. this._setProp(key, val);
  9584. }
  9585. });
  9586. }
  9587. }
  9588. _setAttr(key) {
  9589. let value = this.getAttribute(key);
  9590. const camelKey = camelize(key);
  9591. if (this._numberProps && this._numberProps[camelKey]) {
  9592. value = toNumber(value);
  9593. }
  9594. this._setProp(camelKey, value, false);
  9595. }
  9596. /**
  9597. * @internal
  9598. */
  9599. _getProp(key) {
  9600. return this._props[key];
  9601. }
  9602. /**
  9603. * @internal
  9604. */
  9605. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9606. if (val !== this._props[key]) {
  9607. this._props[key] = val;
  9608. if (shouldUpdate && this._instance) {
  9609. this._update();
  9610. }
  9611. if (shouldReflect) {
  9612. if (val === true) {
  9613. this.setAttribute(hyphenate(key), "");
  9614. } else if (typeof val === "string" || typeof val === "number") {
  9615. this.setAttribute(hyphenate(key), val + "");
  9616. } else if (!val) {
  9617. this.removeAttribute(hyphenate(key));
  9618. }
  9619. }
  9620. }
  9621. }
  9622. _update() {
  9623. render(this._createVNode(), this.shadowRoot);
  9624. }
  9625. _createVNode() {
  9626. const vnode = createVNode(this._def, extend({}, this._props));
  9627. if (!this._instance) {
  9628. vnode.ce = (instance) => {
  9629. this._instance = instance;
  9630. instance.isCE = true;
  9631. {
  9632. instance.ceReload = (newStyles) => {
  9633. if (this._styles) {
  9634. this._styles.forEach((s) => this.shadowRoot.removeChild(s));
  9635. this._styles.length = 0;
  9636. }
  9637. this._applyStyles(newStyles);
  9638. this._instance = null;
  9639. this._update();
  9640. };
  9641. }
  9642. const dispatch = (event, args) => {
  9643. this.dispatchEvent(
  9644. new CustomEvent(event, {
  9645. detail: args
  9646. })
  9647. );
  9648. };
  9649. instance.emit = (event, ...args) => {
  9650. dispatch(event, args);
  9651. if (hyphenate(event) !== event) {
  9652. dispatch(hyphenate(event), args);
  9653. }
  9654. };
  9655. let parent = this;
  9656. while (parent = parent && (parent.parentNode || parent.host)) {
  9657. if (parent instanceof VueElement) {
  9658. instance.parent = parent._instance;
  9659. instance.provides = parent._instance.provides;
  9660. break;
  9661. }
  9662. }
  9663. };
  9664. }
  9665. return vnode;
  9666. }
  9667. _applyStyles(styles) {
  9668. if (styles) {
  9669. styles.forEach((css) => {
  9670. const s = document.createElement("style");
  9671. s.textContent = css;
  9672. this.shadowRoot.appendChild(s);
  9673. {
  9674. (this._styles || (this._styles = [])).push(s);
  9675. }
  9676. });
  9677. }
  9678. }
  9679. }
  9680.  
  9681. function useCssModule(name = "$style") {
  9682. {
  9683. {
  9684. warn(`useCssModule() is not supported in the global build.`);
  9685. }
  9686. return EMPTY_OBJ;
  9687. }
  9688. }
  9689.  
  9690. function useCssVars(getter) {
  9691. const instance = getCurrentInstance();
  9692. if (!instance) {
  9693. warn(`useCssVars is called without current active component instance.`);
  9694. return;
  9695. }
  9696. const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
  9697. Array.from(
  9698. document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
  9699. ).forEach((node) => setVarsOnNode(node, vars));
  9700. };
  9701. const setVars = () => {
  9702. const vars = getter(instance.proxy);
  9703. setVarsOnVNode(instance.subTree, vars);
  9704. updateTeleports(vars);
  9705. };
  9706. watchPostEffect(setVars);
  9707. onMounted(() => {
  9708. const ob = new MutationObserver(setVars);
  9709. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9710. onUnmounted(() => ob.disconnect());
  9711. });
  9712. }
  9713. function setVarsOnVNode(vnode, vars) {
  9714. if (vnode.shapeFlag & 128) {
  9715. const suspense = vnode.suspense;
  9716. vnode = suspense.activeBranch;
  9717. if (suspense.pendingBranch && !suspense.isHydrating) {
  9718. suspense.effects.push(() => {
  9719. setVarsOnVNode(suspense.activeBranch, vars);
  9720. });
  9721. }
  9722. }
  9723. while (vnode.component) {
  9724. vnode = vnode.component.subTree;
  9725. }
  9726. if (vnode.shapeFlag & 1 && vnode.el) {
  9727. setVarsOnNode(vnode.el, vars);
  9728. } else if (vnode.type === Fragment) {
  9729. vnode.children.forEach((c) => setVarsOnVNode(c, vars));
  9730. } else if (vnode.type === Static) {
  9731. let { el, anchor } = vnode;
  9732. while (el) {
  9733. setVarsOnNode(el, vars);
  9734. if (el === anchor)
  9735. break;
  9736. el = el.nextSibling;
  9737. }
  9738. }
  9739. }
  9740. function setVarsOnNode(el, vars) {
  9741. if (el.nodeType === 1) {
  9742. const style = el.style;
  9743. for (const key in vars) {
  9744. style.setProperty(`--${key}`, vars[key]);
  9745. }
  9746. }
  9747. }
  9748.  
  9749. const TRANSITION$1 = "transition";
  9750. const ANIMATION = "animation";
  9751. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9752. Transition.displayName = "Transition";
  9753. const DOMTransitionPropsValidators = {
  9754. name: String,
  9755. type: String,
  9756. css: {
  9757. type: Boolean,
  9758. default: true
  9759. },
  9760. duration: [String, Number, Object],
  9761. enterFromClass: String,
  9762. enterActiveClass: String,
  9763. enterToClass: String,
  9764. appearFromClass: String,
  9765. appearActiveClass: String,
  9766. appearToClass: String,
  9767. leaveFromClass: String,
  9768. leaveActiveClass: String,
  9769. leaveToClass: String
  9770. };
  9771. const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
  9772. {},
  9773. BaseTransitionPropsValidators,
  9774. DOMTransitionPropsValidators
  9775. );
  9776. const callHook = (hook, args = []) => {
  9777. if (isArray(hook)) {
  9778. hook.forEach((h2) => h2(...args));
  9779. } else if (hook) {
  9780. hook(...args);
  9781. }
  9782. };
  9783. const hasExplicitCallback = (hook) => {
  9784. return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
  9785. };
  9786. function resolveTransitionProps(rawProps) {
  9787. const baseProps = {};
  9788. for (const key in rawProps) {
  9789. if (!(key in DOMTransitionPropsValidators)) {
  9790. baseProps[key] = rawProps[key];
  9791. }
  9792. }
  9793. if (rawProps.css === false) {
  9794. return baseProps;
  9795. }
  9796. const {
  9797. name = "v",
  9798. type,
  9799. duration,
  9800. enterFromClass = `${name}-enter-from`,
  9801. enterActiveClass = `${name}-enter-active`,
  9802. enterToClass = `${name}-enter-to`,
  9803. appearFromClass = enterFromClass,
  9804. appearActiveClass = enterActiveClass,
  9805. appearToClass = enterToClass,
  9806. leaveFromClass = `${name}-leave-from`,
  9807. leaveActiveClass = `${name}-leave-active`,
  9808. leaveToClass = `${name}-leave-to`
  9809. } = rawProps;
  9810. const durations = normalizeDuration(duration);
  9811. const enterDuration = durations && durations[0];
  9812. const leaveDuration = durations && durations[1];
  9813. const {
  9814. onBeforeEnter,
  9815. onEnter,
  9816. onEnterCancelled,
  9817. onLeave,
  9818. onLeaveCancelled,
  9819. onBeforeAppear = onBeforeEnter,
  9820. onAppear = onEnter,
  9821. onAppearCancelled = onEnterCancelled
  9822. } = baseProps;
  9823. const finishEnter = (el, isAppear, done) => {
  9824. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9825. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  9826. done && done();
  9827. };
  9828. const finishLeave = (el, done) => {
  9829. el._isLeaving = false;
  9830. removeTransitionClass(el, leaveFromClass);
  9831. removeTransitionClass(el, leaveToClass);
  9832. removeTransitionClass(el, leaveActiveClass);
  9833. done && done();
  9834. };
  9835. const makeEnterHook = (isAppear) => {
  9836. return (el, done) => {
  9837. const hook = isAppear ? onAppear : onEnter;
  9838. const resolve = () => finishEnter(el, isAppear, done);
  9839. callHook(hook, [el, resolve]);
  9840. nextFrame(() => {
  9841. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  9842. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9843. if (!hasExplicitCallback(hook)) {
  9844. whenTransitionEnds(el, type, enterDuration, resolve);
  9845. }
  9846. });
  9847. };
  9848. };
  9849. return extend(baseProps, {
  9850. onBeforeEnter(el) {
  9851. callHook(onBeforeEnter, [el]);
  9852. addTransitionClass(el, enterFromClass);
  9853. addTransitionClass(el, enterActiveClass);
  9854. },
  9855. onBeforeAppear(el) {
  9856. callHook(onBeforeAppear, [el]);
  9857. addTransitionClass(el, appearFromClass);
  9858. addTransitionClass(el, appearActiveClass);
  9859. },
  9860. onEnter: makeEnterHook(false),
  9861. onAppear: makeEnterHook(true),
  9862. onLeave(el, done) {
  9863. el._isLeaving = true;
  9864. const resolve = () => finishLeave(el, done);
  9865. addTransitionClass(el, leaveFromClass);
  9866. forceReflow();
  9867. addTransitionClass(el, leaveActiveClass);
  9868. nextFrame(() => {
  9869. if (!el._isLeaving) {
  9870. return;
  9871. }
  9872. removeTransitionClass(el, leaveFromClass);
  9873. addTransitionClass(el, leaveToClass);
  9874. if (!hasExplicitCallback(onLeave)) {
  9875. whenTransitionEnds(el, type, leaveDuration, resolve);
  9876. }
  9877. });
  9878. callHook(onLeave, [el, resolve]);
  9879. },
  9880. onEnterCancelled(el) {
  9881. finishEnter(el, false);
  9882. callHook(onEnterCancelled, [el]);
  9883. },
  9884. onAppearCancelled(el) {
  9885. finishEnter(el, true);
  9886. callHook(onAppearCancelled, [el]);
  9887. },
  9888. onLeaveCancelled(el) {
  9889. finishLeave(el);
  9890. callHook(onLeaveCancelled, [el]);
  9891. }
  9892. });
  9893. }
  9894. function normalizeDuration(duration) {
  9895. if (duration == null) {
  9896. return null;
  9897. } else if (isObject(duration)) {
  9898. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  9899. } else {
  9900. const n = NumberOf(duration);
  9901. return [n, n];
  9902. }
  9903. }
  9904. function NumberOf(val) {
  9905. const res = toNumber(val);
  9906. {
  9907. assertNumber(res, "<transition> explicit duration");
  9908. }
  9909. return res;
  9910. }
  9911. function addTransitionClass(el, cls) {
  9912. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  9913. (el._vtc || (el._vtc = /* @__PURE__ */ new Set())).add(cls);
  9914. }
  9915. function removeTransitionClass(el, cls) {
  9916. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  9917. const { _vtc } = el;
  9918. if (_vtc) {
  9919. _vtc.delete(cls);
  9920. if (!_vtc.size) {
  9921. el._vtc = void 0;
  9922. }
  9923. }
  9924. }
  9925. function nextFrame(cb) {
  9926. requestAnimationFrame(() => {
  9927. requestAnimationFrame(cb);
  9928. });
  9929. }
  9930. let endId = 0;
  9931. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  9932. const id = el._endId = ++endId;
  9933. const resolveIfNotStale = () => {
  9934. if (id === el._endId) {
  9935. resolve();
  9936. }
  9937. };
  9938. if (explicitTimeout) {
  9939. return setTimeout(resolveIfNotStale, explicitTimeout);
  9940. }
  9941. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  9942. if (!type) {
  9943. return resolve();
  9944. }
  9945. const endEvent = type + "end";
  9946. let ended = 0;
  9947. const end = () => {
  9948. el.removeEventListener(endEvent, onEnd);
  9949. resolveIfNotStale();
  9950. };
  9951. const onEnd = (e) => {
  9952. if (e.target === el && ++ended >= propCount) {
  9953. end();
  9954. }
  9955. };
  9956. setTimeout(() => {
  9957. if (ended < propCount) {
  9958. end();
  9959. }
  9960. }, timeout + 1);
  9961. el.addEventListener(endEvent, onEnd);
  9962. }
  9963. function getTransitionInfo(el, expectedType) {
  9964. const styles = window.getComputedStyle(el);
  9965. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  9966. const transitionDelays = getStyleProperties(`${TRANSITION$1}Delay`);
  9967. const transitionDurations = getStyleProperties(`${TRANSITION$1}Duration`);
  9968. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  9969. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  9970. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  9971. const animationTimeout = getTimeout(animationDelays, animationDurations);
  9972. let type = null;
  9973. let timeout = 0;
  9974. let propCount = 0;
  9975. if (expectedType === TRANSITION$1) {
  9976. if (transitionTimeout > 0) {
  9977. type = TRANSITION$1;
  9978. timeout = transitionTimeout;
  9979. propCount = transitionDurations.length;
  9980. }
  9981. } else if (expectedType === ANIMATION) {
  9982. if (animationTimeout > 0) {
  9983. type = ANIMATION;
  9984. timeout = animationTimeout;
  9985. propCount = animationDurations.length;
  9986. }
  9987. } else {
  9988. timeout = Math.max(transitionTimeout, animationTimeout);
  9989. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
  9990. propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
  9991. }
  9992. const hasTransform = type === TRANSITION$1 && /\b(transform|all)(,|$)/.test(
  9993. getStyleProperties(`${TRANSITION$1}Property`).toString()
  9994. );
  9995. return {
  9996. type,
  9997. timeout,
  9998. propCount,
  9999. hasTransform
  10000. };
  10001. }
  10002. function getTimeout(delays, durations) {
  10003. while (delays.length < durations.length) {
  10004. delays = delays.concat(delays);
  10005. }
  10006. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  10007. }
  10008. function toMs(s) {
  10009. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  10010. }
  10011. function forceReflow() {
  10012. return document.body.offsetHeight;
  10013. }
  10014.  
  10015. const positionMap = /* @__PURE__ */ new WeakMap();
  10016. const newPositionMap = /* @__PURE__ */ new WeakMap();
  10017. const TransitionGroupImpl = {
  10018. name: "TransitionGroup",
  10019. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  10020. tag: String,
  10021. moveClass: String
  10022. }),
  10023. setup(props, { slots }) {
  10024. const instance = getCurrentInstance();
  10025. const state = useTransitionState();
  10026. let prevChildren;
  10027. let children;
  10028. onUpdated(() => {
  10029. if (!prevChildren.length) {
  10030. return;
  10031. }
  10032. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  10033. if (!hasCSSTransform(
  10034. prevChildren[0].el,
  10035. instance.vnode.el,
  10036. moveClass
  10037. )) {
  10038. return;
  10039. }
  10040. prevChildren.forEach(callPendingCbs);
  10041. prevChildren.forEach(recordPosition);
  10042. const movedChildren = prevChildren.filter(applyTranslation);
  10043. forceReflow();
  10044. movedChildren.forEach((c) => {
  10045. const el = c.el;
  10046. const style = el.style;
  10047. addTransitionClass(el, moveClass);
  10048. style.transform = style.webkitTransform = style.transitionDuration = "";
  10049. const cb = el._moveCb = (e) => {
  10050. if (e && e.target !== el) {
  10051. return;
  10052. }
  10053. if (!e || /transform$/.test(e.propertyName)) {
  10054. el.removeEventListener("transitionend", cb);
  10055. el._moveCb = null;
  10056. removeTransitionClass(el, moveClass);
  10057. }
  10058. };
  10059. el.addEventListener("transitionend", cb);
  10060. });
  10061. });
  10062. return () => {
  10063. const rawProps = toRaw(props);
  10064. const cssTransitionProps = resolveTransitionProps(rawProps);
  10065. let tag = rawProps.tag || Fragment;
  10066. prevChildren = children;
  10067. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10068. for (let i = 0; i < children.length; i++) {
  10069. const child = children[i];
  10070. if (child.key != null) {
  10071. setTransitionHooks(
  10072. child,
  10073. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  10074. );
  10075. } else {
  10076. warn(`<TransitionGroup> children must be keyed.`);
  10077. }
  10078. }
  10079. if (prevChildren) {
  10080. for (let i = 0; i < prevChildren.length; i++) {
  10081. const child = prevChildren[i];
  10082. setTransitionHooks(
  10083. child,
  10084. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  10085. );
  10086. positionMap.set(child, child.el.getBoundingClientRect());
  10087. }
  10088. }
  10089. return createVNode(tag, null, children);
  10090. };
  10091. }
  10092. };
  10093. const removeMode = (props) => delete props.mode;
  10094. /* @__PURE__ */ removeMode(TransitionGroupImpl.props);
  10095. const TransitionGroup = TransitionGroupImpl;
  10096. function callPendingCbs(c) {
  10097. const el = c.el;
  10098. if (el._moveCb) {
  10099. el._moveCb();
  10100. }
  10101. if (el._enterCb) {
  10102. el._enterCb();
  10103. }
  10104. }
  10105. function recordPosition(c) {
  10106. newPositionMap.set(c, c.el.getBoundingClientRect());
  10107. }
  10108. function applyTranslation(c) {
  10109. const oldPos = positionMap.get(c);
  10110. const newPos = newPositionMap.get(c);
  10111. const dx = oldPos.left - newPos.left;
  10112. const dy = oldPos.top - newPos.top;
  10113. if (dx || dy) {
  10114. const s = c.el.style;
  10115. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10116. s.transitionDuration = "0s";
  10117. return c;
  10118. }
  10119. }
  10120. function hasCSSTransform(el, root, moveClass) {
  10121. const clone = el.cloneNode();
  10122. if (el._vtc) {
  10123. el._vtc.forEach((cls) => {
  10124. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  10125. });
  10126. }
  10127. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  10128. clone.style.display = "none";
  10129. const container = root.nodeType === 1 ? root : root.parentNode;
  10130. container.appendChild(clone);
  10131. const { hasTransform } = getTransitionInfo(clone);
  10132. container.removeChild(clone);
  10133. return hasTransform;
  10134. }
  10135.  
  10136. const getModelAssigner = (vnode) => {
  10137. const fn = vnode.props["onUpdate:modelValue"] || false;
  10138. return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
  10139. };
  10140. function onCompositionStart(e) {
  10141. e.target.composing = true;
  10142. }
  10143. function onCompositionEnd(e) {
  10144. const target = e.target;
  10145. if (target.composing) {
  10146. target.composing = false;
  10147. target.dispatchEvent(new Event("input"));
  10148. }
  10149. }
  10150. const vModelText = {
  10151. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10152. el._assign = getModelAssigner(vnode);
  10153. const castToNumber = number || vnode.props && vnode.props.type === "number";
  10154. addEventListener(el, lazy ? "change" : "input", (e) => {
  10155. if (e.target.composing)
  10156. return;
  10157. let domValue = el.value;
  10158. if (trim) {
  10159. domValue = domValue.trim();
  10160. }
  10161. if (castToNumber) {
  10162. domValue = looseToNumber(domValue);
  10163. }
  10164. el._assign(domValue);
  10165. });
  10166. if (trim) {
  10167. addEventListener(el, "change", () => {
  10168. el.value = el.value.trim();
  10169. });
  10170. }
  10171. if (!lazy) {
  10172. addEventListener(el, "compositionstart", onCompositionStart);
  10173. addEventListener(el, "compositionend", onCompositionEnd);
  10174. addEventListener(el, "change", onCompositionEnd);
  10175. }
  10176. },
  10177. // set value on mounted so it's after min/max for type="range"
  10178. mounted(el, { value }) {
  10179. el.value = value == null ? "" : value;
  10180. },
  10181. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10182. el._assign = getModelAssigner(vnode);
  10183. if (el.composing)
  10184. return;
  10185. if (document.activeElement === el && el.type !== "range") {
  10186. if (lazy) {
  10187. return;
  10188. }
  10189. if (trim && el.value.trim() === value) {
  10190. return;
  10191. }
  10192. if ((number || el.type === "number") && looseToNumber(el.value) === value) {
  10193. return;
  10194. }
  10195. }
  10196. const newValue = value == null ? "" : value;
  10197. if (el.value !== newValue) {
  10198. el.value = newValue;
  10199. }
  10200. }
  10201. };
  10202. const vModelCheckbox = {
  10203. // #4096 array checkboxes need to be deep traversed
  10204. deep: true,
  10205. created(el, _, vnode) {
  10206. el._assign = getModelAssigner(vnode);
  10207. addEventListener(el, "change", () => {
  10208. const modelValue = el._modelValue;
  10209. const elementValue = getValue(el);
  10210. const checked = el.checked;
  10211. const assign = el._assign;
  10212. if (isArray(modelValue)) {
  10213. const index = looseIndexOf(modelValue, elementValue);
  10214. const found = index !== -1;
  10215. if (checked && !found) {
  10216. assign(modelValue.concat(elementValue));
  10217. } else if (!checked && found) {
  10218. const filtered = [...modelValue];
  10219. filtered.splice(index, 1);
  10220. assign(filtered);
  10221. }
  10222. } else if (isSet(modelValue)) {
  10223. const cloned = new Set(modelValue);
  10224. if (checked) {
  10225. cloned.add(elementValue);
  10226. } else {
  10227. cloned.delete(elementValue);
  10228. }
  10229. assign(cloned);
  10230. } else {
  10231. assign(getCheckboxValue(el, checked));
  10232. }
  10233. });
  10234. },
  10235. // set initial checked on mount to wait for true-value/false-value
  10236. mounted: setChecked,
  10237. beforeUpdate(el, binding, vnode) {
  10238. el._assign = getModelAssigner(vnode);
  10239. setChecked(el, binding, vnode);
  10240. }
  10241. };
  10242. function setChecked(el, { value, oldValue }, vnode) {
  10243. el._modelValue = value;
  10244. if (isArray(value)) {
  10245. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10246. } else if (isSet(value)) {
  10247. el.checked = value.has(vnode.props.value);
  10248. } else if (value !== oldValue) {
  10249. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10250. }
  10251. }
  10252. const vModelRadio = {
  10253. created(el, { value }, vnode) {
  10254. el.checked = looseEqual(value, vnode.props.value);
  10255. el._assign = getModelAssigner(vnode);
  10256. addEventListener(el, "change", () => {
  10257. el._assign(getValue(el));
  10258. });
  10259. },
  10260. beforeUpdate(el, { value, oldValue }, vnode) {
  10261. el._assign = getModelAssigner(vnode);
  10262. if (value !== oldValue) {
  10263. el.checked = looseEqual(value, vnode.props.value);
  10264. }
  10265. }
  10266. };
  10267. const vModelSelect = {
  10268. // <select multiple> value need to be deep traversed
  10269. deep: true,
  10270. created(el, { value, modifiers: { number } }, vnode) {
  10271. const isSetModel = isSet(value);
  10272. addEventListener(el, "change", () => {
  10273. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  10274. (o) => number ? looseToNumber(getValue(o)) : getValue(o)
  10275. );
  10276. el._assign(
  10277. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  10278. );
  10279. });
  10280. el._assign = getModelAssigner(vnode);
  10281. },
  10282. // set value in mounted & updated because <select> relies on its children
  10283. // <option>s.
  10284. mounted(el, { value }) {
  10285. setSelected(el, value);
  10286. },
  10287. beforeUpdate(el, _binding, vnode) {
  10288. el._assign = getModelAssigner(vnode);
  10289. },
  10290. updated(el, { value }) {
  10291. setSelected(el, value);
  10292. }
  10293. };
  10294. function setSelected(el, value) {
  10295. const isMultiple = el.multiple;
  10296. if (isMultiple && !isArray(value) && !isSet(value)) {
  10297. warn(
  10298. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  10299. );
  10300. return;
  10301. }
  10302. for (let i = 0, l = el.options.length; i < l; i++) {
  10303. const option = el.options[i];
  10304. const optionValue = getValue(option);
  10305. if (isMultiple) {
  10306. if (isArray(value)) {
  10307. option.selected = looseIndexOf(value, optionValue) > -1;
  10308. } else {
  10309. option.selected = value.has(optionValue);
  10310. }
  10311. } else {
  10312. if (looseEqual(getValue(option), value)) {
  10313. if (el.selectedIndex !== i)
  10314. el.selectedIndex = i;
  10315. return;
  10316. }
  10317. }
  10318. }
  10319. if (!isMultiple && el.selectedIndex !== -1) {
  10320. el.selectedIndex = -1;
  10321. }
  10322. }
  10323. function getValue(el) {
  10324. return "_value" in el ? el._value : el.value;
  10325. }
  10326. function getCheckboxValue(el, checked) {
  10327. const key = checked ? "_trueValue" : "_falseValue";
  10328. return key in el ? el[key] : checked;
  10329. }
  10330. const vModelDynamic = {
  10331. created(el, binding, vnode) {
  10332. callModelHook(el, binding, vnode, null, "created");
  10333. },
  10334. mounted(el, binding, vnode) {
  10335. callModelHook(el, binding, vnode, null, "mounted");
  10336. },
  10337. beforeUpdate(el, binding, vnode, prevVNode) {
  10338. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  10339. },
  10340. updated(el, binding, vnode, prevVNode) {
  10341. callModelHook(el, binding, vnode, prevVNode, "updated");
  10342. }
  10343. };
  10344. function resolveDynamicModel(tagName, type) {
  10345. switch (tagName) {
  10346. case "SELECT":
  10347. return vModelSelect;
  10348. case "TEXTAREA":
  10349. return vModelText;
  10350. default:
  10351. switch (type) {
  10352. case "checkbox":
  10353. return vModelCheckbox;
  10354. case "radio":
  10355. return vModelRadio;
  10356. default:
  10357. return vModelText;
  10358. }
  10359. }
  10360. }
  10361. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10362. const modelToUse = resolveDynamicModel(
  10363. el.tagName,
  10364. vnode.props && vnode.props.type
  10365. );
  10366. const fn = modelToUse[hook];
  10367. fn && fn(el, binding, vnode, prevVNode);
  10368. }
  10369.  
  10370. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  10371. const modifierGuards = {
  10372. stop: (e) => e.stopPropagation(),
  10373. prevent: (e) => e.preventDefault(),
  10374. self: (e) => e.target !== e.currentTarget,
  10375. ctrl: (e) => !e.ctrlKey,
  10376. shift: (e) => !e.shiftKey,
  10377. alt: (e) => !e.altKey,
  10378. meta: (e) => !e.metaKey,
  10379. left: (e) => "button" in e && e.button !== 0,
  10380. middle: (e) => "button" in e && e.button !== 1,
  10381. right: (e) => "button" in e && e.button !== 2,
  10382. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  10383. };
  10384. const withModifiers = (fn, modifiers) => {
  10385. return (event, ...args) => {
  10386. for (let i = 0; i < modifiers.length; i++) {
  10387. const guard = modifierGuards[modifiers[i]];
  10388. if (guard && guard(event, modifiers))
  10389. return;
  10390. }
  10391. return fn(event, ...args);
  10392. };
  10393. };
  10394. const keyNames = {
  10395. esc: "escape",
  10396. space: " ",
  10397. up: "arrow-up",
  10398. left: "arrow-left",
  10399. right: "arrow-right",
  10400. down: "arrow-down",
  10401. delete: "backspace"
  10402. };
  10403. const withKeys = (fn, modifiers) => {
  10404. return (event) => {
  10405. if (!("key" in event)) {
  10406. return;
  10407. }
  10408. const eventKey = hyphenate(event.key);
  10409. if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
  10410. return fn(event);
  10411. }
  10412. };
  10413. };
  10414.  
  10415. const vShow = {
  10416. beforeMount(el, { value }, { transition }) {
  10417. el._vod = el.style.display === "none" ? "" : el.style.display;
  10418. if (transition && value) {
  10419. transition.beforeEnter(el);
  10420. } else {
  10421. setDisplay(el, value);
  10422. }
  10423. },
  10424. mounted(el, { value }, { transition }) {
  10425. if (transition && value) {
  10426. transition.enter(el);
  10427. }
  10428. },
  10429. updated(el, { value, oldValue }, { transition }) {
  10430. if (!value === !oldValue)
  10431. return;
  10432. if (transition) {
  10433. if (value) {
  10434. transition.beforeEnter(el);
  10435. setDisplay(el, true);
  10436. transition.enter(el);
  10437. } else {
  10438. transition.leave(el, () => {
  10439. setDisplay(el, false);
  10440. });
  10441. }
  10442. } else {
  10443. setDisplay(el, value);
  10444. }
  10445. },
  10446. beforeUnmount(el, { value }) {
  10447. setDisplay(el, value);
  10448. }
  10449. };
  10450. function setDisplay(el, value) {
  10451. el.style.display = value ? el._vod : "none";
  10452. }
  10453.  
  10454. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
  10455. let renderer;
  10456. let enabledHydration = false;
  10457. function ensureRenderer() {
  10458. return renderer || (renderer = createRenderer(rendererOptions));
  10459. }
  10460. function ensureHydrationRenderer() {
  10461. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
  10462. enabledHydration = true;
  10463. return renderer;
  10464. }
  10465. const render = (...args) => {
  10466. ensureRenderer().render(...args);
  10467. };
  10468. const hydrate = (...args) => {
  10469. ensureHydrationRenderer().hydrate(...args);
  10470. };
  10471. const createApp = (...args) => {
  10472. const app = ensureRenderer().createApp(...args);
  10473. {
  10474. injectNativeTagCheck(app);
  10475. injectCompilerOptionsCheck(app);
  10476. }
  10477. const { mount } = app;
  10478. app.mount = (containerOrSelector) => {
  10479. const container = normalizeContainer(containerOrSelector);
  10480. if (!container)
  10481. return;
  10482. const component = app._component;
  10483. if (!isFunction(component) && !component.render && !component.template) {
  10484. component.template = container.innerHTML;
  10485. }
  10486. container.innerHTML = "";
  10487. const proxy = mount(container, false, container instanceof SVGElement);
  10488. if (container instanceof Element) {
  10489. container.removeAttribute("v-cloak");
  10490. container.setAttribute("data-v-app", "");
  10491. }
  10492. return proxy;
  10493. };
  10494. return app;
  10495. };
  10496. const createSSRApp = (...args) => {
  10497. const app = ensureHydrationRenderer().createApp(...args);
  10498. {
  10499. injectNativeTagCheck(app);
  10500. injectCompilerOptionsCheck(app);
  10501. }
  10502. const { mount } = app;
  10503. app.mount = (containerOrSelector) => {
  10504. const container = normalizeContainer(containerOrSelector);
  10505. if (container) {
  10506. return mount(container, true, container instanceof SVGElement);
  10507. }
  10508. };
  10509. return app;
  10510. };
  10511. function injectNativeTagCheck(app) {
  10512. Object.defineProperty(app.config, "isNativeTag", {
  10513. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10514. writable: false
  10515. });
  10516. }
  10517. function injectCompilerOptionsCheck(app) {
  10518. if (isRuntimeOnly()) {
  10519. const isCustomElement = app.config.isCustomElement;
  10520. Object.defineProperty(app.config, "isCustomElement", {
  10521. get() {
  10522. return isCustomElement;
  10523. },
  10524. set() {
  10525. warn(
  10526. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  10527. );
  10528. }
  10529. });
  10530. const compilerOptions = app.config.compilerOptions;
  10531. const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
  10532. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  10533. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  10534. - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
  10535. Object.defineProperty(app.config, "compilerOptions", {
  10536. get() {
  10537. warn(msg);
  10538. return compilerOptions;
  10539. },
  10540. set() {
  10541. warn(msg);
  10542. }
  10543. });
  10544. }
  10545. }
  10546. function normalizeContainer(container) {
  10547. if (isString(container)) {
  10548. const res = document.querySelector(container);
  10549. if (!res) {
  10550. warn(
  10551. `Failed to mount app: mount target selector "${container}" returned null.`
  10552. );
  10553. }
  10554. return res;
  10555. }
  10556. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  10557. warn(
  10558. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  10559. );
  10560. }
  10561. return container;
  10562. }
  10563. const initDirectivesForSSR = NOOP;
  10564.  
  10565. function initDev() {
  10566. {
  10567. {
  10568. console.info(
  10569. `You are running a development build of Vue.
  10570. Make sure to use the production build (*.prod.js) when deploying for production.`
  10571. );
  10572. }
  10573. initCustomFormatter();
  10574. }
  10575. }
  10576.  
  10577. function defaultOnError(error) {
  10578. throw error;
  10579. }
  10580. function defaultOnWarn(msg) {
  10581. console.warn(`[Vue warn] ${msg.message}`);
  10582. }
  10583. function createCompilerError(code, loc, messages, additionalMessage) {
  10584. const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
  10585. const error = new SyntaxError(String(msg));
  10586. error.code = code;
  10587. error.loc = loc;
  10588. return error;
  10589. }
  10590. const errorMessages = {
  10591. // parse errors
  10592. [0]: "Illegal comment.",
  10593. [1]: "CDATA section is allowed only in XML context.",
  10594. [2]: "Duplicate attribute.",
  10595. [3]: "End tag cannot have attributes.",
  10596. [4]: "Illegal '/' in tags.",
  10597. [5]: "Unexpected EOF in tag.",
  10598. [6]: "Unexpected EOF in CDATA section.",
  10599. [7]: "Unexpected EOF in comment.",
  10600. [8]: "Unexpected EOF in script.",
  10601. [9]: "Unexpected EOF in tag.",
  10602. [10]: "Incorrectly closed comment.",
  10603. [11]: "Incorrectly opened comment.",
  10604. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  10605. [13]: "Attribute value was expected.",
  10606. [14]: "End tag name was expected.",
  10607. [15]: "Whitespace was expected.",
  10608. [16]: "Unexpected '<!--' in comment.",
  10609. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  10610. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  10611. [19]: "Attribute name cannot start with '='.",
  10612. [21]: "'<?' is allowed only in XML context.",
  10613. [20]: `Unexpected null character.`,
  10614. [22]: "Illegal '/' in tags.",
  10615. // Vue-specific parse errors
  10616. [23]: "Invalid end tag.",
  10617. [24]: "Element is missing end tag.",
  10618. [25]: "Interpolation end sign was not found.",
  10619. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  10620. [26]: "Legal directive name was expected.",
  10621. // transform errors
  10622. [28]: `v-if/v-else-if is missing expression.`,
  10623. [29]: `v-if/else branches must use unique keys.`,
  10624. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  10625. [31]: `v-for is missing expression.`,
  10626. [32]: `v-for has invalid expression.`,
  10627. [33]: `<template v-for> key should be placed on the <template> tag.`,
  10628. [34]: `v-bind is missing expression.`,
  10629. [35]: `v-on is missing expression.`,
  10630. [36]: `Unexpected custom directive on <slot> outlet.`,
  10631. [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
  10632. [38]: `Duplicate slot names found. `,
  10633. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  10634. [40]: `v-slot can only be used on components or <template> tags.`,
  10635. [41]: `v-model is missing expression.`,
  10636. [42]: `v-model value must be a valid JavaScript member expression.`,
  10637. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  10638. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  10639. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  10640. [45]: `Error parsing JavaScript expression: `,
  10641. [46]: `<KeepAlive> expects exactly one child component.`,
  10642. // generic errors
  10643. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  10644. [48]: `ES module mode is not supported in this build of compiler.`,
  10645. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  10646. [50]: `"scopeId" option is only supported in module mode.`,
  10647. // deprecations
  10648. [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
  10649. [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
  10650. // just to fulfill types
  10651. [53]: ``
  10652. };
  10653.  
  10654. const FRAGMENT = Symbol(`Fragment` );
  10655. const TELEPORT = Symbol(`Teleport` );
  10656. const SUSPENSE = Symbol(`Suspense` );
  10657. const KEEP_ALIVE = Symbol(`KeepAlive` );
  10658. const BASE_TRANSITION = Symbol(`BaseTransition` );
  10659. const OPEN_BLOCK = Symbol(`openBlock` );
  10660. const CREATE_BLOCK = Symbol(`createBlock` );
  10661. const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
  10662. const CREATE_VNODE = Symbol(`createVNode` );
  10663. const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
  10664. const CREATE_COMMENT = Symbol(`createCommentVNode` );
  10665. const CREATE_TEXT = Symbol(`createTextVNode` );
  10666. const CREATE_STATIC = Symbol(`createStaticVNode` );
  10667. const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
  10668. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  10669. `resolveDynamicComponent`
  10670. );
  10671. const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
  10672. const RESOLVE_FILTER = Symbol(`resolveFilter` );
  10673. const WITH_DIRECTIVES = Symbol(`withDirectives` );
  10674. const RENDER_LIST = Symbol(`renderList` );
  10675. const RENDER_SLOT = Symbol(`renderSlot` );
  10676. const CREATE_SLOTS = Symbol(`createSlots` );
  10677. const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
  10678. const MERGE_PROPS = Symbol(`mergeProps` );
  10679. const NORMALIZE_CLASS = Symbol(`normalizeClass` );
  10680. const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
  10681. const NORMALIZE_PROPS = Symbol(`normalizeProps` );
  10682. const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
  10683. const TO_HANDLERS = Symbol(`toHandlers` );
  10684. const CAMELIZE = Symbol(`camelize` );
  10685. const CAPITALIZE = Symbol(`capitalize` );
  10686. const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
  10687. const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
  10688. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  10689. const POP_SCOPE_ID = Symbol(`popScopeId` );
  10690. const WITH_CTX = Symbol(`withCtx` );
  10691. const UNREF = Symbol(`unref` );
  10692. const IS_REF = Symbol(`isRef` );
  10693. const WITH_MEMO = Symbol(`withMemo` );
  10694. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  10695. const helperNameMap = {
  10696. [FRAGMENT]: `Fragment`,
  10697. [TELEPORT]: `Teleport`,
  10698. [SUSPENSE]: `Suspense`,
  10699. [KEEP_ALIVE]: `KeepAlive`,
  10700. [BASE_TRANSITION]: `BaseTransition`,
  10701. [OPEN_BLOCK]: `openBlock`,
  10702. [CREATE_BLOCK]: `createBlock`,
  10703. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  10704. [CREATE_VNODE]: `createVNode`,
  10705. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  10706. [CREATE_COMMENT]: `createCommentVNode`,
  10707. [CREATE_TEXT]: `createTextVNode`,
  10708. [CREATE_STATIC]: `createStaticVNode`,
  10709. [RESOLVE_COMPONENT]: `resolveComponent`,
  10710. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  10711. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  10712. [RESOLVE_FILTER]: `resolveFilter`,
  10713. [WITH_DIRECTIVES]: `withDirectives`,
  10714. [RENDER_LIST]: `renderList`,
  10715. [RENDER_SLOT]: `renderSlot`,
  10716. [CREATE_SLOTS]: `createSlots`,
  10717. [TO_DISPLAY_STRING]: `toDisplayString`,
  10718. [MERGE_PROPS]: `mergeProps`,
  10719. [NORMALIZE_CLASS]: `normalizeClass`,
  10720. [NORMALIZE_STYLE]: `normalizeStyle`,
  10721. [NORMALIZE_PROPS]: `normalizeProps`,
  10722. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  10723. [TO_HANDLERS]: `toHandlers`,
  10724. [CAMELIZE]: `camelize`,
  10725. [CAPITALIZE]: `capitalize`,
  10726. [TO_HANDLER_KEY]: `toHandlerKey`,
  10727. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  10728. [PUSH_SCOPE_ID]: `pushScopeId`,
  10729. [POP_SCOPE_ID]: `popScopeId`,
  10730. [WITH_CTX]: `withCtx`,
  10731. [UNREF]: `unref`,
  10732. [IS_REF]: `isRef`,
  10733. [WITH_MEMO]: `withMemo`,
  10734. [IS_MEMO_SAME]: `isMemoSame`
  10735. };
  10736. function registerRuntimeHelpers(helpers) {
  10737. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  10738. helperNameMap[s] = helpers[s];
  10739. });
  10740. }
  10741.  
  10742. const locStub = {
  10743. source: "",
  10744. start: { line: 1, column: 1, offset: 0 },
  10745. end: { line: 1, column: 1, offset: 0 }
  10746. };
  10747. function createRoot(children, loc = locStub) {
  10748. return {
  10749. type: 0,
  10750. children,
  10751. helpers: /* @__PURE__ */ new Set(),
  10752. components: [],
  10753. directives: [],
  10754. hoists: [],
  10755. imports: [],
  10756. cached: 0,
  10757. temps: 0,
  10758. codegenNode: void 0,
  10759. loc
  10760. };
  10761. }
  10762. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  10763. if (context) {
  10764. if (isBlock) {
  10765. context.helper(OPEN_BLOCK);
  10766. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  10767. } else {
  10768. context.helper(getVNodeHelper(context.inSSR, isComponent));
  10769. }
  10770. if (directives) {
  10771. context.helper(WITH_DIRECTIVES);
  10772. }
  10773. }
  10774. return {
  10775. type: 13,
  10776. tag,
  10777. props,
  10778. children,
  10779. patchFlag,
  10780. dynamicProps,
  10781. directives,
  10782. isBlock,
  10783. disableTracking,
  10784. isComponent,
  10785. loc
  10786. };
  10787. }
  10788. function createArrayExpression(elements, loc = locStub) {
  10789. return {
  10790. type: 17,
  10791. loc,
  10792. elements
  10793. };
  10794. }
  10795. function createObjectExpression(properties, loc = locStub) {
  10796. return {
  10797. type: 15,
  10798. loc,
  10799. properties
  10800. };
  10801. }
  10802. function createObjectProperty(key, value) {
  10803. return {
  10804. type: 16,
  10805. loc: locStub,
  10806. key: isString(key) ? createSimpleExpression(key, true) : key,
  10807. value
  10808. };
  10809. }
  10810. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  10811. return {
  10812. type: 4,
  10813. loc,
  10814. content,
  10815. isStatic,
  10816. constType: isStatic ? 3 : constType
  10817. };
  10818. }
  10819. function createCompoundExpression(children, loc = locStub) {
  10820. return {
  10821. type: 8,
  10822. loc,
  10823. children
  10824. };
  10825. }
  10826. function createCallExpression(callee, args = [], loc = locStub) {
  10827. return {
  10828. type: 14,
  10829. loc,
  10830. callee,
  10831. arguments: args
  10832. };
  10833. }
  10834. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  10835. return {
  10836. type: 18,
  10837. params,
  10838. returns,
  10839. newline,
  10840. isSlot,
  10841. loc
  10842. };
  10843. }
  10844. function createConditionalExpression(test, consequent, alternate, newline = true) {
  10845. return {
  10846. type: 19,
  10847. test,
  10848. consequent,
  10849. alternate,
  10850. newline,
  10851. loc: locStub
  10852. };
  10853. }
  10854. function createCacheExpression(index, value, isVNode = false) {
  10855. return {
  10856. type: 20,
  10857. index,
  10858. value,
  10859. isVNode,
  10860. loc: locStub
  10861. };
  10862. }
  10863. function createBlockStatement(body) {
  10864. return {
  10865. type: 21,
  10866. body,
  10867. loc: locStub
  10868. };
  10869. }
  10870. function getVNodeHelper(ssr, isComponent) {
  10871. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  10872. }
  10873. function getVNodeBlockHelper(ssr, isComponent) {
  10874. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  10875. }
  10876. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  10877. if (!node.isBlock) {
  10878. node.isBlock = true;
  10879. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  10880. helper(OPEN_BLOCK);
  10881. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  10882. }
  10883. }
  10884.  
  10885. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  10886. const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
  10887. function isCoreComponent(tag) {
  10888. if (isBuiltInType(tag, "Teleport")) {
  10889. return TELEPORT;
  10890. } else if (isBuiltInType(tag, "Suspense")) {
  10891. return SUSPENSE;
  10892. } else if (isBuiltInType(tag, "KeepAlive")) {
  10893. return KEEP_ALIVE;
  10894. } else if (isBuiltInType(tag, "BaseTransition")) {
  10895. return BASE_TRANSITION;
  10896. }
  10897. }
  10898. const nonIdentifierRE = /^\d|[^\$\w]/;
  10899. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  10900. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  10901. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  10902. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  10903. const isMemberExpressionBrowser = (path) => {
  10904. path = path.trim().replace(whitespaceRE, (s) => s.trim());
  10905. let state = 0 /* inMemberExp */;
  10906. let stateStack = [];
  10907. let currentOpenBracketCount = 0;
  10908. let currentOpenParensCount = 0;
  10909. let currentStringType = null;
  10910. for (let i = 0; i < path.length; i++) {
  10911. const char = path.charAt(i);
  10912. switch (state) {
  10913. case 0 /* inMemberExp */:
  10914. if (char === "[") {
  10915. stateStack.push(state);
  10916. state = 1 /* inBrackets */;
  10917. currentOpenBracketCount++;
  10918. } else if (char === "(") {
  10919. stateStack.push(state);
  10920. state = 2 /* inParens */;
  10921. currentOpenParensCount++;
  10922. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  10923. return false;
  10924. }
  10925. break;
  10926. case 1 /* inBrackets */:
  10927. if (char === `'` || char === `"` || char === "`") {
  10928. stateStack.push(state);
  10929. state = 3 /* inString */;
  10930. currentStringType = char;
  10931. } else if (char === `[`) {
  10932. currentOpenBracketCount++;
  10933. } else if (char === `]`) {
  10934. if (!--currentOpenBracketCount) {
  10935. state = stateStack.pop();
  10936. }
  10937. }
  10938. break;
  10939. case 2 /* inParens */:
  10940. if (char === `'` || char === `"` || char === "`") {
  10941. stateStack.push(state);
  10942. state = 3 /* inString */;
  10943. currentStringType = char;
  10944. } else if (char === `(`) {
  10945. currentOpenParensCount++;
  10946. } else if (char === `)`) {
  10947. if (i === path.length - 1) {
  10948. return false;
  10949. }
  10950. if (!--currentOpenParensCount) {
  10951. state = stateStack.pop();
  10952. }
  10953. }
  10954. break;
  10955. case 3 /* inString */:
  10956. if (char === currentStringType) {
  10957. state = stateStack.pop();
  10958. currentStringType = null;
  10959. }
  10960. break;
  10961. }
  10962. }
  10963. return !currentOpenBracketCount && !currentOpenParensCount;
  10964. };
  10965. const isMemberExpression = isMemberExpressionBrowser ;
  10966. function getInnerRange(loc, offset, length) {
  10967. const source = loc.source.slice(offset, offset + length);
  10968. const newLoc = {
  10969. source,
  10970. start: advancePositionWithClone(loc.start, loc.source, offset),
  10971. end: loc.end
  10972. };
  10973. if (length != null) {
  10974. newLoc.end = advancePositionWithClone(
  10975. loc.start,
  10976. loc.source,
  10977. offset + length
  10978. );
  10979. }
  10980. return newLoc;
  10981. }
  10982. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  10983. return advancePositionWithMutation(
  10984. extend({}, pos),
  10985. source,
  10986. numberOfCharacters
  10987. );
  10988. }
  10989. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  10990. let linesCount = 0;
  10991. let lastNewLinePos = -1;
  10992. for (let i = 0; i < numberOfCharacters; i++) {
  10993. if (source.charCodeAt(i) === 10) {
  10994. linesCount++;
  10995. lastNewLinePos = i;
  10996. }
  10997. }
  10998. pos.offset += numberOfCharacters;
  10999. pos.line += linesCount;
  11000. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  11001. return pos;
  11002. }
  11003. function assert(condition, msg) {
  11004. if (!condition) {
  11005. throw new Error(msg || `unexpected compiler condition`);
  11006. }
  11007. }
  11008. function findDir(node, name, allowEmpty = false) {
  11009. for (let i = 0; i < node.props.length; i++) {
  11010. const p = node.props[i];
  11011. if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
  11012. return p;
  11013. }
  11014. }
  11015. }
  11016. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  11017. for (let i = 0; i < node.props.length; i++) {
  11018. const p = node.props[i];
  11019. if (p.type === 6) {
  11020. if (dynamicOnly)
  11021. continue;
  11022. if (p.name === name && (p.value || allowEmpty)) {
  11023. return p;
  11024. }
  11025. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  11026. return p;
  11027. }
  11028. }
  11029. }
  11030. function isStaticArgOf(arg, name) {
  11031. return !!(arg && isStaticExp(arg) && arg.content === name);
  11032. }
  11033. function hasDynamicKeyVBind(node) {
  11034. return node.props.some(
  11035. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  11036. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  11037. !p.arg.isStatic)
  11038. // v-bind:[foo]
  11039. );
  11040. }
  11041. function isText$1(node) {
  11042. return node.type === 5 || node.type === 2;
  11043. }
  11044. function isVSlot(p) {
  11045. return p.type === 7 && p.name === "slot";
  11046. }
  11047. function isTemplateNode(node) {
  11048. return node.type === 1 && node.tagType === 3;
  11049. }
  11050. function isSlotOutlet(node) {
  11051. return node.type === 1 && node.tagType === 2;
  11052. }
  11053. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  11054. function getUnnormalizedProps(props, callPath = []) {
  11055. if (props && !isString(props) && props.type === 14) {
  11056. const callee = props.callee;
  11057. if (!isString(callee) && propsHelperSet.has(callee)) {
  11058. return getUnnormalizedProps(
  11059. props.arguments[0],
  11060. callPath.concat(props)
  11061. );
  11062. }
  11063. }
  11064. return [props, callPath];
  11065. }
  11066. function injectProp(node, prop, context) {
  11067. let propsWithInjection;
  11068. let props = node.type === 13 ? node.props : node.arguments[2];
  11069. let callPath = [];
  11070. let parentCall;
  11071. if (props && !isString(props) && props.type === 14) {
  11072. const ret = getUnnormalizedProps(props);
  11073. props = ret[0];
  11074. callPath = ret[1];
  11075. parentCall = callPath[callPath.length - 1];
  11076. }
  11077. if (props == null || isString(props)) {
  11078. propsWithInjection = createObjectExpression([prop]);
  11079. } else if (props.type === 14) {
  11080. const first = props.arguments[0];
  11081. if (!isString(first) && first.type === 15) {
  11082. if (!hasProp(prop, first)) {
  11083. first.properties.unshift(prop);
  11084. }
  11085. } else {
  11086. if (props.callee === TO_HANDLERS) {
  11087. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  11088. createObjectExpression([prop]),
  11089. props
  11090. ]);
  11091. } else {
  11092. props.arguments.unshift(createObjectExpression([prop]));
  11093. }
  11094. }
  11095. !propsWithInjection && (propsWithInjection = props);
  11096. } else if (props.type === 15) {
  11097. if (!hasProp(prop, props)) {
  11098. props.properties.unshift(prop);
  11099. }
  11100. propsWithInjection = props;
  11101. } else {
  11102. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  11103. createObjectExpression([prop]),
  11104. props
  11105. ]);
  11106. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  11107. parentCall = callPath[callPath.length - 2];
  11108. }
  11109. }
  11110. if (node.type === 13) {
  11111. if (parentCall) {
  11112. parentCall.arguments[0] = propsWithInjection;
  11113. } else {
  11114. node.props = propsWithInjection;
  11115. }
  11116. } else {
  11117. if (parentCall) {
  11118. parentCall.arguments[0] = propsWithInjection;
  11119. } else {
  11120. node.arguments[2] = propsWithInjection;
  11121. }
  11122. }
  11123. }
  11124. function hasProp(prop, props) {
  11125. let result = false;
  11126. if (prop.key.type === 4) {
  11127. const propKeyName = prop.key.content;
  11128. result = props.properties.some(
  11129. (p) => p.key.type === 4 && p.key.content === propKeyName
  11130. );
  11131. }
  11132. return result;
  11133. }
  11134. function toValidAssetId(name, type) {
  11135. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  11136. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  11137. })}`;
  11138. }
  11139. function getMemoedVNodeCall(node) {
  11140. if (node.type === 14 && node.callee === WITH_MEMO) {
  11141. return node.arguments[1].returns;
  11142. } else {
  11143. return node;
  11144. }
  11145. }
  11146.  
  11147. const decodeRE = /&(gt|lt|amp|apos|quot);/g;
  11148. const decodeMap = {
  11149. gt: ">",
  11150. lt: "<",
  11151. amp: "&",
  11152. apos: "'",
  11153. quot: '"'
  11154. };
  11155. const defaultParserOptions = {
  11156. delimiters: [`{{`, `}}`],
  11157. getNamespace: () => 0,
  11158. getTextMode: () => 0,
  11159. isVoidTag: NO,
  11160. isPreTag: NO,
  11161. isCustomElement: NO,
  11162. decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
  11163. onError: defaultOnError,
  11164. onWarn: defaultOnWarn,
  11165. comments: true
  11166. };
  11167. function baseParse(content, options = {}) {
  11168. const context = createParserContext(content, options);
  11169. const start = getCursor(context);
  11170. return createRoot(
  11171. parseChildren(context, 0, []),
  11172. getSelection(context, start)
  11173. );
  11174. }
  11175. function createParserContext(content, rawOptions) {
  11176. const options = extend({}, defaultParserOptions);
  11177. let key;
  11178. for (key in rawOptions) {
  11179. options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
  11180. }
  11181. return {
  11182. options,
  11183. column: 1,
  11184. line: 1,
  11185. offset: 0,
  11186. originalSource: content,
  11187. source: content,
  11188. inPre: false,
  11189. inVPre: false,
  11190. onWarn: options.onWarn
  11191. };
  11192. }
  11193. function parseChildren(context, mode, ancestors) {
  11194. const parent = last(ancestors);
  11195. const ns = parent ? parent.ns : 0;
  11196. const nodes = [];
  11197. while (!isEnd(context, mode, ancestors)) {
  11198. const s = context.source;
  11199. let node = void 0;
  11200. if (mode === 0 || mode === 1) {
  11201. if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
  11202. node = parseInterpolation(context, mode);
  11203. } else if (mode === 0 && s[0] === "<") {
  11204. if (s.length === 1) {
  11205. emitError(context, 5, 1);
  11206. } else if (s[1] === "!") {
  11207. if (startsWith(s, "<!--")) {
  11208. node = parseComment(context);
  11209. } else if (startsWith(s, "<!DOCTYPE")) {
  11210. node = parseBogusComment(context);
  11211. } else if (startsWith(s, "<![CDATA[")) {
  11212. if (ns !== 0) {
  11213. node = parseCDATA(context, ancestors);
  11214. } else {
  11215. emitError(context, 1);
  11216. node = parseBogusComment(context);
  11217. }
  11218. } else {
  11219. emitError(context, 11);
  11220. node = parseBogusComment(context);
  11221. }
  11222. } else if (s[1] === "/") {
  11223. if (s.length === 2) {
  11224. emitError(context, 5, 2);
  11225. } else if (s[2] === ">") {
  11226. emitError(context, 14, 2);
  11227. advanceBy(context, 3);
  11228. continue;
  11229. } else if (/[a-z]/i.test(s[2])) {
  11230. emitError(context, 23);
  11231. parseTag(context, TagType.End, parent);
  11232. continue;
  11233. } else {
  11234. emitError(
  11235. context,
  11236. 12,
  11237. 2
  11238. );
  11239. node = parseBogusComment(context);
  11240. }
  11241. } else if (/[a-z]/i.test(s[1])) {
  11242. node = parseElement(context, ancestors);
  11243. } else if (s[1] === "?") {
  11244. emitError(
  11245. context,
  11246. 21,
  11247. 1
  11248. );
  11249. node = parseBogusComment(context);
  11250. } else {
  11251. emitError(context, 12, 1);
  11252. }
  11253. }
  11254. }
  11255. if (!node) {
  11256. node = parseText(context, mode);
  11257. }
  11258. if (isArray(node)) {
  11259. for (let i = 0; i < node.length; i++) {
  11260. pushNode(nodes, node[i]);
  11261. }
  11262. } else {
  11263. pushNode(nodes, node);
  11264. }
  11265. }
  11266. let removedWhitespace = false;
  11267. if (mode !== 2 && mode !== 1) {
  11268. const shouldCondense = context.options.whitespace !== "preserve";
  11269. for (let i = 0; i < nodes.length; i++) {
  11270. const node = nodes[i];
  11271. if (node.type === 2) {
  11272. if (!context.inPre) {
  11273. if (!/[^\t\r\n\f ]/.test(node.content)) {
  11274. const prev = nodes[i - 1];
  11275. const next = nodes[i + 1];
  11276. if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
  11277. removedWhitespace = true;
  11278. nodes[i] = null;
  11279. } else {
  11280. node.content = " ";
  11281. }
  11282. } else if (shouldCondense) {
  11283. node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
  11284. }
  11285. } else {
  11286. node.content = node.content.replace(/\r\n/g, "\n");
  11287. }
  11288. } else if (node.type === 3 && !context.options.comments) {
  11289. removedWhitespace = true;
  11290. nodes[i] = null;
  11291. }
  11292. }
  11293. if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
  11294. const first = nodes[0];
  11295. if (first && first.type === 2) {
  11296. first.content = first.content.replace(/^\r?\n/, "");
  11297. }
  11298. }
  11299. }
  11300. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  11301. }
  11302. function pushNode(nodes, node) {
  11303. if (node.type === 2) {
  11304. const prev = last(nodes);
  11305. if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
  11306. prev.content += node.content;
  11307. prev.loc.end = node.loc.end;
  11308. prev.loc.source += node.loc.source;
  11309. return;
  11310. }
  11311. }
  11312. nodes.push(node);
  11313. }
  11314. function parseCDATA(context, ancestors) {
  11315. advanceBy(context, 9);
  11316. const nodes = parseChildren(context, 3, ancestors);
  11317. if (context.source.length === 0) {
  11318. emitError(context, 6);
  11319. } else {
  11320. advanceBy(context, 3);
  11321. }
  11322. return nodes;
  11323. }
  11324. function parseComment(context) {
  11325. const start = getCursor(context);
  11326. let content;
  11327. const match = /--(\!)?>/.exec(context.source);
  11328. if (!match) {
  11329. content = context.source.slice(4);
  11330. advanceBy(context, context.source.length);
  11331. emitError(context, 7);
  11332. } else {
  11333. if (match.index <= 3) {
  11334. emitError(context, 0);
  11335. }
  11336. if (match[1]) {
  11337. emitError(context, 10);
  11338. }
  11339. content = context.source.slice(4, match.index);
  11340. const s = context.source.slice(0, match.index);
  11341. let prevIndex = 1, nestedIndex = 0;
  11342. while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
  11343. advanceBy(context, nestedIndex - prevIndex + 1);
  11344. if (nestedIndex + 4 < s.length) {
  11345. emitError(context, 16);
  11346. }
  11347. prevIndex = nestedIndex + 1;
  11348. }
  11349. advanceBy(context, match.index + match[0].length - prevIndex + 1);
  11350. }
  11351. return {
  11352. type: 3,
  11353. content,
  11354. loc: getSelection(context, start)
  11355. };
  11356. }
  11357. function parseBogusComment(context) {
  11358. const start = getCursor(context);
  11359. const contentStart = context.source[1] === "?" ? 1 : 2;
  11360. let content;
  11361. const closeIndex = context.source.indexOf(">");
  11362. if (closeIndex === -1) {
  11363. content = context.source.slice(contentStart);
  11364. advanceBy(context, context.source.length);
  11365. } else {
  11366. content = context.source.slice(contentStart, closeIndex);
  11367. advanceBy(context, closeIndex + 1);
  11368. }
  11369. return {
  11370. type: 3,
  11371. content,
  11372. loc: getSelection(context, start)
  11373. };
  11374. }
  11375. function parseElement(context, ancestors) {
  11376. const wasInPre = context.inPre;
  11377. const wasInVPre = context.inVPre;
  11378. const parent = last(ancestors);
  11379. const element = parseTag(context, TagType.Start, parent);
  11380. const isPreBoundary = context.inPre && !wasInPre;
  11381. const isVPreBoundary = context.inVPre && !wasInVPre;
  11382. if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
  11383. if (isPreBoundary) {
  11384. context.inPre = false;
  11385. }
  11386. if (isVPreBoundary) {
  11387. context.inVPre = false;
  11388. }
  11389. return element;
  11390. }
  11391. ancestors.push(element);
  11392. const mode = context.options.getTextMode(element, parent);
  11393. const children = parseChildren(context, mode, ancestors);
  11394. ancestors.pop();
  11395. element.children = children;
  11396. if (startsWithEndTagOpen(context.source, element.tag)) {
  11397. parseTag(context, TagType.End, parent);
  11398. } else {
  11399. emitError(context, 24, 0, element.loc.start);
  11400. if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
  11401. const first = children[0];
  11402. if (first && startsWith(first.loc.source, "<!--")) {
  11403. emitError(context, 8);
  11404. }
  11405. }
  11406. }
  11407. element.loc = getSelection(context, element.loc.start);
  11408. if (isPreBoundary) {
  11409. context.inPre = false;
  11410. }
  11411. if (isVPreBoundary) {
  11412. context.inVPre = false;
  11413. }
  11414. return element;
  11415. }
  11416. var TagType = /* @__PURE__ */ ((TagType2) => {
  11417. TagType2[TagType2["Start"] = 0] = "Start";
  11418. TagType2[TagType2["End"] = 1] = "End";
  11419. return TagType2;
  11420. })(TagType || {});
  11421. const isSpecialTemplateDirective = /* @__PURE__ */ makeMap(
  11422. `if,else,else-if,for,slot`
  11423. );
  11424. function parseTag(context, type, parent) {
  11425. const start = getCursor(context);
  11426. const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
  11427. const tag = match[1];
  11428. const ns = context.options.getNamespace(tag, parent);
  11429. advanceBy(context, match[0].length);
  11430. advanceSpaces(context);
  11431. const cursor = getCursor(context);
  11432. const currentSource = context.source;
  11433. if (context.options.isPreTag(tag)) {
  11434. context.inPre = true;
  11435. }
  11436. let props = parseAttributes(context, type);
  11437. if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
  11438. context.inVPre = true;
  11439. extend(context, cursor);
  11440. context.source = currentSource;
  11441. props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
  11442. }
  11443. let isSelfClosing = false;
  11444. if (context.source.length === 0) {
  11445. emitError(context, 9);
  11446. } else {
  11447. isSelfClosing = startsWith(context.source, "/>");
  11448. if (type === 1 /* End */ && isSelfClosing) {
  11449. emitError(context, 4);
  11450. }
  11451. advanceBy(context, isSelfClosing ? 2 : 1);
  11452. }
  11453. if (type === 1 /* End */) {
  11454. return;
  11455. }
  11456. let tagType = 0;
  11457. if (!context.inVPre) {
  11458. if (tag === "slot") {
  11459. tagType = 2;
  11460. } else if (tag === "template") {
  11461. if (props.some(
  11462. (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
  11463. )) {
  11464. tagType = 3;
  11465. }
  11466. } else if (isComponent(tag, props, context)) {
  11467. tagType = 1;
  11468. }
  11469. }
  11470. return {
  11471. type: 1,
  11472. ns,
  11473. tag,
  11474. tagType,
  11475. props,
  11476. isSelfClosing,
  11477. children: [],
  11478. loc: getSelection(context, start),
  11479. codegenNode: void 0
  11480. // to be created during transform phase
  11481. };
  11482. }
  11483. function isComponent(tag, props, context) {
  11484. const options = context.options;
  11485. if (options.isCustomElement(tag)) {
  11486. return false;
  11487. }
  11488. if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
  11489. return true;
  11490. }
  11491. for (let i = 0; i < props.length; i++) {
  11492. const p = props[i];
  11493. if (p.type === 6) {
  11494. if (p.name === "is" && p.value) {
  11495. if (p.value.content.startsWith("vue:")) {
  11496. return true;
  11497. }
  11498. }
  11499. } else {
  11500. if (p.name === "is") {
  11501. return true;
  11502. } else if (
  11503. // :is on plain element - only treat as component in compat mode
  11504. p.name === "bind" && isStaticArgOf(p.arg, "is") && false
  11505. ) {
  11506. return true;
  11507. }
  11508. }
  11509. }
  11510. }
  11511. function parseAttributes(context, type) {
  11512. const props = [];
  11513. const attributeNames = /* @__PURE__ */ new Set();
  11514. while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
  11515. if (startsWith(context.source, "/")) {
  11516. emitError(context, 22);
  11517. advanceBy(context, 1);
  11518. advanceSpaces(context);
  11519. continue;
  11520. }
  11521. if (type === 1 /* End */) {
  11522. emitError(context, 3);
  11523. }
  11524. const attr = parseAttribute(context, attributeNames);
  11525. if (attr.type === 6 && attr.value && attr.name === "class") {
  11526. attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
  11527. }
  11528. if (type === 0 /* Start */) {
  11529. props.push(attr);
  11530. }
  11531. if (/^[^\t\r\n\f />]/.test(context.source)) {
  11532. emitError(context, 15);
  11533. }
  11534. advanceSpaces(context);
  11535. }
  11536. return props;
  11537. }
  11538. function parseAttribute(context, nameSet) {
  11539. var _a;
  11540. const start = getCursor(context);
  11541. const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
  11542. const name = match[0];
  11543. if (nameSet.has(name)) {
  11544. emitError(context, 2);
  11545. }
  11546. nameSet.add(name);
  11547. if (name[0] === "=") {
  11548. emitError(context, 19);
  11549. }
  11550. {
  11551. const pattern = /["'<]/g;
  11552. let m;
  11553. while (m = pattern.exec(name)) {
  11554. emitError(
  11555. context,
  11556. 17,
  11557. m.index
  11558. );
  11559. }
  11560. }
  11561. advanceBy(context, name.length);
  11562. let value = void 0;
  11563. if (/^[\t\r\n\f ]*=/.test(context.source)) {
  11564. advanceSpaces(context);
  11565. advanceBy(context, 1);
  11566. advanceSpaces(context);
  11567. value = parseAttributeValue(context);
  11568. if (!value) {
  11569. emitError(context, 13);
  11570. }
  11571. }
  11572. const loc = getSelection(context, start);
  11573. if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
  11574. const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
  11575. name
  11576. );
  11577. let isPropShorthand = startsWith(name, ".");
  11578. let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
  11579. let arg;
  11580. if (match2[2]) {
  11581. const isSlot = dirName === "slot";
  11582. const startOffset = name.lastIndexOf(
  11583. match2[2],
  11584. name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
  11585. );
  11586. const loc2 = getSelection(
  11587. context,
  11588. getNewPosition(context, start, startOffset),
  11589. getNewPosition(
  11590. context,
  11591. start,
  11592. startOffset + match2[2].length + (isSlot && match2[3] || "").length
  11593. )
  11594. );
  11595. let content = match2[2];
  11596. let isStatic = true;
  11597. if (content.startsWith("[")) {
  11598. isStatic = false;
  11599. if (!content.endsWith("]")) {
  11600. emitError(
  11601. context,
  11602. 27
  11603. );
  11604. content = content.slice(1);
  11605. } else {
  11606. content = content.slice(1, content.length - 1);
  11607. }
  11608. } else if (isSlot) {
  11609. content += match2[3] || "";
  11610. }
  11611. arg = {
  11612. type: 4,
  11613. content,
  11614. isStatic,
  11615. constType: isStatic ? 3 : 0,
  11616. loc: loc2
  11617. };
  11618. }
  11619. if (value && value.isQuoted) {
  11620. const valueLoc = value.loc;
  11621. valueLoc.start.offset++;
  11622. valueLoc.start.column++;
  11623. valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
  11624. valueLoc.source = valueLoc.source.slice(1, -1);
  11625. }
  11626. const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
  11627. if (isPropShorthand)
  11628. modifiers.push("prop");
  11629. return {
  11630. type: 7,
  11631. name: dirName,
  11632. exp: value && {
  11633. type: 4,
  11634. content: value.content,
  11635. isStatic: false,
  11636. // Treat as non-constant by default. This can be potentially set to
  11637. // other values by `transformExpression` to make it eligible for hoisting.
  11638. constType: 0,
  11639. loc: value.loc
  11640. },
  11641. arg,
  11642. modifiers,
  11643. loc
  11644. };
  11645. }
  11646. if (!context.inVPre && startsWith(name, "v-")) {
  11647. emitError(context, 26);
  11648. }
  11649. return {
  11650. type: 6,
  11651. name,
  11652. value: value && {
  11653. type: 2,
  11654. content: value.content,
  11655. loc: value.loc
  11656. },
  11657. loc
  11658. };
  11659. }
  11660. function parseAttributeValue(context) {
  11661. const start = getCursor(context);
  11662. let content;
  11663. const quote = context.source[0];
  11664. const isQuoted = quote === `"` || quote === `'`;
  11665. if (isQuoted) {
  11666. advanceBy(context, 1);
  11667. const endIndex = context.source.indexOf(quote);
  11668. if (endIndex === -1) {
  11669. content = parseTextData(
  11670. context,
  11671. context.source.length,
  11672. 4
  11673. );
  11674. } else {
  11675. content = parseTextData(context, endIndex, 4);
  11676. advanceBy(context, 1);
  11677. }
  11678. } else {
  11679. const match = /^[^\t\r\n\f >]+/.exec(context.source);
  11680. if (!match) {
  11681. return void 0;
  11682. }
  11683. const unexpectedChars = /["'<=`]/g;
  11684. let m;
  11685. while (m = unexpectedChars.exec(match[0])) {
  11686. emitError(
  11687. context,
  11688. 18,
  11689. m.index
  11690. );
  11691. }
  11692. content = parseTextData(context, match[0].length, 4);
  11693. }
  11694. return { content, isQuoted, loc: getSelection(context, start) };
  11695. }
  11696. function parseInterpolation(context, mode) {
  11697. const [open, close] = context.options.delimiters;
  11698. const closeIndex = context.source.indexOf(close, open.length);
  11699. if (closeIndex === -1) {
  11700. emitError(context, 25);
  11701. return void 0;
  11702. }
  11703. const start = getCursor(context);
  11704. advanceBy(context, open.length);
  11705. const innerStart = getCursor(context);
  11706. const innerEnd = getCursor(context);
  11707. const rawContentLength = closeIndex - open.length;
  11708. const rawContent = context.source.slice(0, rawContentLength);
  11709. const preTrimContent = parseTextData(context, rawContentLength, mode);
  11710. const content = preTrimContent.trim();
  11711. const startOffset = preTrimContent.indexOf(content);
  11712. if (startOffset > 0) {
  11713. advancePositionWithMutation(innerStart, rawContent, startOffset);
  11714. }
  11715. const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
  11716. advancePositionWithMutation(innerEnd, rawContent, endOffset);
  11717. advanceBy(context, close.length);
  11718. return {
  11719. type: 5,
  11720. content: {
  11721. type: 4,
  11722. isStatic: false,
  11723. // Set `isConstant` to false by default and will decide in transformExpression
  11724. constType: 0,
  11725. content,
  11726. loc: getSelection(context, innerStart, innerEnd)
  11727. },
  11728. loc: getSelection(context, start)
  11729. };
  11730. }
  11731. function parseText(context, mode) {
  11732. const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
  11733. let endIndex = context.source.length;
  11734. for (let i = 0; i < endTokens.length; i++) {
  11735. const index = context.source.indexOf(endTokens[i], 1);
  11736. if (index !== -1 && endIndex > index) {
  11737. endIndex = index;
  11738. }
  11739. }
  11740. const start = getCursor(context);
  11741. const content = parseTextData(context, endIndex, mode);
  11742. return {
  11743. type: 2,
  11744. content,
  11745. loc: getSelection(context, start)
  11746. };
  11747. }
  11748. function parseTextData(context, length, mode) {
  11749. const rawText = context.source.slice(0, length);
  11750. advanceBy(context, length);
  11751. if (mode === 2 || mode === 3 || !rawText.includes("&")) {
  11752. return rawText;
  11753. } else {
  11754. return context.options.decodeEntities(
  11755. rawText,
  11756. mode === 4
  11757. );
  11758. }
  11759. }
  11760. function getCursor(context) {
  11761. const { column, line, offset } = context;
  11762. return { column, line, offset };
  11763. }
  11764. function getSelection(context, start, end) {
  11765. end = end || getCursor(context);
  11766. return {
  11767. start,
  11768. end,
  11769. source: context.originalSource.slice(start.offset, end.offset)
  11770. };
  11771. }
  11772. function last(xs) {
  11773. return xs[xs.length - 1];
  11774. }
  11775. function startsWith(source, searchString) {
  11776. return source.startsWith(searchString);
  11777. }
  11778. function advanceBy(context, numberOfCharacters) {
  11779. const { source } = context;
  11780. advancePositionWithMutation(context, source, numberOfCharacters);
  11781. context.source = source.slice(numberOfCharacters);
  11782. }
  11783. function advanceSpaces(context) {
  11784. const match = /^[\t\r\n\f ]+/.exec(context.source);
  11785. if (match) {
  11786. advanceBy(context, match[0].length);
  11787. }
  11788. }
  11789. function getNewPosition(context, start, numberOfCharacters) {
  11790. return advancePositionWithClone(
  11791. start,
  11792. context.originalSource.slice(start.offset, numberOfCharacters),
  11793. numberOfCharacters
  11794. );
  11795. }
  11796. function emitError(context, code, offset, loc = getCursor(context)) {
  11797. if (offset) {
  11798. loc.offset += offset;
  11799. loc.column += offset;
  11800. }
  11801. context.options.onError(
  11802. createCompilerError(code, {
  11803. start: loc,
  11804. end: loc,
  11805. source: ""
  11806. })
  11807. );
  11808. }
  11809. function isEnd(context, mode, ancestors) {
  11810. const s = context.source;
  11811. switch (mode) {
  11812. case 0:
  11813. if (startsWith(s, "</")) {
  11814. for (let i = ancestors.length - 1; i >= 0; --i) {
  11815. if (startsWithEndTagOpen(s, ancestors[i].tag)) {
  11816. return true;
  11817. }
  11818. }
  11819. }
  11820. break;
  11821. case 1:
  11822. case 2: {
  11823. const parent = last(ancestors);
  11824. if (parent && startsWithEndTagOpen(s, parent.tag)) {
  11825. return true;
  11826. }
  11827. break;
  11828. }
  11829. case 3:
  11830. if (startsWith(s, "]]>")) {
  11831. return true;
  11832. }
  11833. break;
  11834. }
  11835. return !s;
  11836. }
  11837. function startsWithEndTagOpen(source, tag) {
  11838. return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
  11839. }
  11840.  
  11841. function hoistStatic(root, context) {
  11842. walk(
  11843. root,
  11844. context,
  11845. // Root node is unfortunately non-hoistable due to potential parent
  11846. // fallthrough attributes.
  11847. isSingleElementRoot(root, root.children[0])
  11848. );
  11849. }
  11850. function isSingleElementRoot(root, child) {
  11851. const { children } = root;
  11852. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  11853. }
  11854. function walk(node, context, doNotHoistNode = false) {
  11855. const { children } = node;
  11856. const originalCount = children.length;
  11857. let hoistedCount = 0;
  11858. for (let i = 0; i < children.length; i++) {
  11859. const child = children[i];
  11860. if (child.type === 1 && child.tagType === 0) {
  11861. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  11862. if (constantType > 0) {
  11863. if (constantType >= 2) {
  11864. child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
  11865. child.codegenNode = context.hoist(child.codegenNode);
  11866. hoistedCount++;
  11867. continue;
  11868. }
  11869. } else {
  11870. const codegenNode = child.codegenNode;
  11871. if (codegenNode.type === 13) {
  11872. const flag = getPatchFlag(codegenNode);
  11873. if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  11874. const props = getNodeProps(child);
  11875. if (props) {
  11876. codegenNode.props = context.hoist(props);
  11877. }
  11878. }
  11879. if (codegenNode.dynamicProps) {
  11880. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  11881. }
  11882. }
  11883. }
  11884. }
  11885. if (child.type === 1) {
  11886. const isComponent = child.tagType === 1;
  11887. if (isComponent) {
  11888. context.scopes.vSlot++;
  11889. }
  11890. walk(child, context);
  11891. if (isComponent) {
  11892. context.scopes.vSlot--;
  11893. }
  11894. } else if (child.type === 11) {
  11895. walk(child, context, child.children.length === 1);
  11896. } else if (child.type === 9) {
  11897. for (let i2 = 0; i2 < child.branches.length; i2++) {
  11898. walk(
  11899. child.branches[i2],
  11900. context,
  11901. child.branches[i2].children.length === 1
  11902. );
  11903. }
  11904. }
  11905. }
  11906. if (hoistedCount && context.transformHoist) {
  11907. context.transformHoist(children, context, node);
  11908. }
  11909. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
  11910. node.codegenNode.children = context.hoist(
  11911. createArrayExpression(node.codegenNode.children)
  11912. );
  11913. }
  11914. }
  11915. function getConstantType(node, context) {
  11916. const { constantCache } = context;
  11917. switch (node.type) {
  11918. case 1:
  11919. if (node.tagType !== 0) {
  11920. return 0;
  11921. }
  11922. const cached = constantCache.get(node);
  11923. if (cached !== void 0) {
  11924. return cached;
  11925. }
  11926. const codegenNode = node.codegenNode;
  11927. if (codegenNode.type !== 13) {
  11928. return 0;
  11929. }
  11930. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
  11931. return 0;
  11932. }
  11933. const flag = getPatchFlag(codegenNode);
  11934. if (!flag) {
  11935. let returnType2 = 3;
  11936. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  11937. if (generatedPropsType === 0) {
  11938. constantCache.set(node, 0);
  11939. return 0;
  11940. }
  11941. if (generatedPropsType < returnType2) {
  11942. returnType2 = generatedPropsType;
  11943. }
  11944. for (let i = 0; i < node.children.length; i++) {
  11945. const childType = getConstantType(node.children[i], context);
  11946. if (childType === 0) {
  11947. constantCache.set(node, 0);
  11948. return 0;
  11949. }
  11950. if (childType < returnType2) {
  11951. returnType2 = childType;
  11952. }
  11953. }
  11954. if (returnType2 > 1) {
  11955. for (let i = 0; i < node.props.length; i++) {
  11956. const p = node.props[i];
  11957. if (p.type === 7 && p.name === "bind" && p.exp) {
  11958. const expType = getConstantType(p.exp, context);
  11959. if (expType === 0) {
  11960. constantCache.set(node, 0);
  11961. return 0;
  11962. }
  11963. if (expType < returnType2) {
  11964. returnType2 = expType;
  11965. }
  11966. }
  11967. }
  11968. }
  11969. if (codegenNode.isBlock) {
  11970. for (let i = 0; i < node.props.length; i++) {
  11971. const p = node.props[i];
  11972. if (p.type === 7) {
  11973. constantCache.set(node, 0);
  11974. return 0;
  11975. }
  11976. }
  11977. context.removeHelper(OPEN_BLOCK);
  11978. context.removeHelper(
  11979. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  11980. );
  11981. codegenNode.isBlock = false;
  11982. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  11983. }
  11984. constantCache.set(node, returnType2);
  11985. return returnType2;
  11986. } else {
  11987. constantCache.set(node, 0);
  11988. return 0;
  11989. }
  11990. case 2:
  11991. case 3:
  11992. return 3;
  11993. case 9:
  11994. case 11:
  11995. case 10:
  11996. return 0;
  11997. case 5:
  11998. case 12:
  11999. return getConstantType(node.content, context);
  12000. case 4:
  12001. return node.constType;
  12002. case 8:
  12003. let returnType = 3;
  12004. for (let i = 0; i < node.children.length; i++) {
  12005. const child = node.children[i];
  12006. if (isString(child) || isSymbol(child)) {
  12007. continue;
  12008. }
  12009. const childType = getConstantType(child, context);
  12010. if (childType === 0) {
  12011. return 0;
  12012. } else if (childType < returnType) {
  12013. returnType = childType;
  12014. }
  12015. }
  12016. return returnType;
  12017. default:
  12018. return 0;
  12019. }
  12020. }
  12021. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  12022. NORMALIZE_CLASS,
  12023. NORMALIZE_STYLE,
  12024. NORMALIZE_PROPS,
  12025. GUARD_REACTIVE_PROPS
  12026. ]);
  12027. function getConstantTypeOfHelperCall(value, context) {
  12028. if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  12029. const arg = value.arguments[0];
  12030. if (arg.type === 4) {
  12031. return getConstantType(arg, context);
  12032. } else if (arg.type === 14) {
  12033. return getConstantTypeOfHelperCall(arg, context);
  12034. }
  12035. }
  12036. return 0;
  12037. }
  12038. function getGeneratedPropsConstantType(node, context) {
  12039. let returnType = 3;
  12040. const props = getNodeProps(node);
  12041. if (props && props.type === 15) {
  12042. const { properties } = props;
  12043. for (let i = 0; i < properties.length; i++) {
  12044. const { key, value } = properties[i];
  12045. const keyType = getConstantType(key, context);
  12046. if (keyType === 0) {
  12047. return keyType;
  12048. }
  12049. if (keyType < returnType) {
  12050. returnType = keyType;
  12051. }
  12052. let valueType;
  12053. if (value.type === 4) {
  12054. valueType = getConstantType(value, context);
  12055. } else if (value.type === 14) {
  12056. valueType = getConstantTypeOfHelperCall(value, context);
  12057. } else {
  12058. valueType = 0;
  12059. }
  12060. if (valueType === 0) {
  12061. return valueType;
  12062. }
  12063. if (valueType < returnType) {
  12064. returnType = valueType;
  12065. }
  12066. }
  12067. }
  12068. return returnType;
  12069. }
  12070. function getNodeProps(node) {
  12071. const codegenNode = node.codegenNode;
  12072. if (codegenNode.type === 13) {
  12073. return codegenNode.props;
  12074. }
  12075. }
  12076. function getPatchFlag(node) {
  12077. const flag = node.patchFlag;
  12078. return flag ? parseInt(flag, 10) : void 0;
  12079. }
  12080.  
  12081. function createTransformContext(root, {
  12082. filename = "",
  12083. prefixIdentifiers = false,
  12084. hoistStatic: hoistStatic2 = false,
  12085. cacheHandlers = false,
  12086. nodeTransforms = [],
  12087. directiveTransforms = {},
  12088. transformHoist = null,
  12089. isBuiltInComponent = NOOP,
  12090. isCustomElement = NOOP,
  12091. expressionPlugins = [],
  12092. scopeId = null,
  12093. slotted = true,
  12094. ssr = false,
  12095. inSSR = false,
  12096. ssrCssVars = ``,
  12097. bindingMetadata = EMPTY_OBJ,
  12098. inline = false,
  12099. isTS = false,
  12100. onError = defaultOnError,
  12101. onWarn = defaultOnWarn,
  12102. compatConfig
  12103. }) {
  12104. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  12105. const context = {
  12106. // options
  12107. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  12108. prefixIdentifiers,
  12109. hoistStatic: hoistStatic2,
  12110. cacheHandlers,
  12111. nodeTransforms,
  12112. directiveTransforms,
  12113. transformHoist,
  12114. isBuiltInComponent,
  12115. isCustomElement,
  12116. expressionPlugins,
  12117. scopeId,
  12118. slotted,
  12119. ssr,
  12120. inSSR,
  12121. ssrCssVars,
  12122. bindingMetadata,
  12123. inline,
  12124. isTS,
  12125. onError,
  12126. onWarn,
  12127. compatConfig,
  12128. // state
  12129. root,
  12130. helpers: /* @__PURE__ */ new Map(),
  12131. components: /* @__PURE__ */ new Set(),
  12132. directives: /* @__PURE__ */ new Set(),
  12133. hoists: [],
  12134. imports: [],
  12135. constantCache: /* @__PURE__ */ new Map(),
  12136. temps: 0,
  12137. cached: 0,
  12138. identifiers: /* @__PURE__ */ Object.create(null),
  12139. scopes: {
  12140. vFor: 0,
  12141. vSlot: 0,
  12142. vPre: 0,
  12143. vOnce: 0
  12144. },
  12145. parent: null,
  12146. currentNode: root,
  12147. childIndex: 0,
  12148. inVOnce: false,
  12149. // methods
  12150. helper(name) {
  12151. const count = context.helpers.get(name) || 0;
  12152. context.helpers.set(name, count + 1);
  12153. return name;
  12154. },
  12155. removeHelper(name) {
  12156. const count = context.helpers.get(name);
  12157. if (count) {
  12158. const currentCount = count - 1;
  12159. if (!currentCount) {
  12160. context.helpers.delete(name);
  12161. } else {
  12162. context.helpers.set(name, currentCount);
  12163. }
  12164. }
  12165. },
  12166. helperString(name) {
  12167. return `_${helperNameMap[context.helper(name)]}`;
  12168. },
  12169. replaceNode(node) {
  12170. {
  12171. if (!context.currentNode) {
  12172. throw new Error(`Node being replaced is already removed.`);
  12173. }
  12174. if (!context.parent) {
  12175. throw new Error(`Cannot replace root node.`);
  12176. }
  12177. }
  12178. context.parent.children[context.childIndex] = context.currentNode = node;
  12179. },
  12180. removeNode(node) {
  12181. if (!context.parent) {
  12182. throw new Error(`Cannot remove root node.`);
  12183. }
  12184. const list = context.parent.children;
  12185. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  12186. if (removalIndex < 0) {
  12187. throw new Error(`node being removed is not a child of current parent`);
  12188. }
  12189. if (!node || node === context.currentNode) {
  12190. context.currentNode = null;
  12191. context.onNodeRemoved();
  12192. } else {
  12193. if (context.childIndex > removalIndex) {
  12194. context.childIndex--;
  12195. context.onNodeRemoved();
  12196. }
  12197. }
  12198. context.parent.children.splice(removalIndex, 1);
  12199. },
  12200. onNodeRemoved: () => {
  12201. },
  12202. addIdentifiers(exp) {
  12203. },
  12204. removeIdentifiers(exp) {
  12205. },
  12206. hoist(exp) {
  12207. if (isString(exp))
  12208. exp = createSimpleExpression(exp);
  12209. context.hoists.push(exp);
  12210. const identifier = createSimpleExpression(
  12211. `_hoisted_${context.hoists.length}`,
  12212. false,
  12213. exp.loc,
  12214. 2
  12215. );
  12216. identifier.hoisted = exp;
  12217. return identifier;
  12218. },
  12219. cache(exp, isVNode = false) {
  12220. return createCacheExpression(context.cached++, exp, isVNode);
  12221. }
  12222. };
  12223. return context;
  12224. }
  12225. function transform(root, options) {
  12226. const context = createTransformContext(root, options);
  12227. traverseNode(root, context);
  12228. if (options.hoistStatic) {
  12229. hoistStatic(root, context);
  12230. }
  12231. if (!options.ssr) {
  12232. createRootCodegen(root, context);
  12233. }
  12234. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  12235. root.components = [...context.components];
  12236. root.directives = [...context.directives];
  12237. root.imports = context.imports;
  12238. root.hoists = context.hoists;
  12239. root.temps = context.temps;
  12240. root.cached = context.cached;
  12241. }
  12242. function createRootCodegen(root, context) {
  12243. const { helper } = context;
  12244. const { children } = root;
  12245. if (children.length === 1) {
  12246. const child = children[0];
  12247. if (isSingleElementRoot(root, child) && child.codegenNode) {
  12248. const codegenNode = child.codegenNode;
  12249. if (codegenNode.type === 13) {
  12250. convertToBlock(codegenNode, context);
  12251. }
  12252. root.codegenNode = codegenNode;
  12253. } else {
  12254. root.codegenNode = child;
  12255. }
  12256. } else if (children.length > 1) {
  12257. let patchFlag = 64;
  12258. let patchFlagText = PatchFlagNames[64];
  12259. if (children.filter((c) => c.type !== 3).length === 1) {
  12260. patchFlag |= 2048;
  12261. patchFlagText += `, ${PatchFlagNames[2048]}`;
  12262. }
  12263. root.codegenNode = createVNodeCall(
  12264. context,
  12265. helper(FRAGMENT),
  12266. void 0,
  12267. root.children,
  12268. patchFlag + (` /* ${patchFlagText} */` ),
  12269. void 0,
  12270. void 0,
  12271. true,
  12272. void 0,
  12273. false
  12274. /* isComponent */
  12275. );
  12276. } else ;
  12277. }
  12278. function traverseChildren(parent, context) {
  12279. let i = 0;
  12280. const nodeRemoved = () => {
  12281. i--;
  12282. };
  12283. for (; i < parent.children.length; i++) {
  12284. const child = parent.children[i];
  12285. if (isString(child))
  12286. continue;
  12287. context.parent = parent;
  12288. context.childIndex = i;
  12289. context.onNodeRemoved = nodeRemoved;
  12290. traverseNode(child, context);
  12291. }
  12292. }
  12293. function traverseNode(node, context) {
  12294. context.currentNode = node;
  12295. const { nodeTransforms } = context;
  12296. const exitFns = [];
  12297. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  12298. const onExit = nodeTransforms[i2](node, context);
  12299. if (onExit) {
  12300. if (isArray(onExit)) {
  12301. exitFns.push(...onExit);
  12302. } else {
  12303. exitFns.push(onExit);
  12304. }
  12305. }
  12306. if (!context.currentNode) {
  12307. return;
  12308. } else {
  12309. node = context.currentNode;
  12310. }
  12311. }
  12312. switch (node.type) {
  12313. case 3:
  12314. if (!context.ssr) {
  12315. context.helper(CREATE_COMMENT);
  12316. }
  12317. break;
  12318. case 5:
  12319. if (!context.ssr) {
  12320. context.helper(TO_DISPLAY_STRING);
  12321. }
  12322. break;
  12323. case 9:
  12324. for (let i2 = 0; i2 < node.branches.length; i2++) {
  12325. traverseNode(node.branches[i2], context);
  12326. }
  12327. break;
  12328. case 10:
  12329. case 11:
  12330. case 1:
  12331. case 0:
  12332. traverseChildren(node, context);
  12333. break;
  12334. }
  12335. context.currentNode = node;
  12336. let i = exitFns.length;
  12337. while (i--) {
  12338. exitFns[i]();
  12339. }
  12340. }
  12341. function createStructuralDirectiveTransform(name, fn) {
  12342. const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
  12343. return (node, context) => {
  12344. if (node.type === 1) {
  12345. const { props } = node;
  12346. if (node.tagType === 3 && props.some(isVSlot)) {
  12347. return;
  12348. }
  12349. const exitFns = [];
  12350. for (let i = 0; i < props.length; i++) {
  12351. const prop = props[i];
  12352. if (prop.type === 7 && matches(prop.name)) {
  12353. props.splice(i, 1);
  12354. i--;
  12355. const onExit = fn(node, prop, context);
  12356. if (onExit)
  12357. exitFns.push(onExit);
  12358. }
  12359. }
  12360. return exitFns;
  12361. }
  12362. };
  12363. }
  12364.  
  12365. const PURE_ANNOTATION = `/*#__PURE__*/`;
  12366. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  12367. function createCodegenContext(ast, {
  12368. mode = "function",
  12369. prefixIdentifiers = mode === "module",
  12370. sourceMap = false,
  12371. filename = `template.vue.html`,
  12372. scopeId = null,
  12373. optimizeImports = false,
  12374. runtimeGlobalName = `Vue`,
  12375. runtimeModuleName = `vue`,
  12376. ssrRuntimeModuleName = "vue/server-renderer",
  12377. ssr = false,
  12378. isTS = false,
  12379. inSSR = false
  12380. }) {
  12381. const context = {
  12382. mode,
  12383. prefixIdentifiers,
  12384. sourceMap,
  12385. filename,
  12386. scopeId,
  12387. optimizeImports,
  12388. runtimeGlobalName,
  12389. runtimeModuleName,
  12390. ssrRuntimeModuleName,
  12391. ssr,
  12392. isTS,
  12393. inSSR,
  12394. source: ast.loc.source,
  12395. code: ``,
  12396. column: 1,
  12397. line: 1,
  12398. offset: 0,
  12399. indentLevel: 0,
  12400. pure: false,
  12401. map: void 0,
  12402. helper(key) {
  12403. return `_${helperNameMap[key]}`;
  12404. },
  12405. push(code, node) {
  12406. context.code += code;
  12407. },
  12408. indent() {
  12409. newline(++context.indentLevel);
  12410. },
  12411. deindent(withoutNewLine = false) {
  12412. if (withoutNewLine) {
  12413. --context.indentLevel;
  12414. } else {
  12415. newline(--context.indentLevel);
  12416. }
  12417. },
  12418. newline() {
  12419. newline(context.indentLevel);
  12420. }
  12421. };
  12422. function newline(n) {
  12423. context.push("\n" + ` `.repeat(n));
  12424. }
  12425. return context;
  12426. }
  12427. function generate(ast, options = {}) {
  12428. const context = createCodegenContext(ast, options);
  12429. if (options.onContextCreated)
  12430. options.onContextCreated(context);
  12431. const {
  12432. mode,
  12433. push,
  12434. prefixIdentifiers,
  12435. indent,
  12436. deindent,
  12437. newline,
  12438. scopeId,
  12439. ssr
  12440. } = context;
  12441. const helpers = Array.from(ast.helpers);
  12442. const hasHelpers = helpers.length > 0;
  12443. const useWithBlock = !prefixIdentifiers && mode !== "module";
  12444. const isSetupInlined = false;
  12445. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  12446. {
  12447. genFunctionPreamble(ast, preambleContext);
  12448. }
  12449. const functionName = ssr ? `ssrRender` : `render`;
  12450. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  12451. const signature = args.join(", ");
  12452. {
  12453. push(`function ${functionName}(${signature}) {`);
  12454. }
  12455. indent();
  12456. if (useWithBlock) {
  12457. push(`with (_ctx) {`);
  12458. indent();
  12459. if (hasHelpers) {
  12460. push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
  12461. push(`
  12462. `);
  12463. newline();
  12464. }
  12465. }
  12466. if (ast.components.length) {
  12467. genAssets(ast.components, "component", context);
  12468. if (ast.directives.length || ast.temps > 0) {
  12469. newline();
  12470. }
  12471. }
  12472. if (ast.directives.length) {
  12473. genAssets(ast.directives, "directive", context);
  12474. if (ast.temps > 0) {
  12475. newline();
  12476. }
  12477. }
  12478. if (ast.temps > 0) {
  12479. push(`let `);
  12480. for (let i = 0; i < ast.temps; i++) {
  12481. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  12482. }
  12483. }
  12484. if (ast.components.length || ast.directives.length || ast.temps) {
  12485. push(`
  12486. `);
  12487. newline();
  12488. }
  12489. if (!ssr) {
  12490. push(`return `);
  12491. }
  12492. if (ast.codegenNode) {
  12493. genNode(ast.codegenNode, context);
  12494. } else {
  12495. push(`null`);
  12496. }
  12497. if (useWithBlock) {
  12498. deindent();
  12499. push(`}`);
  12500. }
  12501. deindent();
  12502. push(`}`);
  12503. return {
  12504. ast,
  12505. code: context.code,
  12506. preamble: isSetupInlined ? preambleContext.code : ``,
  12507. // SourceMapGenerator does have toJSON() method but it's not in the types
  12508. map: context.map ? context.map.toJSON() : void 0
  12509. };
  12510. }
  12511. function genFunctionPreamble(ast, context) {
  12512. const {
  12513. ssr,
  12514. prefixIdentifiers,
  12515. push,
  12516. newline,
  12517. runtimeModuleName,
  12518. runtimeGlobalName,
  12519. ssrRuntimeModuleName
  12520. } = context;
  12521. const VueBinding = runtimeGlobalName;
  12522. const helpers = Array.from(ast.helpers);
  12523. if (helpers.length > 0) {
  12524. {
  12525. push(`const _Vue = ${VueBinding}
  12526. `);
  12527. if (ast.hoists.length) {
  12528. const staticHelpers = [
  12529. CREATE_VNODE,
  12530. CREATE_ELEMENT_VNODE,
  12531. CREATE_COMMENT,
  12532. CREATE_TEXT,
  12533. CREATE_STATIC
  12534. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  12535. push(`const { ${staticHelpers} } = _Vue
  12536. `);
  12537. }
  12538. }
  12539. }
  12540. genHoists(ast.hoists, context);
  12541. newline();
  12542. push(`return `);
  12543. }
  12544. function genAssets(assets, type, { helper, push, newline, isTS }) {
  12545. const resolver = helper(
  12546. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  12547. );
  12548. for (let i = 0; i < assets.length; i++) {
  12549. let id = assets[i];
  12550. const maybeSelfReference = id.endsWith("__self");
  12551. if (maybeSelfReference) {
  12552. id = id.slice(0, -6);
  12553. }
  12554. push(
  12555. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  12556. );
  12557. if (i < assets.length - 1) {
  12558. newline();
  12559. }
  12560. }
  12561. }
  12562. function genHoists(hoists, context) {
  12563. if (!hoists.length) {
  12564. return;
  12565. }
  12566. context.pure = true;
  12567. const { push, newline, helper, scopeId, mode } = context;
  12568. newline();
  12569. for (let i = 0; i < hoists.length; i++) {
  12570. const exp = hoists[i];
  12571. if (exp) {
  12572. push(
  12573. `const _hoisted_${i + 1} = ${``}`
  12574. );
  12575. genNode(exp, context);
  12576. newline();
  12577. }
  12578. }
  12579. context.pure = false;
  12580. }
  12581. function isText(n) {
  12582. return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  12583. }
  12584. function genNodeListAsArray(nodes, context) {
  12585. const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
  12586. context.push(`[`);
  12587. multilines && context.indent();
  12588. genNodeList(nodes, context, multilines);
  12589. multilines && context.deindent();
  12590. context.push(`]`);
  12591. }
  12592. function genNodeList(nodes, context, multilines = false, comma = true) {
  12593. const { push, newline } = context;
  12594. for (let i = 0; i < nodes.length; i++) {
  12595. const node = nodes[i];
  12596. if (isString(node)) {
  12597. push(node);
  12598. } else if (isArray(node)) {
  12599. genNodeListAsArray(node, context);
  12600. } else {
  12601. genNode(node, context);
  12602. }
  12603. if (i < nodes.length - 1) {
  12604. if (multilines) {
  12605. comma && push(",");
  12606. newline();
  12607. } else {
  12608. comma && push(", ");
  12609. }
  12610. }
  12611. }
  12612. }
  12613. function genNode(node, context) {
  12614. if (isString(node)) {
  12615. context.push(node);
  12616. return;
  12617. }
  12618. if (isSymbol(node)) {
  12619. context.push(context.helper(node));
  12620. return;
  12621. }
  12622. switch (node.type) {
  12623. case 1:
  12624. case 9:
  12625. case 11:
  12626. assert(
  12627. node.codegenNode != null,
  12628. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  12629. );
  12630. genNode(node.codegenNode, context);
  12631. break;
  12632. case 2:
  12633. genText(node, context);
  12634. break;
  12635. case 4:
  12636. genExpression(node, context);
  12637. break;
  12638. case 5:
  12639. genInterpolation(node, context);
  12640. break;
  12641. case 12:
  12642. genNode(node.codegenNode, context);
  12643. break;
  12644. case 8:
  12645. genCompoundExpression(node, context);
  12646. break;
  12647. case 3:
  12648. genComment(node, context);
  12649. break;
  12650. case 13:
  12651. genVNodeCall(node, context);
  12652. break;
  12653. case 14:
  12654. genCallExpression(node, context);
  12655. break;
  12656. case 15:
  12657. genObjectExpression(node, context);
  12658. break;
  12659. case 17:
  12660. genArrayExpression(node, context);
  12661. break;
  12662. case 18:
  12663. genFunctionExpression(node, context);
  12664. break;
  12665. case 19:
  12666. genConditionalExpression(node, context);
  12667. break;
  12668. case 20:
  12669. genCacheExpression(node, context);
  12670. break;
  12671. case 21:
  12672. genNodeList(node.body, context, true, false);
  12673. break;
  12674. case 22:
  12675. break;
  12676. case 23:
  12677. break;
  12678. case 24:
  12679. break;
  12680. case 25:
  12681. break;
  12682. case 26:
  12683. break;
  12684. case 10:
  12685. break;
  12686. default:
  12687. {
  12688. assert(false, `unhandled codegen node type: ${node.type}`);
  12689. const exhaustiveCheck = node;
  12690. return exhaustiveCheck;
  12691. }
  12692. }
  12693. }
  12694. function genText(node, context) {
  12695. context.push(JSON.stringify(node.content), node);
  12696. }
  12697. function genExpression(node, context) {
  12698. const { content, isStatic } = node;
  12699. context.push(isStatic ? JSON.stringify(content) : content, node);
  12700. }
  12701. function genInterpolation(node, context) {
  12702. const { push, helper, pure } = context;
  12703. if (pure)
  12704. push(PURE_ANNOTATION);
  12705. push(`${helper(TO_DISPLAY_STRING)}(`);
  12706. genNode(node.content, context);
  12707. push(`)`);
  12708. }
  12709. function genCompoundExpression(node, context) {
  12710. for (let i = 0; i < node.children.length; i++) {
  12711. const child = node.children[i];
  12712. if (isString(child)) {
  12713. context.push(child);
  12714. } else {
  12715. genNode(child, context);
  12716. }
  12717. }
  12718. }
  12719. function genExpressionAsPropertyKey(node, context) {
  12720. const { push } = context;
  12721. if (node.type === 8) {
  12722. push(`[`);
  12723. genCompoundExpression(node, context);
  12724. push(`]`);
  12725. } else if (node.isStatic) {
  12726. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  12727. push(text, node);
  12728. } else {
  12729. push(`[${node.content}]`, node);
  12730. }
  12731. }
  12732. function genComment(node, context) {
  12733. const { push, helper, pure } = context;
  12734. if (pure) {
  12735. push(PURE_ANNOTATION);
  12736. }
  12737. push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
  12738. }
  12739. function genVNodeCall(node, context) {
  12740. const { push, helper, pure } = context;
  12741. const {
  12742. tag,
  12743. props,
  12744. children,
  12745. patchFlag,
  12746. dynamicProps,
  12747. directives,
  12748. isBlock,
  12749. disableTracking,
  12750. isComponent
  12751. } = node;
  12752. if (directives) {
  12753. push(helper(WITH_DIRECTIVES) + `(`);
  12754. }
  12755. if (isBlock) {
  12756. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  12757. }
  12758. if (pure) {
  12759. push(PURE_ANNOTATION);
  12760. }
  12761. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  12762. push(helper(callHelper) + `(`, node);
  12763. genNodeList(
  12764. genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
  12765. context
  12766. );
  12767. push(`)`);
  12768. if (isBlock) {
  12769. push(`)`);
  12770. }
  12771. if (directives) {
  12772. push(`, `);
  12773. genNode(directives, context);
  12774. push(`)`);
  12775. }
  12776. }
  12777. function genNullableArgs(args) {
  12778. let i = args.length;
  12779. while (i--) {
  12780. if (args[i] != null)
  12781. break;
  12782. }
  12783. return args.slice(0, i + 1).map((arg) => arg || `null`);
  12784. }
  12785. function genCallExpression(node, context) {
  12786. const { push, helper, pure } = context;
  12787. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  12788. if (pure) {
  12789. push(PURE_ANNOTATION);
  12790. }
  12791. push(callee + `(`, node);
  12792. genNodeList(node.arguments, context);
  12793. push(`)`);
  12794. }
  12795. function genObjectExpression(node, context) {
  12796. const { push, indent, deindent, newline } = context;
  12797. const { properties } = node;
  12798. if (!properties.length) {
  12799. push(`{}`, node);
  12800. return;
  12801. }
  12802. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  12803. push(multilines ? `{` : `{ `);
  12804. multilines && indent();
  12805. for (let i = 0; i < properties.length; i++) {
  12806. const { key, value } = properties[i];
  12807. genExpressionAsPropertyKey(key, context);
  12808. push(`: `);
  12809. genNode(value, context);
  12810. if (i < properties.length - 1) {
  12811. push(`,`);
  12812. newline();
  12813. }
  12814. }
  12815. multilines && deindent();
  12816. push(multilines ? `}` : ` }`);
  12817. }
  12818. function genArrayExpression(node, context) {
  12819. genNodeListAsArray(node.elements, context);
  12820. }
  12821. function genFunctionExpression(node, context) {
  12822. const { push, indent, deindent } = context;
  12823. const { params, returns, body, newline, isSlot } = node;
  12824. if (isSlot) {
  12825. push(`_${helperNameMap[WITH_CTX]}(`);
  12826. }
  12827. push(`(`, node);
  12828. if (isArray(params)) {
  12829. genNodeList(params, context);
  12830. } else if (params) {
  12831. genNode(params, context);
  12832. }
  12833. push(`) => `);
  12834. if (newline || body) {
  12835. push(`{`);
  12836. indent();
  12837. }
  12838. if (returns) {
  12839. if (newline) {
  12840. push(`return `);
  12841. }
  12842. if (isArray(returns)) {
  12843. genNodeListAsArray(returns, context);
  12844. } else {
  12845. genNode(returns, context);
  12846. }
  12847. } else if (body) {
  12848. genNode(body, context);
  12849. }
  12850. if (newline || body) {
  12851. deindent();
  12852. push(`}`);
  12853. }
  12854. if (isSlot) {
  12855. push(`)`);
  12856. }
  12857. }
  12858. function genConditionalExpression(node, context) {
  12859. const { test, consequent, alternate, newline: needNewline } = node;
  12860. const { push, indent, deindent, newline } = context;
  12861. if (test.type === 4) {
  12862. const needsParens = !isSimpleIdentifier(test.content);
  12863. needsParens && push(`(`);
  12864. genExpression(test, context);
  12865. needsParens && push(`)`);
  12866. } else {
  12867. push(`(`);
  12868. genNode(test, context);
  12869. push(`)`);
  12870. }
  12871. needNewline && indent();
  12872. context.indentLevel++;
  12873. needNewline || push(` `);
  12874. push(`? `);
  12875. genNode(consequent, context);
  12876. context.indentLevel--;
  12877. needNewline && newline();
  12878. needNewline || push(` `);
  12879. push(`: `);
  12880. const isNested = alternate.type === 19;
  12881. if (!isNested) {
  12882. context.indentLevel++;
  12883. }
  12884. genNode(alternate, context);
  12885. if (!isNested) {
  12886. context.indentLevel--;
  12887. }
  12888. needNewline && deindent(
  12889. true
  12890. /* without newline */
  12891. );
  12892. }
  12893. function genCacheExpression(node, context) {
  12894. const { push, helper, indent, deindent, newline } = context;
  12895. push(`_cache[${node.index}] || (`);
  12896. if (node.isVNode) {
  12897. indent();
  12898. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  12899. newline();
  12900. }
  12901. push(`_cache[${node.index}] = `);
  12902. genNode(node.value, context);
  12903. if (node.isVNode) {
  12904. push(`,`);
  12905. newline();
  12906. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  12907. newline();
  12908. push(`_cache[${node.index}]`);
  12909. deindent();
  12910. }
  12911. push(`)`);
  12912. }
  12913.  
  12914. const prohibitedKeywordRE = new RegExp(
  12915. "\\b" + "arguments,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,let,new,return,super,switch,throw,try,var,void,while,with,yield".split(",").join("\\b|\\b") + "\\b"
  12916. );
  12917. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  12918. function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
  12919. const exp = node.content;
  12920. if (!exp.trim()) {
  12921. return;
  12922. }
  12923. try {
  12924. new Function(
  12925. asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
  12926. );
  12927. } catch (e) {
  12928. let message = e.message;
  12929. const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
  12930. if (keywordMatch) {
  12931. message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
  12932. }
  12933. context.onError(
  12934. createCompilerError(
  12935. 45,
  12936. node.loc,
  12937. void 0,
  12938. message
  12939. )
  12940. );
  12941. }
  12942. }
  12943.  
  12944. const transformExpression = (node, context) => {
  12945. if (node.type === 5) {
  12946. node.content = processExpression(
  12947. node.content,
  12948. context
  12949. );
  12950. } else if (node.type === 1) {
  12951. for (let i = 0; i < node.props.length; i++) {
  12952. const dir = node.props[i];
  12953. if (dir.type === 7 && dir.name !== "for") {
  12954. const exp = dir.exp;
  12955. const arg = dir.arg;
  12956. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  12957. dir.exp = processExpression(
  12958. exp,
  12959. context,
  12960. // slot args must be processed as function params
  12961. dir.name === "slot"
  12962. );
  12963. }
  12964. if (arg && arg.type === 4 && !arg.isStatic) {
  12965. dir.arg = processExpression(arg, context);
  12966. }
  12967. }
  12968. }
  12969. }
  12970. };
  12971. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  12972. {
  12973. {
  12974. validateBrowserExpression(node, context, asParams, asRawStatements);
  12975. }
  12976. return node;
  12977. }
  12978. }
  12979.  
  12980. const transformIf = createStructuralDirectiveTransform(
  12981. /^(if|else|else-if)$/,
  12982. (node, dir, context) => {
  12983. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  12984. const siblings = context.parent.children;
  12985. let i = siblings.indexOf(ifNode);
  12986. let key = 0;
  12987. while (i-- >= 0) {
  12988. const sibling = siblings[i];
  12989. if (sibling && sibling.type === 9) {
  12990. key += sibling.branches.length;
  12991. }
  12992. }
  12993. return () => {
  12994. if (isRoot) {
  12995. ifNode.codegenNode = createCodegenNodeForBranch(
  12996. branch,
  12997. key,
  12998. context
  12999. );
  13000. } else {
  13001. const parentCondition = getParentCondition(ifNode.codegenNode);
  13002. parentCondition.alternate = createCodegenNodeForBranch(
  13003. branch,
  13004. key + ifNode.branches.length - 1,
  13005. context
  13006. );
  13007. }
  13008. };
  13009. });
  13010. }
  13011. );
  13012. function processIf(node, dir, context, processCodegen) {
  13013. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  13014. const loc = dir.exp ? dir.exp.loc : node.loc;
  13015. context.onError(
  13016. createCompilerError(28, dir.loc)
  13017. );
  13018. dir.exp = createSimpleExpression(`true`, false, loc);
  13019. }
  13020. if (dir.exp) {
  13021. validateBrowserExpression(dir.exp, context);
  13022. }
  13023. if (dir.name === "if") {
  13024. const branch = createIfBranch(node, dir);
  13025. const ifNode = {
  13026. type: 9,
  13027. loc: node.loc,
  13028. branches: [branch]
  13029. };
  13030. context.replaceNode(ifNode);
  13031. if (processCodegen) {
  13032. return processCodegen(ifNode, branch, true);
  13033. }
  13034. } else {
  13035. const siblings = context.parent.children;
  13036. const comments = [];
  13037. let i = siblings.indexOf(node);
  13038. while (i-- >= -1) {
  13039. const sibling = siblings[i];
  13040. if (sibling && sibling.type === 3) {
  13041. context.removeNode(sibling);
  13042. comments.unshift(sibling);
  13043. continue;
  13044. }
  13045. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  13046. context.removeNode(sibling);
  13047. continue;
  13048. }
  13049. if (sibling && sibling.type === 9) {
  13050. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  13051. context.onError(
  13052. createCompilerError(30, node.loc)
  13053. );
  13054. }
  13055. context.removeNode();
  13056. const branch = createIfBranch(node, dir);
  13057. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  13058. !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
  13059. branch.children = [...comments, ...branch.children];
  13060. }
  13061. {
  13062. const key = branch.userKey;
  13063. if (key) {
  13064. sibling.branches.forEach(({ userKey }) => {
  13065. if (isSameKey(userKey, key)) {
  13066. context.onError(
  13067. createCompilerError(
  13068. 29,
  13069. branch.userKey.loc
  13070. )
  13071. );
  13072. }
  13073. });
  13074. }
  13075. }
  13076. sibling.branches.push(branch);
  13077. const onExit = processCodegen && processCodegen(sibling, branch, false);
  13078. traverseNode(branch, context);
  13079. if (onExit)
  13080. onExit();
  13081. context.currentNode = null;
  13082. } else {
  13083. context.onError(
  13084. createCompilerError(30, node.loc)
  13085. );
  13086. }
  13087. break;
  13088. }
  13089. }
  13090. }
  13091. function createIfBranch(node, dir) {
  13092. const isTemplateIf = node.tagType === 3;
  13093. return {
  13094. type: 10,
  13095. loc: node.loc,
  13096. condition: dir.name === "else" ? void 0 : dir.exp,
  13097. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  13098. userKey: findProp(node, `key`),
  13099. isTemplateIf
  13100. };
  13101. }
  13102. function createCodegenNodeForBranch(branch, keyIndex, context) {
  13103. if (branch.condition) {
  13104. return createConditionalExpression(
  13105. branch.condition,
  13106. createChildrenCodegenNode(branch, keyIndex, context),
  13107. // make sure to pass in asBlock: true so that the comment node call
  13108. // closes the current block.
  13109. createCallExpression(context.helper(CREATE_COMMENT), [
  13110. '"v-if"' ,
  13111. "true"
  13112. ])
  13113. );
  13114. } else {
  13115. return createChildrenCodegenNode(branch, keyIndex, context);
  13116. }
  13117. }
  13118. function createChildrenCodegenNode(branch, keyIndex, context) {
  13119. const { helper } = context;
  13120. const keyProperty = createObjectProperty(
  13121. `key`,
  13122. createSimpleExpression(
  13123. `${keyIndex}`,
  13124. false,
  13125. locStub,
  13126. 2
  13127. )
  13128. );
  13129. const { children } = branch;
  13130. const firstChild = children[0];
  13131. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  13132. if (needFragmentWrapper) {
  13133. if (children.length === 1 && firstChild.type === 11) {
  13134. const vnodeCall = firstChild.codegenNode;
  13135. injectProp(vnodeCall, keyProperty, context);
  13136. return vnodeCall;
  13137. } else {
  13138. let patchFlag = 64;
  13139. let patchFlagText = PatchFlagNames[64];
  13140. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  13141. patchFlag |= 2048;
  13142. patchFlagText += `, ${PatchFlagNames[2048]}`;
  13143. }
  13144. return createVNodeCall(
  13145. context,
  13146. helper(FRAGMENT),
  13147. createObjectExpression([keyProperty]),
  13148. children,
  13149. patchFlag + (` /* ${patchFlagText} */` ),
  13150. void 0,
  13151. void 0,
  13152. true,
  13153. false,
  13154. false,
  13155. branch.loc
  13156. );
  13157. }
  13158. } else {
  13159. const ret = firstChild.codegenNode;
  13160. const vnodeCall = getMemoedVNodeCall(ret);
  13161. if (vnodeCall.type === 13) {
  13162. convertToBlock(vnodeCall, context);
  13163. }
  13164. injectProp(vnodeCall, keyProperty, context);
  13165. return ret;
  13166. }
  13167. }
  13168. function isSameKey(a, b) {
  13169. if (!a || a.type !== b.type) {
  13170. return false;
  13171. }
  13172. if (a.type === 6) {
  13173. if (a.value.content !== b.value.content) {
  13174. return false;
  13175. }
  13176. } else {
  13177. const exp = a.exp;
  13178. const branchExp = b.exp;
  13179. if (exp.type !== branchExp.type) {
  13180. return false;
  13181. }
  13182. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  13183. return false;
  13184. }
  13185. }
  13186. return true;
  13187. }
  13188. function getParentCondition(node) {
  13189. while (true) {
  13190. if (node.type === 19) {
  13191. if (node.alternate.type === 19) {
  13192. node = node.alternate;
  13193. } else {
  13194. return node;
  13195. }
  13196. } else if (node.type === 20) {
  13197. node = node.value;
  13198. }
  13199. }
  13200. }
  13201.  
  13202. const transformFor = createStructuralDirectiveTransform(
  13203. "for",
  13204. (node, dir, context) => {
  13205. const { helper, removeHelper } = context;
  13206. return processFor(node, dir, context, (forNode) => {
  13207. const renderExp = createCallExpression(helper(RENDER_LIST), [
  13208. forNode.source
  13209. ]);
  13210. const isTemplate = isTemplateNode(node);
  13211. const memo = findDir(node, "memo");
  13212. const keyProp = findProp(node, `key`);
  13213. const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
  13214. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  13215. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  13216. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  13217. forNode.codegenNode = createVNodeCall(
  13218. context,
  13219. helper(FRAGMENT),
  13220. void 0,
  13221. renderExp,
  13222. fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
  13223. void 0,
  13224. void 0,
  13225. true,
  13226. !isStableFragment,
  13227. false,
  13228. node.loc
  13229. );
  13230. return () => {
  13231. let childBlock;
  13232. const { children } = forNode;
  13233. if (isTemplate) {
  13234. node.children.some((c) => {
  13235. if (c.type === 1) {
  13236. const key = findProp(c, "key");
  13237. if (key) {
  13238. context.onError(
  13239. createCompilerError(
  13240. 33,
  13241. key.loc
  13242. )
  13243. );
  13244. return true;
  13245. }
  13246. }
  13247. });
  13248. }
  13249. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  13250. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  13251. if (slotOutlet) {
  13252. childBlock = slotOutlet.codegenNode;
  13253. if (isTemplate && keyProperty) {
  13254. injectProp(childBlock, keyProperty, context);
  13255. }
  13256. } else if (needFragmentWrapper) {
  13257. childBlock = createVNodeCall(
  13258. context,
  13259. helper(FRAGMENT),
  13260. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  13261. node.children,
  13262. 64 + (` /* ${PatchFlagNames[64]} */` ),
  13263. void 0,
  13264. void 0,
  13265. true,
  13266. void 0,
  13267. false
  13268. /* isComponent */
  13269. );
  13270. } else {
  13271. childBlock = children[0].codegenNode;
  13272. if (isTemplate && keyProperty) {
  13273. injectProp(childBlock, keyProperty, context);
  13274. }
  13275. if (childBlock.isBlock !== !isStableFragment) {
  13276. if (childBlock.isBlock) {
  13277. removeHelper(OPEN_BLOCK);
  13278. removeHelper(
  13279. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  13280. );
  13281. } else {
  13282. removeHelper(
  13283. getVNodeHelper(context.inSSR, childBlock.isComponent)
  13284. );
  13285. }
  13286. }
  13287. childBlock.isBlock = !isStableFragment;
  13288. if (childBlock.isBlock) {
  13289. helper(OPEN_BLOCK);
  13290. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  13291. } else {
  13292. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  13293. }
  13294. }
  13295. if (memo) {
  13296. const loop = createFunctionExpression(
  13297. createForLoopParams(forNode.parseResult, [
  13298. createSimpleExpression(`_cached`)
  13299. ])
  13300. );
  13301. loop.body = createBlockStatement([
  13302. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  13303. createCompoundExpression([
  13304. `if (_cached`,
  13305. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  13306. ` && ${context.helperString(
  13307. IS_MEMO_SAME
  13308. )}(_cached, _memo)) return _cached`
  13309. ]),
  13310. createCompoundExpression([`const _item = `, childBlock]),
  13311. createSimpleExpression(`_item.memo = _memo`),
  13312. createSimpleExpression(`return _item`)
  13313. ]);
  13314. renderExp.arguments.push(
  13315. loop,
  13316. createSimpleExpression(`_cache`),
  13317. createSimpleExpression(String(context.cached++))
  13318. );
  13319. } else {
  13320. renderExp.arguments.push(
  13321. createFunctionExpression(
  13322. createForLoopParams(forNode.parseResult),
  13323. childBlock,
  13324. true
  13325. /* force newline */
  13326. )
  13327. );
  13328. }
  13329. };
  13330. });
  13331. }
  13332. );
  13333. function processFor(node, dir, context, processCodegen) {
  13334. if (!dir.exp) {
  13335. context.onError(
  13336. createCompilerError(31, dir.loc)
  13337. );
  13338. return;
  13339. }
  13340. const parseResult = parseForExpression(
  13341. // can only be simple expression because vFor transform is applied
  13342. // before expression transform.
  13343. dir.exp,
  13344. context
  13345. );
  13346. if (!parseResult) {
  13347. context.onError(
  13348. createCompilerError(32, dir.loc)
  13349. );
  13350. return;
  13351. }
  13352. const { addIdentifiers, removeIdentifiers, scopes } = context;
  13353. const { source, value, key, index } = parseResult;
  13354. const forNode = {
  13355. type: 11,
  13356. loc: dir.loc,
  13357. source,
  13358. valueAlias: value,
  13359. keyAlias: key,
  13360. objectIndexAlias: index,
  13361. parseResult,
  13362. children: isTemplateNode(node) ? node.children : [node]
  13363. };
  13364. context.replaceNode(forNode);
  13365. scopes.vFor++;
  13366. const onExit = processCodegen && processCodegen(forNode);
  13367. return () => {
  13368. scopes.vFor--;
  13369. if (onExit)
  13370. onExit();
  13371. };
  13372. }
  13373. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  13374. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  13375. const stripParensRE = /^\(|\)$/g;
  13376. function parseForExpression(input, context) {
  13377. const loc = input.loc;
  13378. const exp = input.content;
  13379. const inMatch = exp.match(forAliasRE);
  13380. if (!inMatch)
  13381. return;
  13382. const [, LHS, RHS] = inMatch;
  13383. const result = {
  13384. source: createAliasExpression(
  13385. loc,
  13386. RHS.trim(),
  13387. exp.indexOf(RHS, LHS.length)
  13388. ),
  13389. value: void 0,
  13390. key: void 0,
  13391. index: void 0
  13392. };
  13393. {
  13394. validateBrowserExpression(result.source, context);
  13395. }
  13396. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  13397. const trimmedOffset = LHS.indexOf(valueContent);
  13398. const iteratorMatch = valueContent.match(forIteratorRE);
  13399. if (iteratorMatch) {
  13400. valueContent = valueContent.replace(forIteratorRE, "").trim();
  13401. const keyContent = iteratorMatch[1].trim();
  13402. let keyOffset;
  13403. if (keyContent) {
  13404. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  13405. result.key = createAliasExpression(loc, keyContent, keyOffset);
  13406. {
  13407. validateBrowserExpression(
  13408. result.key,
  13409. context,
  13410. true
  13411. );
  13412. }
  13413. }
  13414. if (iteratorMatch[2]) {
  13415. const indexContent = iteratorMatch[2].trim();
  13416. if (indexContent) {
  13417. result.index = createAliasExpression(
  13418. loc,
  13419. indexContent,
  13420. exp.indexOf(
  13421. indexContent,
  13422. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  13423. )
  13424. );
  13425. {
  13426. validateBrowserExpression(
  13427. result.index,
  13428. context,
  13429. true
  13430. );
  13431. }
  13432. }
  13433. }
  13434. }
  13435. if (valueContent) {
  13436. result.value = createAliasExpression(loc, valueContent, trimmedOffset);
  13437. {
  13438. validateBrowserExpression(
  13439. result.value,
  13440. context,
  13441. true
  13442. );
  13443. }
  13444. }
  13445. return result;
  13446. }
  13447. function createAliasExpression(range, content, offset) {
  13448. return createSimpleExpression(
  13449. content,
  13450. false,
  13451. getInnerRange(range, offset, content.length)
  13452. );
  13453. }
  13454. function createForLoopParams({ value, key, index }, memoArgs = []) {
  13455. return createParamsList([value, key, index, ...memoArgs]);
  13456. }
  13457. function createParamsList(args) {
  13458. let i = args.length;
  13459. while (i--) {
  13460. if (args[i])
  13461. break;
  13462. }
  13463. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  13464. }
  13465.  
  13466. const defaultFallback = createSimpleExpression(`undefined`, false);
  13467. const trackSlotScopes = (node, context) => {
  13468. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  13469. const vSlot = findDir(node, "slot");
  13470. if (vSlot) {
  13471. vSlot.exp;
  13472. context.scopes.vSlot++;
  13473. return () => {
  13474. context.scopes.vSlot--;
  13475. };
  13476. }
  13477. }
  13478. };
  13479. const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
  13480. props,
  13481. children,
  13482. false,
  13483. true,
  13484. children.length ? children[0].loc : loc
  13485. );
  13486. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  13487. context.helper(WITH_CTX);
  13488. const { children, loc } = node;
  13489. const slotsProperties = [];
  13490. const dynamicSlots = [];
  13491. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  13492. const onComponentSlot = findDir(node, "slot", true);
  13493. if (onComponentSlot) {
  13494. const { arg, exp } = onComponentSlot;
  13495. if (arg && !isStaticExp(arg)) {
  13496. hasDynamicSlots = true;
  13497. }
  13498. slotsProperties.push(
  13499. createObjectProperty(
  13500. arg || createSimpleExpression("default", true),
  13501. buildSlotFn(exp, children, loc)
  13502. )
  13503. );
  13504. }
  13505. let hasTemplateSlots = false;
  13506. let hasNamedDefaultSlot = false;
  13507. const implicitDefaultChildren = [];
  13508. const seenSlotNames = /* @__PURE__ */ new Set();
  13509. let conditionalBranchIndex = 0;
  13510. for (let i = 0; i < children.length; i++) {
  13511. const slotElement = children[i];
  13512. let slotDir;
  13513. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  13514. if (slotElement.type !== 3) {
  13515. implicitDefaultChildren.push(slotElement);
  13516. }
  13517. continue;
  13518. }
  13519. if (onComponentSlot) {
  13520. context.onError(
  13521. createCompilerError(37, slotDir.loc)
  13522. );
  13523. break;
  13524. }
  13525. hasTemplateSlots = true;
  13526. const { children: slotChildren, loc: slotLoc } = slotElement;
  13527. const {
  13528. arg: slotName = createSimpleExpression(`default`, true),
  13529. exp: slotProps,
  13530. loc: dirLoc
  13531. } = slotDir;
  13532. let staticSlotName;
  13533. if (isStaticExp(slotName)) {
  13534. staticSlotName = slotName ? slotName.content : `default`;
  13535. } else {
  13536. hasDynamicSlots = true;
  13537. }
  13538. const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
  13539. let vIf;
  13540. let vElse;
  13541. let vFor;
  13542. if (vIf = findDir(slotElement, "if")) {
  13543. hasDynamicSlots = true;
  13544. dynamicSlots.push(
  13545. createConditionalExpression(
  13546. vIf.exp,
  13547. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  13548. defaultFallback
  13549. )
  13550. );
  13551. } else if (vElse = findDir(
  13552. slotElement,
  13553. /^else(-if)?$/,
  13554. true
  13555. /* allowEmpty */
  13556. )) {
  13557. let j = i;
  13558. let prev;
  13559. while (j--) {
  13560. prev = children[j];
  13561. if (prev.type !== 3) {
  13562. break;
  13563. }
  13564. }
  13565. if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
  13566. children.splice(i, 1);
  13567. i--;
  13568. let conditional = dynamicSlots[dynamicSlots.length - 1];
  13569. while (conditional.alternate.type === 19) {
  13570. conditional = conditional.alternate;
  13571. }
  13572. conditional.alternate = vElse.exp ? createConditionalExpression(
  13573. vElse.exp,
  13574. buildDynamicSlot(
  13575. slotName,
  13576. slotFunction,
  13577. conditionalBranchIndex++
  13578. ),
  13579. defaultFallback
  13580. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  13581. } else {
  13582. context.onError(
  13583. createCompilerError(30, vElse.loc)
  13584. );
  13585. }
  13586. } else if (vFor = findDir(slotElement, "for")) {
  13587. hasDynamicSlots = true;
  13588. const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
  13589. if (parseResult) {
  13590. dynamicSlots.push(
  13591. createCallExpression(context.helper(RENDER_LIST), [
  13592. parseResult.source,
  13593. createFunctionExpression(
  13594. createForLoopParams(parseResult),
  13595. buildDynamicSlot(slotName, slotFunction),
  13596. true
  13597. /* force newline */
  13598. )
  13599. ])
  13600. );
  13601. } else {
  13602. context.onError(
  13603. createCompilerError(32, vFor.loc)
  13604. );
  13605. }
  13606. } else {
  13607. if (staticSlotName) {
  13608. if (seenSlotNames.has(staticSlotName)) {
  13609. context.onError(
  13610. createCompilerError(
  13611. 38,
  13612. dirLoc
  13613. )
  13614. );
  13615. continue;
  13616. }
  13617. seenSlotNames.add(staticSlotName);
  13618. if (staticSlotName === "default") {
  13619. hasNamedDefaultSlot = true;
  13620. }
  13621. }
  13622. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  13623. }
  13624. }
  13625. if (!onComponentSlot) {
  13626. const buildDefaultSlotProperty = (props, children2) => {
  13627. const fn = buildSlotFn(props, children2, loc);
  13628. return createObjectProperty(`default`, fn);
  13629. };
  13630. if (!hasTemplateSlots) {
  13631. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  13632. } else if (implicitDefaultChildren.length && // #3766
  13633. // with whitespace: 'preserve', whitespaces between slots will end up in
  13634. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  13635. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  13636. if (hasNamedDefaultSlot) {
  13637. context.onError(
  13638. createCompilerError(
  13639. 39,
  13640. implicitDefaultChildren[0].loc
  13641. )
  13642. );
  13643. } else {
  13644. slotsProperties.push(
  13645. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  13646. );
  13647. }
  13648. }
  13649. }
  13650. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  13651. let slots = createObjectExpression(
  13652. slotsProperties.concat(
  13653. createObjectProperty(
  13654. `_`,
  13655. // 2 = compiled but dynamic = can skip normalization, but must run diff
  13656. // 1 = compiled and static = can skip normalization AND diff as optimized
  13657. createSimpleExpression(
  13658. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  13659. false
  13660. )
  13661. )
  13662. ),
  13663. loc
  13664. );
  13665. if (dynamicSlots.length) {
  13666. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  13667. slots,
  13668. createArrayExpression(dynamicSlots)
  13669. ]);
  13670. }
  13671. return {
  13672. slots,
  13673. hasDynamicSlots
  13674. };
  13675. }
  13676. function buildDynamicSlot(name, fn, index) {
  13677. const props = [
  13678. createObjectProperty(`name`, name),
  13679. createObjectProperty(`fn`, fn)
  13680. ];
  13681. if (index != null) {
  13682. props.push(
  13683. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  13684. );
  13685. }
  13686. return createObjectExpression(props);
  13687. }
  13688. function hasForwardedSlots(children) {
  13689. for (let i = 0; i < children.length; i++) {
  13690. const child = children[i];
  13691. switch (child.type) {
  13692. case 1:
  13693. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  13694. return true;
  13695. }
  13696. break;
  13697. case 9:
  13698. if (hasForwardedSlots(child.branches))
  13699. return true;
  13700. break;
  13701. case 10:
  13702. case 11:
  13703. if (hasForwardedSlots(child.children))
  13704. return true;
  13705. break;
  13706. }
  13707. }
  13708. return false;
  13709. }
  13710. function isNonWhitespaceContent(node) {
  13711. if (node.type !== 2 && node.type !== 12)
  13712. return true;
  13713. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  13714. }
  13715.  
  13716. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  13717. const transformElement = (node, context) => {
  13718. return function postTransformElement() {
  13719. node = context.currentNode;
  13720. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  13721. return;
  13722. }
  13723. const { tag, props } = node;
  13724. const isComponent = node.tagType === 1;
  13725. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  13726. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  13727. let vnodeProps;
  13728. let vnodeChildren;
  13729. let vnodePatchFlag;
  13730. let patchFlag = 0;
  13731. let vnodeDynamicProps;
  13732. let dynamicPropNames;
  13733. let vnodeDirectives;
  13734. let shouldUseBlock = (
  13735. // dynamic component may resolve to plain elements
  13736. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  13737. // updates inside get proper isSVG flag at runtime. (#639, #643)
  13738. // This is technically web-specific, but splitting the logic out of core
  13739. // leads to too much unnecessary complexity.
  13740. (tag === "svg" || tag === "foreignObject")
  13741. );
  13742. if (props.length > 0) {
  13743. const propsBuildResult = buildProps(
  13744. node,
  13745. context,
  13746. void 0,
  13747. isComponent,
  13748. isDynamicComponent
  13749. );
  13750. vnodeProps = propsBuildResult.props;
  13751. patchFlag = propsBuildResult.patchFlag;
  13752. dynamicPropNames = propsBuildResult.dynamicPropNames;
  13753. const directives = propsBuildResult.directives;
  13754. vnodeDirectives = directives && directives.length ? createArrayExpression(
  13755. directives.map((dir) => buildDirectiveArgs(dir, context))
  13756. ) : void 0;
  13757. if (propsBuildResult.shouldUseBlock) {
  13758. shouldUseBlock = true;
  13759. }
  13760. }
  13761. if (node.children.length > 0) {
  13762. if (vnodeTag === KEEP_ALIVE) {
  13763. shouldUseBlock = true;
  13764. patchFlag |= 1024;
  13765. if (node.children.length > 1) {
  13766. context.onError(
  13767. createCompilerError(46, {
  13768. start: node.children[0].loc.start,
  13769. end: node.children[node.children.length - 1].loc.end,
  13770. source: ""
  13771. })
  13772. );
  13773. }
  13774. }
  13775. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  13776. vnodeTag !== TELEPORT && // explained above.
  13777. vnodeTag !== KEEP_ALIVE;
  13778. if (shouldBuildAsSlots) {
  13779. const { slots, hasDynamicSlots } = buildSlots(node, context);
  13780. vnodeChildren = slots;
  13781. if (hasDynamicSlots) {
  13782. patchFlag |= 1024;
  13783. }
  13784. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  13785. const child = node.children[0];
  13786. const type = child.type;
  13787. const hasDynamicTextChild = type === 5 || type === 8;
  13788. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  13789. patchFlag |= 1;
  13790. }
  13791. if (hasDynamicTextChild || type === 2) {
  13792. vnodeChildren = child;
  13793. } else {
  13794. vnodeChildren = node.children;
  13795. }
  13796. } else {
  13797. vnodeChildren = node.children;
  13798. }
  13799. }
  13800. if (patchFlag !== 0) {
  13801. {
  13802. if (patchFlag < 0) {
  13803. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  13804. } else {
  13805. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  13806. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  13807. }
  13808. }
  13809. if (dynamicPropNames && dynamicPropNames.length) {
  13810. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  13811. }
  13812. }
  13813. node.codegenNode = createVNodeCall(
  13814. context,
  13815. vnodeTag,
  13816. vnodeProps,
  13817. vnodeChildren,
  13818. vnodePatchFlag,
  13819. vnodeDynamicProps,
  13820. vnodeDirectives,
  13821. !!shouldUseBlock,
  13822. false,
  13823. isComponent,
  13824. node.loc
  13825. );
  13826. };
  13827. };
  13828. function resolveComponentType(node, context, ssr = false) {
  13829. let { tag } = node;
  13830. const isExplicitDynamic = isComponentTag(tag);
  13831. const isProp = findProp(node, "is");
  13832. if (isProp) {
  13833. if (isExplicitDynamic || false) {
  13834. const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
  13835. if (exp) {
  13836. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  13837. exp
  13838. ]);
  13839. }
  13840. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  13841. tag = isProp.value.content.slice(4);
  13842. }
  13843. }
  13844. const isDir = !isExplicitDynamic && findDir(node, "is");
  13845. if (isDir && isDir.exp) {
  13846. {
  13847. context.onWarn(
  13848. createCompilerError(52, isDir.loc)
  13849. );
  13850. }
  13851. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  13852. isDir.exp
  13853. ]);
  13854. }
  13855. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  13856. if (builtIn) {
  13857. if (!ssr)
  13858. context.helper(builtIn);
  13859. return builtIn;
  13860. }
  13861. context.helper(RESOLVE_COMPONENT);
  13862. context.components.add(tag);
  13863. return toValidAssetId(tag, `component`);
  13864. }
  13865. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  13866. const { tag, loc: elementLoc, children } = node;
  13867. let properties = [];
  13868. const mergeArgs = [];
  13869. const runtimeDirectives = [];
  13870. const hasChildren = children.length > 0;
  13871. let shouldUseBlock = false;
  13872. let patchFlag = 0;
  13873. let hasRef = false;
  13874. let hasClassBinding = false;
  13875. let hasStyleBinding = false;
  13876. let hasHydrationEventBinding = false;
  13877. let hasDynamicKeys = false;
  13878. let hasVnodeHook = false;
  13879. const dynamicPropNames = [];
  13880. const pushMergeArg = (arg) => {
  13881. if (properties.length) {
  13882. mergeArgs.push(
  13883. createObjectExpression(dedupeProperties(properties), elementLoc)
  13884. );
  13885. properties = [];
  13886. }
  13887. if (arg)
  13888. mergeArgs.push(arg);
  13889. };
  13890. const analyzePatchFlag = ({ key, value }) => {
  13891. if (isStaticExp(key)) {
  13892. const name = key.content;
  13893. const isEventHandler = isOn(name);
  13894. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  13895. // dedicated fast path.
  13896. name.toLowerCase() !== "onclick" && // omit v-model handlers
  13897. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  13898. !isReservedProp(name)) {
  13899. hasHydrationEventBinding = true;
  13900. }
  13901. if (isEventHandler && isReservedProp(name)) {
  13902. hasVnodeHook = true;
  13903. }
  13904. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  13905. return;
  13906. }
  13907. if (name === "ref") {
  13908. hasRef = true;
  13909. } else if (name === "class") {
  13910. hasClassBinding = true;
  13911. } else if (name === "style") {
  13912. hasStyleBinding = true;
  13913. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  13914. dynamicPropNames.push(name);
  13915. }
  13916. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  13917. dynamicPropNames.push(name);
  13918. }
  13919. } else {
  13920. hasDynamicKeys = true;
  13921. }
  13922. };
  13923. for (let i = 0; i < props.length; i++) {
  13924. const prop = props[i];
  13925. if (prop.type === 6) {
  13926. const { loc, name, value } = prop;
  13927. let isStatic = true;
  13928. if (name === "ref") {
  13929. hasRef = true;
  13930. if (context.scopes.vFor > 0) {
  13931. properties.push(
  13932. createObjectProperty(
  13933. createSimpleExpression("ref_for", true),
  13934. createSimpleExpression("true")
  13935. )
  13936. );
  13937. }
  13938. }
  13939. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  13940. continue;
  13941. }
  13942. properties.push(
  13943. createObjectProperty(
  13944. createSimpleExpression(
  13945. name,
  13946. true,
  13947. getInnerRange(loc, 0, name.length)
  13948. ),
  13949. createSimpleExpression(
  13950. value ? value.content : "",
  13951. isStatic,
  13952. value ? value.loc : loc
  13953. )
  13954. )
  13955. );
  13956. } else {
  13957. const { name, arg, exp, loc } = prop;
  13958. const isVBind = name === "bind";
  13959. const isVOn = name === "on";
  13960. if (name === "slot") {
  13961. if (!isComponent) {
  13962. context.onError(
  13963. createCompilerError(40, loc)
  13964. );
  13965. }
  13966. continue;
  13967. }
  13968. if (name === "once" || name === "memo") {
  13969. continue;
  13970. }
  13971. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  13972. continue;
  13973. }
  13974. if (isVOn && ssr) {
  13975. continue;
  13976. }
  13977. if (
  13978. // #938: elements with dynamic keys should be forced into blocks
  13979. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  13980. // before children
  13981. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  13982. ) {
  13983. shouldUseBlock = true;
  13984. }
  13985. if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
  13986. properties.push(
  13987. createObjectProperty(
  13988. createSimpleExpression("ref_for", true),
  13989. createSimpleExpression("true")
  13990. )
  13991. );
  13992. }
  13993. if (!arg && (isVBind || isVOn)) {
  13994. hasDynamicKeys = true;
  13995. if (exp) {
  13996. if (isVBind) {
  13997. pushMergeArg();
  13998. mergeArgs.push(exp);
  13999. } else {
  14000. pushMergeArg({
  14001. type: 14,
  14002. loc,
  14003. callee: context.helper(TO_HANDLERS),
  14004. arguments: isComponent ? [exp] : [exp, `true`]
  14005. });
  14006. }
  14007. } else {
  14008. context.onError(
  14009. createCompilerError(
  14010. isVBind ? 34 : 35,
  14011. loc
  14012. )
  14013. );
  14014. }
  14015. continue;
  14016. }
  14017. const directiveTransform = context.directiveTransforms[name];
  14018. if (directiveTransform) {
  14019. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  14020. !ssr && props2.forEach(analyzePatchFlag);
  14021. if (isVOn && arg && !isStaticExp(arg)) {
  14022. pushMergeArg(createObjectExpression(props2, elementLoc));
  14023. } else {
  14024. properties.push(...props2);
  14025. }
  14026. if (needRuntime) {
  14027. runtimeDirectives.push(prop);
  14028. if (isSymbol(needRuntime)) {
  14029. directiveImportMap.set(prop, needRuntime);
  14030. }
  14031. }
  14032. } else if (!isBuiltInDirective(name)) {
  14033. runtimeDirectives.push(prop);
  14034. if (hasChildren) {
  14035. shouldUseBlock = true;
  14036. }
  14037. }
  14038. }
  14039. }
  14040. let propsExpression = void 0;
  14041. if (mergeArgs.length) {
  14042. pushMergeArg();
  14043. if (mergeArgs.length > 1) {
  14044. propsExpression = createCallExpression(
  14045. context.helper(MERGE_PROPS),
  14046. mergeArgs,
  14047. elementLoc
  14048. );
  14049. } else {
  14050. propsExpression = mergeArgs[0];
  14051. }
  14052. } else if (properties.length) {
  14053. propsExpression = createObjectExpression(
  14054. dedupeProperties(properties),
  14055. elementLoc
  14056. );
  14057. }
  14058. if (hasDynamicKeys) {
  14059. patchFlag |= 16;
  14060. } else {
  14061. if (hasClassBinding && !isComponent) {
  14062. patchFlag |= 2;
  14063. }
  14064. if (hasStyleBinding && !isComponent) {
  14065. patchFlag |= 4;
  14066. }
  14067. if (dynamicPropNames.length) {
  14068. patchFlag |= 8;
  14069. }
  14070. if (hasHydrationEventBinding) {
  14071. patchFlag |= 32;
  14072. }
  14073. }
  14074. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  14075. patchFlag |= 512;
  14076. }
  14077. if (!context.inSSR && propsExpression) {
  14078. switch (propsExpression.type) {
  14079. case 15:
  14080. let classKeyIndex = -1;
  14081. let styleKeyIndex = -1;
  14082. let hasDynamicKey = false;
  14083. for (let i = 0; i < propsExpression.properties.length; i++) {
  14084. const key = propsExpression.properties[i].key;
  14085. if (isStaticExp(key)) {
  14086. if (key.content === "class") {
  14087. classKeyIndex = i;
  14088. } else if (key.content === "style") {
  14089. styleKeyIndex = i;
  14090. }
  14091. } else if (!key.isHandlerKey) {
  14092. hasDynamicKey = true;
  14093. }
  14094. }
  14095. const classProp = propsExpression.properties[classKeyIndex];
  14096. const styleProp = propsExpression.properties[styleKeyIndex];
  14097. if (!hasDynamicKey) {
  14098. if (classProp && !isStaticExp(classProp.value)) {
  14099. classProp.value = createCallExpression(
  14100. context.helper(NORMALIZE_CLASS),
  14101. [classProp.value]
  14102. );
  14103. }
  14104. if (styleProp && // the static style is compiled into an object,
  14105. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  14106. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  14107. // v-bind:style with static literal object
  14108. styleProp.value.type === 17)) {
  14109. styleProp.value = createCallExpression(
  14110. context.helper(NORMALIZE_STYLE),
  14111. [styleProp.value]
  14112. );
  14113. }
  14114. } else {
  14115. propsExpression = createCallExpression(
  14116. context.helper(NORMALIZE_PROPS),
  14117. [propsExpression]
  14118. );
  14119. }
  14120. break;
  14121. case 14:
  14122. break;
  14123. default:
  14124. propsExpression = createCallExpression(
  14125. context.helper(NORMALIZE_PROPS),
  14126. [
  14127. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  14128. propsExpression
  14129. ])
  14130. ]
  14131. );
  14132. break;
  14133. }
  14134. }
  14135. return {
  14136. props: propsExpression,
  14137. directives: runtimeDirectives,
  14138. patchFlag,
  14139. dynamicPropNames,
  14140. shouldUseBlock
  14141. };
  14142. }
  14143. function dedupeProperties(properties) {
  14144. const knownProps = /* @__PURE__ */ new Map();
  14145. const deduped = [];
  14146. for (let i = 0; i < properties.length; i++) {
  14147. const prop = properties[i];
  14148. if (prop.key.type === 8 || !prop.key.isStatic) {
  14149. deduped.push(prop);
  14150. continue;
  14151. }
  14152. const name = prop.key.content;
  14153. const existing = knownProps.get(name);
  14154. if (existing) {
  14155. if (name === "style" || name === "class" || isOn(name)) {
  14156. mergeAsArray(existing, prop);
  14157. }
  14158. } else {
  14159. knownProps.set(name, prop);
  14160. deduped.push(prop);
  14161. }
  14162. }
  14163. return deduped;
  14164. }
  14165. function mergeAsArray(existing, incoming) {
  14166. if (existing.value.type === 17) {
  14167. existing.value.elements.push(incoming.value);
  14168. } else {
  14169. existing.value = createArrayExpression(
  14170. [existing.value, incoming.value],
  14171. existing.loc
  14172. );
  14173. }
  14174. }
  14175. function buildDirectiveArgs(dir, context) {
  14176. const dirArgs = [];
  14177. const runtime = directiveImportMap.get(dir);
  14178. if (runtime) {
  14179. dirArgs.push(context.helperString(runtime));
  14180. } else {
  14181. {
  14182. context.helper(RESOLVE_DIRECTIVE);
  14183. context.directives.add(dir.name);
  14184. dirArgs.push(toValidAssetId(dir.name, `directive`));
  14185. }
  14186. }
  14187. const { loc } = dir;
  14188. if (dir.exp)
  14189. dirArgs.push(dir.exp);
  14190. if (dir.arg) {
  14191. if (!dir.exp) {
  14192. dirArgs.push(`void 0`);
  14193. }
  14194. dirArgs.push(dir.arg);
  14195. }
  14196. if (Object.keys(dir.modifiers).length) {
  14197. if (!dir.arg) {
  14198. if (!dir.exp) {
  14199. dirArgs.push(`void 0`);
  14200. }
  14201. dirArgs.push(`void 0`);
  14202. }
  14203. const trueExpression = createSimpleExpression(`true`, false, loc);
  14204. dirArgs.push(
  14205. createObjectExpression(
  14206. dir.modifiers.map(
  14207. (modifier) => createObjectProperty(modifier, trueExpression)
  14208. ),
  14209. loc
  14210. )
  14211. );
  14212. }
  14213. return createArrayExpression(dirArgs, dir.loc);
  14214. }
  14215. function stringifyDynamicPropNames(props) {
  14216. let propsNamesString = `[`;
  14217. for (let i = 0, l = props.length; i < l; i++) {
  14218. propsNamesString += JSON.stringify(props[i]);
  14219. if (i < l - 1)
  14220. propsNamesString += ", ";
  14221. }
  14222. return propsNamesString + `]`;
  14223. }
  14224. function isComponentTag(tag) {
  14225. return tag === "component" || tag === "Component";
  14226. }
  14227.  
  14228. const transformSlotOutlet = (node, context) => {
  14229. if (isSlotOutlet(node)) {
  14230. const { children, loc } = node;
  14231. const { slotName, slotProps } = processSlotOutlet(node, context);
  14232. const slotArgs = [
  14233. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  14234. slotName,
  14235. "{}",
  14236. "undefined",
  14237. "true"
  14238. ];
  14239. let expectedLen = 2;
  14240. if (slotProps) {
  14241. slotArgs[2] = slotProps;
  14242. expectedLen = 3;
  14243. }
  14244. if (children.length) {
  14245. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  14246. expectedLen = 4;
  14247. }
  14248. if (context.scopeId && !context.slotted) {
  14249. expectedLen = 5;
  14250. }
  14251. slotArgs.splice(expectedLen);
  14252. node.codegenNode = createCallExpression(
  14253. context.helper(RENDER_SLOT),
  14254. slotArgs,
  14255. loc
  14256. );
  14257. }
  14258. };
  14259. function processSlotOutlet(node, context) {
  14260. let slotName = `"default"`;
  14261. let slotProps = void 0;
  14262. const nonNameProps = [];
  14263. for (let i = 0; i < node.props.length; i++) {
  14264. const p = node.props[i];
  14265. if (p.type === 6) {
  14266. if (p.value) {
  14267. if (p.name === "name") {
  14268. slotName = JSON.stringify(p.value.content);
  14269. } else {
  14270. p.name = camelize(p.name);
  14271. nonNameProps.push(p);
  14272. }
  14273. }
  14274. } else {
  14275. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  14276. if (p.exp)
  14277. slotName = p.exp;
  14278. } else {
  14279. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  14280. p.arg.content = camelize(p.arg.content);
  14281. }
  14282. nonNameProps.push(p);
  14283. }
  14284. }
  14285. }
  14286. if (nonNameProps.length > 0) {
  14287. const { props, directives } = buildProps(
  14288. node,
  14289. context,
  14290. nonNameProps,
  14291. false,
  14292. false
  14293. );
  14294. slotProps = props;
  14295. if (directives.length) {
  14296. context.onError(
  14297. createCompilerError(
  14298. 36,
  14299. directives[0].loc
  14300. )
  14301. );
  14302. }
  14303. }
  14304. return {
  14305. slotName,
  14306. slotProps
  14307. };
  14308. }
  14309.  
  14310. const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  14311. const transformOn$1 = (dir, node, context, augmentor) => {
  14312. const { loc, modifiers, arg } = dir;
  14313. if (!dir.exp && !modifiers.length) {
  14314. context.onError(createCompilerError(35, loc));
  14315. }
  14316. let eventName;
  14317. if (arg.type === 4) {
  14318. if (arg.isStatic) {
  14319. let rawName = arg.content;
  14320. if (rawName.startsWith("vnode")) {
  14321. context.onWarn(
  14322. createCompilerError(51, arg.loc)
  14323. );
  14324. }
  14325. if (rawName.startsWith("vue:")) {
  14326. rawName = `vnode-${rawName.slice(4)}`;
  14327. }
  14328. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  14329. // for non-element and vnode lifecycle event listeners, auto convert
  14330. // it to camelCase. See issue #2249
  14331. toHandlerKey(camelize(rawName))
  14332. ) : (
  14333. // preserve case for plain element listeners that have uppercase
  14334. // letters, as these may be custom elements' custom events
  14335. `on:${rawName}`
  14336. );
  14337. eventName = createSimpleExpression(eventString, true, arg.loc);
  14338. } else {
  14339. eventName = createCompoundExpression([
  14340. `${context.helperString(TO_HANDLER_KEY)}(`,
  14341. arg,
  14342. `)`
  14343. ]);
  14344. }
  14345. } else {
  14346. eventName = arg;
  14347. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  14348. eventName.children.push(`)`);
  14349. }
  14350. let exp = dir.exp;
  14351. if (exp && !exp.content.trim()) {
  14352. exp = void 0;
  14353. }
  14354. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  14355. if (exp) {
  14356. const isMemberExp = isMemberExpression(exp.content);
  14357. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  14358. const hasMultipleStatements = exp.content.includes(`;`);
  14359. {
  14360. validateBrowserExpression(
  14361. exp,
  14362. context,
  14363. false,
  14364. hasMultipleStatements
  14365. );
  14366. }
  14367. if (isInlineStatement || shouldCache && isMemberExp) {
  14368. exp = createCompoundExpression([
  14369. `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  14370. exp,
  14371. hasMultipleStatements ? `}` : `)`
  14372. ]);
  14373. }
  14374. }
  14375. let ret = {
  14376. props: [
  14377. createObjectProperty(
  14378. eventName,
  14379. exp || createSimpleExpression(`() => {}`, false, loc)
  14380. )
  14381. ]
  14382. };
  14383. if (augmentor) {
  14384. ret = augmentor(ret);
  14385. }
  14386. if (shouldCache) {
  14387. ret.props[0].value = context.cache(ret.props[0].value);
  14388. }
  14389. ret.props.forEach((p) => p.key.isHandlerKey = true);
  14390. return ret;
  14391. };
  14392.  
  14393. const transformBind = (dir, _node, context) => {
  14394. const { exp, modifiers, loc } = dir;
  14395. const arg = dir.arg;
  14396. if (arg.type !== 4) {
  14397. arg.children.unshift(`(`);
  14398. arg.children.push(`) || ""`);
  14399. } else if (!arg.isStatic) {
  14400. arg.content = `${arg.content} || ""`;
  14401. }
  14402. if (modifiers.includes("camel")) {
  14403. if (arg.type === 4) {
  14404. if (arg.isStatic) {
  14405. arg.content = camelize(arg.content);
  14406. } else {
  14407. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  14408. }
  14409. } else {
  14410. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  14411. arg.children.push(`)`);
  14412. }
  14413. }
  14414. if (!context.inSSR) {
  14415. if (modifiers.includes("prop")) {
  14416. injectPrefix(arg, ".");
  14417. }
  14418. if (modifiers.includes("attr")) {
  14419. injectPrefix(arg, "^");
  14420. }
  14421. }
  14422. if (!exp || exp.type === 4 && !exp.content.trim()) {
  14423. context.onError(createCompilerError(34, loc));
  14424. return {
  14425. props: [createObjectProperty(arg, createSimpleExpression("", true, loc))]
  14426. };
  14427. }
  14428. return {
  14429. props: [createObjectProperty(arg, exp)]
  14430. };
  14431. };
  14432. const injectPrefix = (arg, prefix) => {
  14433. if (arg.type === 4) {
  14434. if (arg.isStatic) {
  14435. arg.content = prefix + arg.content;
  14436. } else {
  14437. arg.content = `\`${prefix}\${${arg.content}}\``;
  14438. }
  14439. } else {
  14440. arg.children.unshift(`'${prefix}' + (`);
  14441. arg.children.push(`)`);
  14442. }
  14443. };
  14444.  
  14445. const transformText = (node, context) => {
  14446. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  14447. return () => {
  14448. const children = node.children;
  14449. let currentContainer = void 0;
  14450. let hasText = false;
  14451. for (let i = 0; i < children.length; i++) {
  14452. const child = children[i];
  14453. if (isText$1(child)) {
  14454. hasText = true;
  14455. for (let j = i + 1; j < children.length; j++) {
  14456. const next = children[j];
  14457. if (isText$1(next)) {
  14458. if (!currentContainer) {
  14459. currentContainer = children[i] = createCompoundExpression(
  14460. [child],
  14461. child.loc
  14462. );
  14463. }
  14464. currentContainer.children.push(` + `, next);
  14465. children.splice(j, 1);
  14466. j--;
  14467. } else {
  14468. currentContainer = void 0;
  14469. break;
  14470. }
  14471. }
  14472. }
  14473. }
  14474. if (!hasText || // if this is a plain element with a single text child, leave it
  14475. // as-is since the runtime has dedicated fast path for this by directly
  14476. // setting textContent of the element.
  14477. // for component root it's always normalized anyway.
  14478. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  14479. // custom directives can potentially add DOM elements arbitrarily,
  14480. // we need to avoid setting textContent of the element at runtime
  14481. // to avoid accidentally overwriting the DOM elements added
  14482. // by the user through custom directives.
  14483. !node.props.find(
  14484. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  14485. ) && // in compat mode, <template> tags with no special directives
  14486. // will be rendered as a fragment so its children must be
  14487. // converted into vnodes.
  14488. true)) {
  14489. return;
  14490. }
  14491. for (let i = 0; i < children.length; i++) {
  14492. const child = children[i];
  14493. if (isText$1(child) || child.type === 8) {
  14494. const callArgs = [];
  14495. if (child.type !== 2 || child.content !== " ") {
  14496. callArgs.push(child);
  14497. }
  14498. if (!context.ssr && getConstantType(child, context) === 0) {
  14499. callArgs.push(
  14500. 1 + (` /* ${PatchFlagNames[1]} */` )
  14501. );
  14502. }
  14503. children[i] = {
  14504. type: 12,
  14505. content: child,
  14506. loc: child.loc,
  14507. codegenNode: createCallExpression(
  14508. context.helper(CREATE_TEXT),
  14509. callArgs
  14510. )
  14511. };
  14512. }
  14513. }
  14514. };
  14515. }
  14516. };
  14517.  
  14518. const seen$1 = /* @__PURE__ */ new WeakSet();
  14519. const transformOnce = (node, context) => {
  14520. if (node.type === 1 && findDir(node, "once", true)) {
  14521. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  14522. return;
  14523. }
  14524. seen$1.add(node);
  14525. context.inVOnce = true;
  14526. context.helper(SET_BLOCK_TRACKING);
  14527. return () => {
  14528. context.inVOnce = false;
  14529. const cur = context.currentNode;
  14530. if (cur.codegenNode) {
  14531. cur.codegenNode = context.cache(
  14532. cur.codegenNode,
  14533. true
  14534. /* isVNode */
  14535. );
  14536. }
  14537. };
  14538. }
  14539. };
  14540.  
  14541. const transformModel$1 = (dir, node, context) => {
  14542. const { exp, arg } = dir;
  14543. if (!exp) {
  14544. context.onError(
  14545. createCompilerError(41, dir.loc)
  14546. );
  14547. return createTransformProps();
  14548. }
  14549. const rawExp = exp.loc.source;
  14550. const expString = exp.type === 4 ? exp.content : rawExp;
  14551. const bindingType = context.bindingMetadata[rawExp];
  14552. if (bindingType === "props" || bindingType === "props-aliased") {
  14553. context.onError(createCompilerError(44, exp.loc));
  14554. return createTransformProps();
  14555. }
  14556. const maybeRef = false;
  14557. if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
  14558. context.onError(
  14559. createCompilerError(42, exp.loc)
  14560. );
  14561. return createTransformProps();
  14562. }
  14563. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  14564. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  14565. let assignmentExp;
  14566. const eventArg = context.isTS ? `($event: any)` : `$event`;
  14567. {
  14568. assignmentExp = createCompoundExpression([
  14569. `${eventArg} => ((`,
  14570. exp,
  14571. `) = $event)`
  14572. ]);
  14573. }
  14574. const props = [
  14575. // modelValue: foo
  14576. createObjectProperty(propName, dir.exp),
  14577. // "onUpdate:modelValue": $event => (foo = $event)
  14578. createObjectProperty(eventName, assignmentExp)
  14579. ];
  14580. if (dir.modifiers.length && node.tagType === 1) {
  14581. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  14582. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  14583. props.push(
  14584. createObjectProperty(
  14585. modifiersKey,
  14586. createSimpleExpression(
  14587. `{ ${modifiers} }`,
  14588. false,
  14589. dir.loc,
  14590. 2
  14591. )
  14592. )
  14593. );
  14594. }
  14595. return createTransformProps(props);
  14596. };
  14597. function createTransformProps(props = []) {
  14598. return { props };
  14599. }
  14600.  
  14601. const seen = /* @__PURE__ */ new WeakSet();
  14602. const transformMemo = (node, context) => {
  14603. if (node.type === 1) {
  14604. const dir = findDir(node, "memo");
  14605. if (!dir || seen.has(node)) {
  14606. return;
  14607. }
  14608. seen.add(node);
  14609. return () => {
  14610. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  14611. if (codegenNode && codegenNode.type === 13) {
  14612. if (node.tagType !== 1) {
  14613. convertToBlock(codegenNode, context);
  14614. }
  14615. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  14616. dir.exp,
  14617. createFunctionExpression(void 0, codegenNode),
  14618. `_cache`,
  14619. String(context.cached++)
  14620. ]);
  14621. }
  14622. };
  14623. }
  14624. };
  14625.  
  14626. function getBaseTransformPreset(prefixIdentifiers) {
  14627. return [
  14628. [
  14629. transformOnce,
  14630. transformIf,
  14631. transformMemo,
  14632. transformFor,
  14633. ...[],
  14634. ...[transformExpression] ,
  14635. transformSlotOutlet,
  14636. transformElement,
  14637. trackSlotScopes,
  14638. transformText
  14639. ],
  14640. {
  14641. on: transformOn$1,
  14642. bind: transformBind,
  14643. model: transformModel$1
  14644. }
  14645. ];
  14646. }
  14647. function baseCompile(template, options = {}) {
  14648. const onError = options.onError || defaultOnError;
  14649. const isModuleMode = options.mode === "module";
  14650. {
  14651. if (options.prefixIdentifiers === true) {
  14652. onError(createCompilerError(47));
  14653. } else if (isModuleMode) {
  14654. onError(createCompilerError(48));
  14655. }
  14656. }
  14657. const prefixIdentifiers = false;
  14658. if (options.cacheHandlers) {
  14659. onError(createCompilerError(49));
  14660. }
  14661. if (options.scopeId && !isModuleMode) {
  14662. onError(createCompilerError(50));
  14663. }
  14664. const ast = isString(template) ? baseParse(template, options) : template;
  14665. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
  14666. transform(
  14667. ast,
  14668. extend({}, options, {
  14669. prefixIdentifiers,
  14670. nodeTransforms: [
  14671. ...nodeTransforms,
  14672. ...options.nodeTransforms || []
  14673. // user transforms
  14674. ],
  14675. directiveTransforms: extend(
  14676. {},
  14677. directiveTransforms,
  14678. options.directiveTransforms || {}
  14679. // user transforms
  14680. )
  14681. })
  14682. );
  14683. return generate(
  14684. ast,
  14685. extend({}, options, {
  14686. prefixIdentifiers
  14687. })
  14688. );
  14689. }
  14690.  
  14691. const noopDirectiveTransform = () => ({ props: [] });
  14692.  
  14693. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  14694. const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
  14695. const V_MODEL_TEXT = Symbol(`vModelText` );
  14696. const V_MODEL_SELECT = Symbol(`vModelSelect` );
  14697. const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
  14698. const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
  14699. const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
  14700. const V_SHOW = Symbol(`vShow` );
  14701. const TRANSITION = Symbol(`Transition` );
  14702. const TRANSITION_GROUP = Symbol(`TransitionGroup` );
  14703. registerRuntimeHelpers({
  14704. [V_MODEL_RADIO]: `vModelRadio`,
  14705. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  14706. [V_MODEL_TEXT]: `vModelText`,
  14707. [V_MODEL_SELECT]: `vModelSelect`,
  14708. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  14709. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  14710. [V_ON_WITH_KEYS]: `withKeys`,
  14711. [V_SHOW]: `vShow`,
  14712. [TRANSITION]: `Transition`,
  14713. [TRANSITION_GROUP]: `TransitionGroup`
  14714. });
  14715.  
  14716. let decoder;
  14717. function decodeHtmlBrowser(raw, asAttr = false) {
  14718. if (!decoder) {
  14719. decoder = document.createElement("div");
  14720. }
  14721. if (asAttr) {
  14722. decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
  14723. return decoder.children[0].getAttribute("foo");
  14724. } else {
  14725. decoder.innerHTML = raw;
  14726. return decoder.textContent;
  14727. }
  14728. }
  14729.  
  14730. const isRawTextContainer = /* @__PURE__ */ makeMap(
  14731. "style,iframe,script,noscript",
  14732. true
  14733. );
  14734. const parserOptions = {
  14735. isVoidTag,
  14736. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  14737. isPreTag: (tag) => tag === "pre",
  14738. decodeEntities: decodeHtmlBrowser ,
  14739. isBuiltInComponent: (tag) => {
  14740. if (isBuiltInType(tag, `Transition`)) {
  14741. return TRANSITION;
  14742. } else if (isBuiltInType(tag, `TransitionGroup`)) {
  14743. return TRANSITION_GROUP;
  14744. }
  14745. },
  14746. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  14747. getNamespace(tag, parent) {
  14748. let ns = parent ? parent.ns : 0;
  14749. if (parent && ns === 2) {
  14750. if (parent.tag === "annotation-xml") {
  14751. if (tag === "svg") {
  14752. return 1;
  14753. }
  14754. if (parent.props.some(
  14755. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  14756. )) {
  14757. ns = 0;
  14758. }
  14759. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  14760. ns = 0;
  14761. }
  14762. } else if (parent && ns === 1) {
  14763. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  14764. ns = 0;
  14765. }
  14766. }
  14767. if (ns === 0) {
  14768. if (tag === "svg") {
  14769. return 1;
  14770. }
  14771. if (tag === "math") {
  14772. return 2;
  14773. }
  14774. }
  14775. return ns;
  14776. },
  14777. // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
  14778. getTextMode({ tag, ns }) {
  14779. if (ns === 0) {
  14780. if (tag === "textarea" || tag === "title") {
  14781. return 1;
  14782. }
  14783. if (isRawTextContainer(tag)) {
  14784. return 2;
  14785. }
  14786. }
  14787. return 0;
  14788. }
  14789. };
  14790.  
  14791. const transformStyle = (node) => {
  14792. if (node.type === 1) {
  14793. node.props.forEach((p, i) => {
  14794. if (p.type === 6 && p.name === "style" && p.value) {
  14795. node.props[i] = {
  14796. type: 7,
  14797. name: `bind`,
  14798. arg: createSimpleExpression(`style`, true, p.loc),
  14799. exp: parseInlineCSS(p.value.content, p.loc),
  14800. modifiers: [],
  14801. loc: p.loc
  14802. };
  14803. }
  14804. });
  14805. }
  14806. };
  14807. const parseInlineCSS = (cssText, loc) => {
  14808. const normalized = parseStringStyle(cssText);
  14809. return createSimpleExpression(
  14810. JSON.stringify(normalized),
  14811. false,
  14812. loc,
  14813. 3
  14814. );
  14815. };
  14816.  
  14817. function createDOMCompilerError(code, loc) {
  14818. return createCompilerError(
  14819. code,
  14820. loc,
  14821. DOMErrorMessages
  14822. );
  14823. }
  14824. const DOMErrorMessages = {
  14825. [53]: `v-html is missing expression.`,
  14826. [54]: `v-html will override element children.`,
  14827. [55]: `v-text is missing expression.`,
  14828. [56]: `v-text will override element children.`,
  14829. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  14830. [58]: `v-model argument is not supported on plain elements.`,
  14831. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  14832. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  14833. [61]: `v-show is missing expression.`,
  14834. [62]: `<Transition> expects exactly one child element or component.`,
  14835. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  14836. };
  14837.  
  14838. const transformVHtml = (dir, node, context) => {
  14839. const { exp, loc } = dir;
  14840. if (!exp) {
  14841. context.onError(
  14842. createDOMCompilerError(53, loc)
  14843. );
  14844. }
  14845. if (node.children.length) {
  14846. context.onError(
  14847. createDOMCompilerError(54, loc)
  14848. );
  14849. node.children.length = 0;
  14850. }
  14851. return {
  14852. props: [
  14853. createObjectProperty(
  14854. createSimpleExpression(`innerHTML`, true, loc),
  14855. exp || createSimpleExpression("", true)
  14856. )
  14857. ]
  14858. };
  14859. };
  14860.  
  14861. const transformVText = (dir, node, context) => {
  14862. const { exp, loc } = dir;
  14863. if (!exp) {
  14864. context.onError(
  14865. createDOMCompilerError(55, loc)
  14866. );
  14867. }
  14868. if (node.children.length) {
  14869. context.onError(
  14870. createDOMCompilerError(56, loc)
  14871. );
  14872. node.children.length = 0;
  14873. }
  14874. return {
  14875. props: [
  14876. createObjectProperty(
  14877. createSimpleExpression(`textContent`, true),
  14878. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  14879. context.helperString(TO_DISPLAY_STRING),
  14880. [exp],
  14881. loc
  14882. ) : createSimpleExpression("", true)
  14883. )
  14884. ]
  14885. };
  14886. };
  14887.  
  14888. const transformModel = (dir, node, context) => {
  14889. const baseResult = transformModel$1(dir, node, context);
  14890. if (!baseResult.props.length || node.tagType === 1) {
  14891. return baseResult;
  14892. }
  14893. if (dir.arg) {
  14894. context.onError(
  14895. createDOMCompilerError(
  14896. 58,
  14897. dir.arg.loc
  14898. )
  14899. );
  14900. }
  14901. function checkDuplicatedValue() {
  14902. const value = findProp(node, "value");
  14903. if (value) {
  14904. context.onError(
  14905. createDOMCompilerError(
  14906. 60,
  14907. value.loc
  14908. )
  14909. );
  14910. }
  14911. }
  14912. const { tag } = node;
  14913. const isCustomElement = context.isCustomElement(tag);
  14914. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  14915. let directiveToUse = V_MODEL_TEXT;
  14916. let isInvalidType = false;
  14917. if (tag === "input" || isCustomElement) {
  14918. const type = findProp(node, `type`);
  14919. if (type) {
  14920. if (type.type === 7) {
  14921. directiveToUse = V_MODEL_DYNAMIC;
  14922. } else if (type.value) {
  14923. switch (type.value.content) {
  14924. case "radio":
  14925. directiveToUse = V_MODEL_RADIO;
  14926. break;
  14927. case "checkbox":
  14928. directiveToUse = V_MODEL_CHECKBOX;
  14929. break;
  14930. case "file":
  14931. isInvalidType = true;
  14932. context.onError(
  14933. createDOMCompilerError(
  14934. 59,
  14935. dir.loc
  14936. )
  14937. );
  14938. break;
  14939. default:
  14940. checkDuplicatedValue();
  14941. break;
  14942. }
  14943. }
  14944. } else if (hasDynamicKeyVBind(node)) {
  14945. directiveToUse = V_MODEL_DYNAMIC;
  14946. } else {
  14947. checkDuplicatedValue();
  14948. }
  14949. } else if (tag === "select") {
  14950. directiveToUse = V_MODEL_SELECT;
  14951. } else {
  14952. checkDuplicatedValue();
  14953. }
  14954. if (!isInvalidType) {
  14955. baseResult.needRuntime = context.helper(directiveToUse);
  14956. }
  14957. } else {
  14958. context.onError(
  14959. createDOMCompilerError(
  14960. 57,
  14961. dir.loc
  14962. )
  14963. );
  14964. }
  14965. baseResult.props = baseResult.props.filter(
  14966. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  14967. );
  14968. return baseResult;
  14969. };
  14970.  
  14971. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  14972. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  14973. // event propagation management
  14974. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  14975. );
  14976. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  14977. const isKeyboardEvent = /* @__PURE__ */ makeMap(
  14978. `onkeyup,onkeydown,onkeypress`,
  14979. true
  14980. );
  14981. const resolveModifiers = (key, modifiers, context, loc) => {
  14982. const keyModifiers = [];
  14983. const nonKeyModifiers = [];
  14984. const eventOptionModifiers = [];
  14985. for (let i = 0; i < modifiers.length; i++) {
  14986. const modifier = modifiers[i];
  14987. if (isEventOptionModifier(modifier)) {
  14988. eventOptionModifiers.push(modifier);
  14989. } else {
  14990. if (maybeKeyModifier(modifier)) {
  14991. if (isStaticExp(key)) {
  14992. if (isKeyboardEvent(key.content)) {
  14993. keyModifiers.push(modifier);
  14994. } else {
  14995. nonKeyModifiers.push(modifier);
  14996. }
  14997. } else {
  14998. keyModifiers.push(modifier);
  14999. nonKeyModifiers.push(modifier);
  15000. }
  15001. } else {
  15002. if (isNonKeyModifier(modifier)) {
  15003. nonKeyModifiers.push(modifier);
  15004. } else {
  15005. keyModifiers.push(modifier);
  15006. }
  15007. }
  15008. }
  15009. }
  15010. return {
  15011. keyModifiers,
  15012. nonKeyModifiers,
  15013. eventOptionModifiers
  15014. };
  15015. };
  15016. const transformClick = (key, event) => {
  15017. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  15018. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  15019. `(`,
  15020. key,
  15021. `) === "onClick" ? "${event}" : (`,
  15022. key,
  15023. `)`
  15024. ]) : key;
  15025. };
  15026. const transformOn = (dir, node, context) => {
  15027. return transformOn$1(dir, node, context, (baseResult) => {
  15028. const { modifiers } = dir;
  15029. if (!modifiers.length)
  15030. return baseResult;
  15031. let { key, value: handlerExp } = baseResult.props[0];
  15032. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  15033. if (nonKeyModifiers.includes("right")) {
  15034. key = transformClick(key, `onContextmenu`);
  15035. }
  15036. if (nonKeyModifiers.includes("middle")) {
  15037. key = transformClick(key, `onMouseup`);
  15038. }
  15039. if (nonKeyModifiers.length) {
  15040. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  15041. handlerExp,
  15042. JSON.stringify(nonKeyModifiers)
  15043. ]);
  15044. }
  15045. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  15046. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  15047. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  15048. handlerExp,
  15049. JSON.stringify(keyModifiers)
  15050. ]);
  15051. }
  15052. if (eventOptionModifiers.length) {
  15053. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  15054. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  15055. }
  15056. return {
  15057. props: [createObjectProperty(key, handlerExp)]
  15058. };
  15059. });
  15060. };
  15061.  
  15062. const transformShow = (dir, node, context) => {
  15063. const { exp, loc } = dir;
  15064. if (!exp) {
  15065. context.onError(
  15066. createDOMCompilerError(61, loc)
  15067. );
  15068. }
  15069. return {
  15070. props: [],
  15071. needRuntime: context.helper(V_SHOW)
  15072. };
  15073. };
  15074.  
  15075. const transformTransition = (node, context) => {
  15076. if (node.type === 1 && node.tagType === 1) {
  15077. const component = context.isBuiltInComponent(node.tag);
  15078. if (component === TRANSITION) {
  15079. return () => {
  15080. if (!node.children.length) {
  15081. return;
  15082. }
  15083. if (hasMultipleChildren(node)) {
  15084. context.onError(
  15085. createDOMCompilerError(
  15086. 62,
  15087. {
  15088. start: node.children[0].loc.start,
  15089. end: node.children[node.children.length - 1].loc.end,
  15090. source: ""
  15091. }
  15092. )
  15093. );
  15094. }
  15095. const child = node.children[0];
  15096. if (child.type === 1) {
  15097. for (const p of child.props) {
  15098. if (p.type === 7 && p.name === "show") {
  15099. node.props.push({
  15100. type: 6,
  15101. name: "persisted",
  15102. value: void 0,
  15103. loc: node.loc
  15104. });
  15105. }
  15106. }
  15107. }
  15108. };
  15109. }
  15110. }
  15111. };
  15112. function hasMultipleChildren(node) {
  15113. const children = node.children = node.children.filter(
  15114. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  15115. );
  15116. const child = children[0];
  15117. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  15118. }
  15119.  
  15120. const ignoreSideEffectTags = (node, context) => {
  15121. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  15122. context.onError(
  15123. createDOMCompilerError(
  15124. 63,
  15125. node.loc
  15126. )
  15127. );
  15128. context.removeNode();
  15129. }
  15130. };
  15131.  
  15132. const DOMNodeTransforms = [
  15133. transformStyle,
  15134. ...[transformTransition]
  15135. ];
  15136. const DOMDirectiveTransforms = {
  15137. cloak: noopDirectiveTransform,
  15138. html: transformVHtml,
  15139. text: transformVText,
  15140. model: transformModel,
  15141. // override compiler-core
  15142. on: transformOn,
  15143. // override compiler-core
  15144. show: transformShow
  15145. };
  15146. function compile(template, options = {}) {
  15147. return baseCompile(
  15148. template,
  15149. extend({}, parserOptions, options, {
  15150. nodeTransforms: [
  15151. // ignore <script> and <tag>
  15152. // this is not put inside DOMNodeTransforms because that list is used
  15153. // by compiler-ssr to generate vnode fallback branches
  15154. ignoreSideEffectTags,
  15155. ...DOMNodeTransforms,
  15156. ...options.nodeTransforms || []
  15157. ],
  15158. directiveTransforms: extend(
  15159. {},
  15160. DOMDirectiveTransforms,
  15161. options.directiveTransforms || {}
  15162. ),
  15163. transformHoist: null
  15164. })
  15165. );
  15166. }
  15167.  
  15168. {
  15169. initDev();
  15170. }
  15171. const compileCache = /* @__PURE__ */ Object.create(null);
  15172. function compileToFunction(template, options) {
  15173. if (!isString(template)) {
  15174. if (template.nodeType) {
  15175. template = template.innerHTML;
  15176. } else {
  15177. warn(`invalid template option: `, template);
  15178. return NOOP;
  15179. }
  15180. }
  15181. const key = template;
  15182. const cached = compileCache[key];
  15183. if (cached) {
  15184. return cached;
  15185. }
  15186. if (template[0] === "#") {
  15187. const el = document.querySelector(template);
  15188. if (!el) {
  15189. warn(`Template element not found or is empty: ${template}`);
  15190. }
  15191. template = el ? el.innerHTML : ``;
  15192. }
  15193. const opts = extend(
  15194. {
  15195. hoistStatic: true,
  15196. onError: onError ,
  15197. onWarn: (e) => onError(e, true)
  15198. },
  15199. options
  15200. );
  15201. if (!opts.isCustomElement && typeof customElements !== "undefined") {
  15202. opts.isCustomElement = (tag) => !!customElements.get(tag);
  15203. }
  15204. const { code } = compile(template, opts);
  15205. function onError(err, asWarning = false) {
  15206. const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
  15207. const codeFrame = err.loc && generateCodeFrame(
  15208. template,
  15209. err.loc.start.offset,
  15210. err.loc.end.offset
  15211. );
  15212. warn(codeFrame ? `${message}
  15213. ${codeFrame}` : message);
  15214. }
  15215. const render = new Function(code)() ;
  15216. render._rc = true;
  15217. return compileCache[key] = render;
  15218. }
  15219. registerRuntimeCompiler(compileToFunction);
  15220.  
  15221. exports.BaseTransition = BaseTransition;
  15222. exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
  15223. exports.Comment = Comment;
  15224. exports.EffectScope = EffectScope;
  15225. exports.Fragment = Fragment;
  15226. exports.KeepAlive = KeepAlive;
  15227. exports.ReactiveEffect = ReactiveEffect;
  15228. exports.Static = Static;
  15229. exports.Suspense = Suspense;
  15230. exports.Teleport = Teleport;
  15231. exports.Text = Text;
  15232. exports.Transition = Transition;
  15233. exports.TransitionGroup = TransitionGroup;
  15234. exports.VueElement = VueElement;
  15235. exports.assertNumber = assertNumber;
  15236. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  15237. exports.callWithErrorHandling = callWithErrorHandling;
  15238. exports.camelize = camelize;
  15239. exports.capitalize = capitalize;
  15240. exports.cloneVNode = cloneVNode;
  15241. exports.compatUtils = compatUtils;
  15242. exports.compile = compileToFunction;
  15243. exports.computed = computed;
  15244. exports.createApp = createApp;
  15245. exports.createBlock = createBlock;
  15246. exports.createCommentVNode = createCommentVNode;
  15247. exports.createElementBlock = createElementBlock;
  15248. exports.createElementVNode = createBaseVNode;
  15249. exports.createHydrationRenderer = createHydrationRenderer;
  15250. exports.createPropsRestProxy = createPropsRestProxy;
  15251. exports.createRenderer = createRenderer;
  15252. exports.createSSRApp = createSSRApp;
  15253. exports.createSlots = createSlots;
  15254. exports.createStaticVNode = createStaticVNode;
  15255. exports.createTextVNode = createTextVNode;
  15256. exports.createVNode = createVNode;
  15257. exports.customRef = customRef;
  15258. exports.defineAsyncComponent = defineAsyncComponent;
  15259. exports.defineComponent = defineComponent;
  15260. exports.defineCustomElement = defineCustomElement;
  15261. exports.defineEmits = defineEmits;
  15262. exports.defineExpose = defineExpose;
  15263. exports.defineModel = defineModel;
  15264. exports.defineOptions = defineOptions;
  15265. exports.defineProps = defineProps;
  15266. exports.defineSSRCustomElement = defineSSRCustomElement;
  15267. exports.defineSlots = defineSlots;
  15268. exports.effect = effect;
  15269. exports.effectScope = effectScope;
  15270. exports.getCurrentInstance = getCurrentInstance;
  15271. exports.getCurrentScope = getCurrentScope;
  15272. exports.getTransitionRawChildren = getTransitionRawChildren;
  15273. exports.guardReactiveProps = guardReactiveProps;
  15274. exports.h = h;
  15275. exports.handleError = handleError;
  15276. exports.hasInjectionContext = hasInjectionContext;
  15277. exports.hydrate = hydrate;
  15278. exports.initCustomFormatter = initCustomFormatter;
  15279. exports.initDirectivesForSSR = initDirectivesForSSR;
  15280. exports.inject = inject;
  15281. exports.isMemoSame = isMemoSame;
  15282. exports.isProxy = isProxy;
  15283. exports.isReactive = isReactive;
  15284. exports.isReadonly = isReadonly;
  15285. exports.isRef = isRef;
  15286. exports.isRuntimeOnly = isRuntimeOnly;
  15287. exports.isShallow = isShallow;
  15288. exports.isVNode = isVNode;
  15289. exports.markRaw = markRaw;
  15290. exports.mergeDefaults = mergeDefaults;
  15291. exports.mergeModels = mergeModels;
  15292. exports.mergeProps = mergeProps;
  15293. exports.nextTick = nextTick;
  15294. exports.normalizeClass = normalizeClass;
  15295. exports.normalizeProps = normalizeProps;
  15296. exports.normalizeStyle = normalizeStyle;
  15297. exports.onActivated = onActivated;
  15298. exports.onBeforeMount = onBeforeMount;
  15299. exports.onBeforeUnmount = onBeforeUnmount;
  15300. exports.onBeforeUpdate = onBeforeUpdate;
  15301. exports.onDeactivated = onDeactivated;
  15302. exports.onErrorCaptured = onErrorCaptured;
  15303. exports.onMounted = onMounted;
  15304. exports.onRenderTracked = onRenderTracked;
  15305. exports.onRenderTriggered = onRenderTriggered;
  15306. exports.onScopeDispose = onScopeDispose;
  15307. exports.onServerPrefetch = onServerPrefetch;
  15308. exports.onUnmounted = onUnmounted;
  15309. exports.onUpdated = onUpdated;
  15310. exports.openBlock = openBlock;
  15311. exports.popScopeId = popScopeId;
  15312. exports.provide = provide;
  15313. exports.proxyRefs = proxyRefs;
  15314. exports.pushScopeId = pushScopeId;
  15315. exports.queuePostFlushCb = queuePostFlushCb;
  15316. exports.reactive = reactive;
  15317. exports.readonly = readonly;
  15318. exports.ref = ref;
  15319. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  15320. exports.render = render;
  15321. exports.renderList = renderList;
  15322. exports.renderSlot = renderSlot;
  15323. exports.resolveComponent = resolveComponent;
  15324. exports.resolveDirective = resolveDirective;
  15325. exports.resolveDynamicComponent = resolveDynamicComponent;
  15326. exports.resolveFilter = resolveFilter;
  15327. exports.resolveTransitionHooks = resolveTransitionHooks;
  15328. exports.setBlockTracking = setBlockTracking;
  15329. exports.setDevtoolsHook = setDevtoolsHook;
  15330. exports.setTransitionHooks = setTransitionHooks;
  15331. exports.shallowReactive = shallowReactive;
  15332. exports.shallowReadonly = shallowReadonly;
  15333. exports.shallowRef = shallowRef;
  15334. exports.ssrContextKey = ssrContextKey;
  15335. exports.ssrUtils = ssrUtils;
  15336. exports.stop = stop;
  15337. exports.toDisplayString = toDisplayString;
  15338. exports.toHandlerKey = toHandlerKey;
  15339. exports.toHandlers = toHandlers;
  15340. exports.toRaw = toRaw;
  15341. exports.toRef = toRef;
  15342. exports.toRefs = toRefs;
  15343. exports.toValue = toValue;
  15344. exports.transformVNodeArgs = transformVNodeArgs;
  15345. exports.triggerRef = triggerRef;
  15346. exports.unref = unref;
  15347. exports.useAttrs = useAttrs;
  15348. exports.useCssModule = useCssModule;
  15349. exports.useCssVars = useCssVars;
  15350. exports.useModel = useModel;
  15351. exports.useSSRContext = useSSRContext;
  15352. exports.useSlots = useSlots;
  15353. exports.useTransitionState = useTransitionState;
  15354. exports.vModelCheckbox = vModelCheckbox;
  15355. exports.vModelDynamic = vModelDynamic;
  15356. exports.vModelRadio = vModelRadio;
  15357. exports.vModelSelect = vModelSelect;
  15358. exports.vModelText = vModelText;
  15359. exports.vShow = vShow;
  15360. exports.version = version;
  15361. exports.warn = warn;
  15362. exports.watch = watch;
  15363. exports.watchEffect = watchEffect;
  15364. exports.watchPostEffect = watchPostEffect;
  15365. exports.watchSyncEffect = watchSyncEffect;
  15366. exports.withAsyncContext = withAsyncContext;
  15367. exports.withCtx = withCtx;
  15368. exports.withDefaults = withDefaults;
  15369. exports.withDirectives = withDirectives;
  15370. exports.withKeys = withKeys;
  15371. exports.withMemo = withMemo;
  15372. exports.withModifiers = withModifiers;
  15373. exports.withScopeId = withScopeId;
  15374.  
  15375. return exports;
  15376.  
  15377. })({});