@meridianlabs/log-viewer 0.3.272 → 0.3.275

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.
Files changed (168) hide show
  1. package/lib/AnsiDisplayRich-302CIkEj.js +1431 -0
  2. package/lib/AnsiDisplayRich-302CIkEj.js.map +1 -0
  3. package/lib/ToolButton-BmBvTvKO.js +124 -0
  4. package/lib/ToolButton-BmBvTvKO.js.map +1 -0
  5. package/lib/e2e/content-trust.spec.d.ts +2 -0
  6. package/lib/e2e/content-trust.spec.d.ts.map +1 -0
  7. package/lib/e2e/expandable-panel-sticky-toggle.spec.d.ts +2 -0
  8. package/lib/e2e/expandable-panel-sticky-toggle.spec.d.ts.map +1 -0
  9. package/lib/e2e/fixtures/log-list-scenario.d.ts +37 -1
  10. package/lib/e2e/fixtures/log-list-scenario.d.ts.map +1 -1
  11. package/lib/e2e/fixtures/serve-eval-file.d.ts +20 -0
  12. package/lib/e2e/fixtures/serve-eval-file.d.ts.map +1 -0
  13. package/lib/e2e/log-location-trust.spec.d.ts +2 -0
  14. package/lib/e2e/log-location-trust.spec.d.ts.map +1 -0
  15. package/lib/e2e/sample-activity.spec.d.ts +10 -0
  16. package/lib/e2e/sample-activity.spec.d.ts.map +1 -0
  17. package/lib/e2e/scanner-glob.spec.d.ts +2 -0
  18. package/lib/e2e/scanner-glob.spec.d.ts.map +1 -0
  19. package/lib/e2e/timeline-axis-bounds.spec.d.ts +2 -0
  20. package/lib/e2e/timeline-axis-bounds.spec.d.ts.map +1 -0
  21. package/lib/e2e/zip-reader.spec.d.ts +2 -0
  22. package/lib/e2e/zip-reader.spec.d.ts.map +1 -0
  23. package/lib/index.js +27678 -45828
  24. package/lib/index.js.map +1 -1
  25. package/lib/markdownPipeline-BeMkkZRz.js +8575 -0
  26. package/lib/markdownPipeline-BeMkkZRz.js.map +1 -0
  27. package/lib/markdownText-z5R6PHwt.js +105 -0
  28. package/lib/markdownText-z5R6PHwt.js.map +1 -0
  29. package/lib/prismHighlighter-D-PZtkPX.js +1927 -0
  30. package/lib/prismHighlighter-D-PZtkPX.js.map +1 -0
  31. package/lib/rolldown-runtime-B-lAHAz2.js +37 -0
  32. package/lib/src/app/App.d.ts.map +1 -1
  33. package/lib/src/app/flow/FlowButton.d.ts +2 -1
  34. package/lib/src/app/flow/FlowButton.d.ts.map +1 -1
  35. package/lib/src/app/flow/FlowPanel.d.ts.map +1 -1
  36. package/lib/src/app/log-list/grid/LogListGrid.d.ts.map +1 -1
  37. package/lib/src/app/log-list/grid/columns/hooks.d.ts.map +1 -1
  38. package/lib/src/app/log-view/LogSampleDetailView.d.ts.map +1 -1
  39. package/lib/src/app/log-view/LogView.d.ts.map +1 -1
  40. package/lib/src/app/log-view/tabs/ConfigCard.d.ts.map +1 -1
  41. package/lib/src/app/log-view/tabs/InfoTab.d.ts +1 -0
  42. package/lib/src/app/log-view/tabs/InfoTab.d.ts.map +1 -1
  43. package/lib/src/app/log-view/tabs/JsonTab.d.ts +9 -1
  44. package/lib/src/app/log-view/tabs/JsonTab.d.ts.map +1 -1
  45. package/lib/src/app/log-view/tabs/ModelsTab.d.ts +1 -0
  46. package/lib/src/app/log-view/tabs/ModelsTab.d.ts.map +1 -1
  47. package/lib/src/app/log-view/tabs/SamplesTab.d.ts +1 -1
  48. package/lib/src/app/log-view/tabs/SamplesTab.d.ts.map +1 -1
  49. package/lib/src/app/log-view/tabs/TaskTab.d.ts +1 -0
  50. package/lib/src/app/log-view/tabs/TaskTab.d.ts.map +1 -1
  51. package/lib/src/app/log-view/tabs/timeline/HistoryList.d.ts +3 -2
  52. package/lib/src/app/log-view/tabs/timeline/HistoryList.d.ts.map +1 -1
  53. package/lib/src/app/log-view/tabs/timeline/OpenSampleLink.d.ts +24 -0
  54. package/lib/src/app/log-view/tabs/timeline/OpenSampleLink.d.ts.map +1 -0
  55. package/lib/src/app/log-view/tabs/timeline/TimelineChart.d.ts +3 -2
  56. package/lib/src/app/log-view/tabs/timeline/TimelineChart.d.ts.map +1 -1
  57. package/lib/src/app/log-view/tabs/timeline/TimelineTab.d.ts +6 -36
  58. package/lib/src/app/log-view/tabs/timeline/TimelineTab.d.ts.map +1 -1
  59. package/lib/src/app/log-view/tabs/timeline/timelineAxis.d.ts +11 -0
  60. package/lib/src/app/log-view/tabs/timeline/timelineAxis.d.ts.map +1 -0
  61. package/lib/src/app/log-view/title-view/ScoreGrid.d.ts.map +1 -1
  62. package/lib/src/app/log-view/title-view/SecondaryBar.d.ts.map +1 -1
  63. package/lib/src/app/log-view/useTimelineNavigation.d.ts +24 -0
  64. package/lib/src/app/log-view/useTimelineNavigation.d.ts.map +1 -0
  65. package/lib/src/app/navbar/ViewSegmentedControl.d.ts.map +1 -1
  66. package/lib/src/app/routing/AppRouter.d.ts.map +1 -1
  67. package/lib/src/app/routing/logNavigation.d.ts +1 -0
  68. package/lib/src/app/routing/logNavigation.d.ts.map +1 -1
  69. package/lib/src/app/routing/sampleNavigation.d.ts +4 -1
  70. package/lib/src/app/routing/sampleNavigation.d.ts.map +1 -1
  71. package/lib/src/app/routing/url.d.ts.map +1 -1
  72. package/lib/src/app/samples/SampleDisplay.d.ts.map +1 -1
  73. package/lib/src/app/samples/SampleNavbar.d.ts +3 -0
  74. package/lib/src/app/samples/SampleNavbar.d.ts.map +1 -1
  75. package/lib/src/app/samples/SampleSummaryView.d.ts.map +1 -1
  76. package/lib/src/app/samples/descriptor/samplesDescriptor.d.ts.map +1 -1
  77. package/lib/src/app/samples/descriptor/score/BooleanScoreDescriptor.d.ts.map +1 -1
  78. package/lib/src/app/samples/descriptor/score/CategoricalScoreDescriptor.d.ts.map +1 -1
  79. package/lib/src/app/samples/descriptor/score/PassFailScoreDescriptor.d.ts.map +1 -1
  80. package/lib/src/app/samples/event/SampleEventView.d.ts.map +1 -1
  81. package/lib/src/app/samples/header-v2/ScorePanel.d.ts.map +1 -1
  82. package/lib/src/app/samples/header-v2/ScoreValueDisplay.d.ts.map +1 -1
  83. package/lib/src/app/samples/header-v2/scoreTone.d.ts.map +1 -1
  84. package/lib/src/app/samples/list/SampleList.d.ts.map +1 -1
  85. package/lib/src/app/samples/print/SamplePrintView.d.ts.map +1 -1
  86. package/lib/src/app/samples/sample-tools/filters.d.ts.map +1 -1
  87. package/lib/src/app/samples/sample-tools/sample-filter/completions.d.ts.map +1 -1
  88. package/lib/src/app/samples/status/status.d.ts +1 -1
  89. package/lib/src/app/samples-panel/SampleDetailView.d.ts.map +1 -1
  90. package/lib/src/app/samples-panel/SamplesPanel.d.ts.map +1 -1
  91. package/lib/src/app/shared/contentTrust.d.ts +14 -0
  92. package/lib/src/app/shared/contentTrust.d.ts.map +1 -0
  93. package/lib/src/app/shared/data-grid/DataGrid.d.ts +8 -3
  94. package/lib/src/app/shared/data-grid/DataGrid.d.ts.map +1 -1
  95. package/lib/src/app/shared/openInNewTab.d.ts +7 -1
  96. package/lib/src/app/shared/openInNewTab.d.ts.map +1 -1
  97. package/lib/src/app/shared/samples-grid/SamplesGrid.d.ts +3 -1
  98. package/lib/src/app/shared/samples-grid/SamplesGrid.d.ts.map +1 -1
  99. package/lib/src/app/shared/samples-grid/cells.d.ts.map +1 -1
  100. package/lib/src/app/shared/samples-grid/columns.d.ts.map +1 -1
  101. package/lib/src/app/shared/samples-grid/types.d.ts +1 -0
  102. package/lib/src/app/shared/samples-grid/types.d.ts.map +1 -1
  103. package/lib/src/app_config/LogLocationGate.d.ts +12 -0
  104. package/lib/src/app_config/LogLocationGate.d.ts.map +1 -0
  105. package/lib/src/app_config/appConfig.d.ts +14 -0
  106. package/lib/src/app_config/appConfig.d.ts.map +1 -1
  107. package/lib/src/app_config/index.d.ts +2 -1
  108. package/lib/src/app_config/index.d.ts.map +1 -1
  109. package/lib/src/app_config/logLocationTrust.d.ts +28 -0
  110. package/lib/src/app_config/logLocationTrust.d.ts.map +1 -0
  111. package/lib/src/app_config/resolveBackend.d.ts +9 -0
  112. package/lib/src/app_config/resolveBackend.d.ts.map +1 -1
  113. package/lib/src/client/api/static-http/fetch.d.ts +3 -1
  114. package/lib/src/client/api/static-http/fetch.d.ts.map +1 -1
  115. package/lib/src/client/api/types.d.ts +9 -3
  116. package/lib/src/client/api/types.d.ts.map +1 -1
  117. package/lib/src/client/api/view-server/api-view-server.d.ts.map +1 -1
  118. package/lib/src/client/api/view-server/request.d.ts +0 -4
  119. package/lib/src/client/api/view-server/request.d.ts.map +1 -1
  120. package/lib/src/client/database/schema.d.ts +3 -5
  121. package/lib/src/client/database/schema.d.ts.map +1 -1
  122. package/lib/src/client/database/service.d.ts +1 -0
  123. package/lib/src/client/database/service.d.ts.map +1 -1
  124. package/lib/src/client/remote/decompression.d.ts +1 -1
  125. package/lib/src/client/remote/remoteLogFile.d.ts.map +1 -1
  126. package/lib/src/client/remote/remotePendingSampleData.d.ts.map +1 -1
  127. package/lib/src/client/remote/remoteZipFile.d.ts +4 -19
  128. package/lib/src/client/remote/remoteZipFile.d.ts.map +1 -1
  129. package/lib/src/client/remote/zstd-decoder.d.ts +20 -0
  130. package/lib/src/client/remote/zstd-decoder.d.ts.map +1 -0
  131. package/lib/src/client/remote/zstd-worker-code.d.ts +1 -1
  132. package/lib/src/client/remote/zstd-worker-code.d.ts.map +1 -1
  133. package/lib/src/client/remote/zstd-worker.d.ts +23 -8
  134. package/lib/src/client/remote/zstd-worker.d.ts.map +1 -1
  135. package/lib/src/client/utils/derive.d.ts +3 -0
  136. package/lib/src/client/utils/derive.d.ts.map +1 -1
  137. package/lib/src/client/utils/normalize.d.ts +19 -3
  138. package/lib/src/client/utils/normalize.d.ts.map +1 -1
  139. package/lib/src/components/CodePanel.d.ts.map +1 -1
  140. package/lib/src/constants.d.ts +1 -0
  141. package/lib/src/constants.d.ts.map +1 -1
  142. package/lib/src/log_data/fetchEngine.d.ts +13 -2
  143. package/lib/src/log_data/fetchEngine.d.ts.map +1 -1
  144. package/lib/src/log_data/logsContent.d.ts +3 -2
  145. package/lib/src/log_data/logsContent.d.ts.map +1 -1
  146. package/lib/src/log_data/runningSampleQuery.d.ts.map +1 -1
  147. package/lib/src/log_data/sampleSummaries.d.ts.map +1 -1
  148. package/lib/src/log_data/samplesListing.d.ts +3 -0
  149. package/lib/src/log_data/samplesListing.d.ts.map +1 -1
  150. package/lib/src/state/actions.d.ts.map +1 -1
  151. package/lib/src/state/hooks.d.ts +1 -0
  152. package/lib/src/state/hooks.d.ts.map +1 -1
  153. package/lib/src/test/nodeBlobWorker.d.ts +2 -0
  154. package/lib/src/test/nodeBlobWorker.d.ts.map +1 -0
  155. package/lib/src/utils/format.d.ts +0 -6
  156. package/lib/src/utils/format.d.ts.map +1 -1
  157. package/lib/src-s8Cexy_j.js +9977 -0
  158. package/lib/src-s8Cexy_j.js.map +1 -0
  159. package/lib/styles/index.css +2840 -1492
  160. package/lib/type-CI-Mc4Kw.js +29 -0
  161. package/lib/type-CI-Mc4Kw.js.map +1 -0
  162. package/package.json +27 -28
  163. package/lib/src/app/log-view/useShowTimeline.d.ts +0 -24
  164. package/lib/src/app/log-view/useShowTimeline.d.ts.map +0 -1
  165. package/lib/src/utils/html.d.ts +0 -6
  166. package/lib/src/utils/html.d.ts.map +0 -1
  167. package/lib/src/utils/markdown.d.ts +0 -16
  168. package/lib/src/utils/markdown.d.ts.map +0 -1
@@ -0,0 +1,1431 @@
1
+ import { r as __require, t as __commonJSMin } from "./rolldown-runtime-B-lAHAz2.js";
2
+ import { a as clsx, i as useComponentIcons, n as AnsiDisplay_module_default, t as ToolButton } from "./ToolButton-BmBvTvKO.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { c } from "react/compiler-runtime";
5
+ import { useState } from "react";
6
+ //#endregion
7
+ //#region ../../packages/react/src/components/AnsiDisplayRich.module.css
8
+ var import_ansi_output = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
9
+ (function(factory) {
10
+ if (typeof module === "object" && typeof module.exports === "object") {
11
+ var v = factory(__require, exports);
12
+ if (v !== void 0) module.exports = v;
13
+ } else if (typeof define === "function" && define.amd) define(["require", "exports"], factory);
14
+ })(function(require, exports$1) {
15
+ "use strict";
16
+ Object.defineProperty(exports$1, "__esModule", { value: true });
17
+ exports$1.ANSIOutput = exports$1.ANSIColor = exports$1.ANSIFont = exports$1.ANSIStyle = void 0;
18
+ /**
19
+ * The counter used to generate identifiers.
20
+ */
21
+ let counter = 0;
22
+ /**
23
+ * Generates an identifier.
24
+ * @returns The identifier.
25
+ */
26
+ const generateId = () => {
27
+ return `${++counter}`.padStart(16, "0");
28
+ };
29
+ /**
30
+ * ANSIStyle enumeration.
31
+ */
32
+ var ANSIStyle;
33
+ (function(ANSIStyle) {
34
+ ANSIStyle["Bold"] = "ansiBold";
35
+ ANSIStyle["Dim"] = "ansiDim";
36
+ ANSIStyle["Italic"] = "ansiItalic";
37
+ ANSIStyle["Underlined"] = "ansiUnderlined";
38
+ ANSIStyle["SlowBlink"] = "ansiSlowBlink";
39
+ ANSIStyle["RapidBlink"] = "ansiRapidBlink";
40
+ ANSIStyle["Hidden"] = "ansiHidden";
41
+ ANSIStyle["CrossedOut"] = "ansiCrossedOut";
42
+ ANSIStyle["Fraktur"] = "ansiFraktur";
43
+ ANSIStyle["DoubleUnderlined"] = "ansiDoubleUnderlined";
44
+ ANSIStyle["Framed"] = "ansiFramed";
45
+ ANSIStyle["Encircled"] = "ansiEncircled";
46
+ ANSIStyle["Overlined"] = "ansiOverlined";
47
+ ANSIStyle["Superscript"] = "ansiSuperscript";
48
+ ANSIStyle["Subscript"] = "ansiSubscript";
49
+ })(ANSIStyle || (exports$1.ANSIStyle = ANSIStyle = {}));
50
+ /**
51
+ * ANSIFont enumeration.
52
+ */
53
+ var ANSIFont;
54
+ (function(ANSIFont) {
55
+ ANSIFont["AlternativeFont1"] = "ansiAlternativeFont1";
56
+ ANSIFont["AlternativeFont2"] = "ansiAlternativeFont2";
57
+ ANSIFont["AlternativeFont3"] = "ansiAlternativeFont3";
58
+ ANSIFont["AlternativeFont4"] = "ansiAlternativeFont4";
59
+ ANSIFont["AlternativeFont5"] = "ansiAlternativeFont5";
60
+ ANSIFont["AlternativeFont6"] = "ansiAlternativeFont6";
61
+ ANSIFont["AlternativeFont7"] = "ansiAlternativeFont7";
62
+ ANSIFont["AlternativeFont8"] = "ansiAlternativeFont8";
63
+ ANSIFont["AlternativeFont9"] = "ansiAlternativeFont9";
64
+ })(ANSIFont || (exports$1.ANSIFont = ANSIFont = {}));
65
+ /**
66
+ * SGRColor enumeration.
67
+ */
68
+ var ANSIColor;
69
+ (function(ANSIColor) {
70
+ ANSIColor["Black"] = "ansiBlack";
71
+ ANSIColor["Red"] = "ansiRed";
72
+ ANSIColor["Green"] = "ansiGreen";
73
+ ANSIColor["Yellow"] = "ansiYellow";
74
+ ANSIColor["Blue"] = "ansiBlue";
75
+ ANSIColor["Magenta"] = "ansiMagenta";
76
+ ANSIColor["Cyan"] = "ansiCyan";
77
+ ANSIColor["White"] = "ansiWhite";
78
+ ANSIColor["BrightBlack"] = "ansiBrightBlack";
79
+ ANSIColor["BrightRed"] = "ansiBrightRed";
80
+ ANSIColor["BrightGreen"] = "ansiBrightGreen";
81
+ ANSIColor["BrightYellow"] = "ansiBrightYellow";
82
+ ANSIColor["BrightBlue"] = "ansiBrightBlue";
83
+ ANSIColor["BrightMagenta"] = "ansiBrightMagenta";
84
+ ANSIColor["BrightCyan"] = "ansiBrightCyan";
85
+ ANSIColor["BrightWhite"] = "ansiBrightWhite";
86
+ })(ANSIColor || (exports$1.ANSIColor = ANSIColor = {}));
87
+ /**
88
+ * ANSIOutput class.
89
+ */
90
+ class ANSIOutput {
91
+ /**
92
+ * Gets or sets the parser state.
93
+ */
94
+ _parserState = ParserState.BufferingOutput;
95
+ /**
96
+ * Gets or sets the control sequence that's being parsed.
97
+ */
98
+ _controlSequence = "";
99
+ /**
100
+ * Gets or sets the SGR state.
101
+ */
102
+ _sgrState = void 0;
103
+ /**
104
+ * Gets or sets the current set of output lines.
105
+ */
106
+ _outputLines = [];
107
+ /**
108
+ * Gets or sets the output line.
109
+ */
110
+ _outputLine = 0;
111
+ /**
112
+ * Gets or sets the output column.
113
+ */
114
+ _outputColumn = 0;
115
+ /**
116
+ * Gets or sets the buffer.
117
+ */
118
+ _buffer = "";
119
+ /**
120
+ * Gets or sets a value which indicates whether there is a pending newline.
121
+ */
122
+ _pendingNewline = false;
123
+ /**
124
+ * Gets the output lines.
125
+ */
126
+ get outputLines() {
127
+ this.flushBuffer();
128
+ return this._outputLines;
129
+ }
130
+ /**
131
+ * Processes output and returns the ANSIOutput lines of the output.
132
+ * @param output The output to process.
133
+ * @returns The ANSIOutput lines of the output.
134
+ */
135
+ static processOutput(output) {
136
+ const ansiOutput = new ANSIOutput();
137
+ ansiOutput.processOutput(output);
138
+ return ansiOutput.outputLines;
139
+ }
140
+ /**
141
+ * Processes output.
142
+ * @param output The output to process.
143
+ */
144
+ processOutput(output) {
145
+ for (let i = 0; i < output.length; i++) {
146
+ if (this._pendingNewline) {
147
+ this.flushBuffer();
148
+ this._outputLine++;
149
+ this._outputColumn = 0;
150
+ this._pendingNewline = false;
151
+ }
152
+ const char = output.charAt(i);
153
+ if (this._parserState === ParserState.BufferingOutput) {
154
+ if (char === "\x1B") {
155
+ this.flushBuffer();
156
+ this._parserState = ParserState.ControlSequenceStarted;
157
+ } else if (char === "›") {
158
+ this.flushBuffer();
159
+ this._parserState = ParserState.ParsingControlSequence;
160
+ } else this.processCharacter(char);
161
+ } else if (this._parserState === ParserState.ControlSequenceStarted) {
162
+ if (char === "[") this._parserState = ParserState.ParsingControlSequence;
163
+ else {
164
+ this._parserState = ParserState.BufferingOutput;
165
+ this.processCharacter(char);
166
+ }
167
+ } else if (this._parserState === ParserState.ParsingControlSequence) {
168
+ this._controlSequence += char;
169
+ if (char.match(/^[A-Za-z]$/)) this.processControlSequence();
170
+ }
171
+ }
172
+ this.flushBuffer();
173
+ }
174
+ /**
175
+ * Flushes the buffer to the output line.
176
+ */
177
+ flushBuffer() {
178
+ for (let i = this._outputLines.length; i < this._outputLine + 1; i++) this._outputLines.push(new OutputLine());
179
+ if (this._buffer) {
180
+ this._outputLines[this._outputLine].insert(this._buffer, this._outputColumn, this._sgrState);
181
+ this._outputColumn += this._buffer.length;
182
+ this._buffer = "";
183
+ }
184
+ }
185
+ /**
186
+ * Processes a character.
187
+ * @param char The character.
188
+ */
189
+ processCharacter(char) {
190
+ switch (char) {
191
+ case "\n":
192
+ this._pendingNewline = true;
193
+ break;
194
+ case "\r":
195
+ this.flushBuffer();
196
+ this._outputColumn = 0;
197
+ break;
198
+ default: this._buffer += char;
199
+ }
200
+ }
201
+ /**
202
+ * Processes a control sequence.
203
+ */
204
+ processControlSequence() {
205
+ switch (this._controlSequence.charAt(this._controlSequence.length - 1)) {
206
+ case "A":
207
+ this.processCUU();
208
+ break;
209
+ case "B":
210
+ this.processCUD();
211
+ break;
212
+ case "C":
213
+ this.processCUF();
214
+ break;
215
+ case "D":
216
+ this.processCUB();
217
+ break;
218
+ case "H":
219
+ this.processCUP();
220
+ break;
221
+ case "J":
222
+ this.processED();
223
+ break;
224
+ case "K":
225
+ this.processEL();
226
+ break;
227
+ case "m": this.processSGR();
228
+ }
229
+ this._controlSequence = "";
230
+ this._parserState = ParserState.BufferingOutput;
231
+ }
232
+ /**
233
+ * Processes a CUU (Cursor Up) control sequence.
234
+ */
235
+ processCUU() {
236
+ const match = this._controlSequence.match(/^([0-9]*)A$/);
237
+ if (match) this._outputLine = Math.max(this._outputLine - rangeParam(match[1], 1, 1), 0);
238
+ }
239
+ /**
240
+ * Processes a CUD (Cursor Down) control sequence.
241
+ */
242
+ processCUD() {
243
+ const match = this._controlSequence.match(/^([0-9]*)B$/);
244
+ if (match) this._outputLine = this._outputLine + rangeParam(match[1], 1, 1);
245
+ }
246
+ /**
247
+ * Processes a CUF (Cursor Forward) control sequence.
248
+ */
249
+ processCUF() {
250
+ const match = this._controlSequence.match(/^([0-9]*)C$/);
251
+ if (match) this._outputColumn = this._outputColumn + rangeParam(match[1], 1, 1);
252
+ }
253
+ /**
254
+ * Processes a CUB (Cursor Backward) control sequence.
255
+ */
256
+ processCUB() {
257
+ const match = this._controlSequence.match(/^([0-9]*)D$/);
258
+ if (match) this._outputColumn = Math.max(this._outputColumn - rangeParam(match[1], 1, 1), 0);
259
+ }
260
+ /**
261
+ * Processes a CUP (Cursor Position) control sequence.
262
+ */
263
+ processCUP() {
264
+ const match = this._controlSequence.match(/^([0-9]*)(?:;?([0-9]*))H$/);
265
+ if (match) {
266
+ this._outputLine = rangeParam(match[1], 1, 1) - 1;
267
+ this._outputColumn = rangeParam(match[2], 1, 1) - 1;
268
+ }
269
+ }
270
+ /**
271
+ * Processes an ED (Erase in Display) control sequence.
272
+ */
273
+ processED() {
274
+ const match = this._controlSequence.match(/^([0-9]*)J$/);
275
+ if (match) switch (getParam(match[1], 0)) {
276
+ case 0:
277
+ this._outputLines[this._outputLine].clearToEndOfLine(this._outputColumn);
278
+ for (let i = this._outputLine + 1; i < this._outputLines.length; i++) this._outputLines[i].clearEntireLine();
279
+ break;
280
+ case 1:
281
+ this._outputLines[this._outputLine].clearToBeginningOfLine(this._outputColumn);
282
+ for (let i = 0; i < this._outputLine; i++) this._outputLines[i].clearEntireLine();
283
+ break;
284
+ case 2: for (let i = 0; i < this._outputLines.length; i++) this._outputLines[i].clearEntireLine();
285
+ }
286
+ }
287
+ /**
288
+ * Processes an EL (Erase in Line) control sequence.
289
+ */
290
+ processEL() {
291
+ const match = this._controlSequence.match(/^([0-9]*)K$/);
292
+ if (match) {
293
+ const outputLine = this._outputLines[this._outputLine];
294
+ switch (getParam(match[1], 0)) {
295
+ case 0:
296
+ outputLine.clearToEndOfLine(this._outputColumn);
297
+ break;
298
+ case 1:
299
+ outputLine.clearToBeginningOfLine(this._outputColumn);
300
+ break;
301
+ case 2: outputLine.clearEntireLine();
302
+ }
303
+ }
304
+ }
305
+ /**
306
+ * Processes an SGR (Select Graphic Rendition) control sequence.
307
+ */
308
+ processSGR() {
309
+ const sgrState = this._sgrState ? this._sgrState.copy() : new SGRState();
310
+ const sgrParams = this._controlSequence.slice(0, -1).split(";").map((sgrParam) => sgrParam === "" ? SGRParam.Reset : parseInt(sgrParam, 10));
311
+ for (let index = 0; index < sgrParams.length; index++) {
312
+ const sgrParam = sgrParams[index];
313
+ /**
314
+ * Process SetForeground, SetBackground, or SetUnderline. Contrary to information you
315
+ * will find on the web, these parameters can be combined with other parameters. As an
316
+ * example:
317
+ *
318
+ * For the 256-color palette:
319
+ * console.log('\x1b[31;38;5;196mThis will be red\x1b[m');
320
+ * console.log('\x1b[31;38;5;20mThis will be blue\x1b[m')
321
+ *
322
+ * For RGB:
323
+ * console.log('\x1b[31;38;2;255;0;0mThis will be red\x1b[m');
324
+ * console.log('\x1b[31;38;2;0;0;255mThis will be blue\x1b[m');
325
+ */
326
+ const processSetColor = () => {
327
+ if (index + 1 === sgrParams.length) return;
328
+ switch (sgrParams[++index]) {
329
+ case SGRParamColor.Color256: {
330
+ if (index + 1 === sgrParams.length) return;
331
+ const colorIndex = sgrParams[++index];
332
+ switch (colorIndex) {
333
+ case SGRParamIndexedColor.Black: return ANSIColor.Black;
334
+ case SGRParamIndexedColor.Red: return ANSIColor.Red;
335
+ case SGRParamIndexedColor.Green: return ANSIColor.Green;
336
+ case SGRParamIndexedColor.Yellow: return ANSIColor.Yellow;
337
+ case SGRParamIndexedColor.Blue: return ANSIColor.Blue;
338
+ case SGRParamIndexedColor.Magenta: return ANSIColor.Magenta;
339
+ case SGRParamIndexedColor.Cyan: return ANSIColor.Cyan;
340
+ case SGRParamIndexedColor.White: return ANSIColor.White;
341
+ case SGRParamIndexedColor.BrightBlack: return ANSIColor.BrightBlack;
342
+ case SGRParamIndexedColor.BrightRed: return ANSIColor.BrightRed;
343
+ case SGRParamIndexedColor.BrightGreen: return ANSIColor.BrightGreen;
344
+ case SGRParamIndexedColor.BrightYellow: return ANSIColor.BrightYellow;
345
+ case SGRParamIndexedColor.BrightBlue: return ANSIColor.BrightBlue;
346
+ case SGRParamIndexedColor.BrightMagenta: return ANSIColor.BrightMagenta;
347
+ case SGRParamIndexedColor.BrightCyan: return ANSIColor.BrightCyan;
348
+ case SGRParamIndexedColor.BrightWhite: return ANSIColor.BrightWhite;
349
+ default:
350
+ if (colorIndex % 1 !== 0) return;
351
+ if (colorIndex >= 16 && colorIndex <= 231) {
352
+ let colorNumber = colorIndex - 16;
353
+ let blue = colorNumber % 6;
354
+ colorNumber = (colorNumber - blue) / 6;
355
+ let green = colorNumber % 6;
356
+ colorNumber = (colorNumber - green) / 6;
357
+ let red = colorNumber;
358
+ blue = Math.round(blue * 255 / 5);
359
+ green = Math.round(green * 255 / 5);
360
+ red = Math.round(red * 255 / 5);
361
+ return "#" + twoDigitHex(red) + twoDigitHex(green) + twoDigitHex(blue);
362
+ } else if (colorIndex >= 232 && colorIndex <= 255) {
363
+ const rgb = Math.round((colorIndex - 232) / 23 * 255);
364
+ const grayscale = twoDigitHex(rgb);
365
+ return "#" + grayscale + grayscale + grayscale;
366
+ } else return;
367
+ }
368
+ }
369
+ case SGRParamColor.ColorRGB: {
370
+ const rgb = [
371
+ 0,
372
+ 0,
373
+ 0
374
+ ];
375
+ for (let i = 0; i < 3 && index + 1 < sgrParams.length; i++) rgb[i] = sgrParams[++index];
376
+ return "#" + twoDigitHex(rgb[0]) + twoDigitHex(rgb[1]) + twoDigitHex(rgb[2]);
377
+ }
378
+ }
379
+ };
380
+ switch (sgrParam) {
381
+ case SGRParam.Reset:
382
+ sgrState.reset();
383
+ break;
384
+ case SGRParam.Bold:
385
+ sgrState.setStyle(ANSIStyle.Bold);
386
+ break;
387
+ case SGRParam.Dim:
388
+ sgrState.setStyle(ANSIStyle.Dim);
389
+ break;
390
+ case SGRParam.Italic:
391
+ sgrState.setStyle(ANSIStyle.Italic);
392
+ break;
393
+ case SGRParam.Underlined:
394
+ sgrState.setStyle(ANSIStyle.Underlined, ANSIStyle.DoubleUnderlined);
395
+ break;
396
+ case SGRParam.SlowBlink:
397
+ sgrState.setStyle(ANSIStyle.SlowBlink, ANSIStyle.RapidBlink);
398
+ break;
399
+ case SGRParam.RapidBlink:
400
+ sgrState.setStyle(ANSIStyle.RapidBlink, ANSIStyle.SlowBlink);
401
+ break;
402
+ case SGRParam.Reversed:
403
+ sgrState.setReversed(true);
404
+ break;
405
+ case SGRParam.Hidden:
406
+ sgrState.setStyle(ANSIStyle.Hidden);
407
+ break;
408
+ case SGRParam.CrossedOut:
409
+ sgrState.setStyle(ANSIStyle.CrossedOut);
410
+ break;
411
+ case SGRParam.PrimaryFont:
412
+ sgrState.setFont();
413
+ break;
414
+ case SGRParam.AlternativeFont1:
415
+ sgrState.setFont(ANSIFont.AlternativeFont1);
416
+ break;
417
+ case SGRParam.AlternativeFont2:
418
+ sgrState.setFont(ANSIFont.AlternativeFont2);
419
+ break;
420
+ case SGRParam.AlternativeFont3:
421
+ sgrState.setFont(ANSIFont.AlternativeFont3);
422
+ break;
423
+ case SGRParam.AlternativeFont4:
424
+ sgrState.setFont(ANSIFont.AlternativeFont4);
425
+ break;
426
+ case SGRParam.AlternativeFont5:
427
+ sgrState.setFont(ANSIFont.AlternativeFont5);
428
+ break;
429
+ case SGRParam.AlternativeFont6:
430
+ sgrState.setFont(ANSIFont.AlternativeFont6);
431
+ break;
432
+ case SGRParam.AlternativeFont7:
433
+ sgrState.setFont(ANSIFont.AlternativeFont7);
434
+ break;
435
+ case SGRParam.AlternativeFont8:
436
+ sgrState.setFont(ANSIFont.AlternativeFont8);
437
+ break;
438
+ case SGRParam.AlternativeFont9:
439
+ sgrState.setFont(ANSIFont.AlternativeFont9);
440
+ break;
441
+ case SGRParam.Fraktur:
442
+ sgrState.setStyle(ANSIStyle.Fraktur);
443
+ break;
444
+ case SGRParam.DoubleUnderlined:
445
+ sgrState.setStyle(ANSIStyle.DoubleUnderlined, ANSIStyle.Underlined);
446
+ break;
447
+ case SGRParam.NormalIntensity:
448
+ sgrState.deleteStyles(ANSIStyle.Bold, ANSIStyle.Dim);
449
+ break;
450
+ case SGRParam.NotItalicNotFraktur:
451
+ sgrState.deleteStyles(ANSIStyle.Italic, ANSIStyle.Fraktur);
452
+ break;
453
+ case SGRParam.NotUnderlined:
454
+ sgrState.deleteStyles(ANSIStyle.Underlined, ANSIStyle.DoubleUnderlined);
455
+ break;
456
+ case SGRParam.NotBlinking:
457
+ sgrState.deleteStyles(ANSIStyle.SlowBlink, ANSIStyle.RapidBlink);
458
+ break;
459
+ case SGRParam.ProportionalSpacing: break;
460
+ case SGRParam.NotReversed:
461
+ sgrState.setReversed(false);
462
+ break;
463
+ case SGRParam.Reveal:
464
+ sgrState.deleteStyles(ANSIStyle.Hidden);
465
+ break;
466
+ case SGRParam.NotCrossedOut:
467
+ sgrState.deleteStyles(ANSIStyle.CrossedOut);
468
+ break;
469
+ case SGRParam.ForegroundBlack:
470
+ sgrState.setForegroundColor(ANSIColor.Black);
471
+ break;
472
+ case SGRParam.ForegroundRed:
473
+ sgrState.setForegroundColor(ANSIColor.Red);
474
+ break;
475
+ case SGRParam.ForegroundGreen:
476
+ sgrState.setForegroundColor(ANSIColor.Green);
477
+ break;
478
+ case SGRParam.ForegroundYellow:
479
+ sgrState.setForegroundColor(ANSIColor.Yellow);
480
+ break;
481
+ case SGRParam.ForegroundBlue:
482
+ sgrState.setForegroundColor(ANSIColor.Blue);
483
+ break;
484
+ case SGRParam.ForegroundMagenta:
485
+ sgrState.setForegroundColor(ANSIColor.Magenta);
486
+ break;
487
+ case SGRParam.ForegroundCyan:
488
+ sgrState.setForegroundColor(ANSIColor.Cyan);
489
+ break;
490
+ case SGRParam.ForegroundWhite:
491
+ sgrState.setForegroundColor(ANSIColor.White);
492
+ break;
493
+ case SGRParam.SetForeground: {
494
+ const foregroundColor = processSetColor();
495
+ if (foregroundColor) sgrState.setForegroundColor(foregroundColor);
496
+ break;
497
+ }
498
+ case SGRParam.DefaultForeground:
499
+ sgrState.setForegroundColor();
500
+ break;
501
+ case SGRParam.BackgroundBlack:
502
+ sgrState.setBackgroundColor(ANSIColor.Black);
503
+ break;
504
+ case SGRParam.BackgroundRed:
505
+ sgrState.setBackgroundColor(ANSIColor.Red);
506
+ break;
507
+ case SGRParam.BackgroundGreen:
508
+ sgrState.setBackgroundColor(ANSIColor.Green);
509
+ break;
510
+ case SGRParam.BackgroundYellow:
511
+ sgrState.setBackgroundColor(ANSIColor.Yellow);
512
+ break;
513
+ case SGRParam.BackgroundBlue:
514
+ sgrState.setBackgroundColor(ANSIColor.Blue);
515
+ break;
516
+ case SGRParam.BackgroundMagenta:
517
+ sgrState.setBackgroundColor(ANSIColor.Magenta);
518
+ break;
519
+ case SGRParam.BackgroundCyan:
520
+ sgrState.setBackgroundColor(ANSIColor.Cyan);
521
+ break;
522
+ case SGRParam.BackgroundWhite:
523
+ sgrState.setBackgroundColor(ANSIColor.White);
524
+ break;
525
+ case SGRParam.SetBackground: {
526
+ const backgroundColor = processSetColor();
527
+ if (backgroundColor) sgrState.setBackgroundColor(backgroundColor);
528
+ break;
529
+ }
530
+ case SGRParam.DefaultBackground:
531
+ sgrState.setBackgroundColor();
532
+ break;
533
+ case SGRParam.ForegroundBrightBlack:
534
+ sgrState.setForegroundColor(ANSIColor.BrightBlack);
535
+ break;
536
+ case SGRParam.ForegroundBrightRed:
537
+ sgrState.setForegroundColor(ANSIColor.BrightRed);
538
+ break;
539
+ case SGRParam.ForegroundBrightGreen:
540
+ sgrState.setForegroundColor(ANSIColor.BrightGreen);
541
+ break;
542
+ case SGRParam.ForegroundBrightYellow:
543
+ sgrState.setForegroundColor(ANSIColor.BrightYellow);
544
+ break;
545
+ case SGRParam.ForegroundBrightBlue:
546
+ sgrState.setForegroundColor(ANSIColor.BrightBlue);
547
+ break;
548
+ case SGRParam.ForegroundBrightMagenta:
549
+ sgrState.setForegroundColor(ANSIColor.BrightMagenta);
550
+ break;
551
+ case SGRParam.ForegroundBrightCyan:
552
+ sgrState.setForegroundColor(ANSIColor.BrightCyan);
553
+ break;
554
+ case SGRParam.ForegroundBrightWhite:
555
+ sgrState.setForegroundColor(ANSIColor.BrightWhite);
556
+ break;
557
+ case SGRParam.BackgroundBrightBlack:
558
+ sgrState.setBackgroundColor(ANSIColor.BrightBlack);
559
+ break;
560
+ case SGRParam.BackgroundBrightRed:
561
+ sgrState.setBackgroundColor(ANSIColor.BrightRed);
562
+ break;
563
+ case SGRParam.BackgroundBrightGreen:
564
+ sgrState.setBackgroundColor(ANSIColor.BrightGreen);
565
+ break;
566
+ case SGRParam.BackgroundBrightYellow:
567
+ sgrState.setBackgroundColor(ANSIColor.BrightYellow);
568
+ break;
569
+ case SGRParam.BackgroundBrightBlue:
570
+ sgrState.setBackgroundColor(ANSIColor.BrightBlue);
571
+ break;
572
+ case SGRParam.BackgroundBrightMagenta:
573
+ sgrState.setBackgroundColor(ANSIColor.BrightMagenta);
574
+ break;
575
+ case SGRParam.BackgroundBrightCyan:
576
+ sgrState.setBackgroundColor(ANSIColor.BrightCyan);
577
+ break;
578
+ case SGRParam.BackgroundBrightWhite: sgrState.setBackgroundColor(ANSIColor.BrightWhite);
579
+ }
580
+ }
581
+ if (!SGRState.equivalent(sgrState, this._sgrState)) this._sgrState = sgrState;
582
+ }
583
+ }
584
+ exports$1.ANSIOutput = ANSIOutput;
585
+ /**
586
+ * SGRParam enumeration.
587
+ */
588
+ var SGRParam;
589
+ (function(SGRParam) {
590
+ SGRParam[SGRParam["Reset"] = 0] = "Reset";
591
+ SGRParam[SGRParam["Bold"] = 1] = "Bold";
592
+ SGRParam[SGRParam["Dim"] = 2] = "Dim";
593
+ SGRParam[SGRParam["Italic"] = 3] = "Italic";
594
+ SGRParam[SGRParam["Underlined"] = 4] = "Underlined";
595
+ SGRParam[SGRParam["SlowBlink"] = 5] = "SlowBlink";
596
+ SGRParam[SGRParam["RapidBlink"] = 6] = "RapidBlink";
597
+ SGRParam[SGRParam["Reversed"] = 7] = "Reversed";
598
+ SGRParam[SGRParam["Hidden"] = 8] = "Hidden";
599
+ SGRParam[SGRParam["CrossedOut"] = 9] = "CrossedOut";
600
+ SGRParam[SGRParam["PrimaryFont"] = 10] = "PrimaryFont";
601
+ SGRParam[SGRParam["AlternativeFont1"] = 11] = "AlternativeFont1";
602
+ SGRParam[SGRParam["AlternativeFont2"] = 12] = "AlternativeFont2";
603
+ SGRParam[SGRParam["AlternativeFont3"] = 13] = "AlternativeFont3";
604
+ SGRParam[SGRParam["AlternativeFont4"] = 14] = "AlternativeFont4";
605
+ SGRParam[SGRParam["AlternativeFont5"] = 15] = "AlternativeFont5";
606
+ SGRParam[SGRParam["AlternativeFont6"] = 16] = "AlternativeFont6";
607
+ SGRParam[SGRParam["AlternativeFont7"] = 17] = "AlternativeFont7";
608
+ SGRParam[SGRParam["AlternativeFont8"] = 18] = "AlternativeFont8";
609
+ SGRParam[SGRParam["AlternativeFont9"] = 19] = "AlternativeFont9";
610
+ SGRParam[SGRParam["Fraktur"] = 20] = "Fraktur";
611
+ SGRParam[SGRParam["DoubleUnderlined"] = 21] = "DoubleUnderlined";
612
+ SGRParam[SGRParam["NormalIntensity"] = 22] = "NormalIntensity";
613
+ SGRParam[SGRParam["NotItalicNotFraktur"] = 23] = "NotItalicNotFraktur";
614
+ SGRParam[SGRParam["NotUnderlined"] = 24] = "NotUnderlined";
615
+ SGRParam[SGRParam["NotBlinking"] = 25] = "NotBlinking";
616
+ SGRParam[SGRParam["ProportionalSpacing"] = 26] = "ProportionalSpacing";
617
+ SGRParam[SGRParam["NotReversed"] = 27] = "NotReversed";
618
+ SGRParam[SGRParam["Reveal"] = 28] = "Reveal";
619
+ SGRParam[SGRParam["NotCrossedOut"] = 29] = "NotCrossedOut";
620
+ SGRParam[SGRParam["ForegroundBlack"] = 30] = "ForegroundBlack";
621
+ SGRParam[SGRParam["ForegroundRed"] = 31] = "ForegroundRed";
622
+ SGRParam[SGRParam["ForegroundGreen"] = 32] = "ForegroundGreen";
623
+ SGRParam[SGRParam["ForegroundYellow"] = 33] = "ForegroundYellow";
624
+ SGRParam[SGRParam["ForegroundBlue"] = 34] = "ForegroundBlue";
625
+ SGRParam[SGRParam["ForegroundMagenta"] = 35] = "ForegroundMagenta";
626
+ SGRParam[SGRParam["ForegroundCyan"] = 36] = "ForegroundCyan";
627
+ SGRParam[SGRParam["ForegroundWhite"] = 37] = "ForegroundWhite";
628
+ SGRParam[SGRParam["SetForeground"] = 38] = "SetForeground";
629
+ SGRParam[SGRParam["DefaultForeground"] = 39] = "DefaultForeground";
630
+ SGRParam[SGRParam["BackgroundBlack"] = 40] = "BackgroundBlack";
631
+ SGRParam[SGRParam["BackgroundRed"] = 41] = "BackgroundRed";
632
+ SGRParam[SGRParam["BackgroundGreen"] = 42] = "BackgroundGreen";
633
+ SGRParam[SGRParam["BackgroundYellow"] = 43] = "BackgroundYellow";
634
+ SGRParam[SGRParam["BackgroundBlue"] = 44] = "BackgroundBlue";
635
+ SGRParam[SGRParam["BackgroundMagenta"] = 45] = "BackgroundMagenta";
636
+ SGRParam[SGRParam["BackgroundCyan"] = 46] = "BackgroundCyan";
637
+ SGRParam[SGRParam["BackgroundWhite"] = 47] = "BackgroundWhite";
638
+ SGRParam[SGRParam["SetBackground"] = 48] = "SetBackground";
639
+ SGRParam[SGRParam["DefaultBackground"] = 49] = "DefaultBackground";
640
+ SGRParam[SGRParam["DisableProportionalSpacing"] = 50] = "DisableProportionalSpacing";
641
+ SGRParam[SGRParam["Framed"] = 51] = "Framed";
642
+ SGRParam[SGRParam["Encircled"] = 52] = "Encircled";
643
+ SGRParam[SGRParam["Overlined"] = 53] = "Overlined";
644
+ SGRParam[SGRParam["NotFramedNotEncircled"] = 54] = "NotFramedNotEncircled";
645
+ SGRParam[SGRParam["NotOverlined"] = 55] = "NotOverlined";
646
+ SGRParam[SGRParam["SetUnderline"] = 58] = "SetUnderline";
647
+ SGRParam[SGRParam["DefaultUnderline"] = 59] = "DefaultUnderline";
648
+ SGRParam[SGRParam["IdeogramUnderlineOrRightSideLine"] = 60] = "IdeogramUnderlineOrRightSideLine";
649
+ SGRParam[SGRParam["IdeogramDoubleUnderlineOrDoubleRightSideLine"] = 61] = "IdeogramDoubleUnderlineOrDoubleRightSideLine";
650
+ SGRParam[SGRParam["IdeogramOverlineOrLeftSideLine"] = 62] = "IdeogramOverlineOrLeftSideLine";
651
+ SGRParam[SGRParam["IdeogramDoubleOverlineOrDoubleLeftSideLine"] = 63] = "IdeogramDoubleOverlineOrDoubleLeftSideLine";
652
+ SGRParam[SGRParam["IdeogramStressMarking"] = 64] = "IdeogramStressMarking";
653
+ SGRParam[SGRParam["NoIdeogramAttributes"] = 65] = "NoIdeogramAttributes";
654
+ SGRParam[SGRParam["Superscript"] = 73] = "Superscript";
655
+ SGRParam[SGRParam["Subscript"] = 74] = "Subscript";
656
+ SGRParam[SGRParam["NotSuperscriptNotSubscript"] = 75] = "NotSuperscriptNotSubscript";
657
+ SGRParam[SGRParam["ForegroundBrightBlack"] = 90] = "ForegroundBrightBlack";
658
+ SGRParam[SGRParam["ForegroundBrightRed"] = 91] = "ForegroundBrightRed";
659
+ SGRParam[SGRParam["ForegroundBrightGreen"] = 92] = "ForegroundBrightGreen";
660
+ SGRParam[SGRParam["ForegroundBrightYellow"] = 93] = "ForegroundBrightYellow";
661
+ SGRParam[SGRParam["ForegroundBrightBlue"] = 94] = "ForegroundBrightBlue";
662
+ SGRParam[SGRParam["ForegroundBrightMagenta"] = 95] = "ForegroundBrightMagenta";
663
+ SGRParam[SGRParam["ForegroundBrightCyan"] = 96] = "ForegroundBrightCyan";
664
+ SGRParam[SGRParam["ForegroundBrightWhite"] = 97] = "ForegroundBrightWhite";
665
+ SGRParam[SGRParam["BackgroundBrightBlack"] = 100] = "BackgroundBrightBlack";
666
+ SGRParam[SGRParam["BackgroundBrightRed"] = 101] = "BackgroundBrightRed";
667
+ SGRParam[SGRParam["BackgroundBrightGreen"] = 102] = "BackgroundBrightGreen";
668
+ SGRParam[SGRParam["BackgroundBrightYellow"] = 103] = "BackgroundBrightYellow";
669
+ SGRParam[SGRParam["BackgroundBrightBlue"] = 104] = "BackgroundBrightBlue";
670
+ SGRParam[SGRParam["BackgroundBrightMagenta"] = 105] = "BackgroundBrightMagenta";
671
+ SGRParam[SGRParam["BackgroundBrightCyan"] = 106] = "BackgroundBrightCyan";
672
+ SGRParam[SGRParam["BackgroundBrightWhite"] = 107] = "BackgroundBrightWhite";
673
+ })(SGRParam || (SGRParam = {}));
674
+ /**
675
+ * SGRParamColor enumeration.
676
+ */
677
+ var SGRParamColor;
678
+ (function(SGRParamColor) {
679
+ SGRParamColor[SGRParamColor["Color256"] = 5] = "Color256";
680
+ SGRParamColor[SGRParamColor["ColorRGB"] = 2] = "ColorRGB";
681
+ })(SGRParamColor || (SGRParamColor = {}));
682
+ /**
683
+ * SGRParamIndexedColor enumeration.
684
+ */
685
+ var SGRParamIndexedColor;
686
+ (function(SGRParamIndexedColor) {
687
+ SGRParamIndexedColor[SGRParamIndexedColor["Black"] = 0] = "Black";
688
+ SGRParamIndexedColor[SGRParamIndexedColor["Red"] = 1] = "Red";
689
+ SGRParamIndexedColor[SGRParamIndexedColor["Green"] = 2] = "Green";
690
+ SGRParamIndexedColor[SGRParamIndexedColor["Yellow"] = 3] = "Yellow";
691
+ SGRParamIndexedColor[SGRParamIndexedColor["Blue"] = 4] = "Blue";
692
+ SGRParamIndexedColor[SGRParamIndexedColor["Magenta"] = 5] = "Magenta";
693
+ SGRParamIndexedColor[SGRParamIndexedColor["Cyan"] = 6] = "Cyan";
694
+ SGRParamIndexedColor[SGRParamIndexedColor["White"] = 7] = "White";
695
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightBlack"] = 8] = "BrightBlack";
696
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightRed"] = 9] = "BrightRed";
697
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightGreen"] = 10] = "BrightGreen";
698
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightYellow"] = 11] = "BrightYellow";
699
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightBlue"] = 12] = "BrightBlue";
700
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightMagenta"] = 13] = "BrightMagenta";
701
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightCyan"] = 14] = "BrightCyan";
702
+ SGRParamIndexedColor[SGRParamIndexedColor["BrightWhite"] = 15] = "BrightWhite";
703
+ })(SGRParamIndexedColor || (SGRParamIndexedColor = {}));
704
+ /**
705
+ * ParserState enumeration.
706
+ */
707
+ var ParserState;
708
+ (function(ParserState) {
709
+ ParserState[ParserState["BufferingOutput"] = 0] = "BufferingOutput";
710
+ ParserState[ParserState["ControlSequenceStarted"] = 1] = "ControlSequenceStarted";
711
+ ParserState[ParserState["ParsingControlSequence"] = 2] = "ParsingControlSequence";
712
+ })(ParserState || (ParserState = {}));
713
+ /**
714
+ * SGRState class.
715
+ */
716
+ class SGRState {
717
+ /**
718
+ * Gets or sets the styles.
719
+ */
720
+ _styles;
721
+ /**
722
+ * Gets or sets the foreground color.
723
+ */
724
+ _foregroundColor;
725
+ /**
726
+ * Gets or sets the background color.
727
+ */
728
+ _backgroundColor;
729
+ /**
730
+ * Gets or sets the underlined color.
731
+ */
732
+ _underlinedColor;
733
+ /**
734
+ * Gets or sets a value which indicates whether the foreground and background colors are
735
+ * reversed.
736
+ */
737
+ _reversed;
738
+ /**
739
+ * Gets or sets the font.
740
+ */
741
+ _font;
742
+ /**
743
+ * Resets the SGRState.
744
+ */
745
+ reset() {
746
+ this._styles = void 0;
747
+ this._foregroundColor = void 0;
748
+ this._backgroundColor = void 0;
749
+ this._underlinedColor = void 0;
750
+ this._reversed = void 0;
751
+ this._font = void 0;
752
+ }
753
+ /**
754
+ * Creates a copy of the SGRState.
755
+ * @returns The copy of the SGRState.
756
+ */
757
+ copy() {
758
+ const copy = new SGRState();
759
+ if (this._styles && this._styles.size) {
760
+ const styles = /* @__PURE__ */ new Set();
761
+ this._styles.forEach((style) => styles.add(style));
762
+ copy._styles = styles;
763
+ }
764
+ copy._foregroundColor = this._foregroundColor;
765
+ copy._backgroundColor = this._backgroundColor;
766
+ copy._underlinedColor = this._underlinedColor;
767
+ copy._reversed = this._reversed;
768
+ copy._font = this._font;
769
+ return copy;
770
+ }
771
+ /**
772
+ * Sets a style.
773
+ * @param style The style to set.
774
+ * @param stylesToDelete The styles to delete.
775
+ */
776
+ setStyle(style, ...stylesToDelete) {
777
+ if (this._styles) for (const style of stylesToDelete) this._styles.delete(style);
778
+ else this._styles = /* @__PURE__ */ new Set();
779
+ this._styles.add(style);
780
+ }
781
+ /**
782
+ * Deletes styles.
783
+ * @param stylesToDelete The styles to delete.
784
+ */
785
+ deleteStyles(...stylesToDelete) {
786
+ if (this._styles) {
787
+ for (const style of stylesToDelete) this._styles.delete(style);
788
+ if (!this._styles.size) this._styles = void 0;
789
+ }
790
+ }
791
+ /**
792
+ * Sets the foreground color.
793
+ * @param color The foreground color.
794
+ */
795
+ setForegroundColor(color) {
796
+ if (!this._reversed) this._foregroundColor = color;
797
+ else this._backgroundColor = color;
798
+ }
799
+ /**
800
+ * Sets the background color.
801
+ * @param color The background color.
802
+ */
803
+ setBackgroundColor(color) {
804
+ if (!this._reversed) this._backgroundColor = color;
805
+ else this._foregroundColor = color;
806
+ }
807
+ /**
808
+ * Sets reversed.
809
+ * @param reversed A value which indicates whether the foreground and background colors are
810
+ * reversed.
811
+ */
812
+ setReversed(reversed) {
813
+ if (reversed) {
814
+ if (!this._reversed) {
815
+ this._reversed = true;
816
+ this.reverseForegroundAndBackgroundColors();
817
+ }
818
+ } else if (this._reversed) {
819
+ this._reversed = void 0;
820
+ this.reverseForegroundAndBackgroundColors();
821
+ }
822
+ }
823
+ /**
824
+ * Sets the font.
825
+ * @param font The font.
826
+ */
827
+ setFont(font) {
828
+ this._font = font;
829
+ }
830
+ /**
831
+ *
832
+ * @param left
833
+ * @param right
834
+ * @returns
835
+ */
836
+ static equivalent(left, right) {
837
+ const setReplacer = (_, value) => value instanceof Set ? !value.size ? void 0 : [...value] : value;
838
+ return left === right || JSON.stringify(left, setReplacer) === JSON.stringify(right, setReplacer);
839
+ }
840
+ /**
841
+ * Gets the styles.
842
+ */
843
+ get styles() {
844
+ return !this._styles ? void 0 : [...this._styles];
845
+ }
846
+ /**
847
+ * Gets the foreground color.
848
+ */
849
+ get foregroundColor() {
850
+ if (this._backgroundColor && !this._foregroundColor) switch (this._backgroundColor) {
851
+ case ANSIColor.Black:
852
+ case ANSIColor.BrightBlack:
853
+ case ANSIColor.Red:
854
+ case ANSIColor.BrightRed: return ANSIColor.White;
855
+ case ANSIColor.Green:
856
+ case ANSIColor.BrightGreen:
857
+ case ANSIColor.Yellow:
858
+ case ANSIColor.BrightYellow:
859
+ case ANSIColor.Blue:
860
+ case ANSIColor.BrightBlue:
861
+ case ANSIColor.Magenta:
862
+ case ANSIColor.BrightMagenta:
863
+ case ANSIColor.Cyan:
864
+ case ANSIColor.BrightCyan:
865
+ case ANSIColor.White:
866
+ case ANSIColor.BrightWhite: return ANSIColor.Black;
867
+ }
868
+ return this._foregroundColor;
869
+ }
870
+ /**
871
+ * Gets the background color.
872
+ */
873
+ get backgroundColor() {
874
+ return this._backgroundColor;
875
+ }
876
+ /**
877
+ * Gets the underlined color.
878
+ */
879
+ get underlinedColor() {
880
+ return this._underlinedColor;
881
+ }
882
+ /**
883
+ * Gets the font.
884
+ */
885
+ get font() {
886
+ return this._font;
887
+ }
888
+ /**
889
+ * Reverses the foreground and background colors.
890
+ */
891
+ reverseForegroundAndBackgroundColors() {
892
+ const foregroundColor = this._foregroundColor;
893
+ this._foregroundColor = this._backgroundColor;
894
+ this._backgroundColor = foregroundColor;
895
+ }
896
+ }
897
+ /**
898
+ * OutputLine class.
899
+ */
900
+ class OutputLine {
901
+ /**
902
+ * Gets the identifier.
903
+ */
904
+ _id = generateId();
905
+ /**
906
+ * Gets or sets the output runs.
907
+ */
908
+ _outputRuns = [];
909
+ /**
910
+ * Gets or sets the total length.
911
+ */
912
+ _totalLength = 0;
913
+ /**
914
+ * Clears the entire output line.
915
+ */
916
+ clearEntireLine() {
917
+ if (this._totalLength) this._outputRuns = [new OutputRun(" ".repeat(this._totalLength))];
918
+ }
919
+ /**
920
+ * Clears to the end of the output line.
921
+ * @param column The column at which to clear from.
922
+ */
923
+ clearToEndOfLine(column) {
924
+ column = Math.max(column, 0);
925
+ if (column >= this._totalLength) return;
926
+ if (column === 0) {
927
+ this.clearEntireLine();
928
+ return;
929
+ }
930
+ let leftOffset = 0;
931
+ let leftOutputRun;
932
+ let leftOutputRunIndex = void 0;
933
+ for (let index = 0; index < this._outputRuns.length; index++) {
934
+ const outputRun = this._outputRuns[index];
935
+ if (column < leftOffset + outputRun.text.length) {
936
+ leftOutputRun = outputRun;
937
+ leftOutputRunIndex = index;
938
+ break;
939
+ }
940
+ leftOffset += outputRun.text.length;
941
+ }
942
+ if (leftOutputRun === void 0 || leftOutputRunIndex === void 0) return;
943
+ const leftTextLength = column - leftOffset;
944
+ const erasureText = " ".repeat(this._totalLength - column);
945
+ const outputRuns = [];
946
+ if (!leftTextLength) outputRuns.push(new OutputRun(erasureText));
947
+ else {
948
+ const leftText = leftOutputRun.text.slice(0, leftTextLength);
949
+ outputRuns.push(new OutputRun(leftText, leftOutputRun.sgrState));
950
+ outputRuns.push(new OutputRun(erasureText));
951
+ }
952
+ this.outputRuns.splice(leftOutputRunIndex, this._outputRuns.length - leftOutputRunIndex, ...outputRuns);
953
+ }
954
+ /**
955
+ * Clears to the beginning of the output line.
956
+ * @param column The column at which to clear from.
957
+ */
958
+ clearToBeginningOfLine(column) {
959
+ column = Math.max(column, 0);
960
+ if (column === 0) return;
961
+ if (column >= this._totalLength) {
962
+ this.clearEntireLine();
963
+ return;
964
+ }
965
+ let rightOffset = 0;
966
+ let rightOutputRun;
967
+ let rightOutputRunIndex = void 0;
968
+ for (let index = this._outputRuns.length - 1; index >= 0; index--) {
969
+ const outputRun = this._outputRuns[index];
970
+ if (column >= rightOffset - outputRun.text.length) {
971
+ rightOutputRun = outputRun;
972
+ rightOutputRunIndex = index;
973
+ break;
974
+ }
975
+ rightOffset -= outputRun.text.length;
976
+ }
977
+ if (rightOutputRun === void 0 || rightOutputRunIndex === void 0) return;
978
+ const rightTextLength = rightOffset - column;
979
+ const erasureText = " ".repeat(column);
980
+ const outputRuns = [new OutputRun(erasureText)];
981
+ if (rightTextLength) {
982
+ const rightOutputRunText = rightOutputRun.text.slice(-rightTextLength);
983
+ outputRuns.push(new OutputRun(rightOutputRunText, rightOutputRun.sgrState));
984
+ }
985
+ this.outputRuns.splice(0, this._outputRuns.length - rightOutputRunIndex, ...outputRuns);
986
+ }
987
+ /**
988
+ * Inserts text into the output line.
989
+ * @param text The text to insert.
990
+ * @param column The column at which to insert the text.
991
+ * @param sgrState The SGR state.
992
+ */
993
+ insert(text, column, sgrState) {
994
+ if (!text.length) return;
995
+ if (column === this._totalLength) {
996
+ this._totalLength += text.length;
997
+ if (this._outputRuns.length) {
998
+ const lastOutputRun = this._outputRuns[this._outputRuns.length - 1];
999
+ if (SGRState.equivalent(lastOutputRun.sgrState, sgrState)) {
1000
+ lastOutputRun.appendText(text);
1001
+ return;
1002
+ }
1003
+ }
1004
+ this._outputRuns.push(new OutputRun(text, sgrState));
1005
+ return;
1006
+ }
1007
+ if (column > this._totalLength) {
1008
+ const spacer = " ".repeat(column - this._totalLength);
1009
+ this._totalLength += spacer.length + text.length;
1010
+ if (!sgrState && this._outputRuns.length) {
1011
+ const lastOutputRun = this._outputRuns[this._outputRuns.length - 1];
1012
+ if (!lastOutputRun.sgrState) {
1013
+ lastOutputRun.appendText(spacer);
1014
+ lastOutputRun.appendText(text);
1015
+ return;
1016
+ }
1017
+ }
1018
+ if (!sgrState) this._outputRuns.push(new OutputRun(spacer + text));
1019
+ else {
1020
+ this._outputRuns.push(new OutputRun(spacer));
1021
+ this._outputRuns.push(new OutputRun(text, sgrState));
1022
+ }
1023
+ }
1024
+ let leftOffset = 0;
1025
+ let leftOutputRunIndex = void 0;
1026
+ for (let index = 0; index < this._outputRuns.length; index++) {
1027
+ const outputRun = this._outputRuns[index];
1028
+ if (column < leftOffset + outputRun.text.length) {
1029
+ leftOutputRunIndex = index;
1030
+ break;
1031
+ }
1032
+ leftOffset += outputRun.text.length;
1033
+ }
1034
+ if (leftOutputRunIndex === void 0) {
1035
+ this._outputRuns.push(new OutputRun(text, sgrState));
1036
+ return;
1037
+ }
1038
+ if (column + text.length >= this._totalLength) {
1039
+ const leftTextLength = column - leftOffset;
1040
+ const outputRuns = [];
1041
+ if (!leftTextLength) outputRuns.push(new OutputRun(text, sgrState));
1042
+ else {
1043
+ const leftOutputRun = this._outputRuns[leftOutputRunIndex];
1044
+ const leftText = leftOutputRun.text.slice(0, leftTextLength);
1045
+ if (SGRState.equivalent(leftOutputRun.sgrState, sgrState)) outputRuns.push(new OutputRun(leftText + text, sgrState));
1046
+ else {
1047
+ outputRuns.push(new OutputRun(leftText, leftOutputRun.sgrState));
1048
+ outputRuns.push(new OutputRun(text, sgrState));
1049
+ }
1050
+ }
1051
+ this.outputRuns.splice(leftOutputRunIndex, 1, ...outputRuns);
1052
+ this._totalLength = leftOffset + leftTextLength + text.length;
1053
+ return;
1054
+ }
1055
+ let rightOffset = this._totalLength;
1056
+ let rightOutputRunIndex = void 0;
1057
+ for (let index = this._outputRuns.length - 1; index >= 0; index--) {
1058
+ const outputRun = this._outputRuns[index];
1059
+ if (column + text.length > rightOffset - outputRun.text.length) {
1060
+ rightOutputRunIndex = index;
1061
+ break;
1062
+ }
1063
+ rightOffset -= outputRun.text.length;
1064
+ }
1065
+ if (rightOutputRunIndex === void 0) {
1066
+ this._outputRuns.push(new OutputRun(text, sgrState));
1067
+ return;
1068
+ }
1069
+ const outputRuns = [];
1070
+ const leftOutputRunTextLength = column - leftOffset;
1071
+ if (leftOutputRunTextLength) {
1072
+ const leftOutputRun = this._outputRuns[leftOutputRunIndex];
1073
+ const leftOutputRunText = leftOutputRun.text.slice(0, leftOutputRunTextLength);
1074
+ outputRuns.push(new OutputRun(leftOutputRunText, leftOutputRun.sgrState));
1075
+ }
1076
+ outputRuns.push(new OutputRun(text, sgrState));
1077
+ const rightOutputRunTextLength = rightOffset - (column + text.length);
1078
+ if (rightOutputRunTextLength) {
1079
+ const rightOutputRun = this._outputRuns[rightOutputRunIndex];
1080
+ const rightOutputRunText = rightOutputRun.text.slice(-rightOutputRunTextLength);
1081
+ outputRuns.push(new OutputRun(rightOutputRunText, rightOutputRun.sgrState));
1082
+ }
1083
+ this._outputRuns.splice(leftOutputRunIndex, rightOutputRunIndex - leftOutputRunIndex + 1, ...outputRuns);
1084
+ if (this._outputRuns.length > 1) this._outputRuns = OutputRun.optimizeOutputRuns(this._outputRuns);
1085
+ this._totalLength = this._outputRuns.reduce((totalLength, outputRun) => totalLength + outputRun.text.length, 0);
1086
+ }
1087
+ /**
1088
+ * Gets the identifier.
1089
+ */
1090
+ get id() {
1091
+ return this._id;
1092
+ }
1093
+ /**
1094
+ * Gets the output runs.
1095
+ */
1096
+ get outputRuns() {
1097
+ return this._outputRuns;
1098
+ }
1099
+ }
1100
+ /**
1101
+ * OutputRun class.
1102
+ */
1103
+ class OutputRun {
1104
+ /**
1105
+ * Gets the identifier.
1106
+ */
1107
+ _id = generateId();
1108
+ /**
1109
+ * Gets the SGR state.
1110
+ */
1111
+ _sgrState;
1112
+ /**
1113
+ * Gets or sets the text.
1114
+ */
1115
+ _text;
1116
+ get sgrState() {
1117
+ return this._sgrState;
1118
+ }
1119
+ /**
1120
+ * Constructor.
1121
+ * @param text The text.
1122
+ * @param sgrState The SGR state.
1123
+ */
1124
+ constructor(text, sgrState) {
1125
+ this._sgrState = sgrState;
1126
+ this._text = text;
1127
+ }
1128
+ /**
1129
+ * Optimizes a an array of output runs by combining adjacent output runs with equivalent SGR
1130
+ * states.
1131
+ * @param outputRunsIn The output runs to optimize.
1132
+ * @returns The optimized output runs.
1133
+ */
1134
+ static optimizeOutputRuns(outputRunsIn) {
1135
+ const outputRunsOut = [outputRunsIn[0]];
1136
+ for (let i = 1, o = 0; i < outputRunsIn.length; i++) {
1137
+ const outputRun = outputRunsIn[i];
1138
+ if (SGRState.equivalent(outputRunsOut[o].sgrState, outputRun.sgrState)) outputRunsOut[o]._text += outputRun.text;
1139
+ else outputRunsOut[++o] = outputRun;
1140
+ }
1141
+ return outputRunsOut;
1142
+ }
1143
+ /**
1144
+ * Appends text to the end of the output run.
1145
+ * @param text The text to append.
1146
+ */
1147
+ appendText(text) {
1148
+ this._text += text;
1149
+ }
1150
+ /**
1151
+ * Gets the identifier.
1152
+ */
1153
+ get id() {
1154
+ return this._id;
1155
+ }
1156
+ /**
1157
+ * Gets the format.
1158
+ */
1159
+ get format() {
1160
+ return this._sgrState;
1161
+ }
1162
+ /**
1163
+ * Gets the text.
1164
+ */
1165
+ get text() {
1166
+ return this._text;
1167
+ }
1168
+ }
1169
+ /**
1170
+ * Gets and ranges a parameter value.
1171
+ * @param value The value.
1172
+ * @param defaultValue The default value.
1173
+ * @param minValue The minimum value.
1174
+ * @returns The ranged parameter value.
1175
+ */
1176
+ const rangeParam = (value, defaultValue, minValue) => {
1177
+ const param = getParam(value, defaultValue);
1178
+ return Math.max(param, minValue);
1179
+ };
1180
+ /**
1181
+ * Gets a parameter value.
1182
+ * @param value The value.
1183
+ * @param defaultValue The default value.
1184
+ * @returns The parameter value.
1185
+ */
1186
+ const getParam = (value, defaultValue) => {
1187
+ const param = parseInt(value);
1188
+ return Number.isNaN(param) ? defaultValue : param;
1189
+ };
1190
+ /**
1191
+ * Converts a number to a two-digit hex string representing the value.
1192
+ * @param value The value.
1193
+ * @returns A two digit hex string representing the value.
1194
+ */
1195
+ const twoDigitHex = (value) => {
1196
+ const hex = Math.max(Math.min(255, value), 0).toString(16);
1197
+ return hex.length === 2 ? hex : "0" + hex;
1198
+ };
1199
+ });
1200
+ })))();
1201
+ var AnsiDisplayRich_module_default = {
1202
+ container: "_container_f35vk_1",
1203
+ toggle: "_toggle_f35vk_1"
1204
+ };
1205
+ //#endregion
1206
+ //#region ../../packages/react/src/components/AnsiDisplayRich.tsx
1207
+ var RichANSIDisplay = (t0) => {
1208
+ const $ = c(18);
1209
+ const { output, style, className } = t0;
1210
+ const icons = useComponentIcons();
1211
+ const [showRaw, setShowRaw] = useState(false);
1212
+ let t1;
1213
+ if ($[0] !== className || $[1] !== icons.code || $[2] !== output || $[3] !== showRaw || $[4] !== style) {
1214
+ const ansiOutput = new import_ansi_output.ANSIOutput();
1215
+ ansiOutput.processOutput(output);
1216
+ const getUniformBackgroundColor = () => {
1217
+ const backgroundColorCounts = /* @__PURE__ */ new Map();
1218
+ let totalLinesWithBackground = 0;
1219
+ for (const line of ansiOutput.outputLines) {
1220
+ let lineBackgroundColor = void 0;
1221
+ for (const run of line.outputRuns) if (run.format?.backgroundColor) {
1222
+ lineBackgroundColor = run.format.backgroundColor;
1223
+ break;
1224
+ }
1225
+ if (lineBackgroundColor) {
1226
+ totalLinesWithBackground++;
1227
+ backgroundColorCounts.set(lineBackgroundColor, (backgroundColorCounts.get(lineBackgroundColor) || 0) + 1);
1228
+ }
1229
+ }
1230
+ if (totalLinesWithBackground === 0) return;
1231
+ const backgroundColorPercentages = /* @__PURE__ */ new Map();
1232
+ for (const [color, count] of backgroundColorCounts.entries()) backgroundColorPercentages.set(color, count / totalLinesWithBackground);
1233
+ let dominantColor = void 0;
1234
+ let maxPercentage = 0;
1235
+ for (const [color_0, percentage] of backgroundColorPercentages.entries()) if (percentage > maxPercentage) {
1236
+ maxPercentage = percentage;
1237
+ dominantColor = color_0;
1238
+ }
1239
+ return maxPercentage > .8 ? dominantColor : void 0;
1240
+ };
1241
+ const uniformBackgroundColor = getUniformBackgroundColor();
1242
+ const backgroundStyle = uniformBackgroundColor ? computeForegroundBackgroundColor(kBackground, uniformBackgroundColor) : {};
1243
+ const firstOutputIndex = ansiOutput.outputLines.findIndex(_temp);
1244
+ let t2;
1245
+ if ($[6] !== className) {
1246
+ t2 = clsx(AnsiDisplay_module_default.ansiDisplayContainer, AnsiDisplayRich_module_default.container, className);
1247
+ $[6] = className;
1248
+ $[7] = t2;
1249
+ } else t2 = $[7];
1250
+ let t3;
1251
+ if ($[8] !== style) {
1252
+ t3 = { ...style };
1253
+ $[8] = style;
1254
+ $[9] = t3;
1255
+ } else t3 = $[9];
1256
+ let t4;
1257
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
1258
+ t4 = clsx(AnsiDisplayRich_module_default.toggle, "text-size-smallest");
1259
+ $[10] = t4;
1260
+ } else t4 = $[10];
1261
+ let t5;
1262
+ if ($[11] !== showRaw) {
1263
+ t5 = () => setShowRaw(!showRaw);
1264
+ $[11] = showRaw;
1265
+ $[12] = t5;
1266
+ } else t5 = $[12];
1267
+ const t6 = showRaw ? "Show rendered output" : "Show raw output";
1268
+ let t7;
1269
+ if ($[13] !== icons.code || $[14] !== showRaw || $[15] !== t5 || $[16] !== t6) {
1270
+ t7 = /*#__PURE__*/ jsx(ToolButton, {
1271
+ className: t4,
1272
+ icon: icons.code,
1273
+ label: "",
1274
+ latched: showRaw,
1275
+ onClick: t5,
1276
+ title: t6
1277
+ });
1278
+ $[13] = icons.code;
1279
+ $[14] = showRaw;
1280
+ $[15] = t5;
1281
+ $[16] = t6;
1282
+ $[17] = t7;
1283
+ } else t7 = $[17];
1284
+ t1 = /*#__PURE__*/ jsxs("div", {
1285
+ className: t2,
1286
+ style: t3,
1287
+ children: [t7, showRaw ? /*#__PURE__*/ jsx("pre", {
1288
+ className: clsx(AnsiDisplay_module_default.ansiDisplay, AnsiDisplay_module_default.ansiDisplayRaw),
1289
+ children: output
1290
+ }) : /*#__PURE__*/ jsx("div", {
1291
+ className: clsx(AnsiDisplay_module_default.ansiDisplay),
1292
+ style: backgroundStyle,
1293
+ children: ansiOutput.outputLines.map((line_1, index) => /*#__PURE__*/ jsx("div", { children: !line_1.outputRuns.length ? firstOutputIndex !== -1 && index > firstOutputIndex ? /*#__PURE__*/ jsx("br", {}) : null : line_1.outputRuns.map(_temp2) }, index))
1294
+ })]
1295
+ });
1296
+ $[0] = className;
1297
+ $[1] = icons.code;
1298
+ $[2] = output;
1299
+ $[3] = showRaw;
1300
+ $[4] = style;
1301
+ $[5] = t1;
1302
+ } else t1 = $[5];
1303
+ return t1;
1304
+ };
1305
+ var kForeground = 0;
1306
+ var kBackground = 1;
1307
+ var OutputRun = (t0) => {
1308
+ const $ = c(5);
1309
+ const { run } = t0;
1310
+ let t1;
1311
+ if ($[0] !== run) {
1312
+ t1 = computeCSSProperties(run);
1313
+ $[0] = run;
1314
+ $[1] = t1;
1315
+ } else t1 = $[1];
1316
+ let t2;
1317
+ if ($[2] !== run.text || $[3] !== t1) {
1318
+ t2 = /*#__PURE__*/ jsx("span", {
1319
+ style: t1,
1320
+ children: run.text
1321
+ });
1322
+ $[2] = run.text;
1323
+ $[3] = t1;
1324
+ $[4] = t2;
1325
+ } else t2 = $[4];
1326
+ return t2;
1327
+ };
1328
+ var computeCSSProperties = (outputRun) => {
1329
+ return !outputRun.format ? {} : {
1330
+ ...computeStyles(outputRun.format.styles || []),
1331
+ ...computeForegroundBackgroundColor(kForeground, outputRun.format.foregroundColor),
1332
+ ...computeForegroundBackgroundColor(kBackground, outputRun.format.backgroundColor)
1333
+ };
1334
+ };
1335
+ var computeStyles = (styles) => {
1336
+ let cssProperties = {};
1337
+ styles.forEach((style) => {
1338
+ switch (style) {
1339
+ case import_ansi_output.ANSIStyle.Bold:
1340
+ cssProperties = {
1341
+ ...cssProperties,
1342
+ fontWeight: "bold"
1343
+ };
1344
+ break;
1345
+ case import_ansi_output.ANSIStyle.Dim:
1346
+ cssProperties = {
1347
+ ...cssProperties,
1348
+ fontWeight: "lighter"
1349
+ };
1350
+ break;
1351
+ case import_ansi_output.ANSIStyle.Italic:
1352
+ cssProperties = {
1353
+ ...cssProperties,
1354
+ fontStyle: "italic"
1355
+ };
1356
+ break;
1357
+ case import_ansi_output.ANSIStyle.Underlined:
1358
+ cssProperties = {
1359
+ ...cssProperties,
1360
+ textDecorationLine: "underline",
1361
+ textDecorationStyle: "solid"
1362
+ };
1363
+ break;
1364
+ case import_ansi_output.ANSIStyle.SlowBlink:
1365
+ cssProperties = {
1366
+ ...cssProperties,
1367
+ animation: "ansi-display-run-blink 1s linear infinite"
1368
+ };
1369
+ break;
1370
+ case import_ansi_output.ANSIStyle.RapidBlink:
1371
+ cssProperties = {
1372
+ ...cssProperties,
1373
+ animation: "ansi-display-run-blink 0.5s linear infinite"
1374
+ };
1375
+ break;
1376
+ case import_ansi_output.ANSIStyle.Hidden:
1377
+ cssProperties = {
1378
+ ...cssProperties,
1379
+ visibility: "hidden"
1380
+ };
1381
+ break;
1382
+ case import_ansi_output.ANSIStyle.CrossedOut:
1383
+ cssProperties = {
1384
+ ...cssProperties,
1385
+ textDecorationLine: "line-through",
1386
+ textDecorationStyle: "solid"
1387
+ };
1388
+ break;
1389
+ case import_ansi_output.ANSIStyle.DoubleUnderlined: cssProperties = {
1390
+ ...cssProperties,
1391
+ textDecorationLine: "underline",
1392
+ textDecorationStyle: "double"
1393
+ };
1394
+ }
1395
+ });
1396
+ return cssProperties;
1397
+ };
1398
+ var computeForegroundBackgroundColor = (colorType, color) => {
1399
+ switch (color) {
1400
+ case void 0: return {};
1401
+ case import_ansi_output.ANSIColor.Black:
1402
+ case import_ansi_output.ANSIColor.Red:
1403
+ case import_ansi_output.ANSIColor.Green:
1404
+ case import_ansi_output.ANSIColor.Yellow:
1405
+ case import_ansi_output.ANSIColor.Blue:
1406
+ case import_ansi_output.ANSIColor.Magenta:
1407
+ case import_ansi_output.ANSIColor.Cyan:
1408
+ case import_ansi_output.ANSIColor.White:
1409
+ case import_ansi_output.ANSIColor.BrightBlack:
1410
+ case import_ansi_output.ANSIColor.BrightRed:
1411
+ case import_ansi_output.ANSIColor.BrightGreen:
1412
+ case import_ansi_output.ANSIColor.BrightYellow:
1413
+ case import_ansi_output.ANSIColor.BrightBlue:
1414
+ case import_ansi_output.ANSIColor.BrightMagenta:
1415
+ case import_ansi_output.ANSIColor.BrightCyan:
1416
+ case import_ansi_output.ANSIColor.BrightWhite: if (colorType === kForeground) return { color: `var(--${color})` };
1417
+ else return { background: `var(--${color})` };
1418
+ default: if (colorType === kForeground) return { color };
1419
+ else return { background: color };
1420
+ }
1421
+ };
1422
+ function _temp(line_0) {
1423
+ return line_0.outputRuns.length > 0;
1424
+ }
1425
+ function _temp2(outputRun) {
1426
+ return /*#__PURE__*/ jsx(OutputRun, { run: outputRun }, outputRun.id);
1427
+ }
1428
+ //#endregion
1429
+ export { RichANSIDisplay as default };
1430
+
1431
+ //# sourceMappingURL=AnsiDisplayRich-302CIkEj.js.map