@onerjs/code-input 0.1.1 → 0.1.3

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