@cortexkit/pi-magic-context 0.49.15 → 0.49.17

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 (54) hide show
  1. package/dist/auto-search-worker.js +76 -63
  2. package/dist/chunk-embedding-write-worker.js +11 -9
  3. package/dist/{compaction-marker-candidates-k4tqg4jb.js → compaction-marker-candidates-wjzqbspm.js} +2 -2
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/embedding-backfill-vwag34t0.js +23 -0
  6. package/dist/embedding-worker-process.js +1 -1
  7. package/dist/embedding-worker.js +5 -5
  8. package/dist/historian-calibration-extension.js +4 -1
  9. package/dist/index-1cvyaw9a.js +58 -0
  10. package/dist/{index-g4jf772p.js → index-1kcfwk9c.js} +22 -2
  11. package/dist/{index-9jvktm7k.js → index-2mmy81qt.js} +3 -3
  12. package/dist/{index-ccsscaap.js → index-469ttgzv.js} +38 -17
  13. package/dist/index-4knyh1kt.js +1387 -0
  14. package/dist/{index-75ah9413.js → index-5k2mshvq.js} +10 -10
  15. package/dist/{index-a4pk5yv9.js → index-8r2t8fv2.js} +853 -84
  16. package/dist/{index-0awvkeb5.js → index-9j809q6f.js} +32 -72
  17. package/dist/{index-1k729e4f.js → index-bxmf4dhr.js} +6 -6
  18. package/dist/{index-6dz2ed1v.js → index-d8gc0112.js} +2 -2
  19. package/dist/{index-1vw4f2pe.js → index-dvbjsh98.js} +6 -8
  20. package/dist/{index-hy44m6jc.js → index-e1rza8gp.js} +1 -1
  21. package/dist/{index-j0n09wtp.js → index-ej4eak9d.js} +9 -7
  22. package/dist/{index-hshd96pt.js → index-es03azap.js} +127 -2093
  23. package/dist/{index-ajfpyk0x.js → index-fa485mqs.js} +59 -1
  24. package/dist/{index-6ex901g3.js → index-g7p75667.js} +33 -4
  25. package/dist/{index-bet4sd3e.js → index-gdjv1nnd.js} +2 -2
  26. package/dist/{index-46q4e104.js → index-qpq6w67c.js} +1 -1
  27. package/dist/{index-asrxgdt4.js → index-rrwv9y2k.js} +8 -0
  28. package/dist/{index-1mrvw9en.js → index-svgkv4g2.js} +1 -1
  29. package/dist/{index-he9s4qsj.js → index-vktahpdj.js} +23 -3
  30. package/dist/{index-nwbhe6qv.js → index-vmcgew7x.js} +11 -8
  31. package/dist/index-wrr9rp9a.js +16 -0
  32. package/dist/{index-7qc73yk5.js → index-xnch62s6.js} +14 -8
  33. package/dist/{index-djxc8w8c.js → index-yygsh681.js} +25 -26
  34. package/dist/{index-7wagp5jp.js → index-z2rkv0mb.js} +4 -4
  35. package/dist/index-z7kbck29.js +62 -0
  36. package/dist/index.js +688 -339
  37. package/dist/message-fts-rowid-map-cvpy2dmb.js +24 -0
  38. package/dist/{message-index-dw4z9efj.js → message-index-2g23b7fe.js} +13 -13
  39. package/dist/{message-index-bounded-z4d3x9ty.js → message-index-bounded-d6zj2tn5.js} +15 -15
  40. package/dist/{message-time-backfill-r2ar1qvk.js → message-time-backfill-ssshbdy8.js} +5 -5
  41. package/dist/migration-worker.js +8 -6
  42. package/dist/{project-embedding-registry-52zwmtbn.js → project-embedding-registry-vf1ncptn.js} +12 -10
  43. package/dist/raw-ordinal-warmup-worker.js +40 -10
  44. package/dist/{read-session-chunk-0fsgg2k1.js → read-session-chunk-2ky7mbqp.js} +7 -7
  45. package/dist/{read-session-raw-azkqjgzg.js → read-session-raw-9s3xn7fc.js} +2 -2
  46. package/dist/search-archive-9akqcr90.js +20 -0
  47. package/dist/{search-ddbz6v60.js → search-zjyc65g1.js} +20 -19
  48. package/dist/{sqlite-adjpy399.js → sqlite-fsp0sf3r.js} +1 -1
  49. package/dist/{storage-memory-axnsk5t1.js → storage-memory-yxxc5v4n.js} +2 -2
  50. package/dist/{storage-tags-3kb5tvgg.js → storage-tags-cx6ccsv1.js} +3 -3
  51. package/dist/subagent-entry.js +25 -22
  52. package/dist/tag-snapshot-worker-pi.js +17 -20
  53. package/package.json +1 -1
  54. package/dist/embedding-backfill-7kj16fh9.js +0 -21
@@ -0,0 +1,1387 @@
1
+ // ../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
2
+ function createScanner2(text, ignoreTrivia = false) {
3
+ const len = text.length;
4
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
5
+ function scanHexDigits(count, exact) {
6
+ let digits = 0;
7
+ let value = 0;
8
+ while (digits < count || !exact) {
9
+ let ch = text.charCodeAt(pos);
10
+ if (ch >= 48 && ch <= 57) {
11
+ value = value * 16 + ch - 48;
12
+ } else if (ch >= 65 && ch <= 70) {
13
+ value = value * 16 + ch - 65 + 10;
14
+ } else if (ch >= 97 && ch <= 102) {
15
+ value = value * 16 + ch - 97 + 10;
16
+ } else {
17
+ break;
18
+ }
19
+ pos++;
20
+ digits++;
21
+ }
22
+ if (digits < count) {
23
+ value = -1;
24
+ }
25
+ return value;
26
+ }
27
+ function setPosition(newPosition) {
28
+ pos = newPosition;
29
+ value = "";
30
+ tokenOffset = 0;
31
+ token = 16;
32
+ scanError = 0;
33
+ }
34
+ function scanNumber() {
35
+ let start = pos;
36
+ if (text.charCodeAt(pos) === 48) {
37
+ pos++;
38
+ } else {
39
+ pos++;
40
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
41
+ pos++;
42
+ }
43
+ }
44
+ if (pos < text.length && text.charCodeAt(pos) === 46) {
45
+ pos++;
46
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
47
+ pos++;
48
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
49
+ pos++;
50
+ }
51
+ } else {
52
+ scanError = 3;
53
+ return text.substring(start, pos);
54
+ }
55
+ }
56
+ let end = pos;
57
+ if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
58
+ pos++;
59
+ if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
60
+ pos++;
61
+ }
62
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
63
+ pos++;
64
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
65
+ pos++;
66
+ }
67
+ end = pos;
68
+ } else {
69
+ scanError = 3;
70
+ }
71
+ }
72
+ return text.substring(start, end);
73
+ }
74
+ function scanString() {
75
+ let result = "", start = pos;
76
+ while (true) {
77
+ if (pos >= len) {
78
+ result += text.substring(start, pos);
79
+ scanError = 2;
80
+ break;
81
+ }
82
+ const ch = text.charCodeAt(pos);
83
+ if (ch === 34) {
84
+ result += text.substring(start, pos);
85
+ pos++;
86
+ break;
87
+ }
88
+ if (ch === 92) {
89
+ result += text.substring(start, pos);
90
+ pos++;
91
+ if (pos >= len) {
92
+ scanError = 2;
93
+ break;
94
+ }
95
+ const ch2 = text.charCodeAt(pos++);
96
+ switch (ch2) {
97
+ case 34:
98
+ result += '"';
99
+ break;
100
+ case 92:
101
+ result += "\\";
102
+ break;
103
+ case 47:
104
+ result += "/";
105
+ break;
106
+ case 98:
107
+ result += "\b";
108
+ break;
109
+ case 102:
110
+ result += "\f";
111
+ break;
112
+ case 110:
113
+ result += `
114
+ `;
115
+ break;
116
+ case 114:
117
+ result += "\r";
118
+ break;
119
+ case 116:
120
+ result += "\t";
121
+ break;
122
+ case 117:
123
+ const ch3 = scanHexDigits(4, true);
124
+ if (ch3 >= 0) {
125
+ result += String.fromCharCode(ch3);
126
+ } else {
127
+ scanError = 4;
128
+ }
129
+ break;
130
+ default:
131
+ scanError = 5;
132
+ }
133
+ start = pos;
134
+ continue;
135
+ }
136
+ if (ch >= 0 && ch <= 31) {
137
+ if (isLineBreak(ch)) {
138
+ result += text.substring(start, pos);
139
+ scanError = 2;
140
+ break;
141
+ } else {
142
+ scanError = 6;
143
+ }
144
+ }
145
+ pos++;
146
+ }
147
+ return result;
148
+ }
149
+ function scanNext() {
150
+ value = "";
151
+ scanError = 0;
152
+ tokenOffset = pos;
153
+ lineStartOffset = lineNumber;
154
+ prevTokenLineStartOffset = tokenLineStartOffset;
155
+ if (pos >= len) {
156
+ tokenOffset = len;
157
+ return token = 17;
158
+ }
159
+ let code = text.charCodeAt(pos);
160
+ if (isWhiteSpace(code)) {
161
+ do {
162
+ pos++;
163
+ value += String.fromCharCode(code);
164
+ code = text.charCodeAt(pos);
165
+ } while (isWhiteSpace(code));
166
+ return token = 15;
167
+ }
168
+ if (isLineBreak(code)) {
169
+ pos++;
170
+ value += String.fromCharCode(code);
171
+ if (code === 13 && text.charCodeAt(pos) === 10) {
172
+ pos++;
173
+ value += `
174
+ `;
175
+ }
176
+ lineNumber++;
177
+ tokenLineStartOffset = pos;
178
+ return token = 14;
179
+ }
180
+ switch (code) {
181
+ case 123:
182
+ pos++;
183
+ return token = 1;
184
+ case 125:
185
+ pos++;
186
+ return token = 2;
187
+ case 91:
188
+ pos++;
189
+ return token = 3;
190
+ case 93:
191
+ pos++;
192
+ return token = 4;
193
+ case 58:
194
+ pos++;
195
+ return token = 6;
196
+ case 44:
197
+ pos++;
198
+ return token = 5;
199
+ case 34:
200
+ pos++;
201
+ value = scanString();
202
+ return token = 10;
203
+ case 47:
204
+ const start = pos - 1;
205
+ if (text.charCodeAt(pos + 1) === 47) {
206
+ pos += 2;
207
+ while (pos < len) {
208
+ if (isLineBreak(text.charCodeAt(pos))) {
209
+ break;
210
+ }
211
+ pos++;
212
+ }
213
+ value = text.substring(start, pos);
214
+ return token = 12;
215
+ }
216
+ if (text.charCodeAt(pos + 1) === 42) {
217
+ pos += 2;
218
+ const safeLength = len - 1;
219
+ let commentClosed = false;
220
+ while (pos < safeLength) {
221
+ const ch = text.charCodeAt(pos);
222
+ if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
223
+ pos += 2;
224
+ commentClosed = true;
225
+ break;
226
+ }
227
+ pos++;
228
+ if (isLineBreak(ch)) {
229
+ if (ch === 13 && text.charCodeAt(pos) === 10) {
230
+ pos++;
231
+ }
232
+ lineNumber++;
233
+ tokenLineStartOffset = pos;
234
+ }
235
+ }
236
+ if (!commentClosed) {
237
+ pos++;
238
+ scanError = 1;
239
+ }
240
+ value = text.substring(start, pos);
241
+ return token = 13;
242
+ }
243
+ value += String.fromCharCode(code);
244
+ pos++;
245
+ return token = 16;
246
+ case 45:
247
+ value += String.fromCharCode(code);
248
+ pos++;
249
+ if (pos === len || !isDigit(text.charCodeAt(pos))) {
250
+ return token = 16;
251
+ }
252
+ case 48:
253
+ case 49:
254
+ case 50:
255
+ case 51:
256
+ case 52:
257
+ case 53:
258
+ case 54:
259
+ case 55:
260
+ case 56:
261
+ case 57:
262
+ value += scanNumber();
263
+ return token = 11;
264
+ default:
265
+ while (pos < len && isUnknownContentCharacter(code)) {
266
+ pos++;
267
+ code = text.charCodeAt(pos);
268
+ }
269
+ if (tokenOffset !== pos) {
270
+ value = text.substring(tokenOffset, pos);
271
+ switch (value) {
272
+ case "true":
273
+ return token = 8;
274
+ case "false":
275
+ return token = 9;
276
+ case "null":
277
+ return token = 7;
278
+ }
279
+ return token = 16;
280
+ }
281
+ value += String.fromCharCode(code);
282
+ pos++;
283
+ return token = 16;
284
+ }
285
+ }
286
+ function isUnknownContentCharacter(code) {
287
+ if (isWhiteSpace(code) || isLineBreak(code)) {
288
+ return false;
289
+ }
290
+ switch (code) {
291
+ case 125:
292
+ case 93:
293
+ case 123:
294
+ case 91:
295
+ case 34:
296
+ case 58:
297
+ case 44:
298
+ case 47:
299
+ return false;
300
+ }
301
+ return true;
302
+ }
303
+ function scanNextNonTrivia() {
304
+ let result;
305
+ do {
306
+ result = scanNext();
307
+ } while (result >= 12 && result <= 15);
308
+ return result;
309
+ }
310
+ return {
311
+ setPosition,
312
+ getPosition: () => pos,
313
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
314
+ getToken: () => token,
315
+ getTokenValue: () => value,
316
+ getTokenOffset: () => tokenOffset,
317
+ getTokenLength: () => pos - tokenOffset,
318
+ getTokenStartLine: () => lineStartOffset,
319
+ getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
320
+ getTokenError: () => scanError
321
+ };
322
+ }
323
+ function isWhiteSpace(ch) {
324
+ return ch === 32 || ch === 9;
325
+ }
326
+ function isLineBreak(ch) {
327
+ return ch === 10 || ch === 13;
328
+ }
329
+ function isDigit(ch) {
330
+ return ch >= 48 && ch <= 57;
331
+ }
332
+ var CharacterCodes;
333
+ (function(CharacterCodes) {
334
+ CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
335
+ CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
336
+ CharacterCodes[CharacterCodes["space"] = 32] = "space";
337
+ CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
338
+ CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
339
+ CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
340
+ CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
341
+ CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
342
+ CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
343
+ CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
344
+ CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
345
+ CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
346
+ CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
347
+ CharacterCodes[CharacterCodes["a"] = 97] = "a";
348
+ CharacterCodes[CharacterCodes["b"] = 98] = "b";
349
+ CharacterCodes[CharacterCodes["c"] = 99] = "c";
350
+ CharacterCodes[CharacterCodes["d"] = 100] = "d";
351
+ CharacterCodes[CharacterCodes["e"] = 101] = "e";
352
+ CharacterCodes[CharacterCodes["f"] = 102] = "f";
353
+ CharacterCodes[CharacterCodes["g"] = 103] = "g";
354
+ CharacterCodes[CharacterCodes["h"] = 104] = "h";
355
+ CharacterCodes[CharacterCodes["i"] = 105] = "i";
356
+ CharacterCodes[CharacterCodes["j"] = 106] = "j";
357
+ CharacterCodes[CharacterCodes["k"] = 107] = "k";
358
+ CharacterCodes[CharacterCodes["l"] = 108] = "l";
359
+ CharacterCodes[CharacterCodes["m"] = 109] = "m";
360
+ CharacterCodes[CharacterCodes["n"] = 110] = "n";
361
+ CharacterCodes[CharacterCodes["o"] = 111] = "o";
362
+ CharacterCodes[CharacterCodes["p"] = 112] = "p";
363
+ CharacterCodes[CharacterCodes["q"] = 113] = "q";
364
+ CharacterCodes[CharacterCodes["r"] = 114] = "r";
365
+ CharacterCodes[CharacterCodes["s"] = 115] = "s";
366
+ CharacterCodes[CharacterCodes["t"] = 116] = "t";
367
+ CharacterCodes[CharacterCodes["u"] = 117] = "u";
368
+ CharacterCodes[CharacterCodes["v"] = 118] = "v";
369
+ CharacterCodes[CharacterCodes["w"] = 119] = "w";
370
+ CharacterCodes[CharacterCodes["x"] = 120] = "x";
371
+ CharacterCodes[CharacterCodes["y"] = 121] = "y";
372
+ CharacterCodes[CharacterCodes["z"] = 122] = "z";
373
+ CharacterCodes[CharacterCodes["A"] = 65] = "A";
374
+ CharacterCodes[CharacterCodes["B"] = 66] = "B";
375
+ CharacterCodes[CharacterCodes["C"] = 67] = "C";
376
+ CharacterCodes[CharacterCodes["D"] = 68] = "D";
377
+ CharacterCodes[CharacterCodes["E"] = 69] = "E";
378
+ CharacterCodes[CharacterCodes["F"] = 70] = "F";
379
+ CharacterCodes[CharacterCodes["G"] = 71] = "G";
380
+ CharacterCodes[CharacterCodes["H"] = 72] = "H";
381
+ CharacterCodes[CharacterCodes["I"] = 73] = "I";
382
+ CharacterCodes[CharacterCodes["J"] = 74] = "J";
383
+ CharacterCodes[CharacterCodes["K"] = 75] = "K";
384
+ CharacterCodes[CharacterCodes["L"] = 76] = "L";
385
+ CharacterCodes[CharacterCodes["M"] = 77] = "M";
386
+ CharacterCodes[CharacterCodes["N"] = 78] = "N";
387
+ CharacterCodes[CharacterCodes["O"] = 79] = "O";
388
+ CharacterCodes[CharacterCodes["P"] = 80] = "P";
389
+ CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
390
+ CharacterCodes[CharacterCodes["R"] = 82] = "R";
391
+ CharacterCodes[CharacterCodes["S"] = 83] = "S";
392
+ CharacterCodes[CharacterCodes["T"] = 84] = "T";
393
+ CharacterCodes[CharacterCodes["U"] = 85] = "U";
394
+ CharacterCodes[CharacterCodes["V"] = 86] = "V";
395
+ CharacterCodes[CharacterCodes["W"] = 87] = "W";
396
+ CharacterCodes[CharacterCodes["X"] = 88] = "X";
397
+ CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
398
+ CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
399
+ CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
400
+ CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
401
+ CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
402
+ CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
403
+ CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
404
+ CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
405
+ CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
406
+ CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
407
+ CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
408
+ CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
409
+ CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
410
+ CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
411
+ CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
412
+ CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
413
+ CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
414
+ })(CharacterCodes || (CharacterCodes = {}));
415
+
416
+ // ../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
417
+ var cachedSpaces = new Array(20).fill(0).map((_, index) => {
418
+ return " ".repeat(index);
419
+ });
420
+ var maxCachedValues = 200;
421
+ var cachedBreakLinesWithSpaces = {
422
+ " ": {
423
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
424
+ return `
425
+ ` + " ".repeat(index);
426
+ }),
427
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
428
+ return "\r" + " ".repeat(index);
429
+ }),
430
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
431
+ return `\r
432
+ ` + " ".repeat(index);
433
+ })
434
+ },
435
+ "\t": {
436
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
437
+ return `
438
+ ` + "\t".repeat(index);
439
+ }),
440
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
441
+ return "\r" + "\t".repeat(index);
442
+ }),
443
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
444
+ return `\r
445
+ ` + "\t".repeat(index);
446
+ })
447
+ }
448
+ };
449
+ var supportedEols = [`
450
+ `, "\r", `\r
451
+ `];
452
+
453
+ // ../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js
454
+ function format(documentText, range, options) {
455
+ let initialIndentLevel;
456
+ let formatText;
457
+ let formatTextStart;
458
+ let rangeStart;
459
+ let rangeEnd;
460
+ if (range) {
461
+ rangeStart = range.offset;
462
+ rangeEnd = rangeStart + range.length;
463
+ formatTextStart = rangeStart;
464
+ while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
465
+ formatTextStart--;
466
+ }
467
+ let endOffset = rangeEnd;
468
+ while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
469
+ endOffset++;
470
+ }
471
+ formatText = documentText.substring(formatTextStart, endOffset);
472
+ initialIndentLevel = computeIndentLevel(formatText, options);
473
+ } else {
474
+ formatText = documentText;
475
+ initialIndentLevel = 0;
476
+ formatTextStart = 0;
477
+ rangeStart = 0;
478
+ rangeEnd = documentText.length;
479
+ }
480
+ const eol = getEOL(options, documentText);
481
+ const eolFastPathSupported = supportedEols.includes(eol);
482
+ let numberLineBreaks = 0;
483
+ let indentLevel = 0;
484
+ let indentValue;
485
+ if (options.insertSpaces) {
486
+ indentValue = cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces[1], options.tabSize || 4);
487
+ } else {
488
+ indentValue = "\t";
489
+ }
490
+ const indentType = indentValue === "\t" ? "\t" : " ";
491
+ let scanner = createScanner2(formatText, false);
492
+ let hasError = false;
493
+ function newLinesAndIndent() {
494
+ if (numberLineBreaks > 1) {
495
+ return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
496
+ }
497
+ const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
498
+ if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol].length) {
499
+ return eol + repeat(indentValue, initialIndentLevel + indentLevel);
500
+ }
501
+ if (amountOfSpaces <= 0) {
502
+ return eol;
503
+ }
504
+ return cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
505
+ }
506
+ function scanNext() {
507
+ let token = scanner.scan();
508
+ numberLineBreaks = 0;
509
+ while (token === 15 || token === 14) {
510
+ if (token === 14 && options.keepLines) {
511
+ numberLineBreaks += 1;
512
+ } else if (token === 14) {
513
+ numberLineBreaks = 1;
514
+ }
515
+ token = scanner.scan();
516
+ }
517
+ hasError = token === 16 || scanner.getTokenError() !== 0;
518
+ return token;
519
+ }
520
+ const editOperations = [];
521
+ function addEdit(text, startOffset, endOffset) {
522
+ if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text) {
523
+ editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
524
+ }
525
+ }
526
+ let firstToken = scanNext();
527
+ if (options.keepLines && numberLineBreaks > 0) {
528
+ addEdit(repeat(eol, numberLineBreaks), 0, 0);
529
+ }
530
+ if (firstToken !== 17) {
531
+ let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
532
+ let initialIndent = indentValue.length * initialIndentLevel < 20 && options.insertSpaces ? cachedSpaces[indentValue.length * initialIndentLevel] : repeat(indentValue, initialIndentLevel);
533
+ addEdit(initialIndent, formatTextStart, firstTokenStart);
534
+ }
535
+ while (firstToken !== 17) {
536
+ let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
537
+ let secondToken = scanNext();
538
+ let replaceContent = "";
539
+ let needsLineBreak = false;
540
+ while (numberLineBreaks === 0 && (secondToken === 12 || secondToken === 13)) {
541
+ let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
542
+ addEdit(cachedSpaces[1], firstTokenEnd, commentTokenStart);
543
+ firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
544
+ needsLineBreak = secondToken === 12;
545
+ replaceContent = needsLineBreak ? newLinesAndIndent() : "";
546
+ secondToken = scanNext();
547
+ }
548
+ if (secondToken === 2) {
549
+ if (firstToken !== 1) {
550
+ indentLevel--;
551
+ }
552
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1) {
553
+ replaceContent = newLinesAndIndent();
554
+ } else if (options.keepLines) {
555
+ replaceContent = cachedSpaces[1];
556
+ }
557
+ } else if (secondToken === 4) {
558
+ if (firstToken !== 3) {
559
+ indentLevel--;
560
+ }
561
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3) {
562
+ replaceContent = newLinesAndIndent();
563
+ } else if (options.keepLines) {
564
+ replaceContent = cachedSpaces[1];
565
+ }
566
+ } else {
567
+ switch (firstToken) {
568
+ case 3:
569
+ case 1:
570
+ indentLevel++;
571
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
572
+ replaceContent = newLinesAndIndent();
573
+ } else {
574
+ replaceContent = cachedSpaces[1];
575
+ }
576
+ break;
577
+ case 5:
578
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
579
+ replaceContent = newLinesAndIndent();
580
+ } else {
581
+ replaceContent = cachedSpaces[1];
582
+ }
583
+ break;
584
+ case 12:
585
+ replaceContent = newLinesAndIndent();
586
+ break;
587
+ case 13:
588
+ if (numberLineBreaks > 0) {
589
+ replaceContent = newLinesAndIndent();
590
+ } else if (!needsLineBreak) {
591
+ replaceContent = cachedSpaces[1];
592
+ }
593
+ break;
594
+ case 6:
595
+ if (options.keepLines && numberLineBreaks > 0) {
596
+ replaceContent = newLinesAndIndent();
597
+ } else if (!needsLineBreak) {
598
+ replaceContent = cachedSpaces[1];
599
+ }
600
+ break;
601
+ case 10:
602
+ if (options.keepLines && numberLineBreaks > 0) {
603
+ replaceContent = newLinesAndIndent();
604
+ } else if (secondToken === 6 && !needsLineBreak) {
605
+ replaceContent = "";
606
+ }
607
+ break;
608
+ case 7:
609
+ case 8:
610
+ case 9:
611
+ case 11:
612
+ case 2:
613
+ case 4:
614
+ if (options.keepLines && numberLineBreaks > 0) {
615
+ replaceContent = newLinesAndIndent();
616
+ } else {
617
+ if ((secondToken === 12 || secondToken === 13) && !needsLineBreak) {
618
+ replaceContent = cachedSpaces[1];
619
+ } else if (secondToken !== 5 && secondToken !== 17) {
620
+ hasError = true;
621
+ }
622
+ }
623
+ break;
624
+ case 16:
625
+ hasError = true;
626
+ break;
627
+ }
628
+ if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) {
629
+ replaceContent = newLinesAndIndent();
630
+ }
631
+ }
632
+ if (secondToken === 17) {
633
+ if (options.keepLines && numberLineBreaks > 0) {
634
+ replaceContent = newLinesAndIndent();
635
+ } else {
636
+ replaceContent = options.insertFinalNewline ? eol : "";
637
+ }
638
+ }
639
+ const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
640
+ addEdit(replaceContent, firstTokenEnd, secondTokenStart);
641
+ firstToken = secondToken;
642
+ }
643
+ return editOperations;
644
+ }
645
+ function repeat(s, count) {
646
+ let result = "";
647
+ for (let i = 0;i < count; i++) {
648
+ result += s;
649
+ }
650
+ return result;
651
+ }
652
+ function computeIndentLevel(content, options) {
653
+ let i = 0;
654
+ let nChars = 0;
655
+ const tabSize = options.tabSize || 4;
656
+ while (i < content.length) {
657
+ let ch = content.charAt(i);
658
+ if (ch === cachedSpaces[1]) {
659
+ nChars++;
660
+ } else if (ch === "\t") {
661
+ nChars += tabSize;
662
+ } else {
663
+ break;
664
+ }
665
+ i++;
666
+ }
667
+ return Math.floor(nChars / tabSize);
668
+ }
669
+ function getEOL(options, text) {
670
+ for (let i = 0;i < text.length; i++) {
671
+ const ch = text.charAt(i);
672
+ if (ch === "\r") {
673
+ if (i + 1 < text.length && text.charAt(i + 1) === `
674
+ `) {
675
+ return `\r
676
+ `;
677
+ }
678
+ return "\r";
679
+ } else if (ch === `
680
+ `) {
681
+ return `
682
+ `;
683
+ }
684
+ }
685
+ return options && options.eol || `
686
+ `;
687
+ }
688
+ function isEOL(text, offset) {
689
+ return `\r
690
+ `.indexOf(text.charAt(offset)) !== -1;
691
+ }
692
+
693
+ // ../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
694
+ var ParseOptions;
695
+ (function(ParseOptions) {
696
+ ParseOptions.DEFAULT = {
697
+ allowTrailingComma: false
698
+ };
699
+ })(ParseOptions || (ParseOptions = {}));
700
+ function parse2(text, errors = [], options = ParseOptions.DEFAULT) {
701
+ let currentProperty = null;
702
+ let currentParent = [];
703
+ const previousParents = [];
704
+ function onValue(value) {
705
+ if (Array.isArray(currentParent)) {
706
+ currentParent.push(value);
707
+ } else if (currentProperty !== null) {
708
+ currentParent[currentProperty] = value;
709
+ }
710
+ }
711
+ const visitor = {
712
+ onObjectBegin: () => {
713
+ const object = {};
714
+ onValue(object);
715
+ previousParents.push(currentParent);
716
+ currentParent = object;
717
+ currentProperty = null;
718
+ },
719
+ onObjectProperty: (name) => {
720
+ currentProperty = name;
721
+ },
722
+ onObjectEnd: () => {
723
+ currentParent = previousParents.pop();
724
+ },
725
+ onArrayBegin: () => {
726
+ const array = [];
727
+ onValue(array);
728
+ previousParents.push(currentParent);
729
+ currentParent = array;
730
+ currentProperty = null;
731
+ },
732
+ onArrayEnd: () => {
733
+ currentParent = previousParents.pop();
734
+ },
735
+ onLiteralValue: onValue,
736
+ onError: (error, offset, length) => {
737
+ errors.push({ error, offset, length });
738
+ }
739
+ };
740
+ visit(text, visitor, options);
741
+ return currentParent[0];
742
+ }
743
+ function parseTree2(text, errors = [], options = ParseOptions.DEFAULT) {
744
+ let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: undefined };
745
+ function ensurePropertyComplete(endOffset) {
746
+ if (currentParent.type === "property") {
747
+ currentParent.length = endOffset - currentParent.offset;
748
+ currentParent = currentParent.parent;
749
+ }
750
+ }
751
+ function onValue(valueNode) {
752
+ currentParent.children.push(valueNode);
753
+ return valueNode;
754
+ }
755
+ const visitor = {
756
+ onObjectBegin: (offset) => {
757
+ currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
758
+ },
759
+ onObjectProperty: (name, offset, length) => {
760
+ currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
761
+ currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
762
+ },
763
+ onObjectEnd: (offset, length) => {
764
+ ensurePropertyComplete(offset + length);
765
+ currentParent.length = offset + length - currentParent.offset;
766
+ currentParent = currentParent.parent;
767
+ ensurePropertyComplete(offset + length);
768
+ },
769
+ onArrayBegin: (offset, length) => {
770
+ currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
771
+ },
772
+ onArrayEnd: (offset, length) => {
773
+ currentParent.length = offset + length - currentParent.offset;
774
+ currentParent = currentParent.parent;
775
+ ensurePropertyComplete(offset + length);
776
+ },
777
+ onLiteralValue: (value, offset, length) => {
778
+ onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
779
+ ensurePropertyComplete(offset + length);
780
+ },
781
+ onSeparator: (sep, offset, length) => {
782
+ if (currentParent.type === "property") {
783
+ if (sep === ":") {
784
+ currentParent.colonOffset = offset;
785
+ } else if (sep === ",") {
786
+ ensurePropertyComplete(offset);
787
+ }
788
+ }
789
+ },
790
+ onError: (error, offset, length) => {
791
+ errors.push({ error, offset, length });
792
+ }
793
+ };
794
+ visit(text, visitor, options);
795
+ const result = currentParent.children[0];
796
+ if (result) {
797
+ delete result.parent;
798
+ }
799
+ return result;
800
+ }
801
+ function findNodeAtLocation2(root, path) {
802
+ if (!root) {
803
+ return;
804
+ }
805
+ let node = root;
806
+ for (let segment of path) {
807
+ if (typeof segment === "string") {
808
+ if (node.type !== "object" || !Array.isArray(node.children)) {
809
+ return;
810
+ }
811
+ let found = false;
812
+ for (const propertyNode of node.children) {
813
+ if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
814
+ node = propertyNode.children[1];
815
+ found = true;
816
+ break;
817
+ }
818
+ }
819
+ if (!found) {
820
+ return;
821
+ }
822
+ } else {
823
+ const index = segment;
824
+ if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
825
+ return;
826
+ }
827
+ node = node.children[index];
828
+ }
829
+ }
830
+ return node;
831
+ }
832
+ function getNodeValue2(node) {
833
+ switch (node.type) {
834
+ case "array":
835
+ return node.children.map(getNodeValue2);
836
+ case "object":
837
+ const obj = Object.create(null);
838
+ for (let prop of node.children) {
839
+ const valueNode = prop.children[1];
840
+ if (valueNode) {
841
+ obj[prop.children[0].value] = getNodeValue2(valueNode);
842
+ }
843
+ }
844
+ return obj;
845
+ case "null":
846
+ case "string":
847
+ case "number":
848
+ case "boolean":
849
+ return node.value;
850
+ default:
851
+ return;
852
+ }
853
+ }
854
+ function visit(text, visitor, options = ParseOptions.DEFAULT) {
855
+ const _scanner = createScanner2(text, false);
856
+ const _jsonPath = [];
857
+ let suppressedCallbacks = 0;
858
+ function toNoArgVisit(visitFunction) {
859
+ return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
860
+ }
861
+ function toOneArgVisit(visitFunction) {
862
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
863
+ }
864
+ function toOneArgVisitWithPath(visitFunction) {
865
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
866
+ }
867
+ function toBeginVisit(visitFunction) {
868
+ return visitFunction ? () => {
869
+ if (suppressedCallbacks > 0) {
870
+ suppressedCallbacks++;
871
+ } else {
872
+ let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
873
+ if (cbReturn === false) {
874
+ suppressedCallbacks = 1;
875
+ }
876
+ }
877
+ } : () => true;
878
+ }
879
+ function toEndVisit(visitFunction) {
880
+ return visitFunction ? () => {
881
+ if (suppressedCallbacks > 0) {
882
+ suppressedCallbacks--;
883
+ }
884
+ if (suppressedCallbacks === 0) {
885
+ visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
886
+ }
887
+ } : () => true;
888
+ }
889
+ const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
890
+ const disallowComments = options && options.disallowComments;
891
+ const allowTrailingComma = options && options.allowTrailingComma;
892
+ function scanNext() {
893
+ while (true) {
894
+ const token = _scanner.scan();
895
+ switch (_scanner.getTokenError()) {
896
+ case 4:
897
+ handleError(14);
898
+ break;
899
+ case 5:
900
+ handleError(15);
901
+ break;
902
+ case 3:
903
+ handleError(13);
904
+ break;
905
+ case 1:
906
+ if (!disallowComments) {
907
+ handleError(11);
908
+ }
909
+ break;
910
+ case 2:
911
+ handleError(12);
912
+ break;
913
+ case 6:
914
+ handleError(16);
915
+ break;
916
+ }
917
+ switch (token) {
918
+ case 12:
919
+ case 13:
920
+ if (disallowComments) {
921
+ handleError(10);
922
+ } else {
923
+ onComment();
924
+ }
925
+ break;
926
+ case 16:
927
+ handleError(1);
928
+ break;
929
+ case 15:
930
+ case 14:
931
+ break;
932
+ default:
933
+ return token;
934
+ }
935
+ }
936
+ }
937
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
938
+ onError(error);
939
+ if (skipUntilAfter.length + skipUntil.length > 0) {
940
+ let token = _scanner.getToken();
941
+ while (token !== 17) {
942
+ if (skipUntilAfter.indexOf(token) !== -1) {
943
+ scanNext();
944
+ break;
945
+ } else if (skipUntil.indexOf(token) !== -1) {
946
+ break;
947
+ }
948
+ token = scanNext();
949
+ }
950
+ }
951
+ }
952
+ function parseString(isValue) {
953
+ const value = _scanner.getTokenValue();
954
+ if (isValue) {
955
+ onLiteralValue(value);
956
+ } else {
957
+ onObjectProperty(value);
958
+ _jsonPath.push(value);
959
+ }
960
+ scanNext();
961
+ return true;
962
+ }
963
+ function parseLiteral() {
964
+ switch (_scanner.getToken()) {
965
+ case 11:
966
+ const tokenValue = _scanner.getTokenValue();
967
+ let value = Number(tokenValue);
968
+ if (isNaN(value)) {
969
+ handleError(2);
970
+ value = 0;
971
+ }
972
+ onLiteralValue(value);
973
+ break;
974
+ case 7:
975
+ onLiteralValue(null);
976
+ break;
977
+ case 8:
978
+ onLiteralValue(true);
979
+ break;
980
+ case 9:
981
+ onLiteralValue(false);
982
+ break;
983
+ default:
984
+ return false;
985
+ }
986
+ scanNext();
987
+ return true;
988
+ }
989
+ function parseProperty() {
990
+ if (_scanner.getToken() !== 10) {
991
+ handleError(3, [], [2, 5]);
992
+ return false;
993
+ }
994
+ parseString(false);
995
+ if (_scanner.getToken() === 6) {
996
+ onSeparator(":");
997
+ scanNext();
998
+ if (!parseValue()) {
999
+ handleError(4, [], [2, 5]);
1000
+ }
1001
+ } else {
1002
+ handleError(5, [], [2, 5]);
1003
+ }
1004
+ _jsonPath.pop();
1005
+ return true;
1006
+ }
1007
+ function parseObject() {
1008
+ onObjectBegin();
1009
+ scanNext();
1010
+ let needsComma = false;
1011
+ while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
1012
+ if (_scanner.getToken() === 5) {
1013
+ if (!needsComma) {
1014
+ handleError(4, [], []);
1015
+ }
1016
+ onSeparator(",");
1017
+ scanNext();
1018
+ if (_scanner.getToken() === 2 && allowTrailingComma) {
1019
+ break;
1020
+ }
1021
+ } else if (needsComma) {
1022
+ handleError(6, [], []);
1023
+ }
1024
+ if (!parseProperty()) {
1025
+ handleError(4, [], [2, 5]);
1026
+ }
1027
+ needsComma = true;
1028
+ }
1029
+ onObjectEnd();
1030
+ if (_scanner.getToken() !== 2) {
1031
+ handleError(7, [2], []);
1032
+ } else {
1033
+ scanNext();
1034
+ }
1035
+ return true;
1036
+ }
1037
+ function parseArray() {
1038
+ onArrayBegin();
1039
+ scanNext();
1040
+ let isFirstElement = true;
1041
+ let needsComma = false;
1042
+ while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
1043
+ if (_scanner.getToken() === 5) {
1044
+ if (!needsComma) {
1045
+ handleError(4, [], []);
1046
+ }
1047
+ onSeparator(",");
1048
+ scanNext();
1049
+ if (_scanner.getToken() === 4 && allowTrailingComma) {
1050
+ break;
1051
+ }
1052
+ } else if (needsComma) {
1053
+ handleError(6, [], []);
1054
+ }
1055
+ if (isFirstElement) {
1056
+ _jsonPath.push(0);
1057
+ isFirstElement = false;
1058
+ } else {
1059
+ _jsonPath[_jsonPath.length - 1]++;
1060
+ }
1061
+ if (!parseValue()) {
1062
+ handleError(4, [], [4, 5]);
1063
+ }
1064
+ needsComma = true;
1065
+ }
1066
+ onArrayEnd();
1067
+ if (!isFirstElement) {
1068
+ _jsonPath.pop();
1069
+ }
1070
+ if (_scanner.getToken() !== 4) {
1071
+ handleError(8, [4], []);
1072
+ } else {
1073
+ scanNext();
1074
+ }
1075
+ return true;
1076
+ }
1077
+ function parseValue() {
1078
+ switch (_scanner.getToken()) {
1079
+ case 3:
1080
+ return parseArray();
1081
+ case 1:
1082
+ return parseObject();
1083
+ case 10:
1084
+ return parseString(true);
1085
+ default:
1086
+ return parseLiteral();
1087
+ }
1088
+ }
1089
+ scanNext();
1090
+ if (_scanner.getToken() === 17) {
1091
+ if (options.allowEmptyContent) {
1092
+ return true;
1093
+ }
1094
+ handleError(4, [], []);
1095
+ return false;
1096
+ }
1097
+ if (!parseValue()) {
1098
+ handleError(4, [], []);
1099
+ return false;
1100
+ }
1101
+ if (_scanner.getToken() !== 17) {
1102
+ handleError(9, [], []);
1103
+ }
1104
+ return true;
1105
+ }
1106
+ function getNodeType(value) {
1107
+ switch (typeof value) {
1108
+ case "boolean":
1109
+ return "boolean";
1110
+ case "number":
1111
+ return "number";
1112
+ case "string":
1113
+ return "string";
1114
+ case "object": {
1115
+ if (!value) {
1116
+ return "null";
1117
+ } else if (Array.isArray(value)) {
1118
+ return "array";
1119
+ }
1120
+ return "object";
1121
+ }
1122
+ default:
1123
+ return "null";
1124
+ }
1125
+ }
1126
+
1127
+ // ../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js
1128
+ function setProperty(text, originalPath, value, options) {
1129
+ const path = originalPath.slice();
1130
+ const errors = [];
1131
+ const root = parseTree2(text, errors);
1132
+ let parent = undefined;
1133
+ let lastSegment = undefined;
1134
+ while (path.length > 0) {
1135
+ lastSegment = path.pop();
1136
+ parent = findNodeAtLocation2(root, path);
1137
+ if (parent === undefined && value !== undefined) {
1138
+ if (typeof lastSegment === "string") {
1139
+ value = { [lastSegment]: value };
1140
+ } else {
1141
+ value = [value];
1142
+ }
1143
+ } else {
1144
+ break;
1145
+ }
1146
+ }
1147
+ if (!parent) {
1148
+ if (value === undefined) {
1149
+ throw new Error("Can not delete in empty document");
1150
+ }
1151
+ return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
1152
+ } else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
1153
+ const existing = findNodeAtLocation2(parent, [lastSegment]);
1154
+ if (existing !== undefined) {
1155
+ if (value === undefined) {
1156
+ if (!existing.parent) {
1157
+ throw new Error("Malformed AST");
1158
+ }
1159
+ const propertyIndex = parent.children.indexOf(existing.parent);
1160
+ let removeBegin;
1161
+ let removeEnd = existing.parent.offset + existing.parent.length;
1162
+ if (propertyIndex > 0) {
1163
+ let previous = parent.children[propertyIndex - 1];
1164
+ removeBegin = previous.offset + previous.length;
1165
+ } else {
1166
+ removeBegin = parent.offset + 1;
1167
+ if (parent.children.length > 1) {
1168
+ let next = parent.children[1];
1169
+ removeEnd = next.offset;
1170
+ }
1171
+ }
1172
+ return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: "" }, options);
1173
+ } else {
1174
+ return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
1175
+ }
1176
+ } else {
1177
+ if (value === undefined) {
1178
+ return [];
1179
+ }
1180
+ const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
1181
+ const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
1182
+ let edit;
1183
+ if (index > 0) {
1184
+ let previous = parent.children[index - 1];
1185
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
1186
+ } else if (parent.children.length === 0) {
1187
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty };
1188
+ } else {
1189
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty + "," };
1190
+ }
1191
+ return withFormatting(text, edit, options);
1192
+ }
1193
+ } else if (parent.type === "array" && typeof lastSegment === "number" && Array.isArray(parent.children)) {
1194
+ const insertIndex = lastSegment;
1195
+ if (insertIndex === -1) {
1196
+ const newProperty = `${JSON.stringify(value)}`;
1197
+ let edit;
1198
+ if (parent.children.length === 0) {
1199
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty };
1200
+ } else {
1201
+ const previous = parent.children[parent.children.length - 1];
1202
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
1203
+ }
1204
+ return withFormatting(text, edit, options);
1205
+ } else if (value === undefined && parent.children.length >= 0) {
1206
+ const removalIndex = lastSegment;
1207
+ const toRemove = parent.children[removalIndex];
1208
+ let edit;
1209
+ if (parent.children.length === 1) {
1210
+ edit = { offset: parent.offset + 1, length: parent.length - 2, content: "" };
1211
+ } else if (parent.children.length - 1 === removalIndex) {
1212
+ let previous = parent.children[removalIndex - 1];
1213
+ let offset = previous.offset + previous.length;
1214
+ let parentEndOffset = parent.offset + parent.length;
1215
+ edit = { offset, length: parentEndOffset - 2 - offset, content: "" };
1216
+ } else {
1217
+ edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: "" };
1218
+ }
1219
+ return withFormatting(text, edit, options);
1220
+ } else if (value !== undefined) {
1221
+ let edit;
1222
+ const newProperty = `${JSON.stringify(value)}`;
1223
+ if (!options.isArrayInsertion && parent.children.length > lastSegment) {
1224
+ const toModify = parent.children[lastSegment];
1225
+ edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
1226
+ } else if (parent.children.length === 0 || lastSegment === 0) {
1227
+ edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + "," };
1228
+ } else {
1229
+ const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
1230
+ const previous = parent.children[index - 1];
1231
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
1232
+ }
1233
+ return withFormatting(text, edit, options);
1234
+ } else {
1235
+ throw new Error(`Can not ${value === undefined ? "remove" : options.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
1236
+ }
1237
+ } else {
1238
+ throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent.type}`);
1239
+ }
1240
+ }
1241
+ function withFormatting(text, edit, options) {
1242
+ if (!options.formattingOptions) {
1243
+ return [edit];
1244
+ }
1245
+ let newText = applyEdit(text, edit);
1246
+ let begin = edit.offset;
1247
+ let end = edit.offset + edit.content.length;
1248
+ if (edit.length === 0 || edit.content.length === 0) {
1249
+ while (begin > 0 && !isEOL(newText, begin - 1)) {
1250
+ begin--;
1251
+ }
1252
+ while (end < newText.length && !isEOL(newText, end)) {
1253
+ end++;
1254
+ }
1255
+ }
1256
+ const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
1257
+ for (let i = edits.length - 1;i >= 0; i--) {
1258
+ const edit = edits[i];
1259
+ newText = applyEdit(newText, edit);
1260
+ begin = Math.min(begin, edit.offset);
1261
+ end = Math.max(end, edit.offset + edit.length);
1262
+ end += edit.content.length - edit.length;
1263
+ }
1264
+ const editLength = text.length - (newText.length - end) - begin;
1265
+ return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
1266
+ }
1267
+ function applyEdit(text, edit) {
1268
+ return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
1269
+ }
1270
+
1271
+ // ../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
1272
+ var createScanner = createScanner2;
1273
+ var ScanError;
1274
+ (function(ScanError) {
1275
+ ScanError[ScanError["None"] = 0] = "None";
1276
+ ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
1277
+ ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
1278
+ ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
1279
+ ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
1280
+ ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
1281
+ ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
1282
+ })(ScanError || (ScanError = {}));
1283
+ var SyntaxKind;
1284
+ (function(SyntaxKind) {
1285
+ SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
1286
+ SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
1287
+ SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
1288
+ SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
1289
+ SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
1290
+ SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
1291
+ SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
1292
+ SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
1293
+ SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
1294
+ SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
1295
+ SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
1296
+ SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
1297
+ SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
1298
+ SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
1299
+ SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
1300
+ SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
1301
+ SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
1302
+ })(SyntaxKind || (SyntaxKind = {}));
1303
+ var parse = parse2;
1304
+ var parseTree = parseTree2;
1305
+ var findNodeAtLocation = findNodeAtLocation2;
1306
+ var getNodeValue = getNodeValue2;
1307
+ var ParseErrorCode;
1308
+ (function(ParseErrorCode) {
1309
+ ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
1310
+ ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
1311
+ ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
1312
+ ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
1313
+ ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
1314
+ ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
1315
+ ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
1316
+ ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
1317
+ ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
1318
+ ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
1319
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
1320
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
1321
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
1322
+ ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
1323
+ ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
1324
+ ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
1325
+ })(ParseErrorCode || (ParseErrorCode = {}));
1326
+ function printParseErrorCode(code) {
1327
+ switch (code) {
1328
+ case 1:
1329
+ return "InvalidSymbol";
1330
+ case 2:
1331
+ return "InvalidNumberFormat";
1332
+ case 3:
1333
+ return "PropertyNameExpected";
1334
+ case 4:
1335
+ return "ValueExpected";
1336
+ case 5:
1337
+ return "ColonExpected";
1338
+ case 6:
1339
+ return "CommaExpected";
1340
+ case 7:
1341
+ return "CloseBraceExpected";
1342
+ case 8:
1343
+ return "CloseBracketExpected";
1344
+ case 9:
1345
+ return "EndOfFileExpected";
1346
+ case 10:
1347
+ return "InvalidCommentToken";
1348
+ case 11:
1349
+ return "UnexpectedEndOfComment";
1350
+ case 12:
1351
+ return "UnexpectedEndOfString";
1352
+ case 13:
1353
+ return "UnexpectedEndOfNumber";
1354
+ case 14:
1355
+ return "InvalidUnicode";
1356
+ case 15:
1357
+ return "InvalidEscapeCharacter";
1358
+ case 16:
1359
+ return "InvalidCharacter";
1360
+ }
1361
+ return "<unknown ParseErrorCode>";
1362
+ }
1363
+ function modify(text, path, value, options) {
1364
+ return setProperty(text, path, value, options);
1365
+ }
1366
+ function applyEdits(text, edits) {
1367
+ let sortedEdits = edits.slice(0).sort((a, b) => {
1368
+ const diff = a.offset - b.offset;
1369
+ if (diff === 0) {
1370
+ return a.length - b.length;
1371
+ }
1372
+ return diff;
1373
+ });
1374
+ let lastModifiedOffset = text.length;
1375
+ for (let i = sortedEdits.length - 1;i >= 0; i--) {
1376
+ let e = sortedEdits[i];
1377
+ if (e.offset + e.length <= lastModifiedOffset) {
1378
+ text = applyEdit(text, e);
1379
+ } else {
1380
+ throw new Error("Overlapping edit");
1381
+ }
1382
+ lastModifiedOffset = e.offset;
1383
+ }
1384
+ return text;
1385
+ }
1386
+
1387
+ export { createScanner, parse, parseTree, findNodeAtLocation, getNodeValue, printParseErrorCode, modify, applyEdits };