@visulima/tui 1.0.0-alpha.14 → 1.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/LICENSE.md +351 -209
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/approval-prompt.d.ts +1 -1
- package/dist/components/area-chart.d.ts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/bar-chart.d.ts +1 -1
- package/dist/components/blink-dot.d.ts +1 -1
- package/dist/components/box.d.ts +3 -4
- package/dist/components/breadcrumb.d.ts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/calendar.d.ts +1 -1
- package/dist/components/canvas.js +1 -1
- package/dist/components/card.d.ts +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/collapsible.d.ts +1 -1
- package/dist/components/command-block.js +1 -1
- package/dist/components/command-palette.d.ts +1 -1
- package/dist/components/console-overlay.js +1 -1
- package/dist/components/content-switcher.d.ts +1 -1
- package/dist/components/controlled-scroll-view.d.ts +3 -4
- package/dist/components/cursor.d.ts +3 -4
- package/dist/components/date-picker.d.ts +1 -1
- package/dist/components/definition-list.d.ts +1 -1
- package/dist/components/dialog.d.ts +4 -5
- package/dist/components/diff-view.js +1 -1
- package/dist/components/divider.d.ts +1 -1
- package/dist/components/form.d.ts +1 -1
- package/dist/components/gauge.d.ts +1 -1
- package/dist/components/gradient.d.ts +18 -1
- package/dist/components/gradient.js +4 -1
- package/dist/components/heading.d.ts +1 -1
- package/dist/components/heatmap.d.ts +1 -1
- package/dist/components/histogram.d.ts +1 -1
- package/dist/components/kbd.d.ts +1 -1
- package/dist/components/line-chart.d.ts +1 -1
- package/dist/components/link.js +1 -1
- package/dist/components/loading-indicator.d.ts +2 -2
- package/dist/components/markdown.js +1 -1
- package/dist/components/menu.d.ts +1 -1
- package/dist/components/message-bubble.d.ts +1 -1
- package/dist/components/model-badge.d.ts +1 -1
- package/dist/components/multi-select.d.ts +1 -1
- package/dist/components/option-list.d.ts +1 -1
- package/dist/components/paginator.js +1 -1
- package/dist/components/paragraph.d.ts +1 -1
- package/dist/components/placeholder.d.ts +1 -1
- package/dist/components/progress-bar.d.ts +2 -3
- package/dist/components/radio-group.d.ts +1 -1
- package/dist/components/scatter-plot.d.ts +1 -1
- package/dist/components/scroll-bar-box.d.ts +3 -4
- package/dist/components/scroll-bar.d.ts +3 -4
- package/dist/components/scroll-list.d.ts +3 -4
- package/dist/components/scroll-view.d.ts +3 -4
- package/dist/components/search-input.d.ts +1 -1
- package/dist/components/select-input-indicator.d.ts +1 -1
- package/dist/components/select-input-item.d.ts +1 -1
- package/dist/components/select-input.d.ts +1 -1
- package/dist/components/shimmer-text.d.ts +1 -1
- package/dist/components/slider.d.ts +1 -1
- package/dist/components/sparkline.d.ts +1 -1
- package/dist/components/spinner.d.ts +1 -1
- package/dist/components/spinner.js +1 -1
- package/dist/components/static-render.d.ts +2 -3
- package/dist/components/static.d.ts +2 -3
- package/dist/components/status-line.d.ts +1 -1
- package/dist/components/stepper.d.ts +1 -1
- package/dist/components/streaming-text.d.ts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/tag.d.ts +1 -1
- package/dist/components/text.d.ts +2 -3
- package/dist/components/text.js +1 -1
- package/dist/components/tooltip.d.ts +1 -1
- package/dist/components/tree-view-entry.d.ts +3 -4
- package/dist/components/tree-view-entry.js +1 -1
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.js +1 -1
- package/dist/ink/hooks/use-box-metrics.d.ts +4 -5
- package/dist/ink/hooks/use-box-metrics.js +1 -1
- package/dist/ink/hooks/use-input.js +1 -1
- package/dist/ink/hooks/use-linked-scroll.d.ts +3 -4
- package/dist/ink/hooks/use-paste.js +1 -1
- package/dist/ink/hooks/use-text-selection.d.ts +4 -5
- package/dist/ink/hooks/use-text-selection.js +1 -1
- package/dist/ink/hooks/use-window-size.js +1 -1
- package/dist/ink/index.d.ts +6 -7
- package/dist/ink/index.js +1 -1
- package/dist/packem_shared/{DevTools-CsxLcAu2.js → DevTools-ClnTSU76.js} +1 -1
- package/dist/packem_shared/InputParser-Cfi5GVKV.js +2 -0
- package/dist/packem_shared/{LayoutNode-B8zej4dm.js → LayoutNode-Q7nU3hmO.js} +1 -1
- package/dist/packem_shared/{MouseProvider-PnIUKURs.js → MouseProvider-CHU5DuwC.js} +1 -1
- package/dist/packem_shared/{TreeView-GkPr_VYn.js → TreeView-C0Iv3et8.js} +1 -1
- package/dist/packem_shared/TuiApp-BSWPFrDu.js +1 -0
- package/dist/packem_shared/ansi-parser-C5JuL732.js +1 -0
- package/dist/packem_shared/boxes-DyY_LXCi.js +1 -0
- package/dist/packem_shared/colorize-gy_cY-wC.js +2 -0
- package/dist/packem_shared/{comparePoints-C85EsmNz.js → comparePoints-l0iqUoL_.js} +1 -1
- package/dist/packem_shared/constants-D12jy2Zh-RSfxu1eM.js +1 -0
- package/dist/packem_shared/createInlineLoop-fhXU93QT.js +2 -0
- package/dist/packem_shared/createScreen-87XLHZq6.js +3 -0
- package/dist/packem_shared/dom-CMbdnYbk.js +8 -0
- package/dist/packem_shared/{dom.d-Be9F_YcI.d.ts → dom.d-BZZeZlyP.d.ts} +8 -5
- package/dist/packem_shared/erase-DeDffywz.js +1 -0
- package/dist/packem_shared/get-string-width-4oMZhv2Q.js +1 -0
- package/dist/packem_shared/{getPathToRoot-B2tKmx3i.js → getPathToRoot-Nb2eTx2o.js} +1 -1
- package/dist/packem_shared/index-LwZN2xbk.js +75 -0
- package/dist/packem_shared/index.d-Bk52cbgN.d.ts +14 -0
- package/dist/packem_shared/index.server.d-eZWyC2Ku.d.ts +5 -0
- package/dist/packem_shared/input.d-D-Yxqha8.d.ts +172 -0
- package/dist/packem_shared/measure-text-CIs55Wao.js +3 -0
- package/dist/packem_shared/mode-BOIU4Roy.js +1 -0
- package/dist/packem_shared/parseSgrMouse-DoBY7MKw.js +1 -0
- package/dist/packem_shared/{reconciler-DIfG72R9.js → reconciler-BQvF1kRj.js} +1 -1
- package/dist/packem_shared/{reconciler-BuOP-TZ6.js → reconciler-tOH9yL_j.js} +1 -1
- package/dist/packem_shared/render-D9bHMHrx.js +26 -0
- package/dist/packem_shared/{render-F9Hk9p1a.js → render-yGJFE4of.js} +1 -1
- package/dist/packem_shared/{render.d-qLMbbSmP.d.ts → render.d-BJmVQ_cd.d.ts} +2 -1
- package/dist/packem_shared/{renderToString-BbQiRHrd.js → renderToString-D4JqS-Zv.js} +1 -1
- package/dist/packem_shared/{renderToString-BDk2FZEN.js → renderToString-GyN-Rw9F.js} +1 -1
- package/dist/packem_shared/renderTreeToBuffer-DWl5_yTW.js +2 -0
- package/dist/packem_shared/renderer-Cidd3s9K.js +17 -0
- package/dist/packem_shared/{selection.d-C6q1U6Rv.d.ts → selection.d-vfuEzv1p.d.ts} +1 -1
- package/dist/packem_shared/setEnableStyledLineCache-Aja0FbWo.js +1 -0
- package/dist/packem_shared/strip-C6HQYmlg.js +1 -0
- package/dist/packem_shared/{styles.d-C1g4Iwzr.d.ts → styles.d-i6Mejqz2.d.ts} +98 -2
- package/dist/packem_shared/text-width-DSx26OmB.js +2 -0
- package/dist/packem_shared/utils-THUhYKG2.js +1 -0
- package/dist/packem_shared/{wrapOrTruncateStyledLine-BZ00SM8i.js → wrapOrTruncateStyledLine-D29Fq7pW.js} +1 -1
- package/dist/react/index.d.ts +1 -2
- package/dist/react/index.js +1 -1
- package/dist/testing/index.d.ts +4 -5
- package/dist/testing/index.js +1 -1
- package/index.js +52 -52
- package/package.json +19 -33
- package/dist/packem_shared/InputParser-rZKjY_7Y.js +0 -2
- package/dist/packem_shared/TuiApp-DrjI_i-R.js +0 -1
- package/dist/packem_shared/ansi-parser-B6uXaq65.js +0 -1
- package/dist/packem_shared/colorize-DbTZMrJO.js +0 -1
- package/dist/packem_shared/createInlineLoop-DRNZ7jqH.js +0 -2
- package/dist/packem_shared/createScreen-CrLrxA6t.js +0 -3
- package/dist/packem_shared/dom-4y__5fWB.js +0 -1
- package/dist/packem_shared/input.d-Bfq7oc06.d.ts +0 -90
- package/dist/packem_shared/measure-text-DDjHT1jD.js +0 -3
- package/dist/packem_shared/parseSgrMouse-Ccj70ijb.js +0 -1
- package/dist/packem_shared/render-BOqty71z.js +0 -26
- package/dist/packem_shared/renderTreeToBuffer-CZilzyhN.js +0 -2
- package/dist/packem_shared/renderer-gqplqpkQ.js +0 -17
- package/dist/packem_shared/setEnableStyledLineCache-D2gZbwFM.js +0 -1
- package/dist/packem_shared/text-width-BU2eeTWn.js +0 -2
- package/dist/packem_shared/utils-CoviI5Vm.js +0 -1
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
2
|
-
declare class TuiApp extends EventEmitter {
|
|
3
|
-
private renderer;
|
|
4
|
-
private terminal;
|
|
5
|
-
private backBuffer;
|
|
6
|
-
private width;
|
|
7
|
-
private height;
|
|
8
|
-
private isRunning;
|
|
9
|
-
private stdoutBuffer;
|
|
10
|
-
private stderrBuffer;
|
|
11
|
-
constructor();
|
|
12
|
-
/** Enters raw mode + alternate screen. Does NOT start any render loop. */
|
|
13
|
-
start(): void;
|
|
14
|
-
/** Request a clean exit — restores terminal, stops input, exits the process. */
|
|
15
|
-
quit(): void;
|
|
16
|
-
/** Exits raw mode + alternate screen, then flushes any buffered stdout/stderr. */
|
|
17
|
-
stop(): void;
|
|
18
|
-
/**
|
|
19
|
-
* Buffer a write to stdout. While the alternate screen is active, writing
|
|
20
|
-
* directly would corrupt the TUI. Buffered output is flushed on stop().
|
|
21
|
-
*/
|
|
22
|
-
writeStdout(text: string): void;
|
|
23
|
-
/**
|
|
24
|
-
* Buffer a write to stderr. While the alternate screen is active, writing
|
|
25
|
-
* directly would corrupt the TUI. Buffered output is flushed on stop().
|
|
26
|
-
*/
|
|
27
|
-
writeStderr(text: string): void;
|
|
28
|
-
/** Returns the shared Uint32Array back-buffer (width * height * 2 u32 cells). */
|
|
29
|
-
getBuffer(): Uint32Array;
|
|
30
|
-
/** Returns current terminal dimensions. */
|
|
31
|
-
getSize(): {
|
|
32
|
-
height: number;
|
|
33
|
-
width: number;
|
|
34
|
-
};
|
|
35
|
-
/** Update terminal dimensions (called on SIGWINCH). */
|
|
36
|
-
resize(width: number, height: number): void;
|
|
37
|
-
/**
|
|
38
|
-
* Callbacks fired on every frame after React paints the buffer but before
|
|
39
|
-
* the Rust diff engine flushes to stdout. Use for direct buffer painting
|
|
40
|
-
* that needs to overlay React output (animated graphs, overlays, FPS counters).
|
|
41
|
-
* Multiple listeners are supported — they fire in registration order.
|
|
42
|
-
*/
|
|
43
|
-
private beforeFlushListeners;
|
|
44
|
-
onBeforeFlush(function_: (buffer: Uint32Array, width: number, height: number) => void): () => void;
|
|
45
|
-
/**
|
|
46
|
-
* Layout + paint synchronously. Called from the render loop on every dirty frame,
|
|
47
|
-
* and directly on resize for immediate response.
|
|
48
|
-
*/
|
|
49
|
-
paintNow(calculateLayout: (w: number, h: number) => void, renderToBuffer: (buf: Uint32Array, w: number, h: number) => void): void;
|
|
50
|
-
}
|
|
51
|
-
interface InlineOptions {
|
|
52
|
-
/** Frames per second. Default: 60 */
|
|
53
|
-
fps?: number;
|
|
54
|
-
/**
|
|
55
|
-
* What to do with the rendered content when the loop stops.
|
|
56
|
-
* - 'preserve' (default) — content stays in terminal scrollback
|
|
57
|
-
* - 'destroy' — content is cleared, terminal looks untouched
|
|
58
|
-
*/
|
|
59
|
-
onExit?: "preserve" | "destroy";
|
|
60
|
-
/** Number of terminal rows to reserve. Default: 10 */
|
|
61
|
-
rows?: number;
|
|
62
|
-
}
|
|
63
|
-
type InlinePaintFn = (buf: Uint32Array, cols: number, rows: number, frame: number) => void;
|
|
64
|
-
interface InlineLoop {
|
|
65
|
-
start: () => void;
|
|
66
|
-
stop: () => void;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Create an inline render loop. Renders `rows` lines immediately below the
|
|
70
|
-
* current cursor position (no alternate screen).
|
|
71
|
-
*/
|
|
72
|
-
declare function createInlineLoop(paint: InlinePaintFn, options?: InlineOptions): InlineLoop;
|
|
73
|
-
interface MouseEvent {
|
|
74
|
-
button: "left" | "right" | "middle" | "scrollUp" | "scrollDown";
|
|
75
|
-
ctrl: boolean;
|
|
76
|
-
meta: boolean;
|
|
77
|
-
shift: boolean;
|
|
78
|
-
x: number;
|
|
79
|
-
y: number;
|
|
80
|
-
}
|
|
81
|
-
declare class InputParser extends EventEmitter {
|
|
82
|
-
private stdin;
|
|
83
|
-
private _boundHandleData;
|
|
84
|
-
private _pasteBuffer;
|
|
85
|
-
constructor(stdin: NodeJS.ReadStream);
|
|
86
|
-
start(): void;
|
|
87
|
-
stop(): void;
|
|
88
|
-
private handleData;
|
|
89
|
-
}
|
|
90
|
-
export { InlineLoop as I, MouseEvent as M, TuiApp as T, InlineOptions as a, InlinePaintFn as b, InputParser as c, createInlineLoop as d };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var X=Object.defineProperty;var k=(r,t)=>X(r,"name",{value:t,configurable:!0});import{isFullwidthCodePoint as Y,getStringWidth as Z}from"@visulima/string";import{t as tt}from"./ansi-tokenizer-DqX9nJuk.js";var et=Object.defineProperty,st=k((r,t)=>et(r,"name",{value:t,configurable:!0}),"r$1");let H=class{static{k(this,"h")}static{st(this,"DataLimitedLruMap")}map;maxDataSize;maxKeys;currentDataSize=0;constructor(t,e){this.map=new Map,this.maxKeys=t,this.maxDataSize=e}get size(){return this.map.size}clear(){this.map.clear(),this.currentDataSize=0}get(t){if(!this.map.has(t))return;const e=this.map.get(t);return this.map.delete(t),this.map.set(t,e),e}set(t,e){const s=t.length;if(!(s>this.maxDataSize)){for(this.map.has(t)&&(this.map.delete(t),this.currentDataSize-=s);this.currentDataSize+s>this.maxDataSize&&this.map.size>0;){const a=this.map.keys().next().value;if(a===void 0)break;this.map.delete(a),this.currentDataSize-=a.length}for(;this.map.size>=this.maxKeys;){const a=this.map.keys().next().value;if(a===void 0)break;this.map.delete(a),this.currentDataSize-=a.length}this.map.set(t,e),this.currentDataSize+=s}}};const at=1,nt=2,K=4,j=8,R=16,M=32,V=64,x=128;var rt=Object.defineProperty,it=k((r,t)=>rt(r,"name",{value:t,configurable:!0}),"x");const p=1073741823,C=1073741824;class d{static{k(this,"StyledLine")}static{it(this,"StyledLine")}length=0;static emptyCache=new Map;text;charData;spans;_cachedTrimmedLength;static empty(t){if(t<=0)return new d;const e=d.emptyCache.get(t);if(e)return e.clone();const s=new d;s.length=t,s.text=" ".repeat(t),s.charData=Array.from({length:t});for(let a=0;a<t;a++)s.charData[a]=a;return s.spans=[{formatFlags:0,length:t}],s._cachedTrimmedLength=0,Object.freeze(s.spans[0]),Object.freeze(s.spans),Object.freeze(s),d.emptyCache.set(t,s),s.clone()}getValue(t){if(this.text===void 0||t<0||t>=this.length)return"";const e=this.charData[t]&p,s=t+1<this.length?this.charData[t+1]&p:this.text.length;return this.text.slice(e,s)}getTextRange(t,e){if(this.text===void 0||t<0||e>this.length||t>=e)return"";const s=this.charData[t]&p,a=e<this.length?this.charData[e]&p:this.text.length;return this.text.slice(s,a)}getSpan(t){if(this.spans===void 0||t<0||t>=this.length)return;let e=0;for(const s of this.spans){if(t<e+s.length)return s;e+=s.length}}getFullWidth(t){return this.charData===void 0||t<0||t>=this.length?!1:(this.charData[t]&C)!==0}hasStyles(t){const e=this.getSpan(t);return e?(e.formatFlags&~x)!==0||e.fgColor!==void 0||e.bgColor!==void 0||e.link!==void 0:!1}getFormatFlags(t){let e=this.getSpan(t)?.formatFlags??0;return this.getFullWidth(t)&&(e|=x),e}getFgColor(t){return this.getSpan(t)?.fgColor}getBgColor(t){return this.getSpan(t)?.bgColor}getLink(t){return this.getSpan(t)?.link}setInverted(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{e?s.formatFlags|=M:s.formatFlags&=~M})}setBackgroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.bgColor=e})}setForegroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.fgColor=e})}setChar(t,e,s,a,n,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&p,c=t+1<this.length?this.charData[t+1]&p:this.text.length,m=c-l,b=e.length;if(this.text=this.text.slice(0,l)+e+this.text.slice(c),m!==b){const f=b-m;for(let S=t+1;S<this.length;S++){const T=this.charData[S],w=T&p,L=T&C;this.charData[S]=w+f|L}}if(this.charData[t]=l|(i?C:0),this.trySetStyleAtIndex(t,o,a,n,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let u=0;for(let f=0;f<this.spans.length;f++){const S=this.spans[f];if(u===t&&S.length===1){this.spans[f]={bgColor:n,fgColor:a,formatFlags:o,length:1,link:h};break}u+=S.length}this.mergeSpans()}setCharFast(t,e,s,a,n,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&p,c=t+1<this.length?this.charData[t+1]&p:this.text.length,m=c-l;if(e.length===m)e!==this.text.slice(l,c)&&(this.text=this.text.slice(0,l)+e+this.text.slice(c)),this.charData[t]=l|(i?C:0);else{if(this.text=this.text.slice(0,l)+e+this.text.slice(c),m!==e.length){const u=e.length-m;for(let f=t+1;f<this.length;f++){const S=this.charData[f];this.charData[f]=(S&p)+u|S&C}}this.charData[t]=l|(i?C:0)}if(this.trySetStyleAtIndex(t,o,a,n,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let b=0;for(let u=0;u<this.spans.length;u++){const f=this.spans[u];if(b===t&&f.length===1){this.spans[u]={bgColor:n,fgColor:a,formatFlags:o,length:1,link:h};break}b+=f.length}this.mergeSpans()}writeFrom(t,e,s=0,a){const n=a??e.length-s;if(n<=0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=Math.min(n,this.length-t,e.length-s),i=this.charData[t]&p,o=t+h<this.length?this.charData[t+h]&p:this.text.length;let l="";for(let g=0;g<h;g++)l+=e.getValue(s+g);const c=o-i,m=l.length-c;this.text=this.text.slice(0,i)+l+this.text.slice(o);let b=i;for(let g=0;g<h;g++){const D=e.getFullWidth(s+g);this.charData[t+g]=b|(D?C:0),b+=e.getValue(s+g).length}if(m!==0)for(let g=t+h;g<this.length;g++){const D=this.charData[g];this.charData[g]=(D&p)+m|D&C}this.splitSpansAt(t),this.splitSpansAt(t+h);const u=[];let f=0;for(const g of e.getSpans()){const D=f+g.length,P=Math.max(s,f),E=Math.min(s+h,D);if(P<E&&u.push({...g,length:E-P}),f=D,f>=s+h)break}let S=0,T=0;for(let g=0;g<this.spans.length;g++){if(T===t){S=g;break}T+=this.spans[g].length}let w=0,L=0;for(let g=S;g<this.spans.length&&L<h;g++)L+=this.spans[g].length,w++;this.spans.splice(S,w,...u),this.mergeSpans()}pushChar(t,e,s,a,n){this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=(e&x)!==0,i=e&~x,o=this.text.length;this.text=(this.text??"")+t,this.charData.push(o|(h?C:0));const l=this.spans.at(-1);l?.formatFlags===i&&l.fgColor===s&&l.bgColor===a&&l.link===n?l.length++:this.spans.push({bgColor:a,fgColor:s,formatFlags:i,length:1,link:n}),this.length++}clone(){if(this.charData===void 0)return new d;const t=new d;return t.length=this.length,t.text=this.text,t.charData=[...this.charData],t.spans=this.spans.map(e=>({...e})),t._cachedTrimmedLength=this._cachedTrimmedLength,t}slice(t,e){if(this.charData===void 0)return new d;const s=Math.max(0,t),a=e===void 0?this.length:Math.min(this.length,e);if(s>=a)return new d;if(s===0&&a===this.length)return this.clone();const n=new d;n.length=a-s,n.charData=Array.from({length:n.length});const h=this.charData[s]&p,i=a<this.length?this.charData[a]&p:this.text.length;n.text=this.text.slice(h,i);for(let c=0;c<n.length;c++){const m=this.charData[s+c],b=m&p,u=m&C;n.charData[c]=b-h|u}const o=[];let l=0;for(const c of this.spans){const m=l,b=l+c.length,u=Math.max(s,m),f=Math.min(a,b);if(u<f&&o.push({...c,length:f-u}),l+=c.length,l>=a)break}return n.spans=o,n.mergeSpans(),n}combine(...t){if(t.length===0)return this.clone();const e=[this,...t].filter(i=>i.length>0);if(e.length===0)return new d;if(e.length===1)return e[0].clone();let s=0;for(const i of e)s+=i.length;const a=new d;a.length=s,a.text=e.map(i=>i.getText()).join(""),a.charData=Array.from({length:s});let n=0,h=0;for(const i of e){const o=i.charData,l=i.getText();if(o)for(let c=0;c<i.length;c++){const m=o[c],b=m&p,u=m&C;a.charData[n+c]=h+b|u}else for(let c=0;c<i.length;c++)a.charData[n+c]=h+c;n+=i.length,h+=l.length}return a.spans=e.flatMap(i=>i.getSpans().map(o=>({...o}))),a.mergeSpans(),a}getTrimmedLength(){if(this._cachedTrimmedLength!==void 0)return this._cachedTrimmedLength;if(this.length===0)return this._cachedTrimmedLength=0,0;if(this.text===void 0||this.charData===void 0)return this._cachedTrimmedLength=0,0;let t=this.length-1;if(this.spans)for(let e=this.spans.length-1;e>=0;e--){const s=this.spans[e];if((s.formatFlags&~x)!==0||s.fgColor!==void 0||s.bgColor!==void 0||s.link!==void 0)return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;for(let a=0;a<s.length;a++){const n=this.charData[t]&p;if((t+1<this.length?this.charData[t+1]&p:this.text.length)-n!==1||this.text[n]!==" ")return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;t--}}return this._cachedTrimmedLength=0,0}trimEnd(){const t=this.getTrimmedLength();return t===this.length?this:t===0?new d:this.slice(0,t)}equals(t){if(this.length!==t.length)return!1;if(this.length===0)return!0;if(this.getText()!==t.getText())return!1;const e=this.getSpans(),s=t.getSpans();if(e.length!==s.length)return!1;for(const[h,i]of e.entries()){const o=i,l=s[h];if(o.length!==l.length||o.formatFlags!==l.formatFlags||o.fgColor!==l.fgColor||o.bgColor!==l.bgColor||o.link!==l.link)return!1}const a=this.charData,n=t.charData;if(a&&n){for(let h=0;h<this.length;h++)if(a[h]!==n[h])return!1}return!0}getText(){return this.text??""}getSpans(){return this.spans??[]}getValues(){return Array.from({length:this.length},(t,e)=>this.getValue(e))}*[Symbol.iterator](){if(this.length===0)return;let t=0,e=0;const s=this.getSpans();for(let a=0;a<this.length;a++){const n=s[t],h=n?n.formatFlags:0,i=this.getFullWidth(a);yield{bgColor:n?.bgColor,fgColor:n?.fgColor,formatFlags:h|(i?x:0),fullWidth:i,hasStyles:(h&~x)!==0||n?.fgColor!==void 0||n?.bgColor!==void 0||n?.link!==void 0,link:n?.link,value:this.getValue(a)},n&&(e++,e>=n.length&&(t++,e=0))}}updateSpanAt(t,e){if(t<0||t>=this.length)return;this.ensureInitialized(),this.splitSpansAt(t),this.splitSpansAt(t+1);let s=0;for(const a of this.spans){if(s===t&&a.length===1){e(a);break}s+=a.length}this.mergeSpans()}ensureWidth(t){if(t<=this.length)return;this.ensureInitialized();const e=this.length,s=t-e,a=this.text.length;for(let h=0;h<s;h++)this.charData.push(a);this.length=t;const n=this.spans.at(-1);n?.formatFlags===0&&n.fgColor===void 0&&n.bgColor===void 0&&n.link===void 0?n.length+=s:this.spans.push({formatFlags:0,length:s})}ensureInitialized(){if(this.charData===void 0&&(this.text="",this.charData=Array.from({length:this.length}),this.spans=this.length>0?[{formatFlags:0,length:this.length}]:[],this.length>0&&this.text.length===0)){this.text=" ".repeat(this.length);for(let t=0;t<this.length;t++)this.charData[t]=t}}splitSpansAt(t){if(this.spans===void 0||t<=0||t>=this.length)return;let e=0;for(let s=0;s<this.spans.length;s++){const a=this.spans[s];if(t>e&&t<e+a.length){const n=t-e,h=a.length-n;this.spans.splice(s,1,{...a,length:n},{...a,length:h});return}e+=a.length}}trySetStyleAtIndex(t,e,s,a,n){if(!this.spans)return!1;let h=0,i=-1,o;for(let l=0;l<this.spans.length;l++){const c=this.spans[l];if(h<=t&&h+c.length>t){i=l,o=c;break}h+=c.length}if(!o)return!1;if(o.formatFlags===e&&o.fgColor===s&&o.bgColor===a&&o.link===n)return!0;if(t===h&&i>0){const l=this.spans[i-1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===a&&l.link===n)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}if(t===h+o.length-1&&i<this.spans.length-1){const l=this.spans[i+1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===a&&l.link===n)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}return!1}mergeSpans(){if(this.spans===void 0)return;const t=[];for(const e of this.spans){if(e.length===0)continue;const s=t.at(-1);s?.formatFlags===e.formatFlags&&s.fgColor===e.fgColor&&s.bgColor===e.bgColor&&s.link===e.link?s.length+=e.length:t.push({...e})}this.spans=t}}var ht=Object.defineProperty,I=k((r,t)=>ht(r,"name",{value:t,configurable:!0}),"u$1");const G={black:0,blue:4,cyan:6,gray:8,green:2,grey:8,magenta:5,red:1,white:7,yellow:3},U={blackBright:8,blueBright:12,cyanBright:14,greenBright:10,magentaBright:13,redBright:9,whiteBright:15,yellowBright:11},q=/^ansi256\(\s?(\d+)\s?\)$/,J=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,Nt=I(r=>{const t=G[r];if(t!==void 0)return t;const e=U[r];if(e!==void 0)return e;const s=q.exec(r);if(s)return Number(s[1])&255;if(r.startsWith("#")&&r.length===7){const n=Number.parseInt(r.slice(1,3),16),h=Number.parseInt(r.slice(3,5),16),i=Number.parseInt(r.slice(5,7),16);return 16+36*Math.round(n/51)+6*Math.round(h/51)+Math.round(i/51)}const a=J.exec(r);return a?16+36*Math.round(Number(a[1])/51)+6*Math.round(Number(a[2])/51)+Math.round(Number(a[3])/51):255},"colorToAnsi256"),lt=I((r,t)=>{const e=t?30:40,s=G[r];if(s!==void 0)return[e+s];const a=U[r];if(a!==void 0)return[e+60+(a-8)];if(r.startsWith("#")&&r.length===7){const i=Number.parseInt(r.slice(1,3),16),o=Number.parseInt(r.slice(3,5),16),l=Number.parseInt(r.slice(5,7),16);return[t?38:48,2,i,o,l]}const n=q.exec(r);if(n)return[t?38:48,5,Number(n[1])];const h=J.exec(r);return h?[t?38:48,2,Number(h[1]),Number(h[2]),Number(h[3])]:[]},"colorToSgrParams");I((r,t)=>{const e=lt(r,t);if(e.length!==0)return`\x1B[${e.join(";")}m`},"colorToAnsiCode");const A=I(r=>{const t=["black","red","green","yellow","blue","magenta","cyan","white"];return r>=0&&r<=7?t[r]:`ansi256(${r})`},"ansi256ToColorName");var ot=Object.defineProperty,y=k((r,t)=>ot(r,"name",{value:t,configurable:!0}),"u");const _=y(()=>({bgColor:void 0,fgColor:void 0,formatFlags:0,link:void 0}),"createSgrState"),ct=y((r,t)=>{if(t.length===0)return _();const e=(t.includes(":")?t.replaceAll(":",";"):t).split(";").filter(o=>o.length>0).map(Number);let{bgColor:s,fgColor:a,formatFlags:n,link:h}=r,i=0;for(;i<e.length;){const o=e[i];switch(o){case 0:{n=0,a=void 0,s=void 0,h=void 0;break}case 1:{n|=at;break}case 2:{n|=nt;break}case 3:{n|=K;break}case 4:{n|=j;break}case 7:{n|=M;break}case 8:{n|=V;break}case 9:{n|=R;break}case 22:{n&=-4;break}case 23:{n&=~K;break}case 24:{n&=~j;break}case 27:{n&=~M;break}case 28:{n&=~V;break}case 29:{n&=~R;break}case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:{a=A(o-30);break}case 38:{e[i+1]===5&&e[i+2]!==void 0?(a=A(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(a=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 39:{a=void 0;break}case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:{s=A(o-40);break}case 48:{e[i+1]===5&&e[i+2]!==void 0?(s=A(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(s=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 49:{s=void 0;break}case 90:case 91:case 92:case 93:case 94:case 95:case 96:case 97:{a=`ansi256(${o-90+8})`;break}case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:{s=`ansi256(${o-100+8})`;break}}i++}return{bgColor:s,fgColor:a,formatFlags:n,link:h}},"applySgrParams"),z=127462,N=127487,gt=127995,ft=127999,ut=8205,dt=917504,mt=917631,pt=new RegExp("\\p{Mark}","u"),bt=new Intl.Segmenter(void 0,{granularity:"grapheme"}),St=y((r,t)=>!!(Y(t)||r.includes("️")||t>=z&&t<=N),"isFullwidthGrapheme"),xt=/(?:\u001B\]|\u009D)8;([^;]*);(.*?)(?:\u001B\\|\u0007|\u009C)/,Ct=y(r=>{const t=xt.exec(r);return!t?.[2]||t[2].length===0?void 0:r.endsWith("\x1B\\")?`ST:${t[2]}`:t[2]},"parseOscHyperlink"),Q=y((r,t,e)=>{const s=bt.segment(r),a=[];for(const{segment:n}of s)a.push(n);for(let n=0;n<a.length;n++){let h=a[n];if(h===" "){for(let l=0;l<4;l++)t.pushChar(" ",e.formatFlags,e.fgColor,e.bgColor,e.link);continue}if(h==="\b")continue;const i=h.codePointAt(0);if(!i)continue;if(i>=z&&i<=N&&n+1<a.length){const l=a[n+1],c=l.codePointAt(0);c&&c>=z&&c<=N&&(h+=l,n++)}else for(;n+1<a.length;){const l=a[n+1],c=l.codePointAt(0);if(!c)break;const m=pt.test(String.fromCodePoint(c)),b=c>=gt&&c<=ft,u=c===ut,f=c>=dt&&c<=mt;if(!m&&!b&&!u&&!f)break;h+=l,n++,u&&n+1<a.length&&(h+=a[n+1],n++)}const o=St(h,i)?e.formatFlags|x:e.formatFlags;t.pushChar(h,o,e.fgColor,e.bgColor,e.link)}},"processTextToken"),vt=y(r=>{if(r.length===0)return new d;const t=tt(r),e=new d;let s=_();for(const a of t)switch(a.type){case"csi":{a.finalCharacter==="m"&&(s=ct(s,a.parameterString));break}case"osc":{const n=Ct(a.value);n!==void 0?s={...s,link:n}:a.value.includes("8;")&&(s={...s,link:void 0});break}case"text":{Q(a.value,e,s);break}}return e},"textToStyledLine"),kt=/^[\u0020-\u007E]*$/,$t=y(r=>{if(r.length===0)return new d;const t=new d;if(kt.test(r)){for(const e of r)t.pushChar(e,0);return t}return Q(r,t,_()),t},"plainTextToStyledLine");var Dt=Object.defineProperty,v=k((r,t)=>Dt(r,"name",{value:t,configurable:!0}),"r");const $=new H(1e4,1e6),W=new Map,F=new H(1e4,1e6);let B=!0,O=Z;const Wt=v(r=>{B=r,r||F.clear()},"setEnableStyledLineCache"),Bt=v(()=>{F.clear()},"clearStyledLineCache"),_t=v(r=>{O=r,yt()},"setStringWidthFunction"),yt=v(()=>{$.clear(),W.clear(),F.clear()},"clearStringWidthCache"),Tt=v(r=>{if(r.length===1){const s=r.codePointAt(0);if(s!==void 0&&s>=32&&s<127)return 1}const t=W.get(r);if(t!==void 0)return t;let e;try{e=O(r)}catch{e=1}return W.set(r,e),e},"inkCharacterWidth"),Ft=v(r=>{try{return O(r)}catch{return 1}},"safeGetStringWidth"),Ot=v(r=>{if(r.length===0)return{height:0,width:0};const t=$.get(r);if(t)return t;const e=r.split(`
|
|
2
|
-
`),s=Math.max(...e.map(n=>Ft(n))),a={height:e.length,width:s};return $.set(r,a),a},"measureText"),Pt=v(r=>{if(B){const e=F.get(r);if(e!==void 0)return e}const t=vt(r);return B&&F.set(r,t),t},"toStyledLine"),wt=v(r=>{let t=0;for(let e=0;e<r.length;e++)t+=Tt(r.getValue(e));return t},"styledLineWidth"),Lt=v(r=>{if(r.length===0)return[new d];const t=[];let e=0;for(let s=0;s<r.length;s++)r.getValue(s)===`
|
|
3
|
-
`&&(t.push(s>e?r.slice(e,s):new d),e=s+1);return t.push(e<r.length?r.slice(e):new d),t},"splitStyledLineByNewline"),Et=v(r=>{if(r.length===0)return{height:0,width:0};const t=Lt(r);let e=0;for(const s of t)e=Math.max(e,wt(s));return{height:t.length,width:e}},"measureStyledLine");export{at as B,nt as D,x as F,V as H,K as I,d as S,j as U,Bt as a,_t as b,yt as c,wt as d,Ot as e,M as f,R as g,lt as h,Tt as i,Nt as j,vt as k,Lt as l,Et as m,$t as p,Wt as s,Pt as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./ansi-parser-B6uXaq65.js";export{e as parseSgrMouse};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var Pe=Object.defineProperty;var T=(e,t)=>Pe(e,"name",{value:t,configurable:!0});import{createRequire as Oe}from"node:module";import{jsxs as k,jsx as b}from"react/jsx-runtime";import{setMode as ee,BracketedPasteMode as ie,resetMode as re,cursorShow as ut,cursorUp as Ct,cursorTo as Tt,cursorDown as Ie,cursorHide as z,eraseLines as Y,cursorNextLine as ke,eraseLineEnd as $e,createDecMode as De,ALT_SCREEN_ON as Ae,clearScreenAndHomeCursor as We,ALT_SCREEN_OFF as Be}from"@visulima/ansi";import{wordWrap as Me}from"@visulima/string";import{throttle as jt}from"es-toolkit/compat";import se from"is-in-ci";import Ue from"patch-console";import{ConcurrentRoot as He,LegacyRoot as Ke}from"react-reconciler/constants.js";import{onExit as _e}from"signal-exit";import qt from"yoga-layout";import{a as je}from"./accessibility-context-DDyHTwmA.js";import{PureComponent as Fe,useState as ht,useRef as M,useCallback as g,useEffect as wt,useMemo as q}from"react";import{e as Ye}from"./animation-context-DW3p-vpk.js";import{t as ze}from"./app-context-BVpKlG1z.js";import{o as Ve}from"./cursor-context-CFviBqPX.js";import Ze from"code-excerpt";import Ft from"stack-utils";import{Box as U}from"../components/box.js";import{Text as W}from"../components/text.js";import{o as Ge}from"./focus-context-CsT69klR.js";import{t as Je}from"./stderr-context-BzEaUICS.js";import{e as ti}from"./stdin-context-BTaaFagk.js";import{t as ei}from"./stdout-context-BnblEPez.js";import{c as ii}from"./dom-4y__5fWB.js";import{resolveFlags as ri}from"./kittyFlags-C3rZLbcK.js";import{a as si}from"./measure-text-DDjHT1jD.js";import{L as $,u as oi}from"./reconciler-BuOP-TZ6.js";import{r as ni,R as ui}from"./renderer-gqplqpkQ.js";import{measureAndExtractObservers as ai}from"./ResizeObserverEntry-Dq0dk8Kq.js";import{calculateScroll as li}from"./getScrollHeight-BTEY8ewu.js";import{g as Z}from"./utils-CoviI5Vm.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
-
const Ee=Oe(import.meta.url),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,nt=T(e=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[t,i]=J.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return J.getBuiltinModule(e)}return Ee(e)},"__cjs_getBuiltinModule"),D=J,{cwd:te}=D,{Stream:Ne}=nt("node:stream"),{Buffer:_t}=nt("node:buffer"),{Console:Le}=nt("node:console"),{EventEmitter:qe}=nt("node:events"),{existsSync:Qe,readFileSync:Xe}=nt("node:fs");var di=Object.defineProperty,L=T((e,t)=>di(e,"name",{value:t,configurable:!0}),"i$2");const oe="\x1B[200~",Yt="\x1B[201~",ci=L(e=>e>=48&&e<=63,"isCsiParameterByte"),hi=L(e=>e>=32&&e<=47,"isCsiIntermediateByte"),ne=L(e=>e>=64&&e<=126,"isCsiFinalByte"),pi=L((e,t,i)=>{const r=t+i+1;let s=r;for(;s<e.length;s++){const l=e.codePointAt(s);if(l===void 0)return"pending";if(!(ci(l)||hi(l))&&!(l===91&&s===r))return ne(l)?{nextIndex:s+1,sequence:e.slice(t,s+1)}:void 0}return"pending"},"parseCsiSequence"),fi=L((e,t,i)=>{const r=t+i+2;if(r>e.length)return"pending";const s=e.codePointAt(r-1);if(!(s===void 0||!ne(s)))return{nextIndex:r,sequence:e.slice(t,r)}},"parseSs3Sequence"),zt=L((e,t,i)=>{const r=e[t+i];if(r===void 0)return"pending";if(r==="[")return pi(e,t,i);if(r==="O")return fi(e,t,i)},"parseControlSequence"),mi=L((e,t)=>{const i=e.codePointAt(t+1),r=i!==void 0&&i>65535?2:1,s=t+1+r;return{nextIndex:s,sequence:e.slice(t,s)}},"parseEscapedCodePoint"),gi=L((e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]==="\x1B"){if(t+2>=e.length)return"pending";const r=zt(e,t,2);return r==="pending"?"pending":r||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const i=zt(e,t,1);return i==="pending"?"pending":i||mi(e,t)},"parseEscapeSequence"),Vt=L((e,t)=>{let i=0;for(let r=0;r<e.length;r++){const s=e[r];(s===""||s==="\b")&&(r>i&&t.push(e.slice(i,r)),t.push(s),i=r+1)}i<e.length&&t.push(e.slice(i))},"splitDeleteAndBackspace"),vi=L(e=>{const t=[];let i=0;const r=L(s=>({events:t,pending:e.slice(s)}),"pendingFrom");for(;i<e.length;){const s=e.indexOf("\x1B",i);if(s===-1)return Vt(e.slice(i),t),{events:t,pending:""};s>i&&Vt(e.slice(i,s),t);const l=gi(e,s);if(l==="pending")return r(s);if(l.sequence===oe){const u=l.nextIndex,o=e.indexOf(Yt,u);if(o===-1)return r(s);t.push({paste:e.slice(u,o)}),i=o+Yt.length;continue}t.push(l.sequence),i=l.nextIndex}return{events:t,pending:""}},"parseKeypresses"),wi=L(()=>{let e="";return{flushPendingEscape(){if(!e.startsWith("\x1B"))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith("\x1B")&&!e.startsWith(oe)&&e!=="\x1B[200"},push(t){const i=vi(e+t);return e=i.pending,i.events},reset(){e=""}}},"createInputParser");var yi=Object.defineProperty,ue=T((e,t)=>yi(e,"name",{value:t,configurable:!0}),"p$1");const yt=ue(e=>e?.replace(`file://${te()}/`,""),"cleanupPath"),Qt=new Ft({cwd:te(),internals:Ft.nodeInternals()});function ae({error:e}){const t=e.stack?e.stack.split(`
|
|
4
|
-
`).slice(1):void 0,i=t?Qt.parseLine(t[0]):void 0,r=yt(i?.file);let s,l=0;if(r&&i?.line&&Qe(r)){const u=Xe(r,"utf8");if(s=Ze(u,i.line),s)for(const{line:o}of s)l=Math.max(l,String(o).length)}return k(U,{flexDirection:"column",padding:1,children:[k(U,{children:[k(W,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),k(W,{children:[" ",e.message]})]}),i&&r?b(U,{marginTop:1,children:k(W,{dimColor:!0,children:[r,":",i.line,":",i.column]})}):null,i&&s?b(U,{flexDirection:"column",marginTop:1,children:s.map(({line:u,value:o})=>k(U,{children:[b(U,{width:l+1,children:k(W,{"aria-label":u===i.line?`Line ${u}, error`:`Line ${u}`,backgroundColor:u===i.line?"red":void 0,color:u===i.line?"white":void 0,dimColor:u!==i.line,children:[String(u).padStart(l," "),":"]})}),b(W,{backgroundColor:u===i.line?"red":void 0,color:u===i.line?"white":void 0,children:` ${o}`},u)]},u))}):null,t?b(U,{flexDirection:"column",marginTop:1,children:t.map(u=>{const o=Qt.parseLine(u);return o?k(U,{children:[b(W,{dimColor:!0,children:"- "}),b(W,{bold:!0,dimColor:!0,children:o.function}),k(W,{"aria-label":`at ${yt(o.file)??""} line ${o.line} column ${o.column}`,color:"gray",dimColor:!0,children:[" ","(",yt(o.file)??"",":",o.line,":",o.column,")"]})]},u):k(U,{children:[b(W,{dimColor:!0,children:"- "}),k(W,{bold:!0,dimColor:!0,children:[u,"\\t"," "]})]},u)})}):null]})}T(ae,"B");ue(ae,"ErrorOverview");var bi=Object.defineProperty,Ci=T((e,t)=>bi(e,"name",{value:t,configurable:!0}),"o$1");let xi=class extends Fe{static{T(this,"i")}static{Ci(this,"ErrorBoundary")}static displayName="InternalErrorBoundary";static getDerivedStateFromError(t){return{error:t}}state={error:void 0};componentDidCatch(t){this.props.onError(t)}render(){return this.state.error?b(ae,{error:this.state.error}):this.props.children}};var Ri=Object.defineProperty,Xt=T((e,t)=>Ri(e,"name",{value:t,configurable:!0}),"V$1");const Ti=" ",Si="\x1B[Z",Pi="\x1B",Oi=ee(ie),Zt=re(ie),le=Xt(({children:e,exitOnCtrlC:t,interactive:i,onExit:r,onWaitUntilRenderFlush:s,renderThrottleMs:l,setCursorPosition:u,stderr:o,stdin:n,stdout:f,writeToStderr:C,writeToStdout:v})=>{const[d,c]=ht(!0),[x,R]=ht(void 0),[,w]=ht([]),B=M(0),I=M(new Map),H=M(void 0),P=M(0),A=M(0),[E]=ht(()=>{const a=new qe;return a.setMaxListeners(1/0),a}),S=M(void 0),K=M(void 0);K.current??=wi();const et=M(void 0),Pt=M(!1),ge=20,V=g(()=>{et.current&&(clearTimeout(et.current),et.current=void 0)},[]),Q=g(()=>{H.current&&(clearTimeout(H.current),H.current=void 0)},[]),lt=g(()=>{if(Q(),I.current.size===0)return;let a=Number.POSITIVE_INFINITY;for(const h of I.current.values())a=Math.min(a,h.nextDueTime);const p=Math.max(0,a-performance.now());H.current=setTimeout(()=>{H.current=void 0;const h=performance.now(),y=[...I.current.values()];for(const O of y){if(h<O.nextDueTime)continue;O.callback(h);const Te=h-O.startTime,Se=Math.floor(Te/O.interval)+1;O.nextDueTime=O.startTime+Se*O.interval}lt()},p)},[Q]),Ot=g((a,p)=>{const h=performance.now();return I.current.set(a,{callback:a,interval:p,nextDueTime:h+p,startTime:h}),lt(),{startTime:h,unsubscribe(){if(I.current.delete(a),I.current.size===0){Q();return}lt()}}},[Q,lt]);wt(()=>()=>{Q()},[Q]);const _=n.isTTY,Et=g(()=>{S.current&&(n.removeListener("readable",S.current),S.current=void 0)},[n]),X=g(()=>{n.setRawMode(!1),Et(),n.unref(),P.current=0,K.current?.reset(),V()},[n,Et,V]),it=g(a=>{_&&P.current>0&&X(),r(a)},[_,X,r]),Nt=g(a=>{if(a.includes("")&&t){it();return}a===Pi&&R(p=>{if(!p)return p})},[t,it]),rt=g(a=>{Nt(a),E.emit("input",a)},[Nt,E]),Lt=g(()=>{V(),et.current=setTimeout(()=>{et.current=void 0;const a=K.current.flushPendingEscape();a&&rt(a)},ge)},[V,rt]),vt=g(()=>{V();let a;for(;(a=n.read())!==null;){const p=K.current.push(a);for(const h of p)if(typeof h=="string")rt(h);else{if(E.listenerCount("paste")===0){Pt.current||(Pt.current=!0,C(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
|
|
5
|
-
`)),rt(h.paste);continue}E.emit("paste",h.paste)}}K.current.hasPendingEscape()&&Lt()},[n,rt,V,Lt,C,E]),It=g(a=>{if(!_)throw n===D.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
|
|
6
|
-
Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
|
|
7
|
-
Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(n.setEncoding("utf8"),a){P.current===0&&(n.ref(),n.setRawMode(!0),S.current=vt,n.addListener("readable",vt)),P.current++;return}P.current!==0&&--P.current===0&&X()},[_,n,vt,X]),kt=g(a=>{if(f.isTTY){if(a){A.current===0&&f.write(Oi),A.current++;return}A.current!==0&&--A.current===0&&f.write(Zt)}},[f]),$t=g((a,p)=>{const h=a.findIndex(y=>y.id===p);for(let y=h+1;y<a.length;y++){const O=a[y];if(O?.isActive)return O.id}},[]),Dt=g((a,p)=>{const h=a.findIndex(y=>y.id===p);for(let y=h-1;y>=0;y--){const O=a[y];if(O?.isActive)return O.id}},[]),dt=g(()=>{w(a=>(R(p=>{const h=a.find(y=>y.isActive)?.id;return $t(a,p)??h}),a))},[$t]),ct=g(()=>{w(a=>(R(p=>{const h=a.findLast(y=>y.isActive)?.id;return Dt(a,p)??h}),a))},[Dt]);wt(()=>{const a=Xt(h=>{!d||B.current===0||(h===Ti&&dt(),h===Si&&ct())},"handleTabNavigation");E.on("input",a);const p=E;return()=>{p.off("input",a)}},[d,dt,ct,E]);const At=g(()=>{c(!0)},[]),Wt=g(()=>{c(!1)},[]),Bt=g(a=>{w(p=>(p.some(h=>h?.id===a)&&R(a),p))},[]),Mt=g((a,{autoFocus:p})=>{w(h=>(B.current=h.length+1,[...h,{id:a,isActive:!0}])),p&&R(h=>h||a)},[]),Ut=g(a=>{R(p=>{if(p!==a)return p}),w(p=>{const h=p.filter(y=>y.id!==a);return B.current=h.length,h})},[]),Ht=g(a=>{w(p=>p.map(h=>h.id!==a?h:{id:a,isActive:!0}))},[]),Kt=g(a=>{R(p=>{if(p!==a)return p}),w(p=>p.map(h=>h.id!==a?h:{id:a,isActive:!1}))},[]);wt(()=>()=>{const a=!f.destroyed&&!f.writableEnded;i&&a&&f.write(ut),_&&P.current>0&&X(),A.current>0&&(f.isTTY&&a&&f.write(Zt),A.current=0)},[f,_,X,i]);const ve=q(()=>({exit:it,waitUntilRenderFlush:s}),[it,s]),we=q(()=>({internal_eventEmitter:E,internal_exitOnCtrlC:t,isRawModeSupported:_,setBracketedPasteMode:kt,setRawMode:It,stdin:n}),[n,It,kt,_,t,E]),ye=q(()=>({stdout:f,write:v}),[f,v]),be=q(()=>({stderr:o,write:C}),[o,C]),Ce=q(()=>({setCursorPosition:u}),[u]),xe=q(()=>({activate:Ht,activeId:x,add:Mt,deactivate:Kt,disableFocus:Wt,enableFocus:At,focus:Bt,focusNext:dt,focusPrevious:ct,remove:Ut}),[x,Mt,Ut,Ht,Kt,At,Wt,dt,ct,Bt]),Re=q(()=>({renderThrottleMs:l,subscribe:Ot}),[Ot,l]);return b(ze.Provider,{value:ve,children:b(ti.Provider,{value:we,children:b(ei.Provider,{value:ye,children:b(Je.Provider,{value:be,children:b(Ge.Provider,{value:xe,children:b(Ye.Provider,{value:Re,children:b(Ve.Provider,{value:Ce,children:b(xi,{onError:it,children:e})})})})})})})})},"App");le.displayName="InternalApp";const xt=new WeakMap;var Ei=Object.defineProperty,at=T((e,t)=>Ei(e,"name",{value:t,configurable:!0}),"e");const ft=at((e,t)=>e?.x!==t?.x||e?.y!==t?.y,"cursorPositionChanged"),tt=at((e,t)=>{if(!t)return"";const i=e-t.y;return(i>0?Ct(i):"")+Tt(t.x)+ut},"buildCursorSuffix"),de=at((e,t)=>{if(!t)return"";const i=e-1-t.y;return(i>0?Ie(i):"")+Tt(0)},"buildReturnToBottom"),ce=at(e=>{const t=e.cursorWasShown?z:"",i=de(e.previousLineCount,e.previousCursorPosition),r=tt(e.visibleLineCount,e.cursorPosition);return t+i+r},"buildCursorOnlySequence"),mt=at((e,t,i)=>e?z+de(t,i):"","buildReturnToBottomPrefix");var Ni=Object.defineProperty,N=T((e,t)=>Ni(e,"name",{value:t,configurable:!0}),"c$2");const ot=N((e,t)=>t.endsWith(`
|
|
8
|
-
`)?e.length-1:e.length,"visibleLineCount"),he=N(e=>e.rows||1/0,"getViewportRows"),gt=N((e,t)=>Math.min(e,he(t)),"clampToViewport"),Li=N((e,{showCursor:t=!1}={})=>{let i=0,r="",s=!1,l,u=!1,o,n=!1;const f=N(()=>u?l:void 0,"getActiveCursor"),C=N((d,c)=>{const x=ft(c,o);return d!==r||x},"hasChanges"),v=N(d=>{!t&&!s&&(e.write(z),s=!0);const c=f();u=!1;const x=ft(c,o);if(!C(d,c))return!1;const R=d.split(`
|
|
9
|
-
`),w=ot(R,d),B=tt(w,c);if(d===r&&x)e.write(ce({cursorPosition:c,cursorWasShown:n,previousCursorPosition:o,previousLineCount:i,visibleLineCount:w}));else{r=d;const I=mt(n,i,o);e.write(I+Y(gt(i,e))+d+B),i=R.length}return o=c?{...c}:void 0,n=c!==void 0,!0},"render");return v.clear=()=>{const d=mt(n,i,o);e.write(d+Y(gt(i,e))),r="",i=0,o=void 0,n=!1},v.done=()=>{r="",i=0,o=void 0,n=!1,t||(e.write(ut),s=!1)},v.reset=()=>{r="",i=0,o=void 0,n=!1},v.sync=d=>{const c=u?l:void 0;u=!1;const x=d.split(`
|
|
10
|
-
`);r=d,i=x.length,!c&&n&&e.write(z),c&&e.write(tt(ot(x,d),c)),o=c?{...c}:void 0,n=c!==void 0},v.setCursorPosition=d=>{l=d,u=!0},v.isCursorDirty=()=>u,v.willRender=d=>C(d,f()),v},"createStandard"),Ii=N((e,{showCursor:t=!1}={})=>{let i=[],r="",s=!1,l,u=!1,o,n=!1;const f=N(()=>u?l:void 0,"getActiveCursor"),C=N((d,c)=>{const x=ft(c,o);return d!==r||x},"hasChanges"),v=N(d=>{!t&&!s&&(e.write(z),s=!0);const c=f();u=!1;const x=ft(c,o);if(!C(d,c))return!1;const R=d.split(`
|
|
11
|
-
`),w=ot(R,d),B=ot(i,r);if(d===r&&x)return e.write(ce({cursorPosition:c,cursorWasShown:n,previousCursorPosition:o,previousLineCount:i.length,visibleLineCount:w})),o=c?{...c}:void 0,n=c!==void 0,!0;const I=mt(n,i.length,o);if(d===`
|
|
12
|
-
`||r.length===0){const S=tt(w,c);return e.write(I+Y(gt(i.length,e))+d+S),n=c!==void 0,o=c?{...c}:void 0,r=d,i=R,!0}const H=d.endsWith(`
|
|
13
|
-
`),P=[I],A=he(e);if(w<B){const S=r.endsWith(`
|
|
14
|
-
`)?1:0;P.push(Y(Math.min(B-w+S,A)),Ct(Math.min(w,A-1)))}else P.push(Ct(Math.min(B-1,A-1)));for(let S=0;S<w;S++){const K=S===w-1;if(R[S]===i[S]){(!K||H)&&P.push(ke());continue}P.push(Tt(0)+R[S]+$e+(K&&!H?"":`
|
|
15
|
-
`))}const E=tt(w,c);return P.push(E),e.write(P.join("")),n=c!==void 0,o=c?{...c}:void 0,r=d,i=R,!0},"render");return v.clear=()=>{const d=mt(n,i.length,o);e.write(d+Y(gt(i.length,e))),r="",i=[],o=void 0,n=!1},v.done=()=>{r="",i=[],o=void 0,n=!1,t||(e.write(ut),s=!1)},v.reset=()=>{r="",i=[],o=void 0,n=!1},v.sync=d=>{const c=u?l:void 0;u=!1;const x=d.split(`
|
|
16
|
-
`);r=d,i=x,!c&&n&&e.write(z),c&&e.write(tt(ot(x,d),c)),o=c?{...c}:void 0,n=c!==void 0},v.setCursorPosition=d=>{l=d,u=!0},v.isCursorDirty=()=>u,v.willRender=d=>C(d,f()),v},"createIncremental"),ki=N((e,{incremental:t=!1,showCursor:i=!1}={})=>t?Ii(e,{showCursor:i}):Li(e,{showCursor:i}),"create"),$i={create:ki};var Di=Object.defineProperty,Ai=T((e,t)=>Di(e,"name",{value:t,configurable:!0}),"t");const pe=De(2026),F=ee(pe),j=re(pe);function fe(e,t){return"isTTY"in e&&e.isTTY&&(t??!se)}T(fe,"shouldSynchronize");Ai(fe,"shouldSynchronize");var Wi=Object.defineProperty,Rt=T((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"o");let G;const Bi=Rt(()=>{if(G!==!1){if(G!==void 0)return G;try{return G=require("../../index.js").Renderer,G}catch{G=!1;return}}},"getRendererClass"),Mi=Rt(e=>{const t=Bi();if(!t)return;let i,r=0,s=0;const l=Rt((u,o)=>{(!i||r!==u||s!==o)&&(i?i.resize(u,o):i=new t(u,o),r=u,s=o)},"ensureRenderer");return{clear(){if(i){const u=new Uint32Array(r*s*2),o=65535;for(let n=0;n<u.length;n+=2)u[n]=32,u[n+1]=o;i.render(u)}},destroy(){i=void 0},render(u,o,n){if(l(o,n),!!i){e.isTTY&&i.writeRaw(F);try{i.render(u)}finally{e.isTTY&&i.writeRaw(j)}}},resize(u,o){l(u,o)}}},"createNative");var Ui=Object.defineProperty,m=T((e,t)=>Ui(e,"name",{value:t,configurable:!0}),"n");console.Console||(console.Console=Le);const st=m(()=>{},"noop"),Gt=m(async()=>new Promise(e=>{setImmediate(e)}),"yieldImmediate"),Hi=27,Ki=91,_i=63,ji=117,qi=48,Fi=57,Yi=m(e=>e>=qi&&e<=Fi,"isDigitByte"),me=m((e,t)=>{if(e[t]!==Hi||e[t+1]!==Ki||e[t+2]!==_i)return;let i=t+3;const r=i;for(;i<e.length&&Yi(e[i]);)i++;if(i!==r){if(i===e.length)return{state:"partial"};if(e[i]===ji)return{endIndex:i,state:"complete"}}},"matchKittyQueryResponse"),zi=m(e=>{for(let t=0;t<e.length;t++)if(me(e,t)?.state==="complete")return!0;return!1},"hasCompleteKittyQueryResponse"),Vi=m(e=>{const t=[];let i=0;for(;i<e.length;){const r=me(e,i);if(r?.state==="complete"){i=r.endIndex+1;continue}if(r?.state==="partial")break;t.push(e[i]),i++}return t},"stripKittyQueryResponsesAndTrailingPartial"),Qi=m(({isTty:e,isUnmounting:t,nextOutputHeight:i,previousOutputHeight:r,viewportRows:s})=>{if(!e)return!1;const l=r>0,u=r>=s,o=r>s,n=i>s,f=u&&i<s;return o||n&&l||f||t&&u},"shouldClearTerminalForFrame"),bt=m(e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]","isErrorInput"),Jt=m(e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),i=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:i}},"getWritableStreamState"),pt=m((e,t)=>{if(!e||typeof e.flush!="function")return;const i=e;t?i.flush():typeof i.cancel=="function"&&i.cancel()},"settleThrottle");class Xi{static{T(this,"ft")}static{m(this,"Ink")}isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=ii("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??D.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const i=t.debug||this.isScreenReaderEnabled,r=t.maxFps??30,s=r>0?Math.max(1,Math.ceil(1e3/r)):0;this.renderThrottleMs=i?0:s;const l=i?this.onRender:(()=>{const o=jt(this.onRender,s,{leading:!0,trailing:!0});return this.throttledOnRender=o,()=>{this.hasPendingThrottledRender=!0,o()}})();if(i&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let o=!1;const n=m(()=>{o||(o=!0,queueMicrotask(()=>{o=!1,this.onRender()}))},"deferredRender");this.rootNode.onRender=n,this.rootNode.onImmediateRender=n}else this.rootNode.onRender=l,this.rootNode.onImmediateRender=this.onRender;this.log=$i.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Mi(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=i?this.log:jt(o=>{const n=this.log.willRender(o),f=this.shouldSync();f&&n&&this.options.stdout.write(F),this.log(o),f&&n&&this.options.stdout.write(j)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=Z(this.options.stdout).columns,this.fullStaticOutput="";const u=t.concurrent?He:Ke;this.container=$.createContainer(this.rootNode,u,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=_e(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),D.env.DEV==="true"&&$.injectIntoDevTools(),this.exitPromise=new Promise((o,n)=>{this.resolveExitPromise=o,this.rejectExitPromise=n}),this.exitPromise.catch(st)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=m(()=>{const t=Z(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),si(),this.calculateLayout(),this.onRender(),this.lastTerminalWidth=t},"resized");resolveExitPromise=m(()=>{},"resolveExitPromise");rejectExitPromise=m(()=>{},"rejectExitPromise");unsubscribeExit=m(()=>{},"unsubscribeExit");handleAppExit=m(t=>{if(!(this.isUnmounted||this.isUnmounting)){if(bt(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}},"handleAppExit");getActiveCursorPosition=m(()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition,"getActiveCursorPosition");setCursorPosition=m(t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())},"setCursorPosition");restoreLastOutput=m(()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
|
|
17
|
-
`))},"restoreLastOutput");calculateLayout=m(()=>{const t=m(r=>{const s=new Map;this.calculateScrollAndTriggerObservers(r,s);for(const[l,u]of s)l.internalTrigger(u)},"flushLayoutObservers");this.prepareYogaTree(this.rootNode,t);const i=Z(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(i),this.rootNode.yogaNode.calculateLayout(void 0,void 0,qt.DIRECTION_LTR),t(this.rootNode)},"calculateLayout");calculateScrollAndTriggerObservers(t,i){if(t.nodeName==="ink-box"){const{style:r}=t,s=r.overflow??"visible",l=r.overflowX??s,u=r.overflowY??s;l==="scroll"||u==="scroll"?li(t):t.internal_scrollState&&delete t.internal_scrollState}if(ai(t,i),!t.internal_static)for(const r of t.childNodes)r.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(r,i)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,i){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),oi(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let r=0;for(const s of t.childNodes){const l=s;s.nodeName!=="#text"&&l.yogaNode&&(t.yogaNode.insertChild(l.yogaNode,r),r++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const r of t.childNodes)r.nodeName!=="#text"&&this.prepareYogaTree(r,i);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const r=Z(this.options.stdout).columns,{width:s}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof s=="number"?s:r),t.yogaNode.calculateLayout(void 0,void 0,qt.DIRECTION_LTR)),i(t),ni(t,{skipStaticElements:!1,trackSelection:this.options.trackSelection}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const i of t.childNodes)i.nodeName!=="#text"&&this.markAllTextNodesDirty(i)}}onRender=m(()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=ui(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:i,cursorRequested:r,output:s,outputBuffer:l,outputHeight:u,outputWidth:o,staticOutput:n}=t;if(this.renderedCursorRequested=r,this.renderedCursorPosition=i,this.useNativeRenderer&&this.nativeLog&&l&&o){n&&n!==`
|
|
18
|
-
`&&this.options.stdout.write(n),this.nativeLog.render(l,o,u),this.lastOutputHeight=u;return}r&&this.log.setCursorPosition(this.getActiveCursorPosition());const f=n&&n!==`
|
|
19
|
-
`;if(this.options.debug){f&&(this.fullStaticOutput+=n),this.lastOutput=s,this.lastOutputToRender=s,this.lastOutputHeight=u,this.options.stdout.write(this.fullStaticOutput+s);return}if(!this.interactive){f&&this.options.stdout.write(n),this.lastOutput=s,this.lastOutputToRender=`${s}
|
|
20
|
-
`,this.lastOutputHeight=u;return}if(this.isScreenReaderEnabled){const C=this.shouldSync();if(C&&this.options.stdout.write(F),f){const c=this.lastOutputHeight>0?Y(this.lastOutputHeight):"";this.options.stdout.write(c+n),this.lastOutputHeight=0}if(s===this.lastOutput&&!f){C&&this.options.stdout.write(j);return}const v=Z(this.options.stdout).columns,d=Me(s,{trim:!1,width:v,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(f)this.options.stdout.write(d);else{const c=this.lastOutputHeight>0?Y(this.lastOutputHeight):"";this.options.stdout.write(c+d)}this.lastOutput=s,this.lastOutputToRender=d,this.lastOutputHeight=d===""?0:d.split(`
|
|
21
|
-
`).length,C&&this.options.stdout.write(j);return}f&&(this.fullStaticOutput+=n),this.renderInteractiveFrame(s,u,f?n:"")},"onRender");accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const i=b(je.Provider,{value:this.accessibilityContextValue,children:b(le,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?$.updateContainer(i,this.container,null,st):($.updateContainerSync(i,this.container,null,st),$.flushSyncWork())}writeToStdout=m(t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const i=this.shouldSync();i&&this.options.stdout.write(F),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),i&&this.options.stdout.write(j)},"writeToStdout");writeToStderr=m(t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const i=this.shouldSync();i&&this.options.stdout.write(F),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),i&&this.options.stdout.write(j)},"writeToStderr");unmount=m(t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(D.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const i=this.options.stdout,{canWriteToStdout:r,hasWritableState:s}=Jt(i);pt(this.throttledOnRender,r),r&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),pt(this.throttledLog,r),typeof this.restoreConsole=="function"&&this.restoreConsole();const l=m(()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),r&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,Be),this.writeBestEffort(this.options.stdout,ut),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
|
|
22
|
-
`:`${this.lastOutput}
|
|
23
|
-
`)),this.kittyProtocolEnabled=!1,xt.delete(this.options.stdout);const{exitResult:o}=this,n=m(()=>{bt(t)?this.rejectExitPromise(t):this.resolveExitPromise(o)},"resolveOrReject");t!==void 0&&!bt(t)?n():r&&s?this.options.stdout.write("",n):setImmediate(n)},"finishUnmount"),u=$;this.options.concurrent?($.updateContainerSync(null,this.container,null,st),$.flushSyncWork(),u.flushPassiveEffects?.(),l()):($.updateContainerSync(null,this.container,null,st),$.flushSyncWork(),l())},"unmount");async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},D.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await Gt(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}$.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:i,hasWritableState:r}=Jt(t);if(pt(this.throttledOnRender,i),pt(this.throttledLog,i),i&&r){await new Promise(s=>{this.options.stdout.write("",()=>{s()})});return}await Gt()}clear(){this.interactive&&!this.options.debug&&(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
|
|
24
|
-
`))}patchConsole(){this.options.debug||(this.restoreConsole=Ue((t,i)=>{t==="stdout"&&this.writeToStdout(i),t==="stderr"&&(i.startsWith("The above error occurred")||this.writeToStderr(i))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Ae),this.writeBestEffort(this.options.stdout,z))}resolveInteractiveOption(t){return t??(!se&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(t,i){return!!t&&i&&!!this.options.stdout.isTTY}shouldSync(){return fe(this.options.stdout,this.interactive)}writeBestEffort(t,i){try{t.write(i)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const i=new Promise(r=>{t=r});this.nextRenderCommit={promise:i,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,i,r){const s=r!=="",l=this.options.stdout.isTTY,u=l?Z(this.options.stdout).rows:24,o=l&&i>=u?t:`${t}
|
|
25
|
-
`;if(Qi({isTty:l,isUnmounting:this.isUnmounting,nextOutputHeight:i,previousOutputHeight:this.lastOutputHeight,viewportRows:u})){if(this.options.incrementalRendering){s&&(this.log.clear(),this.options.stdout.write(r)),(t!==this.lastOutput||this.log.isCursorDirty()||s)&&this.throttledLog(o),this.lastOutput=t,this.lastOutputToRender=o,this.lastOutputHeight=i;return}const n=this.shouldSync();n&&this.options.stdout.write(F),this.options.stdout.write(We+this.fullStaticOutput+t),this.lastOutput=t,this.lastOutputToRender=o,this.lastOutputHeight=i,this.log.sync(o),n&&this.options.stdout.write(j);return}if(s){const n=this.shouldSync();n&&this.options.stdout.write(F),this.log.clear(),this.options.stdout.write(r),this.log(o),n&&this.options.stdout.write(j)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(o);this.lastOutput=t,this.lastOutputToRender=o,this.lastOutputHeight=i}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const i=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(i)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const i=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(i)}confirmKittySupport(t){const{stdin:i,stdout:r}=this.options;let s=[];const l=m(()=>{this.cancelKittyDetection=void 0,clearTimeout(o),i.removeListener("data",u);const n=Vi(s);s=[],n.length>0&&i.unshift(_t.from(n))},"cleanup"),u=m(n=>{const f=typeof n=="string"?_t.from(n):n;for(const C of f)s.push(C);zi(s)&&(l(),this.isUnmounted||this.enableKittyProtocol(t))},"onData");i.on("data",u);const o=setTimeout(l,200);this.cancelKittyDetection=l,r.write("\x1B[?u")}enableKittyProtocol(t){this.options.stdout.write(`\x1B[>${ri(t)}u`),this.kittyProtocolEnabled=!0}}var Zi=Object.defineProperty,St=T((e,t)=>Zi(e,"name",{value:t,configurable:!0}),"i");const $r=St((e,t)=>{const i={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:D.stderr,stdin:D.stdin,stdout:D.stdout,...Gi(t)},r=Ji(i.stdout,()=>new Xi(i));return r.render(e),{cleanup(){r.unmount()},clear(){r.clear()},rerender(s){r.render(s)},rootNode:r.rootNode,unmount(){r.unmount()},waitUntilExit(){return r.waitUntilExit()},waitUntilRenderFlush(){return r.waitUntilRenderFlush()}}},"render"),Gi=St((e={})=>e instanceof Ne?{stdin:D.stdin,stdout:e}:e,"getOptions"),Ji=St((e,t)=>{const i=xt.get(e);if(i===void 0){const r=t();return xt.set(e,r),r}return D.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
|
|
26
|
-
`),i},"getInstance");export{$r as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var D=Object.defineProperty;var R=(t,o)=>D(t,"name",{value:o,configurable:!0});import G from"cli-boxes";import{resolveColor as W}from"./NAMED_COLORS-B9fJsYdg.js";import{g as I}from"./text-width-BU2eeTWn.js";var K=Object.defineProperty,B=R((t,o)=>K(t,"name",{value:o,configurable:!0}),"N");const V=1114112,F=9608,J=9600,Q=9604;function j(t){const o=t?.borderStyle?1:0;return{bottom:t?.borderBottom===!1?0:o,left:t?.borderLeft===!1?0:o,right:t?.borderRight===!1?0:o,top:t?.borderTop===!1?0:o}}R(j,"k");B(j,"getEffectiveBorderWidths");function H(t){let o=0;for(const i of t.children){const b=i.getLayout(),e=b.top+b.height;e>o&&(o=e)}const n=t._style,l=n?.paddingBottom??n?.paddingY??n?.padding??0;return o+l}R(H,"q");B(H,"getScrollContentHeight");function N(t,o,n,l,i,b,e,m,v,_,g,d){const r=j(d),a=m-r.top-r.bottom,u=d.scrollTop??0,h=H(t),M=a;if(h<=M||a<=0)return;const f=a*2,y=Math.max(2,Math.round(M/h*f)),s=h-M,x=f-y,T=s>0?Math.round(u/s*x):0,c=typeof d.scrollbarThumbColor=="string"?W(d.scrollbarThumbColor):v,p=i+e-1-r.right,S=_<<16|65280|c;for(let w=0;w<a;w++){const Y=w*2,X=Y+1,k=Y>=T&&Y<T+y,L=X>=T&&X<T+y;if(!k&&!L)continue;let C=F;k&&!L?C=J:!k&&L&&(C=Q),A(o,n,l,p,b+r.top+w,C,S,g)}}R(N,"z");B(N,"paintScrollbar");function q(t,o,n,l,i,b,e,m,v,_,g,d,r,a){const u=j(a),h=a.scrollTop??0,M=b+u.top;for(const f of t.children){if(!f._style?.sticky)continue;const y=f.getLayout();if(y.top>=h)continue;const s=f.parent;if(s&&s!==t){const S=s.getLayout();if(S.top+S.height<=h)continue}const x=M,T=f.fg===255?v:f.fg,c=f.bg===255?_:f.bg,p=f.styles===0?g:f.styles;E(f,o,n,l,i-y.left,x-y.top,T,c,p,d,r)}}R(q,"G");B(q,"paintStickyHeaders");function Z(t,o,n,l){for(let e=0;e<o.length;e+=2)o[e]=32,o[e+1]=65535;const i=[],b={x0:0,x1:n,y0:0,y1:l};try{E(t,o,n,l,0,0,t.fg,t.bg,t.styles,i,b);for(const e of i)z(e.node,o,n,l,e.absX,e.absY,e.w,e.h,e.fg,e.bg,e.styles,e.clip)}catch(e){console.error("Renderer Error:",e)}}R(Z,"renderTreeToBuffer");B(Z,"renderTreeToBuffer");function A(t,o,n,l,i,b,e,m){if(l<m.x0||l>=m.x1||i<m.y0||i>=m.y1||l<0||l>=o||i<0||i>=n)return;const v=(i*o+l)*2;t[v]=b,t[v+1]=e}R(A,"M");B(A,"writeCell");function z(t,o,n,l,i,b,e,m,v,_,g,d){if(!t._style?.borderStyle||e<=0||m<=0)return;const r=G[t._style.borderStyle],a=t._style.borderColor===void 0?v:W(t._style.borderColor),u=g<<16|_<<8|a,h=t._style.borderTop!==!1,M=t._style.borderBottom!==!1,f=t._style.borderLeft!==!1,y=t._style.borderRight!==!1,s=M&&(m>1||!h);if(h)for(let c=0;c<e;c++){let p;e===1?p=f&&y?r.left:f?r.topLeft:y?r.topRight:r.top:c===0&&f?p=r.topLeft:c===e-1&&y?p=r.topRight:p=r.top,A(o,n,l,i+c,b,p.codePointAt(0),u,d)}if(s)for(let c=0;c<e;c++){let p;e===1?p=f&&y?r.left:f?r.bottomLeft:y?r.bottomRight:r.bottom:c===0&&f?p=r.bottomLeft:c===e-1&&y?p=r.bottomRight:p=r.bottom,A(o,n,l,i+c,b+m-1,p.codePointAt(0),u,d)}const x=h?1:0,T=s?m-1:m;for(let c=x;c<T;c++)f&&A(o,n,l,i,b+c,r.left.codePointAt(0),u,d),y&&A(o,n,l,i+e-1,b+c,r.right.codePointAt(0),u,d)}R(z,"K");B(z,"paintBorder");function U(t){if(t._hidden)return"";if(t.text!==void 0)return t.text;const o=t.children.map(U).join("");return typeof t.transform=="function"?t.transform(o,0):o}R(U,"X");B(U,"collectText");function O(t,o,n,l,i,b,e,m,v,_){if(e<=0||m<=0)return;let g=0,d=0;for(const r of t){if(r===`
|
|
2
|
-
`){g=0,d++;continue}const a=r.codePointAt(0)??32,u=I(r);if(g+u>e&&(g=0,d++),d>=m)break;if(u>e){A(o,n,l,i+g,b+d,32,v,_),g+=1;continue}A(o,n,l,i+g,b+d,a,v,_),u===2&&g+1<e&&A(o,n,l,i+g+1,b+d,V,v,_),g+=u}}R(O,"E");B(O,"paintText");function E(t,o,n,l,i,b,e,m,v,_,g){if(t._hidden)return;const d=t.getLayout(),r=Math.round(i+d.left),a=Math.round(b+d.top),u=Math.round(d.width),h=Math.round(d.height),M=t.fg===255?e:t.fg,f=t.bg===255?m:t.bg,y=t.styles===0?v:t.styles,s={x0:Math.max(g.x0,r),x1:Math.min(g.x1,r+u),y0:Math.max(g.y0,a),y1:Math.min(g.y1,a+h)};if(s.x0>=s.x1||s.y0>=s.y1)return;if(typeof t.transform=="function"){const L=U(t),C=t.transform(L,0),P=y<<16|f<<8|M;O(C,o,n,l,r,a,u,h,P,s);return}if(t.text===void 0){if(f!==255||y!==0){const L=y<<16|f<<8|M;for(let C=0;C<h;C++)for(let P=0;P<u;P++)A(o,n,l,r+P,a+C,32,L,s)}t._style?.borderStyle&&_.push({absX:r,absY:a,bg:f,clip:s,fg:M,h,node:t,styles:y,w:u})}else{const L=y<<16|f<<8|M;if(t.bg!==255)for(let C=0;C<h;C++)for(let P=0;P<u;P++)A(o,n,l,r+P,a+C,32,L,s);O(t.text,o,n,l,r,a,u,h,L,s)}const x=t._style,T=x?.overflow??"visible",c=x?.overflowX??T,p=x?.overflowY??T,S=c==="hidden"||c==="scroll",w=p==="hidden"||p==="scroll";let Y=s,X=0,k=0;if(S||w){const L=j(x);Y={x0:S?Math.max(s.x0,r+L.left):s.x0,x1:S?Math.min(s.x1,r+u-L.right):s.x1,y0:w?Math.max(s.y0,a+L.top):s.y0,y1:w?Math.min(s.y1,a+h-L.bottom):s.y1},p==="scroll"&&typeof x?.scrollTop=="number"&&(k=-x.scrollTop),c==="scroll"&&typeof x?.scrollLeft=="number"&&(X=-x.scrollLeft)}for(const L of t.children)L._style?.internalStickyAlternate||E(L,o,n,l,r+X,a+k,M,f,y,_,Y);(p==="scroll"||c==="scroll")&&x?.scrollbar!==!1&&N(t,o,n,l,r,a,u,h,M,y,s,x),p==="scroll"&&typeof x?.scrollTop=="number"&&q(t,o,n,l,r,a,u,h,M,f,y,_,Y,x)}R(E,"S");B(E,"paintNode");export{Z as renderTreeToBuffer};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var Be=Object.defineProperty;var D=(o,e)=>Be(o,"name",{value:e,configurable:!0});import{T as Oe,i as De}from"./dom-4y__5fWB.js";import{getStringWidth as Q,indent as Pe,isFullwidthCodePoint as We}from"@visulima/string";import{B as H,D as A,I,U as j,f as z,H as Y,g as q,h as ae,F as V,j as de,S as $e,k as He,p as Ae}from"./measure-text-DDjHT1jD.js";import T from"yoga-layout";import{j as F,i as Fe,m as ue,c as ce}from"./layout-P24eyWyL.js";import{g as Ge,d as J}from"./colorize-DbTZMrJO.js";import Ie from"@visulima/colorize";import je from"cli-boxes";import{getScrollTop as Me}from"./getScrollHeight-BTEY8ewu.js";import Te from"./squashTextNodesWithMap-Cpqmc45i.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
-
var ze=Object.defineProperty,Ye=D((o,e)=>ze(o,"name",{value:e,configurable:!0}),"d");const qe=Ye(o=>Math.round(o.getComputedWidth()-Math.max(0,o.getComputedLeft()+o.getComputedWidth()-(o.getParent()?.getComputedWidth()??o.getComputedWidth()))-o.getComputedPadding(T.EDGE_LEFT)-o.getComputedPadding(T.EDGE_RIGHT)-o.getComputedBorder(T.EDGE_LEFT)-o.getComputedBorder(T.EDGE_RIGHT)),"getMaxWidth"),Ke=1114112;var Xe=Object.defineProperty,xe=D((o,e)=>Xe(o,"name",{value:e,configurable:!0}),"T$1");const Ue=1,Ve=2,Je=3,Qe=4,Ze=7,et=8,tt=9,he=22,ge=23,fe=24,pe=27,me=28,ye=29,be=39,ve=49,ot="\x1B[",E=xe(o=>o.length===0?"":`${ot}${o.join(";")}m`,"sgr"),rt=xe(o=>{if(o.length===0)return"";let e="",t=0,r,n,s,i=!1,d=0;const g=o.getSpans();for(const f of g){const c=f.formatFlags&127,{fgColor:l}=f,{bgColor:a}=f,{link:h}=f,u=c;if(u!==t||l!==r||a!==n||h!==s){if(h!==s&&(s&&(e+=s.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),h)){const m=h.startsWith("ST:");e+=`\x1B]8;;${m?h.slice(3):h}${m?"\x1B\\":"\x07"}`}const p=t&(H|A),b=u&(H|A);if(p!==b){const m=t&H&&!(u&H),y=t&A&&!(u&A);(m||y)&&(e+=E([he])),u&H&&(!(t&H)||y)&&(e+=E([Ue])),u&A&&(!(t&A)||m)&&(e+=E([Ve]))}u&I&&!(t&I)?e+=E([Je]):!(u&I)&&t&I&&(e+=E([ge])),u&j&&!(t&j)?e+=E([Qe]):!(u&j)&&t&j&&(e+=E([fe])),u&z&&!(t&z)?e+=E([Ze]):!(u&z)&&t&z&&(e+=E([pe])),u&Y&&!(t&Y)?e+=E([et]):!(u&Y)&&t&Y&&(e+=E([me])),u&q&&!(t&q)?e+=E([tt]):!(u&q)&&t&q&&(e+=E([ye])),l!==r&&(e+=E(l?ae(l,!0):[be])),a!==n&&(e+=E(a?ae(a,!1):[ve])),i=u!==0||l!==void 0||a!==void 0,t=u,r=l,n=a,s=h}e+=o.getTextRange(d,d+f.length),d+=f.length}return i&&(t&(H|A)&&(e+=E([he])),t&I&&(e+=E([ge])),t&j&&(e+=E([fe])),t&z&&(e+=E([pe])),t&Y&&(e+=E([me])),t&q&&(e+=E([ye])),r!==void 0&&(e+=E([be])),n!==void 0&&(e+=E([ve]))),s&&(e+=s.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),e},"styledLineToString");var it=Object.defineProperty,ke=D((o,e)=>it(o,"name",{value:e,configurable:!0}),"v");class ee{static{D(this,"OutputCaches")}static{ke(this,"OutputCaches")}widths=new Map;blockWidths=new Map;styledLines=new Map;lines=new Map;maxEntries;pruneToFactor;constructor(e={}){const{maxEntries:t=3e4,pruneToFactor:r=.8}=e;this.maxEntries=Math.max(1,t),this.pruneToFactor=Math.min(.99,Math.max(.1,r))}getStyledLine(e){let t=this.styledLines.get(e);return t===void 0&&(t=this.hasAnsiControlMarker(e)?He(e):Ae(e),this.setCacheEntry(this.styledLines,e,t)),t}getStringWidth(e){let t=this.widths.get(e);return t===void 0&&(t=Q(e),this.setCacheEntry(this.widths,e,t)),t}getWidestLine(e){let t=this.blockWidths.get(e);if(t===void 0){let r=0;for(const n of this.getLines(e))r=Math.max(r,this.getStringWidth(n));t=r,this.setCacheEntry(this.blockWidths,e,t)}return t}getLines(e){let t=this.lines.get(e);return t===void 0&&(t=e.split(`
|
|
4
|
-
`),this.setCacheEntry(this.lines,e,t)),t}hasAnsiControlMarker(e){for(const t of e){const r=t.codePointAt(0);if(nt.has(r))return!0}return!1}setCacheEntry(e,t,r){!e.has(t)&&e.size>=this.maxEntries&&this.pruneCache(e),e.set(t,r)}pruneCache(e){const t=Math.floor(this.maxEntries*this.pruneToFactor);for(const r of e.keys())if(e.delete(r),e.size<=t)break}}const nt=new Set([27,144,152,155,157,158,159]),st=.6,lt=30;class te{static{D(this,"A")}static{ke(this,"Output")}width;height;caches;grid;clipStack=[];previousLines=[];previousRenderedLines=[];lineMemoizationEnabled=!0;memoizationProbeCountdown=0;constructor(e){const{caches:t,height:r,width:n}=e;this.width=Math.round(n),this.height=Math.round(r),this.caches=t??new ee,this.grid=this.createGrid(this.width,this.height)}reset(e,t){this.width=Math.round(e),this.height=Math.round(t),this.clipStack.length=0,this.grid=this.createGrid(this.width,this.height)}startChildRegion(e,t,r,n){const s=Math.round(e),i=Math.round(t);this.clipStack.push({x1:s,x2:s+Math.round(r),y1:i,y2:i+Math.round(n)})}endChildRegion(){this.clipStack.pop()}write(e,t,r,n){if(!r)return;const{transformers:s}=n,i=this.clipStack.at(-1),d=this.caches.getLines(r),g=s.length>0;for(const[f,c]of d.entries()){const l=t+f;if(l<0||l>=this.grid.length||i&&(l<i.y1||l>=i.y2))continue;let a=c;if(g)for(const m of s)a=m(a,f);if(a.length===0)continue;const h=this.grid[l],u=this.caches.getStyledLine(a);let p=e;const b=i?Math.min(i.x2,h.length):1/0;for(let m=0;m<u.length&&!(p>=b);m++){if(i&&(p<i.x1||p>=i.x2)){p++,u.getFullWidth(m)&&p++;continue}if(p>=0){p>=h.length&&h.ensureWidth(p+2);const y=u.getSpan(m),k=u.getFullWidth(m),w=(y?.formatFlags??0)|(k?V:0);h.setCharFast(p,u.getValue(m),w,y?.fgColor,y?.bgColor,y?.link),k&&(p++,p>=h.length&&h.ensureWidth(p+1),h.setCharFast(p,"",w&~V,y?.fgColor,y?.bgColor,y?.link))}p++}}}writeStyledLine(e,t,r){if(r.length===0||t<0||t>=this.grid.length)return;const n=this.clipStack.at(-1);n&&(t<n.y1||t>=n.y2)||this.writeStyledLineToRow(this.grid[t],e,r,this.width,n)}getRootLines(){return this.grid}getCurrentClip(){return this.clipStack.at(-1)}addRegionTree(e,t,r){for(let n=0;n<e.height;n++){const s=r+n;if(s<0||s>=this.grid.length)continue;const i=e.lines[n];if(!i)continue;const d=this.grid[s];for(let g=0;g<i.length;g++){const f=t+g;if(f<0||f>=d.length)continue;const c=i.getValue(g);(c!==" "||i.hasStyles(g))&&d.setCharFast(f,c,i.getFormatFlags(g),i.getFgColor(g),i.getBgColor(g),i.getLink(g))}}for(const n of e.children)this.addRegionTree(n,t+n.x,r+n.y)}writeStyledLineToRow(e,t,r,n,s){let i=t;const d=s?Math.min(s.x2,n):1/0;for(let g=0;g<r.length&&!(i>=d);g++){if(s&&(i<s.x1||i>=s.x2)){i++,r.getFullWidth(g)&&i++;continue}if(i>=0){i>=e.length&&e.ensureWidth(i+2);const f=r.getSpan(g),c=r.getFullWidth(g),l=(f?.formatFlags??0)|(c?V:0);e.setCharFast(i,r.getValue(g),l,f?.fgColor,f?.bgColor,f?.link),c&&(i++,i>=e.length&&e.ensureWidth(i+1),e.setCharFast(i,"",l&~V,f?.fgColor,f?.bgColor,f?.link))}i++}}get(){const e=this.grid;this.lineMemoizationEnabled||(this.memoizationProbeCountdown>0?this.memoizationProbeCountdown--:this.lineMemoizationEnabled=!0);const t=this.lineMemoizationEnabled,r=this.previousLines.length>0,n=t&&r&&this.previousLines.length===e.length&&this.previousRenderedLines.length===e.length;this.previousLines.length>e.length&&(this.previousLines.length=e.length),this.previousRenderedLines.length>e.length&&(this.previousRenderedLines.length=e.length);const s=Array.from({length:e.length});let i=0;for(const[d,g]of e.entries()){const f=g;if(n&&this.previousLines[d]?.equals(f)){s[d]=this.previousRenderedLines[d]??"";continue}i++;const c=f.trimEnd(),l=rt(c);s[d]=l,t&&(this.previousRenderedLines[d]=l,this.previousLines[d]=f.clone())}return t&&n&&e.length>0&&i/e.length>st&&this.disableLineMemoization(),{height:e.length,output:s.join(`
|
|
5
|
-
`)}}getBuffer(){const e=this.grid,t=e.length,r=new Uint32Array(this.width*t*2),n=65535;for(let s=0;s<r.length;s+=2)r[s]=32,r[s+1]=n;for(let s=0;s<t;s++){const i=e[s];for(let d=0;d<i.length&&d<this.width;d++){const g=i.getValue(d);if(g.length===0)continue;const f=g.codePointAt(0)??32,c=(s*this.width+d)*2,l=i.getSpan(d),a=l?.formatFlags??0,h=l?.fgColor,u=l?.bgColor,p=h?de(h):255,b=u?de(u):255,m=(a&255)<<16|(b&255)<<8|p&255;if(r[c]=f,r[c+1]=m,i.getFullWidth(d)&&d+1<this.width){const y=c+2;r[y]=Ke,r[y+1]=m,d++}}}return{buffer:r,height:t}}createGrid(e,t){const r=[];for(let n=0;n<t;n++)r.push($e.empty(e));return r}disableLineMemoization(){this.lineMemoizationEnabled=!1,this.memoizationProbeCountdown=lt,this.previousLines.length=0,this.previousRenderedLines.length=0}}var at=Object.defineProperty,dt=D((o,e)=>at(o,"name",{value:e,configurable:!0}),"c");const ut=dt((o,e,t,r)=>{if(!t.style.backgroundColor)return;const n=Math.round(t.yogaNode.getComputedWidth()),s=Math.round(t.yogaNode.getComputedHeight()),i=t.style.borderStyle&&t.style.borderLeft!==!1?1:0,d=t.style.borderStyle&&t.style.borderRight!==!1?1:0,g=t.style.borderStyle&&t.style.borderTop!==!1?1:0,f=t.style.borderStyle&&t.style.borderBottom!==!1?1:0,c=n-i-d,l=s-g-f;if(!(c>0&&l>0))return;const a=Ge(t.style.backgroundColor);if(!a)return;const h=`${a}${" ".repeat(c)}\x1B[49m`;for(let u=0;u<l;u++)r.write(o+i,e+g+u,h,{transformers:[]})},"renderBackground");var ct=Object.defineProperty,oe=D((o,e)=>ct(o,"name",{value:e,configurable:!0}),"T");const P=oe((o,e,t,r)=>{let n=J(o,e,"foreground");return n=J(n,t,"background"),r&&(n=Ie.dim(n)),n},"stylePiece"),Ce=oe((o,e,t,r,n,s,i,d)=>{if(!t&&!n)return P(o.repeat(e),s,i,d);const g=t?` ${t} `:"",f=n?` ${n} `:"",c=g.length,l=f.length,a=r??"left";if(c+l>=e){if(c>=e)return`${g.slice(0,e-1)}…`;const b=e-c;return b>3?g+f.slice(0,b):g+P(o.repeat(e-c),s,i,d)}const h=e-c-l;if(a==="left"||n)return g+P(o.repeat(h),s,i,d)+f;if(a==="right"){const b=e-c;return P(o.repeat(b),s,i,d)+g}const u=Math.floor(h/2),p=h-u;return P(o.repeat(u),s,i,d)+g+P(o.repeat(p),s,i,d)},"buildBorderWithTitle"),ht=oe((o,e,t,r)=>{if(t.style.borderStyle){const n=Math.round(t.yogaNode.getComputedWidth()),s=Math.round(t.yogaNode.getComputedHeight()),i=typeof t.style.borderStyle=="string"?je[t.style.borderStyle]:t.style.borderStyle,d=t.style.borderTopColor??t.style.borderColor,g=t.style.borderBottomColor??t.style.borderColor,f=t.style.borderLeftColor??t.style.borderColor,c=t.style.borderRightColor??t.style.borderColor,l=t.style.borderTopBackgroundColor??t.style.borderBackgroundColor,a=t.style.borderBottomBackgroundColor??t.style.borderBackgroundColor,h=t.style.borderLeftBackgroundColor??t.style.borderBackgroundColor,u=t.style.borderRightBackgroundColor??t.style.borderBackgroundColor,p=t.style.borderTopDimColor??t.style.borderDimColor,b=t.style.borderBottomDimColor??t.style.borderDimColor,m=t.style.borderLeftDimColor??t.style.borderDimColor,y=t.style.borderRightDimColor??t.style.borderDimColor,k=t.style.borderTop!==!1,w=t.style.borderBottom!==!1,B=t.style.borderLeft!==!1,W=t.style.borderRight!==!1,v=Math.max(0,n-(B?1:0)-(W?1:0));let M;if(k){const L=B?P(i.topLeft,d,l,p):"",O=W?P(i.topRight,d,l,p):"",R=Ce(i.top,v,t.style.borderTopTitle,t.style.borderTopTitleAlignment,t.style.borderTopRightTitle,d,l,p);M=L+R+O}let C=s;k&&(C-=1),w&&(C-=1),C=Math.max(0,C);let S="";B&&(S=`${P(i.left,f,h,m)}
|
|
6
|
-
`.repeat(C));let N="";W&&(N=`${P(i.right,c,u,y)}
|
|
7
|
-
`.repeat(C));let x;if(w){const L=B?P(i.bottomLeft,g,a,b):"",O=W?P(i.bottomRight,g,a,b):"",R=Ce(i.bottom,v,t.style.borderBottomTitle,t.style.borderBottomTitleAlignment,void 0,g,a,b);x=L+R+O}const _=k?1:0;M&&r.write(o,e,M,{transformers:[]}),S&&r.write(o,e+_,S,{transformers:[]}),N&&r.write(o+n-1,e+_,N,{transformers:[]}),x&&r.write(o,e+s-1,x,{transformers:[]})}},"renderBorder");var gt=Object.defineProperty,ft=D((o,e)=>gt(o,"name",{value:e,configurable:!0}),"m");const Ne=[],Se=ft(({axis:o,color:e,layout:t,output:r})=>{const{thumb:{end:n,endHalf:s,start:i,startHalf:d},x:g,y:f}=t;if(o==="vertical")for(let c=i;c<n;c++){let l="█";const a=2*c>=d&&2*c<s,h=2*c+1>=d&&2*c+1<s;a&&!h?l="▀":!a&&h&&(l="▄");const u=e?J(l,e,"foreground"):l;r.write(g,f+c,u,{transformers:Ne})}else for(let c=i;c<n;c++){let l="█";const a=2*c>=d&&2*c<s,h=2*c+1>=d&&2*c+1<s;a&&!h?l="▌":!a&&h&&(l="▐");const u=e?J(l,e,"foreground"):l;r.write(g+c,f,u,{transformers:Ne})}},"renderScrollbar");var pt=Object.defineProperty,re=D((o,e)=>pt(o,"name",{value:e,configurable:!0}),"b");const we=re((o,e=[])=>{for(const t of o.childNodes){if(t.nodeName==="#text")continue;const r=t;if(!r.internal_stickyAlternate)if(r.internal_sticky)e.push({node:r,type:r.internal_sticky==="bottom"?"bottom":"top"});else{const n=r.style.overflow??"visible",s=r.style.overflowX??n,i=r.style.overflowY??n;!(s==="scroll"||i==="scroll")&&r.childNodes&&we(r,e)}}return e},"getStickyDescendants"),mt=re((o,e,t,r)=>{let n,s=-1,i,d=-1;for(const[f,c]of o.entries()){const{node:l,type:a}=c;if(!l.yogaNode)continue;const h=F(l,e)??0,u=Math.round(l.yogaNode.getComputedHeight()),p=h+u,b=l.parentNode;let m=0,y=Number.MAX_SAFE_INTEGER;b?.yogaNode&&(m=F(b,e)??0,y=Math.round(b.yogaNode.getComputedHeight())),a==="top"&&h<t&&m+y>t&&(n=c,s=f),a==="bottom"&&Math.floor(p)>Math.floor(r)&&m<r&&(i=c,d=f)}const g=[];if(n){let f;for(let c=s+1;c<o.length;c++){const l=o[c];if(l.type!=="bottom"){f=l;break}}g.push({nextStickyNodeInfo:f,stickyNode:n.node,type:"top"})}if(i){let f;for(let c=d-1;c>=0;c--){const l=o[c];if(l.type==="bottom"){f=l;break}}g.push({nextStickyNodeInfo:f,stickyNode:i.node,type:"bottom"})}return g},"identifyActiveStickyNodes"),yt=re((o,e,t,r,n)=>{const{newTransformers:s,skipStaticElements:i,x:d,y:g}=n,{yogaNode:f}=e;if(!f)return;const c=f.getComputedBorder(T.EDGE_TOP),l=f.getComputedBorder(T.EDGE_LEFT),a=Me(e),h=e.internal_scrollState?.clientHeight??0;for(const{nextStickyNodeInfo:u,stickyNode:p,type:b}of o){if(!p.yogaNode)continue;const m=F(p,e)??0,y=Math.round(p.yogaNode.getComputedHeight()),k=d+(Fe(p,e)??0),w=p.parentNode;let B=0,W=Number.MAX_SAFE_INTEGER;w?.yogaNode&&(B=F(w,e)??0,W=Math.round(w.yogaNode.getComputedHeight()));let v;if(b==="top"){const S=w?.yogaNode?.getComputedBorder(T.EDGE_BOTTOM)??0,N=B+W-S;let x=g-a+N-y;const _=g-a+m,L=g+c;if(u?.node?.yogaNode){const O=F(u.node,e)??0,R=g-a+O-y;R<x&&(x=R)}v=Math.min(Math.max(L,_),x)}else{const S=w?.yogaNode?.getComputedBorder(T.EDGE_TOP)??0;let N=g-a+B+S;const x=g-a+m,_=g+c+h-y;if(u?.node?.yogaNode){const L=Math.round(u.node.yogaNode.getComputedHeight()),O=F(u.node,e)??0,R=g-a+O+L;R>N&&(N=R)}v=Math.max(Math.min(_,x),N)}const M=r({height:y,width:Math.round(p.yogaNode.getComputedWidth())});X(p,M,{offsetX:-Math.round(p.yogaNode.getComputedLeft()),offsetY:-Math.round(p.yogaNode.getComputedTop()),skipStaticElements:i,transformers:s});const C=M.get().output.split(`
|
|
8
|
-
`);for(const[S,N]of C.entries())N&&N.length>0&&t.write(k-(d+l),v-(g+c)+S,N,{transformers:[]})}},"renderActiveStickyNodes");var bt=Object.defineProperty,$=D((o,e)=>bt(o,"name",{value:e,configurable:!0}),"x");const vt=$((o,e)=>{const t=o.childNodes[0]?.yogaNode;if(t){const r=Math.round(t.getComputedLeft()),n=Math.round(t.getComputedTop());e=`
|
|
9
|
-
`.repeat(n)+Pe(e,r)}return e},"applyPaddingToText"),Ct=31,Nt=127,St=128,Et=159,Mt=$((o,e)=>{if(!Number.isFinite(e))return!1;if(e<0)return!0;let t=0;for(const r of o){if(r===`
|
|
10
|
-
`){if(t>e)return!0;t=0;continue}const n=r.codePointAt(0);if(n<=Ct||n===Nt||n>=St&&n<=Et||We(n)||(t++,t>e))return!0}return!1},"mightExceedWidth"),Tt=$(o=>(o.internal_hidden??!1)||o.yogaNode?.getDisplay()===T.DISPLAY_NONE,"isNodeHidden"),xt=$(o=>{let e=o;for(;e;){if(Tt(e))return!0;e=e.parentNode}return!1},"isNodeOrAncestorHidden"),Z=$((o,e={})=>{if(e.skipStaticElements&&o.internal_static||o.internal_hidden||o.internal_stickyAlternate||o.yogaNode?.getDisplay()===T.DISPLAY_NONE)return"";let t="";if(o.nodeName==="ink-text")t=Te(o);else if(o.nodeName==="ink-box"||o.nodeName==="ink-root"){const r=o.style.flexDirection==="row"||o.style.flexDirection==="row-reverse"?" ":`
|
|
11
|
-
`;t=(o.style.flexDirection==="row-reverse"||o.style.flexDirection==="column-reverse"?o.childNodes.toReversed():[...o.childNodes]).map(n=>Z(n,{parentRole:o.internal_accessibility?.role,skipStaticElements:e.skipStaticElements})).filter(Boolean).join(r)}if(o.internal_accessibility){const{role:r,state:n}=o.internal_accessibility;if(n){const s=Object.keys(n).filter(i=>n[i]).join(", ");s&&(t=`(${s}) ${t}`)}r&&r!==e.parentRole&&(t=`${r}: ${t}`)}return t},"renderNodeToScreenReaderOutput"),X=$((o,e,t)=>{const{absoluteOffsetX:r,absoluteOffsetY:n,offsetX:s=0,offsetY:i=0,renderState:d,selectionMap:g,skipStaticElements:f,transformers:c=[]}=t;if(f&&o.internal_static||o.internal_hidden)return;if(o.cachedRender){const a=Math.round(s+(o.yogaNode?.getComputedLeft()??0)),h=Math.round(i+(o.yogaNode?.getComputedTop()??0));e.addRegionTree(o.cachedRender,a,h);return}if(o.nodeName==="ink-cursor"){if(!d)return;d.cursorRequested=!0;const a=o.internal_cursor;if(!a){d.cursorPosition=void 0;return}if(a.inline){if(d.lastTextWriteEnd)d.cursorPosition={x:d.lastTextWriteEnd.x,y:d.lastTextWriteEnd.y};else{const p=o.parentNode?ue(o.parentNode):void 0;d.cursorPosition=p?{x:p.x,y:p.y}:void 0}return}const h=a.anchorRef?a.anchorRef.current:o.parentNode;if(!h){d.cursorPosition=void 0;return}if(a.anchorRef&&xt(h)){d.cursorPosition=void 0;return}const u=ue(h);if(!u){d.cursorPosition=void 0;return}d.cursorPosition={x:u.x+a.x,y:u.y+a.y};return}const{yogaNode:l}=o;if(l){if(l.getDisplay()===T.DISPLAY_NONE)return;const a=l.getComputedLeft(),h=l.getComputedTop(),u=Math.round(s+a),p=Math.round(i+h),b=Math.round((r??s)+a),m=Math.round((n??i)+h),y=e.getCurrentClip();if(y){const v=Math.round(l.getComputedWidth()),M=Math.round(l.getComputedHeight()),C=b+v,S=m+M,N=y.x1??-1/0,x=y.x2??1/0,_=y.y1??-1/0,L=y.y2??1/0;if(C<=N||b>=x||S<=_||m>=L)return}let k=c;if(typeof o.internal_transform=="function"&&(k=[o.internal_transform,...c]),o.nodeName==="ink-text"){let v=Te(o);if(v.length>0){const M=qe(l);if(Mt(v,M)&&Math.max(...v.split(`
|
|
12
|
-
`).map(C=>Q(C)))>M){const C=o.style.textWrap??"wrap";v=Oe(v,Math.floor(M),C)}if(v=vt(o,v),e.write(u,p,v,{transformers:k}),d){const C=v.split(`
|
|
13
|
-
`),S=C.at(-1)??"";d.lastTextWriteEnd={x:u+Q(S),y:p+C.length-1}}}return}let w=!1,B=0,W=0;if(o.nodeName==="ink-box"){ut(u,p,o,e),ht(u,p,o,e);const v=o.style.overflow??"visible",M=o.style.overflowX??v,C=o.style.overflowY??v,S=M==="hidden"||M==="scroll",N=C==="hidden"||C==="scroll";if(S||N){const x=Math.round(l.getComputedWidth()),_=Math.round(l.getComputedHeight()),L=S?u+l.getComputedBorder(T.EDGE_LEFT):u,O=S?x-l.getComputedBorder(T.EDGE_LEFT)-l.getComputedBorder(T.EDGE_RIGHT):x,R=N?p+l.getComputedBorder(T.EDGE_TOP):p,U=N?_-l.getComputedBorder(T.EDGE_TOP)-l.getComputedBorder(T.EDGE_BOTTOM):_;e.startChildRegion(L,R,Math.max(0,O),Math.max(0,U)),w=!0,C==="scroll"&&o.internal_scrollState&&(W=-o.internal_scrollState.scrollTop),M==="scroll"&&o.internal_scrollState&&(B=-o.internal_scrollState.scrollLeft)}}if(o.nodeName==="ink-root"||o.nodeName==="ink-box"||o.nodeName==="ink-static-render"){for(const v of o.childNodes)X(v,e,{absoluteOffsetX:b+B,absoluteOffsetY:m+W,offsetX:u+B,offsetY:p+W,renderState:d,selectionMap:g,skipStaticElements:f,transformers:k});if(o.nodeName==="ink-box"&&o.internal_scrollState){const v=we(o);if(v.length>0){const M=Me(o),C=o.internal_scrollState.clientHeight,S=M+C,N=mt(v,o,M,S);N.length>0&&yt(N,o,e,$(x=>new te(x),"createOutput"),{newTransformers:k,skipStaticElements:f,x:u,y:p})}}if(o.nodeName==="ink-box"&&o.internal_scrollState){const v=o.style.overflow??"visible",M=o.style.overflowX??v,C=o.style.overflowY??v,S=l.getComputedBorder(T.EDGE_LEFT),N=l.getComputedBorder(T.EDGE_RIGHT),x=l.getComputedBorder(T.EDGE_TOP),_=l.getComputedBorder(T.EDGE_BOTTOM),L=Math.round(l.getComputedWidth()-S-N),O=Math.round(l.getComputedHeight()-x-_),{clientHeight:R,clientWidth:U,scrollHeight:ie,scrollLeft:Le,scrollTop:Re,scrollWidth:ne}=o.internal_scrollState,se=C==="scroll"&&ie>R,_e=M==="scroll"&&ne>U,le=o.internal_scrollbar!==!1;if(se&&le){const G=ce({axis:"vertical",clientDimension:R,hasOppositeScrollbar:!1,height:O,marginBottom:0,marginRight:0,scrollDimension:ie,scrollPosition:Re,width:L,x:u+S,y:p+x});G&&Se({axis:"vertical",color:o.style.scrollbarThumbColor,layout:G,output:e})}if(_e&&le){const G=ce({axis:"horizontal",clientDimension:U,hasOppositeScrollbar:se,height:O,marginBottom:0,marginRight:0,scrollDimension:ne,scrollPosition:Le,width:L,x:u+S,y:p+x});G&&Se({axis:"horizontal",color:o.style.scrollbarThumbColor,layout:G,output:e})}}w&&e.endChildRegion()}}},"renderNodeToOutput"),zt=$((o,e)=>{if(!o.yogaNode)return;const t=Math.round(o.yogaNode.getComputedWidth()),r=Math.round(o.yogaNode.getComputedHeight());if(t<=0||r<=0)return;const{setCachedRender:n}=require("./dom"),s=new te({height:r,width:t});for(const d of o.childNodes)X(d,s,{skipStaticElements:e?.skipStaticElements??!1});const i={children:[],cursorPosition:void 0,height:r,id:o.internalId??"static",isScrollable:!1,lines:[...s.getRootLines()],selectableSpans:[],stickyHeaders:[],styledOutput:[...s.getRootLines()],width:t,x:0,y:0};n(o,i)},"renderToStatic");var kt=Object.defineProperty,K=D((o,e)=>kt(o,"name",{value:e,configurable:!0}),"N");const wt=K((o,e)=>{const t=new Map;if(e.rangeCount===0)return t;const r=e.getRangeAt(0),{endContainer:n,endOffset:s,startContainer:i,startOffset:d}=r;if(!i||!n)return t;let g=!1,f=!1;const c=K((a,h,u,p,b,m)=>{if(a.nodeName==="#text"){const{length:y}=a.nodeValue;i===a&&(b.value=!0,u.value=h.value+d),n===a&&(m.value=!0,p.value=h.value+s),h.value+=y}else if("childNodes"in a){for(const y of a.childNodes)a===i&&(b.value=!0,u.value=h.value),a===n&&(m.value=!0,p.value=h.value),c(y,h,u,p,b,m);a===i&&d===a.childNodes.length&&(b.value=!0,u.value=h.value),a===n&&s===a.childNodes.length&&(m.value=!0,p.value=h.value)}},"visitChildren"),l=K(a=>{if(a.nodeName==="ink-text"){if(!De(a))return;const h={value:0},u={value:-1},p={value:-1},b={value:!1},m={value:!1};for(const y of a.childNodes)a===i&&(b.value=!0,u.value=h.value),a===n&&(m.value=!0,p.value=h.value),c(y,h,u,p,b,m);if(a===i&&d===a.childNodes.length&&(b.value=!0,u.value=h.value),a===n&&s===a.childNodes.length&&(m.value=!0,p.value=h.value),(g||b.value)&&(!f||m.value)){const y=b.value?u.value:0,k=m.value?p.value:h.value;y!==-1&&k!==-1&&y<k&&t.set(a,{end:k,start:y})}b.value&&(g=!0),m.value&&(f=!0)}else{const{childNodes:h}=a;if(h){for(const u of h)a===i&&(g=!0),a===n&&(f=!0),l(u);a===i&&d===h.length&&(g=!0),a===n&&s===h.length&&(f=!0)}}},"visit");return l(o),t},"calculateSelectionMap"),Lt=new ee,Rt=new ee,_t=new WeakMap,Bt=new WeakMap,Ee=K(({caches:o,height:e,node:t,outputs:r,width:n})=>{let s=r.get(t);return s||(s=new te({caches:o,height:e,width:n}),r.set(t,s)),s.reset(n,e),s},"getReusableOutput"),Yt=K((o,e,t)=>{if(o.yogaNode){if(e){const f=Z(o,{skipStaticElements:!0}),c=f===""?0:f.split(`
|
|
14
|
-
`).length;let l="";return o.staticNode&&(l=Z(o.staticNode,{skipStaticElements:!1})),{cursorPosition:void 0,cursorRequested:!1,output:f,outputHeight:c,staticOutput:l?`${l}
|
|
15
|
-
`:""}}const r=t?.selection&&t.selection.rangeCount>0?wt(o,t.selection):void 0,n=Ee({caches:Lt,height:o.yogaNode.getComputedHeight(),node:o,outputs:_t,width:o.yogaNode.getComputedWidth()}),s={cursorPosition:void 0,cursorRequested:!1};X(o,n,{renderState:s,selectionMap:r,skipStaticElements:!0});let i;if(o.staticNode?.yogaNode&&(i=Ee({caches:Rt,height:o.staticNode.yogaNode.getComputedHeight(),node:o,outputs:Bt,width:o.staticNode.yogaNode.getComputedWidth()}),X(o.staticNode,i,{skipStaticElements:!1})),t?.useNativeRenderer){const{buffer:f,height:c}=n.getBuffer();return{cursorPosition:s.cursorPosition,cursorRequested:s.cursorRequested,output:"",outputBuffer:f,outputHeight:c,outputWidth:n.width,staticOutput:i?`${i.get().output}
|
|
16
|
-
`:""}}const{height:d,output:g}=n.get();return{cursorPosition:s.cursorPosition,cursorRequested:s.cursorRequested,output:g,outputHeight:d,staticOutput:i?`${i.get().output}
|
|
17
|
-
`:""}}return{cursorPosition:void 0,cursorRequested:!1,output:"",outputHeight:0,staticOutput:""}},"renderer");export{Yt as R,zt as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"@visulima/string";import{c as i,a as s,e as l,i as n,m as d,s as r,b as c,l as h,d as y,t as S}from"./measure-text-DDjHT1jD.js";export{i as clearStringWidthCache,s as clearStyledLineCache,l as default,n as inkCharacterWidth,d as measureStyledLine,r as setEnableStyledLineCache,c as setStringWidthFunction,h as splitStyledLineByNewline,y as styledLineWidth,S as toStyledLine};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty;var o=(t,e)=>m(t,"name",{value:e,configurable:!0});import{getStringWidth as c}from"@visulima/string";var p=Object.defineProperty,u=o((t,e)=>p(t,"name",{value:e,configurable:!0}),"i");const d={ambiguousIsNarrow:!0,emojiWidth:1};function g(t){return Math.max(1,c(t,d))}o(g,"getCodePointWidth");u(g,"getCodePointWidth");function f(t){return c(t,d)}o(f,"getStringWidth");u(f,"getStringWidth");function h(t,e){if(e<=0)return 0;if(t.length===0)return 1;let i=1,r=0;for(const a of t){const n=Math.min(g(a),e);r+n>e&&(i++,r=0),r+=n}return i}o(h,"countWrappedRowsForLine");u(h,"countWrappedRowsForLine");function W(t,e){const i=t.split(`
|
|
2
|
-
`);let r=0,a=0;for(const n of i){const s=f(n);s>r&&(r=s),a+=e>0?h(n,e):0}return{maxLineWidth:r,wrappedRows:a}}o(W,"measureTextBlock");u(W,"measureTextBlock");export{f as a,g,W as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=Object.defineProperty;var s=(r,o)=>t(r,"name",{value:o,configurable:!0});import c from"terminal-size";var u=Object.defineProperty,i=s((r,o)=>u(r,"name",{value:o,configurable:!0}),"s");const l=i(r=>{const{columns:o,rows:e}=r;if(o&&e)return{columns:o,rows:e};const n=c();return{columns:o||n.columns||80,rows:e||n.rows||24}},"getWindowSize");export{l as g};
|