blecsd 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +145 -145
  2. package/dist/{border-DGNDfT6T.d.ts → border-Br-Jc027.d.ts} +2 -2
  3. package/dist/{cell-DwIu2ryP.d.ts → cell-5Ty_3yMs.d.ts} +1 -1
  4. package/dist/cellRenderer-D0-DJXWl.d.ts +374 -0
  5. package/dist/chunk-4N7IFBRQ.js +4 -0
  6. package/dist/{chunk-DNRXW56C.js → chunk-4XCFTNGN.js} +1 -1
  7. package/dist/chunk-5YWRP2KG.js +3 -0
  8. package/dist/chunk-73Y45MLV.js +12 -0
  9. package/dist/chunk-7ZFQO3OQ.js +1 -0
  10. package/dist/chunk-A3GSH6MV.js +1 -0
  11. package/dist/chunk-A5B2BGUM.js +1 -0
  12. package/dist/chunk-AM6IDSXI.js +1 -0
  13. package/dist/chunk-EHYOVHRL.js +2 -0
  14. package/dist/chunk-EMZA6G2M.js +4 -0
  15. package/dist/chunk-EOFT3PNU.js +1 -0
  16. package/dist/chunk-ETFDYZVJ.js +1 -0
  17. package/dist/chunk-FUW7OD3H.js +1 -0
  18. package/dist/chunk-GRMSEMU7.js +1 -0
  19. package/dist/chunk-I7AUKTXE.js +1 -0
  20. package/dist/chunk-IANAVH2A.js +1 -0
  21. package/dist/chunk-JN2OGNK3.js +1 -0
  22. package/dist/chunk-JVMNMAHX.js +1 -0
  23. package/dist/chunk-K2QWNDXV.js +1 -0
  24. package/dist/chunk-KYNS3GBJ.js +2 -0
  25. package/dist/chunk-LI3ZYXUT.js +1 -0
  26. package/dist/chunk-LNEISTXM.js +1 -0
  27. package/dist/chunk-QABNK7IA.js +1 -0
  28. package/dist/chunk-QS5QXZNJ.js +1 -0
  29. package/dist/chunk-QTDRFJG2.js +1 -0
  30. package/dist/chunk-SVHITP3F.js +2 -0
  31. package/dist/chunk-UKVY43V3.js +1 -0
  32. package/dist/chunk-VIT4KE6Q.js +1 -0
  33. package/dist/chunk-XG5PVDOP.js +1 -0
  34. package/dist/chunk-XH5GTWCV.js +1 -0
  35. package/dist/chunk-XYMPBCYW.js +1 -0
  36. package/dist/chunk-YRSSCEAS.js +1 -0
  37. package/dist/chunk-ZL46COQF.js +1 -0
  38. package/dist/cli/init.js +1 -1
  39. package/dist/{componentStorage-CJTh-TPO.d.ts → componentStorage-CXJvx4Lt.d.ts} +2 -2
  40. package/dist/components/index.d.ts +8172 -7777
  41. package/dist/components/index.js +5 -1
  42. package/dist/core/index.d.ts +4777 -3942
  43. package/dist/core/index.js +1 -1
  44. package/dist/debug/index.d.ts +310 -84
  45. package/dist/debug/index.js +8 -1
  46. package/dist/{dirtyTracking-C4v8MmM9.d.ts → dirtyTracking-kCS9-NVF.d.ts} +2 -2
  47. package/dist/{doubleBuffer-CKQFmlPN.d.ts → doubleBuffer-CWASihKh.d.ts} +1 -1
  48. package/dist/errors/index.js +1 -1
  49. package/dist/{inputActions-Fyw14_Gm.d.ts → factories-vW7bn_He.d.ts} +21 -786
  50. package/dist/{gameLoop-CSTb7e0L.d.ts → gameLoop-C1AyRWyP.d.ts} +3 -3
  51. package/dist/index.d.ts +24 -1217
  52. package/dist/index.js +1 -3
  53. package/dist/input/index.d.ts +1 -1
  54. package/dist/input/index.js +1 -1
  55. package/dist/inputStream-COARA4CP.d.ts +1182 -0
  56. package/dist/interactiveSystem-h92W9W4n.d.ts +1977 -0
  57. package/dist/{keyParser-m7fWto6g.d.ts → keyParser-DReXe2j-.d.ts} +28 -28
  58. package/dist/{events-9ForpTfM.d.ts → mouseParser-CCqSEUVN.d.ts} +177 -2
  59. package/dist/{packedStore-BgvnEdE7.d.ts → packedStore-480t2X74.d.ts} +1 -1
  60. package/dist/panelMovement-DGzIQ8Ll.d.ts +1908 -0
  61. package/dist/{parser-iMHmQuUh.d.ts → parser-Q1YLXYpF.d.ts} +1 -1
  62. package/dist/positioning-DiUivJXa.d.ts +917 -0
  63. package/dist/{renderable-CwqGwrEV.d.ts → renderable-IbSJao5y.d.ts} +2 -2
  64. package/dist/{scheduler-DeeZleia.d.ts → scheduler-NbHT3-D2.d.ts} +1 -1
  65. package/dist/schemas/index.d.ts +6 -6
  66. package/dist/schemas/index.js +1 -1
  67. package/dist/systems/index.d.ts +785 -1882
  68. package/dist/systems/index.js +1 -1
  69. package/dist/terminal/index.d.ts +7563 -3387
  70. package/dist/terminal/index.js +1 -1
  71. package/dist/terminalBuffer-BbUz27qM.d.ts +691 -0
  72. package/dist/{terminus-14-bold-HWSPRLJD.js → terminus-14-bold-ZS4IH465.js} +1 -1
  73. package/dist/{terminus-14-normal-T3SWMH4D.js → terminus-14-normal-HD5N7F5W.js} +1 -1
  74. package/dist/text/index.d.ts +263 -0
  75. package/dist/text/index.js +3 -0
  76. package/dist/textWrap-Ct2J8gO6.d.ts +761 -0
  77. package/dist/{tilemap-BirMJdbu.d.ts → tilemap-ByvTsepD.d.ts} +5 -5
  78. package/dist/{types-CPB4CpbH.d.ts → types-B8LmNkzG.d.ts} +1 -1
  79. package/dist/utils/index.d.ts +829 -782
  80. package/dist/utils/index.js +32 -1
  81. package/dist/{virtualScrollback-D9uLFe8l.d.ts → virtualScrollback-CiooIebp.d.ts} +4 -4
  82. package/dist/virtualViewport-fIlbIGPt.d.ts +657 -0
  83. package/dist/{virtualizedLineStore-DwPEvPkk.d.ts → virtualizedLineStore-DfyhojPZ.d.ts} +1 -1
  84. package/dist/widgets/bigText.d.ts +13 -13
  85. package/dist/widgets/bigText.js +1 -1
  86. package/dist/widgets/fonts/index.d.ts +1 -1
  87. package/dist/widgets/fonts/index.js +1 -1
  88. package/dist/widgets/index.d.ts +1620 -910
  89. package/dist/widgets/index.js +24 -1
  90. package/package.json +9 -22
  91. package/dist/3d/index.d.ts +0 -5
  92. package/dist/3d/index.js +0 -1
  93. package/dist/audio/index.d.ts +0 -177
  94. package/dist/audio/index.js +0 -1
  95. package/dist/chunk-25OEBENM.js +0 -3
  96. package/dist/chunk-26STV7ZS.js +0 -1
  97. package/dist/chunk-2NMGUEFC.js +0 -4
  98. package/dist/chunk-35LCBY6P.js +0 -1
  99. package/dist/chunk-4PRDJTCM.js +0 -1
  100. package/dist/chunk-5PELJRUQ.js +0 -1
  101. package/dist/chunk-5VEKHA3B.js +0 -5
  102. package/dist/chunk-6KEM3OS2.js +0 -11
  103. package/dist/chunk-6XWY6GB7.js +0 -1
  104. package/dist/chunk-735KKTP3.js +0 -1
  105. package/dist/chunk-7SWJNDOL.js +0 -26
  106. package/dist/chunk-APKUNIMB.js +0 -1
  107. package/dist/chunk-CJCSZRV6.js +0 -1
  108. package/dist/chunk-DMBMCCLN.js +0 -1
  109. package/dist/chunk-DQTVJITR.js +0 -1
  110. package/dist/chunk-DSKQ5J4R.js +0 -1
  111. package/dist/chunk-E4CJRSND.js +0 -1
  112. package/dist/chunk-EF4DC6IN.js +0 -1
  113. package/dist/chunk-EJAKECSN.js +0 -1
  114. package/dist/chunk-FNQRUMFD.js +0 -1
  115. package/dist/chunk-GJ3RS2VG.js +0 -1
  116. package/dist/chunk-KTVEMB2I.js +0 -1
  117. package/dist/chunk-KYAPE44E.js +0 -8
  118. package/dist/chunk-LI4Y7TBZ.js +0 -1
  119. package/dist/chunk-NHOL4BN6.js +0 -1
  120. package/dist/chunk-NPNUUSIB.js +0 -1
  121. package/dist/chunk-NZ55KBM6.js +0 -1
  122. package/dist/chunk-OFRWGW2G.js +0 -1
  123. package/dist/chunk-OMMJ7B5P.js +0 -1
  124. package/dist/chunk-OMU5BSAS.js +0 -2
  125. package/dist/chunk-P3ZLIQJP.js +0 -1
  126. package/dist/chunk-PWI36BQJ.js +0 -1
  127. package/dist/chunk-QQMUDJ32.js +0 -2
  128. package/dist/chunk-R3ICZOE4.js +0 -1
  129. package/dist/chunk-RZ7FGVI6.js +0 -1
  130. package/dist/chunk-S6WS46FE.js +0 -1
  131. package/dist/chunk-TSARUU56.js +0 -1
  132. package/dist/chunk-WJRVUAZR.js +0 -33
  133. package/dist/chunk-WY5EZOOL.js +0 -1
  134. package/dist/chunk-YY6RZCZH.js +0 -4
  135. package/dist/chunk-ZPGJCHXH.js +0 -1
  136. package/dist/chunk-ZPL2J25N.js +0 -1
  137. package/dist/game/index.d.ts +0 -486
  138. package/dist/game/index.js +0 -1
  139. package/dist/index-DBS5Uefn.d.ts +0 -3156
  140. package/dist/mouseParser-B7p5ow7K.d.ts +0 -177
  141. package/dist/viewport3d-xI33-_wq.d.ts +0 -182
  142. package/dist/virtualViewport-DTSN6jFk.d.ts +0 -1856
@@ -0,0 +1,374 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Graphics Protocol Abstraction
5
+ *
6
+ * Pluggable terminal graphics backend for image rendering.
7
+ * Provides a unified interface for different terminal graphics protocols
8
+ * (Kitty, iTerm2, Sixel, ANSI art, ASCII).
9
+ *
10
+ * @module terminal/graphics/backend
11
+ */
12
+
13
+ /**
14
+ * Graphics backend capability flags.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import type { GraphicsCapabilities } from 'blecsd';
19
+ *
20
+ * const caps: GraphicsCapabilities = {
21
+ * staticImages: true,
22
+ * animation: false,
23
+ * alphaChannel: true,
24
+ * maxWidth: null,
25
+ * maxHeight: null,
26
+ * };
27
+ * ```
28
+ */
29
+ interface GraphicsCapabilities {
30
+ /** Whether the backend can render static images */
31
+ readonly staticImages: boolean;
32
+ /** Whether the backend supports animated images */
33
+ readonly animation: boolean;
34
+ /** Whether the backend supports alpha/transparency */
35
+ readonly alphaChannel: boolean;
36
+ /** Maximum image width in pixels, or null for unlimited */
37
+ readonly maxWidth: number | null;
38
+ /** Maximum image height in pixels, or null for unlimited */
39
+ readonly maxHeight: number | null;
40
+ }
41
+ /**
42
+ * Image data passed to graphics backends.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * import type { ImageData } from 'blecsd';
47
+ *
48
+ * const img: ImageData = {
49
+ * width: 100, height: 50,
50
+ * data: rgbaBuffer,
51
+ * format: 'rgba',
52
+ * };
53
+ * ```
54
+ */
55
+ interface ImageData {
56
+ /** Image width in pixels */
57
+ readonly width: number;
58
+ /** Image height in pixels */
59
+ readonly height: number;
60
+ /** Raw pixel data */
61
+ readonly data: Uint8Array;
62
+ /** Pixel format */
63
+ readonly format: 'rgba' | 'rgb' | 'png';
64
+ }
65
+ /**
66
+ * Options for rendering an image.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * import type { RenderOptions } from 'blecsd';
71
+ *
72
+ * const opts: RenderOptions = { x: 10, y: 5, width: 40, height: 20 };
73
+ * ```
74
+ */
75
+ interface RenderOptions {
76
+ /** X position in terminal columns */
77
+ readonly x: number;
78
+ /** Y position in terminal rows */
79
+ readonly y: number;
80
+ /** Display width in terminal columns (optional, auto-sized if omitted) */
81
+ readonly width?: number;
82
+ /** Display height in terminal rows (optional, auto-sized if omitted) */
83
+ readonly height?: number;
84
+ /** Image identifier for clear operations */
85
+ readonly id?: number;
86
+ /** Whether to preserve aspect ratio (default: true) */
87
+ readonly preserveAspectRatio?: boolean;
88
+ }
89
+ /**
90
+ * Graphics backend name.
91
+ */
92
+ type BackendName = 'kitty' | 'iterm2' | 'sixel' | 'ansi' | 'ascii' | 'braille';
93
+ /**
94
+ * A graphics backend that can render images to the terminal.
95
+ * All functions are stateless and pure where possible.
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * import type { GraphicsBackend } from 'blecsd';
100
+ *
101
+ * const backend: GraphicsBackend = {
102
+ * name: 'ansi',
103
+ * capabilities: { staticImages: true, animation: false, alphaChannel: true, maxWidth: null, maxHeight: null },
104
+ * render: (image, options) => ansiSequence,
105
+ * clear: (id) => clearSequence,
106
+ * isSupported: () => true,
107
+ * };
108
+ * ```
109
+ */
110
+ interface GraphicsBackend {
111
+ /** Backend identifier */
112
+ readonly name: BackendName;
113
+ /** Backend capabilities */
114
+ readonly capabilities: GraphicsCapabilities;
115
+ /** Render an image and return the terminal escape sequence */
116
+ readonly render: (image: ImageData, options: RenderOptions) => string;
117
+ /** Clear an image (or all images) and return the escape sequence */
118
+ readonly clear: (id?: number) => string;
119
+ /** Check if this backend is supported in the current terminal */
120
+ readonly isSupported: () => boolean;
121
+ }
122
+ /**
123
+ * Zod schema for GraphicsCapabilities.
124
+ */
125
+ declare const GraphicsCapabilitiesSchema: z.ZodObject<{
126
+ staticImages: z.ZodBoolean;
127
+ animation: z.ZodBoolean;
128
+ alphaChannel: z.ZodBoolean;
129
+ maxWidth: z.ZodNullable<z.ZodNumber>;
130
+ maxHeight: z.ZodNullable<z.ZodNumber>;
131
+ }, z.core.$strip>;
132
+ /**
133
+ * Zod schema for ImageData.
134
+ */
135
+ declare const ImageDataSchema: z.ZodObject<{
136
+ width: z.ZodNumber;
137
+ height: z.ZodNumber;
138
+ data: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
139
+ format: z.ZodEnum<{
140
+ png: "png";
141
+ rgb: "rgb";
142
+ rgba: "rgba";
143
+ }>;
144
+ }, z.core.$strip>;
145
+ /**
146
+ * Zod schema for RenderOptions.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * import { RenderOptionsSchema } from 'blecsd';
151
+ *
152
+ * const result = RenderOptionsSchema.safeParse({ x: 0, y: 0 });
153
+ * ```
154
+ */
155
+ declare const RenderOptionsSchema: z.ZodObject<{
156
+ x: z.ZodNumber;
157
+ y: z.ZodNumber;
158
+ width: z.ZodOptional<z.ZodNumber>;
159
+ height: z.ZodOptional<z.ZodNumber>;
160
+ id: z.ZodOptional<z.ZodNumber>;
161
+ preserveAspectRatio: z.ZodOptional<z.ZodBoolean>;
162
+ }, z.core.$strip>;
163
+ /**
164
+ * Default backend preference order.
165
+ * Higher-fidelity protocols are preferred first.
166
+ */
167
+ declare const DEFAULT_FALLBACK_CHAIN: readonly BackendName[];
168
+ /**
169
+ * Selects the best available backend from a list of registered backends.
170
+ *
171
+ * Checks each backend in the preference order and returns the first one
172
+ * that reports itself as supported in the current terminal.
173
+ *
174
+ * @param backends - Map of registered backends
175
+ * @param preferenceOrder - Backend preference order (default: kitty > iterm2 > sixel > ansi > ascii)
176
+ * @returns The best available backend, or undefined if none are supported
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * import { selectBackend } from 'blecsd';
181
+ *
182
+ * const backend = selectBackend(registeredBackends);
183
+ * if (backend) {
184
+ * const output = backend.render(imageData, { x: 0, y: 0 });
185
+ * }
186
+ * ```
187
+ */
188
+ declare function selectBackend(backends: ReadonlyMap<BackendName, GraphicsBackend>, preferenceOrder?: readonly BackendName[]): GraphicsBackend | undefined;
189
+ /**
190
+ * Configuration for the graphics manager.
191
+ */
192
+ interface GraphicsManagerConfig {
193
+ /** Backend preference order */
194
+ readonly preferenceOrder?: readonly BackendName[];
195
+ /** Pre-registered backends */
196
+ readonly backends?: readonly GraphicsBackend[];
197
+ }
198
+ /**
199
+ * Zod schema for GraphicsManagerConfig.
200
+ */
201
+ declare const GraphicsManagerConfigSchema: z.ZodObject<{
202
+ preferenceOrder: z.ZodOptional<z.ZodArray<z.ZodEnum<{
203
+ ascii: "ascii";
204
+ ansi: "ansi";
205
+ kitty: "kitty";
206
+ iterm2: "iterm2";
207
+ sixel: "sixel";
208
+ braille: "braille";
209
+ }>>>;
210
+ }, z.core.$strip>;
211
+ /**
212
+ * Graphics manager state, holding registered backends and the active backend.
213
+ */
214
+ interface GraphicsManagerState {
215
+ /** Registered backends by name */
216
+ readonly backends: Map<BackendName, GraphicsBackend>;
217
+ /** Currently active backend (lazily selected) */
218
+ activeBackend: GraphicsBackend | undefined;
219
+ /** Backend preference order */
220
+ readonly preferenceOrder: readonly BackendName[];
221
+ }
222
+ /**
223
+ * Creates a graphics manager state.
224
+ *
225
+ * @param config - Manager configuration
226
+ * @returns Initialized graphics manager state
227
+ *
228
+ * @example
229
+ * ```typescript
230
+ * import { createGraphicsManager, registerBackend } from 'blecsd';
231
+ *
232
+ * const manager = createGraphicsManager();
233
+ * registerBackend(manager, ansiBackend);
234
+ * ```
235
+ */
236
+ declare function createGraphicsManager(config?: GraphicsManagerConfig): GraphicsManagerState;
237
+ /**
238
+ * Registers a graphics backend with the manager.
239
+ *
240
+ * @param manager - Graphics manager state
241
+ * @param backend - Backend to register
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * import { registerBackend } from 'blecsd';
246
+ *
247
+ * registerBackend(manager, iterm2Backend);
248
+ * ```
249
+ */
250
+ declare function registerBackend(manager: GraphicsManagerState, backend: GraphicsBackend): void;
251
+ /**
252
+ * Gets the active graphics backend, selecting the best one if needed.
253
+ *
254
+ * @param manager - Graphics manager state
255
+ * @returns The active backend, or undefined if none available
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * import { getActiveBackend } from 'blecsd';
260
+ *
261
+ * const backend = getActiveBackend(manager);
262
+ * if (backend) {
263
+ * console.log(`Using ${backend.name} backend`);
264
+ * }
265
+ * ```
266
+ */
267
+ declare function getActiveBackend(manager: GraphicsManagerState): GraphicsBackend | undefined;
268
+ /**
269
+ * Renders an image using the active backend.
270
+ *
271
+ * @param manager - Graphics manager state
272
+ * @param image - Image data to render
273
+ * @param options - Render options
274
+ * @returns The terminal escape sequence, or empty string if no backend
275
+ *
276
+ * @example
277
+ * ```typescript
278
+ * import { renderImage } from 'blecsd';
279
+ *
280
+ * const output = renderImage(manager, imageData, { x: 10, y: 5 });
281
+ * process.stdout.write(output);
282
+ * ```
283
+ */
284
+ declare function renderImage(manager: GraphicsManagerState, image: ImageData, options: RenderOptions): string;
285
+ /**
286
+ * Clears an image (or all images) using the active backend.
287
+ *
288
+ * @param manager - Graphics manager state
289
+ * @param id - Optional image ID to clear (clears all if omitted)
290
+ * @returns The terminal escape sequence, or empty string if no backend
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * import { clearImage } from 'blecsd';
295
+ *
296
+ * const output = clearImage(manager, 1);
297
+ * process.stdout.write(output);
298
+ * ```
299
+ */
300
+ declare function clearImage(manager: GraphicsManagerState, id?: number): string;
301
+ /**
302
+ * Re-selects the active backend. Call after terminal resize or
303
+ * when capabilities change.
304
+ *
305
+ * @param manager - Graphics manager state
306
+ * @returns The newly selected backend, or undefined
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * import { refreshBackend } from 'blecsd';
311
+ *
312
+ * process.on('SIGWINCH', () => refreshBackend(manager));
313
+ * ```
314
+ */
315
+ declare function refreshBackend(manager: GraphicsManagerState): GraphicsBackend | undefined;
316
+ /**
317
+ * Gets the capabilities of the active backend.
318
+ *
319
+ * @param manager - Graphics manager state
320
+ * @returns Capabilities or undefined if no backend
321
+ */
322
+ declare function getBackendCapabilities(manager: GraphicsManagerState): GraphicsCapabilities | undefined;
323
+
324
+ /**
325
+ * Cell-based image renderer for converting bitmap data to terminal-displayable cells.
326
+ *
327
+ * Supports 256-color palette mapping, ASCII art mode, and bitmap scaling
328
+ * with alpha blending. Used by the ANSI and braille graphics backends.
329
+ *
330
+ * @module terminal/graphics/cellRenderer
331
+ */
332
+
333
+ /**
334
+ * A single cell in the rendered output, representing one terminal character.
335
+ */
336
+ interface Cell {
337
+ /** The character displayed in this cell */
338
+ readonly char: string;
339
+ /** Foreground color as a 256-color palette index */
340
+ readonly fg: number;
341
+ /** Background color as a 256-color palette index */
342
+ readonly bg: number;
343
+ }
344
+ /**
345
+ * A 2D grid of cells representing the rendered image.
346
+ */
347
+ interface CellMap {
348
+ /** Width in terminal columns */
349
+ readonly width: number;
350
+ /** Height in terminal rows */
351
+ readonly height: number;
352
+ /** 2D array of cells, indexed as cells[row][col] */
353
+ readonly cells: readonly (readonly Cell[])[];
354
+ }
355
+ /**
356
+ * Raw RGBA bitmap pixel data.
357
+ */
358
+ interface Bitmap {
359
+ /** Width in pixels */
360
+ readonly width: number;
361
+ /** Height in pixels */
362
+ readonly height: number;
363
+ /** RGBA pixel data (4 bytes per pixel: R, G, B, A) */
364
+ readonly data: Uint8Array;
365
+ }
366
+ /**
367
+ * Render mode for ANSI output.
368
+ * - 'color': Full 256-color background blocks using upper-half-block characters
369
+ * - 'ascii': ASCII art using luminance-based character ramp
370
+ * - 'braille': Braille pattern characters for higher resolution
371
+ */
372
+ type RenderMode = 'color' | 'ascii' | 'braille';
373
+
374
+ export { type BackendName as B, type CellMap as C, DEFAULT_FALLBACK_CHAIN as D, type GraphicsBackend as G, type ImageData as I, type RenderOptions as R, type GraphicsManagerConfig as a, type GraphicsManagerState as b, type Bitmap as c, createGraphicsManager as d, clearImage as e, registerBackend as f, getActiveBackend as g, refreshBackend as h, getBackendCapabilities as i, type GraphicsCapabilities as j, GraphicsCapabilitiesSchema as k, GraphicsManagerConfigSchema as l, RenderOptionsSchema as m, ImageDataSchema as n, type RenderMode as o, renderImage as r, selectBackend as s };
@@ -0,0 +1,4 @@
1
+ import {f as f$2,e as e$2,g as g$1,j}from'./chunk-JHCKPCUH.js';import {f as f$1,e as e$1}from'./chunk-AEJIX2MW.js';import {e,f as f$3,k as k$2,c,b as b$1}from'./chunk-C5PCEQ6G.js';import {b,k as k$1,d as d$1,f}from'./chunk-XG5PVDOP.js';import {m as m$1}from'./chunk-RJULLVTH.js';import {M as M$1}from'./chunk-ETFDYZVJ.js';import {m as m$2,l,a as a$1}from'./chunk-7ZFQO3OQ.js';import {q as q$1,p as p$1}from'./chunk-Z4EZERNE.js';import {z as z$1}from'zod';var Kt=1e4,C={role:new Uint8Array(Kt),labelId:new Uint32Array(Kt)},ue={button:1,checkbox:2,list:3,listitem:4,textbox:5,dialog:6,menu:7,menuitem:8,tree:9,treeitem:10},fe={1:"button",2:"checkbox",3:"list",4:"listitem",5:"textbox",6:"dialog",7:"menu",8:"menuitem",9:"tree",10:"treeitem"},rt=new Map,$t=1;function Fn(e,t,r){m$2(e,t,C)||(l(e,t,C),C.labelId[t]=0),C.role[t]=ue[r];}function Bn(e,t){if(!m$2(e,t,C))return;let r=C.role[t];if(!(r===void 0||r===0))return fe[r]}function Mn(e,t,r){m$2(e,t,C)||(l(e,t,C),C.role[t]=0);let n=C.labelId[t];if(n&&n>0)rt.set(n,r);else {let o=$t++;rt.set(o,r),C.labelId[t]=o;}}function kn(e,t){if(!m$2(e,t,C))return;let r=C.labelId[t];if(!(r===void 0||r===0))return rt.get(r)}function Rn(e){if(typeof process<"u"&&process.stdout){let t=e.replace(/[\x00-\x1F\x7F]/g,"");process.stdout.write(`\x1B]2;${t}\x07`);}}function Un(){rt.clear(),$t=1;}var mt="> ",bt=" ",pt=4294967295,dt=6750207,gt=3435973887,yt=255,Et=1717987071;var jt="Loading...";var a={isList:new Uint8Array(1e4),selectedIndex:new Int32Array(1e4).fill(-1),itemCount:new Uint32Array(1e4),firstVisible:new Uint32Array(1e4),visibleCount:new Uint32Array(1e4),interactive:new Uint8Array(1e4),mouse:new Uint8Array(1e4),keys:new Uint8Array(1e4),searchEnabled:new Uint8Array(1e4),totalCount:new Uint32Array(1e4),isLoading:new Uint8Array(1e4)},d=m$1({iterable:true}),U=new Map,H=new Map,Z=new Map,X=new Map,w=new Map,D=new Map,I=new Map,V=new Map,F=new Map,J=new Map,A=new Map,z=new Map,P=new Map;function B(e,t){return d.get(t)??[]}function me(e,t,r){d.set(t,[...r]),a.itemCount[t]=r.length,(a.selectedIndex[t]??-1)>=r.length&&(a.selectedIndex[t]=r.length>0?r.length-1:-1),(a.firstVisible[t]??0)>=r.length&&(a.firstVisible[t]=Math.max(0,r.length-1)),M$1(e,t);}function be(e,t,r,n){let o=d.get(t)??[],l=n??o.length;o.splice(l,0,r),d.set(t,o),a.itemCount[t]=o.length;let s=a.selectedIndex[t]??-1;s>=0&&l<=s&&(a.selectedIndex[t]=s+1),M$1(e,t);}function pe(e,t,r){let n=d.get(t)??[];if(r<0||r>=n.length)return;let o=n.splice(r,1)[0];a.itemCount[t]=n.length;let l=a.selectedIndex[t]??-1;return l>=0&&(r<l?a.selectedIndex[t]=l-1:r===l&&(a.selectedIndex[t]=n.length>0?Math.min(r,n.length-1):-1)),M$1(e,t),o}function W(e,t,r){return d.get(t)?.[r]}function de(e,t,r,n){let o=d.get(t);return !o||r<0||r>=o.length?false:(o[r]=n,M$1(e,t),true)}function ge(e,t){return a.itemCount[t]??0}function ye(e,t){d.set(t,[]),a.itemCount[t]=0,a.selectedIndex[t]=-1,a.firstVisible[t]=0,M$1(e,t);}function Ee(e,t){return a.firstVisible[t]??0}function xe(e,t,r){let n=H.get(t);if(!n||n.size===0)return;let o=a.firstVisible[t]??0,l=a.visibleCount[t]??0,s=a.itemCount[t]??0,c=a.totalCount[t]??s,f=l,b={firstVisible:o,visibleCount:l,loadedCount:s,totalCount:c,nearEnd:o+l>=s-f,nearStart:o<=f};for(let y of n)y(b);}function nt(e,t,r){let n=a.itemCount[t]??0,o=a.totalCount[t]??n,l=Math.max(0,Math.max(n,o)-1),s=Math.max(0,Math.min(r,l));a.firstVisible[t]=s,M$1(e,t),xe(e,t);}function he(e,t){return a.visibleCount[t]??0}function Ce(e,t,r){a.visibleCount[t]=Math.max(1,r),M$1(e,t);}function Ct(e,t,r){if(r<0)return;let n=a.firstVisible[t]??0,o=a.visibleCount[t]??0,l=n+o-1;r<n?nt(e,t,r):r>l&&nt(e,t,r-o+1);}var xt=null;function Zt(e){xt=e;}function Le(e,t,r){let n=a.firstVisible[t]??0,o=a.visibleCount[t]??0,l=a.itemCount[t]??0,s=n+r*o;if(s<0||s>=l)return false;nt(e,t,s);let c=a.selectedIndex[t]??-1;if(c>=0&&xt){let f=c+r*o;xt(e,t,Math.max(0,Math.min(f,l-1)));}return true}function Lt(e,t){let r=d.get(t)??[],n=a.firstVisible[t]??0,o=a.visibleCount[t]??r.length,l=[];for(let s=0;s<o&&n+s<r.length;s++){let c=n+s,f=r[c];f&&l.push({index:c,item:f});}return l}function Se(e,t,r){a.totalCount[t]=r,M$1(e,t);}function Jt(e,t){let r=a.totalCount[t]??0;return r===0?a.itemCount[t]??0:r}function Te(e,t,r){U.set(t,r);}function ve(e,t){return U.get(t)}function Ie(e,t){U.delete(t);}function Ae(e,t,r){let n=H.get(t);return n||(n=new Set,H.set(t,n)),n.add(r),()=>{n?.delete(r);}}function ht(e,t,r){a.isLoading[t]=r?1:0,M$1(e,t);}function We(e,t){return a.isLoading[t]===1}function _e(e,t,r){Z.set(t,r);}function we(e,t){return Z.get(t)??jt}async function De(e,t,r,n){let o=U.get(t);if(o&&a.isLoading[t]!==1){ht(e,t,true);try{let l=await o(r,n),s=d.get(t)??[];for(;s.length<r+l.length;)s.push({text:"",disabled:!0});for(let c=0;c<l.length;c++){let f=l[c];f&&(s[r+c]=f);}d.set(t,s),a.itemCount[t]=s.length,M$1(e,t);}finally{ht(e,t,false);}}}function Fe(e,t){let r=a.firstVisible[t]??0,n=a.visibleCount[t]??0,o=a.totalCount[t]??0,l=d.get(t)??[],s=Math.min(r+n,o);for(let c=r;c<s;c++){let f=l[c];if(!f||f.text==="")return {needsLoad:true,startIndex:r,count:n}}return {needsLoad:false,startIndex:0,count:0}}function Be(e,t,r){let n=a.firstVisible[t]??0,o=a.visibleCount[t]??0,l=a.itemCount[t]??0,s=Jt(e,t),c=r??o;return {firstVisible:n,visibleCount:o,loadedCount:l,totalCount:s,nearEnd:n+o>=l-c,nearStart:n<=c}}function Me(e,t,r){let n=d.get(t)??[];n.push(...r),d.set(t,n),a.itemCount[t]=n.length,M$1(e,t);}function ke(e,t){return a.selectedIndex[t]??-1}function Re(e,t){let r=a.selectedIndex[t]??-1;if(!(r<0))return W(e,t,r)}function Ue(e,t,r,n){return r<-1||r>=n?false:r<0?true:!W(e,t,r)?.disabled}function Xe(e,t,r){if(r<0)return;let n=W(e,t,r);if(!n)return;let o=w.get(t);if(o)for(let l of o)l(r,n);}function L(e,t,r){let n=a.itemCount[t]??0,o=a.selectedIndex[t]??-1;return !Ue(e,t,r,n)||o===r?false:(a.selectedIndex[t]=r,M$1(e,t),Xe(e,t,r),Ct(e,t,r),true)}function Ve(e,t,r=true){let n=a.itemCount[t]??0;if(n===0)return false;let o=a.selectedIndex[t]??-1,l=o;do{if(o--,o<0)if(r)o=n-1;else return false;if(!W(e,t,o)?.disabled)return L(e,t,o)}while(o!==l);return false}function Pe(e,t,r=true){let n=a.itemCount[t]??0;if(n===0)return false;let o=a.selectedIndex[t]??-1,l=o;do{if(o++,o>=n)if(r)o=0;else return false;if(!W(e,t,o)?.disabled)return L(e,t,o)}while(o!==l);return false}function Ne(e,t){let r=a.itemCount[t]??0;for(let n=0;n<r;n++)if(!W(e,t,n)?.disabled)return L(e,t,n);return false}function Ye(e,t){let r=a.itemCount[t]??0;for(let n=r-1;n>=0;n--)if(!W(e,t,n)?.disabled)return L(e,t,n);return false}function Oe(e,t,r){let o=(d.get(t)??[]).findIndex(l=>l.value===r);return o>=0?L(e,t,o):false}function Ge(e,t){L(e,t,-1);}function He(e,t){let r=a.selectedIndex[t]??-1;if(r<0)return false;let n=W(e,t,r);if(!n||n.disabled)return false;let o=D.get(t);if(o)for(let l of o)l(r,n);return true}function ze(e,t,r){let n=w.get(t)??[];return n.push(r),w.set(t,n),()=>{let o=w.get(t);if(o){let l=o.indexOf(r);l!==-1&&o.splice(l,1);}}}function Qe(e,t,r){let n=D.get(t)??[];return n.push(r),D.set(t,n),()=>{let o=D.get(t);if(o){let l=o.indexOf(r);l!==-1&&o.splice(l,1);}}}function Ke(e,t,r){let n=F.get(t)??[];return n.push(r),F.set(t,n),()=>{let o=F.get(t);if(o){let l=o.indexOf(r);l!==-1&&o.splice(l,1);}}}function $e(e,t){let r=F.get(t);if(r)for(let n of r)n();}function je(e,t){w.delete(t),D.delete(t),F.delete(t);}var St={initial:"idle",states:{idle:{on:{focus:"focused",disable:"disabled"}},focused:{on:{blur:"idle",startSelect:"selecting",startSearch:"searching",disable:"disabled"}},selecting:{on:{endSelect:"focused",blur:"idle",disable:"disabled"}},searching:{on:{endSearch:"focused",blur:"idle",disable:"disabled"}},disabled:{on:{enable:"idle"}}}};function Je(e,t,r=[],n={}){z$1.array(q$1).parse(r),p$1.parse(n),a.isList[t]=1,a.selectedIndex[t]=n.selectedIndex??-1,a.itemCount[t]=r.length,a.firstVisible[t]=0,a.visibleCount[t]=n.visibleCount??r.length,a.interactive[t]=n.interactive!==false?1:0,a.mouse[t]=n.mouse!==false?1:0,a.keys[t]=n.keys!==false?1:0,a.searchEnabled[t]=n.search===true?1:0,d.set(t,[...r]),b(e,t,St);}function N(e,t){return a.isList[t]===1&&k$1(e,t)}function Tt(e,t){return d$1(e,t)??"idle"}function ot(e,t,r){return Tt(e,t)===r}function qe(e,t){let r=Tt(e,t);return r==="focused"||r==="selecting"}function vt(e,t){return ot(e,t,"disabled")}function M(e,t,r){if(!N(e,t))return false;let n=f(e,t,r);return n&&M$1(e,t),n}function tr(e,t){return M(e,t,"focus")}function er(e,t){return M(e,t,"blur")}function rr(e,t){return M(e,t,"disable")}function nr(e,t){return M(e,t,"enable")}function or(e,t,r){let n=X.get(t);X.set(t,{selectedPrefix:r.selectedPrefix??n?.selectedPrefix??"> ",unselectedPrefix:r.unselectedPrefix??n?.unselectedPrefix??" ",selectedFg:r.selectedFg??n?.selectedFg??4294967295,selectedBg:r.selectedBg??n?.selectedBg??6750207,itemFg:r.itemFg??n?.itemFg??3435973887,itemBg:r.itemBg??n?.itemBg??255,disabledFg:r.disabledFg??n?.disabledFg??1717987071});}function It(e,t){return X.get(t)??{selectedPrefix:"> ",unselectedPrefix:" ",selectedFg:4294967295,selectedBg:6750207,itemFg:3435973887,itemBg:255,disabledFg:1717987071}}function lr(e,t){X.delete(t);}function sr(e,t,r){let n=r.toLowerCase();z.set(t,n);let o=B(e,t),l=n===""?[...o]:o.filter(s=>s.text.toLowerCase().includes(n));P.set(t,l),l.length>0?a.selectedIndex[t]=0:a.selectedIndex[t]=-1,a.firstVisible[t]=0,M$1(e,t);}function ir(e,t){z.delete(t),P.delete(t),a.firstVisible[t]=0,B(e,t).length>0&&(a.selectedIndex[t]=0),M$1(e,t);}function ar(e,t){let r=z.get(t);if(r===void 0||r==="")return B(e,t);let n=P.get(t);if(n)return n;let l=B(e,t).filter(s=>s.text.toLowerCase().includes(r.toLowerCase()));return P.set(t,l),l}function cr(e,t,r){J.set(t,r),r&&!A.has(t)&&A.set(t,new Set);}function k(e,t){return J.get(t)??false}function ur(e,t,r){if(!k(e,t))throw new Error("Multi-select is not enabled for this list");let n=A.get(t);return n?n.has(r)?(n.delete(r),false):(n.add(r),true):false}function fr(e,t){if(!k(e,t))throw new Error("Multi-select is not enabled for this list");let r=A.get(t);return r?Array.from(r).sort((n,o)=>n-o):[]}function mr(e,t){if(!k(e,t))return;let r=B(e,t),n=A.get(t);if(n){n.clear();for(let o=0;o<r.length;o++)n.add(o);}}function br(e,t){if(!k(e,t))return;let r=A.get(t);r&&r.clear();}function pr(e,t,r){return k(e,t)?A.get(t)?.has(r)??false:false}function dr(e,t){return a.interactive[t]===1}function gr(e,t,r){a.interactive[t]=r?1:0,M$1(e,t);}function yr(e,t){return a.mouse[t]===1}function Er(e,t,r){a.mouse[t]=r?1:0,M$1(e,t);}function At(e,t){return a.keys[t]===1}function xr(e,t,r){a.keys[t]=r?1:0,M$1(e,t);}function qt(e,t){return a.searchEnabled[t]===1}function hr(e,t,r){a.searchEnabled[t]=r?1:0,M$1(e,t);}function Wt(e,t){return ot(e,t,"searching")}function Cr(e,t){if(!N(e,t)||!qt(e,t))return false;let r=M(e,t,"startSearch");return r&&I.set(t,""),r}function Lr(e,t){if(!N(e,t))return false;let r=M(e,t,"endSearch");return r&&I.delete(t),r}function Sr(e,t){return I.get(t)??""}function lt(e,t,r){I.set(t,r),M$1(e,t);let n=V.get(t);if(n)for(let o of n)o(r);return r.length>0?te(e,t,r):false}function Tr(e,t,r){let n=I.get(t)??"";return lt(e,t,n+r)}function vr(e,t){let r=I.get(t)??"";return r.length===0?false:lt(e,t,r.slice(0,-1))}function Ir(e,t){lt(e,t,"");}function te(e,t,r){let n=d.get(t)??[],o=r.toLowerCase();for(let l=0;l<n.length;l++){let s=n[l];if(s&&!s.disabled&&s.text.toLowerCase().startsWith(o))return L(e,t,l)}return false}function Ar(e,t){let r=I.get(t);if(!r||r.length===0)return false;let n=d.get(t)??[],o=a.selectedIndex[t]??-1,l=r.toLowerCase();for(let s=o+1;s<n.length;s++){let c=n[s];if(c&&!c.disabled&&c.text.toLowerCase().startsWith(l))return L(e,t,s)}for(let s=0;s<=o;s++){let c=n[s];if(c&&!c.disabled&&c.text.toLowerCase().startsWith(l))return L(e,t,s)}return false}function Wr(e,t,r){let n=V.get(t)??[];return n.push(r),V.set(t,n),()=>{let o=V.get(t);if(o){let l=o.indexOf(r);l!==-1&&o.splice(l,1);}}}function _r(e,t,r){if(!N(e,t)||vt(e,t)||!At(e,t))return null;if(Wt(e,t))return wr(r);switch(r){case "up":case "k":return {type:"selectPrev"};case "down":case "j":return {type:"selectNext"};case "home":case "g":return {type:"selectFirst"};case "end":case "G":return {type:"selectLast"};case "pageup":return {type:"pageUp"};case "pagedown":return {type:"pageDown"};case "enter":return {type:"confirm"};case " ":case "space":return k(e,t)?{type:"toggleSelect"}:{type:"confirm"};case "escape":return {type:"cancel"};case "/":return {type:"startSearch"};default:return null}}function wr(e){switch(e){case "escape":return {type:"endSearch"};case "enter":return {type:"endSearch"};case "backspace":return {type:"searchBackspace"};case "up":case "down":return {type:"endSearch"};case "tab":case "C-n":return {type:"searchNextMatch"};default:return e.length===1&&e>=" "?{type:"searchChar",char:e}:null}}function Dr(e,t,r){let n=It(e,t),o=Lt(e,t),l=a.selectedIndex[t]??-1,s=[];for(let{index:c,item:f}of o){let y=c===l?n.selectedPrefix:n.unselectedPrefix,x=f.text,h=r-y.length,O=x.length>h?`${x.slice(0,h-1)}\u2026`:x;s.push(y+O);}return s}function Fr(){a.isList.fill(0),a.selectedIndex.fill(-1),a.itemCount.fill(0),a.firstVisible.fill(0),a.visibleCount.fill(0),a.interactive.fill(0),a.mouse.fill(0),a.keys.fill(0),a.searchEnabled.fill(0),a.totalCount.fill(0),a.isLoading.fill(0),d.clear(),X.clear(),w.clear(),D.clear(),F.clear(),J.clear(),A.clear(),z.clear(),P.clear(),I.clear(),V.clear(),U.clear(),H.clear(),Z.clear();}Zt(L);var Br=["|","/","-","\\"],ll=[". ",".. ","..."," .."," ."," "],sl=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],il=["\u2596","\u2598","\u259D","\u2597"],al=100,p={frame:new Uint8Array(1e4),frameCount:new Uint8Array(1e4),interval:new Uint16Array(1e4),elapsed:new Float32Array(1e4)},Q=new Map,q=new Set;function cl(e,t,r={}){let n=r.frames??Br,o=r.interval??100;p.frame[t]=0,p.frameCount[t]=n.length,p.interval[t]=o,p.elapsed[t]=0,Q.set(t,n),q.add(t);}function ul(e,t){q.has(t)&&(p.frame[t]=0,p.frameCount[t]=0,p.interval[t]=0,p.elapsed[t]=0,Q.delete(t),q.delete(t));}function fl(e,t){return q.has(t)}function ml(e,t){let r=Q.get(t);if(!r)return "";let n=p.frame[t]??0;return r[n%r.length]??""}function bl(e,t){let r=Q.get(t);return r?{frame:p.frame[t]??0,frameCount:p.frameCount[t]??0,interval:p.interval[t]??100,elapsed:p.elapsed[t]??0,frames:r}:null}function pl(e,t,r){p.interval[t]=r;}function dl(e,t,r){Q.set(t,r),p.frameCount[t]=r.length,(p.frame[t]??0)>=r.length&&(p.frame[t]=0);}function Mr(e,t){let r=p.frameCount[t]??1,n=((p.frame[t]??0)+1)%r;return p.frame[t]=n,n}function gl(e,t,r){let n=(p.elapsed[t]??0)+r,o=p.interval[t]??100;return n>=o?(Mr(e,t),p.elapsed[t]=n%o,true):(p.elapsed[t]=n,false)}function yl(e,t){p.frame[t]=0,p.elapsed[t]=0;}function El(){Q.clear(),q.clear();}var _t=4294967295,wt=858993663,Dt=3435973887,Ft=255,Bt=1717987071,Mt=255;var T={rowCount:new Uint32Array(1e4),colCount:new Uint16Array(1e4),headerRows:new Uint8Array(1e4).fill(1),pad:new Uint8Array(1e4).fill(1),cellBorders:new Uint8Array(1e4)},m={isTable:new Uint8Array(1e4),rowCount:new Uint32Array(1e4),colCount:new Uint16Array(1e4),headerRows:new Uint8Array(1e4).fill(1),pad:new Uint8Array(1e4).fill(1),cellBorders:new Uint8Array(1e4)};function g(e){return a$1(e,"table:data")}function $(e){return a$1(e,"table:columns")}function K(e){return a$1(e,"table:display")}function Tl(e,t,r={}){m.isTable[t]=1,m.rowCount[t]=0,m.colCount[t]=0,m.headerRows[t]=r.headerRows??1,m.pad[t]=r.pad??1,m.cellBorders[t]=r.cellBorders===true?1:0,T.rowCount[t]=0,T.colCount[t]=0,T.headerRows[t]=r.headerRows??1,T.pad[t]=r.pad??1,T.cellBorders[t]=r.cellBorders===true?1:0,g(e).set(t,[]),$(e).set(t,[]);}function vl(e,t){return m.isTable[t]===1}function Il(e,t){m.isTable[t]=0,m.rowCount[t]=0,m.colCount[t]=0,m.headerRows[t]=1,m.pad[t]=1,m.cellBorders[t]=0,T.rowCount[t]=0,T.colCount[t]=0,T.headerRows[t]=1,T.pad[t]=1,T.cellBorders[t]=0,g(e).delete(t),$(e).delete(t),K(e).delete(t);}function Al(e,t,r){let n=r.map(o=>o.map(l=>typeof l=="string"?{value:l}:l));g(e).set(t,n),m.rowCount[t]=n.length,m.colCount[t]=n.reduce((o,l)=>Math.max(o,l.length),0),M$1(e,t);}function Wl(e,t){return g(e).get(t)??[]}function _l(e,t){return (g(e).get(t)??[]).map(n=>n.map(o=>o.value))}function wl(e,t,r,n,o){let l=g(e).get(t);if(!l||r<0||n<0)return false;for(;l.length<=r;)l.push([]);let s=l[r];if(!s)return false;for(;s.length<=n;)s.push({value:""});s[n]=typeof o=="string"?{value:o}:o;let c=l.reduce((f,b)=>Math.max(f,b.length),0);return m.colCount[t]=c,m.rowCount[t]=l.length,M$1(e,t),true}function kr(e,t,r,n){let o=g(e).get(t);if(!(!o||r<0||n<0))return o[r]?.[n]}function Dl(e,t,r,n){return kr(e,t,r,n)?.value}function Fl(e,t,r){return g(e).get(t)?.[r]}function Bl(e,t,r){return (g(e).get(t)??[]).map(o=>o[r]??{value:""})}function Ml(e,t){return m.rowCount[t]??0}function kl(e,t){return m.colCount[t]??0}function Rl(e,t,r){let n=g(e).get(t)??[],o=r.map(l=>typeof l=="string"?{value:l}:l);n.push(o),m.rowCount[t]=n.length,m.colCount[t]=Math.max(m.colCount[t]??0,o.length),M$1(e,t);}function Ul(e,t,r,n){let o=g(e).get(t)??[],l=n.map(c=>typeof c=="string"?{value:c}:c),s=Math.max(0,Math.min(r,o.length));o.splice(s,0,l),m.rowCount[t]=o.length,m.colCount[t]=Math.max(m.colCount[t]??0,l.length),M$1(e,t);}function Xl(e,t,r){let n=g(e).get(t);if(!n||r<0||r>=n.length)return;let o=n.splice(r,1)[0];return m.rowCount[t]=n.length,m.colCount[t]=n.reduce((l,s)=>Math.max(l,s.length),0),M$1(e,t),o}function Vl(e,t){g(e).set(t,[]),m.rowCount[t]=0,m.colCount[t]=0,M$1(e,t);}function Pl(e,t,r){$(e).set(t,[...r]);let n=g(e).get(t)??[];if((m.headerRows[t]??1)>0){let l=r.map(s=>({value:s.header,align:s.align??"left"}));n.length===0?n.unshift(l):n[0]=l,m.rowCount[t]=n.length,m.colCount[t]=r.length;}M$1(e,t);}function Nl(e,t){return $(e).get(t)??[]}function Yl(e,t){let r=g(e).get(t)??[],n=m.headerRows[t]??1;return r.slice(0,n)}function Ol(e,t){let r=g(e).get(t)??[],n=m.headerRows[t]??1;return r.slice(n)}function Gl(e,t,r){m.headerRows[t]=Math.max(0,Math.min(255,r)),M$1(e,t);}function Hl(e,t){return m.headerRows[t]??1}function zl(e,t,r){let n=K(e).get(t),o=r.altRowBg??n?.altRowBg,l=r.selectedFg??n?.selectedFg,s=r.selectedBg??n?.selectedBg,c={headerFg:r.headerFg??n?.headerFg??4294967295,headerBg:r.headerBg??n?.headerBg??858993663,cellFg:r.cellFg??n?.cellFg??3435973887,cellBg:r.cellBg??n?.cellBg??255,borderFg:r.borderFg??n?.borderFg??1717987071,borderBg:r.borderBg??n?.borderBg??255,...o!==void 0&&{altRowBg:o},...l!==void 0&&{selectedFg:l},...s!==void 0&&{selectedBg:s}};K(e).set(t,c);}function Ql(e,t){return K(e).get(t)??{headerFg:4294967295,headerBg:858993663,cellFg:3435973887,cellBg:255,borderFg:1717987071,borderBg:255}}function Kl(e,t){K(e).delete(t);}function $l(e,t){return m.pad[t]??1}function jl(e,t,r){m.pad[t]=Math.max(0,Math.min(255,r)),M$1(e,t);}function Zl(e,t){return m.cellBorders[t]===1}function Jl(e,t,r){m.cellBorders[t]=r?1:0,M$1(e,t);}function Rr(e,t,r){let n=new Array(t).fill(0);for(let o of e)for(let l=0;l<o.length;l++){let s=o[l];s&&(n[l]=Math.max(n[l]??0,s.value.length+r*2));}return n}function Ur(e,t){for(let r=0;r<t.length;r++){let n=t[r];n&&(n.width!==void 0?e[r]=n.width:(n.minWidth!==void 0&&(e[r]=Math.max(e[r]??0,n.minWidth)),n.maxWidth!==void 0&&(e[r]=Math.min(e[r]??0,n.maxWidth))));}}function Xr(e,t){let r=e.reduce((n,o)=>n+o,0);if(r>t){let n=t/r;for(let o=0;o<e.length;o++)e[o]=Math.floor((e[o]??0)*n);}}function Vr(e,t,r){let n=g(e).get(t)??[],o=$(e).get(t)??[],l=m.colCount[t]??0,s=m.pad[t]??1,c=Rr(n,l,s);return Ur(c,o),r!==void 0&&Xr(c,r),c}function Pr(e,t,r){if(r==="right")return e.padStart(t);if(r==="center"){let n=Math.floor((t-e.length)/2);return e.padStart(n+e.length).padEnd(t)}return e.padEnd(t)}function Nr(e,t,r,n){let o=t-r*2,l=e.value;l.length>o&&(l=`${l.slice(0,o-1)}\u2026`);let s=Pr(l,o,e.align??"left");return n+s+n}function Yr(e,t,r,n){let o=" ".repeat(r),l=n?"\u2502":"",s="";for(let c=0;c<t.length;c++){let f=e[c]??{value:""};c>0&&n&&(s+=l),s+=Nr(f,t[c]??0,r,o);}return s}function ql(e,t,r){let n=g(e).get(t)??[],o=Vr(e,t,r),l=m.pad[t]??1,s=m.cellBorders[t]===1,c=m.headerRows[t]??1,f=[];for(let b=0;b<n.length;b++)f.push(Yr(n[b]??[],o,l,s)),s&&b===c-1&&b<n.length-1&&f.push(o.map(y=>"\u2500".repeat(y)).join("\u253C"));return f}function ts(e){m.isTable.fill(0),m.rowCount.fill(0),m.colCount.fill(0),m.headerRows.fill(1),m.pad.fill(1),m.cellBorders.fill(0),g(e).clear(),$(e).clear(),K(e).clear();}var R=1e4,Or=80,Gr=24,Hr=1e3,i={isTerminal:new Uint8Array(R),width:new Uint16Array(R),height:new Uint16Array(R),cursorX:new Uint16Array(R),cursorY:new Uint16Array(R),cursorVisible:new Uint8Array(R),scrollOffset:new Uint32Array(R),altScreenActive:new Uint8Array(R)},S=new Map,zr=z$1.object({width:z$1.number().int().positive().default(Or),height:z$1.number().int().positive().default(Gr),scrollbackLines:z$1.number().int().nonnegative().default(Hr),cursorVisible:z$1.boolean().default(true),cursorShape:z$1.enum(["block","underline","bar"]).default("block"),cursorBlink:z$1.boolean().default(true)});function Qr(e,t,r,n,o){let l={maxLines:r,chunkSize:Math.min(r,1e3)};return {buffer:k$2(e,t),scrollback:e$2(l),currentAttr:e$1(),escapeBuffer:"",inEscape:false,savedCursorX:0,savedCursorY:0,savedAttr:e$1(),altBuffer:null,cursorShape:n,cursorBlink:o}}function Kr(e,t,r){return r*e+t}function $r(e){let t=b$1,r=c,n=[255,2852126975,11141375,2863268095,43775,2852170495,11184895,2863311615,1431655935,4283782655,1442797055,4294923775,1431699455,4283826175,1442840575,4294967295];return e.fg.type===1?t=n[e.fg.value]??b$1:e.fg.type===3&&(t=e.fg.value<<8|255),e.bg.type===1?r=n[e.bg.value]??c:e.bg.type===3&&(r=e.bg.value<<8|255),{fg:t,bg:r,attrs:e.styles}}function Rt(e$1,t,r){let n=jr(e$1.buffer,0,t);g$1(e$1.scrollback,n);for(let l=0;l<r-1;l++)for(let s=0;s<t;s++){let c=(l+1)*t+s,f=l*t+s,b=e$1.buffer.cells[c];b&&(e$1.buffer.cells[f]=f$3(b));}let o=e();for(let l=0;l<t;l++){let s=(r-1)*t+l;e$1.buffer.cells[s]=f$3(o);}}function jr(e,t,r){let n="";for(let o=0;o<r;o++){let l=t*r+o,s=e.cells[l];n+=s?.char??" ";}return n.trimEnd()}function is(e,t,r={}){let n=zr.parse(r);i.isTerminal[t]=1,i.width[t]=n.width,i.height[t]=n.height,i.cursorX[t]=0,i.cursorY[t]=0,i.cursorVisible[t]=n.cursorVisible?1:0,i.scrollOffset[t]=0,i.altScreenActive[t]=0;let o=Qr(n.width,n.height,n.scrollbackLines,n.cursorShape,n.cursorBlink);S.set(t,o),M$1(e,t);}function Zr(e){return i.isTerminal[e]===1}function as(e){return S.get(e)}function cs(e){if(Zr(e))return {width:i.width[e]??0,height:i.height[e]??0,cursorX:i.cursorX[e]??0,cursorY:i.cursorY[e]??0,cursorVisible:i.cursorVisible[e]===1,scrollOffset:i.scrollOffset[e]??0}}function Jr(e,t,r,n,o){let l=(i.cursorY[t]??0)+1;l>=o&&(Rt(r,n,o),l=o-1),i.cursorX[t]=0,i.cursorY[t]=l,M$1(e,t);}function qr(e,t,r){let n=i.cursorX[t]??0,o=Math.min((Math.floor(n/8)+1)*8,r-1);i.cursorX[t]=o,M$1(e,t);}function tn(e$1,t,r,n,o,l){let s=i.cursorX[t]??0,c=i.cursorY[t]??0,{fg:f,bg:b,attrs:y}=$r(r.currentAttr),x=Kr(o,s,c);r.buffer.cells[x]=e(n,f,b,y);let h=s+1;h>=o&&(h=0,c++,c>=l&&(Rt(r,o,l),c=l-1)),i.cursorX[t]=h,i.cursorY[t]=c,M$1(e$1,t);}function en(e,t,r){let n=S.get(t);if(!n)return;let o=i.width[t]??0,l=i.height[t]??0;if(r===`
2
+ `){Jr(e,t,n,o,l);return}if(r==="\r"){i.cursorX[t]=0,M$1(e,t);return}if(r==="\b"){let s=i.cursorX[t]??0;s>0&&(i.cursorX[t]=s-1),M$1(e,t);return}if(r===" "){qr(e,t,o);return}tn(e,t,n,r,o,l);}function us(e,t,r){let n=S.get(t);if(n)for(let o=0;o<r.length;o++){let l=r[o];if(l!==void 0){if(l==="\x1B"){n.inEscape=true,n.escapeBuffer=l;continue}if(n.inEscape){n.escapeBuffer+=l,rn(n.escapeBuffer)&&(nn(e,t,n,n.escapeBuffer),n.inEscape=false,n.escapeBuffer="");continue}en(e,t,l);}}}function rn(e){if(e.length<2)return false;if(e[1]==="["){let t=e[e.length-1];return t===void 0?false:/[A-Za-z@`~]/.test(t)}return e[1]==="]"?e.endsWith("\x07")||e.endsWith("\x1B\\"):e.length>=2}function nn(e,t,r,n){if(n.length<2)return;let o=n[1];if(o==="["){on(e,t,r,n);return}switch(o){case "c":Wn(e,t);break;case "7":r.savedCursorX=i.cursorX[t]??0,r.savedCursorY=i.cursorY[t]??0,r.savedAttr=f$1(r.currentAttr);break;case "8":i.cursorX[t]=r.savedCursorX,i.cursorY[t]=r.savedCursorY,r.currentAttr=f$1(r.savedAttr),M$1(e,t);break;case "D":st(e,t,r,1);break;case "M":kt(e,t,1);break;case "E":i.cursorX[t]=0,st(e,t,r,1);break}}function on(e,t,r,n){let o=n.match(/^\x1b\[(\??[\d;]*)([A-Za-z@`~])$/);if(!o)return;let l=o[1]??"",s=o[2],c=l===""?[]:l.split(";").map(h=>parseInt(h,10)||0),f=c[0]??1,b=c[1]??1,y=i.width[t]??0,x=i.height[t]??0;switch(s){case "A":kt(e,t,f);break;case "B":st(e,t,r,f);break;case "C":cn(e,t,f,y);break;case "D":un(e,t,f);break;case "E":i.cursorX[t]=0,st(e,t,r,f);break;case "F":i.cursorX[t]=0,kt(e,t,f);break;case "G":i.cursorX[t]=Math.min(Math.max(f-1,0),y-1),M$1(e,t);break;case "H":case "f":i.cursorY[t]=Math.min(Math.max(f-1,0),x-1),i.cursorX[t]=Math.min(Math.max(b-1,0),y-1),M$1(e,t);break;case "J":bn(e,t,r,c[0]??0);break;case "K":pn(e,t,r,c[0]??0);break;case "m":In(r,c.length===0?[0]:c);break;case "h":ee(e,t,r,l,true);break;case "l":ee(e,t,r,l,false);break;case "s":r.savedCursorX=i.cursorX[t]??0,r.savedCursorY=i.cursorY[t]??0;break;case "u":i.cursorX[t]=r.savedCursorX,i.cursorY[t]=r.savedCursorY,M$1(e,t);break}}function ln(e,t,r){i.cursorVisible[t]=r?1:0,M$1(e,t);}function sn(e,t,r,n){n?(r.savedCursorX=i.cursorX[t]??0,r.savedCursorY=i.cursorY[t]??0,ne(e,t,r)):(oe(e,t,r),i.cursorX[t]=r.savedCursorX,i.cursorY[t]=r.savedCursorY),M$1(e,t);}function an(e,t,r,n,o){o?(ne(e,t,r),n==="1047"&&le(r,0,r.buffer.cells.length)):oe(e,t,r),M$1(e,t);}function ee(e,t,r,n,o){let l=n.startsWith("?")?n.slice(1):n;if(l==="25"){ln(e,t,o);return}if(l==="1049"){sn(e,t,r,o);return}if(l==="47"||l==="1047"){an(e,t,r,l,o);return}}function ne(e$1,t,r){if(i.altScreenActive[t]===1)return;let n=i.width[t]??0,o=i.height[t]??0;r.altBuffer||(r.altBuffer=k$2(n,o));for(let s=0;s<r.buffer.cells.length&&s<r.altBuffer.cells.length;s++){let c=r.buffer.cells[s];c&&(r.altBuffer.cells[s]=f$3(c));}let l=e();for(let s=0;s<r.buffer.cells.length;s++)r.buffer.cells[s]=f$3(l);i.cursorX[t]=0,i.cursorY[t]=0,i.altScreenActive[t]=1;}function oe(e,t,r){if(i.altScreenActive[t]!==0){if(r.altBuffer)for(let n=0;n<r.altBuffer.cells.length&&n<r.buffer.cells.length;n++){let o=r.altBuffer.cells[n];o&&(r.buffer.cells[n]=f$3(o));}i.altScreenActive[t]=0;}}function kt(e,t,r){let n=i.cursorY[t]??0;i.cursorY[t]=Math.max(0,n-r),M$1(e,t);}function st(e,t,r,n){let o=i.width[t]??0,l=i.height[t]??0,s=i.cursorY[t]??0;for(s+=n;s>=l;)Rt(r,o,l),s--;i.cursorY[t]=s,M$1(e,t);}function cn(e,t,r,n){let o=i.cursorX[t]??0;i.cursorX[t]=Math.min(n-1,o+r),M$1(e,t);}function un(e,t,r){let n=i.cursorX[t]??0;i.cursorX[t]=Math.max(0,n-r),M$1(e,t);}function le(e$1,t,r){let n=e();for(let o=t;o<r;o++)e$1.buffer.cells[o]=f$3(n);}function se(e$1,t,r,n,o){let l=e();for(let s=n;s<=o;s++){let c=r*t+s;e$1.buffer.cells[c]=f$3(l);}}function ie(e$1,t,r,n){let o=e();for(let l=r;l<n;l++)for(let s=0;s<t;s++){let c=l*t+s;e$1.buffer.cells[c]=f$3(o);}}function fn(e,t,r,n,o){se(e,t,o,n,t-1),ie(e,t,o+1,r);}function mn(e,t,r,n){ie(e,t,0,n),se(e,t,n,0,r);}function bn(e,t,r,n){let o=i.width[t]??0,l=i.height[t]??0,s=i.cursorX[t]??0,c=i.cursorY[t]??0;n===0?fn(r,o,l,s,c):n===1?mn(r,o,s,c):(n===2||n===3)&&(le(r,0,r.buffer.cells.length),n===3&&f$2(r.scrollback)),M$1(e,t);}function pn(e$1,t,r,n){let o=i.width[t]??0,l=i.cursorX[t]??0,s=i.cursorY[t]??0,c=e();switch(n){case 0:for(let f=l;f<o;f++){let b=s*o+f;r.buffer.cells[b]=f$3(c);}break;case 1:for(let f=0;f<=l;f++){let b=s*o+f;r.buffer.cells[b]=f$3(c);}break;case 2:for(let f=0;f<o;f++){let b=s*o+f;r.buffer.cells[b]=f$3(c);}break}M$1(e$1,t);}function dn(e){return e.currentAttr=e$1(),1}function gn(e,t,r){let n=t[r]??0;return e.currentAttr.styles|=1<<n-1,1}function yn(e,t,r){let n=t[r]??0;return e.currentAttr.styles&=~(1<<n-22+1),1}function En(e,t,r){let n=t[r]??0;return e.currentAttr.fg={type:1,value:n-30},1}function xn(e){return e.currentAttr.fg={type:0,value:0},1}function hn(e,t,r){let n=t[r]??0;return e.currentAttr.bg={type:1,value:n-40},1}function Cn(e){return e.currentAttr.bg={type:0,value:0},1}function Ln(e,t,r){let n=t[r]??0;return e.currentAttr.fg={type:1,value:n-90+8},1}function Sn(e,t,r){let n=t[r]??0;return e.currentAttr.bg={type:1,value:n-100+8},1}function Tn(e){return e===0?dn:e>=1&&e<=9?gn:e>=22&&e<=29?yn:e>=30&&e<=37?En:e===39?xn:e>=90&&e<=97?Ln:e>=40&&e<=47?hn:e===49?Cn:e>=100&&e<=107?Sn:null}function vn(e,t,r){let n=t[r]??0;if(n===38){let l=re(e,t,r,"fg");return l>0?l:1}if(n===48){let l=re(e,t,r,"bg");return l>0?l:1}let o=Tn(n);return o?o(e,t,r):1}function re(e,t,r,n){if(r+1>=t.length)return 0;let o=t[r+1];if(o===5&&r+2<t.length){let l=t[r+2]??0;return e.currentAttr[n]={type:2,value:l},3}if(o===2&&r+4<t.length){let l=t[r+2]??0,s=t[r+3]??0,c=t[r+4]??0;return e.currentAttr[n]={type:3,value:l<<16|s<<8|c},5}return 0}function In(e,t){let r=0;for(;r<t.length;){let n=vn(e,t,r);r+=n;}}function An(e$2,t){let r=S.get(t);if(!r)return;let n=e();for(let o=0;o<r.buffer.cells.length;o++)r.buffer.cells[o]=f$3(n);i.cursorX[t]=0,i.cursorY[t]=0,r.currentAttr=e$1(),M$1(e$2,t);}function Wn(e,t){let r=S.get(t);r&&(An(e,t),f$2(r.scrollback),r.escapeBuffer="",r.inEscape=false,r.savedCursorX=0,r.savedCursorY=0,r.savedAttr=e$1(),i.cursorVisible[t]=1,i.scrollOffset[t]=0,M$1(e,t));}function fs(e,t,r,n){let o=i.width[t]??0,l=i.height[t]??0;i.cursorX[t]=Math.min(Math.max(r,0),o-1),i.cursorY[t]=Math.min(Math.max(n,0),l-1),M$1(e,t);}function ms(e,t,r){i.cursorVisible[t]=r?1:0,M$1(e,t);}function bs(e,t,r){let n=S.get(t);if(!n)return;let o=i.scrollOffset[t]??0,l=n.scrollback.totalLines;i.scrollOffset[t]=Math.min(o+r,l),M$1(e,t);}function ps(e,t,r){let n=i.scrollOffset[t]??0;i.scrollOffset[t]=Math.max(0,n-r),M$1(e,t);}function ds(e,t){let r=S.get(t);r&&(i.scrollOffset[t]=r.scrollback.totalLines,M$1(e,t));}function gs(e,t){i.scrollOffset[t]=0,M$1(e,t);}function ys(e,t,r,n){let o=S.get(t);if(!o)return;let l=i.width[t]??0,s=i.height[t]??0,c=k$2(r,n),f=Math.min(l,r),b=Math.min(s,n);for(let h=0;h<b;h++)for(let O=0;O<f;O++){let ae=h*l+O,ce=h*r+O,Ut=o.buffer.cells[ae];Ut&&(c.cells[ce]=f$3(Ut));}o.buffer=c,i.width[t]=r,i.height[t]=n;let y=i.cursorX[t]??0,x=i.cursorY[t]??0;i.cursorX[t]=Math.min(y,r-1),i.cursorY[t]=Math.min(x,n-1),M$1(e,t);}function Es(e){i.isTerminal[e]=0,i.width[e]=0,i.height[e]=0,i.cursorX[e]=0,i.cursorY[e]=0,i.cursorVisible[e]=0,i.scrollOffset[e]=0,i.altScreenActive[e]=0,S.delete(e);}function _n(e,t,r){let n=j(e.scrollback,e.scrollback.totalLines-r,e.scrollback.totalLines-r+t),o="";for(let l of n.lines)o+=l.ansi??l.text,o+=`
3
+ `;return o}function wn(e,t){let r="";return (e.fg!==t.fg||e.bg!==t.bg)&&(r+="\x1B[0m",t.fg=e.fg,t.bg=e.bg),r+=e.char,{output:r,fg:t.fg,bg:t.bg}}function xs(e){let t=S.get(e);if(!t)return "";let r=i.width[e]??0,n=i.height[e]??0,o=i.scrollOffset[e]??0;if(o>0)return _n(t,n,o);let l="",s={fg:-1,bg:-1};for(let c=0;c<n;c++){for(let f=0;f<r;f++){let b=c*r+f,y=t.buffer.cells[b];if(!y)continue;let x=wn(y,s);l+=x.output,s.fg=x.fg,s.bg=x.bg;}c<n-1&&(l+=`
4
+ `);}return l}function hs(e){return S.get(e)?.buffer.cells}function Cs(){i.isTerminal.fill(0),i.width.fill(0),i.height.fill(0),i.cursorX.fill(0),i.cursorY.fill(0),i.cursorVisible.fill(0),i.scrollOffset.fill(0),i.altScreenActive.fill(0),S.clear();}export{He as $,ll as $a,Vr as $b,Ce as A,fr as Aa,Al as Ab,Ct as B,mr as Ba,Wl as Bb,Le as C,br as Ca,_l as Cb,Lt as D,pr as Da,wl as Db,Se as E,dr as Ea,kr as Eb,Jt as F,gr as Fa,Dl as Fb,Te as G,yr as Ga,Fl as Gb,ve as H,Er as Ha,Bl as Hb,Ie as I,At as Ia,Ml as Ib,Ae as J,xr as Ja,kl as Jb,ht as K,qt as Ka,Rl as Kb,We as L,hr as La,Ul as Lb,_e as M,Wt as Ma,Xl as Mb,we as N,Cr as Na,Vl as Nb,De as O,Lr as Oa,Pl as Ob,Fe as P,Sr as Pa,Nl as Pb,Be as Q,lt as Qa,Yl as Qb,Me as R,Tr as Ra,Ol as Rb,ke as S,vr as Sa,Gl as Sb,Re as T,Ir as Ta,Hl as Tb,L as U,te as Ua,zl as Ub,Ve as V,Ar as Va,Ql as Vb,Pe as W,Wr as Wa,Kl as Wb,Ne as X,_r as Xa,$l as Xb,Ye as Y,Dr as Ya,jl as Yb,Oe as Z,Fr as Za,Zl as Zb,Ge as _,Br as _a,Jl as _b,C as a,ze as aa,sl as ab,ql as ac,Fn as b,Qe as ba,il as bb,ts as bc,Bn as c,Ke as ca,al as cb,Or as cc,Mn as d,$e as da,p as db,Gr as dc,kn as e,je as ea,cl as eb,Hr as ec,Rn as f,St as fa,ul as fb,i as fc,Un as g,Je as ga,fl as gb,zr as gc,mt as h,N as ha,ml as hb,is as hc,bt as i,Tt as ia,bl as ib,Zr as ic,pt as j,ot as ja,pl as jb,as as jc,dt as k,qe as ka,dl as kb,cs as kc,gt as l,vt as la,Mr as lb,en as lc,yt as m,M as ma,gl as mb,us as mc,Et as n,tr as na,yl as nb,An as nc,a as o,er as oa,El as ob,Wn as oc,B as p,rr as pa,_t as pb,fs as pc,me as q,nr as qa,wt as qb,ms as qc,be as r,or as ra,Dt as rb,bs as rc,pe as s,It as sa,Ft as sb,ps as sc,W as t,lr as ta,Bt as tb,ds as tc,de as u,sr as ua,Mt as ub,gs as uc,ge as v,ir as va,T as vb,ys as vc,ye as w,ar as wa,m as wb,Es as wc,Ee as x,cr as xa,Tl as xb,xs as xc,nt as y,k as ya,vl as yb,hs as yc,he as z,ur as za,Il as zb,Cs as zc};
@@ -1 +1 @@
1
- import {z}from'zod';var p=z.object({width:z.number().int().positive(),height:z.number().int().positive(),bitmap:z.array(z.array(z.union([z.literal(0),z.literal(1)])))}).superRefine((t,r)=>{t.bitmap.length!==t.height&&r.addIssue({code:z.ZodIssueCode.custom,message:`Bitmap row count (${t.bitmap.length}) does not match height (${t.height}).`,path:["bitmap"]}),t.bitmap.forEach((o,n)=>{o.length!==t.width&&r.addIssue({code:z.ZodIssueCode.custom,message:`Bitmap row ${n} length (${o.length}) does not match width (${t.width}).`,path:["bitmap",n]});});}),C=z.object({name:z.string(),size:z.number().int().positive(),weight:z.enum(["normal","bold"]),charWidth:z.number().int().positive(),charHeight:z.number().int().positive(),chars:z.record(z.string().regex(/^\d+$/),p)}).superRefine((t,r)=>{for(let[o,n]of Object.entries(t.chars))n.width!==t.charWidth&&r.addIssue({code:z.ZodIssueCode.custom,message:`Glyph ${o} width (${n.width}) does not match font width (${t.charWidth}).`,path:["chars",o,"width"]}),n.height!==t.charHeight&&r.addIssue({code:z.ZodIssueCode.custom,message:`Glyph ${o} height (${n.height}) does not match font height (${t.charHeight}).`,path:["chars",o,"height"]});}),c=["terminus-14-bold","terminus-14-normal"],i={},u=async t=>{let r=i[t];if(r)return r;let o;switch(t){case "terminus-14-bold":o=await import('./terminus-14-bold-HWSPRLJD.js');break;case "terminus-14-normal":o=await import('./terminus-14-normal-T3SWMH4D.js');break;default:throw F(t)}let n=o.default;return i[t]=n,n},f="\u2588",g=" ",a=(t,r)=>{if(!t)return r;let[o]=Array.from(t);return o??r},F=t=>{let r=[...c].sort().join(", "),o=new Error(`Font '${t}' not found. Available fonts: ${r||"none"}`);return o.name="FontNotFoundError",o},y=t=>u(t),B=t=>i[t],l=(t,r)=>{let o=Array.from(r);if(o.length!==1)return;let n=o[0]?.codePointAt(0);if(n!==void 0)return t.chars[String(n)]},w=(t,r,o)=>{let n=l(t,r);if(!n)return [];let s=a(o?.fillChar,f),h=a(o?.emptyChar,g);return n.bitmap.map(d=>d.map(m=>m===1?s:h).join(""))};export{p as a,C as b,F as c,y as d,B as e,l as f,w as g};
1
+ import {z}from'zod';var p=z.object({width:z.number().int().positive(),height:z.number().int().positive(),bitmap:z.array(z.array(z.union([z.literal(0),z.literal(1)])))}).superRefine((t,r)=>{t.bitmap.length!==t.height&&r.addIssue({code:z.ZodIssueCode.custom,message:`Bitmap row count (${t.bitmap.length}) does not match height (${t.height}).`,path:["bitmap"]}),t.bitmap.forEach((o,n)=>{o.length!==t.width&&r.addIssue({code:z.ZodIssueCode.custom,message:`Bitmap row ${n} length (${o.length}) does not match width (${t.width}).`,path:["bitmap",n]});});}),C=z.object({name:z.string(),size:z.number().int().positive(),weight:z.enum(["normal","bold"]),charWidth:z.number().int().positive(),charHeight:z.number().int().positive(),chars:z.record(z.string().regex(/^\d+$/),p)}).superRefine((t,r)=>{for(let[o,n]of Object.entries(t.chars))n.width!==t.charWidth&&r.addIssue({code:z.ZodIssueCode.custom,message:`Glyph ${o} width (${n.width}) does not match font width (${t.charWidth}).`,path:["chars",o,"width"]}),n.height!==t.charHeight&&r.addIssue({code:z.ZodIssueCode.custom,message:`Glyph ${o} height (${n.height}) does not match font height (${t.charHeight}).`,path:["chars",o,"height"]});}),c=["terminus-14-bold","terminus-14-normal"],i={},u=async t=>{let r=i[t];if(r)return r;let o;switch(t){case "terminus-14-bold":o=await import('./terminus-14-bold-ZS4IH465.js');break;case "terminus-14-normal":o=await import('./terminus-14-normal-HD5N7F5W.js');break;default:throw F(t)}let n=o.default;return i[t]=n,n},f="\u2588",g=" ",a=(t,r)=>{if(!t)return r;let[o]=Array.from(t);return o??r},F=t=>{let r=[...c].sort().join(", "),o=new Error(`Font '${t}' not found. Available fonts: ${r||"none"}`);return o.name="FontNotFoundError",o},y=t=>u(t),B=t=>i[t],l=(t,r)=>{let o=Array.from(r);if(o.length!==1)return;let n=o[0]?.codePointAt(0);if(n!==void 0)return t.chars[String(n)]},w=(t,r,o)=>{let n=l(t,r);if(!n)return [];let s=a(o?.fillChar,f),h=a(o?.emptyChar,g);return n.bitmap.map(d=>d.map(m=>m===1?s:h).join(""))};export{p as a,C as b,F as c,y as d,B as e,l as f,w as g};
@@ -0,0 +1,3 @@
1
+ import {b,e as e$1,d as d$1,f as f$2,g}from'./chunk-4XCFTNGN.js';import {e}from'./chunk-JN2OGNK3.js';import {la,M as M$1,f as f$1,d,na,qa,pa,Ca,Ha,P,aa,da,J as J$1}from'./chunk-ETFDYZVJ.js';import {i,v}from'./chunk-7ZFQO3OQ.js';import {readFileSync}from'fs';import {z}from'zod';var N=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),f=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),G=z.object({left:f.optional(),top:f.optional(),right:f.optional(),bottom:f.optional(),width:N.optional(),height:N.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),text:z.string(),font:z.union([z.string(),b]).optional(),shrink:z.boolean().optional()}),I=1e4,c={isBigText:new Uint8Array(I)},U="terminus-14-bold",T=new Map,a=new Map;function _(t){if(t===void 0)return 0;if(typeof t=="number")return t;switch(t){case "left":case "top":return 0;case "center":return 0;case "right":case "bottom":return 0}return 0}function M(t){return t===void 0||typeof t=="string"&&t==="auto"?"auto":t}async function j(t){return t?typeof t!="string"?t:t==="terminus-14-bold"||t==="terminus-14-normal"?d$1(t):H(t):d$1(U)}function J(t){return t?typeof t!="string"?t:t==="terminus-14-bold"||t==="terminus-14-normal"?e$1(t):T.get(t):e$1(U)}function Y(t,i){let n=" ".repeat(t);return Array.from({length:i},()=>n)}function q(t,i){let n=t.charHeight,r=Array.from({length:n},()=>"");for(let e of Array.from(i)){let u=f$2(t,e)?g(t,e):Y(t.charWidth,t.charHeight);for(let g=0;g<n;g+=1){let O=u[g]??"";r[g]=`${r[g]}${O}`;}}return r}function B(t,i){let n=i.split(`
2
+ `),r=[];for(let e of n)r.push(...q(t,e));return r.join(`
3
+ `)}function H(t){let i=T.get(t);if(i)return i;let n=readFileSync(t,"utf8"),r=JSON.parse(n),e=b.parse(r);return T.set(t,e),e}var dt=H;function K(t,i,n){let r=_(n.left),e=_(n.top);Ca(t,i,r,e);let s=M(n.width),u=M(n.height);aa(t,i,s,u);let g=n.shrink!==false;da(t,i,g);}function Q(t,i,n){n.fg===void 0&&n.bg===void 0||J$1(t,i,{fg:n.fg!==void 0?v(n.fg):void 0,bg:n.bg!==void 0?v(n.bg):void 0});}async function R(t,i,n){let r=await j(n.font),e$1=B(r,n.text);a.set(i,n.text),e(t,i,e$1);}async function mt(t,i$1,n){let r=G.parse(n),e=i$1;c.isBigText[e]=1,K(t,e,r),Q(t,e,r),await R(t,e,r),la(t,e,{focusable:true});let s={eid:e,show(){return P(t,e,true),s},hide(){return P(t,e,false),s},move(u,g){return Ha(t,e,u,g),M$1(t,e),s},setPosition(u,g){return Ca(t,e,u,g),M$1(t,e),s},setText(u){return Z(t,e,u,r.font),s},getText(){return a.get(e)??""},focus(){return pa(t,e),s},blur(){return qa(t,e),s},isFocused(){return na(t,e)},append(u){return d(t,e,u),s},getChildren(){return f$1(t,e)},destroy(){c.isBigText[e]=0,a.delete(e),i(t,e);}};return s}function X(t,i,n,r){let e$1=J(r);if(e$1){let s=B(e$1,n);a.set(i,n),e(t,i,s),M$1(t,i);return}j(r).then(s=>{let u=B(s,n);a.set(i,n),e(t,i,u),M$1(t,i);});}function Z(t,i,n,r){return X(t,i,n,r),i}function ft(t,i){return c.isBigText[i]===1}function ct(){c.isBigText.fill(0),a.clear();}export{G as a,c as b,H as c,dt as d,mt as e,X as f,ft as g,ct as h};