物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8159 lines
223 KiB

  1. /**
  2. * @vue/server-renderer v3.4.27
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. */
  6. /*! #__NO_SIDE_EFFECTS__ */
  7. // @__NO_SIDE_EFFECTS__
  8. function makeMap(str, expectsLowerCase) {
  9. const set = new Set(str.split(','))
  10. return val => set.has(val)
  11. }
  12. const EMPTY_OBJ = Object.freeze({})
  13. const EMPTY_ARR = Object.freeze([])
  14. function NOOP() {
  15. }
  16. const NO = () => false
  17. function isOn(key) {
  18. return key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 // uppercase letter
  19. && (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97)
  20. }
  21. const isModelListener = key => key.startsWith('onUpdate:')
  22. const extend = Object.assign
  23. function remove(arr, el) {
  24. const i = arr.indexOf(el)
  25. if (i > -1)
  26. arr.splice(i, 1)
  27. }
  28. const hasOwnProperty$1 = Object.prototype.hasOwnProperty
  29. const hasOwn = (val, key) => hasOwnProperty$1.call(val, key)
  30. const isArray = Array.isArray
  31. const isMap = val => toTypeString(val) === '[object Map]'
  32. const isSet = val => toTypeString(val) === '[object Set]'
  33. const isDate = val => toTypeString(val) === '[object Date]'
  34. const isFunction = val => typeof val === 'function'
  35. const isString = val => typeof val === 'string'
  36. const isSymbol = val => typeof val === 'symbol'
  37. const isObject = val => val !== null && typeof val === 'object'
  38. function isPromise(val) {
  39. return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch)
  40. }
  41. const objectToString = Object.prototype.toString
  42. const toTypeString = value => objectToString.call(value)
  43. function toRawType(value) {
  44. return toTypeString(value).slice(8, -1)
  45. }
  46. const isPlainObject = val => toTypeString(val) === '[object Object]'
  47. const isIntegerKey = key => isString(key) && key !== 'NaN' && key[0] !== '-' && `${Number.parseInt(key, 10)}` === key
  48. const isReservedProp = /* @__PURE__ */ makeMap(
  49. // the leading comma is intentional so empty string "" is also included
  50. ',key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted',
  51. )
  52. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  53. 'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo',
  54. )
  55. function cacheStringFunction(fn) {
  56. const cache = /* @__PURE__ */ Object.create(null)
  57. return (str) => {
  58. const hit = cache[str]
  59. return hit || (cache[str] = fn(str))
  60. }
  61. }
  62. const camelizeRE = /-(\w)/g
  63. const camelize = cacheStringFunction((str) => {
  64. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
  65. })
  66. const hyphenateRE = /\B([A-Z])/g
  67. const hyphenate = cacheStringFunction(
  68. str => str.replace(hyphenateRE, '-$1').toLowerCase(),
  69. )
  70. const capitalize = cacheStringFunction((str) => {
  71. return str.charAt(0).toUpperCase() + str.slice(1)
  72. })
  73. const toHandlerKey = cacheStringFunction((str) => {
  74. const s = str ? `on${capitalize(str)}` : ``
  75. return s
  76. })
  77. const hasChanged = (value, oldValue) => !Object.is(value, oldValue)
  78. function invokeArrayFns(fns, ...arg) {
  79. for (let i = 0; i < fns.length; i++)
  80. fns[i](...arg)
  81. }
  82. function def(obj, key, value, writable = false) {
  83. Object.defineProperty(obj, key, {
  84. configurable: true,
  85. enumerable: false,
  86. writable,
  87. value,
  88. })
  89. }
  90. function looseToNumber(val) {
  91. const n = Number.parseFloat(val)
  92. return isNaN(n) ? val : n
  93. }
  94. let _globalThis
  95. function getGlobalThis() {
  96. return _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {})
  97. }
  98. function normalizeStyle(value) {
  99. if (isArray(value)) {
  100. const res = {}
  101. for (let i = 0; i < value.length; i++) {
  102. const item = value[i]
  103. const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item)
  104. if (normalized) {
  105. for (const key in normalized)
  106. res[key] = normalized[key]
  107. }
  108. }
  109. return res
  110. }
  111. else if (isString(value) || isObject(value)) {
  112. return value
  113. }
  114. }
  115. const listDelimiterRE = /;(?![^(]*\))/g
  116. const propertyDelimiterRE = /:([^]+)/
  117. const styleCommentRE = /\/\*[^]*?\*\//g
  118. function parseStringStyle(cssText) {
  119. const ret = {}
  120. cssText.replace(styleCommentRE, '').split(listDelimiterRE).forEach((item) => {
  121. if (item) {
  122. const tmp = item.split(propertyDelimiterRE)
  123. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim())
  124. }
  125. })
  126. return ret
  127. }
  128. function stringifyStyle(styles) {
  129. let ret = ''
  130. if (!styles || isString(styles))
  131. return ret
  132. for (const key in styles) {
  133. const value = styles[key]
  134. if (isString(value) || typeof value === 'number') {
  135. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key)
  136. ret += `${normalizedKey}:${value};`
  137. }
  138. }
  139. return ret
  140. }
  141. function normalizeClass(value) {
  142. let res = ''
  143. if (isString(value)) {
  144. res = value
  145. }
  146. else if (isArray(value)) {
  147. for (let i = 0; i < value.length; i++) {
  148. const normalized = normalizeClass(value[i])
  149. if (normalized)
  150. res += `${normalized} `
  151. }
  152. }
  153. else if (isObject(value)) {
  154. for (const name in value) {
  155. if (value[name])
  156. res += `${name} `
  157. }
  158. }
  159. return res.trim()
  160. }
  161. 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'
  162. 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'
  163. const MATH_TAGS = 'annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics'
  164. const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'
  165. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS)
  166. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS)
  167. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS)
  168. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS)
  169. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`
  170. const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs)
  171. const isBooleanAttr = /* @__PURE__ */ makeMap(
  172. `${specialBooleanAttrs},async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`,
  173. )
  174. function includeBooleanAttr(value) {
  175. return !!value || value === ''
  176. }
  177. const unsafeAttrCharRE = /[>/="'\u0009\u000A\u000C\u0020]/
  178. const attrValidationCache = {}
  179. function isSSRSafeAttrName(name) {
  180. if (attrValidationCache.hasOwnProperty(name))
  181. return attrValidationCache[name]
  182. const isUnsafe = unsafeAttrCharRE.test(name)
  183. if (isUnsafe)
  184. console.error(`unsafe attribute name: ${name}`)
  185. return attrValidationCache[name] = !isUnsafe
  186. }
  187. const propsToAttrMap = {
  188. acceptCharset: 'accept-charset',
  189. className: 'class',
  190. htmlFor: 'for',
  191. httpEquiv: 'http-equiv',
  192. }
  193. function isRenderableAttrValue(value) {
  194. if (value == null)
  195. return false
  196. const type = typeof value
  197. return type === 'string' || type === 'number' || type === 'boolean'
  198. }
  199. const escapeRE = /["'&<>]/
  200. function escapeHtml(string) {
  201. const str = `${string}`
  202. const match = escapeRE.exec(str)
  203. if (!match)
  204. return str
  205. let html = ''
  206. let escaped
  207. let index
  208. let lastIndex = 0
  209. for (index = match.index; index < str.length; index++) {
  210. switch (str.charCodeAt(index)) {
  211. case 34:
  212. escaped = '&quot;'
  213. break
  214. case 38:
  215. escaped = '&amp;'
  216. break
  217. case 39:
  218. escaped = '&#39;'
  219. break
  220. case 60:
  221. escaped = '&lt;'
  222. break
  223. case 62:
  224. escaped = '&gt;'
  225. break
  226. default:
  227. continue
  228. }
  229. if (lastIndex !== index)
  230. html += str.slice(lastIndex, index)
  231. lastIndex = index + 1
  232. html += escaped
  233. }
  234. return lastIndex !== index ? html + str.slice(lastIndex, index) : html
  235. }
  236. const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g
  237. function escapeHtmlComment(src) {
  238. return src.replace(commentStripRE, '')
  239. }
  240. function looseCompareArrays(a, b) {
  241. if (a.length !== b.length)
  242. return false
  243. let equal = true
  244. for (let i = 0; equal && i < a.length; i++)
  245. equal = looseEqual(a[i], b[i])
  246. return equal
  247. }
  248. function looseEqual(a, b) {
  249. if (a === b)
  250. return true
  251. let aValidType = isDate(a)
  252. let bValidType = isDate(b)
  253. if (aValidType || bValidType)
  254. return aValidType && bValidType ? a.getTime() === b.getTime() : false
  255. aValidType = isSymbol(a)
  256. bValidType = isSymbol(b)
  257. if (aValidType || bValidType)
  258. return a === b
  259. aValidType = isArray(a)
  260. bValidType = isArray(b)
  261. if (aValidType || bValidType)
  262. return aValidType && bValidType ? looseCompareArrays(a, b) : false
  263. aValidType = isObject(a)
  264. bValidType = isObject(b)
  265. if (aValidType || bValidType) {
  266. if (!aValidType || !bValidType)
  267. return false
  268. const aKeysCount = Object.keys(a).length
  269. const bKeysCount = Object.keys(b).length
  270. if (aKeysCount !== bKeysCount)
  271. return false
  272. for (const key in a) {
  273. const aHasKey = a.hasOwnProperty(key)
  274. const bHasKey = b.hasOwnProperty(key)
  275. if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key]))
  276. return false
  277. }
  278. }
  279. return String(a) === String(b)
  280. }
  281. function looseIndexOf(arr, val) {
  282. return arr.findIndex(item => looseEqual(item, val))
  283. }
  284. function toDisplayString(val) {
  285. return isString(val) ? val : val == null ? '' : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val)
  286. }
  287. function replacer(_key, val) {
  288. if (val && val.__v_isRef) {
  289. return replacer(_key, val.value)
  290. }
  291. else if (isMap(val)) {
  292. return {
  293. [`Map(${val.size})`]: [...val.entries()].reduce(
  294. (entries, [key, val2], i) => {
  295. entries[`${stringifySymbol(key, i)} =>`] = val2
  296. return entries
  297. },
  298. {},
  299. ),
  300. }
  301. }
  302. else if (isSet(val)) {
  303. return {
  304. [`Set(${val.size})`]: [...val.values()].map(v => stringifySymbol(v)),
  305. }
  306. }
  307. else if (isSymbol(val)) {
  308. return stringifySymbol(val)
  309. }
  310. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  311. return String(val)
  312. }
  313. return val
  314. }
  315. function stringifySymbol(v, i = '') {
  316. let _a
  317. return (
  318. // Symbol.description in es2019+ so we need to cast here to pass
  319. // the lib: es2016 check
  320. isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  321. )
  322. }
  323. function warn$2(msg, ...args) {
  324. console.warn(`[Vue warn] ${msg}`, ...args)
  325. }
  326. let activeEffectScope
  327. class EffectScope {
  328. constructor(detached = false) {
  329. this.detached = detached
  330. /**
  331. * @internal
  332. */
  333. this._active = true
  334. /**
  335. * @internal
  336. */
  337. this.effects = []
  338. /**
  339. * @internal
  340. */
  341. this.cleanups = []
  342. this.parent = activeEffectScope
  343. if (!detached && activeEffectScope) {
  344. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  345. this,
  346. ) - 1
  347. }
  348. }
  349. get active() {
  350. return this._active
  351. }
  352. run(fn) {
  353. if (this._active) {
  354. const currentEffectScope = activeEffectScope
  355. try {
  356. activeEffectScope = this
  357. return fn()
  358. }
  359. finally {
  360. activeEffectScope = currentEffectScope
  361. }
  362. }
  363. else {
  364. warn$2(`cannot run an inactive effect scope.`)
  365. }
  366. }
  367. /**
  368. * This should only be called on non-detached scopes
  369. * @internal
  370. */
  371. on() {
  372. activeEffectScope = this
  373. }
  374. /**
  375. * This should only be called on non-detached scopes
  376. * @internal
  377. */
  378. off() {
  379. activeEffectScope = this.parent
  380. }
  381. stop(fromParent) {
  382. if (this._active) {
  383. let i, l
  384. for (i = 0, l = this.effects.length; i < l; i++)
  385. this.effects[i].stop()
  386. for (i = 0, l = this.cleanups.length; i < l; i++)
  387. this.cleanups[i]()
  388. if (this.scopes) {
  389. for (i = 0, l = this.scopes.length; i < l; i++)
  390. this.scopes[i].stop(true)
  391. }
  392. if (!this.detached && this.parent && !fromParent) {
  393. const last = this.parent.scopes.pop()
  394. if (last && last !== this) {
  395. this.parent.scopes[this.index] = last
  396. last.index = this.index
  397. }
  398. }
  399. this.parent = void 0
  400. this._active = false
  401. }
  402. }
  403. }
  404. function recordEffectScope(effect, scope = activeEffectScope) {
  405. if (scope && scope.active)
  406. scope.effects.push(effect)
  407. }
  408. function getCurrentScope() {
  409. return activeEffectScope
  410. }
  411. let activeEffect
  412. class ReactiveEffect {
  413. constructor(fn, trigger, scheduler, scope) {
  414. this.fn = fn
  415. this.trigger = trigger
  416. this.scheduler = scheduler
  417. this.active = true
  418. this.deps = []
  419. /**
  420. * @internal
  421. */
  422. this._dirtyLevel = 4
  423. /**
  424. * @internal
  425. */
  426. this._trackId = 0
  427. /**
  428. * @internal
  429. */
  430. this._runnings = 0
  431. /**
  432. * @internal
  433. */
  434. this._shouldSchedule = false
  435. /**
  436. * @internal
  437. */
  438. this._depsLength = 0
  439. recordEffectScope(this, scope)
  440. }
  441. get dirty() {
  442. if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
  443. this._dirtyLevel = 1
  444. pauseTracking()
  445. for (let i = 0; i < this._depsLength; i++) {
  446. const dep = this.deps[i]
  447. if (dep.computed) {
  448. triggerComputed(dep.computed)
  449. if (this._dirtyLevel >= 4)
  450. break
  451. }
  452. }
  453. if (this._dirtyLevel === 1)
  454. this._dirtyLevel = 0
  455. resetTracking()
  456. }
  457. return this._dirtyLevel >= 4
  458. }
  459. set dirty(v) {
  460. this._dirtyLevel = v ? 4 : 0
  461. }
  462. run() {
  463. this._dirtyLevel = 0
  464. if (!this.active)
  465. return this.fn()
  466. const lastShouldTrack = shouldTrack
  467. const lastEffect = activeEffect
  468. try {
  469. shouldTrack = true
  470. activeEffect = this
  471. this._runnings++
  472. preCleanupEffect(this)
  473. return this.fn()
  474. }
  475. finally {
  476. postCleanupEffect(this)
  477. this._runnings--
  478. activeEffect = lastEffect
  479. shouldTrack = lastShouldTrack
  480. }
  481. }
  482. stop() {
  483. if (this.active) {
  484. preCleanupEffect(this)
  485. postCleanupEffect(this)
  486. this.onStop && this.onStop()
  487. this.active = false
  488. }
  489. }
  490. }
  491. function triggerComputed(computed) {
  492. return computed.value
  493. }
  494. function preCleanupEffect(effect2) {
  495. effect2._trackId++
  496. effect2._depsLength = 0
  497. }
  498. function postCleanupEffect(effect2) {
  499. if (effect2.deps.length > effect2._depsLength) {
  500. for (let i = effect2._depsLength; i < effect2.deps.length; i++)
  501. cleanupDepEffect(effect2.deps[i], effect2)
  502. effect2.deps.length = effect2._depsLength
  503. }
  504. }
  505. function cleanupDepEffect(dep, effect2) {
  506. const trackId = dep.get(effect2)
  507. if (trackId !== void 0 && effect2._trackId !== trackId) {
  508. dep.delete(effect2)
  509. if (dep.size === 0)
  510. dep.cleanup()
  511. }
  512. }
  513. let shouldTrack = true
  514. let pauseScheduleStack = 0
  515. const trackStack = []
  516. function pauseTracking() {
  517. trackStack.push(shouldTrack)
  518. shouldTrack = false
  519. }
  520. function resetTracking() {
  521. const last = trackStack.pop()
  522. shouldTrack = last === void 0 ? true : last
  523. }
  524. function pauseScheduling() {
  525. pauseScheduleStack++
  526. }
  527. function resetScheduling() {
  528. pauseScheduleStack--
  529. while (!pauseScheduleStack && queueEffectSchedulers.length)
  530. queueEffectSchedulers.shift()()
  531. }
  532. function trackEffect(effect2, dep, debuggerEventExtraInfo) {
  533. let _a
  534. if (dep.get(effect2) !== effect2._trackId) {
  535. dep.set(effect2, effect2._trackId)
  536. const oldDep = effect2.deps[effect2._depsLength]
  537. if (oldDep !== dep) {
  538. if (oldDep)
  539. cleanupDepEffect(oldDep, effect2)
  540. effect2.deps[effect2._depsLength++] = dep
  541. }
  542. else {
  543. effect2._depsLength++
  544. }
  545. {
  546. (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo))
  547. }
  548. }
  549. }
  550. const queueEffectSchedulers = []
  551. function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
  552. let _a
  553. pauseScheduling()
  554. for (const effect2 of dep.keys()) {
  555. let tracking
  556. if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
  557. effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0)
  558. effect2._dirtyLevel = dirtyLevel
  559. }
  560. if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
  561. {
  562. (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo))
  563. }
  564. effect2.trigger()
  565. if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
  566. effect2._shouldSchedule = false
  567. if (effect2.scheduler)
  568. queueEffectSchedulers.push(effect2.scheduler)
  569. }
  570. }
  571. }
  572. resetScheduling()
  573. }
  574. function createDep(cleanup, computed) {
  575. const dep = /* @__PURE__ */ new Map()
  576. dep.cleanup = cleanup
  577. dep.computed = computed
  578. return dep
  579. }
  580. const targetMap = /* @__PURE__ */ new WeakMap()
  581. const ITERATE_KEY = Symbol('iterate')
  582. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate')
  583. function track(target, type, key) {
  584. if (shouldTrack && activeEffect) {
  585. let depsMap = targetMap.get(target)
  586. if (!depsMap)
  587. targetMap.set(target, depsMap = /* @__PURE__ */ new Map())
  588. let dep = depsMap.get(key)
  589. if (!dep)
  590. depsMap.set(key, dep = createDep(() => depsMap.delete(key)))
  591. trackEffect(
  592. activeEffect,
  593. dep,
  594. {
  595. target,
  596. type,
  597. key,
  598. },
  599. )
  600. }
  601. }
  602. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  603. const depsMap = targetMap.get(target)
  604. if (!depsMap)
  605. return
  606. let deps = []
  607. if (type === 'clear') {
  608. deps = [...depsMap.values()]
  609. }
  610. else if (key === 'length' && isArray(target)) {
  611. const newLength = Number(newValue)
  612. depsMap.forEach((dep, key2) => {
  613. if (key2 === 'length' || !isSymbol(key2) && key2 >= newLength)
  614. deps.push(dep)
  615. })
  616. }
  617. else {
  618. if (key !== void 0)
  619. deps.push(depsMap.get(key))
  620. switch (type) {
  621. case 'add':
  622. if (!isArray(target)) {
  623. deps.push(depsMap.get(ITERATE_KEY))
  624. if (isMap(target))
  625. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY))
  626. }
  627. else if (isIntegerKey(key)) {
  628. deps.push(depsMap.get('length'))
  629. }
  630. break
  631. case 'delete':
  632. if (!isArray(target)) {
  633. deps.push(depsMap.get(ITERATE_KEY))
  634. if (isMap(target))
  635. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY))
  636. }
  637. break
  638. case 'set':
  639. if (isMap(target))
  640. deps.push(depsMap.get(ITERATE_KEY))
  641. break
  642. }
  643. }
  644. pauseScheduling()
  645. for (const dep of deps) {
  646. if (dep) {
  647. triggerEffects(
  648. dep,
  649. 4,
  650. {
  651. target,
  652. type,
  653. key,
  654. newValue,
  655. oldValue,
  656. oldTarget,
  657. },
  658. )
  659. }
  660. }
  661. resetScheduling()
  662. }
  663. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`)
  664. const builtInSymbols = new Set(
  665. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter(key => key !== 'arguments' && key !== 'caller').map(key => Symbol[key]).filter(isSymbol),
  666. )
  667. const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations()
  668. function createArrayInstrumentations() {
  669. const instrumentations = {};
  670. ['includes', 'indexOf', 'lastIndexOf'].forEach((key) => {
  671. instrumentations[key] = function (...args) {
  672. const arr = toRaw(this)
  673. for (let i = 0, l = this.length; i < l; i++)
  674. track(arr, 'get', `${i}`)
  675. const res = arr[key](...args)
  676. if (res === -1 || res === false)
  677. return arr[key](...args.map(toRaw))
  678. else
  679. return res
  680. }
  681. });
  682. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach((key) => {
  683. instrumentations[key] = function (...args) {
  684. pauseTracking()
  685. pauseScheduling()
  686. const res = toRaw(this)[key].apply(this, args)
  687. resetScheduling()
  688. resetTracking()
  689. return res
  690. }
  691. })
  692. return instrumentations
  693. }
  694. function hasOwnProperty(key) {
  695. if (!isSymbol(key))
  696. key = String(key)
  697. const obj = toRaw(this)
  698. track(obj, 'has', key)
  699. return obj.hasOwnProperty(key)
  700. }
  701. class BaseReactiveHandler {
  702. constructor(_isReadonly = false, _isShallow = false) {
  703. this._isReadonly = _isReadonly
  704. this._isShallow = _isShallow
  705. }
  706. get(target, key, receiver) {
  707. const isReadonly2 = this._isReadonly; const isShallow2 = this._isShallow
  708. if (key === '__v_isReactive') {
  709. return !isReadonly2
  710. }
  711. else if (key === '__v_isReadonly') {
  712. return isReadonly2
  713. }
  714. else if (key === '__v_isShallow') {
  715. return isShallow2
  716. }
  717. else if (key === '__v_raw') {
  718. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) // receiver is not the reactive proxy, but has the same prototype
  719. // this means the reciever is a user proxy of the reactive proxy
  720. || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver))
  721. return target
  722. return
  723. }
  724. const targetIsArray = isArray(target)
  725. if (!isReadonly2) {
  726. if (targetIsArray && hasOwn(arrayInstrumentations, key))
  727. return Reflect.get(arrayInstrumentations, key, receiver)
  728. if (key === 'hasOwnProperty')
  729. return hasOwnProperty
  730. }
  731. const res = Reflect.get(target, key, receiver)
  732. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key))
  733. return res
  734. if (!isReadonly2)
  735. track(target, 'get', key)
  736. if (isShallow2)
  737. return res
  738. if (isRef(res))
  739. return targetIsArray && isIntegerKey(key) ? res : res.value
  740. if (isObject(res))
  741. return isReadonly2 ? readonly(res) : reactive(res)
  742. return res
  743. }
  744. }
  745. class MutableReactiveHandler extends BaseReactiveHandler {
  746. constructor(isShallow2 = false) {
  747. super(false, isShallow2)
  748. }
  749. set(target, key, value, receiver) {
  750. let oldValue = target[key]
  751. if (!this._isShallow) {
  752. const isOldValueReadonly = isReadonly(oldValue)
  753. if (!isShallow(value) && !isReadonly(value)) {
  754. oldValue = toRaw(oldValue)
  755. value = toRaw(value)
  756. }
  757. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  758. if (isOldValueReadonly) {
  759. return false
  760. }
  761. else {
  762. oldValue.value = value
  763. return true
  764. }
  765. }
  766. }
  767. const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key)
  768. const result = Reflect.set(target, key, value, receiver)
  769. if (target === toRaw(receiver)) {
  770. if (!hadKey)
  771. trigger(target, 'add', key, value)
  772. else if (hasChanged(value, oldValue))
  773. trigger(target, 'set', key, value, oldValue)
  774. }
  775. return result
  776. }
  777. deleteProperty(target, key) {
  778. const hadKey = hasOwn(target, key)
  779. const oldValue = target[key]
  780. const result = Reflect.deleteProperty(target, key)
  781. if (result && hadKey)
  782. trigger(target, 'delete', key, void 0, oldValue)
  783. return result
  784. }
  785. has(target, key) {
  786. const result = Reflect.has(target, key)
  787. if (!isSymbol(key) || !builtInSymbols.has(key))
  788. track(target, 'has', key)
  789. return result
  790. }
  791. ownKeys(target) {
  792. track(
  793. target,
  794. 'iterate',
  795. isArray(target) ? 'length' : ITERATE_KEY,
  796. )
  797. return Reflect.ownKeys(target)
  798. }
  799. }
  800. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  801. constructor(isShallow2 = false) {
  802. super(true, isShallow2)
  803. }
  804. set(target, key) {
  805. {
  806. warn$2(
  807. `Set operation on key "${String(key)}" failed: target is readonly.`,
  808. target,
  809. )
  810. }
  811. return true
  812. }
  813. deleteProperty(target, key) {
  814. {
  815. warn$2(
  816. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  817. target,
  818. )
  819. }
  820. return true
  821. }
  822. }
  823. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler()
  824. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler()
  825. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
  826. true,
  827. )
  828. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true)
  829. const toShallow = value => value
  830. const getProto = v => Reflect.getPrototypeOf(v)
  831. function get(target, key, isReadonly = false, isShallow = false) {
  832. target = target.__v_raw
  833. const rawTarget = toRaw(target)
  834. const rawKey = toRaw(key)
  835. if (!isReadonly) {
  836. if (hasChanged(key, rawKey))
  837. track(rawTarget, 'get', key)
  838. track(rawTarget, 'get', rawKey)
  839. }
  840. const { has: has2 } = getProto(rawTarget)
  841. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive
  842. if (has2.call(rawTarget, key))
  843. return wrap(target.get(key))
  844. else if (has2.call(rawTarget, rawKey))
  845. return wrap(target.get(rawKey))
  846. else if (target !== rawTarget)
  847. target.get(key)
  848. }
  849. function has(key, isReadonly = false) {
  850. const target = this.__v_raw
  851. const rawTarget = toRaw(target)
  852. const rawKey = toRaw(key)
  853. if (!isReadonly) {
  854. if (hasChanged(key, rawKey))
  855. track(rawTarget, 'has', key)
  856. track(rawTarget, 'has', rawKey)
  857. }
  858. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey)
  859. }
  860. function size(target, isReadonly = false) {
  861. target = target.__v_raw
  862. !isReadonly && track(toRaw(target), 'iterate', ITERATE_KEY)
  863. return Reflect.get(target, 'size', target)
  864. }
  865. function add(value) {
  866. value = toRaw(value)
  867. const target = toRaw(this)
  868. const proto = getProto(target)
  869. const hadKey = proto.has.call(target, value)
  870. if (!hadKey) {
  871. target.add(value)
  872. trigger(target, 'add', value, value)
  873. }
  874. return this
  875. }
  876. function set(key, value) {
  877. value = toRaw(value)
  878. const target = toRaw(this)
  879. const { has: has2, get: get2 } = getProto(target)
  880. let hadKey = has2.call(target, key)
  881. if (!hadKey) {
  882. key = toRaw(key)
  883. hadKey = has2.call(target, key)
  884. }
  885. else {
  886. checkIdentityKeys(target, has2, key)
  887. }
  888. const oldValue = get2.call(target, key)
  889. target.set(key, value)
  890. if (!hadKey)
  891. trigger(target, 'add', key, value)
  892. else if (hasChanged(value, oldValue))
  893. trigger(target, 'set', key, value, oldValue)
  894. return this
  895. }
  896. function deleteEntry(key) {
  897. const target = toRaw(this)
  898. const { has: has2, get: get2 } = getProto(target)
  899. let hadKey = has2.call(target, key)
  900. if (!hadKey) {
  901. key = toRaw(key)
  902. hadKey = has2.call(target, key)
  903. }
  904. else {
  905. checkIdentityKeys(target, has2, key)
  906. }
  907. const oldValue = get2 ? get2.call(target, key) : void 0
  908. const result = target.delete(key)
  909. if (hadKey)
  910. trigger(target, 'delete', key, void 0, oldValue)
  911. return result
  912. }
  913. function clear() {
  914. const target = toRaw(this)
  915. const hadItems = target.size !== 0
  916. const oldTarget = isMap(target) ? new Map(target) : new Set(target)
  917. const result = target.clear()
  918. if (hadItems)
  919. trigger(target, 'clear', void 0, void 0, oldTarget)
  920. return result
  921. }
  922. function createForEach(isReadonly, isShallow) {
  923. return function forEach(callback, thisArg) {
  924. const observed = this
  925. const target = observed.__v_raw
  926. const rawTarget = toRaw(target)
  927. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive
  928. !isReadonly && track(rawTarget, 'iterate', ITERATE_KEY)
  929. return target.forEach((value, key) => {
  930. return callback.call(thisArg, wrap(value), wrap(key), observed)
  931. })
  932. }
  933. }
  934. function createIterableMethod(method, isReadonly, isShallow) {
  935. return function (...args) {
  936. const target = this.__v_raw
  937. const rawTarget = toRaw(target)
  938. const targetIsMap = isMap(rawTarget)
  939. const isPair = method === 'entries' || method === Symbol.iterator && targetIsMap
  940. const isKeyOnly = method === 'keys' && targetIsMap
  941. const innerIterator = target[method](...args)
  942. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive
  943. !isReadonly && track(
  944. rawTarget,
  945. 'iterate',
  946. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY,
  947. )
  948. return {
  949. // iterator protocol
  950. next() {
  951. const { value, done } = innerIterator.next()
  952. return done
  953. ? { value, done }
  954. : {
  955. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  956. done,
  957. }
  958. },
  959. // iterable protocol
  960. [Symbol.iterator]() {
  961. return this
  962. },
  963. }
  964. }
  965. }
  966. function createReadonlyMethod(type) {
  967. return function (...args) {
  968. {
  969. const key = args[0] ? `on key "${args[0]}" ` : ``
  970. warn$2(
  971. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  972. toRaw(this),
  973. )
  974. }
  975. return type === 'delete' ? false : type === 'clear' ? void 0 : this
  976. }
  977. }
  978. function createInstrumentations() {
  979. const mutableInstrumentations2 = {
  980. get(key) {
  981. return get(this, key)
  982. },
  983. get size() {
  984. return size(this)
  985. },
  986. has,
  987. add,
  988. set,
  989. delete: deleteEntry,
  990. clear,
  991. forEach: createForEach(false, false),
  992. }
  993. const shallowInstrumentations2 = {
  994. get(key) {
  995. return get(this, key, false, true)
  996. },
  997. get size() {
  998. return size(this)
  999. },
  1000. has,
  1001. add,
  1002. set,
  1003. delete: deleteEntry,
  1004. clear,
  1005. forEach: createForEach(false, true),
  1006. }
  1007. const readonlyInstrumentations2 = {
  1008. get(key) {
  1009. return get(this, key, true)
  1010. },
  1011. get size() {
  1012. return size(this, true)
  1013. },
  1014. has(key) {
  1015. return has.call(this, key, true)
  1016. },
  1017. add: createReadonlyMethod('add'),
  1018. set: createReadonlyMethod('set'),
  1019. delete: createReadonlyMethod('delete'),
  1020. clear: createReadonlyMethod('clear'),
  1021. forEach: createForEach(true, false),
  1022. }
  1023. const shallowReadonlyInstrumentations2 = {
  1024. get(key) {
  1025. return get(this, key, true, true)
  1026. },
  1027. get size() {
  1028. return size(this, true)
  1029. },
  1030. has(key) {
  1031. return has.call(this, key, true)
  1032. },
  1033. add: createReadonlyMethod('add'),
  1034. set: createReadonlyMethod('set'),
  1035. delete: createReadonlyMethod('delete'),
  1036. clear: createReadonlyMethod('clear'),
  1037. forEach: createForEach(true, true),
  1038. }
  1039. const iteratorMethods = [
  1040. 'keys',
  1041. 'values',
  1042. 'entries',
  1043. Symbol.iterator,
  1044. ]
  1045. iteratorMethods.forEach((method) => {
  1046. mutableInstrumentations2[method] = createIterableMethod(method, false, false)
  1047. readonlyInstrumentations2[method] = createIterableMethod(method, true, false)
  1048. shallowInstrumentations2[method] = createIterableMethod(method, false, true)
  1049. shallowReadonlyInstrumentations2[method] = createIterableMethod(
  1050. method,
  1051. true,
  1052. true,
  1053. )
  1054. })
  1055. return [
  1056. mutableInstrumentations2,
  1057. readonlyInstrumentations2,
  1058. shallowInstrumentations2,
  1059. shallowReadonlyInstrumentations2,
  1060. ]
  1061. }
  1062. const [
  1063. mutableInstrumentations,
  1064. readonlyInstrumentations,
  1065. shallowInstrumentations,
  1066. shallowReadonlyInstrumentations,
  1067. ] = /* @__PURE__ */ createInstrumentations()
  1068. function createInstrumentationGetter(isReadonly, shallow) {
  1069. const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations
  1070. return (target, key, receiver) => {
  1071. if (key === '__v_isReactive')
  1072. return !isReadonly
  1073. else if (key === '__v_isReadonly')
  1074. return isReadonly
  1075. else if (key === '__v_raw')
  1076. return target
  1077. return Reflect.get(
  1078. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1079. key,
  1080. receiver,
  1081. )
  1082. }
  1083. }
  1084. const mutableCollectionHandlers = {
  1085. get: /* @__PURE__ */ createInstrumentationGetter(false, false),
  1086. }
  1087. const shallowCollectionHandlers = {
  1088. get: /* @__PURE__ */ createInstrumentationGetter(false, true),
  1089. }
  1090. const readonlyCollectionHandlers = {
  1091. get: /* @__PURE__ */ createInstrumentationGetter(true, false),
  1092. }
  1093. const shallowReadonlyCollectionHandlers = {
  1094. get: /* @__PURE__ */ createInstrumentationGetter(true, true),
  1095. }
  1096. function checkIdentityKeys(target, has2, key) {
  1097. const rawKey = toRaw(key)
  1098. if (rawKey !== key && has2.call(target, rawKey)) {
  1099. const type = toRawType(target)
  1100. warn$2(
  1101. `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.`,
  1102. )
  1103. }
  1104. }
  1105. const reactiveMap = /* @__PURE__ */ new WeakMap()
  1106. const shallowReactiveMap = /* @__PURE__ */ new WeakMap()
  1107. const readonlyMap = /* @__PURE__ */ new WeakMap()
  1108. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap()
  1109. function targetTypeMap(rawType) {
  1110. switch (rawType) {
  1111. case 'Object':
  1112. case 'Array':
  1113. return 1 /* COMMON */
  1114. case 'Map':
  1115. case 'Set':
  1116. case 'WeakMap':
  1117. case 'WeakSet':
  1118. return 2 /* COLLECTION */
  1119. default:
  1120. return 0 /* INVALID */
  1121. }
  1122. }
  1123. function getTargetType(value) {
  1124. return value.__v_skip || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value))
  1125. }
  1126. function reactive(target) {
  1127. if (isReadonly(target))
  1128. return target
  1129. return createReactiveObject(
  1130. target,
  1131. false,
  1132. mutableHandlers,
  1133. mutableCollectionHandlers,
  1134. reactiveMap,
  1135. )
  1136. }
  1137. function shallowReactive(target) {
  1138. return createReactiveObject(
  1139. target,
  1140. false,
  1141. shallowReactiveHandlers,
  1142. shallowCollectionHandlers,
  1143. shallowReactiveMap,
  1144. )
  1145. }
  1146. function readonly(target) {
  1147. return createReactiveObject(
  1148. target,
  1149. true,
  1150. readonlyHandlers,
  1151. readonlyCollectionHandlers,
  1152. readonlyMap,
  1153. )
  1154. }
  1155. function shallowReadonly(target) {
  1156. return createReactiveObject(
  1157. target,
  1158. true,
  1159. shallowReadonlyHandlers,
  1160. shallowReadonlyCollectionHandlers,
  1161. shallowReadonlyMap,
  1162. )
  1163. }
  1164. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1165. if (!isObject(target)) {
  1166. {
  1167. warn$2(
  1168. `value cannot be made ${isReadonly2 ? 'readonly' : 'reactive'}: ${String(
  1169. target,
  1170. )}`,
  1171. )
  1172. }
  1173. return target
  1174. }
  1175. if (target.__v_raw && !(isReadonly2 && target.__v_isReactive))
  1176. return target
  1177. const existingProxy = proxyMap.get(target)
  1178. if (existingProxy)
  1179. return existingProxy
  1180. const targetType = getTargetType(target)
  1181. if (targetType === 0 /* INVALID */)
  1182. return target
  1183. const proxy = new Proxy(
  1184. target,
  1185. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers,
  1186. )
  1187. proxyMap.set(target, proxy)
  1188. return proxy
  1189. }
  1190. function isReactive(value) {
  1191. if (isReadonly(value))
  1192. return isReactive(value.__v_raw)
  1193. return !!(value && value.__v_isReactive)
  1194. }
  1195. function isReadonly(value) {
  1196. return !!(value && value.__v_isReadonly)
  1197. }
  1198. function isShallow(value) {
  1199. return !!(value && value.__v_isShallow)
  1200. }
  1201. function isProxy(value) {
  1202. return value ? !!value.__v_raw : false
  1203. }
  1204. function toRaw(observed) {
  1205. const raw = observed && observed.__v_raw
  1206. return raw ? toRaw(raw) : observed
  1207. }
  1208. function markRaw(value) {
  1209. if (Object.isExtensible(value))
  1210. def(value, '__v_skip', true)
  1211. return value
  1212. }
  1213. const toReactive = value => isObject(value) ? reactive(value) : value
  1214. const toReadonly = value => isObject(value) ? readonly(value) : value
  1215. const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`
  1216. class ComputedRefImpl {
  1217. constructor(getter, _setter, isReadonly, isSSR) {
  1218. this.getter = getter
  1219. this._setter = _setter
  1220. this.dep = void 0
  1221. this.__v_isRef = true
  1222. this.__v_isReadonly = false
  1223. this.effect = new ReactiveEffect(
  1224. () => getter(this._value),
  1225. () => triggerRefValue(
  1226. this,
  1227. this.effect._dirtyLevel === 2 ? 2 : 3,
  1228. ),
  1229. )
  1230. this.effect.computed = this
  1231. this.effect.active = this._cacheable = !isSSR
  1232. this.__v_isReadonly = isReadonly
  1233. }
  1234. get value() {
  1235. const self = toRaw(this)
  1236. if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run()))
  1237. triggerRefValue(self, 4)
  1238. trackRefValue(self)
  1239. if (self.effect._dirtyLevel >= 2) {
  1240. if (this._warnRecursive) {
  1241. warn$2(COMPUTED_SIDE_EFFECT_WARN, `
  1242. getter: `, this.getter)
  1243. }
  1244. triggerRefValue(self, 2)
  1245. }
  1246. return self._value
  1247. }
  1248. set value(newValue) {
  1249. this._setter(newValue)
  1250. }
  1251. // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
  1252. get _dirty() {
  1253. return this.effect.dirty
  1254. }
  1255. set _dirty(v) {
  1256. this.effect.dirty = v
  1257. }
  1258. // #endregion
  1259. }
  1260. function computed$1(getterOrOptions, debugOptions, isSSR = false) {
  1261. let getter
  1262. let setter
  1263. const onlyGetter = isFunction(getterOrOptions)
  1264. if (onlyGetter) {
  1265. getter = getterOrOptions
  1266. setter = () => {
  1267. warn$2('Write operation failed: computed value is readonly')
  1268. }
  1269. }
  1270. else {
  1271. getter = getterOrOptions.get
  1272. setter = getterOrOptions.set
  1273. }
  1274. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR)
  1275. return cRef
  1276. }
  1277. function trackRefValue(ref2) {
  1278. let _a
  1279. if (shouldTrack && activeEffect) {
  1280. ref2 = toRaw(ref2)
  1281. trackEffect(
  1282. activeEffect,
  1283. (_a = ref2.dep) != null
  1284. ? _a
  1285. : ref2.dep = createDep(
  1286. () => ref2.dep = void 0,
  1287. ref2 instanceof ComputedRefImpl ? ref2 : void 0,
  1288. ),
  1289. {
  1290. target: ref2,
  1291. type: 'get',
  1292. key: 'value',
  1293. },
  1294. )
  1295. }
  1296. }
  1297. function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
  1298. ref2 = toRaw(ref2)
  1299. const dep = ref2.dep
  1300. if (dep) {
  1301. triggerEffects(
  1302. dep,
  1303. dirtyLevel,
  1304. {
  1305. target: ref2,
  1306. type: 'set',
  1307. key: 'value',
  1308. newValue: newVal,
  1309. },
  1310. )
  1311. }
  1312. }
  1313. function isRef(r) {
  1314. return !!(r && r.__v_isRef === true)
  1315. }
  1316. function unref(ref2) {
  1317. return isRef(ref2) ? ref2.value : ref2
  1318. }
  1319. const shallowUnwrapHandlers = {
  1320. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1321. set: (target, key, value, receiver) => {
  1322. const oldValue = target[key]
  1323. if (isRef(oldValue) && !isRef(value)) {
  1324. oldValue.value = value
  1325. return true
  1326. }
  1327. else {
  1328. return Reflect.set(target, key, value, receiver)
  1329. }
  1330. },
  1331. }
  1332. function proxyRefs(objectWithRefs) {
  1333. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers)
  1334. }
  1335. const stack = []
  1336. function pushWarningContext(vnode) {
  1337. stack.push(vnode)
  1338. }
  1339. function popWarningContext() {
  1340. stack.pop()
  1341. }
  1342. function warn$1(msg, ...args) {
  1343. pauseTracking()
  1344. const instance = stack.length ? stack[stack.length - 1].component : null
  1345. const appWarnHandler = instance && instance.appContext.config.warnHandler
  1346. const trace = getComponentTrace()
  1347. if (appWarnHandler) {
  1348. callWithErrorHandling(
  1349. appWarnHandler,
  1350. instance,
  1351. 11,
  1352. [
  1353. msg + args.map((a) => {
  1354. let _a, _b
  1355. return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a)
  1356. }).join(''),
  1357. instance && instance.proxy,
  1358. trace.map(
  1359. ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`,
  1360. ).join('\n'),
  1361. trace,
  1362. ],
  1363. )
  1364. }
  1365. else {
  1366. const warnArgs = [`[Vue warn]: ${msg}`, ...args]
  1367. if (trace.length // avoid spamming console during tests
  1368. && true) {
  1369. warnArgs.push(`
  1370. `, ...formatTrace(trace))
  1371. }
  1372. console.warn(...warnArgs)
  1373. }
  1374. resetTracking()
  1375. }
  1376. function getComponentTrace() {
  1377. let currentVNode = stack[stack.length - 1]
  1378. if (!currentVNode)
  1379. return []
  1380. const normalizedStack = []
  1381. while (currentVNode) {
  1382. const last = normalizedStack[0]
  1383. if (last && last.vnode === currentVNode) {
  1384. last.recurseCount++
  1385. }
  1386. else {
  1387. normalizedStack.push({
  1388. vnode: currentVNode,
  1389. recurseCount: 0,
  1390. })
  1391. }
  1392. const parentInstance = currentVNode.component && currentVNode.component.parent
  1393. currentVNode = parentInstance && parentInstance.vnode
  1394. }
  1395. return normalizedStack
  1396. }
  1397. function formatTrace(trace) {
  1398. const logs = []
  1399. trace.forEach((entry, i) => {
  1400. logs.push(...i === 0
  1401. ? []
  1402. : [`
  1403. `], ...formatTraceEntry(entry))
  1404. })
  1405. return logs
  1406. }
  1407. function formatTraceEntry({ vnode, recurseCount }) {
  1408. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``
  1409. const isRoot = vnode.component ? vnode.component.parent == null : false
  1410. const open = ` at <${formatComponentName(
  1411. vnode.component,
  1412. vnode.type,
  1413. isRoot,
  1414. )}`
  1415. const close = `>${postfix}`
  1416. return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close]
  1417. }
  1418. function formatProps(props) {
  1419. const res = []
  1420. const keys = Object.keys(props)
  1421. keys.slice(0, 3).forEach((key) => {
  1422. res.push(...formatProp(key, props[key]))
  1423. })
  1424. if (keys.length > 3)
  1425. res.push(` ...`)
  1426. return res
  1427. }
  1428. function formatProp(key, value, raw) {
  1429. if (isString(value)) {
  1430. value = JSON.stringify(value)
  1431. return raw ? value : [`${key}=${value}`]
  1432. }
  1433. else if (typeof value === 'number' || typeof value === 'boolean' || value == null) {
  1434. return raw ? value : [`${key}=${value}`]
  1435. }
  1436. else if (isRef(value)) {
  1437. value = formatProp(key, toRaw(value.value), true)
  1438. return raw ? value : [`${key}=Ref<`, value, `>`]
  1439. }
  1440. else if (isFunction(value)) {
  1441. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`]
  1442. }
  1443. else {
  1444. value = toRaw(value)
  1445. return raw ? value : [`${key}=`, value]
  1446. }
  1447. }
  1448. const ErrorTypeStrings = {
  1449. sp: 'serverPrefetch hook',
  1450. bc: 'beforeCreate hook',
  1451. c: 'created hook',
  1452. bm: 'beforeMount hook',
  1453. m: 'mounted hook',
  1454. bu: 'beforeUpdate hook',
  1455. u: 'updated',
  1456. bum: 'beforeUnmount hook',
  1457. um: 'unmounted hook',
  1458. a: 'activated hook',
  1459. da: 'deactivated hook',
  1460. ec: 'errorCaptured hook',
  1461. rtc: 'renderTracked hook',
  1462. rtg: 'renderTriggered hook',
  1463. 0: 'setup function',
  1464. 1: 'render function',
  1465. 2: 'watcher getter',
  1466. 3: 'watcher callback',
  1467. 4: 'watcher cleanup function',
  1468. 5: 'native event handler',
  1469. 6: 'component event handler',
  1470. 7: 'vnode hook',
  1471. 8: 'directive hook',
  1472. 9: 'transition hook',
  1473. 10: 'app errorHandler',
  1474. 11: 'app warnHandler',
  1475. 12: 'ref function',
  1476. 13: 'async component loader',
  1477. 14: 'scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .',
  1478. }
  1479. function callWithErrorHandling(fn, instance, type, args) {
  1480. try {
  1481. return args ? fn(...args) : fn()
  1482. }
  1483. catch (err) {
  1484. handleError(err, instance, type)
  1485. }
  1486. }
  1487. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1488. if (isFunction(fn)) {
  1489. const res = callWithErrorHandling(fn, instance, type, args)
  1490. if (res && isPromise(res)) {
  1491. res.catch((err) => {
  1492. handleError(err, instance, type)
  1493. })
  1494. }
  1495. return res
  1496. }
  1497. if (isArray(fn)) {
  1498. const values = []
  1499. for (let i = 0; i < fn.length; i++)
  1500. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args))
  1501. return values
  1502. }
  1503. else {
  1504. warn$1(
  1505. `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`,
  1506. )
  1507. }
  1508. }
  1509. function handleError(err, instance, type, throwInDev = true) {
  1510. const contextVNode = instance ? instance.vnode : null
  1511. if (instance) {
  1512. let cur = instance.parent
  1513. const exposedInstance = instance.proxy
  1514. const errorInfo = ErrorTypeStrings[type]
  1515. while (cur) {
  1516. const errorCapturedHooks = cur.ec
  1517. if (errorCapturedHooks) {
  1518. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1519. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false)
  1520. return
  1521. }
  1522. }
  1523. cur = cur.parent
  1524. }
  1525. const appErrorHandler = instance.appContext.config.errorHandler
  1526. if (appErrorHandler) {
  1527. pauseTracking()
  1528. callWithErrorHandling(
  1529. appErrorHandler,
  1530. null,
  1531. 10,
  1532. [err, exposedInstance, errorInfo],
  1533. )
  1534. resetTracking()
  1535. return
  1536. }
  1537. }
  1538. logError(err, type, contextVNode, throwInDev)
  1539. }
  1540. function logError(err, type, contextVNode, throwInDev = true) {
  1541. {
  1542. const info = ErrorTypeStrings[type]
  1543. if (contextVNode)
  1544. pushWarningContext(contextVNode)
  1545. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`)
  1546. if (contextVNode)
  1547. popWarningContext()
  1548. if (throwInDev)
  1549. throw err
  1550. else
  1551. console.error(err)
  1552. }
  1553. }
  1554. let isFlushing = false
  1555. let isFlushPending = false
  1556. const queue = []
  1557. let flushIndex = 0
  1558. const pendingPostFlushCbs = []
  1559. let activePostFlushCbs = null
  1560. let postFlushIndex = 0
  1561. const resolvedPromise = /* @__PURE__ */ Promise.resolve()
  1562. let currentFlushPromise = null
  1563. const RECURSION_LIMIT = 100
  1564. function nextTick(fn) {
  1565. const p = currentFlushPromise || resolvedPromise
  1566. return fn ? p.then(this ? fn.bind(this) : fn) : p
  1567. }
  1568. function findInsertionIndex(id) {
  1569. let start = flushIndex + 1
  1570. let end = queue.length
  1571. while (start < end) {
  1572. const middle = start + end >>> 1
  1573. const middleJob = queue[middle]
  1574. const middleJobId = getId(middleJob)
  1575. if (middleJobId < id || middleJobId === id && middleJob.pre)
  1576. start = middle + 1
  1577. else
  1578. end = middle
  1579. }
  1580. return start
  1581. }
  1582. function queueJob(job) {
  1583. if (!queue.length || !queue.includes(
  1584. job,
  1585. isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex,
  1586. )) {
  1587. if (job.id == null)
  1588. queue.push(job)
  1589. else
  1590. queue.splice(findInsertionIndex(job.id), 0, job)
  1591. queueFlush()
  1592. }
  1593. }
  1594. function queueFlush() {
  1595. if (!isFlushing && !isFlushPending) {
  1596. isFlushPending = true
  1597. currentFlushPromise = resolvedPromise.then(flushJobs)
  1598. }
  1599. }
  1600. function invalidateJob(job) {
  1601. const i = queue.indexOf(job)
  1602. if (i > flushIndex)
  1603. queue.splice(i, 1)
  1604. }
  1605. function queuePostFlushCb(cb) {
  1606. if (!isArray(cb)) {
  1607. if (!activePostFlushCbs || !activePostFlushCbs.includes(
  1608. cb,
  1609. cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex,
  1610. ))
  1611. pendingPostFlushCbs.push(cb)
  1612. }
  1613. else {
  1614. pendingPostFlushCbs.push(...cb)
  1615. }
  1616. queueFlush()
  1617. }
  1618. function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
  1619. {
  1620. seen = seen || /* @__PURE__ */ new Map()
  1621. }
  1622. for (; i < queue.length; i++) {
  1623. const cb = queue[i]
  1624. if (cb && cb.pre) {
  1625. if (instance && cb.id !== instance.uid)
  1626. continue
  1627. if (checkRecursiveUpdates(seen, cb))
  1628. continue
  1629. queue.splice(i, 1)
  1630. i--
  1631. cb()
  1632. }
  1633. }
  1634. }
  1635. function flushPostFlushCbs(seen) {
  1636. if (pendingPostFlushCbs.length) {
  1637. const deduped = [...new Set(pendingPostFlushCbs)].sort(
  1638. (a, b) => getId(a) - getId(b),
  1639. )
  1640. pendingPostFlushCbs.length = 0
  1641. if (activePostFlushCbs) {
  1642. activePostFlushCbs.push(...deduped)
  1643. return
  1644. }
  1645. activePostFlushCbs = deduped
  1646. {
  1647. seen = seen || /* @__PURE__ */ new Map()
  1648. }
  1649. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1650. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex]))
  1651. continue
  1652. activePostFlushCbs[postFlushIndex]()
  1653. }
  1654. activePostFlushCbs = null
  1655. postFlushIndex = 0
  1656. }
  1657. }
  1658. const getId = job => job.id == null ? Number.POSITIVE_INFINITY : job.id
  1659. function comparator(a, b) {
  1660. const diff = getId(a) - getId(b)
  1661. if (diff === 0) {
  1662. if (a.pre && !b.pre)
  1663. return -1
  1664. if (b.pre && !a.pre)
  1665. return 1
  1666. }
  1667. return diff
  1668. }
  1669. function flushJobs(seen) {
  1670. isFlushPending = false
  1671. isFlushing = true
  1672. {
  1673. seen = seen || /* @__PURE__ */ new Map()
  1674. }
  1675. queue.sort(comparator)
  1676. const check = job => checkRecursiveUpdates(seen, job)
  1677. try {
  1678. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1679. const job = queue[flushIndex]
  1680. if (job && job.active !== false) {
  1681. if (check(job))
  1682. continue
  1683. callWithErrorHandling(job, null, 14)
  1684. }
  1685. }
  1686. }
  1687. finally {
  1688. flushIndex = 0
  1689. queue.length = 0
  1690. flushPostFlushCbs(seen)
  1691. isFlushing = false
  1692. currentFlushPromise = null
  1693. if (queue.length || pendingPostFlushCbs.length)
  1694. flushJobs(seen)
  1695. }
  1696. }
  1697. function checkRecursiveUpdates(seen, fn) {
  1698. if (!seen.has(fn)) {
  1699. seen.set(fn, 1)
  1700. }
  1701. else {
  1702. const count = seen.get(fn)
  1703. if (count > RECURSION_LIMIT) {
  1704. const instance = fn.ownerInstance
  1705. const componentName = instance && getComponentName(instance.type)
  1706. handleError(
  1707. `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.`,
  1708. null,
  1709. 10,
  1710. )
  1711. return true
  1712. }
  1713. else {
  1714. seen.set(fn, count + 1)
  1715. }
  1716. }
  1717. }
  1718. let isHmrUpdating = false
  1719. const hmrDirtyComponents = /* @__PURE__ */ new Set()
  1720. {
  1721. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1722. createRecord: tryWrap(createRecord),
  1723. rerender: tryWrap(rerender),
  1724. reload: tryWrap(reload),
  1725. }
  1726. }
  1727. const map = /* @__PURE__ */ new Map()
  1728. function registerHMR(instance) {
  1729. const id = instance.type.__hmrId
  1730. let record = map.get(id)
  1731. if (!record) {
  1732. createRecord(id, instance.type)
  1733. record = map.get(id)
  1734. }
  1735. record.instances.add(instance)
  1736. }
  1737. function unregisterHMR(instance) {
  1738. map.get(instance.type.__hmrId).instances.delete(instance)
  1739. }
  1740. function createRecord(id, initialDef) {
  1741. if (map.has(id))
  1742. return false
  1743. map.set(id, {
  1744. initialDef: normalizeClassComponent(initialDef),
  1745. instances: /* @__PURE__ */ new Set(),
  1746. })
  1747. return true
  1748. }
  1749. function normalizeClassComponent(component) {
  1750. return isClassComponent(component) ? component.__vccOpts : component
  1751. }
  1752. function rerender(id, newRender) {
  1753. const record = map.get(id)
  1754. if (!record)
  1755. return
  1756. record.initialDef.render = newRender;
  1757. [...record.instances].forEach((instance) => {
  1758. if (newRender) {
  1759. instance.render = newRender
  1760. normalizeClassComponent(instance.type).render = newRender
  1761. }
  1762. instance.renderCache = []
  1763. isHmrUpdating = true
  1764. instance.effect.dirty = true
  1765. instance.update()
  1766. isHmrUpdating = false
  1767. })
  1768. }
  1769. function reload(id, newComp) {
  1770. const record = map.get(id)
  1771. if (!record)
  1772. return
  1773. newComp = normalizeClassComponent(newComp)
  1774. updateComponentDef(record.initialDef, newComp)
  1775. const instances = [...record.instances]
  1776. for (const instance of instances) {
  1777. const oldComp = normalizeClassComponent(instance.type)
  1778. if (!hmrDirtyComponents.has(oldComp)) {
  1779. if (oldComp !== record.initialDef)
  1780. updateComponentDef(oldComp, newComp)
  1781. hmrDirtyComponents.add(oldComp)
  1782. }
  1783. instance.appContext.propsCache.delete(instance.type)
  1784. instance.appContext.emitsCache.delete(instance.type)
  1785. instance.appContext.optionsCache.delete(instance.type)
  1786. if (instance.ceReload) {
  1787. hmrDirtyComponents.add(oldComp)
  1788. instance.ceReload(newComp.styles)
  1789. hmrDirtyComponents.delete(oldComp)
  1790. }
  1791. else if (instance.parent) {
  1792. instance.parent.effect.dirty = true
  1793. queueJob(instance.parent.update)
  1794. }
  1795. else if (instance.appContext.reload) {
  1796. instance.appContext.reload()
  1797. }
  1798. else if (typeof window !== 'undefined') {
  1799. window.location.reload()
  1800. }
  1801. else {
  1802. console.warn(
  1803. '[HMR] Root or manually mounted instance modified. Full reload required.',
  1804. )
  1805. }
  1806. }
  1807. queuePostFlushCb(() => {
  1808. for (const instance of instances) {
  1809. hmrDirtyComponents.delete(
  1810. normalizeClassComponent(instance.type),
  1811. )
  1812. }
  1813. })
  1814. }
  1815. function updateComponentDef(oldComp, newComp) {
  1816. extend(oldComp, newComp)
  1817. for (const key in oldComp) {
  1818. if (key !== '__file' && !(key in newComp))
  1819. delete oldComp[key]
  1820. }
  1821. }
  1822. function tryWrap(fn) {
  1823. return (id, arg) => {
  1824. try {
  1825. return fn(id, arg)
  1826. }
  1827. catch (e) {
  1828. console.error(e)
  1829. console.warn(
  1830. `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`,
  1831. )
  1832. }
  1833. }
  1834. }
  1835. let devtools
  1836. let buffer = []
  1837. let devtoolsNotInstalled = false
  1838. function emit$1(event, ...args) {
  1839. if (devtools)
  1840. devtools.emit(event, ...args)
  1841. else if (!devtoolsNotInstalled)
  1842. buffer.push({ event, args })
  1843. }
  1844. function setDevtoolsHook(hook, target) {
  1845. let _a, _b
  1846. devtools = hook
  1847. if (devtools) {
  1848. devtools.enabled = true
  1849. buffer.forEach(({ event, args }) => devtools.emit(event, ...args))
  1850. buffer = []
  1851. }
  1852. else if (
  1853. // handle late devtools injection - only do this if we are in an actual
  1854. // browser environment to avoid the timer handle stalling test runner exit
  1855. // (#4815)
  1856. typeof window !== 'undefined' // some envs mock window but not fully
  1857. && window.HTMLElement // also exclude jsdom
  1858. && !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes('jsdom'))
  1859. ) {
  1860. const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []
  1861. replay.push((newHook) => {
  1862. setDevtoolsHook(newHook, target)
  1863. })
  1864. setTimeout(() => {
  1865. if (!devtools) {
  1866. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null
  1867. devtoolsNotInstalled = true
  1868. buffer = []
  1869. }
  1870. }, 3e3)
  1871. }
  1872. else {
  1873. devtoolsNotInstalled = true
  1874. buffer = []
  1875. }
  1876. }
  1877. function devtoolsInitApp(app, version) {
  1878. emit$1('app:init' /* APP_INIT */, app, version, {
  1879. Fragment,
  1880. Text,
  1881. Comment,
  1882. Static,
  1883. })
  1884. }
  1885. function devtoolsUnmountApp(app) {
  1886. emit$1('app:unmount' /* APP_UNMOUNT */, app)
  1887. }
  1888. const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
  1889. 'component:added', /* COMPONENT_ADDED */
  1890. )
  1891. const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook('component:updated' /* COMPONENT_UPDATED */)
  1892. const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
  1893. 'component:removed', /* COMPONENT_REMOVED */
  1894. )
  1895. function devtoolsComponentRemoved(component) {
  1896. if (devtools && typeof devtools.cleanupBuffer === 'function' // remove the component if it wasn't buffered
  1897. && !devtools.cleanupBuffer(component))
  1898. _devtoolsComponentRemoved(component)
  1899. }
  1900. /*! #__NO_SIDE_EFFECTS__ */
  1901. // @__NO_SIDE_EFFECTS__
  1902. function createDevtoolsComponentHook(hook) {
  1903. return (component) => {
  1904. emit$1(
  1905. hook,
  1906. component.appContext.app,
  1907. component.uid,
  1908. component.parent ? component.parent.uid : void 0,
  1909. component,
  1910. )
  1911. }
  1912. }
  1913. const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
  1914. 'perf:start', /* PERFORMANCE_START */
  1915. )
  1916. const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
  1917. 'perf:end', /* PERFORMANCE_END */
  1918. )
  1919. function createDevtoolsPerformanceHook(hook) {
  1920. return (component, type, time) => {
  1921. emit$1(hook, component.appContext.app, component.uid, component, type, time)
  1922. }
  1923. }
  1924. function devtoolsComponentEmit(component, event, params) {
  1925. emit$1(
  1926. 'component:emit' /* COMPONENT_EMIT */,
  1927. component.appContext.app,
  1928. component,
  1929. event,
  1930. params,
  1931. )
  1932. }
  1933. function emit(instance, event, ...rawArgs) {
  1934. if (instance.isUnmounted)
  1935. return
  1936. const props = instance.vnode.props || EMPTY_OBJ
  1937. {
  1938. const {
  1939. emitsOptions,
  1940. propsOptions: [propsOptions],
  1941. } = instance
  1942. if (emitsOptions) {
  1943. if (!(event in emitsOptions) && true) {
  1944. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  1945. warn$1(
  1946. `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`,
  1947. )
  1948. }
  1949. }
  1950. else {
  1951. const validator = emitsOptions[event]
  1952. if (isFunction(validator)) {
  1953. const isValid = validator(...rawArgs)
  1954. if (!isValid) {
  1955. warn$1(
  1956. `Invalid event arguments: event validation failed for event "${event}".`,
  1957. )
  1958. }
  1959. }
  1960. }
  1961. }
  1962. }
  1963. let args = rawArgs
  1964. const isModelListener = event.startsWith('update:')
  1965. const modelArg = isModelListener && event.slice(7)
  1966. if (modelArg && modelArg in props) {
  1967. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`
  1968. const { number, trim } = props[modifiersKey] || EMPTY_OBJ
  1969. if (trim)
  1970. args = rawArgs.map(a => isString(a) ? a.trim() : a)
  1971. if (number)
  1972. args = rawArgs.map(looseToNumber)
  1973. }
  1974. {
  1975. devtoolsComponentEmit(instance, event, args)
  1976. }
  1977. {
  1978. const lowerCaseEvent = event.toLowerCase()
  1979. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  1980. warn$1(
  1981. `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
  1982. instance,
  1983. instance.type,
  1984. )} 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(
  1985. event,
  1986. )}" instead of "${event}".`,
  1987. )
  1988. }
  1989. }
  1990. let handlerName
  1991. let handler = props[handlerName = toHandlerKey(event)] // also try camelCase event handler (#2249)
  1992. || props[handlerName = toHandlerKey(camelize(event))]
  1993. if (!handler && isModelListener)
  1994. handler = props[handlerName = toHandlerKey(hyphenate(event))]
  1995. if (handler) {
  1996. callWithAsyncErrorHandling(
  1997. handler,
  1998. instance,
  1999. 6,
  2000. args,
  2001. )
  2002. }
  2003. const onceHandler = props[`${handlerName}Once`]
  2004. if (onceHandler) {
  2005. if (!instance.emitted)
  2006. instance.emitted = {}
  2007. else if (instance.emitted[handlerName])
  2008. return
  2009. instance.emitted[handlerName] = true
  2010. callWithAsyncErrorHandling(
  2011. onceHandler,
  2012. instance,
  2013. 6,
  2014. args,
  2015. )
  2016. }
  2017. }
  2018. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2019. const cache = appContext.emitsCache
  2020. const cached = cache.get(comp)
  2021. if (cached !== void 0)
  2022. return cached
  2023. const raw = comp.emits
  2024. const normalized = {}
  2025. let hasExtends = false
  2026. if (!isFunction(comp)) {
  2027. const extendEmits = (raw2) => {
  2028. const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true)
  2029. if (normalizedFromExtend) {
  2030. hasExtends = true
  2031. extend(normalized, normalizedFromExtend)
  2032. }
  2033. }
  2034. if (!asMixin && appContext.mixins.length)
  2035. appContext.mixins.forEach(extendEmits)
  2036. if (comp.extends)
  2037. extendEmits(comp.extends)
  2038. if (comp.mixins)
  2039. comp.mixins.forEach(extendEmits)
  2040. }
  2041. if (!raw && !hasExtends) {
  2042. if (isObject(comp))
  2043. cache.set(comp, null)
  2044. return null
  2045. }
  2046. if (isArray(raw))
  2047. raw.forEach(key => normalized[key] = null)
  2048. else
  2049. extend(normalized, raw)
  2050. if (isObject(comp))
  2051. cache.set(comp, normalized)
  2052. return normalized
  2053. }
  2054. function isEmitListener(options, key) {
  2055. if (!options || !isOn(key))
  2056. return false
  2057. key = key.slice(2).replace(/Once$/, '')
  2058. return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key)
  2059. }
  2060. let currentRenderingInstance = null
  2061. let currentScopeId = null
  2062. function setCurrentRenderingInstance$1(instance) {
  2063. const prev = currentRenderingInstance
  2064. currentRenderingInstance = instance
  2065. currentScopeId = instance && instance.type.__scopeId || null
  2066. return prev
  2067. }
  2068. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
  2069. if (!ctx)
  2070. return fn
  2071. if (fn._n)
  2072. return fn
  2073. const renderFnWithContext = (...args) => {
  2074. if (renderFnWithContext._d)
  2075. setBlockTracking(-1)
  2076. const prevInstance = setCurrentRenderingInstance$1(ctx)
  2077. let res
  2078. try {
  2079. res = fn(...args)
  2080. }
  2081. finally {
  2082. setCurrentRenderingInstance$1(prevInstance)
  2083. if (renderFnWithContext._d)
  2084. setBlockTracking(1)
  2085. }
  2086. {
  2087. devtoolsComponentUpdated(ctx)
  2088. }
  2089. return res
  2090. }
  2091. renderFnWithContext._n = true
  2092. renderFnWithContext._c = true
  2093. renderFnWithContext._d = true
  2094. return renderFnWithContext
  2095. }
  2096. let accessedAttrs = false
  2097. function markAttrsAccessed() {
  2098. accessedAttrs = true
  2099. }
  2100. function renderComponentRoot$1(instance) {
  2101. const {
  2102. type: Component,
  2103. vnode,
  2104. proxy,
  2105. withProxy,
  2106. propsOptions: [propsOptions],
  2107. slots,
  2108. attrs,
  2109. emit,
  2110. render,
  2111. renderCache,
  2112. props,
  2113. data,
  2114. setupState,
  2115. ctx,
  2116. inheritAttrs,
  2117. } = instance
  2118. const prev = setCurrentRenderingInstance$1(instance)
  2119. let result
  2120. let fallthroughAttrs
  2121. {
  2122. accessedAttrs = false
  2123. }
  2124. try {
  2125. if (vnode.shapeFlag & 4) {
  2126. const proxyToUse = withProxy || proxy
  2127. const thisProxy = setupState.__isScriptSetup
  2128. ? new Proxy(proxyToUse, {
  2129. get(target, key, receiver) {
  2130. warn$1(
  2131. `Property '${String(
  2132. key,
  2133. )}' was accessed via 'this'. Avoid using 'this' in templates.`,
  2134. )
  2135. return Reflect.get(target, key, receiver)
  2136. },
  2137. })
  2138. : proxyToUse
  2139. result = normalizeVNode$1(
  2140. render.call(
  2141. thisProxy,
  2142. proxyToUse,
  2143. renderCache,
  2144. true ? shallowReadonly(props) : props,
  2145. setupState,
  2146. data,
  2147. ctx,
  2148. ),
  2149. )
  2150. fallthroughAttrs = attrs
  2151. }
  2152. else {
  2153. const render2 = Component
  2154. if (attrs === props)
  2155. markAttrsAccessed()
  2156. result = normalizeVNode$1(
  2157. render2.length > 1
  2158. ? render2(
  2159. true ? shallowReadonly(props) : props,
  2160. true
  2161. ? {
  2162. get attrs() {
  2163. markAttrsAccessed()
  2164. return shallowReadonly(attrs)
  2165. },
  2166. slots,
  2167. emit,
  2168. }
  2169. : { attrs, slots, emit },
  2170. )
  2171. : render2(
  2172. true ? shallowReadonly(props) : props,
  2173. null,
  2174. ),
  2175. )
  2176. fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs)
  2177. }
  2178. }
  2179. catch (err) {
  2180. handleError(err, instance, 1)
  2181. result = createVNode(Comment)
  2182. }
  2183. let root = result
  2184. let setRoot = void 0
  2185. if (result.patchFlag > 0 && result.patchFlag & 2048)
  2186. [root, setRoot] = getChildRoot(result)
  2187. if (fallthroughAttrs && inheritAttrs !== false) {
  2188. const keys = Object.keys(fallthroughAttrs)
  2189. const { shapeFlag } = root
  2190. if (keys.length) {
  2191. if (shapeFlag & (1 | 6)) {
  2192. if (propsOptions && keys.some(isModelListener)) {
  2193. fallthroughAttrs = filterModelListeners(
  2194. fallthroughAttrs,
  2195. propsOptions,
  2196. )
  2197. }
  2198. root = cloneVNode(root, fallthroughAttrs, false, true)
  2199. }
  2200. else if (!accessedAttrs && root.type !== Comment) {
  2201. const allAttrs = Object.keys(attrs)
  2202. const eventAttrs = []
  2203. const extraAttrs = []
  2204. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2205. const key = allAttrs[i]
  2206. if (isOn(key)) {
  2207. if (!isModelListener(key))
  2208. eventAttrs.push(key[2].toLowerCase() + key.slice(3))
  2209. }
  2210. else {
  2211. extraAttrs.push(key)
  2212. }
  2213. }
  2214. if (extraAttrs.length) {
  2215. warn$1(
  2216. `Extraneous non-props attributes (${extraAttrs.join(', ')}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`,
  2217. )
  2218. }
  2219. if (eventAttrs.length) {
  2220. warn$1(
  2221. `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.`,
  2222. )
  2223. }
  2224. }
  2225. }
  2226. }
  2227. if (vnode.dirs) {
  2228. if (!isElementRoot(root)) {
  2229. warn$1(
  2230. `Runtime directive used on component with non-element root node. The directives will not function as intended.`,
  2231. )
  2232. }
  2233. root = cloneVNode(root, null, false, true)
  2234. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs
  2235. }
  2236. if (vnode.transition) {
  2237. if (!isElementRoot(root)) {
  2238. warn$1(
  2239. `Component inside <Transition> renders non-element root node that cannot be animated.`,
  2240. )
  2241. }
  2242. root.transition = vnode.transition
  2243. }
  2244. if (setRoot)
  2245. setRoot(root)
  2246. else
  2247. result = root
  2248. setCurrentRenderingInstance$1(prev)
  2249. return result
  2250. }
  2251. function getChildRoot(vnode) {
  2252. const rawChildren = vnode.children
  2253. const dynamicChildren = vnode.dynamicChildren
  2254. const childRoot = filterSingleRoot(rawChildren, false)
  2255. if (!childRoot)
  2256. return [vnode, void 0]
  2257. else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048)
  2258. return getChildRoot(childRoot)
  2259. const index = rawChildren.indexOf(childRoot)
  2260. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1
  2261. const setRoot = (updatedRoot) => {
  2262. rawChildren[index] = updatedRoot
  2263. if (dynamicChildren) {
  2264. if (dynamicIndex > -1)
  2265. dynamicChildren[dynamicIndex] = updatedRoot
  2266. else if (updatedRoot.patchFlag > 0)
  2267. vnode.dynamicChildren = [...dynamicChildren, updatedRoot]
  2268. }
  2269. }
  2270. return [normalizeVNode$1(childRoot), setRoot]
  2271. }
  2272. function filterSingleRoot(children, recurse = true) {
  2273. let singleRoot
  2274. for (let i = 0; i < children.length; i++) {
  2275. const child = children[i]
  2276. if (isVNode$2(child)) {
  2277. if (child.type !== Comment || child.children === 'v-if') {
  2278. if (singleRoot) {
  2279. return
  2280. }
  2281. else {
  2282. singleRoot = child
  2283. if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048)
  2284. return filterSingleRoot(singleRoot.children)
  2285. }
  2286. }
  2287. }
  2288. else {
  2289. return
  2290. }
  2291. }
  2292. return singleRoot
  2293. }
  2294. function getFunctionalFallthrough(attrs) {
  2295. let res
  2296. for (const key in attrs) {
  2297. if (key === 'class' || key === 'style' || isOn(key))
  2298. (res || (res = {}))[key] = attrs[key]
  2299. }
  2300. return res
  2301. }
  2302. function filterModelListeners(attrs, props) {
  2303. const res = {}
  2304. for (const key in attrs) {
  2305. if (!isModelListener(key) || !(key.slice(9) in props))
  2306. res[key] = attrs[key]
  2307. }
  2308. return res
  2309. }
  2310. function isElementRoot(vnode) {
  2311. return vnode.shapeFlag & (6 | 1) || vnode.type === Comment
  2312. }
  2313. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2314. const { props: prevProps, children: prevChildren, component } = prevVNode
  2315. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode
  2316. const emits = component.emitsOptions
  2317. if ((prevChildren || nextChildren) && isHmrUpdating)
  2318. return true
  2319. if (nextVNode.dirs || nextVNode.transition)
  2320. return true
  2321. if (optimized && patchFlag >= 0) {
  2322. if (patchFlag & 1024)
  2323. return true
  2324. if (patchFlag & 16) {
  2325. if (!prevProps)
  2326. return !!nextProps
  2327. return hasPropsChanged(prevProps, nextProps, emits)
  2328. }
  2329. else if (patchFlag & 8) {
  2330. const dynamicProps = nextVNode.dynamicProps
  2331. for (let i = 0; i < dynamicProps.length; i++) {
  2332. const key = dynamicProps[i]
  2333. if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key))
  2334. return true
  2335. }
  2336. }
  2337. }
  2338. else {
  2339. if (prevChildren || nextChildren) {
  2340. if (!nextChildren || !nextChildren.$stable)
  2341. return true
  2342. }
  2343. if (prevProps === nextProps)
  2344. return false
  2345. if (!prevProps)
  2346. return !!nextProps
  2347. if (!nextProps)
  2348. return true
  2349. return hasPropsChanged(prevProps, nextProps, emits)
  2350. }
  2351. return false
  2352. }
  2353. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2354. const nextKeys = Object.keys(nextProps)
  2355. if (nextKeys.length !== Object.keys(prevProps).length)
  2356. return true
  2357. for (let i = 0; i < nextKeys.length; i++) {
  2358. const key = nextKeys[i]
  2359. if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key))
  2360. return true
  2361. }
  2362. return false
  2363. }
  2364. function updateHOCHostEl({ vnode, parent }, el) {
  2365. while (parent) {
  2366. const root = parent.subTree
  2367. if (root.suspense && root.suspense.activeBranch === vnode)
  2368. root.el = vnode.el
  2369. if (root === vnode) {
  2370. (vnode = parent.vnode).el = el
  2371. parent = parent.parent
  2372. }
  2373. else {
  2374. break
  2375. }
  2376. }
  2377. }
  2378. const NULL_DYNAMIC_COMPONENT = Symbol.for('v-ndc')
  2379. const isSuspense = type => type.__isSuspense
  2380. function queueEffectWithSuspense(fn, suspense) {
  2381. if (suspense && suspense.pendingBranch) {
  2382. if (isArray(fn))
  2383. suspense.effects.push(...fn)
  2384. else
  2385. suspense.effects.push(fn)
  2386. }
  2387. else {
  2388. queuePostFlushCb(fn)
  2389. }
  2390. }
  2391. const ssrContextKey = Symbol.for('v-scx')
  2392. function useSSRContext() {
  2393. {
  2394. const ctx = inject(ssrContextKey)
  2395. if (!ctx) {
  2396. warn$1(
  2397. `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`,
  2398. )
  2399. }
  2400. return ctx
  2401. }
  2402. }
  2403. const INITIAL_WATCHER_VALUE = {}
  2404. function watch(source, cb, options) {
  2405. if (!isFunction(cb)) {
  2406. warn$1(
  2407. `\`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.`,
  2408. )
  2409. }
  2410. return doWatch(source, cb, options)
  2411. }
  2412. function doWatch(source, cb, {
  2413. immediate,
  2414. deep,
  2415. flush,
  2416. once,
  2417. onTrack,
  2418. onTrigger,
  2419. } = EMPTY_OBJ) {
  2420. if (cb && once) {
  2421. const _cb = cb
  2422. cb = (...args) => {
  2423. _cb(...args)
  2424. unwatch()
  2425. }
  2426. }
  2427. if (deep !== void 0 && typeof deep === 'number') {
  2428. warn$1(
  2429. `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`,
  2430. )
  2431. }
  2432. if (!cb) {
  2433. if (immediate !== void 0) {
  2434. warn$1(
  2435. `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`,
  2436. )
  2437. }
  2438. if (deep !== void 0) {
  2439. warn$1(
  2440. `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`,
  2441. )
  2442. }
  2443. if (once !== void 0) {
  2444. warn$1(
  2445. `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`,
  2446. )
  2447. }
  2448. }
  2449. const warnInvalidSource = (s) => {
  2450. warn$1(
  2451. `Invalid watch source: `,
  2452. s,
  2453. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`,
  2454. )
  2455. }
  2456. const instance = currentInstance
  2457. const reactiveGetter = source2 => deep === true ? source2 : (
  2458. // for deep: false, only traverse root-level properties
  2459. traverse(source2, deep === false ? 1 : void 0)
  2460. )
  2461. let getter
  2462. let forceTrigger = false
  2463. let isMultiSource = false
  2464. if (isRef(source)) {
  2465. getter = () => source.value
  2466. forceTrigger = isShallow(source)
  2467. }
  2468. else if (isReactive(source)) {
  2469. getter = () => reactiveGetter(source)
  2470. forceTrigger = true
  2471. }
  2472. else if (isArray(source)) {
  2473. isMultiSource = true
  2474. forceTrigger = source.some(s => isReactive(s) || isShallow(s))
  2475. getter = () => source.map((s) => {
  2476. if (isRef(s))
  2477. return s.value
  2478. else if (isReactive(s))
  2479. return reactiveGetter(s)
  2480. else if (isFunction(s))
  2481. return callWithErrorHandling(s, instance, 2)
  2482. else
  2483. warnInvalidSource(s)
  2484. })
  2485. }
  2486. else if (isFunction(source)) {
  2487. if (cb) {
  2488. getter = () => callWithErrorHandling(source, instance, 2)
  2489. }
  2490. else {
  2491. getter = () => {
  2492. if (cleanup)
  2493. cleanup()
  2494. return callWithAsyncErrorHandling(
  2495. source,
  2496. instance,
  2497. 3,
  2498. [onCleanup],
  2499. )
  2500. }
  2501. }
  2502. }
  2503. else {
  2504. getter = NOOP
  2505. warnInvalidSource(source)
  2506. }
  2507. if (cb && deep) {
  2508. const baseGetter = getter
  2509. getter = () => traverse(baseGetter())
  2510. }
  2511. let cleanup
  2512. let onCleanup = (fn) => {
  2513. cleanup = effect.onStop = () => {
  2514. callWithErrorHandling(fn, instance, 4)
  2515. cleanup = effect.onStop = void 0
  2516. }
  2517. }
  2518. let ssrCleanup
  2519. if (isInSSRComponentSetup) {
  2520. onCleanup = NOOP
  2521. if (!cb) {
  2522. getter()
  2523. }
  2524. else if (immediate) {
  2525. callWithAsyncErrorHandling(cb, instance, 3, [
  2526. getter(),
  2527. isMultiSource ? [] : void 0,
  2528. onCleanup,
  2529. ])
  2530. }
  2531. if (flush === 'sync') {
  2532. const ctx = useSSRContext()
  2533. ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = [])
  2534. }
  2535. else {
  2536. return NOOP
  2537. }
  2538. }
  2539. let oldValue = isMultiSource ? Array.from({ length: source.length }).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE
  2540. const job = () => {
  2541. if (!effect.active || !effect.dirty)
  2542. return
  2543. if (cb) {
  2544. const newValue = effect.run()
  2545. if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
  2546. if (cleanup)
  2547. cleanup()
  2548. callWithAsyncErrorHandling(cb, instance, 3, [
  2549. newValue,
  2550. // pass undefined as the old value when it's changed for the first time
  2551. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  2552. onCleanup,
  2553. ])
  2554. oldValue = newValue
  2555. }
  2556. }
  2557. else {
  2558. effect.run()
  2559. }
  2560. }
  2561. job.allowRecurse = !!cb
  2562. let scheduler
  2563. if (flush === 'sync') {
  2564. scheduler = job
  2565. }
  2566. else if (flush === 'post') {
  2567. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense)
  2568. }
  2569. else {
  2570. job.pre = true
  2571. if (instance)
  2572. job.id = instance.uid
  2573. scheduler = () => queueJob(job)
  2574. }
  2575. const effect = new ReactiveEffect(getter, NOOP, scheduler)
  2576. const scope = getCurrentScope()
  2577. const unwatch = () => {
  2578. effect.stop()
  2579. if (scope)
  2580. remove(scope.effects, effect)
  2581. }
  2582. {
  2583. effect.onTrack = onTrack
  2584. effect.onTrigger = onTrigger
  2585. }
  2586. if (cb) {
  2587. if (immediate)
  2588. job()
  2589. else
  2590. oldValue = effect.run()
  2591. }
  2592. else if (flush === 'post') {
  2593. queuePostRenderEffect(
  2594. effect.run.bind(effect),
  2595. instance && instance.suspense,
  2596. )
  2597. }
  2598. else {
  2599. effect.run()
  2600. }
  2601. if (ssrCleanup)
  2602. ssrCleanup.push(unwatch)
  2603. return unwatch
  2604. }
  2605. function instanceWatch(source, value, options) {
  2606. const publicThis = this.proxy
  2607. const getter = isString(source) ? source.includes('.') ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis)
  2608. let cb
  2609. if (isFunction(value)) {
  2610. cb = value
  2611. }
  2612. else {
  2613. cb = value.handler
  2614. options = value
  2615. }
  2616. const reset = setCurrentInstance(this)
  2617. const res = doWatch(getter, cb.bind(publicThis), options)
  2618. reset()
  2619. return res
  2620. }
  2621. function createPathGetter(ctx, path) {
  2622. const segments = path.split('.')
  2623. return () => {
  2624. let cur = ctx
  2625. for (let i = 0; i < segments.length && cur; i++)
  2626. cur = cur[segments[i]]
  2627. return cur
  2628. }
  2629. }
  2630. function traverse(value, depth = Number.POSITIVE_INFINITY, seen) {
  2631. if (depth <= 0 || !isObject(value) || value.__v_skip)
  2632. return value
  2633. seen = seen || /* @__PURE__ */ new Set()
  2634. if (seen.has(value))
  2635. return value
  2636. seen.add(value)
  2637. depth--
  2638. if (isRef(value)) {
  2639. traverse(value.value, depth, seen)
  2640. }
  2641. else if (isArray(value)) {
  2642. for (let i = 0; i < value.length; i++)
  2643. traverse(value[i], depth, seen)
  2644. }
  2645. else if (isSet(value) || isMap(value)) {
  2646. value.forEach((v) => {
  2647. traverse(v, depth, seen)
  2648. })
  2649. }
  2650. else if (isPlainObject(value)) {
  2651. for (const key in value)
  2652. traverse(value[key], depth, seen)
  2653. }
  2654. return value
  2655. }
  2656. function validateDirectiveName(name) {
  2657. if (isBuiltInDirective(name))
  2658. warn$1(`Do not use built-in directive ids as custom directive id: ${name}`)
  2659. }
  2660. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  2661. const bindings = vnode.dirs
  2662. const oldBindings = prevVNode && prevVNode.dirs
  2663. for (let i = 0; i < bindings.length; i++) {
  2664. const binding = bindings[i]
  2665. if (oldBindings)
  2666. binding.oldValue = oldBindings[i].value
  2667. const hook = binding.dir[name]
  2668. if (hook) {
  2669. pauseTracking()
  2670. callWithAsyncErrorHandling(hook, instance, 8, [
  2671. vnode.el,
  2672. binding,
  2673. vnode,
  2674. prevVNode,
  2675. ])
  2676. resetTracking()
  2677. }
  2678. }
  2679. }
  2680. const isAsyncWrapper = i => !!i.type.__asyncLoader
  2681. const isKeepAlive = vnode => vnode.type.__isKeepAlive
  2682. function onActivated(hook, target) {
  2683. registerKeepAliveHook(hook, 'a', target)
  2684. }
  2685. function onDeactivated(hook, target) {
  2686. registerKeepAliveHook(hook, 'da', target)
  2687. }
  2688. function registerKeepAliveHook(hook, type, target = currentInstance) {
  2689. const wrappedHook = hook.__wdc || (hook.__wdc = () => {
  2690. let current = target
  2691. while (current) {
  2692. if (current.isDeactivated)
  2693. return
  2694. current = current.parent
  2695. }
  2696. return hook()
  2697. })
  2698. injectHook(type, wrappedHook, target)
  2699. if (target) {
  2700. let current = target.parent
  2701. while (current && current.parent) {
  2702. if (isKeepAlive(current.parent.vnode))
  2703. injectToKeepAliveRoot(wrappedHook, type, target, current)
  2704. current = current.parent
  2705. }
  2706. }
  2707. }
  2708. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  2709. const injected = injectHook(
  2710. type,
  2711. hook,
  2712. keepAliveRoot,
  2713. true,
  2714. /* prepend */
  2715. )
  2716. onUnmounted(() => {
  2717. remove(keepAliveRoot[type], injected)
  2718. }, target)
  2719. }
  2720. function injectHook(type, hook, target = currentInstance, prepend = false) {
  2721. if (target) {
  2722. const hooks = target[type] || (target[type] = [])
  2723. const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
  2724. if (target.isUnmounted)
  2725. return
  2726. pauseTracking()
  2727. const reset = setCurrentInstance(target)
  2728. const res = callWithAsyncErrorHandling(hook, target, type, args)
  2729. reset()
  2730. resetTracking()
  2731. return res
  2732. })
  2733. if (prepend)
  2734. hooks.unshift(wrappedHook)
  2735. else
  2736. hooks.push(wrappedHook)
  2737. return wrappedHook
  2738. }
  2739. else {
  2740. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''))
  2741. warn$1(
  2742. `${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.`),
  2743. )
  2744. }
  2745. }
  2746. function createHook(lifecycle) {
  2747. return (hook, target = currentInstance) => {
  2748. if (!isInSSRComponentSetup || lifecycle === 'sp')
  2749. injectHook(lifecycle, (...args) => hook(...args), target)
  2750. }
  2751. }
  2752. const onBeforeMount = createHook('bm')
  2753. const onMounted = createHook('m')
  2754. const onBeforeUpdate = createHook('bu')
  2755. const onUpdated = createHook('u')
  2756. const onBeforeUnmount = createHook('bum')
  2757. const onUnmounted = createHook('um')
  2758. const onServerPrefetch = createHook('sp')
  2759. const onRenderTriggered = createHook(
  2760. 'rtg',
  2761. )
  2762. const onRenderTracked = createHook(
  2763. 'rtc',
  2764. )
  2765. function onErrorCaptured(hook, target = currentInstance) {
  2766. injectHook('ec', hook, target)
  2767. }
  2768. function getPublicInstance(i) {
  2769. if (!i)
  2770. return null
  2771. if (isStatefulComponent(i))
  2772. return getExposeProxy(i) || i.proxy
  2773. return getPublicInstance(i.parent)
  2774. }
  2775. const publicPropertiesMap = (
  2776. // Move PURE marker to new line to workaround compiler discarding it
  2777. // due to type annotation
  2778. /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
  2779. $: i => i,
  2780. $el: i => i.vnode.el,
  2781. $data: i => i.data,
  2782. $props: i => shallowReadonly(i.props),
  2783. $attrs: i => shallowReadonly(i.attrs),
  2784. $slots: i => shallowReadonly(i.slots),
  2785. $refs: i => shallowReadonly(i.refs),
  2786. $parent: i => getPublicInstance(i.parent),
  2787. $root: i => getPublicInstance(i.root),
  2788. $emit: i => i.emit,
  2789. $options: i => resolveMergedOptions(i),
  2790. $forceUpdate: i => i.f || (i.f = () => {
  2791. i.effect.dirty = true
  2792. queueJob(i.update)
  2793. }),
  2794. $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
  2795. $watch: i => instanceWatch.bind(i),
  2796. })
  2797. )
  2798. const isReservedPrefix = key => key === '_' || key === '$'
  2799. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key)
  2800. const PublicInstanceProxyHandlers = {
  2801. get({ _: instance }, key) {
  2802. if (key === '__v_skip')
  2803. return true
  2804. const { ctx, setupState, data, props, accessCache, type, appContext } = instance
  2805. if (key === '__isVue')
  2806. return true
  2807. let normalizedProps
  2808. if (key[0] !== '$') {
  2809. const n = accessCache[key]
  2810. if (n !== void 0) {
  2811. switch (n) {
  2812. case 1 /* SETUP */:
  2813. return setupState[key]
  2814. case 2 /* DATA */:
  2815. return data[key]
  2816. case 4 /* CONTEXT */:
  2817. return ctx[key]
  2818. case 3 /* PROPS */:
  2819. return props[key]
  2820. }
  2821. }
  2822. else if (hasSetupBinding(setupState, key)) {
  2823. accessCache[key] = 1 /* SETUP */
  2824. return setupState[key]
  2825. }
  2826. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  2827. accessCache[key] = 2 /* DATA */
  2828. return data[key]
  2829. }
  2830. else if (
  2831. // only cache other properties when instance has declared (thus stable)
  2832. // props
  2833. (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
  2834. ) {
  2835. accessCache[key] = 3 /* PROPS */
  2836. return props[key]
  2837. }
  2838. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  2839. accessCache[key] = 4 /* CONTEXT */
  2840. return ctx[key]
  2841. }
  2842. else if (shouldCacheAccess) {
  2843. accessCache[key] = 0 /* OTHER */
  2844. }
  2845. }
  2846. const publicGetter = publicPropertiesMap[key]
  2847. let cssModule, globalProperties
  2848. if (publicGetter) {
  2849. if (key === '$attrs') {
  2850. track(instance.attrs, 'get', '')
  2851. markAttrsAccessed()
  2852. }
  2853. else if (key === '$slots') {
  2854. track(instance, 'get', key)
  2855. }
  2856. return publicGetter(instance)
  2857. }
  2858. else if (
  2859. // css module (injected by vue-loader)
  2860. (cssModule = type.__cssModules) && (cssModule = cssModule[key])
  2861. ) {
  2862. return cssModule
  2863. }
  2864. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  2865. accessCache[key] = 4 /* CONTEXT */
  2866. return ctx[key]
  2867. }
  2868. else if (
  2869. // global properties
  2870. globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
  2871. ) {
  2872. {
  2873. return globalProperties[key]
  2874. }
  2875. }
  2876. else if (currentRenderingInstance && (!isString(key) // #1091 avoid internal isRef/isVNode checks on component instance leading
  2877. // to infinite warning loop
  2878. || key.indexOf('__v') !== 0)) {
  2879. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  2880. warn$1(
  2881. `Property ${JSON.stringify(
  2882. key,
  2883. )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`,
  2884. )
  2885. }
  2886. else if (instance === currentRenderingInstance) {
  2887. warn$1(
  2888. `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`,
  2889. )
  2890. }
  2891. }
  2892. },
  2893. set({ _: instance }, key, value) {
  2894. const { data, setupState, ctx } = instance
  2895. if (hasSetupBinding(setupState, key)) {
  2896. setupState[key] = value
  2897. return true
  2898. }
  2899. else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
  2900. warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`)
  2901. return false
  2902. }
  2903. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  2904. data[key] = value
  2905. return true
  2906. }
  2907. else if (hasOwn(instance.props, key)) {
  2908. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`)
  2909. return false
  2910. }
  2911. if (key[0] === '$' && key.slice(1) in instance) {
  2912. warn$1(
  2913. `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`,
  2914. )
  2915. return false
  2916. }
  2917. else {
  2918. if (key in instance.appContext.config.globalProperties) {
  2919. Object.defineProperty(ctx, key, {
  2920. enumerable: true,
  2921. configurable: true,
  2922. value,
  2923. })
  2924. }
  2925. else {
  2926. ctx[key] = value
  2927. }
  2928. }
  2929. return true
  2930. },
  2931. has({
  2932. _: { data, setupState, accessCache, ctx, appContext, propsOptions },
  2933. }, key) {
  2934. let normalizedProps
  2935. 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)
  2936. },
  2937. defineProperty(target, key, descriptor) {
  2938. if (descriptor.get != null)
  2939. target._.accessCache[key] = 0
  2940. else if (hasOwn(descriptor, 'value'))
  2941. this.set(target, key, descriptor.value, null)
  2942. return Reflect.defineProperty(target, key, descriptor)
  2943. },
  2944. }
  2945. {
  2946. PublicInstanceProxyHandlers.ownKeys = (target) => {
  2947. warn$1(
  2948. `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`,
  2949. )
  2950. return Reflect.ownKeys(target)
  2951. }
  2952. }
  2953. function createDevRenderContext(instance) {
  2954. const target = {}
  2955. Object.defineProperty(target, `_`, {
  2956. configurable: true,
  2957. enumerable: false,
  2958. get: () => instance,
  2959. })
  2960. Object.keys(publicPropertiesMap).forEach((key) => {
  2961. Object.defineProperty(target, key, {
  2962. configurable: true,
  2963. enumerable: false,
  2964. get: () => publicPropertiesMap[key](instance),
  2965. // intercepted by the proxy so no need for implementation,
  2966. // but needed to prevent set errors
  2967. set: NOOP,
  2968. })
  2969. })
  2970. return target
  2971. }
  2972. function exposePropsOnRenderContext(instance) {
  2973. const {
  2974. ctx,
  2975. propsOptions: [propsOptions],
  2976. } = instance
  2977. if (propsOptions) {
  2978. Object.keys(propsOptions).forEach((key) => {
  2979. Object.defineProperty(ctx, key, {
  2980. enumerable: true,
  2981. configurable: true,
  2982. get: () => instance.props[key],
  2983. set: NOOP,
  2984. })
  2985. })
  2986. }
  2987. }
  2988. function exposeSetupStateOnRenderContext(instance) {
  2989. const { ctx, setupState } = instance
  2990. Object.keys(toRaw(setupState)).forEach((key) => {
  2991. if (!setupState.__isScriptSetup) {
  2992. if (isReservedPrefix(key[0])) {
  2993. warn$1(
  2994. `setup() return property ${JSON.stringify(
  2995. key,
  2996. )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`,
  2997. )
  2998. return
  2999. }
  3000. Object.defineProperty(ctx, key, {
  3001. enumerable: true,
  3002. configurable: true,
  3003. get: () => setupState[key],
  3004. set: NOOP,
  3005. })
  3006. }
  3007. })
  3008. }
  3009. function normalizePropsOrEmits(props) {
  3010. return isArray(props)
  3011. ? props.reduce(
  3012. (normalized, p) => (normalized[p] = null, normalized),
  3013. {},
  3014. )
  3015. : props
  3016. }
  3017. function createDuplicateChecker() {
  3018. const cache = /* @__PURE__ */ Object.create(null)
  3019. return (type, key) => {
  3020. if (cache[key])
  3021. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`)
  3022. else
  3023. cache[key] = type
  3024. }
  3025. }
  3026. let shouldCacheAccess = true
  3027. function applyOptions(instance) {
  3028. const options = resolveMergedOptions(instance)
  3029. const publicThis = instance.proxy
  3030. const ctx = instance.ctx
  3031. shouldCacheAccess = false
  3032. if (options.beforeCreate)
  3033. callHook(options.beforeCreate, instance, 'bc')
  3034. const {
  3035. // state
  3036. data: dataOptions,
  3037. computed: computedOptions,
  3038. methods,
  3039. watch: watchOptions,
  3040. provide: provideOptions,
  3041. inject: injectOptions,
  3042. // lifecycle
  3043. created,
  3044. beforeMount,
  3045. mounted,
  3046. beforeUpdate,
  3047. updated,
  3048. activated,
  3049. deactivated,
  3050. beforeDestroy,
  3051. beforeUnmount,
  3052. destroyed,
  3053. unmounted,
  3054. render,
  3055. renderTracked,
  3056. renderTriggered,
  3057. errorCaptured,
  3058. serverPrefetch,
  3059. // public API
  3060. expose,
  3061. inheritAttrs,
  3062. // assets
  3063. components,
  3064. directives,
  3065. filters,
  3066. } = options
  3067. const checkDuplicateProperties = createDuplicateChecker()
  3068. {
  3069. const [propsOptions] = instance.propsOptions
  3070. if (propsOptions) {
  3071. for (const key in propsOptions)
  3072. checkDuplicateProperties('Props' /* PROPS */, key)
  3073. }
  3074. }
  3075. if (injectOptions)
  3076. resolveInjections(injectOptions, ctx, checkDuplicateProperties)
  3077. if (methods) {
  3078. for (const key in methods) {
  3079. const methodHandler = methods[key]
  3080. if (isFunction(methodHandler)) {
  3081. {
  3082. Object.defineProperty(ctx, key, {
  3083. value: methodHandler.bind(publicThis),
  3084. configurable: true,
  3085. enumerable: true,
  3086. writable: true,
  3087. })
  3088. }
  3089. {
  3090. checkDuplicateProperties('Methods' /* METHODS */, key)
  3091. }
  3092. }
  3093. else {
  3094. warn$1(
  3095. `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`,
  3096. )
  3097. }
  3098. }
  3099. }
  3100. if (dataOptions) {
  3101. if (!isFunction(dataOptions)) {
  3102. warn$1(
  3103. `The data option must be a function. Plain object usage is no longer supported.`,
  3104. )
  3105. }
  3106. const data = dataOptions.call(publicThis, publicThis)
  3107. if (isPromise(data)) {
  3108. warn$1(
  3109. `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`,
  3110. )
  3111. }
  3112. if (!isObject(data)) {
  3113. warn$1(`data() should return an object.`)
  3114. }
  3115. else {
  3116. instance.data = reactive(data)
  3117. {
  3118. for (const key in data) {
  3119. checkDuplicateProperties('Data' /* DATA */, key)
  3120. if (!isReservedPrefix(key[0])) {
  3121. Object.defineProperty(ctx, key, {
  3122. configurable: true,
  3123. enumerable: true,
  3124. get: () => data[key],
  3125. set: NOOP,
  3126. })
  3127. }
  3128. }
  3129. }
  3130. }
  3131. }
  3132. shouldCacheAccess = true
  3133. if (computedOptions) {
  3134. for (const key in computedOptions) {
  3135. const opt = computedOptions[key]
  3136. const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP
  3137. if (get === NOOP)
  3138. warn$1(`Computed property "${key}" has no getter.`)
  3139. const set = !isFunction(opt) && isFunction(opt.set)
  3140. ? opt.set.bind(publicThis)
  3141. : () => {
  3142. warn$1(
  3143. `Write operation failed: computed property "${key}" is readonly.`,
  3144. )
  3145. }
  3146. const c = computed({
  3147. get,
  3148. set,
  3149. })
  3150. Object.defineProperty(ctx, key, {
  3151. enumerable: true,
  3152. configurable: true,
  3153. get: () => c.value,
  3154. set: v => c.value = v,
  3155. })
  3156. {
  3157. checkDuplicateProperties('Computed' /* COMPUTED */, key)
  3158. }
  3159. }
  3160. }
  3161. if (watchOptions) {
  3162. for (const key in watchOptions)
  3163. createWatcher(watchOptions[key], ctx, publicThis, key)
  3164. }
  3165. if (provideOptions) {
  3166. const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions
  3167. Reflect.ownKeys(provides).forEach((key) => {
  3168. provide(key, provides[key])
  3169. })
  3170. }
  3171. if (created)
  3172. callHook(created, instance, 'c')
  3173. function registerLifecycleHook(register, hook) {
  3174. if (isArray(hook))
  3175. hook.forEach(_hook => register(_hook.bind(publicThis)))
  3176. else if (hook)
  3177. register(hook.bind(publicThis))
  3178. }
  3179. registerLifecycleHook(onBeforeMount, beforeMount)
  3180. registerLifecycleHook(onMounted, mounted)
  3181. registerLifecycleHook(onBeforeUpdate, beforeUpdate)
  3182. registerLifecycleHook(onUpdated, updated)
  3183. registerLifecycleHook(onActivated, activated)
  3184. registerLifecycleHook(onDeactivated, deactivated)
  3185. registerLifecycleHook(onErrorCaptured, errorCaptured)
  3186. registerLifecycleHook(onRenderTracked, renderTracked)
  3187. registerLifecycleHook(onRenderTriggered, renderTriggered)
  3188. registerLifecycleHook(onBeforeUnmount, beforeUnmount)
  3189. registerLifecycleHook(onUnmounted, unmounted)
  3190. registerLifecycleHook(onServerPrefetch, serverPrefetch)
  3191. if (isArray(expose)) {
  3192. if (expose.length) {
  3193. const exposed = instance.exposed || (instance.exposed = {})
  3194. expose.forEach((key) => {
  3195. Object.defineProperty(exposed, key, {
  3196. get: () => publicThis[key],
  3197. set: val => publicThis[key] = val,
  3198. })
  3199. })
  3200. }
  3201. else if (!instance.exposed) {
  3202. instance.exposed = {}
  3203. }
  3204. }
  3205. if (render && instance.render === NOOP)
  3206. instance.render = render
  3207. if (inheritAttrs != null)
  3208. instance.inheritAttrs = inheritAttrs
  3209. if (components)
  3210. instance.components = components
  3211. if (directives)
  3212. instance.directives = directives
  3213. }
  3214. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
  3215. if (isArray(injectOptions))
  3216. injectOptions = normalizeInject(injectOptions)
  3217. for (const key in injectOptions) {
  3218. const opt = injectOptions[key]
  3219. let injected
  3220. if (isObject(opt)) {
  3221. if ('default' in opt) {
  3222. injected = inject(
  3223. opt.from || key,
  3224. opt.default,
  3225. true,
  3226. )
  3227. }
  3228. else {
  3229. injected = inject(opt.from || key)
  3230. }
  3231. }
  3232. else {
  3233. injected = inject(opt)
  3234. }
  3235. if (isRef(injected)) {
  3236. Object.defineProperty(ctx, key, {
  3237. enumerable: true,
  3238. configurable: true,
  3239. get: () => injected.value,
  3240. set: v => injected.value = v,
  3241. })
  3242. }
  3243. else {
  3244. ctx[key] = injected
  3245. }
  3246. {
  3247. checkDuplicateProperties('Inject' /* INJECT */, key)
  3248. }
  3249. }
  3250. }
  3251. function callHook(hook, instance, type) {
  3252. callWithAsyncErrorHandling(
  3253. isArray(hook) ? hook.map(h => h.bind(instance.proxy)) : hook.bind(instance.proxy),
  3254. instance,
  3255. type,
  3256. )
  3257. }
  3258. function createWatcher(raw, ctx, publicThis, key) {
  3259. const getter = key.includes('.') ? createPathGetter(publicThis, key) : () => publicThis[key]
  3260. if (isString(raw)) {
  3261. const handler = ctx[raw]
  3262. if (isFunction(handler))
  3263. watch(getter, handler)
  3264. else
  3265. warn$1(`Invalid watch handler specified by key "${raw}"`, handler)
  3266. }
  3267. else if (isFunction(raw)) {
  3268. watch(getter, raw.bind(publicThis))
  3269. }
  3270. else if (isObject(raw)) {
  3271. if (isArray(raw)) {
  3272. raw.forEach(r => createWatcher(r, ctx, publicThis, key))
  3273. }
  3274. else {
  3275. const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler]
  3276. if (isFunction(handler))
  3277. watch(getter, handler, raw)
  3278. else
  3279. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler)
  3280. }
  3281. }
  3282. else {
  3283. warn$1(`Invalid watch option: "${key}"`, raw)
  3284. }
  3285. }
  3286. function resolveMergedOptions(instance) {
  3287. const base = instance.type
  3288. const { mixins, extends: extendsOptions } = base
  3289. const {
  3290. mixins: globalMixins,
  3291. optionsCache: cache,
  3292. config: { optionMergeStrategies },
  3293. } = instance.appContext
  3294. const cached = cache.get(base)
  3295. let resolved
  3296. if (cached) {
  3297. resolved = cached
  3298. }
  3299. else if (!globalMixins.length && !mixins && !extendsOptions) {
  3300. {
  3301. resolved = base
  3302. }
  3303. }
  3304. else {
  3305. resolved = {}
  3306. if (globalMixins.length) {
  3307. globalMixins.forEach(
  3308. m => mergeOptions(resolved, m, optionMergeStrategies, true),
  3309. )
  3310. }
  3311. mergeOptions(resolved, base, optionMergeStrategies)
  3312. }
  3313. if (isObject(base))
  3314. cache.set(base, resolved)
  3315. return resolved
  3316. }
  3317. function mergeOptions(to, from, strats, asMixin = false) {
  3318. const { mixins, extends: extendsOptions } = from
  3319. if (extendsOptions)
  3320. mergeOptions(to, extendsOptions, strats, true)
  3321. if (mixins) {
  3322. mixins.forEach(
  3323. m => mergeOptions(to, m, strats, true),
  3324. )
  3325. }
  3326. for (const key in from) {
  3327. if (asMixin && key === 'expose') {
  3328. warn$1(
  3329. `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`,
  3330. )
  3331. }
  3332. else {
  3333. const strat = internalOptionMergeStrats[key] || strats && strats[key]
  3334. to[key] = strat ? strat(to[key], from[key]) : from[key]
  3335. }
  3336. }
  3337. return to
  3338. }
  3339. const internalOptionMergeStrats = {
  3340. data: mergeDataFn,
  3341. props: mergeEmitsOrPropsOptions,
  3342. emits: mergeEmitsOrPropsOptions,
  3343. // objects
  3344. methods: mergeObjectOptions,
  3345. computed: mergeObjectOptions,
  3346. // lifecycle
  3347. beforeCreate: mergeAsArray,
  3348. created: mergeAsArray,
  3349. beforeMount: mergeAsArray,
  3350. mounted: mergeAsArray,
  3351. beforeUpdate: mergeAsArray,
  3352. updated: mergeAsArray,
  3353. beforeDestroy: mergeAsArray,
  3354. beforeUnmount: mergeAsArray,
  3355. destroyed: mergeAsArray,
  3356. unmounted: mergeAsArray,
  3357. activated: mergeAsArray,
  3358. deactivated: mergeAsArray,
  3359. errorCaptured: mergeAsArray,
  3360. serverPrefetch: mergeAsArray,
  3361. // assets
  3362. components: mergeObjectOptions,
  3363. directives: mergeObjectOptions,
  3364. // watch
  3365. watch: mergeWatchOptions,
  3366. // provide / inject
  3367. provide: mergeDataFn,
  3368. inject: mergeInject,
  3369. }
  3370. function mergeDataFn(to, from) {
  3371. if (!from)
  3372. return to
  3373. if (!to)
  3374. return from
  3375. return function mergedDataFn() {
  3376. return (extend)(
  3377. isFunction(to) ? to.call(this, this) : to,
  3378. isFunction(from) ? from.call(this, this) : from,
  3379. )
  3380. }
  3381. }
  3382. function mergeInject(to, from) {
  3383. return mergeObjectOptions(normalizeInject(to), normalizeInject(from))
  3384. }
  3385. function normalizeInject(raw) {
  3386. if (isArray(raw)) {
  3387. const res = {}
  3388. for (let i = 0; i < raw.length; i++)
  3389. res[raw[i]] = raw[i]
  3390. return res
  3391. }
  3392. return raw
  3393. }
  3394. function mergeAsArray(to, from) {
  3395. return to ? [...new Set([].concat(to, from))] : from
  3396. }
  3397. function mergeObjectOptions(to, from) {
  3398. return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from
  3399. }
  3400. function mergeEmitsOrPropsOptions(to, from) {
  3401. if (to) {
  3402. if (isArray(to) && isArray(from))
  3403. return [...new Set([...to, ...from])]
  3404. return extend(
  3405. /* @__PURE__ */ Object.create(null),
  3406. normalizePropsOrEmits(to),
  3407. normalizePropsOrEmits(from != null ? from : {}),
  3408. )
  3409. }
  3410. else {
  3411. return from
  3412. }
  3413. }
  3414. function mergeWatchOptions(to, from) {
  3415. if (!to)
  3416. return from
  3417. if (!from)
  3418. return to
  3419. const merged = extend(/* @__PURE__ */ Object.create(null), to)
  3420. for (const key in from)
  3421. merged[key] = mergeAsArray(to[key], from[key])
  3422. return merged
  3423. }
  3424. function createAppContext() {
  3425. return {
  3426. app: null,
  3427. config: {
  3428. isNativeTag: NO,
  3429. performance: false,
  3430. globalProperties: {},
  3431. optionMergeStrategies: {},
  3432. errorHandler: void 0,
  3433. warnHandler: void 0,
  3434. compilerOptions: {},
  3435. },
  3436. mixins: [],
  3437. components: {},
  3438. directives: {},
  3439. provides: /* @__PURE__ */ Object.create(null),
  3440. optionsCache: /* @__PURE__ */ new WeakMap(),
  3441. propsCache: /* @__PURE__ */ new WeakMap(),
  3442. emitsCache: /* @__PURE__ */ new WeakMap(),
  3443. }
  3444. }
  3445. let uid$1 = 0
  3446. function createAppAPI(render, hydrate) {
  3447. return function createApp(rootComponent, rootProps = null) {
  3448. if (!isFunction(rootComponent))
  3449. rootComponent = extend({}, rootComponent)
  3450. if (rootProps != null && !isObject(rootProps)) {
  3451. warn$1(`root props passed to app.mount() must be an object.`)
  3452. rootProps = null
  3453. }
  3454. const context = createAppContext()
  3455. const installedPlugins = /* @__PURE__ */ new WeakSet()
  3456. let isMounted = false
  3457. const app = context.app = {
  3458. _uid: uid$1++,
  3459. _component: rootComponent,
  3460. _props: rootProps,
  3461. _container: null,
  3462. _context: context,
  3463. _instance: null,
  3464. version,
  3465. get config() {
  3466. return context.config
  3467. },
  3468. set config(v) {
  3469. {
  3470. warn$1(
  3471. `app.config cannot be replaced. Modify individual options instead.`,
  3472. )
  3473. }
  3474. },
  3475. use(plugin, ...options) {
  3476. if (installedPlugins.has(plugin)) {
  3477. warn$1(`Plugin has already been applied to target app.`)
  3478. }
  3479. else if (plugin && isFunction(plugin.install)) {
  3480. installedPlugins.add(plugin)
  3481. plugin.install(app, ...options)
  3482. }
  3483. else if (isFunction(plugin)) {
  3484. installedPlugins.add(plugin)
  3485. plugin(app, ...options)
  3486. }
  3487. else {
  3488. warn$1(
  3489. `A plugin must either be a function or an object with an "install" function.`,
  3490. )
  3491. }
  3492. return app
  3493. },
  3494. mixin(mixin) {
  3495. {
  3496. if (!context.mixins.includes(mixin)) {
  3497. context.mixins.push(mixin)
  3498. }
  3499. else {
  3500. warn$1(
  3501. `Mixin has already been applied to target app${mixin.name ? `: ${mixin.name}` : ''}`,
  3502. )
  3503. }
  3504. }
  3505. return app
  3506. },
  3507. component(name, component) {
  3508. {
  3509. validateComponentName(name, context.config)
  3510. }
  3511. if (!component)
  3512. return context.components[name]
  3513. if (context.components[name])
  3514. warn$1(`Component "${name}" has already been registered in target app.`)
  3515. context.components[name] = component
  3516. return app
  3517. },
  3518. directive(name, directive) {
  3519. {
  3520. validateDirectiveName(name)
  3521. }
  3522. if (!directive)
  3523. return context.directives[name]
  3524. if (context.directives[name])
  3525. warn$1(`Directive "${name}" has already been registered in target app.`)
  3526. context.directives[name] = directive
  3527. return app
  3528. },
  3529. mount(rootContainer, isHydrate, namespace) {
  3530. if (!isMounted) {
  3531. if (rootContainer.__vue_app__) {
  3532. warn$1(
  3533. `There is already an app instance mounted on the host container.
  3534. If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`,
  3535. )
  3536. }
  3537. const vnode = createVNode(rootComponent, rootProps)
  3538. vnode.appContext = context
  3539. if (namespace === true)
  3540. namespace = 'svg'
  3541. else if (namespace === false)
  3542. namespace = void 0
  3543. {
  3544. context.reload = () => {
  3545. render(
  3546. cloneVNode(vnode),
  3547. rootContainer,
  3548. namespace,
  3549. )
  3550. }
  3551. }
  3552. if (isHydrate && hydrate)
  3553. hydrate(vnode, rootContainer)
  3554. else
  3555. render(vnode, rootContainer, namespace)
  3556. isMounted = true
  3557. app._container = rootContainer
  3558. rootContainer.__vue_app__ = app
  3559. {
  3560. app._instance = vnode.component
  3561. devtoolsInitApp(app, version)
  3562. }
  3563. return getExposeProxy(vnode.component) || vnode.component.proxy
  3564. }
  3565. else {
  3566. warn$1(
  3567. `App has already been mounted.
  3568. 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)\``,
  3569. )
  3570. }
  3571. },
  3572. unmount() {
  3573. if (isMounted) {
  3574. render(null, app._container)
  3575. {
  3576. app._instance = null
  3577. devtoolsUnmountApp(app)
  3578. }
  3579. delete app._container.__vue_app__
  3580. }
  3581. else {
  3582. warn$1(`Cannot unmount an app that is not mounted.`)
  3583. }
  3584. },
  3585. provide(key, value) {
  3586. if (key in context.provides) {
  3587. warn$1(
  3588. `App already provides property with key "${String(key)}". It will be overwritten with the new value.`,
  3589. )
  3590. }
  3591. context.provides[key] = value
  3592. return app
  3593. },
  3594. runWithContext(fn) {
  3595. const lastApp = currentApp
  3596. currentApp = app
  3597. try {
  3598. return fn()
  3599. }
  3600. finally {
  3601. currentApp = lastApp
  3602. }
  3603. },
  3604. }
  3605. return app
  3606. }
  3607. }
  3608. let currentApp = null
  3609. function provide(key, value) {
  3610. if (!currentInstance) {
  3611. {
  3612. warn$1(`provide() can only be used inside setup().`)
  3613. }
  3614. }
  3615. else {
  3616. let provides = currentInstance.provides
  3617. const parentProvides = currentInstance.parent && currentInstance.parent.provides
  3618. if (parentProvides === provides)
  3619. provides = currentInstance.provides = Object.create(parentProvides)
  3620. provides[key] = value
  3621. }
  3622. }
  3623. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3624. const instance = currentInstance || currentRenderingInstance
  3625. if (instance || currentApp) {
  3626. const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides
  3627. if (provides && key in provides)
  3628. return provides[key]
  3629. else if (arguments.length > 1)
  3630. return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue
  3631. else
  3632. warn$1(`injection "${String(key)}" not found.`)
  3633. }
  3634. else {
  3635. warn$1(`inject() can only be used inside setup() or functional components.`)
  3636. }
  3637. }
  3638. const internalObjectProto = {}
  3639. const createInternalObject = () => Object.create(internalObjectProto)
  3640. const isInternalObject = obj => Object.getPrototypeOf(obj) === internalObjectProto
  3641. function initProps(instance, rawProps, isStateful, isSSR = false) {
  3642. const props = {}
  3643. const attrs = createInternalObject()
  3644. instance.propsDefaults = /* @__PURE__ */ Object.create(null)
  3645. setFullProps(instance, rawProps, props, attrs)
  3646. for (const key in instance.propsOptions[0]) {
  3647. if (!(key in props))
  3648. props[key] = void 0
  3649. }
  3650. {
  3651. validateProps(rawProps || {}, props, instance)
  3652. }
  3653. if (isStateful) {
  3654. instance.props = isSSR ? props : shallowReactive(props)
  3655. }
  3656. else {
  3657. if (!instance.type.props)
  3658. instance.props = attrs
  3659. else
  3660. instance.props = props
  3661. }
  3662. instance.attrs = attrs
  3663. }
  3664. function isInHmrContext(instance) {
  3665. while (instance) {
  3666. if (instance.type.__hmrId)
  3667. return true
  3668. instance = instance.parent
  3669. }
  3670. }
  3671. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  3672. const {
  3673. props,
  3674. attrs,
  3675. vnode: { patchFlag },
  3676. } = instance
  3677. const rawCurrentProps = toRaw(props)
  3678. const [options] = instance.propsOptions
  3679. let hasAttrsChanged = false
  3680. if (
  3681. // always force full diff in dev
  3682. // - #1942 if hmr is enabled with sfc component
  3683. // - vite#872 non-sfc component used by sfc component
  3684. !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
  3685. ) {
  3686. if (patchFlag & 8) {
  3687. const propsToUpdate = instance.vnode.dynamicProps
  3688. for (let i = 0; i < propsToUpdate.length; i++) {
  3689. const key = propsToUpdate[i]
  3690. if (isEmitListener(instance.emitsOptions, key))
  3691. continue
  3692. const value = rawProps[key]
  3693. if (options) {
  3694. if (hasOwn(attrs, key)) {
  3695. if (value !== attrs[key]) {
  3696. attrs[key] = value
  3697. hasAttrsChanged = true
  3698. }
  3699. }
  3700. else {
  3701. const camelizedKey = camelize(key)
  3702. props[camelizedKey] = resolvePropValue(
  3703. options,
  3704. rawCurrentProps,
  3705. camelizedKey,
  3706. value,
  3707. instance,
  3708. false,
  3709. )
  3710. }
  3711. }
  3712. else {
  3713. if (value !== attrs[key]) {
  3714. attrs[key] = value
  3715. hasAttrsChanged = true
  3716. }
  3717. }
  3718. }
  3719. }
  3720. }
  3721. else {
  3722. if (setFullProps(instance, rawProps, props, attrs))
  3723. hasAttrsChanged = true
  3724. let kebabKey
  3725. for (const key in rawCurrentProps) {
  3726. if (!rawProps // for camelCase
  3727. || !hasOwn(rawProps, key) // it's possible the original props was passed in as kebab-case
  3728. // and converted to camelCase (#955)
  3729. && ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
  3730. if (options) {
  3731. if (rawPrevProps // for camelCase
  3732. && (rawPrevProps[key] !== void 0 // for kebab-case
  3733. || rawPrevProps[kebabKey] !== void 0)) {
  3734. props[key] = resolvePropValue(
  3735. options,
  3736. rawCurrentProps,
  3737. key,
  3738. void 0,
  3739. instance,
  3740. true,
  3741. )
  3742. }
  3743. }
  3744. else {
  3745. delete props[key]
  3746. }
  3747. }
  3748. }
  3749. if (attrs !== rawCurrentProps) {
  3750. for (const key in attrs) {
  3751. if (!rawProps || !hasOwn(rawProps, key) && true) {
  3752. delete attrs[key]
  3753. hasAttrsChanged = true
  3754. }
  3755. }
  3756. }
  3757. }
  3758. if (hasAttrsChanged)
  3759. trigger(instance.attrs, 'set', '')
  3760. {
  3761. validateProps(rawProps || {}, props, instance)
  3762. }
  3763. }
  3764. function setFullProps(instance, rawProps, props, attrs) {
  3765. const [options, needCastKeys] = instance.propsOptions
  3766. let hasAttrsChanged = false
  3767. let rawCastValues
  3768. if (rawProps) {
  3769. for (const key in rawProps) {
  3770. if (isReservedProp(key))
  3771. continue
  3772. const value = rawProps[key]
  3773. let camelKey
  3774. if (options && hasOwn(options, camelKey = camelize(key))) {
  3775. if (!needCastKeys || !needCastKeys.includes(camelKey))
  3776. props[camelKey] = value
  3777. else
  3778. (rawCastValues || (rawCastValues = {}))[camelKey] = value
  3779. }
  3780. else if (!isEmitListener(instance.emitsOptions, key)) {
  3781. if (!(key in attrs) || value !== attrs[key]) {
  3782. attrs[key] = value
  3783. hasAttrsChanged = true
  3784. }
  3785. }
  3786. }
  3787. }
  3788. if (needCastKeys) {
  3789. const rawCurrentProps = toRaw(props)
  3790. const castValues = rawCastValues || EMPTY_OBJ
  3791. for (let i = 0; i < needCastKeys.length; i++) {
  3792. const key = needCastKeys[i]
  3793. props[key] = resolvePropValue(
  3794. options,
  3795. rawCurrentProps,
  3796. key,
  3797. castValues[key],
  3798. instance,
  3799. !hasOwn(castValues, key),
  3800. )
  3801. }
  3802. }
  3803. return hasAttrsChanged
  3804. }
  3805. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  3806. const opt = options[key]
  3807. if (opt != null) {
  3808. const hasDefault = hasOwn(opt, 'default')
  3809. if (hasDefault && value === void 0) {
  3810. const defaultValue = opt.default
  3811. if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
  3812. const { propsDefaults } = instance
  3813. if (key in propsDefaults) {
  3814. value = propsDefaults[key]
  3815. }
  3816. else {
  3817. const reset = setCurrentInstance(instance)
  3818. value = propsDefaults[key] = defaultValue.call(
  3819. null,
  3820. props,
  3821. )
  3822. reset()
  3823. }
  3824. }
  3825. else {
  3826. value = defaultValue
  3827. }
  3828. }
  3829. if (opt[0 /* shouldCast */]) {
  3830. if (isAbsent && !hasDefault)
  3831. value = false
  3832. else if (opt[1 /* shouldCastTrue */] && (value === '' || value === hyphenate(key)))
  3833. value = true
  3834. }
  3835. }
  3836. return value
  3837. }
  3838. function normalizePropsOptions(comp, appContext, asMixin = false) {
  3839. const cache = appContext.propsCache
  3840. const cached = cache.get(comp)
  3841. if (cached)
  3842. return cached
  3843. const raw = comp.props
  3844. const normalized = {}
  3845. const needCastKeys = []
  3846. let hasExtends = false
  3847. if (!isFunction(comp)) {
  3848. const extendProps = (raw2) => {
  3849. hasExtends = true
  3850. const [props, keys] = normalizePropsOptions(raw2, appContext, true)
  3851. extend(normalized, props)
  3852. if (keys)
  3853. needCastKeys.push(...keys)
  3854. }
  3855. if (!asMixin && appContext.mixins.length)
  3856. appContext.mixins.forEach(extendProps)
  3857. if (comp.extends)
  3858. extendProps(comp.extends)
  3859. if (comp.mixins)
  3860. comp.mixins.forEach(extendProps)
  3861. }
  3862. if (!raw && !hasExtends) {
  3863. if (isObject(comp))
  3864. cache.set(comp, EMPTY_ARR)
  3865. return EMPTY_ARR
  3866. }
  3867. if (isArray(raw)) {
  3868. for (let i = 0; i < raw.length; i++) {
  3869. if (!isString(raw[i]))
  3870. warn$1(`props must be strings when using array syntax.`, raw[i])
  3871. const normalizedKey = camelize(raw[i])
  3872. if (validatePropName(normalizedKey))
  3873. normalized[normalizedKey] = EMPTY_OBJ
  3874. }
  3875. }
  3876. else if (raw) {
  3877. if (!isObject(raw))
  3878. warn$1(`invalid props options`, raw)
  3879. for (const key in raw) {
  3880. const normalizedKey = camelize(key)
  3881. if (validatePropName(normalizedKey)) {
  3882. const opt = raw[key]
  3883. const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt)
  3884. if (prop) {
  3885. const booleanIndex = getTypeIndex(Boolean, prop.type)
  3886. const stringIndex = getTypeIndex(String, prop.type)
  3887. prop[0 /* shouldCast */] = booleanIndex > -1
  3888. prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex
  3889. if (booleanIndex > -1 || hasOwn(prop, 'default'))
  3890. needCastKeys.push(normalizedKey)
  3891. }
  3892. }
  3893. }
  3894. }
  3895. const res = [normalized, needCastKeys]
  3896. if (isObject(comp))
  3897. cache.set(comp, res)
  3898. return res
  3899. }
  3900. function validatePropName(key) {
  3901. if (key[0] !== '$' && !isReservedProp(key))
  3902. return true
  3903. else
  3904. warn$1(`Invalid prop name: "${key}" is a reserved property.`)
  3905. return false
  3906. }
  3907. function getType(ctor) {
  3908. if (ctor === null)
  3909. return 'null'
  3910. if (typeof ctor === 'function') {
  3911. return ctor.name || ''
  3912. }
  3913. else if (typeof ctor === 'object') {
  3914. const name = ctor.constructor && ctor.constructor.name
  3915. return name || ''
  3916. }
  3917. return ''
  3918. }
  3919. function isSameType(a, b) {
  3920. return getType(a) === getType(b)
  3921. }
  3922. function getTypeIndex(type, expectedTypes) {
  3923. if (isArray(expectedTypes))
  3924. return expectedTypes.findIndex(t => isSameType(t, type))
  3925. else if (isFunction(expectedTypes))
  3926. return isSameType(expectedTypes, type) ? 0 : -1
  3927. return -1
  3928. }
  3929. function validateProps(rawProps, props, instance) {
  3930. const resolvedValues = toRaw(props)
  3931. const options = instance.propsOptions[0]
  3932. for (const key in options) {
  3933. const opt = options[key]
  3934. if (opt == null)
  3935. continue
  3936. validateProp(
  3937. key,
  3938. resolvedValues[key],
  3939. opt,
  3940. shallowReadonly(resolvedValues),
  3941. !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)),
  3942. )
  3943. }
  3944. }
  3945. function validateProp(name, value, prop, props, isAbsent) {
  3946. const { type, required, validator, skipCheck } = prop
  3947. if (required && isAbsent) {
  3948. warn$1(`Missing required prop: "${name}"`)
  3949. return
  3950. }
  3951. if (value == null && !required)
  3952. return
  3953. if (type != null && type !== true && !skipCheck) {
  3954. let isValid = false
  3955. const types = isArray(type) ? type : [type]
  3956. const expectedTypes = []
  3957. for (let i = 0; i < types.length && !isValid; i++) {
  3958. const { valid, expectedType } = assertType(value, types[i])
  3959. expectedTypes.push(expectedType || '')
  3960. isValid = valid
  3961. }
  3962. if (!isValid) {
  3963. warn$1(getInvalidTypeMessage(name, value, expectedTypes))
  3964. return
  3965. }
  3966. }
  3967. if (validator && !validator(value, props))
  3968. warn$1(`Invalid prop: custom validator check failed for prop "${name}".`)
  3969. }
  3970. const isSimpleType = /* @__PURE__ */ makeMap(
  3971. 'String,Number,Boolean,Function,Symbol,BigInt',
  3972. )
  3973. function assertType(value, type) {
  3974. let valid
  3975. const expectedType = getType(type)
  3976. if (isSimpleType(expectedType)) {
  3977. const t = typeof value
  3978. valid = t === expectedType.toLowerCase()
  3979. if (!valid && t === 'object')
  3980. valid = value instanceof type
  3981. }
  3982. else if (expectedType === 'Object') {
  3983. valid = isObject(value)
  3984. }
  3985. else if (expectedType === 'Array') {
  3986. valid = isArray(value)
  3987. }
  3988. else if (expectedType === 'null') {
  3989. valid = value === null
  3990. }
  3991. else {
  3992. valid = value instanceof type
  3993. }
  3994. return {
  3995. valid,
  3996. expectedType,
  3997. }
  3998. }
  3999. function getInvalidTypeMessage(name, value, expectedTypes) {
  4000. if (expectedTypes.length === 0)
  4001. return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`
  4002. let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(' | ')}`
  4003. const expectedType = expectedTypes[0]
  4004. const receivedType = toRawType(value)
  4005. const expectedValue = styleValue(value, expectedType)
  4006. const receivedValue = styleValue(value, receivedType)
  4007. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType))
  4008. message += ` with value ${expectedValue}`
  4009. message += `, got ${receivedType} `
  4010. if (isExplicable(receivedType))
  4011. message += `with value ${receivedValue}.`
  4012. return message
  4013. }
  4014. function styleValue(value, type) {
  4015. if (type === 'String')
  4016. return `"${value}"`
  4017. else if (type === 'Number')
  4018. return `${Number(value)}`
  4019. else
  4020. return `${value}`
  4021. }
  4022. function isExplicable(type) {
  4023. const explicitTypes = ['string', 'number', 'boolean']
  4024. return explicitTypes.some(elem => type.toLowerCase() === elem)
  4025. }
  4026. function isBoolean(...args) {
  4027. return args.some(elem => elem.toLowerCase() === 'boolean')
  4028. }
  4029. const isInternalKey = key => key[0] === '_' || key === '$stable'
  4030. const normalizeSlotValue = value => isArray(value) ? value.map(normalizeVNode$1) : [normalizeVNode$1(value)]
  4031. function normalizeSlot(key, rawSlot, ctx) {
  4032. if (rawSlot._n)
  4033. return rawSlot
  4034. const normalized = withCtx((...args) => {
  4035. if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
  4036. warn$1(
  4037. `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.`,
  4038. )
  4039. }
  4040. return normalizeSlotValue(rawSlot(...args))
  4041. }, ctx)
  4042. normalized._c = false
  4043. return normalized
  4044. }
  4045. function normalizeObjectSlots(rawSlots, slots, instance) {
  4046. const ctx = rawSlots._ctx
  4047. for (const key in rawSlots) {
  4048. if (isInternalKey(key))
  4049. continue
  4050. const value = rawSlots[key]
  4051. if (isFunction(value)) {
  4052. slots[key] = normalizeSlot(key, value, ctx)
  4053. }
  4054. else if (value != null) {
  4055. {
  4056. warn$1(
  4057. `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`,
  4058. )
  4059. }
  4060. const normalized = normalizeSlotValue(value)
  4061. slots[key] = () => normalized
  4062. }
  4063. }
  4064. }
  4065. function normalizeVNodeSlots(instance, children) {
  4066. if (!isKeepAlive(instance.vnode) && true) {
  4067. warn$1(
  4068. `Non-function value encountered for default slot. Prefer function slots for better performance.`,
  4069. )
  4070. }
  4071. const normalized = normalizeSlotValue(children)
  4072. instance.slots.default = () => normalized
  4073. }
  4074. function initSlots(instance, children) {
  4075. const slots = instance.slots = createInternalObject()
  4076. if (instance.vnode.shapeFlag & 32) {
  4077. const type = children._
  4078. if (type) {
  4079. extend(slots, children)
  4080. def(slots, '_', type, true)
  4081. }
  4082. else {
  4083. normalizeObjectSlots(children, slots)
  4084. }
  4085. }
  4086. else if (children) {
  4087. normalizeVNodeSlots(instance, children)
  4088. }
  4089. }
  4090. function updateSlots(instance, children, optimized) {
  4091. const { vnode, slots } = instance
  4092. let needDeletionCheck = true
  4093. let deletionComparisonTarget = EMPTY_OBJ
  4094. if (vnode.shapeFlag & 32) {
  4095. const type = children._
  4096. if (type) {
  4097. if (isHmrUpdating) {
  4098. extend(slots, children)
  4099. trigger(instance, 'set', '$slots')
  4100. }
  4101. else if (optimized && type === 1) {
  4102. needDeletionCheck = false
  4103. }
  4104. else {
  4105. extend(slots, children)
  4106. if (!optimized && type === 1)
  4107. delete slots._
  4108. }
  4109. }
  4110. else {
  4111. needDeletionCheck = !children.$stable
  4112. normalizeObjectSlots(children, slots)
  4113. }
  4114. deletionComparisonTarget = children
  4115. }
  4116. else if (children) {
  4117. normalizeVNodeSlots(instance, children)
  4118. deletionComparisonTarget = { default: 1 }
  4119. }
  4120. if (needDeletionCheck) {
  4121. for (const key in slots) {
  4122. if (!isInternalKey(key) && deletionComparisonTarget[key] == null)
  4123. delete slots[key]
  4124. }
  4125. }
  4126. }
  4127. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  4128. if (isArray(rawRef)) {
  4129. rawRef.forEach(
  4130. (r, i) => setRef(
  4131. r,
  4132. oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
  4133. parentSuspense,
  4134. vnode,
  4135. isUnmount,
  4136. ),
  4137. )
  4138. return
  4139. }
  4140. if (isAsyncWrapper(vnode) && !isUnmount)
  4141. return
  4142. const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el
  4143. const value = isUnmount ? null : refValue
  4144. const { i: owner, r: ref } = rawRef
  4145. if (!owner) {
  4146. warn$1(
  4147. `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`,
  4148. )
  4149. return
  4150. }
  4151. const oldRef = oldRawRef && oldRawRef.r
  4152. const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs
  4153. const setupState = owner.setupState
  4154. if (oldRef != null && oldRef !== ref) {
  4155. if (isString(oldRef)) {
  4156. refs[oldRef] = null
  4157. if (hasOwn(setupState, oldRef))
  4158. setupState[oldRef] = null
  4159. }
  4160. else if (isRef(oldRef)) {
  4161. oldRef.value = null
  4162. }
  4163. }
  4164. if (isFunction(ref)) {
  4165. callWithErrorHandling(ref, owner, 12, [value, refs])
  4166. }
  4167. else {
  4168. const _isString = isString(ref)
  4169. const _isRef = isRef(ref)
  4170. if (_isString || _isRef) {
  4171. const doSet = () => {
  4172. if (rawRef.f) {
  4173. const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value
  4174. if (isUnmount) {
  4175. isArray(existing) && remove(existing, refValue)
  4176. }
  4177. else {
  4178. if (!isArray(existing)) {
  4179. if (_isString) {
  4180. refs[ref] = [refValue]
  4181. if (hasOwn(setupState, ref))
  4182. setupState[ref] = refs[ref]
  4183. }
  4184. else {
  4185. ref.value = [refValue]
  4186. if (rawRef.k)
  4187. refs[rawRef.k] = ref.value
  4188. }
  4189. }
  4190. else if (!existing.includes(refValue)) {
  4191. existing.push(refValue)
  4192. }
  4193. }
  4194. }
  4195. else if (_isString) {
  4196. refs[ref] = value
  4197. if (hasOwn(setupState, ref))
  4198. setupState[ref] = value
  4199. }
  4200. else if (_isRef) {
  4201. ref.value = value
  4202. if (rawRef.k)
  4203. refs[rawRef.k] = value
  4204. }
  4205. else {
  4206. warn$1('Invalid template ref type:', ref, `(${typeof ref})`)
  4207. }
  4208. }
  4209. if (value) {
  4210. doSet.id = -1
  4211. queuePostRenderEffect(doSet, parentSuspense)
  4212. }
  4213. else {
  4214. doSet()
  4215. }
  4216. }
  4217. else {
  4218. warn$1('Invalid template ref type:', ref, `(${typeof ref})`)
  4219. }
  4220. }
  4221. }
  4222. let supported
  4223. let perf
  4224. function startMeasure(instance, type) {
  4225. if (instance.appContext.config.performance && isSupported())
  4226. perf.mark(`vue-${type}-${instance.uid}`)
  4227. {
  4228. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now())
  4229. }
  4230. }
  4231. function endMeasure(instance, type) {
  4232. if (instance.appContext.config.performance && isSupported()) {
  4233. const startTag = `vue-${type}-${instance.uid}`
  4234. const endTag = `${startTag}:end`
  4235. perf.mark(endTag)
  4236. perf.measure(
  4237. `<${formatComponentName(instance, instance.type)}> ${type}`,
  4238. startTag,
  4239. endTag,
  4240. )
  4241. perf.clearMarks(startTag)
  4242. perf.clearMarks(endTag)
  4243. }
  4244. {
  4245. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now())
  4246. }
  4247. }
  4248. function isSupported() {
  4249. if (supported !== void 0)
  4250. return supported
  4251. if (typeof window !== 'undefined' && window.performance) {
  4252. supported = true
  4253. perf = window.performance
  4254. }
  4255. else {
  4256. supported = false
  4257. }
  4258. return supported
  4259. }
  4260. const queuePostRenderEffect = queueEffectWithSuspense
  4261. function createRenderer(options) {
  4262. return baseCreateRenderer(options)
  4263. }
  4264. function baseCreateRenderer(options, createHydrationFns) {
  4265. const target = getGlobalThis()
  4266. target.__VUE__ = true
  4267. {
  4268. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target)
  4269. }
  4270. const {
  4271. insert: hostInsert,
  4272. remove: hostRemove,
  4273. patchProp: hostPatchProp,
  4274. createElement: hostCreateElement,
  4275. createText: hostCreateText,
  4276. createComment: hostCreateComment,
  4277. setText: hostSetText,
  4278. setElementText: hostSetElementText,
  4279. parentNode: hostParentNode,
  4280. nextSibling: hostNextSibling,
  4281. setScopeId: hostSetScopeId = NOOP,
  4282. insertStaticContent: hostInsertStaticContent,
  4283. } = options
  4284. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  4285. if (n1 === n2)
  4286. return
  4287. if (n1 && !isSameVNodeType(n1, n2)) {
  4288. anchor = getNextHostNode(n1)
  4289. unmount(n1, parentComponent, parentSuspense, true)
  4290. n1 = null
  4291. }
  4292. if (n2.patchFlag === -2) {
  4293. optimized = false
  4294. n2.dynamicChildren = null
  4295. }
  4296. const { type, ref, shapeFlag } = n2
  4297. switch (type) {
  4298. case Text:
  4299. processText(n1, n2, container, anchor)
  4300. break
  4301. case Comment:
  4302. processCommentNode(n1, n2, container, anchor)
  4303. break
  4304. case Static:
  4305. if (n1 == null)
  4306. mountStaticNode(n2, container, anchor, namespace)
  4307. else
  4308. patchStaticNode(n1, n2, container, namespace)
  4309. break
  4310. case Fragment:
  4311. processFragment(
  4312. n1,
  4313. n2,
  4314. container,
  4315. anchor,
  4316. parentComponent,
  4317. parentSuspense,
  4318. namespace,
  4319. slotScopeIds,
  4320. optimized,
  4321. )
  4322. break
  4323. default:
  4324. if (shapeFlag & 1) {
  4325. processElement(
  4326. n1,
  4327. n2,
  4328. container,
  4329. anchor,
  4330. parentComponent,
  4331. parentSuspense,
  4332. namespace,
  4333. slotScopeIds,
  4334. optimized,
  4335. )
  4336. }
  4337. else if (shapeFlag & 6) {
  4338. processComponent(
  4339. n1,
  4340. n2,
  4341. container,
  4342. anchor,
  4343. parentComponent,
  4344. parentSuspense,
  4345. namespace,
  4346. slotScopeIds,
  4347. optimized,
  4348. )
  4349. }
  4350. else if (shapeFlag & 64) {
  4351. type.process(
  4352. n1,
  4353. n2,
  4354. container,
  4355. anchor,
  4356. parentComponent,
  4357. parentSuspense,
  4358. namespace,
  4359. slotScopeIds,
  4360. optimized,
  4361. internals,
  4362. )
  4363. }
  4364. else if (shapeFlag & 128) {
  4365. type.process(
  4366. n1,
  4367. n2,
  4368. container,
  4369. anchor,
  4370. parentComponent,
  4371. parentSuspense,
  4372. namespace,
  4373. slotScopeIds,
  4374. optimized,
  4375. internals,
  4376. )
  4377. }
  4378. else {
  4379. warn$1('Invalid VNode type:', type, `(${typeof type})`)
  4380. }
  4381. }
  4382. if (ref != null && parentComponent)
  4383. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2)
  4384. }
  4385. const processText = (n1, n2, container, anchor) => {
  4386. if (n1 == null) {
  4387. hostInsert(
  4388. n2.el = hostCreateText(n2.children),
  4389. container,
  4390. anchor,
  4391. )
  4392. }
  4393. else {
  4394. const el = n2.el = n1.el
  4395. if (n2.children !== n1.children)
  4396. hostSetText(el, n2.children)
  4397. }
  4398. }
  4399. const processCommentNode = (n1, n2, container, anchor) => {
  4400. if (n1 == null) {
  4401. hostInsert(
  4402. n2.el = hostCreateComment(n2.children || ''),
  4403. container,
  4404. anchor,
  4405. )
  4406. }
  4407. else {
  4408. n2.el = n1.el
  4409. }
  4410. }
  4411. const mountStaticNode = (n2, container, anchor, namespace) => {
  4412. [n2.el, n2.anchor] = hostInsertStaticContent(
  4413. n2.children,
  4414. container,
  4415. anchor,
  4416. namespace,
  4417. n2.el,
  4418. n2.anchor,
  4419. )
  4420. }
  4421. const patchStaticNode = (n1, n2, container, namespace) => {
  4422. if (n2.children !== n1.children) {
  4423. const anchor = hostNextSibling(n1.anchor)
  4424. removeStaticNode(n1);
  4425. [n2.el, n2.anchor] = hostInsertStaticContent(
  4426. n2.children,
  4427. container,
  4428. anchor,
  4429. namespace,
  4430. )
  4431. }
  4432. else {
  4433. n2.el = n1.el
  4434. n2.anchor = n1.anchor
  4435. }
  4436. }
  4437. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  4438. let next
  4439. while (el && el !== anchor) {
  4440. next = hostNextSibling(el)
  4441. hostInsert(el, container, nextSibling)
  4442. el = next
  4443. }
  4444. hostInsert(anchor, container, nextSibling)
  4445. }
  4446. const removeStaticNode = ({ el, anchor }) => {
  4447. let next
  4448. while (el && el !== anchor) {
  4449. next = hostNextSibling(el)
  4450. hostRemove(el)
  4451. el = next
  4452. }
  4453. hostRemove(anchor)
  4454. }
  4455. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  4456. if (n2.type === 'svg')
  4457. namespace = 'svg'
  4458. else if (n2.type === 'math')
  4459. namespace = 'mathml'
  4460. if (n1 == null) {
  4461. mountElement(
  4462. n2,
  4463. container,
  4464. anchor,
  4465. parentComponent,
  4466. parentSuspense,
  4467. namespace,
  4468. slotScopeIds,
  4469. optimized,
  4470. )
  4471. }
  4472. else {
  4473. patchElement(
  4474. n1,
  4475. n2,
  4476. parentComponent,
  4477. parentSuspense,
  4478. namespace,
  4479. slotScopeIds,
  4480. optimized,
  4481. )
  4482. }
  4483. }
  4484. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  4485. let el
  4486. let vnodeHook
  4487. const { props, shapeFlag, transition, dirs } = vnode
  4488. el = vnode.el = hostCreateElement(
  4489. vnode.type,
  4490. namespace,
  4491. props && props.is,
  4492. props,
  4493. )
  4494. if (shapeFlag & 8) {
  4495. hostSetElementText(el, vnode.children)
  4496. }
  4497. else if (shapeFlag & 16) {
  4498. mountChildren(
  4499. vnode.children,
  4500. el,
  4501. null,
  4502. parentComponent,
  4503. parentSuspense,
  4504. resolveChildrenNamespace(vnode, namespace),
  4505. slotScopeIds,
  4506. optimized,
  4507. )
  4508. }
  4509. if (dirs)
  4510. invokeDirectiveHook(vnode, null, parentComponent, 'created')
  4511. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent)
  4512. if (props) {
  4513. for (const key in props) {
  4514. if (key !== 'value' && !isReservedProp(key)) {
  4515. hostPatchProp(
  4516. el,
  4517. key,
  4518. null,
  4519. props[key],
  4520. namespace,
  4521. vnode.children,
  4522. parentComponent,
  4523. parentSuspense,
  4524. unmountChildren,
  4525. )
  4526. }
  4527. }
  4528. if ('value' in props)
  4529. hostPatchProp(el, 'value', null, props.value, namespace)
  4530. if (vnodeHook = props.onVnodeBeforeMount)
  4531. invokeVNodeHook(vnodeHook, parentComponent, vnode)
  4532. }
  4533. {
  4534. Object.defineProperty(el, '__vnode', {
  4535. value: vnode,
  4536. enumerable: false,
  4537. })
  4538. Object.defineProperty(el, '__vueParentComponent', {
  4539. value: parentComponent,
  4540. enumerable: false,
  4541. })
  4542. }
  4543. if (dirs)
  4544. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
  4545. const needCallTransitionHooks = needTransition(parentSuspense, transition)
  4546. if (needCallTransitionHooks)
  4547. transition.beforeEnter(el)
  4548. hostInsert(el, container, anchor)
  4549. if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
  4550. queuePostRenderEffect(() => {
  4551. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode)
  4552. needCallTransitionHooks && transition.enter(el)
  4553. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted')
  4554. }, parentSuspense)
  4555. }
  4556. }
  4557. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  4558. if (scopeId)
  4559. hostSetScopeId(el, scopeId)
  4560. if (slotScopeIds) {
  4561. for (let i = 0; i < slotScopeIds.length; i++)
  4562. hostSetScopeId(el, slotScopeIds[i])
  4563. }
  4564. if (parentComponent) {
  4565. let subTree = parentComponent.subTree
  4566. if (subTree.patchFlag > 0 && subTree.patchFlag & 2048)
  4567. subTree = filterSingleRoot(subTree.children) || subTree
  4568. if (vnode === subTree) {
  4569. const parentVNode = parentComponent.vnode
  4570. setScopeId(
  4571. el,
  4572. parentVNode,
  4573. parentVNode.scopeId,
  4574. parentVNode.slotScopeIds,
  4575. parentComponent.parent,
  4576. )
  4577. }
  4578. }
  4579. }
  4580. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
  4581. for (let i = start; i < children.length; i++) {
  4582. const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode$1(children[i])
  4583. patch(
  4584. null,
  4585. child,
  4586. container,
  4587. anchor,
  4588. parentComponent,
  4589. parentSuspense,
  4590. namespace,
  4591. slotScopeIds,
  4592. optimized,
  4593. )
  4594. }
  4595. }
  4596. const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  4597. const el = n2.el = n1.el
  4598. let { patchFlag, dynamicChildren, dirs } = n2
  4599. patchFlag |= n1.patchFlag & 16
  4600. const oldProps = n1.props || EMPTY_OBJ
  4601. const newProps = n2.props || EMPTY_OBJ
  4602. let vnodeHook
  4603. parentComponent && toggleRecurse(parentComponent, false)
  4604. if (vnodeHook = newProps.onVnodeBeforeUpdate)
  4605. invokeVNodeHook(vnodeHook, parentComponent, n2, n1)
  4606. if (dirs)
  4607. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate')
  4608. parentComponent && toggleRecurse(parentComponent, true)
  4609. if (isHmrUpdating) {
  4610. patchFlag = 0
  4611. optimized = false
  4612. dynamicChildren = null
  4613. }
  4614. if (dynamicChildren) {
  4615. patchBlockChildren(
  4616. n1.dynamicChildren,
  4617. dynamicChildren,
  4618. el,
  4619. parentComponent,
  4620. parentSuspense,
  4621. resolveChildrenNamespace(n2, namespace),
  4622. slotScopeIds,
  4623. )
  4624. {
  4625. traverseStaticChildren(n1, n2)
  4626. }
  4627. }
  4628. else if (!optimized) {
  4629. patchChildren(
  4630. n1,
  4631. n2,
  4632. el,
  4633. null,
  4634. parentComponent,
  4635. parentSuspense,
  4636. resolveChildrenNamespace(n2, namespace),
  4637. slotScopeIds,
  4638. false,
  4639. )
  4640. }
  4641. if (patchFlag > 0) {
  4642. if (patchFlag & 16) {
  4643. patchProps(
  4644. el,
  4645. n2,
  4646. oldProps,
  4647. newProps,
  4648. parentComponent,
  4649. parentSuspense,
  4650. namespace,
  4651. )
  4652. }
  4653. else {
  4654. if (patchFlag & 2) {
  4655. if (oldProps.class !== newProps.class)
  4656. hostPatchProp(el, 'class', null, newProps.class, namespace)
  4657. }
  4658. if (patchFlag & 4)
  4659. hostPatchProp(el, 'style', oldProps.style, newProps.style, namespace)
  4660. if (patchFlag & 8) {
  4661. const propsToUpdate = n2.dynamicProps
  4662. for (let i = 0; i < propsToUpdate.length; i++) {
  4663. const key = propsToUpdate[i]
  4664. const prev = oldProps[key]
  4665. const next = newProps[key]
  4666. if (next !== prev || key === 'value') {
  4667. hostPatchProp(
  4668. el,
  4669. key,
  4670. prev,
  4671. next,
  4672. namespace,
  4673. n1.children,
  4674. parentComponent,
  4675. parentSuspense,
  4676. unmountChildren,
  4677. )
  4678. }
  4679. }
  4680. }
  4681. }
  4682. if (patchFlag & 1) {
  4683. if (n1.children !== n2.children)
  4684. hostSetElementText(el, n2.children)
  4685. }
  4686. }
  4687. else if (!optimized && dynamicChildren == null) {
  4688. patchProps(
  4689. el,
  4690. n2,
  4691. oldProps,
  4692. newProps,
  4693. parentComponent,
  4694. parentSuspense,
  4695. namespace,
  4696. )
  4697. }
  4698. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  4699. queuePostRenderEffect(() => {
  4700. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1)
  4701. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated')
  4702. }, parentSuspense)
  4703. }
  4704. }
  4705. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
  4706. for (let i = 0; i < newChildren.length; i++) {
  4707. const oldVNode = oldChildren[i]
  4708. const newVNode = newChildren[i]
  4709. const container = (
  4710. // oldVNode may be an errored async setup() component inside Suspense
  4711. // which will not have a mounted element
  4712. oldVNode.el // - In the case of a Fragment, we need to provide the actual parent
  4713. // of the Fragment itself so it can move its children.
  4714. && (oldVNode.type === Fragment // - In the case of different nodes, there is going to be a replacement
  4715. // which also requires the correct parent container
  4716. || !isSameVNodeType(oldVNode, newVNode) // - In the case of a component, it could contain anything.
  4717. || oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
  4718. // In other cases, the parent container is not actually used so we
  4719. // just pass the block element here to avoid a DOM parentNode call.
  4720. fallbackContainer
  4721. )
  4722. )
  4723. patch(
  4724. oldVNode,
  4725. newVNode,
  4726. container,
  4727. null,
  4728. parentComponent,
  4729. parentSuspense,
  4730. namespace,
  4731. slotScopeIds,
  4732. true,
  4733. )
  4734. }
  4735. }
  4736. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, namespace) => {
  4737. if (oldProps !== newProps) {
  4738. if (oldProps !== EMPTY_OBJ) {
  4739. for (const key in oldProps) {
  4740. if (!isReservedProp(key) && !(key in newProps)) {
  4741. hostPatchProp(
  4742. el,
  4743. key,
  4744. oldProps[key],
  4745. null,
  4746. namespace,
  4747. vnode.children,
  4748. parentComponent,
  4749. parentSuspense,
  4750. unmountChildren,
  4751. )
  4752. }
  4753. }
  4754. }
  4755. for (const key in newProps) {
  4756. if (isReservedProp(key))
  4757. continue
  4758. const next = newProps[key]
  4759. const prev = oldProps[key]
  4760. if (next !== prev && key !== 'value') {
  4761. hostPatchProp(
  4762. el,
  4763. key,
  4764. prev,
  4765. next,
  4766. namespace,
  4767. vnode.children,
  4768. parentComponent,
  4769. parentSuspense,
  4770. unmountChildren,
  4771. )
  4772. }
  4773. }
  4774. if ('value' in newProps)
  4775. hostPatchProp(el, 'value', oldProps.value, newProps.value, namespace)
  4776. }
  4777. }
  4778. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  4779. const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText('')
  4780. const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText('')
  4781. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2
  4782. if (
  4783. // #5523 dev root fragment may inherit directives
  4784. isHmrUpdating || patchFlag & 2048
  4785. ) {
  4786. patchFlag = 0
  4787. optimized = false
  4788. dynamicChildren = null
  4789. }
  4790. if (fragmentSlotScopeIds)
  4791. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds
  4792. if (n1 == null) {
  4793. hostInsert(fragmentStartAnchor, container, anchor)
  4794. hostInsert(fragmentEndAnchor, container, anchor)
  4795. mountChildren(
  4796. // #10007
  4797. // such fragment like `<></>` will be compiled into
  4798. // a fragment which doesn't have a children.
  4799. // In this case fallback to an empty array
  4800. n2.children || [],
  4801. container,
  4802. fragmentEndAnchor,
  4803. parentComponent,
  4804. parentSuspense,
  4805. namespace,
  4806. slotScopeIds,
  4807. optimized,
  4808. )
  4809. }
  4810. else {
  4811. if (patchFlag > 0 && patchFlag & 64 && dynamicChildren // #2715 the previous fragment could've been a BAILed one as a result
  4812. // of renderSlot() with no valid children
  4813. && n1.dynamicChildren) {
  4814. patchBlockChildren(
  4815. n1.dynamicChildren,
  4816. dynamicChildren,
  4817. container,
  4818. parentComponent,
  4819. parentSuspense,
  4820. namespace,
  4821. slotScopeIds,
  4822. )
  4823. {
  4824. traverseStaticChildren(n1, n2)
  4825. }
  4826. }
  4827. else {
  4828. patchChildren(
  4829. n1,
  4830. n2,
  4831. container,
  4832. fragmentEndAnchor,
  4833. parentComponent,
  4834. parentSuspense,
  4835. namespace,
  4836. slotScopeIds,
  4837. optimized,
  4838. )
  4839. }
  4840. }
  4841. }
  4842. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  4843. n2.slotScopeIds = slotScopeIds
  4844. if (n1 == null) {
  4845. if (n2.shapeFlag & 512) {
  4846. parentComponent.ctx.activate(
  4847. n2,
  4848. container,
  4849. anchor,
  4850. namespace,
  4851. optimized,
  4852. )
  4853. }
  4854. else {
  4855. mountComponent(
  4856. n2,
  4857. container,
  4858. anchor,
  4859. parentComponent,
  4860. parentSuspense,
  4861. namespace,
  4862. optimized,
  4863. )
  4864. }
  4865. }
  4866. else {
  4867. updateComponent(n1, n2, optimized)
  4868. }
  4869. }
  4870. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
  4871. const instance = (initialVNode.component = createComponentInstance$1(
  4872. initialVNode,
  4873. parentComponent,
  4874. parentSuspense,
  4875. ))
  4876. if (instance.type.__hmrId)
  4877. registerHMR(instance)
  4878. {
  4879. pushWarningContext(initialVNode)
  4880. startMeasure(instance, `mount`)
  4881. }
  4882. if (isKeepAlive(initialVNode))
  4883. instance.ctx.renderer = internals
  4884. {
  4885. {
  4886. startMeasure(instance, `init`)
  4887. }
  4888. setupComponent$1(instance)
  4889. {
  4890. endMeasure(instance, `init`)
  4891. }
  4892. }
  4893. if (instance.asyncDep) {
  4894. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect)
  4895. if (!initialVNode.el) {
  4896. const placeholder = instance.subTree = createVNode(Comment)
  4897. processCommentNode(null, placeholder, container, anchor)
  4898. }
  4899. }
  4900. else {
  4901. setupRenderEffect(
  4902. instance,
  4903. initialVNode,
  4904. container,
  4905. anchor,
  4906. parentSuspense,
  4907. namespace,
  4908. optimized,
  4909. )
  4910. }
  4911. {
  4912. popWarningContext()
  4913. endMeasure(instance, `mount`)
  4914. }
  4915. }
  4916. const updateComponent = (n1, n2, optimized) => {
  4917. const instance = n2.component = n1.component
  4918. if (shouldUpdateComponent(n1, n2, optimized)) {
  4919. if (instance.asyncDep && !instance.asyncResolved) {
  4920. {
  4921. pushWarningContext(n2)
  4922. }
  4923. updateComponentPreRender(instance, n2, optimized)
  4924. {
  4925. popWarningContext()
  4926. }
  4927. }
  4928. else {
  4929. instance.next = n2
  4930. invalidateJob(instance.update)
  4931. instance.effect.dirty = true
  4932. instance.update()
  4933. }
  4934. }
  4935. else {
  4936. n2.el = n1.el
  4937. instance.vnode = n2
  4938. }
  4939. }
  4940. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
  4941. const componentUpdateFn = () => {
  4942. if (!instance.isMounted) {
  4943. let vnodeHook
  4944. const { el, props } = initialVNode
  4945. const { bm, m, parent } = instance
  4946. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode)
  4947. toggleRecurse(instance, false)
  4948. if (bm)
  4949. invokeArrayFns(bm)
  4950. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount))
  4951. invokeVNodeHook(vnodeHook, parent, initialVNode)
  4952. toggleRecurse(instance, true)
  4953. if (el && hydrateNode) {
  4954. const hydrateSubTree = () => {
  4955. {
  4956. startMeasure(instance, `render`)
  4957. }
  4958. instance.subTree = renderComponentRoot$1(instance)
  4959. {
  4960. endMeasure(instance, `render`)
  4961. }
  4962. {
  4963. startMeasure(instance, `hydrate`)
  4964. }
  4965. hydrateNode(
  4966. el,
  4967. instance.subTree,
  4968. instance,
  4969. parentSuspense,
  4970. null,
  4971. )
  4972. {
  4973. endMeasure(instance, `hydrate`)
  4974. }
  4975. }
  4976. if (isAsyncWrapperVNode) {
  4977. initialVNode.type.__asyncLoader().then(
  4978. // note: we are moving the render call into an async callback,
  4979. // which means it won't track dependencies - but it's ok because
  4980. // a server-rendered async wrapper is already in resolved state
  4981. // and it will never need to change.
  4982. () => !instance.isUnmounted && hydrateSubTree(),
  4983. )
  4984. }
  4985. else {
  4986. hydrateSubTree()
  4987. }
  4988. }
  4989. else {
  4990. {
  4991. startMeasure(instance, `render`)
  4992. }
  4993. const subTree = instance.subTree = renderComponentRoot$1(instance)
  4994. {
  4995. endMeasure(instance, `render`)
  4996. }
  4997. {
  4998. startMeasure(instance, `patch`)
  4999. }
  5000. patch(
  5001. null,
  5002. subTree,
  5003. container,
  5004. anchor,
  5005. instance,
  5006. parentSuspense,
  5007. namespace,
  5008. )
  5009. {
  5010. endMeasure(instance, `patch`)
  5011. }
  5012. initialVNode.el = subTree.el
  5013. }
  5014. if (m)
  5015. queuePostRenderEffect(m, parentSuspense)
  5016. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
  5017. const scopedInitialVNode = initialVNode
  5018. queuePostRenderEffect(
  5019. () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
  5020. parentSuspense,
  5021. )
  5022. }
  5023. if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256)
  5024. instance.a && queuePostRenderEffect(instance.a, parentSuspense)
  5025. instance.isMounted = true
  5026. {
  5027. devtoolsComponentAdded(instance)
  5028. }
  5029. initialVNode = container = anchor = null
  5030. }
  5031. else {
  5032. let { next, bu, u, parent, vnode } = instance
  5033. {
  5034. const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance)
  5035. if (nonHydratedAsyncRoot) {
  5036. if (next) {
  5037. next.el = vnode.el
  5038. updateComponentPreRender(instance, next, optimized)
  5039. }
  5040. nonHydratedAsyncRoot.asyncDep.then(() => {
  5041. if (!instance.isUnmounted)
  5042. componentUpdateFn()
  5043. })
  5044. return
  5045. }
  5046. }
  5047. const originNext = next
  5048. let vnodeHook
  5049. {
  5050. pushWarningContext(next || instance.vnode)
  5051. }
  5052. toggleRecurse(instance, false)
  5053. if (next) {
  5054. next.el = vnode.el
  5055. updateComponentPreRender(instance, next, optimized)
  5056. }
  5057. else {
  5058. next = vnode
  5059. }
  5060. if (bu)
  5061. invokeArrayFns(bu)
  5062. if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate)
  5063. invokeVNodeHook(vnodeHook, parent, next, vnode)
  5064. toggleRecurse(instance, true)
  5065. {
  5066. startMeasure(instance, `render`)
  5067. }
  5068. const nextTree = renderComponentRoot$1(instance)
  5069. {
  5070. endMeasure(instance, `render`)
  5071. }
  5072. const prevTree = instance.subTree
  5073. instance.subTree = nextTree
  5074. {
  5075. startMeasure(instance, `patch`)
  5076. }
  5077. patch(
  5078. prevTree,
  5079. nextTree,
  5080. // parent may have changed if it's in a teleport
  5081. hostParentNode(prevTree.el),
  5082. // anchor may have changed if it's in a fragment
  5083. getNextHostNode(prevTree),
  5084. instance,
  5085. parentSuspense,
  5086. namespace,
  5087. )
  5088. {
  5089. endMeasure(instance, `patch`)
  5090. }
  5091. next.el = nextTree.el
  5092. if (originNext === null)
  5093. updateHOCHostEl(instance, nextTree.el)
  5094. if (u)
  5095. queuePostRenderEffect(u, parentSuspense)
  5096. if (vnodeHook = next.props && next.props.onVnodeUpdated) {
  5097. queuePostRenderEffect(
  5098. () => invokeVNodeHook(vnodeHook, parent, next, vnode),
  5099. parentSuspense,
  5100. )
  5101. }
  5102. {
  5103. devtoolsComponentUpdated(instance)
  5104. }
  5105. {
  5106. popWarningContext()
  5107. }
  5108. }
  5109. }
  5110. const effect = instance.effect = new ReactiveEffect(
  5111. componentUpdateFn,
  5112. NOOP,
  5113. () => queueJob(update),
  5114. instance.scope,
  5115. // track it in component's effect scope
  5116. )
  5117. const update = instance.update = () => {
  5118. if (effect.dirty)
  5119. effect.run()
  5120. }
  5121. update.id = instance.uid
  5122. toggleRecurse(instance, true)
  5123. {
  5124. effect.onTrack = instance.rtc ? e => invokeArrayFns(instance.rtc, e) : void 0
  5125. effect.onTrigger = instance.rtg ? e => invokeArrayFns(instance.rtg, e) : void 0
  5126. update.ownerInstance = instance
  5127. }
  5128. update()
  5129. }
  5130. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  5131. nextVNode.component = instance
  5132. const prevProps = instance.vnode.props
  5133. instance.vnode = nextVNode
  5134. instance.next = null
  5135. updateProps(instance, nextVNode.props, prevProps, optimized)
  5136. updateSlots(instance, nextVNode.children, optimized)
  5137. pauseTracking()
  5138. flushPreFlushCbs(instance)
  5139. resetTracking()
  5140. }
  5141. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
  5142. const c1 = n1 && n1.children
  5143. const prevShapeFlag = n1 ? n1.shapeFlag : 0
  5144. const c2 = n2.children
  5145. const { patchFlag, shapeFlag } = n2
  5146. if (patchFlag > 0) {
  5147. if (patchFlag & 128) {
  5148. patchKeyedChildren(
  5149. c1,
  5150. c2,
  5151. container,
  5152. anchor,
  5153. parentComponent,
  5154. parentSuspense,
  5155. namespace,
  5156. slotScopeIds,
  5157. optimized,
  5158. )
  5159. return
  5160. }
  5161. else if (patchFlag & 256) {
  5162. patchUnkeyedChildren(
  5163. c1,
  5164. c2,
  5165. container,
  5166. anchor,
  5167. parentComponent,
  5168. parentSuspense,
  5169. namespace,
  5170. slotScopeIds,
  5171. optimized,
  5172. )
  5173. return
  5174. }
  5175. }
  5176. if (shapeFlag & 8) {
  5177. if (prevShapeFlag & 16)
  5178. unmountChildren(c1, parentComponent, parentSuspense)
  5179. if (c2 !== c1)
  5180. hostSetElementText(container, c2)
  5181. }
  5182. else {
  5183. if (prevShapeFlag & 16) {
  5184. if (shapeFlag & 16) {
  5185. patchKeyedChildren(
  5186. c1,
  5187. c2,
  5188. container,
  5189. anchor,
  5190. parentComponent,
  5191. parentSuspense,
  5192. namespace,
  5193. slotScopeIds,
  5194. optimized,
  5195. )
  5196. }
  5197. else {
  5198. unmountChildren(c1, parentComponent, parentSuspense, true)
  5199. }
  5200. }
  5201. else {
  5202. if (prevShapeFlag & 8)
  5203. hostSetElementText(container, '')
  5204. if (shapeFlag & 16) {
  5205. mountChildren(
  5206. c2,
  5207. container,
  5208. anchor,
  5209. parentComponent,
  5210. parentSuspense,
  5211. namespace,
  5212. slotScopeIds,
  5213. optimized,
  5214. )
  5215. }
  5216. }
  5217. }
  5218. }
  5219. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  5220. c1 = c1 || EMPTY_ARR
  5221. c2 = c2 || EMPTY_ARR
  5222. const oldLength = c1.length
  5223. const newLength = c2.length
  5224. const commonLength = Math.min(oldLength, newLength)
  5225. let i
  5226. for (i = 0; i < commonLength; i++) {
  5227. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i])
  5228. patch(
  5229. c1[i],
  5230. nextChild,
  5231. container,
  5232. null,
  5233. parentComponent,
  5234. parentSuspense,
  5235. namespace,
  5236. slotScopeIds,
  5237. optimized,
  5238. )
  5239. }
  5240. if (oldLength > newLength) {
  5241. unmountChildren(
  5242. c1,
  5243. parentComponent,
  5244. parentSuspense,
  5245. true,
  5246. false,
  5247. commonLength,
  5248. )
  5249. }
  5250. else {
  5251. mountChildren(
  5252. c2,
  5253. container,
  5254. anchor,
  5255. parentComponent,
  5256. parentSuspense,
  5257. namespace,
  5258. slotScopeIds,
  5259. optimized,
  5260. commonLength,
  5261. )
  5262. }
  5263. }
  5264. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  5265. let i = 0
  5266. const l2 = c2.length
  5267. let e1 = c1.length - 1
  5268. let e2 = l2 - 1
  5269. while (i <= e1 && i <= e2) {
  5270. const n1 = c1[i]
  5271. const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i])
  5272. if (isSameVNodeType(n1, n2)) {
  5273. patch(
  5274. n1,
  5275. n2,
  5276. container,
  5277. null,
  5278. parentComponent,
  5279. parentSuspense,
  5280. namespace,
  5281. slotScopeIds,
  5282. optimized,
  5283. )
  5284. }
  5285. else {
  5286. break
  5287. }
  5288. i++
  5289. }
  5290. while (i <= e1 && i <= e2) {
  5291. const n1 = c1[e1]
  5292. const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode$1(c2[e2])
  5293. if (isSameVNodeType(n1, n2)) {
  5294. patch(
  5295. n1,
  5296. n2,
  5297. container,
  5298. null,
  5299. parentComponent,
  5300. parentSuspense,
  5301. namespace,
  5302. slotScopeIds,
  5303. optimized,
  5304. )
  5305. }
  5306. else {
  5307. break
  5308. }
  5309. e1--
  5310. e2--
  5311. }
  5312. if (i > e1) {
  5313. if (i <= e2) {
  5314. const nextPos = e2 + 1
  5315. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor
  5316. while (i <= e2) {
  5317. patch(
  5318. null,
  5319. c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i]),
  5320. container,
  5321. anchor,
  5322. parentComponent,
  5323. parentSuspense,
  5324. namespace,
  5325. slotScopeIds,
  5326. optimized,
  5327. )
  5328. i++
  5329. }
  5330. }
  5331. }
  5332. else if (i > e2) {
  5333. while (i <= e1) {
  5334. unmount(c1[i], parentComponent, parentSuspense, true)
  5335. i++
  5336. }
  5337. }
  5338. else {
  5339. const s1 = i
  5340. const s2 = i
  5341. const keyToNewIndexMap = /* @__PURE__ */ new Map()
  5342. for (i = s2; i <= e2; i++) {
  5343. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode$1(c2[i])
  5344. if (nextChild.key != null) {
  5345. if (keyToNewIndexMap.has(nextChild.key)) {
  5346. warn$1(
  5347. `Duplicate keys found during update:`,
  5348. JSON.stringify(nextChild.key),
  5349. `Make sure keys are unique.`,
  5350. )
  5351. }
  5352. keyToNewIndexMap.set(nextChild.key, i)
  5353. }
  5354. }
  5355. let j
  5356. let patched = 0
  5357. const toBePatched = e2 - s2 + 1
  5358. let moved = false
  5359. let maxNewIndexSoFar = 0
  5360. const newIndexToOldIndexMap = new Array(toBePatched)
  5361. for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0
  5362. for (i = s1; i <= e1; i++) {
  5363. const prevChild = c1[i]
  5364. if (patched >= toBePatched) {
  5365. unmount(prevChild, parentComponent, parentSuspense, true)
  5366. continue
  5367. }
  5368. let newIndex
  5369. if (prevChild.key != null) {
  5370. newIndex = keyToNewIndexMap.get(prevChild.key)
  5371. }
  5372. else {
  5373. for (j = s2; j <= e2; j++) {
  5374. if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
  5375. newIndex = j
  5376. break
  5377. }
  5378. }
  5379. }
  5380. if (newIndex === void 0) {
  5381. unmount(prevChild, parentComponent, parentSuspense, true)
  5382. }
  5383. else {
  5384. newIndexToOldIndexMap[newIndex - s2] = i + 1
  5385. if (newIndex >= maxNewIndexSoFar)
  5386. maxNewIndexSoFar = newIndex
  5387. else
  5388. moved = true
  5389. patch(
  5390. prevChild,
  5391. c2[newIndex],
  5392. container,
  5393. null,
  5394. parentComponent,
  5395. parentSuspense,
  5396. namespace,
  5397. slotScopeIds,
  5398. optimized,
  5399. )
  5400. patched++
  5401. }
  5402. }
  5403. const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR
  5404. j = increasingNewIndexSequence.length - 1
  5405. for (i = toBePatched - 1; i >= 0; i--) {
  5406. const nextIndex = s2 + i
  5407. const nextChild = c2[nextIndex]
  5408. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor
  5409. if (newIndexToOldIndexMap[i] === 0) {
  5410. patch(
  5411. null,
  5412. nextChild,
  5413. container,
  5414. anchor,
  5415. parentComponent,
  5416. parentSuspense,
  5417. namespace,
  5418. slotScopeIds,
  5419. optimized,
  5420. )
  5421. }
  5422. else if (moved) {
  5423. if (j < 0 || i !== increasingNewIndexSequence[j])
  5424. move(nextChild, container, anchor, 2)
  5425. else
  5426. j--
  5427. }
  5428. }
  5429. }
  5430. }
  5431. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  5432. const { el, type, transition, children, shapeFlag } = vnode
  5433. if (shapeFlag & 6) {
  5434. move(vnode.component.subTree, container, anchor, moveType)
  5435. return
  5436. }
  5437. if (shapeFlag & 128) {
  5438. vnode.suspense.move(container, anchor, moveType)
  5439. return
  5440. }
  5441. if (shapeFlag & 64) {
  5442. type.move(vnode, container, anchor, internals)
  5443. return
  5444. }
  5445. if (type === Fragment) {
  5446. hostInsert(el, container, anchor)
  5447. for (let i = 0; i < children.length; i++)
  5448. move(children[i], container, anchor, moveType)
  5449. hostInsert(vnode.anchor, container, anchor)
  5450. return
  5451. }
  5452. if (type === Static) {
  5453. moveStaticNode(vnode, container, anchor)
  5454. return
  5455. }
  5456. const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition
  5457. if (needTransition2) {
  5458. if (moveType === 0) {
  5459. transition.beforeEnter(el)
  5460. hostInsert(el, container, anchor)
  5461. queuePostRenderEffect(() => transition.enter(el), parentSuspense)
  5462. }
  5463. else {
  5464. const { leave, delayLeave, afterLeave } = transition
  5465. const remove2 = () => hostInsert(el, container, anchor)
  5466. const performLeave = () => {
  5467. leave(el, () => {
  5468. remove2()
  5469. afterLeave && afterLeave()
  5470. })
  5471. }
  5472. if (delayLeave)
  5473. delayLeave(el, remove2, performLeave)
  5474. else
  5475. performLeave()
  5476. }
  5477. }
  5478. else {
  5479. hostInsert(el, container, anchor)
  5480. }
  5481. }
  5482. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  5483. const {
  5484. type,
  5485. props,
  5486. ref,
  5487. children,
  5488. dynamicChildren,
  5489. shapeFlag,
  5490. patchFlag,
  5491. dirs,
  5492. } = vnode
  5493. if (ref != null)
  5494. setRef(ref, null, parentSuspense, vnode, true)
  5495. if (shapeFlag & 256) {
  5496. parentComponent.ctx.deactivate(vnode)
  5497. return
  5498. }
  5499. const shouldInvokeDirs = shapeFlag & 1 && dirs
  5500. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode)
  5501. let vnodeHook
  5502. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount))
  5503. invokeVNodeHook(vnodeHook, parentComponent, vnode)
  5504. if (shapeFlag & 6) {
  5505. unmountComponent(vnode.component, parentSuspense, doRemove)
  5506. }
  5507. else {
  5508. if (shapeFlag & 128) {
  5509. vnode.suspense.unmount(parentSuspense, doRemove)
  5510. return
  5511. }
  5512. if (shouldInvokeDirs)
  5513. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount')
  5514. if (shapeFlag & 64) {
  5515. vnode.type.remove(
  5516. vnode,
  5517. parentComponent,
  5518. parentSuspense,
  5519. optimized,
  5520. internals,
  5521. doRemove,
  5522. )
  5523. }
  5524. else if (dynamicChildren // #1153: fast path should not be taken for non-stable (v-for) fragments
  5525. && (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
  5526. unmountChildren(
  5527. dynamicChildren,
  5528. parentComponent,
  5529. parentSuspense,
  5530. false,
  5531. true,
  5532. )
  5533. }
  5534. else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
  5535. unmountChildren(children, parentComponent, parentSuspense)
  5536. }
  5537. if (doRemove)
  5538. remove(vnode)
  5539. }
  5540. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  5541. queuePostRenderEffect(() => {
  5542. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode)
  5543. shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, 'unmounted')
  5544. }, parentSuspense)
  5545. }
  5546. }
  5547. const remove = (vnode) => {
  5548. const { type, el, anchor, transition } = vnode
  5549. if (type === Fragment) {
  5550. if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
  5551. vnode.children.forEach((child) => {
  5552. if (child.type === Comment)
  5553. hostRemove(child.el)
  5554. else
  5555. remove(child)
  5556. })
  5557. }
  5558. else {
  5559. removeFragment(el, anchor)
  5560. }
  5561. return
  5562. }
  5563. if (type === Static) {
  5564. removeStaticNode(vnode)
  5565. return
  5566. }
  5567. const performRemove = () => {
  5568. hostRemove(el)
  5569. if (transition && !transition.persisted && transition.afterLeave)
  5570. transition.afterLeave()
  5571. }
  5572. if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
  5573. const { leave, delayLeave } = transition
  5574. const performLeave = () => leave(el, performRemove)
  5575. if (delayLeave)
  5576. delayLeave(vnode.el, performRemove, performLeave)
  5577. else
  5578. performLeave()
  5579. }
  5580. else {
  5581. performRemove()
  5582. }
  5583. }
  5584. const removeFragment = (cur, end) => {
  5585. let next
  5586. while (cur !== end) {
  5587. next = hostNextSibling(cur)
  5588. hostRemove(cur)
  5589. cur = next
  5590. }
  5591. hostRemove(end)
  5592. }
  5593. const unmountComponent = (instance, parentSuspense, doRemove) => {
  5594. if (instance.type.__hmrId)
  5595. unregisterHMR(instance)
  5596. const { bum, scope, update, subTree, um } = instance
  5597. if (bum)
  5598. invokeArrayFns(bum)
  5599. scope.stop()
  5600. if (update) {
  5601. update.active = false
  5602. unmount(subTree, instance, parentSuspense, doRemove)
  5603. }
  5604. if (um)
  5605. queuePostRenderEffect(um, parentSuspense)
  5606. queuePostRenderEffect(() => {
  5607. instance.isUnmounted = true
  5608. }, parentSuspense)
  5609. if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
  5610. parentSuspense.deps--
  5611. if (parentSuspense.deps === 0)
  5612. parentSuspense.resolve()
  5613. }
  5614. {
  5615. devtoolsComponentRemoved(instance)
  5616. }
  5617. }
  5618. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  5619. for (let i = start; i < children.length; i++)
  5620. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized)
  5621. }
  5622. const getNextHostNode = (vnode) => {
  5623. if (vnode.shapeFlag & 6)
  5624. return getNextHostNode(vnode.component.subTree)
  5625. if (vnode.shapeFlag & 128)
  5626. return vnode.suspense.next()
  5627. return hostNextSibling(vnode.anchor || vnode.el)
  5628. }
  5629. let isFlushing = false
  5630. const render = (vnode, container, namespace) => {
  5631. if (vnode == null) {
  5632. if (container._vnode)
  5633. unmount(container._vnode, null, null, true)
  5634. }
  5635. else {
  5636. patch(
  5637. container._vnode || null,
  5638. vnode,
  5639. container,
  5640. null,
  5641. null,
  5642. null,
  5643. namespace,
  5644. )
  5645. }
  5646. if (!isFlushing) {
  5647. isFlushing = true
  5648. flushPreFlushCbs()
  5649. flushPostFlushCbs()
  5650. isFlushing = false
  5651. }
  5652. container._vnode = vnode
  5653. }
  5654. const internals = {
  5655. p: patch,
  5656. um: unmount,
  5657. m: move,
  5658. r: remove,
  5659. mt: mountComponent,
  5660. mc: mountChildren,
  5661. pc: patchChildren,
  5662. pbc: patchBlockChildren,
  5663. n: getNextHostNode,
  5664. o: options,
  5665. }
  5666. let hydrate
  5667. let hydrateNode
  5668. return {
  5669. render,
  5670. hydrate,
  5671. createApp: createAppAPI(render, hydrate),
  5672. }
  5673. }
  5674. function resolveChildrenNamespace({ type, props }, currentNamespace) {
  5675. return currentNamespace === 'svg' && type === 'foreignObject' || currentNamespace === 'mathml' && type === 'annotation-xml' && props && props.encoding && props.encoding.includes('html') ? void 0 : currentNamespace
  5676. }
  5677. function toggleRecurse({ effect, update }, allowed) {
  5678. effect.allowRecurse = update.allowRecurse = allowed
  5679. }
  5680. function needTransition(parentSuspense, transition) {
  5681. return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted
  5682. }
  5683. function traverseStaticChildren(n1, n2, shallow = false) {
  5684. const ch1 = n1.children
  5685. const ch2 = n2.children
  5686. if (isArray(ch1) && isArray(ch2)) {
  5687. for (let i = 0; i < ch1.length; i++) {
  5688. const c1 = ch1[i]
  5689. let c2 = ch2[i]
  5690. if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
  5691. if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
  5692. c2 = ch2[i] = cloneIfMounted(ch2[i])
  5693. c2.el = c1.el
  5694. }
  5695. if (!shallow)
  5696. traverseStaticChildren(c1, c2)
  5697. }
  5698. if (c2.type === Text)
  5699. c2.el = c1.el
  5700. if (c2.type === Comment && !c2.el)
  5701. c2.el = c1.el
  5702. }
  5703. }
  5704. }
  5705. function getSequence(arr) {
  5706. const p = arr.slice()
  5707. const result = [0]
  5708. let i, j, u, v, c
  5709. const len = arr.length
  5710. for (i = 0; i < len; i++) {
  5711. const arrI = arr[i]
  5712. if (arrI !== 0) {
  5713. j = result[result.length - 1]
  5714. if (arr[j] < arrI) {
  5715. p[i] = j
  5716. result.push(i)
  5717. continue
  5718. }
  5719. u = 0
  5720. v = result.length - 1
  5721. while (u < v) {
  5722. c = u + v >> 1
  5723. if (arr[result[c]] < arrI)
  5724. u = c + 1
  5725. else
  5726. v = c
  5727. }
  5728. if (arrI < arr[result[u]]) {
  5729. if (u > 0)
  5730. p[i] = result[u - 1]
  5731. result[u] = i
  5732. }
  5733. }
  5734. }
  5735. u = result.length
  5736. v = result[u - 1]
  5737. while (u-- > 0) {
  5738. result[u] = v
  5739. v = p[v]
  5740. }
  5741. return result
  5742. }
  5743. function locateNonHydratedAsyncRoot(instance) {
  5744. const subComponent = instance.subTree.component
  5745. if (subComponent) {
  5746. if (subComponent.asyncDep && !subComponent.asyncResolved)
  5747. return subComponent
  5748. else
  5749. return locateNonHydratedAsyncRoot(subComponent)
  5750. }
  5751. }
  5752. const isTeleport = type => type.__isTeleport
  5753. const Fragment = Symbol.for('v-fgt')
  5754. const Text = Symbol.for('v-txt')
  5755. const Comment = Symbol.for('v-cmt')
  5756. const Static = Symbol.for('v-stc')
  5757. const currentBlock = null
  5758. let isBlockTreeEnabled = 1
  5759. function setBlockTracking(value) {
  5760. isBlockTreeEnabled += value
  5761. }
  5762. function isVNode$2(value) {
  5763. return value ? value.__v_isVNode === true : false
  5764. }
  5765. function isSameVNodeType(n1, n2) {
  5766. if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
  5767. n1.shapeFlag &= ~256
  5768. n2.shapeFlag &= ~512
  5769. return false
  5770. }
  5771. return n1.type === n2.type && n1.key === n2.key
  5772. }
  5773. function createVNodeWithArgsTransform(...args) {
  5774. return _createVNode(
  5775. ...args,
  5776. )
  5777. }
  5778. const normalizeKey = ({ key }) => key != null ? key : null
  5779. function normalizeRef({
  5780. ref,
  5781. ref_key,
  5782. ref_for,
  5783. }) {
  5784. if (typeof ref === 'number')
  5785. ref = `${ref}`
  5786. return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null
  5787. }
  5788. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
  5789. const vnode = {
  5790. __v_isVNode: true,
  5791. __v_skip: true,
  5792. type,
  5793. props,
  5794. key: props && normalizeKey(props),
  5795. ref: props && normalizeRef(props),
  5796. scopeId: currentScopeId,
  5797. slotScopeIds: null,
  5798. children,
  5799. component: null,
  5800. suspense: null,
  5801. ssContent: null,
  5802. ssFallback: null,
  5803. dirs: null,
  5804. transition: null,
  5805. el: null,
  5806. anchor: null,
  5807. target: null,
  5808. targetAnchor: null,
  5809. staticCount: 0,
  5810. shapeFlag,
  5811. patchFlag,
  5812. dynamicProps,
  5813. dynamicChildren: null,
  5814. appContext: null,
  5815. ctx: currentRenderingInstance,
  5816. }
  5817. if (needFullChildrenNormalization) {
  5818. normalizeChildren(vnode, children)
  5819. if (shapeFlag & 128)
  5820. type.normalize(vnode)
  5821. }
  5822. else if (children) {
  5823. vnode.shapeFlag |= isString(children) ? 8 : 16
  5824. }
  5825. if (vnode.key !== vnode.key)
  5826. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type)
  5827. if (isBlockTreeEnabled > 0 // avoid a block node from tracking itself
  5828. && !isBlockNode // has current parent block
  5829. && currentBlock // presence of a patch flag indicates this node needs patching on updates.
  5830. // component nodes also should always be patched, because even if the
  5831. // component doesn't need to update, it needs to persist the instance on to
  5832. // the next vnode so that it can be properly unmounted later.
  5833. && (vnode.patchFlag > 0 || shapeFlag & 6) // the EVENTS flag is only for hydration and if it is the only flag, the
  5834. // vnode should not be considered dynamic due to handler caching.
  5835. && vnode.patchFlag !== 32)
  5836. currentBlock.push(vnode)
  5837. return vnode
  5838. }
  5839. const createVNode = createVNodeWithArgsTransform
  5840. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  5841. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  5842. if (!type)
  5843. warn$1(`Invalid vnode type when creating vnode: ${type}.`)
  5844. type = Comment
  5845. }
  5846. if (isVNode$2(type)) {
  5847. const cloned = cloneVNode(
  5848. type,
  5849. props,
  5850. true,
  5851. /* mergeRef: true */
  5852. )
  5853. if (children)
  5854. normalizeChildren(cloned, children)
  5855. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  5856. if (cloned.shapeFlag & 6)
  5857. currentBlock[currentBlock.indexOf(type)] = cloned
  5858. else
  5859. currentBlock.push(cloned)
  5860. }
  5861. cloned.patchFlag |= -2
  5862. return cloned
  5863. }
  5864. if (isClassComponent(type))
  5865. type = type.__vccOpts
  5866. if (props) {
  5867. props = guardReactiveProps(props)
  5868. let { class: klass, style } = props
  5869. if (klass && !isString(klass))
  5870. props.class = normalizeClass(klass)
  5871. if (isObject(style)) {
  5872. if (isProxy(style) && !isArray(style))
  5873. style = extend({}, style)
  5874. props.style = normalizeStyle(style)
  5875. }
  5876. }
  5877. const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0
  5878. if (shapeFlag & 4 && isProxy(type)) {
  5879. type = toRaw(type)
  5880. warn$1(
  5881. `Vue received a Component that 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\`.`,
  5882. `
  5883. Component that was made reactive: `,
  5884. type,
  5885. )
  5886. }
  5887. return createBaseVNode(
  5888. type,
  5889. props,
  5890. children,
  5891. patchFlag,
  5892. dynamicProps,
  5893. shapeFlag,
  5894. isBlockNode,
  5895. true,
  5896. )
  5897. }
  5898. function guardReactiveProps(props) {
  5899. if (!props)
  5900. return null
  5901. return isProxy(props) || isInternalObject(props) ? extend({}, props) : props
  5902. }
  5903. function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
  5904. const { props, ref, patchFlag, children, transition } = vnode
  5905. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props
  5906. const cloned = {
  5907. __v_isVNode: true,
  5908. __v_skip: true,
  5909. type: vnode.type,
  5910. props: mergedProps,
  5911. key: mergedProps && normalizeKey(mergedProps),
  5912. ref: extraProps && extraProps.ref ? (
  5913. // #2078 in the case of <component :is="vnode" ref="extra"/>
  5914. // if the vnode itself already has a ref, cloneVNode will need to merge
  5915. // the refs so the single vnode can be set on multiple refs
  5916. mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
  5917. ) : ref,
  5918. scopeId: vnode.scopeId,
  5919. slotScopeIds: vnode.slotScopeIds,
  5920. children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
  5921. target: vnode.target,
  5922. targetAnchor: vnode.targetAnchor,
  5923. staticCount: vnode.staticCount,
  5924. shapeFlag: vnode.shapeFlag,
  5925. // if the vnode is cloned with extra props, we can no longer assume its
  5926. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  5927. // note: preserve flag for fragments since they use the flag for children
  5928. // fast paths only.
  5929. patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
  5930. dynamicProps: vnode.dynamicProps,
  5931. dynamicChildren: vnode.dynamicChildren,
  5932. appContext: vnode.appContext,
  5933. dirs: vnode.dirs,
  5934. transition,
  5935. // These should technically only be non-null on mounted VNodes. However,
  5936. // they *should* be copied for kept-alive vnodes. So we just always copy
  5937. // them since them being non-null during a mount doesn't affect the logic as
  5938. // they will simply be overwritten.
  5939. component: vnode.component,
  5940. suspense: vnode.suspense,
  5941. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  5942. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  5943. el: vnode.el,
  5944. anchor: vnode.anchor,
  5945. ctx: vnode.ctx,
  5946. ce: vnode.ce,
  5947. }
  5948. if (transition && cloneTransition)
  5949. cloned.transition = transition.clone(cloned)
  5950. return cloned
  5951. }
  5952. function deepCloneVNode(vnode) {
  5953. const cloned = cloneVNode(vnode)
  5954. if (isArray(vnode.children))
  5955. cloned.children = vnode.children.map(deepCloneVNode)
  5956. return cloned
  5957. }
  5958. function createTextVNode(text = ' ', flag = 0) {
  5959. return createVNode(Text, null, text, flag)
  5960. }
  5961. function normalizeVNode$1(child) {
  5962. if (child == null || typeof child === 'boolean') {
  5963. return createVNode(Comment)
  5964. }
  5965. else if (isArray(child)) {
  5966. return createVNode(
  5967. Fragment,
  5968. null,
  5969. // #3666, avoid reference pollution when reusing vnode
  5970. child.slice(),
  5971. )
  5972. }
  5973. else if (typeof child === 'object') {
  5974. return cloneIfMounted(child)
  5975. }
  5976. else {
  5977. return createVNode(Text, null, String(child))
  5978. }
  5979. }
  5980. function cloneIfMounted(child) {
  5981. return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child)
  5982. }
  5983. function normalizeChildren(vnode, children) {
  5984. let type = 0
  5985. const { shapeFlag } = vnode
  5986. if (children == null) {
  5987. children = null
  5988. }
  5989. else if (isArray(children)) {
  5990. type = 16
  5991. }
  5992. else if (typeof children === 'object') {
  5993. if (shapeFlag & (1 | 64)) {
  5994. const slot = children.default
  5995. if (slot) {
  5996. slot._c && (slot._d = false)
  5997. normalizeChildren(vnode, slot())
  5998. slot._c && (slot._d = true)
  5999. }
  6000. return
  6001. }
  6002. else {
  6003. type = 32
  6004. const slotFlag = children._
  6005. if (!slotFlag && !isInternalObject(children)) {
  6006. children._ctx = currentRenderingInstance
  6007. }
  6008. else if (slotFlag === 3 && currentRenderingInstance) {
  6009. if (currentRenderingInstance.slots._ === 1) {
  6010. children._ = 1
  6011. }
  6012. else {
  6013. children._ = 2
  6014. vnode.patchFlag |= 1024
  6015. }
  6016. }
  6017. }
  6018. }
  6019. else if (isFunction(children)) {
  6020. children = { default: children, _ctx: currentRenderingInstance }
  6021. type = 32
  6022. }
  6023. else {
  6024. children = String(children)
  6025. if (shapeFlag & 64) {
  6026. type = 16
  6027. children = [createTextVNode(children)]
  6028. }
  6029. else {
  6030. type = 8
  6031. }
  6032. }
  6033. vnode.children = children
  6034. vnode.shapeFlag |= type
  6035. }
  6036. function mergeProps(...args) {
  6037. const ret = {}
  6038. for (let i = 0; i < args.length; i++) {
  6039. const toMerge = args[i]
  6040. for (const key in toMerge) {
  6041. if (key === 'class') {
  6042. if (ret.class !== toMerge.class)
  6043. ret.class = normalizeClass([ret.class, toMerge.class])
  6044. }
  6045. else if (key === 'style') {
  6046. ret.style = normalizeStyle([ret.style, toMerge.style])
  6047. }
  6048. else if (isOn(key)) {
  6049. const existing = ret[key]
  6050. const incoming = toMerge[key]
  6051. if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming)))
  6052. ret[key] = existing ? [].concat(existing, incoming) : incoming
  6053. }
  6054. else if (key !== '') {
  6055. ret[key] = toMerge[key]
  6056. }
  6057. }
  6058. }
  6059. return ret
  6060. }
  6061. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  6062. callWithAsyncErrorHandling(hook, instance, 7, [
  6063. vnode,
  6064. prevVNode,
  6065. ])
  6066. }
  6067. const emptyAppContext = createAppContext()
  6068. let uid = 0
  6069. function createComponentInstance$1(vnode, parent, suspense) {
  6070. const type = vnode.type
  6071. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext
  6072. const instance = {
  6073. uid: uid++,
  6074. vnode,
  6075. type,
  6076. parent,
  6077. appContext,
  6078. root: null,
  6079. // to be immediately set
  6080. next: null,
  6081. subTree: null,
  6082. // will be set synchronously right after creation
  6083. effect: null,
  6084. update: null,
  6085. // will be set synchronously right after creation
  6086. scope: new EffectScope(
  6087. true,
  6088. /* detached */
  6089. ),
  6090. render: null,
  6091. proxy: null,
  6092. exposed: null,
  6093. exposeProxy: null,
  6094. withProxy: null,
  6095. provides: parent ? parent.provides : Object.create(appContext.provides),
  6096. accessCache: null,
  6097. renderCache: [],
  6098. // local resolved assets
  6099. components: null,
  6100. directives: null,
  6101. // resolved props and emits options
  6102. propsOptions: normalizePropsOptions(type, appContext),
  6103. emitsOptions: normalizeEmitsOptions(type, appContext),
  6104. // emit
  6105. emit: null,
  6106. // to be set immediately
  6107. emitted: null,
  6108. // props default value
  6109. propsDefaults: EMPTY_OBJ,
  6110. // inheritAttrs
  6111. inheritAttrs: type.inheritAttrs,
  6112. // state
  6113. ctx: EMPTY_OBJ,
  6114. data: EMPTY_OBJ,
  6115. props: EMPTY_OBJ,
  6116. attrs: EMPTY_OBJ,
  6117. slots: EMPTY_OBJ,
  6118. refs: EMPTY_OBJ,
  6119. setupState: EMPTY_OBJ,
  6120. setupContext: null,
  6121. attrsProxy: null,
  6122. slotsProxy: null,
  6123. // suspense related
  6124. suspense,
  6125. suspenseId: suspense ? suspense.pendingId : 0,
  6126. asyncDep: null,
  6127. asyncResolved: false,
  6128. // lifecycle hooks
  6129. // not using enums here because it results in computed properties
  6130. isMounted: false,
  6131. isUnmounted: false,
  6132. isDeactivated: false,
  6133. bc: null,
  6134. c: null,
  6135. bm: null,
  6136. m: null,
  6137. bu: null,
  6138. u: null,
  6139. um: null,
  6140. bum: null,
  6141. da: null,
  6142. a: null,
  6143. rtg: null,
  6144. rtc: null,
  6145. ec: null,
  6146. sp: null,
  6147. }
  6148. {
  6149. instance.ctx = createDevRenderContext(instance)
  6150. }
  6151. instance.root = parent ? parent.root : instance
  6152. instance.emit = emit.bind(null, instance)
  6153. if (vnode.ce)
  6154. vnode.ce(instance)
  6155. return instance
  6156. }
  6157. let currentInstance = null
  6158. const getCurrentInstance = () => currentInstance || currentRenderingInstance
  6159. let internalSetCurrentInstance
  6160. let setInSSRSetupState
  6161. {
  6162. const g = getGlobalThis()
  6163. const registerGlobalSetter = (key, setter) => {
  6164. let setters
  6165. if (!(setters = g[key]))
  6166. setters = g[key] = []
  6167. setters.push(setter)
  6168. return (v) => {
  6169. if (setters.length > 1)
  6170. setters.forEach(set => set(v))
  6171. else setters[0](v)
  6172. }
  6173. }
  6174. internalSetCurrentInstance = registerGlobalSetter(
  6175. `__VUE_INSTANCE_SETTERS__`,
  6176. v => currentInstance = v,
  6177. )
  6178. setInSSRSetupState = registerGlobalSetter(
  6179. `__VUE_SSR_SETTERS__`,
  6180. v => isInSSRComponentSetup = v,
  6181. )
  6182. }
  6183. function setCurrentInstance(instance) {
  6184. const prev = currentInstance
  6185. internalSetCurrentInstance(instance)
  6186. instance.scope.on()
  6187. return () => {
  6188. instance.scope.off()
  6189. internalSetCurrentInstance(prev)
  6190. }
  6191. }
  6192. function unsetCurrentInstance() {
  6193. currentInstance && currentInstance.scope.off()
  6194. internalSetCurrentInstance(null)
  6195. }
  6196. const isBuiltInTag = /* @__PURE__ */ makeMap('slot,component')
  6197. function validateComponentName(name, { isNativeTag }) {
  6198. if (isBuiltInTag(name) || isNativeTag(name)) {
  6199. warn$1(
  6200. `Do not use built-in or reserved HTML elements as component id: ${name}`,
  6201. )
  6202. }
  6203. }
  6204. function isStatefulComponent(instance) {
  6205. return instance.vnode.shapeFlag & 4
  6206. }
  6207. let isInSSRComponentSetup = false
  6208. function setupComponent$1(instance, isSSR = false) {
  6209. isSSR && setInSSRSetupState(isSSR)
  6210. const { props, children } = instance.vnode
  6211. const isStateful = isStatefulComponent(instance)
  6212. initProps(instance, props, isStateful, isSSR)
  6213. initSlots(instance, children)
  6214. const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0
  6215. isSSR && setInSSRSetupState(false)
  6216. return setupResult
  6217. }
  6218. function setupStatefulComponent(instance, isSSR) {
  6219. let _a
  6220. const Component = instance.type
  6221. {
  6222. if (Component.name)
  6223. validateComponentName(Component.name, instance.appContext.config)
  6224. if (Component.components) {
  6225. const names = Object.keys(Component.components)
  6226. for (let i = 0; i < names.length; i++)
  6227. validateComponentName(names[i], instance.appContext.config)
  6228. }
  6229. if (Component.directives) {
  6230. const names = Object.keys(Component.directives)
  6231. for (let i = 0; i < names.length; i++)
  6232. validateDirectiveName(names[i])
  6233. }
  6234. if (Component.compilerOptions && isRuntimeOnly()) {
  6235. warn$1(
  6236. `"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.`,
  6237. )
  6238. }
  6239. }
  6240. instance.accessCache = /* @__PURE__ */ Object.create(null)
  6241. instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers)
  6242. {
  6243. exposePropsOnRenderContext(instance)
  6244. }
  6245. const { setup } = Component
  6246. if (setup) {
  6247. const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null
  6248. const reset = setCurrentInstance(instance)
  6249. pauseTracking()
  6250. const setupResult = callWithErrorHandling(
  6251. setup,
  6252. instance,
  6253. 0,
  6254. [
  6255. shallowReadonly(instance.props),
  6256. setupContext,
  6257. ],
  6258. )
  6259. resetTracking()
  6260. reset()
  6261. if (isPromise(setupResult)) {
  6262. setupResult.then(unsetCurrentInstance, unsetCurrentInstance)
  6263. if (isSSR) {
  6264. return setupResult.then((resolvedResult) => {
  6265. handleSetupResult(instance, resolvedResult, isSSR)
  6266. }).catch((e) => {
  6267. handleError(e, instance, 0)
  6268. })
  6269. }
  6270. else {
  6271. instance.asyncDep = setupResult
  6272. if (!instance.suspense) {
  6273. const name = (_a = Component.name) != null ? _a : 'Anonymous'
  6274. warn$1(
  6275. `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.`,
  6276. )
  6277. }
  6278. }
  6279. }
  6280. else {
  6281. handleSetupResult(instance, setupResult, isSSR)
  6282. }
  6283. }
  6284. else {
  6285. finishComponentSetup(instance, isSSR)
  6286. }
  6287. }
  6288. function handleSetupResult(instance, setupResult, isSSR) {
  6289. if (isFunction(setupResult)) {
  6290. if (instance.type.__ssrInlineRender)
  6291. instance.ssrRender = setupResult
  6292. else
  6293. instance.render = setupResult
  6294. }
  6295. else if (isObject(setupResult)) {
  6296. if (isVNode$2(setupResult)) {
  6297. warn$1(
  6298. `setup() should not return VNodes directly - return a render function instead.`,
  6299. )
  6300. }
  6301. {
  6302. instance.devtoolsRawSetupState = setupResult
  6303. }
  6304. instance.setupState = proxyRefs(setupResult)
  6305. {
  6306. exposeSetupStateOnRenderContext(instance)
  6307. }
  6308. }
  6309. else if (setupResult !== void 0) {
  6310. warn$1(
  6311. `setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`,
  6312. )
  6313. }
  6314. finishComponentSetup(instance, isSSR)
  6315. }
  6316. let compile
  6317. const isRuntimeOnly = () => !compile
  6318. function finishComponentSetup(instance, isSSR, skipOptions) {
  6319. const Component = instance.type
  6320. if (!instance.render) {
  6321. if (!isSSR && compile && !Component.render) {
  6322. const template = Component.template || resolveMergedOptions(instance).template
  6323. if (template) {
  6324. {
  6325. startMeasure(instance, `compile`)
  6326. }
  6327. const { isCustomElement, compilerOptions } = instance.appContext.config
  6328. const { delimiters, compilerOptions: componentCompilerOptions } = Component
  6329. const finalCompilerOptions = extend(
  6330. extend(
  6331. {
  6332. isCustomElement,
  6333. delimiters,
  6334. },
  6335. compilerOptions,
  6336. ),
  6337. componentCompilerOptions,
  6338. )
  6339. Component.render = compile(template, finalCompilerOptions)
  6340. {
  6341. endMeasure(instance, `compile`)
  6342. }
  6343. }
  6344. }
  6345. instance.render = Component.render || NOOP
  6346. }
  6347. {
  6348. const reset = setCurrentInstance(instance)
  6349. pauseTracking()
  6350. try {
  6351. applyOptions(instance)
  6352. }
  6353. finally {
  6354. resetTracking()
  6355. reset()
  6356. }
  6357. }
  6358. if (!Component.render && instance.render === NOOP && !isSSR) {
  6359. if (Component.template) {
  6360. warn$1(
  6361. `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.esm-browser.js" instead.`),
  6362. )
  6363. }
  6364. else {
  6365. warn$1(`Component is missing template or render function: `, Component)
  6366. }
  6367. }
  6368. }
  6369. const attrsProxyHandlers = {
  6370. get(target, key) {
  6371. markAttrsAccessed()
  6372. track(target, 'get', '')
  6373. return target[key]
  6374. },
  6375. set() {
  6376. warn$1(`setupContext.attrs is readonly.`)
  6377. return false
  6378. },
  6379. deleteProperty() {
  6380. warn$1(`setupContext.attrs is readonly.`)
  6381. return false
  6382. },
  6383. }
  6384. function getSlotsProxy(instance) {
  6385. return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
  6386. get(target, key) {
  6387. track(instance, 'get', '$slots')
  6388. return target[key]
  6389. },
  6390. }))
  6391. }
  6392. function createSetupContext(instance) {
  6393. const expose = (exposed) => {
  6394. {
  6395. if (instance.exposed)
  6396. warn$1(`expose() should be called only once per setup().`)
  6397. if (exposed != null) {
  6398. let exposedType = typeof exposed
  6399. if (exposedType === 'object') {
  6400. if (isArray(exposed))
  6401. exposedType = 'array'
  6402. else if (isRef(exposed))
  6403. exposedType = 'ref'
  6404. }
  6405. if (exposedType !== 'object') {
  6406. warn$1(
  6407. `expose() should be passed a plain object, received ${exposedType}.`,
  6408. )
  6409. }
  6410. }
  6411. }
  6412. instance.exposed = exposed || {}
  6413. }
  6414. {
  6415. let attrsProxy
  6416. return Object.freeze({
  6417. get attrs() {
  6418. return attrsProxy || (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers))
  6419. },
  6420. get slots() {
  6421. return getSlotsProxy(instance)
  6422. },
  6423. get emit() {
  6424. return (event, ...args) => instance.emit(event, ...args)
  6425. },
  6426. expose,
  6427. })
  6428. }
  6429. }
  6430. function getExposeProxy(instance) {
  6431. if (instance.exposed) {
  6432. return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  6433. get(target, key) {
  6434. if (key in target)
  6435. return target[key]
  6436. else if (key in publicPropertiesMap)
  6437. return publicPropertiesMap[key](instance)
  6438. },
  6439. has(target, key) {
  6440. return key in target || key in publicPropertiesMap
  6441. },
  6442. }))
  6443. }
  6444. }
  6445. const classifyRE = /(?:^|[-_])(\w)/g
  6446. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '')
  6447. function getComponentName(Component, includeInferred = true) {
  6448. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name
  6449. }
  6450. function formatComponentName(instance, Component, isRoot = false) {
  6451. let name = getComponentName(Component)
  6452. if (!name && Component.__file) {
  6453. const match = Component.__file.match(/([^/\\]+)\.\w+$/)
  6454. if (match)
  6455. name = match[1]
  6456. }
  6457. if (!name && instance && instance.parent) {
  6458. const inferFromRegistry = (registry) => {
  6459. for (const key in registry) {
  6460. if (registry[key] === Component)
  6461. return key
  6462. }
  6463. }
  6464. name = inferFromRegistry(
  6465. instance.components || instance.parent.type.components,
  6466. ) || inferFromRegistry(instance.appContext.components)
  6467. }
  6468. return name ? classify(name) : isRoot ? `App` : `Anonymous`
  6469. }
  6470. function isClassComponent(value) {
  6471. return isFunction(value) && '__vccOpts' in value
  6472. }
  6473. function computed(getterOrOptions, debugOptions) {
  6474. const c = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup)
  6475. {
  6476. const i = getCurrentInstance()
  6477. if (i && i.appContext.config.warnRecursiveComputed)
  6478. c._warnRecursive = true
  6479. }
  6480. return c
  6481. }
  6482. const version = '3.4.27'
  6483. const warn = warn$1
  6484. const _ssrUtils = {
  6485. createComponentInstance: createComponentInstance$1,
  6486. setupComponent: setupComponent$1,
  6487. renderComponentRoot: renderComponentRoot$1,
  6488. setCurrentRenderingInstance: setCurrentRenderingInstance$1,
  6489. isVNode: isVNode$2,
  6490. normalizeVNode: normalizeVNode$1,
  6491. }
  6492. const ssrUtils = _ssrUtils
  6493. const svgNS = 'http://www.w3.org/2000/svg'
  6494. const mathmlNS = 'http://www.w3.org/1998/Math/MathML'
  6495. const doc = typeof document !== 'undefined' ? document : null
  6496. const templateContainer = doc && /* @__PURE__ */ doc.createElement('template')
  6497. const nodeOps = {
  6498. insert: (child, parent, anchor) => {
  6499. parent.insertBefore(child, anchor || null)
  6500. },
  6501. remove: (child) => {
  6502. const parent = child.parentNode
  6503. if (parent)
  6504. parent.removeChild(child)
  6505. },
  6506. createElement: (tag, namespace, is, props) => {
  6507. const el = namespace === 'svg' ? doc.createElementNS(svgNS, tag) : namespace === 'mathml' ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0)
  6508. if (tag === 'select' && props && props.multiple != null)
  6509. el.setAttribute('multiple', props.multiple)
  6510. return el
  6511. },
  6512. createText: text => doc.createTextNode(text),
  6513. createComment: text => doc.createComment(text),
  6514. setText: (node, text) => {
  6515. node.nodeValue = text
  6516. },
  6517. setElementText: (el, text) => {
  6518. el.textContent = text
  6519. },
  6520. parentNode: node => node.parentNode,
  6521. nextSibling: node => node.nextSibling,
  6522. querySelector: selector => doc.querySelector(selector),
  6523. setScopeId(el, id) {
  6524. el.setAttribute(id, '')
  6525. },
  6526. // __UNSAFE__
  6527. // Reason: innerHTML.
  6528. // Static content here can only come from compiled templates.
  6529. // As long as the user only uses trusted templates, this is safe.
  6530. insertStaticContent(content, parent, anchor, namespace, start, end) {
  6531. const before = anchor ? anchor.previousSibling : parent.lastChild
  6532. if (start && (start === end || start.nextSibling)) {
  6533. while (true) {
  6534. parent.insertBefore(start.cloneNode(true), anchor)
  6535. if (start === end || !(start = start.nextSibling))
  6536. break
  6537. }
  6538. }
  6539. else {
  6540. templateContainer.innerHTML = namespace === 'svg' ? `<svg>${content}</svg>` : namespace === 'mathml' ? `<math>${content}</math>` : content
  6541. const template = templateContainer.content
  6542. if (namespace === 'svg' || namespace === 'mathml') {
  6543. const wrapper = template.firstChild
  6544. while (wrapper.firstChild)
  6545. template.appendChild(wrapper.firstChild)
  6546. template.removeChild(wrapper)
  6547. }
  6548. parent.insertBefore(template, anchor)
  6549. }
  6550. return [
  6551. // first
  6552. before ? before.nextSibling : parent.firstChild,
  6553. // last
  6554. anchor ? anchor.previousSibling : parent.lastChild,
  6555. ]
  6556. },
  6557. }
  6558. const vtcKey = Symbol('_vtc')
  6559. function patchClass(el, value, isSVG) {
  6560. const transitionClasses = el[vtcKey]
  6561. if (transitionClasses)
  6562. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ')
  6563. if (value == null)
  6564. el.removeAttribute('class')
  6565. else if (isSVG)
  6566. el.setAttribute('class', value)
  6567. else
  6568. el.className = value
  6569. }
  6570. const vShowOriginalDisplay = Symbol('_vod')
  6571. const vShowHidden = Symbol('_vsh')
  6572. const CSS_VAR_TEXT = Symbol('CSS_VAR_TEXT')
  6573. const displayRE = /(^|;)\s*display\s*:/
  6574. function patchStyle(el, prev, next) {
  6575. const style = el.style
  6576. const isCssString = isString(next)
  6577. let hasControlledDisplay = false
  6578. if (next && !isCssString) {
  6579. if (prev) {
  6580. if (!isString(prev)) {
  6581. for (const key in prev) {
  6582. if (next[key] == null)
  6583. setStyle(style, key, '')
  6584. }
  6585. }
  6586. else {
  6587. for (const prevStyle of prev.split(';')) {
  6588. const key = prevStyle.slice(0, prevStyle.indexOf(':')).trim()
  6589. if (next[key] == null)
  6590. setStyle(style, key, '')
  6591. }
  6592. }
  6593. }
  6594. for (const key in next) {
  6595. if (key === 'display')
  6596. hasControlledDisplay = true
  6597. setStyle(style, key, next[key])
  6598. }
  6599. }
  6600. else {
  6601. if (isCssString) {
  6602. if (prev !== next) {
  6603. const cssVarText = style[CSS_VAR_TEXT]
  6604. if (cssVarText)
  6605. next += `;${cssVarText}`
  6606. style.cssText = next
  6607. hasControlledDisplay = displayRE.test(next)
  6608. }
  6609. }
  6610. else if (prev) {
  6611. el.removeAttribute('style')
  6612. }
  6613. }
  6614. if (vShowOriginalDisplay in el) {
  6615. el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : ''
  6616. if (el[vShowHidden])
  6617. style.display = 'none'
  6618. }
  6619. }
  6620. const semicolonRE = /[^\\];\s*$/
  6621. const importantRE = /\s*!important$/
  6622. function setStyle(style, name, val) {
  6623. if (isArray(val)) {
  6624. val.forEach(v => setStyle(style, name, v))
  6625. }
  6626. else {
  6627. if (val == null)
  6628. val = ''
  6629. {
  6630. if (semicolonRE.test(val)) {
  6631. warn(
  6632. `Unexpected semicolon at the end of '${name}' style value: '${val}'`,
  6633. )
  6634. }
  6635. }
  6636. if (name.startsWith('--')) {
  6637. style.setProperty(name, val)
  6638. }
  6639. else {
  6640. const prefixed = autoPrefix(style, name)
  6641. if (importantRE.test(val)) {
  6642. style.setProperty(
  6643. hyphenate(prefixed),
  6644. val.replace(importantRE, ''),
  6645. 'important',
  6646. )
  6647. }
  6648. else {
  6649. style[prefixed] = val
  6650. }
  6651. }
  6652. }
  6653. }
  6654. const prefixes = ['Webkit', 'Moz', 'ms']
  6655. const prefixCache = {}
  6656. function autoPrefix(style, rawName) {
  6657. const cached = prefixCache[rawName]
  6658. if (cached)
  6659. return cached
  6660. let name = camelize(rawName)
  6661. if (name !== 'filter' && name in style)
  6662. return prefixCache[rawName] = name
  6663. name = capitalize(name)
  6664. for (let i = 0; i < prefixes.length; i++) {
  6665. const prefixed = prefixes[i] + name
  6666. if (prefixed in style)
  6667. return prefixCache[rawName] = prefixed
  6668. }
  6669. return rawName
  6670. }
  6671. const xlinkNS = 'http://www.w3.org/1999/xlink'
  6672. function patchAttr(el, key, value, isSVG, instance) {
  6673. if (isSVG && key.startsWith('xlink:')) {
  6674. if (value == null)
  6675. el.removeAttributeNS(xlinkNS, key.slice(6, key.length))
  6676. else
  6677. el.setAttributeNS(xlinkNS, key, value)
  6678. }
  6679. else {
  6680. const isBoolean = isSpecialBooleanAttr(key)
  6681. if (value == null || isBoolean && !includeBooleanAttr(value))
  6682. el.removeAttribute(key)
  6683. else
  6684. el.setAttribute(key, isBoolean ? '' : value)
  6685. }
  6686. }
  6687. function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  6688. if (key === 'innerHTML' || key === 'textContent') {
  6689. if (prevChildren)
  6690. unmountChildren(prevChildren, parentComponent, parentSuspense)
  6691. el[key] = value == null ? '' : value
  6692. return
  6693. }
  6694. const tag = el.tagName
  6695. if (key === 'value' && tag !== 'PROGRESS' // custom elements may use _value internally
  6696. && !tag.includes('-')) {
  6697. const oldValue = tag === 'OPTION' ? el.getAttribute('value') || '' : el.value
  6698. const newValue = value == null ? '' : value
  6699. if (oldValue !== newValue || !('_value' in el))
  6700. el.value = newValue
  6701. if (value == null)
  6702. el.removeAttribute(key)
  6703. el._value = value
  6704. return
  6705. }
  6706. let needRemove = false
  6707. if (value === '' || value == null) {
  6708. const type = typeof el[key]
  6709. if (type === 'boolean') {
  6710. value = includeBooleanAttr(value)
  6711. }
  6712. else if (value == null && type === 'string') {
  6713. value = ''
  6714. needRemove = true
  6715. }
  6716. else if (type === 'number') {
  6717. value = 0
  6718. needRemove = true
  6719. }
  6720. }
  6721. try {
  6722. el[key] = value
  6723. }
  6724. catch (e) {
  6725. if (!needRemove) {
  6726. warn(
  6727. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  6728. e,
  6729. )
  6730. }
  6731. }
  6732. needRemove && el.removeAttribute(key)
  6733. }
  6734. function addEventListener(el, event, handler, options) {
  6735. el.addEventListener(event, handler, options)
  6736. }
  6737. function removeEventListener(el, event, handler, options) {
  6738. el.removeEventListener(event, handler, options)
  6739. }
  6740. const veiKey = Symbol('_vei')
  6741. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  6742. const invokers = el[veiKey] || (el[veiKey] = {})
  6743. const existingInvoker = invokers[rawName]
  6744. if (nextValue && existingInvoker) {
  6745. existingInvoker.value = sanitizeEventValue(nextValue, rawName)
  6746. }
  6747. else {
  6748. const [name, options] = parseName(rawName)
  6749. if (nextValue) {
  6750. const invoker = invokers[rawName] = createInvoker(
  6751. sanitizeEventValue(nextValue, rawName),
  6752. instance,
  6753. )
  6754. addEventListener(el, name, invoker, options)
  6755. }
  6756. else if (existingInvoker) {
  6757. removeEventListener(el, name, existingInvoker, options)
  6758. invokers[rawName] = void 0
  6759. }
  6760. }
  6761. }
  6762. const optionsModifierRE = /(?:Once|Passive|Capture)$/
  6763. function parseName(name) {
  6764. let options
  6765. if (optionsModifierRE.test(name)) {
  6766. options = {}
  6767. let m
  6768. while (m = name.match(optionsModifierRE)) {
  6769. name = name.slice(0, name.length - m[0].length)
  6770. options[m[0].toLowerCase()] = true
  6771. }
  6772. }
  6773. const event = name[2] === ':' ? name.slice(3) : hyphenate(name.slice(2))
  6774. return [event, options]
  6775. }
  6776. let cachedNow = 0
  6777. const p = /* @__PURE__ */ Promise.resolve()
  6778. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now())
  6779. function createInvoker(initialValue, instance) {
  6780. const invoker = (e) => {
  6781. if (!e._vts)
  6782. e._vts = Date.now()
  6783. else if (e._vts <= invoker.attached)
  6784. return
  6785. callWithAsyncErrorHandling(
  6786. patchStopImmediatePropagation(e, invoker.value),
  6787. instance,
  6788. 5,
  6789. [e],
  6790. )
  6791. }
  6792. invoker.value = initialValue
  6793. invoker.attached = getNow()
  6794. return invoker
  6795. }
  6796. function sanitizeEventValue(value, propName) {
  6797. if (isFunction(value) || isArray(value))
  6798. return value
  6799. warn(
  6800. `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
  6801. Expected function or array of functions, received type ${typeof value}.`,
  6802. )
  6803. return NOOP
  6804. }
  6805. function patchStopImmediatePropagation(e, value) {
  6806. if (isArray(value)) {
  6807. const originalStop = e.stopImmediatePropagation
  6808. e.stopImmediatePropagation = () => {
  6809. originalStop.call(e)
  6810. e._stopped = true
  6811. }
  6812. return value.map(
  6813. fn => e2 => !e2._stopped && fn && fn(e2),
  6814. )
  6815. }
  6816. else {
  6817. return value
  6818. }
  6819. }
  6820. function isNativeOn(key) {
  6821. return key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 // lowercase letter
  6822. && key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123
  6823. }
  6824. function patchProp(el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  6825. const isSVG = namespace === 'svg'
  6826. if (key === 'class') {
  6827. patchClass(el, nextValue, isSVG)
  6828. }
  6829. else if (key === 'style') {
  6830. patchStyle(el, prevValue, nextValue)
  6831. }
  6832. else if (isOn(key)) {
  6833. if (!isModelListener(key))
  6834. patchEvent(el, key, prevValue, nextValue, parentComponent)
  6835. }
  6836. else if (key[0] === '.' ? (key = key.slice(1), true) : key[0] === '^' ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  6837. patchDOMProp(
  6838. el,
  6839. key,
  6840. nextValue,
  6841. prevChildren,
  6842. parentComponent,
  6843. parentSuspense,
  6844. unmountChildren,
  6845. )
  6846. }
  6847. else {
  6848. if (key === 'true-value')
  6849. el._trueValue = nextValue
  6850. else if (key === 'false-value')
  6851. el._falseValue = nextValue
  6852. patchAttr(el, key, nextValue, isSVG)
  6853. }
  6854. }
  6855. function shouldSetAsProp(el, key, value, isSVG) {
  6856. if (isSVG) {
  6857. if (key === 'innerHTML' || key === 'textContent')
  6858. return true
  6859. if (key in el && isNativeOn(key) && isFunction(value))
  6860. return true
  6861. return false
  6862. }
  6863. if (key === 'spellcheck' || key === 'draggable' || key === 'translate')
  6864. return false
  6865. if (key === 'form')
  6866. return false
  6867. if (key === 'list' && el.tagName === 'INPUT')
  6868. return false
  6869. if (key === 'type' && el.tagName === 'TEXTAREA')
  6870. return false
  6871. if (key === 'width' || key === 'height') {
  6872. const tag = el.tagName
  6873. if (tag === 'IMG' || tag === 'VIDEO' || tag === 'CANVAS' || tag === 'SOURCE')
  6874. return false
  6875. }
  6876. if (isNativeOn(key) && isString(value))
  6877. return false
  6878. return key in el
  6879. }
  6880. function getModelAssigner(vnode) {
  6881. const fn = vnode.props['onUpdate:modelValue'] || false
  6882. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn
  6883. }
  6884. function onCompositionStart(e) {
  6885. e.target.composing = true
  6886. }
  6887. function onCompositionEnd(e) {
  6888. const target = e.target
  6889. if (target.composing) {
  6890. target.composing = false
  6891. target.dispatchEvent(new Event('input'))
  6892. }
  6893. }
  6894. const assignKey = Symbol('_assign')
  6895. const vModelText = {
  6896. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  6897. el[assignKey] = getModelAssigner(vnode)
  6898. const castToNumber = number || vnode.props && vnode.props.type === 'number'
  6899. addEventListener(el, lazy ? 'change' : 'input', (e) => {
  6900. if (e.target.composing)
  6901. return
  6902. let domValue = el.value
  6903. if (trim)
  6904. domValue = domValue.trim()
  6905. if (castToNumber)
  6906. domValue = looseToNumber(domValue)
  6907. el[assignKey](domValue)
  6908. })
  6909. if (trim) {
  6910. addEventListener(el, 'change', () => {
  6911. el.value = el.value.trim()
  6912. })
  6913. }
  6914. if (!lazy) {
  6915. addEventListener(el, 'compositionstart', onCompositionStart)
  6916. addEventListener(el, 'compositionend', onCompositionEnd)
  6917. addEventListener(el, 'change', onCompositionEnd)
  6918. }
  6919. },
  6920. // set value on mounted so it's after min/max for type="range"
  6921. mounted(el, { value }) {
  6922. el.value = value == null ? '' : value
  6923. },
  6924. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  6925. el[assignKey] = getModelAssigner(vnode)
  6926. if (el.composing)
  6927. return
  6928. const elValue = (number || el.type === 'number') && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value
  6929. const newValue = value == null ? '' : value
  6930. if (elValue === newValue)
  6931. return
  6932. if (document.activeElement === el && el.type !== 'range') {
  6933. if (lazy)
  6934. return
  6935. if (trim && el.value.trim() === newValue)
  6936. return
  6937. }
  6938. el.value = newValue
  6939. },
  6940. }
  6941. const vModelCheckbox = {
  6942. // #4096 array checkboxes need to be deep traversed
  6943. deep: true,
  6944. created(el, _, vnode) {
  6945. el[assignKey] = getModelAssigner(vnode)
  6946. addEventListener(el, 'change', () => {
  6947. const modelValue = el._modelValue
  6948. const elementValue = getValue(el)
  6949. const checked = el.checked
  6950. const assign = el[assignKey]
  6951. if (isArray(modelValue)) {
  6952. const index = looseIndexOf(modelValue, elementValue)
  6953. const found = index !== -1
  6954. if (checked && !found) {
  6955. assign(modelValue.concat(elementValue))
  6956. }
  6957. else if (!checked && found) {
  6958. const filtered = [...modelValue]
  6959. filtered.splice(index, 1)
  6960. assign(filtered)
  6961. }
  6962. }
  6963. else if (isSet(modelValue)) {
  6964. const cloned = new Set(modelValue)
  6965. if (checked)
  6966. cloned.add(elementValue)
  6967. else
  6968. cloned.delete(elementValue)
  6969. assign(cloned)
  6970. }
  6971. else {
  6972. assign(getCheckboxValue(el, checked))
  6973. }
  6974. })
  6975. },
  6976. // set initial checked on mount to wait for true-value/false-value
  6977. mounted: setChecked,
  6978. beforeUpdate(el, binding, vnode) {
  6979. el[assignKey] = getModelAssigner(vnode)
  6980. setChecked(el, binding, vnode)
  6981. },
  6982. }
  6983. function setChecked(el, { value, oldValue }, vnode) {
  6984. el._modelValue = value
  6985. if (isArray(value))
  6986. el.checked = looseIndexOf(value, vnode.props.value) > -1
  6987. else if (isSet(value))
  6988. el.checked = value.has(vnode.props.value)
  6989. else if (value !== oldValue)
  6990. el.checked = looseEqual(value, getCheckboxValue(el, true))
  6991. }
  6992. const vModelRadio = {
  6993. created(el, { value }, vnode) {
  6994. el.checked = looseEqual(value, vnode.props.value)
  6995. el[assignKey] = getModelAssigner(vnode)
  6996. addEventListener(el, 'change', () => {
  6997. el[assignKey](getValue(el))
  6998. })
  6999. },
  7000. beforeUpdate(el, { value, oldValue }, vnode) {
  7001. el[assignKey] = getModelAssigner(vnode)
  7002. if (value !== oldValue)
  7003. el.checked = looseEqual(value, vnode.props.value)
  7004. },
  7005. }
  7006. function getValue(el) {
  7007. return '_value' in el ? el._value : el.value
  7008. }
  7009. function getCheckboxValue(el, checked) {
  7010. const key = checked ? '_trueValue' : '_falseValue'
  7011. return key in el ? el[key] : checked
  7012. }
  7013. function initVModelForSSR() {
  7014. vModelText.getSSRProps = ({ value }) => ({ value })
  7015. vModelRadio.getSSRProps = ({ value }, vnode) => {
  7016. if (vnode.props && looseEqual(vnode.props.value, value))
  7017. return { checked: true }
  7018. }
  7019. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  7020. if (isArray(value)) {
  7021. if (vnode.props && looseIndexOf(value, vnode.props.value) > -1)
  7022. return { checked: true }
  7023. }
  7024. else if (isSet(value)) {
  7025. if (vnode.props && value.has(vnode.props.value))
  7026. return { checked: true }
  7027. }
  7028. else if (value) {
  7029. return { checked: true }
  7030. }
  7031. }
  7032. }
  7033. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps)
  7034. let renderer
  7035. function ensureRenderer() {
  7036. return renderer || (renderer = createRenderer(rendererOptions))
  7037. }
  7038. function createApp(...args) {
  7039. const app = ensureRenderer().createApp(...args)
  7040. {
  7041. injectNativeTagCheck(app)
  7042. injectCompilerOptionsCheck(app)
  7043. }
  7044. const { mount } = app
  7045. app.mount = (containerOrSelector) => {
  7046. const container = normalizeContainer(containerOrSelector)
  7047. if (!container)
  7048. return
  7049. const component = app._component
  7050. if (!isFunction(component) && !component.render && !component.template)
  7051. component.template = container.innerHTML
  7052. container.innerHTML = ''
  7053. const proxy = mount(container, false, resolveRootNamespace(container))
  7054. if (container instanceof Element) {
  7055. container.removeAttribute('v-cloak')
  7056. container.setAttribute('data-v-app', '')
  7057. }
  7058. return proxy
  7059. }
  7060. return app
  7061. }
  7062. function resolveRootNamespace(container) {
  7063. if (container instanceof SVGElement)
  7064. return 'svg'
  7065. if (typeof MathMLElement === 'function' && container instanceof MathMLElement)
  7066. return 'mathml'
  7067. }
  7068. function injectNativeTagCheck(app) {
  7069. Object.defineProperty(app.config, 'isNativeTag', {
  7070. value: tag => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  7071. writable: false,
  7072. })
  7073. }
  7074. function injectCompilerOptionsCheck(app) {
  7075. {
  7076. const isCustomElement = app.config.isCustomElement
  7077. Object.defineProperty(app.config, 'isCustomElement', {
  7078. get() {
  7079. return isCustomElement
  7080. },
  7081. set() {
  7082. warn(
  7083. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`,
  7084. )
  7085. },
  7086. })
  7087. const compilerOptions = app.config.compilerOptions
  7088. 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.
  7089. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  7090. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  7091. - 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`
  7092. Object.defineProperty(app.config, 'compilerOptions', {
  7093. get() {
  7094. warn(msg)
  7095. return compilerOptions
  7096. },
  7097. set() {
  7098. warn(msg)
  7099. },
  7100. })
  7101. }
  7102. }
  7103. function normalizeContainer(container) {
  7104. if (isString(container)) {
  7105. const res = document.querySelector(container)
  7106. if (!res) {
  7107. warn(
  7108. `Failed to mount app: mount target selector "${container}" returned null.`,
  7109. )
  7110. }
  7111. return res
  7112. }
  7113. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === 'closed') {
  7114. warn(
  7115. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`,
  7116. )
  7117. }
  7118. return container
  7119. }
  7120. let ssrDirectiveInitialized = false
  7121. function initDirectivesForSSR() {
  7122. if (!ssrDirectiveInitialized) {
  7123. ssrDirectiveInitialized = true
  7124. initVModelForSSR()
  7125. }
  7126. }
  7127. const shouldIgnoreProp = /* @__PURE__ */ makeMap(
  7128. `,key,ref,innerHTML,textContent,ref_key,ref_for`,
  7129. )
  7130. function ssrRenderAttrs(props, tag) {
  7131. let ret = ''
  7132. for (const key in props) {
  7133. if (shouldIgnoreProp(key) || isOn(key) || tag === 'textarea' && key === 'value')
  7134. continue
  7135. const value = props[key]
  7136. if (key === 'class')
  7137. ret += ` class="${ssrRenderClass(value)}"`
  7138. else if (key === 'style')
  7139. ret += ` style="${ssrRenderStyle(value)}"`
  7140. else
  7141. ret += ssrRenderDynamicAttr(key, value, tag)
  7142. }
  7143. return ret
  7144. }
  7145. function ssrRenderDynamicAttr(key, value, tag) {
  7146. if (!isRenderableAttrValue(value))
  7147. return ``
  7148. const attrKey = tag && (tag.indexOf('-') > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase()
  7149. if (isBooleanAttr(attrKey)) {
  7150. return includeBooleanAttr(value) ? ` ${attrKey}` : ``
  7151. }
  7152. else if (isSSRSafeAttrName(attrKey)) {
  7153. return value === '' ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`
  7154. }
  7155. else {
  7156. console.warn(
  7157. `[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`,
  7158. )
  7159. return ``
  7160. }
  7161. }
  7162. function ssrRenderAttr(key, value) {
  7163. if (!isRenderableAttrValue(value))
  7164. return ``
  7165. return ` ${key}="${escapeHtml(value)}"`
  7166. }
  7167. function ssrRenderClass(raw) {
  7168. return escapeHtml(normalizeClass(raw))
  7169. }
  7170. function ssrRenderStyle(raw) {
  7171. if (!raw)
  7172. return ''
  7173. if (isString(raw))
  7174. return escapeHtml(raw)
  7175. const styles = normalizeStyle(raw)
  7176. return escapeHtml(stringifyStyle(styles))
  7177. }
  7178. function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
  7179. return renderComponentVNode(
  7180. createVNode(comp, props, children),
  7181. parentComponent,
  7182. slotScopeId,
  7183. )
  7184. }
  7185. function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
  7186. push(`<!--[-->`)
  7187. ssrRenderSlotInner(
  7188. slots,
  7189. slotName,
  7190. slotProps,
  7191. fallbackRenderFn,
  7192. push,
  7193. parentComponent,
  7194. slotScopeId,
  7195. )
  7196. push(`<!--]-->`)
  7197. }
  7198. function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
  7199. const slotFn = slots[slotName]
  7200. if (slotFn) {
  7201. const slotBuffer = []
  7202. const bufferedPush = (item) => {
  7203. slotBuffer.push(item)
  7204. }
  7205. const ret = slotFn(
  7206. slotProps,
  7207. bufferedPush,
  7208. parentComponent,
  7209. slotScopeId ? ` ${slotScopeId}` : '',
  7210. )
  7211. if (isArray(ret)) {
  7212. renderVNodeChildren(push, ret, parentComponent, slotScopeId)
  7213. }
  7214. else {
  7215. let isEmptySlot = true
  7216. if (transition) {
  7217. isEmptySlot = false
  7218. }
  7219. else {
  7220. for (let i = 0; i < slotBuffer.length; i++) {
  7221. if (!isComment(slotBuffer[i])) {
  7222. isEmptySlot = false
  7223. break
  7224. }
  7225. }
  7226. }
  7227. if (isEmptySlot) {
  7228. if (fallbackRenderFn)
  7229. fallbackRenderFn()
  7230. }
  7231. else {
  7232. let start = 0
  7233. let end = slotBuffer.length
  7234. if (transition && slotBuffer[0] === '<!--[-->' && slotBuffer[end - 1] === '<!--]-->') {
  7235. start++
  7236. end--
  7237. }
  7238. for (let i = start; i < end; i++)
  7239. push(slotBuffer[i])
  7240. }
  7241. }
  7242. }
  7243. else if (fallbackRenderFn) {
  7244. fallbackRenderFn()
  7245. }
  7246. }
  7247. const commentTestRE = /^<!--.*-->$/s
  7248. const commentRE = /<!--[^]*?-->/gm
  7249. function isComment(item) {
  7250. if (typeof item !== 'string' || !commentTestRE.test(item))
  7251. return false
  7252. if (item.length <= 8)
  7253. return true
  7254. return !item.replace(commentRE, '').trim()
  7255. }
  7256. function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
  7257. parentPush('<!--teleport start-->')
  7258. const context = parentComponent.appContext.provides[ssrContextKey]
  7259. const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {})
  7260. const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = [])
  7261. const bufferIndex = targetBuffer.length
  7262. let teleportContent
  7263. if (disabled) {
  7264. contentRenderFn(parentPush)
  7265. teleportContent = `<!--teleport anchor-->`
  7266. }
  7267. else {
  7268. const { getBuffer, push } = createBuffer()
  7269. contentRenderFn(push)
  7270. push(`<!--teleport anchor-->`)
  7271. teleportContent = getBuffer()
  7272. }
  7273. targetBuffer.splice(bufferIndex, 0, teleportContent)
  7274. parentPush('<!--teleport end-->')
  7275. }
  7276. function ssrInterpolate(value) {
  7277. return escapeHtml(toDisplayString(value))
  7278. }
  7279. function ssrRenderList(source, renderItem) {
  7280. if (isArray(source) || isString(source)) {
  7281. for (let i = 0, l = source.length; i < l; i++)
  7282. renderItem(source[i], i)
  7283. }
  7284. else if (typeof source === 'number') {
  7285. if (!Number.isInteger(source)) {
  7286. warn(`The v-for range expect an integer value but got ${source}.`)
  7287. return
  7288. }
  7289. for (let i = 0; i < source; i++)
  7290. renderItem(i + 1, i)
  7291. }
  7292. else if (isObject(source)) {
  7293. if (source[Symbol.iterator]) {
  7294. const arr = Array.from(source)
  7295. for (let i = 0, l = arr.length; i < l; i++)
  7296. renderItem(arr[i], i)
  7297. }
  7298. else {
  7299. const keys = Object.keys(source)
  7300. for (let i = 0, l = keys.length; i < l; i++) {
  7301. const key = keys[i]
  7302. renderItem(source[key], key, i)
  7303. }
  7304. }
  7305. }
  7306. }
  7307. async function ssrRenderSuspense(push, { default: renderContent }) {
  7308. if (renderContent)
  7309. renderContent()
  7310. else
  7311. push(`<!---->`)
  7312. }
  7313. function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
  7314. if (typeof dir !== 'function' && dir.getSSRProps) {
  7315. return dir.getSSRProps(
  7316. {
  7317. dir,
  7318. instance,
  7319. value,
  7320. oldValue: void 0,
  7321. arg,
  7322. modifiers,
  7323. },
  7324. null,
  7325. ) || {}
  7326. }
  7327. return {}
  7328. }
  7329. const ssrLooseEqual = looseEqual
  7330. function ssrLooseContain(arr, value) {
  7331. return looseIndexOf(arr, value) > -1
  7332. }
  7333. function ssrRenderDynamicModel(type, model, value) {
  7334. switch (type) {
  7335. case 'radio':
  7336. return looseEqual(model, value) ? ' checked' : ''
  7337. case 'checkbox':
  7338. return (isArray(model) ? ssrLooseContain(model, value) : model) ? ' checked' : ''
  7339. default:
  7340. return ssrRenderAttr('value', model)
  7341. }
  7342. }
  7343. function ssrGetDynamicModelProps(existingProps = {}, model) {
  7344. const { type, value } = existingProps
  7345. switch (type) {
  7346. case 'radio':
  7347. return looseEqual(model, value) ? { checked: true } : null
  7348. case 'checkbox':
  7349. return (isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null
  7350. default:
  7351. return { value: model }
  7352. }
  7353. }
  7354. function ssrCompile(template, instance) {
  7355. {
  7356. throw new Error(
  7357. `On-the-fly template compilation is not supported in the ESM build of @vue/server-renderer. All templates must be pre-compiled into render functions.`,
  7358. )
  7359. }
  7360. }
  7361. const {
  7362. createComponentInstance,
  7363. setCurrentRenderingInstance,
  7364. setupComponent,
  7365. renderComponentRoot,
  7366. normalizeVNode,
  7367. } = ssrUtils
  7368. function createBuffer() {
  7369. let appendable = false
  7370. const buffer = []
  7371. return {
  7372. getBuffer() {
  7373. return buffer
  7374. },
  7375. push(item) {
  7376. const isStringItem = isString(item)
  7377. if (appendable && isStringItem)
  7378. buffer[buffer.length - 1] += item
  7379. else
  7380. buffer.push(item)
  7381. appendable = isStringItem
  7382. if (isPromise(item) || isArray(item) && item.hasAsync)
  7383. buffer.hasAsync = true
  7384. },
  7385. }
  7386. }
  7387. function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
  7388. const instance = createComponentInstance(vnode, parentComponent, null)
  7389. const res = setupComponent(
  7390. instance,
  7391. true,
  7392. /* isSSR */
  7393. )
  7394. const hasAsyncSetup = isPromise(res)
  7395. const prefetches = instance.sp
  7396. if (hasAsyncSetup || prefetches) {
  7397. let p = hasAsyncSetup ? res : Promise.resolve()
  7398. if (prefetches) {
  7399. p = p.then(
  7400. () => Promise.all(
  7401. prefetches.map(prefetch => prefetch.call(instance.proxy)),
  7402. ),
  7403. ).catch(NOOP)
  7404. }
  7405. return p.then(() => renderComponentSubTree(instance, slotScopeId))
  7406. }
  7407. else {
  7408. return renderComponentSubTree(instance, slotScopeId)
  7409. }
  7410. }
  7411. function renderComponentSubTree(instance, slotScopeId) {
  7412. const comp = instance.type
  7413. const { getBuffer, push } = createBuffer()
  7414. if (isFunction(comp)) {
  7415. const root = renderComponentRoot(instance)
  7416. if (!comp.props) {
  7417. for (const key in instance.attrs) {
  7418. if (key.startsWith(`data-v-`))
  7419. (root.props || (root.props = {}))[key] = ``
  7420. }
  7421. }
  7422. renderVNode(push, instance.subTree = root, instance, slotScopeId)
  7423. }
  7424. else {
  7425. if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template))
  7426. comp.ssrRender = ssrCompile(comp.template)
  7427. for (const e of instance.scope.effects) {
  7428. if (e.computed) {
  7429. e.computed._dirty = true
  7430. e.computed._cacheable = true
  7431. }
  7432. }
  7433. const ssrRender = instance.ssrRender || comp.ssrRender
  7434. if (ssrRender) {
  7435. let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0
  7436. let hasCloned = false
  7437. let cur = instance
  7438. while (true) {
  7439. const scopeId = cur.vnode.scopeId
  7440. if (scopeId) {
  7441. if (!hasCloned) {
  7442. attrs = { ...attrs }
  7443. hasCloned = true
  7444. }
  7445. attrs[scopeId] = ''
  7446. }
  7447. const parent = cur.parent
  7448. if (parent && parent.subTree && parent.subTree === cur.vnode)
  7449. cur = parent
  7450. else
  7451. break
  7452. }
  7453. if (slotScopeId) {
  7454. if (!hasCloned)
  7455. attrs = { ...attrs }
  7456. attrs[slotScopeId.trim()] = ''
  7457. }
  7458. const prev = setCurrentRenderingInstance(instance)
  7459. try {
  7460. ssrRender(
  7461. instance.proxy,
  7462. push,
  7463. instance,
  7464. attrs,
  7465. // compiler-optimized bindings
  7466. instance.props,
  7467. instance.setupState,
  7468. instance.data,
  7469. instance.ctx,
  7470. )
  7471. }
  7472. finally {
  7473. setCurrentRenderingInstance(prev)
  7474. }
  7475. }
  7476. else if (instance.render && instance.render !== NOOP) {
  7477. renderVNode(
  7478. push,
  7479. instance.subTree = renderComponentRoot(instance),
  7480. instance,
  7481. slotScopeId,
  7482. )
  7483. }
  7484. else {
  7485. const componentName = comp.name || comp.__file || `<Anonymous>`
  7486. warn(`Component ${componentName} is missing template or render function.`)
  7487. push(`<!---->`)
  7488. }
  7489. }
  7490. return getBuffer()
  7491. }
  7492. function renderVNode(push, vnode, parentComponent, slotScopeId) {
  7493. const { type, shapeFlag, children } = vnode
  7494. switch (type) {
  7495. case Text:
  7496. push(escapeHtml(children))
  7497. break
  7498. case Comment:
  7499. push(
  7500. children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`,
  7501. )
  7502. break
  7503. case Static:
  7504. push(children)
  7505. break
  7506. case Fragment:
  7507. if (vnode.slotScopeIds)
  7508. slotScopeId = (slotScopeId ? `${slotScopeId} ` : '') + vnode.slotScopeIds.join(' ')
  7509. push(`<!--[-->`)
  7510. renderVNodeChildren(
  7511. push,
  7512. children,
  7513. parentComponent,
  7514. slotScopeId,
  7515. )
  7516. push(`<!--]-->`)
  7517. break
  7518. default:
  7519. if (shapeFlag & 1) {
  7520. renderElementVNode(push, vnode, parentComponent, slotScopeId)
  7521. }
  7522. else if (shapeFlag & 6) {
  7523. push(renderComponentVNode(vnode, parentComponent, slotScopeId))
  7524. }
  7525. else if (shapeFlag & 64) {
  7526. renderTeleportVNode(push, vnode, parentComponent, slotScopeId)
  7527. }
  7528. else if (shapeFlag & 128) {
  7529. renderVNode(push, vnode.ssContent, parentComponent, slotScopeId)
  7530. }
  7531. else {
  7532. warn(
  7533. '[@vue/server-renderer] Invalid VNode type:',
  7534. type,
  7535. `(${typeof type})`,
  7536. )
  7537. }
  7538. }
  7539. }
  7540. function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
  7541. for (let i = 0; i < children.length; i++)
  7542. renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId)
  7543. }
  7544. function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
  7545. const tag = vnode.type
  7546. let { props, children, shapeFlag, scopeId, dirs } = vnode
  7547. let openTag = `<${tag}`
  7548. if (dirs)
  7549. props = applySSRDirectives(vnode, props, dirs)
  7550. if (props)
  7551. openTag += ssrRenderAttrs(props, tag)
  7552. if (scopeId)
  7553. openTag += ` ${scopeId}`
  7554. let curParent = parentComponent
  7555. let curVnode = vnode
  7556. while (curParent && curVnode === curParent.subTree) {
  7557. curVnode = curParent.vnode
  7558. if (curVnode.scopeId)
  7559. openTag += ` ${curVnode.scopeId}`
  7560. curParent = curParent.parent
  7561. }
  7562. if (slotScopeId)
  7563. openTag += ` ${slotScopeId}`
  7564. push(`${openTag}>`)
  7565. if (!isVoidTag(tag)) {
  7566. let hasChildrenOverride = false
  7567. if (props) {
  7568. if (props.innerHTML) {
  7569. hasChildrenOverride = true
  7570. push(props.innerHTML)
  7571. }
  7572. else if (props.textContent) {
  7573. hasChildrenOverride = true
  7574. push(escapeHtml(props.textContent))
  7575. }
  7576. else if (tag === 'textarea' && props.value) {
  7577. hasChildrenOverride = true
  7578. push(escapeHtml(props.value))
  7579. }
  7580. }
  7581. if (!hasChildrenOverride) {
  7582. if (shapeFlag & 8) {
  7583. push(escapeHtml(children))
  7584. }
  7585. else if (shapeFlag & 16) {
  7586. renderVNodeChildren(
  7587. push,
  7588. children,
  7589. parentComponent,
  7590. slotScopeId,
  7591. )
  7592. }
  7593. }
  7594. push(`</${tag}>`)
  7595. }
  7596. }
  7597. function applySSRDirectives(vnode, rawProps, dirs) {
  7598. const toMerge = []
  7599. for (let i = 0; i < dirs.length; i++) {
  7600. const binding = dirs[i]
  7601. const {
  7602. dir: { getSSRProps },
  7603. } = binding
  7604. if (getSSRProps) {
  7605. const props = getSSRProps(binding, vnode)
  7606. if (props)
  7607. toMerge.push(props)
  7608. }
  7609. }
  7610. return mergeProps(rawProps || {}, ...toMerge)
  7611. }
  7612. function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
  7613. const target = vnode.props && vnode.props.to
  7614. const disabled = vnode.props && vnode.props.disabled
  7615. if (!target) {
  7616. if (!disabled)
  7617. warn(`[@vue/server-renderer] Teleport is missing target prop.`)
  7618. return []
  7619. }
  7620. if (!isString(target)) {
  7621. warn(
  7622. `[@vue/server-renderer] Teleport target must be a query selector string.`,
  7623. )
  7624. return []
  7625. }
  7626. ssrRenderTeleport(
  7627. push,
  7628. (push2) => {
  7629. renderVNodeChildren(
  7630. push2,
  7631. vnode.children,
  7632. parentComponent,
  7633. slotScopeId,
  7634. )
  7635. },
  7636. target,
  7637. disabled || disabled === '',
  7638. parentComponent,
  7639. )
  7640. }
  7641. const { isVNode: isVNode$1 } = ssrUtils
  7642. async function unrollBuffer$1(buffer) {
  7643. if (buffer.hasAsync) {
  7644. let ret = ''
  7645. for (let i = 0; i < buffer.length; i++) {
  7646. let item = buffer[i]
  7647. if (isPromise(item))
  7648. item = await item
  7649. if (isString(item))
  7650. ret += item
  7651. else
  7652. ret += await unrollBuffer$1(item)
  7653. }
  7654. return ret
  7655. }
  7656. else {
  7657. return unrollBufferSync$1(buffer)
  7658. }
  7659. }
  7660. function unrollBufferSync$1(buffer) {
  7661. let ret = ''
  7662. for (let i = 0; i < buffer.length; i++) {
  7663. const item = buffer[i]
  7664. if (isString(item))
  7665. ret += item
  7666. else
  7667. ret += unrollBufferSync$1(item)
  7668. }
  7669. return ret
  7670. }
  7671. async function renderToString(input, context = {}) {
  7672. if (isVNode$1(input))
  7673. return renderToString(createApp({ render: () => input }), context)
  7674. const vnode = createVNode(input._component, input._props)
  7675. vnode.appContext = input._context
  7676. input.provide(ssrContextKey, context)
  7677. const buffer = await renderComponentVNode(vnode)
  7678. const result = await unrollBuffer$1(buffer)
  7679. await resolveTeleports(context)
  7680. if (context.__watcherHandles) {
  7681. for (const unwatch of context.__watcherHandles)
  7682. unwatch()
  7683. }
  7684. return result
  7685. }
  7686. async function resolveTeleports(context) {
  7687. if (context.__teleportBuffers) {
  7688. context.teleports = context.teleports || {}
  7689. for (const key in context.__teleportBuffers) {
  7690. context.teleports[key] = await unrollBuffer$1(
  7691. await Promise.all([context.__teleportBuffers[key]]),
  7692. )
  7693. }
  7694. }
  7695. }
  7696. const { isVNode } = ssrUtils
  7697. async function unrollBuffer(buffer, stream) {
  7698. if (buffer.hasAsync) {
  7699. for (let i = 0; i < buffer.length; i++) {
  7700. let item = buffer[i]
  7701. if (isPromise(item))
  7702. item = await item
  7703. if (isString(item))
  7704. stream.push(item)
  7705. else
  7706. await unrollBuffer(item, stream)
  7707. }
  7708. }
  7709. else {
  7710. unrollBufferSync(buffer, stream)
  7711. }
  7712. }
  7713. function unrollBufferSync(buffer, stream) {
  7714. for (let i = 0; i < buffer.length; i++) {
  7715. const item = buffer[i]
  7716. if (isString(item))
  7717. stream.push(item)
  7718. else
  7719. unrollBufferSync(item, stream)
  7720. }
  7721. }
  7722. function renderToSimpleStream(input, context, stream) {
  7723. if (isVNode(input)) {
  7724. return renderToSimpleStream(
  7725. createApp({ render: () => input }),
  7726. context,
  7727. stream,
  7728. )
  7729. }
  7730. const vnode = createVNode(input._component, input._props)
  7731. vnode.appContext = input._context
  7732. input.provide(ssrContextKey, context)
  7733. Promise.resolve(renderComponentVNode(vnode)).then(buffer => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
  7734. if (context.__watcherHandles) {
  7735. for (const unwatch of context.__watcherHandles)
  7736. unwatch()
  7737. }
  7738. }).then(() => stream.push(null)).catch((error) => {
  7739. stream.destroy(error)
  7740. })
  7741. return stream
  7742. }
  7743. function renderToStream(input, context = {}) {
  7744. console.warn(
  7745. `[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`,
  7746. )
  7747. return renderToNodeStream(input, context)
  7748. }
  7749. function renderToNodeStream(input, context = {}) {
  7750. {
  7751. throw new Error(
  7752. `ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`,
  7753. )
  7754. }
  7755. }
  7756. function pipeToNodeWritable(input, context = {}, writable) {
  7757. renderToSimpleStream(input, context, {
  7758. push(content) {
  7759. if (content != null)
  7760. writable.write(content)
  7761. else
  7762. writable.end()
  7763. },
  7764. destroy(err) {
  7765. writable.destroy(err)
  7766. },
  7767. })
  7768. }
  7769. function renderToWebStream(input, context = {}) {
  7770. if (typeof ReadableStream !== 'function') {
  7771. throw new TypeError(
  7772. `ReadableStream constructor is not available in the global scope. If the target environment does support web streams, consider using pipeToWebWritable() with an existing WritableStream instance instead.`,
  7773. )
  7774. }
  7775. const encoder = new TextEncoder()
  7776. let cancelled = false
  7777. return new ReadableStream({
  7778. start(controller) {
  7779. renderToSimpleStream(input, context, {
  7780. push(content) {
  7781. if (cancelled)
  7782. return
  7783. if (content != null)
  7784. controller.enqueue(encoder.encode(content))
  7785. else
  7786. controller.close()
  7787. },
  7788. destroy(err) {
  7789. controller.error(err)
  7790. },
  7791. })
  7792. },
  7793. cancel() {
  7794. cancelled = true
  7795. },
  7796. })
  7797. }
  7798. function pipeToWebWritable(input, context = {}, writable) {
  7799. const writer = writable.getWriter()
  7800. const encoder = new TextEncoder()
  7801. let hasReady = false
  7802. try {
  7803. hasReady = isPromise(writer.ready)
  7804. }
  7805. catch (e) {
  7806. }
  7807. renderToSimpleStream(input, context, {
  7808. async push(content) {
  7809. if (hasReady)
  7810. await writer.ready
  7811. if (content != null)
  7812. return writer.write(encoder.encode(content))
  7813. else
  7814. return writer.close()
  7815. },
  7816. destroy(err) {
  7817. console.log(err)
  7818. writer.close()
  7819. },
  7820. })
  7821. }
  7822. initDirectivesForSSR()
  7823. export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, includeBooleanAttr as ssrIncludeBooleanAttr, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode }