@jxsuite/studio 2.4.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/chunks/{cf-settings-g5fbf2zp.js → cf-settings-zj2cj1ar.js} +6 -3
  2. package/dist/chunks/{content-source-k9724vcv.js → content-source-7fy9qrm0.js} +10 -9
  3. package/dist/chunks/{convert-to-repeater-k10dvcc7.js → convert-to-repeater-6vvx96n2.js} +9 -8
  4. package/dist/chunks/{extension-sections-0ada0xcw.js → extension-sections-kwzvpemr.js} +13 -12
  5. package/dist/chunks/{files-yew27sn9.js → files-xcybanxe.js} +14 -13
  6. package/dist/chunks/{format-host-wewba4nq.js → format-host-8fr3545e.js} +2 -2
  7. package/dist/chunks/{git-panel-2dh1aw50.js → git-panel-g01d93vc.js} +9 -8
  8. package/dist/chunks/{layers-panel-qnsghwwd.js → layers-panel-27essgkc.js} +12 -11
  9. package/dist/chunks/{publish-panel-a0pdft5w.js → publish-panel-09sy2bab.js} +8 -7
  10. package/dist/chunks/{quick-search-9avyc4pc.js → quick-search-sefb61v8.js} +15 -14
  11. package/dist/chunks/{right-panel-kcnhtc5j.js → right-panel-9r32jd5j.js} +11 -10
  12. package/dist/chunks/{studio-aweyr4v1.js → studio-2x9zbxmx.js} +2 -2
  13. package/dist/chunks/{studio-ef8t53vc.js → studio-3dkcd4c5.js} +3 -3
  14. package/dist/chunks/{studio-hb7c46jy.js → studio-5efrtn1m.js} +9 -7
  15. package/dist/chunks/{studio-v1va0vhd.js → studio-6z5eyjwn.js} +24 -25
  16. package/dist/chunks/{studio-ke244pam.js → studio-7p35254k.js} +33 -11
  17. package/dist/chunks/{studio-f5yyvqxv.js → studio-8ezdegcx.js} +13 -11
  18. package/dist/chunks/{studio-cz2j1c0g.js → studio-a0yp7syn.js} +55 -18
  19. package/dist/chunks/{studio-26sv44br.js → studio-dc8s8heb.js} +34 -23
  20. package/dist/chunks/{studio-jnakhg87.js → studio-g5gdqnyd.js} +4 -4
  21. package/dist/chunks/{studio-rqemfhz6.js → studio-hcxzyk3x.js} +2 -2
  22. package/dist/chunks/{studio-ws6ef6js.js → studio-hj2se583.js} +12 -10
  23. package/dist/chunks/{studio-pyrw8h0w.js → studio-j595e748.js} +407 -167
  24. package/dist/chunks/{studio-dgj7gq44.js → studio-k4jvjcfx.js} +4 -4
  25. package/dist/chunks/studio-kfpek536.js +28 -0
  26. package/dist/chunks/{studio-sccge2wf.js → studio-p5dja96s.js} +2 -2
  27. package/dist/chunks/{studio-0b6fs05q.js → studio-pkp61mh8.js} +5 -5
  28. package/dist/chunks/studio-qpfq7xhm.js +1802 -0
  29. package/dist/chunks/{studio-ra7ar50f.js → studio-r5xbtctf.js} +51 -1565
  30. package/dist/chunks/{studio-v2c5pmjj.js → studio-rh1cnamv.js} +17 -15
  31. package/dist/chunks/{studio-28xc8ws4.js → studio-ry1vz5sv.js} +10 -8
  32. package/dist/chunks/{studio-hyn3vhwr.js → studio-xntfdy1x.js} +5 -5
  33. package/dist/iframe-entry.js +344 -26
  34. package/dist/studio.js +274 -247
  35. package/package.json +9 -9
  36. package/src/browse/library-layouts.ts +3 -3
  37. package/src/browse/library-pane.ts +2 -2
  38. package/src/browse/library-preview.ts +19 -3
  39. package/src/canvas/asset-refs.ts +119 -0
  40. package/src/canvas/asset-resolve.ts +256 -0
  41. package/src/canvas/canvas-live-render.ts +23 -15
  42. package/src/canvas/iframe-entry.ts +1 -0
  43. package/src/canvas/iframe-host.ts +4 -0
  44. package/src/canvas/iframe-protocol.ts +9 -0
  45. package/src/canvas/iframe-render.ts +28 -10
  46. package/src/canvas/site-style-css.ts +2 -6
  47. package/src/editor/file-drop-action.ts +2 -1
  48. package/src/files/files.ts +2 -2
  49. package/src/files/media-paths.ts +37 -14
  50. package/src/files/media-upload.ts +47 -6
  51. package/src/grid/grid-idle.ts +45 -0
  52. package/src/grid/grid-view.ts +21 -0
  53. package/src/grid/schema-columns.ts +2 -1
  54. package/src/grid/sources/content-source.ts +24 -3
  55. package/src/new-project/import-tab.ts +3 -2
  56. package/src/panels/ai-chat/composer.ts +30 -13
  57. package/src/panels/frontmatter-fields.ts +6 -2
  58. package/src/panels/properties-panel.ts +8 -2
  59. package/src/panels/seo-modal.ts +5 -6
  60. package/src/panels/signals-panel.ts +2 -1
  61. package/src/platforms/cloud.ts +14 -3
  62. package/src/platforms/devserver.ts +5 -1
  63. package/src/services/ai-models.ts +101 -11
  64. package/src/services/ai-settings.ts +69 -71
  65. package/src/services/cf-settings.ts +19 -37
  66. package/src/services/document-assistant.ts +4 -3
  67. package/src/services/idle.ts +6 -1
  68. package/src/services/settings/definitions.ts +164 -0
  69. package/src/services/settings/kernel.ts +335 -0
  70. package/src/services/settings/write-queue.ts +116 -0
  71. package/src/settings/preferences-accounts.ts +6 -19
  72. package/src/settings/preferences-keymap.ts +8 -18
  73. package/src/settings/schema-field-ui.ts +2 -2
  74. package/src/shell.ts +6 -14
  75. package/src/studio.ts +32 -1
  76. package/src/types.ts +61 -3
  77. package/src/ui/ai-credentials-form.ts +52 -27
  78. package/src/ui/media-picker.ts +6 -11
  79. package/src/utils/studio-utils.ts +45 -3
  80. package/dist/chunks/studio-a7pzveq1.js +0 -110
  81. package/src/canvas/content-assets.ts +0 -263
  82. package/src/services/settings-store.ts +0 -99
@@ -0,0 +1,1802 @@
1
+ import {
2
+ getPlatform,
3
+ hasPlatform
4
+ } from "./studio-sas7mt3k.js";
5
+
6
+ // ../../node_modules/@vue/shared/dist/shared.esm-bundler.js
7
+ function makeMap(str) {
8
+ const map = /* @__PURE__ */ Object.create(null);
9
+ for (const key of str.split(","))
10
+ map[key] = 1;
11
+ return (val) => (val in map);
12
+ }
13
+ var EMPTY_OBJ = Object.freeze({});
14
+ var EMPTY_ARR = Object.freeze([]);
15
+ var extend = Object.assign;
16
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
17
+ var hasOwn = (val, key) => hasOwnProperty.call(val, key);
18
+ var isArray = Array.isArray;
19
+ var isMap = (val) => toTypeString(val) === "[object Map]";
20
+ var isFunction = (val) => typeof val === "function";
21
+ var isString = (val) => typeof val === "string";
22
+ var isSymbol = (val) => typeof val === "symbol";
23
+ var isObject = (val) => val !== null && typeof val === "object";
24
+ var objectToString = Object.prototype.toString;
25
+ var toTypeString = (value) => objectToString.call(value);
26
+ var toRawType = (value) => {
27
+ return toTypeString(value).slice(8, -1);
28
+ };
29
+ var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
30
+ var cacheStringFunction = (fn) => {
31
+ const cache = /* @__PURE__ */ Object.create(null);
32
+ return (str) => {
33
+ const hit = cache[str];
34
+ return hit || (cache[str] = fn(str));
35
+ };
36
+ };
37
+ var camelizeRE = /-\w/g;
38
+ var camelize = cacheStringFunction((str) => {
39
+ return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
40
+ });
41
+ var hyphenateRE = /\B([A-Z])/g;
42
+ var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
43
+ var capitalize = cacheStringFunction((str) => {
44
+ return str.charAt(0).toUpperCase() + str.slice(1);
45
+ });
46
+ var toHandlerKey = cacheStringFunction((str) => {
47
+ const s = str ? `on${capitalize(str)}` : ``;
48
+ return s;
49
+ });
50
+ var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
51
+ var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
52
+ var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
53
+
54
+ // ../../node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
55
+ function warn(msg, ...args) {
56
+ console.warn(`[Vue warn] ${msg}`, ...args);
57
+ }
58
+ var activeEffectScope;
59
+
60
+ class EffectScope {
61
+ constructor(detached = false) {
62
+ this.detached = detached;
63
+ this._active = true;
64
+ this._on = 0;
65
+ this.effects = [];
66
+ this.cleanups = [];
67
+ this._isPaused = false;
68
+ this._warnOnRun = true;
69
+ this.__v_skip = true;
70
+ if (!detached && activeEffectScope) {
71
+ if (activeEffectScope.active) {
72
+ this.parent = activeEffectScope;
73
+ this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
74
+ } else {
75
+ this._active = false;
76
+ this._warnOnRun = false;
77
+ }
78
+ }
79
+ }
80
+ get active() {
81
+ return this._active;
82
+ }
83
+ pause() {
84
+ if (this._active) {
85
+ this._isPaused = true;
86
+ let i, l;
87
+ if (this.scopes) {
88
+ const scopes = this.scopes.slice();
89
+ for (i = 0, l = scopes.length;i < l; i++) {
90
+ scopes[i].pause();
91
+ }
92
+ }
93
+ for (i = 0, l = this.effects.length;i < l; i++) {
94
+ this.effects[i].pause();
95
+ }
96
+ }
97
+ }
98
+ resume() {
99
+ if (this._active) {
100
+ if (this._isPaused) {
101
+ this._isPaused = false;
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].resume();
107
+ }
108
+ }
109
+ const effects = this.effects.slice();
110
+ for (i = 0, l = effects.length;i < l; i++) {
111
+ effects[i].resume();
112
+ }
113
+ }
114
+ }
115
+ }
116
+ run(fn) {
117
+ if (this._active) {
118
+ const currentEffectScope = activeEffectScope;
119
+ try {
120
+ activeEffectScope = this;
121
+ return fn();
122
+ } finally {
123
+ activeEffectScope = currentEffectScope;
124
+ }
125
+ } else if (this._warnOnRun) {
126
+ warn(`cannot run an inactive effect scope.`);
127
+ }
128
+ }
129
+ on() {
130
+ if (++this._on === 1) {
131
+ this.prevScope = activeEffectScope;
132
+ activeEffectScope = this;
133
+ }
134
+ }
135
+ off() {
136
+ if (this._on > 0 && --this._on === 0) {
137
+ if (activeEffectScope === this) {
138
+ activeEffectScope = this.prevScope;
139
+ } else {
140
+ let current = activeEffectScope;
141
+ while (current) {
142
+ if (current.prevScope === this) {
143
+ current.prevScope = this.prevScope;
144
+ break;
145
+ }
146
+ current = current.prevScope;
147
+ }
148
+ }
149
+ this.prevScope = undefined;
150
+ }
151
+ }
152
+ stop(fromParent) {
153
+ if (this._active) {
154
+ this._active = false;
155
+ let i, l;
156
+ for (i = 0, l = this.effects.length;i < l; i++) {
157
+ this.effects[i].stop();
158
+ }
159
+ this.effects.length = 0;
160
+ for (i = 0, l = this.cleanups.length;i < l; i++) {
161
+ this.cleanups[i]();
162
+ }
163
+ this.cleanups.length = 0;
164
+ if (this.scopes) {
165
+ const scopes = this.scopes.slice();
166
+ for (i = 0, l = scopes.length;i < l; i++) {
167
+ scopes[i].stop(true);
168
+ }
169
+ this.scopes.length = 0;
170
+ }
171
+ if (!this.detached && this.parent && !fromParent) {
172
+ const last = this.parent.scopes.pop();
173
+ if (last && last !== this) {
174
+ this.parent.scopes[this.index] = last;
175
+ last.index = this.index;
176
+ }
177
+ }
178
+ this.parent = undefined;
179
+ }
180
+ }
181
+ }
182
+ function effectScope(detached) {
183
+ return new EffectScope(detached);
184
+ }
185
+ function onScopeDispose(fn, failSilently = false) {
186
+ if (activeEffectScope) {
187
+ activeEffectScope.cleanups.push(fn);
188
+ } else if (!failSilently) {
189
+ warn(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
190
+ }
191
+ }
192
+ var activeSub;
193
+ var pausedQueueEffects = /* @__PURE__ */ new WeakSet;
194
+
195
+ class ReactiveEffect {
196
+ constructor(fn) {
197
+ this.fn = fn;
198
+ this.deps = undefined;
199
+ this.depsTail = undefined;
200
+ this.flags = 1 | 4;
201
+ this.next = undefined;
202
+ this.cleanup = undefined;
203
+ this.scheduler = undefined;
204
+ if (activeEffectScope) {
205
+ if (activeEffectScope.active) {
206
+ activeEffectScope.effects.push(this);
207
+ } else {
208
+ this.flags &= -2;
209
+ }
210
+ }
211
+ }
212
+ pause() {
213
+ this.flags |= 64;
214
+ }
215
+ resume() {
216
+ if (this.flags & 64) {
217
+ this.flags &= -65;
218
+ if (pausedQueueEffects.has(this)) {
219
+ pausedQueueEffects.delete(this);
220
+ this.trigger();
221
+ }
222
+ }
223
+ }
224
+ notify() {
225
+ if (this.flags & 2 && !(this.flags & 32)) {
226
+ return;
227
+ }
228
+ if (!(this.flags & 8)) {
229
+ batch(this);
230
+ }
231
+ }
232
+ run() {
233
+ if (!(this.flags & 1)) {
234
+ return this.fn();
235
+ }
236
+ this.flags |= 2;
237
+ cleanupEffect(this);
238
+ prepareDeps(this);
239
+ const prevEffect = activeSub;
240
+ const prevShouldTrack = shouldTrack;
241
+ activeSub = this;
242
+ shouldTrack = true;
243
+ try {
244
+ return this.fn();
245
+ } finally {
246
+ if (activeSub !== this) {
247
+ warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
248
+ }
249
+ cleanupDeps(this);
250
+ activeSub = prevEffect;
251
+ shouldTrack = prevShouldTrack;
252
+ this.flags &= -3;
253
+ }
254
+ }
255
+ stop() {
256
+ if (this.flags & 1) {
257
+ for (let link = this.deps;link; link = link.nextDep) {
258
+ removeSub(link);
259
+ }
260
+ this.deps = this.depsTail = undefined;
261
+ cleanupEffect(this);
262
+ this.onStop && this.onStop();
263
+ this.flags &= -2;
264
+ }
265
+ }
266
+ trigger() {
267
+ if (this.flags & 64) {
268
+ pausedQueueEffects.add(this);
269
+ } else if (this.scheduler) {
270
+ this.scheduler();
271
+ } else {
272
+ this.runIfDirty();
273
+ }
274
+ }
275
+ runIfDirty() {
276
+ if (isDirty(this)) {
277
+ this.run();
278
+ }
279
+ }
280
+ get dirty() {
281
+ return isDirty(this);
282
+ }
283
+ }
284
+ var batchDepth = 0;
285
+ var batchedSub;
286
+ var batchedComputed;
287
+ function batch(sub, isComputed = false) {
288
+ sub.flags |= 8;
289
+ if (isComputed) {
290
+ sub.next = batchedComputed;
291
+ batchedComputed = sub;
292
+ return;
293
+ }
294
+ sub.next = batchedSub;
295
+ batchedSub = sub;
296
+ }
297
+ function startBatch() {
298
+ batchDepth++;
299
+ }
300
+ function endBatch() {
301
+ if (--batchDepth > 0) {
302
+ return;
303
+ }
304
+ if (batchedComputed) {
305
+ let e = batchedComputed;
306
+ batchedComputed = undefined;
307
+ while (e) {
308
+ const next = e.next;
309
+ e.next = undefined;
310
+ e.flags &= -9;
311
+ e = next;
312
+ }
313
+ }
314
+ let error;
315
+ while (batchedSub) {
316
+ let e = batchedSub;
317
+ batchedSub = undefined;
318
+ while (e) {
319
+ const next = e.next;
320
+ e.next = undefined;
321
+ e.flags &= -9;
322
+ if (e.flags & 1) {
323
+ try {
324
+ e.trigger();
325
+ } catch (err) {
326
+ if (!error)
327
+ error = err;
328
+ }
329
+ }
330
+ e = next;
331
+ }
332
+ }
333
+ if (error)
334
+ throw error;
335
+ }
336
+ function prepareDeps(sub) {
337
+ for (let link = sub.deps;link; link = link.nextDep) {
338
+ link.version = -1;
339
+ link.prevActiveLink = link.dep.activeLink;
340
+ link.dep.activeLink = link;
341
+ }
342
+ }
343
+ function cleanupDeps(sub) {
344
+ let head;
345
+ let tail = sub.depsTail;
346
+ let link = tail;
347
+ while (link) {
348
+ const prev = link.prevDep;
349
+ if (link.version === -1) {
350
+ if (link === tail)
351
+ tail = prev;
352
+ removeSub(link);
353
+ removeDep(link);
354
+ } else {
355
+ head = link;
356
+ }
357
+ link.dep.activeLink = link.prevActiveLink;
358
+ link.prevActiveLink = undefined;
359
+ link = prev;
360
+ }
361
+ sub.deps = head;
362
+ sub.depsTail = tail;
363
+ }
364
+ function isDirty(sub) {
365
+ for (let link = sub.deps;link; link = link.nextDep) {
366
+ if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
367
+ return true;
368
+ }
369
+ }
370
+ if (sub._dirty) {
371
+ return true;
372
+ }
373
+ return false;
374
+ }
375
+ function refreshComputed(computed) {
376
+ if (computed.flags & 4 && !(computed.flags & 16)) {
377
+ return;
378
+ }
379
+ computed.flags &= -17;
380
+ if (computed.globalVersion === globalVersion) {
381
+ return;
382
+ }
383
+ computed.globalVersion = globalVersion;
384
+ if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) {
385
+ return;
386
+ }
387
+ computed.flags |= 2;
388
+ const dep = computed.dep;
389
+ const prevSub = activeSub;
390
+ const prevShouldTrack = shouldTrack;
391
+ activeSub = computed;
392
+ shouldTrack = true;
393
+ try {
394
+ prepareDeps(computed);
395
+ const value = computed.fn(computed._value);
396
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
397
+ computed.flags |= 128;
398
+ computed._value = value;
399
+ dep.version++;
400
+ }
401
+ } catch (err) {
402
+ dep.version++;
403
+ throw err;
404
+ } finally {
405
+ activeSub = prevSub;
406
+ shouldTrack = prevShouldTrack;
407
+ cleanupDeps(computed);
408
+ computed.flags &= -3;
409
+ }
410
+ }
411
+ function removeSub(link, soft = false) {
412
+ const { dep, prevSub, nextSub } = link;
413
+ if (prevSub) {
414
+ prevSub.nextSub = nextSub;
415
+ link.prevSub = undefined;
416
+ }
417
+ if (nextSub) {
418
+ nextSub.prevSub = prevSub;
419
+ link.nextSub = undefined;
420
+ }
421
+ if (dep.subsHead === link) {
422
+ dep.subsHead = nextSub;
423
+ }
424
+ if (dep.subs === link) {
425
+ dep.subs = prevSub;
426
+ if (!prevSub && dep.computed) {
427
+ dep.computed.flags &= -5;
428
+ for (let l = dep.computed.deps;l; l = l.nextDep) {
429
+ removeSub(l, true);
430
+ }
431
+ }
432
+ }
433
+ if (!soft && !--dep.sc && dep.map) {
434
+ dep.map.delete(dep.key);
435
+ }
436
+ }
437
+ function removeDep(link) {
438
+ const { prevDep, nextDep } = link;
439
+ if (prevDep) {
440
+ prevDep.nextDep = nextDep;
441
+ link.prevDep = undefined;
442
+ }
443
+ if (nextDep) {
444
+ nextDep.prevDep = prevDep;
445
+ link.nextDep = undefined;
446
+ }
447
+ }
448
+ function effect(fn, options) {
449
+ if (fn.effect instanceof ReactiveEffect) {
450
+ fn = fn.effect.fn;
451
+ }
452
+ const e = new ReactiveEffect(fn);
453
+ if (options) {
454
+ extend(e, options);
455
+ }
456
+ try {
457
+ e.run();
458
+ } catch (err) {
459
+ e.stop();
460
+ throw err;
461
+ }
462
+ const runner = e.run.bind(e);
463
+ runner.effect = e;
464
+ return runner;
465
+ }
466
+ var shouldTrack = true;
467
+ var trackStack = [];
468
+ function pauseTracking() {
469
+ trackStack.push(shouldTrack);
470
+ shouldTrack = false;
471
+ }
472
+ function resetTracking() {
473
+ const last = trackStack.pop();
474
+ shouldTrack = last === undefined ? true : last;
475
+ }
476
+ function onEffectCleanup(fn, failSilently = false) {
477
+ if (activeSub instanceof ReactiveEffect) {
478
+ activeSub.cleanup = fn;
479
+ } else if (!failSilently) {
480
+ warn(`onEffectCleanup() was called when there was no active effect to associate with.`);
481
+ }
482
+ }
483
+ function cleanupEffect(e) {
484
+ const { cleanup } = e;
485
+ e.cleanup = undefined;
486
+ if (cleanup) {
487
+ const prevSub = activeSub;
488
+ activeSub = undefined;
489
+ try {
490
+ cleanup();
491
+ } finally {
492
+ activeSub = prevSub;
493
+ }
494
+ }
495
+ }
496
+ var globalVersion = 0;
497
+
498
+ class Link {
499
+ constructor(sub, dep) {
500
+ this.sub = sub;
501
+ this.dep = dep;
502
+ this.version = dep.version;
503
+ this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = undefined;
504
+ }
505
+ }
506
+
507
+ class Dep {
508
+ constructor(computed) {
509
+ this.computed = computed;
510
+ this.version = 0;
511
+ this.activeLink = undefined;
512
+ this.subs = undefined;
513
+ this.map = undefined;
514
+ this.key = undefined;
515
+ this.sc = 0;
516
+ this.__v_skip = true;
517
+ if (true) {
518
+ this.subsHead = undefined;
519
+ }
520
+ }
521
+ track(debugInfo) {
522
+ if (!activeSub || !shouldTrack || activeSub === this.computed) {
523
+ return;
524
+ }
525
+ let link = this.activeLink;
526
+ if (link === undefined || link.sub !== activeSub) {
527
+ link = this.activeLink = new Link(activeSub, this);
528
+ if (!activeSub.deps) {
529
+ activeSub.deps = activeSub.depsTail = link;
530
+ } else {
531
+ link.prevDep = activeSub.depsTail;
532
+ activeSub.depsTail.nextDep = link;
533
+ activeSub.depsTail = link;
534
+ }
535
+ addSub(link);
536
+ } else if (link.version === -1) {
537
+ link.version = this.version;
538
+ if (link.nextDep) {
539
+ const next = link.nextDep;
540
+ next.prevDep = link.prevDep;
541
+ if (link.prevDep) {
542
+ link.prevDep.nextDep = next;
543
+ }
544
+ link.prevDep = activeSub.depsTail;
545
+ link.nextDep = undefined;
546
+ activeSub.depsTail.nextDep = link;
547
+ activeSub.depsTail = link;
548
+ if (activeSub.deps === link) {
549
+ activeSub.deps = next;
550
+ }
551
+ }
552
+ }
553
+ if (activeSub.onTrack) {
554
+ activeSub.onTrack(extend({
555
+ effect: activeSub
556
+ }, debugInfo));
557
+ }
558
+ return link;
559
+ }
560
+ trigger(debugInfo) {
561
+ this.version++;
562
+ globalVersion++;
563
+ this.notify(debugInfo);
564
+ }
565
+ notify(debugInfo) {
566
+ startBatch();
567
+ try {
568
+ if (true) {
569
+ for (let head = this.subsHead;head; head = head.nextSub) {
570
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
571
+ head.sub.onTrigger(extend({
572
+ effect: head.sub
573
+ }, debugInfo));
574
+ }
575
+ }
576
+ }
577
+ for (let link = this.subs;link; link = link.prevSub) {
578
+ if (link.sub.notify()) {
579
+ link.sub.dep.notify();
580
+ }
581
+ }
582
+ } finally {
583
+ endBatch();
584
+ }
585
+ }
586
+ }
587
+ function addSub(link) {
588
+ link.dep.sc++;
589
+ if (link.sub.flags & 4) {
590
+ const computed = link.dep.computed;
591
+ if (computed && !link.dep.subs) {
592
+ computed.flags |= 4 | 16;
593
+ for (let l = computed.deps;l; l = l.nextDep) {
594
+ addSub(l);
595
+ }
596
+ }
597
+ const currentTail = link.dep.subs;
598
+ if (currentTail !== link) {
599
+ link.prevSub = currentTail;
600
+ if (currentTail)
601
+ currentTail.nextSub = link;
602
+ }
603
+ if (link.dep.subsHead === undefined) {
604
+ link.dep.subsHead = link;
605
+ }
606
+ link.dep.subs = link;
607
+ }
608
+ }
609
+ var targetMap = /* @__PURE__ */ new WeakMap;
610
+ var ITERATE_KEY = /* @__PURE__ */ Symbol("Object iterate");
611
+ var MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol("Map keys iterate");
612
+ var ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol("Array iterate");
613
+ function track(target, type, key) {
614
+ if (shouldTrack && activeSub) {
615
+ let depsMap = targetMap.get(target);
616
+ if (!depsMap) {
617
+ targetMap.set(target, depsMap = /* @__PURE__ */ new Map);
618
+ }
619
+ let dep = depsMap.get(key);
620
+ if (!dep) {
621
+ depsMap.set(key, dep = new Dep);
622
+ dep.map = depsMap;
623
+ dep.key = key;
624
+ }
625
+ if (true) {
626
+ dep.track({
627
+ target,
628
+ type,
629
+ key
630
+ });
631
+ }
632
+ }
633
+ }
634
+ function trigger(target, type, key, newValue, oldValue, oldTarget) {
635
+ const depsMap = targetMap.get(target);
636
+ if (!depsMap) {
637
+ globalVersion++;
638
+ return;
639
+ }
640
+ const run = (dep) => {
641
+ if (dep) {
642
+ if (true) {
643
+ dep.trigger({
644
+ target,
645
+ type,
646
+ key,
647
+ newValue,
648
+ oldValue,
649
+ oldTarget
650
+ });
651
+ }
652
+ }
653
+ };
654
+ startBatch();
655
+ if (type === "clear") {
656
+ depsMap.forEach(run);
657
+ } else {
658
+ const targetIsArray = isArray(target);
659
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
660
+ if (targetIsArray && key === "length") {
661
+ const newLength = Number(newValue);
662
+ depsMap.forEach((dep, key2) => {
663
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
664
+ run(dep);
665
+ }
666
+ });
667
+ } else {
668
+ if (key !== undefined || depsMap.has(undefined)) {
669
+ run(depsMap.get(key));
670
+ }
671
+ if (isArrayIndex) {
672
+ run(depsMap.get(ARRAY_ITERATE_KEY));
673
+ }
674
+ switch (type) {
675
+ case "add":
676
+ if (!targetIsArray) {
677
+ run(depsMap.get(ITERATE_KEY));
678
+ if (isMap(target)) {
679
+ run(depsMap.get(MAP_KEY_ITERATE_KEY));
680
+ }
681
+ } else if (isArrayIndex) {
682
+ run(depsMap.get("length"));
683
+ }
684
+ break;
685
+ case "delete":
686
+ if (!targetIsArray) {
687
+ run(depsMap.get(ITERATE_KEY));
688
+ if (isMap(target)) {
689
+ run(depsMap.get(MAP_KEY_ITERATE_KEY));
690
+ }
691
+ }
692
+ break;
693
+ case "set":
694
+ if (isMap(target)) {
695
+ run(depsMap.get(ITERATE_KEY));
696
+ }
697
+ break;
698
+ }
699
+ }
700
+ }
701
+ endBatch();
702
+ }
703
+ function reactiveReadArray(array) {
704
+ const raw = toRaw(array);
705
+ if (raw === array)
706
+ return raw;
707
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
708
+ return isShallow(array) ? raw : raw.map(toReactive);
709
+ }
710
+ function shallowReadArray(arr) {
711
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
712
+ return arr;
713
+ }
714
+ function toWrapped(target, item) {
715
+ if (isReadonly(target)) {
716
+ return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
717
+ }
718
+ return toReactive(item);
719
+ }
720
+ var arrayInstrumentations = {
721
+ __proto__: null,
722
+ [Symbol.iterator]() {
723
+ return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
724
+ },
725
+ concat(...args) {
726
+ return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
727
+ },
728
+ entries() {
729
+ return iterator(this, "entries", (value) => {
730
+ value[1] = toWrapped(this, value[1]);
731
+ return value;
732
+ });
733
+ },
734
+ every(fn, thisArg) {
735
+ return apply(this, "every", fn, thisArg, undefined, arguments);
736
+ },
737
+ filter(fn, thisArg) {
738
+ return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
739
+ },
740
+ find(fn, thisArg) {
741
+ return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
742
+ },
743
+ findIndex(fn, thisArg) {
744
+ return apply(this, "findIndex", fn, thisArg, undefined, arguments);
745
+ },
746
+ findLast(fn, thisArg) {
747
+ return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
748
+ },
749
+ findLastIndex(fn, thisArg) {
750
+ return apply(this, "findLastIndex", fn, thisArg, undefined, arguments);
751
+ },
752
+ forEach(fn, thisArg) {
753
+ return apply(this, "forEach", fn, thisArg, undefined, arguments);
754
+ },
755
+ includes(...args) {
756
+ return searchProxy(this, "includes", args);
757
+ },
758
+ indexOf(...args) {
759
+ return searchProxy(this, "indexOf", args);
760
+ },
761
+ join(separator) {
762
+ return reactiveReadArray(this).join(separator);
763
+ },
764
+ lastIndexOf(...args) {
765
+ return searchProxy(this, "lastIndexOf", args);
766
+ },
767
+ map(fn, thisArg) {
768
+ return apply(this, "map", fn, thisArg, undefined, arguments);
769
+ },
770
+ pop() {
771
+ return noTracking(this, "pop");
772
+ },
773
+ push(...args) {
774
+ return noTracking(this, "push", args);
775
+ },
776
+ reduce(fn, ...args) {
777
+ return reduce(this, "reduce", fn, args);
778
+ },
779
+ reduceRight(fn, ...args) {
780
+ return reduce(this, "reduceRight", fn, args);
781
+ },
782
+ shift() {
783
+ return noTracking(this, "shift");
784
+ },
785
+ some(fn, thisArg) {
786
+ return apply(this, "some", fn, thisArg, undefined, arguments);
787
+ },
788
+ splice(...args) {
789
+ return noTracking(this, "splice", args);
790
+ },
791
+ toReversed() {
792
+ return reactiveReadArray(this).toReversed();
793
+ },
794
+ toSorted(comparer) {
795
+ return reactiveReadArray(this).toSorted(comparer);
796
+ },
797
+ toSpliced(...args) {
798
+ return reactiveReadArray(this).toSpliced(...args);
799
+ },
800
+ unshift(...args) {
801
+ return noTracking(this, "unshift", args);
802
+ },
803
+ values() {
804
+ return iterator(this, "values", (item) => toWrapped(this, item));
805
+ }
806
+ };
807
+ function iterator(self2, method, wrapValue) {
808
+ const arr = shallowReadArray(self2);
809
+ const iter = arr[method]();
810
+ if (arr !== self2 && !isShallow(self2)) {
811
+ iter._next = iter.next;
812
+ iter.next = () => {
813
+ const result = iter._next();
814
+ if (!result.done) {
815
+ result.value = wrapValue(result.value);
816
+ }
817
+ return result;
818
+ };
819
+ }
820
+ return iter;
821
+ }
822
+ var arrayProto = Array.prototype;
823
+ function apply(self2, method, fn, thisArg, wrappedRetFn, args) {
824
+ const arr = shallowReadArray(self2);
825
+ const needsWrap = arr !== self2 && !isShallow(self2);
826
+ const methodFn = arr[method];
827
+ if (methodFn !== arrayProto[method]) {
828
+ const result2 = methodFn.apply(self2, args);
829
+ return needsWrap ? toReactive(result2) : result2;
830
+ }
831
+ let wrappedFn = fn;
832
+ if (arr !== self2) {
833
+ if (needsWrap) {
834
+ wrappedFn = function(item, index) {
835
+ return fn.call(this, toWrapped(self2, item), index, self2);
836
+ };
837
+ } else if (fn.length > 2) {
838
+ wrappedFn = function(item, index) {
839
+ return fn.call(this, item, index, self2);
840
+ };
841
+ }
842
+ }
843
+ const result = methodFn.call(arr, wrappedFn, thisArg);
844
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
845
+ }
846
+ function reduce(self2, method, fn, args) {
847
+ const arr = shallowReadArray(self2);
848
+ const needsWrap = arr !== self2 && !isShallow(self2);
849
+ let wrappedFn = fn;
850
+ let wrapInitialAccumulator = false;
851
+ if (arr !== self2) {
852
+ if (needsWrap) {
853
+ wrapInitialAccumulator = args.length === 0;
854
+ wrappedFn = function(acc, item, index) {
855
+ if (wrapInitialAccumulator) {
856
+ wrapInitialAccumulator = false;
857
+ acc = toWrapped(self2, acc);
858
+ }
859
+ return fn.call(this, acc, toWrapped(self2, item), index, self2);
860
+ };
861
+ } else if (fn.length > 3) {
862
+ wrappedFn = function(acc, item, index) {
863
+ return fn.call(this, acc, item, index, self2);
864
+ };
865
+ }
866
+ }
867
+ const result = arr[method](wrappedFn, ...args);
868
+ return wrapInitialAccumulator ? toWrapped(self2, result) : result;
869
+ }
870
+ function searchProxy(self2, method, args) {
871
+ const arr = toRaw(self2);
872
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
873
+ const res = arr[method](...args);
874
+ if ((res === -1 || res === false) && isProxy(args[0])) {
875
+ args[0] = toRaw(args[0]);
876
+ return arr[method](...args);
877
+ }
878
+ return res;
879
+ }
880
+ function noTracking(self2, method, args = []) {
881
+ pauseTracking();
882
+ startBatch();
883
+ const res = toRaw(self2)[method].apply(self2, args);
884
+ endBatch();
885
+ resetTracking();
886
+ return res;
887
+ }
888
+ var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
889
+ var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
890
+ function hasOwnProperty2(key) {
891
+ if (!isSymbol(key))
892
+ key = String(key);
893
+ const obj = toRaw(this);
894
+ track(obj, "has", key);
895
+ return obj.hasOwnProperty(key);
896
+ }
897
+
898
+ class BaseReactiveHandler {
899
+ constructor(_isReadonly = false, _isShallow = false) {
900
+ this._isReadonly = _isReadonly;
901
+ this._isShallow = _isShallow;
902
+ }
903
+ get(target, key, receiver) {
904
+ if (key === "__v_skip")
905
+ return target["__v_skip"];
906
+ const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
907
+ if (key === "__v_isReactive") {
908
+ return !isReadonly2;
909
+ } else if (key === "__v_isReadonly") {
910
+ return isReadonly2;
911
+ } else if (key === "__v_isShallow") {
912
+ return isShallow2;
913
+ } else if (key === "__v_raw") {
914
+ if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
915
+ return target;
916
+ }
917
+ return;
918
+ }
919
+ const targetIsArray = isArray(target);
920
+ if (!isReadonly2) {
921
+ let fn;
922
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
923
+ return fn;
924
+ }
925
+ if (key === "hasOwnProperty") {
926
+ return hasOwnProperty2;
927
+ }
928
+ }
929
+ const res = Reflect.get(target, key, isRef(target) ? target : receiver);
930
+ if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
931
+ return res;
932
+ }
933
+ if (!isReadonly2) {
934
+ track(target, "get", key);
935
+ }
936
+ if (isShallow2) {
937
+ return res;
938
+ }
939
+ if (isRef(res)) {
940
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
941
+ return isReadonly2 && isObject(value) ? readonly(value) : value;
942
+ }
943
+ if (isObject(res)) {
944
+ return isReadonly2 ? readonly(res) : reactive(res);
945
+ }
946
+ return res;
947
+ }
948
+ }
949
+
950
+ class MutableReactiveHandler extends BaseReactiveHandler {
951
+ constructor(isShallow2 = false) {
952
+ super(false, isShallow2);
953
+ }
954
+ set(target, key, value, receiver) {
955
+ let oldValue = target[key];
956
+ const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
957
+ if (!this._isShallow) {
958
+ const isOldValueReadonly = isReadonly(oldValue);
959
+ if (!isShallow(value) && !isReadonly(value)) {
960
+ oldValue = toRaw(oldValue);
961
+ value = toRaw(value);
962
+ }
963
+ if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
964
+ if (isOldValueReadonly) {
965
+ if (true) {
966
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
967
+ }
968
+ return true;
969
+ } else {
970
+ oldValue.value = value;
971
+ return true;
972
+ }
973
+ }
974
+ }
975
+ const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
976
+ const result = Reflect.set(target, key, value, isRef(target) ? target : receiver);
977
+ if (target === toRaw(receiver) && result) {
978
+ if (!hadKey) {
979
+ trigger(target, "add", key, value);
980
+ } else if (hasChanged(value, oldValue)) {
981
+ trigger(target, "set", key, value, oldValue);
982
+ }
983
+ }
984
+ return result;
985
+ }
986
+ deleteProperty(target, key) {
987
+ const hadKey = hasOwn(target, key);
988
+ const oldValue = target[key];
989
+ const result = Reflect.deleteProperty(target, key);
990
+ if (result && hadKey) {
991
+ trigger(target, "delete", key, undefined, oldValue);
992
+ }
993
+ return result;
994
+ }
995
+ has(target, key) {
996
+ const result = Reflect.has(target, key);
997
+ if (!isSymbol(key) || !builtInSymbols.has(key)) {
998
+ track(target, "has", key);
999
+ }
1000
+ return result;
1001
+ }
1002
+ ownKeys(target) {
1003
+ track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
1004
+ return Reflect.ownKeys(target);
1005
+ }
1006
+ }
1007
+
1008
+ class ReadonlyReactiveHandler extends BaseReactiveHandler {
1009
+ constructor(isShallow2 = false) {
1010
+ super(true, isShallow2);
1011
+ }
1012
+ set(target, key) {
1013
+ if (true) {
1014
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
1015
+ }
1016
+ return true;
1017
+ }
1018
+ deleteProperty(target, key) {
1019
+ if (true) {
1020
+ warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
1021
+ }
1022
+ return true;
1023
+ }
1024
+ }
1025
+ var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler;
1026
+ var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler;
1027
+ var toShallow = (value) => value;
1028
+ var getProto = (v) => Reflect.getPrototypeOf(v);
1029
+ function createIterableMethod(method, isReadonly2, isShallow2) {
1030
+ return function(...args) {
1031
+ const target = this["__v_raw"];
1032
+ const rawTarget = toRaw(target);
1033
+ const targetIsMap = isMap(rawTarget);
1034
+ const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1035
+ const isKeyOnly = method === "keys" && targetIsMap;
1036
+ const innerIterator = target[method](...args);
1037
+ const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
1038
+ !isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
1039
+ return extend(Object.create(innerIterator), {
1040
+ next() {
1041
+ const { value, done } = innerIterator.next();
1042
+ return done ? { value, done } : {
1043
+ value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1044
+ done
1045
+ };
1046
+ }
1047
+ });
1048
+ };
1049
+ }
1050
+ function createReadonlyMethod(type) {
1051
+ return function(...args) {
1052
+ if (true) {
1053
+ const key = args[0] ? `on key "${args[0]}" ` : ``;
1054
+ warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
1055
+ }
1056
+ return type === "delete" ? false : type === "clear" ? undefined : this;
1057
+ };
1058
+ }
1059
+ function createInstrumentations(readonly, shallow) {
1060
+ const instrumentations = {
1061
+ get(key) {
1062
+ const target = this["__v_raw"];
1063
+ const rawTarget = toRaw(target);
1064
+ const rawKey = toRaw(key);
1065
+ if (!readonly) {
1066
+ if (hasChanged(key, rawKey)) {
1067
+ track(rawTarget, "get", key);
1068
+ }
1069
+ track(rawTarget, "get", rawKey);
1070
+ }
1071
+ const { has } = getProto(rawTarget);
1072
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1073
+ if (has.call(rawTarget, key)) {
1074
+ return wrap(target.get(key));
1075
+ } else if (has.call(rawTarget, rawKey)) {
1076
+ return wrap(target.get(rawKey));
1077
+ } else if (target !== rawTarget) {
1078
+ target.get(key);
1079
+ }
1080
+ },
1081
+ get size() {
1082
+ const target = this["__v_raw"];
1083
+ !readonly && track(toRaw(target), "iterate", ITERATE_KEY);
1084
+ return target.size;
1085
+ },
1086
+ has(key) {
1087
+ const target = this["__v_raw"];
1088
+ const rawTarget = toRaw(target);
1089
+ const rawKey = toRaw(key);
1090
+ if (!readonly) {
1091
+ if (hasChanged(key, rawKey)) {
1092
+ track(rawTarget, "has", key);
1093
+ }
1094
+ track(rawTarget, "has", rawKey);
1095
+ }
1096
+ return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1097
+ },
1098
+ forEach(callback, thisArg) {
1099
+ const observed = this;
1100
+ const target = observed["__v_raw"];
1101
+ const rawTarget = toRaw(target);
1102
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1103
+ !readonly && track(rawTarget, "iterate", ITERATE_KEY);
1104
+ return target.forEach((value, key) => {
1105
+ return callback.call(thisArg, wrap(value), wrap(key), observed);
1106
+ });
1107
+ }
1108
+ };
1109
+ extend(instrumentations, readonly ? {
1110
+ add: createReadonlyMethod("add"),
1111
+ set: createReadonlyMethod("set"),
1112
+ delete: createReadonlyMethod("delete"),
1113
+ clear: createReadonlyMethod("clear")
1114
+ } : {
1115
+ add(value) {
1116
+ const target = toRaw(this);
1117
+ const proto = getProto(target);
1118
+ const rawValue = toRaw(value);
1119
+ const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
1120
+ const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
1121
+ if (!hadKey) {
1122
+ target.add(valueToAdd);
1123
+ trigger(target, "add", valueToAdd, valueToAdd);
1124
+ }
1125
+ return this;
1126
+ },
1127
+ set(key, value) {
1128
+ if (!shallow && !isShallow(value) && !isReadonly(value)) {
1129
+ value = toRaw(value);
1130
+ }
1131
+ const target = toRaw(this);
1132
+ const { has, get } = getProto(target);
1133
+ let hadKey = has.call(target, key);
1134
+ if (!hadKey) {
1135
+ key = toRaw(key);
1136
+ hadKey = has.call(target, key);
1137
+ } else if (true) {
1138
+ checkIdentityKeys(target, has, key);
1139
+ }
1140
+ const oldValue = get.call(target, key);
1141
+ target.set(key, value);
1142
+ if (!hadKey) {
1143
+ trigger(target, "add", key, value);
1144
+ } else if (hasChanged(value, oldValue)) {
1145
+ trigger(target, "set", key, value, oldValue);
1146
+ }
1147
+ return this;
1148
+ },
1149
+ delete(key) {
1150
+ const target = toRaw(this);
1151
+ const { has, get } = getProto(target);
1152
+ let hadKey = has.call(target, key);
1153
+ if (!hadKey) {
1154
+ key = toRaw(key);
1155
+ hadKey = has.call(target, key);
1156
+ } else if (true) {
1157
+ checkIdentityKeys(target, has, key);
1158
+ }
1159
+ const oldValue = get ? get.call(target, key) : undefined;
1160
+ const result = target.delete(key);
1161
+ if (hadKey) {
1162
+ trigger(target, "delete", key, undefined, oldValue);
1163
+ }
1164
+ return result;
1165
+ },
1166
+ clear() {
1167
+ const target = toRaw(this);
1168
+ const hadItems = target.size !== 0;
1169
+ const oldTarget = isMap(target) ? new Map(target) : new Set(target);
1170
+ const result = target.clear();
1171
+ if (hadItems) {
1172
+ trigger(target, "clear", undefined, undefined, oldTarget);
1173
+ }
1174
+ return result;
1175
+ }
1176
+ });
1177
+ const iteratorMethods = [
1178
+ "keys",
1179
+ "values",
1180
+ "entries",
1181
+ Symbol.iterator
1182
+ ];
1183
+ iteratorMethods.forEach((method) => {
1184
+ instrumentations[method] = createIterableMethod(method, readonly, shallow);
1185
+ });
1186
+ return instrumentations;
1187
+ }
1188
+ function createInstrumentationGetter(isReadonly2, shallow) {
1189
+ const instrumentations = createInstrumentations(isReadonly2, shallow);
1190
+ return (target, key, receiver) => {
1191
+ if (key === "__v_isReactive") {
1192
+ return !isReadonly2;
1193
+ } else if (key === "__v_isReadonly") {
1194
+ return isReadonly2;
1195
+ } else if (key === "__v_raw") {
1196
+ return target;
1197
+ }
1198
+ return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
1199
+ };
1200
+ }
1201
+ var mutableCollectionHandlers = {
1202
+ get: /* @__PURE__ */ createInstrumentationGetter(false, false)
1203
+ };
1204
+ var readonlyCollectionHandlers = {
1205
+ get: /* @__PURE__ */ createInstrumentationGetter(true, false)
1206
+ };
1207
+ function checkIdentityKeys(target, has, key) {
1208
+ const rawKey = toRaw(key);
1209
+ if (rawKey !== key && has.call(target, rawKey)) {
1210
+ const type = toRawType(target);
1211
+ warn(`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.`);
1212
+ }
1213
+ }
1214
+ var reactiveMap = /* @__PURE__ */ new WeakMap;
1215
+ var shallowReactiveMap = /* @__PURE__ */ new WeakMap;
1216
+ var readonlyMap = /* @__PURE__ */ new WeakMap;
1217
+ var shallowReadonlyMap = /* @__PURE__ */ new WeakMap;
1218
+ function targetTypeMap(rawType) {
1219
+ switch (rawType) {
1220
+ case "Object":
1221
+ case "Array":
1222
+ return 1;
1223
+ case "Map":
1224
+ case "Set":
1225
+ case "WeakMap":
1226
+ case "WeakSet":
1227
+ return 2;
1228
+ default:
1229
+ return 0;
1230
+ }
1231
+ }
1232
+ function reactive(target) {
1233
+ if (/* @__PURE__ */ isReadonly(target)) {
1234
+ return target;
1235
+ }
1236
+ return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1237
+ }
1238
+ function readonly(target) {
1239
+ return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1240
+ }
1241
+ function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
1242
+ if (!isObject(target)) {
1243
+ if (true) {
1244
+ warn(`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(target)}`);
1245
+ }
1246
+ return target;
1247
+ }
1248
+ if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
1249
+ return target;
1250
+ }
1251
+ if (target["__v_skip"] || !Object.isExtensible(target)) {
1252
+ return target;
1253
+ }
1254
+ const existingProxy = proxyMap.get(target);
1255
+ if (existingProxy) {
1256
+ return existingProxy;
1257
+ }
1258
+ const targetType = targetTypeMap(toRawType(target));
1259
+ if (targetType === 0) {
1260
+ return target;
1261
+ }
1262
+ const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1263
+ proxyMap.set(target, proxy);
1264
+ return proxy;
1265
+ }
1266
+ function isReactive(value) {
1267
+ if (/* @__PURE__ */ isReadonly(value)) {
1268
+ return /* @__PURE__ */ isReactive(value["__v_raw"]);
1269
+ }
1270
+ return !!(value && value["__v_isReactive"]);
1271
+ }
1272
+ function isReadonly(value) {
1273
+ return !!(value && value["__v_isReadonly"]);
1274
+ }
1275
+ function isShallow(value) {
1276
+ return !!(value && value["__v_isShallow"]);
1277
+ }
1278
+ function isProxy(value) {
1279
+ return value ? !!value["__v_raw"] : false;
1280
+ }
1281
+ function toRaw(observed) {
1282
+ const raw = observed && observed["__v_raw"];
1283
+ return raw ? /* @__PURE__ */ toRaw(raw) : observed;
1284
+ }
1285
+ var toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
1286
+ var toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1287
+ function isRef(r) {
1288
+ return r ? r["__v_isRef"] === true : false;
1289
+ }
1290
+ function ref(value) {
1291
+ return createRef(value, false);
1292
+ }
1293
+ function shallowRef(value) {
1294
+ return createRef(value, true);
1295
+ }
1296
+ function createRef(rawValue, shallow) {
1297
+ if (/* @__PURE__ */ isRef(rawValue)) {
1298
+ return rawValue;
1299
+ }
1300
+ return new RefImpl(rawValue, shallow);
1301
+ }
1302
+
1303
+ class RefImpl {
1304
+ constructor(value, isShallow2) {
1305
+ this.dep = new Dep;
1306
+ this["__v_isRef"] = true;
1307
+ this["__v_isShallow"] = false;
1308
+ this._rawValue = isShallow2 ? value : toRaw(value);
1309
+ this._value = isShallow2 ? value : toReactive(value);
1310
+ this["__v_isShallow"] = isShallow2;
1311
+ }
1312
+ get value() {
1313
+ if (true) {
1314
+ this.dep.track({
1315
+ target: this,
1316
+ type: "get",
1317
+ key: "value"
1318
+ });
1319
+ }
1320
+ return this._value;
1321
+ }
1322
+ set value(newValue) {
1323
+ const oldValue = this._rawValue;
1324
+ const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
1325
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1326
+ if (hasChanged(newValue, oldValue)) {
1327
+ this._rawValue = newValue;
1328
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1329
+ if (true) {
1330
+ this.dep.trigger({
1331
+ target: this,
1332
+ type: "set",
1333
+ key: "value",
1334
+ newValue,
1335
+ oldValue
1336
+ });
1337
+ }
1338
+ }
1339
+ }
1340
+ }
1341
+ class ComputedRefImpl {
1342
+ constructor(fn, setter, isSSR) {
1343
+ this.fn = fn;
1344
+ this.setter = setter;
1345
+ this._value = undefined;
1346
+ this.dep = new Dep(this);
1347
+ this.__v_isRef = true;
1348
+ this.deps = undefined;
1349
+ this.depsTail = undefined;
1350
+ this.flags = 16;
1351
+ this.globalVersion = globalVersion - 1;
1352
+ this.next = undefined;
1353
+ this.effect = this;
1354
+ this["__v_isReadonly"] = !setter;
1355
+ this.isSSR = isSSR;
1356
+ }
1357
+ notify() {
1358
+ this.flags |= 16;
1359
+ if (!(this.flags & 8) && activeSub !== this) {
1360
+ batch(this, true);
1361
+ return true;
1362
+ } else if (true)
1363
+ ;
1364
+ }
1365
+ get value() {
1366
+ const link = this.dep.track({
1367
+ target: this,
1368
+ type: "get",
1369
+ key: "value"
1370
+ });
1371
+ refreshComputed(this);
1372
+ if (link) {
1373
+ link.version = this.dep.version;
1374
+ }
1375
+ return this._value;
1376
+ }
1377
+ set value(newValue) {
1378
+ if (this.setter) {
1379
+ this.setter(newValue);
1380
+ } else if (true) {
1381
+ warn("Write operation failed: computed value is readonly");
1382
+ }
1383
+ }
1384
+ }
1385
+ function computed(getterOrOptions, debugOptions, isSSR = false) {
1386
+ let getter;
1387
+ let setter;
1388
+ if (isFunction(getterOrOptions)) {
1389
+ getter = getterOrOptions;
1390
+ } else {
1391
+ getter = getterOrOptions.get;
1392
+ setter = getterOrOptions.set;
1393
+ }
1394
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1395
+ if (debugOptions && !isSSR) {
1396
+ cRef.onTrack = debugOptions.onTrack;
1397
+ cRef.onTrigger = debugOptions.onTrigger;
1398
+ }
1399
+ return cRef;
1400
+ }
1401
+ // src/services/settings/definitions.ts
1402
+ function normalizeBaseUrl(raw) {
1403
+ return raw.trim().replace(/\/+$/, "");
1404
+ }
1405
+ function trimmed(raw) {
1406
+ return raw.trim();
1407
+ }
1408
+ var SETTINGS = {
1409
+ aiBaseUrl: {
1410
+ default: "",
1411
+ key: "jx.ai.baseUrl",
1412
+ normalize: normalizeBaseUrl,
1413
+ scope: "user"
1414
+ },
1415
+ aiOpenAiKey: {
1416
+ default: "",
1417
+ key: "jx.ai.openaiKey",
1418
+ normalize: trimmed,
1419
+ scope: "user",
1420
+ secret: true
1421
+ },
1422
+ aiModel: {
1423
+ default: "gpt-4o",
1424
+ key: "jx.ai.model",
1425
+ normalize: trimmed,
1426
+ scope: "user"
1427
+ },
1428
+ keybindings: {
1429
+ default: "",
1430
+ key: "jx.keybindings",
1431
+ normalize: (raw) => raw.trim() === "{}" ? "" : raw.trim(),
1432
+ scope: "user"
1433
+ },
1434
+ theme: {
1435
+ default: "",
1436
+ key: "jx-studio-theme",
1437
+ normalize: trimmed,
1438
+ scope: "user"
1439
+ },
1440
+ cfAccountId: {
1441
+ default: "",
1442
+ key: "jx.cf.accountId",
1443
+ normalize: trimmed,
1444
+ scope: "user"
1445
+ },
1446
+ cfToken: {
1447
+ default: "",
1448
+ key: "jx.cf.token",
1449
+ normalize: trimmed,
1450
+ scope: "user",
1451
+ secret: true
1452
+ }
1453
+ };
1454
+ var ALL_SETTINGS = Object.values(SETTINGS);
1455
+ var USER_SETTINGS = ALL_SETTINGS.filter((definition) => definition.scope === "user");
1456
+ var USER_SETTING_KEYS = USER_SETTINGS.map((definition) => definition.key);
1457
+
1458
+ // src/services/clock.ts
1459
+ var _pinned = null;
1460
+ function now() {
1461
+ return _pinned ?? Date.now();
1462
+ }
1463
+ function pinClock(at) {
1464
+ const ms = at instanceof Date ? at.getTime() : typeof at === "number" ? at : Date.parse(at);
1465
+ if (!Number.isFinite(ms)) {
1466
+ throw new TypeError(`clock: cannot pin to ${JSON.stringify(at)}`);
1467
+ }
1468
+ _pinned = ms;
1469
+ return ms;
1470
+ }
1471
+
1472
+ // src/services/announce.ts
1473
+ var REGION_ID = {
1474
+ assertive: "jx-live-assertive",
1475
+ polite: "jx-live-polite"
1476
+ };
1477
+ function region(politeness) {
1478
+ if (typeof document === "undefined") {
1479
+ return null;
1480
+ }
1481
+ const id = REGION_ID[politeness];
1482
+ const existing = document.querySelector(`#${id}`);
1483
+ if (existing) {
1484
+ return existing;
1485
+ }
1486
+ const node = document.createElement("div");
1487
+ node.id = id;
1488
+ node.setAttribute("aria-live", politeness);
1489
+ node.setAttribute("role", politeness === "assertive" ? "alert" : "status");
1490
+ node.setAttribute("aria-atomic", "true");
1491
+ node.style.cssText = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;" + "clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0";
1492
+ document.body.append(node);
1493
+ return node;
1494
+ }
1495
+ function announce(message, politeness = "polite") {
1496
+ if (message === "") {
1497
+ return;
1498
+ }
1499
+ const node = region(politeness);
1500
+ if (!node) {
1501
+ return;
1502
+ }
1503
+ node.textContent = "";
1504
+ setTimeout(() => {
1505
+ node.textContent = message;
1506
+ }, 0);
1507
+ }
1508
+
1509
+ // src/services/notify.ts
1510
+ var DEFAULT_TIER = {
1511
+ error: "problem",
1512
+ info: "toast",
1513
+ success: "toast",
1514
+ warn: "toast"
1515
+ };
1516
+ var TOAST_LIFETIME_MS = {
1517
+ error: 8000,
1518
+ info: 4000,
1519
+ success: 4000,
1520
+ warn: 8000
1521
+ };
1522
+ var _seq = 0;
1523
+ function nextId() {
1524
+ _seq += 1;
1525
+ return `n${_seq}`;
1526
+ }
1527
+ var toasts = reactive([]);
1528
+ var problems = reactive([]);
1529
+ var MAX_TOASTS = 4;
1530
+ function storeFor(tier) {
1531
+ return tier === "problem" ? problems : toasts;
1532
+ }
1533
+ function notify(severity, message, options = {}) {
1534
+ const tier = options.tier ?? DEFAULT_TIER[severity];
1535
+ const record = {
1536
+ at: now(),
1537
+ id: nextId(),
1538
+ message,
1539
+ severity,
1540
+ tier,
1541
+ ...options.action === undefined ? {} : { action: options.action },
1542
+ ...options.actionArgs === undefined ? {} : { actionArgs: options.actionArgs },
1543
+ ...options.detail === undefined ? {} : { detail: options.detail },
1544
+ ...options.source === undefined ? {} : { source: options.source },
1545
+ ...options.path === undefined ? {} : { path: options.path },
1546
+ ...options.key === undefined ? {} : { key: options.key },
1547
+ ...tier === "toast" ? { timeoutMs: options.timeoutMs ?? TOAST_LIFETIME_MS[severity] } : {}
1548
+ };
1549
+ const store = storeFor(tier);
1550
+ if (record.key !== undefined) {
1551
+ const at = store.findIndex((existing) => existing.key === record.key);
1552
+ if (at !== -1) {
1553
+ store.splice(at, 1);
1554
+ }
1555
+ }
1556
+ store.push(record);
1557
+ if (tier === "toast") {
1558
+ while (toasts.length > MAX_TOASTS) {
1559
+ toasts.shift();
1560
+ }
1561
+ }
1562
+ announce(record.source === undefined ? record.message : `${record.source}: ${record.message}`, severity === "error" ? "assertive" : "polite");
1563
+ return record;
1564
+ }
1565
+ function severityHelper(severity) {
1566
+ return (message, options = {}) => notify(severity, message, options);
1567
+ }
1568
+ notify.success = severityHelper("success");
1569
+ notify.info = severityHelper("info");
1570
+ notify.warn = severityHelper("warn");
1571
+ notify.error = severityHelper("error");
1572
+ function dismiss(id) {
1573
+ for (const store of [toasts, problems]) {
1574
+ const at = store.findIndex((record) => record.id === id);
1575
+ if (at !== -1) {
1576
+ store.splice(at, 1);
1577
+ return true;
1578
+ }
1579
+ }
1580
+ return false;
1581
+ }
1582
+ function clearProblems(match) {
1583
+ const kept = match ? problems.filter((record) => !match(record)) : [];
1584
+ const removed = problems.length - kept.length;
1585
+ problems.splice(0, problems.length, ...kept);
1586
+ return removed;
1587
+ }
1588
+ function problemCount(severity) {
1589
+ return severity === undefined ? problems.length : problems.filter((record) => record.severity === severity).length;
1590
+ }
1591
+
1592
+ // src/services/settings/write-queue.ts
1593
+ function createWriteQueue(opts) {
1594
+ const schedule = opts.schedule ?? queueMicrotask;
1595
+ let pending = null;
1596
+ let tail = Promise.resolve();
1597
+ let idle = Promise.resolve();
1598
+ function flush() {
1599
+ const patch = pending;
1600
+ pending = null;
1601
+ if (!patch) {
1602
+ return tail;
1603
+ }
1604
+ tail = tail.then(() => opts.send(patch)).catch((error) => {
1605
+ opts.onError?.(error, patch);
1606
+ });
1607
+ return tail;
1608
+ }
1609
+ return {
1610
+ enqueue(patch) {
1611
+ if (pending) {
1612
+ Object.assign(pending, patch);
1613
+ return;
1614
+ }
1615
+ pending = { ...patch };
1616
+ idle = new Promise((resolve) => {
1617
+ schedule(() => {
1618
+ flush().then(resolve);
1619
+ });
1620
+ });
1621
+ },
1622
+ settled() {
1623
+ return idle;
1624
+ }
1625
+ };
1626
+ }
1627
+
1628
+ // src/services/settings/kernel.ts
1629
+ var values = new Map;
1630
+ function writeCache(key, value) {
1631
+ try {
1632
+ if (value === null) {
1633
+ globalThis.localStorage?.removeItem(key);
1634
+ } else {
1635
+ globalThis.localStorage?.setItem(key, value);
1636
+ }
1637
+ } catch {}
1638
+ }
1639
+ try {
1640
+ for (const definition of ALL_SETTINGS) {
1641
+ const cached = globalThis.localStorage?.getItem(definition.key);
1642
+ if (cached !== null && cached !== undefined) {
1643
+ values.set(definition.key, cached);
1644
+ }
1645
+ }
1646
+ } catch {}
1647
+ function readStoredSetting(definition) {
1648
+ return values.get(definition.key) ?? "";
1649
+ }
1650
+ function hasSetting(definition) {
1651
+ return (values.get(definition.key) ?? "") !== "";
1652
+ }
1653
+ var listeners = new Set;
1654
+ function onSettingsChanged(listener) {
1655
+ listeners.add(listener);
1656
+ return () => {
1657
+ listeners.delete(listener);
1658
+ };
1659
+ }
1660
+ function announce2(keys) {
1661
+ for (const listener of listeners) {
1662
+ listener(keys);
1663
+ }
1664
+ }
1665
+ var queue = createWriteQueue({
1666
+ onError(error) {
1667
+ notify("error", "Your settings could not be saved.", {
1668
+ detail: error instanceof Error ? error.message : String(error),
1669
+ key: "settings-write",
1670
+ source: "Settings"
1671
+ });
1672
+ },
1673
+ async send(patch) {
1674
+ if (!hasPlatform()) {
1675
+ return;
1676
+ }
1677
+ const platform = getPlatform();
1678
+ if (!platform.patchSettings) {
1679
+ return;
1680
+ }
1681
+ const set = {};
1682
+ const remove2 = [];
1683
+ for (const [key, value] of Object.entries(patch)) {
1684
+ if (value) {
1685
+ set[key] = value;
1686
+ } else {
1687
+ remove2.push(key);
1688
+ }
1689
+ }
1690
+ await platform.patchSettings({ remove: remove2, set });
1691
+ }
1692
+ });
1693
+ function settingsSettled() {
1694
+ return queue.settled();
1695
+ }
1696
+ function apply2(patch) {
1697
+ const moved = [];
1698
+ for (const [key, next] of Object.entries(patch)) {
1699
+ const before = values.get(key) ?? null;
1700
+ if (before === next) {
1701
+ continue;
1702
+ }
1703
+ if (next === null) {
1704
+ values.delete(key);
1705
+ } else {
1706
+ values.set(key, next);
1707
+ }
1708
+ writeCache(key, next);
1709
+ moved.push(key);
1710
+ }
1711
+ return moved;
1712
+ }
1713
+ function setSetting(definition, value) {
1714
+ const next = definition.normalize ? definition.normalize(value) : value;
1715
+ const moved = apply2({ [definition.key]: next });
1716
+ if (moved.length > 0) {
1717
+ queue.enqueue({ [definition.key]: next });
1718
+ announce2(moved);
1719
+ }
1720
+ }
1721
+ function setSettings(entries) {
1722
+ const patch = {};
1723
+ for (const [definition, value] of entries) {
1724
+ patch[definition.key] = definition.normalize ? definition.normalize(value) : value;
1725
+ }
1726
+ const moved = apply2(patch);
1727
+ if (moved.length > 0) {
1728
+ queue.enqueue(patch);
1729
+ announce2(moved);
1730
+ }
1731
+ }
1732
+ function clearSettings(definitions) {
1733
+ const patch = {};
1734
+ for (const definition of definitions) {
1735
+ patch[definition.key] = null;
1736
+ }
1737
+ const moved = apply2(patch);
1738
+ if (moved.length > 0) {
1739
+ queue.enqueue(patch);
1740
+ announce2(moved);
1741
+ }
1742
+ }
1743
+ async function hydrateSettings() {
1744
+ if (!hasPlatform()) {
1745
+ return;
1746
+ }
1747
+ const platform = getPlatform();
1748
+ if (!platform.getSettings) {
1749
+ return;
1750
+ }
1751
+ let stored;
1752
+ try {
1753
+ stored = await platform.getSettings();
1754
+ } catch {
1755
+ return;
1756
+ }
1757
+ const incoming = {};
1758
+ let needsMigration = false;
1759
+ for (const definition of USER_SETTINGS) {
1760
+ const backendValue = stored[definition.key];
1761
+ if (backendValue) {
1762
+ incoming[definition.key] = backendValue;
1763
+ } else if (values.get(definition.key)) {
1764
+ needsMigration = true;
1765
+ }
1766
+ }
1767
+ const moved = apply2(incoming);
1768
+ if (moved.length > 0) {
1769
+ announce2(moved);
1770
+ }
1771
+ if (needsMigration) {
1772
+ const push = {};
1773
+ for (const definition of USER_SETTINGS) {
1774
+ const value = values.get(definition.key);
1775
+ if (value && !stored[definition.key]) {
1776
+ push[definition.key] = value;
1777
+ }
1778
+ }
1779
+ queue.enqueue(push);
1780
+ }
1781
+ }
1782
+ function adoptRemoteSettings(stored) {
1783
+ const patch = {};
1784
+ for (const definition of USER_SETTINGS) {
1785
+ patch[definition.key] = stored[definition.key] ?? null;
1786
+ }
1787
+ const moved = apply2(patch);
1788
+ if (moved.length > 0) {
1789
+ announce2(moved);
1790
+ }
1791
+ }
1792
+ function watchRemoteSettings() {
1793
+ if (!hasPlatform()) {
1794
+ return;
1795
+ }
1796
+ getPlatform().subscribeSettings?.(adoptRemoteSettings);
1797
+ }
1798
+
1799
+ export { effectScope, onScopeDispose, effect, onEffectCleanup, reactive, toRaw, isRef, ref, shallowRef, computed, SETTINGS, now, pinClock, toasts, problems, notify, dismiss, clearProblems, problemCount, readStoredSetting, hasSetting, onSettingsChanged, settingsSettled, setSetting, setSettings, clearSettings, hydrateSettings, watchRemoteSettings };
1800
+
1801
+ //# debugId=E24768F07DA88AB964756E2164756E21
1802
+ //# sourceMappingURL=studio-qpfq7xhm.js.map