智慧水务管理系统 - 精河县供水工程综合管理平台

reactivity.global.js 58KB

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