@tectra-ng/code-editor 0.0.0-stage → 0.2.2

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,1219 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, ViewEncapsulation, booleanAttribute, computed, inject, input, numberAttribute } from "@angular/core";
3
+ import { injectPassThrough, injectUnstyled } from "@tectra-ng/core/config";
4
+ import { injectTranslations } from "@tectra-ng/core/i18n";
5
+ import { TxStyleLoader } from "@tectra-ng/core/styles";
6
+ import { optionalBoolean } from "@tectra-ng/core/utils";
7
+ import { toStyleObject } from "@tectra-ng/themes";
8
+ const STICKY = /* @__PURE__ */ new WeakMap();
9
+ function sticky(pattern) {
10
+ let compiled = STICKY.get(pattern);
11
+ if (!compiled) {
12
+ compiled = new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, "") + "y");
13
+ STICKY.set(pattern, compiled);
14
+ }
15
+ return compiled;
16
+ }
17
+ var TxCodeStream = class {
18
+ string;
19
+ pos = 0;
20
+ start = 0;
21
+ constructor(string) {
22
+ this.string = string;
23
+ }
24
+ eol() {
25
+ return this.pos >= this.string.length;
26
+ }
27
+ sol() {
28
+ return this.pos === 0;
29
+ }
30
+ peek(offset = 0) {
31
+ return this.string.charAt(this.pos + offset);
32
+ }
33
+ next() {
34
+ return this.pos < this.string.length ? this.string.charAt(this.pos++) : "";
35
+ }
36
+ eat(match) {
37
+ const char = this.peek();
38
+ if (char && (typeof match === "string" ? char === match : match.test(char))) {
39
+ this.pos++;
40
+ return char;
41
+ }
42
+ return "";
43
+ }
44
+ eatWhile(match) {
45
+ const start = this.pos;
46
+ while (this.eat(match));
47
+ return this.pos > start;
48
+ }
49
+ eatSpace() {
50
+ return this.eatWhile(/\s/);
51
+ }
52
+ skipToEnd() {
53
+ this.pos = this.string.length;
54
+ }
55
+ skipTo(text) {
56
+ const index = this.string.indexOf(text, this.pos);
57
+ if (index < 0) return false;
58
+ this.pos = index;
59
+ return true;
60
+ }
61
+ match(pattern, consume = true) {
62
+ const compiled = sticky(pattern);
63
+ compiled.lastIndex = this.pos;
64
+ const found = compiled.exec(this.string);
65
+ if (found && consume) this.pos += found[0].length;
66
+ return found;
67
+ }
68
+ matchText(text, consume = true, ignoreCase = false) {
69
+ const slice = this.string.substr(this.pos, text.length);
70
+ const same = ignoreCase ? slice.toLowerCase() === text.toLowerCase() : slice === text;
71
+ if (same && consume) this.pos += text.length;
72
+ return same;
73
+ }
74
+ current() {
75
+ return this.string.slice(this.start, this.pos);
76
+ }
77
+ rest() {
78
+ return this.string.slice(this.pos);
79
+ }
80
+ before() {
81
+ return this.string.slice(0, this.start);
82
+ }
83
+ };
84
+ function tokenInside(stream, end, run) {
85
+ const inner = new TxCodeStream(stream.string.slice(0, end));
86
+ inner.pos = stream.pos;
87
+ inner.start = stream.pos;
88
+ const result = run(inner);
89
+ stream.pos = inner.pos;
90
+ return result;
91
+ }
92
+ const NUMBER$2 = /[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:%|[a-zA-Z]+)?/;
93
+ const WORD = /-?[A-Za-z_\u00a0-\uffff][\w\u00a0-\uffff-]*/;
94
+ const PROPERTY = /--?[A-Za-z_][\w-]*(?=\s*:(?![^;{}]*\{))|[A-Za-z][\w-]*(?=\s*:(?![^;{}]*\{))/;
95
+ function quoted$1(stream, state) {
96
+ let escaped = false;
97
+ while (!stream.eol()) {
98
+ const char = stream.next();
99
+ if (char === state.quote && !escaped) {
100
+ state.quote = "";
101
+ return "string";
102
+ }
103
+ escaped = !escaped && char === "\\";
104
+ }
105
+ if (!escaped) state.quote = "";
106
+ return "string";
107
+ }
108
+ function cssToken(stream, state) {
109
+ if (state.comment) {
110
+ if (stream.skipTo("*/")) {
111
+ stream.pos += 2;
112
+ state.comment = false;
113
+ } else stream.skipToEnd();
114
+ return "comment";
115
+ }
116
+ if (state.quote) return quoted$1(stream, state);
117
+ if (stream.eatSpace()) return null;
118
+ if (stream.matchText("/*")) {
119
+ state.comment = true;
120
+ return cssToken(stream, state) ?? "comment";
121
+ }
122
+ const char = stream.peek();
123
+ if (char === "\"" || char === "'") {
124
+ stream.next();
125
+ state.quote = char;
126
+ return quoted$1(stream, state);
127
+ }
128
+ if (char === "{") {
129
+ stream.next();
130
+ state.depth++;
131
+ state.value = false;
132
+ state.prelude = false;
133
+ return "delimiter";
134
+ }
135
+ if (char === "}") {
136
+ stream.next();
137
+ state.depth = Math.max(0, state.depth - 1);
138
+ state.value = false;
139
+ return "delimiter";
140
+ }
141
+ if (char === ";") {
142
+ stream.next();
143
+ state.value = false;
144
+ state.prelude = false;
145
+ return "delimiter";
146
+ }
147
+ if (char === "@" && stream.match(/@[\w-]+/)) {
148
+ state.prelude = true;
149
+ return "keyword";
150
+ }
151
+ if (state.value || state.prelude) {
152
+ if (stream.match(/!\s*important/i)) return "keyword";
153
+ if (char === "#" && stream.match(/#[\da-fA-F]{3,8}\b/)) return "value";
154
+ if (/[\d.+-]/.test(char) && stream.match(NUMBER$2)) return "number";
155
+ if (state.prelude && stream.match(PROPERTY)) return "attribute";
156
+ if (stream.match(WORD)) return "value";
157
+ stream.next();
158
+ return "delimiter";
159
+ }
160
+ if (state.depth > 0 && stream.match(PROPERTY)) return "attribute";
161
+ if (char === ":" && state.depth > 0 && stream.match(/:(?![^;{}]*\{)/)) {
162
+ state.value = true;
163
+ return "delimiter";
164
+ }
165
+ if (char === "," || char === ">" || char === "+" || char === "~" || char === "(" || char === ")") {
166
+ stream.next();
167
+ return "delimiter";
168
+ }
169
+ if (stream.match(/[^\s{},;/"'>+~()]+/)) return "tag";
170
+ stream.next();
171
+ return "delimiter";
172
+ }
173
+ const TX_CSS_MODE = {
174
+ language: "css",
175
+ comments: { block: ["/*", "*/"] },
176
+ start: () => ({
177
+ comment: false,
178
+ depth: 0,
179
+ value: false,
180
+ prelude: false,
181
+ quote: ""
182
+ }),
183
+ copy: (state) => ({ ...state }),
184
+ token: cssToken
185
+ };
186
+ const SHARED_KEYWORDS = [
187
+ "async",
188
+ "await",
189
+ "break",
190
+ "case",
191
+ "catch",
192
+ "class",
193
+ "const",
194
+ "constructor",
195
+ "continue",
196
+ "debugger",
197
+ "default",
198
+ "delete",
199
+ "do",
200
+ "else",
201
+ "export",
202
+ "extends",
203
+ "false",
204
+ "finally",
205
+ "for",
206
+ "from",
207
+ "function",
208
+ "get",
209
+ "if",
210
+ "import",
211
+ "in",
212
+ "instanceof",
213
+ "let",
214
+ "new",
215
+ "null",
216
+ "of",
217
+ "return",
218
+ "set",
219
+ "static",
220
+ "super",
221
+ "switch",
222
+ "symbol",
223
+ "this",
224
+ "throw",
225
+ "true",
226
+ "try",
227
+ "typeof",
228
+ "undefined",
229
+ "var",
230
+ "void",
231
+ "while",
232
+ "with",
233
+ "yield"
234
+ ];
235
+ const TYPESCRIPT_KEYWORDS = [
236
+ "abstract",
237
+ "any",
238
+ "as",
239
+ "asserts",
240
+ "bigint",
241
+ "boolean",
242
+ "declare",
243
+ "enum",
244
+ "global",
245
+ "implements",
246
+ "infer",
247
+ "interface",
248
+ "is",
249
+ "keyof",
250
+ "module",
251
+ "namespace",
252
+ "never",
253
+ "number",
254
+ "object",
255
+ "out",
256
+ "override",
257
+ "package",
258
+ "private",
259
+ "protected",
260
+ "public",
261
+ "readonly",
262
+ "require",
263
+ "satisfies",
264
+ "string",
265
+ "type",
266
+ "unique",
267
+ "unknown"
268
+ ];
269
+ const JAVASCRIPT = new Set(SHARED_KEYWORDS);
270
+ const TYPESCRIPT = /* @__PURE__ */ new Set([...SHARED_KEYWORDS, ...TYPESCRIPT_KEYWORDS]);
271
+ const VALUE_KEYWORDS = /* @__PURE__ */ new Set([
272
+ "this",
273
+ "super",
274
+ "null",
275
+ "true",
276
+ "false",
277
+ "undefined"
278
+ ]);
279
+ const NUMBER$1 = /0[xX][\da-fA-F_]+n?|0[bB][01_]+n?|0[oO][0-7_]+n?|(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:[eE][+-]?\d+)?n?/;
280
+ const IDENTIFIER = /[A-Za-z_$\u00a0-\uffff][\w$\u00a0-\uffff]*/;
281
+ const REGEXP = /\/(?![*/])(?:\\.|\[(?:\\.|[^\]\\])*\]|[^/\\\n[])+\/[dgimsuvy]*/;
282
+ const OPERATOR = /[=><!~?:&|+\-*/^%]+/;
283
+ function quoted(stream, quote) {
284
+ let escaped = false;
285
+ while (!stream.eol()) {
286
+ const char = stream.next();
287
+ if (char === quote && !escaped) return;
288
+ escaped = !escaped && char === "\\";
289
+ }
290
+ }
291
+ function templateText(stream, state) {
292
+ while (!stream.eol()) {
293
+ if (stream.matchText("`")) {
294
+ state.stack.pop();
295
+ state.regexAllowed = false;
296
+ return "string";
297
+ }
298
+ if (stream.matchText("${", false)) {
299
+ if (stream.pos === stream.start) {
300
+ stream.pos += 2;
301
+ state.stack.push("expression");
302
+ state.regexAllowed = true;
303
+ return "delimiter";
304
+ }
305
+ return "string";
306
+ }
307
+ if (stream.next() === "\\") stream.next();
308
+ }
309
+ return "string";
310
+ }
311
+ function scriptToken(stream, state, keywords) {
312
+ if (state.comment) {
313
+ if (stream.skipTo("*/")) {
314
+ stream.pos += 2;
315
+ state.comment = false;
316
+ } else stream.skipToEnd();
317
+ return "comment";
318
+ }
319
+ if (state.stack[state.stack.length - 1] === "template") return templateText(stream, state);
320
+ if (stream.eatSpace()) return null;
321
+ if (stream.matchText("//")) {
322
+ stream.skipToEnd();
323
+ return "comment";
324
+ }
325
+ if (stream.matchText("/*")) {
326
+ state.comment = true;
327
+ return scriptToken(stream, state, keywords) ?? "comment";
328
+ }
329
+ const char = stream.peek();
330
+ const afterDot = state.afterDot;
331
+ state.afterDot = false;
332
+ if (char === "\"" || char === "'") {
333
+ stream.next();
334
+ quoted(stream, char);
335
+ state.regexAllowed = false;
336
+ return "string";
337
+ }
338
+ if (char === "`") {
339
+ stream.next();
340
+ state.stack.push("template");
341
+ return templateText(stream, state);
342
+ }
343
+ if (/[\d.]/.test(char) && stream.match(NUMBER$1)) {
344
+ state.regexAllowed = false;
345
+ return "number";
346
+ }
347
+ if (char === "/" && state.regexAllowed && stream.match(REGEXP)) {
348
+ state.regexAllowed = false;
349
+ return "regexp";
350
+ }
351
+ const word = stream.match(IDENTIFIER);
352
+ if (word) {
353
+ const name = word[0];
354
+ if (!afterDot && keywords.has(name)) {
355
+ state.regexAllowed = !VALUE_KEYWORDS.has(name);
356
+ return "keyword";
357
+ }
358
+ state.regexAllowed = false;
359
+ return /^[A-Z]/.test(name) ? "type" : null;
360
+ }
361
+ stream.next();
362
+ if (char === ".") {
363
+ state.afterDot = true;
364
+ state.regexAllowed = false;
365
+ return "delimiter";
366
+ }
367
+ if (char === "{") {
368
+ state.stack.push("brace");
369
+ state.regexAllowed = true;
370
+ return "delimiter";
371
+ }
372
+ if (char === "}") {
373
+ if (state.stack.pop() === "expression") {
374
+ state.regexAllowed = false;
375
+ return "delimiter";
376
+ }
377
+ state.regexAllowed = true;
378
+ return "delimiter";
379
+ }
380
+ if (char === ")" || char === "]") {
381
+ state.regexAllowed = false;
382
+ return "delimiter";
383
+ }
384
+ if (char === "@") {
385
+ stream.match(IDENTIFIER);
386
+ return "type";
387
+ }
388
+ if (OPERATOR.test(char)) stream.match(OPERATOR);
389
+ state.regexAllowed = true;
390
+ return "delimiter";
391
+ }
392
+ function scriptMode(language, keywords) {
393
+ return {
394
+ language,
395
+ comments: {
396
+ line: "//",
397
+ block: ["/*", "*/"]
398
+ },
399
+ start: () => ({
400
+ comment: false,
401
+ stack: [],
402
+ regexAllowed: true,
403
+ afterDot: false
404
+ }),
405
+ copy: (state) => ({
406
+ ...state,
407
+ stack: [...state.stack]
408
+ }),
409
+ token: (stream, state) => scriptToken(stream, state, keywords)
410
+ };
411
+ }
412
+ const TX_JAVASCRIPT_MODE = scriptMode("javascript", JAVASCRIPT);
413
+ const TX_TYPESCRIPT_MODE = scriptMode("typescript", TYPESCRIPT);
414
+ const NUMBER = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
415
+ function jsonToken(stream, state) {
416
+ if (state.comment) {
417
+ if (stream.skipTo("*/")) {
418
+ stream.pos += 2;
419
+ state.comment = false;
420
+ } else stream.skipToEnd();
421
+ return "comment";
422
+ }
423
+ if (stream.eatSpace()) return null;
424
+ if (stream.matchText("//")) {
425
+ stream.skipToEnd();
426
+ return "comment";
427
+ }
428
+ if (stream.matchText("/*")) {
429
+ state.comment = true;
430
+ return jsonToken(stream, state) ?? "comment";
431
+ }
432
+ if (stream.peek() === "\"") {
433
+ stream.next();
434
+ let escaped = false;
435
+ while (!stream.eol()) {
436
+ const next = stream.next();
437
+ if (next === "\"" && !escaped) break;
438
+ escaped = !escaped && next === "\\";
439
+ }
440
+ return stream.match(/\s*:/, false) ? "key" : "value";
441
+ }
442
+ if (stream.match(NUMBER)) return "number";
443
+ if (stream.match(/true|false|null/)) return "literal";
444
+ stream.next();
445
+ return "delimiter";
446
+ }
447
+ const TX_JSON_MODE = {
448
+ language: "json",
449
+ comments: {
450
+ line: "//",
451
+ block: ["/*", "*/"]
452
+ },
453
+ start: () => ({ comment: false }),
454
+ copy: (state) => ({ ...state }),
455
+ token: jsonToken
456
+ };
457
+ const RAW_TAGS = /* @__PURE__ */ new Set([
458
+ "script",
459
+ "style",
460
+ "textarea",
461
+ "title"
462
+ ]);
463
+ function embedFor(tag, scriptType) {
464
+ let mode = null;
465
+ if (tag === "style") mode = TX_CSS_MODE;
466
+ else if (tag === "script") {
467
+ const type = scriptType.toLowerCase();
468
+ if (type.includes("json")) mode = TX_JSON_MODE;
469
+ else if (!type || type === "module" || type.includes("javascript") || type.includes("ecmascript")) mode = TX_JAVASCRIPT_MODE;
470
+ }
471
+ return {
472
+ mode,
473
+ state: mode?.start() ?? null
474
+ };
475
+ }
476
+ function embeddedToken(stream, state) {
477
+ const embed = state.embed;
478
+ const close = stream.string.toLowerCase().indexOf(`</${state.tagName}`, stream.pos);
479
+ const end = close < 0 ? stream.string.length : close;
480
+ if (stream.pos >= end) {
481
+ state.context = "text";
482
+ state.embed = null;
483
+ return htmlToken(stream, state);
484
+ }
485
+ if (!embed?.mode) {
486
+ stream.pos = end;
487
+ return null;
488
+ }
489
+ const mode = embed.mode;
490
+ return tokenInside(stream, end, (inner) => {
491
+ const type = mode.token(inner, embed.state);
492
+ if (inner.pos === inner.start) inner.next();
493
+ return type;
494
+ });
495
+ }
496
+ function attributeValue(stream, state) {
497
+ const start = stream.pos;
498
+ if (stream.skipTo(state.quote)) {
499
+ stream.pos++;
500
+ if (state.attribute === "type") state.scriptType += stream.string.slice(start, stream.pos - 1);
501
+ state.quote = "";
502
+ } else {
503
+ if (state.attribute === "type") state.scriptType += stream.string.slice(start);
504
+ stream.skipToEnd();
505
+ }
506
+ return "attribute-value";
507
+ }
508
+ function tagToken(stream, state) {
509
+ if (state.quote) return attributeValue(stream, state);
510
+ if (stream.eatSpace()) return null;
511
+ if (state.expectName) {
512
+ state.expectName = false;
513
+ const name = stream.match(/[A-Za-z][\w:.-]*/);
514
+ if (name) {
515
+ state.tagName = name[0].toLowerCase();
516
+ return "tag";
517
+ }
518
+ }
519
+ if (stream.matchText("/>")) {
520
+ state.context = "text";
521
+ return "tag-delimiter";
522
+ }
523
+ if (stream.matchText(">")) {
524
+ const raw = !state.closing && RAW_TAGS.has(state.tagName);
525
+ state.context = raw ? "embedded" : "text";
526
+ state.embed = raw ? embedFor(state.tagName, state.scriptType) : null;
527
+ return "tag-delimiter";
528
+ }
529
+ if (state.afterEquals) {
530
+ state.afterEquals = false;
531
+ const char = stream.peek();
532
+ if (char === "\"" || char === "'") {
533
+ stream.next();
534
+ state.quote = char;
535
+ return attributeValue(stream, state);
536
+ }
537
+ const value = stream.match(/[^\s"'`=<>]+/);
538
+ if (value) {
539
+ if (state.attribute === "type") state.scriptType = value[0];
540
+ return "attribute-value";
541
+ }
542
+ }
543
+ if (stream.eat("=")) {
544
+ state.afterEquals = true;
545
+ return "delimiter";
546
+ }
547
+ const attribute = stream.match(/[^\s"'>/=]+/);
548
+ if (attribute) {
549
+ state.attribute = attribute[0].toLowerCase();
550
+ return "attribute";
551
+ }
552
+ stream.next();
553
+ return "tag-delimiter";
554
+ }
555
+ function htmlToken(stream, state) {
556
+ switch (state.context) {
557
+ case "comment":
558
+ if (stream.skipTo("-->")) {
559
+ stream.pos += 3;
560
+ state.context = "text";
561
+ } else stream.skipToEnd();
562
+ return "comment";
563
+ case "doctype":
564
+ if (stream.eat(">")) {
565
+ state.context = "text";
566
+ return "meta";
567
+ }
568
+ if (stream.eatSpace()) return null;
569
+ stream.match(/[^>\s]+/);
570
+ return "attribute";
571
+ case "embedded": return embeddedToken(stream, state);
572
+ case "tag": return tagToken(stream, state);
573
+ }
574
+ if (stream.matchText("<!--")) {
575
+ state.context = "comment";
576
+ return htmlToken(stream, state);
577
+ }
578
+ if (stream.match(/<!doctype/i)) {
579
+ state.context = "doctype";
580
+ return "meta";
581
+ }
582
+ const open = stream.match(/<\/?(?=[A-Za-z])/);
583
+ if (open) {
584
+ state.context = "tag";
585
+ state.closing = open[0] === "</";
586
+ state.expectName = true;
587
+ state.afterEquals = false;
588
+ state.attribute = "";
589
+ state.scriptType = state.closing ? state.scriptType : "";
590
+ return "tag-delimiter";
591
+ }
592
+ if (!stream.match(/[^<]+/)) stream.next();
593
+ return null;
594
+ }
595
+ const TX_HTML_MODE = {
596
+ language: "html",
597
+ comments: { block: ["<!--", "-->"] },
598
+ start: () => ({
599
+ context: "text",
600
+ tagName: "",
601
+ closing: false,
602
+ expectName: false,
603
+ afterEquals: false,
604
+ quote: "",
605
+ attribute: "",
606
+ scriptType: "",
607
+ embed: null
608
+ }),
609
+ copy: (state) => ({
610
+ ...state,
611
+ embed: state.embed ? {
612
+ mode: state.embed.mode,
613
+ state: state.embed.mode ? state.embed.mode.copy(state.embed.state) : null
614
+ } : null
615
+ }),
616
+ token: htmlToken
617
+ };
618
+ const FENCE = /^\s*(`{3,}|~{3,})\s*([\w+#.-]*).*$/;
619
+ function inline(stream) {
620
+ const char = stream.peek();
621
+ if (char === "\\") {
622
+ stream.next();
623
+ stream.next();
624
+ return null;
625
+ }
626
+ if (char === "`" && stream.match(/(`+)(?:(?!\1).)+?\1|`+.*$/)) return "code";
627
+ if ((char === "*" || char === "_") && (char === "*" || !/\w/.test(stream.string.charAt(stream.pos - 1)))) {
628
+ if (stream.match(/(\*\*|__)(?=\S)(?:(?!\1).)+?\1/)) return "strong";
629
+ if (stream.match(/(\*|_)(?=[^\s*_])(?:(?!\1).)+?\1/)) return "emphasis";
630
+ }
631
+ if ((char === "[" || char === "!") && stream.match(/!?\[[^\]]*\]\([^)]*\)/)) return "link";
632
+ if (char === "<") {
633
+ if (stream.match(/<!--.*?-->/)) return "comment";
634
+ if (stream.match(/<https?:[^>\s]+>/)) return "link";
635
+ if (stream.match(/<\/?[A-Za-z][^>]*>/)) return "tag";
636
+ }
637
+ if (char === "h" && stream.match(/https?:\/\/[^\s<>()]+/)) return "link";
638
+ if (!stream.match(/[^`*_[!<\\h]+/)) stream.next();
639
+ return null;
640
+ }
641
+ function createMarkdownMode(modes) {
642
+ function token(stream, state) {
643
+ if (stream.sol()) {
644
+ const fence = stream.match(FENCE, false);
645
+ if (state.fence) {
646
+ if (fence && fence[1][0] === state.fence[0] && fence[1].length >= state.fence.length && !fence[2]) {
647
+ stream.skipToEnd();
648
+ state.fence = "";
649
+ state.inner = null;
650
+ state.innerState = null;
651
+ return "string";
652
+ }
653
+ } else if (fence) {
654
+ stream.skipToEnd();
655
+ state.fence = fence[1];
656
+ const language = modes.resolve(fence[2]);
657
+ state.inner = language && language !== "plain" ? modes.mode(language) : null;
658
+ state.innerState = state.inner?.start() ?? null;
659
+ return "string";
660
+ } else {
661
+ if (stream.match(/#{1,6}(?=\s|$)/, false)) {
662
+ stream.skipToEnd();
663
+ return "heading";
664
+ }
665
+ if (stream.match(/\s{0,3}>/, false)) {
666
+ stream.skipToEnd();
667
+ return "quote";
668
+ }
669
+ if (stream.match(/\s{0,3}([-*_])(?:\s*\1){2,}\s*$/)) return "keyword";
670
+ if (stream.match(/\s*(?:[*+-]|\d+[.)])(?=\s)/)) return "keyword";
671
+ }
672
+ }
673
+ if (state.fence) {
674
+ if (!state.inner) {
675
+ stream.skipToEnd();
676
+ return "code";
677
+ }
678
+ const type = state.inner.token(stream, state.innerState);
679
+ if (stream.pos === stream.start) stream.next();
680
+ return type;
681
+ }
682
+ return inline(stream);
683
+ }
684
+ return {
685
+ language: "markdown",
686
+ comments: { block: ["<!--", "-->"] },
687
+ start: () => ({
688
+ fence: "",
689
+ inner: null,
690
+ innerState: null
691
+ }),
692
+ copy: (state) => ({
693
+ ...state,
694
+ innerState: state.inner ? state.inner.copy(state.innerState) : null
695
+ }),
696
+ token
697
+ };
698
+ }
699
+ const ALIASES = {
700
+ html: "html",
701
+ htm: "html",
702
+ xhtml: "html",
703
+ xml: "html",
704
+ svg: "html",
705
+ vue: "html",
706
+ css: "css",
707
+ javascript: "javascript",
708
+ js: "javascript",
709
+ jsx: "javascript",
710
+ mjs: "javascript",
711
+ cjs: "javascript",
712
+ typescript: "typescript",
713
+ ts: "typescript",
714
+ tsx: "typescript",
715
+ json: "json",
716
+ jsonc: "json",
717
+ json5: "json",
718
+ markdown: "markdown",
719
+ md: "markdown",
720
+ plain: "plain",
721
+ plaintext: "plain",
722
+ text: "plain",
723
+ txt: "plain"
724
+ };
725
+ function resolveCodeLanguage(name) {
726
+ return name ? ALIASES[name.trim().toLowerCase()] ?? null : null;
727
+ }
728
+ const MODES = {
729
+ html: TX_HTML_MODE,
730
+ css: TX_CSS_MODE,
731
+ javascript: TX_JAVASCRIPT_MODE,
732
+ typescript: TX_TYPESCRIPT_MODE,
733
+ json: TX_JSON_MODE,
734
+ markdown: createMarkdownMode({
735
+ resolve: resolveCodeLanguage,
736
+ mode: getCodeMode
737
+ }),
738
+ plain: {
739
+ language: "plain",
740
+ comments: {},
741
+ start: () => null,
742
+ copy: () => null,
743
+ token: (stream) => {
744
+ stream.skipToEnd();
745
+ return null;
746
+ }
747
+ }
748
+ };
749
+ function getCodeMode(language) {
750
+ return MODES[resolveCodeLanguage(language) ?? "plain"];
751
+ }
752
+ function tokenizeLine(mode, text, state) {
753
+ const stream = new TxCodeStream(text);
754
+ const tokens = [];
755
+ while (!stream.eol()) {
756
+ stream.start = stream.pos;
757
+ const type = mode.token(stream, state);
758
+ if (stream.pos <= stream.start) stream.pos = stream.start + 1;
759
+ if (type) pushToken(tokens, stream.start, stream.pos, type);
760
+ }
761
+ return tokens;
762
+ }
763
+ function pushToken(tokens, from, to, type) {
764
+ const last = tokens[tokens.length - 1];
765
+ if (last && last.type === type && last.to === from) tokens[tokens.length - 1] = {
766
+ from: last.from,
767
+ to,
768
+ type
769
+ };
770
+ else tokens.push({
771
+ from,
772
+ to,
773
+ type
774
+ });
775
+ }
776
+ function splitCodeLines(code) {
777
+ return code.split(/\r\n?|\n/);
778
+ }
779
+ function highlightCode(code, language = "plain") {
780
+ const mode = getCodeMode(language);
781
+ const state = mode.start();
782
+ return splitCodeLines(code).map((line) => tokenizeLine(mode, line, state));
783
+ }
784
+ var TxCodeLineStates = class {
785
+ mode;
786
+ states;
787
+ constructor(mode) {
788
+ this.mode = mode;
789
+ this.states = [mode.start()];
790
+ }
791
+ get language() {
792
+ return this.mode.language;
793
+ }
794
+ invalidateFrom(line) {
795
+ if (this.states.length > line + 1) this.states.length = Math.max(1, line + 1);
796
+ }
797
+ tokens(line, lineText) {
798
+ while (this.states.length <= line) {
799
+ const index = this.states.length - 1;
800
+ const state = this.mode.copy(this.states[index]);
801
+ tokenizeLine(this.mode, lineText(index), state);
802
+ this.states.push(state);
803
+ }
804
+ return tokenizeLine(this.mode, lineText(line), this.mode.copy(this.states[line]));
805
+ }
806
+ };
807
+ function indentWidth(text, tabSize) {
808
+ let columns = 0;
809
+ for (const char of text) if (char === " ") columns++;
810
+ else if (char === " ") columns += tabSize - columns % tabSize;
811
+ else return columns;
812
+ return null;
813
+ }
814
+ function guideLevels(count, lineText, tabSize = 4, from = 0, to = count, reach = 200) {
815
+ const width = (index) => indentWidth(lineText(index), tabSize);
816
+ const nearest = (index, step) => {
817
+ for (let other = index + step, seen = 0; other >= 0 && other < count && seen < reach; other += step, seen++) {
818
+ const value = width(other);
819
+ if (value !== null) return value;
820
+ }
821
+ return 0;
822
+ };
823
+ const levels = [];
824
+ for (let index = from; index < to; index++) {
825
+ const columns = width(index) ?? Math.min(nearest(index, -1), nearest(index, 1));
826
+ levels.push(Math.ceil(columns / tabSize));
827
+ }
828
+ return levels;
829
+ }
830
+ function lineIndent(text, tabSize = 4) {
831
+ let columns = 0;
832
+ let index = 0;
833
+ for (; index < text.length; index++) {
834
+ const char = text[index];
835
+ if (char === " ") columns++;
836
+ else if (char === " ") columns += tabSize - columns % tabSize;
837
+ else break;
838
+ }
839
+ return columns > 0 && index < text.length ? `${columns}ch` : null;
840
+ }
841
+ function tokenClass(type) {
842
+ return `tx-code-tok-${type}`;
843
+ }
844
+ function lineSegments(text, tokens) {
845
+ const segments = [];
846
+ let position = 0;
847
+ for (const token of tokens) {
848
+ if (token.from > position) segments.push({
849
+ text: text.slice(position, token.from),
850
+ className: null
851
+ });
852
+ segments.push({
853
+ text: text.slice(token.from, token.to),
854
+ className: tokenClass(token.type)
855
+ });
856
+ position = token.to;
857
+ }
858
+ if (position < text.length) segments.push({
859
+ text: text.slice(position),
860
+ className: null
861
+ });
862
+ return segments;
863
+ }
864
+ function codeLines(code, language, firstLine = 1, tabSize = 4) {
865
+ const texts = splitCodeLines(code);
866
+ const guides = guideLevels(texts.length, (index) => texts[index], tabSize);
867
+ return highlightCode(code, language).map((tokens, index) => ({
868
+ number: firstLine + index,
869
+ segments: lineSegments(texts[index], tokens),
870
+ indent: lineIndent(texts[index], tabSize),
871
+ guides: guides[index]
872
+ }));
873
+ }
874
+ var TxCodeSyntaxStyles = class TxCodeSyntaxStyles {
875
+ static ɵfac = i0.ɵɵngDeclareFactory({
876
+ minVersion: "12.0.0",
877
+ version: "22.2.3",
878
+ ngImport: i0,
879
+ type: TxCodeSyntaxStyles,
880
+ deps: [],
881
+ target: i0.ɵɵFactoryTarget.Component
882
+ });
883
+ static ɵcmp = i0.ɵɵngDeclareComponent({
884
+ minVersion: "14.0.0",
885
+ version: "22.2.3",
886
+ type: TxCodeSyntaxStyles,
887
+ isStandalone: true,
888
+ selector: "tx-code-syntax-styles",
889
+ ngImport: i0,
890
+ template: "",
891
+ isInline: true,
892
+ styles: ["[data-styled] .tx-code-tok-comment,[data-styled] .tx-code-tok-quote{color:var(--tx-code-syntax-comment)}[data-styled] .tx-code-tok-quote{color:var(--tx-code-syntax-quote)}[data-styled] .tx-code-tok-keyword{color:var(--tx-code-syntax-keyword)}[data-styled] .tx-code-tok-literal{color:var(--tx-code-syntax-literal)}[data-styled] .tx-code-tok-string{color:var(--tx-code-syntax-string)}[data-styled] .tx-code-tok-number{color:var(--tx-code-syntax-number)}[data-styled] .tx-code-tok-regexp{color:var(--tx-code-syntax-regexp)}[data-styled] .tx-code-tok-type{color:var(--tx-code-syntax-type)}[data-styled] .tx-code-tok-delimiter{color:var(--tx-code-syntax-delimiter)}[data-styled] .tx-code-tok-tag{color:var(--tx-code-syntax-tag)}[data-styled] .tx-code-tok-tag-delimiter{color:var(--tx-code-syntax-tag-delimiter)}[data-styled] .tx-code-tok-meta{color:var(--tx-code-syntax-meta)}[data-styled] .tx-code-tok-attribute{color:var(--tx-code-syntax-attribute)}[data-styled] .tx-code-tok-attribute-value{color:var(--tx-code-syntax-attribute-value)}[data-styled] .tx-code-tok-value{color:var(--tx-code-syntax-value)}[data-styled] .tx-code-tok-key{color:var(--tx-code-syntax-key)}[data-styled] .tx-code-tok-heading{color:var(--tx-code-syntax-heading);font-weight:var(--tx-code-syntax-heading-weight)}[data-styled] .tx-code-tok-strong{font-weight:var(--tx-code-syntax-strong-weight)}[data-styled] .tx-code-tok-emphasis{font-style:italic}[data-styled] .tx-code-tok-link{color:var(--tx-code-syntax-link);text-decoration:underline}[data-styled] .tx-code-tok-code{color:var(--tx-code-syntax-code)}\n"],
893
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
894
+ encapsulation: i0.ViewEncapsulation.None
895
+ });
896
+ };
897
+ i0.ɵɵngDeclareClassMetadata({
898
+ minVersion: "12.0.0",
899
+ version: "22.2.3",
900
+ ngImport: i0,
901
+ type: TxCodeSyntaxStyles,
902
+ decorators: [{
903
+ type: Component,
904
+ args: [{
905
+ selector: "tx-code-syntax-styles",
906
+ template: "",
907
+ encapsulation: ViewEncapsulation.None,
908
+ changeDetection: ChangeDetectionStrategy.OnPush,
909
+ styles: ["[data-styled] .tx-code-tok-comment,[data-styled] .tx-code-tok-quote{color:var(--tx-code-syntax-comment)}[data-styled] .tx-code-tok-quote{color:var(--tx-code-syntax-quote)}[data-styled] .tx-code-tok-keyword{color:var(--tx-code-syntax-keyword)}[data-styled] .tx-code-tok-literal{color:var(--tx-code-syntax-literal)}[data-styled] .tx-code-tok-string{color:var(--tx-code-syntax-string)}[data-styled] .tx-code-tok-number{color:var(--tx-code-syntax-number)}[data-styled] .tx-code-tok-regexp{color:var(--tx-code-syntax-regexp)}[data-styled] .tx-code-tok-type{color:var(--tx-code-syntax-type)}[data-styled] .tx-code-tok-delimiter{color:var(--tx-code-syntax-delimiter)}[data-styled] .tx-code-tok-tag{color:var(--tx-code-syntax-tag)}[data-styled] .tx-code-tok-tag-delimiter{color:var(--tx-code-syntax-tag-delimiter)}[data-styled] .tx-code-tok-meta{color:var(--tx-code-syntax-meta)}[data-styled] .tx-code-tok-attribute{color:var(--tx-code-syntax-attribute)}[data-styled] .tx-code-tok-attribute-value{color:var(--tx-code-syntax-attribute-value)}[data-styled] .tx-code-tok-value{color:var(--tx-code-syntax-value)}[data-styled] .tx-code-tok-key{color:var(--tx-code-syntax-key)}[data-styled] .tx-code-tok-heading{color:var(--tx-code-syntax-heading);font-weight:var(--tx-code-syntax-heading-weight)}[data-styled] .tx-code-tok-strong{font-weight:var(--tx-code-syntax-strong-weight)}[data-styled] .tx-code-tok-emphasis{font-style:italic}[data-styled] .tx-code-tok-link{color:var(--tx-code-syntax-link);text-decoration:underline}[data-styled] .tx-code-tok-code{color:var(--tx-code-syntax-code)}\n"]
910
+ }]
911
+ }]
912
+ });
913
+ var TxCodeHighlight = class TxCodeHighlight {
914
+ code = input("", ...ngDevMode ? [{ debugName: "code" }] : /* istanbul ignore next */ []);
915
+ language = input("html", ...ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []);
916
+ lineNumbers = input(true, {
917
+ ...ngDevMode ? { debugName: "lineNumbers" } : /* istanbul ignore next */ {},
918
+ transform: booleanAttribute
919
+ });
920
+ wordWrap = input(false, {
921
+ ...ngDevMode ? { debugName: "wordWrap" } : /* istanbul ignore next */ {},
922
+ transform: booleanAttribute
923
+ });
924
+ indentGuides = input(true, {
925
+ ...ngDevMode ? { debugName: "indentGuides" } : /* istanbul ignore next */ {},
926
+ transform: booleanAttribute
927
+ });
928
+ tabSize = input(4, {
929
+ ...ngDevMode ? { debugName: "tabSize" } : /* istanbul ignore next */ {},
930
+ transform: numberAttribute
931
+ });
932
+ firstLine = input(1, {
933
+ ...ngDevMode ? { debugName: "firstLine" } : /* istanbul ignore next */ {},
934
+ transform: numberAttribute
935
+ });
936
+ height = input(void 0, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
937
+ ariaLabel = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
938
+ dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
939
+ pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
940
+ ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
941
+ unstyled = input(void 0, {
942
+ ...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
943
+ transform: optionalBoolean
944
+ });
945
+ isUnstyled = injectUnstyled(this.unstyled);
946
+ passThrough = injectPassThrough("codeHighlight", this, this.pt, this.ptOptions);
947
+ t = injectTranslations();
948
+ lines = computed(() => codeLines(this.code() ?? "", this.language(), this.firstLine(), this.tabSize()), ...ngDevMode ? [{ debugName: "lines" }] : /* istanbul ignore next */ []);
949
+ label = computed(() => this.ariaLabel() ?? this.t().codeHighlightLabel, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
950
+ hostStyle = computed(() => {
951
+ const { syntax, ...own } = this.dt() ?? {};
952
+ return {
953
+ ...toStyleObject(own, "--tx-code-highlight"),
954
+ ...toStyleObject(syntax, "--tx-code-syntax"),
955
+ ...this.height() ? { height: this.height() } : {},
956
+ ...this.passThrough().root?.style
957
+ };
958
+ }, ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
959
+ constructor() {
960
+ inject(TxStyleLoader).load(TxCodeSyntaxStyles);
961
+ }
962
+ static ɵfac = i0.ɵɵngDeclareFactory({
963
+ minVersion: "12.0.0",
964
+ version: "22.2.3",
965
+ ngImport: i0,
966
+ type: TxCodeHighlight,
967
+ deps: [],
968
+ target: i0.ɵɵFactoryTarget.Component
969
+ });
970
+ static ɵcmp = i0.ɵɵngDeclareComponent({
971
+ minVersion: "17.0.0",
972
+ version: "22.2.3",
973
+ type: TxCodeHighlight,
974
+ isStandalone: true,
975
+ selector: "tx-code-highlight",
976
+ inputs: {
977
+ code: {
978
+ classPropertyName: "code",
979
+ publicName: "code",
980
+ isSignal: true,
981
+ isRequired: false,
982
+ transformFunction: null
983
+ },
984
+ language: {
985
+ classPropertyName: "language",
986
+ publicName: "language",
987
+ isSignal: true,
988
+ isRequired: false,
989
+ transformFunction: null
990
+ },
991
+ lineNumbers: {
992
+ classPropertyName: "lineNumbers",
993
+ publicName: "lineNumbers",
994
+ isSignal: true,
995
+ isRequired: false,
996
+ transformFunction: null
997
+ },
998
+ wordWrap: {
999
+ classPropertyName: "wordWrap",
1000
+ publicName: "wordWrap",
1001
+ isSignal: true,
1002
+ isRequired: false,
1003
+ transformFunction: null
1004
+ },
1005
+ indentGuides: {
1006
+ classPropertyName: "indentGuides",
1007
+ publicName: "indentGuides",
1008
+ isSignal: true,
1009
+ isRequired: false,
1010
+ transformFunction: null
1011
+ },
1012
+ tabSize: {
1013
+ classPropertyName: "tabSize",
1014
+ publicName: "tabSize",
1015
+ isSignal: true,
1016
+ isRequired: false,
1017
+ transformFunction: null
1018
+ },
1019
+ firstLine: {
1020
+ classPropertyName: "firstLine",
1021
+ publicName: "firstLine",
1022
+ isSignal: true,
1023
+ isRequired: false,
1024
+ transformFunction: null
1025
+ },
1026
+ height: {
1027
+ classPropertyName: "height",
1028
+ publicName: "height",
1029
+ isSignal: true,
1030
+ isRequired: false,
1031
+ transformFunction: null
1032
+ },
1033
+ ariaLabel: {
1034
+ classPropertyName: "ariaLabel",
1035
+ publicName: "ariaLabel",
1036
+ isSignal: true,
1037
+ isRequired: false,
1038
+ transformFunction: null
1039
+ },
1040
+ dt: {
1041
+ classPropertyName: "dt",
1042
+ publicName: "dt",
1043
+ isSignal: true,
1044
+ isRequired: false,
1045
+ transformFunction: null
1046
+ },
1047
+ pt: {
1048
+ classPropertyName: "pt",
1049
+ publicName: "pt",
1050
+ isSignal: true,
1051
+ isRequired: false,
1052
+ transformFunction: null
1053
+ },
1054
+ ptOptions: {
1055
+ classPropertyName: "ptOptions",
1056
+ publicName: "ptOptions",
1057
+ isSignal: true,
1058
+ isRequired: false,
1059
+ transformFunction: null
1060
+ },
1061
+ unstyled: {
1062
+ classPropertyName: "unstyled",
1063
+ publicName: "unstyled",
1064
+ isSignal: true,
1065
+ isRequired: false,
1066
+ transformFunction: null
1067
+ }
1068
+ },
1069
+ host: {
1070
+ properties: {
1071
+ "class": "passThrough().root?.class",
1072
+ "style": "hostStyle()",
1073
+ "attr.data-styled": "!isUnstyled() || null",
1074
+ "attr.data-language": "language()",
1075
+ "class.tx-code-highlight--wrap": "wordWrap()",
1076
+ "class.tx-code-highlight--numbers": "lineNumbers()"
1077
+ },
1078
+ classAttribute: "tx-code-highlight"
1079
+ },
1080
+ ngImport: i0,
1081
+ template: "<pre\n class=\"tx-code-highlight__code\"\n tabindex=\"0\"\n role=\"region\"\n [attr.aria-label]=\"label()\"\n [class]=\"passThrough().content?.class\"\n [style]=\"passThrough().content?.style\"\n><code>@for (line of lines(); track $index) {<span class=\"tx-code-highlight__line\" [class]=\"passThrough().line?.class\" [style]=\"passThrough().line?.style\">@if (lineNumbers()) {<span class=\"tx-code-highlight__number\" aria-hidden=\"true\" [class]=\"passThrough().gutter?.class\" [style]=\"passThrough().gutter?.style\">{{ line.number }}</span>}<span class=\"tx-code-highlight__text\" [class.tx-code-guides]=\"indentGuides() && line.guides > 0\" [style.--tx-code-guides]=\"indentGuides() && line.guides > 0 ? line.guides : null\" [style.--tx-code-guide-step]=\"tabSize() + 'ch'\" [style.--tx-code-wrap-indent]=\"wordWrap() ? line.indent : null\">@for (segment of line.segments; track $index) {<span [class]=\"segment.className\">{{ segment.text }}</span>}{{ '\\n' }}</span></span>}</code></pre>\n",
1082
+ styles: [":host{display:block;min-width:0}:host([data-styled]){overflow:hidden;border:var(--tx-code-highlight-border-width) solid var(--tx-code-highlight-border-color);border-radius:var(--tx-code-highlight-border-radius);background:var(--tx-code-highlight-background);color:var(--tx-code-highlight-color);font-family:var(--tx-code-highlight-font-family);font-size:var(--tx-code-highlight-font-size);line-height:var(--tx-code-highlight-line-height)}:host([data-styled]) .tx-code-highlight__code{height:100%;margin:0;padding-block:var(--tx-code-highlight-padding-block);overflow:auto;font:inherit;tab-size:var(--tx-code-highlight-tab-size)}:host([data-styled]) .tx-code-highlight__code:focus-visible{outline:2px solid var(--tx-focus-ring-color);outline-offset:-2px}:host([data-styled]) code{display:block;width:max-content;min-width:100%;font:inherit}:host([data-styled]) .tx-code-highlight__line{display:flex;min-height:var(--tx-code-highlight-line-height)}:host([data-styled]) .tx-code-highlight__number{position:sticky;left:0;flex:none;box-sizing:content-box;min-width:var(--tx-code-highlight-gutter-min-digits);padding-inline:var(--tx-code-highlight-gutter-padding-start) var(--tx-code-highlight-gutter-gap);background:var(--tx-code-highlight-gutter-background);color:var(--tx-code-highlight-gutter-color);text-align:right;-webkit-user-select:none;user-select:none}:host([data-styled]) .tx-code-highlight__text{flex:1 1 auto;padding-inline-end:var(--tx-code-highlight-padding-inline-end);white-space:pre}:host([data-styled]) .tx-code-highlight__text.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start, 0) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}:host([data-styled]):not(.tx-code-highlight--numbers) .tx-code-highlight__text{--tx-code-line-start: var(--tx-code-highlight-padding-inline-end);padding-inline-start:var(--tx-code-highlight-padding-inline-end)}:host([data-styled]).tx-code-highlight--wrap code{width:auto}:host([data-styled]).tx-code-highlight--wrap .tx-code-highlight__text{min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}:host([data-styled]).tx-code-highlight--wrap .tx-code-highlight__text[style*=--tx-code-wrap-indent]{padding-inline-start:var(--tx-code-wrap-indent);text-indent:calc(-1 * var(--tx-code-wrap-indent))}:host([data-styled]).tx-code-highlight--wrap:not(.tx-code-highlight--numbers) .tx-code-highlight__text[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-highlight-padding-inline-end) + var(--tx-code-wrap-indent))}\n"],
1083
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1084
+ });
1085
+ };
1086
+ i0.ɵɵngDeclareClassMetadata({
1087
+ minVersion: "12.0.0",
1088
+ version: "22.2.3",
1089
+ ngImport: i0,
1090
+ type: TxCodeHighlight,
1091
+ decorators: [{
1092
+ type: Component,
1093
+ args: [{
1094
+ selector: "tx-code-highlight",
1095
+ changeDetection: ChangeDetectionStrategy.OnPush,
1096
+ host: {
1097
+ class: "tx-code-highlight",
1098
+ "[class]": "passThrough().root?.class",
1099
+ "[style]": "hostStyle()",
1100
+ "[attr.data-styled]": "!isUnstyled() || null",
1101
+ "[attr.data-language]": "language()",
1102
+ "[class.tx-code-highlight--wrap]": "wordWrap()",
1103
+ "[class.tx-code-highlight--numbers]": "lineNumbers()"
1104
+ },
1105
+ template: "<pre\n class=\"tx-code-highlight__code\"\n tabindex=\"0\"\n role=\"region\"\n [attr.aria-label]=\"label()\"\n [class]=\"passThrough().content?.class\"\n [style]=\"passThrough().content?.style\"\n><code>@for (line of lines(); track $index) {<span class=\"tx-code-highlight__line\" [class]=\"passThrough().line?.class\" [style]=\"passThrough().line?.style\">@if (lineNumbers()) {<span class=\"tx-code-highlight__number\" aria-hidden=\"true\" [class]=\"passThrough().gutter?.class\" [style]=\"passThrough().gutter?.style\">{{ line.number }}</span>}<span class=\"tx-code-highlight__text\" [class.tx-code-guides]=\"indentGuides() && line.guides > 0\" [style.--tx-code-guides]=\"indentGuides() && line.guides > 0 ? line.guides : null\" [style.--tx-code-guide-step]=\"tabSize() + 'ch'\" [style.--tx-code-wrap-indent]=\"wordWrap() ? line.indent : null\">@for (segment of line.segments; track $index) {<span [class]=\"segment.className\">{{ segment.text }}</span>}{{ '\\n' }}</span></span>}</code></pre>\n",
1106
+ styles: [":host{display:block;min-width:0}:host([data-styled]){overflow:hidden;border:var(--tx-code-highlight-border-width) solid var(--tx-code-highlight-border-color);border-radius:var(--tx-code-highlight-border-radius);background:var(--tx-code-highlight-background);color:var(--tx-code-highlight-color);font-family:var(--tx-code-highlight-font-family);font-size:var(--tx-code-highlight-font-size);line-height:var(--tx-code-highlight-line-height)}:host([data-styled]) .tx-code-highlight__code{height:100%;margin:0;padding-block:var(--tx-code-highlight-padding-block);overflow:auto;font:inherit;tab-size:var(--tx-code-highlight-tab-size)}:host([data-styled]) .tx-code-highlight__code:focus-visible{outline:2px solid var(--tx-focus-ring-color);outline-offset:-2px}:host([data-styled]) code{display:block;width:max-content;min-width:100%;font:inherit}:host([data-styled]) .tx-code-highlight__line{display:flex;min-height:var(--tx-code-highlight-line-height)}:host([data-styled]) .tx-code-highlight__number{position:sticky;left:0;flex:none;box-sizing:content-box;min-width:var(--tx-code-highlight-gutter-min-digits);padding-inline:var(--tx-code-highlight-gutter-padding-start) var(--tx-code-highlight-gutter-gap);background:var(--tx-code-highlight-gutter-background);color:var(--tx-code-highlight-gutter-color);text-align:right;-webkit-user-select:none;user-select:none}:host([data-styled]) .tx-code-highlight__text{flex:1 1 auto;padding-inline-end:var(--tx-code-highlight-padding-inline-end);white-space:pre}:host([data-styled]) .tx-code-highlight__text.tx-code-guides{background-image:repeating-linear-gradient(to right,var(--tx-code-syntax-indent-guide) 0 1px,transparent 1px var(--tx-code-guide-step));background-position:var(--tx-code-line-start, 0) 0;background-repeat:no-repeat;background-size:calc(var(--tx-code-guides) * var(--tx-code-guide-step)) 100%}:host([data-styled]):not(.tx-code-highlight--numbers) .tx-code-highlight__text{--tx-code-line-start: var(--tx-code-highlight-padding-inline-end);padding-inline-start:var(--tx-code-highlight-padding-inline-end)}:host([data-styled]).tx-code-highlight--wrap code{width:auto}:host([data-styled]).tx-code-highlight--wrap .tx-code-highlight__text{min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}:host([data-styled]).tx-code-highlight--wrap .tx-code-highlight__text[style*=--tx-code-wrap-indent]{padding-inline-start:var(--tx-code-wrap-indent);text-indent:calc(-1 * var(--tx-code-wrap-indent))}:host([data-styled]).tx-code-highlight--wrap:not(.tx-code-highlight--numbers) .tx-code-highlight__text[style*=--tx-code-wrap-indent]{padding-inline-start:calc(var(--tx-code-highlight-padding-inline-end) + var(--tx-code-wrap-indent))}\n"]
1107
+ }]
1108
+ }],
1109
+ ctorParameters: () => [],
1110
+ propDecorators: {
1111
+ code: [{
1112
+ type: i0.Input,
1113
+ args: [{
1114
+ isSignal: true,
1115
+ alias: "code",
1116
+ required: false
1117
+ }]
1118
+ }],
1119
+ language: [{
1120
+ type: i0.Input,
1121
+ args: [{
1122
+ isSignal: true,
1123
+ alias: "language",
1124
+ required: false
1125
+ }]
1126
+ }],
1127
+ lineNumbers: [{
1128
+ type: i0.Input,
1129
+ args: [{
1130
+ isSignal: true,
1131
+ alias: "lineNumbers",
1132
+ required: false
1133
+ }]
1134
+ }],
1135
+ wordWrap: [{
1136
+ type: i0.Input,
1137
+ args: [{
1138
+ isSignal: true,
1139
+ alias: "wordWrap",
1140
+ required: false
1141
+ }]
1142
+ }],
1143
+ indentGuides: [{
1144
+ type: i0.Input,
1145
+ args: [{
1146
+ isSignal: true,
1147
+ alias: "indentGuides",
1148
+ required: false
1149
+ }]
1150
+ }],
1151
+ tabSize: [{
1152
+ type: i0.Input,
1153
+ args: [{
1154
+ isSignal: true,
1155
+ alias: "tabSize",
1156
+ required: false
1157
+ }]
1158
+ }],
1159
+ firstLine: [{
1160
+ type: i0.Input,
1161
+ args: [{
1162
+ isSignal: true,
1163
+ alias: "firstLine",
1164
+ required: false
1165
+ }]
1166
+ }],
1167
+ height: [{
1168
+ type: i0.Input,
1169
+ args: [{
1170
+ isSignal: true,
1171
+ alias: "height",
1172
+ required: false
1173
+ }]
1174
+ }],
1175
+ ariaLabel: [{
1176
+ type: i0.Input,
1177
+ args: [{
1178
+ isSignal: true,
1179
+ alias: "ariaLabel",
1180
+ required: false
1181
+ }]
1182
+ }],
1183
+ dt: [{
1184
+ type: i0.Input,
1185
+ args: [{
1186
+ isSignal: true,
1187
+ alias: "dt",
1188
+ required: false
1189
+ }]
1190
+ }],
1191
+ pt: [{
1192
+ type: i0.Input,
1193
+ args: [{
1194
+ isSignal: true,
1195
+ alias: "pt",
1196
+ required: false
1197
+ }]
1198
+ }],
1199
+ ptOptions: [{
1200
+ type: i0.Input,
1201
+ args: [{
1202
+ isSignal: true,
1203
+ alias: "ptOptions",
1204
+ required: false
1205
+ }]
1206
+ }],
1207
+ unstyled: [{
1208
+ type: i0.Input,
1209
+ args: [{
1210
+ isSignal: true,
1211
+ alias: "unstyled",
1212
+ required: false
1213
+ }]
1214
+ }]
1215
+ }
1216
+ });
1217
+ export { TxCodeHighlight, TxCodeLineStates, TxCodeStream, TxCodeSyntaxStyles, codeLines, getCodeMode, guideLevels, highlightCode, lineIndent, lineSegments, resolveCodeLanguage, splitCodeLines, tokenClass, tokenInside, tokenizeLine };
1218
+
1219
+ //# sourceMappingURL=tectra-ng-code-editor-highlight.mjs.map