@onerjs/code-input 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,1316 @@
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 = [
3
+ {
4
+ label: "Math",
5
+ kind: "class",
6
+ detail: "Math",
7
+ type: `interface Math {
8
+ readonly PI: number
9
+ readonly E: number
10
+ abs(x: number): number
11
+ round(x: number): number
12
+ max(...values: number[]): number
13
+ random(): number
14
+ }`,
15
+ documentation: "内置数学对象",
16
+ members: [
17
+ { label: "PI", kind: "property", detail: "number" },
18
+ { label: "E", kind: "property", detail: "number" },
19
+ { label: "abs", kind: "function", detail: "(x: number) => number" },
20
+ { label: "ceil", kind: "function", detail: "(x: number) => number" },
21
+ { label: "floor", kind: "function", detail: "(x: number) => number" },
22
+ { label: "round", kind: "function", detail: "(x: number) => number" },
23
+ { label: "max", kind: "function", detail: "(...values: number[]) => number" },
24
+ { label: "min", kind: "function", detail: "(...values: number[]) => number" },
25
+ { label: "pow", kind: "function", detail: "(base: number, exp: number) => number" },
26
+ { label: "random", kind: "function", detail: "() => number" },
27
+ { label: "sqrt", kind: "function", detail: "(x: number) => number" },
28
+ { label: "trunc", kind: "function", detail: "(x: number) => number" }
29
+ ]
30
+ },
31
+ {
32
+ label: "JSON",
33
+ kind: "class",
34
+ detail: "JSON",
35
+ members: [
36
+ { label: "parse", kind: "function", detail: "(text: string) => any" },
37
+ { label: "stringify", kind: "function", detail: "(value: any, space?: number) => string" }
38
+ ]
39
+ },
40
+ {
41
+ label: "console",
42
+ kind: "variable",
43
+ detail: "Console",
44
+ members: [
45
+ { label: "log", kind: "function", detail: "(...data: any[]) => void" },
46
+ { label: "info", kind: "function", detail: "(...data: any[]) => void" },
47
+ { label: "warn", kind: "function", detail: "(...data: any[]) => void" },
48
+ { label: "error", kind: "function", detail: "(...data: any[]) => void" },
49
+ { label: "debug", kind: "function", detail: "(...data: any[]) => void" },
50
+ { label: "table", kind: "function", detail: "(data: any) => void" },
51
+ { label: "time", kind: "function", detail: "(label: string) => void" },
52
+ { label: "timeEnd", kind: "function", detail: "(label: string) => void" }
53
+ ]
54
+ },
55
+ {
56
+ label: "Object",
57
+ kind: "class",
58
+ detail: "Object",
59
+ members: [
60
+ { label: "keys", kind: "function", detail: "(o: object) => string[]" },
61
+ { label: "values", kind: "function", detail: "(o: object) => any[]" },
62
+ { label: "entries", kind: "function", detail: "(o: object) => [string, any][]" },
63
+ { label: "assign", kind: "function", detail: "(target: object, ...sources: object[]) => object" },
64
+ { label: "freeze", kind: "function", detail: "(o: object) => object" }
65
+ ]
66
+ },
67
+ {
68
+ label: "Array",
69
+ kind: "class",
70
+ detail: "Array",
71
+ members: [
72
+ { label: "isArray", kind: "function", detail: "(value: any) => boolean" },
73
+ { label: "from", kind: "function", detail: "(iterable: any) => any[]" },
74
+ { label: "of", kind: "function", detail: "(...items: any[]) => any[]" }
75
+ ]
76
+ },
77
+ {
78
+ label: "Promise",
79
+ kind: "class",
80
+ detail: "Promise",
81
+ members: [
82
+ { label: "resolve", kind: "function", detail: "(value?: any) => Promise<any>" },
83
+ { label: "reject", kind: "function", detail: "(reason?: any) => Promise<never>" },
84
+ { label: "all", kind: "function", detail: "(values: any[]) => Promise<any[]>" },
85
+ { label: "race", kind: "function", detail: "(values: any[]) => Promise<any>" }
86
+ ]
87
+ },
88
+ {
89
+ label: "Date",
90
+ kind: "class",
91
+ detail: "Date",
92
+ members: [
93
+ { label: "now", kind: "function", detail: "() => number" },
94
+ { label: "parse", kind: "function", detail: "(dateString: string) => number" }
95
+ ]
96
+ },
97
+ {
98
+ label: "String",
99
+ kind: "class",
100
+ detail: "String",
101
+ members: [
102
+ { label: "fromCharCode", kind: "function", detail: "(...codes: number[]) => string" },
103
+ { label: "from", kind: "function", detail: "(value: any) => string" }
104
+ ]
105
+ },
106
+ {
107
+ label: "Number",
108
+ kind: "class",
109
+ detail: "Number",
110
+ members: [
111
+ { label: "isNaN", kind: "function", detail: "(value: any) => boolean" },
112
+ { label: "isInteger", kind: "function", detail: "(value: any) => boolean" },
113
+ { label: "parseFloat", kind: "function", detail: "(value: string) => number" },
114
+ { label: "parseInt", kind: "function", detail: "(value: string, radix?: number) => number" }
115
+ ]
116
+ },
117
+ {
118
+ label: "setTimeout",
119
+ kind: "function",
120
+ detail: "(callback: Function, ms?: number) => number"
121
+ },
122
+ {
123
+ label: "clearTimeout",
124
+ kind: "function",
125
+ detail: "(id: number) => void"
126
+ },
127
+ {
128
+ label: "setInterval",
129
+ kind: "function",
130
+ detail: "(callback: Function, ms?: number) => number"
131
+ },
132
+ {
133
+ label: "clearInterval",
134
+ kind: "function",
135
+ detail: "(id: number) => void"
136
+ }
137
+ ], Be = [
138
+ "break",
139
+ "case",
140
+ "catch",
141
+ "class",
142
+ "const",
143
+ "continue",
144
+ "debugger",
145
+ "default",
146
+ "delete",
147
+ "do",
148
+ "else",
149
+ "export",
150
+ "extends",
151
+ "finally",
152
+ "for",
153
+ "from",
154
+ "function",
155
+ "if",
156
+ "import",
157
+ "in",
158
+ "instanceof",
159
+ "let",
160
+ "new",
161
+ "of",
162
+ "return",
163
+ "super",
164
+ "switch",
165
+ "this",
166
+ "throw",
167
+ "try",
168
+ "typeof",
169
+ "var",
170
+ "void",
171
+ "while",
172
+ "with",
173
+ "yield",
174
+ "async",
175
+ "await",
176
+ "true",
177
+ "false",
178
+ "null",
179
+ "undefined",
180
+ "NaN",
181
+ "Infinity"
182
+ ], xt = [
183
+ "abstract",
184
+ "any",
185
+ "as",
186
+ "asserts",
187
+ "bigint",
188
+ "boolean",
189
+ "declare",
190
+ "enum",
191
+ "implements",
192
+ "infer",
193
+ "interface",
194
+ "is",
195
+ "keyof",
196
+ "namespace",
197
+ "never",
198
+ "number",
199
+ "object",
200
+ "override",
201
+ "private",
202
+ "protected",
203
+ "public",
204
+ "readonly",
205
+ "satisfies",
206
+ "static",
207
+ "string",
208
+ "symbol",
209
+ "type",
210
+ "unknown"
211
+ ];
212
+ function Ke(l) {
213
+ return l === "typescript" ? [...Be, ...xt] : Be;
214
+ }
215
+ function Le(l) {
216
+ return new Set(Ke(l));
217
+ }
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 };
224
+ }
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",
236
+ detail: "当前文件"
237
+ });
238
+ }
239
+ return a;
240
+ }
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);
246
+ if (!o) return null;
247
+ a = o.members ?? [];
248
+ }
249
+ return a;
250
+ }
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;
259
+ }
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 });
266
+ }
267
+ return a.sort((n, o) => o.score - n.score || n.item.label.localeCompare(o.item.label)), a.map((n) => n.item);
268
+ }
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;
274
+ }
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)))
278
+ 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);
283
+ if (!f || f.length === 0) return null;
284
+ d = f;
285
+ } else
286
+ d = [
287
+ ...a.completions,
288
+ ...c,
289
+ ...Ke(a.language).map((f) => ({
290
+ label: f,
291
+ kind: "keyword"
292
+ }))
293
+ ];
294
+ const i = Et(_t(d), n);
295
+ return i.length === 0 ? null : {
296
+ items: i,
297
+ start: r - n.length,
298
+ end: r
299
+ };
300
+ }
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);
308
+ if (f) return f;
309
+ }
310
+ return c.find((d) => d.label === o) ?? null;
311
+ }
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;
323
+ break;
324
+ }
325
+ }
326
+ return { end: o, body: l.slice(r + 1, o) };
327
+ }
328
+ function De(l) {
329
+ return l.trim().replace(/[,;]$/, "").trim();
330
+ }
331
+ function U(l) {
332
+ return l.length ? l.join(`
333
+ `).replace(/^\s*\/\*\*?/, "").replace(/\*\/\s*$/, "").split(`
334
+ `).map((r) => r.replace(/^\s*\*+\s?/, "").replace(/^\s*\/\/\s?/, "")).join(`
335
+ `).replace(/\n{3,}/g, `
336
+
337
+ `).trim() : "";
338
+ }
339
+ function We(l) {
340
+ return l.split(`
341
+ `).filter((r) => !/^\s*(\/\/|\/\*|\*)/.test(r)).join(`
342
+ `).replace(/\n{2,}/g, `
343
+ `).trim();
344
+ }
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);
352
+ continue;
353
+ }
354
+ if (i.startsWith("/*")) {
355
+ c.push(i), i.includes("*/") || (u = !0);
356
+ continue;
357
+ }
358
+ if (i.startsWith("//")) {
359
+ c.push(i);
360
+ continue;
361
+ }
362
+ if (!i || i.startsWith("}") || i.startsWith("[")) {
363
+ c = [];
364
+ continue;
365
+ }
366
+ const f = n.exec(i);
367
+ 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,
374
+ kind: "function",
375
+ detail: `(${f[3].trim()}) => ${De(f[4])}`,
376
+ documentation: W || void 0
377
+ });
378
+ continue;
379
+ }
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,
391
+ detail: b,
392
+ documentation: W || void 0
393
+ });
394
+ }
395
+ }
396
+ return r;
397
+ }
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;
401
+ }
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;
407
+ }
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)
418
+ };
419
+ });
420
+ }
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);
430
+ continue;
431
+ }
432
+ if (b.startsWith("/*")) {
433
+ u.push(b), b.includes("*/") || (d = !0);
434
+ continue;
435
+ }
436
+ if (b.startsWith("//")) {
437
+ u.push(b);
438
+ continue;
439
+ }
440
+ if (!b) {
441
+ u = [];
442
+ continue;
443
+ }
444
+ const H = n.exec(b);
445
+ if (H && b.includes("{")) {
446
+ const k = U(u);
447
+ 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(`
453
+ `).replace(/^\s*export\s+/, "")
454
+ ),
455
+ members: Pe(E),
456
+ kind: "interface",
457
+ documentation: k || void 0
458
+ }), g = w;
459
+ continue;
460
+ }
461
+ const O = o.exec(b);
462
+ if (O && b.includes("{")) {
463
+ const k = U(u);
464
+ 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(`
470
+ `).replace(/^\s*export\s+/, "")
471
+ ),
472
+ members: Pe(E),
473
+ kind: "class",
474
+ documentation: k || void 0
475
+ }), g = w;
476
+ continue;
477
+ }
478
+ const A = c.exec(b);
479
+ if (A) {
480
+ const k = U(u);
481
+ 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(`
488
+ `).replace(/^\s*export\s+/, "").replace(/;\s*$/, "").trim();
489
+ a.set(A[1], {
490
+ label: A[1],
491
+ type: v,
492
+ members: [],
493
+ kind: "type",
494
+ documentation: k || void 0
495
+ }), g = E;
496
+ continue;
497
+ }
498
+ u = [];
499
+ }
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*([^=;]+)`
504
+ );
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);
510
+ continue;
511
+ }
512
+ if (b.startsWith("/*")) {
513
+ u.push(b), b.includes("*/") || (d = !0);
514
+ continue;
515
+ }
516
+ if (b.startsWith("//")) {
517
+ u.push(b);
518
+ continue;
519
+ }
520
+ if (!b) {
521
+ u = [];
522
+ continue;
523
+ }
524
+ const H = _.exec(b);
525
+ if (H) {
526
+ const A = U(u);
527
+ u = [];
528
+ const k = H[1];
529
+ f.has(k) || (f.add(k), i.push({
530
+ label: k,
531
+ kind: "function",
532
+ detail: `(${H[2].trim()}) => ${H[3].trim()}`,
533
+ documentation: A || void 0
534
+ }));
535
+ continue;
536
+ }
537
+ const O = W.exec(b);
538
+ if (O) {
539
+ const A = U(u);
540
+ 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
552
+ });
553
+ continue;
554
+ }
555
+ u = [];
556
+ }
557
+ return i;
558
+ }
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);
564
+ return {
565
+ start: c + a.length,
566
+ end: d === -1 ? l.length : d
567
+ };
568
+ }
569
+ function ln(l, r, a, n) {
570
+ return he(l, r, a, n) !== null;
571
+ }
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++;
580
+ continue;
581
+ }
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;
586
+ continue;
587
+ }
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;
591
+ continue;
592
+ }
593
+ if (c === '"' || c === "'") {
594
+ let i = o + 1;
595
+ for (; i < n; ) {
596
+ if (l[i] === "\\") {
597
+ i += 2;
598
+ continue;
599
+ }
600
+ if (l[i] === `
601
+ `) break;
602
+ if (l[i] === c) {
603
+ i++;
604
+ break;
605
+ }
606
+ i++;
607
+ }
608
+ a.push({ start: o, end: i, type: "string" }), o = i;
609
+ continue;
610
+ }
611
+ if (c === "`") {
612
+ let i = o + 1;
613
+ for (; i < n; ) {
614
+ if (l[i] === "\\") {
615
+ i += 2;
616
+ continue;
617
+ }
618
+ if (l[i] === "`") {
619
+ i++;
620
+ break;
621
+ }
622
+ i++;
623
+ }
624
+ a.push({ start: o, end: i, type: "template" }), o = i;
625
+ continue;
626
+ }
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;
631
+ continue;
632
+ }
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;
638
+ continue;
639
+ }
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++;
645
+ }
646
+ a.push({ start: o, end: d, type: "punctuation" }), o = d;
647
+ }
648
+ return a;
649
+ }
650
+ const Lt = {
651
+ "&": "&amp;",
652
+ "<": "&lt;",
653
+ ">": "&gt;"
654
+ };
655
+ function Y(l) {
656
+ return l.replace(/[&<>]/g, (r) => Lt[r] ?? r);
657
+ }
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;
664
+ }
665
+ return o < l.length && (n += Y(l.slice(o))), n;
666
+ }
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));
674
+ break;
675
+ }
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);
679
+ }
680
+ return o;
681
+ }
682
+ const Nt = {
683
+ key: 0,
684
+ class: "gutter",
685
+ "aria-hidden": "true"
686
+ }, jt = ["innerHTML"], zt = ["value", "readonly", "placeholder"], Dt = ["onMouseenter", "onClick"], Wt = { class: "popup-label" }, Pt = {
687
+ key: 0,
688
+ class: "popup-detail"
689
+ }, Ft = { class: "hover-head" }, Vt = { class: "hover-name" }, Kt = {
690
+ key: 0,
691
+ class: "hover-colon"
692
+ }, Zt = {
693
+ key: 0,
694
+ class: "hover-type"
695
+ }, qt = {
696
+ key: 0,
697
+ class: "hover-doc"
698
+ }, Ut = {
699
+ key: 1,
700
+ class: "hover-def"
701
+ }, Yt = ["innerHTML"], Jt = ["title", "aria-label"], Gt = {
702
+ key: 0,
703
+ viewBox: "0 0 16 16",
704
+ width: "14",
705
+ height: "14",
706
+ "aria-hidden": "true"
707
+ }, Xt = {
708
+ key: 1,
709
+ viewBox: "0 0 16 16",
710
+ width: "14",
711
+ height: "14",
712
+ "aria-hidden": "true"
713
+ }, Qt = /* @__PURE__ */ bt({
714
+ __name: "CodeEditor",
715
+ props: {
716
+ modelValue: {},
717
+ mode: { default: "code" },
718
+ language: { default: "javascript" },
719
+ completions: { default: () => [] },
720
+ tsTypes: { default: "" },
721
+ templateCompletions: { default: () => [] },
722
+ templateOpen: { default: "{{" },
723
+ templateClose: { default: "}}" },
724
+ placeholder: { default: "" },
725
+ readonly: { type: Boolean, default: !1 },
726
+ lineNumbers: { type: Boolean, default: !0 },
727
+ hover: { type: Boolean, default: !0 },
728
+ theme: { default: "light" },
729
+ collapsible: { type: Boolean, default: !1 },
730
+ defaultExpanded: { type: Boolean, default: !1 },
731
+ collapsedHeight: { default: "34px" },
732
+ collapseOnBlur: { type: Boolean, default: !1 },
733
+ minHeight: { default: "260px" }
734
+ },
735
+ emits: ["update:modelValue", "change", "expand", "collapse"],
736
+ setup(l, { expose: r, emit: a }) {
737
+ const n = l, o = a, c = {
738
+ variable: "变量",
739
+ function: "函数",
740
+ property: "属性",
741
+ class: "对象",
742
+ keyword: "关键字"
743
+ }, u = {
744
+ "(": ")",
745
+ "[": "]",
746
+ "{": "}",
747
+ '"': '"',
748
+ "'": "'"
749
+ }, d = /* @__PURE__ */ new Set([
750
+ "ArrowLeft",
751
+ "ArrowRight",
752
+ "ArrowUp",
753
+ "ArrowDown",
754
+ "Home",
755
+ "End",
756
+ "PageUp",
757
+ "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))
770
+ };
771
+ return n.mode === "template" ? `${Ot(i.value, e, n.templateOpen, n.templateClose)}
772
+ ` : `${se(i.value, ae(i.value, e))}
773
+ `;
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();
786
+ return;
787
+ }
788
+ N(!0), e && n.collapseOnBlur && t && document.activeElement !== t && t.focus();
789
+ });
790
+ }
791
+ function et() {
792
+ ye(!z.value);
793
+ }
794
+ Me(
795
+ () => n.modelValue,
796
+ (e) => {
797
+ e !== i.value && (i.value = e, R());
798
+ }
799
+ ), Me(i, () => {
800
+ j(() => N(!0));
801
+ });
802
+ function ke(e) {
803
+ return c[e];
804
+ }
805
+ function tt(e) {
806
+ return e ? se(
807
+ e,
808
+ ae(e, { keywords: Le("typescript"), builtins: /* @__PURE__ */ new Set() })
809
+ ) : "";
810
+ }
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
820
+ };
821
+ }
822
+ function N(e = !1) {
823
+ const t = f.value;
824
+ 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());
829
+ }
830
+ }
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) => {
845
+ const p = h.getBoundingClientRect();
846
+ m.push({
847
+ start: Number(h.dataset.start),
848
+ 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
853
+ });
854
+ }), we = m;
855
+ }
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;
860
+ return null;
861
+ }
862
+ function L() {
863
+ $.value = null, ne = 0, ue = -1, de = -1;
864
+ }
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` };
871
+ }
872
+ function it(e, t) {
873
+ const s = f.value;
874
+ if (!s || n.readonly || !n.hover || w.value) {
875
+ L();
876
+ return;
877
+ }
878
+ if (s.selectionStart !== s.selectionEnd) {
879
+ L();
880
+ return;
881
+ }
882
+ 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)
886
+ return;
887
+ }
888
+ const h = s.getBoundingClientRect(), p = lt(e - h.left + s.scrollLeft, t - h.top + s.scrollTop);
889
+ if (!p) {
890
+ L();
891
+ return;
892
+ }
893
+ if ($.value && ue === p.start && de === p.end)
894
+ return;
895
+ const x = Mt(s.value, p.start, p.end, {
896
+ completions: re.value,
897
+ declared: Ne(s.value, p.start)
898
+ });
899
+ if (!x) {
900
+ L();
901
+ return;
902
+ }
903
+ $.value = x, ue = p.start, de = p.end, j(() => ot(p));
904
+ }
905
+ function at(e) {
906
+ fe = { x: e.clientX, y: e.clientY }, !ne && (ne = requestAnimationFrame(() => {
907
+ ne = 0, it(fe.x, fe.y);
908
+ }));
909
+ }
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, {
915
+ position: "fixed",
916
+ left: `${p.left}px`,
917
+ top: `${p.top}px`,
918
+ visibility: "hidden",
919
+ pointerEvents: "none",
920
+ zIndex: "-1",
921
+ whiteSpace: "pre-wrap",
922
+ overflowWrap: "break-word",
923
+ wordBreak: "normal",
924
+ 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,
930
+ 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);
941
+ 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;
946
+ return {
947
+ left: y.left - p.left - e.scrollLeft,
948
+ top: y.top - p.top - e.scrollTop - P,
949
+ lineHeight: I
950
+ };
951
+ }
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`
962
+ };
963
+ }
964
+ function R() {
965
+ w.value = !1, A.value = [], k.value = 0, L();
966
+ }
967
+ function Q(e = !1) {
968
+ const t = f.value;
969
+ if (!t || n.readonly) return;
970
+ if (t.selectionStart !== t.selectionEnd) {
971
+ R();
972
+ return;
973
+ }
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
982
+ );
983
+ if (!p) {
984
+ R();
985
+ return;
986
+ }
987
+ e && t.value.slice(p.start, s).trim() === "" && (m = !0);
988
+ }
989
+ const h = Rt(t.value, s, {
990
+ language: n.language,
991
+ completions: re.value,
992
+ declared: Ne(t.value, s),
993
+ auto: !m
994
+ });
995
+ if (!h) {
996
+ R();
997
+ return;
998
+ }
999
+ A.value = h.items, E.value = { start: h.start, end: h.end }, k.value = 0, w.value = !0, st();
1000
+ }
1001
+ function rt(e) {
1002
+ i.value = e, o("update:modelValue", e), o("change", e);
1003
+ }
1004
+ function le(e, t, s, m = e + s.length) {
1005
+ const h = f.value;
1006
+ 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();
1010
+ });
1011
+ }
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();
1016
+ }
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" });
1022
+ }));
1023
+ }
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);
1027
+ }
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);
1032
+ }
1033
+ function dt() {
1034
+ Se(), X();
1035
+ }
1036
+ function Se() {
1037
+ const e = f.value;
1038
+ if (!e || n.readonly) return;
1039
+ if (e.selectionStart !== e.selectionEnd) {
1040
+ R();
1041
+ return;
1042
+ }
1043
+ const t = e.selectionStart;
1044
+ if (t > 0 && e.value[t - 1] === ".") {
1045
+ Q(!0);
1046
+ return;
1047
+ }
1048
+ if (n.mode === "template") {
1049
+ const s = he(
1050
+ e.value,
1051
+ t,
1052
+ n.templateOpen,
1053
+ n.templateClose
1054
+ );
1055
+ if (s && e.value.slice(s.start, t).trim() === "") {
1056
+ Q(!0);
1057
+ return;
1058
+ }
1059
+ }
1060
+ R();
1061
+ }
1062
+ let pe = 0;
1063
+ function Ee() {
1064
+ window.clearTimeout(pe), pe = window.setTimeout(() => {
1065
+ pe = 0, Se(), X();
1066
+ }, 0);
1067
+ }
1068
+ function _e(e) {
1069
+ e.target !== f.value && w.value && R();
1070
+ }
1071
+ function ft() {
1072
+ L(), N(), J.value && pt();
1073
+ }
1074
+ let me = 0;
1075
+ function pt() {
1076
+ window.clearTimeout(me), me = window.setTimeout(() => {
1077
+ me = 0, mt();
1078
+ }, 120);
1079
+ }
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;
1088
+ const t = f.value;
1089
+ 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);
1093
+ return;
1094
+ }
1095
+ if (w.value) {
1096
+ if (e.key === "ArrowDown") {
1097
+ e.preventDefault(), Te(1);
1098
+ return;
1099
+ }
1100
+ if (e.key === "ArrowUp") {
1101
+ e.preventDefault(), Te(-1);
1102
+ return;
1103
+ }
1104
+ if (e.key === "Enter" || e.key === "Tab") {
1105
+ e.preventDefault(), Ce();
1106
+ return;
1107
+ }
1108
+ if (e.key === "Escape") {
1109
+ e.preventDefault(), R();
1110
+ return;
1111
+ }
1112
+ if (m || s) {
1113
+ R(), m && !s && Ee();
1114
+ return;
1115
+ }
1116
+ }
1117
+ if (m && !s) {
1118
+ Ee();
1119
+ return;
1120
+ }
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}`);
1128
+ return;
1129
+ }
1130
+ if (e.key === "Tab") {
1131
+ e.preventDefault(), le(t.selectionStart, t.selectionEnd, " ");
1132
+ return;
1133
+ }
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));
1139
+ }
1140
+ }
1141
+ function Re() {
1142
+ w.value && R(), L(), j(() => {
1143
+ ce(), N(!0);
1144
+ });
1145
+ }
1146
+ return gt(() => {
1147
+ window.addEventListener("resize", Re), window.addEventListener("scroll", _e, !0), j(() => {
1148
+ ce(), N(!0);
1149
+ });
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)
1162
+ }, [
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)
1180
+ }, [
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"
1190
+ }, [
1191
+ M("code", { innerHTML: Je.value }, null, 8, jt)
1192
+ ], 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"]))
1222
+ }, [
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)
1228
+ }, [
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", {
1237
+ key: 1,
1238
+ ref_key: "hoverCard",
1239
+ ref: O,
1240
+ class: "hover-card",
1241
+ style: oe(be.value)
1242
+ }, [
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)
1289
+ ], 6));
1290
+ }
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);
1299
+ }
1300
+ };
1301
+ 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
1316
+ };