@visulima/tui 1.0.0-alpha.21 → 1.0.0-alpha.23

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 CHANGED
@@ -1,3 +1,28 @@
1
+ ## @visulima/tui [1.0.0-alpha.23](https://github.com/visulima/visulima/compare/@visulima/tui@1.0.0-alpha.22...@visulima/tui@1.0.0-alpha.23) (2026-06-04)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/string:** upgraded to 3.0.0-alpha.16
7
+ * **@visulima/boxen:** upgraded to 3.0.0-alpha.13
8
+
9
+ ## @visulima/tui [1.0.0-alpha.22](https://github.com/visulima/visulima/compare/@visulima/tui@1.0.0-alpha.21...@visulima/tui@1.0.0-alpha.22) (2026-06-04)
10
+
11
+ ### Bug Fixes
12
+
13
+ * **tui:** 2 bug fixes + 2 perf ([53eb884](https://github.com/visulima/visulima/commit/53eb884de4609e6fb2c0ed8af7773673c0b83b2f))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * **@visulima/ansi:** upgraded to 4.0.0-alpha.16
19
+ * **@visulima/colorize:** upgraded to 2.0.0-alpha.13
20
+ * **@visulima/error:** upgraded to 6.0.0-alpha.32
21
+ * **@visulima/spinner:** upgraded to 1.0.0-alpha.3
22
+ * **@visulima/string:** upgraded to 3.0.0-alpha.15
23
+ * **@visulima/boxen:** upgraded to 3.0.0-alpha.12
24
+ * **@visulima/tabular:** upgraded to 4.0.0-alpha.13
25
+
1
26
  ## @visulima/tui [1.0.0-alpha.21](https://github.com/visulima/visulima/compare/@visulima/tui@1.0.0-alpha.20...@visulima/tui@1.0.0-alpha.21) (2026-06-02)
2
27
 
3
28
  ### Miscellaneous Chores
@@ -1 +1 @@
1
- var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:!0});import{useState as s,useCallback as m,useEffect as i,useMemo as g}from"react";import{a as N}from"../../packem_shared/dom-BG-LS10p.js";var v=Object.defineProperty,f=n((t,r)=>v(t,"name",{value:r,configurable:!0}),"n");const d={height:0,left:0,top:0,width:0},c=f(t=>{if(t)return t.parentNode?c(t.parentNode):t.nodeName==="ink-root"?t:void 0},"findRootNode"),w=f(t=>{const[r,h]=s(d),[a,l]=s(!1),u=m(()=>{const e=t.current?.yogaNode?.getComputedLayout()??d;h(o=>o.width!==e.width||o.height!==e.height||o.left!==e.left||o.top!==e.top?e:o),l(!!t.current)},[t]);return i(u),i(()=>{const e=c(t.current);if(e)return N(e,u)}),g(()=>({...r,hasMeasured:a}),[r,a])},"useBoxMetrics");export{w as default,w as useBoxMetrics};
1
+ var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:!0});import{useState as s,useCallback as m,useEffect as i,useMemo as g}from"react";import{a as N}from"../../packem_shared/dom-CXB-19sK.js";var v=Object.defineProperty,f=n((t,r)=>v(t,"name",{value:r,configurable:!0}),"n");const d={height:0,left:0,top:0,width:0},c=f(t=>{if(t)return t.parentNode?c(t.parentNode):t.nodeName==="ink-root"?t:void 0},"findRootNode"),w=f(t=>{const[r,h]=s(d),[a,l]=s(!1),u=m(()=>{const e=t.current?.yogaNode?.getComputedLayout()??d;h(o=>o.width!==e.width||o.height!==e.height||o.left!==e.left||o.top!==e.top?e:o),l(!!t.current)},[t]);return i(u),i(()=>{const e=c(t.current);if(e)return N(e,u)}),g(()=>({...r,hasMeasured:a}),[r,a])},"useBoxMetrics");export{w as default,w as useBoxMetrics};
@@ -1,2 +1,2 @@
1
- var K=Object.defineProperty;var m=(e,r)=>K(e,"name",{value:r,configurable:!0});import{createRequire as S}from"node:module";import{useRef as I,useEffectEvent as $,useEffect as w}from"react";import{IMECompositionBuffer as q,isIMEInput as j}from"../../packem_shared/IMECompositionBuffer-C89PhiOu.js";import{kittyModifiers as u}from"../../packem_shared/kittyFlags-C3rZLbcK.js";import{L as x}from"../../packem_shared/reconciler-CUbhOvcr.js";import{useStdinContext as N}from"./use-stdin.js";const _=S(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=m(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[r,s]=h.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return h.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{Buffer:M}=E("node:buffer");var T=Object.defineProperty,c=m((e,r)=>T(e,"name",{value:r,configurable:!0}),"i");const D=/^\u001B([a-z0-9])$/i,R=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,C={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},Z=[...Object.values(C),"backspace"],F=c(e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),"isShiftKey"),U=c(e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),"isCtrlKey"),P=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,z=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,H={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},Q={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},A={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},L=c(e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),"isValidCodepoint"),y=c(e=>L(e)?String.fromCodePoint(e):"?","safeFromCodePoint");function B(e){return e===3?"release":e===2?"repeat":"press"}m(B,"k");c(B,"resolveEventType");function O(e){return{capsLock:!!(e&u.capsLock),ctrl:!!(e&u.ctrl),hyper:!!(e&u.hyper),meta:!!(e&u.meta),numLock:!!(e&u.numLock),option:!!(e&u.alt),shift:!!(e&u.shift),super:!!(e&u.super)}}m(O,"h");c(O,"parseKittyModifiers");const V=c(e=>{const r=P.exec(e);if(!r)return null;const s=Number.parseInt(r[1],10),p=r[2]?Math.max(0,Number.parseInt(r[2],10)-1):0,t=r[3]?Number.parseInt(r[3],10):1,l=r[4];if(!L(s))return null;let n;l&&(n=l.split(":").map(k=>y(Number.parseInt(k,10))).join(""));let i,f;return s===32?(i="space",f=!0):s===13?(i="return",f=!0):A[s]?(i=A[s],f=!1):s>=1&&s<=26?(i=String.fromCodePoint(s+96),f=!1):(i=y(s).toLowerCase(),f=!0),f&&!n&&(n=y(s)),{name:i,...O(p),eventType:B(t),isKittyProtocol:!0,isPrintable:f,raw:e,sequence:e,text:n}},"parseKittyKeypress"),W=c(e=>{const r=z.exec(e);if(!r)return null;const s=Number.parseInt(r[1],10),p=Math.max(0,Number.parseInt(r[2],10)-1),t=Number.parseInt(r[3],10),l=r[4],n=l==="~"?Q[s]:H[l];return n?{name:n,...O(p),eventType:B(t),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},"parseKittySpecialKey"),G=c((e="")=>{let r;M.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const s=V(e);if(s)return s;const p=W(e);if(p)return p;if(P.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const t={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(t.sequence=t.sequence||e||t.name,e){case"\r":case"\x1B\r":{t.raw=void 0,t.name="return",t.option=e.length===2;break}case`
1
+ var K=Object.defineProperty;var m=(e,r)=>K(e,"name",{value:r,configurable:!0});import{createRequire as S}from"node:module";import{useRef as I,useEffectEvent as $,useEffect as w}from"react";import{IMECompositionBuffer as q,isIMEInput as j}from"../../packem_shared/IMECompositionBuffer-C89PhiOu.js";import{kittyModifiers as u}from"../../packem_shared/kittyFlags-C3rZLbcK.js";import{L as x}from"../../packem_shared/reconciler-DYE5h4K4.js";import{useStdinContext as N}from"./use-stdin.js";const _=S(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=m(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[r,s]=h.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return h.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{Buffer:M}=E("node:buffer");var T=Object.defineProperty,c=m((e,r)=>T(e,"name",{value:r,configurable:!0}),"i");const D=/^\u001B([a-z0-9])$/i,R=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,C={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},Z=[...Object.values(C),"backspace"],F=c(e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),"isShiftKey"),U=c(e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),"isCtrlKey"),P=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,z=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,H={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},Q={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},A={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},L=c(e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),"isValidCodepoint"),y=c(e=>L(e)?String.fromCodePoint(e):"?","safeFromCodePoint");function B(e){return e===3?"release":e===2?"repeat":"press"}m(B,"k");c(B,"resolveEventType");function O(e){return{capsLock:!!(e&u.capsLock),ctrl:!!(e&u.ctrl),hyper:!!(e&u.hyper),meta:!!(e&u.meta),numLock:!!(e&u.numLock),option:!!(e&u.alt),shift:!!(e&u.shift),super:!!(e&u.super)}}m(O,"h");c(O,"parseKittyModifiers");const V=c(e=>{const r=P.exec(e);if(!r)return null;const s=Number.parseInt(r[1],10),p=r[2]?Math.max(0,Number.parseInt(r[2],10)-1):0,t=r[3]?Number.parseInt(r[3],10):1,l=r[4];if(!L(s))return null;let n;l&&(n=l.split(":").map(k=>y(Number.parseInt(k,10))).join(""));let i,f;return s===32?(i="space",f=!0):s===13?(i="return",f=!0):A[s]?(i=A[s],f=!1):s>=1&&s<=26?(i=String.fromCodePoint(s+96),f=!1):(i=y(s).toLowerCase(),f=!0),f&&!n&&(n=y(s)),{name:i,...O(p),eventType:B(t),isKittyProtocol:!0,isPrintable:f,raw:e,sequence:e,text:n}},"parseKittyKeypress"),W=c(e=>{const r=z.exec(e);if(!r)return null;const s=Number.parseInt(r[1],10),p=Math.max(0,Number.parseInt(r[2],10)-1),t=Number.parseInt(r[3],10),l=r[4],n=l==="~"?Q[s]:H[l];return n?{name:n,...O(p),eventType:B(t),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},"parseKittySpecialKey"),G=c((e="")=>{let r;M.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const s=V(e);if(s)return s;const p=W(e);if(p)return p;if(P.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const t={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(t.sequence=t.sequence||e||t.name,e){case"\r":case"\x1B\r":{t.raw=void 0,t.name="return",t.option=e.length===2;break}case`
2
2
  `:{t.name="enter";break}case" ":{t.name="tab";break}case" ":case"\x1B ":{t.name="space",t.meta=e.length===2;break}case"\b":case"\x1B\b":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{t.name="escape",t.meta=e.length===2;break}case"\x1B":case"":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")t.name=String.fromCharCode(e.charCodeAt(0)+97-1),t.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")t.name="number";else if(e.length===1&&e>="a"&&e<="z")t.name=e;else if(e.length===1&&e>="A"&&e<="Z")t.name=e.toLowerCase(),t.shift=!0;else if(r=D.exec(e))t.meta=!0,t.shift=/^[A-Z]$/.test(r[1]);else if(r=R.exec(e)){const l=[...e];l[0]==="\x1B"&&l[1]==="\x1B"&&(t.option=!0);const n=[r[1],r[2],r[4],r[6]].filter(Boolean).join(""),i=(r[3]||r[5]||1)-1;t.ctrl=!!(i&4),t.meta=!!(i&10),t.shift=!!(i&1),t.code=n,t.name=C[n]??"",t.shift=F(n)||t.shift,t.ctrl=U(n)||t.ctrl}}return t},"parseKeypress");var J=Object.defineProperty,v=m((e,r)=>J(e,"name",{value:r,configurable:!0}),"l");const ne=v((e,r={})=>{const{internal_eventEmitter:s,internal_exitOnCtrlC:p,setRawMode:t,stdin:l}=N(),n=r.imeEnabled??!0,i=r.imeTimeout??50,f=I(void 0),k=$(e);w(()=>{if(n)return f.current=new q({onFlush:v(g=>{const d={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};x.discreteUpdates(()=>{k(g,d)})},"onFlush"),timeout:i}),()=>{f.current?.destroy(),f.current=void 0}},[n,i]),w(()=>{if(r.isActive!==!1)return t(!0),()=>{t(!1)}},[r.isActive,t]),w(()=>{if(r.isActive===!1)return;const g=v(d=>{if(n&&j(d)){f.current?.add(d);return}f.current?.flush();const a=G(d),b={backspace:a.name==="backspace",capsLock:a.capsLock??!1,ctrl:a.ctrl,delete:a.name==="delete",downArrow:a.name==="down",end:a.name==="end",escape:a.name==="escape",eventType:a.eventType,home:a.name==="home",hyper:a.hyper??!1,leftArrow:a.name==="left",meta:a.meta||a.option,numLock:a.numLock??!1,pageDown:a.name==="pagedown",pageUp:a.name==="pageup",return:a.name==="return",rightArrow:a.name==="right",shift:a.shift,super:a.super??!1,tab:a.name==="tab",upArrow:a.name==="up"};let o;a.isKittyProtocol?a.isPrintable?o=a.text??a.name:a.ctrl&&a.name.length===1?o=a.name:o="":a.ctrl?o=a.name:o=a.sequence,!a.isKittyProtocol&&Z.includes(a.name)&&(o=""),o.startsWith("\x1B")&&(o=o.slice(1)),o.length===1&&typeof o[0]=="string"&&/[A-Z]/.test(o[0])&&(b.shift=!0),!(o==="c"&&b.ctrl&&p)&&(!a.name&&o===""||x.discreteUpdates(()=>{k(o,b)}))},"handleData");return s.on("input",g),()=>{s.removeListener("input",g)}},[r.isActive,l,p,n])},"useInput");export{ne as default,ne as useInput};
@@ -1 +1 @@
1
- var l=Object.defineProperty;var n=(t,e)=>l(t,"name",{value:e,configurable:!0});import{useEffectEvent as v,useEffect as f}from"react";import{L as d}from"../../packem_shared/reconciler-CUbhOvcr.js";import{useStdinContext as m}from"./use-stdin.js";var p=Object.defineProperty,o=n((t,e)=>p(t,"name",{value:e,configurable:!0}),"n");const x=o((t,e={})=>{const{internal_eventEmitter:s,setBracketedPasteMode:r,setRawMode:a}=m(),c=v(t);f(()=>{if(e.isActive!==!1)return a(!0),r(!0),()=>{a(!1),r(!1)}},[e.isActive,a,r]),f(()=>{if(e.isActive===!1)return;const i=o(u=>{d.discreteUpdates(()=>{c(u)})},"handlePaste");return s.on("paste",i),()=>{s.removeListener("paste",i)}},[e.isActive,s])},"usePaste");export{x as default,x as usePaste};
1
+ var l=Object.defineProperty;var n=(t,e)=>l(t,"name",{value:e,configurable:!0});import{useEffectEvent as v,useEffect as f}from"react";import{L as d}from"../../packem_shared/reconciler-DYE5h4K4.js";import{useStdinContext as m}from"./use-stdin.js";var p=Object.defineProperty,o=n((t,e)=>p(t,"name",{value:e,configurable:!0}),"n");const x=o((t,e={})=>{const{internal_eventEmitter:s,setBracketedPasteMode:r,setRawMode:a}=m(),c=v(t);f(()=>{if(e.isActive!==!1)return a(!0),r(!0),()=>{a(!1),r(!1)}},[e.isActive,a,r]),f(()=>{if(e.isActive===!1)return;const i=o(u=>{d.discreteUpdates(()=>{c(u)})},"handlePaste");return s.on("paste",i),()=>{s.removeListener("paste",i)}},[e.isActive,s])},"usePaste");export{x as default,x as usePaste};
@@ -1 +1 @@
1
- var v=Object.defineProperty;var m=(n,o)=>v(n,"name",{value:o,configurable:!0});import{useRef as d,useState as x,useEffect as R,useCallback as p,useMemo as y}from"react";import{Selection as A,Range as C}from"../../packem_shared/comparePoints-YxQfR_zq.js";import b from"./use-clipboard.js";var h=Object.defineProperty,T=m((n,o)=>h(n,"name",{value:o,configurable:!0}),"f");const E=T((n,o={})=>{const{copyOnSelect:c=!1,isActive:r=!0,onSelectionChange:s}=o,{copy:l}=b(),e=d(new A).current,[a,S]=x(""),u=d(s);u.current=s,R(()=>r?e.onChange(()=>{const t=e.toString();S(t),u.current?.(t),c&&t.length>0&&l(t)}):void 0,[r,e,c,l]);const i=p(()=>{const t=n.current;if(!t||!r)return;e.removeAllRanges();const g=new C;g.selectNodeContents(t),e.addRange(g)},[n,r,e]),f=p(()=>{e.removeAllRanges()},[e]);return y(()=>({clearSelection:f,selectAll:i,selectedText:a,selection:e}),[f,a,i,e])},"useTextSelection");export{E as default,E as useTextSelection};
1
+ var v=Object.defineProperty;var m=(n,o)=>v(n,"name",{value:o,configurable:!0});import{useRef as d,useState as x,useEffect as R,useCallback as p,useMemo as y}from"react";import{Selection as A,Range as C}from"../../packem_shared/comparePoints-C3NJirbh.js";import b from"./use-clipboard.js";var h=Object.defineProperty,T=m((n,o)=>h(n,"name",{value:o,configurable:!0}),"f");const E=T((n,o={})=>{const{copyOnSelect:c=!1,isActive:r=!0,onSelectionChange:s}=o,{copy:l}=b(),e=d(new A).current,[a,S]=x(""),u=d(s);u.current=s,R(()=>r?e.onChange(()=>{const t=e.toString();S(t),u.current?.(t),c&&t.length>0&&l(t)}):void 0,[r,e,c,l]);const i=p(()=>{const t=n.current;if(!t||!r)return;e.removeAllRanges();const g=new C;g.selectNodeContents(t),e.addRange(g)},[n,r,e]),f=p(()=>{e.removeAllRanges()},[e]);return y(()=>({clearSelection:f,selectAll:i,selectedText:a,selection:e}),[f,a,i,e])},"useTextSelection");export{E as default,E as useTextSelection};
package/dist/ink/index.js CHANGED
@@ -1 +1 @@
1
- import{clearOsc52 as o,isOsc52Supported as r,writeOsc52 as a}from"../packem_shared/isOsc52Supported-DKK7Uee6.js";import{COLOR_BLINDNESS_COMPENSATION as l,COLOR_BLINDNESS_SIMULATION as i,IDENTITY_MATRIX as n,applyColorMatrix as u,hexToRgb as f,rgbToHex as p,transformHexColor as c}from"../packem_shared/COLOR_BLINDNESS_SIMULATION-DqErf7XX.js";import{g as d,i as x}from"../packem_shared/dom-BG-LS10p.js";import{IMECompositionBuffer as S,isIMEInput as h}from"../packem_shared/IMECompositionBuffer-C89PhiOu.js";import{kittyFlags as M,kittyModifiers as O}from"../packem_shared/kittyFlags-C3rZLbcK.js";import{c as I,a as L,b,g as C,d as E,e as N,f as R,h as B,i as P,j as H,k as v,l as W,P as k,p as A}from"../packem_shared/layout-BMo200nF.js";import{c as D,a as F,i as z,s as q,b as w,t as j}from"../packem_shared/measure-text-DDjHT1jD.js";import{default as U}from"../packem_shared/render-BFio00DS.js";import{default as X}from"../packem_shared/renderToString-SDrrFvu8.js";import{default as G,ResizeObserverEntry as J}from"../packem_shared/ResizeObserverEntry-Dq0dk8Kq.js";import{calculateScroll as Z,getScrollHeight as $,getScrollLeft as ee,getScrollTop as te,getScrollWidth as oe}from"../packem_shared/getScrollHeight-ClEOyLHH.js";import{Range as ae,Selection as se,applySelectionToStyledLine as le,comparePoints as ie}from"../packem_shared/comparePoints-YxQfR_zq.js";import{squashTextNodesWithMap as ue}from"../packem_shared/squashTextNodesWithMap-DCdi3SZ2.js";import{isTerminalPaletteQuerySupported as pe,queryTerminalPalette as ce}from"../packem_shared/isTerminalPaletteQuerySupported-Dn2hFAZ_.js";import{wrapOrTruncateStyledLine as de}from"../packem_shared/wrapOrTruncateStyledLine-BZ00SM8i.js";import{default as ge}from"../packem_shared/Fullscreen-CxLd1-Zu.js";import{default as he}from"../packem_shared/MouseProvider-PnIUKURs.js";import{default as Me}from"../packem_shared/isIntersecting-B3KbKTmu.js";import{default as ye}from"../packem_shared/useMouseAction-2dRfU1vE.js";import{default as Le}from"../packem_shared/useMouseContext-C746G7kY.js";import{default as Ce}from"../packem_shared/useMousePosition-BTWfV4JK.js";import{default as Ne}from"../packem_shared/useOnMouseHover-D3DczIol.js";import{default as Be}from"../packem_shared/useOnMouseState-cRK8QvzD.js";import{a as He}from"../packem_shared/ansi-parser-B6uXaq65.js";import{useElementDimensions as We,useElementPosition as ke}from"../packem_shared/useElementDimensions-qJ_WXFZ9.js";import{useOnMouseClick as _e}from"../packem_shared/useOnMouseClick-nY8xLZmt.js";export{l as COLOR_BLINDNESS_COMPENSATION,i as COLOR_BLINDNESS_SIMULATION,ge as Fullscreen,n as IDENTITY_MATRIX,S as IMECompositionBuffer,he as MouseProvider,ae as Range,G as ResizeObserver,J as ResizeObserverEntry,se as Selection,u as applyColorMatrix,le as applySelectionToStyledLine,Z as calculateScroll,I as calculateScrollbarLayout,L as calculateScrollbarThumb,o as clearOsc52,D as clearStringWidthCache,F as clearStyledLineCache,b as collectSortedFragments,ie as comparePoints,C as getAddedScrollHeight,E as getBoundingBox,N as getHorizontalScrollbarBoundingBox,R as getInnerHeight,B as getInnerWidth,d as getPathToRoot,P as getRelativeLeft,H as getRelativeTop,$ as getScrollHeight,ee as getScrollLeft,te as getScrollTop,oe as getScrollWidth,v as getText,W as getVerticalScrollbarBoundingBox,f as hexToRgb,z as inkCharacterWidth,h as isIMEInput,Me as isIntersecting,x as isNodeSelectable,r as isOsc52Supported,pe as isTerminalPaletteQuerySupported,M as kittyFlags,O as kittyModifiers,k as measureElement,He as parseSgrMouse,A as processLayout,ce as queryTerminalPalette,U as render,X as renderToString,p as rgbToHex,q as setEnableStyledLineCache,w as setStringWidthFunction,ue as squashTextNodesWithMap,j as toStyledLine,c as transformHexColor,We as useElementDimensions,ke as useElementPosition,ye as useMouseAction,Le as useMouseContext,Ce as useMousePosition,_e as useOnMouseClick,Ne as useOnMouseHover,Be as useOnMouseState,de as wrapOrTruncateStyledLine,a as writeOsc52};
1
+ import{clearOsc52 as o,isOsc52Supported as r,writeOsc52 as a}from"../packem_shared/isOsc52Supported-DKK7Uee6.js";import{COLOR_BLINDNESS_COMPENSATION as l,COLOR_BLINDNESS_SIMULATION as i,IDENTITY_MATRIX as n,applyColorMatrix as u,hexToRgb as f,rgbToHex as p,transformHexColor as c}from"../packem_shared/COLOR_BLINDNESS_SIMULATION-DqErf7XX.js";import{g as d,i as x}from"../packem_shared/dom-CXB-19sK.js";import{IMECompositionBuffer as S,isIMEInput as h}from"../packem_shared/IMECompositionBuffer-C89PhiOu.js";import{kittyFlags as M,kittyModifiers as O}from"../packem_shared/kittyFlags-C3rZLbcK.js";import{c as I,a as L,b,g as C,d as E,e as N,f as R,h as B,i as P,j as H,k as v,l as W,P as k,p as A}from"../packem_shared/layout-BMo200nF.js";import{c as D,a as F,i as z,s as q,b as w,t as j}from"../packem_shared/measure-text-Ce2widM1.js";import{default as U}from"../packem_shared/render-BRR1ESvR.js";import{default as X}from"../packem_shared/renderToString-vEQyGmv6.js";import{default as G,ResizeObserverEntry as J}from"../packem_shared/ResizeObserverEntry-Dq0dk8Kq.js";import{calculateScroll as Z,getScrollHeight as $,getScrollLeft as ee,getScrollTop as te,getScrollWidth as oe}from"../packem_shared/getScrollHeight-ClEOyLHH.js";import{Range as ae,Selection as se,applySelectionToStyledLine as le,comparePoints as ie}from"../packem_shared/comparePoints-C3NJirbh.js";import{squashTextNodesWithMap as ue}from"../packem_shared/squashTextNodesWithMap-DCdi3SZ2.js";import{isTerminalPaletteQuerySupported as pe,queryTerminalPalette as ce}from"../packem_shared/isTerminalPaletteQuerySupported-Dn2hFAZ_.js";import{wrapOrTruncateStyledLine as de}from"../packem_shared/wrapOrTruncateStyledLine-C5rcIrNb.js";import{default as ge}from"../packem_shared/Fullscreen-CxLd1-Zu.js";import{default as he}from"../packem_shared/MouseProvider-PnIUKURs.js";import{default as Me}from"../packem_shared/isIntersecting-B3KbKTmu.js";import{default as ye}from"../packem_shared/useMouseAction-2dRfU1vE.js";import{default as Le}from"../packem_shared/useMouseContext-C746G7kY.js";import{default as Ce}from"../packem_shared/useMousePosition-BTWfV4JK.js";import{default as Ne}from"../packem_shared/useOnMouseHover-D3DczIol.js";import{default as Be}from"../packem_shared/useOnMouseState-cRK8QvzD.js";import{a as He}from"../packem_shared/ansi-parser-B6uXaq65.js";import{useElementDimensions as We,useElementPosition as ke}from"../packem_shared/useElementDimensions-qJ_WXFZ9.js";import{useOnMouseClick as _e}from"../packem_shared/useOnMouseClick-nY8xLZmt.js";export{l as COLOR_BLINDNESS_COMPENSATION,i as COLOR_BLINDNESS_SIMULATION,ge as Fullscreen,n as IDENTITY_MATRIX,S as IMECompositionBuffer,he as MouseProvider,ae as Range,G as ResizeObserver,J as ResizeObserverEntry,se as Selection,u as applyColorMatrix,le as applySelectionToStyledLine,Z as calculateScroll,I as calculateScrollbarLayout,L as calculateScrollbarThumb,o as clearOsc52,D as clearStringWidthCache,F as clearStyledLineCache,b as collectSortedFragments,ie as comparePoints,C as getAddedScrollHeight,E as getBoundingBox,N as getHorizontalScrollbarBoundingBox,R as getInnerHeight,B as getInnerWidth,d as getPathToRoot,P as getRelativeLeft,H as getRelativeTop,$ as getScrollHeight,ee as getScrollLeft,te as getScrollTop,oe as getScrollWidth,v as getText,W as getVerticalScrollbarBoundingBox,f as hexToRgb,z as inkCharacterWidth,h as isIMEInput,Me as isIntersecting,x as isNodeSelectable,r as isOsc52Supported,pe as isTerminalPaletteQuerySupported,M as kittyFlags,O as kittyModifiers,k as measureElement,He as parseSgrMouse,A as processLayout,ce as queryTerminalPalette,U as render,X as renderToString,p as rgbToHex,q as setEnableStyledLineCache,w as setStringWidthFunction,ue as squashTextNodesWithMap,j as toStyledLine,c as transformHexColor,We as useElementDimensions,ke as useElementPosition,ye as useMouseAction,Le as useMouseContext,Ce as useMousePosition,_e as useOnMouseClick,Ne as useOnMouseHover,Be as useOnMouseState,de as wrapOrTruncateStyledLine,a as writeOsc52};
@@ -1 +1 @@
1
- var N=Object.defineProperty;var g=(n,t)=>N(n,"name",{value:t,configurable:!0});import{g as m}from"./dom-BG-LS10p.js";import{t as O}from"./measure-text-DDjHT1jD.js";import{squashTextNodesWithMap as S}from"./squashTextNodesWithMap-DCdi3SZ2.js";var v=Object.defineProperty,l=g((n,t)=>v(n,"name",{value:t,configurable:!0}),"f");const x=l(n=>{if(n.nodeName==="#text"){const r=O(n.nodeValue);return{charOffsetMap:new Map([[n,{end:r.length,start:0}]]),styledLine:r}}const t=new Map,e=S(n,t,{current:0}),s=O(e);return t.set(n,{end:s.length,start:0}),{charOffsetMap:t,styledLine:s}},"getPlainTextFromDomNode"),y=l((n,t)=>{if(!n.startContainer||!n.endContainer)return;const e=l((i,h)=>{const o=t.get(i);if(!o)return;if(i.nodeName==="#text")return o.start+h;const d=i;if(h>=d.childNodes.length)return o.end;const a=d.childNodes[h],u=t.get(a);if(u)return u.start;for(let f=h-1;f>=0;f--){const c=d.childNodes[f],C=t.get(c);if(C)return C.end}return o.start},"getOffset"),s=e(n.startContainer,n.startOffset),r=e(n.endContainer,n.endOffset);if(!(s===void 0||r===void 0))return{end:r,start:s}},"getRangeCharacterOffsets"),p=l((n,t,e,s)=>{if(n===e)return t===s?0:t<s?-1:1;const r=m(n),i=m(e);let h,o=0;for(;o<r.length&&o<i.length&&r[o]===i[o];)h=r[o],o++;if(!h)return 0;if(o===r.length){const c=i[o],C=n.childNodes.indexOf(c);return t<=C?-1:1}if(o===i.length){const c=r[o];return e.childNodes.indexOf(c)<s?-1:1}const d=r[o],a=i[o],u=h.childNodes.indexOf(d),f=h.childNodes.indexOf(a);return u<f?-1:1},"comparePoints");class A{static{g(this,"Range")}static{l(this,"Range")}startContainer=void 0;startOffset=0;endContainer=void 0;endOffset=0;collapsed=!0;commonAncestorContainer=void 0;setStart(t,e){this.startContainer=t,this.startOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}setEnd(t,e){this.endContainer=t,this.endOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}collapse(t){t?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,this.startOffset=this.endOffset),this.collapsed=!0,this.updateCommonAncestor()}selectNode(t){if(!t.parentNode)throw new Error("Node has no parent");const e=t.parentNode.childNodes.indexOf(t);this.setStart(t.parentNode,e),this.setEnd(t.parentNode,e+1)}selectNodeContents(t){this.setStart(t,0),t.nodeName==="#text"?this.setEnd(t,t.nodeValue.length):this.setEnd(t,t.childNodes.length)}toString(){if(this.collapsed||!this.startContainer||!this.endContainer||!this.commonAncestorContainer)return"";const{charOffsetMap:t,styledLine:e}=x(this.commonAncestorContainer),s=y(this,t);if(!s)return"";const r=e.slice(s.start,s.end);return r.getTextRange(0,r.length)}updateCollapsed(){this.collapsed=this.startContainer===this.endContainer&&this.startOffset===this.endOffset}updateCommonAncestor(){if(!this.startContainer||!this.endContainer){this.commonAncestorContainer=void 0;return}if(this.startContainer===this.endContainer){this.commonAncestorContainer=this.startContainer;return}const t=m(this.startContainer),e=m(this.endContainer);let s;for(let r=0;r<Math.min(t.length,e.length)&&t[r]===e[r];r++)s=t[r];this.commonAncestorContainer=s}}class L{static{g(this,"Selection")}static{l(this,"Selection")}anchorNode=void 0;anchorOffset=0;focusNode=void 0;focusOffset=0;isCollapsed=!0;rangeCount=0;ranges=[];listeners=new Set;onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}toString(){return this.ranges.map(t=>t.toString()).join("")}getRangeAt(t){return this.ranges[t]}addRange(t){this.ranges.includes(t)||(this.ranges.push(t),this.rangeCount=this.ranges.length,this.rangeCount===1&&(this.anchorNode=t.startContainer,this.anchorOffset=t.startOffset,this.focusNode=t.endContainer,this.focusOffset=t.endOffset,this.isCollapsed=t.collapsed),this.notifyChange())}removeRange(t){const e=this.ranges.indexOf(t);e!==-1&&(this.ranges.splice(e,1),this.rangeCount=this.ranges.length,this.rangeCount===0&&this.clearState(),this.notifyChange())}removeAllRanges(){this.ranges=[],this.rangeCount=0,this.clearState(),this.notifyChange()}collapse(t,e){this.removeAllRanges();const s=new A;s.setStart(t,e),s.setEnd(t,e),this.addRange(s)}containsNode(t,e=!1){if(!t.parentNode)return!1;const s=t.parentNode,r=s.childNodes.indexOf(t),i=s,h=r,o=s,d=r+1;return this.ranges.some(a=>{if(!a.startContainer||!a.endContainer)return!1;const u=p(a.startContainer,a.startOffset,i,h),f=p(a.endContainer,a.endOffset,o,d);if(e){const c=p(a.startContainer,a.startOffset,o,d),C=p(a.endContainer,a.endOffset,i,h);return c<0&&C>0}return u<=0&&f>=0})}clearState(){this.anchorNode=void 0,this.anchorOffset=0,this.focusNode=void 0,this.focusOffset=0,this.isCollapsed=!0}notifyChange(){for(const t of this.listeners)t()}}const T=l((n,t)=>{if(n.length===0||t.start>=t.end)return n;const e=n.clone(),s=Math.max(0,t.start),r=Math.min(n.length,t.end);for(let i=s;i<r;i++)e.setInverted(i,!0);return e},"applySelectionToStyledLine");export{A as Range,L as Selection,T as applySelectionToStyledLine,p as comparePoints};
1
+ var N=Object.defineProperty;var g=(n,t)=>N(n,"name",{value:t,configurable:!0});import{g as m}from"./dom-CXB-19sK.js";import{t as O}from"./measure-text-Ce2widM1.js";import{squashTextNodesWithMap as S}from"./squashTextNodesWithMap-DCdi3SZ2.js";var v=Object.defineProperty,l=g((n,t)=>v(n,"name",{value:t,configurable:!0}),"f");const x=l(n=>{if(n.nodeName==="#text"){const r=O(n.nodeValue);return{charOffsetMap:new Map([[n,{end:r.length,start:0}]]),styledLine:r}}const t=new Map,e=S(n,t,{current:0}),s=O(e);return t.set(n,{end:s.length,start:0}),{charOffsetMap:t,styledLine:s}},"getPlainTextFromDomNode"),y=l((n,t)=>{if(!n.startContainer||!n.endContainer)return;const e=l((i,h)=>{const o=t.get(i);if(!o)return;if(i.nodeName==="#text")return o.start+h;const d=i;if(h>=d.childNodes.length)return o.end;const a=d.childNodes[h],u=t.get(a);if(u)return u.start;for(let f=h-1;f>=0;f--){const c=d.childNodes[f],C=t.get(c);if(C)return C.end}return o.start},"getOffset"),s=e(n.startContainer,n.startOffset),r=e(n.endContainer,n.endOffset);if(!(s===void 0||r===void 0))return{end:r,start:s}},"getRangeCharacterOffsets"),p=l((n,t,e,s)=>{if(n===e)return t===s?0:t<s?-1:1;const r=m(n),i=m(e);let h,o=0;for(;o<r.length&&o<i.length&&r[o]===i[o];)h=r[o],o++;if(!h)return 0;if(o===r.length){const c=i[o],C=n.childNodes.indexOf(c);return t<=C?-1:1}if(o===i.length){const c=r[o];return e.childNodes.indexOf(c)<s?-1:1}const d=r[o],a=i[o],u=h.childNodes.indexOf(d),f=h.childNodes.indexOf(a);return u<f?-1:1},"comparePoints");class A{static{g(this,"Range")}static{l(this,"Range")}startContainer=void 0;startOffset=0;endContainer=void 0;endOffset=0;collapsed=!0;commonAncestorContainer=void 0;setStart(t,e){this.startContainer=t,this.startOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}setEnd(t,e){this.endContainer=t,this.endOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}collapse(t){t?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,this.startOffset=this.endOffset),this.collapsed=!0,this.updateCommonAncestor()}selectNode(t){if(!t.parentNode)throw new Error("Node has no parent");const e=t.parentNode.childNodes.indexOf(t);this.setStart(t.parentNode,e),this.setEnd(t.parentNode,e+1)}selectNodeContents(t){this.setStart(t,0),t.nodeName==="#text"?this.setEnd(t,t.nodeValue.length):this.setEnd(t,t.childNodes.length)}toString(){if(this.collapsed||!this.startContainer||!this.endContainer||!this.commonAncestorContainer)return"";const{charOffsetMap:t,styledLine:e}=x(this.commonAncestorContainer),s=y(this,t);if(!s)return"";const r=e.slice(s.start,s.end);return r.getTextRange(0,r.length)}updateCollapsed(){this.collapsed=this.startContainer===this.endContainer&&this.startOffset===this.endOffset}updateCommonAncestor(){if(!this.startContainer||!this.endContainer){this.commonAncestorContainer=void 0;return}if(this.startContainer===this.endContainer){this.commonAncestorContainer=this.startContainer;return}const t=m(this.startContainer),e=m(this.endContainer);let s;for(let r=0;r<Math.min(t.length,e.length)&&t[r]===e[r];r++)s=t[r];this.commonAncestorContainer=s}}class L{static{g(this,"Selection")}static{l(this,"Selection")}anchorNode=void 0;anchorOffset=0;focusNode=void 0;focusOffset=0;isCollapsed=!0;rangeCount=0;ranges=[];listeners=new Set;onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}toString(){return this.ranges.map(t=>t.toString()).join("")}getRangeAt(t){return this.ranges[t]}addRange(t){this.ranges.includes(t)||(this.ranges.push(t),this.rangeCount=this.ranges.length,this.rangeCount===1&&(this.anchorNode=t.startContainer,this.anchorOffset=t.startOffset,this.focusNode=t.endContainer,this.focusOffset=t.endOffset,this.isCollapsed=t.collapsed),this.notifyChange())}removeRange(t){const e=this.ranges.indexOf(t);e!==-1&&(this.ranges.splice(e,1),this.rangeCount=this.ranges.length,this.rangeCount===0&&this.clearState(),this.notifyChange())}removeAllRanges(){this.ranges=[],this.rangeCount=0,this.clearState(),this.notifyChange()}collapse(t,e){this.removeAllRanges();const s=new A;s.setStart(t,e),s.setEnd(t,e),this.addRange(s)}containsNode(t,e=!1){if(!t.parentNode)return!1;const s=t.parentNode,r=s.childNodes.indexOf(t),i=s,h=r,o=s,d=r+1;return this.ranges.some(a=>{if(!a.startContainer||!a.endContainer)return!1;const u=p(a.startContainer,a.startOffset,i,h),f=p(a.endContainer,a.endOffset,o,d);if(e){const c=p(a.startContainer,a.startOffset,o,d),C=p(a.endContainer,a.endOffset,i,h);return c<0&&C>0}return u<=0&&f>=0})}clearState(){this.anchorNode=void 0,this.anchorOffset=0,this.focusNode=void 0,this.focusOffset=0,this.isCollapsed=!0}notifyChange(){for(const t of this.listeners)t()}}const T=l((n,t)=>{if(n.length===0||t.start>=t.end)return n;const e=n.clone(),s=Math.max(0,t.start),r=Math.min(n.length,t.end);for(let i=s;i<r;i++)e.setInverted(i,!0);return e},"applySelectionToStyledLine");export{A as Range,L as Selection,T as applySelectionToStyledLine,p as comparePoints};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var s=(e,t)=>f(e,"name",{value:t,configurable:!0});import p from"yoga-layout";import{e as c}from"./measure-text-DDjHT1jD.js";import m from"./squashTextNodesWithMap-DCdi3SZ2.js";import{wordWrap as C,truncate as v}from"@visulima/string";var x=Object.defineProperty,R=s((e,t)=>x(e,"name",{value:t,configurable:!0}),"R");const u={},T={hard:"STRICT_WIDTH",wrap:"BREAK_WORDS","wrap-anywhere":"BREAK_AT_CHARACTERS","wrap-preserve-words":"PRESERVE_WORDS","wrap-strict":"STRICT_WIDTH"},k=R((e,t,o)=>{const r=e+String(t)+String(o),n=u[r];if(n)return n;let d=e;const N=T[o];if(N)d=C(e,{trim:!1,width:t,wrapMode:N}).replace(/\n$/,"");else if(o.startsWith("truncate")){let i="end";o==="truncate-middle"&&(i="middle"),o==="truncate-start"&&(i="start"),d=v(e,t,{position:i})}return u[r]=d,d},"wrapText");var S=Object.defineProperty,a=s((e,t)=>S(e,"name",{value:t,configurable:!0}),"n");let b=0;const P=a(e=>{const t={attributes:{},childNodes:[],internal_accessibility:{},internal_id:b++,nodeName:e,parentNode:void 0,style:{},yogaNode:e==="ink-virtual-text"||e==="ink-cursor"?void 0:p.Node.create()};return e==="ink-text"&&t.yogaNode?.setMeasureFunc(_.bind(null,t)),t},"createNode"),l=a(e=>{g(e.nodeName==="ink-static-render"&&e.cachedRender?e.parentNode:e)},"markNodeAndParentIfStaticAsDirty"),O=a((e,t)=>{t.parentNode&&y(t.parentNode,t),t.parentNode=e,e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount()),l(e)},"appendChildNode"),V=a((e,t,o)=>{t.parentNode&&y(t.parentNode,t),t.parentNode=e;const r=e.childNodes.indexOf(o);if(r===-1)e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount());else if(e.childNodes.splice(r,0,t),t.yogaNode){const n=e.childNodes.slice(0,r).filter(d=>!!d.yogaNode).length;e.yogaNode?.insertChild(t.yogaNode,n)}l(e)},"insertBeforeNode"),y=a((e,t)=>{if(t.yogaNode){const r=t.yogaNode.getParent();r&&r.removeChild(t.yogaNode)}t.parentNode=void 0;const o=e.childNodes.indexOf(t);o!==-1&&e.childNodes.splice(o,1),l(e)},"removeChildNode"),I=a((e,t,o)=>{if(t==="internal_accessibility"){e.internal_accessibility=o;return}e.attributes[t]=o},"setAttribute"),B=a((e,t)=>{e.style=t??{}},"setStyle"),H=a(e=>{const t={nodeName:"#text",nodeValue:e,parentNode:void 0,style:{},yogaNode:void 0};return w(t,e),t},"createTextNode"),_=a(function(e,t){const o=e.nodeName==="#text"?e.nodeValue:m(e),r=c(o);if(r.width<=t||r.width>=1&&t>0&&t<1)return r;const n=e.style?.textWrap??"wrap",d=k(o,Math.floor(t),n);return c(d)},"measureTextNode"),h=a(e=>{if(e?.parentNode)return e.yogaNode??h(e.parentNode)},"findClosestYogaNode"),g=a(e=>{(e?.nodeName==="#text"||e?.nodeName==="ink-text"||e?.nodeName==="ink-virtual-text")&&h(e)?.markDirty();let t=e;for(;t;){if((t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text")&&(t.internal_textCache=void 0),"childNodes"in t){if(t!==e&&t.nodeName==="ink-static-render"&&t.cachedRender)break;t.cachedRender=void 0}t=t.parentNode}},"markNodeAsDirty"),w=a((e,t)=>{typeof t!="string"&&(t=String(t)),e.nodeValue=t,g(e)},"setTextNodeValue"),$=a((e,t)=>e.nodeName!=="ink-root"?()=>{}:(e.internal_layoutListeners??=new Set,e.internal_layoutListeners.add(t),()=>{e.internal_layoutListeners?.delete(t)}),"addLayoutListener"),j=a(e=>{if(!(e.nodeName!=="ink-root"||!e.internal_layoutListeners))for(const t of e.internal_layoutListeners)t()},"emitLayoutListeners"),M=a((e,t)=>{if(e.cachedRender=t,e.yogaNode){for(e.yogaNode.setWidth(t.width),e.yogaNode.setHeight(t.height);e.yogaNode.getChildCount()>0;)e.yogaNode.removeChild(e.yogaNode.getChild(0));e.isYogaTreeDetached=!0}},"setCachedRender"),K=a(e=>{const t=[];let o=e;for(;o;)t.unshift(o),o=o.parentNode;return t},"getPathToRoot"),Y=a(e=>{let t=e;for(;t;){const{userSelect:o}=t.style;if(o==="none")return!1;if(o==="text"||o==="all")return!0;t=t.parentNode}return!0},"isNodeSelectable");export{k as T,$ as a,V as b,P as c,O as d,j as e,H as f,K as g,B as h,Y as i,I as j,M as k,g as m,y as r,w as s};
1
+ var f=Object.defineProperty;var s=(e,t)=>f(e,"name",{value:t,configurable:!0});import p from"yoga-layout";import{L as c}from"./measure-text-Ce2widM1.js";import m from"./squashTextNodesWithMap-DCdi3SZ2.js";import{wordWrap as C,truncate as v}from"@visulima/string";var x=Object.defineProperty,R=s((e,t)=>x(e,"name",{value:t,configurable:!0}),"R");const u={},T={hard:"STRICT_WIDTH",wrap:"BREAK_WORDS","wrap-anywhere":"BREAK_AT_CHARACTERS","wrap-preserve-words":"PRESERVE_WORDS","wrap-strict":"STRICT_WIDTH"},k=R((e,t,o)=>{const a=e+String(t)+String(o),n=u[a];if(n)return n;let d=e;const N=T[o];if(N)d=C(e,{trim:!1,width:t,wrapMode:N}).replace(/\n$/,"");else if(o.startsWith("truncate")){let i="end";o==="truncate-middle"&&(i="middle"),o==="truncate-start"&&(i="start"),d=v(e,t,{position:i})}return u[a]=d,d},"wrapText");var b=Object.defineProperty,r=s((e,t)=>b(e,"name",{value:t,configurable:!0}),"n");let S=0;const P=r(e=>{const t={attributes:{},childNodes:[],internal_accessibility:{},internal_id:S++,nodeName:e,parentNode:void 0,style:{},yogaNode:e==="ink-virtual-text"||e==="ink-cursor"?void 0:p.Node.create()};return e==="ink-text"&&t.yogaNode?.setMeasureFunc(_.bind(null,t)),t},"createNode"),l=r(e=>{g(e.nodeName==="ink-static-render"&&e.cachedRender?e.parentNode:e)},"markNodeAndParentIfStaticAsDirty"),O=r((e,t)=>{t.parentNode&&y(t.parentNode,t),t.parentNode=e,e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount()),l(e)},"appendChildNode"),V=r((e,t,o)=>{t.parentNode&&y(t.parentNode,t),t.parentNode=e;const a=e.childNodes.indexOf(o);if(a===-1)e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount());else if(e.childNodes.splice(a,0,t),t.yogaNode){const n=e.childNodes.slice(0,a).filter(d=>!!d.yogaNode).length;e.yogaNode?.insertChild(t.yogaNode,n)}l(e)},"insertBeforeNode"),y=r((e,t)=>{if(t.yogaNode){const a=t.yogaNode.getParent();a&&a.removeChild(t.yogaNode)}t.parentNode=void 0;const o=e.childNodes.indexOf(t);o!==-1&&e.childNodes.splice(o,1),l(e)},"removeChildNode"),I=r((e,t,o)=>{if(t==="internal_accessibility"){e.internal_accessibility=o;return}e.attributes[t]=o},"setAttribute"),B=r((e,t)=>{e.style=t??{}},"setStyle"),H=r(e=>{const t={nodeName:"#text",nodeValue:e,parentNode:void 0,style:{},yogaNode:void 0};return w(t,e),t},"createTextNode"),_=r(function(e,t){const o=e.nodeName==="#text"?e.nodeValue:m(e),a=c(o);if(a.width<=t||a.width>=1&&t>0&&t<1)return a;const n=e.style?.textWrap??"wrap",d=k(o,Math.floor(t),n);return c(d)},"measureTextNode"),h=r(e=>{if(e?.parentNode)return e.yogaNode??h(e.parentNode)},"findClosestYogaNode"),g=r(e=>{(e?.nodeName==="#text"||e?.nodeName==="ink-text"||e?.nodeName==="ink-virtual-text")&&h(e)?.markDirty();let t=e;for(;t;){if((t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text")&&(t.internal_textCache=void 0),"childNodes"in t){if(t!==e&&t.nodeName==="ink-static-render"&&t.cachedRender)break;t.cachedRender=void 0}t=t.parentNode}},"markNodeAsDirty"),w=r((e,t)=>{typeof t!="string"&&(t=String(t)),e.nodeValue=t,g(e)},"setTextNodeValue"),$=r((e,t)=>e.nodeName!=="ink-root"?()=>{}:(e.internal_layoutListeners??=new Set,e.internal_layoutListeners.add(t),()=>{e.internal_layoutListeners?.delete(t)}),"addLayoutListener"),j=r(e=>{if(!(e.nodeName!=="ink-root"||!e.internal_layoutListeners))for(const t of e.internal_layoutListeners)t()},"emitLayoutListeners"),M=r((e,t)=>{if(e.cachedRender=t,e.yogaNode){for(e.yogaNode.setWidth(t.width),e.yogaNode.setHeight(t.height);e.yogaNode.getChildCount()>0;)e.yogaNode.removeChild(e.yogaNode.getChild(0));e.isYogaTreeDetached=!0}},"setCachedRender"),K=r(e=>{const t=[];let o=e;for(;o;)t.unshift(o),o=o.parentNode;return t},"getPathToRoot"),Y=r(e=>{let t=e;for(;t;){const{userSelect:o}=t.style;if(o==="none")return!1;if(o==="text"||o==="all")return!0;t=t.parentNode}return!0},"isNodeSelectable");export{k as T,$ as a,V as b,P as c,O as d,j as e,H as f,K as g,B as h,Y as i,I as j,M as k,g as m,y as r,w as s};
@@ -1 +1 @@
1
- import"yoga-layout";import"./measure-text-DDjHT1jD.js";import"./squashTextNodesWithMap-DCdi3SZ2.js";import{a as r,d,c as i,f as m,e as N,g as l,b as p,i as c,m as h,r as n,j as u,k as y,h as L,s as b}from"./dom-BG-LS10p.js";export{r as addLayoutListener,d as appendChildNode,i as createNode,m as createTextNode,N as emitLayoutListeners,l as getPathToRoot,p as insertBeforeNode,c as isNodeSelectable,h as markNodeAsDirty,n as removeChildNode,u as setAttribute,y as setCachedRender,L as setStyle,b as setTextNodeValue};
1
+ import"yoga-layout";import"./measure-text-Ce2widM1.js";import"./squashTextNodesWithMap-DCdi3SZ2.js";import{a as r,d,c as i,f as m,e as N,g as l,b as p,i as c,m as h,r as n,j as u,k as y,h as L,s as b}from"./dom-CXB-19sK.js";export{r as addLayoutListener,d as appendChildNode,i as createNode,m as createTextNode,N as emitLayoutListeners,l as getPathToRoot,p as insertBeforeNode,c as isNodeSelectable,h as markNodeAsDirty,n as removeChildNode,u as setAttribute,y as setCachedRender,L as setStyle,b as setTextNodeValue};
@@ -1,3 +1,3 @@
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
+ 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 _=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,j=4,R=8,V=16,M=32,H=64,C=128;var rt=Object.defineProperty,it=k((r,t)=>rt(r,"name",{value:t,configurable:!0}),"x");const p=1073741823,x=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]&x)!==0}hasStyles(t){const e=this.getSpan(t);return e?(e.formatFlags&~C)!==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|=C),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&C)!==0,o=s&~C,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&x;this.charData[S]=w+f|L}}if(this.charData[t]=l|(i?x: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&C)!==0,o=s&~C,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?x: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&x}}this.charData[t]=l|(i?x: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?x: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&x}this.splitSpansAt(t),this.splitSpansAt(t+h);const u=[];let f=0;for(const g of e.getSpans()){const D=f+g.length,E=Math.max(s,f),K=Math.min(s+h,D);if(E<K&&u.push({...g,length:K-E}),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&C)!==0,i=e&~C,o=this.text.length;this.text=(this.text??"")+t,this.charData.push(o|(h?x: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&x;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&x;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&~C)!==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?C:0),fullWidth:i,hasStyles:(h&~C)!==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$2");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$1");const O=y(()=>({bgColor:void 0,fgColor:void 0,formatFlags:0,link:void 0}),"createSgrState"),ct=y((r,t)=>{if(t.length===0)return O();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|=j;break}case 4:{n|=R;break}case 7:{n|=M;break}case 8:{n|=H;break}case 9:{n|=V;break}case 22:{n&=-4;break}case 23:{n&=~j;break}case 24:{n&=~R;break}case 27:{n&=~M;break}case 28:{n&=~H;break}case 29:{n&=~V;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"),Ct=/(?:\u001B\]|\u009D)8;([^;]*);(.*?)(?:\u001B\\|\u0007|\u009C)/,xt=y(r=>{const t=Ct.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|C: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=O();for(const a of t)switch(a.type){case"csi":{a.finalCharacter==="m"&&(s=ct(s,a.parameterString));break}case"osc":{const n=xt(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,O()),t},"plainTextToStyledLine");var Dt=Object.defineProperty,v=k((r,t)=>Dt(r,"name",{value:t,configurable:!0}),"r");const $=new _(1e4,1e6),W=new _(1e4,1e6),F=new _(1e4,1e6);let B=!0,P=Z;const Wt=v(r=>{B=r,r||F.clear()},"setEnableStyledLineCache"),Bt=v(()=>{F.clear()},"clearStyledLineCache"),_t=v(r=>{P=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=P(r)}catch{e=1}return W.set(r,e),e},"inkCharacterWidth"),Ft=v(r=>{try{return P(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
+ `);let s=0;for(const n of e){const h=Ft(n);h>s&&(s=h)}const 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,C as F,H,j as I,Ot as L,d as S,R as U,Bt as a,_t as b,yt as c,wt as d,M as e,V as f,lt as g,Nt as h,Tt as i,vt as j,Lt as k,Et as m,$t as p,Wt as s,Pt as t};
@@ -1 +1 @@
1
- var P=Object.defineProperty;var p=(e,t)=>P(e,"name",{value:t,configurable:!0});import{createRequire as b}from"node:module";import{version as O,createContext as F}from"react";import G from"react-reconciler";import{NoEventPriority as L,DefaultEventPriority as v}from"react-reconciler/constants.js";import{unstable_shouldYield as w,unstable_scheduleCallback as k,unstable_now as B,unstable_cancelCallback as W}from"scheduler";import n from"yoga-layout";import{b as y,d as g,s as E,m as _,e as M,r as I,f as H,c as U,h as C,j as N}from"./dom-BG-LS10p.js";const re=b(import.meta.url),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=D;var Y=Object.defineProperty,u=p((e,t)=>Y(e,"name",{value:t,configurable:!0}),"t");const j=[["top",n.EDGE_TOP],["right",n.EDGE_RIGHT],["bottom",n.EDGE_BOTTOM],["left",n.EDGE_LEFT]],X=u((e,t)=>{if("position"in t){let r=n.POSITION_TYPE_RELATIVE;t.position==="absolute"?r=n.POSITION_TYPE_ABSOLUTE:t.position==="static"&&(r=n.POSITION_TYPE_STATIC),e.setPositionType(r)}for(const[r,s]of j){if(!(r in t))continue;const l=t[r];if(typeof l=="string"){e.setPositionPercent(s,Number.parseFloat(l));continue}e.setPosition(s,l)}},"applyPositionStyles"),V=u((e,t)=>{"margin"in t&&e.setMargin(n.EDGE_ALL,t.margin??0),"marginX"in t&&e.setMargin(n.EDGE_HORIZONTAL,t.marginX??0),"marginY"in t&&e.setMargin(n.EDGE_VERTICAL,t.marginY??0),"marginLeft"in t&&e.setMargin(n.EDGE_START,t.marginLeft||0),"marginRight"in t&&e.setMargin(n.EDGE_END,t.marginRight||0),"marginTop"in t&&e.setMargin(n.EDGE_TOP,t.marginTop||0),"marginBottom"in t&&e.setMargin(n.EDGE_BOTTOM,t.marginBottom||0)},"applyMarginStyles"),J=u((e,t)=>{"padding"in t&&e.setPadding(n.EDGE_ALL,t.padding??0),"paddingX"in t&&e.setPadding(n.EDGE_HORIZONTAL,t.paddingX??0),"paddingY"in t&&e.setPadding(n.EDGE_VERTICAL,t.paddingY??0),"paddingLeft"in t&&e.setPadding(n.EDGE_LEFT,t.paddingLeft||0),"paddingRight"in t&&e.setPadding(n.EDGE_RIGHT,t.paddingRight||0),"paddingTop"in t&&e.setPadding(n.EDGE_TOP,t.paddingTop||0),"paddingBottom"in t&&e.setPadding(n.EDGE_BOTTOM,t.paddingBottom||0)},"applyPaddingStyles"),q=u((e,t)=>{"flexGrow"in t&&e.setFlexGrow(t.flexGrow??0),"flexShrink"in t&&e.setFlexShrink(typeof t.flexShrink=="number"?t.flexShrink:1),"flexWrap"in t&&(t.flexWrap==="nowrap"&&e.setFlexWrap(n.WRAP_NO_WRAP),t.flexWrap==="wrap"&&e.setFlexWrap(n.WRAP_WRAP),t.flexWrap==="wrap-reverse"&&e.setFlexWrap(n.WRAP_WRAP_REVERSE)),"flexDirection"in t&&(t.flexDirection==="row"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW),t.flexDirection==="row-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW_REVERSE),t.flexDirection==="column"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN),t.flexDirection==="column-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in t&&(typeof t.flexBasis=="number"?e.setFlexBasis(t.flexBasis):typeof t.flexBasis=="string"?e.setFlexBasisPercent(Number.parseInt(t.flexBasis,10)):e.setFlexBasis(Number.NaN)),"alignItems"in t&&((t.alignItems==="stretch"||!t.alignItems)&&e.setAlignItems(n.ALIGN_STRETCH),t.alignItems==="flex-start"&&e.setAlignItems(n.ALIGN_FLEX_START),t.alignItems==="center"&&e.setAlignItems(n.ALIGN_CENTER),t.alignItems==="flex-end"&&e.setAlignItems(n.ALIGN_FLEX_END),t.alignItems==="baseline"&&e.setAlignItems(n.ALIGN_BASELINE)),"alignSelf"in t&&((t.alignSelf==="auto"||!t.alignSelf)&&e.setAlignSelf(n.ALIGN_AUTO),t.alignSelf==="flex-start"&&e.setAlignSelf(n.ALIGN_FLEX_START),t.alignSelf==="center"&&e.setAlignSelf(n.ALIGN_CENTER),t.alignSelf==="flex-end"&&e.setAlignSelf(n.ALIGN_FLEX_END),t.alignSelf==="stretch"&&e.setAlignSelf(n.ALIGN_STRETCH),t.alignSelf==="baseline"&&e.setAlignSelf(n.ALIGN_BASELINE)),"alignContent"in t&&((t.alignContent==="flex-start"||!t.alignContent)&&e.setAlignContent(n.ALIGN_FLEX_START),t.alignContent==="center"&&e.setAlignContent(n.ALIGN_CENTER),t.alignContent==="flex-end"&&e.setAlignContent(n.ALIGN_FLEX_END),t.alignContent==="space-between"&&e.setAlignContent(n.ALIGN_SPACE_BETWEEN),t.alignContent==="space-around"&&e.setAlignContent(n.ALIGN_SPACE_AROUND),t.alignContent==="space-evenly"&&e.setAlignContent(n.ALIGN_SPACE_EVENLY),t.alignContent==="stretch"&&e.setAlignContent(n.ALIGN_STRETCH)),"justifyContent"in t&&((t.justifyContent==="flex-start"||!t.justifyContent)&&e.setJustifyContent(n.JUSTIFY_FLEX_START),t.justifyContent==="center"&&e.setJustifyContent(n.JUSTIFY_CENTER),t.justifyContent==="flex-end"&&e.setJustifyContent(n.JUSTIFY_FLEX_END),t.justifyContent==="space-between"&&e.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),t.justifyContent==="space-around"&&e.setJustifyContent(n.JUSTIFY_SPACE_AROUND),t.justifyContent==="space-evenly"&&e.setJustifyContent(n.JUSTIFY_SPACE_EVENLY))},"applyFlexStyles"),$=u((e,t)=>{"width"in t&&(typeof t.width=="number"?e.setWidth(t.width):typeof t.width=="string"?e.setWidthPercent(Number.parseInt(t.width,10)):e.setWidthAuto()),"height"in t&&(typeof t.height=="number"?e.setHeight(t.height):typeof t.height=="string"?e.setHeightPercent(Number.parseInt(t.height,10)):e.setHeightAuto()),"minWidth"in t&&(typeof t.minWidth=="string"?e.setMinWidthPercent(Number.parseInt(t.minWidth,10)):e.setMinWidth(t.minWidth??0)),"minHeight"in t&&(typeof t.minHeight=="string"?e.setMinHeightPercent(Number.parseInt(t.minHeight,10)):e.setMinHeight(t.minHeight??0)),"maxWidth"in t&&(typeof t.maxWidth=="string"?e.setMaxWidthPercent(Number.parseInt(t.maxWidth,10)):e.setMaxWidth(t.maxWidth)),"maxHeight"in t&&(typeof t.maxHeight=="string"?e.setMaxHeightPercent(Number.parseInt(t.maxHeight,10)):e.setMaxHeight(t.maxHeight)),"aspectRatio"in t&&e.setAspectRatio(t.aspectRatio)},"applyDimensionStyles"),z=u((e,t)=>{"display"in t&&e.setDisplay(t.display==="flex"?n.DISPLAY_FLEX:n.DISPLAY_NONE)},"applyDisplayStyles"),Z=u((e,t,r)=>{if(!("borderStyle"in t||"borderTop"in t||"borderBottom"in t||"borderLeft"in t||"borderRight"in t))return;const s=r.borderStyle?1:0;e.setBorder(n.EDGE_TOP,r.borderTop===!1?0:s),e.setBorder(n.EDGE_BOTTOM,r.borderBottom===!1?0:s),e.setBorder(n.EDGE_LEFT,r.borderLeft===!1?0:s),e.setBorder(n.EDGE_RIGHT,r.borderRight===!1?0:s)},"applyBorderStyles"),K=u((e,t)=>{"gap"in t&&e.setGap(n.GUTTER_ALL,t.gap??0),"columnGap"in t&&e.setGap(n.GUTTER_COLUMN,t.columnGap??0),"rowGap"in t&&e.setGap(n.GUTTER_ROW,t.rowGap??0)},"applyGapStyles"),Q=u((e,t)=>{const r=t.overflow??"visible",s=t.overflowX??r,l=t.overflowY??r;s==="scroll"||l==="scroll"?e.setOverflow(n.OVERFLOW_SCROLL):s==="hidden"||l==="hidden"?e.setOverflow(n.OVERFLOW_HIDDEN):e.setOverflow(n.OVERFLOW_VISIBLE)},"applyOverflowStyles"),S=u((e,t={},r=t)=>{X(e,t),V(e,t),J(e,t),q(e,t),$(e,t),z(e,t),Z(e,t,r),K(e,t),Q(e,r)},"styles");var ee=Object.defineProperty,c=p((e,t)=>ee(e,"name",{value:t,configurable:!0}),"c");if(A.env.DEV==="true"){let e=!1;try{import.meta.resolve("react-devtools-core"),e=!0}catch{}e&&await import("../packem_chunks/devtools.js")}const x=c((e,t)=>{if(e===t)return;if(!e)return t;const r={};let s=!1;for(const l of Object.keys(e))(!t||!Object.hasOwn(t,l))&&(r[l]=void 0,s=!0);if(t)for(const l of Object.keys(t))t[l]!==e[l]&&(r[l]=t[l],s=!0);return s?r:void 0},"diff"),h=c(e=>{if(e){if(e.yogaNode?.unsetMeasureFunc(),"resizeObservers"in e&&e.resizeObservers?.clear(),"childNodes"in e&&e.childNodes)for(const t of e.childNodes)h(t);e.yogaNode?.free(),"cachedRender"in e&&(e.cachedRender=void 0),"childNodes"in e&&(e.childNodes=[]),e.parentNode=void 0}},"cleanupNodeTree");let m=L,T;async function R(){const e=(await import("node:fs")).readFileSync(new URL("../package.json",import.meta.url),"utf8"),t=JSON.parse(e);return{name:t?.name,version:t?.version}}p(R,"B");c(R,"loadPackageJson");let f={name:"ink",version:O};if(A.env.DEV==="true")try{const e=await R();f={name:e.name||f.name,version:e.version||f.version}}catch(e){console.warn("Failed to load package.json in development mode. Falling back to default renderer metadata.",e)}const de=G({afterActiveInstanceBlur(){},appendChild:g,appendChildToContainer:g,appendInitialChild:g,beforeActiveInstanceBlur(){},cancelCallback:W,cancelTimeout:clearTimeout,clearContainer:c(()=>!1,"clearContainer"),commitTextUpdate(e,t,r){E(e,r)},commitUpdate(e,t,r,s){T&&e.internal_static&&(T.isStaticDirty=!0);const l=x(r,s),a=x(r.style,s.style);if(!l&&!a)return;let i=!!a;if(l){for(const[o,d]of Object.entries(l))if(o!=="children"){if(o==="style"){C(e,d);continue}if(o==="internal_transform"){e.internal_transform=d,i=!0;continue}if(o==="internal_cursor"){e.internal_cursor=d,i=!0;continue}if(o==="internal_static"){e.internal_static=!0,i=!0;continue}if(o==="sticky"){e.internal_sticky=d,i=!0;continue}if(o==="internalStickyAlternate"){e.internal_stickyAlternate=d,i=!0;continue}if(o==="opaque"){e.internal_opaque=d,i=!0;continue}if(o==="scrollbar"){e.internal_scrollbar=d,i=!0;continue}if(o==="internal_terminalCursorFocus"){e.internal_terminalCursorFocus=d,i=!0;continue}if(o==="internal_terminalCursorPosition"){e.internal_terminalCursorPosition=d,i=!0;continue}if(o==="cachedRender"){e.cachedRender=d,i=!0;continue}N(e,o,d),i=!0}}a&&e.yogaNode&&S(e.yogaNode,a,s.style??{}),i&&_(e)},createInstance(e,t,r,s){if(s.isInsideText&&e==="ink-box")throw new Error("<Box> can’t be nested inside <Text> component");if(s.isInsideText&&e==="ink-cursor")throw new Error("<Cursor> can’t be nested inside <Text> component");const l=e==="ink-text"&&s.isInsideText?"ink-virtual-text":e,a=U(l);for(const[i,o]of Object.entries(t))if(i!=="children"){if(i==="style"){C(a,o),a.yogaNode&&S(a.yogaNode,o);continue}if(i==="internal_transform"){a.internal_transform=o;continue}if(i==="internal_cursor"){a.internal_cursor=o;continue}if(i==="internal_static"){T=r,a.internal_static=!0,r.isStaticDirty=!0,r.staticNode=a;continue}if(i==="sticky"){a.internal_sticky=o;continue}if(i==="internalStickyAlternate"){a.internal_stickyAlternate=o;continue}if(i==="opaque"){a.internal_opaque=o;continue}if(i==="scrollbar"){a.internal_scrollbar=o;continue}if(i==="internal_terminalCursorFocus"){a.internal_terminalCursorFocus=o;continue}if(i==="internal_terminalCursorPosition"){a.internal_terminalCursorPosition=o;continue}if(i==="internal_static"){a.internal_static=!0;continue}if(i==="cachedRender"){a.cachedRender=o;continue}N(a,i,o)}return a},createTextInstance(e,t,r){if(!r.isInsideText)throw new Error(`Text string "${e}" must be rendered inside <Text> component`);return H(e)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(e,t){const r=e.isInsideText,s=t==="ink-text"||t==="ink-virtual-text";return r===s?e:{isInsideText:s}},getCurrentUpdatePriority:c(()=>m,"getCurrentUpdatePriority"),getInstanceFromNode:c(()=>null,"getInstanceFromNode"),getInstanceFromScope:c(()=>null,"getInstanceFromScope"),getPublicInstance:c(e=>e,"getPublicInstance"),getRootHostContext:c(()=>({isInsideText:!1}),"getRootHostContext"),hideInstance(e){e.internal_hidden=!0,e.yogaNode?.setDisplay(n.DISPLAY_NONE),_(e)},hideTextInstance(e){E(e,"")},HostTransitionContext:F(null),insertBefore:y,insertInContainerBefore:y,isPrimaryRenderer:!0,maySuspendCommit(){return!0},noTimeout:-1,NotPendingTransition:void 0,now:B,preloadInstance(){return!0},prepareForCommit:c(()=>null,"prepareForCommit"),preparePortalMount:c(()=>null,"preparePortalMount"),prepareScopeUpdate(){},removeChild(e,t){I(e,t),h(t)},removeChildFromContainer(e,t){I(e,t),h(t)},rendererPackageName:f.name,rendererVersion:f.version,requestPostPaintCallback(){},resetAfterCommit(e){if(typeof e.onComputeLayout=="function"&&e.onComputeLayout(),M(e),e.staticNode!==e.previousStaticNode&&(e.previousStaticNode=e.staticNode,typeof e.onStaticChange=="function"&&e.onStaticChange()),e.isStaticDirty){e.isStaticDirty=!1,typeof e.onImmediateRender=="function"&&e.onImmediateRender();return}typeof e.onRender=="function"&&e.onRender()},resetFormInstance(){},resetTextContent(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return m!==L?m:v},scheduleCallback:k,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){m=e},shouldAttemptEagerTransition(){return!1},shouldSetTextContent:c(()=>!1,"shouldSetTextContent"),shouldYield:w,startSuspendingCommit(){},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},trackSchedulerEvent(){},unhideInstance(e){e.internal_hidden=!1,e.yogaNode?.setDisplay(n.DISPLAY_FLEX),_(e)},unhideTextInstance(e,t){E(e,t)},waitForCommitToBeReady(){return null}});export{de as L,S as u};
1
+ var P=Object.defineProperty;var p=(e,t)=>P(e,"name",{value:t,configurable:!0});import{createRequire as b}from"node:module";import{version as O,createContext as F}from"react";import G from"react-reconciler";import{NoEventPriority as L,DefaultEventPriority as v}from"react-reconciler/constants.js";import{unstable_shouldYield as w,unstable_scheduleCallback as k,unstable_now as B,unstable_cancelCallback as W}from"scheduler";import n from"yoga-layout";import{b as y,d as g,s as E,m as _,e as M,r as I,f as H,c as U,h as C,j as N}from"./dom-CXB-19sK.js";const re=b(import.meta.url),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=D;var Y=Object.defineProperty,u=p((e,t)=>Y(e,"name",{value:t,configurable:!0}),"t");const j=[["top",n.EDGE_TOP],["right",n.EDGE_RIGHT],["bottom",n.EDGE_BOTTOM],["left",n.EDGE_LEFT]],X=u((e,t)=>{if("position"in t){let r=n.POSITION_TYPE_RELATIVE;t.position==="absolute"?r=n.POSITION_TYPE_ABSOLUTE:t.position==="static"&&(r=n.POSITION_TYPE_STATIC),e.setPositionType(r)}for(const[r,s]of j){if(!(r in t))continue;const l=t[r];if(typeof l=="string"){e.setPositionPercent(s,Number.parseFloat(l));continue}e.setPosition(s,l)}},"applyPositionStyles"),V=u((e,t)=>{"margin"in t&&e.setMargin(n.EDGE_ALL,t.margin??0),"marginX"in t&&e.setMargin(n.EDGE_HORIZONTAL,t.marginX??0),"marginY"in t&&e.setMargin(n.EDGE_VERTICAL,t.marginY??0),"marginLeft"in t&&e.setMargin(n.EDGE_START,t.marginLeft||0),"marginRight"in t&&e.setMargin(n.EDGE_END,t.marginRight||0),"marginTop"in t&&e.setMargin(n.EDGE_TOP,t.marginTop||0),"marginBottom"in t&&e.setMargin(n.EDGE_BOTTOM,t.marginBottom||0)},"applyMarginStyles"),J=u((e,t)=>{"padding"in t&&e.setPadding(n.EDGE_ALL,t.padding??0),"paddingX"in t&&e.setPadding(n.EDGE_HORIZONTAL,t.paddingX??0),"paddingY"in t&&e.setPadding(n.EDGE_VERTICAL,t.paddingY??0),"paddingLeft"in t&&e.setPadding(n.EDGE_LEFT,t.paddingLeft||0),"paddingRight"in t&&e.setPadding(n.EDGE_RIGHT,t.paddingRight||0),"paddingTop"in t&&e.setPadding(n.EDGE_TOP,t.paddingTop||0),"paddingBottom"in t&&e.setPadding(n.EDGE_BOTTOM,t.paddingBottom||0)},"applyPaddingStyles"),q=u((e,t)=>{"flexGrow"in t&&e.setFlexGrow(t.flexGrow??0),"flexShrink"in t&&e.setFlexShrink(typeof t.flexShrink=="number"?t.flexShrink:1),"flexWrap"in t&&(t.flexWrap==="nowrap"&&e.setFlexWrap(n.WRAP_NO_WRAP),t.flexWrap==="wrap"&&e.setFlexWrap(n.WRAP_WRAP),t.flexWrap==="wrap-reverse"&&e.setFlexWrap(n.WRAP_WRAP_REVERSE)),"flexDirection"in t&&(t.flexDirection==="row"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW),t.flexDirection==="row-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_ROW_REVERSE),t.flexDirection==="column"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN),t.flexDirection==="column-reverse"&&e.setFlexDirection(n.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in t&&(typeof t.flexBasis=="number"?e.setFlexBasis(t.flexBasis):typeof t.flexBasis=="string"?e.setFlexBasisPercent(Number.parseInt(t.flexBasis,10)):e.setFlexBasis(Number.NaN)),"alignItems"in t&&((t.alignItems==="stretch"||!t.alignItems)&&e.setAlignItems(n.ALIGN_STRETCH),t.alignItems==="flex-start"&&e.setAlignItems(n.ALIGN_FLEX_START),t.alignItems==="center"&&e.setAlignItems(n.ALIGN_CENTER),t.alignItems==="flex-end"&&e.setAlignItems(n.ALIGN_FLEX_END),t.alignItems==="baseline"&&e.setAlignItems(n.ALIGN_BASELINE)),"alignSelf"in t&&((t.alignSelf==="auto"||!t.alignSelf)&&e.setAlignSelf(n.ALIGN_AUTO),t.alignSelf==="flex-start"&&e.setAlignSelf(n.ALIGN_FLEX_START),t.alignSelf==="center"&&e.setAlignSelf(n.ALIGN_CENTER),t.alignSelf==="flex-end"&&e.setAlignSelf(n.ALIGN_FLEX_END),t.alignSelf==="stretch"&&e.setAlignSelf(n.ALIGN_STRETCH),t.alignSelf==="baseline"&&e.setAlignSelf(n.ALIGN_BASELINE)),"alignContent"in t&&((t.alignContent==="flex-start"||!t.alignContent)&&e.setAlignContent(n.ALIGN_FLEX_START),t.alignContent==="center"&&e.setAlignContent(n.ALIGN_CENTER),t.alignContent==="flex-end"&&e.setAlignContent(n.ALIGN_FLEX_END),t.alignContent==="space-between"&&e.setAlignContent(n.ALIGN_SPACE_BETWEEN),t.alignContent==="space-around"&&e.setAlignContent(n.ALIGN_SPACE_AROUND),t.alignContent==="space-evenly"&&e.setAlignContent(n.ALIGN_SPACE_EVENLY),t.alignContent==="stretch"&&e.setAlignContent(n.ALIGN_STRETCH)),"justifyContent"in t&&((t.justifyContent==="flex-start"||!t.justifyContent)&&e.setJustifyContent(n.JUSTIFY_FLEX_START),t.justifyContent==="center"&&e.setJustifyContent(n.JUSTIFY_CENTER),t.justifyContent==="flex-end"&&e.setJustifyContent(n.JUSTIFY_FLEX_END),t.justifyContent==="space-between"&&e.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),t.justifyContent==="space-around"&&e.setJustifyContent(n.JUSTIFY_SPACE_AROUND),t.justifyContent==="space-evenly"&&e.setJustifyContent(n.JUSTIFY_SPACE_EVENLY))},"applyFlexStyles"),$=u((e,t)=>{"width"in t&&(typeof t.width=="number"?e.setWidth(t.width):typeof t.width=="string"?e.setWidthPercent(Number.parseInt(t.width,10)):e.setWidthAuto()),"height"in t&&(typeof t.height=="number"?e.setHeight(t.height):typeof t.height=="string"?e.setHeightPercent(Number.parseInt(t.height,10)):e.setHeightAuto()),"minWidth"in t&&(typeof t.minWidth=="string"?e.setMinWidthPercent(Number.parseInt(t.minWidth,10)):e.setMinWidth(t.minWidth??0)),"minHeight"in t&&(typeof t.minHeight=="string"?e.setMinHeightPercent(Number.parseInt(t.minHeight,10)):e.setMinHeight(t.minHeight??0)),"maxWidth"in t&&(typeof t.maxWidth=="string"?e.setMaxWidthPercent(Number.parseInt(t.maxWidth,10)):e.setMaxWidth(t.maxWidth)),"maxHeight"in t&&(typeof t.maxHeight=="string"?e.setMaxHeightPercent(Number.parseInt(t.maxHeight,10)):e.setMaxHeight(t.maxHeight)),"aspectRatio"in t&&e.setAspectRatio(t.aspectRatio)},"applyDimensionStyles"),z=u((e,t)=>{"display"in t&&e.setDisplay(t.display==="flex"?n.DISPLAY_FLEX:n.DISPLAY_NONE)},"applyDisplayStyles"),Z=u((e,t,r)=>{if(!("borderStyle"in t||"borderTop"in t||"borderBottom"in t||"borderLeft"in t||"borderRight"in t))return;const s=r.borderStyle?1:0;e.setBorder(n.EDGE_TOP,r.borderTop===!1?0:s),e.setBorder(n.EDGE_BOTTOM,r.borderBottom===!1?0:s),e.setBorder(n.EDGE_LEFT,r.borderLeft===!1?0:s),e.setBorder(n.EDGE_RIGHT,r.borderRight===!1?0:s)},"applyBorderStyles"),K=u((e,t)=>{"gap"in t&&e.setGap(n.GUTTER_ALL,t.gap??0),"columnGap"in t&&e.setGap(n.GUTTER_COLUMN,t.columnGap??0),"rowGap"in t&&e.setGap(n.GUTTER_ROW,t.rowGap??0)},"applyGapStyles"),Q=u((e,t)=>{const r=t.overflow??"visible",s=t.overflowX??r,l=t.overflowY??r;s==="scroll"||l==="scroll"?e.setOverflow(n.OVERFLOW_SCROLL):s==="hidden"||l==="hidden"?e.setOverflow(n.OVERFLOW_HIDDEN):e.setOverflow(n.OVERFLOW_VISIBLE)},"applyOverflowStyles"),S=u((e,t={},r=t)=>{X(e,t),V(e,t),J(e,t),q(e,t),$(e,t),z(e,t),Z(e,t,r),K(e,t),Q(e,r)},"styles");var ee=Object.defineProperty,c=p((e,t)=>ee(e,"name",{value:t,configurable:!0}),"c");if(A.env.DEV==="true"){let e=!1;try{import.meta.resolve("react-devtools-core"),e=!0}catch{}e&&await import("../packem_chunks/devtools.js")}const x=c((e,t)=>{if(e===t)return;if(!e)return t;const r={};let s=!1;for(const l of Object.keys(e))(!t||!Object.hasOwn(t,l))&&(r[l]=void 0,s=!0);if(t)for(const l of Object.keys(t))t[l]!==e[l]&&(r[l]=t[l],s=!0);return s?r:void 0},"diff"),h=c(e=>{if(e){if(e.yogaNode?.unsetMeasureFunc(),"resizeObservers"in e&&e.resizeObservers?.clear(),"childNodes"in e&&e.childNodes)for(const t of e.childNodes)h(t);e.yogaNode?.free(),"cachedRender"in e&&(e.cachedRender=void 0),"childNodes"in e&&(e.childNodes=[]),e.parentNode=void 0}},"cleanupNodeTree");let m=L,T;async function R(){const e=(await import("node:fs")).readFileSync(new URL("../package.json",import.meta.url),"utf8"),t=JSON.parse(e);return{name:t?.name,version:t?.version}}p(R,"B");c(R,"loadPackageJson");let f={name:"ink",version:O};if(A.env.DEV==="true")try{const e=await R();f={name:e.name||f.name,version:e.version||f.version}}catch(e){console.warn("Failed to load package.json in development mode. Falling back to default renderer metadata.",e)}const de=G({afterActiveInstanceBlur(){},appendChild:g,appendChildToContainer:g,appendInitialChild:g,beforeActiveInstanceBlur(){},cancelCallback:W,cancelTimeout:clearTimeout,clearContainer:c(()=>!1,"clearContainer"),commitTextUpdate(e,t,r){E(e,r)},commitUpdate(e,t,r,s){T&&e.internal_static&&(T.isStaticDirty=!0);const l=x(r,s),a=x(r.style,s.style);if(!l&&!a)return;let i=!!a;if(l){for(const[o,d]of Object.entries(l))if(o!=="children"){if(o==="style"){C(e,d);continue}if(o==="internal_transform"){e.internal_transform=d,i=!0;continue}if(o==="internal_cursor"){e.internal_cursor=d,i=!0;continue}if(o==="internal_static"){e.internal_static=!0,i=!0;continue}if(o==="sticky"){e.internal_sticky=d,i=!0;continue}if(o==="internalStickyAlternate"){e.internal_stickyAlternate=d,i=!0;continue}if(o==="opaque"){e.internal_opaque=d,i=!0;continue}if(o==="scrollbar"){e.internal_scrollbar=d,i=!0;continue}if(o==="internal_terminalCursorFocus"){e.internal_terminalCursorFocus=d,i=!0;continue}if(o==="internal_terminalCursorPosition"){e.internal_terminalCursorPosition=d,i=!0;continue}if(o==="cachedRender"){e.cachedRender=d,i=!0;continue}N(e,o,d),i=!0}}a&&e.yogaNode&&S(e.yogaNode,a,s.style??{}),i&&_(e)},createInstance(e,t,r,s){if(s.isInsideText&&e==="ink-box")throw new Error("<Box> can’t be nested inside <Text> component");if(s.isInsideText&&e==="ink-cursor")throw new Error("<Cursor> can’t be nested inside <Text> component");const l=e==="ink-text"&&s.isInsideText?"ink-virtual-text":e,a=U(l);for(const[i,o]of Object.entries(t))if(i!=="children"){if(i==="style"){C(a,o),a.yogaNode&&S(a.yogaNode,o);continue}if(i==="internal_transform"){a.internal_transform=o;continue}if(i==="internal_cursor"){a.internal_cursor=o;continue}if(i==="internal_static"){T=r,a.internal_static=!0,r.isStaticDirty=!0,r.staticNode=a;continue}if(i==="sticky"){a.internal_sticky=o;continue}if(i==="internalStickyAlternate"){a.internal_stickyAlternate=o;continue}if(i==="opaque"){a.internal_opaque=o;continue}if(i==="scrollbar"){a.internal_scrollbar=o;continue}if(i==="internal_terminalCursorFocus"){a.internal_terminalCursorFocus=o;continue}if(i==="internal_terminalCursorPosition"){a.internal_terminalCursorPosition=o;continue}if(i==="internal_static"){a.internal_static=!0;continue}if(i==="cachedRender"){a.cachedRender=o;continue}N(a,i,o)}return a},createTextInstance(e,t,r){if(!r.isInsideText)throw new Error(`Text string "${e}" must be rendered inside <Text> component`);return H(e)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(e,t){const r=e.isInsideText,s=t==="ink-text"||t==="ink-virtual-text";return r===s?e:{isInsideText:s}},getCurrentUpdatePriority:c(()=>m,"getCurrentUpdatePriority"),getInstanceFromNode:c(()=>null,"getInstanceFromNode"),getInstanceFromScope:c(()=>null,"getInstanceFromScope"),getPublicInstance:c(e=>e,"getPublicInstance"),getRootHostContext:c(()=>({isInsideText:!1}),"getRootHostContext"),hideInstance(e){e.internal_hidden=!0,e.yogaNode?.setDisplay(n.DISPLAY_NONE),_(e)},hideTextInstance(e){E(e,"")},HostTransitionContext:F(null),insertBefore:y,insertInContainerBefore:y,isPrimaryRenderer:!0,maySuspendCommit(){return!0},noTimeout:-1,NotPendingTransition:void 0,now:B,preloadInstance(){return!0},prepareForCommit:c(()=>null,"prepareForCommit"),preparePortalMount:c(()=>null,"preparePortalMount"),prepareScopeUpdate(){},removeChild(e,t){I(e,t),h(t)},removeChildFromContainer(e,t){I(e,t),h(t)},rendererPackageName:f.name,rendererVersion:f.version,requestPostPaintCallback(){},resetAfterCommit(e){if(typeof e.onComputeLayout=="function"&&e.onComputeLayout(),M(e),e.staticNode!==e.previousStaticNode&&(e.previousStaticNode=e.staticNode,typeof e.onStaticChange=="function"&&e.onStaticChange()),e.isStaticDirty){e.isStaticDirty=!1,typeof e.onImmediateRender=="function"&&e.onImmediateRender();return}typeof e.onRender=="function"&&e.onRender()},resetFormInstance(){},resetTextContent(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return m!==L?m:v},scheduleCallback:k,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){m=e},shouldAttemptEagerTransition(){return!1},shouldSetTextContent:c(()=>!1,"shouldSetTextContent"),shouldYield:w,startSuspendingCommit(){},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},trackSchedulerEvent(){},unhideInstance(e){e.internal_hidden=!1,e.yogaNode?.setDisplay(n.DISPLAY_FLEX),_(e)},unhideTextInstance(e,t){E(e,t)},waitForCommitToBeReady(){return null}});export{de as L,S as u};
@@ -1,19 +1,19 @@
1
- var ke=Object.defineProperty;var x=(e,t)=>ke(e,"name",{value:t,configurable:!0});import{createRequire as De}from"node:module";import{jsxs as W,jsx as T}from"react/jsx-runtime";import{setMode as se,BracketedPasteMode as oe,resetMode as ne,cursorShow as ht,setCursorStyle as Me,cursorUp as Pt,cursorTo as kt,cursorDown as Ae,cursorHide as Q,eraseLines as V,cursorNextLine as We,eraseLineEnd as _e,createDecMode as He,ALT_SCREEN_ON as Ue,clearScreenAndHomeCursor as Ke,ALT_SCREEN_OFF as je}from"@visulima/ansi";import{wordWrap as Fe}from"@visulima/string";import ue from"is-in-ci";import qe from"patch-console";import{ConcurrentRoot as Ye,LegacyRoot as ze}from"react-reconciler/constants.js";import{onExit as Ge}from"signal-exit";import K from"yoga-layout";import{a as Ve}from"./accessibility-context-DDyHTwmA.js";import{PureComponent as Xe,useState as vt,useRef as _,useCallback as y,useEffect as Rt,useMemo as z}from"react";import{e as Je}from"./animation-context-DW3p-vpk.js";import{t as Ze}from"./app-context-BVpKlG1z.js";import{o as tr}from"./cursor-context-CFviBqPX.js";import{parseStacktrace as ir}from"@visulima/error/stacktrace";import sr from"code-excerpt";import{Box as U}from"../components/box.js";import{Text as H}from"../components/text.js";import{o as or}from"./focus-context-CsT69klR.js";import{t as nr}from"./stderr-context-BzEaUICS.js";import{e as ur}from"./stdin-context-BTaaFagk.js";import{t as ar}from"./stdout-context-BnblEPez.js";import{A as lr,B as dr,r as cr,R as hr}from"./renderer-DG986Pcr.js";import{c as fr,e as pr}from"./dom-BG-LS10p.js";import{resolveFlags as mr}from"./kittyFlags-C3rZLbcK.js";import{a as gr}from"./measure-text-DDjHT1jD.js";import{L as B,u as vr}from"./reconciler-CUbhOvcr.js";import{measureAndExtractObservers as br}from"./ResizeObserverEntry-Dq0dk8Kq.js";import{calculateScroll as wr}from"./getScrollHeight-ClEOyLHH.js";import{g as tt}from"./utils-CoviI5Vm.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
1
+ var ke=Object.defineProperty;var x=(e,t)=>ke(e,"name",{value:t,configurable:!0});import{createRequire as De}from"node:module";import{jsxs as A,jsx as T}from"react/jsx-runtime";import{setMode as se,BracketedPasteMode as oe,resetMode as ne,cursorShow as ht,setCursorStyle as Me,cursorUp as Pt,cursorTo as kt,cursorDown as We,cursorHide as Q,eraseLines as V,cursorNextLine as Ae,eraseLineEnd as _e,createDecMode as Ue,ALT_SCREEN_ON as He,clearScreenAndHomeCursor as Ke,ALT_SCREEN_OFF as je}from"@visulima/ansi";import{wordWrap as Fe}from"@visulima/string";import ue from"is-in-ci";import qe from"patch-console";import{ConcurrentRoot as Ye,LegacyRoot as ze}from"react-reconciler/constants.js";import{onExit as Ge}from"signal-exit";import K from"yoga-layout";import{a as Ve}from"./accessibility-context-DDyHTwmA.js";import{PureComponent as Xe,useState as vt,useRef as _,useCallback as y,useEffect as Rt,useMemo as z}from"react";import{e as Je}from"./animation-context-DW3p-vpk.js";import{t as Ze}from"./app-context-BVpKlG1z.js";import{o as tr}from"./cursor-context-CFviBqPX.js";import{parseStacktrace as ir}from"@visulima/error/stacktrace";import sr from"code-excerpt";import{Box as H}from"../components/box.js";import{Text as U}from"../components/text.js";import{o as or}from"./focus-context-CsT69klR.js";import{t as nr}from"./stderr-context-BzEaUICS.js";import{e as ur}from"./stdin-context-BTaaFagk.js";import{t as ar}from"./stdout-context-BnblEPez.js";import{U as lr,B as dr,r as cr,R as hr}from"./renderer-maLLQcut.js";import{c as fr,e as pr}from"./dom-CXB-19sK.js";import{resolveFlags as mr}from"./kittyFlags-C3rZLbcK.js";import{a as gr}from"./measure-text-Ce2widM1.js";import{L as B,u as vr}from"./reconciler-DYE5h4K4.js";import{measureAndExtractObservers as br}from"./ResizeObserverEntry-Dq0dk8Kq.js";import{calculateScroll as wr}from"./getScrollHeight-ClEOyLHH.js";import{g as tt}from"./utils-CoviI5Vm.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
2
  const require = __cjs_mod__.createRequire(import.meta.url);
3
- const $e=De(import.meta.url),it=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ct=x(e=>{if(typeof it<"u"&&it.versions&&it.versions.node){const[t,r]=it.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return it.getBuiltinModule(e)}return $e(e)},"__cjs_getBuiltinModule"),M=it,{cwd:Le}=M,{Stream:Ie}=ct("node:stream"),{Buffer:Vt}=ct("node:buffer"),{Console:Be}=ct("node:console"),{EventEmitter:Qe}=ct("node:events"),{existsSync:er,readFileSync:rr}=ct("node:fs");var yr=Object.defineProperty,L=x((e,t)=>yr(e,"name",{value:t,configurable:!0}),"i$2");const ae="\x1B[200~",Qt="\x1B[201~",Cr=L(e=>e>=48&&e<=63,"isCsiParameterByte"),Tr=L(e=>e>=32&&e<=47,"isCsiIntermediateByte"),le=L(e=>e>=64&&e<=126,"isCsiFinalByte"),Rr=L((e,t,r)=>{const i=t+r+1;let o=i;for(;o<e.length;o++){const a=e.codePointAt(o);if(a===void 0)return"pending";if(!(Cr(a)||Tr(a))&&!(a===91&&o===i))return le(a)?{nextIndex:o+1,sequence:e.slice(t,o+1)}:void 0}return"pending"},"parseCsiSequence"),xr=L((e,t,r)=>{const i=t+r+2;if(i>e.length)return"pending";const o=e.codePointAt(i-1);if(!(o===void 0||!le(o)))return{nextIndex:i,sequence:e.slice(t,i)}},"parseSs3Sequence"),Xt=L((e,t,r)=>{const i=e[t+r];if(i===void 0)return"pending";if(i==="[")return Rr(e,t,r);if(i==="O")return xr(e,t,r)},"parseControlSequence"),Sr=L((e,t)=>{const r=e.codePointAt(t+1),i=r!==void 0&&r>65535?2:1,o=t+1+i;return{nextIndex:o,sequence:e.slice(t,o)}},"parseEscapedCodePoint"),Pr=L((e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]==="\x1B"){if(t+2>=e.length)return"pending";const i=Xt(e,t,2);return i==="pending"?"pending":i||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const r=Xt(e,t,1);return r==="pending"?"pending":r||Sr(e,t)},"parseEscapeSequence"),Jt=L((e,t)=>{let r=0;for(let i=0;i<e.length;i++){const o=e[i];(o===""||o==="\b")&&(i>r&&t.push(e.slice(r,i)),t.push(o),r=i+1)}r<e.length&&t.push(e.slice(r))},"splitDeleteAndBackspace"),Or=L(e=>{const t=[];let r=0;const i=L(o=>({events:t,pending:e.slice(o)}),"pendingFrom");for(;r<e.length;){const o=e.indexOf("\x1B",r);if(o===-1)return Jt(e.slice(r),t),{events:t,pending:""};o>r&&Jt(e.slice(r,o),t);const a=Pr(e,o);if(a==="pending")return i(o);if(a.sequence===ae){const l=a.nextIndex,n=e.indexOf(Qt,l);if(n===-1)return i(o);t.push({paste:e.slice(l,n)}),r=n+Qt.length;continue}t.push(a.sequence),r=a.nextIndex}return{events:t,pending:""}},"parseKeypresses"),Er=L(()=>{let e="";return{flushPendingEscape(){if(!e.startsWith("\x1B"))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith("\x1B")&&!e.startsWith(ae)&&e!=="\x1B[200"},push(t){const r=Or(e+t);return e=r.pending,r.events},reset(){e=""}}},"createInputParser");var Nr=Object.defineProperty,de=x((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"x");const xt=de(e=>{if(!e)return e;const t=Le();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")},"cleanupPath");function ce({error:e}){const t=ir(e),r=new Map,i=t.map(s=>{const u=!s.methodName&&!s.file?`raw:${s.raw}`:`${xt(s.file)??""}:${s.line}:${s.column}:${s.methodName??""}`,m=r.get(u)??0;return r.set(u,m+1),{key:`${u}#${m}`,trace:s}}),o=t[0],a=xt(o?.file);let l,n=0;if(a&&o?.line&&er(a)){const s=rr(a,"utf8");if(l=sr(s,o.line),l)for(const{line:u}of l)n=Math.max(n,String(u).length)}return W(U,{flexDirection:"column",padding:1,children:[W(U,{children:[W(H,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),W(H,{children:[" ",e.message]})]}),o&&a?T(U,{marginTop:1,children:W(H,{dimColor:!0,children:[a,":",o.line,":",o.column]})}):null,o&&l?T(U,{flexDirection:"column",marginTop:1,children:l.map(({line:s,value:u})=>W(U,{children:[T(U,{width:n+1,children:W(H,{"aria-label":s===o.line?`Line ${s}, error`:`Line ${s}`,backgroundColor:s===o.line?"red":void 0,color:s===o.line?"white":void 0,dimColor:s!==o.line,children:[String(s).padStart(n," "),":"]})}),T(H,{backgroundColor:s===o.line?"red":void 0,color:s===o.line?"white":void 0,children:` ${u}`})]},`excerpt-${s}`))}):null,t.length>0?T(U,{flexDirection:"column",marginTop:1,children:i.map(({key:s,trace:u})=>{const m=xt(u.file)??"";return!u.methodName&&!u.file?W(U,{children:[T(H,{dimColor:!0,children:"- "}),T(H,{bold:!0,dimColor:!0,children:u.raw})]},s):W(U,{children:[T(H,{dimColor:!0,children:"- "}),T(H,{bold:!0,dimColor:!0,children:u.methodName??"<anonymous>"}),W(H,{"aria-label":`at ${m} line ${u.line} column ${u.column}`,color:"gray",dimColor:!0,children:[" ","(",m,":",u.line,":",u.column,")"]})]},s)})}):null]})}x(ce,"b");de(ce,"ErrorOverview");var kr=Object.defineProperty,Dr=x((e,t)=>kr(e,"name",{value:t,configurable:!0}),"o$1");let $r=class extends Xe{static{x(this,"i")}static{Dr(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?T(ce,{error:this.state.error}):this.props.children}};var Lr=Object.defineProperty,Zt=x((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"J");const Ir=" ",Br="\x1B[Z",Mr="\x1B",Ar=se(oe),te=ne(oe),he=Zt(({children:e,exitOnCtrlC:t,interactive:r,onExit:i,onWaitUntilRenderFlush:o,renderThrottleMs:a,setCursorPosition:l,stderr:n,stdin:s,stdout:u,writeToStderr:m,writeToStdout:C})=>{const[g,c]=vt(!0),[h,b]=vt(void 0),[,w]=vt([]),D=_(0),S=_(new Map),I=_(void 0),$=_(0),A=_(!1),N=_(0),[E]=vt(()=>{const d=new Qe;return d.setMaxListeners(1/0),d}),Y=_(void 0),O=_(void 0);O.current??=Er();const j=_(void 0),$t=_(!1),ye=20,X=y(()=>{j.current&&(clearTimeout(j.current),j.current=void 0)},[]),J=y(()=>{I.current&&(clearTimeout(I.current),I.current=void 0)},[]),ft=y(()=>{if(J(),S.current.size===0)return;let d=Number.POSITIVE_INFINITY;for(const f of S.current.values())d=Math.min(d,f.nextDueTime);const p=Math.max(0,d-performance.now());I.current=setTimeout(()=>{I.current=void 0;const f=performance.now(),R=[...S.current.values()];for(const k of R){if(f<k.nextDueTime)continue;k.callback(f);const Ee=f-k.startTime,Ne=Math.floor(Ee/k.interval)+1;k.nextDueTime=k.startTime+Ne*k.interval}ft()},p)},[J]),Lt=y((d,p)=>{const f=performance.now();return S.current.set(d,{callback:d,interval:p,nextDueTime:f+p,startTime:f}),ft(),{startTime:f,unsubscribe(){if(S.current.delete(d),S.current.size===0){J();return}ft()}}},[J,ft]);Rt(()=>()=>{J()},[J]);const F=s.isTTY,It=y(()=>{Y.current&&(s.removeListener("readable",Y.current),Y.current=void 0)},[s]),pt=y(()=>{O.current?.reset(),X(),It()},[X,It]),Z=y(()=>{A.current=!1,s.setRawMode(!1),s.unref(),$.current=0,pt()},[s,pt]),ut=y(d=>{F&&($.current>0||A.current)&&Z(),i(d)},[F,Z,i]),Bt=y(d=>{if(d.includes("")&&t){ut();return}d===Mr&&g&&b(p=>{if(!p)return p})},[t,ut,g]),at=y(d=>{Bt(d),E.emit("input",d)},[Bt,E]),Mt=y(()=>{X(),j.current=setTimeout(()=>{j.current=void 0;const d=O.current.flushPendingEscape();d&&at(d)},ye)},[X,at]),Tt=y(()=>{X();let d;for(;(d=s.read())!==null;){const p=O.current.push(d);for(const f of p)if(typeof f=="string")at(f);else{if(E.listenerCount("paste")===0){$t.current||($t.current=!0,m(`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().
4
- `)),at(f.paste);continue}E.emit("paste",f.paste)}}O.current.hasPendingEscape()&&Mt()},[s,at,X,Mt,m,E]),At=y(()=>{Y.current||(Y.current=Tt,s.addListener("readable",Tt))},[s,Tt]),Wt=y(d=>{if(!F)throw s===M.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
3
+ const $e=De(import.meta.url),it=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ct=x(e=>{if(typeof it<"u"&&it.versions&&it.versions.node){const[t,r]=it.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return it.getBuiltinModule(e)}return $e(e)},"__cjs_getBuiltinModule"),M=it,{cwd:Le}=M,{Stream:Ie}=ct("node:stream"),{Buffer:Vt}=ct("node:buffer"),{Console:Be}=ct("node:console"),{EventEmitter:Qe}=ct("node:events"),{existsSync:er,readFileSync:rr}=ct("node:fs");var yr=Object.defineProperty,L=x((e,t)=>yr(e,"name",{value:t,configurable:!0}),"i$2");const ae="\x1B[200~",Qt="\x1B[201~",Cr=L(e=>e>=48&&e<=63,"isCsiParameterByte"),Tr=L(e=>e>=32&&e<=47,"isCsiIntermediateByte"),le=L(e=>e>=64&&e<=126,"isCsiFinalByte"),Rr=L((e,t,r)=>{const i=t+r+1;let o=i;for(;o<e.length;o++){const a=e.codePointAt(o);if(a===void 0)return"pending";if(!(Cr(a)||Tr(a))&&!(a===91&&o===i))return le(a)?{nextIndex:o+1,sequence:e.slice(t,o+1)}:void 0}return"pending"},"parseCsiSequence"),xr=L((e,t,r)=>{const i=t+r+2;if(i>e.length)return"pending";const o=e.codePointAt(i-1);if(!(o===void 0||!le(o)))return{nextIndex:i,sequence:e.slice(t,i)}},"parseSs3Sequence"),Xt=L((e,t,r)=>{const i=e[t+r];if(i===void 0)return"pending";if(i==="[")return Rr(e,t,r);if(i==="O")return xr(e,t,r)},"parseControlSequence"),Sr=L((e,t)=>{const r=e.codePointAt(t+1),i=r!==void 0&&r>65535?2:1,o=t+1+i;return{nextIndex:o,sequence:e.slice(t,o)}},"parseEscapedCodePoint"),Pr=L((e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]==="\x1B"){if(t+2>=e.length)return"pending";const i=Xt(e,t,2);return i==="pending"?"pending":i||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const r=Xt(e,t,1);return r==="pending"?"pending":r||Sr(e,t)},"parseEscapeSequence"),Jt=L((e,t)=>{let r=0;for(let i=0;i<e.length;i++){const o=e[i];(o===""||o==="\b")&&(i>r&&t.push(e.slice(r,i)),t.push(o),r=i+1)}r<e.length&&t.push(e.slice(r))},"splitDeleteAndBackspace"),Or=L(e=>{const t=[];let r=0;const i=L(o=>({events:t,pending:e.slice(o)}),"pendingFrom");for(;r<e.length;){const o=e.indexOf("\x1B",r);if(o===-1)return Jt(e.slice(r),t),{events:t,pending:""};o>r&&Jt(e.slice(r,o),t);const a=Pr(e,o);if(a==="pending")return i(o);if(a.sequence===ae){const l=a.nextIndex,n=e.indexOf(Qt,l);if(n===-1)return i(o);t.push({paste:e.slice(l,n)}),r=n+Qt.length;continue}t.push(a.sequence),r=a.nextIndex}return{events:t,pending:""}},"parseKeypresses"),Er=L(()=>{let e="";return{flushPendingEscape(){if(!e.startsWith("\x1B"))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith("\x1B")&&!e.startsWith(ae)&&e!=="\x1B[200"},push(t){const r=Or(e+t);return e=r.pending,r.events},reset(){e=""}}},"createInputParser");var Nr=Object.defineProperty,de=x((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"x");const xt=de(e=>{if(!e)return e;const t=Le();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")},"cleanupPath");function ce({error:e}){const t=ir(e),r=new Map,i=t.map(s=>{const u=!s.methodName&&!s.file?`raw:${s.raw}`:`${xt(s.file)??""}:${s.line}:${s.column}:${s.methodName??""}`,m=r.get(u)??0;return r.set(u,m+1),{key:`${u}#${m}`,trace:s}}),o=t[0],a=xt(o?.file);let l,n=0;if(a&&o?.line&&er(a)){const s=rr(a,"utf8");if(l=sr(s,o.line),l)for(const{line:u}of l)n=Math.max(n,String(u).length)}return A(H,{flexDirection:"column",padding:1,children:[A(H,{children:[A(U,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),A(U,{children:[" ",e.message]})]}),o&&a?T(H,{marginTop:1,children:A(U,{dimColor:!0,children:[a,":",o.line,":",o.column]})}):null,o&&l?T(H,{flexDirection:"column",marginTop:1,children:l.map(({line:s,value:u})=>A(H,{children:[T(H,{width:n+1,children:A(U,{"aria-label":s===o.line?`Line ${s}, error`:`Line ${s}`,backgroundColor:s===o.line?"red":void 0,color:s===o.line?"white":void 0,dimColor:s!==o.line,children:[String(s).padStart(n," "),":"]})}),T(U,{backgroundColor:s===o.line?"red":void 0,color:s===o.line?"white":void 0,children:` ${u}`})]},`excerpt-${s}`))}):null,t.length>0?T(H,{flexDirection:"column",marginTop:1,children:i.map(({key:s,trace:u})=>{const m=xt(u.file)??"";return!u.methodName&&!u.file?A(H,{children:[T(U,{dimColor:!0,children:"- "}),T(U,{bold:!0,dimColor:!0,children:u.raw})]},s):A(H,{children:[T(U,{dimColor:!0,children:"- "}),T(U,{bold:!0,dimColor:!0,children:u.methodName??"<anonymous>"}),A(U,{"aria-label":`at ${m} line ${u.line} column ${u.column}`,color:"gray",dimColor:!0,children:[" ","(",m,":",u.line,":",u.column,")"]})]},s)})}):null]})}x(ce,"b");de(ce,"ErrorOverview");var kr=Object.defineProperty,Dr=x((e,t)=>kr(e,"name",{value:t,configurable:!0}),"o$1");let $r=class extends Xe{static{x(this,"i")}static{Dr(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?T(ce,{error:this.state.error}):this.props.children}};var Lr=Object.defineProperty,Zt=x((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"J");const Ir=" ",Br="\x1B[Z",Mr="\x1B",Wr=se(oe),te=ne(oe),he=Zt(({children:e,exitOnCtrlC:t,interactive:r,onExit:i,onWaitUntilRenderFlush:o,renderThrottleMs:a,setCursorPosition:l,stderr:n,stdin:s,stdout:u,writeToStderr:m,writeToStdout:C})=>{const[g,c]=vt(!0),[h,b]=vt(void 0),[,w]=vt([]),D=_(0),S=_(new Map),I=_(void 0),$=_(0),W=_(!1),N=_(0),[E]=vt(()=>{const d=new Qe;return d.setMaxListeners(1/0),d}),Y=_(void 0),O=_(void 0);O.current??=Er();const j=_(void 0),$t=_(!1),ye=20,X=y(()=>{j.current&&(clearTimeout(j.current),j.current=void 0)},[]),J=y(()=>{I.current&&(clearTimeout(I.current),I.current=void 0)},[]),ft=y(()=>{if(J(),S.current.size===0)return;let d=Number.POSITIVE_INFINITY;for(const f of S.current.values())d=Math.min(d,f.nextDueTime);const p=Math.max(0,d-performance.now());I.current=setTimeout(()=>{I.current=void 0;const f=performance.now(),R=[...S.current.values()];for(const k of R){if(f<k.nextDueTime)continue;k.callback(f);const Ee=f-k.startTime,Ne=Math.floor(Ee/k.interval)+1;k.nextDueTime=k.startTime+Ne*k.interval}ft()},p)},[J]),Lt=y((d,p)=>{const f=performance.now();return S.current.set(d,{callback:d,interval:p,nextDueTime:f+p,startTime:f}),ft(),{startTime:f,unsubscribe(){if(S.current.delete(d),S.current.size===0){J();return}ft()}}},[J,ft]);Rt(()=>()=>{J()},[J]);const F=s.isTTY,It=y(()=>{Y.current&&(s.removeListener("readable",Y.current),Y.current=void 0)},[s]),pt=y(()=>{O.current?.reset(),X(),It()},[X,It]),Z=y(()=>{W.current=!1,s.setRawMode(!1),s.unref(),$.current=0,pt()},[s,pt]),ut=y(d=>{F&&($.current>0||W.current)&&Z(),i(d)},[F,Z,i]),Bt=y(d=>{if(d.includes("")&&t){ut();return}d===Mr&&g&&b(p=>{if(!p)return p})},[t,ut,g]),at=y(d=>{Bt(d),E.emit("input",d)},[Bt,E]),Mt=y(()=>{X(),j.current=setTimeout(()=>{j.current=void 0;const d=O.current.flushPendingEscape();d&&at(d)},ye)},[X,at]),Tt=y(()=>{X();let d;for(;(d=s.read())!==null;){const p=O.current.push(d);for(const f of p)if(typeof f=="string")at(f);else{if(E.listenerCount("paste")===0){$t.current||($t.current=!0,m(`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().
4
+ `)),at(f.paste);continue}E.emit("paste",f.paste)}}O.current.hasPendingEscape()&&Mt()},[s,at,X,Mt,m,E]),Wt=y(()=>{Y.current||(Y.current=Tt,s.addListener("readable",Tt))},[s,Tt]),At=y(d=>{if(!F)throw s===M.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
5
5
  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.
6
- Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(s.setEncoding("utf8"),d){if($.current===0){const p=A.current;A.current=!1,p||(s.ref(),s.setRawMode(!0)),At()}$.current++;return}$.current!==0&&--$.current===0&&(pt(),A.current=!0,queueMicrotask(()=>{A.current&&Z()}))},[F,s,At,pt,Z]),_t=y(d=>{if(u.isTTY){if(d){N.current===0&&u.write(Ar),N.current++;return}N.current!==0&&--N.current===0&&u.write(te)}},[u]),Ht=y((d,p)=>{const f=d.findIndex(R=>R.id===p);for(let R=f+1;R<d.length;R++){const k=d[R];if(k?.isActive)return k.id}},[]),Ut=y((d,p)=>{const f=d.findIndex(R=>R.id===p);for(let R=f-1;R>=0;R--){const k=d[R];if(k?.isActive)return k.id}},[]),mt=y(()=>{w(d=>(b(p=>{const f=d.find(R=>R.isActive)?.id;return Ht(d,p)??f}),d))},[Ht]),gt=y(()=>{w(d=>(b(p=>{const f=d.findLast(R=>R.isActive)?.id;return Ut(d,p)??f}),d))},[Ut]);Rt(()=>{const d=Zt(f=>{!g||D.current===0||(f===Ir&&mt(),f===Br&&gt())},"handleTabNavigation");E.on("input",d);const p=E;return()=>{p.off("input",d)}},[g,mt,gt,E]);const Kt=y(()=>{c(!0)},[]),jt=y(()=>{c(!1)},[]),Ft=y(d=>{w(p=>(p.some(f=>f?.id===d)&&b(d),p))},[]),qt=y((d,{autoFocus:p})=>{w(f=>(D.current=f.length+1,[...f,{id:d,isActive:!0}])),p&&b(f=>f||d)},[]),Yt=y(d=>{b(p=>{if(p!==d)return p}),w(p=>{const f=p.filter(R=>R.id!==d);return D.current=f.length,f})},[]),zt=y(d=>{w(p=>p.map(f=>f.id!==d?f:{id:d,isActive:!0}))},[]),Gt=y(d=>{b(p=>{if(p!==d)return p}),w(p=>p.map(f=>f.id!==d?f:{id:d,isActive:!1}))},[]);Rt(()=>()=>{const d=!u.destroyed&&!u.writableEnded;r&&d&&u.write(ht),F&&($.current>0||A.current)&&Z(),N.current>0&&(u.isTTY&&d&&u.write(te),N.current=0)},[u,F,Z,r]);const Ce=z(()=>({exit:ut,waitUntilRenderFlush:o}),[ut,o]),Te=z(()=>({internal_eventEmitter:E,internal_exitOnCtrlC:t,isRawModeSupported:F,setBracketedPasteMode:_t,setRawMode:Wt,stdin:s}),[s,Wt,_t,F,t,E]),Re=z(()=>({stdout:u,write:C}),[u,C]),xe=z(()=>({stderr:n,write:m}),[n,m]),Se=z(()=>({setCursorPosition:l}),[l]),Pe=z(()=>({activate:zt,activeId:h,add:qt,deactivate:Gt,disableFocus:jt,enableFocus:Kt,focus:Ft,focusNext:mt,focusPrevious:gt,remove:Yt}),[h,qt,Yt,zt,Gt,Kt,jt,mt,gt,Ft]),Oe=z(()=>({renderThrottleMs:a,subscribe:Lt}),[Lt,a]);return T(Ze.Provider,{value:Ce,children:T(ur.Provider,{value:Te,children:T(ar.Provider,{value:Re,children:T(nr.Provider,{value:xe,children:T(or.Provider,{value:Pe,children:T(Je.Provider,{value:Oe,children:T(tr.Provider,{value:Se,children:T($r,{onError:ut,children:e})})})})})})})})},"App");he.displayName="InternalApp";var Wr=Object.defineProperty,_r=x((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"m$2");const Hr=_r((e,t,r)=>{if(r<=0||!e.yogaNode)return"";const{yogaNode:i}=e,o=i.getComputedBorder(K.EDGE_LEFT),a=i.getComputedBorder(K.EDGE_RIGHT),l=i.getComputedBorder(K.EDGE_TOP),n=i.getComputedPadding(K.EDGE_LEFT),s=i.getComputedPadding(K.EDGE_RIGHT),u=i.getComputedPadding(K.EDGE_TOP),m=Math.round(i.getComputedWidth()-o-a-n-s);if(m<=0)return"";const C=new lr({height:r,width:m}),g=-(e.internal_scrollState?.scrollLeft??0)-o-n,c=-t-l-u;for(const h of e.childNodes)dr(h,C,{absoluteOffsetX:g,absoluteOffsetY:c,offsetX:g,offsetY:c,skipStaticElements:!1});return C.get().output},"composeBackbufferSlice"),Ot=new WeakMap;var Ur=Object.defineProperty,nt=x((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"e");const Kr={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},ee=nt(e=>Me(Kr[e]),"buildCursorShapeSequence"),wt=nt((e,t)=>e?.x!==t?.x||e?.y!==t?.y,"cursorPositionChanged"),ot=nt((e,t)=>{if(!t)return"";const r=e-t.y;return(r>0?Pt(r):"")+kt(t.x)+ht},"buildCursorSuffix"),fe=nt((e,t)=>{if(!t)return"";const r=e-1-t.y;return(r>0?Ae(r):"")+kt(0)},"buildReturnToBottom"),pe=nt(e=>{const t=e.cursorWasShown?Q:"",r=fe(e.previousLineCount,e.previousCursorPosition),i=ot(e.visibleLineCount,e.cursorPosition);return t+r+i},"buildCursorOnlySequence"),yt=nt((e,t,r)=>e?Q+fe(t,r):"","buildReturnToBottomPrefix");var jr=Object.defineProperty,P=x((e,t)=>jr(e,"name",{value:t,configurable:!0}),"l");const et=P(e=>e??"default","normalizeShape"),me=P(()=>{let e,t;return{consumeDelta:P(()=>{if(et(t)===et(e))return"";const r=et(t);return e=t,ee(r)},"consumeDelta"),consumeRestoreOnDone:P(()=>{const r=et(e)!=="default";return e=void 0,t=void 0,r?ee("default"):""},"consumeRestoreOnDone"),isDirty:P(()=>et(t)!==et(e),"isDirty"),setPending:P(r=>{t=r},"setPending")}},"createCursorShapeTracker"),dt=P((e,t)=>t.endsWith(`
6
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(s.setEncoding("utf8"),d){if($.current===0){const p=W.current;W.current=!1,p||(s.ref(),s.setRawMode(!0)),Wt()}$.current++;return}$.current!==0&&--$.current===0&&(pt(),W.current=!0,queueMicrotask(()=>{W.current&&Z()}))},[F,s,Wt,pt,Z]),_t=y(d=>{if(u.isTTY){if(d){N.current===0&&u.write(Wr),N.current++;return}N.current!==0&&--N.current===0&&u.write(te)}},[u]),Ut=y((d,p)=>{const f=d.findIndex(R=>R.id===p);for(let R=f+1;R<d.length;R++){const k=d[R];if(k?.isActive)return k.id}},[]),Ht=y((d,p)=>{const f=d.findIndex(R=>R.id===p);for(let R=f-1;R>=0;R--){const k=d[R];if(k?.isActive)return k.id}},[]),mt=y(()=>{w(d=>(b(p=>{const f=d.find(R=>R.isActive)?.id;return Ut(d,p)??f}),d))},[Ut]),gt=y(()=>{w(d=>(b(p=>{const f=d.findLast(R=>R.isActive)?.id;return Ht(d,p)??f}),d))},[Ht]);Rt(()=>{const d=Zt(f=>{!g||D.current===0||(f===Ir&&mt(),f===Br&&gt())},"handleTabNavigation");E.on("input",d);const p=E;return()=>{p.off("input",d)}},[g,mt,gt,E]);const Kt=y(()=>{c(!0)},[]),jt=y(()=>{c(!1)},[]),Ft=y(d=>{w(p=>(p.some(f=>f?.id===d)&&b(d),p))},[]),qt=y((d,{autoFocus:p})=>{w(f=>(D.current=f.length+1,[...f,{id:d,isActive:!0}])),p&&b(f=>f||d)},[]),Yt=y(d=>{b(p=>{if(p!==d)return p}),w(p=>{const f=p.filter(R=>R.id!==d);return D.current=f.length,f})},[]),zt=y(d=>{w(p=>p.map(f=>f.id!==d?f:{id:d,isActive:!0}))},[]),Gt=y(d=>{b(p=>{if(p!==d)return p}),w(p=>p.map(f=>f.id!==d?f:{id:d,isActive:!1}))},[]);Rt(()=>()=>{const d=!u.destroyed&&!u.writableEnded;r&&d&&u.write(ht),F&&($.current>0||W.current)&&Z(),N.current>0&&(u.isTTY&&d&&u.write(te),N.current=0)},[u,F,Z,r]);const Ce=z(()=>({exit:ut,waitUntilRenderFlush:o}),[ut,o]),Te=z(()=>({internal_eventEmitter:E,internal_exitOnCtrlC:t,isRawModeSupported:F,setBracketedPasteMode:_t,setRawMode:At,stdin:s}),[s,At,_t,F,t,E]),Re=z(()=>({stdout:u,write:C}),[u,C]),xe=z(()=>({stderr:n,write:m}),[n,m]),Se=z(()=>({setCursorPosition:l}),[l]),Pe=z(()=>({activate:zt,activeId:h,add:qt,deactivate:Gt,disableFocus:jt,enableFocus:Kt,focus:Ft,focusNext:mt,focusPrevious:gt,remove:Yt}),[h,qt,Yt,zt,Gt,Kt,jt,mt,gt,Ft]),Oe=z(()=>({renderThrottleMs:a,subscribe:Lt}),[Lt,a]);return T(Ze.Provider,{value:Ce,children:T(ur.Provider,{value:Te,children:T(ar.Provider,{value:Re,children:T(nr.Provider,{value:xe,children:T(or.Provider,{value:Pe,children:T(Je.Provider,{value:Oe,children:T(tr.Provider,{value:Se,children:T($r,{onError:ut,children:e})})})})})})})})},"App");he.displayName="InternalApp";var Ar=Object.defineProperty,_r=x((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"m$2");const Ur=_r((e,t,r)=>{if(r<=0||!e.yogaNode)return"";const{yogaNode:i}=e,o=i.getComputedBorder(K.EDGE_LEFT),a=i.getComputedBorder(K.EDGE_RIGHT),l=i.getComputedBorder(K.EDGE_TOP),n=i.getComputedPadding(K.EDGE_LEFT),s=i.getComputedPadding(K.EDGE_RIGHT),u=i.getComputedPadding(K.EDGE_TOP),m=Math.round(i.getComputedWidth()-o-a-n-s);if(m<=0)return"";const C=new lr({height:r,width:m}),g=-(e.internal_scrollState?.scrollLeft??0)-o-n,c=-t-l-u;for(const h of e.childNodes)dr(h,C,{absoluteOffsetX:g,absoluteOffsetY:c,offsetX:g,offsetY:c,skipStaticElements:!1});return C.get().output},"composeBackbufferSlice"),Ot=new WeakMap;var Hr=Object.defineProperty,nt=x((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"e");const Kr={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},ee=nt(e=>Me(Kr[e]),"buildCursorShapeSequence"),wt=nt((e,t)=>e?.x!==t?.x||e?.y!==t?.y,"cursorPositionChanged"),ot=nt((e,t)=>{if(!t)return"";const r=e-t.y;return(r>0?Pt(r):"")+kt(t.x)+ht},"buildCursorSuffix"),fe=nt((e,t)=>{if(!t)return"";const r=e-1-t.y;return(r>0?We(r):"")+kt(0)},"buildReturnToBottom"),pe=nt(e=>{const t=e.cursorWasShown?Q:"",r=fe(e.previousLineCount,e.previousCursorPosition),i=ot(e.visibleLineCount,e.cursorPosition);return t+r+i},"buildCursorOnlySequence"),yt=nt((e,t,r)=>e?Q+fe(t,r):"","buildReturnToBottomPrefix");var jr=Object.defineProperty,P=x((e,t)=>jr(e,"name",{value:t,configurable:!0}),"l");const et=P(e=>e??"default","normalizeShape"),me=P(()=>{let e,t;return{consumeDelta:P(()=>{if(et(t)===et(e))return"";const r=et(t);return e=t,ee(r)},"consumeDelta"),consumeRestoreOnDone:P(()=>{const r=et(e)!=="default";return e=void 0,t=void 0,r?ee("default"):""},"consumeRestoreOnDone"),isDirty:P(()=>et(t)!==et(e),"isDirty"),setPending:P(r=>{t=r},"setPending")}},"createCursorShapeTracker"),dt=P((e,t)=>t.endsWith(`
7
7
  `)?e.length-1:e.length,"visibleLineCount"),ge=P(e=>e.rows||1/0,"getViewportRows"),Ct=P((e,t)=>Math.min(e,ge(t)),"clampToViewport"),Fr=P((e,{showCursor:t=!1}={})=>{let r=0,i="",o=!1,a,l=!1,n,s=!1;const u=me(),m=P(()=>l?a:void 0,"getActiveCursor"),C=P((c,h)=>{const b=wt(h,n);return c!==i||b||u.isDirty()},"hasChanges"),g=P(c=>{!t&&!o&&(e.write(Q),o=!0);const h=m();l=!1;const b=wt(h,n);if(!C(c,h))return!1;const w=u.consumeDelta(),D=c.split(`
8
8
  `),S=dt(D,c),I=ot(S,h);if(c===i&&b)e.write(w+pe({cursorPosition:h,cursorWasShown:s,previousCursorPosition:n,previousLineCount:r,visibleLineCount:S}));else if(c===i&&w!=="")e.write(w);else{i=c;const $=yt(s,r,n);e.write(w+$+V(Ct(r,e))+c+I),r=D.length}return n=h?{...h}:void 0,s=h!==void 0,!0},"render");return g.clear=()=>{const c=yt(s,r,n);e.write(c+V(Ct(r,e))),i="",r=0,n=void 0,s=!1},g.done=()=>{i="",r=0,n=void 0,s=!1;const c=u.consumeRestoreOnDone();c!==""&&e.write(c),t||(e.write(ht),o=!1)},g.reset=()=>{i="",r=0,n=void 0,s=!1},g.sync=c=>{const h=l?a:void 0;l=!1;const b=c.split(`
9
9
  `);i=c,r=b.length;const w=u.consumeDelta();w!==""&&e.write(w),!h&&s&&e.write(Q),h&&e.write(ot(dt(b,c),h)),n=h?{...h}:void 0,s=h!==void 0},g.setCursorPosition=c=>{a=c,l=!0},g.setCursorShape=u.setPending,g.isCursorDirty=()=>l||u.isDirty(),g.willRender=c=>C(c,m()),g},"createStandard"),qr=P((e,{showCursor:t=!1}={})=>{let r=[],i="",o=!1,a,l=!1,n,s=!1;const u=me(),m=P(()=>l?a:void 0,"getActiveCursor"),C=P((c,h)=>{const b=wt(h,n);return c!==i||b||u.isDirty()},"hasChanges"),g=P(c=>{!t&&!o&&(e.write(Q),o=!0);const h=m();l=!1;const b=wt(h,n);if(!C(c,h))return!1;const w=u.consumeDelta(),D=c.split(`
10
10
  `),S=dt(D,c),I=dt(r,i);if(c===i&&b)return e.write(w+pe({cursorPosition:h,cursorWasShown:s,previousCursorPosition:n,previousLineCount:r.length,visibleLineCount:S})),n=h?{...h}:void 0,s=h!==void 0,!0;if(c===i&&w!=="")return e.write(w),!0;const $=yt(s,r.length,n);if(c===`
11
- `||i.length===0){const O=ot(S,h);return e.write(w+$+V(Ct(r.length,e))+c+O),s=h!==void 0,n=h?{...h}:void 0,i=c,r=D,!0}const A=c.endsWith(`
11
+ `||i.length===0){const O=ot(S,h);return e.write(w+$+V(Ct(r.length,e))+c+O),s=h!==void 0,n=h?{...h}:void 0,i=c,r=D,!0}const W=c.endsWith(`
12
12
  `),N=[w,$],E=ge(e);if(S<I){const O=i.endsWith(`
13
- `)?1:0;N.push(V(Math.min(I-S+O,E)),Pt(Math.min(S,E-1)))}else N.push(Pt(Math.min(I-1,E-1)));for(let O=0;O<S;O++){const j=O===S-1;if(D[O]===r[O]){(!j||A)&&N.push(We());continue}N.push(kt(0)+D[O]+_e+(j&&!A?"":`
13
+ `)?1:0;N.push(V(Math.min(I-S+O,E)),Pt(Math.min(S,E-1)))}else N.push(Pt(Math.min(I-1,E-1)));for(let O=0;O<S;O++){const j=O===S-1;if(D[O]===r[O]){(!j||W)&&N.push(Ae());continue}N.push(kt(0)+D[O]+_e+(j&&!W?"":`
14
14
  `))}const Y=ot(S,h);return N.push(Y),e.write(N.join("")),s=h!==void 0,n=h?{...h}:void 0,i=c,r=D,!0},"render");return g.clear=()=>{const c=yt(s,r.length,n);e.write(c+V(Ct(r.length,e))),i="",r=[],n=void 0,s=!1},g.done=()=>{i="",r=[],n=void 0,s=!1;const c=u.consumeRestoreOnDone();c!==""&&e.write(c),t||(e.write(ht),o=!1)},g.reset=()=>{i="",r=[],n=void 0,s=!1},g.sync=c=>{const h=l?a:void 0;l=!1;const b=c.split(`
15
- `);i=c,r=b;const w=u.consumeDelta();w!==""&&e.write(w),!h&&s&&e.write(Q),h&&e.write(ot(dt(b,c),h)),n=h?{...h}:void 0,s=h!==void 0},g.setCursorPosition=c=>{a=c,l=!0},g.setCursorShape=u.setPending,g.isCursorDirty=()=>l||u.isDirty(),g.willRender=c=>C(c,m()),g},"createIncremental"),Yr=P((e,{incremental:t=!1,showCursor:r=!1}={})=>t?qr(e,{showCursor:r}):Fr(e,{showCursor:r}),"create"),zr={create:Yr};var Gr=Object.defineProperty,Vr=x((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"t");const ve=He(2026),G=se(ve),q=ne(ve);function be(e,t){return"isTTY"in e&&e.isTTY&&(t??!ue)}x(be,"shouldSynchronize");Vr(be,"shouldSynchronize");var Qr=Object.defineProperty,Et=x((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"o");let rt;const Xr=Et(()=>{if(rt!==!1){if(rt!==void 0)return rt;try{return rt=require("../../index.js").Renderer,rt}catch{rt=!1;return}}},"getRendererClass"),Jr=Et(e=>{const t=Xr();if(!t)return;let r,i=0,o=0;const a=Et((l,n)=>{(!r||i!==l||o!==n)&&(r?r.resize(l,n):r=new t(l,n),i=l,o=n)},"ensureRenderer");return{clear(){if(r){const l=new Uint32Array(i*o*2),n=65535;for(let s=0;s<l.length;s+=2)l[s]=32,l[s+1]=n;r.render(l)}},destroy(){r=void 0},render(l,n,s){if(a(n,s),!!r){e.isTTY&&r.writeRaw(G);try{r.render(l)}finally{e.isTTY&&r.writeRaw(q)}}},resize(l,n){a(l,n)}}},"createNative");var Zr=Object.defineProperty,st=x((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"n$1");function Nt(e,t=0,r={}){const i=r.leading??!0,o=r.trailing??!0;let a,l,n,s;const u=st(()=>{if(l===void 0)return;const h=l;l=void 0,s=e(...h)},"invoke"),m=st(()=>{a!==void 0&&(clearTimeout(a),a=void 0)},"clearTimer"),C=st(()=>{a=void 0,o&&u(),l=void 0,n=void 0},"onTimerEnd"),g=st(()=>{m(),a=setTimeout(C,t)},"scheduleTimer"),c=st(function(...h){const b=Date.now();if(n??=b,b-n>=t)return l=h,u(),n=b,g(),s;l=h;const w=a===void 0;return g(),i&&w&&u(),s},"throttled");return c.cancel=()=>{m(),l=void 0,n=void 0},c.flush=()=>(m(),u(),n=void 0,s),c}x(Nt,"throttle");st(Nt,"throttle");var ti=Object.defineProperty,v=x((e,t)=>ti(e,"name",{value:t,configurable:!0}),"n");console.Console||(console.Console=Be);const lt=v(()=>{},"noop"),re=v(async()=>new Promise(e=>{setImmediate(e)}),"yieldImmediate"),ei=27,ri=91,ii=63,si=117,oi=48,ni=57,ui=v(e=>e>=oi&&e<=ni,"isDigitByte"),we=v((e,t)=>{if(e[t]!==ei||e[t+1]!==ri||e[t+2]!==ii)return;let r=t+3;const i=r;for(;r<e.length&&ui(e[r]);)r++;if(r!==i){if(r===e.length)return{state:"partial"};if(e[r]===si)return{endIndex:r,state:"complete"}}},"matchKittyQueryResponse"),ai=v(e=>{for(let t=0;t<e.length;t++)if(we(e,t)?.state==="complete")return!0;return!1},"hasCompleteKittyQueryResponse"),li=v(e=>{const t=[];let r=0;for(;r<e.length;){const i=we(e,r);if(i?.state==="complete"){r=i.endIndex+1;continue}if(i?.state==="partial")break;t.push(e[r]),r++}return t},"stripKittyQueryResponsesAndTrailingPartial"),di=v(({isTty:e,isUnmounting:t,nextOutputHeight:r,previousOutputHeight:i,viewportRows:o})=>{if(!e)return!1;const a=i>0,l=i>=o,n=i>o,s=r>o,u=l&&r<o;return n||s&&a||u||t&&l},"shouldClearTerminalForFrame"),St=v(e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]","isErrorInput"),ie=v(e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),r=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:r}},"getWritableStreamState"),bt=v((e,t)=>{if(!e||typeof e.flush!="function")return;const r=e;t?r.flush():typeof r.cancel=="function"&&r.cancel()},"settleThrottle");class ci{static{x(this,"yt")}static{v(this,"Ink")}isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=fr("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??M.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const r=t.debug||this.isScreenReaderEnabled,i=t.maxFps??30,o=i>0?Math.max(1,Math.ceil(1e3/i)):0;this.renderThrottleMs=r?0:o;const a=r?this.onRender:(()=>{const n=Nt(this.onRender,o,{leading:!0,trailing:!0});return this.throttledOnRender=n,()=>{this.hasPendingThrottledRender=!0,n()}})();if(r&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let n=!1;const s=v(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,this.onRender()}))},"deferredRender");this.rootNode.onRender=s,this.rootNode.onImmediateRender=s}else this.rootNode.onRender=a,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=zr.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Jr(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=r?this.log:Nt(n=>{const s=this.log.willRender(n),u=this.shouldSync();u&&s&&this.options.stdout.write(G),this.log(n),u&&s&&this.options.stdout.write(q)},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=tt(this.options.stdout).columns,this.fullStaticOutput="";const l=t.concurrent?Ye:ze;this.container=B.createContainer(this.rootNode,l,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=Ge(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(),M.env.DEV==="true"&&B.injectIntoDevTools(),this.exitPromise=new Promise((n,s)=>{this.resolveExitPromise=n,this.rejectExitPromise=s}),this.exitPromise.catch(lt)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=v(()=>{const t=tt(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),gr(),this.calculateLayout(),pr(this.rootNode),this.onRender(),this.lastTerminalWidth=t},"resized");resolveExitPromise=v(()=>{},"resolveExitPromise");rejectExitPromise=v(()=>{},"rejectExitPromise");unsubscribeExit=v(()=>{},"unsubscribeExit");handleAppExit=v(t=>{if(!(this.isUnmounted||this.isUnmounting)){if(St(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}},"handleAppExit");getActiveCursorPosition=v(()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition,"getActiveCursorPosition");setCursorPosition=v(t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())},"setCursorPosition");restoreLastOutput=v(()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
16
- `))},"restoreLastOutput");calculateLayout=v(()=>{const t=v(i=>{const o=new Map;this.calculateScrollAndTriggerObservers(i,o);for(const[a,l]of o)a.internalTrigger(l)},"flushLayoutObservers");this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const r=tt(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(r),this.rootNode.yogaNode.calculateLayout(void 0,void 0,K.DIRECTION_LTR),t(this.rootNode)},"calculateLayout");calculateScrollAndTriggerObservers(t,r){if(t.nodeName==="ink-box"){const{style:i}=t,o=i.overflow??"visible",a=i.overflowX??o,l=i.overflowY??o;a==="scroll"||l==="scroll"?(wr(t),i.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(br(t,r),!t.internal_static)for(const i of t.childNodes)i.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(i,r)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,r){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),vr(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let i=0;for(const o of t.childNodes){const a=o;o.nodeName!=="#text"&&a.yogaNode&&(t.yogaNode.insertChild(a.yogaNode,i),i++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const i of t.childNodes)i.nodeName!=="#text"&&this.prepareYogaTree(i,r);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const i=tt(this.options.stdout).columns,{width:o}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof o=="number"?o:i),t.yogaNode.calculateLayout(void 0,void 0,K.DIRECTION_LTR)),r(t),cr(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 r of t.childNodes)r.nodeName!=="#text"&&this.markAllTextNodesDirty(r)}}handleStaticChange=v(()=>{this.fullStaticOutput=""},"handleStaticChange");computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const r=Math.round(t.internal_scrollState.scrollTop),i=t.yogaNode?.getComputedPadding(K.EDGE_TOP)??0,o=Math.max(0,r-Math.round(i)),a=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:l}=t.style,n=l===void 0?a:Math.max(a,o-Math.max(0,l)),s=o-n;if(s<=0)return"";const u=Hr(t,n,s);return u===""?"":(t.internal_maxPushedScrollTop=o,`${u}\x1B[0m
15
+ `);i=c,r=b;const w=u.consumeDelta();w!==""&&e.write(w),!h&&s&&e.write(Q),h&&e.write(ot(dt(b,c),h)),n=h?{...h}:void 0,s=h!==void 0},g.setCursorPosition=c=>{a=c,l=!0},g.setCursorShape=u.setPending,g.isCursorDirty=()=>l||u.isDirty(),g.willRender=c=>C(c,m()),g},"createIncremental"),Yr=P((e,{incremental:t=!1,showCursor:r=!1}={})=>t?qr(e,{showCursor:r}):Fr(e,{showCursor:r}),"create"),zr={create:Yr};var Gr=Object.defineProperty,Vr=x((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"t");const ve=Ue(2026),G=se(ve),q=ne(ve);function be(e,t){return"isTTY"in e&&e.isTTY&&(t??!ue)}x(be,"shouldSynchronize");Vr(be,"shouldSynchronize");var Qr=Object.defineProperty,Et=x((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"o");let rt;const Xr=Et(()=>{if(rt!==!1){if(rt!==void 0)return rt;try{return rt=require("../../index.js").Renderer,rt}catch{rt=!1;return}}},"getRendererClass"),Jr=Et(e=>{const t=Xr();if(!t)return;let r,i=0,o=0;const a=Et((l,n)=>{(!r||i!==l||o!==n)&&(r?r.resize(l,n):r=new t(l,n),i=l,o=n)},"ensureRenderer");return{clear(){if(r){const l=new Uint32Array(i*o*2),n=65535;for(let s=0;s<l.length;s+=2)l[s]=32,l[s+1]=n;r.render(l)}},destroy(){r=void 0},render(l,n,s){if(a(n,s),!!r){e.isTTY&&r.writeRaw(G);try{r.render(l)}finally{e.isTTY&&r.writeRaw(q)}}},resize(l,n){a(l,n)}}},"createNative");var Zr=Object.defineProperty,st=x((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"n$1");function Nt(e,t=0,r={}){const i=r.leading??!0,o=r.trailing??!0;let a,l,n,s;const u=st(()=>{if(l===void 0)return;const h=l;l=void 0,s=e(...h)},"invoke"),m=st(()=>{a!==void 0&&(clearTimeout(a),a=void 0)},"clearTimer"),C=st(()=>{a=void 0,o&&u(),l=void 0,n=void 0},"onTimerEnd"),g=st(()=>{m(),a=setTimeout(C,t)},"scheduleTimer"),c=st(function(...h){const b=Date.now();if(n??=b,b-n>=t)return l=h,u(),n=b,g(),s;l=h;const w=a===void 0;return g(),i&&w&&u(),s},"throttled");return c.cancel=()=>{m(),l=void 0,n=void 0},c.flush=()=>(m(),u(),n=void 0,s),c}x(Nt,"throttle");st(Nt,"throttle");var ti=Object.defineProperty,v=x((e,t)=>ti(e,"name",{value:t,configurable:!0}),"n");console.Console||(console.Console=Be);const lt=v(()=>{},"noop"),re=v(async()=>new Promise(e=>{setImmediate(e)}),"yieldImmediate"),ei=27,ri=91,ii=63,si=117,oi=48,ni=57,ui=v(e=>e>=oi&&e<=ni,"isDigitByte"),we=v((e,t)=>{if(e[t]!==ei||e[t+1]!==ri||e[t+2]!==ii)return;let r=t+3;const i=r;for(;r<e.length&&ui(e[r]);)r++;if(r!==i){if(r===e.length)return{state:"partial"};if(e[r]===si)return{endIndex:r,state:"complete"}}},"matchKittyQueryResponse"),ai=v(e=>{for(let t=0;t<e.length;t++)if(we(e,t)?.state==="complete")return!0;return!1},"hasCompleteKittyQueryResponse"),li=v(e=>{const t=[];let r=0;for(;r<e.length;){const i=we(e,r);if(i?.state==="complete"){r=i.endIndex+1;continue}if(i?.state==="partial")break;t.push(e[r]),r++}return t},"stripKittyQueryResponsesAndTrailingPartial"),di=v(({isTty:e,isUnmounting:t,nextOutputHeight:r,previousOutputHeight:i,viewportRows:o})=>{if(!e)return!1;const a=i>0,l=i>=o,n=i>o,s=r>o,u=l&&r<o;return n||s&&a||u||t&&l},"shouldClearTerminalForFrame"),St=v(e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]","isErrorInput"),ie=v(e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),r=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:r}},"getWritableStreamState"),bt=v((e,t)=>{if(!e||typeof e.flush!="function")return;const r=e;t?r.flush():typeof r.cancel=="function"&&r.cancel()},"settleThrottle");class ci{static{x(this,"yt")}static{v(this,"Ink")}isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=fr("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??M.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const r=t.debug||this.isScreenReaderEnabled,i=t.maxFps??30,o=i>0?Math.max(1,Math.ceil(1e3/i)):0;this.renderThrottleMs=r?0:o;const a=r?this.onRender:(()=>{const n=Nt(this.onRender,o,{leading:!0,trailing:!0});return this.throttledOnRender=n,()=>{this.hasPendingThrottledRender=!0,n()}})();if(r&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let n=!1;const s=v(()=>{n||(n=!0,queueMicrotask(()=>{n=!1,this.onRender()}))},"deferredRender");this.rootNode.onRender=s,this.rootNode.onImmediateRender=s}else this.rootNode.onRender=a,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=zr.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Jr(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=r?this.log:Nt(n=>{const s=this.log.willRender(n),u=this.shouldSync();u&&s&&this.options.stdout.write(G),this.log(n),u&&s&&this.options.stdout.write(q)},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=tt(this.options.stdout).columns,this.fullStaticOutput="";const l=t.concurrent?Ye:ze;this.container=B.createContainer(this.rootNode,l,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=Ge(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(),M.env.DEV==="true"&&B.injectIntoDevTools(),this.exitPromise=new Promise((n,s)=>{this.resolveExitPromise=n,this.rejectExitPromise=s}),this.exitPromise.catch(lt)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=v(()=>{const t=tt(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),gr(),this.calculateLayout(),pr(this.rootNode),this.onRender(),this.lastTerminalWidth=t},"resized");resolveExitPromise=v(()=>{},"resolveExitPromise");rejectExitPromise=v(()=>{},"rejectExitPromise");unsubscribeExit=v(()=>{},"unsubscribeExit");handleAppExit=v(t=>{if(!(this.isUnmounted||this.isUnmounting)){if(St(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}},"handleAppExit");getActiveCursorPosition=v(()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition,"getActiveCursorPosition");setCursorPosition=v(t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())},"setCursorPosition");restoreLastOutput=v(()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
16
+ `))},"restoreLastOutput");calculateLayout=v(()=>{const t=v(i=>{const o=new Map;this.calculateScrollAndTriggerObservers(i,o);for(const[a,l]of o)a.internalTrigger(l)},"flushLayoutObservers");this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const r=tt(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(r),this.rootNode.yogaNode.calculateLayout(void 0,void 0,K.DIRECTION_LTR),t(this.rootNode)},"calculateLayout");calculateScrollAndTriggerObservers(t,r){if(t.nodeName==="ink-box"){const{style:i}=t,o=i.overflow??"visible",a=i.overflowX??o,l=i.overflowY??o;a==="scroll"||l==="scroll"?(wr(t),i.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(br(t,r),!t.internal_static)for(const i of t.childNodes)i.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(i,r)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,r){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),vr(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let i=0;for(const o of t.childNodes){const a=o;o.nodeName!=="#text"&&a.yogaNode&&(t.yogaNode.insertChild(a.yogaNode,i),i++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const i of t.childNodes)i.nodeName!=="#text"&&this.prepareYogaTree(i,r);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const i=tt(this.options.stdout).columns,{width:o}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof o=="number"?o:i),t.yogaNode.calculateLayout(void 0,void 0,K.DIRECTION_LTR)),r(t),cr(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 r of t.childNodes)r.nodeName!=="#text"&&this.markAllTextNodesDirty(r)}}handleStaticChange=v(()=>{this.fullStaticOutput=""},"handleStaticChange");computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const r=Math.round(t.internal_scrollState.scrollTop),i=t.yogaNode?.getComputedPadding(K.EDGE_TOP)??0,o=Math.max(0,r-Math.round(i)),a=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:l}=t.style,n=l===void 0?a:Math.max(a,o-Math.max(0,l)),s=o-n;if(s<=0)return"";const u=Ur(t,n,s);return u===""?"":(t.internal_maxPushedScrollTop=o,`${u}\x1B[0m
17
17
  `)}onRender=v(()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=hr(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:r,cursorRequested:i,cursorShape:o,output:a,outputBuffer:l,outputHeight:n,outputWidth:s,staticOutput:u}=t;this.renderedCursorRequested=i,this.renderedCursorPosition=r,this.log.setCursorShape(i?o:void 0);const m=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&l&&s){u&&u!==`
18
18
  `&&this.options.stdout.write(u),m&&this.options.stdout.write(m),this.nativeLog.render(l,s,n),this.lastOutputHeight=n;return}i&&this.log.setCursorPosition(this.getActiveCursorPosition());const C=u&&u!==`
19
19
  `;if(this.options.debug){C&&(this.fullStaticOutput+=u),this.lastOutput=a,this.lastOutputToRender=a,this.lastOutputHeight=n,this.options.stdout.write(this.fullStaticOutput+a);return}if(!this.interactive){C&&this.options.stdout.write(u),this.lastOutput=a,this.lastOutputToRender=`${a}
@@ -21,6 +21,6 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
21
21
  `).length,g&&this.options.stdout.write(q);return}C&&(this.fullStaticOutput+=u),this.renderInteractiveFrame(a,n,C?u:"",m)},"onRender");accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const r=T(Ve.Provider,{value:this.accessibilityContextValue,children:T(he,{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?B.updateContainer(r,this.container,null,lt):(B.updateContainerSync(r,this.container,null,lt),B.flushSyncWork())}writeToStdout=v(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 r=this.shouldSync();r&&this.options.stdout.write(G),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),r&&this.options.stdout.write(q)},"writeToStdout");writeToStderr=v(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 r=this.shouldSync();r&&this.options.stdout.write(G),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),r&&this.options.stdout.write(q)},"writeToStderr");unmount=v(t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(M.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const r=this.options.stdout,{canWriteToStdout:i,hasWritableState:o}=ie(r);bt(this.throttledOnRender,i),i&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),bt(this.throttledLog,i),typeof this.restoreConsole=="function"&&this.restoreConsole();const a=v(()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),i&&(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,je),this.writeBestEffort(this.options.stdout,ht),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
22
22
  `:`${this.lastOutput}
23
23
  `)),this.kittyProtocolEnabled=!1,Ot.delete(this.options.stdout);const{exitResult:n}=this,s=v(()=>{St(t)?this.rejectExitPromise(t):this.resolveExitPromise(n)},"resolveOrReject");t!==void 0&&!St(t)?s():i&&o?this.options.stdout.write("",s):setImmediate(s)},"finishUnmount"),l=B;this.options.concurrent?(B.updateContainerSync(null,this.container,null,lt),B.flushSyncWork(),l.flushPassiveEffects?.(),a()):(B.updateContainerSync(null,this.container,null,lt),B.flushSyncWork(),a())},"unmount");async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},M.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await re(),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}B.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:r,hasWritableState:i}=ie(t);if(bt(this.throttledOnRender,r),bt(this.throttledLog,r),r&&i){await new Promise(o=>{this.options.stdout.write("",()=>{o()})});return}await re()}clear(){this.interactive&&!this.options.debug&&(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
24
- `))}patchConsole(){this.options.debug||(this.restoreConsole=qe((t,r)=>{t==="stdout"&&this.writeToStdout(r),t==="stderr"&&(r.startsWith("The above error occurred")||this.writeToStderr(r))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Ue),this.writeBestEffort(this.options.stdout,Q))}resolveInteractiveOption(t){return t??(!ue&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(t,r){return!!t&&r&&!!this.options.stdout.isTTY}shouldSync(){return be(this.options.stdout,this.interactive)}writeBestEffort(t,r){try{t.write(r)}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 r=new Promise(i=>{t=i});this.nextRenderCommit={promise:r,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,r,i,o=""){const a=i+o,l=a!=="",n=this.options.stdout.isTTY,s=n?tt(this.options.stdout).rows:24,u=n&&r>=s?t:`${t}
24
+ `))}patchConsole(){this.options.debug||(this.restoreConsole=qe((t,r)=>{t==="stdout"&&this.writeToStdout(r),t==="stderr"&&(r.startsWith("The above error occurred")||this.writeToStderr(r))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,He),this.writeBestEffort(this.options.stdout,Q))}resolveInteractiveOption(t){return t??(!ue&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(t,r){return!!t&&r&&!!this.options.stdout.isTTY}shouldSync(){return be(this.options.stdout,this.interactive)}writeBestEffort(t,r){try{t.write(r)}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 r=new Promise(i=>{t=i});this.nextRenderCommit={promise:r,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,r,i,o=""){const a=i+o,l=a!=="",n=this.options.stdout.isTTY,s=n?tt(this.options.stdout).rows:24,u=n&&r>=s?t:`${t}
25
25
  `;if(di({isTty:n,isUnmounting:this.isUnmounting,nextOutputHeight:r,previousOutputHeight:this.lastOutputHeight,viewportRows:s})){if(this.options.incrementalRendering){l&&(this.log.clear(),this.options.stdout.write(a)),(t!==this.lastOutput||this.log.isCursorDirty()||l)&&this.throttledLog(u),this.lastOutput=t,this.lastOutputToRender=u,this.lastOutputHeight=r;return}const m=this.shouldSync();m&&this.options.stdout.write(G),this.options.stdout.write(Ke+this.fullStaticOutput+o+t),this.lastOutput=t,this.lastOutputToRender=u,this.lastOutputHeight=r,this.log.sync(u),m&&this.options.stdout.write(q);return}if(l){const m=this.shouldSync();m&&this.options.stdout.write(G),this.log.clear(),this.options.stdout.write(a),this.log(u),m&&this.options.stdout.write(q)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(u);this.lastOutput=t,this.lastOutputToRender=u,this.lastOutputHeight=r}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const r=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(r)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const r=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(r)}confirmKittySupport(t){const{stdin:r,stdout:i}=this.options;let o=[];const a=v(()=>{this.cancelKittyDetection=void 0,clearTimeout(n),r.removeListener("data",l);const s=li(o);o=[],s.length>0&&r.unshift(Vt.from(s))},"cleanup"),l=v(s=>{const u=typeof s=="string"?Vt.from(s):s;for(const m of u)o.push(m);ai(o)&&(a(),this.isUnmounted||this.enableKittyProtocol(t))},"onData");r.on("data",l);const n=setTimeout(a,200);this.cancelKittyDetection=a,i.write("\x1B[?u")}enableKittyProtocol(t){this.options.stdout.write(`\x1B[>${mr(t)}u`),this.kittyProtocolEnabled=!0}}var hi=Object.defineProperty,Dt=x((e,t)=>hi(e,"name",{value:t,configurable:!0}),"i");const zi=Dt((e,t)=>{const r={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:M.stderr,stdin:M.stdin,stdout:M.stdout,...fi(t)},i=pi(r.stdout,()=>new ci(r));return i.render(e),{cleanup(){i.unmount()},clear(){i.clear()},rerender(o){i.render(o)},rootNode:i.rootNode,unmount(){i.unmount()},waitUntilExit(){return i.waitUntilExit()},waitUntilRenderFlush(){return i.waitUntilRenderFlush()}}},"render"),fi=Dt((e={})=>e instanceof Ie?{stdin:M.stdin,stdout:e}:e,"getOptions"),pi=Dt((e,t)=>{const r=Ot.get(e);if(r===void 0){const i=t();return Ot.set(e,i),i}return M.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
26
  `),r},"getInstance");export{zi as default};
@@ -1,4 +1,4 @@
1
- var g=Object.defineProperty;var u=(t,n)=>g(t,"name",{value:n,configurable:!0});import{LegacyRoot as N}from"react-reconciler/constants.js";import S from"yoga-layout";import{c as h}from"./dom-BG-LS10p.js";import{L as c}from"./reconciler-CUbhOvcr.js";import{R as d}from"./renderer-DG986Pcr.js";import{calculateScroll as w}from"./getScrollHeight-ClEOyLHH.js";var R=Object.defineProperty,m=u((t,n)=>R(t,"name",{value:n,configurable:!0}),"u");const I=m((t,n)=>{const y=n?.columns??80,e=h("ink-root");let i="";e.onComputeLayout=()=>{e.yogaNode.setWidth(y),e.yogaNode.calculateLayout(void 0,void 0,S.DIRECTION_LTR);const o=m(r=>{if(r.nodeName==="ink-box"){const a=r.style.overflow??"visible",p=r.style.overflowX??a,v=r.style.overflowY??a;(p==="scroll"||v==="scroll")&&w(r)}for(const a of r.childNodes)a.nodeName!=="#text"&&o(a)},"walkScroll");o(e)},e.onImmediateRender=()=>{const{staticOutput:o}=d(e,!1);o&&o!==`
1
+ var g=Object.defineProperty;var u=(t,n)=>g(t,"name",{value:n,configurable:!0});import{LegacyRoot as N}from"react-reconciler/constants.js";import S from"yoga-layout";import{c as h}from"./dom-CXB-19sK.js";import{L as c}from"./reconciler-DYE5h4K4.js";import{R as d}from"./renderer-maLLQcut.js";import{calculateScroll as w}from"./getScrollHeight-ClEOyLHH.js";var R=Object.defineProperty,m=u((t,n)=>R(t,"name",{value:n,configurable:!0}),"u");const I=m((t,n)=>{const y=n?.columns??80,e=h("ink-root");let i="";e.onComputeLayout=()=>{e.yogaNode.setWidth(y),e.yogaNode.calculateLayout(void 0,void 0,S.DIRECTION_LTR);const o=m(r=>{if(r.nodeName==="ink-box"){const a=r.style.overflow??"visible",p=r.style.overflowX??a,v=r.style.overflowY??a;(p==="scroll"||v==="scroll")&&w(r)}for(const a of r.childNodes)a.nodeName!=="#text"&&o(a)},"walkScroll");o(e)},e.onImmediateRender=()=>{const{staticOutput:o}=d(e,!1);o&&o!==`
2
2
  `&&(i+=o)};let l;const s=c.createContainer(e,N,null,!1,null,"render-to-string",o=>{l??=o},()=>{},()=>{},()=>{});let f=!1;try{c.updateContainerSync(t,s,null,()=>{}),c.flushSyncWork();const{output:o}=d(e,!1);if(c.updateContainerSync(null,s,null,()=>{}),c.flushSyncWork(),f=!0,e.yogaNode.free(),l!==void 0)throw l instanceof Error?l:new Error(String(l));const r=i.endsWith(`
3
3
  `)?i.slice(0,-1):i;return r&&o?`${r}
4
4
  ${o}`:r||o}finally{if(!f&&e.yogaNode)try{e.yogaNode.freeRecursive()}catch{}}},"renderToString");export{I as default};
@@ -0,0 +1,17 @@
1
+ var Be=Object.defineProperty;var P=(o,e)=>Be(o,"name",{value:e,configurable:!0});import{T as Oe,i as De}from"./dom-CXB-19sK.js";import{getStringWidth as Q,indent as Pe,isFullwidthCodePoint as We}from"@visulima/string";import{B as H,D as A,I as j,U as z,e as Y,H as q,f as K,g as ae,F,h as de,S as $e,j as He,p as Ae}from"./measure-text-Ce2widM1.js";import k from"yoga-layout";import{j as G,i as Fe,m as ue,c as ce}from"./layout-BMo200nF.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 Ee}from"./getScrollHeight-ClEOyLHH.js";import Te from"./squashTextNodesWithMap-DCdi3SZ2.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ const require = __cjs_mod__.createRequire(import.meta.url);
3
+ const ze=1114112;var Ye=Object.defineProperty,xe=P((o,e)=>Ye(o,"name",{value:e,configurable:!0}),"T$2");const qe=1,Ke=2,Xe=3,Ue=4,Ve=7,Je=8,Qe=9,he=22,ge=23,fe=24,pe=27,me=28,ye=29,ve=39,be=49,Ze="\x1B[",T=xe(o=>o.length===0?"":`${Ze}${o.join(";")}m`,"sgr"),et=xe(o=>{if(o.length===0)return"";let e="",t=0,r,i,a,n=!1,h=0;const p=o.getSpans();for(const g of p){const u=g.formatFlags&127,{fgColor:s}=g,{bgColor:l}=g,{link:c}=g,d=u;if(d!==t||s!==r||l!==i||c!==a){if(c!==a&&(a&&(e+=a.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),c)){const y=c.startsWith("ST:");e+=`\x1B]8;;${y?c.slice(3):c}${y?"\x1B\\":"\x07"}`}const f=t&(H|A),m=d&(H|A);if(f!==m){const y=t&H&&!(d&H),v=t&A&&!(d&A);(y||v)&&(e+=T([he])),d&H&&(!(t&H)||v)&&(e+=T([qe])),d&A&&(!(t&A)||y)&&(e+=T([Ke]))}d&j&&!(t&j)?e+=T([Xe]):!(d&j)&&t&j&&(e+=T([ge])),d&z&&!(t&z)?e+=T([Ue]):!(d&z)&&t&z&&(e+=T([fe])),d&Y&&!(t&Y)?e+=T([Ve]):!(d&Y)&&t&Y&&(e+=T([pe])),d&q&&!(t&q)?e+=T([Je]):!(d&q)&&t&q&&(e+=T([me])),d&K&&!(t&K)?e+=T([Qe]):!(d&K)&&t&K&&(e+=T([ye])),s!==r&&(e+=T(s?ae(s,!0):[ve])),l!==i&&(e+=T(l?ae(l,!1):[be])),n=d!==0||s!==void 0||l!==void 0,t=d,r=s,i=l,a=c}e+=o.getTextRange(h,h+g.length),h+=g.length}return n&&(t&(H|A)&&(e+=T([he])),t&j&&(e+=T([ge])),t&z&&(e+=T([fe])),t&Y&&(e+=T([pe])),t&q&&(e+=T([me])),t&K&&(e+=T([ye])),r!==void 0&&(e+=T([ve])),i!==void 0&&(e+=T([be]))),a&&(e+=a.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),e},"styledLineToString");var tt=Object.defineProperty,ke=P((o,e)=>tt(o,"name",{value:e,configurable:!0}),"M");class ee{static{P(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 i of this.getLines(e))r=Math.max(r,this.getStringWidth(i));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(ot.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 ot=new Set([27,144,152,155,157,158,159]),rt=.6,it=30;class te{static{P(this,"U")}static{ke(this,"Output")}width;height;caches;grid;clipStack=[];previousLines=[];previousRenderedLines=[];lineMemoizationEnabled=!0;memoizationProbeCountdown=0;constructor(e){const{caches:t,height:r,width:i}=e;this.width=Math.round(i),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,i){const a=Math.round(e),n=Math.round(t);this.clipStack.push({x1:a,x2:a+Math.round(r),y1:n,y2:n+Math.round(i)})}endChildRegion(){this.clipStack.pop()}write(e,t,r,i){if(!r)return;const{transformers:a}=i,n=this.clipStack.at(-1),h=this.caches.getLines(r),p=a.length>0;for(const[g,u]of h.entries()){const s=t+g;if(s<0||s>=this.grid.length||n&&(s<n.y1||s>=n.y2))continue;let l=u;if(p)for(const S of a)l=S(l,g);if(l.length===0)continue;const c=this.grid[s],d=this.caches.getStyledLine(l);let f=e;const m=n?Math.min(n.x2,c.length):1/0,y=d.getSpans();let v=0,L=y[0]?.length??0;for(let S=0;S<d.length;S++){for(;v<y.length&&S>=L;)v++,L+=y[v]?.length??0;if(f>=m)break;if(n&&(f<n.x1||f>=n.x2)){f++,d.getFullWidth(S)&&f++;continue}if(f>=0){f>=c.length&&c.ensureWidth(f+2);const M=y[v],R=d.getFullWidth(S),b=(M?.formatFlags??0)|(R?F:0);c.setCharFast(f,d.getValue(S),b,M?.fgColor,M?.bgColor,M?.link),R&&(f++,f>=c.length&&c.ensureWidth(f+1),c.setCharFast(f,"",b&~F,M?.fgColor,M?.bgColor,M?.link))}f++}}}writeStyledLine(e,t,r){if(r.length===0||t<0||t>=this.grid.length)return;const i=this.clipStack.at(-1);i&&(t<i.y1||t>=i.y2)||this.writeStyledLineToRow(this.grid[t],e,r,this.width,i)}getRootLines(){return this.grid}getCurrentClip(){return this.clipStack.at(-1)}addRegionTree(e,t,r){for(let i=0;i<e.height;i++){const a=r+i;if(a<0||a>=this.grid.length)continue;const n=e.lines[i];if(!n)continue;const h=this.grid[a],p=n.getSpans();let g=0,u=p[0]?.length??0;for(let s=0;s<n.length;s++){for(;g<p.length&&s>=u;)g++,u+=p[g]?.length??0;const l=t+s;if(l<0||l>=h.length)continue;const c=n.getValue(s),d=p[g],f=d!==void 0&&(d.formatFlags&~F)!==0||d?.fgColor!==void 0||d?.bgColor!==void 0||d?.link!==void 0;if(c!==" "||f){const m=(d?.formatFlags??0)|(n.getFullWidth(s)?F:0);h.setCharFast(l,c,m,d?.fgColor,d?.bgColor,d?.link)}}}for(const i of e.children)this.addRegionTree(i,t+i.x,r+i.y)}writeStyledLineToRow(e,t,r,i,a){let n=t;const h=a?Math.min(a.x2,i):1/0,p=r.getSpans();let g=0,u=p[0]?.length??0;for(let s=0;s<r.length;s++){for(;g<p.length&&s>=u;)g++,u+=p[g]?.length??0;if(n>=h)break;if(a&&(n<a.x1||n>=a.x2)){n++,r.getFullWidth(s)&&n++;continue}if(n>=0){n>=e.length&&e.ensureWidth(n+2);const l=p[g],c=r.getFullWidth(s),d=(l?.formatFlags??0)|(c?F:0);e.setCharFast(n,r.getValue(s),d,l?.fgColor,l?.bgColor,l?.link),c&&(n++,n>=e.length&&e.ensureWidth(n+1),e.setCharFast(n,"",d&~F,l?.fgColor,l?.bgColor,l?.link))}n++}}get(){const e=this.grid;this.lineMemoizationEnabled||(this.memoizationProbeCountdown>0?this.memoizationProbeCountdown--:this.lineMemoizationEnabled=!0);const t=this.lineMemoizationEnabled,r=this.previousLines.length>0,i=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 a=Array.from({length:e.length});let n=0;for(const[h,p]of e.entries()){const g=p;if(i&&this.previousLines[h]?.equals(g)){a[h]=this.previousRenderedLines[h]??"";continue}n++;const u=g.trimEnd(),s=et(u);a[h]=s,t&&(this.previousRenderedLines[h]=s,this.previousLines[h]=g.clone())}return t&&i&&e.length>0&&n/e.length>rt&&this.disableLineMemoization(),{height:e.length,output:a.join(`
5
+ `)}}getBuffer(){const e=this.grid,t=e.length,r=new Uint32Array(this.width*t*2),i=65535;for(let a=0;a<r.length;a+=2)r[a]=32,r[a+1]=i;for(let a=0;a<t;a++){const n=e[a],h=n.getSpans();let p=0,g=h[0]?.length??0;for(let u=0;u<n.length&&u<this.width;u++){for(;p<h.length&&u>=g;)p++,g+=h[p]?.length??0;const s=n.getValue(u);if(s.length===0)continue;const l=s.codePointAt(0)??32,c=(a*this.width+u)*2,d=h[p],f=d?.formatFlags??0,m=d?.fgColor,y=d?.bgColor,v=m?de(m):255,L=y?de(y):255,S=(f&255)<<16|(L&255)<<8|v&255;if(r[c]=l,r[c+1]=S,n.getFullWidth(u)&&u+1<this.width){const M=c+2;r[M]=ze,r[M+1]=S,u++}}}return{buffer:r,height:t}}createGrid(e,t){const r=[];for(let i=0;i<t;i++)r.push($e.empty(e));return r}disableLineMemoization(){this.lineMemoizationEnabled=!1,this.memoizationProbeCountdown=it,this.previousLines.length=0,this.previousRenderedLines.length=0}}var nt=Object.defineProperty,st=P((o,e)=>nt(o,"name",{value:e,configurable:!0}),"d");const lt=st(o=>Math.round(o.getComputedWidth()-Math.max(0,o.getComputedLeft()+o.getComputedWidth()-(o.getParent()?.getComputedWidth()??o.getComputedWidth()))-o.getComputedPadding(k.EDGE_LEFT)-o.getComputedPadding(k.EDGE_RIGHT)-o.getComputedBorder(k.EDGE_LEFT)-o.getComputedBorder(k.EDGE_RIGHT)),"getMaxWidth");var at=Object.defineProperty,dt=P((o,e)=>at(o,"name",{value:e,configurable:!0}),"c");const ut=dt((o,e,t,r)=>{if(!t.style.backgroundColor)return;const i=Math.round(t.yogaNode.getComputedWidth()),a=Math.round(t.yogaNode.getComputedHeight()),n=t.style.borderStyle&&t.style.borderLeft!==!1?1:0,h=t.style.borderStyle&&t.style.borderRight!==!1?1:0,p=t.style.borderStyle&&t.style.borderTop!==!1?1:0,g=t.style.borderStyle&&t.style.borderBottom!==!1?1:0,u=i-n-h,s=a-p-g;if(!(u>0&&s>0))return;const l=Ge(t.style.backgroundColor);if(!l)return;const c=`${l}${" ".repeat(u)}\x1B[49m`;for(let d=0;d<s;d++)r.write(o+n,e+p+d,c,{transformers:[]})},"renderBackground");var ct=Object.defineProperty,oe=P((o,e)=>ct(o,"name",{value:e,configurable:!0}),"T");const W=oe((o,e,t,r)=>{let i=J(o,e,"foreground");return i=J(i,t,"background"),r&&(i=Ie.dim(i)),i},"stylePiece"),Ce=oe((o,e,t,r,i,a,n,h)=>{if(!t&&!i)return W(o.repeat(e),a,n,h);const p=t?` ${t} `:"",g=i?` ${i} `:"",u=p.length,s=g.length,l=r??"left";if(u+s>=e){if(u>=e)return`${p.slice(0,e-1)}…`;const m=e-u;return m>3?p+g.slice(0,m):p+W(o.repeat(e-u),a,n,h)}const c=e-u-s;if(l==="left"||i)return p+W(o.repeat(c),a,n,h)+g;if(l==="right"){const m=e-u;return W(o.repeat(m),a,n,h)+p}const d=Math.floor(c/2),f=c-d;return W(o.repeat(d),a,n,h)+p+W(o.repeat(f),a,n,h)},"buildBorderWithTitle"),ht=oe((o,e,t,r)=>{if(t.style.borderStyle){const i=Math.round(t.yogaNode.getComputedWidth()),a=Math.round(t.yogaNode.getComputedHeight()),n=typeof t.style.borderStyle=="string"?je[t.style.borderStyle]:t.style.borderStyle,h=t.style.borderTopColor??t.style.borderColor,p=t.style.borderBottomColor??t.style.borderColor,g=t.style.borderLeftColor??t.style.borderColor,u=t.style.borderRightColor??t.style.borderColor,s=t.style.borderTopBackgroundColor??t.style.borderBackgroundColor,l=t.style.borderBottomBackgroundColor??t.style.borderBackgroundColor,c=t.style.borderLeftBackgroundColor??t.style.borderBackgroundColor,d=t.style.borderRightBackgroundColor??t.style.borderBackgroundColor,f=t.style.borderTopDimColor??t.style.borderDimColor,m=t.style.borderBottomDimColor??t.style.borderDimColor,y=t.style.borderLeftDimColor??t.style.borderDimColor,v=t.style.borderRightDimColor??t.style.borderDimColor,L=t.style.borderTop!==!1,S=t.style.borderBottom!==!1,M=t.style.borderLeft!==!1,R=t.style.borderRight!==!1,b=Math.max(0,i-(M?1:0)-(R?1:0));let x;if(L){const _=M?W(n.topLeft,h,s,f):"",D=R?W(n.topRight,h,s,f):"",B=Ce(n.top,b,t.style.borderTopTitle,t.style.borderTopTitleAlignment,t.style.borderTopRightTitle,h,s,f);x=_+B+D}let C=a;L&&(C-=1),S&&(C-=1),C=Math.max(0,C);let E="";M&&(E=`${W(n.left,g,c,y)}
6
+ `.repeat(C));let N="";R&&(N=`${W(n.right,u,d,v)}
7
+ `.repeat(C));let w;if(S){const _=M?W(n.bottomLeft,p,l,m):"",D=R?W(n.bottomRight,p,l,m):"",B=Ce(n.bottom,b,t.style.borderBottomTitle,t.style.borderBottomTitleAlignment,void 0,p,l,m);w=_+B+D}const O=L?1:0;x&&r.write(o,e,x,{transformers:[]}),E&&r.write(o,e+O,E,{transformers:[]}),N&&r.write(o+i-1,e+O,N,{transformers:[]}),w&&r.write(o,e+a-1,w,{transformers:[]})}},"renderBorder");var gt=Object.defineProperty,ft=P((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:i,endHalf:a,start:n,startHalf:h},x:p,y:g}=t;if(o==="vertical")for(let u=n;u<i;u++){let s="█";const l=2*u>=h&&2*u<a,c=2*u+1>=h&&2*u+1<a;l&&!c?s="▀":!l&&c&&(s="▄");const d=e?J(s,e,"foreground"):s;r.write(p,g+u,d,{transformers:Ne})}else for(let u=n;u<i;u++){let s="█";const l=2*u>=h&&2*u<a,c=2*u+1>=h&&2*u+1<a;l&&!c?s="▌":!l&&c&&(s="▐");const d=e?J(s,e,"foreground"):s;r.write(p+u,g,d,{transformers:Ne})}},"renderScrollbar");var pt=Object.defineProperty,re=P((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 i=r.style.overflow??"visible",a=r.style.overflowX??i,n=r.style.overflowY??i;!(a==="scroll"||n==="scroll")&&r.childNodes&&we(r,e)}}return e},"getStickyDescendants"),mt=re((o,e,t,r)=>{let i,a=-1,n,h=-1;for(const[g,u]of o.entries()){const{node:s,type:l}=u;if(!s.yogaNode)continue;const c=G(s,e)??0,d=Math.round(s.yogaNode.getComputedHeight()),f=c+d,m=s.parentNode;let y=0,v=Number.MAX_SAFE_INTEGER;m?.yogaNode&&(y=G(m,e)??0,v=Math.round(m.yogaNode.getComputedHeight())),l==="top"&&c<t&&y+v>t&&(i=u,a=g),l==="bottom"&&Math.floor(f)>Math.floor(r)&&y<r&&(n=u,h=g)}const p=[];if(i){let g;for(let u=a+1;u<o.length;u++){const s=o[u];if(s.type!=="bottom"){g=s;break}}p.push({nextStickyNodeInfo:g,stickyNode:i.node,type:"top"})}if(n){let g;for(let u=h-1;u>=0;u--){const s=o[u];if(s.type==="bottom"){g=s;break}}p.push({nextStickyNodeInfo:g,stickyNode:n.node,type:"bottom"})}return p},"identifyActiveStickyNodes"),yt=re((o,e,t,r,i)=>{const{newTransformers:a,skipStaticElements:n,x:h,y:p}=i,{yogaNode:g}=e;if(!g)return;const u=g.getComputedBorder(k.EDGE_TOP),s=g.getComputedBorder(k.EDGE_LEFT),l=Ee(e),c=e.internal_scrollState?.clientHeight??0;for(const{nextStickyNodeInfo:d,stickyNode:f,type:m}of o){if(!f.yogaNode)continue;const y=G(f,e)??0,v=Math.round(f.yogaNode.getComputedHeight()),L=h+(Fe(f,e)??0),S=f.parentNode;let M=0,R=Number.MAX_SAFE_INTEGER;S?.yogaNode&&(M=G(S,e)??0,R=Math.round(S.yogaNode.getComputedHeight()));let b;if(m==="top"){const E=S?.yogaNode?.getComputedBorder(k.EDGE_BOTTOM)??0,N=M+R-E;let w=p-l+N-v;const O=p-l+y,_=p+u;if(d?.node?.yogaNode){const D=G(d.node,e)??0,B=p-l+D-v;B<w&&(w=B)}b=Math.min(Math.max(_,O),w)}else{const E=S?.yogaNode?.getComputedBorder(k.EDGE_TOP)??0;let N=p-l+M+E;const w=p-l+y,O=p+u+c-v;if(d?.node?.yogaNode){const _=Math.round(d.node.yogaNode.getComputedHeight()),D=G(d.node,e)??0,B=p-l+D+_;B>N&&(N=B)}b=Math.max(Math.min(O,w),N)}const x=r({height:v,width:Math.round(f.yogaNode.getComputedWidth())});U(f,x,{offsetX:-Math.round(f.yogaNode.getComputedLeft()),offsetY:-Math.round(f.yogaNode.getComputedTop()),skipStaticElements:n,transformers:a});const C=x.get().output.split(`
8
+ `);for(const[E,N]of C.entries())N&&N.length>0&&t.write(L-(h+s),b-(p+u)+E,N,{transformers:[]})}},"renderActiveStickyNodes");var vt=Object.defineProperty,$=P((o,e)=>vt(o,"name",{value:e,configurable:!0}),"x");const bt=$((o,e)=>{const t=o.childNodes[0]?.yogaNode;if(t){const r=Math.round(t.getComputedLeft()),i=Math.round(t.getComputedTop());e=`
9
+ `.repeat(i)+Pe(e,r)}return e},"applyPaddingToText"),Ct=31,Nt=127,St=128,Mt=159,Et=$((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 i=r.codePointAt(0);if(i<=Ct||i===Nt||i>=St&&i<=Mt||We(i)||(t++,t>e))return!0}return!1},"mightExceedWidth"),Tt=$(o=>(o.internal_hidden??!1)||o.yogaNode?.getDisplay()===k.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()===k.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(i=>Z(i,{parentRole:o.internal_accessibility?.role,skipStaticElements:e.skipStaticElements})).filter(Boolean).join(r)}if(o.internal_accessibility){const{role:r,state:i}=o.internal_accessibility;if(i){const a=Object.keys(i).filter(n=>i[n]).join(", ");a&&(t=`(${a}) ${t}`)}r&&r!==e.parentRole&&(t=`${r}: ${t}`)}return t},"renderNodeToScreenReaderOutput"),U=$((o,e,t)=>{const{absoluteOffsetX:r,absoluteOffsetY:i,offsetX:a=0,offsetY:n=0,renderState:h,selectionMap:p,skipStaticElements:g,transformers:u=[]}=t;if(g&&o.internal_static||o.internal_hidden)return;if(o.cachedRender){const l=Math.round(a+(o.yogaNode?.getComputedLeft()??0)),c=Math.round(n+(o.yogaNode?.getComputedTop()??0));e.addRegionTree(o.cachedRender,l,c);return}if(o.nodeName==="ink-cursor"){if(!h)return;h.cursorRequested=!0;const l=o.internal_cursor;if(!l){h.cursorPosition=void 0;return}if(h.cursorShape=l.shape,l.inline){if(h.lastTextWriteEnd)h.cursorPosition={x:h.lastTextWriteEnd.x,y:h.lastTextWriteEnd.y};else{const f=o.parentNode?ue(o.parentNode):void 0;h.cursorPosition=f?{x:f.x,y:f.y}:void 0}return}const c=l.anchorRef?l.anchorRef.current:o.parentNode;if(!c){h.cursorPosition=void 0;return}if(l.anchorRef&&xt(c)){h.cursorPosition=void 0;return}const d=ue(c);if(!d){h.cursorPosition=void 0;return}h.cursorPosition={x:d.x+l.x,y:d.y+l.y};return}const{yogaNode:s}=o;if(s){if(s.getDisplay()===k.DISPLAY_NONE)return;const l=s.getComputedLeft(),c=s.getComputedTop(),d=Math.round(a+l),f=Math.round(n+c),m=Math.round((r??a)+l),y=Math.round((i??n)+c),v=e.getCurrentClip();if(v){const b=Math.round(s.getComputedWidth()),x=Math.round(s.getComputedHeight()),C=m+b,E=y+x,N=v.x1??-1/0,w=v.x2??1/0,O=v.y1??-1/0,_=v.y2??1/0;if(C<=N||m>=w||E<=O||y>=_)return}let L=u;if(typeof o.internal_transform=="function"&&(L=[o.internal_transform,...u]),o.nodeName==="ink-text"){let b=Te(o);if(b.length>0){const x=lt(s);if(Et(b,x)&&Math.max(...b.split(`
12
+ `).map(C=>Q(C)))>x){const C=o.style.textWrap??"wrap";b=Oe(b,Math.floor(x),C)}if(b=bt(o,b),e.write(d,f,b,{transformers:L}),h){const C=b.split(`
13
+ `),E=C.at(-1)??"";h.lastTextWriteEnd={x:d+Q(E),y:f+C.length-1}}}return}let S=!1,M=0,R=0;if(o.nodeName==="ink-box"){ut(d,f,o,e),ht(d,f,o,e);const b=o.style.overflow??"visible",x=o.style.overflowX??b,C=o.style.overflowY??b,E=x==="hidden"||x==="scroll",N=C==="hidden"||C==="scroll";if(E||N){const w=Math.round(s.getComputedWidth()),O=Math.round(s.getComputedHeight()),_=E?d+s.getComputedBorder(k.EDGE_LEFT):d,D=E?w-s.getComputedBorder(k.EDGE_LEFT)-s.getComputedBorder(k.EDGE_RIGHT):w,B=N?f+s.getComputedBorder(k.EDGE_TOP):f,V=N?O-s.getComputedBorder(k.EDGE_TOP)-s.getComputedBorder(k.EDGE_BOTTOM):O;e.startChildRegion(_,B,Math.max(0,D),Math.max(0,V)),S=!0,C==="scroll"&&o.internal_scrollState&&(R=-o.internal_scrollState.scrollTop),x==="scroll"&&o.internal_scrollState&&(M=-o.internal_scrollState.scrollLeft)}}if(o.nodeName==="ink-root"||o.nodeName==="ink-box"||o.nodeName==="ink-static-render"){for(const b of o.childNodes)U(b,e,{absoluteOffsetX:m+M,absoluteOffsetY:y+R,offsetX:d+M,offsetY:f+R,renderState:h,selectionMap:p,skipStaticElements:g,transformers:L});if(o.nodeName==="ink-box"&&o.internal_scrollState){const b=we(o);if(b.length>0){const x=Ee(o),C=o.internal_scrollState.clientHeight,E=x+C,N=mt(b,o,x,E);N.length>0&&yt(N,o,e,$(w=>new te(w),"createOutput"),{newTransformers:L,skipStaticElements:g,x:d,y:f})}}if(o.nodeName==="ink-box"&&o.internal_scrollState){const b=o.style.overflow??"visible",x=o.style.overflowX??b,C=o.style.overflowY??b,E=s.getComputedBorder(k.EDGE_LEFT),N=s.getComputedBorder(k.EDGE_RIGHT),w=s.getComputedBorder(k.EDGE_TOP),O=s.getComputedBorder(k.EDGE_BOTTOM),_=Math.round(s.getComputedWidth()-E-N),D=Math.round(s.getComputedHeight()-w-O),{clientHeight:B,clientWidth:V,scrollHeight:ie,scrollLeft:Le,scrollTop:Re,scrollWidth:ne}=o.internal_scrollState,se=C==="scroll"&&ie>B,_e=x==="scroll"&&ne>V,le=o.internal_scrollbar!==!1;if(se&&le){const I=ce({axis:"vertical",clientDimension:B,hasOppositeScrollbar:!1,height:D,marginBottom:0,marginRight:0,scrollDimension:ie,scrollPosition:Re,width:_,x:d+E,y:f+w});I&&Se({axis:"vertical",color:o.style.scrollbarThumbColor,layout:I,output:e})}if(_e&&le){const I=ce({axis:"horizontal",clientDimension:V,hasOppositeScrollbar:se,height:D,marginBottom:0,marginRight:0,scrollDimension:ne,scrollPosition:Le,width:_,x:d+E,y:f+w});I&&Se({axis:"horizontal",color:o.style.scrollbarThumbColor,layout:I,output:e})}}S&&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:i}=require("./dom"),a=new te({height:r,width:t});for(const h of o.childNodes)U(h,a,{skipStaticElements:e?.skipStaticElements??!1});const n={children:[],cursorPosition:void 0,height:r,id:o.internalId??"static",isScrollable:!1,lines:[...a.getRootLines()],selectableSpans:[],stickyHeaders:[],styledOutput:[...a.getRootLines()],width:t,x:0,y:0};i(o,n)},"renderToStatic");var kt=Object.defineProperty,X=P((o,e)=>kt(o,"name",{value:e,configurable:!0}),"N");const wt=X((o,e)=>{const t=new Map;if(e.rangeCount===0)return t;const r=e.getRangeAt(0),{endContainer:i,endOffset:a,startContainer:n,startOffset:h}=r;if(!n||!i)return t;let p=!1,g=!1;const u=X((l,c,d,f,m,y)=>{if(l.nodeName==="#text"){const{length:v}=l.nodeValue;n===l&&(m.value=!0,d.value=c.value+h),i===l&&(y.value=!0,f.value=c.value+a),c.value+=v}else if("childNodes"in l){for(const v of l.childNodes)l===n&&(m.value=!0,d.value=c.value),l===i&&(y.value=!0,f.value=c.value),u(v,c,d,f,m,y);l===n&&h===l.childNodes.length&&(m.value=!0,d.value=c.value),l===i&&a===l.childNodes.length&&(y.value=!0,f.value=c.value)}},"visitChildren"),s=X(l=>{if(l.nodeName==="ink-text"){if(!De(l))return;const c={value:0},d={value:-1},f={value:-1},m={value:!1},y={value:!1};for(const v of l.childNodes)l===n&&(m.value=!0,d.value=c.value),l===i&&(y.value=!0,f.value=c.value),u(v,c,d,f,m,y);if(l===n&&h===l.childNodes.length&&(m.value=!0,d.value=c.value),l===i&&a===l.childNodes.length&&(y.value=!0,f.value=c.value),(p||m.value)&&(!g||y.value)){const v=m.value?d.value:0,L=y.value?f.value:c.value;v!==-1&&L!==-1&&v<L&&t.set(l,{end:L,start:v})}m.value&&(p=!0),y.value&&(g=!0)}else{const{childNodes:c}=l;if(c){for(const d of c)l===n&&(p=!0),l===i&&(g=!0),s(d);l===n&&h===c.length&&(p=!0),l===i&&a===c.length&&(g=!0)}}},"visit");return s(o),t},"calculateSelectionMap"),Lt=new ee,Rt=new ee,_t=new WeakMap,Bt=new WeakMap,Me=X(({caches:o,height:e,node:t,outputs:r,width:i})=>{let a=r.get(t);return a||(a=new te({caches:o,height:e,width:i}),r.set(t,a)),a.reset(i,e),a},"getReusableOutput"),Yt=X((o,e,t)=>{if(o.yogaNode){if(e){const g=Z(o,{skipStaticElements:!0}),u=g===""?0:g.split(`
14
+ `).length;let s="";return o.staticNode&&(s=Z(o.staticNode,{skipStaticElements:!1})),{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:g,outputHeight:u,staticOutput:s?`${s}
15
+ `:""}}const r=t?.selection&&t.selection.rangeCount>0?wt(o,t.selection):void 0,i=Me({caches:Lt,height:o.yogaNode.getComputedHeight(),node:o,outputs:_t,width:o.yogaNode.getComputedWidth()}),a={cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0};U(o,i,{renderState:a,selectionMap:r,skipStaticElements:!0});let n;if(o.staticNode?.yogaNode&&(n=Me({caches:Rt,height:o.staticNode.yogaNode.getComputedHeight(),node:o,outputs:Bt,width:o.staticNode.yogaNode.getComputedWidth()}),U(o.staticNode,n,{skipStaticElements:!1})),t?.useNativeRenderer){const{buffer:g,height:u}=i.getBuffer();return{cursorPosition:a.cursorPosition,cursorRequested:a.cursorRequested,cursorShape:a.cursorShape,output:"",outputBuffer:g,outputHeight:u,outputWidth:i.width,staticOutput:n?`${n.get().output}
16
+ `:""}}const{height:h,output:p}=i.get();return{cursorPosition:a.cursorPosition,cursorRequested:a.cursorRequested,cursorShape:a.cursorShape,output:p,outputHeight:h,staticOutput:n?`${n.get().output}
17
+ `:""}}return{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:"",outputHeight:0,staticOutput:""}},"renderer");export{U as B,Yt as R,te as U,zt as r};
@@ -0,0 +1 @@
1
+ import"@visulima/string";import{c as i,a as s,L as n,i as d,m as l,s as r,b as c,k as h,d as y,t as L}from"./measure-text-Ce2widM1.js";export{i as clearStringWidthCache,s as clearStyledLineCache,n as default,d as inkCharacterWidth,l as measureStyledLine,r as setEnableStyledLineCache,c as setStringWidthFunction,h as splitStyledLineByNewline,y as styledLineWidth,L as toStyledLine};
@@ -1,3 +1,3 @@
1
- var y=Object.defineProperty;var p=(e,n)=>y(e,"name",{value:n,configurable:!0});import{S as V,d as m,i as h}from"./measure-text-DDjHT1jD.js";var b=Object.defineProperty,g=p((e,n)=>b(e,"name",{value:n,configurable:!0}),"g");const S=g((e,n,u="end")=>{if(n<1)return new V;if(m(e)<=n)return e;const r=new V;if(r.pushChar("…",0),n===1)return r;if(u==="start"){let t=0,s=e.length;for(let l=e.length-1;l>=0&&(t+=h(e.getValue(l)),!(t>n-1));l--)s=l;return r.combine(e.slice(s))}if(u==="middle"){const t=Math.ceil(n/2),s=n-t;let l=0,c=0;for(let i=0;i<e.length;i++){const d=h(e.getValue(i));if(c+d>t-1)break;c+=d,l=i+1}let a=e.length;c=0;for(let i=e.length-1;i>=0&&(c+=h(e.getValue(i)),!(c>s));i--)a=i;return e.slice(0,l).combine(r,e.slice(a))}let f=0,o=0;for(let t=0;t<e.length;t++){const s=h(e.getValue(t));if(o+s>n-1)break;o+=s,f=t+1}return e.slice(0,f).combine(r)},"truncateStyledLine"),w=g((e,n)=>{const u=[];let r=0,f=0,o=!0,t=0;for(;t<e.length;){const s=e.getValue(t);if(s===`
1
+ var y=Object.defineProperty;var p=(e,n)=>y(e,"name",{value:n,configurable:!0});import{S as V,d as m,i as h}from"./measure-text-Ce2widM1.js";var b=Object.defineProperty,g=p((e,n)=>b(e,"name",{value:n,configurable:!0}),"g");const S=g((e,n,u="end")=>{if(n<1)return new V;if(m(e)<=n)return e;const r=new V;if(r.pushChar("…",0),n===1)return r;if(u==="start"){let t=0,s=e.length;for(let l=e.length-1;l>=0&&(t+=h(e.getValue(l)),!(t>n-1));l--)s=l;return r.combine(e.slice(s))}if(u==="middle"){const t=Math.ceil(n/2),s=n-t;let l=0,c=0;for(let i=0;i<e.length;i++){const d=h(e.getValue(i));if(c+d>t-1)break;c+=d,l=i+1}let a=e.length;c=0;for(let i=e.length-1;i>=0&&(c+=h(e.getValue(i)),!(c>s));i--)a=i;return e.slice(0,l).combine(r,e.slice(a))}let f=0,o=0;for(let t=0;t<e.length;t++){const s=h(e.getValue(t));if(o+s>n-1)break;o+=s,f=t+1}return e.slice(0,f).combine(r)},"truncateStyledLine"),w=g((e,n)=>{const u=[];let r=0,f=0,o=!0,t=0;for(;t<e.length;){const s=e.getValue(t);if(s===`
2
2
  `){u.push(e.slice(r,t)),r=t+1,f=0,o=!0,t++;continue}let l=t,c=0;if(s===" ")c=h(" "),l=t+1;else for(;l<e.length&&e.getValue(l)!==" "&&e.getValue(l)!==`
3
3
  `;)c+=h(e.getValue(l)),l++;if(f+c>n&&f>0){if(s===" "&&!o&&!e.hasStyles(t)){t=l;continue}let a=t;for(;a>r&&e.getValue(a-1)===" "&&!e.hasStyles(a-1);)a--;u.push(e.slice(r,a)),r=t,f=0;continue}if(f===0&&c>n){let a=t,i=0;for(;a<l;){const d=h(e.getValue(a));i+d>n&&i>0&&(u.push(e.slice(r,a)),r=a,i=0),i+=d,a++}f=i,t=l,o=!1}else f+=c,t=l,s!==" "&&(o=!1)}return(r<e.length||u.length===0)&&u.push(e.slice(r)),u},"wrapStyledLine"),v=g((e,n,u="wrap")=>{if(u.startsWith("truncate")){let r="end";return u==="truncate-middle"?r="middle":u==="truncate-start"&&(r="start"),[S(e,n,r)]}return w(e,n)},"wrapOrTruncateStyledLine");export{v as wrapOrTruncateStyledLine};
@@ -1 +1 @@
1
- var w=Object.defineProperty;var a=(t,e)=>w(t,"name",{value:e,configurable:!0});import{createRequire as F}from"node:module";import x from"../packem_shared/render-BFio00DS.js";import{createKeySender as y}from"../packem_shared/KEY-Bk8B-3h_.js";import{KEY as $}from"../packem_shared/KEY-Bk8B-3h_.js";import{createScreen as T}from"../packem_shared/createScreen-CrLrxA6t.js";import{waitFor as j}from"../packem_shared/waitFor-Dj5zfL5s.js";const b=F(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=a(t=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,i]=o.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return o.getBuiltinModule(t)}return b(t)},"__cjs_getBuiltinModule"),l=v("node:events");var R=Object.defineProperty,r=a((t,e)=>R(t,"name",{value:e,configurable:!0}),"t");class S extends l{static{a(this,"v")}static{r(this,"Stdout")}columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=r(e=>(this._frames.push(e),this._lastFrame=e,!0),"write")}class D extends l{static{a(this,"x")}static{r(this,"Stderr")}columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=r(e=>(this._frames.push(e),this._lastFrame=e,!0),"write")}class P extends l{static{a(this,"R")}static{r(this,"Stdin")}isTTY=!0;pendingData;write=r(e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0),"write");read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const c=[],O=r((t,e={})=>{const{columns:i,options:p}=e,n=new S(i),d=new D(i),m=new P,u=x(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:d,stdin:m,stdout:n,...p});c.push(u);const f=T(()=>n.lastFrame(),n.frames),h=y(s=>m.write(s)),_=r(async()=>{await new Promise(s=>{setTimeout(s,0)}),await new Promise(s=>{setTimeout(s,0)})},"flush");return{cleanup:u.cleanup,flush:_,get frames(){return n.frames},keys:h,lastFrame:r(()=>n.lastFrame(),"lastFrame"),rerender:u.rerender,screen:f,stderr:d,stdin:m,stdout:n,unmount:u.unmount,async waitFor(s,g){await j(s,()=>f.text(),g)}}},"testRender"),Y=r(()=>{for(const t of c)t.cleanup();c.length=0},"cleanup");export{$ as KEY,Y as cleanup,y as createKeySender,T as createScreen,O as render,j as waitFor};
1
+ var w=Object.defineProperty;var a=(t,e)=>w(t,"name",{value:e,configurable:!0});import{createRequire as F}from"node:module";import x from"../packem_shared/render-BRR1ESvR.js";import{createKeySender as y}from"../packem_shared/KEY-Bk8B-3h_.js";import{KEY as $}from"../packem_shared/KEY-Bk8B-3h_.js";import{createScreen as T}from"../packem_shared/createScreen-CrLrxA6t.js";import{waitFor as j}from"../packem_shared/waitFor-Dj5zfL5s.js";const b=F(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=a(t=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,i]=o.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return o.getBuiltinModule(t)}return b(t)},"__cjs_getBuiltinModule"),l=v("node:events");var R=Object.defineProperty,r=a((t,e)=>R(t,"name",{value:e,configurable:!0}),"t");class S extends l{static{a(this,"v")}static{r(this,"Stdout")}columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=r(e=>(this._frames.push(e),this._lastFrame=e,!0),"write")}class D extends l{static{a(this,"x")}static{r(this,"Stderr")}columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=r(e=>(this._frames.push(e),this._lastFrame=e,!0),"write")}class P extends l{static{a(this,"R")}static{r(this,"Stdin")}isTTY=!0;pendingData;write=r(e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0),"write");read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const c=[],O=r((t,e={})=>{const{columns:i,options:p}=e,n=new S(i),d=new D(i),m=new P,u=x(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:d,stdin:m,stdout:n,...p});c.push(u);const f=T(()=>n.lastFrame(),n.frames),h=y(s=>m.write(s)),_=r(async()=>{await new Promise(s=>{setTimeout(s,0)}),await new Promise(s=>{setTimeout(s,0)})},"flush");return{cleanup:u.cleanup,flush:_,get frames(){return n.frames},keys:h,lastFrame:r(()=>n.lastFrame(),"lastFrame"),rerender:u.rerender,screen:f,stderr:d,stdin:m,stdout:n,unmount:u.unmount,async waitFor(s,g){await j(s,()=>f.text(),g)}}},"testRender"),Y=r(()=>{for(const t of c)t.cleanup();c.length=0},"cleanup");export{$ as KEY,Y as cleanup,y as createKeySender,T as createScreen,O as render,j as waitFor};
package/index.js CHANGED
@@ -81,8 +81,8 @@ function requireNative() {
81
81
  try {
82
82
  const binding = require('@visulima/tui-binding-android-arm64')
83
83
  const bindingPackageVersion = require('@visulima/tui-binding-android-arm64/package.json').version
84
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
86
  }
87
87
  return binding
88
88
  } catch (e) {
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('@visulima/tui-binding-android-arm-eabi')
99
99
  const bindingPackageVersion = require('@visulima/tui-binding-android-arm-eabi/package.json').version
100
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -118,8 +118,8 @@ function requireNative() {
118
118
  try {
119
119
  const binding = require('@visulima/tui-binding-win32-x64-gnu')
120
120
  const bindingPackageVersion = require('@visulima/tui-binding-win32-x64-gnu/package.json').version
121
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
123
123
  }
124
124
  return binding
125
125
  } catch (e) {
@@ -134,8 +134,8 @@ function requireNative() {
134
134
  try {
135
135
  const binding = require('@visulima/tui-binding-win32-x64-msvc')
136
136
  const bindingPackageVersion = require('@visulima/tui-binding-win32-x64-msvc/package.json').version
137
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
139
139
  }
140
140
  return binding
141
141
  } catch (e) {
@@ -151,8 +151,8 @@ function requireNative() {
151
151
  try {
152
152
  const binding = require('@visulima/tui-binding-win32-ia32-msvc')
153
153
  const bindingPackageVersion = require('@visulima/tui-binding-win32-ia32-msvc/package.json').version
154
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
156
156
  }
157
157
  return binding
158
158
  } catch (e) {
@@ -167,8 +167,8 @@ function requireNative() {
167
167
  try {
168
168
  const binding = require('@visulima/tui-binding-win32-arm64-msvc')
169
169
  const bindingPackageVersion = require('@visulima/tui-binding-win32-arm64-msvc/package.json').version
170
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
172
  }
173
173
  return binding
174
174
  } catch (e) {
@@ -186,8 +186,8 @@ function requireNative() {
186
186
  try {
187
187
  const binding = require('@visulima/tui-binding-darwin-universal')
188
188
  const bindingPackageVersion = require('@visulima/tui-binding-darwin-universal/package.json').version
189
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
191
191
  }
192
192
  return binding
193
193
  } catch (e) {
@@ -202,8 +202,8 @@ function requireNative() {
202
202
  try {
203
203
  const binding = require('@visulima/tui-binding-darwin-x64')
204
204
  const bindingPackageVersion = require('@visulima/tui-binding-darwin-x64/package.json').version
205
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
207
207
  }
208
208
  return binding
209
209
  } catch (e) {
@@ -218,8 +218,8 @@ function requireNative() {
218
218
  try {
219
219
  const binding = require('@visulima/tui-binding-darwin-arm64')
220
220
  const bindingPackageVersion = require('@visulima/tui-binding-darwin-arm64/package.json').version
221
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
223
  }
224
224
  return binding
225
225
  } catch (e) {
@@ -238,8 +238,8 @@ function requireNative() {
238
238
  try {
239
239
  const binding = require('@visulima/tui-binding-freebsd-x64')
240
240
  const bindingPackageVersion = require('@visulima/tui-binding-freebsd-x64/package.json').version
241
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
243
243
  }
244
244
  return binding
245
245
  } catch (e) {
@@ -254,8 +254,8 @@ function requireNative() {
254
254
  try {
255
255
  const binding = require('@visulima/tui-binding-freebsd-arm64')
256
256
  const bindingPackageVersion = require('@visulima/tui-binding-freebsd-arm64/package.json').version
257
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
259
259
  }
260
260
  return binding
261
261
  } catch (e) {
@@ -275,8 +275,8 @@ function requireNative() {
275
275
  try {
276
276
  const binding = require('@visulima/tui-binding-linux-x64-musl')
277
277
  const bindingPackageVersion = require('@visulima/tui-binding-linux-x64-musl/package.json').version
278
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
280
280
  }
281
281
  return binding
282
282
  } catch (e) {
@@ -291,8 +291,8 @@ function requireNative() {
291
291
  try {
292
292
  const binding = require('@visulima/tui-binding-linux-x64-gnu')
293
293
  const bindingPackageVersion = require('@visulima/tui-binding-linux-x64-gnu/package.json').version
294
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
296
  }
297
297
  return binding
298
298
  } catch (e) {
@@ -309,8 +309,8 @@ function requireNative() {
309
309
  try {
310
310
  const binding = require('@visulima/tui-binding-linux-arm64-musl')
311
311
  const bindingPackageVersion = require('@visulima/tui-binding-linux-arm64-musl/package.json').version
312
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
314
314
  }
315
315
  return binding
316
316
  } catch (e) {
@@ -325,8 +325,8 @@ function requireNative() {
325
325
  try {
326
326
  const binding = require('@visulima/tui-binding-linux-arm64-gnu')
327
327
  const bindingPackageVersion = require('@visulima/tui-binding-linux-arm64-gnu/package.json').version
328
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
330
  }
331
331
  return binding
332
332
  } catch (e) {
@@ -343,8 +343,8 @@ function requireNative() {
343
343
  try {
344
344
  const binding = require('@visulima/tui-binding-linux-arm-musleabihf')
345
345
  const bindingPackageVersion = require('@visulima/tui-binding-linux-arm-musleabihf/package.json').version
346
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
348
348
  }
349
349
  return binding
350
350
  } catch (e) {
@@ -359,8 +359,8 @@ function requireNative() {
359
359
  try {
360
360
  const binding = require('@visulima/tui-binding-linux-arm-gnueabihf')
361
361
  const bindingPackageVersion = require('@visulima/tui-binding-linux-arm-gnueabihf/package.json').version
362
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
364
  }
365
365
  return binding
366
366
  } catch (e) {
@@ -377,8 +377,8 @@ function requireNative() {
377
377
  try {
378
378
  const binding = require('@visulima/tui-binding-linux-loong64-musl')
379
379
  const bindingPackageVersion = require('@visulima/tui-binding-linux-loong64-musl/package.json').version
380
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
382
382
  }
383
383
  return binding
384
384
  } catch (e) {
@@ -393,8 +393,8 @@ function requireNative() {
393
393
  try {
394
394
  const binding = require('@visulima/tui-binding-linux-loong64-gnu')
395
395
  const bindingPackageVersion = require('@visulima/tui-binding-linux-loong64-gnu/package.json').version
396
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
398
398
  }
399
399
  return binding
400
400
  } catch (e) {
@@ -411,8 +411,8 @@ function requireNative() {
411
411
  try {
412
412
  const binding = require('@visulima/tui-binding-linux-riscv64-musl')
413
413
  const bindingPackageVersion = require('@visulima/tui-binding-linux-riscv64-musl/package.json').version
414
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
416
416
  }
417
417
  return binding
418
418
  } catch (e) {
@@ -427,8 +427,8 @@ function requireNative() {
427
427
  try {
428
428
  const binding = require('@visulima/tui-binding-linux-riscv64-gnu')
429
429
  const bindingPackageVersion = require('@visulima/tui-binding-linux-riscv64-gnu/package.json').version
430
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
432
432
  }
433
433
  return binding
434
434
  } catch (e) {
@@ -444,8 +444,8 @@ function requireNative() {
444
444
  try {
445
445
  const binding = require('@visulima/tui-binding-linux-ppc64-gnu')
446
446
  const bindingPackageVersion = require('@visulima/tui-binding-linux-ppc64-gnu/package.json').version
447
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
449
449
  }
450
450
  return binding
451
451
  } catch (e) {
@@ -460,8 +460,8 @@ function requireNative() {
460
460
  try {
461
461
  const binding = require('@visulima/tui-binding-linux-s390x-gnu')
462
462
  const bindingPackageVersion = require('@visulima/tui-binding-linux-s390x-gnu/package.json').version
463
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
463
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
465
  }
466
466
  return binding
467
467
  } catch (e) {
@@ -480,8 +480,8 @@ function requireNative() {
480
480
  try {
481
481
  const binding = require('@visulima/tui-binding-openharmony-arm64')
482
482
  const bindingPackageVersion = require('@visulima/tui-binding-openharmony-arm64/package.json').version
483
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
485
485
  }
486
486
  return binding
487
487
  } catch (e) {
@@ -496,8 +496,8 @@ function requireNative() {
496
496
  try {
497
497
  const binding = require('@visulima/tui-binding-openharmony-x64')
498
498
  const bindingPackageVersion = require('@visulima/tui-binding-openharmony-x64/package.json').version
499
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
501
501
  }
502
502
  return binding
503
503
  } catch (e) {
@@ -512,8 +512,8 @@ function requireNative() {
512
512
  try {
513
513
  const binding = require('@visulima/tui-binding-openharmony-arm')
514
514
  const bindingPackageVersion = require('@visulima/tui-binding-openharmony-arm/package.json').version
515
- if (bindingPackageVersion !== '1.0.0-alpha.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
- throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.21 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '1.0.0-alpha.21' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 1.0.0-alpha.23 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
517
517
  }
518
518
  return binding
519
519
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/tui",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.23",
4
4
  "description": "React-based TUI library powered by a native Rust diff engine, drop-in Ink-compatible API",
5
5
  "keywords": [
6
6
  "cli",
@@ -568,11 +568,11 @@
568
568
  "LICENSE.md"
569
569
  ],
570
570
  "dependencies": {
571
- "@visulima/ansi": "4.0.0-alpha.15",
572
- "@visulima/colorize": "2.0.0-alpha.12",
573
- "@visulima/error": "6.0.0-alpha.31",
574
- "@visulima/spinner": "1.0.0-alpha.2",
575
- "@visulima/string": "3.0.0-alpha.14",
571
+ "@visulima/ansi": "4.0.0-alpha.16",
572
+ "@visulima/colorize": "2.0.0-alpha.13",
573
+ "@visulima/error": "6.0.0-alpha.32",
574
+ "@visulima/spinner": "1.0.0-alpha.3",
575
+ "@visulima/string": "3.0.0-alpha.16",
576
576
  "cli-boxes": "^4.0.1",
577
577
  "code-excerpt": "^4.0.0",
578
578
  "is-in-ci": "^2.0.0",
@@ -586,7 +586,7 @@
586
586
  "peerDependencies": {
587
587
  "@shikijs/langs": "^4.0.2",
588
588
  "@shikijs/themes": "^4.0.2",
589
- "@visulima/tabular": "4.0.0-alpha.12",
589
+ "@visulima/tabular": "4.0.0-alpha.13",
590
590
  "cfonts": "^3.3.1",
591
591
  "diff": "^9.0.0",
592
592
  "marked": "^18.0.3",
@@ -626,14 +626,14 @@
626
626
  }
627
627
  },
628
628
  "optionalDependencies": {
629
- "@visulima/tui-binding-linux-arm64-gnu": "1.0.0-alpha.21",
630
- "@visulima/tui-binding-darwin-arm64": "1.0.0-alpha.21",
631
- "@visulima/tui-binding-darwin-x64": "1.0.0-alpha.21",
632
- "@visulima/tui-binding-linux-arm64-musl": "1.0.0-alpha.21",
633
- "@visulima/tui-binding-linux-x64-gnu": "1.0.0-alpha.21",
634
- "@visulima/tui-binding-linux-x64-musl": "1.0.0-alpha.21",
635
- "@visulima/tui-binding-win32-arm64-msvc": "1.0.0-alpha.21",
636
- "@visulima/tui-binding-win32-x64-msvc": "1.0.0-alpha.21"
629
+ "@visulima/tui-binding-darwin-arm64": "1.0.0-alpha.23",
630
+ "@visulima/tui-binding-darwin-x64": "1.0.0-alpha.23",
631
+ "@visulima/tui-binding-linux-x64-gnu": "1.0.0-alpha.23",
632
+ "@visulima/tui-binding-linux-arm64-gnu": "1.0.0-alpha.23",
633
+ "@visulima/tui-binding-linux-arm64-musl": "1.0.0-alpha.23",
634
+ "@visulima/tui-binding-linux-x64-musl": "1.0.0-alpha.23",
635
+ "@visulima/tui-binding-win32-x64-msvc": "1.0.0-alpha.23",
636
+ "@visulima/tui-binding-win32-arm64-msvc": "1.0.0-alpha.23"
637
637
  },
638
638
  "engines": {
639
639
  "node": "^22.14.0 || >=24.10.0"
@@ -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-BG-LS10p.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-BMo200nF.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-ClEOyLHH.js";import Te from"./squashTextNodesWithMap-DCdi3SZ2.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
- const require = __cjs_mod__.createRequire(import.meta.url);
3
- const ze=1114112;var Ye=Object.defineProperty,xe=D((o,e)=>Ye(o,"name",{value:e,configurable:!0}),"T$1");const qe=1,Ke=2,Xe=3,Ue=4,Ve=7,Je=8,Qe=9,he=22,ge=23,fe=24,pe=27,me=28,ye=29,be=39,ve=49,Ze="\x1B[",E=xe(o=>o.length===0?"":`${Ze}${o.join(";")}m`,"sgr"),et=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([qe])),u&A&&(!(t&A)||m)&&(e+=E([Ke]))}u&I&&!(t&I)?e+=E([Xe]):!(u&I)&&t&I&&(e+=E([ge])),u&j&&!(t&j)?e+=E([Ue]):!(u&j)&&t&j&&(e+=E([fe])),u&z&&!(t&z)?e+=E([Ve]):!(u&z)&&t&z&&(e+=E([pe])),u&Y&&!(t&Y)?e+=E([Je]):!(u&Y)&&t&Y&&(e+=E([me])),u&q&&!(t&q)?e+=E([Qe]):!(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 tt=Object.defineProperty,ke=D((o,e)=>tt(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(ot.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 ot=new Set([27,144,152,155,157,158,159]),rt=.6,it=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=et(c);s[d]=l,t&&(this.previousRenderedLines[d]=l,this.previousLines[d]=f.clone())}return t&&n&&e.length>0&&i/e.length>rt&&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]=ze,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=it,this.previousLines.length=0,this.previousRenderedLines.length=0}}var nt=Object.defineProperty,st=D((o,e)=>nt(o,"name",{value:e,configurable:!0}),"d");const lt=st(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");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(d.cursorShape=a.shape,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=lt(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,cursorShape:void 0,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,cursorShape:void 0};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,cursorShape:s.cursorShape,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,cursorShape:s.cursorShape,output:g,outputHeight:d,staticOutput:i?`${i.get().output}
17
- `:""}}return{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:"",outputHeight:0,staticOutput:""}},"renderer");export{te as A,X as B,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};