/** * vue v3.6.0-rc.14 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let _vue_shared = require("@vue/shared"); let _dcloudio_uni_shared = require("@dcloudio/uni-shared"); //#region packages/reactivity/src/debug.ts const triggerEventInfos = []; function onTrack(sub, debugInfo) { if (sub.onTrack) sub.onTrack((0, _vue_shared.extend)({ effect: sub }, debugInfo)); } function onTrigger(sub) { if (sub.onTrigger) { const debugInfo = triggerEventInfos[triggerEventInfos.length - 1]; sub.onTrigger((0, _vue_shared.extend)({ effect: sub }, debugInfo)); } } function setupOnTrigger(target) { Object.defineProperty(target.prototype, "onTrigger", { get() { return this._onTrigger; }, set(val) { if (val && !this._onTrigger) setupFlagsHandler(this); this._onTrigger = val; } }); } function setupFlagsHandler(target) { target._flags = target.flags; Object.defineProperty(target, "flags", { get() { return target._flags; }, set(value) { if (!(target._flags & 48) && !!(value & 48)) onTrigger(this); target._flags = value; } }); } //#endregion //#region packages/reactivity/src/warning.ts function warn$2(msg, ...args) { console.warn(`[Vue warn] ${msg}`, ...args); } //#endregion //#region packages/reactivity/src/system.ts const notifyBuffer = []; let batchDepth = 0; let activeSub = void 0; let runDepth = 0; function incRunDepth() { ++runDepth; } function decRunDepth() { --runDepth; } let globalVersion = 0; let notifyIndex = 0; let notifyBufferLength = 0; function setActiveSub(sub) { try { return activeSub; } finally { activeSub = sub; } } function startBatch() { ++batchDepth; } function endBatch() { if (!--batchDepth && notifyBufferLength) flush(); } function link(dep, sub) { const prevDep = sub.depsTail; if (prevDep !== void 0 && prevDep.dep === dep) return; const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps; if (nextDep !== void 0 && nextDep.dep === dep) { nextDep.version = globalVersion; sub.depsTail = nextDep; return; } const prevSub = dep.subsTail; if (prevSub !== void 0 && prevSub.version === globalVersion && prevSub.sub === sub) return; const newLink = sub.depsTail = dep.subsTail = { version: globalVersion, dep, sub, prevDep, nextDep, prevSub, nextSub: void 0 }; if (nextDep !== void 0) nextDep.prevDep = newLink; if (prevDep !== void 0) prevDep.nextDep = newLink; else sub.deps = newLink; if (prevSub !== void 0) prevSub.nextSub = newLink; else dep.subs = newLink; } function unlink(link, sub = link.sub) { const dep = link.dep; const prevDep = link.prevDep; const nextDep = link.nextDep; const nextSub = link.nextSub; const prevSub = link.prevSub; if (nextDep !== void 0) nextDep.prevDep = prevDep; else sub.depsTail = prevDep; if (prevDep !== void 0) prevDep.nextDep = nextDep; else sub.deps = nextDep; if (nextSub !== void 0) nextSub.prevSub = prevSub; else dep.subsTail = prevSub; if (prevSub !== void 0) prevSub.nextSub = nextSub; else if ((dep.subs = nextSub) === void 0) { let toRemove = dep.deps; if (toRemove !== void 0) { do toRemove = unlink(toRemove, dep); while (toRemove !== void 0); dep.flags |= 16; } } return nextDep; } function propagate(link) { let next = link.nextSub; let stack; top: do { const sub = link.sub; let flags = sub.flags; if (flags & 3) { if (!(flags & 60)) { sub.flags = flags | 32; if (runDepth) sub.flags |= 8; } else if (!(flags & 12)) flags = 0; else if (!(flags & 4)) sub.flags = flags & -9 | 32; else if (!(flags & 48) && isValidLink(link, sub)) { sub.flags = flags | 40; flags &= 1; } else flags = 0; if (flags & 2) notifyBuffer[notifyBufferLength++] = sub; if (flags & 1) { const subSubs = sub.subs; if (subSubs !== void 0) { link = subSubs; if (subSubs.nextSub !== void 0) { stack = { value: next, prev: stack }; next = link.nextSub; } continue; } } } if ((link = next) !== void 0) { next = link.nextSub; continue; } while (stack !== void 0) { link = stack.value; stack = stack.prev; if (link !== void 0) { next = link.nextSub; continue top; } } break; } while (true); } function startTracking(sub) { ++globalVersion; sub.depsTail = void 0; sub.flags = sub.flags & -57 | 4; return setActiveSub(sub); } function endTracking(sub, prevSub) { if (activeSub !== sub) warn$2("Active effect was not restored correctly - this is likely a Vue internal bug."); activeSub = prevSub; const depsTail = sub.depsTail; let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps; while (toRemove !== void 0) toRemove = unlink(toRemove, sub); sub.flags &= -5; } function flush() { let hasError = false; let error; while (notifyIndex < notifyBufferLength) { const effect = notifyBuffer[notifyIndex]; notifyBuffer[notifyIndex++] = void 0; try { effect.notify(); } catch (err) { if (!hasError) { hasError = true; error = err; } } } notifyIndex = 0; notifyBufferLength = 0; if (hasError) throw error; } function checkDirty(link, sub) { let stack; let checkDepth = 0; top: do { const dep = link.dep; const depFlags = dep.flags; let dirty = false; if (sub.flags & 16) dirty = true; else if ((depFlags & 17) === 17) { const subs = dep.subs; if (dep.update()) { if (subs.nextSub !== void 0) shallowPropagate(subs); dirty = true; } } else if ((depFlags & 33) === 33) { stack = { value: link, prev: stack }; link = dep.deps; sub = dep; ++checkDepth; continue; } if (!dirty && link.nextDep !== void 0) { link = link.nextDep; continue; } while (checkDepth) { --checkDepth; link = stack.value; stack = stack.prev; if (dirty) { const subs = sub.subs; if (sub.update()) { if (subs.nextSub !== void 0) shallowPropagate(subs); sub = link.sub; continue; } } else sub.flags &= -33; sub = link.sub; if (link.nextDep !== void 0) { link = link.nextDep; continue top; } dirty = false; } return dirty && !!sub.flags; } while (true); } function shallowPropagate(link) { do { const sub = link.sub; const nextSub = link.nextSub; const subFlags = sub.flags; if ((subFlags & 48) === 32) sub.flags = subFlags | 16; link = nextSub; } while (link !== void 0); } function isValidLink(checkLink, sub) { let link = sub.depsTail; while (link !== void 0) { if (link === checkLink) return true; link = link.prevDep; } return false; } //#endregion //#region packages/reactivity/src/dep.ts var Dep = class { constructor(map, key) { this.map = map; this.key = key; this._subs = void 0; this.subsTail = void 0; this.flags = 0; } get subs() { return this._subs; } set subs(value) { this._subs = value; if (value === void 0 && this.map) this.map.delete(this.key); } }; /** * Tracks a dep its owner keys on its own, outside `targetMap`. * @internal */ function trackDep(dep, target = dep, key = "value") { if (activeSub !== void 0) { onTrack(activeSub, { target, type: "get", key }); link(dep, activeSub); } } /** * @internal */ function triggerDep(dep, target = dep, key = "value", newValue, oldValue) { const subs = dep.subs; if (subs !== void 0) { triggerEventInfos.push({ target, type: "set", key, newValue, oldValue }); propagate(subs); shallowPropagate(subs); if (!batchDepth) flush(); triggerEventInfos.pop(); } } const targetMap = /* @__PURE__ */ new WeakMap(); const ITERATE_KEY = Symbol("Object iterate"); const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate"); const ARRAY_ITERATE_KEY = Symbol("Array iterate"); /** * Tracks access to a reactive property. * * This will check which effect is running at the moment and record it as dep * which records all effects that depend on the reactive property. * * @param target - Object holding the reactive property. * @param type - Defines the type of access to the reactive property. * @param key - Identifier of the reactive property to track. */ function track(target, type, key) { if (activeSub !== void 0) { let depsMap = targetMap.get(target); if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map()); let dep = depsMap.get(key); if (!dep) depsMap.set(key, dep = new Dep(depsMap, key)); onTrack(activeSub, { target, type, key }); link(dep, activeSub); } } /** * Finds all deps associated with the target (or a specific property) and * triggers the effects stored within. * * @param target - The reactive object. * @param type - Defines the type of the operation that needs to trigger effects. * @param key - Can be used to target a specific reactive property in the target object. */ function trigger(target, type, key, newValue, oldValue, oldTarget) { const depsMap = targetMap.get(target); if (!depsMap) return; const run = (dep) => { if (dep !== void 0 && dep.subs !== void 0) { triggerEventInfos.push({ target, type, key, newValue, oldValue, oldTarget }); propagate(dep.subs); shallowPropagate(dep.subs); triggerEventInfos.pop(); } }; startBatch(); if (type === "clear") depsMap.forEach(run); else { const targetIsArray = (0, _vue_shared.isArray)(target); const isArrayIndex = targetIsArray && (0, _vue_shared.isIntegerKey)(key); if (targetIsArray && key === "length") { const newLength = Number(newValue); depsMap.forEach((dep, key) => { if (key === "length" || key === ARRAY_ITERATE_KEY || !(0, _vue_shared.isSymbol)(key) && key >= newLength) run(dep); }); } else { if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key)); if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY)); switch (type) { case "add": if (!targetIsArray) { run(depsMap.get(ITERATE_KEY)); if ((0, _vue_shared.isMap)(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY)); } else if (isArrayIndex) run(depsMap.get("length")); break; case "delete": if (!targetIsArray) { run(depsMap.get(ITERATE_KEY)); if ((0, _vue_shared.isMap)(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY)); } break; case "set": if ((0, _vue_shared.isMap)(target)) run(depsMap.get(ITERATE_KEY)); } } } endBatch(); } function getDepFromReactive(object, key) { const depMap = targetMap.get(object); return depMap && depMap.get(key); } //#endregion //#region packages/reactivity/src/arrayInstrumentations.ts /** * Track array iteration and return: * - if input is reactive: a cloned raw array with reactive values * - if input is readonly: a cloned raw array with readonly values, preserving * reactivity * - if input is raw or shallow: the original raw array */ function reactiveReadArray(array) { const raw = /* @__PURE__ */ toRaw(array); if (raw === array) return raw; track(raw, "iterate", ARRAY_ITERATE_KEY); if (/* @__PURE__ */ isShallow(array)) return raw; if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive); return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly); } /** * Track array iteration and return raw array */ function shallowReadArray(arr) { track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY); return arr; } function toWrapped(target, item) { if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item); return toReactive(item); } const arrayInstrumentations = { __proto__: null, [Symbol.iterator]() { return iterator(this, Symbol.iterator, (item) => toWrapped(this, item)); }, concat(...args) { return reactiveReadArray(this).concat(...args.map((x) => (0, _vue_shared.isArray)(x) ? reactiveReadArray(x) : x)); }, entries() { return iterator(this, "entries", (value) => { value[1] = toWrapped(this, value[1]); return value; }); }, every(fn, thisArg) { return apply(this, "every", fn, thisArg, void 0, arguments); }, filter(fn, thisArg) { return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments); }, find(fn, thisArg) { return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments); }, findIndex(fn, thisArg) { return apply(this, "findIndex", fn, thisArg, void 0, arguments); }, findLast(fn, thisArg) { return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments); }, findLastIndex(fn, thisArg) { return apply(this, "findLastIndex", fn, thisArg, void 0, arguments); }, forEach(fn, thisArg) { return apply(this, "forEach", fn, thisArg, void 0, arguments); }, includes(...args) { return searchProxy(this, "includes", args); }, indexOf(...args) { return searchProxy(this, "indexOf", args); }, join(separator) { return reactiveReadArray(this).join(separator); }, lastIndexOf(...args) { return searchProxy(this, "lastIndexOf", args); }, map(fn, thisArg) { return apply(this, "map", fn, thisArg, void 0, arguments); }, pop() { return noTracking(this, "pop"); }, push(...args) { return noTracking(this, "push", args); }, reduce(fn, ...args) { return reduce(this, "reduce", fn, args); }, reduceRight(fn, ...args) { return reduce(this, "reduceRight", fn, args); }, shift() { return noTracking(this, "shift"); }, some(fn, thisArg) { return apply(this, "some", fn, thisArg, void 0, arguments); }, splice(...args) { return noTracking(this, "splice", args); }, toReversed() { return reactiveReadArray(this).toReversed(); }, toSorted(comparer) { return reactiveReadArray(this).toSorted(comparer); }, toSpliced(...args) { return reactiveReadArray(this).toSpliced(...args); }, unshift(...args) { return noTracking(this, "unshift", args); }, values() { return iterator(this, "values", (item) => toWrapped(this, item)); } }; function iterator(self, method, wrapValue) { const arr = shallowReadArray(self); const methodFn = arr[method]; const iter = methodFn.call(arr); if (arr !== self && !/* @__PURE__ */ isShallow(self)) { if (iter[Symbol.toStringTag] === "Array Iterator") { const wrapped = Object.create(Object.getPrototypeOf(iter)); wrapped.next = () => wrapResult(iter.next(), wrapValue); if (methodFn !== arrayProto[method]) Object.defineProperties(wrapped, { return: { get() { const fn = iter.return; return typeof fn === "function" ? fn.bind(iter) : fn; } }, throw: { get() { const fn = iter.throw; return typeof fn === "function" ? fn.bind(iter) : fn; } } }); return wrapped; } iter._next = iter.next; iter.next = () => wrapResult(iter._next(), wrapValue); } return iter; } function wrapResult(result, wrapValue) { if (!result.done) result.value = wrapValue(result.value); return result; } const arrayProto = Array.prototype; function apply(self, method, fn, thisArg, wrappedRetFn, args) { const arr = shallowReadArray(self); const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self); const methodFn = arr[method]; if (methodFn !== arrayProto[method]) { const result = methodFn.apply(self, args); return needsWrap ? toReactive(result) : result; } let wrappedFn = fn; if (arr !== self) { if (needsWrap) wrappedFn = function(item, index) { return fn.call(this, toWrapped(self, item), index, self); }; else if (fn.length > 2) wrappedFn = function(item, index) { return fn.call(this, item, index, self); }; } const result = methodFn.call(arr, wrappedFn, thisArg); return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result; } function reduce(self, method, fn, args) { const arr = shallowReadArray(self); const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self); let wrappedFn = fn; let wrapInitialAccumulator = false; if (arr !== self) { if (needsWrap) { wrapInitialAccumulator = args.length === 0; wrappedFn = function(acc, item, index) { if (wrapInitialAccumulator) { wrapInitialAccumulator = false; acc = toWrapped(self, acc); } return fn.call(this, acc, toWrapped(self, item), index, self); }; } else if (fn.length > 3) wrappedFn = function(acc, item, index) { return fn.call(this, acc, item, index, self); }; } const result = arr[method](wrappedFn, ...args); return wrapInitialAccumulator ? toWrapped(self, result) : result; } function searchProxy(self, method, args) { const arr = /* @__PURE__ */ toRaw(self); track(arr, "iterate", ARRAY_ITERATE_KEY); const res = arr[method](...args); if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) { args[0] = /* @__PURE__ */ toRaw(args[0]); return arr[method](...args); } return res; } function noTracking(self, method, args = []) { startBatch(); const prevSub = setActiveSub(); const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args); setActiveSub(prevSub); endBatch(); return res; } //#endregion //#region packages/reactivity/src/baseHandlers.ts const isNonTrackableKeys = /*@__PURE__*/ (0, _vue_shared.makeMap)(`__proto__,__v_isRef,__isVue`); const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(_vue_shared.isSymbol)); function hasOwnProperty(key) { if (!(0, _vue_shared.isSymbol)(key)) key = String(key); const obj = /* @__PURE__ */ toRaw(this); track(obj, "has", key); return obj.hasOwnProperty(key); } var BaseReactiveHandler = class { constructor(_isReadonly = false, _isShallow = false) { this._isReadonly = _isReadonly; this._isShallow = _isShallow; } get(target, key, receiver) { if (key === "__v_skip") return target["__v_skip"]; const isReadonly = this._isReadonly, isShallow = this._isShallow; if (key === "__v_isReactive") return !isReadonly; else if (key === "__v_isReadonly") return isReadonly; else if (key === "__v_isShallow") return isShallow; else if (key === "__v_raw") { if (receiver === (isReadonly ? isShallow ? shallowReadonlyMap : readonlyMap : isShallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target; return; } const targetIsArray = (0, _vue_shared.isArray)(target); if (!isReadonly) { let fn; if (targetIsArray && (fn = arrayInstrumentations[key])) return fn; if (key === "hasOwnProperty") return hasOwnProperty; } const wasRef = /* @__PURE__ */ isRef(target); const res = Reflect.get(target, key, wasRef ? target : receiver); if (wasRef && key !== "value") return res; if ((0, _vue_shared.isSymbol)(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res; if (!isReadonly) track(target, "get", key); if (isShallow) return res; if (/* @__PURE__ */ isRef(res)) { const value = targetIsArray && (0, _vue_shared.isIntegerKey)(key) ? res : res.value; return isReadonly && (0, _vue_shared.isObject)(value) ? /* @__PURE__ */ readonly(value) : value; } if ((0, _vue_shared.isObject)(res)) return isReadonly ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res); return res; } }; var MutableReactiveHandler = class extends BaseReactiveHandler { constructor(isShallow = false) { super(false, isShallow); } set(target, key, value, receiver) { let oldValue = target[key]; const isArrayWithIntegerKey = (0, _vue_shared.isArray)(target) && (0, _vue_shared.isIntegerKey)(key); if (!this._isShallow) { const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue); if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) { oldValue = /* @__PURE__ */ toRaw(oldValue); value = /* @__PURE__ */ toRaw(value); } if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) { if (isOldValueReadonly) { warn$2(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]); return true; } else { oldValue.value = value; return true; } } } const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : (0, _vue_shared.hasOwn)(target, key); const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver); if (target === /* @__PURE__ */ toRaw(receiver) && result) { if (!hadKey) trigger(target, "add", key, value); else if ((0, _vue_shared.hasChanged)(value, oldValue)) trigger(target, "set", key, value, oldValue); } return result; } deleteProperty(target, key) { const hadKey = (0, _vue_shared.hasOwn)(target, key); const oldValue = target[key]; const result = Reflect.deleteProperty(target, key); if (result && hadKey) trigger(target, "delete", key, void 0, oldValue); return result; } has(target, key) { const result = Reflect.has(target, key); if (!(0, _vue_shared.isSymbol)(key) || !builtInSymbols.has(key)) track(target, "has", key); return result; } ownKeys(target) { track(target, "iterate", (0, _vue_shared.isArray)(target) ? "length" : ITERATE_KEY); return Reflect.ownKeys(target); } }; var ReadonlyReactiveHandler = class extends BaseReactiveHandler { constructor(isShallow = false) { super(true, isShallow); } set(target, key) { warn$2(`Set operation on key "${String(key)}" failed: target is readonly.`, target); return true; } deleteProperty(target, key) { warn$2(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); return true; } }; const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler(); const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler(); const shallowReactiveHandlers = /*@__PURE__*/ new MutableReactiveHandler(true); const shallowReadonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler(true); //#endregion //#region packages/reactivity/src/collectionHandlers.ts const toShallow = (value) => value; const getProto = (v) => Reflect.getPrototypeOf(v); function createIterableMethod(method, isReadonly, isShallow) { return function(...args) { const target = this["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const targetIsMap = (0, _vue_shared.isMap)(rawTarget); const isPair = method === "entries" || method === Symbol.iterator && targetIsMap; const isKeyOnly = method === "keys" && targetIsMap; const innerIterator = target[method](...args); const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); return (0, _vue_shared.extend)(Object.create(innerIterator), { next() { const { value, done } = innerIterator.next(); return done ? { value, done } : { value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), done }; } }); }; } function createReadonlyMethod(type) { return function(...args) { { const key = args[0] ? `on key "${args[0]}" ` : ``; warn$2(`${(0, _vue_shared.capitalize)(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this)); } return type === "delete" ? false : type === "clear" ? void 0 : this; }; } function createInstrumentations(readonly, shallow) { const instrumentations = { get(key) { const target = this["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const rawKey = /* @__PURE__ */ toRaw(key); if (!readonly) { if ((0, _vue_shared.hasChanged)(key, rawKey)) track(rawTarget, "get", key); track(rawTarget, "get", rawKey); } const { has } = getProto(rawTarget); const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive; if (has.call(rawTarget, key)) return wrap(target.get(key)); else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey)); else if (target !== rawTarget) target.get(key); }, get size() { const target = this["__v_raw"]; !readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY); return target.size; }, has(key) { const target = this["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const rawKey = /* @__PURE__ */ toRaw(key); if (!readonly) { if ((0, _vue_shared.hasChanged)(key, rawKey)) track(rawTarget, "has", key); track(rawTarget, "has", rawKey); } return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); }, forEach(callback, thisArg) { const observed = this; const target = observed["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive; !readonly && track(rawTarget, "iterate", ITERATE_KEY); return target.forEach((value, key) => { return callback.call(thisArg, wrap(value), wrap(key), observed); }); } }; (0, _vue_shared.extend)(instrumentations, readonly ? { add: createReadonlyMethod("add"), set: createReadonlyMethod("set"), delete: createReadonlyMethod("delete"), clear: createReadonlyMethod("clear") } : { add(value) { const target = /* @__PURE__ */ toRaw(this); const proto = getProto(target); const rawValue = /* @__PURE__ */ toRaw(value); const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value; if (!(proto.has.call(target, valueToAdd) || (0, _vue_shared.hasChanged)(value, valueToAdd) && proto.has.call(target, value) || (0, _vue_shared.hasChanged)(rawValue, valueToAdd) && proto.has.call(target, rawValue))) { target.add(valueToAdd); trigger(target, "add", valueToAdd, valueToAdd); } return this; }, set(key, value) { if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value); const target = /* @__PURE__ */ toRaw(this); const { has, get } = getProto(target); let hadKey = has.call(target, key); if (!hadKey) { key = /* @__PURE__ */ toRaw(key); hadKey = has.call(target, key); } else checkIdentityKeys(target, has, key); const oldValue = get.call(target, key); target.set(key, value); if (!hadKey) trigger(target, "add", key, value); else if ((0, _vue_shared.hasChanged)(value, oldValue)) trigger(target, "set", key, value, oldValue); return this; }, delete(key) { const target = /* @__PURE__ */ toRaw(this); const { has, get } = getProto(target); let hadKey = has.call(target, key); if (!hadKey) { key = /* @__PURE__ */ toRaw(key); hadKey = has.call(target, key); } else checkIdentityKeys(target, has, key); const oldValue = get ? get.call(target, key) : void 0; const result = target.delete(key); if (hadKey) trigger(target, "delete", key, void 0, oldValue); return result; }, clear() { const target = /* @__PURE__ */ toRaw(this); const hadItems = target.size !== 0; const oldTarget = (0, _vue_shared.isMap)(target) ? new Map(target) : new Set(target); const result = target.clear(); if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget); return result; } }); [ "keys", "values", "entries", Symbol.iterator ].forEach((method) => { instrumentations[method] = createIterableMethod(method, readonly, shallow); }); return instrumentations; } function createInstrumentationGetter(isReadonly, shallow) { const instrumentations = createInstrumentations(isReadonly, shallow); return (target, key, receiver) => { if (key === "__v_isReactive") return !isReadonly; else if (key === "__v_isReadonly") return isReadonly; else if (key === "__v_isShallow") return shallow; else if (key === "__v_raw") return target; return Reflect.get((0, _vue_shared.hasOwn)(instrumentations, key) && key in target ? instrumentations : target, key, receiver); }; } const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) }; const shallowCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, true) }; const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) }; const shallowReadonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, true) }; function checkIdentityKeys(target, has, key) { const rawKey = /* @__PURE__ */ toRaw(key); if (rawKey !== key && has.call(target, rawKey)) { const type = (0, _vue_shared.toRawType)(target); warn$2(`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.`); } } //#endregion //#region packages/reactivity/src/reactive.ts const reactiveMap = /* @__PURE__ */ new WeakMap(); const shallowReactiveMap = /* @__PURE__ */ new WeakMap(); const readonlyMap = /* @__PURE__ */ new WeakMap(); const shallowReadonlyMap = /* @__PURE__ */ new WeakMap(); function targetTypeMap(rawType) { switch (rawType) { case "Object": case "Array": return 1; case "Map": case "Set": case "WeakMap": case "WeakSet": return 2; default: return 0; } } /*@__NO_SIDE_EFFECTS__*/ function reactive(target) { if (/* @__PURE__ */ isReadonly(target)) return target; return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); } /** * Shallow version of {@link reactive}. * * Unlike {@link reactive}, there is no deep conversion: only root-level * properties are reactive for a shallow reactive object. Property values are * stored and exposed as-is - this also means properties with ref values will * not be automatically unwrapped. * * @example * ```js * const state = shallowReactive({ * foo: 1, * nested: { * bar: 2 * } * }) * * // mutating state's own properties is reactive * state.foo++ * * // ...but does not convert nested objects * isReactive(state.nested) // false * * // NOT reactive * state.nested.bar++ * ``` * * @param target - The source object. * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive} */ /*@__NO_SIDE_EFFECTS__*/ function shallowReactive(target) { return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); } /** * Takes an object (reactive or plain) or a ref and returns a readonly proxy to * the original. * * A readonly proxy is deep: any nested property accessed will be readonly as * well. It also has the same ref-unwrapping behavior as {@link reactive}, * except the unwrapped values will also be made readonly. * * @example * ```js * const original = reactive({ count: 0 }) * * const copy = readonly(original) * * watchEffect(() => { * // works for reactivity tracking * console.log(copy.count) * }) * * // mutating original will trigger watchers relying on the copy * original.count++ * * // mutating the copy will fail and result in a warning * copy.count++ // warning! * ``` * * @param target - The source object. * @see {@link https://vuejs.org/api/reactivity-core.html#readonly} */ /*@__NO_SIDE_EFFECTS__*/ function readonly(target) { return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); } /** * Shallow version of {@link readonly}. * * Unlike {@link readonly}, there is no deep conversion: only root-level * properties are made readonly. Property values are stored and exposed as-is - * this also means properties with ref values will not be automatically * unwrapped. * * @example * ```js * const state = shallowReadonly({ * foo: 1, * nested: { * bar: 2 * } * }) * * // mutating state's own properties will fail * state.foo++ * * // ...but works on nested objects * isReadonly(state.nested) // false * * // works * state.nested.bar++ * ``` * * @param target - The source object. * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly} */ /*@__NO_SIDE_EFFECTS__*/ function shallowReadonly(target) { return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); } function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { if (!(0, _vue_shared.isObject)(target)) { warn$2(`value cannot be made ${isReadonly ? "readonly" : "reactive"}: ${String(target)}`); return target; } if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target; if (target["__v_skip"] || !Object.isExtensible(target)) return target; const existingProxy = proxyMap.get(target); if (existingProxy) return existingProxy; const targetType = targetTypeMap((0, _vue_shared.toRawType)(target)); if (targetType === 0) return target; const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); proxyMap.set(target, proxy); return proxy; } /** * Checks if an object is a proxy created by {@link reactive} or * {@link shallowReactive} (or {@link ref} in some cases). * * @example * ```js * isReactive(reactive({})) // => true * isReactive(readonly(reactive({}))) // => true * isReactive(ref({}).value) // => true * isReactive(readonly(ref({})).value) // => true * isReactive(ref(true)) // => false * isReactive(shallowRef({}).value) // => false * isReactive(shallowReactive({})) // => true * ``` * * @param value - The value to check. * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive} */ /*@__NO_SIDE_EFFECTS__*/ function isReactive(value) { if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]); return !!(value && value["__v_isReactive"]); } /** * Checks whether the passed value is a readonly object. The properties of a * readonly object can change, but they can't be assigned directly via the * passed object. * * The proxies created by {@link readonly} and {@link shallowReadonly} are * both considered readonly, as is a computed ref without a set function. * * @param value - The value to check. * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly} */ /*@__NO_SIDE_EFFECTS__*/ function isReadonly(value) { return !!(value && value["__v_isReadonly"]); } /*@__NO_SIDE_EFFECTS__*/ function isShallow(value) { return !!(value && value["__v_isShallow"]); } /** * Checks if an object is a proxy created by {@link reactive}, * {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}. * * @param value - The value to check. * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy} */ /*@__NO_SIDE_EFFECTS__*/ function isProxy(value) { return value ? !!value["__v_raw"] : false; } /** * Returns the raw, original object of a Vue-created proxy. * * `toRaw()` can return the original object from proxies created by * {@link reactive}, {@link readonly}, {@link shallowReactive} or * {@link shallowReadonly}. * * This is an escape hatch that can be used to temporarily read without * incurring proxy access / tracking overhead or write without triggering * changes. It is **not** recommended to hold a persistent reference to the * original object. Use with caution. * * @example * ```js * const foo = {} * const reactiveFoo = reactive(foo) * * console.log(toRaw(reactiveFoo) === foo) // true * ``` * * @param observed - The object for which the "raw" value is requested. * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw} */ /*@__NO_SIDE_EFFECTS__*/ function toRaw(observed) { const raw = observed && observed["__v_raw"]; return raw ? /* @__PURE__ */ toRaw(raw) : observed; } /** * Marks an object so that it will never be converted to a proxy. Returns the * object itself. * * @example * ```js * const foo = markRaw({}) * console.log(isReactive(reactive(foo))) // false * * // also works when nested inside other reactive objects * const bar = reactive({ foo }) * console.log(isReactive(bar.foo)) // false * ``` * * **Warning:** `markRaw()` together with the shallow APIs such as * {@link shallowReactive} allow you to selectively opt-out of the default * deep reactive/readonly conversion and embed raw, non-proxied objects in your * state graph. * * @param value - The object to be marked as "raw". * @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw} */ function markRaw(value) { if (!(0, _vue_shared.hasOwn)(value, "__v_skip") && Object.isExtensible(value)) (0, _vue_shared.def)(value, "__v_skip", true); return value; } /** * Returns a reactive proxy of the given value (if possible). * * If the given value is not an object, the original value itself is returned. * * @param value - The value for which a reactive proxy shall be created. */ const toReactive = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */ reactive(value) : value; /** * Returns a readonly proxy of the given value (if possible). * * If the given value is not an object, the original value itself is returned. * * @param value - The value for which a readonly proxy shall be created. */ const toReadonly = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */ readonly(value) : value; //#endregion //#region packages/reactivity/src/ref.ts /*@__NO_SIDE_EFFECTS__*/ function isRef(r) { return r ? r["__v_isRef"] === true : false; } /*@__NO_SIDE_EFFECTS__*/ function ref(value) { return createRef(value, toReactive); } /*@__NO_SIDE_EFFECTS__*/ function shallowRef(value) { return createRef(value); } function createRef(rawValue, wrap) { if (/* @__PURE__ */ isRef(rawValue)) return rawValue; return new RefImpl(rawValue, wrap); } /** * @internal */ var RefImpl = class { constructor(value, wrap) { this.subs = void 0; this.subsTail = void 0; this.flags = 1; this.__v_isRef = true; this.__v_isShallow = false; this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value; this._value = wrap ? wrap(value) : value; this._wrap = wrap; this["__v_isShallow"] = !wrap; } get dep() { return this; } get value() { trackRef(this); if (this.flags & 16 && this.update()) { const subs = this.subs; if (subs !== void 0) shallowPropagate(subs); } return this._value; } set value(newValue) { const oldValue = this._rawValue; const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue); newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue); if ((0, _vue_shared.hasChanged)(newValue, oldValue)) { this.flags |= 16; this._rawValue = newValue; this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue; const subs = this.subs; if (subs !== void 0) { triggerEventInfos.push({ target: this, type: "set", key: "value", newValue, oldValue }); propagate(subs); if (!batchDepth) flush(); triggerEventInfos.pop(); } } } update() { this.flags &= -17; return (0, _vue_shared.hasChanged)(this._oldValue, this._oldValue = this._rawValue); } }; /** * Force trigger effects that depends on a shallow ref. This is typically used * after making deep mutations to the inner value of a shallow ref. * * @example * ```js * const shallow = shallowRef({ * greet: 'Hello, world' * }) * * // Logs "Hello, world" once for the first run-through * watchEffect(() => { * console.log(shallow.value.greet) * }) * * // This won't trigger the effect because the ref is shallow * shallow.value.greet = 'Hello, universe' * * // Logs "Hello, universe" * triggerRef(shallow) * ``` * * @param ref - The ref whose tied effects shall be executed. * @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref} */ function triggerRef(ref) { const dep = ref.dep; if (dep !== void 0 && dep.subs !== void 0) { propagate(dep.subs); shallowPropagate(dep.subs); if (!batchDepth) flush(); } } function trackRef(dep) { if (activeSub !== void 0) { onTrack(activeSub, { target: dep, type: "get", key: "value" }); link(dep, activeSub); } } /** * Returns the inner value if the argument is a ref, otherwise return the * argument itself. This is a sugar function for * `val = isRef(val) ? val.value : val`. * * @example * ```js * function useFoo(x: number | Ref) { * const unwrapped = unref(x) * // unwrapped is guaranteed to be number now * } * ``` * * @param ref - Ref or plain value to be converted into the plain value. * @see {@link https://vuejs.org/api/reactivity-utilities.html#unref} */ function unref(ref) { return /* @__PURE__ */ isRef(ref) ? ref.value : ref; } /** * Normalizes values / refs / getters to values. * This is similar to {@link unref}, except that it also normalizes getters. * If the argument is a getter, it will be invoked and its return value will * be returned. * * @example * ```js * toValue(1) // 1 * toValue(ref(1)) // 1 * toValue(() => 1) // 1 * ``` * * @param source - A getter, an existing ref, or a non-function value. * @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue} */ function toValue(source) { return (0, _vue_shared.isFunction)(source) ? source() : unref(source); } const shallowUnwrapHandlers = { get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)), set: (target, key, value, receiver) => { const oldValue = target[key]; if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) { oldValue.value = value; return true; } else return Reflect.set(target, key, value, receiver); } }; /** * Returns a proxy for the given object that shallowly unwraps properties that * are refs. If the object already is reactive, it's returned as-is. If not, a * new reactive proxy is created. * * @param objectWithRefs - Either an already-reactive object or a simple object * that contains refs. */ function proxyRefs(objectWithRefs) { return /* @__PURE__ */ isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers); } var CustomRefImpl = class { constructor(factory) { this.subs = void 0; this.subsTail = void 0; this.flags = 0; this["__v_isRef"] = true; this._value = void 0; const { get, set } = factory(() => trackRef(this), () => triggerRef(this)); this._get = get; this._set = set; } get dep() { return this; } get value() { return this._value = this._get(); } set value(newVal) { this._set(newVal); } }; /** * Creates a customized ref with explicit control over its dependency tracking * and updates triggering. * * @param factory - The function that receives the `track` and `trigger` callbacks. * @see {@link https://vuejs.org/api/reactivity-advanced.html#customref} */ function customRef(factory) { return new CustomRefImpl(factory); } /** * Converts a reactive object to a plain object where each property of the * resulting object is a ref pointing to the corresponding property of the * original object. Each individual ref is created using {@link toRef}. * * @param object - Reactive object to be made into an object of linked refs. * @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs} */ /*@__NO_SIDE_EFFECTS__*/ function toRefs(object) { const ret = (0, _vue_shared.isArray)(object) ? new Array(object.length) : {}; for (const key in object) ret[key] = propertyToRef(object, key); return ret; } var ObjectRefImpl = class { constructor(_object, key, _defaultValue) { this._object = _object; this._defaultValue = _defaultValue; this["__v_isRef"] = true; this._value = void 0; this._key = (0, _vue_shared.isSymbol)(key) ? key : String(key); this._raw = /* @__PURE__ */ toRaw(_object); let shallow = true; let obj = _object; if (!(0, _vue_shared.isArray)(_object) || (0, _vue_shared.isSymbol)(this._key) || !(0, _vue_shared.isIntegerKey)(this._key)) do shallow = !/* @__PURE__ */ isProxy(obj) || /* @__PURE__ */ isShallow(obj); while (shallow && (obj = obj["__v_raw"])); this._shallow = shallow; } get value() { let val = this._object[this._key]; if (this._shallow) val = unref(val); return this._value = val === void 0 ? this._defaultValue : val; } set value(newVal) { if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) { const nestedRef = this._object[this._key]; if (/* @__PURE__ */ isRef(nestedRef)) { nestedRef.value = newVal; return; } } this._object[this._key] = newVal; } get dep() { return getDepFromReactive(this._raw, this._key); } }; var GetterRefImpl = class { constructor(_getter) { this._getter = _getter; this["__v_isRef"] = true; this["__v_isReadonly"] = true; this._value = void 0; } get value() { return this._value = this._getter(); } }; /*@__NO_SIDE_EFFECTS__*/ function toRef(source, key, defaultValue) { if (/* @__PURE__ */ isRef(source)) return source; else if ((0, _vue_shared.isFunction)(source)) return new GetterRefImpl(source); else if ((0, _vue_shared.isObject)(source) && arguments.length > 1) return propertyToRef(source, key, defaultValue); else return /* @__PURE__ */ ref(source); } function propertyToRef(source, key, defaultValue) { return new ObjectRefImpl(source, key, defaultValue); } //#endregion //#region packages/reactivity/src/effect.ts var ReactiveEffect = class { fn() {} constructor(fn) { this.deps = void 0; this.depsTail = void 0; this.subs = void 0; this.subsTail = void 0; this.flags = 18; this.cleanups = []; this.cleanupsLength = 0; if (fn !== void 0) this.fn = fn; if (activeEffectScope) link(this, activeEffectScope); } get active() { return !(this.flags & 1024); } pause() { this.flags |= 256; } resume() { if ((this.flags &= -257) & 48) this.notify(); } notify() { if (!(this.flags & 256) && this.dirty) this.run(); } run() { if (!this.active) return this.fn(); cleanup(this); const prevSub = startTracking(this); incRunDepth(); try { return this.fn(); } finally { decRunDepth(); endTracking(this, prevSub); const flags = this.flags; if ((flags & 136) === 136) { this.flags = flags & -9; this.notify(); } } } stop() { if (!this.active) return; this.flags = 1024; let dep = this.deps; while (dep !== void 0) dep = unlink(dep, this); const sub = this.subs; if (sub !== void 0) unlink(sub); cleanup(this); } get dirty() { const flags = this.flags; if (flags & 16) return true; if (flags & 32) { if (checkDirty(this.deps, this)) { this.flags = flags | 16; return true; } else this.flags = flags & -33; } return false; } }; setupOnTrigger(ReactiveEffect); function effect(fn, options) { if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn; const e = new ReactiveEffect(fn); if (options) { const { onStop, scheduler } = options; if (onStop) { options.onStop = void 0; const stop = e.stop.bind(e); e.stop = () => { stop(); onStop(); }; } if (scheduler) { options.scheduler = void 0; e.notify = () => { if (!(e.flags & 256)) scheduler(); }; } (0, _vue_shared.extend)(e, options); } try { e.run(); } catch (err) { e.stop(); throw err; } const runner = e.run.bind(e); runner.effect = e; return runner; } /** * Stops the effect associated with the given runner. * * @param runner - Association with the effect to stop tracking. */ function stop(runner) { runner.effect.stop(); } const resetTrackingStack = []; /** * Temporarily pauses tracking. */ function pauseTracking() { resetTrackingStack.push(activeSub); setActiveSub(); } /** * Resets the previous global effect tracking state. */ function resetTracking() { if (resetTrackingStack.length === 0) warn$2("resetTracking() was called when there was no active tracking to reset."); if (resetTrackingStack.length) setActiveSub(resetTrackingStack.pop()); else setActiveSub(); } function cleanup(sub) { const l = sub.cleanupsLength; if (l) { for (let i = 0; i < l; i++) sub.cleanups[i](); sub.cleanupsLength = 0; } } /** * Registers a cleanup function for the current active effect. * The cleanup function is called right before the next effect run, or when the * effect is stopped. * * Throws a warning if there is no current active effect. The warning can be * suppressed by passing `true` to the second argument. * * @param fn - the cleanup function to be registered * @param failSilently - if `true`, will not throw warning when called without * an active effect. */ function onEffectCleanup(fn, failSilently = false) { if (activeSub instanceof ReactiveEffect) activeSub.cleanups[activeSub.cleanupsLength++] = () => cleanupEffect(fn); else if (!failSilently) warn$2("onEffectCleanup() was called when there was no active effect to associate with."); } function cleanupEffect(fn) { const prevSub = setActiveSub(); try { fn(); } finally { setActiveSub(prevSub); } } //#endregion //#region packages/reactivity/src/effectScope.ts let activeEffectScope; var EffectScope = class { constructor(detached = false) { this.deps = void 0; this.depsTail = void 0; this.subs = void 0; this.subsTail = void 0; this.flags = 0; this.cleanups = []; this.cleanupsLength = 0; if (!detached && activeEffectScope) link(this, activeEffectScope); } get active() { return !(this.flags & 1024); } pause() { if (!(this.flags & 256)) { this.flags |= 256; for (let link = this.deps; link !== void 0; link = link.nextDep) { const dep = link.dep; if ("pause" in dep) dep.pause(); } } } /** * Resumes the effect scope, including all child scopes and effects. */ resume() { const flags = this.flags; if (flags & 256) { this.flags = flags & -257; for (let link = this.deps; link !== void 0; link = link.nextDep) { const dep = link.dep; if ("resume" in dep) dep.resume(); } } } run(fn) { const prevScope = activeEffectScope; try { activeEffectScope = this; return fn(); } finally { activeEffectScope = prevScope; } } stop() { if (!this.active) return; this.flags = 1024; this.reset(); const sub = this.subs; if (sub !== void 0) unlink(sub); } /** * @internal */ reset() { let dep = this.deps; while (dep !== void 0) { const node = dep.dep; if ("stop" in node) { dep = dep.nextDep; node.stop(); } else dep = unlink(dep, this); } cleanup(this); } }; /** * Creates an effect scope object which can capture the reactive effects (i.e. * computed and watchers) created within it so that these effects can be * disposed together. For detailed use cases of this API, please consult its * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}. * * @param detached - Can be used to create a "detached" effect scope. * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope} */ function effectScope(detached) { return new EffectScope(detached); } /** * Returns the current active effect scope if there is one. * * @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope} */ function getCurrentScope() { return activeEffectScope; } function setCurrentScope(scope) { try { return activeEffectScope; } finally { activeEffectScope = scope; } } /** * Registers a dispose callback on the current active effect scope. The * callback will be invoked when the associated effect scope is stopped. * * @param fn - The callback function to attach to the scope's cleanup. * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose} */ function onScopeDispose(fn, failSilently = false) { if (activeEffectScope !== void 0) activeEffectScope.cleanups[activeEffectScope.cleanupsLength++] = fn; else if (!failSilently) warn$2("onScopeDispose() is called when there is no active effect scope to be associated with."); } //#endregion //#region packages/reactivity/src/computed.ts /** * @private exported by @vue/reactivity for Vue core use, but not exported from * the main vue package */ var ComputedRefImpl = class { get effect() { return this; } get dep() { return this; } /** * @internal * for backwards compat */ get _dirty() { const flags = this.flags; if (flags & 16) return true; if (flags & 32) { if (checkDirty(this.deps, this)) { this.flags = flags | 16; return true; } else this.flags = flags & -33; } return false; } /** * @internal * for backwards compat */ set _dirty(v) { if (v) this.flags |= 16; else this.flags &= -49; } constructor(fn, setter) { this.fn = fn; this.setter = setter; this._value = void 0; this.subs = void 0; this.subsTail = void 0; this.deps = void 0; this.depsTail = void 0; this.flags = 17; this.__v_isRef = true; this["__v_isReadonly"] = !setter; } get value() { const flags = this.flags; if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) { if (this.update()) { const subs = this.subs; if (subs !== void 0) shallowPropagate(subs); } } else if (flags & 32) this.flags = flags & -33; if (activeSub !== void 0) { onTrack(activeSub, { target: this, type: "get", key: "value" }); link(this, activeSub); } else if (activeEffectScope !== void 0) link(this, activeEffectScope); return this._value; } set value(newValue) { if (this.setter) this.setter(newValue); else warn$2("Write operation failed: computed value is readonly"); } update() { const prevSub = startTracking(this); try { const oldValue = this._value; const newValue = this.fn(oldValue); if ((0, _vue_shared.hasChanged)(oldValue, newValue)) { this._value = newValue; return true; } return false; } finally { endTracking(this, prevSub); } } }; setupOnTrigger(ComputedRefImpl); /*@__NO_SIDE_EFFECTS__*/ function computed$1(getterOrOptions, debugOptions, isSSR = false) { let getter; let setter; if ((0, _vue_shared.isFunction)(getterOrOptions)) getter = getterOrOptions; else { getter = getterOrOptions.get; setter = getterOrOptions.set; } const cRef = new ComputedRefImpl(getter, setter); if (debugOptions && !isSSR) { cRef.onTrack = debugOptions.onTrack; cRef.onTrigger = debugOptions.onTrigger; } return cRef; } //#endregion //#region packages/reactivity/src/constants.ts const TrackOpTypes = { "GET": "get", "HAS": "has", "ITERATE": "iterate" }; const TriggerOpTypes = { "SET": "set", "ADD": "add", "DELETE": "delete", "CLEAR": "clear" }; //#endregion //#region packages/reactivity/src/watch.ts const INITIAL_WATCHER_VALUE = {}; let activeWatcher = void 0; /** * Returns the current active effect if there is one. */ function getCurrentWatcher() { return activeWatcher; } /** * Registers a cleanup callback on the current active effect. This * registered cleanup callback will be invoked right before the * associated effect re-runs. * * @param cleanupFn - The callback function to attach to the effect's cleanup. * @param failSilently - if `true`, will not throw warning when called without * an active effect. * @param owner - The effect that this cleanup function should be attached to. * By default, the current active effect. */ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) { if (owner) { const { call } = owner.options; const cleanup = call ? () => call(cleanupFn, 4) : cleanupFn; if (owner.cb) (owner.cbCleanups || (owner.cbCleanups = [])).push(cleanup); else owner.cleanups[owner.cleanupsLength++] = cleanup; } else if (!failSilently) warn$2("onWatcherCleanup() was called when there was no active watcher to associate with."); } var WatcherEffect = class extends ReactiveEffect { constructor(source, cb, options = _vue_shared.EMPTY_OBJ) { const { deep, once, call, onWarn } = options; let getter; let forceTrigger = false; let isMultiSource = false; if (/* @__PURE__ */ isRef(source)) { getter = () => source.value; forceTrigger = /* @__PURE__ */ isShallow(source); } else if (/* @__PURE__ */ isReactive(source)) { getter = () => reactiveGetter(source, deep); forceTrigger = true; } else if ((0, _vue_shared.isArray)(source)) { isMultiSource = true; forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s)); getter = () => source.map((s) => { if (/* @__PURE__ */ isRef(s)) return s.value; else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s, deep); else if ((0, _vue_shared.isFunction)(s)) return call ? call(s, 2) : s(); else warnInvalidSource(s, onWarn); }); } else if ((0, _vue_shared.isFunction)(source)) { if (cb) getter = call ? () => call(source, 2) : source; else getter = () => { if (this.cleanupsLength) { const prevSub = setActiveSub(); try { cleanup(this); } finally { setActiveSub(prevSub); } } const currentEffect = activeWatcher; activeWatcher = this; try { return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup); } finally { activeWatcher = currentEffect; } }; } else { getter = _vue_shared.NOOP; warnInvalidSource(source, onWarn); } if (cb && deep) { const baseGetter = getter; const depth = deep === true ? Infinity : deep; getter = () => traverse(baseGetter(), depth); } super(getter); this.cb = cb; this.options = options; this.boundCleanup = (fn) => onWatcherCleanup(fn, false, this); this.forceTrigger = forceTrigger; this.isMultiSource = isMultiSource; if (once && cb) { const _cb = cb; cb = (...args) => { try { return _cb(...args); } finally { this.stop(); } }; } this.cb = cb; this.oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE; this.onTrack = options.onTrack; this.onTrigger = options.onTrigger; } cleanupCallback() { const cleanups = this.cbCleanups; if (cleanups) { this.cbCleanups = void 0; for (let i = 0, l = cleanups.length; i < l; i++) cleanups[i](); } } stop() { if (this.active) { super.stop(); this.cleanupCallback(); } } run(initialRun = false) { const oldValue = this.oldValue; const newValue = this.oldValue = super.run(); if (!this.cb) return; const { immediate, deep, call } = this.options; if (initialRun && !immediate) return; if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => (0, _vue_shared.hasChanged)(v, oldValue[i])) : (0, _vue_shared.hasChanged)(newValue, oldValue))) { const currentWatcher = activeWatcher; const prevSub = setActiveSub(); try { this.cleanupCallback(); activeWatcher = this; const args = [ newValue, oldValue === INITIAL_WATCHER_VALUE ? void 0 : this.isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue, this.boundCleanup ]; call ? call(this.cb, 3, args) : this.cb(...args); } finally { activeWatcher = currentWatcher; setActiveSub(prevSub); } } } }; function reactiveGetter(source, deep) { if (deep) return source; if (/* @__PURE__ */ isShallow(source) || deep === false || deep === 0) return traverse(source, 1); return traverse(source); } function warnInvalidSource(s, onWarn) { (onWarn || warn$2)(`Invalid watch source: `, s, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."); } function watch$1(source, cb, options = _vue_shared.EMPTY_OBJ) { const effect = new WatcherEffect(source, cb, options); effect.run(true); const stop = effect.stop.bind(effect); stop.pause = effect.pause.bind(effect); stop.resume = effect.resume.bind(effect); stop.stop = stop; return stop; } function traverse(value, depth = Infinity, seen) { if (depth <= 0 || !(0, _vue_shared.isObject)(value) || value["__v_skip"]) return value; seen = seen || /* @__PURE__ */ new Map(); if ((seen.get(value) || 0) >= depth) return value; seen.set(value, depth); depth--; if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen); else if ((0, _vue_shared.isArray)(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen); else if ((0, _vue_shared.isSet)(value) || (0, _vue_shared.isMap)(value)) value.forEach((v) => { traverse(v, depth, seen); }); else if ((0, _vue_shared.isPlainObject)(value)) { for (const key in value) traverse(value[key], depth, seen); for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen); } return value; } //#endregion //#region packages/runtime-core/src/warning.ts const stack = []; /** * @internal */ function pushWarningContext(ctx) { stack.push(ctx); } /** * @internal */ function popWarningContext() { stack.pop(); } let isWarning = false; function warn$1(msg, ...args) { if (isWarning) return; isWarning = true; const prevSub = setActiveSub(); const entry = stack.length ? stack[stack.length - 1] : null; const instance = isVNode(entry) ? entry.component : entry; const appWarnHandler = instance && instance.appContext.config.warnHandler; const trace = getComponentTrace(); if (appWarnHandler) callWithErrorHandling(appWarnHandler, instance, 11, [ msg + args.map((a) => { const toString = a.toString; return toString == null ? JSON.stringify(a) : toString.call(a); }).join(""), instance && instance.vapor ? instance : instance && instance.proxy || instance, trace.map(({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`).join("\n"), trace ]); else { const warnArgs = [`[Vue warn]: ${msg}`, ...args]; if (trace.length && true) /* v8 ignore next 2 */ warnArgs.push(`\n`, ...formatTrace(trace)); console.warn(...warnArgs); } setActiveSub(prevSub); isWarning = false; } function getComponentTrace() { let currentCtx = stack[stack.length - 1]; if (!currentCtx) return []; const normalizedStack = []; while (currentCtx) { const last = normalizedStack[0]; if (last && last.ctx === currentCtx) last.recurseCount++; else normalizedStack.push({ ctx: currentCtx, recurseCount: 0 }); if (isVNode(currentCtx)) { const parent = currentCtx.component && currentCtx.component.parent; currentCtx = parent && parent.vnode || parent; } else currentCtx = currentCtx.parent; } return normalizedStack; } /* v8 ignore start */ function formatTrace(trace) { const logs = []; trace.forEach((entry, i) => { logs.push(...i === 0 ? [] : [`\n`], ...formatTraceEntry(entry)); }); return logs; } function formatTraceEntry({ ctx, recurseCount }) { const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``; const instance = isVNode(ctx) ? ctx.component : ctx; const isRoot = instance ? instance.parent == null : false; const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`; const close = `>` + postfix; return ctx.props ? [ open, ...formatProps(ctx.props), close ] : [open + close]; } function formatProps(props) { const res = []; const keys = Object.keys(props); keys.slice(0, 3).forEach((key) => { res.push(...formatProp(key, props[key])); }); if (keys.length > 3) res.push(` ...`); return res; } function formatProp(key, value, raw) { if ((0, _vue_shared.isString)(value)) { value = JSON.stringify(value); return raw ? value : [`${key}=${value}`]; } else if (typeof value === "number" || typeof value === "boolean" || value == null) return raw ? value : [`${key}=${value}`]; else if (/* @__PURE__ */ isRef(value)) { value = formatProp(key, /* @__PURE__ */ toRaw(value.value), true); return raw ? value : [ `${key}=Ref<`, value, `>` ]; } else if ((0, _vue_shared.isFunction)(value)) return [`${key}=fn${value.name ? `<${value.name}>` : ``}`]; else { value = /* @__PURE__ */ toRaw(value); return raw ? value : [`${key}=`, value]; } } /** * @internal */ function assertNumber(val, type) { if (val === void 0) return; else if (typeof val !== "number") warn$1(`${type} is not a valid number - got ${JSON.stringify(val)}.`); else if (isNaN(val)) warn$1(`${type} is NaN - the duration expression might be incorrect.`); } /* v8 ignore stop */ //#endregion //#region packages/runtime-core/src/errorHandling.ts const ErrorCodes = { "SETUP_FUNCTION": 0, "0": "SETUP_FUNCTION", "RENDER_FUNCTION": 1, "1": "RENDER_FUNCTION", "NATIVE_EVENT_HANDLER": 5, "5": "NATIVE_EVENT_HANDLER", "COMPONENT_EVENT_HANDLER": 6, "6": "COMPONENT_EVENT_HANDLER", "VNODE_HOOK": 7, "7": "VNODE_HOOK", "DIRECTIVE_HOOK": 8, "8": "DIRECTIVE_HOOK", "TRANSITION_HOOK": 9, "9": "TRANSITION_HOOK", "APP_ERROR_HANDLER": 10, "10": "APP_ERROR_HANDLER", "APP_WARN_HANDLER": 11, "11": "APP_WARN_HANDLER", "FUNCTION_REF": 12, "12": "FUNCTION_REF", "ASYNC_COMPONENT_LOADER": 13, "13": "ASYNC_COMPONENT_LOADER", "SCHEDULER": 14, "14": "SCHEDULER", "COMPONENT_UPDATE": 15, "15": "COMPONENT_UPDATE", "APP_UNMOUNT_CLEANUP": 16, "16": "APP_UNMOUNT_CLEANUP" }; const ErrorTypeStrings$1 = { ["sp"]: "serverPrefetch hook", ["bc"]: "beforeCreate hook", ["c"]: "created hook", ["bm"]: "beforeMount hook", ["m"]: "mounted hook", ["bu"]: "beforeUpdate hook", ["u"]: "updated", ["bum"]: "beforeUnmount hook", ["um"]: "unmounted hook", ["a"]: "activated hook", ["da"]: "deactivated hook", ["ba"]: "beforeActivate hook", ["bda"]: "beforeDeactivate hook", ["ec"]: "errorCaptured hook", ["rtc"]: "renderTracked hook", ["rtg"]: "renderTriggered hook", [0]: "setup function", [1]: "render function", [2]: "watcher getter", [3]: "watcher callback", [4]: "watcher cleanup function", [5]: "native event handler", [6]: "component event handler", [7]: "vnode hook", [8]: "directive hook", [9]: "transition hook", [10]: "app errorHandler", [11]: "app warnHandler", [12]: "ref function", [13]: "async component loader", [14]: "scheduler flush", [15]: "component update", [16]: "app unmount cleanup function" }; function callWithErrorHandling(fn, instance, type, args) { try { return args ? fn(...args) : fn(); } catch (err) { handleError(err, instance, type); } } function callWithAsyncErrorHandling(fn, instance, type, args) { if ((0, _vue_shared.isFunction)(fn)) { const res = callWithErrorHandling(fn, instance, type, args); if (res && (0, _vue_shared.isPromise)(res)) res.catch((err) => { handleError(err, instance, type); }); return res; } if ((0, _vue_shared.isArray)(fn)) { const values = []; for (let i = 0; i < fn.length; i++) values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)); return values; } else warn$1(`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`); } function handleError(err, instance, type, throwInDev = true) { const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || _vue_shared.EMPTY_OBJ; if (instance) { let cur = instance.parent; const exposedInstance = instance.vapor ? instance : instance.proxy || instance; const errorInfo = ErrorTypeStrings$1[type]; while (cur) { const errorCapturedHooks = cur.ec; if (errorCapturedHooks) { for (let i = 0; i < errorCapturedHooks.length; i++) if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) return; } cur = cur.parent; } if (errorHandler) { const prevSub = setActiveSub(); callWithErrorHandling(errorHandler, null, 10, [ err, exposedInstance, errorInfo ]); setActiveSub(prevSub); return; } } logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction); } function logError(err, type, instance, throwInDev = true, throwInProd = false) { { const info = ErrorTypeStrings$1[type] || type; if (instance) pushWarningContext(instance); warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`); if (instance) popWarningContext(); if (throwInDev) throw err; else console.error(err); } } //#endregion //#region packages/runtime-core/src/scheduler.ts const SchedulerJobFlags = { "QUEUED": 1, "1": "QUEUED", "ALLOW_RECURSE": 2, "2": "ALLOW_RECURSE", "DISPOSED": 4, "4": "DISPOSED", "REQUEUE_ON_SUSPENSE_DISCARD": 8, "8": "REQUEUE_ON_SUSPENSE_DISCARD" }; const jobs = []; let postJobs = []; let activePostJobs = null; let currentFlushPromise = null; let jobsLength = 0; let flushIndex = 0; let postFlushIndex = 0; const resolvedPromise = /*@__PURE__*/ Promise.resolve(); const RECURSION_LIMIT = 100; function nextTick(fn) { const p = currentFlushPromise || resolvedPromise; return fn ? p.then(this ? fn.bind(this) : fn) : p; } function findInsertionIndex(order, queue, start, end) { while (start < end) { const middle = start + end >>> 1; if (queue[middle].order <= order) start = middle + 1; else end = middle; } return start; } /** * @internal for runtime-vapor only */ function queueJob(job, id, isPre = false, order = 0) { if (queueJobWorker(job, id === void 0 ? isPre ? -2 : Infinity : isPre ? id * 2 : order ? id * 2 + 1 + order / (order + 1) : id * 2 + 1, jobs, jobsLength, flushIndex)) { jobsLength++; queueFlush(); } } function queueJobWorker(job, order, queue, length, flushIndex) { const flags = job.flags; if (!(flags & 1)) { job.flags = flags | 1; job.order = order; if (flushIndex === length || order >= queue[length - 1].order) queue[length] = job; else queue.splice(findInsertionIndex(order, queue, flushIndex, length), 0, job); return true; } return false; } const doFlushJobs = () => { try { flushJobs(); } catch (e) { currentFlushPromise = null; if (jobsLength || postJobs.length) queueFlush(); throw e; } }; function queueFlush() { if (!currentFlushPromise) currentFlushPromise = resolvedPromise.then(doFlushJobs); } function queuePostFlushCb(jobs, id = Infinity) { if (!(0, _vue_shared.isArray)(jobs)) { if (activePostJobs && id === -1) activePostJobs.splice(postFlushIndex, 0, jobs); else queueJobWorker(jobs, id, postJobs, postJobs.length, 0); } else for (let i = 0; i < jobs.length; i++) queueJobWorker(jobs[i], id, postJobs, postJobs.length, 0); queueFlush(); } function flushPreFlushCbs(instance, minUid, seen) { seen = seen || /* @__PURE__ */ new Map(); for (let i = flushIndex; i < jobsLength; i++) { const cb = jobs[i]; if (cb.order & 1 || cb.order === Infinity) continue; if (instance && cb.order !== instance.uid * 2 || minUid !== void 0 && !(cb.order >= minUid * 2)) continue; if (checkRecursiveUpdates(seen, cb)) continue; jobs.splice(i, 1); i = instance ? i - 1 : flushIndex - 1; jobsLength--; if (cb.flags & 2) cb.flags &= -2; try { cb(); } finally { if (!(cb.flags & 2)) cb.flags &= -2; } } } function flushPostFlushCbs(seen, skip, minUid = 0) { if (postJobs.length) { let cbs = postJobs; if (skip) { cbs = []; let kept = 0; for (let i = 0; i < postJobs.length; i++) { const cb = postJobs[i]; if (cb.i !== void 0 ? !cb.i || cb.i.uid < minUid : skip.has(cb)) postJobs[kept++] = cb; else cbs.push(cb); } postJobs.length = kept; } else postJobs = []; if (activePostJobs) { for (let i = 0; i < cbs.length; i++) activePostJobs.push(cbs[i]); return; } activePostJobs = cbs; seen = seen || /* @__PURE__ */ new Map(); try { while (postFlushIndex < activePostJobs.length) { const cb = activePostJobs[postFlushIndex++]; if (checkRecursiveUpdates(seen, cb)) continue; if (cb.flags & 2) cb.flags &= -2; if (!(cb.flags & 4)) try { cb(); } finally { if (!(cb.flags & 2)) cb.flags &= -2; } } } finally { while (postFlushIndex < activePostJobs.length) activePostJobs[postFlushIndex++].flags &= -2; activePostJobs = null; postFlushIndex = 0; } } } let isFlushing = false; /** * Run a root render, then flush the jobs it is responsible for. A mount or * unmount (`minUid` given) only flushes the jobs of the components it created * and the post cbs it queued, so pre watchers triggered in setup run before * mounted (#5721) while the jobs of other components stay in the queue and * keep their order (#6728). A root update keeps flushing all pending pre jobs * and post cbs, as the jobs of the components it re-renders may predate it. * * @internal */ function flushOnAppMount(fn, minUid) { if (isFlushing) { fn(); return; } const queued = minUid === void 0 ? void 0 : new Set(postJobs); fn(); isFlushing = true; try { flushPreFlushCbs(void 0, minUid); flushPostFlushCbs(void 0, queued, minUid); } finally { isFlushing = false; } } function flushJobs(seen) { seen || (seen = /* @__PURE__ */ new Map()); try { while (flushIndex < jobsLength) { const job = jobs[flushIndex]; jobs[flushIndex++] = void 0; if (!(job.flags & 4)) { if (checkRecursiveUpdates(seen, job)) continue; if (job.flags & 2) job.flags &= -2; try { job(); } catch (err) { handleError(err, job.i, job.i ? 15 : 14); } finally { if (!(job.flags & 2)) job.flags &= -2; } } } } finally { while (flushIndex < jobsLength) { jobs[flushIndex].flags &= -2; jobs[flushIndex++] = void 0; } flushIndex = 0; jobsLength = 0; jobs.length = 0; flushPostFlushCbs(seen); if (jobsLength || postJobs.length) flushJobs(seen); else currentFlushPromise = null; } } function checkRecursiveUpdates(seen, fn) { const count = seen.get(fn) || 0; if (count > RECURSION_LIMIT) { const instance = fn.i; const componentName = instance && getComponentName(instance.type); handleError(`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.`, null, 10); return true; } seen.set(fn, count + 1); return false; } //#endregion //#region packages/runtime-core/src/hmr.ts let isHmrUpdating = false; const setHmrUpdating = (v) => { try { return isHmrUpdating; } finally { isHmrUpdating = v; } }; const hmrDirtyComponents = /* @__PURE__ */ new Map(); const hmrDirtyComponentsMode = /* @__PURE__ */ new Map(); (0, _vue_shared.getGlobalThis)().__VUE_HMR_RUNTIME__ = { createRecord: tryWrap(createRecord), rerender: tryWrap(rerender), reload: tryWrap(reload) }; function runWithHmrUpdating(fn) { isHmrUpdating = true; let done = false; try { fn(); done = true; } finally { if (done) nextTick(() => { isHmrUpdating = false; }); else isHmrUpdating = false; } } const map = /* @__PURE__ */ new Map(); function registerHMR(instance) { const id = instance.type.__hmrId; let record = map.get(id); if (!record) { createRecord(id, instance.type); record = map.get(id); } record.instances.add(instance); } function unregisterHMR(instance) { map.get(instance.type.__hmrId).instances.delete(instance); } function createRecord(id, initialDef) { if (map.has(id)) return false; map.set(id, { initialDef: normalizeClassComponent(initialDef), instances: /* @__PURE__ */ new Set() }); return true; } function normalizeClassComponent(component) { return isClassComponent(component) ? component.__vccOpts : component; } function hasDirtyAncestor(instance, dirtyInstances) { let parent = instance.parent; while (parent) { if (dirtyInstances.has(parent)) return true; parent = parent.parent; } return false; } function rerender(id, newRender) { const record = map.get(id); if (!record) return; record.initialDef.render = newRender; [...record.instances].forEach((instance) => { if (newRender) { instance.render = newRender; normalizeClassComponent(instance.type).render = newRender; } runWithHmrUpdating(() => { if (instance.vapor) { if (!instance.isUnmounted) instance.hmrRerender(); } else { const i = instance; if (!(i.effect.flags & 1024)) { i.renderCache = []; i.effect.run(); } } }); }); } function reload(id, newComp) { const record = map.get(id); if (!record) return; let pageComp; if (typeof window !== "undefined" && record.initialDef.__vapor && record.initialDef.__mpType === "page") { const setupPage = window.__setupPage; if (setupPage) pageComp = normalizeClassComponent(setupPage(newComp)); } newComp = normalizeClassComponent(newComp); const resolveNewComp = (instance) => pageComp && instance.vapor && instance.$pageInstance === instance ? pageComp : newComp; const isVapor = record.initialDef.__vapor; updateComponentDef(record.initialDef, newComp); const instances = [...record.instances]; if (isVapor && newComp.__vapor && !instances.some((instance) => instance.parent && !instance.parent.vapor) && !instances.some((i) => i.ceReload)) { for (const instance of instances) { const oldComp = normalizeClassComponent(instance.type); if (oldComp !== record.initialDef) updateComponentDef(oldComp, resolveNewComp(instance)); if (instance.root && instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(instance.type); } const dirtyInstances = new Set(instances); const rerenderedParents = /* @__PURE__ */ new Set(); runWithHmrUpdating(() => { for (const instance of instances) { const parent = instance.parent; if (parent) { if (!hasDirtyAncestor(instance, dirtyInstances) && !rerenderedParents.has(parent)) { rerenderedParents.add(parent); parent.hmrRerender(); } } else instance.hmrReload(resolveNewComp(instance)); } }); } else { const parents = /* @__PURE__ */ new Set(); const dirtyInstanceSet = new Set(instances); for (const instance of instances) { const oldComp = normalizeClassComponent(instance.type); let dirtyInstances = hmrDirtyComponents.get(oldComp); if (!dirtyInstances) { if (oldComp !== record.initialDef) updateComponentDef(oldComp, resolveNewComp(instance)); hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set()); } dirtyInstances.add(instance); hmrDirtyComponentsMode.set(oldComp, !!isVapor); instance.appContext.propsCache.delete(instance.type); instance.appContext.emitsCache.delete(instance.type); instance.appContext.optionsCache.delete(instance.type); if (instance.ceReload) { dirtyInstances.add(instance); instance.ceReload(newComp.styles); dirtyInstances.delete(instance); } else if (instance.parent) { if (!hasDirtyAncestor(instance, dirtyInstanceSet)) parents.add(instance.parent); } else if (instance.appContext.reload) instance.appContext.reload(); else if (typeof window !== "undefined") window.location.reload(); else console.warn("[HMR] Root or manually mounted instance modified. Full reload required."); if (instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(oldComp); } parents.forEach((parent) => { queueJob(() => { runWithHmrUpdating(() => { if (parent.vapor) parent.hmrRerender(); else { const i = parent; if (!(i.effect.flags & 1024)) { i.renderCache = []; i.effect.run(); } } }); }); }); } queuePostFlushCb(() => { hmrDirtyComponents.clear(); hmrDirtyComponentsMode.clear(); }); } function updateComponentDef(oldComp, newComp) { (0, _vue_shared.extend)(oldComp, newComp); for (const key in oldComp) if (key !== "__file" && !(key in newComp)) delete oldComp[key]; } function tryWrap(fn) { return (id, arg) => { try { return fn(id, arg); } catch (e) { console.error(e); console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required."); } }; } //#endregion //#region packages/runtime-core/src/devtools.ts let devtools$1; let buffer = []; let devtoolsNotInstalled = false; function emit$2(event, ...args) { if (devtools$1) devtools$1.emit(event, ...args); else if (!devtoolsNotInstalled) buffer.push({ event, args }); } function setDevtoolsHook$1(hook, target) { var _window$navigator; devtools$1 = hook; if (devtools$1) { devtools$1.enabled = true; buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args)); buffer = []; } else if (typeof window !== "undefined" && window.HTMLElement && !((_window$navigator = window.navigator) === null || _window$navigator === void 0 || (_window$navigator = _window$navigator.userAgent) === null || _window$navigator === void 0 ? void 0 : _window$navigator.includes("jsdom"))) { (target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((newHook) => { setDevtoolsHook$1(newHook, target); }); setTimeout(() => { if (!devtools$1) { target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null; devtoolsNotInstalled = true; buffer = []; } }, 3e3); } else { devtoolsNotInstalled = true; buffer = []; } } function devtoolsInitApp(app, version) { emit$2("app:init", app, version, { Fragment, Text: Text$1, Comment: Comment$1, Static }); } function devtoolsUnmountApp(app) { emit$2("app:unmount", app); } const devtoolsComponentAdded = /*@__PURE__*/ createDevtoolsComponentHook("component:added"); const devtoolsComponentUpdated = /*@__PURE__*/ createDevtoolsComponentHook("component:updated"); const _devtoolsComponentRemoved = /*@__PURE__*/ createDevtoolsComponentHook("component:removed"); const devtoolsComponentRemoved = (component) => { if (devtools$1 && typeof devtools$1.cleanupBuffer === "function" && !devtools$1.cleanupBuffer(component)) _devtoolsComponentRemoved(component); }; /*@__NO_SIDE_EFFECTS__*/ function createDevtoolsComponentHook(hook) { return (component) => { emit$2(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : void 0, component); }; } const devtoolsPerfStart = /*@__PURE__*/ createDevtoolsPerformanceHook("perf:start"); const devtoolsPerfEnd = /*@__PURE__*/ createDevtoolsPerformanceHook("perf:end"); function createDevtoolsPerformanceHook(hook) { return (component, type, time) => { emit$2(hook, component.appContext.app, component.uid, component, type, time); }; } function devtoolsComponentEmit(component, event, params) { emit$2("component:emit", component.appContext.app, component, event, params); } //#endregion //#region packages/runtime-core/src/componentRenderContext.ts /** * mark the current rendering instance for asset resolution (e.g. * resolveComponent, resolveDirective) during render */ let currentRenderingInstance = null; let currentScopeId = null; /** * Note: rendering calls maybe nested. The function returns the parent rendering * instance if present, which should be restored after the render is done: * * ```js * const prev = setCurrentRenderingInstance(i) * // ...render * setCurrentRenderingInstance(prev) * ``` */ function setCurrentRenderingInstance(instance) { const prev = currentRenderingInstance; currentRenderingInstance = instance; currentScopeId = instance && instance.type.__scopeId || null; return prev; } /** * Set scope id when creating hoisted vnodes. * @private compiler helper */ function pushScopeId(id) { currentScopeId = id; } /** * Technically we no longer need this after 3.0.8 but we need to keep the same * API for backwards compat w/ code generated by compilers. * @private */ function popScopeId() { currentScopeId = null; } /** * Only for backwards compat * @private */ const withScopeId = (_id) => withCtx; /** * Wrap a slot function to memoize current rendering instance * @private compiler helper */ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) { if (!ctx) return fn; if (fn._n) return fn; const renderFnWithContext = (...args) => { if (renderFnWithContext._d) setBlockTracking(-1); const prevInstance = setCurrentRenderingInstance(ctx); const prevStackSize = blockStack.length; let res; try { res = fn(...args); } finally { for (let i = blockStack.length; i > prevStackSize; i--) closeBlock(); setCurrentRenderingInstance(prevInstance); if (renderFnWithContext._d) setBlockTracking(1); } devtoolsComponentUpdated(ctx); return res; }; renderFnWithContext._n = true; renderFnWithContext._c = true; renderFnWithContext._d = true; return renderFnWithContext; } //#endregion //#region packages/runtime-core/src/directives.ts function validateDirectiveName(name) { if ((0, _vue_shared.isBuiltInDirective)(name)) warn$1("Do not use built-in directive ids as custom directive id: " + name); } /** * Adds directives to a VNode. */ function withDirectives(vnode, directives) { if (currentRenderingInstance === null) { warn$1(`withDirectives can only be used inside render functions.`); return vnode; } const instance = getComponentPublicInstance(currentRenderingInstance); const bindings = vnode.dirs || (vnode.dirs = []); for (let i = 0; i < directives.length; i++) { let [dir, value, arg, modifiers = _vue_shared.EMPTY_OBJ] = directives[i]; if (dir) { if ((0, _vue_shared.isFunction)(dir)) dir = { mounted: dir, updated: dir }; if (dir.deep) traverse(value); bindings.push({ dir, instance, value, oldValue: void 0, arg, modifiers }); } } return vnode; } function invokeDirectiveHook(vnode, prevVNode, instance, name) { const bindings = vnode.dirs; const oldBindings = prevVNode && prevVNode.dirs; for (let i = 0; i < bindings.length; i++) { const binding = bindings[i]; if (oldBindings) binding.oldValue = oldBindings[i].value; let hook = binding.dir[name]; if (hook) { const prevSub = setActiveSub(); callWithAsyncErrorHandling(hook, instance, 8, [ vnode.el, binding, vnode, prevVNode ]); setActiveSub(prevSub); } } } //#endregion //#region packages/runtime-core/src/apiInject.ts function provide(key, value) { if (!currentInstance || currentInstance.isMounted && !isHmrUpdating) warn$1(`provide() can only be used inside setup().`); if (currentInstance) { let provides = currentInstance.provides; const parentProvides = currentInstance.parent && currentInstance.parent.provides; if (parentProvides === provides) provides = currentInstance.provides = Object.create(parentProvides); provides[key] = value; } } function inject(key, defaultValue, treatDefaultAsFactory = false) { const instance = getCurrentGenericInstance(); if (instance || currentApp) { let provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null || instance.ce ? instance.appContext && instance.appContext.provides : instance.parent.provides : void 0; if (provides && key in provides) return provides[key]; else if (arguments.length > 1) return treatDefaultAsFactory && (0, _vue_shared.isFunction)(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue; else warn$1(`injection "${String(key)}" not found.`); } else warn$1(`inject() can only be used inside setup() or functional components.`); } /** * Returns true if `inject()` can be used without warning about being called in the wrong place (e.g. outside of * setup()). This is used by libraries that want to use `inject()` internally without triggering a warning to the end * user. One example is `useRoute()` in `vue-router`. */ function hasInjectionContext() { return !!(getCurrentGenericInstance() || currentApp); } //#endregion //#region packages/runtime-core/src/helpers/useSsrContext.ts const ssrContextKey = Symbol.for("v-scx"); const useSSRContext = () => { { const ctx = inject(ssrContextKey); if (!ctx) warn$1("Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build."); return ctx; } }; //#endregion //#region packages/runtime-core/src/apiWatch.ts function watchEffect(effect, options) { return doWatch(effect, null, options); } function watchPostEffect(effect, options) { return doWatch(effect, null, (0, _vue_shared.extend)({}, options, { flush: "post" })); } function watchSyncEffect(effect, options) { return doWatch(effect, null, (0, _vue_shared.extend)({}, options, { flush: "sync" })); } function watch(source, cb, options) { if (!(0, _vue_shared.isFunction)(cb)) warn$1("`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."); return doWatch(source, cb, options); } var RenderWatcherEffect = class extends WatcherEffect { constructor(instance, source, cb, options, flush) { super(source, cb, options); this.flush = flush; const job = () => { if (this.dirty) this.run(); }; if (cb) { this.flags |= 128; job.flags |= 2; } job.i = instance; this.job = job; } notify() { if (!(this.flags & 256)) { const flush = this.flush; const job = this.job; if (flush === "post") queuePostRenderEffect(job, void 0, job.i ? job.i.suspense : null); else if (flush === "pre") queueJob(job, job.i ? job.i.uid : void 0, true); else job(); } } }; function doWatch(source, cb, options = _vue_shared.EMPTY_OBJ) { const { immediate, deep, flush = "pre", once } = options; if (!cb) { if (immediate !== void 0) warn$1("watch() \"immediate\" option is only respected when using the watch(source, callback, options?) signature."); if (deep !== void 0) warn$1("watch() \"deep\" option is only respected when using the watch(source, callback, options?) signature."); if (once !== void 0) warn$1("watch() \"once\" option is only respected when using the watch(source, callback, options?) signature."); } const baseWatchOptions = (0, _vue_shared.extend)({}, options); baseWatchOptions.onWarn = warn$1; const runsImmediately = cb && immediate || !cb && flush !== "post"; let ssrCleanup; if (isInSSRComponentSetup) { if (flush === "sync") { const ctx = useSSRContext(); ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []); } else if (!runsImmediately) { const watchStopHandle = () => {}; watchStopHandle.stop = _vue_shared.NOOP; watchStopHandle.resume = _vue_shared.NOOP; watchStopHandle.pause = _vue_shared.NOOP; return watchStopHandle; } } const instance = currentInstance; baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args); const effect = new RenderWatcherEffect(instance, source, cb, baseWatchOptions, flush); if (cb) effect.run(true); else if (flush === "post") queuePostRenderEffect(effect.job, void 0, instance && instance.suspense); else effect.run(true); const stop = effect.stop.bind(effect); stop.pause = effect.pause.bind(effect); stop.resume = effect.resume.bind(effect); stop.stop = stop; if (isInSSRComponentSetup) { if (ssrCleanup) ssrCleanup.push(stop); else if (runsImmediately) stop(); } return stop; } function instanceWatch(source, value, options) { const publicThis = this.proxy; const getter = (0, _vue_shared.isString)(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis); let cb; if ((0, _vue_shared.isFunction)(value)) cb = value; else { cb = value.handler; options = value; } const prev = setCurrentInstance(this); const res = doWatch(getter, cb.bind(publicThis), options); restoreCurrentInstance(prev); return res; } function createPathGetter(ctx, path) { const segments = path.split("."); return () => { let cur = ctx; for (let i = 0; i < segments.length && cur; i++) cur = cur[segments[i]]; return cur; }; } //#endregion //#region packages/runtime-core/src/vaporInteropState.ts /** * Set by `vaporInteropPlugin`. Stays false in apps that never import the * plugin, so bundlers drop the vapor-in-vdom branches of the renderer. */ let isVaporInteropEnabled = false; function setVaporInteropEnabled() { isVaporInteropEnabled = true; } //#endregion //#region packages/runtime-core/src/components/Teleport.ts const pendingMounts = /* @__PURE__ */ new WeakMap(); const TeleportEndKey = Symbol("_vte"); const isTeleport = (type) => type.__isTeleport; const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === ""); const isTeleportDeferred = (props) => props && (props.defer || props.defer === ""); const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement; const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement; const resolveTarget = (props, select) => { const targetSelector = props && props.to; if ((0, _vue_shared.isString)(targetSelector)) { if (!select) { warn$1("Current renderer does not support string target for Teleports. (missing querySelector renderer option)"); return null; } else { const target = select(targetSelector); if (!target && !isTeleportDisabled(props)) warn$1(`Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`); return target; } } else { if (!targetSelector && !isTeleportDisabled(props)) warn$1(`Invalid Teleport target: ${targetSelector}`); return targetSelector; } }; const TeleportImpl = { name: "Teleport", __isTeleport: true, process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) { const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment, parentNode } } = internals; const disabled = isTeleportDisabled(n2.props); let { dynamicChildren } = n2; if (isHmrUpdating) { optimized = false; dynamicChildren = null; } const mount = (vnode, container, anchor) => { if (vnode.shapeFlag & 16) mountChildren(vnode.children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); }; const mountToTarget = (vnode = n2) => { const disabled = isTeleportDisabled(vnode.props); const target = vnode.target = resolveTarget(vnode.props, querySelector); const targetAnchor = prepareAnchor(target, vnode, createText, insert); if (target) { if (namespace !== "svg" && isTargetSVG(target)) namespace = "svg"; else if (namespace !== "mathml" && isTargetMathML(target)) namespace = "mathml"; if (parentComponent && parentComponent.isCE) (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target); if (!disabled) { mount(vnode, target, targetAnchor); updateCssVars(vnode, false); } } else if (!disabled) warn$1("Invalid Teleport target on mount:", target, `(${typeof target})`); }; const queuePendingMount = (vnode) => { const mountJob = () => { if (pendingMounts.get(vnode) !== mountJob) return; pendingMounts.delete(vnode); if (isTeleportDisabled(vnode.props)) { const mountContainer = parentNode(vnode.el) || container; mount(vnode, mountContainer, vnode.anchor); updateCssVars(vnode, true); } mountToTarget(vnode); }; pendingMounts.set(vnode, mountJob); queuePostRenderEffect(mountJob, void 0, parentSuspense); }; if (n1 == null) { const placeholder = n2.el = createComment("teleport start"); const mainAnchor = n2.anchor = createComment("teleport end"); insert(placeholder, container, anchor); insert(mainAnchor, container, anchor); if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) { queuePendingMount(n2); return; } if (disabled) { mount(n2, container, mainAnchor); updateCssVars(n2, true); } mountToTarget(); } else { n2.el = n1.el; const mainAnchor = n2.anchor = n1.anchor; const pendingMount = pendingMounts.get(n1); if (pendingMount) { pendingMount.flags |= 4; pendingMounts.delete(n1); queuePendingMount(n2); return; } n2.targetStart = n1.targetStart; const target = n2.target = n1.target; const targetAnchor = n2.targetAnchor = n1.targetAnchor; const wasDisabled = isTeleportDisabled(n1.props); const currentContainer = wasDisabled ? container : target; const currentAnchor = wasDisabled ? mainAnchor : targetAnchor; if (namespace === "svg" || isTargetSVG(target)) namespace = "svg"; else if (namespace === "mathml" || isTargetMathML(target)) namespace = "mathml"; if (dynamicChildren) { patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, namespace, slotScopeIds); traverseStaticChildren(n1, n2, false); } else if (!optimized) patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, false); if (disabled) { if (!wasDisabled) moveTeleport(n2, container, mainAnchor, internals, parentComponent, 1); else if (n2.props && n1.props && n2.props.to !== n1.props.to) n2.props.to = n1.props.to; } else if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) { const nextTarget = resolveTarget(n2.props, querySelector); if (nextTarget) { n2.target = nextTarget; moveTeleport(n2, nextTarget, null, internals, parentComponent, 0); } else warn$1("Invalid Teleport target on update:", target, `(${typeof target})`); } else if (wasDisabled) moveTeleport(n2, target, targetAnchor, internals, parentComponent, 1); updateCssVars(n2, disabled); } }, remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) { const { shapeFlag, children, anchor, targetStart, targetAnchor, target, props } = vnode; const disabled = isTeleportDisabled(props); const shouldRemove = doRemove || !disabled; const pendingMount = pendingMounts.get(vnode); if (pendingMount) { pendingMount.flags |= 4; pendingMounts.delete(vnode); } if (targetStart) hostRemove(targetStart); if (targetAnchor) hostRemove(targetAnchor); doRemove && hostRemove(anchor); if (!pendingMount && (disabled || target) && shapeFlag & 16) for (let i = 0; i < children.length; i++) { const child = children[i]; unmount(child, parentComponent, parentSuspense, shouldRemove, !!child.dynamicChildren); } }, move: moveTeleport, hydrate: hydrateTeleport }; function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, parentComponent, moveType = 2) { if (moveType === 0) { if (vnode.targetStart) insert(vnode.targetStart, container, parentAnchor); insert(vnode.targetAnchor, container, parentAnchor); parentAnchor = vnode.targetAnchor; } const { el, anchor, shapeFlag, children, props } = vnode; const isReorder = moveType === 2; if (isReorder) insert(el, container, parentAnchor); if (!pendingMounts.has(vnode) && (!isReorder || isTeleportDisabled(props))) { if (shapeFlag & 16) for (let i = 0; i < children.length; i++) move(children[i], container, parentAnchor, 2, parentComponent); } if (isReorder) insert(anchor, container, parentAnchor); } function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector, insert, createText } }, hydrateChildren) { function hydrateAnchor(target, targetNode) { let targetAnchor = targetNode; while (targetAnchor) { if (targetAnchor && targetAnchor.nodeType === 8) { if (targetAnchor.data === "teleport start anchor") vnode.targetStart = targetAnchor; else if (targetAnchor.data === "teleport anchor") { vnode.targetAnchor = targetAnchor; target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor); break; } } targetAnchor = nextSibling(targetAnchor); } } function hydrateDisabledTeleport(node, vnode) { vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized); } const target = vnode.target = resolveTarget(vnode.props, querySelector); const disabled = isTeleportDisabled(vnode.props); if (target) { const targetNode = target._lpa || target.firstChild; if (vnode.shapeFlag & 16) { if (disabled) { hydrateDisabledTeleport(node, vnode); hydrateAnchor(target, targetNode); if (!vnode.targetAnchor) prepareAnchor(target, vnode, createText, insert, parentNode(node) === target ? node : null); } else { vnode.anchor = nextSibling(node); hydrateAnchor(target, targetNode); if (!vnode.targetAnchor) prepareAnchor(target, vnode, createText, insert); hydrateChildren(targetNode && nextSibling(targetNode), vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized); } } updateCssVars(vnode, disabled); } else if (disabled) { if (vnode.shapeFlag & 16) { hydrateDisabledTeleport(node, vnode); vnode.targetStart = node; vnode.targetAnchor = nextSibling(node); } } return vnode.anchor && nextSibling(vnode.anchor); } const Teleport = TeleportImpl; function updateCssVars(vnode, isDisabled) { const ctx = vnode.ctx; if (ctx && ctx.ut) { let node, anchor; if (isDisabled) { node = vnode.el; anchor = vnode.anchor; } else { node = vnode.targetStart; anchor = vnode.targetAnchor; } while (node && node !== anchor) { if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid); node = node.nextSibling; } ctx.ut(); } } function prepareAnchor(target, vnode, createText, insert, anchor = null) { const targetStart = vnode.targetStart = createText(""); const targetAnchor = vnode.targetAnchor = createText(""); targetStart[TeleportEndKey] = targetAnchor; if (target) { insert(targetStart, target, anchor); insert(targetAnchor, target, anchor); } return targetAnchor; } //#endregion //#region packages/runtime-core/src/components/BaseTransition.ts const leaveCbKey = Symbol("_leaveCb"); const enterCbKey = Symbol("_enterCb"); function useTransitionState() { const state = { isMounted: false, isLeaving: false, isUnmounting: false, leavingNodes: /* @__PURE__ */ new Map() }; onMounted(() => { state.isMounted = true; }); onBeforeUnmount(() => { state.isUnmounting = true; }); return state; } const TransitionHookValidator = [Function, Array]; const BaseTransitionPropsValidators = { mode: String, appear: Boolean, persisted: Boolean, onBeforeEnter: TransitionHookValidator, onEnter: TransitionHookValidator, onAfterEnter: TransitionHookValidator, onEnterCancelled: TransitionHookValidator, onBeforeLeave: TransitionHookValidator, onLeave: TransitionHookValidator, onAfterLeave: TransitionHookValidator, onLeaveCancelled: TransitionHookValidator, onBeforeAppear: TransitionHookValidator, onAppear: TransitionHookValidator, onAfterAppear: TransitionHookValidator, onAppearCancelled: TransitionHookValidator }; let isTransitionEnabled$1 = false; function withTransitionEnabled(value) { isTransitionEnabled$1 = true; return value; } function isEmptyTransitionChild(vnode, instance) { if (vnode.type === Comment$1) return true; if (vnode.type === Fragment) { const child = (0, _vue_shared.isArray)(vnode.children) && filterSingleRoot(vnode.children, false); return !child || isEmptyTransitionChild(child, instance); } if (isVaporInteropEnabled && (vnode.type === VaporSlot || isVaporComponent$1(vnode.type))) return !getVaporInterface(instance, vnode).hasTransitionChild(vnode); return !!vnode.component && isEmptyTransitionChild(vnode.component.subTree, instance); } const BaseTransitionImpl = { name: `BaseTransition`, props: BaseTransitionPropsValidators, setup(props, { slots }) { const instance = getCurrentInstance(); const state = useTransitionState(); let resumeAfterLeave; return () => { const child = resolveTransitionChild(slots.default && slots.default(), !!instance.subTree); if (!child) return; const rawProps = /* @__PURE__ */ toRaw(props); const { mode } = rawProps; checkTransitionMode(mode); return prepareTransitionSwitch(instance.subTree, child, rawProps, state, instance, mode === "out-in" ? resumeAfterLeave || (resumeAfterLeave = () => { if (!(instance.effect.flags & 1024)) instance.update(); }) : _vue_shared.NOOP); }; } }; function findNonCommentChild(children) { let child = children[0]; if (children.length > 1) { let hasFound = false; for (const c of children) if (c.type !== Comment$1) { if (hasFound) { warn$1(" can only be used on a single element or component. Use for lists."); break; } child = c; hasFound = true; } } return child; } const BaseTransition = /*@__PURE__*/ withTransitionEnabled(BaseTransitionImpl); function getLeavingNodesForType$1(state, vnode) { const { leavingNodes } = state; let leavingVNodesCache = leavingNodes.get(vnode.type); if (!leavingVNodesCache) { leavingVNodesCache = Object.create(null); leavingNodes.set(vnode.type, leavingVNodesCache); } return leavingVNodesCache; } function resolveTransitionHooks(vnode, props, state, instance, postClone) { const key = String(vnode.key); const leavingVNodesCache = getLeavingNodesForType$1(state, vnode); const hooks = baseResolveTransitionHooks({ isLeaving: () => leavingVNodesCache[key] === vnode, setLeavingNodeCache: () => { leavingVNodesCache[key] = vnode; }, unsetLeavingNodeCache: () => { if (leavingVNodesCache[key] === vnode) delete leavingVNodesCache[key]; }, earlyRemove: () => { const leavingVNode = leavingVNodesCache[key]; if (leavingVNode && isSameVNodeType(vnode, leavingVNode)) { let leavingCb = leavingVNode.el[leaveCbKey]; if (!leavingCb) { const leavingRoot = getTransitionRoot(leavingVNode); leavingCb = leavingRoot && leavingRoot.el[leaveCbKey]; } if (leavingCb) leavingCb(); } }, cloneHooks: (vnode) => { const hooks = resolveTransitionHooks(vnode, props, state, instance, postClone); if (postClone) postClone(hooks); return hooks; } }, props, state, instance); if (isVaporInteropEnabled && vnode.type === VaporSlot) (0, _vue_shared.extend)(hooks, { __vapor: true, props, state, instance }); return hooks; } function baseResolveTransitionHooks(context, props, state, instance) { const { isLeaving, setLeavingNodeCache, unsetLeavingNodeCache, earlyRemove, cloneHooks } = context; const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props; const callHook = (hook, args) => { hook && callWithAsyncErrorHandling(hook, instance, 9, args); }; const callAsyncHook = (hook, args) => { const done = args[1]; callHook(hook, args); if ((0, _vue_shared.isArray)(hook)) { if (hook.every((hook) => hook.length <= 1)) done(); } else if (hook.length <= 1) done(); }; const hooks = { mode, persisted, beforeEnter(el) { let hook = onBeforeEnter; if (!state.isMounted) { if (appear) hook = onBeforeAppear || onBeforeEnter; else return; } if (el[leaveCbKey]) el[leaveCbKey](true); earlyRemove(); callHook(hook, [el]); }, enter(el) { if (!isHmrUpdating && isLeaving()) return; let hook = onEnter; let afterHook = onAfterEnter; let cancelHook = onEnterCancelled; if (!state.isMounted) { if (appear) { hook = onAppear || onEnter; afterHook = onAfterAppear || onAfterEnter; cancelHook = onAppearCancelled || onEnterCancelled; } else return; } let called = false; el[enterCbKey] = (cancelled) => { if (called) return; called = true; if (cancelled) callHook(cancelHook, [el]); else callHook(afterHook, [el]); if (hooks.delayedLeave) hooks.delayedLeave(); el[enterCbKey] = void 0; }; const done = el[enterCbKey].bind(null, false); if (hook) callAsyncHook(hook, [el, done]); else done(); }, leave(el, remove) { if (el[enterCbKey]) el[enterCbKey](true); if (state.isUnmounting) return remove(); callHook(onBeforeLeave, [el]); let called = false; el[leaveCbKey] = (cancelled) => { if (called) return; called = true; remove(); if (cancelled) callHook(onLeaveCancelled, [el]); else callHook(onAfterLeave, [el]); el[leaveCbKey] = void 0; unsetLeavingNodeCache(el); }; setLeavingNodeCache(el); const done = el[leaveCbKey].bind(null, false); if (onLeave) callAsyncHook(onLeave, [el, done]); else done(); }, clone(node) { return cloneHooks ? cloneHooks(node) : hooks; } }; return hooks; } function emptyPlaceholder(vnode) { if (isKeepAlive(vnode)) { vnode = cloneVNode(vnode); vnode.children = null; return vnode; } } function getInnerChild$1(vnode) { if (!isKeepAlive(vnode)) { if (isTeleport(vnode.type) && vnode.children) return findNonCommentChild(vnode.children); return vnode; } if (vnode.component) return vnode.component.subTree; const { shapeFlag, children } = vnode; if (children) { if (shapeFlag & 16) return children[0]; if (shapeFlag & 32 && (0, _vue_shared.isFunction)(children.default)) return children.default(); } } function resolveTransitionChild(children, renderEmpty = false) { const branches = children && getTransitionRawChildren(children, true); return branches && branches.length ? findNonCommentChild(branches) : renderEmpty ? createCommentVNode() : void 0; } /** * @internal */ function prepareTransitionSwitch(previous, next, props, state, instance, resumeAfterLeave, delayedLeaveSource) { if (state.isLeaving) return emptyPlaceholder(next); const nextInner = getInnerChild$1(next); if (!nextInner) return emptyPlaceholder(next); let enterHooks = resolveTransitionHooks(nextInner, props, state, instance, (hooks) => { if (delayedLeaveSource) forwardDelayedLeave(hooks, delayedLeaveSource); enterHooks = hooks; }); if (delayedLeaveSource) forwardDelayedLeave(enterHooks, delayedLeaveSource); if (nextInner.type !== Comment$1) setTransitionHooks(nextInner, enterHooks); const mode = props.mode; const previousInner = previous && getInnerChild$1(previous); if (previous && previousInner && !isSameVNodeType(previousInner, nextInner) && !isEmptyTransitionChild(previousInner, instance)) { const leavingHooks = prepareLeavingTransitionHooks(previousInner, props, state, instance); if (nextInner.type !== Comment$1 && (mode === "out-in" || mode === "in-out") && applyTransitionModeSwitch(previousInner, leavingHooks, mode === "in-out" ? () => enterHooks : void 0, props, state, resumeAfterLeave)) return emptyPlaceholder(next); } return next; } function forwardDelayedLeave(hooks, source) { const delayedLeave = source && source.delayedLeave; if (!delayedLeave) return; hooks.delayedLeave = () => { if (source.delayedLeave === delayedLeave) delayedLeave(); delete hooks.delayedLeave; }; } /** * Prepares an outgoing VNode when the incoming branch belongs to another * renderer. Returns true under out-in, where that branch is a comment * child's: no mode holds for it, the leave runs on its own and * `resumeAfterLeave` follows it. * * @internal */ function prepareTransitionLeave(previous, enterHooks, props, state, instance, resumeAfterLeave) { const previousInner = getInnerChild$1(previous); if (!previousInner || isEmptyTransitionChild(previousInner, instance)) return false; const leavingHooks = prepareLeavingTransitionHooks(previousInner, props, state, instance); if (props.mode === "out-in") { leavingHooks.afterLeave = resumeAfterLeave; return true; } return applyTransitionModeSwitch(previousInner, leavingHooks, enterHooks ? () => enterHooks : void 0, props, state, resumeAfterLeave); } function prepareLeavingTransitionHooks(previousInner, props, state, instance) { return setTransitionHooks(previousInner, resolveTransitionHooks(previousInner, props, state, instance)); } function applyTransitionModeSwitch(leavingVNode, leavingHooks, getEnterHooks, props, state, resumeAfterLeave) { if (props.mode === "out-in") { state.isLeaving = true; leavingHooks.afterLeave = () => { state.isLeaving = false; resumeAfterLeave(); delete leavingHooks.afterLeave; }; return true; } else if (props.mode === "in-out" && getEnterHooks) { let delayedLeavingVNode = leavingVNode; leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => { const enterHooks = getEnterHooks(); if (!enterHooks) { delayedLeave(); return; } const vnode = delayedLeavingVNode; const leavingVNodesCache = getLeavingNodesForType$1(state, vnode); leavingVNodesCache[String(vnode.key)] = vnode; el[leaveCbKey] = () => { earlyRemove(); el[leaveCbKey] = void 0; delete enterHooks.delayedLeave; delayedLeavingVNode = void 0; }; enterHooks.delayedLeave = () => { delayedLeave(); delete enterHooks.delayedLeave; delayedLeavingVNode = void 0; }; }; } return false; } function setTransitionHooks(vnode, hooks) { if (vnode.shapeFlag & 6 && vnode.component) { vnode.transition = hooks; if (isVaporInteropEnabled && isVaporComponent$1(vnode.type)) getVaporInterface(vnode.component, vnode).setTransitionHooks(vnode.component, hooks); else { const subTree = vnode.component.subTree; return setTransitionHooks(isTeleport(subTree.type) ? getInnerChild$1(subTree) || subTree : subTree, hooks); } } else if (vnode.shapeFlag & 128) { const contentHooks = vnode.ssContent.transition = hooks.clone(vnode.ssContent); const fallbackHooks = vnode.ssFallback.transition = hooks.clone(vnode.ssFallback); return vnode.suspense && vnode.suspense.activeBranch === vnode.ssFallback ? fallbackHooks : contentHooks; } else { vnode.transition = hooks; if (vnode.type === Fragment && (0, _vue_shared.isArray)(vnode.children)) { const child = filterSingleRoot(vnode.children, false); if (child) setTransitionHooks(child, hooks); } } return hooks; } function getTransitionRawChildren(children, keepComment = false, parentKey) { let ret = []; let keyedFragmentCount = 0; for (let i = 0; i < children.length; i++) { let child = children[i]; const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i); if (child.type === Fragment) { if (child.patchFlag & 128) keyedFragmentCount++; ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key)); } else if (keepComment || child.type !== Comment$1) ret.push(key != null ? cloneVNode(child, { key }) : child); } if (keyedFragmentCount > 1) for (let i = 0; i < ret.length; i++) ret[i].patchFlag = -2; return ret; } /** * dev-only */ function checkTransitionMode(mode) { if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") warn$1(`invalid mode: ${mode}`); } function getTransitionRoot(vnode) { if (vnode.component && (!isVaporInteropEnabled || !isVaporComponent$1(vnode.type))) return getTransitionRoot(vnode.component.subTree); if (vnode.type === Fragment) { const child = (0, _vue_shared.isArray)(vnode.children) && filterSingleRoot(vnode.children, false); return child ? getTransitionRoot(child) : void 0; } if (vnode.type !== Comment$1) return vnode; } //#endregion //#region packages/runtime-core/src/apiDefineComponent.ts /*@__NO_SIDE_EFFECTS__*/ function defineComponent(options, extraOptions) { return (0, _vue_shared.isFunction)(options) ? /*@__PURE__*/ (() => (0, _vue_shared.extend)({ name: options.name }, extraOptions, { setup: options }))() : options; } //#endregion //#region packages/runtime-core/src/helpers/useId.ts function useId() { const i = getCurrentGenericInstance(); if (i) return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++; else warn$1("useId() is called when there is no active component instance to be associated with."); return ""; } /** * There are 3 types of async boundaries: * - async components * - components with async setup() * - components with serverPrefetch */ function markAsyncBoundary(instance) { instance.ids = [ instance.ids[0] + instance.ids[2]++ + "-", 0, 0 ]; } //#endregion //#region packages/runtime-core/src/helpers/useTemplateRef.ts const knownTemplateRefs = /* @__PURE__ */ new WeakSet(); function useTemplateRef(key) { const i = getCurrentGenericInstance(); const r = /* @__PURE__ */ shallowRef(null); if (i) { const refs = i.refs === _vue_shared.EMPTY_OBJ ? i.refs = {} : i.refs; if (isTemplateRefKey(refs, key)) warn$1(`useTemplateRef('${key}') already exists.`); else Object.defineProperty(refs, key, { enumerable: true, get: () => r.value, set: (val) => r.value = val }); } else warn$1("useTemplateRef() is called when there is no active component instance to be associated with."); const ret = /* @__PURE__ */ readonly(r); knownTemplateRefs.add(ret); return ret; } function isTemplateRefKey(refs, key) { let desc; return !!((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable); } //#endregion //#region packages/runtime-core/src/rendererTemplateRef.ts const pendingSetRefMap = /* @__PURE__ */ new WeakMap(); /** * Function for handling a template ref */ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) { if ((0, _vue_shared.isArray)(rawRef)) { rawRef.forEach((r, i) => setRef(r, oldRawRef && ((0, _vue_shared.isArray)(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount)); return; } if (isAsyncWrapper(vnode) && !isUnmount) { if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree); return; } const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el; const value = isUnmount ? null : refValue; const { i: owner, r: ref } = rawRef; if (!owner) { warn$1("Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function."); return; } const oldRef = oldRawRef && oldRawRef.r; const refs = owner.refs === _vue_shared.EMPTY_OBJ ? owner.refs = {} : owner.refs; const setupState = owner.setupState; const canSetSetupRef = createCanSetSetupRefChecker(setupState, refs); const canSetRef = (ref, key) => { if (knownTemplateRefs.has(ref)) return false; if (key && isTemplateRefKey(refs, key)) return false; return true; }; if (oldRef != null && oldRef !== ref) { invalidatePendingSetRef(oldRawRef); if ((0, _vue_shared.isString)(oldRef)) { refs[oldRef] = null; if (canSetSetupRef(oldRef)) setupState[oldRef] = null; } else if (/* @__PURE__ */ isRef(oldRef)) { const oldRawRefAtom = oldRawRef; if (canSetRef(oldRef, oldRawRefAtom.k)) oldRef.value = null; if (oldRawRefAtom.k) refs[oldRawRefAtom.k] = null; } } if ((0, _vue_shared.isFunction)(ref)) callWithErrorHandling(ref, owner, 12, [value, refs]); else { const _isString = (0, _vue_shared.isString)(ref); const _isRef = /* @__PURE__ */ isRef(ref); if (_isString || _isRef) { const doSet = () => { if (rawRef.f) { const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : canSetRef(ref) || !rawRef.k ? ref.value : refs[rawRef.k]; if (isUnmount) (0, _vue_shared.isArray)(existing) && (0, _vue_shared.remove)(existing, refValue); else if (!(0, _vue_shared.isArray)(existing)) { if (_isString) { refs[ref] = [refValue]; if (canSetSetupRef(ref)) setupState[ref] = refs[ref]; } else { const newVal = [refValue]; if (canSetRef(ref, rawRef.k)) ref.value = newVal; if (rawRef.k) refs[rawRef.k] = newVal; } } else if (!existing.includes(refValue)) existing.push(refValue); } else if (_isString) { refs[ref] = value; if (canSetSetupRef(ref)) setupState[ref] = value; } else if (_isRef) { if (canSetRef(ref, rawRef.k)) ref.value = value; if (rawRef.k) refs[rawRef.k] = value; } else warn$1("Invalid template ref type:", ref, `(${typeof ref})`); }; if (value) { const job = () => { doSet(); pendingSetRefMap.delete(rawRef); }; pendingSetRefMap.set(rawRef, job); queuePostRenderEffect(job, -1, parentSuspense); } else { invalidatePendingSetRef(rawRef); doSet(); } } else warn$1("Invalid template ref type:", ref, `(${typeof ref})`); } } function createCanSetSetupRefChecker(setupState, refs) { const rawSetupState = /* @__PURE__ */ toRaw(setupState); return setupState === void 0 || setupState === _vue_shared.EMPTY_OBJ ? _vue_shared.NO : (key) => { if ((0, _vue_shared.hasOwn)(rawSetupState, key) && !/* @__PURE__ */ isRef(rawSetupState[key])) warn$1(`Template ref "${key}" used on a non-ref value. It will not work in the production build.`); if (knownTemplateRefs.has(rawSetupState[key])) return false; if (isTemplateRefKey(refs, key)) return false; return (0, _vue_shared.hasOwn)(rawSetupState, key); }; } function invalidatePendingSetRef(rawRef) { const pendingSetRef = pendingSetRefMap.get(rawRef); if (pendingSetRef) { pendingSetRef.flags |= 4; pendingSetRefMap.delete(rawRef); } } //#endregion //#region packages/runtime-core/src/hydration.ts let isHydratingEnabled = false; function setIsHydratingEnabled(value) { isHydratingEnabled = value; } /** * VDOM hydration state. * Also used by vapor interop plugin for tree-shaking: * In non-hydration builds, this is never set to true, so the logic in * vaporInteropImpl's hydrate/hydrateSlot can be tree-shaken. */ let isHydrating = false; let hasLoggedMismatchError = false; const logMismatchError = () => { if (hasLoggedMismatchError) return; console.error("Hydration completed but contains mismatches."); hasLoggedMismatchError = true; }; const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject"; const isMathMLContainer = (container) => { if (!container.namespaceURI.includes("MathML")) return false; if (container.tagName !== "annotation-xml") return true; const encoding = container.getAttribute("encoding"); return !encoding || !encoding.includes("html"); }; /** * Resolve the element namespace a container's children should be created in. * The live DOM is the source of truth, so this also covers containers that are * only known at runtime (interop boundaries, teleport targets). * @internal */ const getContainerType = (container) => { if (container.nodeType !== 1) return void 0; if (isSVGContainer(container)) return "svg"; if (isMathMLContainer(container)) return "mathml"; }; const isComment$1 = (node) => node.nodeType === 8; /** The data of a comment opening a range a hydration steps over as one. */ const isRangeStart$1 = (data) => data === "[" || data === "(" || (0, _vue_shared.isVaporBranchStart)(data); function createHydrationFunctions(rendererInternals) { const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals; const hydrate = (vnode, container) => { if (!isHydratingEnabled) return; if (!container.hasChildNodes()) { warn$1("Attempting to hydrate existing markup but container is empty. Performing full mount instead."); patch(null, vnode, container); flushPostFlushCbs(); container._vnode = vnode; return; } isHydrating = true; hydrateNode(container.firstChild, vnode, null, null, null); isHydrating = false; flushPostFlushCbs(); container._vnode = vnode; }; const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => { optimized = optimized || !!vnode.dynamicChildren; const isFragmentStart = isComment$1(node) && (node.data === "[" || node.data === "(" || isVaporInteropEnabled && (0, _vue_shared.isVaporBranchStart)(node.data)); const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart); const { type, ref, shapeFlag, patchFlag } = vnode; let domType = node.nodeType; vnode.el = node; (0, _vue_shared.def)(node, "__vnode", vnode, true); (0, _vue_shared.def)(node, "__vueParentComponent", parentComponent, true); if (patchFlag === -2) { optimized = false; vnode.dynamicChildren = null; } let nextNode = null; switch (type) { case Text$1: if (domType !== 3) { if (vnode.children === "") { insert(vnode.el = createText(""), parentNode(node), node); nextNode = node; } else nextNode = onMismatch(); } else { if (node.data !== vnode.children) { warn$1(`Hydration text mismatch in`, node.parentNode, `\n - rendered on server: ${JSON.stringify(node.data)}\n - expected on client: ${JSON.stringify(vnode.children)}`); logMismatchError(); node.data = vnode.children; } nextNode = nextSibling(node); } break; case Comment$1: if (isTemplateNode(node)) { nextNode = nextSibling(node); replaceNode(vnode.el = node.content.firstChild, node, parentComponent); } else if (domType !== 8 || isFragmentStart) nextNode = onMismatch(); else nextNode = nextSibling(node); break; case Static: if (isFragmentStart) { node = nextSibling(node); domType = node.nodeType; } if (domType === 1 || domType === 3) { nextNode = node; const needToAdoptContent = !vnode.children.length; for (let i = 0; i < vnode.staticCount; i++) { if (needToAdoptContent) vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data; if (i === vnode.staticCount - 1) vnode.anchor = nextNode; nextNode = nextSibling(nextNode); } return isFragmentStart ? nextSibling(nextNode) : nextNode; } else onMismatch(); break; case Fragment: if (!isFragmentStart) nextNode = onMismatch(); else nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized); break; case VaporSlot: if (isVaporInteropEnabled) nextNode = getVaporInterface(parentComponent, vnode).hydrateSlot(vnode, node, parentComponent, parentSuspense, slotScopeIds); break; default: if (shapeFlag & 1) { if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) nextNode = onMismatch(); else nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized); } else if (shapeFlag & 6) { vnode.slotScopeIds = slotScopeIds; const container = parentNode(node); if (isFragmentStart) nextNode = locateClosingAnchor(node); else if (isComment$1(node) && node.data === "teleport start") nextNode = locateClosingAnchor(node, node.data, "teleport end"); else nextNode = nextSibling(node); if (vnode.type.__vapor) getVaporInterface(parentComponent, vnode).hydrate(vnode, node, container, nextNode, parentComponent, parentSuspense); else { mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized); const component = vnode.component; if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) { let subTree; if (isFragmentStart) { subTree = createVNode(Static); subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild; } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment$1 : "div"); subTree.el = node; component.subTree = subTree; } } } else if (shapeFlag & 64) { if (domType !== 8) nextNode = onMismatch(); else nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren); } else if (shapeFlag & 128) nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, getContainerType(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode); else warn$1("Invalid HostVNode type:", type, `(${typeof type})`); } if (ref != null) setRef(ref, null, parentSuspense, vnode); return nextNode; }; const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => { optimized = optimized || !!vnode.dynamicChildren; const { type, dynamicProps, props, patchFlag, shapeFlag, dirs, transition } = vnode; const forcePatch = type === "input" || type === "option"; { if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "created"); let needCallTransitionHooks = false; if (isTemplateNode(el)) { needCallTransitionHooks = needTransition(null, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear; const content = el.content.firstChild; if (needCallTransitionHooks) { const cls = content.getAttribute("class"); if (cls) content.$cls = cls; transition.beforeEnter(content); } replaceNode(content, el, parentComponent); vnode.el = el = content; } if (shapeFlag & 16 && !(props && (props.innerHTML || props.textContent))) { let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized); if (next && !isMismatchAllowed(el, 1)) { warn$1(`Hydration children mismatch on`, el, `\nServer rendered element contains more child nodes than client vdom.`); logMismatchError(); } while (next) { const cur = next; next = next.nextSibling; remove(cur); } } else if (shapeFlag & 8) { let clientText = vnode.children; if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) clientText = clientText.slice(1); const { textContent } = el; if (textContent !== clientText && textContent !== clientText.replace(/\r\n|\r/g, "\n")) { if (!isMismatchAllowed(el, 0)) { warn$1(`Hydration text content mismatch on`, el, `\n - rendered on server: ${textContent}\n - expected on client: ${clientText}`); logMismatchError(); } el.textContent = vnode.children; } } if (props) { const isCustomElement = el.tagName.includes("-"); const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0; for (const key in props) { if (!(dirs && dirs.some((d) => d.dir.created)) && propHasMismatch(el, key, props[key], vnode, parentComponent)) logMismatchError(); if (forcePatch && (key.endsWith("value") || key === "indeterminate") || (0, _vue_shared.isOn)(key) && !(0, _vue_shared.isReservedProp)(key) || key[0] === "." || isCustomElement && !(0, _vue_shared.isReservedProp)(key) || dynamicProps && dynamicProps.includes(key)) { if (isUnchangedResourceProp(el, key, props[key])) continue; patchProp(el, key, null, props[key], namespace, parentComponent); } } } let vnodeHooks; if (vnodeHooks = props && props.onVnodeBeforeMount) invokeVNodeHook(vnodeHooks, parentComponent, vnode); if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "beforeMount"); if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) queueEffectWithSuspense(() => { vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode); needCallTransitionHooks && transition.enter(el); dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted"); }, void 0, parentSuspense); } return el.nextSibling; }; const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => { optimized = optimized || !!parentVNode.dynamicChildren; const children = parentVNode.children; const l = children.length; let hasCheckedMismatch = false; for (let i = 0; i < l; i++) { const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]); const isText = vnode.type === Text$1; if (node) { if (isText && !optimized) { if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text$1) { insert(createText(node.data.slice(vnode.children.length)), container, nextSibling(node)); node.data = vnode.children; } } node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized); } else if (isText && !vnode.children) insert(vnode.el = createText(""), container); else { if (!hasCheckedMismatch) { hasCheckedMismatch = true; if (!isMismatchAllowed(container, 1)) { warn$1(`Hydration children mismatch on`, container, `\nServer rendered element contains fewer child nodes than client vdom.`); logMismatchError(); } } patch(null, vnode, container, null, parentComponent, parentSuspense, getContainerType(container), slotScopeIds); } } return node; }; const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => { const { slotScopeIds: fragmentSlotScopeIds } = vnode; if (fragmentSlotScopeIds) slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds; const container = parentNode(node); const first = nextSibling(node); const next = isVaporInteropEnabled && vnode.vo && node.data === "(" ? getVaporInterface(parentComponent, vnode).hydrateSlotOutlet(vnode, node, parentComponent, parentSuspense, slotScopeIds) : hydrateChildren(first, vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized); if (next && isComment$1(next) && next.data === (node.data === "(" ? ")" : "]")) return nextSibling(vnode.anchor = next); else { logMismatchError(); insert(vnode.anchor = createComment(`]`), container, next); return next; } }; const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => { if (!isNodeMismatchAllowed(node, vnode)) { warn$1(`Hydration node mismatch:\n- rendered on server:`, node, node.nodeType === 3 ? `(text)` : isComment$1(node) && isRangeStart$1(node.data) ? `(start of fragment)` : ``, `\n- expected on client:`, vnode.type); logMismatchError(); } vnode.el = null; if (isFragment) { const end = locateClosingAnchor(node); while (true) { const next = nextSibling(node); if (next && next !== end) remove(next); else break; } } const next = nextSibling(node); const container = parentNode(node); remove(node); patch(null, vnode, container, next, parentComponent, parentSuspense, getContainerType(container), slotScopeIds); if (parentComponent && parentComponent.vnode) { parentComponent.vnode.el = vnode.el; updateHOCHostEl(parentComponent, vnode.el); } return next; }; const locateClosingAnchor = (node, open = node && isComment$1(node) && node.data === "(" ? "(" : "[", close = open === "(" ? ")" : "]") => { let match = 0; while (node) { node = nextSibling(node); if (node && isComment$1(node)) { if (node.data === open || isVaporInteropEnabled && open === "[" && (0, _vue_shared.isVaporBranchStart)(node.data)) match++; if (node.data === close) { if (match === 0) return nextSibling(node); else match--; } } } return node; }; const replaceNode = (newNode, oldNode, parentComponent) => { const parentNode = oldNode.parentNode; if (parentNode) parentNode.replaceChild(newNode, oldNode); let parent = parentComponent; while (parent) { if (parent.vnode && parent.vnode.el === oldNode) parent.vnode.el = parent.subTree.el = newNode; parent = parent.parent; } }; return [hydrate, hydrateNode]; } const isTemplateNode = (node) => { return node.nodeType === 1 && node.tagName === "TEMPLATE"; }; const resourceProps = /*@__PURE__*/ new Set([ "src", "srcset", "href", "poster" ]); function isUnchangedResourceProp(el, key, clientValue) { if (!resourceProps.has(key)) return false; return el.getAttribute(key) === (clientValue == null ? null : `${clientValue}`); } /** * Dev only */ function propHasMismatch(el, key, clientValue, vnode, instance) { let mismatchType; let mismatchKey; let actual; let expected; if (key === "class") { if (el.$cls) { actual = el.$cls; delete el.$cls; } else actual = el.getAttribute("class"); expected = (0, _vue_shared.normalizeClass)(clientValue); if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) { mismatchType = 2; mismatchKey = `class`; } } else if (key === "style") { actual = el.getAttribute("style") || ""; expected = (0, _dcloudio_uni_shared.normalizeRpx)((0, _vue_shared.isString)(clientValue) ? clientValue : (0, _vue_shared.stringifyStyle)((0, _vue_shared.normalizeStyle)(clientValue))); const actualMap = toStyleMap(actual); const expectedMap = toStyleMap(expected); if (vnode.dirs) { for (const { dir, value } of vnode.dirs) if (dir.name === "show" && !value) expectedMap.set("display", "none"); } if (instance) resolveCssVars(instance, vnode, expectedMap); if (!isMapEqual(actualMap, expectedMap)) { mismatchType = 3; mismatchKey = "style"; } } else if (isValidHtmlOrSvgAttribute(el, key)) { ({actual, expected} = getAttributeMismatch(el, key, clientValue)); if (actual !== expected) { mismatchType = 4; mismatchKey = key; } } return warnPropMismatch(el, mismatchKey, mismatchType, actual, expected); } function getAttributeMismatch(el, key, clientValue) { let actual; let expected; if (key === "hidden") { actual = normalizeHiddenValue(el.getAttribute(key)); expected = normalizeHiddenValue(clientValue); } else if ((0, _vue_shared.isBooleanAttr)(key)) { actual = el.hasAttribute(key); expected = (0, _vue_shared.includeBooleanAttr)(clientValue); } else if (clientValue == null) { actual = el.hasAttribute(key); expected = false; } else { if (el.hasAttribute(key)) actual = el.getAttribute(key); else if (key === "value" && el.tagName === "TEXTAREA") actual = el.value; else actual = false; expected = (0, _vue_shared.isRenderableAttrValue)(clientValue) ? String(clientValue) : false; } return { actual, expected }; } function isValidHtmlOrSvgAttribute(el, key) { return el instanceof SVGElement && (0, _vue_shared.isKnownSvgAttr)(key) || el instanceof HTMLElement && ((0, _vue_shared.isBooleanAttr)(key) || (0, _vue_shared.isKnownHtmlAttr)(key)); } function warnPropMismatch(el, mismatchKey, mismatchType, actual, expected) { if (mismatchType != null && !isMismatchAllowed(el, mismatchType)) { const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`; warn$1(`Hydration ${MismatchTypeString[mismatchType]} mismatch on`, el, `\n - rendered on server: ${format(actual)}\n - expected on client: ${format(expected)}\n Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.\n You should fix the source of the mismatch.`); return true; } return false; } function normalizeHiddenValue(value) { if (!(0, _vue_shared.isRenderableAttrValue)(value)) return false; if ((0, _vue_shared.isString)(value)) return value.toLowerCase() === "until-found" ? "until-found" : ""; return (0, _vue_shared.includeBooleanAttr)(value) ? "" : false; } function toClassSet(str) { return new Set(str.trim().split(/\s+/)); } function isSetEqual(a, b) { if (a.size !== b.size) return false; for (const s of a) if (!b.has(s)) return false; return true; } function toStyleMap(str) { const styleMap = /* @__PURE__ */ new Map(); for (const item of str.split(";")) { let [key, value] = item.split(":"); key = key.trim(); value = value && value.trim(); if (key && value) styleMap.set(key, value); } return styleMap; } function isMapEqual(a, b) { if (a.size !== b.size) return false; for (const [key, value] of a) if (value !== b.get(key)) return false; return true; } function resolveCssVars(instance, vnode, expectedMap) { const root = instance.subTree; if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) { const cssVars = instance.getCssVars(); for (const key in cssVars) { const value = (0, _dcloudio_uni_shared.normalizeRpx)((0, _vue_shared.normalizeCssVarValue)(cssVars[key])); expectedMap.set(`--${(0, _vue_shared.getEscapedCssVarName)(key, false)}`, value); } } if (vnode === root && instance.parent) resolveCssVars(instance.parent, instance.vnode, expectedMap); } const allowMismatchAttr = "data-allow-mismatch"; const MismatchTypes = { "TEXT": 0, "0": "TEXT", "CHILDREN": 1, "1": "CHILDREN", "CLASS": 2, "2": "CLASS", "STYLE": 3, "3": "STYLE", "ATTRIBUTE": 4, "4": "ATTRIBUTE" }; const MismatchTypeString = { [0]: "text", [1]: "children", [2]: "class", [3]: "style", [4]: "attribute" }; function isMismatchAllowed(el, allowedType) { if (allowedType === 0 || allowedType === 1) while (el && !el.hasAttribute(allowMismatchAttr)) el = el.parentElement; return isMismatchAllowedByAttr(el && el.getAttribute(allowMismatchAttr), allowedType); } function isMismatchAllowedByAttr(allowedAttr, allowedType) { if (allowedAttr == null) return false; else if (allowedAttr === "") return true; else { const list = allowedAttr.split(","); if (allowedType === 0 && list.includes("children")) return true; return list.includes(MismatchTypeString[allowedType]); } } function isNodeMismatchAllowed(node, vnode) { return isMismatchAllowed(node.parentElement, 1) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode); } function isMismatchAllowedByNode(node) { return node.nodeType === 1 && isMismatchAllowedByAttr(node.getAttribute(allowMismatchAttr), 1); } function isMismatchAllowedByVNode({ props }) { const allowedAttr = props && props[allowMismatchAttr]; return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1); } //#endregion //#region packages/runtime-core/src/hydrationStrategies.ts let requestIdleCallback; let cancelIdleCallback; function ensureIdleCallbacks() { if (!requestIdleCallback) { const g = (0, _vue_shared.getGlobalThis)(); requestIdleCallback = g.requestIdleCallback || ((cb) => setTimeout(cb, 1)); cancelIdleCallback = g.cancelIdleCallback || ((id) => clearTimeout(id)); } } const hydrateOnIdle = (timeout = 1e4) => (hydrate) => { ensureIdleCallbacks(); const id = requestIdleCallback(hydrate, { timeout }); return () => cancelIdleCallback(id); }; function elementIsVisibleInViewport(el) { const { top, left, bottom, right } = el.getBoundingClientRect(); const { innerHeight, innerWidth } = window; return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth); } const hydrateOnVisible = (opts) => (hydrate, forEach) => { const ob = new IntersectionObserver((entries) => { for (const e of entries) { if (!e.isIntersecting) continue; ob.disconnect(); hydrate(); break; } }, opts); const observe = (el) => { if (elementIsVisibleInViewport(el)) { hydrate(); ob.disconnect(); return false; } if (getComputedStyle(el).display === "contents") { for (let i = 0; i < el.children.length; i++) if (observe(el.children[i]) === false) return false; } ob.observe(el); }; forEach((el) => { if (!(el instanceof Element)) return; return observe(el); }); return () => ob.disconnect(); }; const hydrateOnMediaQuery = (query) => (hydrate) => { if (query) { const mql = matchMedia(query); if (mql.matches) hydrate(); else { mql.addEventListener("change", hydrate, { once: true }); return () => mql.removeEventListener("change", hydrate); } } }; const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => { if ((0, _vue_shared.isString)(interactions)) interactions = [interactions]; let hasHydrated = false; const doHydrate = (e) => { if (!hasHydrated) { hasHydrated = true; teardown(); hydrate(); if (!(`$evt${e.type}` in e.target)) e.target.dispatchEvent(new e.constructor(e.type, e)); } }; const teardown = () => { forEach((el) => { for (const i of interactions) el.removeEventListener(i, doHydrate); }); }; forEach((el) => { for (const i of interactions) el.addEventListener(i, doHydrate, { once: true }); }); return teardown; }; function forEachElement(node, cb) { if (isComment$1(node) && isRangeStart$1(node.data)) { const open = node.data; const close = open === "(" ? ")" : "]"; let depth = 1; let next = node.nextSibling; while (next) { if (next.nodeType === 1) { if (cb(next) === false) break; } else if (isComment$1(next)) { if (next.data === close) { if (--depth === 0) break; } else if (close === "]" ? next.data === "[" || (0, _vue_shared.isVaporBranchStart)(next.data) : next.data === open) depth++; } next = next.nextSibling; } } else cb(node); } //#endregion //#region packages/runtime-core/src/apiAsyncComponent.ts const isAsyncWrapper = (i) => !!i.type.__asyncLoader; /*@__NO_SIDE_EFFECTS__*/ function defineAsyncComponent(source) { const { load, getResolvedComp, setPendingRequest, source: { loadingComponent, errorComponent, delay, hydrate: hydrateStrategy, timeout, suspensible = true } } = createAsyncComponentContext(source); return /* @__PURE__ */ defineComponent({ name: "AsyncComponentWrapper", __asyncLoader: load, __asyncHydrate(el, instance, hydrate) { performAsyncHydrate(el, instance, hydrate, getResolvedComp, load, hydrateStrategy, true); }, get __asyncResolved() { return getResolvedComp(); }, setup() { const instance = currentInstance; markAsyncBoundary(instance); let resolvedComp = getResolvedComp(); if (resolvedComp) return () => createInnerComp$1(resolvedComp, instance); const onError = (err) => { setPendingRequest(null); handleError(err, instance, 13, !errorComponent); }; if (suspensible && instance.suspense || isInSSRComponentSetup) return load().then((comp) => { return () => createInnerComp$1(comp, instance); }).catch((err) => { onError(err); return () => errorComponent ? createVNode(errorComponent, { error: err }) : null; }); const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError, instance); load().then(() => { if (instance.isUnmounted) return; loaded.value = true; if (instance.parent && instance.parent.vnode && isKeepAlive(instance.parent.vnode)) instance.parent.update(); }).catch((err) => { if (instance.isUnmounted) { setPendingRequest(null); return; } onError(err); error.value = err; }); return () => { resolvedComp = getResolvedComp(); if (loaded.value && resolvedComp) return createInnerComp$1(resolvedComp, instance); else if (error.value && errorComponent) return createVNode(errorComponent, { error: error.value }); else if (loadingComponent && !delayed.value) return createInnerComp$1(loadingComponent, instance); }; } }); } function createInnerComp$1(comp, parent) { const { ref, props, children, ce } = parent.vnode; const vnode = createVNode(comp, props, children); vnode.ref = ref; vnode.ce = ce; delete parent.vnode.ce; return vnode; } function createAsyncComponentContext(source) { if ((0, _vue_shared.isFunction)(source)) source = { loader: source }; const { loader, onError: userOnError } = source; let pendingRequest = null; let resolvedComp; let retries = 0; const retry = () => { retries++; pendingRequest = null; return load(); }; const load = () => { let thisRequest; return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => { err = err instanceof Error ? err : new Error(String(err)); if (userOnError) return new Promise((resolve, reject) => { const userRetry = () => resolve(retry()); const userFail = () => reject(err); userOnError(err, userRetry, userFail, retries + 1); }); else throw err; }).then((comp) => { if (thisRequest !== pendingRequest && pendingRequest) return pendingRequest; if (!comp) warn$1("Async component loader resolved to undefined. If you are using retry(), make sure to return its return value."); if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) comp = comp.default; if (comp && !(0, _vue_shared.isObject)(comp) && !(0, _vue_shared.isFunction)(comp)) throw new Error(`Invalid async component load result: ${comp}`); resolvedComp = comp; return comp; })); }; return { load, source, getResolvedComp: () => resolvedComp, setPendingRequest: (request) => pendingRequest = request }; } const useAsyncComponentState = (delay = 200, timeout, onError, instance = currentInstance) => { const loaded = /* @__PURE__ */ ref(false); const error = /* @__PURE__ */ ref(); const delayed = /* @__PURE__ */ ref(!!delay); let timeoutTimer; let delayTimer; if (instance) onUnmounted(() => { if (timeoutTimer != null) clearTimeout(timeoutTimer); if (delayTimer != null) clearTimeout(delayTimer); }, instance); if (delay) delayTimer = setTimeout(() => { if (instance && instance.isUnmounted) return; delayed.value = false; }, delay); if (timeout != null) timeoutTimer = setTimeout(() => { if (instance && instance.isUnmounted) return; if (!loaded.value && !error.value) { const err = /* @__PURE__ */ new Error(`Async component timed out after ${timeout}ms.`); onError(err); error.value = err; } }, timeout); return { loaded, error, delayed }; }; /** * shared between core and vapor * @internal */ function performAsyncHydrate(el, instance, hydrate, getResolvedComp, load, hydrateStrategy, skipIfUpdated) { const wasConnected = el.isConnected; let patched = false; if (skipIfUpdated) (instance.bu || (instance.bu = [])).push(() => patched = true); const performHydrate = () => { if (patched) { { const resolvedComp = getResolvedComp(); warn$1(`Skipping lazy hydration for component '${getComponentName(resolvedComp) || resolvedComp.__file}': it was updated before lazy hydration performed.`); } return; } if (!el.parentNode || wasConnected && !el.isConnected) return; hydrate(); }; const doHydrate = hydrateStrategy ? () => { const teardown = hydrateStrategy(performHydrate, (cb) => forEachElement(el, cb)); if (teardown) (instance.bum || (instance.bum = [])).push(teardown); } : performHydrate; if (getResolvedComp()) doHydrate(); else load().then(() => !instance.isUnmounted && doHydrate()); } //#endregion //#region packages/runtime-core/src/components/KeepAlive.ts const isKeepAlive = (vnode) => vnode.type.__isKeepAlive; let isKeepAliveEnabled = false; function withKeepAliveEnabled(value) { isKeepAliveEnabled = true; return value; } const KeepAlive = /*@__PURE__*/ withKeepAliveEnabled({ name: `KeepAlive`, __isKeepAlive: true, props: { include: [ String, RegExp, Array ], exclude: [ String, RegExp, Array ], max: [String, Number] }, setup(props, { slots }) { const keepAliveInstance = getCurrentInstance(); const sharedContext = keepAliveInstance.ctx; if (!sharedContext.renderer) return () => { const children = slots.default && slots.default(); return children && children.length === 1 ? children[0] : children; }; const cache = /* @__PURE__ */ new Map(); const keys = /* @__PURE__ */ new Set(); let current = null; keepAliveInstance.__v_cache = cache; const parentSuspense = keepAliveInstance.suspense; const { renderer } = sharedContext; const { um: _unmount, o: { createElement } } = renderer; const storageContainer = createElement("div"); sharedContext.getStorageContainer = () => storageContainer; sharedContext.getCachedComponent = (vnode) => { const key = vnode.key == null ? vnode.type : vnode.key; return cache.get(key); }; sharedContext.activate = (vnode, container, anchor, namespace, optimized) => { activate(vnode, container, anchor, renderer, keepAliveInstance, parentSuspense, namespace, optimized); }; sharedContext.deactivate = (vnode) => { deactivate(vnode, storageContainer, renderer, keepAliveInstance, parentSuspense); }; function unmount(vnode) { resetShapeFlag(vnode); _unmount(vnode, keepAliveInstance, parentSuspense, true); } function pruneCache(filter) { cache.forEach((vnode, key) => { const name = getComponentName(isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : vnode.type); if (name && !filter(name)) pruneCacheEntry(key); }); } function pruneCacheEntry(key) { const cached = cache.get(key); if (cached && (!current || !isSameVNodeType(cached, current))) unmount(cached); else if (current) { resetShapeFlag(current); if (cached) resetShapeFlag(cached); } cache.delete(key); keys.delete(key); } watch(() => [props.include, props.exclude], ([include, exclude]) => { include && pruneCache((name) => matches(include, name)); exclude && pruneCache((name) => !matches(exclude, name)); }, { flush: "post", deep: true }); let pendingCacheKey = null; const cacheSubtree = () => { if (pendingCacheKey != null) { if (isSuspense(keepAliveInstance.subTree.type)) queuePostRenderEffect(() => { const vnode = getInnerChild(keepAliveInstance.subTree); if (vnode.component) cache.set(pendingCacheKey, vnode); }, void 0, keepAliveInstance.subTree.suspense); else cache.set(pendingCacheKey, getInnerChild(keepAliveInstance.subTree)); } }; onMounted(cacheSubtree); onUpdated(cacheSubtree); onBeforeUnmount(() => { cache.forEach((cached) => { const { subTree, suspense } = keepAliveInstance; const vnode = getInnerChild(subTree); if (cached.type === vnode.type && cached.key === vnode.key) { const bda = vnode.component.bda; bda && (0, _vue_shared.invokeArrayFns)(bda); resetShapeFlag(vnode); const da = vnode.component.da; da && queuePostRenderEffect(da, void 0, suspense); return; } unmount(cached); }); }); return () => { pendingCacheKey = null; if (!slots.default) return current = null; const children = slots.default(); const rawVNode = children[0]; if (children.length > 1) { warn$1(`KeepAlive should contain exactly one component child.`); current = null; return children; } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) { current = null; return rawVNode; } let vnode = getInnerChild(rawVNode); if (vnode.type === Comment$1) { current = null; return vnode; } const comp = vnode.type; const name = getComponentName(isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp); const { include, exclude, max } = props; if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) { vnode.shapeFlag &= -257; current = vnode; return rawVNode; } const key = vnode.key == null ? comp : vnode.key; const cachedVNode = cache.get(key); if (vnode.el) { vnode = cloneVNode(vnode); if (rawVNode.shapeFlag & 128) rawVNode.ssContent = vnode; } pendingCacheKey = key; if (cachedVNode) { vnode.el = cachedVNode.el; vnode.component = cachedVNode.component; if (vnode.transition) setTransitionHooks(vnode, vnode.transition); vnode.shapeFlag |= 512; keys.delete(key); keys.add(key); } else { keys.add(key); if (max && keys.size > parseInt(max, 10)) pruneCacheEntry(keys.values().next().value); } vnode.shapeFlag |= 256; current = vnode; return isSuspense(rawVNode.type) ? rawVNode : vnode; }; } }); function matches(pattern, name) { if ((0, _vue_shared.isArray)(pattern)) return pattern.some((p) => matches(p, name)); else if ((0, _vue_shared.isString)(pattern)) return pattern.split(",").includes(name); else if ((0, _vue_shared.isRegExp)(pattern)) { pattern.lastIndex = 0; return pattern.test(name); } /* v8 ignore next */ return false; } function onActivated(hook, target) { registerKeepAliveHook(hook, "a", target); } function onBeforeActivate(hook, target) { registerKeepAliveHook(hook, "ba", target); } function onDeactivated(hook, target) { registerKeepAliveHook(hook, "da", target); } function onBeforeDeactivate(hook, target) { registerKeepAliveHook(hook, "bda", target); } function registerKeepAliveHook(hook, type, target = getCurrentGenericInstance()) { const wrappedHook = hook.__wdc || (hook.__wdc = () => { let current = target; while (current) { if (current.isDeactivated) return; current = current.parent; } return hook(); }); injectHook(type, wrappedHook, target); if (target) { let current = target.parent; while (current && current.parent) { let parent = current.parent; if (isKeepAlive(parent.vapor ? parent : parent.vnode)) injectToKeepAliveRoot(wrappedHook, type, target, current); current = current.parent; } } } function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) { const injected = injectHook(type, hook, keepAliveRoot, true); onUnmounted(() => { (0, _vue_shared.remove)(keepAliveRoot[type], injected); }, target); } function invokeKeepAliveHooks(hooks) { for (let i = 0; i < hooks.length; i++) { const hook = hooks[i]; if (!hook.__called) { hook(); hook.__called = true; } } } function resetKeepAliveHookState(hooks) { for (let i = 0; i < hooks.length; i++) hooks[i].__called = false; } function resetShapeFlag(vnode) { vnode.shapeFlag &= -257; vnode.shapeFlag &= -513; } function getInnerChild(vnode) { return vnode.shapeFlag & 128 ? vnode.ssContent : vnode; } /** * shared between runtime-core and runtime-vapor */ function activate(vnode, container, anchor, { p: patch, m: move }, parentComponent, parentSuspense, namespace, optimized) { const instance = vnode.component; if (instance.ba) { const isDeactivated = instance.isDeactivated; instance.isDeactivated = false; (0, _vue_shared.invokeArrayFns)(instance.ba); instance.isDeactivated = isDeactivated; } move(vnode, container, anchor, 0, parentComponent, parentSuspense); patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, namespace, vnode.slotScopeIds, optimized); queuePostRenderEffect(() => { instance.isDeactivated = false; if (instance.a) (0, _vue_shared.invokeArrayFns)(instance.a); const vnodeHook = vnode.props && vnode.props.onVnodeMounted; if (vnodeHook) invokeVNodeHook(vnodeHook, instance.parent, vnode); }, void 0, parentSuspense); devtoolsComponentAdded(instance); } /** * shared between runtime-core and runtime-vapor */ function deactivate(vnode, container, { m: move }, parentComponent, parentSuspense) { const instance = vnode.component; if (instance.bda) invokeKeepAliveHooks(instance.bda); invalidateMount(instance.m); invalidateMount(instance.a); move(vnode, container, null, 1, parentComponent, parentSuspense); queuePostRenderEffect(() => { if (instance.bda) resetKeepAliveHookState(instance.bda); if (instance.da) (0, _vue_shared.invokeArrayFns)(instance.da); const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted; if (vnodeHook) invokeVNodeHook(vnodeHook, instance.parent, vnode); instance.isDeactivated = true; }, void 0, parentSuspense); devtoolsComponentAdded(instance); } //#endregion //#region packages/runtime-core/src/apiLifecycle.ts function injectHook(type, hook, target = currentInstance, prepend = false) { if (target) { const pageInstance = target.$pageInstance; if (pageInstance && (0, _dcloudio_uni_shared.isRootHook)(type)) { if (target.type.__reserved) return; if (target !== pageInstance) { target = pageInstance; if ((0, _dcloudio_uni_shared.isRootImmediateHook)(type)) { const proxy = target.proxy; callWithAsyncErrorHandling(hook.bind(proxy), target, type, type === _dcloudio_uni_shared.ON_LOAD ? [proxy.$page.options] : []); } } } const hooks = target[type] || (target[type] = []); const wrappedHook = hook.__weh || (hook.__weh = (...args) => { const prevSub = setActiveSub(); const prev = setCurrentInstance(target); try { return callWithAsyncErrorHandling(hook, target, type, args); } finally { restoreCurrentInstance(prev); setActiveSub(prevSub); } }); if (prepend) hooks.unshift(wrappedHook); else hooks.push(wrappedHook); return wrappedHook; } else warn$1(`${(0, _vue_shared.toHandlerKey)((ErrorTypeStrings$1[type] || type.replace(/^on/, "")).replace(/ hook$/, ""))} 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.`); } const createHook = /* @__NO_SIDE_EFFECTS__ */ (lifecycle) => (hook, target = currentInstance) => { if (!isInSSRComponentSetup || lifecycle === "sp") injectHook(lifecycle, (...args) => hook(...args), target); }; const onBeforeMount = /* @__PURE__ */ createHook("bm"); const onMounted = /* @__PURE__ */ createHook("m"); const onBeforeUpdate = /* @__PURE__ */ createHook("bu"); const onUpdated = /* @__PURE__ */ createHook("u"); const onBeforeUnmount = /* @__PURE__ */ createHook("bum"); const onUnmounted = /* @__PURE__ */ createHook("um"); const onServerPrefetch = /* @__PURE__ */ createHook("sp"); const onRenderTriggered = /* @__PURE__ */ createHook("rtg"); const onRenderTracked = /* @__PURE__ */ createHook("rtc"); function onErrorCaptured(hook, target = currentInstance) { injectHook("ec", hook, target); } const DIRECTIVES = "directives"; /** * @private */ function resolveComponent(name, maybeSelfReference) { return resolveAsset("components", name, true, maybeSelfReference) || name; } const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc"); /** * @private */ function resolveDynamicComponent(component) { if ((0, _vue_shared.isString)(component)) return resolveAsset("components", component, false) || component; else return component || NULL_DYNAMIC_COMPONENT; } /** * @private */ function resolveDirective(name) { return resolveAsset(DIRECTIVES, name); } function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) { const instance = currentRenderingInstance || currentInstance; if (instance) { const Component = instance.type; if (type === "components") { const selfName = getComponentName(Component, false); if (selfName && (selfName === name || selfName === (0, _vue_shared.camelize)(name) || selfName === (0, _vue_shared.capitalize)((0, _vue_shared.camelize)(name)))) return Component; } const res = resolve(instance[type] || Component[type], name) || resolve(instance.appContext[type], name); if (!res && maybeSelfReference) return Component; if (warnMissing && !res) { const extra = type === "components" ? "\nIf this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement." : ``; warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`); } return res; } else warn$1(`resolve${(0, _vue_shared.capitalize)(type.slice(0, -1))} can only be used in render() or setup().`); } function resolve(registry, name) { return registry && (registry[name] || registry[(0, _vue_shared.camelize)(name)] || registry[(0, _vue_shared.capitalize)((0, _vue_shared.camelize)(name))]); } //#endregion //#region packages/runtime-core/src/helpers/renderList.ts /** * Actual implementation */ function renderList(source, renderItem, cache, index) { let ret; const cached = cache && cache[index]; const sourceIsArray = (0, _vue_shared.isArray)(source); if (sourceIsArray || (0, _vue_shared.isString)(source)) { const sourceIsReactiveArray = sourceIsArray && /* @__PURE__ */ isReactive(source); let needsWrap = false; let isReadonlySource = false; if (sourceIsReactiveArray) { needsWrap = !/* @__PURE__ */ isShallow(source); isReadonlySource = /* @__PURE__ */ isReadonly(source); source = shallowReadArray(source); } ret = new Array(source.length); for (let i = 0, l = source.length; i < l; i++) ret[i] = renderItem(needsWrap ? isReadonlySource ? toReadonly(toReactive(source[i])) : toReactive(source[i]) : source[i], i, void 0, cached && cached[i]); } else if (typeof source === "number") { if (!Number.isInteger(source) || source < 0) { warn$1(`The v-for range expects a positive integer value but got ${source}.`); ret = []; } else { ret = new Array(source); for (let i = 0; i < source; i++) ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]); } } else if ((0, _vue_shared.isObject)(source)) { if (source[Symbol.iterator]) ret = Array.from(source, (item, i) => renderItem(item, i, void 0, cached && cached[i])); else { const keys = Object.keys(source); ret = new Array(keys.length); for (let i = 0, l = keys.length; i < l; i++) { const key = keys[i]; ret[i] = renderItem(source[key], key, i, cached && cached[i]); } } } else ret = []; if (cache) cache[index] = ret; return ret; } //#endregion //#region packages/runtime-core/src/helpers/createSlots.ts /** * Compiler runtime helper for creating dynamic slots object * @private */ function createSlots(slots, dynamicSlots) { for (let i = 0; i < dynamicSlots.length; i++) { const slot = dynamicSlots[i]; if ((0, _vue_shared.isArray)(slot)) for (let j = 0; j < slot.length; j++) slots[slot[j].name] = slot[j].fn; else if (slot) slots[slot.name] = slot.key ? (...args) => { const res = slot.fn(...args); if (res) res.key = slot.key; return res; } : slot.fn; } return slots; } //#endregion //#region packages/runtime-core/src/helpers/renderSlot.ts /** * Links a slot function to its raw vapor slot: a raw vapor slot carries * itself, and the wrapper the interop slots proxy hands out carries the raw * slot it wraps — one lookup answers both "is this a vapor slot" and * "which one". Internal to vapor interop. */ const rawVaporSlotKey = Symbol(`rawVaporSlot`); /** * Invokes a VDOM slot fallback under the outlet owner that produced it, the * way `renderSlot` would have rendered it inline. Vapor interop invokes * fallbacks late, outside any render, so it passes the owner recorded on the * vapor slot vnode. Internal to vapor interop. */ function invokeSlotFallback(fallback, owner) { if (!owner) return fallback(); const prev = setCurrentRenderingInstance(owner); const prevStackSize = blockStack.length; try { return fallback(); } finally { for (let i = blockStack.length; i > prevStackSize; i--) closeBlock(); setCurrentRenderingInstance(prev); } } /** * Compiler runtime helper for rendering `` * @private */ function renderSlot(slots, name, props, fallback, noSlotted, branchKey) { if (props == null) props = {}; let slot = slots[name]; const vaporSlot = isVaporInteropEnabled && slot && slot[rawVaporSlotKey]; if (vaporSlot) { const ret = (openBlock(), createBlock(VaporSlot, props)); ret.vs = { slot: vaporSlot, name, outlets: fallback ? [{ fallback, owner: currentRenderingInstance }] : void 0 }; if (branchKey != null && props.key == null) { ret.vs.props = ret.props; ret.props = (0, _vue_shared.extend)({}, ret.props, { key: branchKey }); ret.key = branchKey; } if (!noSlotted && ret.scopeId) ret.slotScopeIds = [ret.scopeId + "-s"]; return ret; } if (currentRenderingInstance && (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce)) { const slotProps = branchKey != null && props.key == null ? (0, _vue_shared.extend)({}, props, { key: branchKey }) : props; const hasProps = Object.keys(slotProps).length > 0; if (name !== "default") slotProps.name = name; return openBlock(), createBlock(Fragment, null, [createVNode("slot", slotProps, fallback && fallback())], hasProps ? -2 : 64); } if (slot && slot.length > 1) { warn$1("SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template."); slot = () => []; } if (slot && slot._c) slot._d = false; const prevStackSize = blockStack.length; openBlock(); let rendered; try { const validSlotContent = slot && ensureValidVNode(slot(props)); let attached = false; if (isVaporInteropEnabled && fallback && validSlotContent && currentRenderingInstance) { const interop = currentRenderingInstance.appContext.vapor; if (interop) attached = interop.attachSlotOutlet(validSlotContent, fallback, currentRenderingInstance); } const slotKey = props.key || branchKey || validSlotContent && validSlotContent.key; rendered = createBlock(Fragment, { key: (slotKey && !(0, _vue_shared.isSymbol)(slotKey) ? slotKey : `_${name}`) + (!validSlotContent && fallback ? "_fb" : "") }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 ? 64 : -2); if (!validSlotContent && fallback) rendered.shapeFlag |= 1024; if (attached) rendered.vo = true; } catch (err) { for (let i = blockStack.length; i > prevStackSize; i--) closeBlock(); throw err; } finally { if (slot && slot._c) slot._d = true; } if (!noSlotted && rendered.scopeId) rendered.slotScopeIds = [rendered.scopeId + "-s"]; return rendered; } function ensureValidVNode(vnodes) { return vnodes.some((child) => { if (!isVNode(child)) return true; if (child.type === Comment$1) return false; if (child.type === Fragment && !ensureValidVNode(child.children)) return false; return true; }) ? vnodes : null; } //#endregion //#region packages/runtime-core/src/helpers/toHandlers.ts /** * For prefixing keys in v-on="obj" with "on" * @private */ function toHandlers(obj, preserveCaseIfNecessary) { const ret = {}; if (!(0, _vue_shared.isObject)(obj)) { warn$1(`v-on with no argument expects an object value.`); return ret; } for (const key in obj) ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : (0, _vue_shared.toHandlerKey)(key)] = obj[key]; return ret; } //#endregion //#region packages/runtime-core/src/componentPublicInstance.ts /** * #2437 In Vue 3, functional components do not have a public instance proxy but * they exist in the internal parent chain. For code that relies on traversing * public $parent chains, skip functional ones and go to the parent instead. */ const getPublicInstance = (i) => { if (i && i.vapor) return getComponentPublicInstance(i); if (!i) return null; if (isStatefulComponent(i)) return getComponentPublicInstance(i); return getPublicInstance(i.parent); }; const resolveDevRootEl = (vnode) => { let found = false; while (true) { if (vnode.patchFlag > 0 && vnode.patchFlag & 2048) { const root = filterSingleRoot(vnode.children); if (!root) return; vnode = root; found = true; continue; } const component = vnode.component; if (component && component.subTree) { vnode = component.subTree; continue; } const suspense = vnode.suspense; if (suspense && suspense.activeBranch) { vnode = suspense.activeBranch; continue; } return found ? vnode.el : void 0; } }; const getDevRootFragmentEl = (i) => { const el = i.subTree && resolveDevRootEl(i.subTree); return el === void 0 ? i.vnode.el : el; }; let publicPropertiesMap; let vaporPublicPropertiesMap; const getPublicPropertiesMap = (vapor = false) => { if (!publicPropertiesMap) publicPropertiesMap = (0, _vue_shared.extend)(Object.create(null), { $: (i) => i, $el: (i) => i.vapor ? i.getRootElement() : getDevRootFragmentEl(i), $data: (i) => i.data, $props: (i) => /* @__PURE__ */ shallowReadonly(i.props), $attrs: (i) => /* @__PURE__ */ shallowReadonly(i.attrs), $slots: (i) => /* @__PURE__ */ shallowReadonly(i.slots), $refs: (i) => /* @__PURE__ */ shallowReadonly(i.refs), $parent: (i) => getPublicInstance(i.parent), $root: (i) => getPublicInstance(i.root), $page: (i) => i.page || null, $host: (i) => i.ce, $emit: (i) => i.emit, $options: (i) => resolveMergedOptions(i), $forceUpdate: (i) => i.f || (i.f = () => { queueJob(i.update); }), $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)), $watch: (i) => instanceWatch.bind(i) }); if (vapor) { if (!vaporPublicPropertiesMap) { vaporPublicPropertiesMap = (0, _vue_shared.extend)(Object.create(null), publicPropertiesMap, { $callMethod: (i) => (methodName, ...args) => { const proxy = getComponentPublicInstance(i) || i.proxy; if (!proxy) return null; const method = proxy[methodName]; if (method) return method(...args); console.error(`method ${methodName} not found`); return null; } }); delete vaporPublicPropertiesMap.$forceUpdate; } return vaporPublicPropertiesMap; } return publicPropertiesMap; }; const isReservedPrefix = (key) => key === "_" || key === "$"; const hasSetupBinding = (state, key) => state !== _vue_shared.EMPTY_OBJ && !state.__isScriptSetup && (0, _vue_shared.hasOwn)(state, key); const PublicInstanceProxyHandlers = { get({ _: instance }, key) { if (key === "__v_skip") return true; const { ctx, setupState, data, props, accessCache, type, appContext } = instance; if (key === "__isVue") return true; if (key[0] !== "$") { const n = accessCache[key]; if (n !== void 0) switch (n) { case 1: return setupState[key]; case 2: return data[key]; case 4: return ctx[key]; case 3: return props[key]; } else if (hasSetupBinding(setupState, key)) { accessCache[key] = 1; return setupState[key]; } else if (data !== _vue_shared.EMPTY_OBJ && (0, _vue_shared.hasOwn)(data, key)) { accessCache[key] = 2; return data[key]; } else if ((0, _vue_shared.hasOwn)(props, key)) { accessCache[key] = 3; return props[key]; } else if (ctx !== _vue_shared.EMPTY_OBJ && (0, _vue_shared.hasOwn)(ctx, key)) { accessCache[key] = 4; return ctx[key]; } else if (shouldCacheAccess) accessCache[key] = 0; } const publicGetter = getPublicPropertiesMap(!!instance.vapor)[key]; let cssModule, globalProperties; if (publicGetter) { if (key === "$attrs") { track(instance.attrs, "get", ""); markAttrsAccessed(); } else if (key === "$slots") track(instance, "get", key); return publicGetter(instance); } else if ((cssModule = type.__cssModules) && (cssModule = cssModule[key])) return cssModule; else if (ctx !== _vue_shared.EMPTY_OBJ && (0, _vue_shared.hasOwn)(ctx, key)) { accessCache[key] = 4; return ctx[key]; } else if (globalProperties = appContext.config.globalProperties, (0, _vue_shared.hasOwn)(globalProperties, key)) return globalProperties[key]; else if (currentRenderingInstance && (!(0, _vue_shared.isString)(key) || key.indexOf("__v") !== 0)) { if (data !== _vue_shared.EMPTY_OBJ && isReservedPrefix(key[0]) && (0, _vue_shared.hasOwn)(data, key)) warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`); else if (instance === currentRenderingInstance) warn$1(`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`); } }, set({ _: instance }, key, value) { const { data, setupState, ctx } = instance; if (hasSetupBinding(setupState, key)) { setupState[key] = value; return true; } else if (setupState.__isScriptSetup && (0, _vue_shared.hasOwn)(setupState, key)) { warn$1(`Cannot mutate