@onerjs/code-input 0.1.2 → 0.1.4

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.
@@ -1,5 +1,5 @@
1
- import { defineComponent as wt, ref as C, computed as V, watch as Be, nextTick as j, onMounted as $t, onBeforeUnmount as Ct, openBlock as S, createElementBlock as E, normalizeStyle as ae, normalizeClass as te, createElementVNode as R, withModifiers as Le, Fragment as Oe, renderList as Ne, toDisplayString as K, createCommentVNode as D, createTextVNode as Tt } from "vue";
2
- const St = [
1
+ import { defineComponent as Et, ref as E, computed as K, watch as Oe, nextTick as V, onMounted as Rt, onBeforeUnmount as Mt, openBlock as I, createElementBlock as L, normalizeStyle as ce, normalizeClass as ne, createElementVNode as A, withModifiers as Ne, Fragment as We, renderList as ze, toDisplayString as Y, createCommentVNode as Z, createTextVNode as It } from "vue";
2
+ const Lt = [
3
3
  {
4
4
  label: "Math",
5
5
  kind: "class",
@@ -134,7 +134,51 @@ const St = [
134
134
  kind: "function",
135
135
  detail: "(id: number) => void"
136
136
  }
137
- ], ze = [
137
+ ], _t = /[\w$]/;
138
+ function Ht(n, s) {
139
+ const o = [];
140
+ let e = null;
141
+ for (let C = 0; C < s; C++) {
142
+ const b = n[C];
143
+ if (e) {
144
+ b === e && n[C - 1] !== "\\" && (e = null);
145
+ continue;
146
+ }
147
+ if (b === "'" || b === '"' || b === "`") {
148
+ e = b;
149
+ continue;
150
+ }
151
+ if (b === "(") {
152
+ o.push({ index: C, commas: 0 });
153
+ continue;
154
+ }
155
+ if (b === ")") {
156
+ o.pop();
157
+ continue;
158
+ }
159
+ b === "," && o.length && o[o.length - 1].commas++;
160
+ }
161
+ const i = o[o.length - 1];
162
+ if (!i) return null;
163
+ let r = i.index - 1;
164
+ for (; r >= 0 && /\s/.test(n[r]); ) r--;
165
+ const f = r;
166
+ for (; r >= 0 && _t.test(n[r]); ) r--;
167
+ const u = n.slice(r + 1, f + 1);
168
+ if (!u) return null;
169
+ let a = s;
170
+ for (; a > 0 && /[\w$'"]/.test(n[a - 1]); ) a--;
171
+ const d = n.slice(a, s);
172
+ let $ = d, z = null;
173
+ return d && (d[0] === "'" || d[0] === '"') && (z = d[0], $ = d.slice(1)), {
174
+ functionName: u,
175
+ paramIndex: i.commas,
176
+ prefix: $,
177
+ replaceStart: a,
178
+ quote: z
179
+ };
180
+ }
181
+ const De = [
138
182
  "break",
139
183
  "case",
140
184
  "catch",
@@ -179,7 +223,7 @@ const St = [
179
223
  "undefined",
180
224
  "NaN",
181
225
  "Infinity"
182
- ], Et = [
226
+ ], At = [
183
227
  "abstract",
184
228
  "any",
185
229
  "as",
@@ -209,534 +253,590 @@ const St = [
209
253
  "type",
210
254
  "unknown"
211
255
  ];
212
- function Ye(l) {
213
- return l === "typescript" ? [...ze, ...Et] : ze;
256
+ function Xe(n) {
257
+ return n === "typescript" ? [...De, ...At] : De;
214
258
  }
215
- function je(l) {
216
- return new Set(Ye(l));
259
+ function je(n) {
260
+ return new Set(Xe(n));
217
261
  }
218
- const It = /((?:[A-Za-z_$][\w$]*\??\.)*)([A-Za-z_$][\w$]*)?$/, De = /\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g, Rt = /^[A-Za-z_$]/;
219
- function Je(l, s) {
220
- const a = l.slice(0, s), t = It.exec(a);
221
- if (!t) return { prefix: "", chain: [] };
222
- const o = t[1] ?? "", c = t[2] ?? "", u = o.split(".").filter(Boolean).map((d) => d.replace(/\?$/, ""));
223
- return { prefix: c, chain: u };
262
+ const Bt = /((?:[A-Za-z_$][\w$]*\??\.)*)([A-Za-z_$][\w$]*)?$/, Fe = /\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g, Ot = /^[A-Za-z_$]/;
263
+ function Ge(n, s) {
264
+ const o = n.slice(0, s), e = Bt.exec(o);
265
+ if (!e) return { prefix: "", chain: [] };
266
+ const i = e[1] ?? "", r = e[2] ?? "", f = i.split(".").filter(Boolean).map((u) => u.replace(/\?$/, ""));
267
+ return { prefix: r, chain: f };
224
268
  }
225
- function We(l, s) {
226
- const a = [], t = /* @__PURE__ */ new Set();
227
- let o;
228
- for (De.lastIndex = 0; (o = De.exec(l)) && !(o.index >= s); ) {
229
- const c = o[1];
230
- if (t.has(c)) continue;
231
- t.add(c);
232
- const u = o[0].slice(0, o[0].indexOf(c)).trim();
233
- a.push({
234
- label: c,
235
- kind: u === "function" ? "function" : u === "class" ? "class" : "variable",
269
+ function Pe(n, s) {
270
+ const o = [], e = /* @__PURE__ */ new Set();
271
+ let i;
272
+ for (Fe.lastIndex = 0; (i = Fe.exec(n)) && !(i.index >= s); ) {
273
+ const r = i[1];
274
+ if (e.has(r)) continue;
275
+ e.add(r);
276
+ const f = i[0].slice(0, i[0].indexOf(r)).trim();
277
+ o.push({
278
+ label: r,
279
+ kind: f === "function" ? "function" : f === "class" ? "class" : "variable",
236
280
  detail: "当前文件"
237
281
  });
238
282
  }
239
- return a;
283
+ return o;
240
284
  }
241
- function Ge(l, s) {
242
- let a = s;
243
- for (const t of l) {
244
- if (!a) return null;
245
- const o = a.find((c) => c.label === t);
285
+ function Qe(n, s) {
286
+ let o = s;
287
+ for (const e of n) {
246
288
  if (!o) return null;
247
- a = o.members ?? [];
289
+ const i = o.find((r) => r.label === e);
290
+ if (!i) return null;
291
+ o = i.members ?? [];
248
292
  }
249
- return a;
293
+ return o;
250
294
  }
251
- function Mt(l, s) {
252
- const a = l.toLowerCase(), t = s.toLowerCase(), o = a.indexOf(t);
253
- if (o === 0) return 1e3 - a.length;
254
- if (o > 0) return 800 - o;
255
- let c = 0, u = 0, d = -1;
256
- for (let i = 0; i < a.length && c < t.length; i++)
257
- a[i] === t[c] && (d >= 0 && (u += i - d - 1), d = i, c++);
258
- return c !== t.length ? null : 400 - u - a.length;
295
+ function Nt(n, s) {
296
+ const o = n.toLowerCase(), e = s.toLowerCase(), i = o.indexOf(e);
297
+ if (i === 0) return 1e3 - o.length;
298
+ if (i > 0) return 800 - i;
299
+ let r = 0, f = 0, u = -1;
300
+ for (let a = 0; a < o.length && r < e.length; a++)
301
+ o[a] === e[r] && (u >= 0 && (f += a - u - 1), u = a, r++);
302
+ return r !== e.length ? null : 400 - f - o.length;
259
303
  }
260
- function _t(l, s) {
261
- if (!s) return l;
262
- const a = [];
263
- for (const t of l) {
264
- const o = Mt(t.label, s);
265
- o !== null && a.push({ item: t, score: o });
304
+ function et(n, s) {
305
+ if (!s) return n;
306
+ const o = [];
307
+ for (const e of n) {
308
+ const i = Nt(e.label, s);
309
+ i !== null && o.push({ item: e, score: i });
266
310
  }
267
- return a.sort((t, o) => o.score - t.score || t.item.label.localeCompare(o.item.label)), a.map((t) => t.item);
311
+ return o.sort((e, i) => i.score - e.score || e.item.label.localeCompare(i.item.label)), o.map((e) => e.item);
268
312
  }
269
- function Ht(l) {
270
- const s = /* @__PURE__ */ new Set(), a = [];
271
- for (const t of l)
272
- s.has(t.label) || (s.add(t.label), a.push(t));
273
- return a;
313
+ function Wt(n) {
314
+ const s = /* @__PURE__ */ new Set(), o = [];
315
+ for (const e of n)
316
+ s.has(e.label) || (s.add(e.label), o.push(e));
317
+ return o;
274
318
  }
275
- function At(l, s, a) {
276
- const { prefix: t, chain: o } = Je(l, s);
277
- if (a.auto && (!t && o.length === 0 || t && !Rt.test(t)))
319
+ function zt(n, s, o) {
320
+ const { prefix: e, chain: i } = Ge(n, s);
321
+ if (o.auto && (!e && i.length === 0 || e && !Ot.test(e)))
278
322
  return null;
279
- const c = a.declared ?? [], u = [...c, ...a.completions];
280
- let d;
281
- if (o.length > 0) {
282
- const p = Ge(o, u);
283
- if (!p || p.length === 0) return null;
284
- d = p;
323
+ const r = o.declared ?? [], f = [...r, ...o.completions];
324
+ let u;
325
+ if (i.length > 0) {
326
+ const d = Qe(i, f);
327
+ if (!d || d.length === 0) return null;
328
+ u = d;
285
329
  } else
286
- d = [
287
- ...a.completions,
288
- ...c,
289
- ...Ye(a.language).map((p) => ({
290
- label: p,
330
+ u = [
331
+ ...o.completions,
332
+ ...r,
333
+ ...Xe(o.language).map((d) => ({
334
+ label: d,
291
335
  kind: "keyword"
292
336
  }))
293
337
  ];
294
- const i = _t(Ht(d), t);
295
- return i.length === 0 ? null : {
296
- items: i,
297
- start: s - t.length,
338
+ const a = et(Wt(u), e);
339
+ return a.length === 0 ? null : {
340
+ items: a,
341
+ start: s - e.length,
298
342
  end: s
299
343
  };
300
344
  }
301
- const Bt = /([A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*)\??\.\s*$/;
302
- function Lt(l, s, a, t) {
303
- const o = l.slice(s, a);
304
- if (!o) return null;
305
- const c = [...t.declared ?? [], ...t.completions], u = Bt.exec(l.slice(0, s));
306
- if (u) {
307
- const d = u[1].split(".").filter(Boolean).map((M) => M.replace(/\?$/, "")), i = Ge(d, c), p = i == null ? void 0 : i.find((M) => M.label === o);
308
- if (p) return p;
345
+ const Dt = /([A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*)\??\.\s*$/;
346
+ function jt(n, s, o, e) {
347
+ const i = n.slice(s, o);
348
+ if (!i) return null;
349
+ const r = [...e.declared ?? [], ...e.completions], f = Dt.exec(n.slice(0, s));
350
+ if (f) {
351
+ const u = f[1].split(".").filter(Boolean).map(($) => $.replace(/\?$/, "")), a = Qe(u, r), d = a == null ? void 0 : a.find(($) => $.label === i);
352
+ if (d) return d;
309
353
  }
310
- return c.find((d) => d.label === o) ?? null;
354
+ return r.find((u) => u.label === i) ?? null;
311
355
  }
312
- const Z = "[A-Za-z_$][\\w$]*", Fe = "(?:readonly\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|abstract\\s+)*";
313
- function Pe(l, s) {
314
- let a = 0, t = !1, o = s;
315
- for (let c = s; c < l.length; c++) {
316
- const u = l[c];
317
- for (let d = 0; d < u.length; d++) {
318
- const i = u[d];
319
- i === "{" ? (a++, t = !0) : i === "}" && a--;
320
- }
321
- if (t && a <= 0) {
322
- o = c;
356
+ const U = "[A-Za-z_$][\\w$]*", Ve = "(?:readonly\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|abstract\\s+)*";
357
+ function qe(n, s) {
358
+ let o = 0, e = !1, i = s;
359
+ for (let r = s; r < n.length; r++) {
360
+ const f = n[r];
361
+ for (let u = 0; u < f.length; u++) {
362
+ const a = f[u];
363
+ a === "{" ? (o++, e = !0) : a === "}" && o--;
364
+ }
365
+ if (e && o <= 0) {
366
+ i = r;
323
367
  break;
324
368
  }
325
369
  }
326
- return { end: o, body: l.slice(s + 1, o) };
370
+ return { end: i, body: n.slice(s + 1, i) };
327
371
  }
328
- function Ve(l) {
329
- return l.trim().replace(/[,;]$/, "").trim();
372
+ function Ke(n) {
373
+ return n.trim().replace(/[,;]$/, "").trim();
330
374
  }
331
- function Ot(l) {
375
+ function Ft(n) {
332
376
  return /^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:interface|class|type|function|const|let|var|namespace|enum)\b/.test(
333
- l
377
+ n
334
378
  );
335
379
  }
336
- function ne(l, s) {
337
- const a = l[s];
338
- let t = a.lastIndexOf("}");
339
- const o = a.lastIndexOf(";");
340
- if (o > t && (t = o), t === -1) return;
341
- const c = a.slice(t + 1).replace(/^[\s;]+/, "").trim();
342
- !c || !Ot(c) || (l[s] = a.slice(0, t + 1), l.splice(s + 1, 0, c));
380
+ function le(n, s) {
381
+ const o = n[s];
382
+ let e = o.lastIndexOf("}");
383
+ const i = o.lastIndexOf(";");
384
+ if (i > e && (e = i), e === -1) return;
385
+ const r = o.slice(e + 1).replace(/^[\s;]+/, "").trim();
386
+ !r || !Ft(r) || (n[s] = o.slice(0, e + 1), n.splice(s + 1, 0, r));
343
387
  }
344
- function U(l) {
345
- return l.length ? l.join(`
388
+ function X(n) {
389
+ return n.length ? n.join(`
346
390
  `).replace(/^\s*\/\*\*?/, "").replace(/\*\/\s*$/, "").split(`
347
391
  `).map((s) => s.replace(/^\s*\*+\s?/, "").replace(/^\s*\/\/\s?/, "")).join(`
348
392
  `).replace(/\n{3,}/g, `
349
393
 
350
394
  `).trim() : "";
351
395
  }
352
- function Ke(l) {
353
- return l.split(`
396
+ function Ze(n) {
397
+ return n.split(`
354
398
  `).filter((s) => !/^\s*(\/\/|\/\*|\*)/.test(s)).join(`
355
399
  `).replace(/\n{2,}/g, `
356
400
  `).trim();
357
401
  }
358
- function Ze(l) {
359
- const s = [], a = /* @__PURE__ */ new Set(), t = new RegExp(`^${Fe}(${Z})(\\?)?\\s*\\((.*)\\)\\s*:\\s*(.+?);?$`), o = new RegExp(`^${Fe}(${Z})(\\?)?\\s*:\\s*(.+?);?$`);
360
- let c = [], u = !1;
361
- for (const d of l) {
362
- const i = d.trim();
363
- if (u) {
364
- c.push(i), i.includes("*/") && (u = !1);
402
+ function Ue(n) {
403
+ const s = [], o = /* @__PURE__ */ new Set(), e = new RegExp(`^${Ve}(${U})(\\?)?\\s*\\((.*)\\)\\s*:\\s*(.+?);?$`), i = new RegExp(`^${Ve}(${U})(\\?)?\\s*:\\s*(.+?);?$`);
404
+ let r = [], f = !1;
405
+ for (const u of n) {
406
+ const a = u.trim();
407
+ if (f) {
408
+ r.push(a), a.includes("*/") && (f = !1);
365
409
  continue;
366
410
  }
367
- if (i.startsWith("/*")) {
368
- c.push(i), i.includes("*/") || (u = !0);
411
+ if (a.startsWith("/*")) {
412
+ r.push(a), a.includes("*/") || (f = !0);
369
413
  continue;
370
414
  }
371
- if (i.startsWith("//")) {
372
- c.push(i);
415
+ if (a.startsWith("//")) {
416
+ r.push(a);
373
417
  continue;
374
418
  }
375
- if (!i || i.startsWith("}") || i.startsWith("[")) {
376
- c = [];
419
+ if (!a || a.startsWith("}") || a.startsWith("[")) {
420
+ r = [];
377
421
  continue;
378
422
  }
379
- const p = t.exec(i);
380
- if (p) {
381
- const W = U(c);
382
- c = [];
383
- const g = p[1];
384
- if (a.has(g)) continue;
385
- a.add(g), s.push({
386
- label: g,
423
+ const d = e.exec(a);
424
+ if (d) {
425
+ const z = X(r);
426
+ r = [];
427
+ const C = d[1];
428
+ if (o.has(C)) continue;
429
+ o.add(C), s.push({
430
+ label: C,
387
431
  kind: "function",
388
- detail: `(${p[3].trim()}) => ${Ve(p[4])}`,
389
- documentation: W || void 0
432
+ detail: `(${d[3].trim()}) => ${Ke(d[4])}`,
433
+ documentation: z || void 0
390
434
  });
391
435
  continue;
392
436
  }
393
- const M = o.exec(i);
394
- if (M) {
395
- const W = U(c);
396
- c = [];
397
- const g = M[1];
398
- if (a.has(g)) continue;
399
- a.add(g);
400
- const b = Ve(M[3]), H = /^\(|=>/.test(b) ? "function" : "property";
437
+ const $ = i.exec(a);
438
+ if ($) {
439
+ const z = X(r);
440
+ r = [];
441
+ const C = $[1];
442
+ if (o.has(C)) continue;
443
+ o.add(C);
444
+ const b = Ke($[3]), y = /^\(|=>/.test(b) ? "function" : "property";
401
445
  s.push({
402
- label: g,
403
- kind: H,
446
+ label: C,
447
+ kind: y,
404
448
  detail: b,
405
- documentation: W || void 0
449
+ documentation: z || void 0
406
450
  });
407
451
  }
408
452
  }
409
453
  return s;
410
454
  }
411
- function Xe(l) {
412
- const s = l.replace(/\[\]/g, "").replace(/<[^>]*>/g, "").replace(/\s*\|\s*null\s*/g, "").trim(), a = new RegExp(`^(${Z})$`).exec(s);
413
- return a ? a[1] : null;
455
+ function tt(n) {
456
+ const s = [], o = /(['"])((?:\\.|(?!\1).)*)\1/g;
457
+ let e;
458
+ for (; e = o.exec(n); )
459
+ s.push(e[2]);
460
+ return s;
461
+ }
462
+ function Pt(n, s) {
463
+ const o = [];
464
+ let e = 0, i = "", r = null;
465
+ for (let f = 0; f < n.length; f++) {
466
+ const u = n[f];
467
+ if (r) {
468
+ i += u, u === r && n[f - 1] !== "\\" && (r = null);
469
+ continue;
470
+ }
471
+ if (u === "'" || u === '"' || u === "`") {
472
+ r = u, i += u;
473
+ continue;
474
+ }
475
+ if (u === "(" || u === "<" || u === "[" || u === "{" ? e++ : (u === ")" || u === ">" || u === "]" || u === "}") && e--, u === s && e === 0) {
476
+ o.push(i), i = "";
477
+ continue;
478
+ }
479
+ i += u;
480
+ }
481
+ return o.push(i), o;
482
+ }
483
+ function Vt(n, s) {
484
+ const o = n.trim(), e = tt(o);
485
+ if (e.length) return e;
486
+ const i = s.get(o.replace(/\[\]$/, ""));
487
+ return (i == null ? void 0 : i.literals) ?? [];
414
488
  }
415
- function Nt(l) {
416
- const s = l.trim();
489
+ function qt(n, s) {
490
+ const o = n.trim();
491
+ return o ? Pt(o, ",").map((e) => {
492
+ const i = new RegExp(`^\\s*(${U})\\s*(\\?)?\\s*:\\s*(.+)$`).exec(e);
493
+ if (!i)
494
+ return { name: e.trim(), type: "", optional: !1, literals: [] };
495
+ const r = i[3].replace(/\s*=\s*[^=]*$/, "").trim();
496
+ return {
497
+ name: i[1],
498
+ optional: !!i[2],
499
+ type: r,
500
+ literals: Vt(r, s)
501
+ };
502
+ }) : [];
503
+ }
504
+ function nt(n) {
505
+ const s = n.replace(/\[\]/g, "").replace(/<[^>]*>/g, "").replace(/\s*\|\s*null\s*/g, "").trim(), o = new RegExp(`^(${U})$`).exec(s);
506
+ return o ? o[1] : null;
507
+ }
508
+ function Kt(n) {
509
+ const s = n.trim();
417
510
  if (!s || s.endsWith(";")) return !1;
418
- const a = (s.match(/[(<[{]/g) ?? []).length, t = (s.match(/[)>\]}]/g) ?? []).length;
419
- return /[|&,(<]\s*$/.test(s) || a > t;
511
+ const o = (s.match(/[(<[{]/g) ?? []).length, e = (s.match(/[)>\]}]/g) ?? []).length;
512
+ return /[|&,(<]\s*$/.test(s) || o > e;
420
513
  }
421
- function Qe(l, s, a, t = 0) {
422
- return t > 6 ? l : l.map((o) => {
423
- if (o.kind !== "property" || !o.detail) return o;
424
- const c = Xe(o.detail), u = c ? s.get(c) : void 0;
425
- if (!u || a.has(u.label)) return o;
426
- const d = new Set(a);
427
- return d.add(u.label), {
428
- ...o,
429
- type: u.type,
430
- members: Qe(u.members, s, d, t + 1)
514
+ function lt(n, s, o, e = 0) {
515
+ return e > 6 ? n : n.map((i) => {
516
+ if (i.kind !== "property" || !i.detail) return i;
517
+ const r = nt(i.detail), f = r ? s.get(r) : void 0;
518
+ if (!f || o.has(f.label)) return i;
519
+ const u = new Set(o);
520
+ return u.add(f.label), {
521
+ ...i,
522
+ type: f.type,
523
+ members: lt(f.members, s, u, e + 1)
431
524
  };
432
525
  });
433
526
  }
434
- const zt = 50, le = /* @__PURE__ */ new Map();
435
- function jt(l) {
436
- if (!l || !l.trim()) return [];
437
- const s = le.get(l);
527
+ const Zt = 50, ie = /* @__PURE__ */ new Map(), Ut = { items: [], signatures: /* @__PURE__ */ new Map() };
528
+ function it(n) {
529
+ if (!n || !n.trim()) return Ut;
530
+ const s = ie.get(n);
438
531
  if (s) return s;
439
- const a = Dt(l);
440
- if (le.size >= zt) {
441
- const t = le.keys().next().value;
442
- t !== void 0 && le.delete(t);
532
+ const o = Xt(n);
533
+ if (ie.size >= Zt) {
534
+ const e = ie.keys().next().value;
535
+ e !== void 0 && ie.delete(e);
443
536
  }
444
- return le.set(l, a), a;
537
+ return ie.set(n, o), o;
445
538
  }
446
- function Dt(l) {
447
- const s = l.split(`
448
- `), a = /* @__PURE__ */ new Map(), t = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${Z})`), o = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${Z})`), c = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?type\\s+(${Z})\\s*=`);
449
- let u = [], d = !1;
450
- for (let g = 0; g < s.length; g++) {
451
- const b = s[g].trim();
452
- if (d) {
453
- u.push(b), b.includes("*/") && (d = !1);
539
+ function Yt(n) {
540
+ return it(n).items;
541
+ }
542
+ function Jt(n) {
543
+ return it(n).signatures;
544
+ }
545
+ function Xt(n) {
546
+ const s = n.split(`
547
+ `), o = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), i = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${U})`), r = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${U})`), f = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?type\\s+(${U})\\s*=`);
548
+ let u = [], a = !1;
549
+ for (let b = 0; b < s.length; b++) {
550
+ const y = s[b].trim();
551
+ if (a) {
552
+ u.push(y), y.includes("*/") && (a = !1);
454
553
  continue;
455
554
  }
456
- if (b.startsWith("/*")) {
457
- u.push(b), b.includes("*/") || (d = !0);
555
+ if (y.startsWith("/*")) {
556
+ u.push(y), y.includes("*/") || (a = !0);
458
557
  continue;
459
558
  }
460
- if (b.startsWith("//")) {
461
- u.push(b);
559
+ if (y.startsWith("//")) {
560
+ u.push(y);
462
561
  continue;
463
562
  }
464
- if (!b) {
563
+ if (!y) {
465
564
  u = [];
466
565
  continue;
467
566
  }
468
- const H = t.exec(b);
469
- if (H && b.includes("{")) {
470
- const w = U(u);
567
+ const O = i.exec(y);
568
+ if (O && y.includes("{")) {
569
+ const w = X(u);
471
570
  u = [];
472
- const { end: y, body: T } = Pe(s, g), k = H[1];
473
- a.set(k, {
474
- label: k,
475
- type: Ke(
476
- s.slice(g, y + 1).join(`
571
+ const { end: T, body: _ } = qe(s, b), g = O[1];
572
+ o.set(g, {
573
+ label: g,
574
+ type: Ze(
575
+ s.slice(b, T + 1).join(`
477
576
  `).replace(/^\s*export\s+/, "")
478
577
  ),
479
- members: Ze(T),
578
+ members: Ue(_),
480
579
  kind: "interface",
481
580
  documentation: w || void 0
482
- }), ne(s, y), g = y;
581
+ }), le(s, T), b = T;
483
582
  continue;
484
583
  }
485
- const O = o.exec(b);
486
- if (O && b.includes("{")) {
487
- const w = U(u);
584
+ const B = r.exec(y);
585
+ if (B && y.includes("{")) {
586
+ const w = X(u);
488
587
  u = [];
489
- const { end: y, body: T } = Pe(s, g), k = O[1];
490
- a.set(k, {
491
- label: k,
492
- type: Ke(
493
- s.slice(g, y + 1).join(`
588
+ const { end: T, body: _ } = qe(s, b), g = B[1];
589
+ o.set(g, {
590
+ label: g,
591
+ type: Ze(
592
+ s.slice(b, T + 1).join(`
494
593
  `).replace(/^\s*export\s+/, "")
495
594
  ),
496
- members: Ze(T),
595
+ members: Ue(_),
497
596
  kind: "class",
498
597
  documentation: w || void 0
499
- }), ne(s, y), g = y;
598
+ }), le(s, T), b = T;
500
599
  continue;
501
600
  }
502
- const A = c.exec(b);
503
- if (A) {
504
- const w = U(u);
601
+ const R = f.exec(y);
602
+ if (R) {
603
+ const w = X(u);
505
604
  u = [];
506
- const y = [s[g]];
507
- let T = g;
508
- for (; Nt(y.join(`
509
- `)) && T + 1 < s.length; )
510
- T++, y.push(s[T]);
511
- const k = y.join(`
605
+ const T = [s[b]];
606
+ let _ = b;
607
+ for (; Kt(T.join(`
608
+ `)) && _ + 1 < s.length; )
609
+ _++, T.push(s[_]);
610
+ const g = T.join(`
512
611
  `).replace(/^\s*export\s+/, "").replace(/;\s*$/, "").trim();
513
- a.set(A[1], {
514
- label: A[1],
515
- type: k,
612
+ o.set(R[1], {
613
+ label: R[1],
614
+ type: g,
516
615
  members: [],
517
616
  kind: "type",
518
- documentation: w || void 0
519
- }), ne(s, T), g = T;
617
+ documentation: w || void 0,
618
+ literals: tt(g)
619
+ }), le(s, _), b = _;
520
620
  continue;
521
621
  }
522
622
  u = [];
523
623
  }
524
- const i = [], p = /* @__PURE__ */ new Set(), M = new RegExp(
525
- `^(?:export\\s+)?(?:declare\\s+)?function\\s+(${Z})\\s*\\(([^)]*)\\)\\s*:\\s*([^;{]+)`
526
- ), W = new RegExp(
527
- `^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${Z})\\s*:\\s*([^=;]+)`
624
+ const d = [], $ = /* @__PURE__ */ new Set(), z = new RegExp(
625
+ `^(?:export\\s+)?(?:declare\\s+)?function\\s+(${U})\\s*\\(([^)]*)\\)\\s*:\\s*([^;{]+)`
626
+ ), C = new RegExp(
627
+ `^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${U})\\s*:\\s*([^=;]+)`
528
628
  );
529
- u = [], d = !1;
530
- for (let g = 0; g < s.length; g++) {
531
- const b = s[g].trim();
532
- if (d) {
533
- u.push(b), b.includes("*/") && (d = !1);
629
+ u = [], a = !1;
630
+ for (let b = 0; b < s.length; b++) {
631
+ const y = s[b].trim();
632
+ if (a) {
633
+ u.push(y), y.includes("*/") && (a = !1);
534
634
  continue;
535
635
  }
536
- if (b.startsWith("/*")) {
537
- u.push(b), b.includes("*/") || (d = !0);
636
+ if (y.startsWith("/*")) {
637
+ u.push(y), y.includes("*/") || (a = !0);
538
638
  continue;
539
639
  }
540
- if (b.startsWith("//")) {
541
- u.push(b);
640
+ if (y.startsWith("//")) {
641
+ u.push(y);
542
642
  continue;
543
643
  }
544
- if (!b) {
644
+ if (!y) {
545
645
  u = [];
546
646
  continue;
547
647
  }
548
- const H = M.exec(b);
549
- if (H) {
550
- ne(s, g);
551
- const A = U(u);
648
+ const O = z.exec(y);
649
+ if (O) {
650
+ le(s, b);
651
+ const R = X(u);
552
652
  u = [];
553
- const w = H[1];
554
- p.has(w) || (p.add(w), i.push({
653
+ const w = O[1];
654
+ $.has(w) || ($.add(w), d.push({
555
655
  label: w,
556
656
  kind: "function",
557
- detail: `(${H[2].trim()}) => ${H[3].trim()}`,
558
- documentation: A || void 0
559
- }));
657
+ detail: `(${O[2].trim()}) => ${O[3].trim()}`,
658
+ documentation: R || void 0
659
+ })), e.set(w, { name: w, params: qt(O[2], o) });
560
660
  continue;
561
661
  }
562
- const O = W.exec(b);
563
- if (O) {
564
- ne(s, g);
565
- const A = U(u);
662
+ const B = C.exec(y);
663
+ if (B) {
664
+ le(s, b);
665
+ const R = X(u);
566
666
  u = [];
567
- const w = O[1];
568
- if (p.has(w)) continue;
569
- p.add(w);
570
- const y = O[2].trim(), T = Xe(y), k = T ? a.get(T) : void 0, $ = (k == null ? void 0 : k.kind) === "class" ? "class" : /^\(|=>/.test(y) ? "function" : "variable";
571
- i.push({
667
+ const w = B[1];
668
+ if ($.has(w)) continue;
669
+ $.add(w);
670
+ const T = B[2].trim(), _ = nt(T), g = _ ? o.get(_) : void 0, oe = (g == null ? void 0 : g.kind) === "class" ? "class" : /^\(|=>/.test(T) ? "function" : "variable";
671
+ d.push({
572
672
  label: w,
573
- kind: $,
574
- detail: y,
575
- type: k == null ? void 0 : k.type,
576
- documentation: A || (k == null ? void 0 : k.documentation) || void 0,
577
- members: k ? Qe(k.members, a, /* @__PURE__ */ new Set([k.label])) : void 0
673
+ kind: oe,
674
+ detail: T,
675
+ type: g == null ? void 0 : g.type,
676
+ documentation: R || (g == null ? void 0 : g.documentation) || void 0,
677
+ members: g ? lt(g.members, o, /* @__PURE__ */ new Set([g.label])) : void 0
578
678
  });
579
679
  continue;
580
680
  }
581
681
  u = [];
582
682
  }
583
- return i;
683
+ return { items: d, signatures: e };
584
684
  }
585
- function ve(l, s, a, t) {
586
- if (!a || !t) return null;
587
- const o = Math.max(0, s - 1), c = l.lastIndexOf(a, o);
588
- if (c === -1 || l.lastIndexOf(t, o) > c) return null;
589
- const d = l.indexOf(t, c + a.length);
685
+ function we(n, s, o, e) {
686
+ if (!o || !e) return null;
687
+ const i = Math.max(0, s - 1), r = n.lastIndexOf(o, i);
688
+ if (r === -1 || n.lastIndexOf(e, i) > r) return null;
689
+ const u = n.indexOf(e, r + o.length);
590
690
  return {
591
- start: c + a.length,
592
- end: d === -1 ? l.length : d
691
+ start: r + o.length,
692
+ end: u === -1 ? n.length : u
593
693
  };
594
694
  }
595
- function dn(l, s, a, t) {
596
- return ve(l, s, a, t) !== null;
695
+ function xn(n, s, o, e) {
696
+ return we(n, s, o, e) !== null;
597
697
  }
598
- const qe = /[A-Za-z_$]/, Wt = /[\w$]/, Ue = /\s/;
599
- function se(l, s) {
600
- const a = [], t = l.length;
601
- let o = 0;
602
- for (; o < t; ) {
603
- const c = l[o], u = l[o + 1];
604
- if (Ue.test(c)) {
605
- o++;
698
+ const Ye = /[A-Za-z_$]/, Gt = /[\w$]/, Je = /\s/;
699
+ function ue(n, s) {
700
+ const o = [], e = n.length;
701
+ let i = 0;
702
+ for (; i < e; ) {
703
+ const r = n[i], f = n[i + 1];
704
+ if (Je.test(r)) {
705
+ i++;
606
706
  continue;
607
707
  }
608
- if (c === "/" && u === "/") {
609
- let i = l.indexOf(`
610
- `, o);
611
- i === -1 && (i = t), a.push({ start: o, end: i, type: "comment" }), o = i;
708
+ if (r === "/" && f === "/") {
709
+ let a = n.indexOf(`
710
+ `, i);
711
+ a === -1 && (a = e), o.push({ start: i, end: a, type: "comment" }), i = a;
612
712
  continue;
613
713
  }
614
- if (c === "/" && u === "*") {
615
- const i = l.indexOf("*/", o + 2), p = i === -1 ? t : i + 2;
616
- a.push({ start: o, end: p, type: "comment" }), o = p;
714
+ if (r === "/" && f === "*") {
715
+ const a = n.indexOf("*/", i + 2), d = a === -1 ? e : a + 2;
716
+ o.push({ start: i, end: d, type: "comment" }), i = d;
617
717
  continue;
618
718
  }
619
- if (c === '"' || c === "'") {
620
- let i = o + 1;
621
- for (; i < t; ) {
622
- if (l[i] === "\\") {
623
- i += 2;
719
+ if (r === '"' || r === "'") {
720
+ let a = i + 1;
721
+ for (; a < e; ) {
722
+ if (n[a] === "\\") {
723
+ a += 2;
624
724
  continue;
625
725
  }
626
- if (l[i] === `
726
+ if (n[a] === `
627
727
  `) break;
628
- if (l[i] === c) {
629
- i++;
728
+ if (n[a] === r) {
729
+ a++;
630
730
  break;
631
731
  }
632
- i++;
732
+ a++;
633
733
  }
634
- a.push({ start: o, end: i, type: "string" }), o = i;
734
+ o.push({ start: i, end: a, type: "string" }), i = a;
635
735
  continue;
636
736
  }
637
- if (c === "`") {
638
- let i = o + 1;
639
- for (; i < t; ) {
640
- if (l[i] === "\\") {
641
- i += 2;
737
+ if (r === "`") {
738
+ let a = i + 1;
739
+ for (; a < e; ) {
740
+ if (n[a] === "\\") {
741
+ a += 2;
642
742
  continue;
643
743
  }
644
- if (l[i] === "`") {
645
- i++;
744
+ if (n[a] === "`") {
745
+ a++;
646
746
  break;
647
747
  }
648
- i++;
748
+ a++;
649
749
  }
650
- a.push({ start: o, end: i, type: "template" }), o = i;
750
+ o.push({ start: i, end: a, type: "template" }), i = a;
651
751
  continue;
652
752
  }
653
- if (/[0-9]/.test(c) || c === "." && /[0-9]/.test(u ?? "")) {
654
- let i = o + 1;
655
- for (; i < t && /[\w.]/.test(l[i]); ) i++;
656
- a.push({ start: o, end: i, type: "number" }), o = i;
753
+ if (/[0-9]/.test(r) || r === "." && /[0-9]/.test(f ?? "")) {
754
+ let a = i + 1;
755
+ for (; a < e && /[\w.]/.test(n[a]); ) a++;
756
+ o.push({ start: i, end: a, type: "number" }), i = a;
657
757
  continue;
658
758
  }
659
- if (qe.test(c)) {
660
- let i = o + 1;
661
- for (; i < t && Wt.test(l[i]); ) i++;
662
- const p = l.slice(o, i), M = s.keywords.has(p) ? "keyword" : s.builtins.has(p) ? "builtin" : "identifier";
663
- a.push({ start: o, end: i, type: M }), o = i;
759
+ if (Ye.test(r)) {
760
+ let a = i + 1;
761
+ for (; a < e && Gt.test(n[a]); ) a++;
762
+ const d = n.slice(i, a), $ = s.keywords.has(d) ? "keyword" : s.builtins.has(d) ? "builtin" : "identifier";
763
+ o.push({ start: i, end: a, type: $ }), i = a;
664
764
  continue;
665
765
  }
666
- let d = o + 1;
667
- for (; d < t; ) {
668
- const i = l[d];
669
- if (Ue.test(i) || qe.test(i) || /[0-9]/.test(i) || i === '"' || i === "'" || i === "`" || i === "/") break;
670
- d++;
766
+ let u = i + 1;
767
+ for (; u < e; ) {
768
+ const a = n[u];
769
+ if (Je.test(a) || Ye.test(a) || /[0-9]/.test(a) || a === '"' || a === "'" || a === "`" || a === "/") break;
770
+ u++;
671
771
  }
672
- a.push({ start: o, end: d, type: "punctuation" }), o = d;
772
+ o.push({ start: i, end: u, type: "punctuation" }), i = u;
673
773
  }
674
- return a;
774
+ return o;
675
775
  }
676
- const Ft = {
776
+ const Qt = {
677
777
  "&": "&amp;",
678
778
  "<": "&lt;",
679
779
  ">": "&gt;"
680
780
  };
681
- function Y(l) {
682
- return l.replace(/[&<>]/g, (s) => Ft[s] ?? s);
781
+ function G(n) {
782
+ return n.replace(/[&<>]/g, (s) => Qt[s] ?? s);
683
783
  }
684
- function re(l, s, a = 0) {
685
- let t = "", o = 0;
686
- for (const c of s) {
687
- c.start > o && (t += Y(l.slice(o, c.start)));
688
- const u = Y(l.slice(c.start, c.end));
689
- t += `<span class="tok-${c.type}" data-start="${c.start + a}" data-end="${c.end + a}">${u}</span>`, o = c.end;
784
+ function de(n, s, o = 0) {
785
+ let e = "", i = 0;
786
+ for (const r of s) {
787
+ r.start > i && (e += G(n.slice(i, r.start)));
788
+ const f = G(n.slice(r.start, r.end));
789
+ e += `<span class="tok-${r.type}" data-start="${r.start + o}" data-end="${r.end + o}">${f}</span>`, i = r.end;
690
790
  }
691
- return o < l.length && (t += Y(l.slice(o))), t;
791
+ return i < n.length && (e += G(n.slice(i))), e;
692
792
  }
693
- function Pt(l, s, a, t) {
694
- if (!a || !t) return re(l, se(l, s));
695
- let o = "", c = 0;
696
- for (; c < l.length; ) {
697
- const u = l.indexOf(a, c);
698
- if (u === -1) {
699
- o += Y(l.slice(c));
793
+ function en(n, s, o, e) {
794
+ if (!o || !e) return de(n, ue(n, s));
795
+ let i = "", r = 0;
796
+ for (; r < n.length; ) {
797
+ const f = n.indexOf(o, r);
798
+ if (f === -1) {
799
+ i += G(n.slice(r));
700
800
  break;
701
801
  }
702
- o += Y(l.slice(c, u));
703
- const d = l.indexOf(t, u + a.length), i = d === -1 ? l.length : d, p = l.slice(u + a.length, i);
704
- o += `<span class="tok-brace">${Y(a)}</span>`, o += re(p, se(p, s), u + a.length), d === -1 ? c = i : (o += `<span class="tok-brace">${Y(t)}</span>`, c = d + t.length);
802
+ i += G(n.slice(r, f));
803
+ const u = n.indexOf(e, f + o.length), a = u === -1 ? n.length : u, d = n.slice(f + o.length, a);
804
+ i += `<span class="tok-brace">${G(o)}</span>`, i += de(d, ue(d, s), f + o.length), u === -1 ? r = a : (i += `<span class="tok-brace">${G(e)}</span>`, r = u + e.length);
705
805
  }
706
- return o;
806
+ return i;
707
807
  }
708
- const Vt = {
808
+ const tn = {
709
809
  key: 0,
710
810
  class: "gutter",
711
811
  "aria-hidden": "true"
712
- }, Kt = ["innerHTML"], Zt = ["value", "readonly", "placeholder"], qt = ["onMouseenter", "onClick"], Ut = { class: "popup-label" }, Yt = {
812
+ }, nn = ["innerHTML"], ln = ["value", "readonly", "placeholder"], on = ["onMouseenter", "onClick"], an = { class: "popup-label" }, sn = {
713
813
  key: 0,
714
814
  class: "popup-detail"
715
- }, Jt = { class: "hover-head" }, Gt = { class: "hover-name" }, Xt = {
815
+ }, rn = { class: "hover-head" }, cn = { class: "hover-name" }, un = {
716
816
  key: 0,
717
817
  class: "hover-colon"
718
- }, Qt = {
818
+ }, dn = {
719
819
  key: 0,
720
820
  class: "hover-type"
721
- }, en = {
821
+ }, fn = {
722
822
  key: 0,
723
823
  class: "hover-doc"
724
- }, tn = {
824
+ }, pn = {
725
825
  key: 1,
726
826
  class: "hover-def"
727
- }, nn = ["innerHTML"], ln = ["title", "aria-label"], on = {
827
+ }, mn = ["innerHTML"], hn = ["title", "aria-label"], gn = {
728
828
  key: 0,
729
829
  viewBox: "0 0 16 16",
730
830
  width: "14",
731
831
  height: "14",
732
832
  "aria-hidden": "true"
733
- }, an = {
833
+ }, bn = {
734
834
  key: 1,
735
835
  viewBox: "0 0 16 16",
736
836
  width: "14",
737
837
  height: "14",
738
838
  "aria-hidden": "true"
739
- }, sn = /* @__PURE__ */ wt({
839
+ }, vn = /* @__PURE__ */ Et({
740
840
  __name: "CodeEditor",
741
841
  props: {
742
842
  modelValue: {},
@@ -758,23 +858,26 @@ const Vt = {
758
858
  collapsedHeight: { default: "34px" },
759
859
  collapseOnBlur: { type: Boolean, default: !1 },
760
860
  borderRadius: { default: "4px" },
861
+ background: { default: "" },
862
+ borderColor: { default: "" },
761
863
  minHeight: { default: "260px" }
762
864
  },
763
865
  emits: ["update:modelValue", "change", "expand", "collapse"],
764
- setup(l, { expose: s, emit: a }) {
765
- const t = l, o = a, c = {
866
+ setup(n, { expose: s, emit: o }) {
867
+ const e = n, i = o, r = {
766
868
  variable: "变量",
767
869
  function: "函数",
768
870
  property: "属性",
769
871
  class: "对象",
770
- keyword: "关键字"
771
- }, u = {
872
+ keyword: "关键字",
873
+ value: "值"
874
+ }, f = {
772
875
  "(": ")",
773
876
  "[": "]",
774
877
  "{": "}",
775
878
  '"': '"',
776
879
  "'": "'"
777
- }, d = /* @__PURE__ */ new Set([
880
+ }, u = /* @__PURE__ */ new Set([
778
881
  "ArrowLeft",
779
882
  "ArrowRight",
780
883
  "ArrowUp",
@@ -783,549 +886,581 @@ const Vt = {
783
886
  "End",
784
887
  "PageUp",
785
888
  "PageDown"
786
- ]), i = C(t.modelValue), p = C(), M = C(), W = C(), g = C(), b = C(), H = C(), O = C(), A = C([]), w = C(0), y = C(!1), T = C({ start: 0, end: 0 }), k = C({}), $ = C(null), ye = C({}), et = V(
787
- () => t.tsTypes ? jt(t.tsTypes) : []
788
- ), ke = V(() => [
789
- ...St,
790
- ...et.value,
791
- ...t.completions
792
- ]), ce = V(
793
- () => t.mode === "template" ? [...t.templateCompletions, ...ke.value] : ke.value
794
- ), tt = V(() => {
795
- const e = {
796
- keywords: je(t.language),
797
- builtins: new Set(ce.value.map((n) => n.label))
889
+ ]), a = E(e.modelValue), d = E(), $ = E(), z = E(), C = E(), b = E(), y = E(), O = E(), B = E([]), R = E(0), w = E(!1), T = E({ start: 0, end: 0 }), _ = E({}), g = E(null), oe = E({}), ot = K(
890
+ () => e.tsTypes ? Yt(e.tsTypes) : []
891
+ ), at = K(
892
+ () => e.tsTypes ? Jt(e.tsTypes) : /* @__PURE__ */ new Map()
893
+ ), xe = K(() => [
894
+ ...Lt,
895
+ ...ot.value,
896
+ ...e.completions
897
+ ]), fe = K(
898
+ () => e.mode === "template" ? [...e.templateCompletions, ...xe.value] : xe.value
899
+ ), st = K(() => {
900
+ const t = {
901
+ keywords: je(e.language),
902
+ builtins: new Set(fe.value.map((l) => l.label))
798
903
  };
799
- return t.mode === "template" ? `${Pt(i.value, e, t.templateOpen, t.templateClose)}
800
- ` : `${re(i.value, se(i.value, e))}
904
+ return e.mode === "template" ? `${en(a.value, t, e.templateOpen, e.templateClose)}
905
+ ` : `${de(a.value, ue(a.value, t))}
801
906
  `;
802
- }), nt = V(() => i.value.split(`
803
- `).length), N = C(t.defaultExpanded), ue = C(!1), de = V(() => t.collapsible && !N.value), lt = V(() => {
804
- const e = {};
805
- return t.collapsible && (e.height = t.collapsedHeight), e;
806
- }), ot = V(() => {
807
- const e = {
808
- "--ce-radius": t.borderRadius,
809
- "--ce-collapsed-height": t.collapsedHeight
907
+ }), rt = K(() => a.value.split(`
908
+ `).length), P = E(e.defaultExpanded), pe = E(!1), me = K(() => e.collapsible && !P.value), ct = K(() => {
909
+ const t = {};
910
+ return e.collapsible && (t.height = e.collapsedHeight), t;
911
+ }), ut = K(() => {
912
+ const t = {
913
+ "--ce-radius": e.borderRadius,
914
+ "--ce-collapsed-height": e.collapsedHeight
810
915
  };
811
- return t.collapsible ? { ...e, height: N.value ? t.minHeight : t.collapsedHeight } : { ...e, height: t.minHeight };
916
+ return e.background && (t["--ce-bg"] = e.background), e.borderColor && (t["--ce-border"] = e.borderColor), e.collapsible ? { ...t, height: P.value ? e.minHeight : e.collapsedHeight } : { ...t, height: e.minHeight };
812
917
  });
813
- let xe = 0;
814
- function we(e) {
815
- if (N.value === e) return;
816
- const n = p.value;
817
- e && n && (xe = n.scrollTop), N.value = e, t.collapsible && (ue.value = !0), o(e ? "expand" : "collapse"), I(), L(), j(() => {
818
- if (fe(), !N.value && n) {
819
- const r = Math.max(0, n.scrollHeight - n.clientHeight);
820
- n.scrollTop = Math.max(0, Math.min(xe, r)), z(!0), document.activeElement === n && G();
918
+ let $e = 0;
919
+ function Te(t) {
920
+ if (P.value === t) return;
921
+ const l = d.value;
922
+ t && l && ($e = l.scrollTop), P.value = t, e.collapsible && (pe.value = !0), i(t ? "expand" : "collapse"), H(), F(), V(() => {
923
+ if (he(), !P.value && l) {
924
+ const c = Math.max(0, l.scrollHeight - l.clientHeight);
925
+ l.scrollTop = Math.max(0, Math.min($e, c)), j(!0), document.activeElement === l && J();
821
926
  return;
822
927
  }
823
- z(!0), e && t.collapseOnBlur && n && document.activeElement !== n && n.focus();
928
+ j(!0), t && e.collapseOnBlur && l && document.activeElement !== l && l.focus();
824
929
  });
825
930
  }
826
- function it() {
827
- ue.value = !1;
931
+ function dt() {
932
+ pe.value = !1;
828
933
  }
829
- function at() {
830
- we(!N.value);
934
+ function ft() {
935
+ Te(!P.value);
831
936
  }
832
- Be(
833
- () => t.modelValue,
834
- (e) => {
835
- e !== i.value && (i.value = e, I());
937
+ Oe(
938
+ () => e.modelValue,
939
+ (t) => {
940
+ t !== a.value && (a.value = t, H());
836
941
  }
837
- ), Be(i, () => {
838
- j(() => z(!0));
942
+ ), Oe(a, () => {
943
+ V(() => j(!0));
839
944
  });
840
- function $e(e) {
841
- return c[e];
945
+ function Ce(t) {
946
+ return r[t];
842
947
  }
843
- function st(e) {
844
- return e ? re(
845
- e,
846
- se(e, { keywords: je("typescript"), builtins: /* @__PURE__ */ new Set() })
948
+ function pt(t) {
949
+ return t ? de(
950
+ t,
951
+ ue(t, { keywords: je("typescript"), builtins: /* @__PURE__ */ new Set() })
847
952
  ) : "";
848
953
  }
849
- let J = { top: 14, bottom: 14, lineHeight: 22 };
850
- function fe() {
851
- const e = p.value;
852
- if (!e) return;
853
- const n = window.getComputedStyle(e);
854
- J = {
855
- top: parseFloat(n.paddingTop) || 0,
856
- bottom: parseFloat(n.paddingBottom) || 0,
857
- lineHeight: parseFloat(n.lineHeight) || 22
954
+ let D = { top: 14, bottom: 14, left: 16, right: 16, lineHeight: 22 };
955
+ function he() {
956
+ const t = d.value;
957
+ if (!t) return;
958
+ const l = window.getComputedStyle(t);
959
+ D = {
960
+ top: parseFloat(l.paddingTop) || 0,
961
+ bottom: parseFloat(l.paddingBottom) || 0,
962
+ left: parseFloat(l.paddingLeft) || 0,
963
+ right: parseFloat(l.paddingRight) || 0,
964
+ lineHeight: parseFloat(l.lineHeight) || 22
858
965
  };
859
966
  }
860
- function z(e = !1) {
861
- const n = p.value;
862
- if (!n) return;
863
- const r = g.value;
864
- if (r && (r.style.transform = `translate(${-n.scrollLeft}px, ${-n.scrollTop}px)`), b.value && (b.value.style.transform = `translateY(${-n.scrollTop}px)`), e) {
865
- const m = `${i.value}|${t.mode}|${n.clientWidth}|${n.clientHeight}`;
866
- m !== Te && (Te = m, rt());
967
+ function j(t = !1) {
968
+ const l = d.value;
969
+ if (!l) return;
970
+ const c = C.value;
971
+ if (c && (c.style.transform = `translate(${-l.scrollLeft}px, ${-l.scrollTop}px)`), b.value && (b.value.style.transform = `translateY(${-l.scrollTop}px)`), t) {
972
+ const m = `${a.value}|${e.mode}|${l.clientWidth}|${l.clientHeight}`;
973
+ m !== Ee && (Ee = m, mt());
867
974
  }
868
975
  }
869
- function G() {
870
- const e = p.value;
871
- if (!e || !de.value) return;
872
- const n = Se();
873
- if (!n) return;
874
- const r = e.clientHeight - J.top - J.bottom, h = n.top + e.scrollTop - J.top - Math.max(0, (r - n.lineHeight) / 2), f = Math.max(0, e.scrollHeight - e.clientHeight), v = Math.max(0, Math.min(h, f));
875
- Math.abs(v - e.scrollTop) > 0.5 && (e.scrollTop = v, z());
876
- }
877
- let Ce = [], Te = "", oe = 0, pe = -1, me = -1, he = { x: 0, y: 0 };
878
- function rt() {
879
- const e = p.value, n = W.value;
880
- if (!e || !n) return;
881
- const r = e.getBoundingClientRect(), m = [];
882
- n.querySelectorAll("[data-start]").forEach((h) => {
883
- const f = h.getBoundingClientRect();
976
+ function J() {
977
+ const t = d.value;
978
+ if (!t) return;
979
+ const l = Re();
980
+ if (!l) return;
981
+ let c = t.scrollTop;
982
+ if (me.value) {
983
+ const q = t.clientHeight - D.top - D.bottom, W = l.top + t.scrollTop - D.top - Math.max(0, (q - l.lineHeight) / 2), re = Math.max(0, t.scrollHeight - t.clientHeight);
984
+ c = Math.max(0, Math.min(W, re));
985
+ }
986
+ const m = t.clientWidth - D.left - D.right, h = l.left + t.scrollLeft, p = t.scrollLeft + D.left, x = t.scrollLeft + D.left + m, k = 8;
987
+ let v = t.scrollLeft;
988
+ h < p + k ? v = Math.max(0, h - D.left - k) : h > x - k && (v = Math.max(0, h - D.left - m + k));
989
+ const S = Math.abs(c - t.scrollTop) > 0.5, M = Math.abs(v - t.scrollLeft) > 0.5;
990
+ !S && !M || (S && (t.scrollTop = c), M && (t.scrollLeft = v), j());
991
+ }
992
+ let Se = [], Ee = "", ae = 0, ge = -1, be = -1, ve = { x: 0, y: 0 };
993
+ function mt() {
994
+ const t = d.value, l = z.value;
995
+ if (!t || !l) return;
996
+ const c = t.getBoundingClientRect(), m = [];
997
+ l.querySelectorAll("[data-start]").forEach((h) => {
998
+ const p = h.getBoundingClientRect();
884
999
  m.push({
885
1000
  start: Number(h.dataset.start),
886
1001
  end: Number(h.dataset.end),
887
- left: f.left - r.left + e.scrollLeft,
888
- right: f.right - r.left + e.scrollLeft,
889
- top: f.top - r.top + e.scrollTop,
890
- bottom: f.bottom - r.top + e.scrollTop
1002
+ left: p.left - c.left + t.scrollLeft,
1003
+ right: p.right - c.left + t.scrollLeft,
1004
+ top: p.top - c.top + t.scrollTop,
1005
+ bottom: p.bottom - c.top + t.scrollTop
891
1006
  });
892
- }), Ce = m;
1007
+ }), Se = m;
893
1008
  }
894
- function ct(e, n) {
895
- for (const r of Ce)
896
- if (e >= r.left - 1 && e <= r.right + 1 && n >= r.top && n <= r.bottom)
897
- return r;
1009
+ function ht(t, l) {
1010
+ for (const c of Se)
1011
+ if (t >= c.left - 1 && t <= c.right + 1 && l >= c.top && l <= c.bottom)
1012
+ return c;
898
1013
  return null;
899
1014
  }
900
- function L() {
901
- $.value = null, oe = 0, pe = -1, me = -1;
1015
+ function F() {
1016
+ g.value = null, ae = 0, ge = -1, be = -1;
902
1017
  }
903
- function ut(e) {
904
- const n = O.value, r = p.value;
905
- if (!n || !r) return;
906
- const m = r.getBoundingClientRect(), h = m.left + e.left - r.scrollLeft, f = m.left + e.right - r.scrollLeft, v = m.top + e.top - r.scrollTop, x = m.top + e.bottom - r.scrollTop, _ = 12, B = 8, F = n.offsetWidth, Q = n.offsetHeight;
907
- let P = h, q = x + B;
908
- P + F > window.innerWidth - _ && (P = f - F), q + Q > window.innerHeight - _ && (q = v - Q - B), P = Math.max(_, Math.min(P, window.innerWidth - _ - F)), q = Math.max(_, q), ye.value = { left: `${P}px`, top: `${q}px` };
1018
+ function gt(t) {
1019
+ const l = O.value, c = d.value;
1020
+ if (!l || !c) return;
1021
+ const m = c.getBoundingClientRect(), h = m.left + t.left - c.scrollLeft, p = m.left + t.right - c.scrollLeft, x = m.top + t.top - c.scrollTop, k = m.top + t.bottom - c.scrollTop, v = 12, S = 8, M = l.offsetWidth, q = l.offsetHeight;
1022
+ let N = h, W = k + S;
1023
+ N + M > window.innerWidth - v && (N = p - M), W + q > window.innerHeight - v && (W = x - q - S), N = Math.max(v, Math.min(N, window.innerWidth - v - M)), W = Math.max(v, W), oe.value = { left: `${N}px`, top: `${W}px` };
909
1024
  }
910
- function dt(e, n) {
911
- const r = p.value;
912
- if (!r || t.readonly || !t.hover || y.value) {
913
- L();
1025
+ function bt(t, l) {
1026
+ const c = d.value;
1027
+ if (!c || e.readonly || !e.hover || w.value) {
1028
+ F();
914
1029
  return;
915
1030
  }
916
- if (r.selectionStart !== r.selectionEnd) {
917
- L();
1031
+ if (c.selectionStart !== c.selectionEnd) {
1032
+ F();
918
1033
  return;
919
1034
  }
920
1035
  const m = O.value;
921
- if ($.value && m) {
922
- const x = m.getBoundingClientRect();
923
- if (e >= x.left && e <= x.right && n >= x.top && n <= x.bottom)
1036
+ if (g.value && m) {
1037
+ const k = m.getBoundingClientRect();
1038
+ if (t >= k.left && t <= k.right && l >= k.top && l <= k.bottom)
924
1039
  return;
925
1040
  }
926
- const h = r.getBoundingClientRect(), f = ct(e - h.left + r.scrollLeft, n - h.top + r.scrollTop);
927
- if (!f) {
928
- L();
1041
+ const h = c.getBoundingClientRect(), p = ht(t - h.left + c.scrollLeft, l - h.top + c.scrollTop);
1042
+ if (!p) {
1043
+ F();
929
1044
  return;
930
1045
  }
931
- if ($.value && pe === f.start && me === f.end)
1046
+ if (g.value && ge === p.start && be === p.end)
932
1047
  return;
933
- const v = Lt(r.value, f.start, f.end, {
934
- completions: ce.value,
935
- declared: We(r.value, f.start)
1048
+ const x = jt(c.value, p.start, p.end, {
1049
+ completions: fe.value,
1050
+ declared: Pe(c.value, p.start)
936
1051
  });
937
- if (!v) {
938
- L();
1052
+ if (!x) {
1053
+ F();
939
1054
  return;
940
1055
  }
941
- $.value = v, pe = f.start, me = f.end, j(() => ut(f));
1056
+ g.value = x, ge = p.start, be = p.end, V(() => gt(p));
942
1057
  }
943
- function ft(e) {
944
- he = { x: e.clientX, y: e.clientY }, !oe && (oe = requestAnimationFrame(() => {
945
- oe = 0, dt(he.x, he.y);
1058
+ function vt(t) {
1059
+ ve = { x: t.clientX, y: t.clientY }, !ae && (ae = requestAnimationFrame(() => {
1060
+ ae = 0, bt(ve.x, ve.y);
946
1061
  }));
947
1062
  }
948
- function Se() {
949
- const e = p.value;
950
- if (!e) return null;
951
- const n = window.getComputedStyle(e), r = document.createElement("div"), m = parseFloat(n.paddingLeft) || 0, h = parseFloat(n.paddingRight) || 0, f = e.getBoundingClientRect();
952
- Object.assign(r.style, {
1063
+ function Re() {
1064
+ const t = d.value;
1065
+ if (!t) return null;
1066
+ const l = window.getComputedStyle(t), c = document.createElement("div"), m = parseFloat(l.paddingLeft) || 0, h = parseFloat(l.paddingRight) || 0, p = t.getBoundingClientRect();
1067
+ Object.assign(c.style, {
953
1068
  position: "fixed",
954
- left: `${f.left}px`,
955
- top: `${f.top}px`,
1069
+ left: `${p.left}px`,
1070
+ top: `${p.top}px`,
956
1071
  visibility: "hidden",
957
1072
  pointerEvents: "none",
958
1073
  zIndex: "-1",
959
- whiteSpace: "pre-wrap",
960
- overflowWrap: "break-word",
961
- wordBreak: "normal",
1074
+ whiteSpace: l.whiteSpace,
1075
+ overflowWrap: l.overflowWrap,
1076
+ wordBreak: l.wordBreak,
962
1077
  boxSizing: "content-box",
963
- width: `${e.clientWidth - m - h}px`,
964
- paddingTop: n.paddingTop,
965
- paddingRight: n.paddingRight,
966
- paddingBottom: n.paddingBottom,
967
- paddingLeft: n.paddingLeft,
1078
+ width: `${t.clientWidth - m - h}px`,
1079
+ paddingTop: l.paddingTop,
1080
+ paddingRight: l.paddingRight,
1081
+ paddingBottom: l.paddingBottom,
1082
+ paddingLeft: l.paddingLeft,
968
1083
  border: "0",
969
- fontFamily: n.fontFamily,
970
- fontSize: n.fontSize,
971
- fontWeight: n.fontWeight,
972
- fontStyle: n.fontStyle,
973
- fontVariant: n.fontVariant,
974
- letterSpacing: n.letterSpacing,
975
- lineHeight: n.lineHeight,
976
- textTransform: n.textTransform,
977
- tabSize: n.tabSize
978
- }), r.textContent = e.value.slice(0, e.selectionStart);
979
- const v = document.createElement("span");
980
- v.textContent = "​", r.appendChild(v), document.body.appendChild(r);
981
- const x = v.getBoundingClientRect();
982
- document.body.removeChild(r);
983
- const _ = parseFloat(n.lineHeight) || 22, B = x.height, F = B > 0 && B < _ ? (_ - B) / 2 : 0;
1084
+ fontFamily: l.fontFamily,
1085
+ fontSize: l.fontSize,
1086
+ fontWeight: l.fontWeight,
1087
+ fontStyle: l.fontStyle,
1088
+ fontVariant: l.fontVariant,
1089
+ letterSpacing: l.letterSpacing,
1090
+ lineHeight: l.lineHeight,
1091
+ textTransform: l.textTransform,
1092
+ tabSize: l.tabSize
1093
+ }), c.textContent = t.value.slice(0, t.selectionStart);
1094
+ const x = document.createElement("span");
1095
+ x.textContent = "​", c.appendChild(x), document.body.appendChild(c);
1096
+ const k = x.getBoundingClientRect();
1097
+ document.body.removeChild(c);
1098
+ const v = parseFloat(l.lineHeight) || 22, S = k.height, M = S > 0 && S < v ? (v - S) / 2 : 0;
984
1099
  return {
985
- left: x.left - f.left - e.scrollLeft,
986
- top: x.top - f.top - e.scrollTop - F,
987
- lineHeight: _
1100
+ left: k.left - p.left - t.scrollLeft,
1101
+ top: k.top - p.top - t.scrollTop - M,
1102
+ lineHeight: v
988
1103
  };
989
1104
  }
990
- async function pt() {
991
- await j();
992
- const e = M.value, n = H.value, r = Se();
993
- if (!e || !n || !r) return;
994
- const m = 4, h = 8, f = window.innerWidth, v = window.innerHeight, x = e.getBoundingClientRect(), _ = n.scrollHeight, B = v - (x.top + r.top + r.lineHeight) - m - h, F = x.top + r.top - m - h, Q = B >= Math.min(_, 180) || B >= F, P = Math.min(248, Math.max(Q ? B : F, 96)), q = Math.min(_, P), Ae = n.offsetWidth || 280;
995
- let ee = r.left;
996
- x.left + ee + Ae > f - h && (ee = f - h - Ae - x.left), ee = Math.max(ee, h - x.left), k.value = {
997
- left: `${ee}px`,
998
- top: `${Q ? r.top + r.lineHeight + m : r.top - m - q}px`,
999
- maxHeight: `${P}px`
1105
+ async function Me() {
1106
+ await V();
1107
+ const t = $.value, l = y.value, c = Re();
1108
+ if (!t || !l || !c) return;
1109
+ const m = 4, h = 8, p = window.innerWidth, x = window.innerHeight, k = t.getBoundingClientRect(), v = l.scrollHeight, S = x - (k.top + c.top + c.lineHeight) - m - h, M = k.top + c.top - m - h, q = S >= Math.min(v, 180) || S >= M, N = Math.min(248, Math.max(q ? S : M, 96)), W = Math.min(v, N), re = l.offsetWidth || 280;
1110
+ let te = c.left;
1111
+ k.left + te + re > p - h && (te = p - h - re - k.left), te = Math.max(te, h - k.left), _.value = {
1112
+ left: `${te}px`,
1113
+ top: `${q ? c.top + c.lineHeight + m : c.top - m - W}px`,
1114
+ maxHeight: `${N}px`
1000
1115
  };
1001
1116
  }
1002
- function I() {
1003
- y.value = !1, A.value = [], w.value = 0, L();
1117
+ function H() {
1118
+ w.value = !1, B.value = [], R.value = 0, F();
1004
1119
  }
1005
- function X(e = !1) {
1006
- const n = p.value;
1007
- if (!n || t.readonly) return;
1008
- if (n.selectionStart !== n.selectionEnd) {
1009
- I();
1120
+ function ee(t = !1) {
1121
+ var k;
1122
+ const l = d.value;
1123
+ if (!l || e.readonly) return;
1124
+ if (l.selectionStart !== l.selectionEnd) {
1125
+ H();
1010
1126
  return;
1011
1127
  }
1012
- const r = n.selectionStart;
1013
- let m = !e;
1014
- if (t.mode === "template") {
1015
- const v = ve(
1016
- n.value,
1017
- r,
1018
- t.templateOpen,
1019
- t.templateClose
1128
+ const c = l.selectionStart;
1129
+ let m = !t;
1130
+ const h = Ht(l.value, c);
1131
+ if (h) {
1132
+ const v = (k = at.value.get(h.functionName)) == null ? void 0 : k.params[h.paramIndex], S = (v == null ? void 0 : v.literals) ?? [];
1133
+ if (S.length) {
1134
+ const M = h.quote ?? "'", q = S.map((W) => ({
1135
+ label: `${M}${W}${M}`,
1136
+ kind: "value",
1137
+ detail: v == null ? void 0 : v.type,
1138
+ insertText: `${M}${W}${M}`
1139
+ })), N = et(q, h.prefix);
1140
+ if (N.length) {
1141
+ B.value = N, T.value = { start: h.replaceStart, end: c }, R.value = 0, w.value = !0, Me();
1142
+ return;
1143
+ }
1144
+ }
1145
+ }
1146
+ if (e.mode === "template") {
1147
+ const v = we(
1148
+ l.value,
1149
+ c,
1150
+ e.templateOpen,
1151
+ e.templateClose
1020
1152
  );
1021
1153
  if (!v) {
1022
- I();
1154
+ H();
1023
1155
  return;
1024
1156
  }
1025
- e && n.value.slice(v.start, r).trim() === "" && (m = !0);
1157
+ t && l.value.slice(v.start, c).trim() === "" && (m = !0);
1026
1158
  }
1027
- const h = At(n.value, r, {
1028
- language: t.language,
1029
- completions: ce.value,
1030
- declared: We(n.value, r),
1159
+ const p = zt(l.value, c, {
1160
+ language: e.language,
1161
+ completions: fe.value,
1162
+ declared: Pe(l.value, c),
1031
1163
  auto: !m
1032
1164
  });
1033
- if (!h) {
1034
- I();
1165
+ if (!p) {
1166
+ H();
1035
1167
  return;
1036
1168
  }
1037
- let f = h.items;
1038
- if (t.completionFilter) {
1039
- const v = Je(n.value, r);
1040
- if (f = t.completionFilter(f, {
1169
+ let x = p.items;
1170
+ if (e.completionFilter) {
1171
+ const v = Ge(l.value, c);
1172
+ if (x = e.completionFilter(x, {
1041
1173
  prefix: v.prefix,
1042
1174
  chain: v.chain,
1043
- text: n.value,
1044
- position: r,
1045
- mode: t.mode,
1046
- language: t.language
1047
- }), f.length === 0) {
1048
- I();
1175
+ text: l.value,
1176
+ position: c,
1177
+ mode: e.mode,
1178
+ language: e.language
1179
+ }), x.length === 0) {
1180
+ H();
1049
1181
  return;
1050
1182
  }
1051
1183
  }
1052
- A.value = f, T.value = { start: h.start, end: h.end }, w.value = 0, y.value = !0, pt();
1184
+ B.value = x, T.value = { start: p.start, end: p.end }, R.value = 0, w.value = !0, Me();
1053
1185
  }
1054
- function mt(e) {
1055
- i.value = e, o("update:modelValue", e), o("change", e);
1186
+ function yt(t) {
1187
+ a.value = t, i("update:modelValue", t), i("change", t);
1056
1188
  }
1057
- function ie(e, n, r, m = e + r.length) {
1058
- const h = p.value;
1189
+ function se(t, l, c, m = t + c.length) {
1190
+ const h = d.value;
1059
1191
  if (!h) return;
1060
- const f = h.value.slice(0, e) + r + h.value.slice(n);
1061
- mt(f), I(), j(() => {
1062
- h.value = f, h.setSelectionRange(m, m), h.focus(), z(!0), G();
1192
+ const p = h.value.slice(0, t) + c + h.value.slice(l);
1193
+ yt(p), H(), V(() => {
1194
+ h.value = p, h.setSelectionRange(m, m), h.focus(), j(!0), J();
1063
1195
  });
1064
1196
  }
1065
- function Ee(e = A.value[w.value]) {
1066
- if (!e) return;
1067
- const n = e.insertText ?? e.label;
1068
- ie(T.value.start, T.value.end, n), I();
1197
+ function Ie(t = B.value[R.value]) {
1198
+ if (!t) return;
1199
+ const l = t.insertText ?? t.label;
1200
+ se(T.value.start, T.value.end, l), H();
1069
1201
  }
1070
- function Ie(e) {
1071
- const n = A.value.length;
1072
- n && (w.value = (w.value + e + n) % n, j(() => {
1073
- var r, m;
1074
- (m = (r = H.value) == null ? void 0 : r.querySelector(".is-active")) == null || m.scrollIntoView({ block: "nearest" });
1202
+ function Le(t) {
1203
+ const l = B.value.length;
1204
+ l && (R.value = (R.value + t + l) % l, V(() => {
1205
+ var c, m;
1206
+ (m = (c = y.value) == null ? void 0 : c.querySelector(".is-active")) == null || m.scrollIntoView({ block: "nearest" });
1075
1207
  }));
1076
1208
  }
1077
- function ht(e) {
1078
- const n = e.target;
1079
- i.value = n.value, o("update:modelValue", n.value), o("change", n.value), L(), z(), j(G), X(!0);
1209
+ function kt(t) {
1210
+ const l = t.target;
1211
+ a.value = l.value, i("update:modelValue", l.value), i("change", l.value), F(), j(), J(), V(J), ee(!0);
1080
1212
  }
1081
- function bt(e) {
1082
- if (I(), L(), !t.collapsible || !t.collapseOnBlur || !N.value) return;
1083
- const n = e.relatedTarget;
1084
- n && n.closest(".expand-toggle") || we(!1);
1213
+ function wt(t) {
1214
+ if (H(), F(), !e.collapsible || !e.collapseOnBlur || !P.value) return;
1215
+ const l = t.relatedTarget;
1216
+ l && l.closest(".expand-toggle") || Te(!1);
1085
1217
  }
1086
- function gt() {
1087
- Re(), G();
1218
+ function xt() {
1219
+ _e(), J();
1088
1220
  }
1089
- function Re() {
1090
- const e = p.value;
1091
- if (!e || t.readonly) return;
1092
- if (e.selectionStart !== e.selectionEnd) {
1093
- I();
1221
+ function _e() {
1222
+ const t = d.value;
1223
+ if (!t || e.readonly) return;
1224
+ if (t.selectionStart !== t.selectionEnd) {
1225
+ H();
1094
1226
  return;
1095
1227
  }
1096
- const n = e.selectionStart;
1097
- if (n > 0 && e.value[n - 1] === ".") {
1098
- X(!0);
1228
+ const l = t.selectionStart;
1229
+ if (l > 0 && t.value[l - 1] === ".") {
1230
+ ee(!0);
1099
1231
  return;
1100
1232
  }
1101
- if (t.mode === "template") {
1102
- const r = ve(
1103
- e.value,
1104
- n,
1105
- t.templateOpen,
1106
- t.templateClose
1233
+ if (e.mode === "template") {
1234
+ const c = we(
1235
+ t.value,
1236
+ l,
1237
+ e.templateOpen,
1238
+ e.templateClose
1107
1239
  );
1108
- if (r && e.value.slice(r.start, n).trim() === "") {
1109
- X(!0);
1240
+ if (c && t.value.slice(c.start, l).trim() === "") {
1241
+ ee(!0);
1110
1242
  return;
1111
1243
  }
1112
1244
  }
1113
- I();
1245
+ H();
1114
1246
  }
1115
- let be = 0;
1116
- function Me() {
1117
- window.clearTimeout(be), be = window.setTimeout(() => {
1118
- be = 0, Re(), G();
1247
+ let ye = 0;
1248
+ function He() {
1249
+ window.clearTimeout(ye), ye = window.setTimeout(() => {
1250
+ ye = 0, _e(), J();
1119
1251
  }, 0);
1120
1252
  }
1121
- function _e(e) {
1122
- e.target !== p.value && y.value && I();
1253
+ function Ae(t) {
1254
+ t.target !== d.value && w.value && H();
1123
1255
  }
1124
- function vt() {
1125
- L(), z(), de.value && yt();
1256
+ function $t() {
1257
+ F(), j(), me.value && Tt();
1126
1258
  }
1127
- let ge = 0;
1128
- function yt() {
1129
- window.clearTimeout(ge), ge = window.setTimeout(() => {
1130
- ge = 0, kt();
1259
+ let ke = 0;
1260
+ function Tt() {
1261
+ window.clearTimeout(ke), ke = window.setTimeout(() => {
1262
+ ke = 0, Ct();
1131
1263
  }, 120);
1132
1264
  }
1133
- function kt() {
1134
- const e = p.value;
1135
- if (!e) return;
1136
- const n = J.lineHeight, r = e.scrollTop, m = Math.round(r / n) * n;
1137
- Math.abs(m - r) < 0.5 || (e.scrollTop = m, z());
1265
+ function Ct() {
1266
+ const t = d.value;
1267
+ if (!t) return;
1268
+ const l = D.lineHeight, c = t.scrollTop, m = Math.round(c / l) * l;
1269
+ Math.abs(m - c) < 0.5 || (t.scrollTop = m, j());
1138
1270
  }
1139
- function xt(e) {
1271
+ function St(t) {
1140
1272
  var h;
1141
- const n = p.value;
1142
- if (!n) return;
1143
- const r = e.metaKey || e.ctrlKey, m = d.has(e.key);
1144
- if (e.key === " " && r) {
1145
- e.preventDefault(), X(!1);
1273
+ const l = d.value;
1274
+ if (!l) return;
1275
+ const c = t.metaKey || t.ctrlKey, m = u.has(t.key);
1276
+ if (t.key === " " && c) {
1277
+ t.preventDefault(), ee(!1);
1146
1278
  return;
1147
1279
  }
1148
- if (y.value) {
1149
- if (e.key === "ArrowDown") {
1150
- e.preventDefault(), Ie(1);
1280
+ if (w.value) {
1281
+ if (t.key === "ArrowDown") {
1282
+ t.preventDefault(), Le(1);
1151
1283
  return;
1152
1284
  }
1153
- if (e.key === "ArrowUp") {
1154
- e.preventDefault(), Ie(-1);
1285
+ if (t.key === "ArrowUp") {
1286
+ t.preventDefault(), Le(-1);
1155
1287
  return;
1156
1288
  }
1157
- if (e.key === "Enter" || e.key === "Tab") {
1158
- e.preventDefault(), Ee();
1289
+ if (t.key === "Enter" || t.key === "Tab") {
1290
+ t.preventDefault(), Ie();
1159
1291
  return;
1160
1292
  }
1161
- if (e.key === "Escape") {
1162
- e.preventDefault(), I();
1293
+ if (t.key === "Escape") {
1294
+ t.preventDefault(), H();
1163
1295
  return;
1164
1296
  }
1165
- if (m || r) {
1166
- I(), m && !r && Me();
1297
+ if (m || c) {
1298
+ H(), m && !c && He();
1167
1299
  return;
1168
1300
  }
1169
1301
  }
1170
- if (m && !r) {
1171
- Me();
1302
+ if (m && !c) {
1303
+ He();
1172
1304
  return;
1173
1305
  }
1174
- if (e.key === "Enter" && !r && !e.shiftKey) {
1175
- const f = n.selectionStart;
1176
- if (f !== n.selectionEnd) return;
1177
- const v = n.value.lastIndexOf(`
1178
- `, f - 1) + 1, x = n.value.slice(v, f), _ = ((h = x.match(/^[ \t]*/)) == null ? void 0 : h[0]) ?? "", B = /[{[(]$/.test(x.trimEnd()) ? " " : "";
1179
- e.preventDefault(), ie(f, f, `
1180
- ${_}${B}`);
1306
+ if (t.key === "Enter" && !c && !t.shiftKey) {
1307
+ const p = l.selectionStart;
1308
+ if (p !== l.selectionEnd) return;
1309
+ const x = l.value.lastIndexOf(`
1310
+ `, p - 1) + 1, k = l.value.slice(x, p), v = ((h = k.match(/^[ \t]*/)) == null ? void 0 : h[0]) ?? "", S = /[{[(]$/.test(k.trimEnd()) ? " " : "";
1311
+ t.preventDefault(), se(p, p, `
1312
+ ${v}${S}`);
1181
1313
  return;
1182
1314
  }
1183
- if (e.key === "Tab") {
1184
- e.preventDefault(), ie(n.selectionStart, n.selectionEnd, " ");
1315
+ if (t.key === "Tab") {
1316
+ t.preventDefault(), se(l.selectionStart, l.selectionEnd, " ");
1185
1317
  return;
1186
1318
  }
1187
- if (e.key.length === 1 && !r && !e.altKey && u[e.key]) {
1188
- if (n.selectionStart !== n.selectionEnd) return;
1189
- const f = n.selectionStart, v = n.value[f - 1], x = n.value[f];
1190
- if ((e.key === '"' || e.key === "'") && v && /[\w$]/.test(v) || x !== void 0 && !/[\s)\]},;:]/.test(x)) return;
1191
- e.preventDefault(), ie(f, f, e.key + u[e.key], f + 1), t.mode === "template" && j(() => X(!0));
1319
+ if (t.key.length === 1 && !c && !t.altKey && f[t.key]) {
1320
+ if (l.selectionStart !== l.selectionEnd) return;
1321
+ const p = l.selectionStart, x = l.value[p - 1], k = l.value[p];
1322
+ if ((t.key === '"' || t.key === "'") && x && /[\w$]/.test(x) || k !== void 0 && !/[\s)\]},;:]/.test(k)) return;
1323
+ t.preventDefault(), se(p, p, t.key + f[t.key], p + 1), e.mode === "template" && V(() => ee(!0));
1192
1324
  }
1193
1325
  }
1194
- function He() {
1195
- y.value && I(), L(), j(() => {
1196
- fe(), z(!0);
1326
+ function Be() {
1327
+ w.value && H(), F(), V(() => {
1328
+ he(), j(!0);
1197
1329
  });
1198
1330
  }
1199
- return $t(() => {
1200
- window.addEventListener("resize", He), window.addEventListener("scroll", _e, !0), j(() => {
1201
- fe(), z(!0);
1202
- });
1203
- }), Ct(() => {
1204
- window.removeEventListener("resize", He), window.removeEventListener("scroll", _e, !0);
1331
+ let Q = null;
1332
+ return Rt(() => {
1333
+ window.addEventListener("resize", Be), window.addEventListener("scroll", Ae, !0), V(() => {
1334
+ he(), j(!0);
1335
+ }), typeof ResizeObserver < "u" && d.value && (Q = new ResizeObserver(() => {
1336
+ j(!0), J();
1337
+ }), Q.observe(d.value));
1338
+ }), Mt(() => {
1339
+ window.removeEventListener("resize", Be), window.removeEventListener("scroll", Ae, !0), Q == null || Q.disconnect(), Q = null;
1205
1340
  }), s({ focus: () => {
1206
- var e;
1207
- return (e = p.value) == null ? void 0 : e.focus();
1208
- } }), (e, n) => (S(), E("div", {
1209
- class: te(["code-input", { "is-collapsible": l.collapsible }]),
1210
- style: ae(lt.value)
1341
+ var t;
1342
+ return (t = d.value) == null ? void 0 : t.focus();
1343
+ } }), (t, l) => (I(), L("div", {
1344
+ class: ne(["code-input", { "is-collapsible": n.collapsible }]),
1345
+ style: ce(ct.value)
1211
1346
  }, [
1212
- R("div", {
1213
- class: te(["code-editor", {
1214
- "is-readonly": l.readonly,
1215
- "is-dark": l.theme === "dark",
1216
- "is-collapsed": de.value,
1217
- "is-expanding": ue.value
1347
+ A("div", {
1348
+ class: ne(["code-editor", {
1349
+ "is-readonly": n.readonly,
1350
+ "is-dark": n.theme === "dark",
1351
+ "is-collapsed": me.value,
1352
+ "is-expanding": pe.value
1218
1353
  }]),
1219
- style: ae(ot.value),
1220
- onAnimationend: Le(it, ["self"])
1354
+ style: ce(ut.value),
1355
+ onAnimationend: Ne(dt, ["self"])
1221
1356
  }, [
1222
- l.lineNumbers ? (S(), E("div", Vt, [
1223
- R("div", {
1357
+ n.lineNumbers ? (I(), L("div", tn, [
1358
+ A("div", {
1224
1359
  ref_key: "gutterInner",
1225
1360
  ref: b,
1226
1361
  class: "gutter-inner code-font"
1227
1362
  }, [
1228
- (S(!0), E(Oe, null, Ne(nt.value, (r) => (S(), E("div", {
1229
- key: r,
1363
+ (I(!0), L(We, null, ze(rt.value, (c) => (I(), L("div", {
1364
+ key: c,
1230
1365
  class: "gutter-line"
1231
- }, K(r), 1))), 128))
1366
+ }, Y(c), 1))), 128))
1232
1367
  ], 512)
1233
- ])) : D("", !0),
1234
- R("div", {
1368
+ ])) : Z("", !0),
1369
+ A("div", {
1235
1370
  ref_key: "stage",
1236
- ref: M,
1371
+ ref: $,
1237
1372
  class: "stage"
1238
1373
  }, [
1239
- R("div", {
1374
+ A("div", {
1240
1375
  ref_key: "highlightLayer",
1241
- ref: W,
1376
+ ref: z,
1242
1377
  class: "highlight code-font"
1243
1378
  }, [
1244
- R("pre", {
1379
+ A("pre", {
1245
1380
  ref_key: "highlightInner",
1246
- ref: g,
1381
+ ref: C,
1247
1382
  class: "code-font"
1248
1383
  }, [
1249
- R("code", { innerHTML: tt.value }, null, 8, Kt)
1384
+ A("code", { innerHTML: st.value }, null, 8, nn)
1250
1385
  ], 512)
1251
1386
  ], 512),
1252
- R("textarea", {
1387
+ A("textarea", {
1253
1388
  ref_key: "textarea",
1254
- ref: p,
1389
+ ref: d,
1255
1390
  class: "code-font input",
1256
- value: i.value,
1257
- readonly: l.readonly,
1258
- placeholder: l.placeholder,
1391
+ value: a.value,
1392
+ readonly: n.readonly,
1393
+ placeholder: n.placeholder,
1259
1394
  spellcheck: "false",
1260
1395
  autocomplete: "off",
1261
1396
  autocapitalize: "off",
1262
1397
  autocorrect: "off",
1263
- wrap: "soft",
1264
- onInput: ht,
1265
- onKeydown: xt,
1266
- onScroll: vt,
1267
- onClick: gt,
1268
- onMousemove: ft,
1269
- onMouseleave: L,
1270
- onBlur: bt
1271
- }, null, 40, Zt),
1272
- y.value ? (S(), E("ul", {
1398
+ wrap: "off",
1399
+ onInput: kt,
1400
+ onKeydown: St,
1401
+ onScroll: $t,
1402
+ onClick: xt,
1403
+ onMousemove: vt,
1404
+ onMouseleave: F,
1405
+ onBlur: wt
1406
+ }, null, 40, ln),
1407
+ w.value ? (I(), L("ul", {
1273
1408
  key: 0,
1274
1409
  ref_key: "popup",
1275
- ref: H,
1410
+ ref: y,
1276
1411
  class: "popup",
1277
- style: ae(k.value),
1278
- onMousedown: n[0] || (n[0] = Le(() => {
1412
+ style: ce(_.value),
1413
+ onMousedown: l[0] || (l[0] = Ne(() => {
1279
1414
  }, ["prevent"]))
1280
1415
  }, [
1281
- (S(!0), E(Oe, null, Ne(A.value, (r, m) => (S(), E("li", {
1282
- key: `${r.label}-${m}`,
1283
- class: te(["popup-item", { "is-active": m === w.value }]),
1284
- onMouseenter: (h) => w.value = m,
1285
- onClick: (h) => Ee(r)
1416
+ (I(!0), L(We, null, ze(B.value, (c, m) => (I(), L("li", {
1417
+ key: `${c.label}-${m}`,
1418
+ class: ne(["popup-item", { "is-active": m === R.value }]),
1419
+ onMouseenter: (h) => R.value = m,
1420
+ onClick: (h) => Ie(c)
1286
1421
  }, [
1287
- R("span", {
1288
- class: te(["badge", `badge-${r.kind}`])
1289
- }, K($e(r.kind)), 3),
1290
- R("span", Ut, K(r.label), 1),
1291
- r.detail ? (S(), E("span", Yt, K(r.detail), 1)) : D("", !0)
1292
- ], 42, qt))), 128))
1293
- ], 36)) : D("", !0),
1294
- $.value ? (S(), E("div", {
1422
+ A("span", {
1423
+ class: ne(["badge", `badge-${c.kind}`])
1424
+ }, Y(Ce(c.kind)), 3),
1425
+ A("span", an, Y(c.label), 1),
1426
+ c.detail ? (I(), L("span", sn, Y(c.detail), 1)) : Z("", !0)
1427
+ ], 42, on))), 128))
1428
+ ], 36)) : Z("", !0),
1429
+ g.value ? (I(), L("div", {
1295
1430
  key: 1,
1296
1431
  ref_key: "hoverCard",
1297
1432
  ref: O,
1298
1433
  class: "hover-card",
1299
- style: ae(ye.value)
1434
+ style: ce(oe.value)
1300
1435
  }, [
1301
- R("div", Jt, [
1302
- R("span", {
1303
- class: te(["badge", `badge-${$.value.kind}`])
1304
- }, K($e($.value.kind)), 3),
1305
- R("span", Gt, [
1306
- Tt(K($.value.label), 1),
1307
- $.value.detail ? (S(), E("span", Xt, ":")) : D("", !0)
1436
+ A("div", rn, [
1437
+ A("span", {
1438
+ class: ne(["badge", `badge-${g.value.kind}`])
1439
+ }, Y(Ce(g.value.kind)), 3),
1440
+ A("span", cn, [
1441
+ It(Y(g.value.label), 1),
1442
+ g.value.detail ? (I(), L("span", un, ":")) : Z("", !0)
1308
1443
  ]),
1309
- $.value.detail ? (S(), E("span", Qt, K($.value.detail), 1)) : D("", !0)
1444
+ g.value.detail ? (I(), L("span", dn, Y(g.value.detail), 1)) : Z("", !0)
1310
1445
  ]),
1311
- $.value.documentation ? (S(), E("p", en, K($.value.documentation), 1)) : D("", !0),
1312
- $.value.type ? (S(), E("pre", tn, [
1313
- R("code", {
1314
- innerHTML: st($.value.type)
1315
- }, null, 8, nn)
1316
- ])) : D("", !0)
1317
- ], 4)) : D("", !0)
1446
+ g.value.documentation ? (I(), L("p", fn, Y(g.value.documentation), 1)) : Z("", !0),
1447
+ g.value.type ? (I(), L("pre", pn, [
1448
+ A("code", {
1449
+ innerHTML: pt(g.value.type)
1450
+ }, null, 8, mn)
1451
+ ])) : Z("", !0)
1452
+ ], 4)) : Z("", !0)
1318
1453
  ], 512),
1319
- l.collapsible ? (S(), E("button", {
1454
+ n.collapsible ? (I(), L("button", {
1320
1455
  key: 1,
1321
1456
  type: "button",
1322
1457
  class: "expand-toggle",
1323
- title: N.value ? "收起" : "展开",
1324
- "aria-label": N.value ? "收起编辑器" : "展开编辑器",
1325
- onClick: at
1458
+ title: P.value ? "收起" : "展开",
1459
+ "aria-label": P.value ? "收起编辑器" : "展开编辑器",
1460
+ onClick: ft
1326
1461
  }, [
1327
- N.value ? (S(), E("svg", an, [...n[2] || (n[2] = [
1328
- R("path", {
1462
+ P.value ? (I(), L("svg", bn, [...l[2] || (l[2] = [
1463
+ A("path", {
1329
1464
  d: "M11 2 5 8 11 14",
1330
1465
  fill: "none",
1331
1466
  stroke: "currentColor",
@@ -1333,8 +1468,8 @@ ${_}${B}`);
1333
1468
  "stroke-linecap": "round",
1334
1469
  "stroke-linejoin": "round"
1335
1470
  }, null, -1)
1336
- ])])) : (S(), E("svg", on, [...n[1] || (n[1] = [
1337
- R("path", {
1471
+ ])])) : (I(), L("svg", gn, [...l[1] || (l[1] = [
1472
+ A("path", {
1338
1473
  d: "M6 2 12 8 6 14",
1339
1474
  fill: "none",
1340
1475
  stroke: "currentColor",
@@ -1343,33 +1478,35 @@ ${_}${B}`);
1343
1478
  "stroke-linejoin": "round"
1344
1479
  }, null, -1)
1345
1480
  ])]))
1346
- ], 8, ln)) : D("", !0)
1481
+ ], 8, hn)) : Z("", !0)
1347
1482
  ], 38)
1348
1483
  ], 6));
1349
1484
  }
1350
- }), rn = (l, s) => {
1351
- const a = l.__vccOpts || l;
1352
- for (const [t, o] of s)
1353
- a[t] = o;
1354
- return a;
1355
- }, cn = /* @__PURE__ */ rn(sn, [["__scopeId", "data-v-fcbf39fe"]]), fn = {
1356
- install(l) {
1357
- l.component("CodeInput", cn);
1485
+ }), yn = (n, s) => {
1486
+ const o = n.__vccOpts || n;
1487
+ for (const [e, i] of s)
1488
+ o[e] = i;
1489
+ return o;
1490
+ }, kn = /* @__PURE__ */ yn(vn, [["__scopeId", "data-v-d6942e2c"]]), $n = {
1491
+ install(n) {
1492
+ n.component("CodeInput", kn);
1358
1493
  }
1359
1494
  };
1360
1495
  export {
1361
- cn as CodeEditor,
1362
- At as collectCompletions,
1363
- fn as default,
1364
- St as defaultCompletions,
1365
- ve as findTemplateRange,
1496
+ kn as CodeEditor,
1497
+ zt as collectCompletions,
1498
+ $n as default,
1499
+ Lt as defaultCompletions,
1500
+ Ht as findArgumentContext,
1501
+ we as findTemplateRange,
1366
1502
  je as getKeywordSet,
1367
- Ye as getKeywords,
1368
- re as highlight,
1369
- Pt as highlightTemplate,
1370
- dn as isInsideTemplate,
1371
- jt as parseTsCompletions,
1372
- Lt as resolveHoverItem,
1373
- We as scanDeclarations,
1374
- se as tokenize
1503
+ Xe as getKeywords,
1504
+ de as highlight,
1505
+ en as highlightTemplate,
1506
+ xn as isInsideTemplate,
1507
+ Yt as parseTsCompletions,
1508
+ Jt as parseTsSignatures,
1509
+ jt as resolveHoverItem,
1510
+ Pe as scanDeclarations,
1511
+ ue as tokenize
1375
1512
  };