reactivity.esm-browser.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057
  1. /**
  2. * @vue/reactivity v3.5.42
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. // @__NO_SIDE_EFFECTS__
  7. function makeMap(str) {
  8. const map = /* @__PURE__ */ Object.create(null);
  9. for (const key of str.split(",")) map[key] = 1;
  10. return (val) => val in map;
  11. }
  12. const EMPTY_OBJ = Object.freeze({}) ;
  13. const NOOP = () => {
  14. };
  15. const extend = Object.assign;
  16. const remove = (arr, el) => {
  17. const i = arr.indexOf(el);
  18. if (i > -1) {
  19. arr.splice(i, 1);
  20. }
  21. };
  22. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  23. const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
  24. const isArray = Array.isArray;
  25. const isMap = (val) => toTypeString(val) === "[object Map]";
  26. const isSet = (val) => toTypeString(val) === "[object Set]";
  27. const isFunction = (val) => typeof val === "function";
  28. const isString = (val) => typeof val === "string";
  29. const isSymbol = (val) => typeof val === "symbol";
  30. const isObject = (val) => val !== null && typeof val === "object";
  31. const objectToString = Object.prototype.toString;
  32. const toTypeString = (value) => objectToString.call(value);
  33. const toRawType = (value) => {
  34. return toTypeString(value).slice(8, -1);
  35. };
  36. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  37. const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  38. const cacheStringFunction = (fn) => {
  39. const cache = /* @__PURE__ */ Object.create(null);
  40. return ((str) => {
  41. const hit = cache[str];
  42. return hit || (cache[str] = fn(str));
  43. });
  44. };
  45. const capitalize = cacheStringFunction((str) => {
  46. return str.charAt(0).toUpperCase() + str.slice(1);
  47. });
  48. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  49. const def = (obj, key, value, writable = false) => {
  50. Object.defineProperty(obj, key, {
  51. configurable: true,
  52. enumerable: false,
  53. writable,
  54. value
  55. });
  56. };
  57. function warn(msg, ...args) {
  58. console.warn(`[Vue warn] ${msg}`, ...args);
  59. }
  60. let activeEffectScope;
  61. class EffectScope {
  62. // TODO isolatedDeclarations "__v_skip"
  63. constructor(detached = false) {
  64. this.detached = detached;
  65. /**
  66. * @internal
  67. */
  68. this._active = true;
  69. /**
  70. * @internal track `on` calls, allow `on` call multiple times
  71. */
  72. this._on = 0;
  73. /**
  74. * @internal
  75. */
  76. this.effects = [];
  77. /**
  78. * @internal
  79. */
  80. this.cleanups = [];
  81. this._isPaused = false;
  82. this._warnOnRun = true;
  83. this.__v_skip = true;
  84. if (!detached && activeEffectScope) {
  85. if (activeEffectScope.active) {
  86. this.parent = activeEffectScope;
  87. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  88. this
  89. ) - 1;
  90. } else {
  91. this._active = false;
  92. this._warnOnRun = false;
  93. }
  94. }
  95. }
  96. get active() {
  97. return this._active;
  98. }
  99. pause() {
  100. if (this._active) {
  101. this._isPaused = true;
  102. let i, l;
  103. if (this.scopes) {
  104. const scopes = this.scopes.slice();
  105. for (i = 0, l = scopes.length; i < l; i++) {
  106. scopes[i].pause();
  107. }
  108. }
  109. for (i = 0, l = this.effects.length; i < l; i++) {
  110. this.effects[i].pause();
  111. }
  112. }
  113. }
  114. /**
  115. * Resumes the effect scope, including all child scopes and effects.
  116. */
  117. resume() {
  118. if (this._active) {
  119. if (this._isPaused) {
  120. this._isPaused = false;
  121. let i, l;
  122. if (this.scopes) {
  123. const scopes = this.scopes.slice();
  124. for (i = 0, l = scopes.length; i < l; i++) {
  125. scopes[i].resume();
  126. }
  127. }
  128. const effects = this.effects.slice();
  129. for (i = 0, l = effects.length; i < l; i++) {
  130. effects[i].resume();
  131. }
  132. }
  133. }
  134. }
  135. run(fn) {
  136. if (this._active) {
  137. const currentEffectScope = activeEffectScope;
  138. try {
  139. activeEffectScope = this;
  140. return fn();
  141. } finally {
  142. activeEffectScope = currentEffectScope;
  143. }
  144. } else if (this._warnOnRun) {
  145. warn(`cannot run an inactive effect scope.`);
  146. }
  147. }
  148. /**
  149. * This should only be called on non-detached scopes
  150. * @internal
  151. */
  152. on() {
  153. if (++this._on === 1) {
  154. this.prevScope = activeEffectScope;
  155. activeEffectScope = this;
  156. }
  157. }
  158. /**
  159. * This should only be called on non-detached scopes
  160. * @internal
  161. */
  162. off() {
  163. if (this._on > 0 && --this._on === 0) {
  164. if (activeEffectScope === this) {
  165. activeEffectScope = this.prevScope;
  166. } else {
  167. let current = activeEffectScope;
  168. while (current) {
  169. if (current.prevScope === this) {
  170. current.prevScope = this.prevScope;
  171. break;
  172. }
  173. current = current.prevScope;
  174. }
  175. }
  176. this.prevScope = void 0;
  177. }
  178. }
  179. stop(fromParent) {
  180. if (this._active) {
  181. this._active = false;
  182. let i, l;
  183. for (i = 0, l = this.effects.length; i < l; i++) {
  184. this.effects[i].stop();
  185. }
  186. this.effects.length = 0;
  187. for (i = 0, l = this.cleanups.length; i < l; i++) {
  188. this.cleanups[i]();
  189. }
  190. this.cleanups.length = 0;
  191. if (this.scopes) {
  192. const scopes = this.scopes.slice();
  193. for (i = 0, l = scopes.length; i < l; i++) {
  194. scopes[i].stop(true);
  195. }
  196. this.scopes.length = 0;
  197. }
  198. if (!this.detached && this.parent && !fromParent) {
  199. const last = this.parent.scopes.pop();
  200. if (last && last !== this) {
  201. this.parent.scopes[this.index] = last;
  202. last.index = this.index;
  203. }
  204. }
  205. this.parent = void 0;
  206. }
  207. }
  208. }
  209. function effectScope(detached) {
  210. return new EffectScope(detached);
  211. }
  212. function getCurrentScope() {
  213. return activeEffectScope;
  214. }
  215. function onScopeDispose(fn, failSilently = false) {
  216. if (activeEffectScope) {
  217. activeEffectScope.cleanups.push(fn);
  218. } else if (!failSilently) {
  219. warn(
  220. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  221. );
  222. }
  223. }
  224. let activeSub;
  225. const EffectFlags = {
  226. "ACTIVE": 1,
  227. "1": "ACTIVE",
  228. "RUNNING": 2,
  229. "2": "RUNNING",
  230. "TRACKING": 4,
  231. "4": "TRACKING",
  232. "NOTIFIED": 8,
  233. "8": "NOTIFIED",
  234. "DIRTY": 16,
  235. "16": "DIRTY",
  236. "ALLOW_RECURSE": 32,
  237. "32": "ALLOW_RECURSE",
  238. "PAUSED": 64,
  239. "64": "PAUSED",
  240. "EVALUATED": 128,
  241. "128": "EVALUATED"
  242. };
  243. const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
  244. class ReactiveEffect {
  245. constructor(fn) {
  246. this.fn = fn;
  247. /**
  248. * @internal
  249. */
  250. this.deps = void 0;
  251. /**
  252. * @internal
  253. */
  254. this.depsTail = void 0;
  255. /**
  256. * @internal
  257. */
  258. this.flags = 1 | 4;
  259. /**
  260. * @internal
  261. */
  262. this.next = void 0;
  263. /**
  264. * @internal
  265. */
  266. this.cleanup = void 0;
  267. this.scheduler = void 0;
  268. if (activeEffectScope) {
  269. if (activeEffectScope.active) {
  270. activeEffectScope.effects.push(this);
  271. } else {
  272. this.flags &= -2;
  273. }
  274. }
  275. }
  276. pause() {
  277. this.flags |= 64;
  278. }
  279. resume() {
  280. if (this.flags & 64) {
  281. this.flags &= -65;
  282. if (pausedQueueEffects.has(this)) {
  283. pausedQueueEffects.delete(this);
  284. this.trigger();
  285. }
  286. }
  287. }
  288. /**
  289. * @internal
  290. */
  291. notify() {
  292. if (this.flags & 2 && !(this.flags & 32)) {
  293. return;
  294. }
  295. if (!(this.flags & 8)) {
  296. batch(this);
  297. }
  298. }
  299. run() {
  300. if (!(this.flags & 1)) {
  301. return this.fn();
  302. }
  303. this.flags |= 2;
  304. cleanupEffect(this);
  305. prepareDeps(this);
  306. const prevEffect = activeSub;
  307. const prevShouldTrack = shouldTrack;
  308. activeSub = this;
  309. shouldTrack = true;
  310. try {
  311. return this.fn();
  312. } finally {
  313. if (activeSub !== this) {
  314. warn(
  315. "Active effect was not restored correctly - this is likely a Vue internal bug."
  316. );
  317. }
  318. cleanupDeps(this);
  319. activeSub = prevEffect;
  320. shouldTrack = prevShouldTrack;
  321. this.flags &= -3;
  322. }
  323. }
  324. stop() {
  325. if (this.flags & 1) {
  326. for (let link = this.deps; link; link = link.nextDep) {
  327. removeSub(link);
  328. }
  329. this.deps = this.depsTail = void 0;
  330. cleanupEffect(this);
  331. this.onStop && this.onStop();
  332. this.flags &= -2;
  333. }
  334. }
  335. trigger() {
  336. if (this.flags & 64) {
  337. pausedQueueEffects.add(this);
  338. } else if (this.scheduler) {
  339. this.scheduler();
  340. } else {
  341. this.runIfDirty();
  342. }
  343. }
  344. /**
  345. * @internal
  346. */
  347. runIfDirty() {
  348. if (isDirty(this)) {
  349. this.run();
  350. }
  351. }
  352. get dirty() {
  353. return isDirty(this);
  354. }
  355. }
  356. let batchDepth = 0;
  357. let batchedSub;
  358. let batchedComputed;
  359. function batch(sub, isComputed = false) {
  360. sub.flags |= 8;
  361. if (isComputed) {
  362. sub.next = batchedComputed;
  363. batchedComputed = sub;
  364. return;
  365. }
  366. sub.next = batchedSub;
  367. batchedSub = sub;
  368. }
  369. function startBatch() {
  370. batchDepth++;
  371. }
  372. function endBatch() {
  373. if (--batchDepth > 0) {
  374. return;
  375. }
  376. if (batchedComputed) {
  377. let e = batchedComputed;
  378. batchedComputed = void 0;
  379. while (e) {
  380. const next = e.next;
  381. e.next = void 0;
  382. e.flags &= -9;
  383. e = next;
  384. }
  385. }
  386. let error;
  387. while (batchedSub) {
  388. let e = batchedSub;
  389. batchedSub = void 0;
  390. while (e) {
  391. const next = e.next;
  392. e.next = void 0;
  393. e.flags &= -9;
  394. if (e.flags & 1) {
  395. try {
  396. ;
  397. e.trigger();
  398. } catch (err) {
  399. if (!error) error = err;
  400. }
  401. }
  402. e = next;
  403. }
  404. }
  405. if (error) throw error;
  406. }
  407. function prepareDeps(sub) {
  408. for (let link = sub.deps; link; link = link.nextDep) {
  409. link.version = -1;
  410. link.prevActiveLink = link.dep.activeLink;
  411. link.dep.activeLink = link;
  412. }
  413. }
  414. function cleanupDeps(sub) {
  415. let head;
  416. let tail = sub.depsTail;
  417. let link = tail;
  418. while (link) {
  419. const prev = link.prevDep;
  420. if (link.version === -1) {
  421. if (link === tail) tail = prev;
  422. removeSub(link);
  423. removeDep(link);
  424. } else {
  425. head = link;
  426. }
  427. link.dep.activeLink = link.prevActiveLink;
  428. link.prevActiveLink = void 0;
  429. link = prev;
  430. }
  431. sub.deps = head;
  432. sub.depsTail = tail;
  433. }
  434. function isDirty(sub) {
  435. for (let link = sub.deps; link; link = link.nextDep) {
  436. if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
  437. return true;
  438. }
  439. }
  440. if (sub._dirty) {
  441. return true;
  442. }
  443. return false;
  444. }
  445. function refreshComputed(computed) {
  446. if (computed.flags & 4 && !(computed.flags & 16)) {
  447. return;
  448. }
  449. computed.flags &= -17;
  450. if (computed.globalVersion === globalVersion) {
  451. return;
  452. }
  453. computed.globalVersion = globalVersion;
  454. if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) {
  455. return;
  456. }
  457. computed.flags |= 2;
  458. const dep = computed.dep;
  459. const prevSub = activeSub;
  460. const prevShouldTrack = shouldTrack;
  461. activeSub = computed;
  462. shouldTrack = true;
  463. try {
  464. prepareDeps(computed);
  465. const value = computed.fn(computed._value);
  466. if (dep.version === 0 || hasChanged(value, computed._value)) {
  467. computed.flags |= 128;
  468. computed._value = value;
  469. dep.version++;
  470. }
  471. } catch (err) {
  472. dep.version++;
  473. throw err;
  474. } finally {
  475. activeSub = prevSub;
  476. shouldTrack = prevShouldTrack;
  477. cleanupDeps(computed);
  478. computed.flags &= -3;
  479. }
  480. }
  481. function removeSub(link, soft = false) {
  482. const { dep, prevSub, nextSub } = link;
  483. if (prevSub) {
  484. prevSub.nextSub = nextSub;
  485. link.prevSub = void 0;
  486. }
  487. if (nextSub) {
  488. nextSub.prevSub = prevSub;
  489. link.nextSub = void 0;
  490. }
  491. if (dep.subsHead === link) {
  492. dep.subsHead = nextSub;
  493. }
  494. if (dep.subs === link) {
  495. dep.subs = prevSub;
  496. if (!prevSub && dep.computed) {
  497. dep.computed.flags &= -5;
  498. for (let l = dep.computed.deps; l; l = l.nextDep) {
  499. removeSub(l, true);
  500. }
  501. }
  502. }
  503. if (!soft && !--dep.sc && dep.map) {
  504. dep.map.delete(dep.key);
  505. }
  506. }
  507. function removeDep(link) {
  508. const { prevDep, nextDep } = link;
  509. if (prevDep) {
  510. prevDep.nextDep = nextDep;
  511. link.prevDep = void 0;
  512. }
  513. if (nextDep) {
  514. nextDep.prevDep = prevDep;
  515. link.nextDep = void 0;
  516. }
  517. }
  518. function effect(fn, options) {
  519. if (fn.effect instanceof ReactiveEffect) {
  520. fn = fn.effect.fn;
  521. }
  522. const e = new ReactiveEffect(fn);
  523. if (options) {
  524. extend(e, options);
  525. }
  526. try {
  527. e.run();
  528. } catch (err) {
  529. e.stop();
  530. throw err;
  531. }
  532. const runner = e.run.bind(e);
  533. runner.effect = e;
  534. return runner;
  535. }
  536. function stop(runner) {
  537. runner.effect.stop();
  538. }
  539. let shouldTrack = true;
  540. const trackStack = [];
  541. function pauseTracking() {
  542. trackStack.push(shouldTrack);
  543. shouldTrack = false;
  544. }
  545. function enableTracking() {
  546. trackStack.push(shouldTrack);
  547. shouldTrack = true;
  548. }
  549. function resetTracking() {
  550. const last = trackStack.pop();
  551. shouldTrack = last === void 0 ? true : last;
  552. }
  553. function onEffectCleanup(fn, failSilently = false) {
  554. if (activeSub instanceof ReactiveEffect) {
  555. activeSub.cleanup = fn;
  556. } else if (!failSilently) {
  557. warn(
  558. `onEffectCleanup() was called when there was no active effect to associate with.`
  559. );
  560. }
  561. }
  562. function cleanupEffect(e) {
  563. const { cleanup } = e;
  564. e.cleanup = void 0;
  565. if (cleanup) {
  566. const prevSub = activeSub;
  567. activeSub = void 0;
  568. try {
  569. cleanup();
  570. } finally {
  571. activeSub = prevSub;
  572. }
  573. }
  574. }
  575. let globalVersion = 0;
  576. class Link {
  577. constructor(sub, dep) {
  578. this.sub = sub;
  579. this.dep = dep;
  580. this.version = dep.version;
  581. this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
  582. }
  583. }
  584. class Dep {
  585. // TODO isolatedDeclarations "__v_skip"
  586. constructor(computed) {
  587. this.computed = computed;
  588. this.version = 0;
  589. /**
  590. * Link between this dep and the current active effect
  591. */
  592. this.activeLink = void 0;
  593. /**
  594. * Doubly linked list representing the subscribing effects (tail)
  595. */
  596. this.subs = void 0;
  597. /**
  598. * For object property deps cleanup
  599. */
  600. this.map = void 0;
  601. this.key = void 0;
  602. /**
  603. * Subscriber counter
  604. */
  605. this.sc = 0;
  606. /**
  607. * @internal
  608. */
  609. this.__v_skip = true;
  610. {
  611. this.subsHead = void 0;
  612. }
  613. }
  614. track(debugInfo) {
  615. if (!activeSub || !shouldTrack || activeSub === this.computed) {
  616. return;
  617. }
  618. let link = this.activeLink;
  619. if (link === void 0 || link.sub !== activeSub) {
  620. link = this.activeLink = new Link(activeSub, this);
  621. if (!activeSub.deps) {
  622. activeSub.deps = activeSub.depsTail = link;
  623. } else {
  624. link.prevDep = activeSub.depsTail;
  625. activeSub.depsTail.nextDep = link;
  626. activeSub.depsTail = link;
  627. }
  628. addSub(link);
  629. } else if (link.version === -1) {
  630. link.version = this.version;
  631. if (link.nextDep) {
  632. const next = link.nextDep;
  633. next.prevDep = link.prevDep;
  634. if (link.prevDep) {
  635. link.prevDep.nextDep = next;
  636. }
  637. link.prevDep = activeSub.depsTail;
  638. link.nextDep = void 0;
  639. activeSub.depsTail.nextDep = link;
  640. activeSub.depsTail = link;
  641. if (activeSub.deps === link) {
  642. activeSub.deps = next;
  643. }
  644. }
  645. }
  646. if (activeSub.onTrack) {
  647. activeSub.onTrack(
  648. extend(
  649. {
  650. effect: activeSub
  651. },
  652. debugInfo
  653. )
  654. );
  655. }
  656. return link;
  657. }
  658. trigger(debugInfo) {
  659. this.version++;
  660. globalVersion++;
  661. this.notify(debugInfo);
  662. }
  663. notify(debugInfo) {
  664. startBatch();
  665. try {
  666. if (true) {
  667. for (let head = this.subsHead; head; head = head.nextSub) {
  668. if (head.sub.onTrigger && !(head.sub.flags & 8)) {
  669. head.sub.onTrigger(
  670. extend(
  671. {
  672. effect: head.sub
  673. },
  674. debugInfo
  675. )
  676. );
  677. }
  678. }
  679. }
  680. for (let link = this.subs; link; link = link.prevSub) {
  681. if (link.sub.notify()) {
  682. ;
  683. link.sub.dep.notify();
  684. }
  685. }
  686. } finally {
  687. endBatch();
  688. }
  689. }
  690. }
  691. function addSub(link) {
  692. link.dep.sc++;
  693. if (link.sub.flags & 4) {
  694. const computed = link.dep.computed;
  695. if (computed && !link.dep.subs) {
  696. computed.flags |= 4 | 16;
  697. for (let l = computed.deps; l; l = l.nextDep) {
  698. addSub(l);
  699. }
  700. }
  701. const currentTail = link.dep.subs;
  702. if (currentTail !== link) {
  703. link.prevSub = currentTail;
  704. if (currentTail) currentTail.nextSub = link;
  705. }
  706. if (link.dep.subsHead === void 0) {
  707. link.dep.subsHead = link;
  708. }
  709. link.dep.subs = link;
  710. }
  711. }
  712. const targetMap = /* @__PURE__ */ new WeakMap();
  713. const ITERATE_KEY = /* @__PURE__ */ Symbol(
  714. "Object iterate"
  715. );
  716. const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  717. "Map keys iterate"
  718. );
  719. const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  720. "Array iterate"
  721. );
  722. function track(target, type, key) {
  723. if (shouldTrack && activeSub) {
  724. let depsMap = targetMap.get(target);
  725. if (!depsMap) {
  726. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  727. }
  728. let dep = depsMap.get(key);
  729. if (!dep) {
  730. depsMap.set(key, dep = new Dep());
  731. dep.map = depsMap;
  732. dep.key = key;
  733. }
  734. {
  735. dep.track({
  736. target,
  737. type,
  738. key
  739. });
  740. }
  741. }
  742. }
  743. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  744. const depsMap = targetMap.get(target);
  745. if (!depsMap) {
  746. globalVersion++;
  747. return;
  748. }
  749. const run = (dep) => {
  750. if (dep) {
  751. {
  752. dep.trigger({
  753. target,
  754. type,
  755. key,
  756. newValue,
  757. oldValue,
  758. oldTarget
  759. });
  760. }
  761. }
  762. };
  763. startBatch();
  764. if (type === "clear") {
  765. depsMap.forEach(run);
  766. } else {
  767. const targetIsArray = isArray(target);
  768. const isArrayIndex = targetIsArray && isIntegerKey(key);
  769. if (targetIsArray && key === "length") {
  770. const newLength = Number(newValue);
  771. depsMap.forEach((dep, key2) => {
  772. if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
  773. run(dep);
  774. }
  775. });
  776. } else {
  777. if (key !== void 0 || depsMap.has(void 0)) {
  778. run(depsMap.get(key));
  779. }
  780. if (isArrayIndex) {
  781. run(depsMap.get(ARRAY_ITERATE_KEY));
  782. }
  783. switch (type) {
  784. case "add":
  785. if (!targetIsArray) {
  786. run(depsMap.get(ITERATE_KEY));
  787. if (isMap(target)) {
  788. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  789. }
  790. } else if (isArrayIndex) {
  791. run(depsMap.get("length"));
  792. }
  793. break;
  794. case "delete":
  795. if (!targetIsArray) {
  796. run(depsMap.get(ITERATE_KEY));
  797. if (isMap(target)) {
  798. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  799. }
  800. }
  801. break;
  802. case "set":
  803. if (isMap(target)) {
  804. run(depsMap.get(ITERATE_KEY));
  805. }
  806. break;
  807. }
  808. }
  809. }
  810. endBatch();
  811. }
  812. function getDepFromReactive(object, key) {
  813. const depMap = targetMap.get(object);
  814. return depMap && depMap.get(key);
  815. }
  816. function reactiveReadArray(array) {
  817. const raw = toRaw(array);
  818. if (raw === array) return raw;
  819. track(raw, "iterate", ARRAY_ITERATE_KEY);
  820. return isShallow(array) ? raw : raw.map(toReactive);
  821. }
  822. function shallowReadArray(arr) {
  823. track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
  824. return arr;
  825. }
  826. function toWrapped(target, item) {
  827. if (isReadonly(target)) {
  828. return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
  829. }
  830. return toReactive(item);
  831. }
  832. const arrayInstrumentations = {
  833. __proto__: null,
  834. [Symbol.iterator]() {
  835. return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
  836. },
  837. concat(...args) {
  838. return reactiveReadArray(this).concat(
  839. ...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
  840. );
  841. },
  842. entries() {
  843. return iterator(this, "entries", (value) => {
  844. value[1] = toWrapped(this, value[1]);
  845. return value;
  846. });
  847. },
  848. every(fn, thisArg) {
  849. return apply(this, "every", fn, thisArg, void 0, arguments);
  850. },
  851. filter(fn, thisArg) {
  852. return apply(
  853. this,
  854. "filter",
  855. fn,
  856. thisArg,
  857. (v) => v.map((item) => toWrapped(this, item)),
  858. arguments
  859. );
  860. },
  861. find(fn, thisArg) {
  862. return apply(
  863. this,
  864. "find",
  865. fn,
  866. thisArg,
  867. (item) => toWrapped(this, item),
  868. arguments
  869. );
  870. },
  871. findIndex(fn, thisArg) {
  872. return apply(this, "findIndex", fn, thisArg, void 0, arguments);
  873. },
  874. findLast(fn, thisArg) {
  875. return apply(
  876. this,
  877. "findLast",
  878. fn,
  879. thisArg,
  880. (item) => toWrapped(this, item),
  881. arguments
  882. );
  883. },
  884. findLastIndex(fn, thisArg) {
  885. return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
  886. },
  887. // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
  888. forEach(fn, thisArg) {
  889. return apply(this, "forEach", fn, thisArg, void 0, arguments);
  890. },
  891. includes(...args) {
  892. return searchProxy(this, "includes", args);
  893. },
  894. indexOf(...args) {
  895. return searchProxy(this, "indexOf", args);
  896. },
  897. join(separator) {
  898. return reactiveReadArray(this).join(separator);
  899. },
  900. // keys() iterator only reads `length`, no optimization required
  901. lastIndexOf(...args) {
  902. return searchProxy(this, "lastIndexOf", args);
  903. },
  904. map(fn, thisArg) {
  905. return apply(this, "map", fn, thisArg, void 0, arguments);
  906. },
  907. pop() {
  908. return noTracking(this, "pop");
  909. },
  910. push(...args) {
  911. return noTracking(this, "push", args);
  912. },
  913. reduce(fn, ...args) {
  914. return reduce(this, "reduce", fn, args);
  915. },
  916. reduceRight(fn, ...args) {
  917. return reduce(this, "reduceRight", fn, args);
  918. },
  919. shift() {
  920. return noTracking(this, "shift");
  921. },
  922. // slice could use ARRAY_ITERATE but also seems to beg for range tracking
  923. some(fn, thisArg) {
  924. return apply(this, "some", fn, thisArg, void 0, arguments);
  925. },
  926. splice(...args) {
  927. return noTracking(this, "splice", args);
  928. },
  929. toReversed() {
  930. return reactiveReadArray(this).toReversed();
  931. },
  932. toSorted(comparer) {
  933. return reactiveReadArray(this).toSorted(comparer);
  934. },
  935. toSpliced(...args) {
  936. return reactiveReadArray(this).toSpliced(...args);
  937. },
  938. unshift(...args) {
  939. return noTracking(this, "unshift", args);
  940. },
  941. values() {
  942. return iterator(this, "values", (item) => toWrapped(this, item));
  943. }
  944. };
  945. function iterator(self, method, wrapValue) {
  946. const arr = shallowReadArray(self);
  947. const iter = arr[method]();
  948. if (arr !== self && !isShallow(self)) {
  949. iter._next = iter.next;
  950. iter.next = () => {
  951. const result = iter._next();
  952. if (!result.done) {
  953. result.value = wrapValue(result.value);
  954. }
  955. return result;
  956. };
  957. }
  958. return iter;
  959. }
  960. const arrayProto = Array.prototype;
  961. function apply(self, method, fn, thisArg, wrappedRetFn, args) {
  962. const arr = shallowReadArray(self);
  963. const needsWrap = arr !== self && !isShallow(self);
  964. const methodFn = arr[method];
  965. if (methodFn !== arrayProto[method]) {
  966. const result2 = methodFn.apply(self, args);
  967. return needsWrap ? toReactive(result2) : result2;
  968. }
  969. let wrappedFn = fn;
  970. if (arr !== self) {
  971. if (needsWrap) {
  972. wrappedFn = function(item, index) {
  973. return fn.call(this, toWrapped(self, item), index, self);
  974. };
  975. } else if (fn.length > 2) {
  976. wrappedFn = function(item, index) {
  977. return fn.call(this, item, index, self);
  978. };
  979. }
  980. }
  981. const result = methodFn.call(arr, wrappedFn, thisArg);
  982. return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
  983. }
  984. function reduce(self, method, fn, args) {
  985. const arr = shallowReadArray(self);
  986. const needsWrap = arr !== self && !isShallow(self);
  987. let wrappedFn = fn;
  988. let wrapInitialAccumulator = false;
  989. if (arr !== self) {
  990. if (needsWrap) {
  991. wrapInitialAccumulator = args.length === 0;
  992. wrappedFn = function(acc, item, index) {
  993. if (wrapInitialAccumulator) {
  994. wrapInitialAccumulator = false;
  995. acc = toWrapped(self, acc);
  996. }
  997. return fn.call(this, acc, toWrapped(self, item), index, self);
  998. };
  999. } else if (fn.length > 3) {
  1000. wrappedFn = function(acc, item, index) {
  1001. return fn.call(this, acc, item, index, self);
  1002. };
  1003. }
  1004. }
  1005. const result = arr[method](wrappedFn, ...args);
  1006. return wrapInitialAccumulator ? toWrapped(self, result) : result;
  1007. }
  1008. function searchProxy(self, method, args) {
  1009. const arr = toRaw(self);
  1010. track(arr, "iterate", ARRAY_ITERATE_KEY);
  1011. const res = arr[method](...args);
  1012. if ((res === -1 || res === false) && isProxy(args[0])) {
  1013. args[0] = toRaw(args[0]);
  1014. return arr[method](...args);
  1015. }
  1016. return res;
  1017. }
  1018. function noTracking(self, method, args = []) {
  1019. pauseTracking();
  1020. startBatch();
  1021. const res = toRaw(self)[method].apply(self, args);
  1022. endBatch();
  1023. resetTracking();
  1024. return res;
  1025. }
  1026. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  1027. const builtInSymbols = new Set(
  1028. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  1029. );
  1030. function hasOwnProperty(key) {
  1031. if (!isSymbol(key)) key = String(key);
  1032. const obj = toRaw(this);
  1033. track(obj, "has", key);
  1034. return obj.hasOwnProperty(key);
  1035. }
  1036. class BaseReactiveHandler {
  1037. constructor(_isReadonly = false, _isShallow = false) {
  1038. this._isReadonly = _isReadonly;
  1039. this._isShallow = _isShallow;
  1040. }
  1041. get(target, key, receiver) {
  1042. if (key === "__v_skip") return target["__v_skip"];
  1043. const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
  1044. if (key === "__v_isReactive") {
  1045. return !isReadonly2;
  1046. } else if (key === "__v_isReadonly") {
  1047. return isReadonly2;
  1048. } else if (key === "__v_isShallow") {
  1049. return isShallow2;
  1050. } else if (key === "__v_raw") {
  1051. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
  1052. // this means the receiver is a user proxy of the reactive proxy
  1053. Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
  1054. return target;
  1055. }
  1056. return;
  1057. }
  1058. const targetIsArray = isArray(target);
  1059. if (!isReadonly2) {
  1060. let fn;
  1061. if (targetIsArray && (fn = arrayInstrumentations[key])) {
  1062. return fn;
  1063. }
  1064. if (key === "hasOwnProperty") {
  1065. return hasOwnProperty;
  1066. }
  1067. }
  1068. const res = Reflect.get(
  1069. target,
  1070. key,
  1071. // if this is a proxy wrapping a ref, return methods using the raw ref
  1072. // as receiver so that we don't have to call `toRaw` on the ref in all
  1073. // its class methods
  1074. isRef(target) ? target : receiver
  1075. );
  1076. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  1077. return res;
  1078. }
  1079. if (!isReadonly2) {
  1080. track(target, "get", key);
  1081. }
  1082. if (isShallow2) {
  1083. return res;
  1084. }
  1085. if (isRef(res)) {
  1086. const value = targetIsArray && isIntegerKey(key) ? res : res.value;
  1087. return isReadonly2 && isObject(value) ? readonly(value) : value;
  1088. }
  1089. if (isObject(res)) {
  1090. return isReadonly2 ? readonly(res) : reactive(res);
  1091. }
  1092. return res;
  1093. }
  1094. }
  1095. class MutableReactiveHandler extends BaseReactiveHandler {
  1096. constructor(isShallow2 = false) {
  1097. super(false, isShallow2);
  1098. }
  1099. set(target, key, value, receiver) {
  1100. let oldValue = target[key];
  1101. const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
  1102. if (!this._isShallow) {
  1103. const isOldValueReadonly = isReadonly(oldValue);
  1104. if (!isShallow(value) && !isReadonly(value)) {
  1105. oldValue = toRaw(oldValue);
  1106. value = toRaw(value);
  1107. }
  1108. if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
  1109. if (isOldValueReadonly) {
  1110. {
  1111. warn(
  1112. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1113. target[key]
  1114. );
  1115. }
  1116. return true;
  1117. } else {
  1118. oldValue.value = value;
  1119. return true;
  1120. }
  1121. }
  1122. }
  1123. const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
  1124. const result = Reflect.set(
  1125. target,
  1126. key,
  1127. value,
  1128. isRef(target) ? target : receiver
  1129. );
  1130. if (target === toRaw(receiver) && result) {
  1131. if (!hadKey) {
  1132. trigger(target, "add", key, value);
  1133. } else if (hasChanged(value, oldValue)) {
  1134. trigger(target, "set", key, value, oldValue);
  1135. }
  1136. }
  1137. return result;
  1138. }
  1139. deleteProperty(target, key) {
  1140. const hadKey = hasOwn(target, key);
  1141. const oldValue = target[key];
  1142. const result = Reflect.deleteProperty(target, key);
  1143. if (result && hadKey) {
  1144. trigger(target, "delete", key, void 0, oldValue);
  1145. }
  1146. return result;
  1147. }
  1148. has(target, key) {
  1149. const result = Reflect.has(target, key);
  1150. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  1151. track(target, "has", key);
  1152. }
  1153. return result;
  1154. }
  1155. ownKeys(target) {
  1156. track(
  1157. target,
  1158. "iterate",
  1159. isArray(target) ? "length" : ITERATE_KEY
  1160. );
  1161. return Reflect.ownKeys(target);
  1162. }
  1163. }
  1164. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  1165. constructor(isShallow2 = false) {
  1166. super(true, isShallow2);
  1167. }
  1168. set(target, key) {
  1169. {
  1170. warn(
  1171. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1172. target
  1173. );
  1174. }
  1175. return true;
  1176. }
  1177. deleteProperty(target, key) {
  1178. {
  1179. warn(
  1180. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  1181. target
  1182. );
  1183. }
  1184. return true;
  1185. }
  1186. }
  1187. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
  1188. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
  1189. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
  1190. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
  1191. const toShallow = (value) => value;
  1192. const getProto = (v) => Reflect.getPrototypeOf(v);
  1193. function createIterableMethod(method, isReadonly2, isShallow2) {
  1194. return function(...args) {
  1195. const target = this["__v_raw"];
  1196. const rawTarget = toRaw(target);
  1197. const targetIsMap = isMap(rawTarget);
  1198. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  1199. const isKeyOnly = method === "keys" && targetIsMap;
  1200. const innerIterator = target[method](...args);
  1201. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  1202. !isReadonly2 && track(
  1203. rawTarget,
  1204. "iterate",
  1205. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  1206. );
  1207. return extend(
  1208. // inheriting all iterator properties
  1209. Object.create(innerIterator),
  1210. {
  1211. // iterator protocol
  1212. next() {
  1213. const { value, done } = innerIterator.next();
  1214. return done ? { value, done } : {
  1215. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1216. done
  1217. };
  1218. }
  1219. }
  1220. );
  1221. };
  1222. }
  1223. function createReadonlyMethod(type) {
  1224. return function(...args) {
  1225. {
  1226. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1227. warn(
  1228. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  1229. toRaw(this)
  1230. );
  1231. }
  1232. return type === "delete" ? false : type === "clear" ? void 0 : this;
  1233. };
  1234. }
  1235. function createInstrumentations(readonly, shallow) {
  1236. const instrumentations = {
  1237. get(key) {
  1238. const target = this["__v_raw"];
  1239. const rawTarget = toRaw(target);
  1240. const rawKey = toRaw(key);
  1241. if (!readonly) {
  1242. if (hasChanged(key, rawKey)) {
  1243. track(rawTarget, "get", key);
  1244. }
  1245. track(rawTarget, "get", rawKey);
  1246. }
  1247. const { has } = getProto(rawTarget);
  1248. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1249. if (has.call(rawTarget, key)) {
  1250. return wrap(target.get(key));
  1251. } else if (has.call(rawTarget, rawKey)) {
  1252. return wrap(target.get(rawKey));
  1253. } else if (target !== rawTarget) {
  1254. target.get(key);
  1255. }
  1256. },
  1257. get size() {
  1258. const target = this["__v_raw"];
  1259. !readonly && track(toRaw(target), "iterate", ITERATE_KEY);
  1260. return target.size;
  1261. },
  1262. has(key) {
  1263. const target = this["__v_raw"];
  1264. const rawTarget = toRaw(target);
  1265. const rawKey = toRaw(key);
  1266. if (!readonly) {
  1267. if (hasChanged(key, rawKey)) {
  1268. track(rawTarget, "has", key);
  1269. }
  1270. track(rawTarget, "has", rawKey);
  1271. }
  1272. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  1273. },
  1274. forEach(callback, thisArg) {
  1275. const observed = this;
  1276. const target = observed["__v_raw"];
  1277. const rawTarget = toRaw(target);
  1278. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1279. !readonly && track(rawTarget, "iterate", ITERATE_KEY);
  1280. return target.forEach((value, key) => {
  1281. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1282. });
  1283. }
  1284. };
  1285. extend(
  1286. instrumentations,
  1287. readonly ? {
  1288. add: createReadonlyMethod("add"),
  1289. set: createReadonlyMethod("set"),
  1290. delete: createReadonlyMethod("delete"),
  1291. clear: createReadonlyMethod("clear")
  1292. } : {
  1293. add(value) {
  1294. const target = toRaw(this);
  1295. const proto = getProto(target);
  1296. const rawValue = toRaw(value);
  1297. const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
  1298. const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
  1299. if (!hadKey) {
  1300. target.add(valueToAdd);
  1301. trigger(target, "add", valueToAdd, valueToAdd);
  1302. }
  1303. return this;
  1304. },
  1305. set(key, value) {
  1306. if (!shallow && !isShallow(value) && !isReadonly(value)) {
  1307. value = toRaw(value);
  1308. }
  1309. const target = toRaw(this);
  1310. const { has, get } = getProto(target);
  1311. let hadKey = has.call(target, key);
  1312. if (!hadKey) {
  1313. key = toRaw(key);
  1314. hadKey = has.call(target, key);
  1315. } else {
  1316. checkIdentityKeys(target, has, key);
  1317. }
  1318. const oldValue = get.call(target, key);
  1319. target.set(key, value);
  1320. if (!hadKey) {
  1321. trigger(target, "add", key, value);
  1322. } else if (hasChanged(value, oldValue)) {
  1323. trigger(target, "set", key, value, oldValue);
  1324. }
  1325. return this;
  1326. },
  1327. delete(key) {
  1328. const target = toRaw(this);
  1329. const { has, get } = getProto(target);
  1330. let hadKey = has.call(target, key);
  1331. if (!hadKey) {
  1332. key = toRaw(key);
  1333. hadKey = has.call(target, key);
  1334. } else {
  1335. checkIdentityKeys(target, has, key);
  1336. }
  1337. const oldValue = get ? get.call(target, key) : void 0;
  1338. const result = target.delete(key);
  1339. if (hadKey) {
  1340. trigger(target, "delete", key, void 0, oldValue);
  1341. }
  1342. return result;
  1343. },
  1344. clear() {
  1345. const target = toRaw(this);
  1346. const hadItems = target.size !== 0;
  1347. const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
  1348. const result = target.clear();
  1349. if (hadItems) {
  1350. trigger(
  1351. target,
  1352. "clear",
  1353. void 0,
  1354. void 0,
  1355. oldTarget
  1356. );
  1357. }
  1358. return result;
  1359. }
  1360. }
  1361. );
  1362. const iteratorMethods = [
  1363. "keys",
  1364. "values",
  1365. "entries",
  1366. Symbol.iterator
  1367. ];
  1368. iteratorMethods.forEach((method) => {
  1369. instrumentations[method] = createIterableMethod(method, readonly, shallow);
  1370. });
  1371. return instrumentations;
  1372. }
  1373. function createInstrumentationGetter(isReadonly2, shallow) {
  1374. const instrumentations = createInstrumentations(isReadonly2, shallow);
  1375. return (target, key, receiver) => {
  1376. if (key === "__v_isReactive") {
  1377. return !isReadonly2;
  1378. } else if (key === "__v_isReadonly") {
  1379. return isReadonly2;
  1380. } else if (key === "__v_raw") {
  1381. return target;
  1382. }
  1383. return Reflect.get(
  1384. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1385. key,
  1386. receiver
  1387. );
  1388. };
  1389. }
  1390. const mutableCollectionHandlers = {
  1391. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1392. };
  1393. const shallowCollectionHandlers = {
  1394. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1395. };
  1396. const readonlyCollectionHandlers = {
  1397. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1398. };
  1399. const shallowReadonlyCollectionHandlers = {
  1400. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1401. };
  1402. function checkIdentityKeys(target, has, key) {
  1403. const rawKey = toRaw(key);
  1404. if (rawKey !== key && has.call(target, rawKey)) {
  1405. const type = toRawType(target);
  1406. warn(
  1407. `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.`
  1408. );
  1409. }
  1410. }
  1411. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1412. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1413. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1414. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1415. function targetTypeMap(rawType) {
  1416. switch (rawType) {
  1417. case "Object":
  1418. case "Array":
  1419. return 1 /* COMMON */;
  1420. case "Map":
  1421. case "Set":
  1422. case "WeakMap":
  1423. case "WeakSet":
  1424. return 2 /* COLLECTION */;
  1425. default:
  1426. return 0 /* INVALID */;
  1427. }
  1428. }
  1429. // @__NO_SIDE_EFFECTS__
  1430. function reactive(target) {
  1431. if (/* @__PURE__ */ isReadonly(target)) {
  1432. return target;
  1433. }
  1434. return createReactiveObject(
  1435. target,
  1436. false,
  1437. mutableHandlers,
  1438. mutableCollectionHandlers,
  1439. reactiveMap
  1440. );
  1441. }
  1442. // @__NO_SIDE_EFFECTS__
  1443. function shallowReactive(target) {
  1444. return createReactiveObject(
  1445. target,
  1446. false,
  1447. shallowReactiveHandlers,
  1448. shallowCollectionHandlers,
  1449. shallowReactiveMap
  1450. );
  1451. }
  1452. // @__NO_SIDE_EFFECTS__
  1453. function readonly(target) {
  1454. return createReactiveObject(
  1455. target,
  1456. true,
  1457. readonlyHandlers,
  1458. readonlyCollectionHandlers,
  1459. readonlyMap
  1460. );
  1461. }
  1462. // @__NO_SIDE_EFFECTS__
  1463. function shallowReadonly(target) {
  1464. return createReactiveObject(
  1465. target,
  1466. true,
  1467. shallowReadonlyHandlers,
  1468. shallowReadonlyCollectionHandlers,
  1469. shallowReadonlyMap
  1470. );
  1471. }
  1472. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1473. if (!isObject(target)) {
  1474. {
  1475. warn(
  1476. `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
  1477. target
  1478. )}`
  1479. );
  1480. }
  1481. return target;
  1482. }
  1483. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1484. return target;
  1485. }
  1486. if (target["__v_skip"] || !Object.isExtensible(target)) {
  1487. return target;
  1488. }
  1489. const existingProxy = proxyMap.get(target);
  1490. if (existingProxy) {
  1491. return existingProxy;
  1492. }
  1493. const targetType = targetTypeMap(toRawType(target));
  1494. if (targetType === 0 /* INVALID */) {
  1495. return target;
  1496. }
  1497. const proxy = new Proxy(
  1498. target,
  1499. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1500. );
  1501. proxyMap.set(target, proxy);
  1502. return proxy;
  1503. }
  1504. // @__NO_SIDE_EFFECTS__
  1505. function isReactive(value) {
  1506. if (/* @__PURE__ */ isReadonly(value)) {
  1507. return /* @__PURE__ */ isReactive(value["__v_raw"]);
  1508. }
  1509. return !!(value && value["__v_isReactive"]);
  1510. }
  1511. // @__NO_SIDE_EFFECTS__
  1512. function isReadonly(value) {
  1513. return !!(value && value["__v_isReadonly"]);
  1514. }
  1515. // @__NO_SIDE_EFFECTS__
  1516. function isShallow(value) {
  1517. return !!(value && value["__v_isShallow"]);
  1518. }
  1519. // @__NO_SIDE_EFFECTS__
  1520. function isProxy(value) {
  1521. return value ? !!value["__v_raw"] : false;
  1522. }
  1523. // @__NO_SIDE_EFFECTS__
  1524. function toRaw(observed) {
  1525. const raw = observed && observed["__v_raw"];
  1526. return raw ? /* @__PURE__ */ toRaw(raw) : observed;
  1527. }
  1528. function markRaw(value) {
  1529. if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
  1530. def(value, "__v_skip", true);
  1531. }
  1532. return value;
  1533. }
  1534. const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
  1535. const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
  1536. // @__NO_SIDE_EFFECTS__
  1537. function isRef(r) {
  1538. return r ? r["__v_isRef"] === true : false;
  1539. }
  1540. // @__NO_SIDE_EFFECTS__
  1541. function ref(value) {
  1542. return createRef(value, false);
  1543. }
  1544. // @__NO_SIDE_EFFECTS__
  1545. function shallowRef(value) {
  1546. return createRef(value, true);
  1547. }
  1548. function createRef(rawValue, shallow) {
  1549. if (/* @__PURE__ */ isRef(rawValue)) {
  1550. return rawValue;
  1551. }
  1552. return new RefImpl(rawValue, shallow);
  1553. }
  1554. class RefImpl {
  1555. constructor(value, isShallow2) {
  1556. this.dep = new Dep();
  1557. this["__v_isRef"] = true;
  1558. this["__v_isShallow"] = false;
  1559. this._rawValue = isShallow2 ? value : toRaw(value);
  1560. this._value = isShallow2 ? value : toReactive(value);
  1561. this["__v_isShallow"] = isShallow2;
  1562. }
  1563. get value() {
  1564. {
  1565. this.dep.track({
  1566. target: this,
  1567. type: "get",
  1568. key: "value"
  1569. });
  1570. }
  1571. return this._value;
  1572. }
  1573. set value(newValue) {
  1574. const oldValue = this._rawValue;
  1575. const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
  1576. newValue = useDirectValue ? newValue : toRaw(newValue);
  1577. if (hasChanged(newValue, oldValue)) {
  1578. this._rawValue = newValue;
  1579. this._value = useDirectValue ? newValue : toReactive(newValue);
  1580. {
  1581. this.dep.trigger({
  1582. target: this,
  1583. type: "set",
  1584. key: "value",
  1585. newValue,
  1586. oldValue
  1587. });
  1588. }
  1589. }
  1590. }
  1591. }
  1592. function triggerRef(ref2) {
  1593. if (ref2.dep) {
  1594. {
  1595. ref2.dep.trigger({
  1596. target: ref2,
  1597. type: "set",
  1598. key: "value",
  1599. newValue: ref2._value
  1600. });
  1601. }
  1602. }
  1603. }
  1604. function unref(ref2) {
  1605. return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
  1606. }
  1607. function toValue(source) {
  1608. return isFunction(source) ? source() : unref(source);
  1609. }
  1610. const shallowUnwrapHandlers = {
  1611. get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
  1612. set: (target, key, value, receiver) => {
  1613. const oldValue = target[key];
  1614. if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
  1615. oldValue.value = value;
  1616. return true;
  1617. } else {
  1618. return Reflect.set(target, key, value, receiver);
  1619. }
  1620. }
  1621. };
  1622. function proxyRefs(objectWithRefs) {
  1623. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1624. }
  1625. class CustomRefImpl {
  1626. constructor(factory) {
  1627. this["__v_isRef"] = true;
  1628. this._value = void 0;
  1629. const dep = this.dep = new Dep();
  1630. const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
  1631. this._get = get;
  1632. this._set = set;
  1633. }
  1634. get value() {
  1635. return this._value = this._get();
  1636. }
  1637. set value(newVal) {
  1638. this._set(newVal);
  1639. }
  1640. }
  1641. function customRef(factory) {
  1642. return new CustomRefImpl(factory);
  1643. }
  1644. // @__NO_SIDE_EFFECTS__
  1645. function toRefs(object) {
  1646. if (!isProxy(object)) {
  1647. warn(`toRefs() expects a reactive object but received a plain one.`);
  1648. }
  1649. const ret = isArray(object) ? new Array(object.length) : {};
  1650. for (const key in object) {
  1651. ret[key] = propertyToRef(object, key);
  1652. }
  1653. return ret;
  1654. }
  1655. class ObjectRefImpl {
  1656. constructor(_object, key, _defaultValue) {
  1657. this._object = _object;
  1658. this._defaultValue = _defaultValue;
  1659. this["__v_isRef"] = true;
  1660. this._value = void 0;
  1661. this._key = isSymbol(key) ? key : String(key);
  1662. this._raw = toRaw(_object);
  1663. let shallow = true;
  1664. let obj = _object;
  1665. if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
  1666. do {
  1667. shallow = !isProxy(obj) || isShallow(obj);
  1668. } while (shallow && (obj = obj["__v_raw"]));
  1669. }
  1670. this._shallow = shallow;
  1671. }
  1672. get value() {
  1673. let val = this._object[this._key];
  1674. if (this._shallow) {
  1675. val = unref(val);
  1676. }
  1677. return this._value = val === void 0 ? this._defaultValue : val;
  1678. }
  1679. set value(newVal) {
  1680. if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
  1681. const nestedRef = this._object[this._key];
  1682. if (/* @__PURE__ */ isRef(nestedRef)) {
  1683. nestedRef.value = newVal;
  1684. return;
  1685. }
  1686. }
  1687. this._object[this._key] = newVal;
  1688. }
  1689. get dep() {
  1690. return getDepFromReactive(this._raw, this._key);
  1691. }
  1692. }
  1693. class GetterRefImpl {
  1694. constructor(_getter) {
  1695. this._getter = _getter;
  1696. this["__v_isRef"] = true;
  1697. this["__v_isReadonly"] = true;
  1698. this._value = void 0;
  1699. }
  1700. get value() {
  1701. return this._value = this._getter();
  1702. }
  1703. }
  1704. // @__NO_SIDE_EFFECTS__
  1705. function toRef(source, key, defaultValue) {
  1706. if (/* @__PURE__ */ isRef(source)) {
  1707. return source;
  1708. } else if (isFunction(source)) {
  1709. return new GetterRefImpl(source);
  1710. } else if (isObject(source) && arguments.length > 1) {
  1711. return propertyToRef(source, key, defaultValue);
  1712. } else {
  1713. return /* @__PURE__ */ ref(source);
  1714. }
  1715. }
  1716. function propertyToRef(source, key, defaultValue) {
  1717. return new ObjectRefImpl(source, key, defaultValue);
  1718. }
  1719. class ComputedRefImpl {
  1720. constructor(fn, setter, isSSR) {
  1721. this.fn = fn;
  1722. this.setter = setter;
  1723. /**
  1724. * @internal
  1725. */
  1726. this._value = void 0;
  1727. /**
  1728. * @internal
  1729. */
  1730. this.dep = new Dep(this);
  1731. /**
  1732. * @internal
  1733. */
  1734. this.__v_isRef = true;
  1735. // TODO isolatedDeclarations "__v_isReadonly"
  1736. // A computed is also a subscriber that tracks other deps
  1737. /**
  1738. * @internal
  1739. */
  1740. this.deps = void 0;
  1741. /**
  1742. * @internal
  1743. */
  1744. this.depsTail = void 0;
  1745. /**
  1746. * @internal
  1747. */
  1748. this.flags = 16;
  1749. /**
  1750. * @internal
  1751. */
  1752. this.globalVersion = globalVersion - 1;
  1753. /**
  1754. * @internal
  1755. */
  1756. this.next = void 0;
  1757. // for backwards compat
  1758. this.effect = this;
  1759. this["__v_isReadonly"] = !setter;
  1760. this.isSSR = isSSR;
  1761. }
  1762. /**
  1763. * @internal
  1764. */
  1765. notify() {
  1766. this.flags |= 16;
  1767. if (!(this.flags & 8) && // avoid infinite self recursion
  1768. activeSub !== this) {
  1769. batch(this, true);
  1770. return true;
  1771. }
  1772. }
  1773. get value() {
  1774. const link = this.dep.track({
  1775. target: this,
  1776. type: "get",
  1777. key: "value"
  1778. }) ;
  1779. refreshComputed(this);
  1780. if (link) {
  1781. link.version = this.dep.version;
  1782. }
  1783. return this._value;
  1784. }
  1785. set value(newValue) {
  1786. if (this.setter) {
  1787. this.setter(newValue);
  1788. } else {
  1789. warn("Write operation failed: computed value is readonly");
  1790. }
  1791. }
  1792. }
  1793. // @__NO_SIDE_EFFECTS__
  1794. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1795. let getter;
  1796. let setter;
  1797. if (isFunction(getterOrOptions)) {
  1798. getter = getterOrOptions;
  1799. } else {
  1800. getter = getterOrOptions.get;
  1801. setter = getterOrOptions.set;
  1802. }
  1803. const cRef = new ComputedRefImpl(getter, setter, isSSR);
  1804. if (debugOptions && !isSSR) {
  1805. cRef.onTrack = debugOptions.onTrack;
  1806. cRef.onTrigger = debugOptions.onTrigger;
  1807. }
  1808. return cRef;
  1809. }
  1810. const TrackOpTypes = {
  1811. "GET": "get",
  1812. "HAS": "has",
  1813. "ITERATE": "iterate"
  1814. };
  1815. const TriggerOpTypes = {
  1816. "SET": "set",
  1817. "ADD": "add",
  1818. "DELETE": "delete",
  1819. "CLEAR": "clear"
  1820. };
  1821. const ReactiveFlags = {
  1822. "SKIP": "__v_skip",
  1823. "IS_REACTIVE": "__v_isReactive",
  1824. "IS_READONLY": "__v_isReadonly",
  1825. "IS_SHALLOW": "__v_isShallow",
  1826. "RAW": "__v_raw",
  1827. "IS_REF": "__v_isRef"
  1828. };
  1829. const WatchErrorCodes = {
  1830. "WATCH_GETTER": 2,
  1831. "2": "WATCH_GETTER",
  1832. "WATCH_CALLBACK": 3,
  1833. "3": "WATCH_CALLBACK",
  1834. "WATCH_CLEANUP": 4,
  1835. "4": "WATCH_CLEANUP"
  1836. };
  1837. const INITIAL_WATCHER_VALUE = {};
  1838. const cleanupMap = /* @__PURE__ */ new WeakMap();
  1839. let activeWatcher = void 0;
  1840. function getCurrentWatcher() {
  1841. return activeWatcher;
  1842. }
  1843. function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
  1844. if (owner) {
  1845. let cleanups = cleanupMap.get(owner);
  1846. if (!cleanups) cleanupMap.set(owner, cleanups = []);
  1847. cleanups.push(cleanupFn);
  1848. } else if (!failSilently) {
  1849. warn(
  1850. `onWatcherCleanup() was called when there was no active watcher to associate with.`
  1851. );
  1852. }
  1853. }
  1854. function watch(source, cb, options = EMPTY_OBJ) {
  1855. const { immediate, deep, once, scheduler, augmentJob, call } = options;
  1856. const warnInvalidSource = (s) => {
  1857. (options.onWarn || warn)(
  1858. `Invalid watch source: `,
  1859. s,
  1860. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  1861. );
  1862. };
  1863. const reactiveGetter = (source2) => {
  1864. if (deep) return source2;
  1865. if (isShallow(source2) || deep === false || deep === 0)
  1866. return traverse(source2, 1);
  1867. return traverse(source2);
  1868. };
  1869. let effect;
  1870. let getter;
  1871. let cleanup;
  1872. let boundCleanup;
  1873. let forceTrigger = false;
  1874. let isMultiSource = false;
  1875. if (isRef(source)) {
  1876. getter = () => source.value;
  1877. forceTrigger = isShallow(source);
  1878. } else if (isReactive(source)) {
  1879. getter = () => reactiveGetter(source);
  1880. forceTrigger = true;
  1881. } else if (isArray(source)) {
  1882. isMultiSource = true;
  1883. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  1884. getter = () => source.map((s) => {
  1885. if (isRef(s)) {
  1886. return s.value;
  1887. } else if (isReactive(s)) {
  1888. return reactiveGetter(s);
  1889. } else if (isFunction(s)) {
  1890. return call ? call(s, 2) : s();
  1891. } else {
  1892. warnInvalidSource(s);
  1893. }
  1894. });
  1895. } else if (isFunction(source)) {
  1896. if (cb) {
  1897. getter = call ? () => call(source, 2) : source;
  1898. } else {
  1899. getter = () => {
  1900. if (cleanup) {
  1901. pauseTracking();
  1902. try {
  1903. cleanup();
  1904. } finally {
  1905. resetTracking();
  1906. }
  1907. }
  1908. const currentEffect = activeWatcher;
  1909. activeWatcher = effect;
  1910. try {
  1911. return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
  1912. } finally {
  1913. activeWatcher = currentEffect;
  1914. }
  1915. };
  1916. }
  1917. } else {
  1918. getter = NOOP;
  1919. warnInvalidSource(source);
  1920. }
  1921. if (cb && deep) {
  1922. const baseGetter = getter;
  1923. const depth = deep === true ? Infinity : deep;
  1924. getter = () => traverse(baseGetter(), depth);
  1925. }
  1926. const scope = getCurrentScope();
  1927. const watchHandle = () => {
  1928. effect.stop();
  1929. if (scope && scope.active) {
  1930. remove(scope.effects, effect);
  1931. }
  1932. };
  1933. if (once && cb) {
  1934. const _cb = cb;
  1935. cb = (...args) => {
  1936. const res = _cb(...args);
  1937. watchHandle();
  1938. return res;
  1939. };
  1940. }
  1941. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  1942. const job = (immediateFirstRun) => {
  1943. if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
  1944. return;
  1945. }
  1946. if (cb) {
  1947. const newValue = effect.run();
  1948. if (immediateFirstRun || deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
  1949. if (cleanup) {
  1950. cleanup();
  1951. }
  1952. const currentWatcher = activeWatcher;
  1953. activeWatcher = effect;
  1954. try {
  1955. const args = [
  1956. newValue,
  1957. // pass undefined as the old value when it's changed for the first time
  1958. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  1959. boundCleanup
  1960. ];
  1961. oldValue = newValue;
  1962. call ? call(cb, 3, args) : (
  1963. // @ts-expect-error
  1964. cb(...args)
  1965. );
  1966. } finally {
  1967. activeWatcher = currentWatcher;
  1968. }
  1969. }
  1970. } else {
  1971. effect.run();
  1972. }
  1973. };
  1974. if (augmentJob) {
  1975. augmentJob(job);
  1976. }
  1977. effect = new ReactiveEffect(getter);
  1978. effect.scheduler = scheduler ? () => scheduler(job, false) : job;
  1979. boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
  1980. cleanup = effect.onStop = () => {
  1981. const cleanups = cleanupMap.get(effect);
  1982. if (cleanups) {
  1983. if (call) {
  1984. call(cleanups, 4);
  1985. } else {
  1986. for (const cleanup2 of cleanups) cleanup2();
  1987. }
  1988. cleanupMap.delete(effect);
  1989. }
  1990. };
  1991. {
  1992. effect.onTrack = options.onTrack;
  1993. effect.onTrigger = options.onTrigger;
  1994. }
  1995. if (cb) {
  1996. if (immediate) {
  1997. job(true);
  1998. } else {
  1999. oldValue = effect.run();
  2000. }
  2001. } else if (scheduler) {
  2002. scheduler(job.bind(null, true), true);
  2003. } else {
  2004. effect.run();
  2005. }
  2006. watchHandle.pause = effect.pause.bind(effect);
  2007. watchHandle.resume = effect.resume.bind(effect);
  2008. watchHandle.stop = watchHandle;
  2009. return watchHandle;
  2010. }
  2011. function traverse(value, depth = Infinity, seen) {
  2012. if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
  2013. return value;
  2014. }
  2015. seen = seen || /* @__PURE__ */ new Map();
  2016. if ((seen.get(value) || 0) >= depth) {
  2017. return value;
  2018. }
  2019. seen.set(value, depth);
  2020. depth--;
  2021. if (isRef(value)) {
  2022. traverse(value.value, depth, seen);
  2023. } else if (isArray(value)) {
  2024. for (let i = 0; i < value.length; i++) {
  2025. traverse(value[i], depth, seen);
  2026. }
  2027. } else if (isSet(value) || isMap(value)) {
  2028. value.forEach((v) => {
  2029. traverse(v, depth, seen);
  2030. });
  2031. } else if (isPlainObject(value)) {
  2032. for (const key in value) {
  2033. traverse(value[key], depth, seen);
  2034. }
  2035. for (const key of Object.getOwnPropertySymbols(value)) {
  2036. if (Object.prototype.propertyIsEnumerable.call(value, key)) {
  2037. traverse(value[key], depth, seen);
  2038. }
  2039. }
  2040. }
  2041. return value;
  2042. }
  2043. export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, traverse, trigger, triggerRef, unref, watch };