@cascivo/editor 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.js +10 -1515
- package/dist/node/index.js +10 -1516
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,1517 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import './editor.css';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
if (i) return i;
|
|
12
|
-
|
|
13
|
-
let { tokens: a, state: o } = e.tokenizeLine(t, n), s = {
|
|
14
|
-
tokens: a,
|
|
15
|
-
endState: o
|
|
16
|
-
};
|
|
17
|
-
return ee.set(r, s), s;
|
|
18
|
-
}
|
|
19
|
-
function h(e, t) {
|
|
20
|
-
let n = t.split("\n"), r = [], i = e.initialState;
|
|
21
|
-
for (let t of n) {
|
|
22
|
-
let n = m(e, t, i);
|
|
23
|
-
r.push(n.tokens), i = n.endState;
|
|
24
|
-
}
|
|
25
|
-
return r;
|
|
26
|
-
}
|
|
27
|
-
function re(e, t, n, r, i) {
|
|
28
|
-
let a = Math.max(0, Math.min(n, t.length)), o = Math.max(a, Math.min(r, t.length)), s = i.startStateOf(t, a), c = [];
|
|
29
|
-
for (let n = a; n < o; n++) {
|
|
30
|
-
let r = m(e, t[n], s);
|
|
31
|
-
c.push(r.tokens), i.setEndState(n, r.endState), s = r.endState;
|
|
32
|
-
}
|
|
33
|
-
return c;
|
|
34
|
-
}
|
|
35
|
-
function ie(e, t, n, r, i) {
|
|
36
|
-
let a = Math.max(0, Math.min(n, t.length)), o = Math.max(a, Math.min(r, t.length)), s = i, c = [];
|
|
37
|
-
for (let n = a; n < o; n++) {
|
|
38
|
-
let r = m(e, t[n], s);
|
|
39
|
-
c.push(r.tokens), s = r.endState;
|
|
40
|
-
}
|
|
41
|
-
return c;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/engine/line-state.ts
|
|
45
|
-
function ae(e) {
|
|
46
|
-
let t = [], n = (n, r) => {
|
|
47
|
-
let i = Math.min(r, n.length - 1), a = t.length;
|
|
48
|
-
if (a > i) return;
|
|
49
|
-
let o = a === 0 ? e.initialState : t[a - 1];
|
|
50
|
-
for (; a <= i; a++) {
|
|
51
|
-
let r = m(e, n[a], o);
|
|
52
|
-
t[a] = r.endState, o = r.endState;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
grammar: e,
|
|
57
|
-
get length() {
|
|
58
|
-
return t.length;
|
|
59
|
-
},
|
|
60
|
-
ensure: n,
|
|
61
|
-
startStateOf: (r, i) => i <= 0 ? e.initialState : (n(r, i - 1), t[i - 1]),
|
|
62
|
-
setEndState: (e, n) => {
|
|
63
|
-
t[e] = n;
|
|
64
|
-
},
|
|
65
|
-
invalidateFrom: (e) => {
|
|
66
|
-
let n = Math.max(0, e);
|
|
67
|
-
n < t.length && (t.length = n);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/engine/registry.ts
|
|
73
|
-
var g = /* @__PURE__ */ new Map(), _ = {
|
|
74
|
-
name: "plaintext",
|
|
75
|
-
initialState: "default",
|
|
76
|
-
tokenizeLine: (e) => ({
|
|
77
|
-
tokens: e.length > 0 ? [{
|
|
78
|
-
kind: "plain",
|
|
79
|
-
value: e
|
|
80
|
-
}] : [],
|
|
81
|
-
state: "default"
|
|
82
|
-
})
|
|
83
|
-
};
|
|
84
|
-
g.set(_.name, _);
|
|
85
|
-
function v(e) {
|
|
86
|
-
g.set(e.name, e);
|
|
87
|
-
}
|
|
88
|
-
function oe(e) {
|
|
89
|
-
if (e !== void 0) {
|
|
90
|
-
let t = g.get(e);
|
|
91
|
-
if (t) return t;
|
|
92
|
-
}
|
|
93
|
-
return g.get("plaintext");
|
|
94
|
-
}
|
|
95
|
-
function y() {
|
|
96
|
-
return [...g.keys()];
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/grammars/rules.ts
|
|
100
|
-
function b(e) {
|
|
101
|
-
let t = {};
|
|
102
|
-
for (let [n, r] of Object.entries(e.states)) t[n] = r.map((e) => {
|
|
103
|
-
let t = `${e.match.flags.replace(/[gy]/g, "")}y`, n = {
|
|
104
|
-
re: new RegExp(e.match.source, t),
|
|
105
|
-
kind: e.kind
|
|
106
|
-
};
|
|
107
|
-
return e.push !== void 0 && (n.push = e.push), e.pop !== void 0 && (n.pop = e.pop), n;
|
|
108
|
-
});
|
|
109
|
-
return {
|
|
110
|
-
name: e.name,
|
|
111
|
-
initialState: "default",
|
|
112
|
-
tokenizeLine(e, n) {
|
|
113
|
-
let r = t[n] ? n : "default", i = [], a = -1, o = 0, s = (t) => {
|
|
114
|
-
a >= 0 && (i.push({
|
|
115
|
-
kind: "plain",
|
|
116
|
-
value: e.slice(a, t)
|
|
117
|
-
}), a = -1);
|
|
118
|
-
};
|
|
119
|
-
for (; o < e.length;) {
|
|
120
|
-
let n = t[r], c = !1;
|
|
121
|
-
for (let a of n) {
|
|
122
|
-
a.re.lastIndex = o;
|
|
123
|
-
let n = a.re.exec(e);
|
|
124
|
-
if (n !== null && n.index === o && n[0].length > 0) {
|
|
125
|
-
s(o), i.push({
|
|
126
|
-
kind: a.kind,
|
|
127
|
-
value: n[0]
|
|
128
|
-
}), o += n[0].length, a.pop ? r = "default" : a.push && t[a.push] && (r = a.push), c = !0;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
c || (a < 0 && (a = o), o++);
|
|
133
|
-
}
|
|
134
|
-
return s(e.length), {
|
|
135
|
-
tokens: i,
|
|
136
|
-
state: r
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/grammars/plaintext.ts
|
|
143
|
-
var se = {
|
|
144
|
-
name: "plaintext",
|
|
145
|
-
initialState: "default",
|
|
146
|
-
tokenizeLine: (e) => ({
|
|
147
|
-
tokens: e.length > 0 ? [{
|
|
148
|
-
kind: "plain",
|
|
149
|
-
value: e
|
|
150
|
-
}] : [],
|
|
151
|
-
state: "default"
|
|
152
|
-
})
|
|
153
|
-
};
|
|
154
|
-
v(se);
|
|
155
|
-
//#endregion
|
|
156
|
-
//#region src/grammars/json.ts
|
|
157
|
-
var ce = b({
|
|
158
|
-
name: "json",
|
|
159
|
-
states: { default: [
|
|
160
|
-
{
|
|
161
|
-
match: /"(?:[^"\\]|\\.)*"(?=\s*:)/,
|
|
162
|
-
kind: "property"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
match: /"(?:[^"\\]|\\.)*"/,
|
|
166
|
-
kind: "string"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
match: /\b(?:true|false|null)\b/,
|
|
170
|
-
kind: "boolean"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
match: /-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/,
|
|
174
|
-
kind: "number"
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
match: /[{}[\],]/,
|
|
178
|
-
kind: "punctuation"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
match: /:/,
|
|
182
|
-
kind: "operator"
|
|
183
|
-
}
|
|
184
|
-
] }
|
|
185
|
-
});
|
|
186
|
-
v(ce);
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/grammars/clike.ts
|
|
189
|
-
var le = /* @__PURE__ */ "async.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.export.extends.finally.for.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.with.yield.as.from.get.set".split(".");
|
|
190
|
-
function ue(e) {
|
|
191
|
-
return RegExp(`(?:${e.join("|")})\\b`);
|
|
192
|
-
}
|
|
193
|
-
function de(e, t, n = []) {
|
|
194
|
-
let r = [
|
|
195
|
-
{
|
|
196
|
-
match: /\/\/.*/,
|
|
197
|
-
kind: "comment"
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
match: /\/\*/,
|
|
201
|
-
kind: "comment",
|
|
202
|
-
push: "block"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
match: /`/,
|
|
206
|
-
kind: "string",
|
|
207
|
-
push: "template"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
match: /'(?:[^'\\]|\\.)*'/,
|
|
211
|
-
kind: "string"
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
match: /"(?:[^"\\]|\\.)*"/,
|
|
215
|
-
kind: "string"
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
match: /0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|(?:\d[\d_]*\.?\d*|\.\d+)(?:[eE][+-]?\d+)?n?/,
|
|
219
|
-
kind: "number"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
match: /\b(?:true|false|null|undefined|NaN|Infinity)\b/,
|
|
223
|
-
kind: "boolean"
|
|
224
|
-
}
|
|
225
|
-
];
|
|
226
|
-
return n.length > 0 && r.push({
|
|
227
|
-
match: ue(n),
|
|
228
|
-
kind: "type"
|
|
229
|
-
}), r.push({
|
|
230
|
-
match: ue(t),
|
|
231
|
-
kind: "keyword"
|
|
232
|
-
}, {
|
|
233
|
-
match: /[A-Za-z_$][\w$]*(?=\s*\()/,
|
|
234
|
-
kind: "function"
|
|
235
|
-
}, {
|
|
236
|
-
match: /[A-Z][\w$]*/,
|
|
237
|
-
kind: "type"
|
|
238
|
-
}, {
|
|
239
|
-
match: /[A-Za-z_$][\w$]*/,
|
|
240
|
-
kind: "variable"
|
|
241
|
-
}, {
|
|
242
|
-
match: /[+\-*/%=<>!&|^~?]+/,
|
|
243
|
-
kind: "operator"
|
|
244
|
-
}, {
|
|
245
|
-
match: /[{}()[\];,.:]/,
|
|
246
|
-
kind: "punctuation"
|
|
247
|
-
}), b({
|
|
248
|
-
name: e,
|
|
249
|
-
states: {
|
|
250
|
-
default: r,
|
|
251
|
-
block: [
|
|
252
|
-
{
|
|
253
|
-
match: /\*\//,
|
|
254
|
-
kind: "comment",
|
|
255
|
-
pop: !0
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
match: /[^*]+/,
|
|
259
|
-
kind: "comment"
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
match: /\*/,
|
|
263
|
-
kind: "comment"
|
|
264
|
-
}
|
|
265
|
-
],
|
|
266
|
-
template: [
|
|
267
|
-
{
|
|
268
|
-
match: /\\./,
|
|
269
|
-
kind: "string"
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
match: /`/,
|
|
273
|
-
kind: "string",
|
|
274
|
-
pop: !0
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
match: /\$\{/,
|
|
278
|
-
kind: "punctuation"
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
match: /[^`\\$]+/,
|
|
282
|
-
kind: "string"
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
match: /\$/,
|
|
286
|
-
kind: "string"
|
|
287
|
-
}
|
|
288
|
-
]
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region src/grammars/javascript.ts
|
|
294
|
-
var x = de("javascript", le);
|
|
295
|
-
v(x);
|
|
296
|
-
var fe = de("typescript", le, [
|
|
297
|
-
"interface",
|
|
298
|
-
"type",
|
|
299
|
-
"enum",
|
|
300
|
-
"implements",
|
|
301
|
-
"namespace",
|
|
302
|
-
"declare",
|
|
303
|
-
"abstract",
|
|
304
|
-
"readonly",
|
|
305
|
-
"public",
|
|
306
|
-
"private",
|
|
307
|
-
"protected",
|
|
308
|
-
"keyof",
|
|
309
|
-
"infer",
|
|
310
|
-
"satisfies",
|
|
311
|
-
"is",
|
|
312
|
-
"asserts",
|
|
313
|
-
"override",
|
|
314
|
-
"string",
|
|
315
|
-
"number",
|
|
316
|
-
"boolean",
|
|
317
|
-
"any",
|
|
318
|
-
"unknown",
|
|
319
|
-
"never",
|
|
320
|
-
"object"
|
|
321
|
-
]);
|
|
322
|
-
v(fe);
|
|
323
|
-
//#endregion
|
|
324
|
-
//#region src/grammars/css.ts
|
|
325
|
-
var pe = b({
|
|
326
|
-
name: "css",
|
|
327
|
-
states: {
|
|
328
|
-
default: [
|
|
329
|
-
{
|
|
330
|
-
match: /\/\*/,
|
|
331
|
-
kind: "comment",
|
|
332
|
-
push: "block"
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
match: /@[\w-]+/,
|
|
336
|
-
kind: "keyword"
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
match: /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/,
|
|
340
|
-
kind: "string"
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
match: /#[0-9a-fA-F]{3,8}\b/,
|
|
344
|
-
kind: "number"
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
match: /-?\d+(?:\.\d+)?(?:px|rem|em|%|vh|vw|s|ms|deg|fr|ch|ex)?/,
|
|
348
|
-
kind: "number"
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
match: /--[\w-]+/,
|
|
352
|
-
kind: "variable"
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
match: /[.#][\w-]+/,
|
|
356
|
-
kind: "tag"
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
match: /&|::?[\w-]+/,
|
|
360
|
-
kind: "tag"
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
match: /[\w-]+(?=\s*:)/,
|
|
364
|
-
kind: "property"
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
match: /[\w-]+(?=\s*\()/,
|
|
368
|
-
kind: "function"
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
match: /[{}();,:]/,
|
|
372
|
-
kind: "punctuation"
|
|
373
|
-
}
|
|
374
|
-
],
|
|
375
|
-
block: [
|
|
376
|
-
{
|
|
377
|
-
match: /\*\//,
|
|
378
|
-
kind: "comment",
|
|
379
|
-
pop: !0
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
match: /[^*]+/,
|
|
383
|
-
kind: "comment"
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
match: /\*/,
|
|
387
|
-
kind: "comment"
|
|
388
|
-
}
|
|
389
|
-
]
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
v(pe);
|
|
393
|
-
//#endregion
|
|
394
|
-
//#region src/grammars/html.ts
|
|
395
|
-
var S = b({
|
|
396
|
-
name: "html",
|
|
397
|
-
states: {
|
|
398
|
-
default: [
|
|
399
|
-
{
|
|
400
|
-
match: /<!--/,
|
|
401
|
-
kind: "comment",
|
|
402
|
-
push: "comment"
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
match: /<!?\/?[A-Za-z][\w-]*/,
|
|
406
|
-
kind: "tag",
|
|
407
|
-
push: "tag"
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
match: /&[a-zA-Z#0-9]+;/,
|
|
411
|
-
kind: "boolean"
|
|
412
|
-
}
|
|
413
|
-
],
|
|
414
|
-
comment: [
|
|
415
|
-
{
|
|
416
|
-
match: /-->/,
|
|
417
|
-
kind: "comment",
|
|
418
|
-
pop: !0
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
match: /[^-]+/,
|
|
422
|
-
kind: "comment"
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
match: /-/,
|
|
426
|
-
kind: "comment"
|
|
427
|
-
}
|
|
428
|
-
],
|
|
429
|
-
tag: [
|
|
430
|
-
{
|
|
431
|
-
match: /\/?>/,
|
|
432
|
-
kind: "tag",
|
|
433
|
-
pop: !0
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
match: /"(?:[^"\\]|\\.)*"|'[^']*'/,
|
|
437
|
-
kind: "string"
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
match: /[\w-]+(?=\s*=)/,
|
|
441
|
-
kind: "attr"
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
match: /=/,
|
|
445
|
-
kind: "operator"
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
match: /[\w-]+/,
|
|
449
|
-
kind: "attr"
|
|
450
|
-
}
|
|
451
|
-
]
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
v(S);
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/grammars/markdown.ts
|
|
457
|
-
var me = b({
|
|
458
|
-
name: "markdown",
|
|
459
|
-
states: {
|
|
460
|
-
default: [
|
|
461
|
-
{
|
|
462
|
-
match: /^```.*/,
|
|
463
|
-
kind: "keyword",
|
|
464
|
-
push: "fence"
|
|
465
|
-
},
|
|
466
|
-
{
|
|
467
|
-
match: /^~~~.*/,
|
|
468
|
-
kind: "keyword",
|
|
469
|
-
push: "fenceTilde"
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
match: /^\s*([-*_])(?:[ \t]*\1){2,}[ \t]*$/,
|
|
473
|
-
kind: "comment"
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
match: /^#{1,6}\s.*/,
|
|
477
|
-
kind: "keyword"
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
match: /^\s*[-*+]\s+\[[ xX]\]/,
|
|
481
|
-
kind: "boolean"
|
|
482
|
-
},
|
|
483
|
-
{
|
|
484
|
-
match: /^\s*(?:[-*+]|\d+\.)\s/,
|
|
485
|
-
kind: "operator"
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
match: /^\s*>\s?.*/,
|
|
489
|
-
kind: "comment"
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
match: /`[^`]+`/,
|
|
493
|
-
kind: "string"
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
match: /~~[^~]+~~/,
|
|
497
|
-
kind: "comment"
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
match: /\*\*[^*]+\*\*|__[^_]+__/,
|
|
501
|
-
kind: "keyword"
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
match: /\*[^*\s][^*]*\*|_[^_\s][^_]*_/,
|
|
505
|
-
kind: "type"
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
match: /!?\[[^\]]*\]\([^)]*\)/,
|
|
509
|
-
kind: "function"
|
|
510
|
-
}
|
|
511
|
-
],
|
|
512
|
-
fence: [{
|
|
513
|
-
match: /^```.*/,
|
|
514
|
-
kind: "keyword",
|
|
515
|
-
pop: !0
|
|
516
|
-
}, {
|
|
517
|
-
match: /.+/,
|
|
518
|
-
kind: "string"
|
|
519
|
-
}],
|
|
520
|
-
fenceTilde: [{
|
|
521
|
-
match: /^~~~.*/,
|
|
522
|
-
kind: "keyword",
|
|
523
|
-
pop: !0
|
|
524
|
-
}, {
|
|
525
|
-
match: /.+/,
|
|
526
|
-
kind: "string"
|
|
527
|
-
}]
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
v(me);
|
|
531
|
-
//#endregion
|
|
532
|
-
//#region src/grammars/bash.ts
|
|
533
|
-
var he = b({
|
|
534
|
-
name: "bash",
|
|
535
|
-
states: { default: [
|
|
536
|
-
{
|
|
537
|
-
match: /#.*/,
|
|
538
|
-
kind: "comment"
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
match: /"(?:[^"\\]|\\.)*"/,
|
|
542
|
-
kind: "string"
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
match: /'[^']*'/,
|
|
546
|
-
kind: "string"
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
match: /\b(?:if|then|else|elif|fi|for|while|until|do|done|case|esac|in|function|select|return|exit|break|continue|local|export|readonly|declare|echo|cd|source|set|unset)\b/,
|
|
550
|
-
kind: "keyword"
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
match: /\$\{[^}]*\}|\$[A-Za-z_]\w*|\$[0-9@*#?$!]/,
|
|
554
|
-
kind: "variable"
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
match: /-?\b\d+\b/,
|
|
558
|
-
kind: "number"
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
match: /[A-Za-z_][\w-]*(?=\s*\(\s*\))/,
|
|
562
|
-
kind: "function"
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
match: /[|&;<>()]+|&&|\|\||=/,
|
|
566
|
-
kind: "operator"
|
|
567
|
-
}
|
|
568
|
-
] }
|
|
569
|
-
});
|
|
570
|
-
v(he);
|
|
571
|
-
var C = {
|
|
572
|
-
root: "_root_1m6ns_2",
|
|
573
|
-
gutter: "_gutter_1m6ns_17",
|
|
574
|
-
gutterLine: "_gutterLine_1m6ns_28",
|
|
575
|
-
gutterActive: "_gutterActive_1m6ns_35",
|
|
576
|
-
pre: "_pre_1m6ns_45",
|
|
577
|
-
code: "_code_1m6ns_57",
|
|
578
|
-
line: "_line_1m6ns_62",
|
|
579
|
-
plain: "_plain_1m6ns_77",
|
|
580
|
-
keyword: "_keyword_1m6ns_80",
|
|
581
|
-
string: "_string_1m6ns_83",
|
|
582
|
-
number: "_number_1m6ns_86",
|
|
583
|
-
comment: "_comment_1m6ns_89",
|
|
584
|
-
function: "_function_1m6ns_93",
|
|
585
|
-
type: "_type_1m6ns_96",
|
|
586
|
-
operator: "_operator_1m6ns_99",
|
|
587
|
-
punctuation: "_punctuation_1m6ns_102",
|
|
588
|
-
variable: "_variable_1m6ns_105",
|
|
589
|
-
tag: "_tag_1m6ns_108",
|
|
590
|
-
attr: "_attr_1m6ns_111",
|
|
591
|
-
regexp: "_regexp_1m6ns_114",
|
|
592
|
-
boolean: "_boolean_1m6ns_117",
|
|
593
|
-
property: "_property_1m6ns_120",
|
|
594
|
-
match: "_match_1m6ns_125",
|
|
595
|
-
matchCurrent: "_matchCurrent_1m6ns_129",
|
|
596
|
-
bracketMatch: "_bracketMatch_1m6ns_133"
|
|
597
|
-
};
|
|
598
|
-
//#endregion
|
|
599
|
-
//#region src/editor/view.tsx
|
|
600
|
-
function ge(e, t) {
|
|
601
|
-
let n = "";
|
|
602
|
-
for (let r of t) e >= r.start && e < r.end && (n = n ? `${n} ${r.className}` : r.className);
|
|
603
|
-
return n;
|
|
604
|
-
}
|
|
605
|
-
function _e(t, n, r, i) {
|
|
606
|
-
let a = n + t.value.length, o = new Set([n, a]);
|
|
607
|
-
for (let e of r) e.start > n && e.start < a && o.add(e.start), e.end > n && e.end < a && o.add(e.end);
|
|
608
|
-
if (o.size === 2) {
|
|
609
|
-
let a = ge(n, r);
|
|
610
|
-
return /* @__PURE__ */ f("span", {
|
|
611
|
-
className: a ? e(C[t.kind], a) : C[t.kind],
|
|
612
|
-
children: t.value
|
|
613
|
-
}, i);
|
|
614
|
-
}
|
|
615
|
-
let s = [...o].sort((e, t) => e - t), c = [];
|
|
616
|
-
for (let i = 0; i < s.length - 1; i++) {
|
|
617
|
-
let a = s[i], o = s[i + 1], l = ge(a, r);
|
|
618
|
-
c.push(/* @__PURE__ */ f("span", {
|
|
619
|
-
className: l ? e(C[t.kind], l) : C[t.kind],
|
|
620
|
-
children: t.value.slice(a - n, o - n)
|
|
621
|
-
}, a));
|
|
622
|
-
}
|
|
623
|
-
return /* @__PURE__ */ f("span", { children: c }, i);
|
|
624
|
-
}
|
|
625
|
-
function ve(e, t = 0, n = t + e.length, r) {
|
|
626
|
-
let i = [];
|
|
627
|
-
for (let a = t; a < n; a++) {
|
|
628
|
-
let n = e[a - t], o = r?.filter((e) => e.line === a);
|
|
629
|
-
i.push(/* @__PURE__ */ f("span", {
|
|
630
|
-
className: C.line,
|
|
631
|
-
children: n.length === 0 ? "" : o && o.length > 0 ? (() => {
|
|
632
|
-
let e = 0;
|
|
633
|
-
return n.map((t, n) => {
|
|
634
|
-
let r = _e(t, e, o, n);
|
|
635
|
-
return e += t.value.length, r;
|
|
636
|
-
});
|
|
637
|
-
})() : n.map((e, t) => /* @__PURE__ */ f("span", {
|
|
638
|
-
className: C[e.kind],
|
|
639
|
-
children: e.value
|
|
640
|
-
}, t))
|
|
641
|
-
}, a));
|
|
642
|
-
}
|
|
643
|
-
return i;
|
|
644
|
-
}
|
|
645
|
-
function ye({ count: e, className: t, gutterRef: n, start: r = 0, end: i = e, topPad: a = 0, bottomPad: o = 0, activeLine: s = !1 }) {
|
|
646
|
-
let c = [];
|
|
647
|
-
for (let e = r + 1; e <= i; e++) c.push(/* @__PURE__ */ f("span", {
|
|
648
|
-
className: C.gutterLine,
|
|
649
|
-
children: e
|
|
650
|
-
}, e));
|
|
651
|
-
return /* @__PURE__ */ p("div", {
|
|
652
|
-
ref: n,
|
|
653
|
-
className: t,
|
|
654
|
-
"aria-hidden": "true",
|
|
655
|
-
children: [
|
|
656
|
-
s && /* @__PURE__ */ f("div", { className: C.gutterActive }),
|
|
657
|
-
a > 0 && /* @__PURE__ */ f("div", { style: { blockSize: a } }),
|
|
658
|
-
c,
|
|
659
|
-
o > 0 && /* @__PURE__ */ f("div", { style: { blockSize: o } })
|
|
660
|
-
]
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
var w = {
|
|
664
|
-
root: "_root_18xci_2",
|
|
665
|
-
textarea: "_textarea_18xci_18",
|
|
666
|
-
gutter: "_gutter_18xci_23",
|
|
667
|
-
codeArea: "_codeArea_18xci_36",
|
|
668
|
-
pre: "_pre_18xci_43",
|
|
669
|
-
currentLine: "_currentLine_18xci_58"
|
|
670
|
-
}, T = {
|
|
671
|
-
panel: "_panel_hawkv_2",
|
|
672
|
-
row: "_row_hawkv_20",
|
|
673
|
-
input: "_input_hawkv_26",
|
|
674
|
-
count: "_count_hawkv_44",
|
|
675
|
-
button: "_button_hawkv_52",
|
|
676
|
-
toggle: "_toggle_hawkv_53",
|
|
677
|
-
active: "_active_hawkv_80"
|
|
678
|
-
};
|
|
679
|
-
//#endregion
|
|
680
|
-
//#region src/editor/code-editor/find-panel.tsx
|
|
681
|
-
function be(t) {
|
|
682
|
-
o();
|
|
683
|
-
let n = t.matchCount === 0 ? c(s.editor.noMatches) : c(s.editor.findCount, {
|
|
684
|
-
current: t.currentIndex + 1,
|
|
685
|
-
total: t.matchCount
|
|
686
|
-
});
|
|
687
|
-
return /* @__PURE__ */ p("div", {
|
|
688
|
-
className: T.panel,
|
|
689
|
-
role: "search",
|
|
690
|
-
"aria-label": c(s.editor.find),
|
|
691
|
-
children: [/* @__PURE__ */ p("div", {
|
|
692
|
-
className: T.row,
|
|
693
|
-
children: [
|
|
694
|
-
/* @__PURE__ */ f("button", {
|
|
695
|
-
type: "button",
|
|
696
|
-
className: T.toggle,
|
|
697
|
-
"aria-label": c(s.editor.toggleReplace),
|
|
698
|
-
"aria-expanded": t.replaceMode,
|
|
699
|
-
onClick: t.onToggleReplace,
|
|
700
|
-
children: t.replaceMode ? "▾" : "▸"
|
|
701
|
-
}),
|
|
702
|
-
/* @__PURE__ */ f("input", {
|
|
703
|
-
className: T.input,
|
|
704
|
-
value: t.query,
|
|
705
|
-
placeholder: c(s.editor.findPlaceholder),
|
|
706
|
-
"aria-label": c(s.editor.find),
|
|
707
|
-
autoFocus: !0,
|
|
708
|
-
autoComplete: "off",
|
|
709
|
-
spellCheck: !1,
|
|
710
|
-
onChange: (e) => t.onQueryChange(e.currentTarget.value),
|
|
711
|
-
onKeyDown: (e) => {
|
|
712
|
-
e.key === "Enter" ? (e.preventDefault(), e.shiftKey ? t.onPrev() : t.onNext()) : e.key === "Escape" && (e.preventDefault(), t.onClose());
|
|
713
|
-
}
|
|
714
|
-
}),
|
|
715
|
-
/* @__PURE__ */ f("span", {
|
|
716
|
-
className: T.count,
|
|
717
|
-
"aria-live": "polite",
|
|
718
|
-
children: n
|
|
719
|
-
}),
|
|
720
|
-
/* @__PURE__ */ f("button", {
|
|
721
|
-
type: "button",
|
|
722
|
-
className: T.button,
|
|
723
|
-
"aria-label": c(s.editor.previous),
|
|
724
|
-
onClick: t.onPrev,
|
|
725
|
-
children: "‹"
|
|
726
|
-
}),
|
|
727
|
-
/* @__PURE__ */ f("button", {
|
|
728
|
-
type: "button",
|
|
729
|
-
className: T.button,
|
|
730
|
-
"aria-label": c(s.editor.next),
|
|
731
|
-
onClick: t.onNext,
|
|
732
|
-
children: "›"
|
|
733
|
-
}),
|
|
734
|
-
/* @__PURE__ */ f("button", {
|
|
735
|
-
type: "button",
|
|
736
|
-
className: e(T.button, t.caseSensitive && T.active),
|
|
737
|
-
"aria-pressed": t.caseSensitive,
|
|
738
|
-
"aria-label": c(s.editor.matchCase),
|
|
739
|
-
onClick: t.onToggleCase,
|
|
740
|
-
children: "Aa"
|
|
741
|
-
}),
|
|
742
|
-
/* @__PURE__ */ f("button", {
|
|
743
|
-
type: "button",
|
|
744
|
-
className: T.button,
|
|
745
|
-
"aria-label": c(s.editor.close),
|
|
746
|
-
onClick: t.onClose,
|
|
747
|
-
children: "×"
|
|
748
|
-
})
|
|
749
|
-
]
|
|
750
|
-
}), t.replaceMode && /* @__PURE__ */ p("div", {
|
|
751
|
-
className: T.row,
|
|
752
|
-
children: [
|
|
753
|
-
/* @__PURE__ */ f("input", {
|
|
754
|
-
className: T.input,
|
|
755
|
-
value: t.replaceQuery,
|
|
756
|
-
placeholder: c(s.editor.replacePlaceholder),
|
|
757
|
-
"aria-label": c(s.editor.replace),
|
|
758
|
-
autoComplete: "off",
|
|
759
|
-
spellCheck: !1,
|
|
760
|
-
onChange: (e) => t.onReplaceChange(e.currentTarget.value),
|
|
761
|
-
onKeyDown: (e) => {
|
|
762
|
-
e.key === "Escape" ? (e.preventDefault(), t.onClose()) : e.key === "Enter" && (e.preventDefault(), t.onReplace());
|
|
763
|
-
}
|
|
764
|
-
}),
|
|
765
|
-
/* @__PURE__ */ f("button", {
|
|
766
|
-
type: "button",
|
|
767
|
-
className: T.button,
|
|
768
|
-
onClick: t.onReplace,
|
|
769
|
-
children: c(s.editor.replaceOne)
|
|
770
|
-
}),
|
|
771
|
-
/* @__PURE__ */ f("button", {
|
|
772
|
-
type: "button",
|
|
773
|
-
className: T.button,
|
|
774
|
-
onClick: t.onReplaceAll,
|
|
775
|
-
children: c(s.editor.replaceAll)
|
|
776
|
-
})
|
|
777
|
-
]
|
|
778
|
-
})]
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
//#endregion
|
|
782
|
-
//#region src/editor/code-editor/find.ts
|
|
783
|
-
var xe = /\w/;
|
|
784
|
-
function E(e) {
|
|
785
|
-
return e !== void 0 && xe.test(e);
|
|
786
|
-
}
|
|
787
|
-
function Se(e, t, n = {}) {
|
|
788
|
-
if (t.length === 0) return [];
|
|
789
|
-
let r = n.caseSensitive ? e : e.toLowerCase(), i = n.caseSensitive ? t : t.toLowerCase(), a = [], o = 0;
|
|
790
|
-
for (;;) {
|
|
791
|
-
let t = r.indexOf(i, o);
|
|
792
|
-
if (t === -1) break;
|
|
793
|
-
let s = t + i.length;
|
|
794
|
-
(!n.wholeWord || !E(e[t - 1]) && !E(e[s])) && a.push({
|
|
795
|
-
start: t,
|
|
796
|
-
end: s
|
|
797
|
-
}), o = s > t ? s : t + 1;
|
|
798
|
-
}
|
|
799
|
-
return a;
|
|
800
|
-
}
|
|
801
|
-
function Ce(e, t) {
|
|
802
|
-
let n = 0, r = 0;
|
|
803
|
-
for (let i = 0; i < t && i < e.length; i++) e[i] === "\n" && (n++, r = i + 1);
|
|
804
|
-
return {
|
|
805
|
-
line: n,
|
|
806
|
-
col: t - r
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
function we(e, t, n, r) {
|
|
810
|
-
return t.map((t, i) => {
|
|
811
|
-
let { line: a, col: o } = Ce(e, t.start);
|
|
812
|
-
return {
|
|
813
|
-
line: a,
|
|
814
|
-
start: o,
|
|
815
|
-
end: o + (t.end - t.start),
|
|
816
|
-
className: i === n ? r.current : r.match
|
|
817
|
-
};
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
function Te(e, t, n) {
|
|
821
|
-
let r = e;
|
|
822
|
-
for (let e = t.length - 1; e >= 0; e--) {
|
|
823
|
-
let i = t[e];
|
|
824
|
-
r = r.slice(0, i.start) + n + r.slice(i.end);
|
|
825
|
-
}
|
|
826
|
-
return r;
|
|
827
|
-
}
|
|
828
|
-
//#endregion
|
|
829
|
-
//#region src/editor/code-editor/brackets.ts
|
|
830
|
-
var D = {
|
|
831
|
-
"(": ")",
|
|
832
|
-
"[": "]",
|
|
833
|
-
"{": "}"
|
|
834
|
-
}, O = {
|
|
835
|
-
")": "(",
|
|
836
|
-
"]": "[",
|
|
837
|
-
"}": "}"
|
|
838
|
-
};
|
|
839
|
-
function k(e, t, n, r) {
|
|
840
|
-
let i = 0;
|
|
841
|
-
for (let a = t; a < e.length; a++) {
|
|
842
|
-
let t = e[a];
|
|
843
|
-
if (t === n) i++;
|
|
844
|
-
else if (t === r && --i === 0) return a;
|
|
845
|
-
}
|
|
846
|
-
return -1;
|
|
847
|
-
}
|
|
848
|
-
function A(e, t, n, r) {
|
|
849
|
-
let i = 0;
|
|
850
|
-
for (let a = t; a >= 0; a--) {
|
|
851
|
-
let t = e[a];
|
|
852
|
-
if (t === r) i++;
|
|
853
|
-
else if (t === n && --i === 0) return a;
|
|
854
|
-
}
|
|
855
|
-
return -1;
|
|
856
|
-
}
|
|
857
|
-
function Ee(e, t) {
|
|
858
|
-
let n = e[t];
|
|
859
|
-
if (n && n in D) {
|
|
860
|
-
let r = k(e, t, n, D[n]);
|
|
861
|
-
if (r !== -1) return {
|
|
862
|
-
open: t,
|
|
863
|
-
close: r
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
let r = e[t - 1];
|
|
867
|
-
if (r && r in O) {
|
|
868
|
-
let n = A(e, t - 1, O[r], r);
|
|
869
|
-
if (n !== -1) return {
|
|
870
|
-
open: n,
|
|
871
|
-
close: t - 1
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
if (r && r in D) {
|
|
875
|
-
let n = k(e, t - 1, r, D[r]);
|
|
876
|
-
if (n !== -1) return {
|
|
877
|
-
open: t - 1,
|
|
878
|
-
close: n
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
if (n && n in O) {
|
|
882
|
-
let r = A(e, t, O[n], n);
|
|
883
|
-
if (r !== -1) return {
|
|
884
|
-
open: r,
|
|
885
|
-
close: t
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
function De(e, t, n) {
|
|
890
|
-
return [t.open, t.close].map((t) => {
|
|
891
|
-
let { line: r, col: i } = Ce(e, t);
|
|
892
|
-
return {
|
|
893
|
-
line: r,
|
|
894
|
-
start: i,
|
|
895
|
-
end: i + 1,
|
|
896
|
-
className: n
|
|
897
|
-
};
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
//#endregion
|
|
901
|
-
//#region src/editor/code-editor/history.ts
|
|
902
|
-
function Oe(e = 200) {
|
|
903
|
-
let t = [], n = -1, r = !1;
|
|
904
|
-
return {
|
|
905
|
-
record(i, a) {
|
|
906
|
-
let o = a?.coalesce ?? !1;
|
|
907
|
-
n < t.length - 1 && (t = t.slice(0, n + 1)), o && r && n >= 0 ? t[n] = i : (t.push(i), n = t.length - 1, t.length > e && (t.shift(), n--)), r = o;
|
|
908
|
-
},
|
|
909
|
-
undo() {
|
|
910
|
-
if (!(n <= 0)) return n--, r = !1, t[n];
|
|
911
|
-
},
|
|
912
|
-
redo() {
|
|
913
|
-
if (!(n >= t.length - 1)) return n++, r = !1, t[n];
|
|
914
|
-
},
|
|
915
|
-
reset(e) {
|
|
916
|
-
t = [e], n = 0, r = !1;
|
|
917
|
-
},
|
|
918
|
-
canUndo() {
|
|
919
|
-
return n > 0;
|
|
920
|
-
},
|
|
921
|
-
canRedo() {
|
|
922
|
-
return n < t.length - 1;
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
//#endregion
|
|
927
|
-
//#region src/editor/code-editor/keymap.ts
|
|
928
|
-
var j = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
|
|
929
|
-
function ke(e) {
|
|
930
|
-
let t = [];
|
|
931
|
-
(j ? e.metaKey : e.ctrlKey) && t.push("Mod"), e.altKey && t.push("Alt"), e.shiftKey && t.push("Shift");
|
|
932
|
-
let n = e.key;
|
|
933
|
-
return n.length === 1 && (n = n.toLowerCase()), t.push(n), t.join("-");
|
|
934
|
-
}
|
|
935
|
-
function Ae(e, t) {
|
|
936
|
-
let n = new Map(Object.entries(e));
|
|
937
|
-
if (t) for (let [e, r] of Object.entries(t)) n.set(e, r);
|
|
938
|
-
return n;
|
|
939
|
-
}
|
|
940
|
-
function je(e, t) {
|
|
941
|
-
let n = e.get(ke(t.event));
|
|
942
|
-
return n ? n(t) : !1;
|
|
943
|
-
}
|
|
944
|
-
function Me(e) {
|
|
945
|
-
let t = () => e.insertSpaces ? " ".repeat(e.tabSize) : " ";
|
|
946
|
-
return {
|
|
947
|
-
indent: ({ textarea: e, setText: n }) => {
|
|
948
|
-
let { selectionStart: r, selectionEnd: i, value: a } = e, o = a.lastIndexOf("\n", r - 1) + 1;
|
|
949
|
-
if (r === i) e.setRangeText(t(), r, i, "end");
|
|
950
|
-
else {
|
|
951
|
-
let n = a.slice(o, i).replace(/^/gm, t());
|
|
952
|
-
e.setRangeText(n, o, i, "select");
|
|
953
|
-
}
|
|
954
|
-
return n(e.value), !0;
|
|
955
|
-
},
|
|
956
|
-
dedent: ({ textarea: t, setText: n }) => {
|
|
957
|
-
let { selectionStart: r, selectionEnd: i, value: a } = t, o = a.lastIndexOf("\n", r - 1) + 1, s = a.slice(o, i).replace(RegExp(`^(?:\\t| {1,${e.tabSize}})`, "gm"), "");
|
|
958
|
-
return t.setRangeText(s, o, i, "select"), n(t.value), !0;
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
//#endregion
|
|
963
|
-
//#region src/editor/code-editor/sync.ts
|
|
964
|
-
function Ne(e, t) {
|
|
965
|
-
if (e === t) return {
|
|
966
|
-
from: e.length,
|
|
967
|
-
to: e.length,
|
|
968
|
-
insert: ""
|
|
969
|
-
};
|
|
970
|
-
let n = Math.min(e.length, t.length), r = 0;
|
|
971
|
-
for (; r < n && e[r] === t[r];) r++;
|
|
972
|
-
let i = e.length, a = t.length;
|
|
973
|
-
for (; i > r && a > r && e[i - 1] === t[a - 1];) i--, a--;
|
|
974
|
-
return {
|
|
975
|
-
from: r,
|
|
976
|
-
to: i,
|
|
977
|
-
insert: t.slice(r, a)
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
function M(e, t) {
|
|
981
|
-
return e <= t.from ? e : e >= t.to ? e + (t.insert.length - (t.to - t.from)) : t.from + t.insert.length;
|
|
982
|
-
}
|
|
983
|
-
function Pe(e, t, n) {
|
|
984
|
-
return {
|
|
985
|
-
start: M(e, n),
|
|
986
|
-
end: M(t, n)
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
//#endregion
|
|
990
|
-
//#region src/editor/code-editor/caret.ts
|
|
991
|
-
function N(e, t) {
|
|
992
|
-
let n = 0;
|
|
993
|
-
for (let r of e) r === " " ? n += t - n % t : n += 1;
|
|
994
|
-
return n;
|
|
995
|
-
}
|
|
996
|
-
function Fe(e, t, n) {
|
|
997
|
-
let { line: r, col: i } = Ce(e, t), a = N(e.slice(t - i, t), n.tabSize);
|
|
998
|
-
return {
|
|
999
|
-
top: r * n.lineHeight - n.scrollTop + n.padTop,
|
|
1000
|
-
left: a * n.charWidth - n.scrollLeft + n.padLeft
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
function Ie(e, t) {
|
|
1004
|
-
if (typeof document > "u") return null;
|
|
1005
|
-
let n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0, i = n.nextNode();
|
|
1006
|
-
for (; i;) {
|
|
1007
|
-
let e = i.textContent?.length ?? 0;
|
|
1008
|
-
if (t <= r + e) {
|
|
1009
|
-
let e = document.createRange();
|
|
1010
|
-
e.setStart(i, Math.max(0, t - r)), e.collapse(!0);
|
|
1011
|
-
let n = e.getClientRects();
|
|
1012
|
-
return n.length > 0 ? n[0] : e.getBoundingClientRect();
|
|
1013
|
-
}
|
|
1014
|
-
r += e, i = n.nextNode();
|
|
1015
|
-
}
|
|
1016
|
-
return null;
|
|
1017
|
-
}
|
|
1018
|
-
function Le(e) {
|
|
1019
|
-
if (typeof document > "u") return 0;
|
|
1020
|
-
let t = getComputedStyle(e), n = document.createElement("span");
|
|
1021
|
-
n.style.position = "absolute", n.style.visibility = "hidden", n.style.whiteSpace = "pre", n.style.font = t.font, n.style.letterSpacing = t.letterSpacing, n.style.tabSize = t.tabSize, n.textContent = "0".repeat(10), document.body.appendChild(n);
|
|
1022
|
-
let r = n.getBoundingClientRect().width / 10;
|
|
1023
|
-
return n.remove(), r;
|
|
1024
|
-
}
|
|
1025
|
-
//#endregion
|
|
1026
|
-
//#region src/editor/code-editor/slash-trigger.ts
|
|
1027
|
-
function Re(e, t) {
|
|
1028
|
-
for (let n = t - 1; n >= 0; n--) {
|
|
1029
|
-
let r = e[n];
|
|
1030
|
-
if (r === "/") {
|
|
1031
|
-
let r = e[n - 1];
|
|
1032
|
-
return r === void 0 || /\s/.test(r) ? {
|
|
1033
|
-
start: n,
|
|
1034
|
-
query: e.slice(n + 1, t)
|
|
1035
|
-
} : null;
|
|
1036
|
-
}
|
|
1037
|
-
if (r === void 0 || /\s/.test(r)) return null;
|
|
1038
|
-
}
|
|
1039
|
-
return null;
|
|
1040
|
-
}
|
|
1041
|
-
function ze(e, t) {
|
|
1042
|
-
if (t === "") return [...e];
|
|
1043
|
-
let n = t.toLowerCase();
|
|
1044
|
-
return e.filter((e) => e.label.toLowerCase().includes(n) || (e.keywords?.some((e) => e.toLowerCase().includes(n)) ?? !1));
|
|
1045
|
-
}
|
|
1046
|
-
var P = {
|
|
1047
|
-
menu: "_menu_zkolh_2",
|
|
1048
|
-
option: "_option_zkolh_24",
|
|
1049
|
-
active: "_active_zkolh_35",
|
|
1050
|
-
label: "_label_zkolh_39",
|
|
1051
|
-
hint: "_hint_zkolh_44",
|
|
1052
|
-
empty: "_empty_zkolh_50"
|
|
1053
|
-
}, Be = l(function({ id: t, items: n, activeIndex: r, onSelect: i, onHover: a, style: l }, u) {
|
|
1054
|
-
return o(), /* @__PURE__ */ f("ul", {
|
|
1055
|
-
ref: u,
|
|
1056
|
-
id: t,
|
|
1057
|
-
className: P.menu,
|
|
1058
|
-
role: "listbox",
|
|
1059
|
-
"aria-label": c(s.editor.commandMenu),
|
|
1060
|
-
style: l,
|
|
1061
|
-
children: n.length === 0 ? /* @__PURE__ */ f("li", {
|
|
1062
|
-
className: P.empty,
|
|
1063
|
-
role: "presentation",
|
|
1064
|
-
children: c(s.editor.commandMenuEmpty)
|
|
1065
|
-
}) : n.map((n, o) => /* @__PURE__ */ p("li", {
|
|
1066
|
-
id: `${t}-opt-${o}`,
|
|
1067
|
-
role: "option",
|
|
1068
|
-
"aria-selected": o === r,
|
|
1069
|
-
className: e(P.option, o === r && P.active),
|
|
1070
|
-
onMouseEnter: () => a(o),
|
|
1071
|
-
onMouseDown: (e) => {
|
|
1072
|
-
e.preventDefault(), i(o);
|
|
1073
|
-
},
|
|
1074
|
-
children: [/* @__PURE__ */ f("span", {
|
|
1075
|
-
className: P.label,
|
|
1076
|
-
children: n.label
|
|
1077
|
-
}), n.hint !== void 0 && /* @__PURE__ */ f("span", {
|
|
1078
|
-
className: P.hint,
|
|
1079
|
-
children: n.hint
|
|
1080
|
-
})]
|
|
1081
|
-
}, n.id))
|
|
1082
|
-
});
|
|
1083
|
-
}), Ve = 2e3, He = l(function({ value: l, defaultValue: ee, onValueChange: te, language: ne = "plaintext", lineNumbers: m = !0, tabSize: h = 2, insertSpaces: g = !0, wrap: _ = !1, virtualize: v, readOnly: y = !1, disabled: b = !1, spellCheck: se = !1, label: ce, ariaLabel: le, onSave: ue, keymap: de, decorations: x, theme: fe, bracketMatching: pe = !1, commands: S, className: me, style: he, onKeyDown: ge, ..._e }, T) {
|
|
1084
|
-
o();
|
|
1085
|
-
let xe = d(ue);
|
|
1086
|
-
xe.current = ue;
|
|
1087
|
-
let [E, D] = n({
|
|
1088
|
-
value: l,
|
|
1089
|
-
defaultValue: ee ?? "",
|
|
1090
|
-
onChange: te
|
|
1091
|
-
}), O = d(null), k = d(null), A = d(null), j = d(null), ke = d([]), M = d(null);
|
|
1092
|
-
M.current === null && (M.current = Oe(), M.current.reset({
|
|
1093
|
-
text: E.value,
|
|
1094
|
-
selectionStart: 0,
|
|
1095
|
-
selectionEnd: 0
|
|
1096
|
-
}));
|
|
1097
|
-
let N = M.current, P = d(null), He = d(void 0), F = d(E.value), Ue = d(void 0), I = d(!1), L = d({
|
|
1098
|
-
start: 0,
|
|
1099
|
-
end: 0
|
|
1100
|
-
}), R = (e, t, n) => {
|
|
1101
|
-
Ue.current = e, F.current = e, N.record({
|
|
1102
|
-
text: e,
|
|
1103
|
-
selectionStart: t.start,
|
|
1104
|
-
selectionEnd: t.end
|
|
1105
|
-
}, { coalesce: n }), D(e);
|
|
1106
|
-
}, We = (e) => {
|
|
1107
|
-
let t = j.current;
|
|
1108
|
-
R(e, t ? {
|
|
1109
|
-
start: t.selectionStart,
|
|
1110
|
-
end: t.selectionEnd
|
|
1111
|
-
} : L.current, !1);
|
|
1112
|
-
}, Ge = (e) => {
|
|
1113
|
-
let t = j.current;
|
|
1114
|
-
if (!t) return;
|
|
1115
|
-
I.current = !0, t.value = e.text, t.setSelectionRange(e.selectionStart, e.selectionEnd), D(e.text), Ue.current = e.text, F.current = e.text, L.current = {
|
|
1116
|
-
start: e.selectionStart,
|
|
1117
|
-
end: e.selectionEnd
|
|
1118
|
-
}, U.value = e.selectionStart;
|
|
1119
|
-
let n = e.text.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1120
|
-
O.current?.style.setProperty("--cascivo-editor-caret-line", String(n)), I.current = !1;
|
|
1121
|
-
}, Ke = () => {
|
|
1122
|
-
let e = N.undo();
|
|
1123
|
-
e && Ge(e);
|
|
1124
|
-
}, qe = () => {
|
|
1125
|
-
let e = N.redo();
|
|
1126
|
-
e && Ge(e);
|
|
1127
|
-
}, z = i(E.value), Je = i(0), Ye = i(0), B = i(0), V = i(!1), Xe = i(""), Ze = i(""), Qe = i(!1), $e = i(!1), H = i(0), U = i(0), et = i(0), W = i(!1), tt = i(0), nt = i(""), G = i(0), rt = i(-1), it = i(0), at = d(null), ot = d(null), st = r("slash-menu");
|
|
1128
|
-
a(() => {
|
|
1129
|
-
let e = E.value;
|
|
1130
|
-
if (typeof requestAnimationFrame != "function") {
|
|
1131
|
-
z.value = e;
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
let t = requestAnimationFrame(() => {
|
|
1135
|
-
z.value = e;
|
|
1136
|
-
});
|
|
1137
|
-
return () => cancelAnimationFrame(t);
|
|
1138
|
-
}), a(() => {
|
|
1139
|
-
let e = E.value;
|
|
1140
|
-
if (I.current || e === F.current) return;
|
|
1141
|
-
if (e === Ue.current) {
|
|
1142
|
-
F.current = e;
|
|
1143
|
-
return;
|
|
1144
|
-
}
|
|
1145
|
-
let t = j.current, n = Ne(F.current, e), r = Pe(L.current.start, L.current.end, n);
|
|
1146
|
-
t && (I.current = !0, t.value !== e && (t.value = e), t.setSelectionRange(r.start, r.end), I.current = !1), L.current = r, N.reset({
|
|
1147
|
-
text: e,
|
|
1148
|
-
selectionStart: r.start,
|
|
1149
|
-
selectionEnd: r.end
|
|
1150
|
-
}), F.current = e;
|
|
1151
|
-
}), a(() => {
|
|
1152
|
-
let e = j.current;
|
|
1153
|
-
if (!e) return;
|
|
1154
|
-
let t = () => {
|
|
1155
|
-
let t = Number.parseFloat(getComputedStyle(e).lineHeight);
|
|
1156
|
-
B.value = Number.isFinite(t) && t > 0 ? t : 0, Ye.value = e.clientHeight;
|
|
1157
|
-
let n = Le(e);
|
|
1158
|
-
n > 0 && (it.value = n);
|
|
1159
|
-
}, n = () => {
|
|
1160
|
-
Je.value = e.scrollTop, Ye.value = e.clientHeight, k.current && (k.current.scrollTop = e.scrollTop, k.current.scrollLeft = e.scrollLeft), A.current && (A.current.scrollTop = e.scrollTop);
|
|
1161
|
-
}, r = () => {
|
|
1162
|
-
let t = e.value.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1163
|
-
O.current?.style.setProperty("--cascivo-editor-caret-line", String(t)), L.current = {
|
|
1164
|
-
start: e.selectionStart,
|
|
1165
|
-
end: e.selectionEnd
|
|
1166
|
-
}, U.value = e.selectionStart;
|
|
1167
|
-
}, i = () => {
|
|
1168
|
-
document.activeElement === e && r();
|
|
1169
|
-
}, a = 0, o = -1, s = () => {
|
|
1170
|
-
n(), e.scrollTop === o ? a = 0 : (o = e.scrollTop, a = requestAnimationFrame(s));
|
|
1171
|
-
}, c = () => {
|
|
1172
|
-
n(), a === 0 && typeof requestAnimationFrame == "function" && (o = -1, a = requestAnimationFrame(s));
|
|
1173
|
-
};
|
|
1174
|
-
t(), r(), e.addEventListener("scroll", c), e.addEventListener("keyup", r), e.addEventListener("click", r), e.addEventListener("input", r), document.addEventListener("selectionchange", i);
|
|
1175
|
-
let l;
|
|
1176
|
-
typeof ResizeObserver < "u" && (l = new ResizeObserver(() => {
|
|
1177
|
-
t(), n();
|
|
1178
|
-
}), l.observe(e));
|
|
1179
|
-
let u = !1, d = document.fonts;
|
|
1180
|
-
return d?.ready && d.ready.then(() => {
|
|
1181
|
-
u || t();
|
|
1182
|
-
}).catch(() => {}), () => {
|
|
1183
|
-
u = !0, a !== 0 && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(a), l?.disconnect(), e.removeEventListener("scroll", c), e.removeEventListener("keyup", r), e.removeEventListener("click", r), e.removeEventListener("input", r), document.removeEventListener("selectionchange", i);
|
|
1184
|
-
};
|
|
1185
|
-
}), a(() => {
|
|
1186
|
-
let e = U.value, t = E.value;
|
|
1187
|
-
if (!S || S.length === 0 || y || b) {
|
|
1188
|
-
W.value &&= !1;
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
let n = Re(t, e);
|
|
1192
|
-
if (!n) {
|
|
1193
|
-
rt.value = -1, W.value &&= !1;
|
|
1194
|
-
return;
|
|
1195
|
-
}
|
|
1196
|
-
if (n.start === rt.value) {
|
|
1197
|
-
W.value &&= !1;
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
W.value || (G.value = 0), W.value = !0, tt.value = n.start, nt.value = n.query;
|
|
1201
|
-
}), a(() => {
|
|
1202
|
-
if (!W.value) return;
|
|
1203
|
-
let e = at.current, t = j.current;
|
|
1204
|
-
if (!e || !t) return;
|
|
1205
|
-
let n = tt.value, r = e.offsetParent, i, a, o = k.current, s = (_ || E.value.includes(" ")) && o ? Ie(o, n) : null;
|
|
1206
|
-
if (s && r) {
|
|
1207
|
-
let e = r.getBoundingClientRect();
|
|
1208
|
-
i = s.bottom - e.top, a = s.left - e.left;
|
|
1209
|
-
} else {
|
|
1210
|
-
let e = getComputedStyle(t), r = Fe(E.value, n, {
|
|
1211
|
-
charWidth: it.value,
|
|
1212
|
-
lineHeight: B.value,
|
|
1213
|
-
scrollTop: t.scrollTop,
|
|
1214
|
-
scrollLeft: t.scrollLeft,
|
|
1215
|
-
padTop: Number.parseFloat(e.paddingTop) || 0,
|
|
1216
|
-
padLeft: Number.parseFloat(e.paddingLeft) || 0,
|
|
1217
|
-
tabSize: h
|
|
1218
|
-
});
|
|
1219
|
-
i = r.top + B.value, a = r.left;
|
|
1220
|
-
}
|
|
1221
|
-
e.style.top = `${i}px`, e.style.left = `${a}px`;
|
|
1222
|
-
});
|
|
1223
|
-
let K = oe(ne);
|
|
1224
|
-
(P.current === null || P.current.grammar !== K) && (P.current = ae(K), He.current = void 0);
|
|
1225
|
-
let q = P.current, ct = z.value.split("\n"), J = ct.length;
|
|
1226
|
-
ke.current = ct;
|
|
1227
|
-
let lt = z.value, ut = He.current;
|
|
1228
|
-
if (lt !== ut) {
|
|
1229
|
-
let e = ut === void 0 ? 0 : (() => {
|
|
1230
|
-
let e = Ne(ut, lt);
|
|
1231
|
-
return ut.slice(0, e.from).split("\n").length - 1;
|
|
1232
|
-
})();
|
|
1233
|
-
q.invalidateFrom(e), He.current = lt;
|
|
1234
|
-
}
|
|
1235
|
-
let dt = B.value > 0, Y = dt ? B.value : 20, ft = (v ?? J > 1e3) && !_, X = 0, Z = J;
|
|
1236
|
-
if (ft) if (dt) {
|
|
1237
|
-
X = Math.max(0, Math.floor(Je.value / Y) - 12);
|
|
1238
|
-
let e = Math.ceil(Ye.value / Y);
|
|
1239
|
-
Z = Math.min(J, X + e + 24);
|
|
1240
|
-
} else Z = Math.min(J, 200);
|
|
1241
|
-
let pt = ft && X > q.length ? X - q.length : 0, mt = !ft || X === 0 || q.length >= X || pt <= 2e3, ht;
|
|
1242
|
-
mt ? ht = re(K, ct, X, Z, q) : (et.value, ht = ie(K, ct, X, Z, K.initialState));
|
|
1243
|
-
let gt = X * Y, _t = (J - Z) * Y;
|
|
1244
|
-
a(() => {
|
|
1245
|
-
z.value, et.value;
|
|
1246
|
-
let e = B.value, t = ke.current, n = t.length;
|
|
1247
|
-
if (!((v ?? n > 1e3) && !_ && e > 0)) return;
|
|
1248
|
-
let r = Math.max(0, Math.floor(Je.value / e) - 12);
|
|
1249
|
-
if (r === 0 || q.length >= r || q.length >= n) return;
|
|
1250
|
-
let i = () => {
|
|
1251
|
-
q.ensure(t, Math.min(r - 1, q.length + Ve)), et.value++;
|
|
1252
|
-
};
|
|
1253
|
-
if (typeof requestAnimationFrame != "function") {
|
|
1254
|
-
i();
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
let a = requestAnimationFrame(i);
|
|
1258
|
-
return () => cancelAnimationFrame(a);
|
|
1259
|
-
});
|
|
1260
|
-
let Q = V.value ? Se(z.value, Xe.value, { caseSensitive: Qe.value }) : [];
|
|
1261
|
-
H.value >= Q.length && (H.value = Math.max(0, Q.length - 1));
|
|
1262
|
-
let vt = Q.length > 0 ? we(z.value, Q, H.value, {
|
|
1263
|
-
match: C.match,
|
|
1264
|
-
current: C.matchCurrent
|
|
1265
|
-
}) : [], yt = typeof x == "function" ? x(z.value) : x ?? [], bt = [];
|
|
1266
|
-
if (pe) {
|
|
1267
|
-
let e = Ee(z.value, U.value);
|
|
1268
|
-
e && (bt = De(z.value, e, C.bracketMatch));
|
|
1269
|
-
}
|
|
1270
|
-
let xt = [
|
|
1271
|
-
...yt,
|
|
1272
|
-
...bt,
|
|
1273
|
-
...vt
|
|
1274
|
-
], St = xt.length > 0 ? xt : void 0, Ct = (e) => {
|
|
1275
|
-
let t = Q[e], n = j.current;
|
|
1276
|
-
if (!(!t || !n) && (n.focus(), n.setSelectionRange(t.start, t.end), L.current = {
|
|
1277
|
-
start: t.start,
|
|
1278
|
-
end: t.end
|
|
1279
|
-
}, Y > 0)) {
|
|
1280
|
-
let { line: e } = Ce(n.value, t.start), r = e * Y;
|
|
1281
|
-
(r < n.scrollTop || r > n.scrollTop + n.clientHeight - Y) && (n.scrollTop = Math.max(0, r - n.clientHeight / 2));
|
|
1282
|
-
}
|
|
1283
|
-
}, wt = () => {
|
|
1284
|
-
Q.length !== 0 && (H.value = (H.value + 1) % Q.length, Ct(H.value));
|
|
1285
|
-
}, Tt = () => {
|
|
1286
|
-
Q.length !== 0 && (H.value = (H.value - 1 + Q.length) % Q.length, Ct(H.value));
|
|
1287
|
-
}, Et = () => {
|
|
1288
|
-
let e = Q[H.value], t = j.current;
|
|
1289
|
-
!e || !t || y || b || (t.setRangeText(Ze.value, e.start, e.end, "end"), R(t.value, {
|
|
1290
|
-
start: t.selectionStart,
|
|
1291
|
-
end: t.selectionEnd
|
|
1292
|
-
}, !1));
|
|
1293
|
-
}, Dt = () => {
|
|
1294
|
-
if (Q.length === 0 || y || b) return;
|
|
1295
|
-
let e = Te(z.value, Q, Ze.value), t = j.current;
|
|
1296
|
-
t && (t.value = e), R(e, {
|
|
1297
|
-
start: t?.selectionStart ?? 0,
|
|
1298
|
-
end: t?.selectionEnd ?? 0
|
|
1299
|
-
}, !1);
|
|
1300
|
-
}, Ot = (e) => {
|
|
1301
|
-
$e.value = e, V.value = !0;
|
|
1302
|
-
}, kt = () => {
|
|
1303
|
-
V.value = !1, j.current?.focus();
|
|
1304
|
-
}, $ = W.value ? ze(S ?? [], nt.value) : [];
|
|
1305
|
-
G.value >= $.length && (G.value = Math.max(0, $.length - 1));
|
|
1306
|
-
let At = $.map((e) => ({
|
|
1307
|
-
id: e.id,
|
|
1308
|
-
label: e.label,
|
|
1309
|
-
...e.hint !== void 0 && { hint: e.hint }
|
|
1310
|
-
})), { anchorStyle: jt, floatingStyle: Mt } = t({
|
|
1311
|
-
anchorRef: at,
|
|
1312
|
-
floatingRef: ot,
|
|
1313
|
-
placement: "bottom-start",
|
|
1314
|
-
enabled: W
|
|
1315
|
-
}), Nt = {
|
|
1316
|
-
applyEdit: ({ from: e, to: t }, n) => {
|
|
1317
|
-
let r = j.current;
|
|
1318
|
-
r && (r.setRangeText(n, e, t, "end"), R(r.value, {
|
|
1319
|
-
start: r.selectionStart,
|
|
1320
|
-
end: r.selectionEnd
|
|
1321
|
-
}, !1));
|
|
1322
|
-
},
|
|
1323
|
-
getSelection: () => {
|
|
1324
|
-
let e = j.current;
|
|
1325
|
-
return e ? {
|
|
1326
|
-
start: e.selectionStart,
|
|
1327
|
-
end: e.selectionEnd
|
|
1328
|
-
} : { ...L.current };
|
|
1329
|
-
},
|
|
1330
|
-
focus: () => j.current?.focus(),
|
|
1331
|
-
undo: Ke,
|
|
1332
|
-
redo: qe,
|
|
1333
|
-
openFind: () => Ot(!1),
|
|
1334
|
-
openCommandMenu: () => {
|
|
1335
|
-
let e = j.current;
|
|
1336
|
-
!e || !S || S.length === 0 || y || b || (e.focus(), e.setRangeText("/", e.selectionStart, e.selectionEnd, "end"), R(e.value, {
|
|
1337
|
-
start: e.selectionStart,
|
|
1338
|
-
end: e.selectionEnd
|
|
1339
|
-
}, !1), U.value = e.selectionStart, L.current = {
|
|
1340
|
-
start: e.selectionStart,
|
|
1341
|
-
end: e.selectionEnd
|
|
1342
|
-
});
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
u(T, () => Nt);
|
|
1346
|
-
let Pt = (e) => {
|
|
1347
|
-
let t = $[e], n = j.current;
|
|
1348
|
-
if (!t || !n || y || b) return;
|
|
1349
|
-
let r = tt.value, i = n.selectionStart;
|
|
1350
|
-
n.setRangeText(t.insert ?? "", r, i, "end"), R(n.value, {
|
|
1351
|
-
start: n.selectionStart,
|
|
1352
|
-
end: n.selectionEnd
|
|
1353
|
-
}, !1), U.value = n.selectionStart, L.current = {
|
|
1354
|
-
start: n.selectionStart,
|
|
1355
|
-
end: n.selectionEnd
|
|
1356
|
-
}, W.value = !1, G.value = 0, n.focus(), t.run?.(Nt);
|
|
1357
|
-
}, Ft = (e) => {
|
|
1358
|
-
let t = e.currentTarget, n = !y && !b, r = {};
|
|
1359
|
-
if (n) {
|
|
1360
|
-
let { indent: e, dedent: t } = Me({
|
|
1361
|
-
tabSize: h,
|
|
1362
|
-
insertSpaces: g
|
|
1363
|
-
});
|
|
1364
|
-
r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (Ke(), !0);
|
|
1365
|
-
let n = () => (qe(), !0);
|
|
1366
|
-
r["Mod-Shift-z"] = n, r["Mod-y"] = n;
|
|
1367
|
-
}
|
|
1368
|
-
if (r["Mod-f"] = () => (Ot(!1), !0), r["Mod-Alt-f"] = () => (Ot(!0), !0), r["Mod-s"] = () => {
|
|
1369
|
-
let e = xe.current;
|
|
1370
|
-
return e ? (e(E.value), !0) : !1;
|
|
1371
|
-
}, V.value && (r.Escape = () => (kt(), !0)), W.value) {
|
|
1372
|
-
let e = (e) => () => {
|
|
1373
|
-
let t = $.length;
|
|
1374
|
-
return t > 0 && (G.value = (G.value + e + t) % t), !0;
|
|
1375
|
-
};
|
|
1376
|
-
r.ArrowDown = e(1), r.ArrowUp = e(-1);
|
|
1377
|
-
let t = () => ($.length > 0 && Pt(G.value), !0);
|
|
1378
|
-
r.Enter = t, r.Tab = t, r.Escape = () => (rt.value = tt.value, W.value = !1, !0);
|
|
1379
|
-
}
|
|
1380
|
-
je(Ae(r, de), {
|
|
1381
|
-
textarea: t,
|
|
1382
|
-
event: e,
|
|
1383
|
-
setText: We
|
|
1384
|
-
}) && e.preventDefault(), ge?.(e);
|
|
1385
|
-
}, It = {
|
|
1386
|
-
"--cascivo-editor-tab-size": h,
|
|
1387
|
-
...fe,
|
|
1388
|
-
...he
|
|
1389
|
-
};
|
|
1390
|
-
return /* @__PURE__ */ p("div", {
|
|
1391
|
-
ref: O,
|
|
1392
|
-
className: e(w.root, me),
|
|
1393
|
-
"data-wrap": _,
|
|
1394
|
-
"data-line-numbers": m,
|
|
1395
|
-
style: It,
|
|
1396
|
-
children: [m && /* @__PURE__ */ f(ye, {
|
|
1397
|
-
count: J,
|
|
1398
|
-
className: w.gutter,
|
|
1399
|
-
gutterRef: A,
|
|
1400
|
-
start: X,
|
|
1401
|
-
end: Z,
|
|
1402
|
-
topPad: gt,
|
|
1403
|
-
bottomPad: _t,
|
|
1404
|
-
activeLine: !0
|
|
1405
|
-
}), /* @__PURE__ */ p("div", {
|
|
1406
|
-
className: w.codeArea,
|
|
1407
|
-
children: [
|
|
1408
|
-
/* @__PURE__ */ p("pre", {
|
|
1409
|
-
ref: k,
|
|
1410
|
-
className: w.pre,
|
|
1411
|
-
"aria-hidden": "true",
|
|
1412
|
-
children: [
|
|
1413
|
-
/* @__PURE__ */ f("div", { className: w.currentLine }),
|
|
1414
|
-
gt > 0 && /* @__PURE__ */ f("div", { style: { blockSize: gt } }),
|
|
1415
|
-
/* @__PURE__ */ f("code", { children: ve(ht, X, Z, St) }),
|
|
1416
|
-
_t > 0 && /* @__PURE__ */ f("div", { style: { blockSize: _t } })
|
|
1417
|
-
]
|
|
1418
|
-
}),
|
|
1419
|
-
/* @__PURE__ */ f("textarea", {
|
|
1420
|
-
ref: j,
|
|
1421
|
-
className: w.textarea,
|
|
1422
|
-
value: E.value,
|
|
1423
|
-
onChange: (e) => {
|
|
1424
|
-
let t = e.currentTarget, n = t.value, r = Math.abs(n.length - F.current.length) === 1;
|
|
1425
|
-
R(n, {
|
|
1426
|
-
start: t.selectionStart,
|
|
1427
|
-
end: t.selectionEnd
|
|
1428
|
-
}, r);
|
|
1429
|
-
},
|
|
1430
|
-
onKeyDown: Ft,
|
|
1431
|
-
readOnly: y,
|
|
1432
|
-
disabled: b,
|
|
1433
|
-
spellCheck: se,
|
|
1434
|
-
role: "combobox",
|
|
1435
|
-
"aria-label": le ?? ce ?? c(s.editor.label),
|
|
1436
|
-
"aria-expanded": W.value,
|
|
1437
|
-
"aria-controls": W.value ? st : void 0,
|
|
1438
|
-
"aria-activedescendant": W.value ? `${st}-opt-${G.value}` : void 0,
|
|
1439
|
-
autoCapitalize: "off",
|
|
1440
|
-
autoCorrect: "off",
|
|
1441
|
-
autoComplete: "off",
|
|
1442
|
-
wrap: _ ? "soft" : "off",
|
|
1443
|
-
..._e
|
|
1444
|
-
}),
|
|
1445
|
-
/* @__PURE__ */ f("div", {
|
|
1446
|
-
ref: at,
|
|
1447
|
-
"aria-hidden": "true",
|
|
1448
|
-
style: {
|
|
1449
|
-
position: "absolute",
|
|
1450
|
-
inlineSize: 0,
|
|
1451
|
-
blockSize: 0,
|
|
1452
|
-
...jt
|
|
1453
|
-
}
|
|
1454
|
-
}),
|
|
1455
|
-
W.value && /* @__PURE__ */ f(Be, {
|
|
1456
|
-
ref: ot,
|
|
1457
|
-
id: st,
|
|
1458
|
-
items: At,
|
|
1459
|
-
activeIndex: G.value,
|
|
1460
|
-
onSelect: Pt,
|
|
1461
|
-
onHover: (e) => G.value = e,
|
|
1462
|
-
style: Mt
|
|
1463
|
-
}),
|
|
1464
|
-
V.value && /* @__PURE__ */ f(be, {
|
|
1465
|
-
query: Xe.value,
|
|
1466
|
-
replaceQuery: Ze.value,
|
|
1467
|
-
replaceMode: $e.value,
|
|
1468
|
-
caseSensitive: Qe.value,
|
|
1469
|
-
matchCount: Q.length,
|
|
1470
|
-
currentIndex: Q.length > 0 ? H.value : -1,
|
|
1471
|
-
onQueryChange: (e) => {
|
|
1472
|
-
Xe.value = e, H.value = 0;
|
|
1473
|
-
},
|
|
1474
|
-
onReplaceChange: (e) => Ze.value = e,
|
|
1475
|
-
onNext: wt,
|
|
1476
|
-
onPrev: Tt,
|
|
1477
|
-
onReplace: Et,
|
|
1478
|
-
onReplaceAll: Dt,
|
|
1479
|
-
onToggleCase: () => Qe.value = !Qe.value,
|
|
1480
|
-
onToggleReplace: () => $e.value = !$e.value,
|
|
1481
|
-
onClose: kt
|
|
1482
|
-
})
|
|
1483
|
-
]
|
|
1484
|
-
})]
|
|
1485
|
-
});
|
|
1486
|
-
});
|
|
1487
|
-
//#endregion
|
|
1488
|
-
//#region src/editor/highlight/highlight.tsx
|
|
1489
|
-
function F({ value: t, language: n = "plaintext", lineNumbers: r = !1, wrap: i = !1, tabSize: a = 2, label: s, ariaLabel: c, className: l, preRef: u, gutterRef: d, style: ee, ...te }) {
|
|
1490
|
-
o();
|
|
1491
|
-
let ne = oe(n), m = t.split("\n"), h = re(ne, m, 0, m.length, ae(ne)), ie = {
|
|
1492
|
-
"--cascivo-editor-tab-size": a,
|
|
1493
|
-
...ee
|
|
1494
|
-
};
|
|
1495
|
-
return /* @__PURE__ */ p("div", {
|
|
1496
|
-
className: e(C.root, l),
|
|
1497
|
-
"data-wrap": i,
|
|
1498
|
-
"data-line-numbers": r,
|
|
1499
|
-
style: ie,
|
|
1500
|
-
"aria-label": c ?? s,
|
|
1501
|
-
...te,
|
|
1502
|
-
children: [r && /* @__PURE__ */ f(ye, {
|
|
1503
|
-
count: h.length,
|
|
1504
|
-
className: C.gutter,
|
|
1505
|
-
gutterRef: d
|
|
1506
|
-
}), /* @__PURE__ */ f("pre", {
|
|
1507
|
-
ref: u,
|
|
1508
|
-
className: C.pre,
|
|
1509
|
-
children: /* @__PURE__ */ f("code", {
|
|
1510
|
-
className: C.code,
|
|
1511
|
-
children: ve(h)
|
|
1512
|
-
})
|
|
1513
|
-
})]
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1516
|
-
//#endregion
|
|
1517
|
-
export { He as CodeEditor, F as Highlight, he as bash, ae as createLineStateIndex, b as createRuleGrammar, pe as css, oe as getGrammar, S as html, x as javascript, ce as json, y as listGrammars, me as markdown, se as plaintext, v as registerGrammar, m as tokenize, h as tokenizeDocument, re as tokenizeRange, fe as typescript };
|
|
3
|
+
import{cn as e,useAnchorPosition as t,useControllableSignal as n,useId as r,useSignal as i,useSignalEffect as a,useSignals as o}from"@cascivo/core";import{builtin as s,t as c}from"@cascivo/i18n";import{forwardRef as l,useImperativeHandle as ee,useRef as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";var p=new Map,te=`\0`,ne=0;function tokenize(e,t,n){let r=`${e.name}${te}${n}${te}${t}`,i=p.get(r);if(i)return i;ne++;let{tokens:a,state:o}=e.tokenizeLine(t,n),s={tokens:a,endState:o};return p.set(r,s),s}function tokenizeDocument(e,t){let n=t.split(`
|
|
4
|
+
`),r=[],i=e.initialState;for(let t of n){let n=tokenize(e,t,i);r.push(n.tokens),i=n.endState}return r}function tokenizeRange(e,t,n,r,i){let a=Math.max(0,Math.min(n,t.length)),o=Math.max(a,Math.min(r,t.length)),s=i.startStateOf(t,a),c=[];for(let n=a;n<o;n++){let r=tokenize(e,t[n],s);c.push(r.tokens),i.setEndState(n,r.endState),s=r.endState}return c}function tokenizeWindowFrom(e,t,n,r,i){let a=Math.max(0,Math.min(n,t.length)),o=Math.max(a,Math.min(r,t.length)),s=i,c=[];for(let n=a;n<o;n++){let r=tokenize(e,t[n],s);c.push(r.tokens),s=r.endState}return c}function createLineStateIndex(e){let t=[],ensure=(n,r)=>{let i=Math.min(r,n.length-1),a=t.length;if(a>i)return;let o=a===0?e.initialState:t[a-1];for(;a<=i;a++){let r=tokenize(e,n[a],o);t[a]=r.endState,o=r.endState}};return{grammar:e,get length(){return t.length},ensure,startStateOf:(n,r)=>r<=0?e.initialState:(ensure(n,r-1),t[r-1]),setEndState:(e,n)=>{t[e]=n},invalidateFrom:e=>{let n=Math.max(0,e);n<t.length&&(t.length=n)}}}var m=new Map,h={name:`plaintext`,initialState:`default`,tokenizeLine:e=>({tokens:e.length>0?[{kind:`plain`,value:e}]:[],state:`default`})};m.set(h.name,h);function registerGrammar(e){m.set(e.name,e)}function getGrammar(e){if(e!==void 0){let t=m.get(e);if(t)return t}return m.get(`plaintext`)}function listGrammars(){return[...m.keys()]}function createRuleGrammar(e){let t={};for(let[n,r]of Object.entries(e.states))t[n]=r.map(e=>{let t=`${e.match.flags.replace(/[gy]/g,``)}y`,n={re:new RegExp(e.match.source,t),kind:e.kind};return e.push!==void 0&&(n.push=e.push),e.pop!==void 0&&(n.pop=e.pop),n});return{name:e.name,initialState:`default`,tokenizeLine(e,n){let r=t[n]?n:`default`,i=[],a=-1,o=0,flushPlain=t=>{a>=0&&(i.push({kind:`plain`,value:e.slice(a,t)}),a=-1)};for(;o<e.length;){let n=t[r],s=!1;for(let a of n){a.re.lastIndex=o;let n=a.re.exec(e);if(n!==null&&n.index===o&&n[0].length>0){flushPlain(o),i.push({kind:a.kind,value:n[0]}),o+=n[0].length,a.pop?r=`default`:a.push&&t[a.push]&&(r=a.push),s=!0;break}}s||(a<0&&(a=o),o++)}return flushPlain(e.length),{tokens:i,state:r}}}}var g={name:`plaintext`,initialState:`default`,tokenizeLine:e=>({tokens:e.length>0?[{kind:`plain`,value:e}]:[],state:`default`})};registerGrammar(g);var _=createRuleGrammar({name:`json`,states:{default:[{match:/"(?:[^"\\]|\\.)*"(?=\s*:)/,kind:`property`},{match:/"(?:[^"\\]|\\.)*"/,kind:`string`},{match:/\b(?:true|false|null)\b/,kind:`boolean`},{match:/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/,kind:`number`},{match:/[{}[\],]/,kind:`punctuation`},{match:/:/,kind:`operator`}]}});registerGrammar(_);var re=`async.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.export.extends.finally.for.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.with.yield.as.from.get.set`.split(`.`);function words(e){return RegExp(`(?:${e.join(`|`)})\\b`)}function createCLikeGrammar(e,t,n=[]){let r=[{match:/\/\/.*/,kind:`comment`},{match:/\/\*/,kind:`comment`,push:`block`},{match:/`/,kind:`string`,push:`template`},{match:/'(?:[^'\\]|\\.)*'/,kind:`string`},{match:/"(?:[^"\\]|\\.)*"/,kind:`string`},{match:/0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|(?:\d[\d_]*\.?\d*|\.\d+)(?:[eE][+-]?\d+)?n?/,kind:`number`},{match:/\b(?:true|false|null|undefined|NaN|Infinity)\b/,kind:`boolean`}];return n.length>0&&r.push({match:words(n),kind:`type`}),r.push({match:words(t),kind:`keyword`},{match:/[A-Za-z_$][\w$]*(?=\s*\()/,kind:`function`},{match:/[A-Z][\w$]*/,kind:`type`},{match:/[A-Za-z_$][\w$]*/,kind:`variable`},{match:/[+\-*/%=<>!&|^~?]+/,kind:`operator`},{match:/[{}()[\];,.:]/,kind:`punctuation`}),createRuleGrammar({name:e,states:{default:r,block:[{match:/\*\//,kind:`comment`,pop:!0},{match:/[^*]+/,kind:`comment`},{match:/\*/,kind:`comment`}],template:[{match:/\\./,kind:`string`},{match:/`/,kind:`string`,pop:!0},{match:/\$\{/,kind:`punctuation`},{match:/[^`\\$]+/,kind:`string`},{match:/\$/,kind:`string`}]}})}var v=createCLikeGrammar(`javascript`,re);registerGrammar(v);var y=createCLikeGrammar(`typescript`,re,[`interface`,`type`,`enum`,`implements`,`namespace`,`declare`,`abstract`,`readonly`,`public`,`private`,`protected`,`keyof`,`infer`,`satisfies`,`is`,`asserts`,`override`,`string`,`number`,`boolean`,`any`,`unknown`,`never`,`object`]);registerGrammar(y);var ie=createRuleGrammar({name:`css`,states:{default:[{match:/\/\*/,kind:`comment`,push:`block`},{match:/@[\w-]+/,kind:`keyword`},{match:/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/,kind:`string`},{match:/#[0-9a-fA-F]{3,8}\b/,kind:`number`},{match:/-?\d+(?:\.\d+)?(?:px|rem|em|%|vh|vw|s|ms|deg|fr|ch|ex)?/,kind:`number`},{match:/--[\w-]+/,kind:`variable`},{match:/[.#][\w-]+/,kind:`tag`},{match:/&|::?[\w-]+/,kind:`tag`},{match:/[\w-]+(?=\s*:)/,kind:`property`},{match:/[\w-]+(?=\s*\()/,kind:`function`},{match:/[{}();,:]/,kind:`punctuation`}],block:[{match:/\*\//,kind:`comment`,pop:!0},{match:/[^*]+/,kind:`comment`},{match:/\*/,kind:`comment`}]}});registerGrammar(ie);var ae=createRuleGrammar({name:`html`,states:{default:[{match:/<!--/,kind:`comment`,push:`comment`},{match:/<!?\/?[A-Za-z][\w-]*/,kind:`tag`,push:`tag`},{match:/&[a-zA-Z#0-9]+;/,kind:`boolean`}],comment:[{match:/-->/,kind:`comment`,pop:!0},{match:/[^-]+/,kind:`comment`},{match:/-/,kind:`comment`}],tag:[{match:/\/?>/,kind:`tag`,pop:!0},{match:/"(?:[^"\\]|\\.)*"|'[^']*'/,kind:`string`},{match:/[\w-]+(?=\s*=)/,kind:`attr`},{match:/=/,kind:`operator`},{match:/[\w-]+/,kind:`attr`}]}});registerGrammar(ae);var oe=createRuleGrammar({name:`markdown`,states:{default:[{match:/^```.*/,kind:`keyword`,push:`fence`},{match:/^~~~.*/,kind:`keyword`,push:`fenceTilde`},{match:/^\s*([-*_])(?:[ \t]*\1){2,}[ \t]*$/,kind:`comment`},{match:/^#{1,6}\s.*/,kind:`keyword`},{match:/^\s*[-*+]\s+\[[ xX]\]/,kind:`boolean`},{match:/^\s*(?:[-*+]|\d+\.)\s/,kind:`operator`},{match:/^\s*>\s?.*/,kind:`comment`},{match:/`[^`]+`/,kind:`string`},{match:/~~[^~]+~~/,kind:`comment`},{match:/\*\*[^*]+\*\*|__[^_]+__/,kind:`keyword`},{match:/\*[^*\s][^*]*\*|_[^_\s][^_]*_/,kind:`type`},{match:/!?\[[^\]]*\]\([^)]*\)/,kind:`function`}],fence:[{match:/^```.*/,kind:`keyword`,pop:!0},{match:/.+/,kind:`string`}],fenceTilde:[{match:/^~~~.*/,kind:`keyword`,pop:!0},{match:/.+/,kind:`string`}]}});registerGrammar(oe);var b=createRuleGrammar({name:`bash`,states:{default:[{match:/#.*/,kind:`comment`},{match:/"(?:[^"\\]|\\.)*"/,kind:`string`},{match:/'[^']*'/,kind:`string`},{match:/\b(?:if|then|else|elif|fi|for|while|until|do|done|case|esac|in|function|select|return|exit|break|continue|local|export|readonly|declare|echo|cd|source|set|unset)\b/,kind:`keyword`},{match:/\$\{[^}]*\}|\$[A-Za-z_]\w*|\$[0-9@*#?$!]/,kind:`variable`},{match:/-?\b\d+\b/,kind:`number`},{match:/[A-Za-z_][\w-]*(?=\s*\(\s*\))/,kind:`function`},{match:/[|&;<>()]+|&&|\|\||=/,kind:`operator`}]}});registerGrammar(b);var x={builds:0,lookups:0,arrayReads:0,arraySplits:0};function createLineIndex(e){x.builds++;let t=64,n=new Int32Array(t),r=1;for(let i=e.indexOf(`
|
|
5
|
+
`);i!==-1;i=e.indexOf(`
|
|
6
|
+
`,i+1)){if(r===t){t*=2;let e=new Int32Array(t);e.set(n),n=e}n[r++]=i+1}let lineAt=e=>{x.lookups++;let t=0,i=r-1;for(;t<i;){let r=t+i+1>>1;n[r]<=e?t=r:i=r-1}return t},i;return{text:e,count:r,startOf:e=>n[Math.max(0,Math.min(e,r-1))],lineAt,locate:e=>{let t=lineAt(e);return{line:t,col:e-n[t]}},toArray:()=>(x.arrayReads++,i===void 0&&(x.arraySplits++,i=e.split(`
|
|
7
|
+
`)),i)}}function createLineIndexCache(){let e,t;return n=>{if(e?.text===n)return e;if(t?.text===n){let n=t;return t=e,e=n,n}return t=e,e=createLineIndex(n),e}}var S={root:`_root_1m6ns_2`,gutter:`_gutter_1m6ns_17`,gutterLine:`_gutterLine_1m6ns_28`,gutterActive:`_gutterActive_1m6ns_35`,pre:`_pre_1m6ns_45`,code:`_code_1m6ns_57`,line:`_line_1m6ns_62`,plain:`_plain_1m6ns_77`,keyword:`_keyword_1m6ns_80`,string:`_string_1m6ns_83`,number:`_number_1m6ns_86`,comment:`_comment_1m6ns_89`,function:`_function_1m6ns_93`,type:`_type_1m6ns_96`,operator:`_operator_1m6ns_99`,punctuation:`_punctuation_1m6ns_102`,variable:`_variable_1m6ns_105`,tag:`_tag_1m6ns_108`,attr:`_attr_1m6ns_111`,regexp:`_regexp_1m6ns_114`,boolean:`_boolean_1m6ns_117`,property:`_property_1m6ns_120`,match:`_match_1m6ns_125`,matchCurrent:`_matchCurrent_1m6ns_129`,bracketMatch:`_bracketMatch_1m6ns_133`};function classesAt(e,t){let n=``;for(let r of t)e>=r.start&&e<r.end&&(n=n?`${n} ${r.className}`:r.className);return n}function renderToken(t,n,r,i){let a=n+t.value.length,o=new Set([n,a]);for(let e of r)e.start>n&&e.start<a&&o.add(e.start),e.end>n&&e.end<a&&o.add(e.end);if(o.size===2){let a=classesAt(n,r);return d(`span`,{className:a?e(S[t.kind],a):S[t.kind],children:t.value},i)}let s=[...o].sort((e,t)=>e-t),c=[];for(let i=0;i<s.length-1;i++){let a=s[i],o=s[i+1],l=classesAt(a,r);c.push(d(`span`,{className:l?e(S[t.kind],l):S[t.kind],children:t.value.slice(a-n,o-n)},a))}return d(`span`,{children:c},i)}function renderRows(e,t=0,n=t+e.length,r){let i=[];for(let a=t;a<n;a++){let n=e[a-t],o=r?.filter(e=>e.line===a);i.push(d(`span`,{className:S.line,children:n.length===0?``:o&&o.length>0?(()=>{let e=0;return n.map((t,n)=>{let r=renderToken(t,e,o,n);return e+=t.value.length,r})})():n.map((e,t)=>d(`span`,{className:S[e.kind],children:e.value},t))},a))}return i}function Gutter({count:e,className:t,gutterRef:n,start:r=0,end:i=e,topPad:a=0,bottomPad:o=0,activeLine:s=!1}){let c=[];for(let e=r+1;e<=i;e++)c.push(d(`span`,{className:S.gutterLine,children:e},e));return f(`div`,{ref:n,className:t,"aria-hidden":`true`,children:[s&&d(`div`,{className:S.gutterActive}),a>0&&d(`div`,{style:{blockSize:a}}),c,o>0&&d(`div`,{style:{blockSize:o}})]})}var C={root:`_root_18xci_2`,textarea:`_textarea_18xci_18`,gutter:`_gutter_18xci_23`,codeArea:`_codeArea_18xci_36`,pre:`_pre_18xci_43`,currentLine:`_currentLine_18xci_58`},w={panel:`_panel_hawkv_2`,row:`_row_hawkv_20`,input:`_input_hawkv_26`,count:`_count_hawkv_44`,button:`_button_hawkv_52`,toggle:`_toggle_hawkv_53`,active:`_active_hawkv_80`};function FindPanel(t){o();let n=t.matchCount===0?c(s.editor.noMatches):c(s.editor.findCount,{current:t.currentIndex+1,total:t.matchCount});return f(`div`,{className:w.panel,role:`search`,"aria-label":c(s.editor.find),children:[f(`div`,{className:w.row,children:[d(`button`,{type:`button`,className:w.toggle,"aria-label":c(s.editor.toggleReplace),"aria-expanded":t.replaceMode,onClick:t.onToggleReplace,children:t.replaceMode?`▾`:`▸`}),d(`input`,{className:w.input,value:t.query,placeholder:c(s.editor.findPlaceholder),"aria-label":c(s.editor.find),autoFocus:!0,autoComplete:`off`,spellCheck:!1,onChange:e=>t.onQueryChange(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.shiftKey?t.onPrev():t.onNext()):e.key===`Escape`&&(e.preventDefault(),t.onClose())}}),d(`span`,{className:w.count,"aria-live":`polite`,children:n}),d(`button`,{type:`button`,className:w.button,"aria-label":c(s.editor.previous),onClick:t.onPrev,children:`‹`}),d(`button`,{type:`button`,className:w.button,"aria-label":c(s.editor.next),onClick:t.onNext,children:`›`}),d(`button`,{type:`button`,className:e(w.button,t.caseSensitive&&w.active),"aria-pressed":t.caseSensitive,"aria-label":c(s.editor.matchCase),onClick:t.onToggleCase,children:`Aa`}),d(`button`,{type:`button`,className:w.button,"aria-label":c(s.editor.close),onClick:t.onClose,children:`×`})]}),t.replaceMode&&f(`div`,{className:w.row,children:[d(`input`,{className:w.input,value:t.replaceQuery,placeholder:c(s.editor.replacePlaceholder),"aria-label":c(s.editor.replace),autoComplete:`off`,spellCheck:!1,onChange:e=>t.onReplaceChange(e.currentTarget.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),t.onClose()):e.key===`Enter`&&(e.preventDefault(),t.onReplace())}}),d(`button`,{type:`button`,className:w.button,onClick:t.onReplace,children:c(s.editor.replaceOne)}),d(`button`,{type:`button`,className:w.button,onClick:t.onReplaceAll,children:c(s.editor.replaceAll)})]})]})}var se=/\w/;function isWordChar(e){return e!==void 0&&se.test(e)}function scan(e,t,n={}){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLowerCase(),i=n.caseSensitive?t:t.toLowerCase(),a=[],o=0;for(;;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||!isWordChar(e[t-1])&&!isWordChar(e[s]))&&a.push({start:t,end:s}),o=s>t?s:t+1}return a}function offsetToLineCol(e,t){let n=0,r=0;for(let i=e.indexOf(`
|
|
8
|
+
`);i!==-1&&i<t;i=e.indexOf(`
|
|
9
|
+
`,i+1))n++,r=i+1;return{line:n,col:t-r}}function toDecorations(e,t,n,r){return t.map((t,i)=>{let{line:a,col:o}=e.locate(t.start);return{line:a,start:o,end:o+(t.end-t.start),className:i===n?r.current:r.match}})}function firstMatchFrom(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i].start<t?n=i+1:r=i}return n}function replaceAll(e,t,n){let r=e;for(let e=t.length-1;e>=0;e--){let i=t[e];r=r.slice(0,i.start)+n+r.slice(i.end)}return r}function createScanCache(){let e,t,n=[];return(r,i,a)=>{let o=`${a?`S`:`i`}${i}`;return r===t&&o===e?n:(t=r,e=o,n=scan(r,i,{caseSensitive:a}),n)}}var T={"(":`)`,"[":`]`,"{":`}`},E={")":`(`,"]":`[`,"}":`}`};function scanForward(e,t,n,r){let i=0;for(let a=t;a<e.length;a++){let t=e[a];if(t===n)i++;else if(t===r&&--i===0)return a}return-1}function scanBackward(e,t,n,r){let i=0;for(let a=t;a>=0;a--){let t=e[a];if(t===r)i++;else if(t===n&&--i===0)return a}return-1}function matchBracket(e,t){let n=e[t];if(n&&n in T){let r=scanForward(e,t,n,T[n]);if(r!==-1)return{open:t,close:r}}let r=e[t-1];if(r&&r in E){let n=scanBackward(e,t-1,E[r],r);if(n!==-1)return{open:n,close:t-1}}if(r&&r in T){let n=scanForward(e,t-1,r,T[r]);if(n!==-1)return{open:t-1,close:n}}if(n&&n in E){let r=scanBackward(e,t,E[n],n);if(r!==-1)return{open:r,close:t}}}function toBracketDecorations(e,t,n){return[t.open,t.close].map(t=>{let{line:r,col:i}=e.locate(t);return{line:r,start:i,end:i+1,className:n}})}var D=1024;function diff(e,t){if(e===t)return{from:e.length,to:e.length,insert:``};let n=Math.min(e.length,t.length),r=0;for(;r+D<=n&&e.slice(r,r+D)===t.slice(r,r+D);)r+=D;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i-D>=r&&a-D>=r&&e.slice(i-D,i)===t.slice(a-D,a);)i-=D,a-=D;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;return{from:r,to:i,insert:t.slice(r,a)}}function rebaseOffset(e,t){return e<=t.from?e:e>=t.to?e+(t.insert.length-(t.to-t.from)):t.from+t.insert.length}function rebaseSelection(e,t,n){return{start:rebaseOffset(e,n),end:rebaseOffset(t,n)}}function detach(e){return e.length===0?e:structuredClone(e)}function makeStep(e,t,n){let r=diff(e,t.text);return{from:r.from,removed:detach(e.slice(r.from,r.to)),inserted:detach(r.insert),before:n,after:{start:t.selectionStart,end:t.selectionEnd}}}function unapply(e,t){return e.slice(0,t.from)+t.removed+e.slice(t.from+t.inserted.length)}function apply(e,t){return e.slice(0,t.from)+t.inserted+e.slice(t.from+t.removed.length)}function createHistory(e=200){let t=Math.max(1,e-1),n=[],r=0,i=``,a={start:0,end:0},o=!1,snapshot=()=>({text:i,selectionStart:a.start,selectionEnd:a.end});return{record(e,s){let c=s?.coalesce??!1;r<n.length&&(n=n.slice(0,r));let l=n[r-1];c&&o&&l?n[r-1]=makeStep(unapply(i,l),e,l.before):(n.push(makeStep(i,e,a)),r=n.length,n.length>t&&(n.shift(),r--)),i=e.text,a={start:e.selectionStart,end:e.selectionEnd},o=c},undo(){if(r===0)return;let e=n[--r];return i=unapply(i,e),a=e.before,o=!1,snapshot()},redo(){if(r>=n.length)return;let e=n[r++];return i=apply(i,e),a=e.after,o=!1,snapshot()},reset(e){n=[],r=0,i=e.text,a={start:e.selectionStart,end:e.selectionEnd},o=!1},canUndo(){return r>0},canRedo(){return r<n.length}}}var ce=typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||``);function chordOf(e){let t=[];(ce?e.metaKey:e.ctrlKey)&&t.push(`Mod`),e.altKey&&t.push(`Alt`),e.shiftKey&&t.push(`Shift`);let n=e.key;return n.length===1&&(n=n.toLowerCase()),t.push(n),t.join(`-`)}function mergeKeymap(e,t){let n=new Map(Object.entries(e));if(t)for(let[e,r]of Object.entries(t))n.set(e,r);return n}function dispatch(e,t){let n=e.get(chordOf(t.event));return n?n(t):!1}function createIndentCommands(e){let indentText=()=>e.insertSpaces?` `.repeat(e.tabSize):` `;return{indent:({textarea:e,setText:t})=>{let{selectionStart:n,selectionEnd:r,value:i}=e,a=i.lastIndexOf(`
|
|
10
|
+
`,n-1)+1;if(n===r)e.setRangeText(indentText(),n,r,`end`);else{let t=i.slice(a,r).replace(/^/gm,indentText());e.setRangeText(t,a,r,`select`)}return t(e.value),!0},dedent:({textarea:t,setText:n})=>{let{selectionStart:r,selectionEnd:i,value:a}=t,o=a.lastIndexOf(`
|
|
11
|
+
`,r-1)+1,s=a.slice(o,i).replace(RegExp(`^(?:\\t| {1,${e.tabSize}})`,`gm`),``);return t.setRangeText(s,o,i,`select`),n(t.value),!0}}}function visualColumn(e,t){let n=0;for(let r of e)r===` `?n+=t-n%t:n+=1;return n}function caretCoords(e,t,n){let{line:r,col:i}=offsetToLineCol(e,t),a=visualColumn(e.slice(t-i,t),n.tabSize);return{top:r*n.lineHeight-n.scrollTop+n.padTop,left:a*n.charWidth-n.scrollLeft+n.padLeft}}function caretRectFromPre(e,t){if(typeof document>`u`)return null;let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=0,i=n.nextNode();for(;i;){let e=i.textContent?.length??0;if(t<=r+e){let e=document.createRange();e.setStart(i,Math.max(0,t-r)),e.collapse(!0);let n=e.getClientRects();return n.length>0?n[0]:e.getBoundingClientRect()}r+=e,i=n.nextNode()}return null}function measureCharWidth(e){if(typeof document>`u`)return 0;let t=getComputedStyle(e),n=document.createElement(`span`);n.style.position=`absolute`,n.style.visibility=`hidden`,n.style.whiteSpace=`pre`,n.style.font=t.font,n.style.letterSpacing=t.letterSpacing,n.style.tabSize=t.tabSize,n.textContent=`0`.repeat(10),document.body.appendChild(n);let r=n.getBoundingClientRect().width/10;return n.remove(),r}function detectTrigger(e,t){for(let n=t-1;n>=0;n--){let r=e[n];if(r===`/`){let r=e[n-1];return r===void 0||/\s/.test(r)?{start:n,query:e.slice(n+1,t)}:null}if(r===void 0||/\s/.test(r))return null}return null}function filterCommands(e,t){if(t===``)return[...e];let n=t.toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(n)||(e.keywords?.some(e=>e.toLowerCase().includes(n))??!1))}var O={menu:`_menu_zkolh_2`,option:`_option_zkolh_24`,active:`_active_zkolh_35`,label:`_label_zkolh_39`,hint:`_hint_zkolh_44`,empty:`_empty_zkolh_50`},le=l(function({id:t,items:n,activeIndex:r,onSelect:i,onHover:a,style:l},ee){return o(),d(`ul`,{ref:ee,id:t,className:O.menu,role:`listbox`,"aria-label":c(s.editor.commandMenu),style:l,children:n.length===0?d(`li`,{className:O.empty,role:`presentation`,children:c(s.editor.commandMenuEmpty)}):n.map((n,o)=>f(`li`,{id:`${t}-opt-${o}`,role:`option`,"aria-selected":o===r,className:e(O.option,o===r&&O.active),onMouseEnter:()=>a(o),onMouseDown:e=>{e.preventDefault(),i(o)},children:[d(`span`,{className:O.label,children:n.label}),n.hint!==void 0&&d(`span`,{className:O.hint,children:n.hint})]},n.id))})}),ue=2e3,de=l(function({value:l,defaultValue:p,onValueChange:te,language:ne=`plaintext`,lineNumbers:m=!0,tabSize:h=2,insertSpaces:g=!0,wrap:_=!1,virtualize:re,readOnly:v=!1,disabled:y=!1,spellCheck:ie=!1,label:ae,ariaLabel:oe,onSave:b,keymap:x,decorations:w,theme:se,bracketMatching:T=!1,commands:E,className:D,style:ce,onKeyDown:O,...de},fe){o();let pe=u(b);pe.current=b;let[k,me]=n({value:l,defaultValue:p??``,onChange:te}),he=u(null);he.current??=createLineIndexCache();let ge=he.current,_e=u(null);_e.current??=createScanCache();let ve=_e.current,ye=u(null),A=u(null),be=u(null),j=u(null),xe=u([]),M=u(null);M.current===null&&(M.current=createHistory(),M.current.reset({text:k.value,selectionStart:0,selectionEnd:0}));let N=M.current,P=u(null),Se=u(void 0),F=u(k.value),Ce=u(void 0),I=u(!1),L=u({start:0,end:0}),commit=(e,t,n)=>{Ce.current=e,F.current=e,N.record({text:e,selectionStart:t.start,selectionEnd:t.end},{coalesce:n}),me(e)},commitFromCommand=e=>{let t=j.current;commit(e,t?{start:t.selectionStart,end:t.selectionEnd}:L.current,!1)},applySnapshot=e=>{let t=j.current;if(!t)return;I.current=!0,t.value=e.text,t.setSelectionRange(e.selectionStart,e.selectionEnd),me(e.text),Ce.current=e.text,F.current=e.text,L.current={start:e.selectionStart,end:e.selectionEnd},H.value=e.selectionStart;let n=ge(e.text).lineAt(e.selectionStart);ye.current?.style.setProperty(`--cascivo-editor-caret-line`,String(n)),I.current=!1},doUndo=()=>{let e=N.undo();e&&applySnapshot(e)},doRedo=()=>{let e=N.redo();e&&applySnapshot(e)},R=i(k.value),we=i(0),Te=i(0),z=i(0),B=i(!1),Ee=i(``),De=i(``),Oe=i(!1),ke=i(!1),V=i(0),H=i(0),Ae=i(0),U=i(!1),je=i(0),Me=i(``),W=i(0),Ne=i(-1),Pe=i(0),Fe=u(null),Ie=u(null),Le=r(`slash-menu`);a(()=>{let e=k.value;if(typeof requestAnimationFrame!=`function`){R.value=e;return}let t=requestAnimationFrame(()=>{R.value=e});return()=>cancelAnimationFrame(t)}),a(()=>{let e=k.value;if(I.current||e===F.current)return;if(e===Ce.current){F.current=e;return}let t=j.current,n=diff(F.current,e),r=rebaseSelection(L.current.start,L.current.end,n);t&&(I.current=!0,t.value!==e&&(t.value=e),t.setSelectionRange(r.start,r.end),I.current=!1),L.current=r,N.reset({text:e,selectionStart:r.start,selectionEnd:r.end}),F.current=e}),a(()=>{let e=j.current;if(!e)return;let measure=()=>{let t=Number.parseFloat(getComputedStyle(e).lineHeight);z.value=Number.isFinite(t)&&t>0?t:0,Te.value=e.clientHeight;let n=measureCharWidth(e);n>0&&(Pe.value=n)},syncScroll=()=>{we.value=e.scrollTop,Te.value=e.clientHeight,A.current&&(A.current.scrollTop=e.scrollTop,A.current.scrollLeft=e.scrollLeft),be.current&&(be.current.scrollTop=e.scrollTop)},syncCaret=()=>{let t=ge(e.value).lineAt(e.selectionStart);ye.current?.style.setProperty(`--cascivo-editor-caret-line`,String(t)),L.current={start:e.selectionStart,end:e.selectionEnd},H.value=e.selectionStart},syncCaretIfActive=()=>{document.activeElement===e&&syncCaret()},t=0,n=-1,sampleFrame=()=>{syncScroll(),e.scrollTop===n?t=0:(n=e.scrollTop,t=requestAnimationFrame(sampleFrame))},onScroll=()=>{syncScroll(),t===0&&typeof requestAnimationFrame==`function`&&(n=-1,t=requestAnimationFrame(sampleFrame))};measure(),syncCaret(),e.addEventListener(`scroll`,onScroll),e.addEventListener(`keyup`,syncCaret),e.addEventListener(`click`,syncCaret),e.addEventListener(`input`,syncCaret),document.addEventListener(`selectionchange`,syncCaretIfActive);let r;typeof ResizeObserver<`u`&&(r=new ResizeObserver(()=>{measure(),syncScroll()}),r.observe(e));let i=!1,a=document.fonts;return a?.ready&&a.ready.then(()=>{i||measure()}).catch(()=>{}),()=>{i=!0,t!==0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),r?.disconnect(),e.removeEventListener(`scroll`,onScroll),e.removeEventListener(`keyup`,syncCaret),e.removeEventListener(`click`,syncCaret),e.removeEventListener(`input`,syncCaret),document.removeEventListener(`selectionchange`,syncCaretIfActive)}}),a(()=>{let e=H.value,t=k.value;if(!E||E.length===0||v||y){U.value&&=!1;return}let n=detectTrigger(t,e);if(!n){Ne.value=-1,U.value&&=!1;return}if(n.start===Ne.value){U.value&&=!1;return}U.value||(W.value=0),U.value=!0,je.value=n.start,Me.value=n.query}),a(()=>{if(!U.value)return;let e=Fe.current,t=j.current;if(!e||!t)return;let n=je.value,r=e.offsetParent,i,a,o=A.current,s=(_||k.value.includes(` `))&&o?caretRectFromPre(o,n):null;if(s&&r){let e=r.getBoundingClientRect();i=s.bottom-e.top,a=s.left-e.left}else{let e=getComputedStyle(t),r=caretCoords(k.value,n,{charWidth:Pe.value,lineHeight:z.value,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,padTop:Number.parseFloat(e.paddingTop)||0,padLeft:Number.parseFloat(e.paddingLeft)||0,tabSize:h});i=r.top+z.value,a=r.left}e.style.top=`${i}px`,e.style.left=`${a}px`});let G=getGrammar(ne);(P.current===null||P.current.grammar!==G)&&(P.current=createLineStateIndex(G),Se.current=void 0);let K=P.current,q=ge(R.value),Re=q.toArray(),J=q.count;xe.current=Re;let ze=R.value,Be=Se.current;if(ze!==Be){let e=Be===void 0?0:q.lineAt(diff(Be,ze).from);K.invalidateFrom(e),Se.current=ze}let Ve=z.value>0,Y=Ve?z.value:20,He=(re??J>1e3)&&!_,X=0,Z=J;if(He)if(Ve){X=Math.max(0,Math.floor(we.value/Y)-12);let e=Math.ceil(Te.value/Y);Z=Math.min(J,X+e+24)}else Z=Math.min(J,200);let Ue=He&&X>K.length?X-K.length:0,We=!He||X===0||K.length>=X||Ue<=2e3,Ge;We?Ge=tokenizeRange(G,Re,X,Z,K):(Ae.value,Ge=tokenizeWindowFrom(G,Re,X,Z,G.initialState));let Ke=X*Y,qe=(J-Z)*Y;a(()=>{R.value,Ae.value;let e=z.value,t=xe.current,n=t.length;if(!((re??n>1e3)&&!_&&e>0))return;let r=Math.max(0,Math.floor(we.value/e)-12);if(r===0||K.length>=r||K.length>=n)return;let advance=()=>{K.ensure(t,Math.min(r-1,K.length+ue)),Ae.value++};if(typeof requestAnimationFrame!=`function`){advance();return}let i=requestAnimationFrame(advance);return()=>cancelAnimationFrame(i)});let Q=B.value?ve(R.value,Ee.value,Oe.value):[];V.value>=Q.length&&(V.value=Math.max(0,Q.length-1));let Je=[];if(Q.length>0){let e=firstMatchFrom(Q,q.startOf(X)),t=Z>=J?Q.length:firstMatchFrom(Q,q.startOf(Z));Je=toDecorations(q,Q.slice(e,t),V.value-e,{match:S.match,current:S.matchCurrent})}let Ye=typeof w==`function`?w(R.value):w??[],Xe=[];if(T){let e=matchBracket(R.value,H.value);e&&(Xe=toBracketDecorations(q,e,S.bracketMatch))}let Ze=[...Ye,...Xe,...Je],Qe=Ze.length>0?Ze:void 0,selectMatch=e=>{let t=Q[e],n=j.current;if(!(!t||!n)&&(n.focus(),n.setSelectionRange(t.start,t.end),L.current={start:t.start,end:t.end},Y>0)){let e=ge(n.value).lineAt(t.start)*Y;(e<n.scrollTop||e>n.scrollTop+n.clientHeight-Y)&&(n.scrollTop=Math.max(0,e-n.clientHeight/2))}},findNext=()=>{Q.length!==0&&(V.value=(V.value+1)%Q.length,selectMatch(V.value))},findPrev=()=>{Q.length!==0&&(V.value=(V.value-1+Q.length)%Q.length,selectMatch(V.value))},replaceCurrent=()=>{let e=Q[V.value],t=j.current;!e||!t||v||y||(t.setRangeText(De.value,e.start,e.end,`end`),commit(t.value,{start:t.selectionStart,end:t.selectionEnd},!1))},replaceAllNow=()=>{if(Q.length===0||v||y)return;let e=replaceAll(R.value,Q,De.value),t=j.current;t&&(t.value=e),commit(e,{start:t?.selectionStart??0,end:t?.selectionEnd??0},!1)},openFind=e=>{ke.value=e,B.value=!0},closeFind=()=>{B.value=!1,j.current?.focus()},$=U.value?filterCommands(E??[],Me.value):[];W.value>=$.length&&(W.value=Math.max(0,$.length-1));let $e=$.map(e=>({id:e.id,label:e.label,...e.hint!==void 0&&{hint:e.hint}})),{anchorStyle:et,floatingStyle:tt}=t({anchorRef:Fe,floatingRef:Ie,placement:`bottom-start`,enabled:U}),nt={applyEdit:({from:e,to:t},n)=>{let r=j.current;r&&(r.setRangeText(n,e,t,`end`),commit(r.value,{start:r.selectionStart,end:r.selectionEnd},!1))},getSelection:()=>{let e=j.current;return e?{start:e.selectionStart,end:e.selectionEnd}:{...L.current}},focus:()=>j.current?.focus(),undo:doUndo,redo:doRedo,openFind:()=>openFind(!1),openCommandMenu:()=>{let e=j.current;!e||!E||E.length===0||v||y||(e.focus(),e.setRangeText(`/`,e.selectionStart,e.selectionEnd,`end`),commit(e.value,{start:e.selectionStart,end:e.selectionEnd},!1),H.value=e.selectionStart,L.current={start:e.selectionStart,end:e.selectionEnd})}};ee(fe,()=>nt);let selectCommand=e=>{let t=$[e],n=j.current;if(!t||!n||v||y)return;let r=je.value,i=n.selectionStart;n.setRangeText(t.insert??``,r,i,`end`),commit(n.value,{start:n.selectionStart,end:n.selectionEnd},!1),H.value=n.selectionStart,L.current={start:n.selectionStart,end:n.selectionEnd},U.value=!1,W.value=0,n.focus(),t.run?.(nt)},handleKeyDown=e=>{let t=e.currentTarget,n=!v&&!y,r={};if(n){let{indent:e,dedent:t}=createIndentCommands({tabSize:h,insertSpaces:g});r.Tab=e,r[`Shift-Tab`]=t,r[`Mod-z`]=()=>(doUndo(),!0);let redo=()=>(doRedo(),!0);r[`Mod-Shift-z`]=redo,r[`Mod-y`]=redo}if(r[`Mod-f`]=()=>(openFind(!1),!0),r[`Mod-Alt-f`]=()=>(openFind(!0),!0),r[`Mod-s`]=()=>{let e=pe.current;return e?(e(k.value),!0):!1},B.value&&(r.Escape=()=>(closeFind(),!0)),U.value){let move=e=>()=>{let t=$.length;return t>0&&(W.value=(W.value+e+t)%t),!0};r.ArrowDown=move(1),r.ArrowUp=move(-1);let choose=()=>($.length>0&&selectCommand(W.value),!0);r.Enter=choose,r.Tab=choose,r.Escape=()=>(Ne.value=je.value,U.value=!1,!0)}dispatch(mergeKeymap(r,x),{textarea:t,event:e,setText:commitFromCommand})&&e.preventDefault(),O?.(e)},rt={"--cascivo-editor-tab-size":h,...se,...ce};return f(`div`,{ref:ye,className:e(C.root,D),"data-wrap":_,"data-line-numbers":m,style:rt,children:[m&&d(Gutter,{count:J,className:C.gutter,gutterRef:be,start:X,end:Z,topPad:Ke,bottomPad:qe,activeLine:!0}),f(`div`,{className:C.codeArea,children:[f(`pre`,{ref:A,className:C.pre,"aria-hidden":`true`,children:[d(`div`,{className:C.currentLine}),Ke>0&&d(`div`,{style:{blockSize:Ke}}),d(`code`,{children:renderRows(Ge,X,Z,Qe)}),qe>0&&d(`div`,{style:{blockSize:qe}})]}),d(`textarea`,{ref:j,className:C.textarea,value:k.value,onChange:e=>{let t=e.currentTarget,n=t.value,r=Math.abs(n.length-F.current.length)===1;commit(n,{start:t.selectionStart,end:t.selectionEnd},r)},onKeyDown:handleKeyDown,readOnly:v,disabled:y,spellCheck:ie,role:`combobox`,"aria-label":oe??ae??c(s.editor.label),"aria-expanded":U.value,"aria-controls":U.value?Le:void 0,"aria-activedescendant":U.value?`${Le}-opt-${W.value}`:void 0,autoCapitalize:`off`,autoCorrect:`off`,autoComplete:`off`,wrap:_?`soft`:`off`,...de}),d(`div`,{ref:Fe,"aria-hidden":`true`,style:{position:`absolute`,inlineSize:0,blockSize:0,...et}}),U.value&&d(le,{ref:Ie,id:Le,items:$e,activeIndex:W.value,onSelect:selectCommand,onHover:e=>W.value=e,style:tt}),B.value&&d(FindPanel,{query:Ee.value,replaceQuery:De.value,replaceMode:ke.value,caseSensitive:Oe.value,matchCount:Q.length,currentIndex:Q.length>0?V.value:-1,onQueryChange:e=>{Ee.value=e,V.value=0},onReplaceChange:e=>De.value=e,onNext:findNext,onPrev:findPrev,onReplace:replaceCurrent,onReplaceAll:replaceAllNow,onToggleCase:()=>Oe.value=!Oe.value,onToggleReplace:()=>ke.value=!ke.value,onClose:closeFind})]})]})});function Highlight({value:t,language:n=`plaintext`,lineNumbers:r=!1,wrap:i=!1,tabSize:a=2,label:s,ariaLabel:c,className:l,preRef:ee,gutterRef:u,style:p,...te}){o();let ne=getGrammar(n),m=t.split(`
|
|
12
|
+
`),h=tokenizeRange(ne,m,0,m.length,createLineStateIndex(ne)),g={"--cascivo-editor-tab-size":a,...p};return f(`div`,{className:e(S.root,l),"data-wrap":i,"data-line-numbers":r,style:g,"aria-label":c??s,...te,children:[r&&d(Gutter,{count:h.length,className:S.gutter,gutterRef:u}),d(`pre`,{ref:ee,className:S.pre,children:d(`code`,{className:S.code,children:renderRows(h)})})]})}export{de as CodeEditor,Highlight,b as bash,createLineStateIndex,createRuleGrammar,ie as css,getGrammar,ae as html,v as javascript,_ as json,listGrammars,oe as markdown,g as plaintext,registerGrammar,tokenize,tokenizeDocument,tokenizeRange,y as typescript};
|