blecsd 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +1 -2
  2. package/dist/3d/index.js +1 -1
  3. package/dist/{border-Jb7TrMob.d.ts → border-DGNDfT6T.d.ts} +1 -1
  4. package/dist/chunk-25OEBENM.js +3 -0
  5. package/dist/chunk-26STV7ZS.js +1 -0
  6. package/dist/chunk-2NMGUEFC.js +4 -0
  7. package/dist/{chunk-LYSK5S63.js → chunk-4PRDJTCM.js} +1 -1
  8. package/dist/chunk-5VEKHA3B.js +5 -0
  9. package/dist/chunk-6KEM3OS2.js +11 -0
  10. package/dist/chunk-6PX5R326.js +1 -0
  11. package/dist/{chunk-3LHLSY3Y.js → chunk-6XWY6GB7.js} +1 -1
  12. package/dist/{chunk-FCMTWFSE.js → chunk-735KKTP3.js} +1 -1
  13. package/dist/chunk-7SWJNDOL.js +26 -0
  14. package/dist/chunk-APKUNIMB.js +1 -0
  15. package/dist/{chunk-FGHEFXLK.js → chunk-CJCSZRV6.js} +1 -1
  16. package/dist/chunk-DMBMCCLN.js +1 -0
  17. package/dist/{chunk-OR3BZY7C.js → chunk-DQTVJITR.js} +1 -1
  18. package/dist/chunk-DSKQ5J4R.js +1 -0
  19. package/dist/{chunk-OB66FB4F.js → chunk-EF4DC6IN.js} +1 -1
  20. package/dist/chunk-EJAKECSN.js +1 -0
  21. package/dist/chunk-FNQRUMFD.js +1 -0
  22. package/dist/chunk-GJ3RS2VG.js +1 -0
  23. package/dist/{chunk-G437VE43.js → chunk-KTVEMB2I.js} +1 -1
  24. package/dist/chunk-KYAPE44E.js +8 -0
  25. package/dist/chunk-LI4Y7TBZ.js +1 -0
  26. package/dist/chunk-NHOL4BN6.js +1 -0
  27. package/dist/chunk-NPNUUSIB.js +1 -0
  28. package/dist/chunk-OFRWGW2G.js +1 -0
  29. package/dist/chunk-OMU5BSAS.js +2 -0
  30. package/dist/chunk-P3ZLIQJP.js +1 -0
  31. package/dist/chunk-PWI36BQJ.js +1 -0
  32. package/dist/{chunk-R7AICVRN.js → chunk-QQMUDJ32.js} +2 -2
  33. package/dist/chunk-R3ICZOE4.js +1 -0
  34. package/dist/chunk-RJULLVTH.js +1 -0
  35. package/dist/chunk-S6WS46FE.js +1 -0
  36. package/dist/{chunk-TWSWTBYL.js → chunk-TSARUU56.js} +1 -1
  37. package/dist/{chunk-MKMFUXLB.js → chunk-WJRVUAZR.js} +2 -2
  38. package/dist/{chunk-XZJRWFOS.js → chunk-WY5EZOOL.js} +1 -1
  39. package/dist/chunk-YY6RZCZH.js +4 -0
  40. package/dist/chunk-ZPGJCHXH.js +1 -0
  41. package/dist/chunk-ZPL2J25N.js +1 -0
  42. package/dist/components/index.d.ts +6886 -6763
  43. package/dist/components/index.js +1 -1
  44. package/dist/core/index.d.ts +3621 -3217
  45. package/dist/core/index.js +1 -1
  46. package/dist/debug/index.d.ts +2 -2
  47. package/dist/debug/index.js +1 -1
  48. package/dist/game/index.d.ts +6 -6
  49. package/dist/game/index.js +1 -1
  50. package/dist/{gameLoop-C-Ez_i54.d.ts → gameLoop-CSTb7e0L.d.ts} +1 -1
  51. package/dist/index.d.ts +741 -23
  52. package/dist/index.js +3 -3
  53. package/dist/input/index.d.ts +1 -1
  54. package/dist/{inputActions-CRsUtTHM.d.ts → inputActions-Fyw14_Gm.d.ts} +3 -3
  55. package/dist/{keyParser-BnHbg2iD.d.ts → keyParser-m7fWto6g.d.ts} +18 -18
  56. package/dist/{mouseParser-Cfrbn3AX.d.ts → mouseParser-B7p5ow7K.d.ts} +1 -1
  57. package/dist/{scheduler-CMcYew9Z.d.ts → scheduler-DeeZleia.d.ts} +2 -0
  58. package/dist/systems/index.d.ts +351 -4
  59. package/dist/systems/index.js +1 -1
  60. package/dist/terminal/index.d.ts +329 -7
  61. package/dist/terminal/index.js +1 -1
  62. package/dist/utils/index.d.ts +3 -3
  63. package/dist/utils/index.js +1 -1
  64. package/dist/widgets/bigText.js +1 -1
  65. package/dist/widgets/index.d.ts +1222 -101
  66. package/dist/widgets/index.js +1 -1
  67. package/package.json +1 -1
  68. package/dist/chunk-2IEMMRUO.js +0 -1
  69. package/dist/chunk-3AV52GY5.js +0 -1
  70. package/dist/chunk-3O4TQHGK.js +0 -4
  71. package/dist/chunk-3UJWZ5ZN.js +0 -1
  72. package/dist/chunk-6M2J5QUA.js +0 -1
  73. package/dist/chunk-7IQEUVGF.js +0 -1
  74. package/dist/chunk-A6M6TFBL.js +0 -1
  75. package/dist/chunk-CIK4AMUA.js +0 -1
  76. package/dist/chunk-CUEUJAHK.js +0 -3
  77. package/dist/chunk-D42Q2KKR.js +0 -1
  78. package/dist/chunk-DYEXOFUU.js +0 -2
  79. package/dist/chunk-DYU72XLL.js +0 -1
  80. package/dist/chunk-EAY7B5GL.js +0 -1
  81. package/dist/chunk-FL56THSI.js +0 -25
  82. package/dist/chunk-G7GIWWLE.js +0 -1
  83. package/dist/chunk-GGXNWT36.js +0 -8
  84. package/dist/chunk-HLFORKXS.js +0 -1
  85. package/dist/chunk-J7MBKEBY.js +0 -1
  86. package/dist/chunk-K3SX2LY5.js +0 -1
  87. package/dist/chunk-LDAFEXN5.js +0 -1
  88. package/dist/chunk-MQWPHPUM.js +0 -1
  89. package/dist/chunk-MTI376CU.js +0 -5
  90. package/dist/chunk-MTV2RJZD.js +0 -1
  91. package/dist/chunk-PXXGH3BV.js +0 -1
  92. package/dist/chunk-SHUC6JWA.js +0 -1
  93. package/dist/chunk-UMGTXSQB.js +0 -11
  94. package/dist/chunk-X3Q3T2SS.js +0 -4
  95. package/dist/chunk-ZAHG7Y3X.js +0 -1
  96. package/dist/{virtualViewport-Bpv6jlKt.d.ts → virtualViewport-DTSN6jFk.d.ts} +152 -152
@@ -0,0 +1,26 @@
1
+ import {e as e$5,i as i$2,o as o$1,h as h$5}from'./chunk-26STV7ZS.js';import {a as a$2}from'./chunk-FNQRUMFD.js';import {c as c$2,d as d$8,h as h$4}from'./chunk-6PX5R326.js';import {e}from'./chunk-25OEBENM.js';import {mb as mb$1,Q,z as z$1,Z,q as q$1,Y,qb as qb$1,y as y$1,P,J,G as G$1,E as E$1}from'./chunk-4PRDJTCM.js';import {ga as ga$1,xa as xa$1,xb as xb$1,Ab as Ab$1,Ob as Ob$1,Ub as Ub$1,_a,eb as eb$1,ra as ra$2,ea as ea$1,Ta,Xa as Xa$1,Va,Sa as Sa$1,Ra,Oa,Na,S,za as za$1,da as da$1,oa as oa$2,$,C as C$1,Y as Y$1,X as X$1,W,V,wa,va,ua as ua$1,Ca as Ca$1,Ba,Aa,Wa as Wa$1,ca as ca$1,ba as ba$1,aa as aa$1,ia as ia$1,Ma,Pa,T,U as U$1,w as w$1,s as s$3,p as p$1,q as q$4,na as na$1,zb as zb$1,ac as ac$1,Vb as Vb$1,Zb as Zb$1,_b as _b$1,Xb as Xb$1,Yb as Yb$1,Rb as Rb$1,Qb as Qb$1,Tb as Tb$1,Sb as Sb$1,$b as $b$1,Jb as Jb$1,Pb as Pb$1,Ib as Ib$1,Mb as Mb$1,Lb as Lb$1,Kb as Kb$1,Gb as Gb$1,Fb as Fb$1,Eb as Eb$1,Db as Db$1,Nb as Nb$1,Bb as Bb$1,Cb as Cb$1,hb as hb$1,fb as fb$1,nb as nb$1,jb as jb$1,kb as kb$1,ha as ha$1,b as b$2,d as d$6,yb as yb$1,gb as gb$1,mb as mb$2,hc as hc$1,wc as wc$1,yc as yc$1,jc as jc$1,kc as kc$1,vc as vc$1,mc as mc$1,qc as qc$1,pc as pc$1,uc as uc$1,tc as tc$1,sc as sc$1,rc as rc$1,oc as oc$1,nc as nc$1}from'./chunk-2NMGUEFC.js';import {e as e$6,d as d$7,p as p$2,y as y$3,u as u$2,q as q$6,n as n$3,m as m$3,o as o$2,l as l$2,s as s$4,r as r$1}from'./chunk-TSARUU56.js';import {g as g$1,h as h$3,i as i$3,o as o$3,n as n$4,m as m$4,w as w$2}from'./chunk-VOCM5T2G.js';import {m}from'./chunk-RJULLVTH.js';import {ia as ia$2,Ua as Ua$1,ab as ab$1,bb as bb$1,O,X as X$2,P as P$1,q as q$5,H as H$1,B as B$1,J as J$1,ob as ob$1,ub as ub$1,Eb as Eb$2,Jb as Jb$2,Hb as Hb$1,Lb as Lb$2,pb as pb$1,vb as vb$1,ra as ra$3,ta as ta$1,F as F$1,K,E as E$2,G as G$2,x as x$1,C as C$2,v as v$2,z as z$3,A as A$1,y as y$2,$ as $$1,Z as Z$2,aa as aa$2,R,Y as Y$2,W as W$1,U as U$2,T as T$2,_,tb as tb$1,sb as sb$1,rb as rb$1,Mb as Mb$2,Nb as Nb$2,Ab as Ab$2,Ib as Ib$2,Db as Db$2,zb as zb$2,Gb as Gb$2,Fb as Fb$2}from'./chunk-DSKQ5J4R.js';import {b,l as l$1,H,G,F,E,D,C,B,A,z as z$2,y,x,s as s$2,v,u as u$1,n as n$1,q as q$3,r,o,p,t as t$2,m as m$2,c as c$1}from'./chunk-6XWY6GB7.js';import {d as d$4,e as e$7}from'./chunk-DQTVJITR.js';import {u,a,l,m as m$1,f as f$3,e as e$3,d as d$2,c,b as b$1,t as t$1}from'./chunk-ZPGJCHXH.js';import {e as e$1,f as f$2,d as d$5,h as h$2}from'./chunk-735KKTP3.js';import {d,f as f$1,i,h}from'./chunk-APKUNIMB.js';import {U,f,la as la$1,g,ra as ra$1,s as s$1,q as q$2,oa as oa$1,Z as Z$1,i as i$1,T as T$1,V as V$1,e as e$4,v as v$1,n as n$2}from'./chunk-GJ3RS2VG.js';import {n,t,s,d as d$1,e as e$2,h as h$1,g as g$2,f as f$4,q as q$7}from'./chunk-P3ZLIQJP.js';import {d as d$3,a as a$1}from'./chunk-5PELJRUQ.js';import {z}from'zod';import {readdirSync,statSync}from'fs';import {resolve,join,dirname}from'path';import {createRequire}from'module';import {pathToFileURL}from'url';n();t();u();n();t();var id=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Gi=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),uf=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),df=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),ld=z.object({left:Gi.optional(),top:Gi.optional(),right:Gi.optional(),bottom:Gi.optional(),width:id.optional(),height:id.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:uf,padding:df,content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional()}),cf=1e4,Or={isBox:new Uint8Array(cf)};function gf(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function mf(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function ff(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$2;case "bold":return e$3;case "ascii":return f$3}}function bf(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function ad(e){return e===void 0?0:typeof e=="number"?e:0}function sd(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function pf(e,r,o){let n=ad(o.left),t=ad(o.top);U(e,r,n,t);let i=sd(o.width),a=sd(o.height);f(e,r,i,a);}function yf(e,r,o){o.fg===void 0&&o.bg===void 0||la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function hf(e,r,o){let n=o.type?bf(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?ff(o.ch):o.ch;m$1(e,r,t);}}function xf(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function Sf(e,r,o){if(o.content===void 0)return;let n={};o.align&&(n.align=gf(o.align)),o.valign&&(n.valign=mf(o.valign)),e$1(e,r,o.content,n);}function Tt(e,r,o={}){let n=ld.parse(o),t=r;Or.isBox[t]=1,pf(e,t,n),yf(e,t,n),n.border&&hf(e,t,n.border),n.padding!==void 0&&xf(e,t,n.padding),Sf(e,t,n),d(e,t,{focusable:true});let i$1={eid:t,show(){return ra$1(e,t,true),i$1},hide(){return ra$1(e,t,false),i$1},move(a,s){return Z$1(e,t,a,s),oa$1(e,t),i$1},setPosition(a,s){return U(e,t,a,s),oa$1(e,t),i$1},setContent(a){return e$1(e,t,a),oa$1(e,t),i$1},getContent(){return f$2(e,t)},focus(){return h(e,t),i$1},blur(){return i(e,t),i$1},isFocused(){return f$1(e,t)},append(a){return q$2(e,t,a),i$1},getChildren(){return s$1(e,t)},destroy(){Or.isBox[t]=0,e$2(e,t);}};return i$1}function Cf(e,r,o){return e$1(e,r,o),oa$1(e,r),r}function Wf(e,r){return f$2(e,r)}function Tf(e,r){return Or.isBox[r]===1}function vf(){Or.isBox.fill(0);}var Lf=z.object({title:z.string(),content:z.union([z.string(),z.number().int().nonnegative()]).optional(),expanded:z.boolean().optional(),onToggle:z.function().nullable().optional()}),Ef=z.object({sections:z.array(Lf).optional(),allowMultiple:z.boolean().optional(),defaultExpanded:z.union([z.array(z.number().int().nonnegative()),z.literal("all")]).optional(),icons:z.object({expanded:z.string().optional(),collapsed:z.string().optional()}).optional(),style:z.object({header:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional(),content:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional()}).optional()}),Bf=z.object({title:z.string(),content:z.union([z.string(),z.number().int().nonnegative()]).optional(),expanded:z.boolean().optional(),onToggle:z.function().nullable().optional(),icons:z.object({expanded:z.string().optional(),collapsed:z.string().optional()}).optional(),style:z.object({header:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional(),content:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional()}).optional()}),xn=new Map,wi=new Map,zi=new Map;function Pf(){xn.clear(),wi.clear(),zi.clear();}var ud="\u25BC",dd="\u25B6";function Mf(e,r){let o=new Set;if(r==="all")for(let n=0;n<e.length;n++)o.add(n);else if(Array.isArray(r))for(let n of r)o.add(n);else for(let n=0;n<e.length;n++)e[n]?.expanded&&o.add(n);return o}function Hi(e,r,o){if(!o)return;let n=typeof o.fg=="string"?s(o.fg):o.fg,t=typeof o.bg=="string"?s(o.bg):o.bg;(n!==void 0||t!==void 0)&&la$1(e,r,{fg:n,bg:t});}function Df(e,r,o,n,t,i,a){let s=d$1(e);return Tt(e,s),U(e,s,0,n*2),f(e,s,40,1),e$1(e,s,`${t?i.expanded:i.collapsed} ${o.title}`),d(e,s,{focusable:true}),q$2(e,r,s),zi.set(s,o.title),e$7(e,s,true),Hi(e,s,a),s}function Ff(e,r,o,n,t,i){let a=d$1(e);return Tt(e,a),U(e,a,2,n*2+1),f(e,a,38,3),b(e,a,{left:1,right:1,top:0,bottom:0}),typeof o.content=="string"?e$1(e,a,o.content):o.content!==void 0&&q$2(e,a,o.content),ra$1(e,a,t),q$2(e,r,a),Hi(e,a,i),a}function Af(e,r,o,n,t,i,a){let s=Df(e,r,o,n,t,i,a?.header),l=Ff(e,r,o,n,t,a?.content);return {headerEntity:s,contentEntity:l,expanded:t,onToggle:o.onToggle??void 0}}function If(e,r,o={}){let n=o.sections??[],t=o.allowMultiple??false,i=o.defaultExpanded,a={expanded:o.icons?.expanded??ud,collapsed:o.icons?.collapsed??dd},s=Mf(n,i),l=n.map((u,d)=>Af(e,r,u,d,s.has(d),a,o.style));return xn.set(r,{allowMultiple:t,expandedSections:s,sections:l,icons:a,world:e}),r}function Ha(e,r){let o=xn.get(e);if(!o)return;let n=o.sections[r];if(!n)return;let t=!n.expanded;!o.allowMultiple&&t&&o.sections.forEach((i,a)=>{a!==r&&i.expanded&&(i.expanded=false,ra$1(o.world,i.contentEntity,false),e$1(o.world,i.headerEntity,`${o.icons.collapsed} ${za(i.headerEntity)}`),o.expandedSections.delete(a));}),n.expanded=t,ra$1(o.world,n.contentEntity,t),e$1(o.world,n.headerEntity,`${t?o.icons.expanded:o.icons.collapsed} ${za(n.headerEntity)}`),t?o.expandedSections.add(r):o.expandedSections.delete(r),oa$1(o.world,e),n.onToggle?.(t);}function cd(e,r){let o=xn.get(e);if(!o)return;let n=o.sections[r];!n||n.expanded||Ha(e,r);}function kf(e){let r=xn.get(e);!r||!r.allowMultiple||r.sections.forEach((o,n)=>{cd(e,n);});}function Rf(e){let r=xn.get(e);r&&r.sections.forEach((o,n)=>{o.expanded&&Ha(e,n);});}function Vf(e){let r=xn.get(e);return r?Array.from(r.expandedSections):[]}function Of(e,r,o,n,t,i){let a=d$1(e);return Tt(e,a),U(e,a,0,0),f(e,a,40,1),e$1(e,a,`${n?t.expanded:t.collapsed} ${o}`),d(e,a,{focusable:true}),q$2(e,r,a),zi.set(a,o),e$7(e,a,true),Hi(e,a,i),a}function _f(e,r,o,n,t){let i=d$1(e);return Tt(e,i),U(e,i,2,1),f(e,i,38,3),b(e,i,{left:1,right:1,top:0,bottom:0}),typeof o=="string"?e$1(e,i,o):o!==void 0&&q$2(e,i,o),ra$1(e,i,n),q$2(e,r,i),Hi(e,i,t),i}function Nf(e,r,o){let n=o.expanded??false,t={expanded:o.icons?.expanded??ud,collapsed:o.icons?.collapsed??dd},i=Of(e,r,o.title,n,t,o.style?.header),a=_f(e,r,o.content,n,o.style?.content);return wi.set(r,{expanded:n,headerEntity:i,contentEntity:a,onToggle:o.onToggle,icons:t,world:e}),r}function Gf(e){let r=wi.get(e);if(!r)return;let o=!r.expanded;r.expanded=o,ra$1(r.world,r.contentEntity,o),e$1(r.world,r.headerEntity,`${o?r.icons.expanded:r.icons.collapsed} ${za(r.headerEntity)}`),oa$1(r.world,e),r.onToggle?.(o);}function gd(e){return xn.has(e)}function wf(e){return wi.has(e)}function zf(e,r){return gd(e)?{entity:e,world:r}:void 0}function za(e){return zi.get(e)??""}n();t();var Hf=1e4,Ua={isAutocomplete:new Uint8Array(Hf)},md=z.object({items:z.array(z.string()).optional().default([]),placeholder:z.string().optional().default("Type to search..."),maxSuggestions:z.number().int().positive().optional().default(10),fuzzyMatch:z.boolean().optional().default(true),value:z.string().optional().default(""),width:z.number().int().positive().optional().default(30),left:z.number().optional().default(0),top:z.number().optional().default(0),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),highlightFg:z.union([z.string(),z.number()]).optional(),highlightBg:z.union([z.string(),z.number()]).optional()}),tt=new Map;function Ui(e,r,o,n){if(!r)return e.slice(0,n).map(a=>({item:a,text:a,score:1,indices:[]}));if(o)return c$2(r,e).slice(0,n);let t=r.toLowerCase(),i=[];for(let a of e){let l=a.toLowerCase().indexOf(t);if(l===-1)continue;let u=1-l/a.length;i.push({item:a,text:a,score:u,indices:Array.from({length:r.length},(d,b)=>l+b)});}return i.sort((a,s)=>s.score-a.score),i.slice(0,n)}function Uf(e,r,o={}){let n=md.parse(o),t=r;Ua.isAutocomplete[t]=1,U(e,t,n.left,n.top),f(e,t,n.width,1),d(e,t,{focusable:true}),ia$2(e,t),Ua$1(e,t,{placeholder:n.placeholder,maxLength:0});let i$1=n.fg?s(n.fg):void 0,a=n.bg?s(n.bg):void 0;(i$1!==void 0||a!==void 0)&&la$1(e,t,{fg:i$1,bg:a});let s$1={items:n.items,inputText:n.value,filteredItems:Ui(n.items,n.value,n.fuzzyMatch,n.maxSuggestions),selectedIndex:0,isOpen:false,fuzzyMatch:n.fuzzyMatch,maxSuggestions:n.maxSuggestions};tt.set(t,s$1),ab$1(e,t,u=>{let d=tt.get(t);d&&(d.inputText=u,d.filteredItems=Ui(d.items,u,d.fuzzyMatch,d.maxSuggestions),d.selectedIndex=0,d.isOpen=u.length>0&&d.filteredItems.length>0,oa$1(e,t),d.onChangeCallback&&d.onChangeCallback(u));}),bb$1(e,t,u=>{let d=tt.get(t);if(d){if(d.isOpen&&d.filteredItems.length>0){let b=d.filteredItems[d.selectedIndex];b&&(d.inputText=b.item,d.isOpen=false,d.selectedIndex=0,d.onSelectCallback&&d.onSelectCallback(b.item));}else d.onSelectCallback&&d.onSelectCallback(u);oa$1(e,t);}});let l={eid:t,show(){return ra$1(e,t,true),oa$1(e,t),l},hide(){return ra$1(e,t,false),oa$1(e,t),l},focus(){return h(e,t),ra$3(e,t),ta$1(e,t),l},blur(){i(e,t);let u=tt.get(t);return u&&(u.isOpen=false),oa$1(e,t),l},getValue(){return tt.get(t)?.inputText??""},setValue(u){let d=tt.get(t);return d&&(d.inputText=u,d.filteredItems=Ui(d.items,u,d.fuzzyMatch,d.maxSuggestions),d.selectedIndex=0,d.isOpen=u.length>0&&d.filteredItems.length>0,oa$1(e,t)),l},setItems(u){let d=tt.get(t);return d&&(d.items=u,d.filteredItems=Ui(u,d.inputText,d.fuzzyMatch,d.maxSuggestions),d.selectedIndex=0,oa$1(e,t)),l},getItems(){return tt.get(t)?.items??[]},getSuggestions(){return tt.get(t)?.filteredItems.map(d=>d.item)??[]},isOpen(){return tt.get(t)?.isOpen??false},openDropdown(){let u=tt.get(t);return u&&u.filteredItems.length>0&&(u.isOpen=true,oa$1(e,t)),l},closeDropdown(){let u=tt.get(t);return u&&(u.isOpen=false,oa$1(e,t)),l},onSelect(u){let d=tt.get(t);return d&&(d.onSelectCallback=u),l},onChange(u){let d=tt.get(t);return d&&(d.onChangeCallback=u),l},destroy(){tt.delete(t),e$2(e,t);}};return l}function $f(e,r){return Ua.isAutocomplete[r]===1}function jf(){tt.clear();}n();t();var Sn=10240,_n=[[1,8],[2,16],[4,32],[64,128]];function Yf(e,r){if(e<0||e>1||r<0||r>3)return " ";let o=_n[r];if(!o)return " ";let n=o[e]??0;return String.fromCharCode(10240|n)}function $a(e){let r=0;for(let[o,n]of e)if(o>=0&&o<=1&&n>=0&&n<=3){let t=_n[n];t&&(r|=t[o]??0);}return String.fromCharCode(10240|r)}function fd(e,r=5){if(e===0)return 1;let o=e/r,n=10**Math.floor(Math.log10(o)),t=o/n,i;return t<=1?i=1:t<=2?i=2:t<=5?i=5:i=10,i*n}function _r(e,r,o=5){if(e===r)return [e];let n=r-e,t=fd(n,o),i=Math.floor(e/t)*t,a=[];for(let l=i;l<=r;l+=t)l>=e&&a.push(l);let s=a[a.length-1];return (a.length===0||s!==void 0&&s<r)&&a.push(r),a}function St(e,r,o,n,t){if(o===r)return (n+t)/2;let i=o-r,a=t-n,s=(e-r)/i;return n+s*a}function cr(e,r=8){if(!Number.isFinite(e))return "NaN";let o=Math.abs(e);if(o<.01&&o>0)return e.toExponential(2);if(o>=1e9)return `${(e/1e9).toFixed(2)}B`;if(o>=1e6)return `${(e/1e6).toFixed(2)}M`;if(o>=1e3)return `${(e/1e3).toFixed(2)}K`;let n=e.toFixed(2);return n.length<=r?n:e.toFixed(0)}function ja(e){return `${Math.round(e*100)}%`}var $i=[4284790262,4286695300,4294948685,4293227379,4290406600,4294956367,4283289825,4288776319];function en(e){let r=$i[e%$i.length];return r===void 0?$i[0]:r}function Kf(e,r,o){let n=e>>16&255,t=e>>8&255,i=e&255,a=e>>24&255,s=r>>16&255,l=r>>8&255,u=r&255,d=r>>24&255,b=Math.round(n+(s-n)*o),f=Math.round(t+(l-t)*o),c=Math.round(i+(u-i)*o);return (Math.round(a+(d-a)*o)<<24|b<<16|f<<8|c)>>>0}function Qf(e,r){return cr(e,r-1).padEnd(r," ")}function Nr(e,r){return cr(e,r).padStart(r," ")}var pd=[" ","\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u2588"],yd=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],Xf=z.object({label:z.string(),data:z.array(z.number()),color:z.union([z.string(),z.number()]).optional()}),hd=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(40),height:z.number().int().positive().default(20),orientation:z.enum(["vertical","horizontal"]).default("vertical"),mode:z.enum(["grouped","stacked"]).default("grouped"),labels:z.array(z.string()).default([]),series:z.array(Xf).default([]),barChar:z.string().length(1).default("\u2588"),barWidth:z.number().int().positive().default(3),barGap:z.number().int().nonnegative().default(1),showValues:z.boolean().default(false),useBlockChars:z.boolean().default(false),yLabel:z.string().optional(),xLabel:z.string().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),Gr=1e4,He={isBarChart:new Uint8Array(Gr),showValues:new Uint8Array(Gr),orientation:new Uint8Array(Gr),mode:new Uint8Array(Gr),useBlockChars:new Uint8Array(Gr)},Cn=new Map;function Ka(e,r){let o=r?yd:pd,n=Math.round(e*(o.length-1)),t=Math.max(0,Math.min(o.length-1,n));return o[t]??" "}function bd(e,r,o){if(e>=r+1)return "\u2588";if(e<=r)return " ";let n=e-r;return Ka(n,o)}function qf(e,r,o,n){let t=[],i=e.mode==="stacked",a=Number.NEGATIVE_INFINITY;if(i)for(let p=0;p<e.labels.length;p++){let h=0;for(let E of e.series)h+=E.data[p]??0;h>a&&(a=h);}else for(let p of e.series)for(let h of p.data)h>a&&(a=h);(a===Number.NEGATIVE_INFINITY||a===0)&&(a=100);let s=8,u=o-2,d=r-s,b=_r(0,a,5),f=i?e.barWidth:e.barWidth*e.series.length+e.barGap*(e.series.length-1);for(let p=0;p<u;p++){let h=u-p-1,E=St(h,0,u-1,0,a),W=b.find(I=>Math.abs(I-E)<a/u),D=`${W!==void 0?Nr(W,s-2):" ".repeat(s-2)}\u2502 `;for(let I=0;I<e.labels.length;I++){if(i){let L=0,N=" ";for(let pe of e.series){let xe=pe.data[I]??0,ft=L+xe,In=St(L,0,a,0,u-1),Xt=St(ft,0,a,0,u-1);if(h>=In&&h<=Xt){e.useBlockChars&&h===Math.floor(Xt)&&h!==Xt?N=bd(Xt,h,true):N=e.barChar;break}L=ft;}D+=N.repeat(e.barWidth);}else for(let L=0;L<e.series.length;L++){let N=e.series[L];if(!N)continue;let pe=N.data[I]??0,xe=St(pe,0,a,0,u-1),ft;h>xe?ft=" ":e.useBlockChars&&h===Math.floor(xe)?ft=bd(xe,h,true):ft=e.barChar,D+=ft.repeat(e.barWidth),L<e.series.length-1&&(D+=" ".repeat(e.barGap));}I<e.labels.length-1&&(D+=" ");}t.push(D.padEnd(r," "));}let c=`${" ".repeat(s)}\u2514${"\u2500".repeat(d-1)}`;t.push(c.padEnd(r," "));let g=`${" ".repeat(s)} `;for(let p=0;p<e.labels.length;p++){let h=e.labels[p]??"",E=f+2;g+=h.slice(0,E).padEnd(E," ");}return t.push(g.padEnd(r," ")),t.join(`
2
+ `)}function Jf(e,r,o,n){let t=[],i=e.mode==="stacked",a=Number.NEGATIVE_INFINITY;if(i)for(let u=0;u<e.labels.length;u++){let d=0;for(let b of e.series)d+=b.data[u]??0;d>a&&(a=d);}else for(let u of e.series)for(let d of u.data)d>a&&(a=d);(a===Number.NEGATIVE_INFINITY||a===0)&&(a=100);let s=Math.max(...e.labels.map(u=>u.length),8),l=r-s-2-(n?10:0);for(let u=0;u<e.labels.length;u++){let d=e.labels[u]??"";if(i){let b=`${d.slice(0,s).padStart(s," ")} \u2502`;for(let f of e.series){let c=f.data[u]??0,g=St(c,0,a,0,l),p=Math.floor(g),h=g-p;b+=e.barChar.repeat(p),e.useBlockChars&&h>0&&(b+=Ka(h,false));}if(n){let f=e.series.reduce((c,g)=>c+(g.data[u]??0),0);b+=` ${cr(f)}`;}t.push(b.padEnd(r," "));}else {let b=`${d.slice(0,s).padStart(s," ")} \u2502`,f=e.series[0];if(f){let c=f.data[u]??0,g=St(c,0,a,0,l),p=Math.floor(g),h=g-p;b+=e.barChar.repeat(p),e.useBlockChars&&h>0&&(b+=Ka(h,false)),n&&(b+=` ${cr(c)}`);}t.push(b.padEnd(r," "));}}return t.join(`
3
+ `)}function Ya(e,r){let o=Cn.get(r);if(!o)return;let n=g(e,r);if(!n)return;let t=He.showValues[r]===1,a=He.orientation[r]===1?Jf(o,n.width,n.height,t):qf(o,n.width,n.height);e$1(e,r,a),oa$1(e,r);}function Zf(e,r={}){let o=hd.parse(r),n=d$1(e);U(e,n,o.x,o.y),f(e,n,o.width,o.height),He.isBarChart[n]=1,He.showValues[n]=o.showValues?1:0,He.orientation[n]=o.orientation==="horizontal"?1:0,He.mode[n]=o.mode==="stacked"?1:0,He.useBlockChars[n]=o.useBlockChars?1:0,Cn.set(n,{labels:[...o.labels],series:o.series.map((i,a)=>({label:i.label,data:[...i.data],color:i.color?s(i.color):en(a)})),barChar:o.barChar,barWidth:o.barWidth,barGap:o.barGap,yLabel:o.yLabel??"",xLabel:o.xLabel??"",mode:o.mode,useBlockChars:o.useBlockChars}),(o.fg!==void 0||o.bg!==void 0)&&la$1(e,n,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),Ya(e,n);let t={eid:n,setSeries(i){let a=Cn.get(n);return a&&(a.series=i.map((s$1,l)=>({label:s$1.label,data:[...s$1.data],color:s$1.color?s(s$1.color):en(l)})),Ya(e,n)),t},getSeries(){return Cn.get(n)?.series??[]},setLabels(i){let a=Cn.get(n);return a&&(a.labels=[...i],Ya(e,n)),t},getLabels(){return Cn.get(n)?.labels??[]},setPosition(i,a){return U(e,n,i,a),oa$1(e,n),t},destroy(){He.isBarChart[n]=0,He.showValues[n]=0,He.orientation[n]=0,He.mode[n]=0,He.useBlockChars[n]=0,Cn.delete(n),e$2(e,n);}};return t}function eb(e,r){return He.isBarChart[r]===1}function tb(){He.isBarChart.fill(0),He.showValues.fill(0),He.orientation.fill(0),He.mode.fill(0),He.useBlockChars.fill(0),Cn.clear();}n();var Sd=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(3),label:z.string().default("Button"),focusable:z.boolean().default(true),disabled:z.boolean().default(false)}),nb=1e4,xd=2,zr={isButtonWidget:new Uint8Array(nb)},wr=new Map;function rb(e,r={}){let o=Sd.parse(r),n=d$1(e);zr.isButtonWidget[n]=1,O(e,n);let t=o.label.length,i$1=o.width??t+xd*2;f(e,n,i$1,o.height),U(e,n,o.x,o.y),wr.set(n,{label:o.label}),e$1(e,n,o.label,{align:1,valign:1}),d$4(e,n,{clickable:true,hoverable:true,keyable:true,focusable:o.focusable}),d(e,n,{focusable:o.focusable}),o.disabled&&X$2(e,n);let a={eid:n,click(){return _(e,n),oa$1(e,n),a},isHovered(){return T$2(e,n)},isPressed(){return U$2(e,n)},isFocused(){return f$1(e,n)},isDisabled(){return W$1(e,n)},setDisabled(s){return s?X$2(e,n):Y$2(e,n),oa$1(e,n),a},setLabel(s){let l=wr.get(n);if(l&&(l.label=s),!o.width){let u=s.length+xd*2;f(e,n,u,o.height);}return e$1(e,n,s,{align:1,valign:1}),oa$1(e,n),a},getLabel(){return wr.get(n)?.label??""},setPosition(s,l){return U(e,n,s,l),oa$1(e,n),a},move(s,l){return Z$1(e,n,s,l),oa$1(e,n),a},getPosition(){return {x:T$1.x[n]??0,y:T$1.y[n]??0}},focus(){return h(e,n),R(e,n,"focus"),oa$1(e,n),a},blur(){return i(e,n),R(e,n,"blur"),oa$1(e,n),a},handleKey(s){if(!f$1(e,n))return false;let l=aa$2(e,n,s);return l&&oa$1(e,n),l},onClick(s){return Z$2(n,s),a},destroy(){zr.isButtonWidget[n]=0,wr.delete(n),$$1(n),e$2(e,n);}};return a}function ob(e,r){return zr.isButtonWidget[r]===1&&P$1(e,r)}function ib(){zr.isButtonWidget.fill(0),wr.clear();}n();var Cd=z.object({left:z.number().default(0),top:z.number().default(0),initialDate:z.date().optional(),minDate:z.date().optional(),maxDate:z.date().optional(),firstDayOfWeek:z.number().int().min(0).max(6).default(0),showWeekNumbers:z.boolean().default(false),markedDates:z.array(z.date()).default([]),theme:z.object({headerFg:z.union([z.string(),z.number()]).optional(),headerBg:z.union([z.string(),z.number()]).optional(),weekdayFg:z.union([z.string(),z.number()]).optional(),dayFg:z.union([z.string(),z.number()]).optional(),selectedFg:z.union([z.string(),z.number()]).optional(),selectedBg:z.union([z.string(),z.number()]).optional(),todayFg:z.union([z.string(),z.number()]).optional(),todayBg:z.union([z.string(),z.number()]).optional(),markedFg:z.union([z.string(),z.number()]).optional(),markedBg:z.union([z.string(),z.number()]).optional(),outsideFg:z.union([z.string(),z.number()]).optional(),cursorFg:z.union([z.string(),z.number()]).optional(),cursorBg:z.union([z.string(),z.number()]).optional()}).optional()}).strict(),Ur=new Map;function Ue(e){return Ur.get(e)}function ab(e,r){Ur.set(e,r);}function sb(e){Ur.delete(e);}function lb(){Ur.clear();}function ji(e){let r=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return `${r}-${o}-${n}`}function Hr(e,r){return new Date(e,r+1,0).getDate()}function ub(e,r){return new Date(e,r,1).getDay()}function db(e){let r=new Date(e.valueOf()),o=(e.getDay()+6)%7;r.setDate(r.getDate()-o+3);let n=r.valueOf();return r.setMonth(0,1),r.getDay()!==4&&r.setMonth(0,1+(4-r.getDay()+7)%7),1+Math.ceil((n-r.valueOf())/6048e5)}function cb(e,r,o){return !(r&&e<r||o&&e>o)}function gb(e,r,o,n,t){let i="";if(o){let s=new Date(n,t,e>0?e:1),l=db(s);i+=`${String(l).padStart(2," ")} `;}let a=e;for(let s=0;s<7;s++){if(a<1||a>r)i+=" ";else {let l=String(a).padStart(2," ");i+=`${l} `;}a++;}return {weekLine:i.trimEnd(),nextDate:a}}function ct(e,r){let o=Ue(r);if(!o)return;let n=[],t=["January","February","March","April","May","June","July","August","September","October","November","December"],i=["Su","Mo","Tu","We","Th","Fr","Sa"],a=[...i.slice(o.firstDayOfWeek),...i.slice(0,o.firstDayOfWeek)],s=`${t[o.month]} ${o.year}`,l=Math.max(0,Math.floor((23-s.length)/2));n.push(" ".repeat(l)+s);let u=o.showWeekNumbers?" ":"";u+=a.join(" "),n.push(u);let d=Hr(o.year,o.month),f=(ub(o.year,o.month)-o.firstDayOfWeek+7)%7,c=1,g=1-f;for(let p=0;p<6;p++){let h=gb(g,d,o.showWeekNumbers,o.year,o.month);if(n.push(h.weekLine),g=h.nextDate,c>d&&g>d)break}e$1(e,r,n.join(`
4
+ `)),oa$1(e,r);}function mb(e,r,o={}){let n=Cd.parse(o),t=r,i=n.initialDate??new Date,a=i.getFullYear(),s=i.getMonth(),l=i.getDate();U(e,t,n.left,n.top);let u=n.showWeekNumbers?23:20;f(e,t,u,8);let b=new Set(n.markedDates.map(ji)),f$1={year:a,month:s,selectedDay:void 0,cursorDay:l,minDate:n.minDate,maxDate:n.maxDate,firstDayOfWeek:n.firstDayOfWeek,showWeekNumbers:n.showWeekNumbers,markedDates:b,theme:n.theme??{},onSelectCallbacks:[]};ab(t,f$1),ct(e,t);let c={eid:t,setDate(g){let p=Ue(t);return p&&(p.year=g.getFullYear(),p.month=g.getMonth(),p.selectedDay=g.getDate(),p.cursorDay=g.getDate(),ct(e,t)),c},getDate(){let g=Ue(t);if(!(!g||g.selectedDay===void 0))return new Date(g.year,g.month,g.selectedDay)},getMonth(){let g=Ue(t);return g?{year:g.year,month:g.month}:{year:new Date().getFullYear(),month:new Date().getMonth()}},prevMonth(){let g=Ue(t);if(!g)return c;g.month--,g.month<0&&(g.month=11,g.year--);let p=Hr(g.year,g.month);return g.cursorDay>p&&(g.cursorDay=p),ct(e,t),c},nextMonth(){let g=Ue(t);if(!g)return c;g.month++,g.month>11&&(g.month=0,g.year++);let p=Hr(g.year,g.month);return g.cursorDay>p&&(g.cursorDay=p),ct(e,t),c},prevYear(){let g=Ue(t);if(!g)return c;g.year--;let p=Hr(g.year,g.month);return g.cursorDay>p&&(g.cursorDay=p),ct(e,t),c},nextYear(){let g=Ue(t);if(!g)return c;g.year++;let p=Hr(g.year,g.month);return g.cursorDay>p&&(g.cursorDay=p),ct(e,t),c},cursorUp(){let g=Ue(t);if(!g)return c;let p=new Date(g.year,g.month,g.cursorDay);return p.setDate(p.getDate()-7),g.year=p.getFullYear(),g.month=p.getMonth(),g.cursorDay=p.getDate(),ct(e,t),c},cursorDown(){let g=Ue(t);if(!g)return c;let p=new Date(g.year,g.month,g.cursorDay);return p.setDate(p.getDate()+7),g.year=p.getFullYear(),g.month=p.getMonth(),g.cursorDay=p.getDate(),ct(e,t),c},cursorLeft(){let g=Ue(t);if(!g)return c;let p=new Date(g.year,g.month,g.cursorDay);return p.setDate(p.getDate()-1),g.year=p.getFullYear(),g.month=p.getMonth(),g.cursorDay=p.getDate(),ct(e,t),c},cursorRight(){let g=Ue(t);if(!g)return c;let p=new Date(g.year,g.month,g.cursorDay);return p.setDate(p.getDate()+1),g.year=p.getFullYear(),g.month=p.getMonth(),g.cursorDay=p.getDate(),ct(e,t),c},selectCursor(){let g=Ue(t);if(!g)return c;let p=new Date(g.year,g.month,g.cursorDay);if(!cb(p,g.minDate,g.maxDate))return c;g.selectedDay=g.cursorDay,ct(e,t);for(let h of g.onSelectCallbacks)h(p);return c},setMarkedDates(g){let p=Ue(t);return p&&(p.markedDates=new Set(g.map(ji)),ct(e,t)),c},addMarkedDate(g){let p=Ue(t);return p&&(p.markedDates.add(ji(g)),ct(e,t)),c},removeMarkedDate(g){let p=Ue(t);return p&&(p.markedDates.delete(ji(g)),ct(e,t)),c},getMarkedDates(){let g=Ue(t);return g?Array.from(g.markedDates).map(p=>new Date(p)):[]},handleKey(g){if(!Ue(t))return false;switch(g){case "up":return c.cursorUp(),true;case "down":return c.cursorDown(),true;case "left":return c.cursorLeft(),true;case "right":return c.cursorRight(),true;case "enter":case "return":return c.selectCursor(),true;case "pageup":return c.prevMonth(),true;case "pagedown":return c.nextMonth(),true;case "S-pageup":return c.prevYear(),true;case "S-pagedown":return c.nextYear(),true;default:return false}},onSelect(g){let p=Ue(t);return p?(p.onSelectCallbacks.push(g),()=>{let h=p.onSelectCallbacks.indexOf(g);h>=0&&p.onSelectCallbacks.splice(h,1);}):()=>{}},render(){return ct(e,t),c},destroy(){sb(t),e$2(e,t);}};return c}function fb(e){return Ur.has(e)}var bb="Calendar";n();t();n();t();var Wd=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Yi=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Ld=z.object({left:Yi.optional(),top:Yi.optional(),right:Yi.optional(),bottom:Yi.optional(),width:Wd.optional(),height:Wd.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional(),shrink:z.boolean().optional()}),pb=1e4,$r={isText:new Uint8Array(pb)};function yb(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function hb(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function Td(e){return e===void 0?0:typeof e=="number"?e:0}function vd(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function xb(e,r,o){let n=Td(o.left),t=Td(o.top);U(e,r,n,t);let i=vd(o.width),a=vd(o.height);f(e,r,i,a);let s=o.shrink!==false;i$1(e,r,s);}function Sb(e,r,o){o.fg===void 0&&o.bg===void 0||la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function Cb(e,r,o){if(o.content===void 0)return;let n={};o.align&&(n.align=yb(o.align)),o.valign&&(n.valign=hb(o.valign)),e$1(e,r,o.content,n);}function jr(e,r,o={}){let n=Ld.parse(o),t=r;$r.isText[t]=1,xb(e,t,n),Sb(e,t,n),Cb(e,t,n),d(e,t,{focusable:true});let i$1={eid:t,show(){return ra$1(e,t,true),i$1},hide(){return ra$1(e,t,false),i$1},move(a,s){return Z$1(e,t,a,s),oa$1(e,t),i$1},setPosition(a,s){return U(e,t,a,s),oa$1(e,t),i$1},setContent(a){return e$1(e,t,a),oa$1(e,t),i$1},getContent(){return f$2(e,t)},focus(){return h(e,t),i$1},blur(){return i(e,t),i$1},isFocused(){return f$1(e,t)},append(a){return q$2(e,t,a),i$1},getChildren(){return s$1(e,t)},destroy(){$r.isText[t]=0,e$2(e,t);}};return i$1}function Qa(e,r,o){return e$1(e,r,o),oa$1(e,r),r}function Wb(e,r){return f$2(e,r)}function Tb(e,r){return $r.isText[r]===1}function vb(){$r.isText.fill(0);}var Lb=1e4,Ki={isCanvas:new Uint8Array(Lb)},Ed=z.object({width:z.number().int().positive().optional().default(40),height:z.number().int().positive().optional().default(40),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),fillChar:z.string().length(1).optional().default(" ")}),gr=new Map;function Eb(e,r){let o=Math.floor(e/2),n=Math.floor(r/4),t=e%2,i=r%4;return {charX:o,charY:n,col:t,row:i}}function Bd(e,r,o){return o*e.widthChars+r}function Pd(e){let r=[];for(let o=0;o<e.heightChars;o++){let n="";for(let t=0;t<e.widthChars;t++){let i=Bd(e,t,o),a=e.pixels[i]??0;n+=String.fromCharCode(10240|a);}r.push(n);}return r.join(`
5
+ `)}function Qi(e){let r=Pd(e);Qa(e.world,e.textEntity,r),oa$1(e.world,e.entity);}function nt(e,r,o,n=true){let t=gr.get(e.entity);if(!t||r<0||r>=t.widthDots||o<0||o>=t.heightDots)return;let{charX:i,charY:a,col:s,row:l}=Eb(r,o),u=Bd(t,i,a),d=_n[l];if(!d)return;let b=d[s]??0;n?t.pixels[u]=(t.pixels[u]??0)|b:t.pixels[u]=(t.pixels[u]??0)&~b,Qi(t);}function Bb(e,r,o,n,t){let i=Math.abs(n-r),a=Math.abs(t-o),s=r<n?1:-1,l=o<t?1:-1,u=i-a,d=r,b=o;for(;nt(e,d,b,true),!(d===n&&b===t);){let f=2*u;f>-a&&(u-=a,d+=s),f<i&&(u+=i,b+=l);}}function Pb(e,r,o,n,t,i=false){if(i)for(let a=0;a<t;a++)for(let s=0;s<n;s++)nt(e,r+s,o+a,true);else {for(let a=0;a<n;a++)nt(e,r+a,o,true),nt(e,r+a,o+t-1,true);for(let a=0;a<t;a++)nt(e,r,o+a,true),nt(e,r+n-1,o+a,true);}}function Mb(e,r,o,n,t=false){if(t)for(let i=-n;i<=n;i++){let a=Math.floor(Math.sqrt(n*n-i*i));for(let s=-a;s<=a;s++)nt(e,r+s,o+i,true);}else {let i=n,a=0,s=0;for(;i>=a;)nt(e,r+i,o+a,true),nt(e,r+a,o+i,true),nt(e,r-a,o+i,true),nt(e,r-i,o+a,true),nt(e,r-i,o-a,true),nt(e,r-a,o-i,true),nt(e,r+a,o-i,true),nt(e,r+i,o-a,true),s<=0&&(a+=1,s+=2*a+1),s>0&&(i-=1,s-=2*i+1);}}function Db(e,r,o,n){let t=gr.get(e.entity);t&&Qi(t);}function Fb(e){let r=gr.get(e.entity);r&&(r.pixels.fill(0),Qi(r));}function Ab(e){let r=gr.get(e.entity);return r?Pd(r):""}function Ib(e,r,o={}){let n=Ed.parse(o),t=Math.ceil(n.width/2),i=Math.ceil(n.height/4);Ki.isCanvas[r]=1,Tt(e,r),U(e,r,0,0);let a=n.fg?s(n.fg):void 0,s$1=n.bg?s(n.bg):void 0;(a!==void 0||s$1!==void 0)&&la$1(e,r,{fg:a,bg:s$1});let l=d$1(e);jr(e,l),U(e,l,0,0),q$2(e,r,l);let u=new Uint8Array(t*i);u.fill(0);let d={world:e,entity:r,textEntity:l,widthDots:n.width,heightDots:n.height,widthChars:t,heightChars:i,pixels:u};return gr.set(r,d),Qi(d),{entity:r,world:e,widthDots:n.width,heightDots:n.height}}function kb(e){return Ki.isCanvas[e]===1}function Rb(){gr.clear(),Ki.isCanvas.fill(0);}n();var Md=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(1),label:z.string().default(""),checked:z.boolean().default(false),checkedChar:z.string().default("\u2611"),uncheckedChar:z.string().default("\u2610"),focusable:z.boolean().default(true),disabled:z.boolean().default(false)}),Vb=1e4,Kr={isCheckboxWidget:new Uint8Array(Vb)},mr=new Map;function Ob(e,r={}){let o=Md.parse(r),n=d$1(e);Kr.isCheckboxWidget[n]=1,q$5(e,n,o.checked),H$1(n,{checkedChar:o.checkedChar,uncheckedChar:o.uncheckedChar});let t=Math.max(o.checkedChar.length,o.uncheckedChar.length),i$1=o.label.length,a=o.width??t+(i$1>0?1+i$1:0);f(e,n,a,o.height),U(e,n,o.x,o.y),mr.set(n,{label:o.label}),Yr(e,n),d$4(e,n,{clickable:true,hoverable:true,keyable:true,focusable:o.focusable}),d(e,n,{focusable:o.focusable}),o.disabled&&B$1(e,n);let s={eid:n,toggle(){return y$2(e,n),Yr(e,n),oa$1(e,n),s},setChecked(l){return l?z$3(e,n):A$1(e,n),Yr(e,n),oa$1(e,n),s},isChecked(){return v$2(e,n)},getChar(){return J$1(e,n)},setDisabled(l){return l?B$1(e,n):C$2(e,n),oa$1(e,n),s},isDisabled(){return x$1(e,n)},setLabel(l){let u=mr.get(n);u&&(u.label=l);let b=J$1(e,n).length+(l.length>0?1+l.length:0);return f(e,n,b,o.height),Yr(e,n),oa$1(e,n),s},getLabel(){return mr.get(n)?.label??""},setPosition(l,u){return U(e,n,l,u),oa$1(e,n),s},move(l,u){return Z$1(e,n,l,u),oa$1(e,n),s},getPosition(){return {x:T$1.x[n]??0,y:T$1.y[n]??0}},focus(){return h(e,n),oa$1(e,n),s},blur(){return i(e,n),oa$1(e,n),s},isFocused(){return f$1(e,n)},handleKey(l){if(!f$1(e,n))return false;let u=G$2(e,n,l);return u&&(Yr(e,n),oa$1(e,n)),u},onChange(l){return E$2(n,l),s},destroy(){Kr.isCheckboxWidget[n]=0,mr.delete(n),F$1(n),K(n),e$2(e,n);}};return s}function Yr(e,r){let o=J$1(e,r),t=mr.get(r)?.label??"",i=t.length>0?`${o} ${t}`:o;e$1(e,r,i);}function _b(e,r){return Kr.isCheckboxWidget[r]===1}function Nb(){Kr.isCheckboxWidget.fill(0),mr.clear();}n();t();n();z.object({item:z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional()}).optional(),selected:z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),prefix:z.string().optional()}).optional(),unselectedPrefix:z.string().optional(),disabledFg:z.number().int().nonnegative().optional()});var Dd=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),height:z.number().int().positive().default(10),items:z.array(z.string()).default([]),selected:z.number().int().min(-1).default(0),style:z.object({item:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional(),prefix:z.string().optional()}).optional(),unselectedPrefix:z.string().optional(),disabledFg:z.number().optional()}).optional(),interactive:z.boolean().default(true),mouse:z.boolean().default(true),keys:z.boolean().default(true),search:z.boolean().default(false),multiSelect:z.boolean().default(false)});function Gb(e,r){let o={};r.selected?.prefix!==void 0&&(o.selectedPrefix=r.selected.prefix),r.unselectedPrefix!==void 0&&(o.unselectedPrefix=r.unselectedPrefix),r.selected?.fg!==void 0&&(o.selectedFg=r.selected.fg),r.selected?.bg!==void 0&&(o.selectedBg=r.selected.bg),r.item?.fg!==void 0&&(o.itemFg=r.item.fg),r.item?.bg!==void 0&&(o.itemBg=r.item.bg),r.disabledFg!==void 0&&(o.disabledFg=r.disabledFg),ra$2(e,o);}function Qr(e,r,o={}){let n=Dd.parse(o),t=r;U(e,t,n.x,n.y),f(e,t,n.width,n.height);let i=n.items.map(s=>({text:s,value:s}));ga$1(e,t,i,{interactive:n.interactive,mouse:n.mouse,keys:n.keys,search:n.search,selectedIndex:n.selected,visibleCount:n.height}),n.multiSelect&&xa$1(t,true),n.style&&Gb(t,n.style);let a={eid:t,show(){return ra$1(e,t,true),a},hide(){return ra$1(e,t,false),a},move(s,l){return T$1.x[t]=(T$1.x[t]??0)+s,T$1.y[t]=(T$1.y[t]??0)+l,oa$1(e,t),a},setPosition(s,l){return U(e,t,s,l),a},focus(){return na$1(e,t),a},blur(){return oa$2(e,t),a},setItems(s){let l=s.map(u=>({text:u,value:u}));return q$4(e,t,l),a},getItems(){return p$1(t)},addItem(s,l){let u=[...p$1(t)];return u.push({text:s,value:l??s}),q$4(e,t,u),a},removeItem(s){return s$3(e,t,s),a},clearItems(){return w$1(e,t),a},select(s){return U$1(e,t,s),a},getSelectedIndex(){return S(t)},getSelectedItem(){return T(t)},selectPrev(){return V(e,t),a},selectNext(){return W(e,t),a},selectFirst(){return X$1(e,t),a},selectLast(){return Y$1(e,t),a},activate(){return $(e,t),a},pageUp(){return C$1(e,t,-1),a},pageDown(){return C$1(e,t,1),a},startSearch(){return Na(e,t),a},endSearch(){return Oa(e,t),a},getSearchQuery(){return Pa(t)},isSearching(){return Ma(e,t)},getState(){return ia$1(e,t)},onSelect(s){return aa$1(t,s)},onActivate(s){return ba$1(t,s)},onCancel(s){return ca$1(t,s)},onSearchChange(s){return Wa$1(t,s)},getSelected(){return Aa(t)},selectAll(){return Ba(t),a},deselectAll(){return Ca$1(t),a},setFilter(s){return ua$1(e,t,s),a},clearFilter(){return va(e,t),a},getVisibleItems(){return wa(t)},handleKey(s){let l=Xa$1(e,t,s);if(l)switch(l.type){case "selectPrev":V(e,t);break;case "selectNext":W(e,t);break;case "selectFirst":X$1(e,t);break;case "selectLast":Y$1(e,t);break;case "pageUp":C$1(e,t,-1);break;case "pageDown":C$1(e,t,1);break;case "confirm":$(e,t);break;case "cancel":da$1(t),oa$2(e,t);break;case "toggleSelect":{let u=S(t);u>=0&&za$1(t,u);break}case "startSearch":Na(e,t);break;case "endSearch":Oa(e,t);break;case "searchChar":Ra(e,t,l.char);break;case "searchBackspace":Sa$1(e,t);break;case "searchNextMatch":Va(e,t);break}return l},destroy(){ea$1(t),Ta(e,t),e$2(e,t);}};return a}function wb(e,r){return ha$1(e,r)}var zb=1e4,Xi={isCommandPalette:new Uint8Array(zb)},Hb=z.object({id:z.string(),label:z.string(),description:z.string().optional(),shortcut:z.string().optional(),category:z.string().optional(),handler:z.function().nullable().optional()}),Ub=z.object({inputFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),inputBg:z.union([z.string(),z.number().int().nonnegative()]).optional(),listFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),listBg:z.union([z.string(),z.number().int().nonnegative()]).optional(),selectedFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),selectedBg:z.union([z.string(),z.number().int().nonnegative()]).optional(),shortcutFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),descriptionFg:z.union([z.string(),z.number().int().nonnegative()]).optional()}),Ad=z.object({commands:z.array(Hb).optional(),placeholder:z.string().optional(),maxResults:z.number().int().positive().optional(),theme:Ub.optional(),width:z.number().int().positive().optional(),onClose:z.function().nullable().optional()}),fr=new Map;function $b(){fr.clear(),Xi.isCommandPalette.fill(0);}function jb(e,r,o){return r.trim()?d$8(r,e,{getText:t=>[t.label,t.description,t.category].filter(Boolean).join(" "),limit:o}).map(t=>({...t.item,match:t})):e.slice(0,o)}function Fd(e){let r=fr.get(e);r&&oa$1(r.world,r.listEntity);}function Yb(e){let r=fr.get(e);if(!r||r.filteredCommands.length===0)return;let o=r.filteredCommands[r.selectedIndex];if(o){Id(e);try{let n=o.handler();n instanceof Promise&&n.catch(t=>{console.error(`Command ${o.id} failed:`,t);});}catch(n){console.error(`Command ${o.id} failed:`,n);}}}function Kb(e){let r=fr.get(e);r&&(r.visible=true,ra$1(r.world,e,true),ra$1(r.world,r.inputEntity,true),ra$1(r.world,r.listEntity,true),oa$1(r.world,e));}function Id(e){let r=fr.get(e);r&&(r.visible=false,ra$1(r.world,e,false),ra$1(r.world,r.inputEntity,false),ra$1(r.world,r.listEntity,false),r.onClose?.(),oa$1(r.world,e));}function Qb(e,r,o){if(!o?.inputFg&&!o?.inputBg)return;let n=typeof o.inputFg=="string"?s(o.inputFg):o.inputFg,t=typeof o.inputBg=="string"?s(o.inputBg):o.inputBg;la$1(e,r,{fg:n,bg:t});}function Xb(e,r,o){if(!o?.listFg&&!o?.listBg)return;let n=typeof o.listFg=="string"?s(o.listFg):o.listFg,t=typeof o.listBg=="string"?s(o.listBg):o.listBg;(n!==void 0||t!==void 0)&&la$1(e,r,{fg:n,bg:t});}function qb(e,r,o,n){let t=d$1(e);return Tt(e,t),U(e,t,1,1),q$2(e,r,t),ia$2(e,t),Ua$1(e,t,{placeholder:o}),Qb(e,t,n),t}function Jb(e,r,o,n,t){let i=d$1(e);U(e,i,1,3),q$2(e,r,i);let a={items:[],width:o-2,height:Math.min(n+2,12)};return Xb(e,i,t),Qr(e,i,a),i}function Zb(e,r,o={}){let n=Ad.omit({commands:true,onClose:true}).parse(o),t=o.commands??[],i=n.placeholder??"Type a command...",a=n.maxResults??10,s=n.width??60,l=n.theme;Tt(e,r),U(e,r,0,0),ra$1(e,r,false);let u=qb(e,r,i,l),d=Jb(e,r,s,a,l),b={world:e,inputEntity:u,listEntity:d,commands:t,filteredCommands:t.slice(0,a),selectedIndex:0,maxResults:a,onClose:o.onClose,visible:false};return fr.set(r,b),ab$1(e,u,f=>{let c=jb(b.commands,f,b.maxResults);b.filteredCommands=c,b.selectedIndex=0,Fd(r);}),bb$1(e,u,()=>{Yb(r);}),Xi.isCommandPalette[r]=1,{entity:r,world:e,show(){Kb(r);},hide(){Id(r);},executeCommand(f){let c=b.commands.find(g=>g.id===f);if(c)try{let g=c.handler();g instanceof Promise&&g.catch(p=>{console.error(`Command ${f} failed:`,p);});}catch(g){console.error(`Command ${f} failed:`,g);}},setCommands(f){b.commands=f,b.filteredCommands=f.slice(0,b.maxResults),b.selectedIndex=0,Fd(r);}}}function ep(e){return Xi.isCommandPalette[e]===1}function tp(e){return e===""?[]:e.split(`
6
+ `)}function Tn(e){return e.join(`
7
+ `)}function jt(e,r){let o=f$2(e,r);return tp(o)}function np(e,r){let o=f$2(e,r);if(o==="")return 0;let n=1;for(let t of o)t===`
8
+ `&&n++;return n}function kd(e,r,o){let n=jt(e,r);return o<0||o>=n.length?"":n[o]??""}function Rd(e,r,o,n){let t=jt(e,r);return o<0||o>=t.length||(t[o]=n,e$1(e,r,Tn(t)),oa$1(e,r)),r}function rp(e,r,o){return kd(e,r,o)}function op(e,r,o,n){return Rd(e,r,o,n)}function Xa(e,r,o,n){let t=jt(e,r),i=Math.max(0,Math.min(o,t.length));if(t.splice(i,0,n),e$1(e,r,Tn(t)),oa$1(e,r),t$2(e,r)){let a=n$1(e,r);i<=a.y&&m$2(e,r,a.x,a.y+1);}return r}function Vd(e,r,o){return Xa(e,r,0,o)}function Od(e,r,o){let n=jt(e,r);return Xa(e,r,n.length,o)}function qa(e,r,o,n=1){let t=jt(e,r);if(o<0||o>=t.length||n<=0)return r;let i=Math.min(n,t.length-o);if(t.splice(o,i),e$1(e,r,Tn(t)),oa$1(e,r),t$2(e,r)){let a=n$1(e,r),s=Math.max(0,t.length-1),l=a.y;if(o<a.y){let u=Math.min(i,a.y-o);l=a.y-u;}l=Math.max(0,Math.min(l,s)),m$2(e,r,a.x,l);}return r}function ip(e,r,o=1){return qa(e,r,0,o)}function ap(e,r,o=1){let n=jt(e,r);if(n.length===0)return r;let t=Math.max(0,n.length-o);return qa(e,r,t,o)}function sp(e,r){return e$1(e,r,""),oa$1(e,r),t$2(e,r)&&m$2(e,r,0,0),r}function lp(e,r,o){if(e$1(e,r,Tn(o)),oa$1(e,r),t$2(e,r)){let n=n$1(e,r),t=Math.max(0,o.length-1);n.y>t&&m$2(e,r,n.x,t);}return r}function up(e,r,o){return Od(e,r,o)}function dp(e,r){let o=jt(e,r);if(o.length===0)return "";let n=o.pop()??"";if(e$1(e,r,Tn(o)),oa$1(e,r),t$2(e,r)){let t=n$1(e,r),i=Math.max(0,o.length-1);t.y>i&&m$2(e,r,t.x,i);}return n}function cp(e,r){let o=jt(e,r);if(o.length===0)return "";let n=o.shift()??"";if(e$1(e,r,Tn(o)),oa$1(e,r),t$2(e,r)){let t=n$1(e,r);t.y>0&&m$2(e,r,t.x,t.y-1);}return n}function gp(e,r,o){return Vd(e,r,o)}function mp(e,r,o,n){let t=jt(e,r);if(o<0||o>=t.length)return r;for(let i=0;i<n.length;i++){let a=o+i;if(a>=t.length)break;t[a]=n[i]??"";}return e$1(e,r,Tn(t)),oa$1(e,r),r}function fp(e,r,o,n,t){let i=jt(e,r),a=t?i.splice(o,n,...t):i.splice(o,n);if(e$1(e,r,Tn(i)),oa$1(e,r),t$2(e,r)){let s=(t?.length??0)-a.length,l=n$1(e,r);if(o<=l.y&&s!==0){let u=Math.max(0,l.y+s),d=Math.max(0,i.length-1);m$2(e,r,l.x,Math.min(u,d));}else {let u=Math.max(0,i.length-1);l.y>u&&m$2(e,r,l.x,u);}}return a}n();var Xr=new Map;function bp(e,r){let o=d$1(e),n=r.termWidth??80,t=r.termHeight??24,i=r.items.map(p=>p.separator?3:p.label?.length??0),a=i.length>0?Math.max(...i):0,s=Math.min(a+4,40),l=r.items.length+2,u=r.x,d$2=r.y;u+s>n&&(u=Math.max(0,n-s)),d$2+l>t&&(d$2=Math.max(0,t-l)),h$1(e,o,T$1),T$1.x[o]=u,T$1.y[o]=d$2,h$1(e,o,e$4),e$4.width[o]=s,e$4.height[o]=l;let b=[],f=1;for(let p of r.items){let h=d$1(e);h$1(e,h,T$1),T$1.x[h]=u+2,T$1.y[h]=d$2+f,h$1(e,h,d$5);let E=p.separator?"---":p.label;h$2(e,h,E),!p.separator&&!p.disabled&&(d(e,h,{focusable:true}),b$2(e,h,"menuitem"),d$6(e,h,p.label)),b.push(h),f++;}let c=Math.max(0,r.items.findIndex(p=>!p.separator&&!p.disabled)),g={items:r.items,itemEntities:b,selectedIndex:c,containerEntity:o};return Xr.set(o,g),b$2(e,o,"menu"),d(e,o,{focusable:true}),o}function pp(e,r,o){let n=Xr.get(r);return n?o==="up"||o==="k"?(_d(e,n,-1),true):o==="down"||o==="j"?(_d(e,n,1),true):o==="enter"?(yp(e,n),true):o==="escape"?(hp(e,r),true):false:false}function _d(e,r,o){let n=[];for(let s=0;s<r.items.length;s++){let l=r.items[s];l&&!l.separator&&!l.disabled&&n.push(s);}if(n.length===0)return;let t=n.indexOf(r.selectedIndex),i;t===-1?i=o>=0?0:n.length-1:(i=t+o,i<0&&(i=n.length-1),i>=n.length&&(i=0));let a=n[i];a!==void 0&&(r.selectedIndex=a);}function yp(e,r){let o=r.items[r.selectedIndex];o&&!o.separator&&!o.disabled&&o.action&&o.action();}function hp(e,r){let o=Xr.get(r);if(o){for(let n of o.itemEntities)e$2(e,n);e$2(e,o.containerEntity),Xr.delete(r);}}function xp(e){return Xr.get(e)?.selectedIndex??0}n();t();u();n();t();var Sp="top",Ud=" \u2502 ",$d="\u2715",Nd=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Gd=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Cp=z.object({label:z.string(),content:z.union([z.number(),z.function()]).optional(),closable:z.boolean().optional()}),Wp=z.object({activeFg:z.union([z.string(),z.number()]).optional(),activeBg:z.union([z.string(),z.number()]).optional(),inactiveFg:z.union([z.string(),z.number()]).optional(),inactiveBg:z.union([z.string(),z.number()]).optional()}),Tp=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),vp=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),Lp=z.object({tab:Wp.optional(),content:Tp.optional(),border:vp.optional()}),jd=z.object({left:Nd.optional(),top:Nd.optional(),width:Gd.optional(),height:Gd.optional(),tabs:z.array(Cp).optional(),activeTab:z.number().nonnegative().optional(),position:z.enum(["top","bottom"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),style:Lp.optional()}),qi=1e4,ce={isTabs:new Uint8Array(qi),activeTab:new Uint16Array(qi),position:new Uint8Array(qi),tabCount:new Uint16Array(qi)},Ot=m({iterable:true});function Ep(e){return {label:e.label,contentEntity:typeof e.content=="number"?e.content:null,lazyLoader:typeof e.content=="function"?e.content:null,closable:e.closable??false,loaded:typeof e.content=="number"}}function Bp(e,r){let o=r?r.map(Ep):[];return Ot.set(e,o),o}function wd(e){return e===void 0?0:typeof e=="number"?e:0}function zd(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function Pp(e,r){if(e==="Tab"||e==="right")return r.nextTab(),{type:"next"};if(e==="S-Tab"||e==="left")return r.prevTab(),{type:"prev"};if(e>="1"&&e<="9"){let o=Number.parseInt(e,10)-1,n=r.getTabCount();if(o<n)return r.setActiveTab(o),{type:"goto",index:o}}return null}function Mp(e,r,o){(o.fg!==void 0||o.bg!==void 0)&&la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function Dp(e,r,o){let n=o.style?.border;n?.type!=="none"&&l(e,r,{type:n?.type==="bg"?2:1,fg:n?.fg!==void 0?s(n.fg):void 0,bg:n?.bg!==void 0?s(n.bg):void 0});}function Hd(e,r,o){let n=Ot.get(r);if(!n||o<0||o>=n.length)return;let t=n[o];t&&!t.loaded&&t.lazyLoader&&(t.contentEntity=t.lazyLoader(),t.loaded=true,t.contentEntity!==null&&q$2(e,r,t.contentEntity));}function Ja(e,r){let o=Ot.get(r);if(!o)return;let n=ce.activeTab[r];for(let t=0;t<o.length;t++){let i=o[t];i?.contentEntity!==null&&i?.contentEntity!==void 0&&ra$1(e,i.contentEntity,t===n);}}function qr(e,r,o={}){let n=jd.parse(o),t=r;ce.isTabs[t]=1,ce.position[t]=n.position==="bottom"?1:0;let i$1=Bp(t,n.tabs);ce.tabCount[t]=i$1.length;let a=Math.min(n.activeTab??0,Math.max(0,i$1.length-1));ce.activeTab[t]=a,U(e,t,wd(n.left),wd(n.top)),f(e,t,zd(n.width),zd(n.height)),Mp(e,t,n),Dp(e,t,n),d(e,t,{focusable:true}),ra$1(e,t,true),i$1.length>0&&(Hd(e,t,a),Ja(e,t));let s={eid:t,show(){return ra$1(e,t,true),s},hide(){return ra$1(e,t,false),s},move(l,u){return Z$1(e,t,l,u),oa$1(e,t),s},setPosition(l,u){return U(e,t,l,u),oa$1(e,t),s},addTab(l){let u=Ot.get(t)??[],d={label:l.label,contentEntity:typeof l.content=="number"?l.content:null,lazyLoader:typeof l.content=="function"?l.content:null,closable:l.closable??false,loaded:typeof l.content=="number"};return u.push(d),Ot.set(t,u),ce.tabCount[t]=u.length,oa$1(e,t),s},removeTab(l){let u=Ot.get(t);return !u||l<0||l>=u.length||(u.splice(l,1),ce.tabCount[t]=u.length,ce.activeTab[t]>=u.length&&u.length>0?ce.activeTab[t]=u.length-1:u.length===0&&(ce.activeTab[t]=0),Ja(e,t),oa$1(e,t)),s},getActiveTab(){return ce.activeTab[t]},setActiveTab(l){let u=Ot.get(t);return !u||l<0||l>=u.length||(ce.activeTab[t]=l,Hd(e,t,l),Ja(e,t),oa$1(e,t)),s},getTabCount(){return ce.tabCount[t]},getTab(l){let u=Ot.get(t);if(!(!u||l<0||l>=u.length))return u[l]},setTabLabel(l,u){let d=Ot.get(t);if(!d||l<0||l>=d.length)return s;let b=d[l];return b&&(b.label=u),oa$1(e,t),s},nextTab(){let l=ce.tabCount[t];if(l===0)return s;let d=(ce.activeTab[t]+1)%l;return s.setActiveTab(d)},prevTab(){let l=ce.tabCount[t];if(l===0)return s;let u=ce.activeTab[t],d=u===0?l-1:u-1;return s.setActiveTab(d)},focus(){return h(e,t),s},blur(){return i(e,t),s},isFocused(){return f$1(e,t)},getChildren(){return s$1(e,t)},handleKey(l){return s.isFocused()?Pp(l,s):null},destroy(){ce.isTabs[t]=0,ce.activeTab[t]=0,ce.position[t]=0,ce.tabCount[t]=0,Ot.delete(t),e$2(e,t);}};return s}function Fp(e,r){return ce.isTabs[r]===1}function Ap(e,r){return ce.activeTab[r]}function Ip(e,r){return ce.tabCount[r]}function kp(e,r){return ce.position[r]===1?"bottom":"top"}function Rp(e,r,o){let n=Ot.get(r);if(!n||n.length===0)return " ".repeat(o);let t=ce.activeTab[r],i="";for(let a=0;a<n.length;a++){let s=n[a];if(!s)continue;a>0&&(i+=Ud);let l=a===t?`[${s.label}]`:` ${s.label} `,u=s.closable?` ${$d}`:"";i+=l+u;}return i.length>o?i=`${i.slice(0,o-1)}\u2026`:i.length<o&&(i=i+" ".repeat(o-i.length)),i}function Vp(){ce.isTabs.fill(0),ce.activeTab.fill(0),ce.position.fill(0),ce.tabCount.fill(0),Ot.clear();}var Op=1e4,Za={isDevTools:new Uint8Array(Op)},Kd=z.object({position:z.enum(["bottom","right","floating"]).optional().default("bottom"),initialTab:z.enum(["entities","components","systems","events"]).optional().default("entities"),theme:z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),borderFg:z.union([z.string(),z.number()]).optional(),borderBg:z.union([z.string(),z.number()]).optional(),tabActiveFg:z.union([z.string(),z.number()]).optional(),tabActiveBg:z.union([z.string(),z.number()]).optional(),tabInactiveFg:z.union([z.string(),z.number()]).optional(),tabInactiveBg:z.union([z.string(),z.number()]).optional()}).optional(),left:z.number().optional(),top:z.number().optional(),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),scheduler:z.any().optional()}),Ge=new Map;function _p(e,r){let t={left:0,top:0,width:80,height:8};switch(e){case "bottom":t={left:0,top:Math.floor(48/3),width:80,height:Math.floor(24/3)};break;case "right":t={left:Math.floor(160/3),top:0,width:Math.floor(80/3),height:24};break;case "floating":t={left:Math.floor(80/4),top:Math.floor(24/4),width:Math.floor(80/2),height:Math.floor(24/2)};break}return {left:r.left??t.left,top:r.top??t.top,width:r.width??t.width,height:r.height??t.height}}function Ji(e,r){let o=g$2(e),n=[];for(let t of o){if(!f$4(e,t))continue;let i=[],a={eid:t,components:i};r&&!i.some(l=>l.name.toLowerCase().includes(r.toLowerCase()))||n.push(a);}return n}function Yd(e){if(!e)return [];let r=[0,1,2,3,4,5,6,7],o=e.getTelemetry();return r.map(n=>{let t=e.getSystemCount(n),i=o?.phases.find(s=>s.phase===n),a={phase:n,systemCount:t};return i?.duration!==void 0&&(a.frameTime=i.duration),a})}function Np(e){let r={};return e.left!==void 0&&(r.left=e.left),e.top!==void 0&&(r.top=e.top),e.width!==void 0&&(r.width=e.width),e.height!==void 0&&(r.height=e.height),r}function Gp(e,r,o){if(!o)return;let n=o.fg?s(o.fg):void 0,t=o.bg?s(o.bg):void 0;(n!==void 0||t!==void 0)&&la$1(e,r,{fg:n,bg:t});}function wp(e){if(!e)return;let r={};return (e.tabActiveFg!==void 0||e.tabActiveBg!==void 0||e.tabInactiveFg!==void 0||e.tabInactiveBg!==void 0)&&(r.tab={...e.tabActiveFg!==void 0&&{activeFg:e.tabActiveFg},...e.tabActiveBg!==void 0&&{activeBg:e.tabActiveBg},...e.tabInactiveFg!==void 0&&{inactiveFg:e.tabInactiveFg},...e.tabInactiveBg!==void 0&&{inactiveBg:e.tabInactiveBg}}),(e.borderFg!==void 0||e.borderBg!==void 0)&&(r.border={...e.borderFg!==void 0&&{fg:e.borderFg},...e.borderBg!==void 0&&{bg:e.borderBg}}),r}function zp(e,r,o={}){let n=Kd.parse(o),t=r;Za.isDevTools[t]=1;let i$1=Np(n),a=_p(n.position,i$1);U(e,t,a.left,a.top),f(e,t,a.width,a.height),d(e,t,{focusable:true}),Gp(e,t,n.theme);let s=d$1(e);q$2(e,t,s);let l=wp(n.theme),u={left:0,top:0,width:a.width,height:a.height,tabs:[{label:"Entities",content:d$1(e)},{label:"Components",content:d$1(e)},{label:"Systems",content:d$1(e)},{label:"Events",content:d$1(e)}],activeTab:["entities","components","systems","events"].indexOf(n.initialTab)};l&&(u.style=l);let d$2=qr(e,s,u),b={world:e,tabsWidget:d$2,currentTab:n.initialTab,visible:false,entities:[],systems:[],eventLog:[],filter:null,scheduler:n.scheduler??null};b.entities=Ji(e,null),b.systems=Yd(b.scheduler),Ge.set(t,b),ra$1(e,t,false);let f$1={eid:t,show(){let c=Ge.get(t);return c&&(c.visible=true,ra$1(e,t,true),oa$1(e,t)),f$1},hide(){let c=Ge.get(t);return c&&(c.visible=false,ra$1(e,t,false),oa$1(e,t)),f$1},toggle(){let c=Ge.get(t);return c&&(c.visible?f$1.hide():f$1.show()),f$1},isVisible(){return Ge.get(t)?.visible??false},focus(){return h(e,t),f$1},blur(){return i(e,t),f$1},setTab(c){let g=Ge.get(t);if(g){g.currentTab=c;let p=["entities","components","systems","events"].indexOf(c);g.tabsWidget.setActiveTab(p),oa$1(e,t);}return f$1},getTab(){return Ge.get(t)?.currentTab??"entities"},refreshEntities(){let c=Ge.get(t);return c&&(c.entities=Ji(c.world,c.filter),oa$1(e,t)),f$1},getEntities(){return Ge.get(t)?.entities??[]},getEntity(c){return Ge.get(t)?.entities.find(p=>p.eid===c)},getSystems(){return Ge.get(t)?.systems??[]},refreshSystems(){let c=Ge.get(t);return c&&(c.systems=Yd(c.scheduler),oa$1(e,t)),f$1},logEvent(c,g){let p=Ge.get(t);return p&&(p.eventLog.push({timestamp:Date.now(),type:c,data:g}),p.eventLog.length>100&&(p.eventLog=p.eventLog.slice(-100)),oa$1(e,t)),f$1},getEventLog(){return Ge.get(t)?.eventLog??[]},clearEventLog(){let c=Ge.get(t);return c&&(c.eventLog=[],oa$1(e,t)),f$1},filterByComponent(c){let g=Ge.get(t);return g&&(g.filter=c,g.entities=Ji(g.world,c),oa$1(e,t)),f$1},clearFilter(){let c=Ge.get(t);return c&&(c.filter=null,c.entities=Ji(c.world,null),oa$1(e,t)),f$1},destroy(){let c=Ge.get(t);c&&c.tabsWidget.destroy(),Ge.delete(t),e$2(e,t);}};return f$1}function Hp(e,r){return Za.isDevTools[r]===1}function Up(){Ge.clear();}u();n();t();var Qd=1e4,Qp=40,Xp=20,qp="\u{1F4C1}",Jp="\u{1F4C4}",Zp="\u2B06\uFE0F",ey="..",ty=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),ny=z.union([z.number().nonnegative(),z.object({left:z.number().nonnegative().optional(),top:z.number().nonnegative().optional(),right:z.number().nonnegative().optional(),bottom:z.number().nonnegative().optional()})]),qd=z.object({cwd:z.string().optional(),showHidden:z.boolean().optional().default(false),filePattern:z.string().optional(),sortBy:z.enum(["name","size","date"]).optional().default("name"),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),left:z.number().int().optional(),top:z.number().int().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:ty.optional(),padding:ny.optional(),showIcons:z.boolean().optional().default(true)}),Be={isFileManager:new Uint8Array(Qd),selectedIndex:new Uint32Array(Qd)},je=new Map;function ry(e){return typeof e=="object"?e:e===void 0||e==="single"?b$1:b$1}function oy(e,r){let n=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`,"i").test(e)}function iy(e){try{let r=readdirSync(e),o=[];for(let n of r){let t=join(e,n);try{let i=statSync(t);o.push({name:n,path:t,isDirectory:i.isDirectory(),size:i.isDirectory()?0:i.size,mtime:i.mtimeMs});}catch{}}return o}catch{return []}}function ay(e,r){return [...e].sort((o,n)=>{if(o.isDirectory!==n.isDirectory)return o.isDirectory?-1:1;switch(r){case "size":return o.size!==n.size?n.size-o.size:o.name.localeCompare(n.name);case "date":return o.mtime!==n.mtime?n.mtime-o.mtime:o.name.localeCompare(n.name);default:return o.name.localeCompare(n.name)}})}function sy(e,r,o){return e.filter(n=>!(!r&&n.name.startsWith(".")||o&&!n.isDirectory&&!oy(n.name,o)))}function vn(e){let r;try{r=e.readDirFn(e.cwd);}catch{return []}let o=sy(r,e.showHidden,e.filePattern);return ay(o,e.sortBy)}function ly(e){let r=[],o=e.width-4,n=e.cwd;n.length>o&&(n=`...${n.slice(-(o-3))}`),r.push(`[${n}]`);let t=Be.selectedIndex[0]===-1?"> ":" ",i=e.showIcons?`${Zp} `:"";r.push(`${t}${i}${ey}`);for(let a=0;a<e.entries.length;a++){let s=e.entries[a],u=a===Be.selectedIndex[0]?"> ":" ",d=e.showIcons?s.isDirectory?`${qp} `:`${Jp} `:"";r.push(`${u}${d}${s.name}`);}return r.join(`
9
+ `)}function uy(e,r,o,n){o===void 0&&n===void 0||la$1(e,r,{fg:o!==void 0?s(o):void 0,bg:n!==void 0?s(n):void 0});}function dy(e,r,o){if(o?.type==="none")return;let n=o?.type==="bg"?2:1;l(e,r,{type:n,fg:o?.fg!==void 0?s(o.fg):void 0,bg:o?.bg!==void 0?s(o.bg):void 0}),m$1(e,r,ry(o?.ch));}function cy(e,r,o){if(typeof o=="number"){b(e,r,{left:o,top:o,right:o,bottom:o});return}o&&b(e,r,{left:o.left??0,top:o.top??0,right:o.right??0,bottom:o.bottom??0});}function nn(e,r,o){let n=ly(o);e$1(e,r,n,{align:0,valign:0}),oa$1(e,r);}function gy(e,r={}){let o=qd.parse(r),n=d$1(e),t=o.width??Qp,i=o.height??Xp,a=o.cwd?resolve(o.cwd):process.cwd();Be.isFileManager[n]=1,Be.selectedIndex[n]=0;let s={cwd:a,showHidden:o.showHidden,showIcons:o.showIcons,filePattern:o.filePattern,sortBy:o.sortBy,width:t,height:i,entries:[],onSelectCallbacks:[],onNavigateCallbacks:[],onDeleteCallbacks:[],onRenameCallbacks:[],readDirFn:iy};return je.set(n,s),s.entries=vn(s),U(e,n,o.left??0,o.top??0),f(e,n,t,i),uy(e,n,o.fg,o.bg),dy(e,n,o.border),cy(e,n,o.padding),nn(e,n,s),ra$1(e,n,true),my(e,n)}function my(e,r){let o={eid:r,show(){return ra$1(e,r,true),oa$1(e,r),o},hide(){return ra$1(e,r,false),oa$1(e,r),o},move(n,t){return Z$1(e,r,n,t),oa$1(e,r),o},setPosition(n,t){return U(e,r,n,t),oa$1(e,r),o},center(n,t){let i=je.get(r);if(!i)return o;let a=Math.max(0,Math.floor((n-i.width)/2)),s=Math.max(0,Math.floor((t-i.height)/2));return U(e,r,a,s),oa$1(e,r),o},setCwd(n){let t=je.get(r);return t&&(t.cwd=resolve(n),t.entries=vn(t),Be.selectedIndex[r]=0,nn(e,r,t)),o},getCwd(){return je.get(r)?.cwd??""},getSelected(){let n=je.get(r);if(!n)return;let t=Be.selectedIndex[r]??0;return n.entries[t]},refresh(){let n=je.get(r);if(!n)return o;n.entries=vn(n);let t=Math.max(0,n.entries.length-1);return (Be.selectedIndex[r]??0)>t&&(Be.selectedIndex[r]=t),nn(e,r,n),o},getEntries(){return je.get(r)?.entries??[]},setSortBy(n){let t=je.get(r);return t&&(t.sortBy=n,t.entries=vn(t),nn(e,r,t)),o},getSortBy(){return je.get(r)?.sortBy??"name"},toggleHidden(){let n=je.get(r);return n&&(n.showHidden=!n.showHidden,n.entries=vn(n),Be.selectedIndex[r]=0,nn(e,r,n)),o},onSelect(n){let t=je.get(r);return t&&t.onSelectCallbacks.push(n),o},onNavigate(n){let t=je.get(r);return t&&t.onNavigateCallbacks.push(n),o},onDelete(n){let t=je.get(r);return t&&t.onDeleteCallbacks.push(n),o},onRename(n){let t=je.get(r);return t&&t.onRenameCallbacks.push(n),o},destroy(){Be.isFileManager[r]=0,Be.selectedIndex[r]=0,je.delete(r),e$2(e,r);}};return o}function fy(e,r,o){let n=Be.selectedIndex[r]??0,t=o.entries[n];if(t)if(t.isDirectory)Jd(e,r,o,t.path);else for(let i of o.onSelectCallbacks)i(t);}function Jd(e,r,o,n){o.cwd=n,o.entries=vn(o),Be.selectedIndex[r]=0,nn(e,r,o);for(let t of o.onNavigateCallbacks)t(n);}function by(e,r,o){let n=Be.selectedIndex[r]??0;n>0&&(Be.selectedIndex[r]=n-1,nn(e,r,o));}function py(e,r,o){let n=Be.selectedIndex[r]??0;n<o.entries.length-1&&(Be.selectedIndex[r]=n+1,nn(e,r,o));}function yy(e,r,o){let n=dirname(o.cwd);n!==o.cwd&&Jd(e,r,o,n);}function hy(e,r,o){o.showHidden=!o.showHidden,o.entries=vn(o),Be.selectedIndex[r]=0,nn(e,r,o);}function xy(e,r){let o=Be.selectedIndex[e]??0,n=r.entries[o];if(n)for(let t of r.onDeleteCallbacks)t(n);}function Sy(e,r){let o=Be.selectedIndex[e]??0,n=r.entries[o];if(n)for(let t of r.onRenameCallbacks)t(n,n.name);}function es(e,r,o,n){o.sortBy=n,o.entries=vn(o),nn(e,r,o);}function Cy(e,r,o){if(Be.isFileManager[r]!==1)return false;let n=je.get(r);if(!n)return false;switch(o){case "up":return by(e,r,n),true;case "down":return py(e,r,n),true;case "enter":return fy(e,r,n),true;case "backspace":return yy(e,r,n),true;case "h":return hy(e,r,n),true;case "d":return xy(r,n),true;case "r":return Sy(r,n),true;case "n":return es(e,r,n,"name"),true;case "s":return es(e,r,n,"size"),true;case "t":return es(e,r,n,"date"),true;default:return false}}function Wy(e,r){return Be.isFileManager[r]===1}function Ty(){Be.isFileManager.fill(0),Be.selectedIndex.fill(0),je.clear();}function vy(e,r){let o=je.get(e);o&&(o.readDirFn=r);}n();t();var Ly=1e4,ns={isFlexContainer:new Uint8Array(Ly)},Zd=z.object({flex:z.number().nonnegative().optional().default(0),flexShrink:z.number().nonnegative().optional().default(1),flexBasis:z.union([z.number().nonnegative(),z.literal("auto")]).optional().default("auto"),alignSelf:z.enum(["start","center","end","stretch"]).optional()}),ec=z.object({direction:z.enum(["row","column"]).optional().default("row"),justifyContent:z.enum(["start","center","end","space-between","space-around","space-evenly"]).optional().default("start"),alignItems:z.enum(["start","center","end","stretch"]).optional().default("stretch"),gap:z.number().nonnegative().optional().default(0),wrap:z.enum(["nowrap","wrap"]).optional().default("nowrap"),left:z.number().optional().default(0),top:z.number().optional().default(0),width:z.union([z.number(),z.string()]).optional().default("auto"),height:z.union([z.number(),z.string()]).optional().default("auto"),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),vt=new Map;function Ey(e,r,o,n,t,i,a,s){let l=r.entity,u=rs(e,l,s);s?(U(e,l,o.x+n,o.y+i+a),f(e,l,t,u)):(U(e,l,o.x+a,o.y+i+n),f(e,l,u,t)),oa$1(e,l);}function By(e,r,o){let n=g(e,r),t=V$1(e,r);if(!n||!t)return;let i=n.width,a=n.height,s=o.children;if(s.length===0)return;let l=o.direction==="row",u=l?i:a,d=Py(e,s,u,o.gap,l,o.wrap),b=0;for(let f of d){let c=f.mainSize,g=f.crossSize,{positions:p,sizes:h}=Iy(f.children,u,c,o.gap,o.justifyContent);for(let E=0;E<f.children.length;E++){let W=f.children[E];if(!W)continue;let B=p[E]??0,D=h[E]??0,I=W.alignSelf??o.alignItems,L=rs(e,W.entity,l),N=ky(I,g,L);Ey(e,W,t,B,D,b,N,l);}b+=g+o.gap;}}function Py(e,r,o,n,t,i){if(i==="nowrap"){let u=My(e,r,n,t),d=ts(e,r,t);return [{children:r,mainSize:u,crossSize:d}]}let a=[],s=[],l=0;for(let u of r){let d=tc(e,u.entity,t,u.flexBasis),b=s.length===0?d:n+d;s.length>0&&l+b>o?(a.push({children:s,mainSize:l-n,crossSize:ts(e,s,t)}),s=[u],l=d):(s.push(u),l+=b);}return s.length>0&&a.push({children:s,mainSize:l-(s.length>0?n:0),crossSize:ts(e,s,t)}),a}function My(e,r,o,n){let t=0;for(let i=0;i<r.length;i++){let a=r[i];a&&(i>0&&(t+=o),t+=tc(e,a.entity,n,a.flexBasis));}return t}function ts(e,r,o){let n=0;for(let t of r){let i=rs(e,t.entity,o);n=Math.max(n,i);}return n}function tc(e,r,o,n){if(n!=="auto")return n;let t=g(e,r);return t?o?t.width:t.height:0}function rs(e,r,o){let n=g(e,r);return n?o?n.height:n.width:0}function Dy(e,r,o){let n=0,t=0;for(let s of e)n+=s.flex,t+=s.flexShrink;let i=r-o,a=[];for(let s of e){let l=0;s.flexBasis==="auto"?l=10:l=s.flexBasis,i>0&&n>0?l+=i*s.flex/n:i<0&&t>0&&(l+=i*s.flexShrink/t),a.push(Math.max(0,l));}return a}function Fy(e,r,o){switch(e){case "start":return 0;case "center":return r/2;case "end":return r;case "space-between":return 0;case "space-around":return r/(o*2);case "space-evenly":return r/(o+1)}}function Ay(e,r,o,n,t){return e==="space-between"&&t>1?r+o+n/(t-1):e==="space-around"?r+o+n/t:e==="space-evenly"?r+o+n/(t+1):r+o}function Iy(e,r,o,n,t){let i=[],a=[];if(e.length===0)return {positions:i,sizes:a};let s=n*(e.length-1),l=r-s,u=Dy(e,l,o),d=u.reduce((c,g)=>c+g,0)+s,b=r-d,f=Fy(t,b,e.length);for(let c=0;c<e.length;c++){let g=u[c]??0;i.push(f),a.push(g),f+=Ay(t,g,n,b,e.length);}return {positions:i,sizes:a}}function ky(e,r,o){switch(e){case "start":return 0;case "center":return (r-o)/2;case "end":return r-o;case "stretch":return 0}}function Ry(e,r,o={}){let n=ec.parse(o),t=r;ns.isFlexContainer[t]=1,U(e,t,n.left,n.top),f(e,t,n.width,n.height),d(e,t,{focusable:true});let i$1=n.fg?s(n.fg):void 0,a=n.bg?s(n.bg):void 0;(i$1!==void 0||a!==void 0)&&la$1(e,t,{fg:i$1,bg:a});let s$1={direction:n.direction,justifyContent:n.justifyContent,alignItems:n.alignItems,gap:n.gap,wrap:n.wrap,children:[]};vt.set(t,s$1);let l={eid:t,show(){return ra$1(e,t,true),oa$1(e,t),l},hide(){return ra$1(e,t,false),oa$1(e,t),l},move(u,d){return Z$1(e,t,u,d),oa$1(e,t),l},setPosition(u,d){return U(e,t,u,d),oa$1(e,t),l},addChild(u,d={}){let b=vt.get(t);if(!b)return l;let f=Zd.parse(d),c=v$1(e,u);return c!==n$2?(console.warn(`Child entity ${u} is already attached to parent ${c}`),l):(q$2(e,t,u),b.children.push({entity:u,flex:f.flex,flexShrink:f.flexShrink,flexBasis:f.flexBasis,alignSelf:f.alignSelf}),oa$1(e,t),l)},removeChild(u){let d=vt.get(t);if(!d)return l;let b=d.children.findIndex(f=>f.entity===u);return b!==-1&&(d.children.splice(b,1),oa$1(e,t)),l},getChildren(){return vt.get(t)?.children.map(d=>d.entity)??[]},setDirection(u){let d=vt.get(t);return d&&(d.direction=u,oa$1(e,t)),l},setJustifyContent(u){let d=vt.get(t);return d&&(d.justifyContent=u,oa$1(e,t)),l},setAlignItems(u){let d=vt.get(t);return d&&(d.alignItems=u,oa$1(e,t)),l},setGap(u){let d=vt.get(t);return d&&(d.gap=u,oa$1(e,t)),l},setWrap(u){let d=vt.get(t);return d&&(d.wrap=u,oa$1(e,t)),l},layout(){let u=vt.get(t);return u&&By(e,t,u),l},focus(){return h(e,t),l},blur(){return i(e,t),l},isFocused(){return f$1(e,t)},destroy(){vt.delete(t),e$2(e,t);}};return l}function Vy(e,r,o,n={}){let t=vt.get(r);if(!t){console.warn(`Entity ${r} is not a flex container`);return}let i=Zd.parse(n),a=v$1(e,o);if(a!==n$2&&a!==r){console.warn(`Child entity ${o} is already attached to parent ${a}`);return}q$2(e,r,o),t.children.push({entity:o,flex:i.flex,flexShrink:i.flexShrink,flexBasis:i.flexBasis,alignSelf:i.alignSelf}),oa$1(e,r);}function Oy(e,r){return ns.isFlexContainer[r]===1}function _y(){vt.clear();}n();t();var Ny=1e4,nc={isFooter:new Uint8Array(Ny)},rc=z.object({status:z.string().optional().default(""),left:z.string().optional(),center:z.string().optional(),right:z.string().optional(),height:z.number().int().positive().optional().default(1),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),align:z.enum(["left","center","right"]).optional().default("left")}),br=new Map;function Jr(e,r,o){let{left:n,center:t,right:i,status:a}=e;if(n||t||i){let s=n||"",l=t||"",u=i||"",d=s.length,b=l.length,f=u.length,c=d+b+f;if(r-c>=2){let p=Math.floor((r-b)/2),h=Math.max(0,p-d),E=p+b,W=Math.max(0,r-E-f);return s+" ".repeat(h)+l+" ".repeat(W)+u}return `${s} ${l} ${u}`.slice(0,r)}if(a){if(o==="center"){let s=Math.max(0,Math.floor((r-a.length)/2));return " ".repeat(s)+a}if(o==="right"){let s=Math.max(0,r-a.length);return " ".repeat(s)+a}return a}return ""}function Gy(e,r,o={}){let n=rc.parse(o),t=r;nc.isFooter[t]=1,U(e,t,0,0),f(e,t,"auto",n.height);let i=n.fg?s(n.fg):void 0,a=n.bg?s(n.bg):void 0;(i!==void 0||a!==void 0)&&la$1(e,t,{fg:i,bg:a});let s$1={status:n.status,left:n.left||"",center:n.center||"",right:n.right||""};br.set(t,s$1);let l=80,u=Jr(s$1,l,n.align);e$1(e,t,u,{align:0});let d={eid:t,show(){return ra$1(e,t,true),oa$1(e,t),d},hide(){return ra$1(e,t,false),oa$1(e,t),d},setStatus(b){let f=br.get(t);if(f){f.status=b;let c=Jr(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},setLeft(b){let f=br.get(t);if(f){f.left=b;let c=Jr(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},setCenter(b){let f=br.get(t);if(f){f.center=b;let c=Jr(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},setRight(b){let f=br.get(t);if(f){f.right=b;let c=Jr(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},getContent(){return f$2(e,t)},destroy(){br.delete(t),e$2(e,t);}};return d}n();var ic=z.object({x:z.number().int().default(0),y:z.number().int().default(0)}),wy=1e4,Zr={isForm:new Uint8Array(wy)},Ve=new Map;function as(e){if("getValue"in e)return e.getValue();if("isChecked"in e)return e.isChecked();if("getSelectedValue"in e)return e.getSelectedValue()}function zy(e){"setValue"in e&&typeof e.setValue=="function"?e.setValue(""):"setChecked"in e&&typeof e.setChecked=="function"?e.setChecked(false):"clearSelection"in e&&typeof e.clearSelection=="function"&&e.clearSelection();}function ac(e){let r=Ve.get(e);if(!r)return;let o={};for(let[n,t]of r.fields)o[n]=as(t);for(let n of r.onChangeCallbacks)n(o);}function Hy(e,r){let o=Ve.get(e);if(o)for(let n of o.onValidationErrorCallbacks)n(r);}function Uy(e,r){"onChange"in r&&typeof r.onChange=="function"&&r.onChange(()=>{ac(e);});}function $y(e,r){return e==="tab"?(r.focusNext(),true):e==="S-tab"||e==="shift-tab"?(r.focusPrevious(),true):e==="enter"||e==="return"?(r.submit(),true):false}function jy(e,r){if(e.focusedIndex<0)return false;let o=e.fieldOrder[e.focusedIndex];if(!o)return false;let n=e.fields.get(o);return !n||!("handleKey"in n)||typeof n.handleKey!="function"?false:n.handleKey(r)}function oc(e,r){if(r.focusedIndex<0)return;let o=r.fieldOrder[r.focusedIndex];if(!o)return;let n=r.fields.get(o);n&&"blur"in n&&i(e,n.eid);}function is(e,r,o){let n=r.fieldOrder[o];if(!n)return;let t=r.fields.get(n);t&&"focus"in t&&h(e,t.eid);}function Yy(e,r={}){let o=ic.parse(r),n=d$1(e);Zr.isForm[n]=1,U(e,n,o.x,o.y),Ve.set(n,{fields:new Map,fieldOrder:[],focusedIndex:-1,onSubmitCallbacks:[],onChangeCallbacks:[],onValidationErrorCallbacks:[]});let t={eid:n,addField(i,a){let s=Ve.get(n);if(!s)return t;if(s.fields.has(i)){let l=s.fieldOrder.indexOf(i);l!==-1&&s.fieldOrder.splice(l,1);}return s.fields.set(i,a),s.fieldOrder.push(i),Uy(n,a),t},removeField(i){let a=Ve.get(n);if(!a)return t;a.fields.delete(i);let s=a.fieldOrder.indexOf(i);return s!==-1&&a.fieldOrder.splice(s,1),a.focusedIndex>=s&&a.focusedIndex>0&&a.focusedIndex--,t},getField(i){return Ve.get(n)?.fields.get(i)},getFieldNames(){return Ve.get(n)?.fieldOrder??[]},getValue(i){let a=Ve.get(n);if(!a)return;let s=a.fields.get(i);if(s)return as(s)},getValues(){let i=Ve.get(n);if(!i)return {};let a={};for(let[s,l]of i.fields)a[s]=as(l);return a},setValidator(i){let a=Ve.get(n);return a&&(a.validator=i),t},validate(i){let a=Ve.get(n);if(!a)return {};let s=i??a.validator;if(!s)return {};let l=t.getValues();return s(l)},reset(){let i=Ve.get(n);if(!i)return t;for(let a of i.fields.values())zy(a);return ac(n),t},submit(){let i=Ve.get(n);if(!i)return;let a=t.validate();if(Object.keys(a).length>0){Hy(n,a);return}let s=t.getValues();for(let l of i.onSubmitCallbacks)l(s);},focusFirst(){let i=Ve.get(n);return !i||i.fieldOrder.length===0||(i.focusedIndex=0,is(e,i,0)),t},focusNext(){let i=Ve.get(n);return !i||i.fieldOrder.length===0||(oc(e,i),i.focusedIndex=(i.focusedIndex+1)%i.fieldOrder.length,is(e,i,i.focusedIndex)),t},focusPrevious(){let i=Ve.get(n);return !i||i.fieldOrder.length===0||(oc(e,i),i.focusedIndex=i.focusedIndex-1,i.focusedIndex<0&&(i.focusedIndex=i.fieldOrder.length-1),is(e,i,i.focusedIndex)),t},handleKey(i){let a=Ve.get(n);return a?$y(i,t)?true:jy(a,i):false},setPosition(i,a){return U(e,n,i,a),oa$1(e,n),t},move(i,a){return Z$1(e,n,i,a),oa$1(e,n),t},getPosition(){return {x:T$1.x[n]??0,y:T$1.y[n]??0}},onSubmit(i){let a=Ve.get(n);return a&&a.onSubmitCallbacks.push(i),t},onChange(i){let a=Ve.get(n);return a&&a.onChangeCallbacks.push(i),t},onValidationError(i){let a=Ve.get(n);return a&&a.onValidationErrorCallbacks.push(i),t},destroy(){Zr.isForm[n]=0,Ve.delete(n),e$2(e,n);}};return t}function Ky(e,r){return Zr.isForm[r]===1}function Qy(){Zr.isForm.fill(0),Ve.clear();}n();t();var Xy=z.object({value:z.number().min(0).max(1),color:z.union([z.string(),z.number()])}),sc=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),height:z.number().int().positive().default(1),value:z.number().min(0).max(1).default(0),label:z.string().optional(),fillChar:z.string().length(1).default("\u2588"),emptyChar:z.string().length(1).default("\u2591"),fillColor:z.union([z.string(),z.number()]).optional(),emptyColor:z.union([z.string(),z.number()]).optional(),showPercentage:z.boolean().default(true),showValue:z.boolean().default(false),thresholds:z.array(Xy).optional(),min:z.number().default(0),max:z.number().default(100)}),ss=1e4,Et={isGauge:new Uint8Array(ss),showPercentage:new Uint8Array(ss),showValue:new Uint8Array(ss)},Ln=new Map;function qy(e,r){if(!r.thresholds||r.thresholds.length===0)return r.fillColor;let o;for(let n of r.thresholds)e>=n.value&&(!o||n.value>o.value)&&(o=n);return o?s(o.color):r.fillColor}function Jy(e){let r="";if(e.label&&(r=e.label),Et.showPercentage[0]===1){let o=ja(e.value);r=r?`${r} ${o}`:o;}if(Et.showValue[0]===1){let n=`${(e.min+e.value*(e.max-e.min)).toFixed(1)}/${e.max}`;r=r?`${r} ${n}`:n;}return r}function Zy(e,r,o){let n=Math.floor((o-r.length)/2),t=" ".repeat(n)+r,i="";for(let a=0;a<o;a++)a<t.length&&t[a]!==" "?i+=t[a]:i+=e[a]??" ";return i}function eh(e,r,o){return !r||r.length>=o?[e]:[Zy(e,r,o)]}function th(e,r,o,n){let t=[e];for(r&&t.push(r.padEnd(o," "));t.length<n;)t.push(" ".repeat(o));return t}function nh(e,r,o){let n=Math.round(e.value*r),t=r-n,i=e.fillChar.repeat(n)+e.emptyChar.repeat(t),a=Jy(e);return (o===1?eh(i,a,r):th(i,a,r,o)).join(`
10
+ `)}function ls(e,r){let o=Ln.get(r);if(!o)return;let n=g(e,r);if(!n)return;let t=nh(o,n.width,n.height);e$1(e,r,t);let i=qy(o.value,o);i!==void 0&&la$1(e,r,{fg:i}),oa$1(e,r);}function rh(e,r={}){let o=sc.parse(r),n=d$1(e);U(e,n,o.x,o.y),f(e,n,o.width,o.height),Et.isGauge[n]=1,Et.showPercentage[n]=o.showPercentage?1:0,Et.showValue[n]=o.showValue?1:0,Ln.set(n,{value:o.value,label:o.label??"",fillChar:o.fillChar,emptyChar:o.emptyChar,fillColor:o.fillColor?s(o.fillColor):void 0,emptyColor:o.emptyColor?s(o.emptyColor):void 0,thresholds:o.thresholds?[...o.thresholds]:[],min:o.min,max:o.max}),ls(e,n);let t={eid:n,setValue(i){let a=Ln.get(n);return a&&(a.value=Math.max(0,Math.min(1,i)),ls(e,n)),t},getValue(){return Ln.get(n)?.value??0},setLabel(i){let a=Ln.get(n);return a&&(a.label=i,ls(e,n)),t},getLabel(){return Ln.get(n)?.label??""},setPosition(i,a){return U(e,n,i,a),oa$1(e,n),t},destroy(){Et.isGauge[n]=0,Et.showPercentage[n]=0,Et.showValue[n]=0,Ln.delete(n),e$2(e,n);}};return t}function oh(e,r){return Et.isGauge[r]===1}function ih(){Et.isGauge.fill(0),Et.showPercentage.fill(0),Et.showValue.fill(0),Ln.clear();}n();t();var ah=1e4,us={isGrid:new Uint8Array(ah)},Zi=z.union([z.number().int().positive(),z.string().regex(/^\d+%$/)]),cc=z.object({rows:z.number().int().positive().optional().default(1),cols:z.number().int().positive().optional().default(1),gap:z.number().int().min(0).optional().default(0),cellWidths:z.union([Zi,z.array(Zi)]).optional(),cellHeights:z.union([Zi,z.array(Zi)]).optional(),padding:z.number().int().min(0).optional().default(0),left:z.number().optional().default(0),top:z.number().optional().default(0),width:z.union([z.number(),z.string(),z.literal("auto")]).optional().default("auto"),height:z.union([z.number(),z.string(),z.literal("auto")]).optional().default("auto"),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),Yt=new Map;function sh(e){return typeof e=="string"&&e.endsWith("%")?{value:Number.parseFloat(e),isPercent:true}:{value:typeof e=="number"?e:Number.parseInt(e,10),isPercent:false}}function lc(e,r,o,n){let t=n*(r-1),i=o-t,a=e.map(sh),s=0,l=0;for(let{value:b,isPercent:f}of a)f?l+=b:s+=b;let u=i-s,d=[];for(let{value:b,isPercent:f}of a)f?d.push(b/100*u):d.push(b);return d}function lh(e,r,o,n,t,i){if(e<0||e>=t)throw new Error(`Row ${e} out of bounds (0-${t-1})`);if(r<0||r>=i)throw new Error(`Column ${r} out of bounds (0-${i-1})`);if(e+o>t)throw new Error(`Row span ${o} exceeds grid bounds (row ${e} + span ${o} > ${t})`);if(r+n>i)throw new Error(`Column span ${n} exceeds grid bounds (col ${r} + span ${n} > ${i})`)}function uc(e,r,o,n){let t=[n];for(let i=0;i<e;i++)i>0&&(t[i]=(t[i-1]??0)+(r[i-1]??0)+o);return t}function dc(e,r,o,n,t){let i=0;for(let a=e;a<e+r&&a<o;a++)i+=n[a]??0,a<e+r-1&&(i+=t);return i}function uh(e,r,o,n,t,i,a,s){let l=n[r.col]??0,u=t[r.row]??0,d=dc(r.col,r.colSpan,s.cols,i,s.gap),b=dc(r.row,r.rowSpan,s.rows,a,s.gap);U(e,r.entity,o.x+l,o.y+u),f(e,r.entity,d,b),oa$1(e,r.entity);}function pr(e,r,o){let n=g(e,r);if(!n)return;let t=n.width-o.padding*2,i=n.height-o.padding*2,a=lc(o.cellWidths,o.cols,t,o.gap),s=lc(o.cellHeights,o.rows,i,o.gap),l=uc(o.cols,a,o.gap,o.padding),u=uc(o.rows,s,o.gap,o.padding),d=V$1(e,r);if(d)for(let b of o.cells)uh(e,b,d,l,u,a,s,o);}function dh(e,r,o={}){let n=cc.parse(o),t=r;us.isGrid[t]=1,U(e,t,n.left,n.top),f(e,t,n.width,n.height),d(e,t,{focusable:true}),n.padding>0&&c$1(e,t,n.padding);let i$1=n.fg?s(n.fg):void 0,a=n.bg?s(n.bg):void 0;(i$1!==void 0||a!==void 0)&&la$1(e,t,{fg:i$1,bg:a});let s$1;if(n.cellWidths)s$1=Array.isArray(n.cellWidths)?n.cellWidths:Array(n.cols).fill(n.cellWidths);else {let b=`${100/n.cols}%`;s$1=Array(n.cols).fill(b);}let l;if(n.cellHeights)l=Array.isArray(n.cellHeights)?n.cellHeights:Array(n.rows).fill(n.cellHeights);else {let b=`${100/n.rows}%`;l=Array(n.rows).fill(b);}let u={rows:n.rows,cols:n.cols,gap:n.gap,cellWidths:s$1,cellHeights:l,padding:n.padding,cells:[]};Yt.set(t,u);let d$1={eid:t,show(){return ra$1(e,t,true),oa$1(e,t),d$1},hide(){return ra$1(e,t,false),oa$1(e,t),d$1},focus(){return h(e,t),d$1},blur(){return i(e,t),d$1},isFocused(){return f$1(e,t)},addToCell(b,f,c,g=1,p=1){let h=Yt.get(t);if(!h)return d$1;lh(f,c,g,p,h.rows,h.cols);let E=h.cells.findIndex(W=>W.entity===b);return E>=0&&h.cells.splice(E,1),h.cells.push({entity:b,row:f,col:c,rowSpan:g,colSpan:p}),v$1(e,b)===n$2&&q$2(e,t,b),pr(e,t,h),oa$1(e,t),d$1},removeFromGrid(b){let f=Yt.get(t);if(!f)return d$1;let c=f.cells.findIndex(g=>g.entity===b);return c>=0&&(f.cells.splice(c,1),oa$1(e,t)),d$1},getCells(){return Yt.get(t)?.cells??[]},layout(){let b=Yt.get(t);return b&&(pr(e,t,b),oa$1(e,t)),d$1},setGap(b){let f=Yt.get(t);return f&&(f.gap=b,pr(e,t,f),oa$1(e,t)),d$1},setCellWidths(b){let f=Yt.get(t);return f&&(f.cellWidths=Array.isArray(b)?b:Array(f.cols).fill(b),pr(e,t,f),oa$1(e,t)),d$1},setCellHeights(b){let f=Yt.get(t);return f&&(f.cellHeights=Array.isArray(b)?b:Array(f.rows).fill(b),pr(e,t,f),oa$1(e,t)),d$1},destroy(){Yt.delete(t),e$2(e,t);}};return d$1}function ch(e,r,o,n,t,i=1,a=1){let s=Yt.get(r);if(!s)throw new Error(`Entity ${r} is not a grid`);if(n<0||n>=s.rows)throw new Error(`Row ${n} out of bounds (0-${s.rows-1})`);if(t<0||t>=s.cols)throw new Error(`Column ${t} out of bounds (0-${s.cols-1})`);if(n+i>s.rows)throw new Error(`Row span ${i} exceeds grid bounds (row ${n} + span ${i} > ${s.rows})`);if(t+a>s.cols)throw new Error(`Column span ${a} exceeds grid bounds (col ${t} + span ${a} > ${s.cols})`);let l=s.cells.findIndex(u=>u.entity===o);l>=0&&s.cells.splice(l,1),s.cells.push({entity:o,row:n,col:t,rowSpan:i,colSpan:a}),v$1(e,o)===n$2&&q$2(e,r,o),pr(e,r,s),oa$1(e,r);}function gh(e,r){return us.isGrid[r]===1}function mh(){Yt.clear();}n();t();var fh=1e4,gc={isHeader:new Uint8Array(fh)},mc=z.object({title:z.string().optional().default(""),left:z.string().optional(),center:z.string().optional(),right:z.string().optional(),height:z.number().int().positive().optional().default(1),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),align:z.enum(["left","center","right"]).optional().default("left")}),yr=new Map;function eo(e,r,o){let{left:n,center:t,right:i,title:a}=e;if(n||t||i){let s=n||"",l=t||"",u=i||"",d=s.length,b=l.length,f=u.length,c=d+b+f;if(r-c>=2){let p=Math.floor((r-b)/2),h=Math.max(0,p-d),E=p+b,W=Math.max(0,r-E-f);return s+" ".repeat(h)+l+" ".repeat(W)+u}return `${s} ${l} ${u}`.slice(0,r)}if(a){if(o==="center"){let s=Math.max(0,Math.floor((r-a.length)/2));return " ".repeat(s)+a}if(o==="right"){let s=Math.max(0,r-a.length);return " ".repeat(s)+a}return a}return ""}function bh(e,r,o={}){let n=mc.parse(o),t=r;gc.isHeader[t]=1,U(e,t,0,0),f(e,t,"auto",n.height);let i=n.fg?s(n.fg):void 0,a=n.bg?s(n.bg):void 0;(i!==void 0||a!==void 0)&&la$1(e,t,{fg:i,bg:a});let s$1={title:n.title,left:n.left||"",center:n.center||"",right:n.right||""};yr.set(t,s$1);let l=80,u=eo(s$1,l,n.align);e$1(e,t,u,{align:0});let d={eid:t,show(){return ra$1(e,t,true),oa$1(e,t),d},hide(){return ra$1(e,t,false),oa$1(e,t),d},setTitle(b){let f=yr.get(t);if(f){f.title=b;let c=eo(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},setLeft(b){let f=yr.get(t);if(f){f.left=b;let c=eo(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},setCenter(b){let f=yr.get(t);if(f){f.center=b;let c=eo(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},setRight(b){let f=yr.get(t);if(f){f.right=b;let c=eo(f,l,n.align);e$1(e,t,c),oa$1(e,t);}return d},getContent(){return f$2(e,t)},destroy(){yr.delete(t),e$2(e,t);}};return d}var pc=500,yc=100,hc=2,xc=1,Sc=4294967295,Cc=4281545523,Wc=4287137928,Tc=z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),border:z.number().int().nonnegative().optional(),padding:z.number().int().nonnegative().optional()}),ph=z.object({text:z.string(),style:Tc.optional(),delay:z.number().positive().optional()}),yh=z.object({showDelay:z.number().nonnegative().optional(),hideDelay:z.number().nonnegative().optional(),offsetX:z.number().optional(),offsetY:z.number().optional(),screenWidth:z.number().int().positive().optional(),screenHeight:z.number().int().positive().optional(),style:Tc.optional()}),Xe=new Map;function vc(e){return typeof e=="string"?{text:e}:e}function hh(e){return e.split(`
11
+ `)}function fc(e,r){let o=0;for(let n of e)n.length>o&&(o=n.length);return o+r*2}function bc(e,r){return e.length+r*2}function xh(e,r,o,n,t,i){let a=e,s=r;return a+o>t&&(a=t-o),a<0&&(a=0),s+n>i&&(s=i-n),s<0&&(s=0),{x:a,y:s}}function ds(e={}){let r=yh.parse(e),o=r.showDelay??pc,n=r.hideDelay??yc,t=r.offsetX??hc,i=r.offsetY??xc,a=r.screenWidth??80,s=r.screenHeight??24,l={fg:r.style?.fg??Sc,bg:r.style?.bg??Cc,border:r.style?.border??Wc,padding:r.style?.padding??1},u=false,d=null,b="",f=[],c={x:0,y:0},g=null,p=null,h=null,E=0,W=0,B=false,D={setHoverText(L,N){let pe=vc(N),xe=ph.parse(pe);Xe.set(L,xe);},clearHoverText(L){Xe.delete(L),d===L&&D.hideNow();},getHoverText(L){return Xe.get(L)},hasHoverText(L){return Xe.has(L)},updateMouse(L,N,pe){E=L,W=N,pe!==h&&(h=pe,pe!==null&&Xe.has(pe)?(g=Date.now(),p=null,B=true):u?(p=Date.now(),g=null,B=false):(g=null,p=null,B=false)),u&&d!==null&&I(L,N);},update(L){let N=Date.now();if(B&&g!==null&&h!==null){let xe=Xe.get(h)?.delay??o;N-g>=xe&&(D.showNow(h,E,W),B=false);}p!==null&&u&&N-p>=n&&D.hideNow();},showNow(L,N,pe){let xe=Xe.get(L);xe&&(u=true,d=L,b=xe.text,f=hh(xe.text),g=null,p=null,B=false,I(N,pe));},hideNow(){u=false,d=null,b="",f=[],g=null,p=null,B=false;},getState(){return {visible:u,sourceEntity:d,text:b,position:c,hoverStartTime:g}},isVisible(){return u},getRenderData(){if(!u||d===null)return null;let L=Xe.get(d),N={fg:L?.style?.fg??l.fg,bg:L?.style?.bg??l.bg,border:L?.style?.border??l.border,padding:L?.style?.padding??l.padding??1},pe=fc(f,N.padding),xe=bc(f,N.padding);return {x:c.x,y:c.y,width:pe,height:xe,text:b,lines:f,style:N}},setScreenSize(L,N){a=L,s=N;},clearAll(){Xe.clear(),D.hideNow();}};function I(L,N){let pe=d!==null?Xe.get(d):void 0,xe={fg:pe?.style?.fg??l.fg,bg:pe?.style?.bg??l.bg,border:pe?.style?.border??l.border,padding:pe?.style?.padding??l.padding},ft=fc(f,xe.padding??1),In=bc(f,xe.padding??1),Xt=L+t,Dr=N+i;c=xh(Xt,Dr,ft,In,a,s);}return D}function Sh(e,r){Xe.set(e,vc(r));}function Ch(e){Xe.delete(e);}function Wh(e){return Xe.get(e)}function Th(e){return Xe.has(e)}function vh(){Xe.clear();}function Lh(){return Xe.size}function Eh(){Xe.clear();}n();z.number().int().min(0).max(255).transform(e=>e);var Bh=z.object({r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255)});Bh.extend({a:z.number().min(0).max(1)});var Ph=z.object({h:z.number().min(0).max(360),s:z.number().min(0).max(100),l:z.number().min(0).max(100)});Ph.extend({a:z.number().min(0).max(1)});z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,"Invalid hex color format. Expected #RGB, #RRGGBB, or #RRGGBBAA");var Mh=[{r:0,g:0,b:0},{r:128,g:0,b:0},{r:0,g:128,b:0},{r:128,g:128,b:0},{r:0,g:0,b:128},{r:128,g:0,b:128},{r:0,g:128,b:128},{r:192,g:192,b:192},{r:128,g:128,b:128},{r:255,g:0,b:0},{r:0,g:255,b:0},{r:255,g:255,b:0},{r:0,g:0,b:255},{r:255,g:0,b:255},{r:0,g:255,b:255},{r:255,g:255,b:255}];function Dh(){let e=[0,95,135,175,215,255],r=[];for(let o=0;o<6;o++)for(let n=0;n<6;n++)for(let t=0;t<6;t++)r.push({r:e[o]??0,g:e[n]??0,b:e[t]??0});return r}function Fh(){let e=[];for(let r=0;r<24;r++){let o=8+r*10;e.push({r:o,g:o,b:o});}return e}var Ah=Dh(),Ih=Fh(),hr=[...Mh,...Ah,...Ih];function kh(e){let r=o=>o.toString(16).padStart(2,"0");return `#${r(e.r)}${r(e.g)}${r(e.b)}`}hr.map(kh);function Vh(e){let r=e.startsWith("#")?e.slice(1):e;if(!/^[0-9a-fA-F]+$/.test(r))throw new Error(`Invalid hex color: ${e}`);let o,n,t,i;if(r.length===3){let a=r[0]??"0",s=r[1]??"0",l=r[2]??"0";o=Number.parseInt(a+a,16),n=Number.parseInt(s+s,16),t=Number.parseInt(l+l,16);}else if(r.length===6)o=Number.parseInt(r.slice(0,2),16),n=Number.parseInt(r.slice(2,4),16),t=Number.parseInt(r.slice(4,6),16);else if(r.length===8)o=Number.parseInt(r.slice(0,2),16),n=Number.parseInt(r.slice(2,4),16),t=Number.parseInt(r.slice(4,6),16),i=Number.parseInt(r.slice(6,8),16)/255;else throw new Error(`Invalid hex color length: ${e}`);return i!==void 0?{r:o,g:n,b:t,a:i}:{r:o,g:n,b:t}}function En(e){let r=0,o=Number.POSITIVE_INFINITY;for(let n=0;n<256;n++){let t=hr[n];if(!t)continue;let i=e.r-t.r,a=e.g-t.g,s=e.b-t.b,l=i*i+a*a+s*s;if(l<o&&(o=l,r=n),l===0)break}return r}function Lc(e){let r=Math.max(0,Math.min(255,Math.round(e.r))),o=Math.max(0,Math.min(255,Math.round(e.g))),n=Math.max(0,Math.min(255,Math.round(e.b)));return r<<16|o<<8|n}function rP(e){let r=Vh(e);return Lc(r)}function oP(e){let r=hr[e];if(!r)throw new Error(`Invalid Color256: ${e}`);return Lc(r)}function Ec(e){return `38;5;${e}`}function Bc(e){return `48;5;${e}`}function Pc(e,r){let o=e.a,n=1-o;return {r:Math.round(e.r*o+r.r*n),g:Math.round(e.g*o+r.g*n),b:Math.round(e.b*o+r.b*n)}}z.object({width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),mode:z.enum(["color","ascii","braille"]).optional(),dither:z.boolean().optional(),background:z.object({r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255)}).optional()});var Mc=" .:-=+*#%@",Dc="\u2580",Oh=10240;function _h(e){let r=Math.max(0,Math.min(1,e)),o=Math.round(r*(Mc.length-1));return Mc[o]??" "}function Fc(e,r,o){return (e*.299+r*.587+o*.114)/255}function Nh(e,r,o){if(r<=0||o<=0)return {width:0,height:0,data:new Uint8Array(0)};let n=new Uint8Array(r*o*4),t=e.width/r,i=e.height/o;for(let a=0;a<o;a++){let s=Math.min(Math.floor(a*i),e.height-1);for(let l=0;l<r;l++){let u=Math.min(Math.floor(l*t),e.width-1),d=(s*e.width+u)*4,b=(a*r+l)*4;n[b]=e.data[d]??0,n[b+1]=e.data[d+1]??0,n[b+2]=e.data[d+2]??0,n[b+3]=e.data[d+3]??0;}}return {width:r,height:o,data:n}}function Gh(e,r){let o=e.a/255;return Pc({r:e.r,g:e.g,b:e.b,a:o},r)}function wh(e,r,o){let n=(o*e.width+r)*4;return {r:e.data[n]??0,g:e.data[n+1]??0,b:e.data[n+2]??0,a:e.data[n+3]??0}}function to(e,r,o,n){let t=wh(e,r,o);return t.a===255?{r:t.r,g:t.g,b:t.b}:t.a===0?n:Gh(t,n)}function zh(e,r,o){for(let n=0;n<o;n++)for(let t=0;t<r;t++){let i=n*r+t,a=e[i];if(!a)continue;let s=En(a),l=hr[s];if(!l)continue;let u=a.r-l.r,d=a.g-l.g,b=a.b-l.b;ea(e,r,o,t+1,n,u,d,b,7/16),ea(e,r,o,t-1,n+1,u,d,b,3/16),ea(e,r,o,t,n+1,u,d,b,5/16),ea(e,r,o,t+1,n+1,u,d,b,1/16);}}function ea(e,r,o,n,t,i,a,s,l){if(n<0||n>=r||t<0||t>=o)return;let u=t*r+n,d=e[u];d&&(d.r=Math.max(0,Math.min(255,Math.round(d.r+i*l))),d.g=Math.max(0,Math.min(255,Math.round(d.g+a*l))),d.b=Math.max(0,Math.min(255,Math.round(d.b+s*l))));}function Hh(e,r,o){let n=Math.ceil(e.height/2),t=e.width;if(o)return Uh(e,r,t,n);let i=[];for(let a=0;a<n;a++){let s=[];for(let l=0;l<t;l++){let u=a*2,d=a*2+1,b=to(e,l,u,r),f=d<e.height?to(e,l,d,r):r,c=En(b),g=En(f);s.push({char:Dc,fg:c,bg:g});}i.push(s);}return {width:t,height:n,cells:i}}function Uh(e,r,o,n){let t=[];for(let a=0;a<e.height;a++)for(let s=0;s<e.width;s++){let l=to(e,s,a,r);t.push({r:l.r,g:l.g,b:l.b});}zh(t,e.width,e.height);let i=[];for(let a=0;a<n;a++){let s=[];for(let l=0;l<o;l++){let u=a*2,d=a*2+1,b=t[u*e.width+l]??{r:0,g:0,b:0},f=d<e.height?t[d*e.width+l]??{r:0,g:0,b:0}:r,c=En(b),g=En(f);s.push({char:Dc,fg:c,bg:g});}i.push(s);}return {width:o,height:n,cells:i}}function $h(e,r){let o=[];for(let n=0;n<e.height;n++){let t=[];for(let i=0;i<e.width;i++){let a=to(e,i,n,r),s=Fc(a.r,a.g,a.b),l=_h(s),u=En(a);t.push({char:l,fg:u,bg:0});}o.push(t);}return {width:e.width,height:e.height,cells:o}}var jh=[[1,8],[2,16],[4,32],[64,128]];function Yh(e,r,o,n,t){let i={pattern:0,totalR:0,totalG:0,totalB:0,count:0};for(let a=0;a<4;a++)for(let s=0;s<2;s++){let l=r*2+s,u=o*4+a;if(l>=e.width||u>=e.height)continue;let d=to(e,l,u,n);if(Fc(d.r,d.g,d.b)>=t){let f=jh[a];f&&(i.pattern|=f[s]??0);}i.totalR+=d.r,i.totalG+=d.g,i.totalB+=d.b,i.count++;}return i}function Kh(e){let r=String.fromCodePoint(Oh+e.pattern),o=e.count>0?En({r:Math.round(e.totalR/e.count),g:Math.round(e.totalG/e.count),b:Math.round(e.totalB/e.count)}):0;return {char:r,fg:o,bg:0}}function Qh(e,r){let o=Math.ceil(e.width/2),n=Math.ceil(e.height/4),t=[],i=.5;for(let a=0;a<n;a++){let s=[];for(let l=0;l<o;l++){let u=Yh(e,l,a,r,i);s.push(Kh(u));}t.push(s);}return {width:o,height:n,cells:t}}function cs(e,r){let o=r?.mode??"color",n=r?.dither??false,t=r?.background??{r:0,g:0,b:0},i=r?.width??e.width,a=r?.height;a!==void 0&&o==="color"&&(a=a*2),a!==void 0&&o==="braille"&&(a=a*4);let l=(o==="braille"&&r?.width?r.width*2:void 0)??i,u=a??e.height,d=l!==e.width||u!==e.height?Nh(e,l,u):e;switch(o){case "color":return Hh(d,t,n);case "ascii":return $h(d,t);case "braille":return Qh(d,t)}}function gs(e){let r=[];for(let o of e.cells){let n="",t=-1,i=-1;for(let a of o)(a.fg!==t||a.bg!==i)&&(n+=`\x1B[${Ec(a.fg)};${Bc(a.bg)}m`,t=a.fg,i=a.bg),n+=a.char;r.push(n);}return `${r.join(`
12
+ `)}\x1B[0m`}var Ac=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),type:z.enum(["ansi","overlay"]).default("ansi"),bitmap:z.object({width:z.number().int().nonnegative(),height:z.number().int().nonnegative(),data:z.instanceof(Uint8Array)}).optional(),renderMode:z.enum(["color","ascii","braille"]).default("color"),dither:z.boolean().default(false),visible:z.boolean().default(true)}),Xh=1e4,oo={isImage:new Uint8Array(Xh)},Bn=new Map,no=new Map,Nn=new Map,ro=new Map,Sr=new Map,xr=new Map;function ms(e,r){let o=Bn.get(r);if(!o){e$1(e,r,""),Sr.delete(r);return}if((no.get(r)??"ansi")!=="ansi"){e$1(e,r,"");return}let t=Nn.get(r)??"color",i=ro.get(r)??false,a=cs(o,{width:void 0,height:void 0,mode:t,dither:i});Sr.set(r,a);let s=gs(a);e$1(e,r,s);}function qh(e,r={}){let o=Ac.parse(r),n=d$1(e);U(e,n,o.x,o.y);let t=o.width??o.bitmap?.width??0,i=o.height??o.bitmap?.height??0;return f(e,n,t,i),oo.isImage[n]=1,no.set(n,o.type),Nn.set(n,o.renderMode),ro.set(n,o.dither),xr.set(n,o.visible),o.bitmap&&(Bn.set(n,o.bitmap),ms(e,n)),o.visible||ra$1(e,n,false),Jh(e,n)}function Jh(e,r){return {get eid(){return r},show(){return xr.set(r,true),ra$1(e,r,true),oa$1(e,r),this},hide(){return xr.set(r,false),ra$1(e,r,false),oa$1(e,r),this},isVisible(){return xr.get(r)??false},move(o,n){let t=T$1.x[r]??0,i=T$1.y[r]??0;return U(e,r,t+o,i+n),oa$1(e,r),this},setPosition(o,n){return U(e,r,o,n),oa$1(e,r),this},getPosition(){return {x:T$1.x[r]??0,y:T$1.y[r]??0}},setImage(o){return Bn.set(r,o),ms(e,r),oa$1(e,r),this},getImage(){return Bn.get(r)},getType(){return no.get(r)??"ansi"},getCellMap(){return Sr.get(r)},setRenderMode(o){return Nn.set(r,o),ms(e,r),oa$1(e,r),this},getRenderMode(){return Nn.get(r)??"color"},render(){let o=Bn.get(r);if(!o)return "";let n=Nn.get(r)??"color",t=ro.get(r)??false,i=cs(o,{mode:n,dither:t});return gs(i)},destroy(){oo.isImage[r]=0,Bn.delete(r),no.delete(r),Nn.delete(r),ro.delete(r),Sr.delete(r),xr.delete(r),e$2(e,r);}}}function Zh(e,r){return oo.isImage[r]===1}function ex(e){return Bn.get(e)}function tx(e){return Sr.get(e)}function nx(){oo.isImage.fill(0),Bn.clear(),no.clear(),Nn.clear(),ro.clear(),Sr.clear(),xr.clear();}n();t();var Ic=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),kc=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Oc=z.object({left:Ic.optional(),top:Ic.optional(),width:kc.optional(),height:kc.optional(),layout:z.enum(["inline","grid","flex"]).optional(),gap:z.number().nonnegative().optional(),wrap:z.boolean().optional(),justify:z.enum(["start","center","end","space-between"]).optional(),align:z.enum(["start","center","end"]).optional(),cols:z.number().positive().optional(),direction:z.enum(["row","column"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),Pn=1e4,q={isLayout:new Uint8Array(Pn),mode:new Uint8Array(Pn),gap:new Float32Array(Pn),wrap:new Uint8Array(Pn),justify:new Uint8Array(Pn),align:new Uint8Array(Pn),cols:new Uint8Array(Pn),direction:new Uint8Array(Pn)};function Rc(e){return e===void 0?0:typeof e=="number"?e:0}function Vc(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function rx(e){switch(e){case "inline":return 0;case "grid":return 1;case "flex":return 2}}function fs(e){switch(e){case 0:return "inline";case 1:return "grid";case 2:return "flex";default:return "inline"}}function ox(e){switch(e){case "start":return 0;case "center":return 1;case "end":return 2;case "space-between":return 3}}function ix(e){switch(e){case "start":return 0;case "center":return 1;case "end":return 2}}function ax(e,r){return r.map(o=>{let n=g(e,o);return {eid:o,width:n?.width??1,height:n?.height??1}})}function _c(e,r,o,n){let t=new Map,i=0,a=0,s=0;for(let l of e)n&&i>0&&i+l.width>r&&(i=0,a+=s+o,s=0),t.set(l.eid,{x:i,y:a}),i+=l.width+o,s=Math.max(s,l.height);return t}function Nc(e,r,o){let n=new Map,t=new Array(r).fill(0),i=[];return e.forEach((a,s)=>{let l=s%r,u=Math.floor(s/r);t[l]=Math.max(t[l],a.width),i[u]||(i[u]=0),i[u]=Math.max(i[u],a.height);}),e.forEach((a,s)=>{let l=s%r,u=Math.floor(s/r),d=0;for(let f=0;f<l;f++)d+=t[f]+o;let b=0;for(let f=0;f<u;f++)b+=i[f]+o;n.set(a.eid,{x:d,y:b});}),n}function Gc(e,r,o,n,t,i){let a=new Map;if(e.length===0)return a;let s=n==="row",l=e.reduce((p,h)=>p+(s?h.width:h.height),0),u=o*(e.length-1),d=l+u,b=Math.max(0,r-d),f=Math.max(...e.map(p=>s?p.height:p.width)),c=0,g=0;switch(t){case "start":c=0;break;case "center":c=b/2;break;case "end":c=b;break;case "space-between":c=0,e.length>1&&(g=b/(e.length-1));break}for(let p of e){let h=s?p.width:p.height,E=s?p.height:p.width,W=0;switch(i){case "start":W=0;break;case "center":W=(f-E)/2;break;case "end":W=f-E;break}s?a.set(p.eid,{x:c,y:W}):a.set(p.eid,{x:W,y:c}),c+=h+o+g;}return a}function bs(e,r,o={}){let n=Oc.parse(o),t=r,i$1=n.layout??"inline";q.isLayout[t]=1,q.mode[t]=rx(i$1),q.gap[t]=n.gap??0,q.wrap[t]=n.wrap!==false?1:0,q.justify[t]=ox(n.justify??"start"),q.align[t]=ix(n.align??"start"),q.cols[t]=n.cols??3,q.direction[t]=n.direction==="column"?1:0;let a=Rc(n.left),s$2=Rc(n.top);U(e,t,a,s$2);let l=Vc(n.width),u=Vc(n.height);f(e,t,l,u),(n.fg!==void 0||n.bg!==void 0)&&la$1(e,t,{fg:n.fg!==void 0?s(n.fg):void 0,bg:n.bg!==void 0?s(n.bg):void 0}),d(e,t,{focusable:true});function d$1(){let f=s$1(e,t);if(f.length===0)return;let c=ax(e,f),g=sx(e,t),p=lx(e,t,c,g.width,g.height);ux(e,t,p),oa$1(e,t);}let b={eid:t,show(){return ra$1(e,t,true),b},hide(){return ra$1(e,t,false),b},move(f,c){return Z$1(e,t,f,c),oa$1(e,t),b},setPosition(f,c){return U(e,t,f,c),oa$1(e,t),b},getLayoutMode(){return fs(q.mode[t])},setGap(f){return q.gap[t]=f,oa$1(e,t),b},getGap(){return q.gap[t]},recalculate(){return d$1(),b},focus(){return h(e,t),b},blur(){return i(e,t),b},isFocused(){return f$1(e,t)},append(f){return q$2(e,t,f),b},getChildren(){return s$1(e,t)},destroy(){q.isLayout[t]=0,q.mode[t]=0,q.gap[t]=0,q.wrap[t]=0,q.justify[t]=0,q.align[t]=0,q.cols[t]=0,q.direction[t]=0,e$2(e,t);}};return b}function sx(e,r){let o=g(e,r);return {width:o?.width??80,height:o?.height??24}}function lx(e,r,o,n,t){let i=q.gap[r];switch(fs(q.mode[r])){case "inline":{let s=q.wrap[r]===1;return _c(o,n,i,s)}case "grid":{let s=q.cols[r];return Nc(o,s,i)}case "flex":{let s=q.direction[r]===0?"row":"column",l=["start","center","end","space-between"][q.justify[r]]??"start",u=["start","center","end"][q.align[r]]??"start";return Gc(o,s==="row"?n:t,i,s,l,u)}}}function ux(e,r,o){let n=V$1(e,r),t=n?.x??0,i=n?.y??0;for(let[a,s]of o)U(e,a,t+s.x,i+s.y),oa$1(e,a);}function dx(e,r){return q.isLayout[r]===1}function cx(e,r){return fs(q.mode[r])}function gx(){q.isLayout.fill(0),q.mode.fill(0),q.gap.fill(0),q.wrap.fill(0),q.justify.fill(0),q.align.fill(0),q.cols.fill(0),q.direction.fill(0);}n();t();var ta="\u2500",Uc="\u2502",$c=10,wc=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),jc=z.object({left:wc.optional(),top:wc.optional(),orientation:z.enum(["horizontal","vertical"]).optional(),length:z.number().positive().optional(),char:z.string().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),ps=1e4,rt={isLine:new Uint8Array(ps),orientation:new Uint8Array(ps),length:new Float32Array(ps)},Gn=new Map;function zc(e){return e===void 0?0:typeof e=="number"?e:0}function mx(e,r,o){let n=zc(o.left),t=zc(o.top);U(e,r,n,t);}function Hc(e,r,o,n){o==="horizontal"?f(e,r,n,1):f(e,r,1,n);}function fx(e,r,o){o.fg===void 0&&o.bg===void 0||la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function ys(e,r,o={}){let n=jc.parse(o),t=r,i$1=n.orientation??"horizontal",a=n.length??$c,s=n.char??(i$1==="horizontal"?ta:Uc);rt.isLine[t]=1,rt.orientation[t]=i$1==="horizontal"?0:1,rt.length[t]=a,Gn.set(t,s),mx(e,t,n),Hc(e,t,i$1,a),fx(e,t,n),d(e,t,{focusable:false});let l={eid:t,show(){return ra$1(e,t,true),l},hide(){return ra$1(e,t,false),l},move(u,d){return Z$1(e,t,u,d),oa$1(e,t),l},setPosition(u,d){return U(e,t,u,d),oa$1(e,t),l},setChar(u){return Gn.set(t,u),oa$1(e,t),l},getChar(){return Gn.get(t)??ta},getOrientation(){return rt.orientation[t]===0?"horizontal":"vertical"},setLength(u){rt.length[t]=u;let d=rt.orientation[t]===0?"horizontal":"vertical";return Hc(e,t,d,u),oa$1(e,t),l},getLength(){return rt.length[t]},focus(){return h(e,t),l},blur(){return i(e,t),l},isFocused(){return f$1(e,t)},append(u){return q$2(e,t,u),l},getChildren(){return s$1(e,t)},destroy(){rt.isLine[t]=0,rt.orientation[t]=0,rt.length[t]=0,Gn.delete(t),e$2(e,t);}};return l}function bx(e,r){return rt.isLine[r]===1}function px(e,r){return Gn.get(r)??ta}function yx(e,r,o){return Gn.set(r,o),oa$1(e,r),r}function hx(e,r){return rt.orientation[r]===0?"horizontal":"vertical"}function xx(){rt.isLine.fill(0),rt.orientation.fill(0),rt.length.fill(0),Gn.clear();}n();t();var Sx=z.object({label:z.string(),data:z.array(z.number()),color:z.union([z.string(),z.number()]).optional()}),Yc=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(60),height:z.number().int().positive().default(20),series:z.array(Sx).default([]),xLabels:z.array(z.string()).optional(),yLabel:z.string().optional(),xLabel:z.string().optional(),showLegend:z.boolean().default(false),showGrid:z.boolean().default(true),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),minY:z.number().optional(),maxY:z.number().optional()}),hs=1e4,Mt={isLineChart:new Uint8Array(hs),showLegend:new Uint8Array(hs),showGrid:new Uint8Array(hs)},Mn=new Map;function Cx(e){let r=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let n of e)for(let t of n.data)t<r&&(r=t),t>o&&(o=t);return {minY:r,maxY:o}}function Wx(e){let r=e.minY??Number.POSITIVE_INFINITY,o=e.maxY??Number.NEGATIVE_INFINITY;if(e.minY===void 0||e.maxY===void 0){let n=Cx(e.series);r=n.minY,o=n.maxY;}return r===Number.POSITIVE_INFINITY&&(r=0),o===Number.NEGATIVE_INFINITY&&(o=100),{minY:r,maxY:o}}function Tx(e,r,o,n){let a=o&&n>0?2:0,s=r-2-a,l=e-8,u=s*4;return {yAxisWidth:8,xAxisHeight:2,legendHeight:a,chartHeight:s,chartWidth:l,pixelHeight:u}}function vx(e){let r=0;for(let o of e)o.data.length>r&&(r=o.data.length);return r}function Lx(e,r,o,n,t,i,a){let s=Math.floor(e/(a-1||1)*(t*2-1)),l=Math.floor(s/2),u=s%2,d=Math.round(St(r,o,n,i-1,0)),b=Math.floor(d/4),f=d%4;return {charX:l,charY:b,col:u,row:f}}function Ex(e,r,o,n,t,i,a){if(r<0||r>=i||o<0||o>=a)return;let s=_n[t];if(!s)return;let l=s[n]??0,u=e[o];u&&u[r]!==void 0&&(u[r]|=l);}function Bx(e,r,o,n,t,i,a,s){for(let l of r)if(l.data.length!==0)for(let u=0;u<l.data.length;u++){let d=l.data[u]??0,b=Lx(u,d,o,n,t,a,s);Ex(e,b.charX,b.charY,b.col,b.row,t,i);}}function Px(e,r,o,n,t,i,a,s){let l=[];for(let u=0;u<r;u++){let d=r-u-1,b=St(d,0,r-1,t,i),f=a.find(h=>Math.abs(h-b)<(i-t)/r),g=`${f!==void 0?Nr(f,n-2):" ".repeat(n-2)}\u2502`,p=e[u];if(p)for(let h=0;h<o;h++){let E=p[h]??10240;g+=String.fromCharCode(E);}l.push(g.padEnd(s," "));}return l}function Mx(e,r,o,n,t){let i=[],a=`${" ".repeat(e)}\u2514${"\u2500".repeat(r-1)}`;if(i.push(a.padEnd(o," ")),n.length>0){let s=`${" ".repeat(e)} `,l=Math.max(1,Math.floor(t/5));for(let u=0;u<t;u+=l){let d=n[u]??u.toString();s+=d.slice(0,8).padEnd(8," ");}i.push(s.padEnd(o," "));}else i.push(" ".repeat(o));return i}function Dx(e,r,o,n){let t=[];if(e&&r.length>0){let i="Legend: ";for(let a=0;a<r.length;a++){let s=r[a];s&&(i+=`${s.label} `);}t.push(i.padEnd(n," ")),o>1&&t.push(" ".repeat(n));}return t}function Fx(e,r,o,n,t){let{minY:i,maxY:a}=Wx(e),s=Tx(r,o,t,e.series.length),l=vx(e.series),u=_r(i,a,5),d=Array.from({length:s.chartHeight},()=>Array(s.chartWidth).fill(10240));Bx(d,e.series,i,a,s.chartWidth,s.chartHeight,s.pixelHeight,l);let b=Px(d,s.chartHeight,s.chartWidth,s.yAxisWidth,i,a,u,r),f=Mx(s.yAxisWidth,s.chartWidth,r,e.xLabels,l),c=Dx(t,e.series,s.legendHeight,r);return [...b,...f,...c].join(`
13
+ `)}function na(e,r){let o=Mn.get(r);if(!o)return;let n=g(e,r);if(!n)return;let t=Mt.showGrid[r]===1,i=Mt.showLegend[r]===1,a=Fx(o,n.width,n.height,t,i);e$1(e,r,a),oa$1(e,r);}function Ax(e,r={}){let o=Yc.parse(r),n=d$1(e);U(e,n,o.x,o.y),f(e,n,o.width,o.height),Mt.isLineChart[n]=1,Mt.showLegend[n]=o.showLegend?1:0,Mt.showGrid[n]=o.showGrid?1:0,Mn.set(n,{series:o.series.map((i,a)=>({label:i.label,data:[...i.data],color:i.color?s(i.color):en(a)})),xLabels:o.xLabels?[...o.xLabels]:[],yLabel:o.yLabel??"",xLabel:o.xLabel??"",minY:o.minY,maxY:o.maxY}),(o.fg!==void 0||o.bg!==void 0)&&la$1(e,n,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),na(e,n);let t={eid:n,setSeries(i){let a=Mn.get(n);return a&&(a.series=i.map((s$1,l)=>({label:s$1.label,data:[...s$1.data],color:s$1.color?s(s$1.color):en(l)})),na(e,n)),t},getSeries(){return Mn.get(n)?.series??[]},appendToSeries(i,a){let s=Mn.get(n);if(s?.series[i]){let l=s.series[i];l&&(l.data.push(a),na(e,n));}return t},clear(){let i=Mn.get(n);if(i){for(let a of i.series)a.data.length=0;na(e,n);}return t},setPosition(i,a){return U(e,n,i,a),oa$1(e,n),t},destroy(){Mt.isLineChart[n]=0,Mt.showLegend[n]=0,Mt.showGrid[n]=0,Mn.delete(n),e$2(e,n);}};return t}function Ix(e,r){return Mt.isLineChart[r]===1}function kx(){Mt.isLineChart.fill(0),Mt.showLegend.fill(0),Mt.showGrid.fill(0),Mn.clear();}n();var wn=1e4,Rx=z.object({text:z.string(),key:z.string().optional(),callback:z.function().optional(),value:z.string().optional()}),eg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),items:z.array(Rx).default([]),selected:z.number().int().min(-1).default(0),style:z.object({item:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),prefix:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),separator:z.string().optional()}).optional(),autoCommandKeys:z.boolean().default(true),mouse:z.boolean().default(true),keys:z.boolean().default(true)}),w={isListbar:new Uint8Array(wn),selectedIndex:new Int32Array(wn).fill(-1),itemCount:new Uint32Array(wn),state:new Uint8Array(wn),autoCommandKeys:new Uint8Array(wn),mouse:new Uint8Array(wn),keys:new Uint8Array(wn)},Dt=new Map,gn=new Map,ao=new Map,so=new Map,Kc=3435973887,Qc=255,Xc=255,qc=16777215,Jc=4294902015,Zc=255,io=" | ",Vx={0:"idle",1:"focused"};function Ox(){w.isListbar.fill(0),w.selectedIndex.fill(-1),w.itemCount.fill(0),w.state.fill(0),w.autoCommandKeys.fill(0),w.mouse.fill(0),w.keys.fill(0),Dt.clear(),gn.clear(),ao.clear(),so.clear();}function xs(e,r,o={}){let n=eg.parse(o),t=r;w.isListbar[t]=1,U(e,t,n.x,n.y),w.autoCommandKeys[t]=n.autoCommandKeys?1:0,w.mouse[t]=n.mouse?1:0,w.keys[t]=n.keys?1:0;let i=[...n.items];Dt.set(t,i),w.itemCount[t]=i.length,n.selected>=0&&n.selected<i.length?w.selectedIndex[t]=n.selected:i.length>0&&(w.selectedIndex[t]=0);let a={itemFg:n.style?.item?.fg??Kc,itemBg:n.style?.item?.bg??Qc,selectedFg:n.style?.selected?.fg??Xc,selectedBg:n.style?.selected?.bg??qc,prefixFg:n.style?.prefix?.fg??Jc,prefixBg:n.style?.prefix?.bg??Zc,separator:n.style?.separator??io};gn.set(t,a);let s=()=>{let c=Dt.get(t)??[],p=gn.get(t)?.separator??io,h=0;for(let E=0;E<c.length;E++){let W=c[E];if(W){let B=u(W,E,w.autoCommandKeys[t]===1);h+=B.length+W.text.length;}E<c.length-1&&(h+=p.length);}return h},l=n.width??s();f(e,t,l,1),ao.set(t,new Set),so.set(t,new Set);function u(c,g,p){return c.key?`[${c.key}]`:p&&g<9?`[${g+1}]`:""}let d=()=>{let c=w.selectedIndex[t]??-1,p=(Dt.get(t)??[])[c];if(p&&c>=0){let h=ao.get(t);if(h)for(let E of h)E(c,p);}},b=()=>{let c=w.selectedIndex[t]??-1,p=(Dt.get(t)??[])[c];if(p&&c>=0){p.callback&&p.callback();let h=so.get(t);if(h)for(let E of h)E(c,p);}},f$1={eid:t,show(){return ra$1(e,t,true),f$1},hide(){return ra$1(e,t,false),f$1},move(c,g){return T$1.x[t]=(T$1.x[t]??0)+c,T$1.y[t]=(T$1.y[t]??0)+g,oa$1(e,t),f$1},setPosition(c,g){return U(e,t,c,g),f$1},focus(){return w.state[t]=1,oa$1(e,t),f$1},blur(){return w.state[t]=0,oa$1(e,t),f$1},setItems(c){let g=[...c];return Dt.set(t,g),w.itemCount[t]=g.length,(w.selectedIndex[t]??-1)>=g.length&&(w.selectedIndex[t]=Math.max(0,g.length-1)),oa$1(e,t),f$1},getItems(){return Dt.get(t)??[]},addItem(c){let g=Dt.get(t)??[];return g.push(c),w.itemCount[t]=g.length,oa$1(e,t),f$1},removeItem(c){let g=Dt.get(t)??[];if(c>=0&&c<g.length){g.splice(c,1),w.itemCount[t]=g.length;let p=w.selectedIndex[t]??-1;p>=g.length?w.selectedIndex[t]=Math.max(0,g.length-1):p>c&&(w.selectedIndex[t]=p-1),oa$1(e,t);}return f$1},getItemCount(){return w.itemCount[t]??0},select(c){let g=w.itemCount[t]??0;return c>=0&&c<g&&w.selectedIndex[t]!==c&&(w.selectedIndex[t]=c,oa$1(e,t),d()),f$1},getSelectedIndex(){return w.selectedIndex[t]??-1},getSelectedItem(){let c=w.selectedIndex[t]??-1;return (Dt.get(t)??[])[c]},selectPrev(){let c=w.selectedIndex[t]??0,g=w.itemCount[t]??0;if(g>0){let p=c<=0?g-1:c-1;f$1.select(p);}return f$1},selectNext(){let c=w.selectedIndex[t]??0,g=w.itemCount[t]??0;if(g>0){let p=c>=g-1?0:c+1;f$1.select(p);}return f$1},selectFirst(){return (w.itemCount[t]??0)>0&&f$1.select(0),f$1},selectLast(){let c=w.itemCount[t]??0;return c>0&&f$1.select(c-1),f$1},selectByKey(c){let g=Dt.get(t)??[],p=w.autoCommandKeys[t]===1;for(let h=0;h<g.length;h++)if(g[h]?.key?.toLowerCase()===c.toLowerCase())return f$1.select(h),true;if(p){let h=Number.parseInt(c,10);if(h>=1&&h<=9&&h<=g.length)return f$1.select(h-1),true}return false},activate(){return b(),f$1},getState(){let c=w.state[t]??0;return Vx[c]??"idle"},setStyle(c){let g=gn.get(t)??{itemFg:Kc,itemBg:Qc,selectedFg:Xc,selectedBg:qc,prefixFg:Jc,prefixBg:Zc,separator:io};return c.item?.fg!==void 0&&(g.itemFg=c.item.fg),c.item?.bg!==void 0&&(g.itemBg=c.item.bg),c.selected?.fg!==void 0&&(g.selectedFg=c.selected.fg),c.selected?.bg!==void 0&&(g.selectedBg=c.selected.bg),c.prefix?.fg!==void 0&&(g.prefixFg=c.prefix.fg),c.prefix?.bg!==void 0&&(g.prefixBg=c.prefix.bg),c.separator!==void 0&&(g.separator=c.separator),gn.set(t,g),oa$1(e,t),f$1},getSeparator(){return gn.get(t)?.separator??io},setSeparator(c){let g=gn.get(t);return g&&(g.separator=c,oa$1(e,t)),f$1},renderLine(){let c=Dt.get(t)??[],g=w.selectedIndex[t]??-1,p=w.autoCommandKeys[t]===1,E=gn.get(t)?.separator??io,W=[];for(let B=0;B<c.length;B++){let D=c[B];if(!D)continue;let I=u(D,B,p),L=B===g,N=I+D.text;L?W.push(`[${N}]`):W.push(` ${N} `);}return W.join(E)},calculateWidth(){return s()},onSelect(c){let g=ao.get(t);return g&&g.add(c),()=>{g?.delete(c);}},onActivate(c){let g=so.get(t);return g&&g.add(c),()=>{g?.delete(c);}},handleKey(c){let g=w.state[t]??0,p=w.keys[t]===1;if(g!==1||!p)return null;switch(c.toLowerCase()){case "left":case "h":return f$1.selectPrev(),{type:"selectPrev"};case "right":case "l":return f$1.selectNext(),{type:"selectNext"};case "home":return f$1.selectFirst(),{type:"selectFirst"};case "end":return f$1.selectLast(),{type:"selectLast"};case "enter":case " ":return f$1.activate(),{type:"confirm"};case "escape":return f$1.blur(),{type:"cancel"}}return f$1.selectByKey(c)?{type:"selectByKey",key:c}:null},destroy(){w.isListbar[t]=0,w.selectedIndex[t]=-1,w.itemCount[t]=0,w.state[t]=0,Dt.delete(t),gn.delete(t),ao.delete(t),so.delete(t),e$2(e,t);}};return f$1}function _x(e,r){return w.isListbar[r]===1}n();var rg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(10),data:z.array(z.array(z.string())).default([]),pad:z.number().int().min(0).max(10).default(1),align:z.enum(["left","center","right"]).default("left"),style:z.object({border:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),header:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),cell:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),altRowBg:z.number().optional()}).optional(),cellBorders:z.boolean().default(true),headerRows:z.number().int().min(0).max(10).default(1),columns:z.array(z.object({header:z.string(),width:z.number().int().positive().optional(),minWidth:z.number().int().positive().optional(),maxWidth:z.number().int().positive().optional(),align:z.enum(["left","center","right"]).optional()})).optional(),selected:z.number().int().min(-1).default(0),interactive:z.boolean().default(true),mouse:z.boolean().default(true),keys:z.boolean().default(true),search:z.boolean().default(false)});function tg(e,r){let o=[];for(let n=r;n<e.length;n++){let t=e[n];if(t){let i=t[0]??"";o.push({text:i,value:t.join(" ")});}}return o}function ng(e){let r=e.border?.fg,o=e.border?.bg,n=e.header?.fg,t=e.header?.bg,i=e.cell?.fg,a=e.cell?.bg,s=e.altRowBg,l=e.selected?.fg,u=e.selected?.bg;return {...r!==void 0?{borderFg:r}:{},...o!==void 0?{borderBg:o}:{},...n!==void 0?{headerFg:n}:{},...t!==void 0?{headerBg:t}:{},...i!==void 0?{cellFg:i}:{},...a!==void 0?{cellBg:a}:{},...s!==void 0?{altRowBg:s}:{},...l!==void 0?{selectedFg:l}:{},...u!==void 0?{selectedBg:u}:{}}}function Ss(e,r,o={}){let n=rg.parse(o),t=r;U(e,t,n.x,n.y),n.width!==void 0&&f(e,t,n.width,n.height),xb$1(e,t,{headerRows:n.headerRows,pad:n.pad,cellBorders:n.cellBorders}),n.data.length>0&&Ab$1(e,t,n.data),n.columns&&Ob$1(e,t,n.columns),n.style&&Ub$1(e,t,ng(n.style));let i=tg(n.data,n.headerRows);ga$1(e,t,i,{interactive:n.interactive,mouse:n.mouse,keys:n.keys,search:n.search,selectedIndex:n.selected,visibleCount:Math.max(1,n.height-n.headerRows)});let a=()=>{let l=Cb$1(e,t),u=Tb$1(e,t),d=tg(l,u);q$4(e,t,d);},s={eid:t,show(){return ra$1(e,t,true),s},hide(){return ra$1(e,t,false),s},move(l,u){return T$1.x[t]=(T$1.x[t]??0)+l,T$1.y[t]=(T$1.y[t]??0)+u,oa$1(e,t),s},setPosition(l,u){return U(e,t,l,u),s},focus(){return na$1(e,t),s},blur(){return oa$2(e,t),s},setData(l){return Ab$1(e,t,l),a(),s},getData(){return Cb$1(e,t)},getFullData(){return Bb$1(e,t)},clearData(){return Nb$1(e,t),a(),s},setCell(l,u,d){return Db$1(e,t,l,u,d),a(),s},getCell(l,u){return Eb$1(e,t,l,u)},getCellValue(l,u){return Fb$1(e,t,l,u)},getRow(l){return Gb$1(e,t,l)},getRowCount(){return Ib$1(e,t)},getDataRowCount(){return Math.max(0,Ib$1(e,t)-Tb$1(e,t))},setColumns(l){return Ob$1(e,t,l),s},getColumns(){return Pb$1(e,t)},getColCount(){return Jb$1(e,t)},setHeaderRowCount(l){return Sb$1(e,t,l),a(),s},getHeaderRowCount(){return Tb$1(e,t)},getHeaderRows(){return Qb$1(e,t)},getDataRows(){return Rb$1(e,t)},setCellPadding(l){return Yb$1(e,t,l),s},getCellPadding(){return Xb$1(e,t)},setCellBorders(l){return _b$1(e,t,l),s},hasCellBorders(){return Zb$1(e,t)},setStyle(l){return Ub$1(e,t,ng(l)),oa$1(e,t),s},getDisplay(){return Vb$1(e,t)},select(l){return U$1(e,t,l),s},getSelectedIndex(){return S(t)},getSelectedRow(){let l=S(t);if(l<0)return;let u=Tb$1(e,t);return Gb$1(e,t,u+l)},selectPrev(){return V(e,t),s},selectNext(){return W(e,t),s},selectFirst(){return X$1(e,t),s},selectLast(){return Y$1(e,t),s},activate(){return $(e,t),s},pageUp(){return C$1(e,t,-1),s},pageDown(){return C$1(e,t,1),s},startSearch(){return Na(e,t),s},endSearch(){return Oa(e,t),s},getSearchQuery(){return Pa(t)},isSearching(){return Ma(e,t)},getState(){return ia$1(e,t)},onSelect(l){return aa$1(t,l)},onActivate(l){return ba$1(t,l)},onSearchChange(l){return Wa$1(t,l)},handleKey(l){let u=Xa$1(e,t,l);if(u)switch(u.type){case "selectPrev":V(e,t);break;case "selectNext":W(e,t);break;case "selectFirst":X$1(e,t);break;case "selectLast":Y$1(e,t);break;case "pageUp":C$1(e,t,-1);break;case "pageDown":C$1(e,t,1);break;case "confirm":$(e,t);break;case "cancel":oa$2(e,t);break;case "startSearch":Na(e,t);break;case "endSearch":Oa(e,t);break;case "searchChar":Ra(e,t,u.char);break;case "searchBackspace":Sa$1(e,t);break;case "searchNextMatch":Va(e,t);break}return u},destroy(){ea$1(t),Ta(e,t),zb$1(e,t),e$2(e,t);}};return s}function Nx(e,r){return yb$1(e,r)}n();var Gx=4294967295,wx=0,og=z.object({fg:z.number().int().optional(),bg:z.number().int().optional()}),ig=z.object({x:z.number().int().default(0),y:z.number().int().default(0),message:z.string().default("Loading..."),spinnerChars:z.array(z.string()).readonly().optional(),interval:z.number().int().positive().default(100),style:og.optional(),width:z.number().int().positive().optional(),visible:z.boolean().default(true)}),zn=new Map,Cr=new Map;function ra(e,r={}){let o=ig.parse(r),n=d$1(e);U(e,n,o.x,o.y);let t=o.message,i=o.spinnerChars??_a,a=Math.max(...i.map(l=>l.length)),s=o.width??t.length+a+1;return f(e,n,s,1),eb$1(e,n,{frames:i,interval:o.interval}),zn.set(n,t),Cr.set(n,o.visible),lo(e,n),o.visible||ra$1(e,n,false),zx(e,n)}function zx(e,r){return {get eid(){return r},show(){return Cr.set(r,true),ra$1(e,r,true),oa$1(e,r),this},hide(){return Cr.set(r,false),ra$1(e,r,false),oa$1(e,r),this},isVisible(){return Cr.get(r)??false},move(o,n){let t=T$1.x[r]??0,i=T$1.y[r]??0;return U(e,r,t+o,i+n),oa$1(e,r),this},setPosition(o,n){return U(e,r,o,n),oa$1(e,r),this},getPosition(){return {x:T$1.x[r]??0,y:T$1.y[r]??0}},setMessage(o){return zn.set(r,o),lo(e,r),oa$1(e,r),this},getMessage(){return zn.get(r)??""},setSpinnerChars(o){return kb$1(r,o),lo(e,r),oa$1(e,r),this},setInterval(o){return jb$1(r,o),this},getSpinnerChar(){return hb$1(r)},reset(){return nb$1(r),lo(e,r),oa$1(e,r),this},destroy(){fb$1(e,r),zn.delete(r),Cr.delete(r),e$2(e,r);}}}function lo(e,r){let o=zn.get(r)??"",t=`${hb$1(r)} ${o}`;e$1(e,r,t);}function Hx(e,r,o={}){return ra(e,{...o,message:r,visible:true})}function Ux(e){e.destroy();}function $x(e,r){e.setMessage(r);}function ag(e,r){return gb$1(e,r)&&zn.has(r)}function jx(e,r,o){if(!ag(e,r))return false;let n=mb$2(r,o);return n&&(lo(e,r),oa$1(e,r)),n}function Yx(){zn.clear(),Cr.clear();}u();n();t();var sg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),oa=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Qx=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),Xx=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),qx=z.union([z.boolean(),z.object({mode:z.enum(["auto","visible","hidden"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),trackChar:z.string().optional(),thumbChar:z.string().optional()})]).optional(),cg=z.object({left:oa.optional(),top:oa.optional(),right:oa.optional(),bottom:oa.optional(),width:sg.optional(),height:sg.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:Qx,padding:Xx,scrollbar:qx,mouse:z.boolean().optional(),keys:z.boolean().optional(),scrollback:z.number().int().positive().optional(),scrollOnInput:z.boolean().optional(),timestamps:z.boolean().optional(),timestampFormat:z.string().optional()}),Hn=1e4,ue={isLog:new Uint8Array(Hn),mouseEnabled:new Uint8Array(Hn),keysEnabled:new Uint8Array(Hn),scrollOnInput:new Uint8Array(Hn),timestamps:new Uint8Array(Hn),scrollback:new Uint32Array(Hn),lineCount:new Uint32Array(Hn)},Dn=new Map;function Jx(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$2;case "bold":return e$3;case "ascii":return f$3}}function Zx(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function lg(e){return e===void 0?0:typeof e=="number"?e:0}function ug(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function eS(e){switch(e){case "auto":return 2;case "visible":return 1;case "hidden":return 0}}function tS(...e){if(e.length===0)return "";if(e.length===1)return String(e[0]);let r=String(e[0]),o=1;return r.replace(/%([sdfjioO%])/g,(n,t)=>{if(t==="%")return "%";if(o>=e.length)return n;let i=e[o++];switch(t){case "s":return String(i);case "d":case "i":return typeof i=="number"?Math.floor(i).toString():"NaN";case "f":return typeof i=="number"?i.toString():"NaN";case "j":case "o":case "O":try{return JSON.stringify(i)}catch{return "[Circular]"}default:return n}})}function nS(e){return h$4(new Date,e)}function dg(e,r){let o=Dn.get(r);if(!o)return;let n=o.lines.join(`
14
+ `);e$1(e,r,n);let t=o.lines.length;u$1(e,r,0,t),ue.lineCount[r]=t,oa$1(e,r);}function rS(e){let r=Dn.get(e);if(!r)return;let o=ue.scrollback[e]??0;if(o!==0)for(;r.lines.length>o;)r.lines.shift();}function oS(e,r){ue.isLog[e]=1,ue.scrollback[e]=r.scrollback??1e3,ue.scrollOnInput[e]=r.scrollOnInput!==false?1:0,ue.timestamps[e]=r.timestamps?1:0,ue.mouseEnabled[e]=r.mouse!==false?1:0,ue.keysEnabled[e]=r.keys!==false?1:0,ue.lineCount[e]=0,Dn.set(e,{lines:[],timestampFormat:r.timestampFormat??"HH:mm:ss"});}function iS(e,r,o){let n=lg(o.left),t=lg(o.top);U(e,r,n,t);let i=ug(o.width),a=ug(o.height);f(e,r,i,a);}function aS(e,r,o){o.fg===void 0&&o.bg===void 0||la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function sS(e,r,o){let n=o.type?Zx(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?Jx(o.ch):o.ch;m$1(e,r,t);}}function lS(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function uS(e,r,o){let n=2;o.scrollbar===false?n=0:typeof o.scrollbar=="object"&&o.scrollbar.mode&&(n=eS(o.scrollbar.mode)),l$1(e,r,{alwaysScroll:true,scrollbarVisible:n});}function dS(e,r$1,o$1={}){let n=cg.parse(o$1),t=r$1;oS(t,n),iS(e,t,n),aS(e,t,n),n.border&&sS(e,t,n.border),n.padding!==void 0&&lS(e,t,n.padding),uS(e,t,n),d(e,t,{focusable:true}),e$1(e,t,"");let i$1={eid:t,log(...a){let s=Dn.get(t);if(!s)return i$1;let l=tS(...a);return ue.timestamps[t]===1&&(l=`[${nS(s.timestampFormat)}] ${l}`),s.lines.push(l),rS(t),dg(e,t),ue.scrollOnInput[t]===1&&y(e,t),i$1},clear(){let a=Dn.get(t);return a&&(a.lines=[],ue.lineCount[t]=0,dg(e,t),x(e,t)),i$1},getLines(){let a=Dn.get(t);return a?[...a.lines]:[]},getLineCount(){return ue.lineCount[t]??0},show(){return ra$1(e,t,true),i$1},hide(){return ra$1(e,t,false),i$1},move(a,s){return Z$1(e,t,a,s),oa$1(e,t),i$1},setPosition(a,s){return U(e,t,a,s),oa$1(e,t),i$1},focus(){return h(e,t),i$1},blur(){return i(e,t),i$1},isFocused(){return f$1(e,t)},append(a){return q$2(e,t,a),i$1},getChildren(){return s$1(e,t)},scrollTo(a,s){return p(e,t,a,s),oa$1(e,t),i$1},scrollBy(a,s){return o(e,t,a,s),oa$1(e,t),i$1},setScrollPerc(a,s){return r(e,t,a,s),oa$1(e,t),i$1},getScrollPerc(){return q$3(e,t)},getScroll(){return n$1(e,t)},setViewport(a,s){return v(e,t,a,s),oa$1(e,t),i$1},getScrollable(){return s$2(e,t)},scrollToTop(){return x(e,t),oa$1(e,t),i$1},scrollToBottom(){return y(e,t),oa$1(e,t),i$1},scrollToLeft(){return z$2(e,t),oa$1(e,t),i$1},scrollToRight(){return A(e,t),oa$1(e,t),i$1},canScroll(){return B(e,t)},canScrollX(){return C(e,t)},canScrollY(){return D(e,t)},isAtTop(){return E(e,t)},isAtBottom(){return F(e,t)},isAtLeft(){return G(e,t)},isAtRight(){return H(e,t)},destroy(){ue.isLog[t]=0,ue.mouseEnabled[t]=0,ue.keysEnabled[t]=0,ue.scrollOnInput[t]=0,ue.timestamps[t]=0,ue.scrollback[t]=0,ue.lineCount[t]=0,Dn.delete(t),e$2(e,t);}};return i$1}function cS(e,r){return ue.isLog[r]===1}function gS(e,r){return ue.mouseEnabled[r]===1}function mS(e,r){return ue.keysEnabled[r]===1}function fS(e,r){return ue.scrollback[r]??0}function bS(){ue.isLog.fill(0),ue.mouseEnabled.fill(0),ue.keysEnabled.fill(0),ue.scrollOnInput.fill(0),ue.timestamps.fill(0),ue.scrollback.fill(0),ue.lineCount.fill(0),Dn.clear();}u();n();t();var gg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),pS=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),ia=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),borderFg:z.union([z.string(),z.number()]).optional()}).optional(),mg=z.object({left:gg.optional(),top:gg.optional(),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),content:z.string().optional(),timeout:z.number().int().nonnegative().optional(),dismissOnClick:z.boolean().optional(),dismissOnKey:z.boolean().optional(),type:z.enum(["info","warning","error","success"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:pS,padding:z.number().int().nonnegative().optional(),infoStyle:ia,warningStyle:ia,errorStyle:ia,successStyle:ia}),fg=3e3,Cs=1,bg={info:{fg:"#ffffff",bg:"#2196f3",borderFg:"#64b5f6"},warning:{fg:"#000000",bg:"#ff9800",borderFg:"#ffb74d"},error:{fg:"#ffffff",bg:"#f44336",borderFg:"#e57373"},success:{fg:"#ffffff",bg:"#4caf50",borderFg:"#81c784"}},aa=1e4,Ie={isMessage:new Uint8Array(aa),dismissOnClick:new Uint8Array(aa),dismissOnKey:new Uint8Array(aa),dismissed:new Uint8Array(aa)},Gt=new Map;function yS(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$2;case "bold":return e$3;case "ascii":return f$3}}function hS(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function pg(e,r){return {info:r.infoStyle,warning:r.warningStyle,error:r.errorStyle,success:r.successStyle}[e]??bg[e]}function xS(e,r){let o=e.split(`
15
+ `),n=Math.max(...o.map(s=>s.length),10),t=o.length,i=n+r*2+2,a=t+r*2+2;return {width:i,height:a}}function SS(e,r){Ie.isMessage[e]=1,Ie.dismissOnClick[e]=r.dismissOnClick!==false?1:0,Ie.dismissOnKey[e]=r.dismissOnKey!==false?1:0,Ie.dismissed[e]=0,Gt.set(e,{content:r.content??""});}function CS(e,r,o){let n=o.content??"",t=o.padding??Cs,{width:i,height:a}=xS(n,t),s=o.width??i,l=o.height??a;f(e,r,s,l);let u=0,d=0;o.left!==void 0&&(typeof o.left=="number"?u=o.left:o.left==="center"&&(u=0)),o.top!==void 0&&(typeof o.top=="number"?d=o.top:o.top==="center"&&(d=0)),U(e,r,u,d);}function WS(e,r,o){let n=o.type??"info",t=pg(n,o),i=o.fg??t.fg,a=o.bg??t.bg;(i!==void 0||a!==void 0)&&la$1(e,r,{fg:i!==void 0?s(i):void 0,bg:a!==void 0?s(a):void 0});}function TS(e,r,o){let n=o.type??"info",t=pg(n,o),i=o.border?.type?hS(o.border.type):1,a=o.border?.fg??t.borderFg;l(e,r,{type:i,fg:a!==void 0?s(a):void 0,bg:o.border?.bg!==void 0?s(o.border.bg):void 0});let s$1=o.border?.ch?typeof o.border.ch=="string"?yS(o.border.ch):o.border.ch:d$2;m$1(e,r,s$1);}function vS(e,r,o){let n=o.content??"";e$1(e,r,n,{align:1,valign:1});}function LS(e,r,o,n){let t=o.timeout??fg;if(t<=0)return;let i=Gt.get(r);i&&(i.timerId=setTimeout(()=>{n();},t));}function uo(e,r={}){let o=mg.parse(r),n=d$1(e);SS(n,o),CS(e,n,o),WS(e,n,o),TS(e,n,o),vS(e,n,o);let t=o.padding??Cs;b(e,n,{left:t,top:t,right:t,bottom:t}),d(e,n,{focusable:true});let i=()=>{if(Ie.dismissed[n]===1)return;Ie.dismissed[n]=1,ra$1(e,n,false);let s=Gt.get(n);s&&(s.timerId&&(clearTimeout(s.timerId),s.timerId=void 0),s.onDismissCallback&&s.onDismissCallback());};LS(e,n,o,i);let a={eid:n,setContent(s){let l=Gt.get(n);return l&&(l.content=s),e$1(e,n,s,{align:1,valign:1}),oa$1(e,n),a},getContent(){return Gt.get(n)?.content??""},show(){return ra$1(e,n,true),a},hide(){return ra$1(e,n,false),a},move(s,l){return Z$1(e,n,s,l),oa$1(e,n),a},setPosition(s,l){return U(e,n,s,l),oa$1(e,n),a},center(s,l){let u=g(e,n),d=u?.width??20,b=u?.height??5,f=Math.floor((s-d)/2),c=Math.floor((l-b)/2);return U(e,n,f,c),oa$1(e,n),a},dismiss:i,isDismissed(){return Ie.dismissed[n]===1},onDismiss(s){let l=Gt.get(n);return l&&(l.onDismissCallback=s),a},destroy(){let s=Gt.get(n);s?.timerId&&clearTimeout(s.timerId),Ie.isMessage[n]=0,Ie.dismissOnClick[n]=0,Ie.dismissOnKey[n]=0,Ie.dismissed[n]=0,Gt.delete(n),e$2(e,n);}};return a}function ES(e,r,o={}){return uo(e,{...o,content:r,type:"info"})}function BS(e,r,o={}){return uo(e,{...o,content:r,type:"warning"})}function PS(e,r,o={}){return uo(e,{...o,content:r,type:"error"})}function MS(e,r,o={}){return uo(e,{...o,content:r,type:"success"})}function Ws(e,r){return Ie.isMessage[r]===1}function yg(e,r){return Ie.dismissOnClick[r]===1}function hg(e,r){return Ie.dismissOnKey[r]===1}function DS(e,r){if(!Ws(e,r)||!yg(e,r)||Ie.dismissed[r]===1)return false;let o=Gt.get(r);return o&&(Ie.dismissed[r]=1,ra$1(e,r,false),o.timerId&&(clearTimeout(o.timerId),o.timerId=void 0),o.onDismissCallback&&o.onDismissCallback()),true}function FS(e,r){if(!Ws(e,r)||!hg(e,r)||Ie.dismissed[r]===1)return false;let o=Gt.get(r);return o&&(Ie.dismissed[r]=1,ra$1(e,r,false),o.timerId&&(clearTimeout(o.timerId),o.timerId=void 0),o.onDismissCallback&&o.onDismissCallback()),true}function AS(){for(let e of Gt.values())e.timerId&&clearTimeout(e.timerId);Ie.isMessage.fill(0),Ie.dismissOnClick.fill(0),Ie.dismissOnKey.fill(0),Ie.dismissed.fill(0),Gt.clear();}u();n();t();var Ts=1e4,IS=40,kS=10,RS=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),VS=z.union([z.number().nonnegative(),z.object({left:z.number().nonnegative().optional(),top:z.number().nonnegative().optional(),right:z.number().nonnegative().optional(),bottom:z.number().nonnegative().optional()})]),xg=z.object({backdrop:z.boolean().optional().default(true),backdropColor:z.union([z.string(),z.number()]).optional().default("#000000"),backdropOpacity:z.number().min(0).max(1).optional().default(.5),closeOnBackdropClick:z.boolean().optional().default(true),closeOnEscape:z.boolean().optional().default(true),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),left:z.number().int().optional(),top:z.number().int().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:RS.optional(),padding:VS.optional(),content:z.string().optional()}),Fe={isModal:new Uint8Array(Ts),isOpen:new Uint8Array(Ts),backdropEnabled:new Uint8Array(Ts)},Ft=new Map,mn=[];function OS(e){if(typeof e=="object")return e;switch(e){case "double":return c;case "rounded":return d$2;case "bold":return e$3;case "ascii":return f$3;default:return b$1}}function _S(e){return e==="bg"?2:e==="none"?0:1}function NS(e,r,o){if(typeof o=="number"){b(e,r,{left:o,top:o,right:o,bottom:o});return}if(o){b(e,r,{left:o.left??0,top:o.top??0,right:o.right??0,bottom:o.bottom??0});return}}function GS(e){let r=mn.indexOf(e);r!==-1&&mn.splice(r,1),mn.push(e);}function vs(e){let r=mn.indexOf(e);r!==-1&&mn.splice(r,1);}function wS(e,r,o,n){o===void 0&&n===void 0||la$1(e,r,{fg:o!==void 0?s(o):void 0,bg:n!==void 0?s(n):void 0});}function zS(e,r,o){o?.type!=="none"&&(l(e,r,{type:_S(o?.type),fg:o?.fg!==void 0?s(o.fg):void 0,bg:o?.bg!==void 0?s(o.bg):void 0}),m$1(e,r,OS(o?.ch)));}function Sg(e,r={}){let o=xg.parse(r),n=d$1(e),t=o.width??IS,i=o.height??kS;return Fe.isModal[n]=1,Fe.isOpen[n]=0,Fe.backdropEnabled[n]=o.backdrop?1:0,Ft.set(n,{content:o.content??"",backdropColor:s(o.backdropColor),backdropOpacity:o.backdropOpacity,closeOnBackdropClick:o.closeOnBackdropClick,closeOnEscape:o.closeOnEscape,width:t,height:i,onCloseCallbacks:[],onOpenCallbacks:[]}),U(e,n,o.left??0,o.top??0),f(e,n,t,i),wS(e,n,o.fg,o.bg),zS(e,n,o.border),NS(e,n,o.padding),o.content&&e$1(e,n,o.content,{align:0,valign:0}),ra$1(e,n,false),HS(e,n)}function HS(e,r){let o={eid:r,show(){Fe.isOpen[r]=1,ra$1(e,r,true),GS(r),oa$1(e,r);let n=Ft.get(r);if(n)for(let t of n.onOpenCallbacks)t();return o},hide(){return Fe.isOpen[r]=0,ra$1(e,r,false),vs(r),oa$1(e,r),o},move(n,t){return Z$1(e,r,n,t),oa$1(e,r),o},setPosition(n,t){return U(e,r,n,t),oa$1(e,r),o},center(n,t){let i=Ft.get(r);if(!i)return o;let a=Math.max(0,Math.floor((n-i.width)/2)),s=Math.max(0,Math.floor((t-i.height)/2));return U(e,r,a,s),oa$1(e,r),o},setContent(n){let t=Ft.get(r);return t&&(t.content=n),e$1(e,r,n,{align:0,valign:0}),oa$1(e,r),o},getContent(){return Ft.get(r)?.content??""},close(){if(Fe.isOpen[r]===0)return;Fe.isOpen[r]=0,ra$1(e,r,false),vs(r),oa$1(e,r);let n=Ft.get(r);if(n)for(let t of n.onCloseCallbacks)t();},isOpen(){return Fe.isOpen[r]===1},onClose(n){let t=Ft.get(r);return t&&t.onCloseCallbacks.push(n),o},onOpen(n){let t=Ft.get(r);return t&&t.onOpenCallbacks.push(n),o},destroy(){Fe.isOpen[r]===1&&o.close(),Fe.isModal[r]=0,Fe.isOpen[r]=0,Fe.backdropEnabled[r]=0,Ft.delete(r),e$2(e,r);}};return o}function US(e,r={}){let o=Sg(e,r);return o.show(),o}function sa(e,r){if(Fe.isModal[r]!==1||Fe.isOpen[r]===0)return;Fe.isOpen[r]=0,ra$1(e,r,false),vs(r),oa$1(e,r);let o=Ft.get(r);if(o)for(let n of o.onCloseCallbacks)n();}function $S(e){let r=[...mn];for(let o=r.length-1;o>=0;o--){let n=r[o];sa(e,n);}}function jS(e){return mn.length>0}function YS(e){return [...mn]}function KS(e,r){return Fe.isModal[r]===1}function QS(){Fe.isModal.fill(0),Fe.isOpen.fill(0),Fe.backdropEnabled.fill(0),Ft.clear(),mn.length=0;}function XS(e,r){return Fe.isModal[r]!==1||Fe.isOpen[r]!==1||!Ft.get(r)?.closeOnBackdropClick?false:(sa(e,r),true)}function qS(e,r){return Fe.isModal[r]!==1||Fe.isOpen[r]!==1||!Ft.get(r)?.closeOnEscape?false:(sa(e,r),true)}n();var JS=30,ZS=10,Ls=1e4,eC="[x]",tC="[ ]",Tg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(JS),height:z.number().int().positive().default(ZS),items:z.array(z.union([z.string(),z.object({text:z.string(),value:z.string().optional(),disabled:z.boolean().optional()})])).default([]),selected:z.array(z.number().int().nonnegative()).default([]),fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),cursorFg:z.number().int().nonnegative().optional(),cursorBg:z.number().int().nonnegative().optional(),selectedFg:z.number().int().nonnegative().optional(),selectedBg:z.number().int().nonnegative().optional(),disabledFg:z.number().int().nonnegative().optional(),filterable:z.boolean().default(true)}),ot={isMultiSelect:new Uint8Array(Ls),visible:new Uint8Array(Ls),focused:new Uint8Array(Ls)},go=new Map;function Cg(e,r,o,n){o==="up"?n?e.rangeSelectTo(Math.max(0,r.cursorIndex-1)):(e.cursorUp(),r.rangeAnchor=r.cursorIndex):n?e.rangeSelectTo(Math.min(r.filteredIndices.length-1,r.cursorIndex+1)):(e.cursorDown(),r.rangeAnchor=r.cursorIndex);}function nC(e,r,o,n){return o==="up"||o==="k"?(Cg(e,r,"up",n),true):o==="down"||o==="j"?(Cg(e,r,"down",n),true):o==="home"||o==="g"?(e.cursorFirst(),true):o==="end"||o==="G"?(e.cursorLast(),true):o==="pageup"?(e.pageUp(),true):o==="pagedown"?(e.pageDown(),true):false}function rC(e,r,o,n){return r.filterable&&o.length===1&&!n?(r.filterQuery+=o,Wr(r),true):r.filterable&&o==="backspace"?(r.filterQuery.length>0&&(r.filterQuery=r.filterQuery.slice(0,-1),Wr(r)),true):o==="escape"?(r.filterQuery.length>0?(r.filterQuery="",Wr(r)):e.blur(),true):false}function oC(e,r,o,n,t){return n&&o==="a"?(r.selected.size===r.items.length?e.deselectAll():e.selectAll(),true):nC(e,r,o,t)?true:o===" "?(e.toggleCurrent(),true):rC(e,r,o,n)}function Wg(e){return e.map(r=>typeof r=="string"?{text:r,value:r}:{...r,value:r.value??r.text})}function Wr(e){if(e.filterQuery.length===0){e.filteredIndices=e.items.map((o,n)=>n);return}let r=e.filterQuery.toLowerCase();e.filteredIndices=[];for(let o=0;o<e.items.length;o++)e.items[o]?.text.toLowerCase().includes(r)&&e.filteredIndices.push(o);e.filteredIndices.length===0?e.cursorIndex=-1:e.cursorIndex>=e.filteredIndices.length?e.cursorIndex=e.filteredIndices.length-1:e.cursorIndex<0&&(e.cursorIndex=0),e.firstVisible=0;}function co(e){let r=Array.from(e.selected).sort((n,t)=>n-t),o=r.map(n=>e.items[n]).filter(n=>n!==void 0);for(let n of e.selectionCallbacks)n(r,o);}function Es(e,r){return e.filteredIndices[r]??-1}function Un(e){e.cursorIndex<e.firstVisible?e.firstVisible=e.cursorIndex:e.cursorIndex>=e.firstVisible+e.visibleCount&&(e.firstVisible=e.cursorIndex-e.visibleCount+1);}function iC(e,r){let o=new Set;for(let n of r){if(n<0||n>=e.length)continue;let t=e[n];t&&!t.disabled&&o.add(n);}return o}function aC(e,r){let o=iC(e,r.selected),n=r.filterable?1:0,t=Math.max(1,r.height-n);return {items:e,selected:o,cursorIndex:e.length>0?0:-1,rangeAnchor:0,filterQuery:"",filteredIndices:e.map((i,a)=>a),filterable:r.filterable,firstVisible:0,visibleCount:t,width:r.width,fg:r.fg??4294967295,bg:r.bg??255,cursorFg:r.cursorFg??255,cursorBg:r.cursorBg??8978431,selectedFg:r.selectedFg??16711935,selectedBg:r.selectedBg??255,disabledFg:r.disabledFg??2290649343,selectionCallbacks:[]}}function sC(e,r){let o=Es(e,r);if(o<0)return;let n=e.items[o];if(!n)return;let t=e.selected.has(o)?eC:tC,i=r===e.cursorIndex?">":" ",a=Math.max(0,e.width-6),s=n.text.length>a?`${n.text.slice(0,a-1)}~`:n.text;return `${i} ${t} ${s}`}function lC(e,r={}){let o=Tg.parse(r),n=d$1(e);ot.isMultiSelect[n]=1,ot.visible[n]=1,ot.focused[n]=0;let t=Wg(o.items),i=aC(t,o);go.set(n,i);let a={eid:n,show(){return ot.visible[n]=1,a},hide(){return ot.visible[n]=0,a},focus(){return ot.focused[n]=1,a},blur(){return ot.focused[n]=0,a},isFocused(){return ot.focused[n]===1},select(s){return s>=0&&s<i.filteredIndices.length&&(i.cursorIndex=s,i.rangeAnchor=s,Un(i)),a},getCursorIndex(){return i.cursorIndex},cursorUp(){return i.cursorIndex>0&&(i.cursorIndex--,Un(i)),a},cursorDown(){return i.cursorIndex<i.filteredIndices.length-1&&(i.cursorIndex++,Un(i)),a},cursorFirst(){return i.filteredIndices.length>0&&(i.cursorIndex=0,i.firstVisible=0),a},cursorLast(){return i.filteredIndices.length>0&&(i.cursorIndex=i.filteredIndices.length-1,Un(i)),a},pageUp(){return i.cursorIndex=Math.max(0,i.cursorIndex-i.visibleCount),Un(i),a},pageDown(){return i.cursorIndex=Math.min(i.filteredIndices.length-1,i.cursorIndex+i.visibleCount),Un(i),a},toggleCurrent(){if(i.cursorIndex<0||i.cursorIndex>=i.filteredIndices.length)return a;let s=Es(i,i.cursorIndex);return s<0||i.items[s]?.disabled||(i.selected.has(s)?i.selected.delete(s):i.selected.add(s),i.rangeAnchor=i.cursorIndex,co(i)),a},toggleItem(s){return s<0||s>=i.items.length||i.items[s]?.disabled||(i.selected.has(s)?i.selected.delete(s):i.selected.add(s),co(i)),a},selectAll(){for(let s=0;s<i.items.length;s++){let l=i.items[s];l&&!l.disabled&&i.selected.add(s);}return co(i),a},deselectAll(){return i.selected.clear(),co(i),a},rangeSelectTo(s){if(s<0||s>=i.filteredIndices.length)return a;let l=Math.min(i.rangeAnchor,s),u=Math.max(i.rangeAnchor,s);for(let d=l;d<=u;d++){let b=Es(i,d);if(b>=0){let f=i.items[b];f&&!f.disabled&&i.selected.add(b);}}return i.cursorIndex=s,Un(i),co(i),a},getSelectedIndices(){return Array.from(i.selected).sort((s,l)=>s-l)},getSelectedItems(){return Array.from(i.selected).sort((s,l)=>s-l).map(s=>i.items[s]).filter(s=>s!==void 0)},getSelectedCount(){return i.selected.size},getSelectionStatus(){let s=i.selected.size;return s===0?"None selected":`${s} selected`},isSelected(s){return i.selected.has(s)},setItems(s){i.items=Wg(s);for(let l of i.selected)l>=i.items.length&&i.selected.delete(l);return Wr(i),i.cursorIndex>=i.filteredIndices.length&&(i.cursorIndex=Math.max(0,i.filteredIndices.length-1)),a},getItems(){return i.items},getVisibleItems(){return i.filteredIndices.map(s=>i.items[s]).filter(s=>s!==void 0)},setFilter(s){return i.filterQuery=s,Wr(i),a},getFilter(){return i.filterQuery},clearFilter(){return i.filterQuery="",Wr(i),a},getRenderLines(){let s=[],l=i.firstVisible,u=Math.min(l+i.visibleCount,i.filteredIndices.length);for(let d=l;d<u;d++){let b=sC(i,d);b!==void 0&&s.push(b);}return s},onSelectionChange(s){return i.selectionCallbacks.push(s),()=>{let l=i.selectionCallbacks.indexOf(s);l!==-1&&i.selectionCallbacks.splice(l,1);}},handleKey(s,l=false,u=false){return oC(a,i,s,l,u)},destroy(){ot.isMultiSelect[n]=0,ot.visible[n]=0,ot.focused[n]=0,go.delete(n),e$2(e,n);}};return a}function uC(e,r){let o=go.get(r);return o?Array.from(o.selected).sort((n,t)=>n-t).map(n=>o.items[n]).filter(n=>n!==void 0):[]}function dC(e,r,o){let n=go.get(r);return n?(n.selectionCallbacks.push(o),()=>{let t=n.selectionCallbacks.indexOf(o);t!==-1&&n.selectionCallbacks.splice(t,1);}):()=>{}}function cC(e,r){return ot.isMultiSelect[r]===1}function gC(){ot.isMultiSelect.fill(0),ot.visible.fill(0),ot.focused.fill(0),go.clear();}u();n();t();z.object({title:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional(),align:z.enum(["left","center","right"]).optional()}).optional(),content:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional(),border:z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.unknown()]).optional()}).optional()});var la="",Pg="\u2715",Mg="\u25BC",Dg="\u25B6",vg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Lg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),mC=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),fC=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),align:z.enum(["left","center","right"]).optional()}),bC=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),pC=z.object({title:fC.optional(),content:bC.optional(),border:mC.optional()}),yC=z.union([z.number().nonnegative(),z.object({left:z.number().nonnegative().optional(),top:z.number().nonnegative().optional(),right:z.number().nonnegative().optional(),bottom:z.number().nonnegative().optional()})]),Fg=z.object({left:vg.optional(),top:vg.optional(),width:Lg.optional(),height:Lg.optional(),title:z.string().optional(),titleAlign:z.enum(["left","center","right"]).optional(),closable:z.boolean().optional(),collapsible:z.boolean().optional(),collapsed:z.boolean().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),style:pC.optional(),padding:yC.optional(),content:z.string().optional()}),Tr=1e4,X={isPanel:new Uint8Array(Tr),collapsed:new Uint8Array(Tr),closable:new Uint8Array(Tr),collapsible:new Uint8Array(Tr),originalHeight:new Float32Array(Tr),titleAlign:new Uint8Array(Tr)},Fn=new Map,mo=new Map;function Eg(e){return e===void 0?0:typeof e=="number"?e:0}function Bg(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function hC(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function Ag(e){switch(e){case 0:return "left";case 1:return "center";case 2:return "right";default:return "left"}}function xC(e){return typeof e=="number"?{left:e,top:e+1,right:e,bottom:e}:e?{left:e.left??0,top:(e.top??0)+1,right:e.right??0,bottom:e.bottom??0}:{left:0,top:1,right:0,bottom:0}}function SC(e){return e===void 0||e==="single"?b$1:typeof e=="object"?e:b$1}function CC(e,r,o){(o.fg!==void 0||o.bg!==void 0)&&la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function WC(e,r,o){let n=o.style?.border;n?.type!=="none"&&l(e,r,{type:n?.type==="bg"?2:1,fg:n?.fg!==void 0?s(n.fg):void 0,bg:n?.bg!==void 0?s(n.bg):void 0}),m$1(e,r,SC(n?.ch));}function Bs(e,r,o={}){let n=Fg.parse(o),t=r;X.isPanel[t]=1,X.collapsed[t]=n.collapsed?1:0,X.closable[t]=n.closable?1:0,X.collapsible[t]=n.collapsible?1:0,X.titleAlign[t]=hC(n.titleAlign??n.style?.title?.align??"left"),Fn.set(t,n.title??la),mo.set(t,n.content??"");let i$1=Eg(n.left),a=Eg(n.top);U(e,t,i$1,a);let s=Bg(n.width),l=Bg(n.height);f(e,t,s,l);let u=g(e,t);X.originalHeight[t]=u?.height??10,CC(e,t,n),WC(e,t,n),b(e,t,xC(n.padding)),n.content&&e$1(e,t,n.content,{align:0,valign:0}),d(e,t,{focusable:true}),ra$1(e,t,true),n.collapsed&&f(e,t,s,3);let d$1={eid:t,show(){return ra$1(e,t,true),d$1},hide(){return ra$1(e,t,false),d$1},move(b,f){return Z$1(e,t,b,f),oa$1(e,t),d$1},setPosition(b,f){return U(e,t,b,f),oa$1(e,t),d$1},setTitle(b){return Fn.set(t,b),oa$1(e,t),d$1},getTitle(){return Fn.get(t)??la},setContent(b){return mo.set(t,b),e$1(e,t,b,{align:0,valign:0}),oa$1(e,t),d$1},getContent(){return mo.get(t)??""},collapse(){if(X.collapsible[t]===0||X.collapsed[t]===1)return d$1;let b=g(e,t);b&&(X.originalHeight[t]=b.height);let f$1=g(e,t);return f(e,t,f$1?.width??"auto",3),X.collapsed[t]=1,oa$1(e,t),d$1},expand(){if(X.collapsible[t]===0||X.collapsed[t]===0)return d$1;let b=X.originalHeight[t],f$1=g(e,t);return f(e,t,f$1?.width??"auto",b),X.collapsed[t]=0,oa$1(e,t),d$1},toggle(){return X.collapsed[t]===1?d$1.expand():d$1.collapse()},isCollapsed(){return X.collapsed[t]===1},isClosable(){return X.closable[t]===1},close(){X.closable[t]===1&&ra$1(e,t,false);},focus(){return h(e,t),d$1},blur(){return i(e,t),d$1},isFocused(){return f$1(e,t)},append(b){return q$2(e,t,b),d$1},getChildren(){return s$1(e,t)},destroy(){X.isPanel[t]=0,X.collapsed[t]=0,X.closable[t]=0,X.collapsible[t]=0,X.originalHeight[t]=0,X.titleAlign[t]=0,Fn.delete(t),mo.delete(t),e$2(e,t);}};return d$1}function TC(e,r){return X.isPanel[r]===1}function vC(e,r){return Fn.get(r)??la}function LC(e,r,o){return Fn.set(r,o),oa$1(e,r),r}function EC(e,r){return X.collapsed[r]===1}function BC(e,r){return Ag(X.titleAlign[r])}function PC(e,r,o){let n=Fn.get(r)??"",t=X.closable[r]===1,i=X.collapsible[r]===1,a=X.collapsed[r]===1,s=Ag(X.titleAlign[r]),l=(t?2:0)+(i?2:0),u=Math.max(0,o-l),d=n;d.length>u&&(d=`${d.slice(0,u-1)}\u2026`);let b="";i&&(b+=a?`${Dg} `:`${Mg} `),t&&(b+=`${Pg} `),b=b.trimEnd();let f=u-d.length,c=0,g=0;switch(s){case "left":g=f;break;case "center":c=Math.floor(f/2),g=f-c;break;case "right":c=f;break}return `${" ".repeat(c)}${d}${" ".repeat(g)}${b}`}function MC(){X.isPanel.fill(0),X.collapsed.fill(0),X.closable.fill(0),X.collapsible.fill(0),X.originalHeight.fill(0),X.titleAlign.fill(0),Fn.clear(),mo.clear();}n();function Ms(e){return Math.max(0,Math.min(100,e))}var kg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),height:z.number().int().positive().default(1),value:z.number().default(0).transform(e=>Ms(e)),fillChar:z.string().default("\u2588"),emptyChar:z.string().default("\u2591"),showPercentage:z.boolean().default(false),label:z.string().default(""),indeterminate:z.boolean().default(false)}),Ps=1e4,qe={isProgressBar:new Uint8Array(Ps),showPercentage:new Uint8Array(Ps),indeterminate:new Uint8Array(Ps)},Wt=new Map;function vr(e,r){let o=Wt.get(r);if(!o)return;let n=qe.indeterminate[r]===1,t=qe.showPercentage[r]===1,i=Math.floor(o.value/100*o.width),a=o.width-i,s=o.fillChar.repeat(i),l=o.emptyChar.repeat(a),u=s+l,d=u;n?d=u:o.label?d=`${u} ${o.label}`:t&&(d=`${u} ${Math.round(o.value)}%`),e$1(e,r,d);}function Ig(e,r){let o=Wt.get(e);if(o)for(let n of o.onChangeCallbacks)n(r);}function DC(e,r={}){let o=kg.parse(r),n=d$1(e);qe.isProgressBar[n]=1,qe.showPercentage[n]=o.showPercentage?1:0,qe.indeterminate[n]=o.indeterminate?1:0,f(e,n,o.width,o.height),U(e,n,o.x,o.y),Wt.set(n,{value:o.value,fillChar:o.fillChar,emptyChar:o.emptyChar,label:o.label,width:o.width,onChangeCallbacks:[]}),vr(e,n);let t={eid:n,setValue(i){let a=Wt.get(n);if(!a)return t;let s=Ms(i);return a.value=s,vr(e,n),oa$1(e,n),Ig(n,s),t},getValue(){return Wt.get(n)?.value??0},increment(i){let a=Wt.get(n);if(!a)return t;let s=Ms(a.value+i);return a.value=s,vr(e,n),oa$1(e,n),Ig(n,s),t},setLabel(i){let a=Wt.get(n);return a&&(a.label=i,vr(e,n),oa$1(e,n)),t},getLabel(){return Wt.get(n)?.label??""},showPercentage(i){return qe.showPercentage[n]=i?1:0,vr(e,n),oa$1(e,n),t},isPercentageShown(){return qe.showPercentage[n]===1},getFillChar(){return Wt.get(n)?.fillChar??"\u2588"},getEmptyChar(){return Wt.get(n)?.emptyChar??"\u2591"},setIndeterminate(i){return qe.indeterminate[n]=i?1:0,vr(e,n),oa$1(e,n),t},isIndeterminate(){return qe.indeterminate[n]===1},setPosition(i,a){return U(e,n,i,a),oa$1(e,n),t},move(i,a){return Z$1(e,n,i,a),oa$1(e,n),t},getPosition(){let i=Wt.get(n);return {x:T$1.x[n]??0,y:T$1.y[n]??0,width:i?.width??20,height:1}},onChange(i){let a=Wt.get(n);return a&&a.onChangeCallbacks.push(i),t},destroy(){qe.isProgressBar[n]=0,qe.showPercentage[n]=0,qe.indeterminate[n]=0,Wt.delete(n),e$2(e,n);}};return t}function FC(e,r){return qe.isProgressBar[r]===1}function AC(){qe.isProgressBar.fill(0),qe.showPercentage.fill(0),qe.indeterminate.fill(0),Wt.clear();}u();n();t();var IC=1e4,kC=4294967295,RC=255,Rg=40,Vg=5,Og=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),_g=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),Fs=z.object({message:z.string().default(""),defaultValue:z.string().default(""),placeholder:z.string().default(""),width:z.number().int().positive().default(Rg),height:z.number().int().positive().default(Vg),left:z.number().int().default(0),top:z.number().int().default(0),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:Og,padding:_g}),fo={isPrompt:new Uint8Array(IC)},it=new Map;function VC(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$2;case "bold":return e$3;case "ascii":return f$3}}function OC(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function _C(e,r,o,n){o===void 0&&n===void 0||la$1(e,r,{fg:o!==void 0?s(o):void 0,bg:n!==void 0?s(n):void 0});}function NC(e,r,o){let n=o.type?OC(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?VC(o.ch):o.ch;m$1(e,r,t);}}function GC(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function Ds(e,r){let o=it.get(r);if(!o)return;let n=o.value||o.placeholder,t=o.message?`${o.message}
16
+ ${n}`:n;e$1(e,r,t);}function Ng(e,r={}){let o=Fs.parse(r),n=d$1(e);return fo.isPrompt[n]=1,U(e,n,o.left,o.top),f(e,n,o.width,o.height),_C(e,n,o.fg,o.bg),o.border&&NC(e,n,o.border),o.padding!==void 0&&GC(e,n,o.padding),it.set(n,{message:o.message,value:o.defaultValue,placeholder:o.placeholder,visible:true,validator:r.validator,submitCallbacks:[],cancelCallbacks:[]}),Ds(e,n),wC(e,n)}function wC(e,r){let o={get eid(){return r},show(){let n=it.get(r);return n&&(n.visible=true),ra$1(e,r,true),oa$1(e,r),o},hide(){let n=it.get(r);return n&&(n.visible=false),ra$1(e,r,false),oa$1(e,r),o},move(n,t){let i=T$1.x[r]??0,a=T$1.y[r]??0;return U(e,r,i+n,a+t),oa$1(e,r),o},setPosition(n,t){return U(e,r,n,t),oa$1(e,r),o},center(n,t){if(!it.get(r))return o;let a=Fs.parse({}),s=a.width,l=a.height,u=Math.floor((n-s)/2),d=Math.floor((t-l)/2);return U(e,r,u,d),oa$1(e,r),o},setMessage(n){let t=it.get(r);return t&&(t.message=n,Ds(e,r),oa$1(e,r)),o},getMessage(){return it.get(r)?.message??""},setValue(n){let t=it.get(r);return t&&(t.value=n,Ds(e,r),oa$1(e,r)),o},getValue(){return it.get(r)?.value??""},submit(){let n=it.get(r);if(!n)return o;if(n.validator){let t=n.validator(n.value);if(t!==true&&typeof t=="string"||t===false)return o}for(let t of n.submitCallbacks)t(n.value);return o},cancel(){let n=it.get(r);if(!n)return o;for(let t of n.cancelCallbacks)t();return o},onSubmit(n){let t=it.get(r);return t&&t.submitCallbacks.push(n),o},onCancel(n){let t=it.get(r);return t&&t.cancelCallbacks.push(n),o},destroy(){fo.isPrompt[r]=0,it.delete(r),e$2(e,r);}};return o}function zC(e,r,o={}){return new Promise(n=>{let t=Ng(e,{...o,message:r});t.onSubmit(i=>{t.destroy(),n(i);}),t.onCancel(()=>{t.destroy(),n(null);});})}function HC(e){return fo.isPrompt[e]===1}function UC(){fo.isPrompt.fill(0),it.clear();}function $C(e,r){return r==="return"||r==="enter"?(e.submit(),true):r==="escape"?(e.cancel(),true):false}u();n();t();var jC=1e4,YC=4294967295,KC=0,Gg=40,wg=5,QC=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),XC=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),zg=z.object({message:z.string().default("Are you sure?"),yesText:z.string().default("Yes"),noText:z.string().default("No"),defaultAnswer:z.boolean().default(true),width:z.number().int().positive().default(Gg),height:z.number().int().positive().default(wg),left:z.number().int().default(0),top:z.number().int().default(0),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:QC,padding:XC}),bo={isQuestion:new Uint8Array(jC)},at=new Map;function qC(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$2;case "bold":return e$3;case "ascii":return f$3}}function JC(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function ua(e,r){let o=at.get(r);if(!o)return;let n=o.selectedAnswer?`[${o.yesText}]`:` ${o.yesText} `,t=o.selectedAnswer?` ${o.noText} `:`[${o.noText}]`,i=`${o.message}
17
+
18
+ ${n} ${t}`;e$1(e,r,i);}function ZC(e,r,o){o.fg===void 0&&o.bg===void 0||la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function eW(e,r,o){let n=o.type?JC(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?qC(o.ch):o.ch;m$1(e,r,t);}}function tW(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function Hg(e,r={}){let o=zg.parse(r),n=d$1(e);return bo.isQuestion[n]=1,U(e,n,o.left,o.top),f(e,n,o.width,o.height),ZC(e,n,o),o.border&&eW(e,n,o.border),o.padding!==void 0&&tW(e,n,o.padding),at.set(n,{message:o.message,yesText:o.yesText,noText:o.noText,selectedAnswer:o.defaultAnswer,visible:true,confirmCallbacks:[],cancelCallbacks:[]}),ua(e,n),nW(e,n)}function nW(e,r){let o={get eid(){return r},show(){let n=at.get(r);return n&&(n.visible=true),ra$1(e,r,true),oa$1(e,r),o},hide(){let n=at.get(r);return n&&(n.visible=false),ra$1(e,r,false),oa$1(e,r),o},move(n,t){let i=T$1.x[r]??0,a=T$1.y[r]??0;return U(e,r,i+n,a+t),oa$1(e,r),o},setPosition(n,t){return U(e,r,n,t),oa$1(e,r),o},center(n,t){let i=g(e,r);if(!i)return o;let a=Math.floor((n-i.width)/2),s=Math.floor((t-i.height)/2);return U(e,r,a,s),oa$1(e,r),o},setMessage(n){let t=at.get(r);return t&&(t.message=n,ua(e,r),oa$1(e,r)),o},getMessage(){return at.get(r)?.message??""},selectYes(){let n=at.get(r);return n&&(n.selectedAnswer=true,ua(e,r),oa$1(e,r)),o},selectNo(){let n=at.get(r);return n&&(n.selectedAnswer=false,ua(e,r),oa$1(e,r)),o},getSelectedAnswer(){return at.get(r)?.selectedAnswer??true},confirm(){let n=at.get(r);if(n)for(let t of n.confirmCallbacks)t(n.selectedAnswer);return o},cancel(){let n=at.get(r);if(n)for(let t of n.cancelCallbacks)t();return o},onConfirm(n){let t=at.get(r);return t&&t.confirmCallbacks.push(n),o},onCancel(n){let t=at.get(r);return t&&t.cancelCallbacks.push(n),o},destroy(){bo.isQuestion[r]=0,at.delete(r),e$2(e,r);}};return o}function Ug(e,r,o={}){return new Promise(n=>{let t=Hg(e,{...o,message:r});t.onConfirm(i=>{t.destroy(),n(i);}),t.onCancel(()=>{t.destroy(),n(false);});})}function rW(e,r){return Ug(e,r)}function oW(e,r){return bo.isQuestion[r]===1}function iW(e,r){switch(r){case "y":case "Y":return e.selectYes().confirm(),true;case "n":case "N":return e.selectNo().confirm(),true;case "enter":case "return":return e.confirm(),true;case "escape":return e.cancel(),true;default:return false}}function aW(){bo.isQuestion.fill(0),at.clear();}n();var $g=z.object({x:z.number().int().default(0),y:z.number().int().default(0)}),jg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(1),label:z.string().default(""),value:z.string().default(""),selectedChar:z.string().default("\u25C9"),unselectedChar:z.string().default("\u25CB"),focusable:z.boolean().default(true),disabled:z.boolean().default(false),groupId:z.number().int().optional()}),Yg=1e4,yo={isRadioGroupWidget:new Uint8Array(Yg)},ho={isRadioButtonWidget:new Uint8Array(Yg)},da=new Map,Lr=new Map;function sW(e,r={}){let o=$g.parse(r),n=d$1(e);yo.isRadioGroupWidget[n]=1,ob$1(e,n),U(e,n,o.x,o.y),da.set(n,{nextY:o.y,world:e});let t={eid:n,addOption(i,a){let s=da.get(n);if(!s)throw new Error("RadioGroup state not found");let l=Kg(e,{x:o.x,y:s.nextY,label:a,value:i,groupId:n});return s.nextY+=1,l},getSelectedValue(){return rb$1(n)},onChange(i){return sb$1(n,a=>{i(a);}),t},destroy(){yo.isRadioGroupWidget[n]=0,da.delete(n),tb$1(n),e$2(e,n);}};return t}function Kg(e,r={}){let o=jg.parse(r),n=d$1(e);ho.isRadioButtonWidget[n]=1,ub$1(e,n,o.groupId),Eb$2(n,o.value),Jb$2(n,{selectedChar:o.selectedChar,unselectedChar:o.unselectedChar});let t=Math.max(o.selectedChar.length,o.unselectedChar.length),i$1=o.label.length,a=o.width??t+(i$1>0?1+i$1:0);f(e,n,a,o.height),U(e,n,o.x,o.y),Lr.set(n,{label:o.label}),po(e,n),d$4(e,n,{clickable:true,hoverable:true,keyable:true,focusable:o.focusable}),d(e,n,{focusable:o.focusable}),o.disabled&&Hb$1(e,n);let s={eid:n,select(){return Fb$2(e,n),po(e,n),oa$1(e,n),s},deselect(){return Gb$2(e,n),po(e,n),oa$1(e,n),s},isSelected(){return zb$2(e,n)},getChar(){return Lb$2(e,n)},getValue(){return Db$2(n)??""},setLabel(l){let u=Lr.get(n);u&&(u.label=l);let b=Lb$2(e,n).length+(l.length>0?1+l.length:0);return f(e,n,b,o.height),po(e,n),oa$1(e,n),s},getLabel(){return Lr.get(n)?.label??""},setDisabled(l){return l?Hb$1(e,n):Ib$2(e,n),oa$1(e,n),s},isDisabled(){return Ab$2(e,n)},setPosition(l,u){return U(e,n,l,u),oa$1(e,n),s},move(l,u){return Z$1(e,n,l,u),oa$1(e,n),s},getPosition(){return {x:T$1.x[n]??0,y:T$1.y[n]??0}},focus(){return h(e,n),oa$1(e,n),s},blur(){return i(e,n),oa$1(e,n),s},isFocused(){return f$1(e,n)},handleKey(l){if(!f$1(e,n))return false;let u=Nb$2(e,n,l);return u&&(po(e,n),oa$1(e,n)),u},destroy(){ho.isRadioButtonWidget[n]=0,Lr.delete(n),Mb$2(n),e$2(e,n);}};return s}function po(e,r){let o=Lb$2(e,r),t=Lr.get(r)?.label??"",i=t.length>0?`${o} ${t}`:o;e$1(e,r,i);}function lW(e,r){return yo.isRadioGroupWidget[r]===1&&pb$1(e,r)}function uW(e,r){return ho.isRadioButtonWidget[r]===1&&vb$1(e,r)}function dW(){yo.isRadioGroupWidget.fill(0),ho.isRadioButtonWidget.fill(0),da.clear(),Lr.clear();}n();u();n();t();var Qg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),ca=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),cW=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),gW=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),mW=z.union([z.boolean(),z.object({mode:z.enum(["auto","visible","hidden"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),trackChar:z.string().optional(),thumbChar:z.string().optional()})]).optional(),Jg=z.object({left:ca.optional(),top:ca.optional(),right:ca.optional(),bottom:ca.optional(),width:Qg.optional(),height:Qg.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:cW,padding:gW,content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional(),scrollbar:mW,alwaysScroll:z.boolean().optional(),mouse:z.boolean().optional(),keys:z.boolean().optional(),scrollWidth:z.number().nonnegative().optional(),scrollHeight:z.number().nonnegative().optional(),scrollX:z.number().optional(),scrollY:z.number().optional()}),As=1e4,At={isScrollableBox:new Uint8Array(As),mouseEnabled:new Uint8Array(As),keysEnabled:new Uint8Array(As)};function fW(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function bW(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function pW(e){let{BORDER_DOUBLE:r,BORDER_ROUNDED:o,BORDER_BOLD:n,BORDER_ASCII:t}=(u(),d$3(t$1));switch(e){case "single":return b$1;case "double":return r;case "rounded":return o;case "bold":return n;case "ascii":return t}}function yW(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Xg(e){return e===void 0?0:typeof e=="number"?e:0}function qg(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function hW(e){switch(e){case "auto":return 2;case "visible":return 1;case "hidden":return 0}}function xW(e,r,o){let n=Xg(o.left),t=Xg(o.top);U(e,r,n,t);let i=qg(o.width),a=qg(o.height);f(e,r,i,a);}function SW(e,r,o){o.fg===void 0&&o.bg===void 0||la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function CW(e,r,o){let n=o.type?yW(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?pW(o.ch):o.ch;m$1(e,r,t);}}function WW(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function TW(e,r,o){if(o.content===void 0)return;let n={};o.align&&(n.align=fW(o.align)),o.valign&&(n.valign=bW(o.valign)),e$1(e,r,o.content,n);}function vW(e,r,o){let n={};o.scrollWidth!==void 0&&(n.scrollWidth=o.scrollWidth),o.scrollHeight!==void 0&&(n.scrollHeight=o.scrollHeight),o.scrollX!==void 0&&(n.scrollX=o.scrollX),o.scrollY!==void 0&&(n.scrollY=o.scrollY),o.alwaysScroll!==void 0&&(n.alwaysScroll=o.alwaysScroll),o.scrollbar===true?n.scrollbarVisible=2:o.scrollbar===false?n.scrollbarVisible=0:typeof o.scrollbar=="object"&&o.scrollbar.mode&&(n.scrollbarVisible=hW(o.scrollbar.mode)),l$1(e,r,n),At.mouseEnabled[r]=o.mouse!==false?1:0,At.keysEnabled[r]=o.keys!==false?1:0;}function xo(e,r$1,o$1={}){let n=Jg.parse(o$1),t=r$1;At.isScrollableBox[t]=1,xW(e,t,n),SW(e,t,n),n.border&&CW(e,t,n.border),n.padding!==void 0&&WW(e,t,n.padding),TW(e,t,n),vW(e,t,n),d(e,t,{focusable:true});let i$1={eid:t,show(){return ra$1(e,t,true),i$1},hide(){return ra$1(e,t,false),i$1},move(a,s){return Z$1(e,t,a,s),oa$1(e,t),i$1},setPosition(a,s){return U(e,t,a,s),oa$1(e,t),i$1},setContent(a){return e$1(e,t,a),oa$1(e,t),i$1},getContent(){return f$2(e,t)},focus(){return h(e,t),i$1},blur(){return i(e,t),i$1},isFocused(){return f$1(e,t)},append(a){return q$2(e,t,a),i$1},getChildren(){return s$1(e,t)},scrollTo(a,s){return p(e,t,a,s),oa$1(e,t),i$1},scrollBy(a,s){return o(e,t,a,s),oa$1(e,t),i$1},setScrollPerc(a,s){return r(e,t,a,s),oa$1(e,t),i$1},getScrollPerc(){return q$3(e,t)},getScroll(){return n$1(e,t)},setScrollSize(a,s){return u$1(e,t,a,s),oa$1(e,t),i$1},setViewport(a,s){return v(e,t,a,s),oa$1(e,t),i$1},getScrollable(){return s$2(e,t)},scrollToTop(){return x(e,t),oa$1(e,t),i$1},scrollToBottom(){return y(e,t),oa$1(e,t),i$1},scrollToLeft(){return z$2(e,t),oa$1(e,t),i$1},scrollToRight(){return A(e,t),oa$1(e,t),i$1},canScroll(){return B(e,t)},canScrollX(){return C(e,t)},canScrollY(){return D(e,t)},isAtTop(){return E(e,t)},isAtBottom(){return F(e,t)},isAtLeft(){return G(e,t)},isAtRight(){return H(e,t)},destroy(){At.isScrollableBox[t]=0,At.mouseEnabled[t]=0,At.keysEnabled[t]=0,e$2(e,t);}};return i$1}function Is(e,r){return At.isScrollableBox[r]===1}function LW(e,r){return At.mouseEnabled[r]===1}function EW(e,r){return At.keysEnabled[r]===1}function BW(){At.isScrollableBox.fill(0),At.mouseEnabled.fill(0),At.keysEnabled.fill(0);}function ks(e,r,o={}){return xo(e,r,{...o,alwaysScroll:true})}n();function Zg(e){let r={};return e.border?.fg!==void 0&&(r.borderFg=e.border.fg),e.border?.bg!==void 0&&(r.borderBg=e.border.bg),e.header?.fg!==void 0&&(r.headerFg=e.header.fg),e.header?.bg!==void 0&&(r.headerBg=e.header.bg),e.cell?.fg!==void 0&&(r.cellFg=e.cell.fg),e.cell?.bg!==void 0&&(r.cellBg=e.cell.bg),e.altRowBg!==void 0&&(r.altRowBg=e.altRowBg),e.selected?.fg!==void 0&&(r.selectedFg=e.selected.fg),e.selected?.bg!==void 0&&(r.selectedBg=e.selected.bg),r}var em=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),data:z.array(z.array(z.string())).default([]),pad:z.number().int().min(0).max(10).default(1),align:z.enum(["left","center","right"]).default("left"),style:z.object({border:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),header:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),cell:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),altRowBg:z.number().optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional()}).optional(),noCellBorders:z.boolean().default(false),headerRows:z.number().int().min(0).max(10).default(1),columns:z.array(z.object({header:z.string(),width:z.number().int().positive().optional(),minWidth:z.number().int().positive().optional(),maxWidth:z.number().int().positive().optional(),align:z.enum(["left","center","right"]).optional()})).optional()});function Rs(e,r,o={}){let n=em.parse(o),t=r;U(e,t,n.x,n.y),n.width!==void 0&&n.height!==void 0&&f(e,t,n.width,n.height),xb$1(e,t,{headerRows:n.headerRows,pad:n.pad,cellBorders:!n.noCellBorders}),n.data.length>0&&Ab$1(e,t,n.data),n.columns&&Ob$1(e,t,n.columns),n.style&&Ub$1(e,t,Zg(n.style));let i={eid:t,show(){return ra$1(e,t,true),i},hide(){return ra$1(e,t,false),i},move(a,s){return T$1.x[t]=(T$1.x[t]??0)+a,T$1.y[t]=(T$1.y[t]??0)+s,oa$1(e,t),i},setPosition(a,s){return U(e,t,a,s),i},setData(a){return Ab$1(e,t,a),i},getData(){return Cb$1(e,t)},getFullData(){return Bb$1(e,t)},clearData(){return Nb$1(e,t),i},setCell(a,s,l){return Db$1(e,t,a,s,l),i},getCell(a,s){return Eb$1(e,t,a,s)},getCellValue(a,s){return Fb$1(e,t,a,s)},getRow(a){return Gb$1(e,t,a)},appendRow(a){return Kb$1(e,t,a),i},insertRow(a,s){return Lb$1(e,t,a,s),i},removeRow(a){return Mb$1(e,t,a),i},getRowCount(){return Ib$1(e,t)},setColumns(a){return Ob$1(e,t,a),i},getColumns(){return Pb$1(e,t)},getColCount(){return Jb$1(e,t)},calculateColumnWidths(a){return $b$1(e,t,a)},setHeaderRowCount(a){return Sb$1(e,t,a),i},getHeaderRowCount(){return Tb$1(e,t)},getHeaderRows(){return Qb$1(e,t)},getDataRows(){return Rb$1(e,t)},setCellPadding(a){return Yb$1(e,t,a),i},getCellPadding(){return Xb$1(e,t)},setCellBorders(a){return _b$1(e,t,a),i},hasCellBorders(){return Zb$1(e,t)},setStyle(a){return Ub$1(e,t,Zg(a)),oa$1(e,t),i},getDisplay(){return Vb$1(e,t)},renderLines(a){return ac$1(e,t,a)},destroy(){zb$1(e,t),e$2(e,t);}};return i}function PW(e,r){return yb$1(e,r)}n();var $n=1e4,fn={VERTICAL:"\u2502",HORIZONTAL:"\u2500",BRANCH:"\u251C",CORNER:"\u2514",EXPANDED:"\u25BC",COLLAPSED:"\u25B6",SPACE:" "},sm=z.lazy(()=>z.object({label:z.string(),value:z.unknown().optional(),children:z.array(sm).optional(),expanded:z.boolean().optional(),icon:z.string().optional(),id:z.string().optional()})),lm=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(40),height:z.number().int().positive().default(10),nodes:z.array(sm).default([]),selected:z.string().optional(),style:z.object({node:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),expanded:z.object({fg:z.number().optional()}).optional(),collapsed:z.object({fg:z.number().optional()}).optional()}).optional(),showLines:z.boolean().default(true),keys:z.boolean().default(true),indent:z.number().int().min(1).max(8).default(2)}),j={isTree:new Uint8Array($n),state:new Uint8Array($n),showLines:new Uint8Array($n),keys:new Uint8Array($n),indent:new Uint8Array($n),firstVisible:new Uint32Array($n),visibleCount:new Uint32Array($n)},Qe=m({iterable:true}),Je=new Map,So=new Map,Co=new Map,Wo=new Map,To=new Map,tm=3435973887,nm=255,rm=255,om=16777215,im=2298448127,am=2290679807,MW={0:"idle",1:"focused"};function DW(){j.isTree.fill(0),j.state.fill(0),j.showLines.fill(0),j.keys.fill(0),j.indent.fill(0),j.firstVisible.fill(0),j.visibleCount.fill(0),Qe.clear(),Je.clear(),So.clear(),Co.clear(),Wo.clear(),To.clear();}var FW=0;function AW(){return `node_${++FW}`}function Os(e,r,o=0){let n={label:e.label,value:e.value,children:[],expanded:e.expanded??false,icon:e.icon,id:e.id??AW(),parent:r,depth:o};return e.children&&(n.children=e.children.map(t=>Os(t,n,o+1))),n}function IW(e,r,o){return r?.expanded?(e.collapse(o),{type:"collapse"}):(e.selectParent(),{type:"selectParent"})}function kW(e,r,o){return r&&r.children.length>0&&!r.expanded?(e.expand(o),{type:"expand"}):null}function RW(e,r,o,n){return r&&r.children.length>0?(e.toggle(o),{type:"toggle"}):(n(),{type:"confirm"})}function VW(e,r,o,n,t){if(e===0)return "";if(!o)return fn.SPACE.repeat(e*r);let i="";for(let a=0;a<e-1;a++)t[a]?i+=fn.SPACE.repeat(r):i+=fn.VERTICAL+fn.SPACE.repeat(r-1);return i+=n?fn.CORNER:fn.BRANCH,i+=fn.HORIZONTAL.repeat(r-1),i}function OW(e,r,o,n){let t=r;return e.children.length>0?(t+=e.expanded?fn.EXPANDED:fn.COLLAPSED,t+=" "):t+=" ",e.icon&&(t+=`${e.icon} `),t+=e.label,t.length>n&&(t=`${t.slice(0,n-1)}\u2026`),o?t=`[${t.padEnd(n-2)}]`:t=` ${t.padEnd(n-2)} `,t}function um(e,r="",o=[]){let n=[];for(let t=0;t<e.length;t++){let i=e[t];if(!i)continue;let a=t===e.length-1,s=r?`${r}.${t}`:`${t}`;n.push({node:i,path:s,depth:i.depth,isLastChild:a,parentIsLast:[...o]}),i.expanded&&i.children.length>0&&n.push(...um(i.children,s,[...o,a]));}return n}function rn(e,r){if(!r)return e[0];let o=r.split(".").map(Number),n=e[o[0]??0];for(let t=1;t<o.length&&n;t++){let i=o[t];i!==void 0&&(n=n.children[i]);}return n}function Vs(e,r){e.expanded=r;}function dm(e){for(let r of e)r.expanded=true,r.children.length>0&&dm(r.children);}function cm(e){for(let r of e)r.expanded=false,r.children.length>0&&cm(r.children);}function _s(e,r,o={}){let n=lm.parse(o),t=r;j.isTree[t]=1,U(e,t,n.x,n.y),f(e,t,n.width,n.height),j.showLines[t]=n.showLines?1:0,j.keys[t]=n.keys?1:0,j.indent[t]=n.indent,j.visibleCount[t]=n.height;let i=n.nodes.map(c=>Os(c));for(let c=0;c<i.length;c++){let g=i[c];g&&(g.rootIndex=c);}Qe.set(t,i),n.selected?Je.set(t,n.selected):i.length>0&&Je.set(t,"0");let a={nodeFg:n.style?.node?.fg??tm,nodeBg:n.style?.node?.bg??nm,selectedFg:n.style?.selected?.fg??rm,selectedBg:n.style?.selected?.bg??om,expandedFg:n.style?.expanded?.fg??im,collapsedFg:n.style?.collapsed?.fg??am};So.set(t,a),Co.set(t,new Set),Wo.set(t,new Set),To.set(t,new Set);let s=()=>{let c=Je.get(t)??"",g=Qe.get(t)??[],p=rn(g,c);if(p){let h=Co.get(t);if(h)for(let E of h)E(c,p);}},l=()=>{let c=Je.get(t)??"",g=Qe.get(t)??[],p=rn(g,c);if(p){let h=Wo.get(t);if(h)for(let E of h)E(c,p);}},u=(c,g)=>{let p=To.get(t);if(p)for(let h of p)h(c,g);},d=()=>{let c=Qe.get(t)??[];return um(c)},b=()=>{let c=d(),g=Je.get(t)??"",p=c.findIndex(B=>B.path===g);if(p<0)return;let h=j.firstVisible[t]??0,E=j.visibleCount[t]??0,W=h+E-1;p<h?j.firstVisible[t]=p:p>W&&(j.firstVisible[t]=Math.max(0,p-E+1));},f$1={eid:t,show(){return ra$1(e,t,true),f$1},hide(){return ra$1(e,t,false),f$1},move(c,g){return T$1.x[t]=(T$1.x[t]??0)+c,T$1.y[t]=(T$1.y[t]??0)+g,oa$1(e,t),f$1},setPosition(c,g){return U(e,t,c,g),f$1},focus(){return j.state[t]=1,oa$1(e,t),f$1},blur(){return j.state[t]=0,oa$1(e,t),f$1},setNodes(c){let g=c.map(p=>Os(p));return Qe.set(t,g),g.length>0?Je.set(t,"0"):Je.delete(t),j.firstVisible[t]=0,oa$1(e,t),f$1},getNodes(){return Qe.get(t)??[]},getNode(c){let g=Qe.get(t)??[];return rn(g,c)},getVisibleNodes(){return d()},select(c){let g=Qe.get(t)??[];return rn(g,c)&&(Je.set(t,c),b(),oa$1(e,t),s()),f$1},getSelectedPath(){return Je.get(t)??""},getSelectedNode(){let c=Je.get(t)??"",g=Qe.get(t)??[];return rn(g,c)},selectPrev(){let c=d(),g=Je.get(t)??"",p=c.findIndex(h=>h.path===g);if(p>0){let h=c[p-1];h&&f$1.select(h.path);}return f$1},selectNext(){let c=d(),g=Je.get(t)??"",p=c.findIndex(h=>h.path===g);if(p<c.length-1){let h=c[p+1];h&&f$1.select(h.path);}return f$1},selectFirst(){let c=d();if(c.length>0){let g=c[0];g&&f$1.select(g.path);}return f$1},selectLast(){let c=d();if(c.length>0){let g=c[c.length-1];g&&f$1.select(g.path);}return f$1},selectParent(){let g=(Je.get(t)??"").split(".");return g.length>1&&(g.pop(),f$1.select(g.join("."))),f$1},expand(c){let g=Qe.get(t)??[],p=rn(g,c);return p&&p.children.length>0&&!p.expanded&&(Vs(p,true),oa$1(e,t),u(c,true)),f$1},collapse(c){let g=Qe.get(t)??[],p=rn(g,c);return p?.expanded&&(Vs(p,false),oa$1(e,t),u(c,false)),f$1},toggle(c){let g=Qe.get(t)??[],p=rn(g,c);if(p&&p.children.length>0){let h=!p.expanded;Vs(p,h),oa$1(e,t),u(c,h);}return f$1},expandAll(){let c=Qe.get(t)??[];return dm(c),oa$1(e,t),f$1},collapseAll(){let c=Qe.get(t)??[];return cm(c),oa$1(e,t),f$1},isExpanded(c){let g=Qe.get(t)??[];return rn(g,c)?.expanded??false},getState(){let c=j.state[t]??0;return MW[c]??"idle"},setStyle(c){let g=So.get(t)??{nodeFg:tm,nodeBg:nm,selectedFg:rm,selectedBg:om,expandedFg:im,collapsedFg:am};return c.node?.fg!==void 0&&(g.nodeFg=c.node.fg),c.node?.bg!==void 0&&(g.nodeBg=c.node.bg),c.selected?.fg!==void 0&&(g.selectedFg=c.selected.fg),c.selected?.bg!==void 0&&(g.selectedBg=c.selected.bg),c.expanded?.fg!==void 0&&(g.expandedFg=c.expanded.fg),c.collapsed?.fg!==void 0&&(g.collapsedFg=c.collapsed.fg),So.set(t,g),oa$1(e,t),f$1},setShowLines(c){return j.showLines[t]=c?1:0,oa$1(e,t),f$1},getShowLines(){return j.showLines[t]===1},getFirstVisible(){return j.firstVisible[t]??0},setFirstVisible(c){return j.firstVisible[t]=Math.max(0,c),oa$1(e,t),f$1},getVisibleCount(){return j.visibleCount[t]??0},renderLines(c){let g=d(),p=Je.get(t)??"",h=j.showLines[t]===1,E=j.indent[t]??2,W=j.firstVisible[t]??0,B=j.visibleCount[t]??g.length,D=[],I=Math.min(W+B,g.length);for(let L=W;L<I;L++){let N=g[L];if(!N)continue;let{node:pe,path:xe,isLastChild:ft,parentIsLast:In}=N,Xt=xe===p,Dr=VW(pe.depth,E,h,ft,In),Fo=OW(pe,Dr,Xt,c);D.push(Fo);}return D},onSelect(c){let g=Co.get(t);return g&&g.add(c),()=>{g?.delete(c);}},onActivate(c){let g=Wo.get(t);return g&&g.add(c),()=>{g?.delete(c);}},onToggle(c){let g=To.get(t);return g&&g.add(c),()=>{g?.delete(c);}},handleKey(c){let g=j.state[t]??0,p=j.keys[t]===1;if(g!==1||!p)return null;let h=Je.get(t)??"",E=Qe.get(t)??[],W=rn(E,h);if(c==="G")return f$1.selectLast(),{type:"selectLast"};switch(c.toLowerCase()){case "up":case "k":return f$1.selectPrev(),{type:"selectPrev"};case "down":case "j":return f$1.selectNext(),{type:"selectNext"};case "left":case "h":return IW(f$1,W,h);case "right":case "l":return kW(f$1,W,h);case "enter":case " ":return RW(f$1,W,h,l);case "escape":return f$1.blur(),{type:"cancel"};case "g":return f$1.selectFirst(),{type:"selectFirst"}}return null},destroy(){j.isTree[t]=0,j.state[t]=0,j.showLines[t]=0,j.keys[t]=0,j.indent[t]=0,j.firstVisible[t]=0,j.visibleCount[t]=0,Qe.delete(t),Je.delete(t),So.delete(t),Co.delete(t),Wo.delete(t),To.delete(t),e$2(e,t);}};return f$1}function _W(e,r){return j.isTree[r]===1}n();var NW=1e4,ga={isViewport3D:new Uint8Array(NW)},vo=new Map;function Ns(e,r,o={}){let n=mb$1.parse(o),t=r;ga.isViewport3D[t]=1;let i=d$1(e);Q(e,i,{}),z$1(e,i,{fov:n.fov,near:n.near,far:n.far,aspect:n.width/n.height,projectionMode:n.projectionMode}),Z(e,t,{left:n.left,top:n.top,width:n.width,height:n.height,cameraEntity:i,backendType:n.backend});let a=n.backend==="auto"?"braille":n.backend,s=q$1(a),l=s.getPixelDimensions(n.width,n.height);Y.pixelWidth[t]=l.width,Y.pixelHeight[t]=l.height,U(e,t,n.left,n.top),f(e,t,n.width,n.height),vo.set(t,new Set);let u={eid:t,cameraEid:i,addMesh(d,b,f){if(!J(d))throw new Error(`Mesh ID ${d} not found in mesh store`);let g=d$1(e);return Q(e,g,b??{}),h$1(e,g,G$1),G$1.meshId[g]=d,f&&E$1(e,g,f),vo.get(t)?.add(g),g},removeMesh(d){vo.get(t)?.delete(d),e$2(e,d);},setCameraPosition(d,b,f){return P.tx[i]=d,P.ty[i]=b,P.tz[i]=f,P.dirty[i]=1,u},setCameraRotation(d,b,f){return P.rx[i]=d,P.ry[i]=b,P.rz[i]=f,P.dirty[i]=1,u},setFov(d){return y$1.fov[i]=d,y$1.dirty[i]=1,u},resize(d,b){Y.width[t]=d,Y.height[t]=b;let f$1=s.getPixelDimensions(d,b);return Y.pixelWidth[t]=f$1.width,Y.pixelHeight[t]=f$1.height,y$1.aspect[i]=d/b,f(e,t,d,b),oa$1(e,t),u},show(){return ra$1(e,t,true),u},hide(){return ra$1(e,t,false),u},destroy(){let d=vo.get(t);if(d){for(let b of d)e$2(e,b);vo.delete(t);}qb$1.delete(t),e$2(e,i),ga.isViewport3D[t]=0,e$2(e,t);}};return u}function GW(e){return ga.isViewport3D[e]===1}function gm(){let e=new Map,r=new Map;function o(i){return i.toLowerCase()}function n(i){let a=o(i);return r.get(a)??a}let t={register(i,a){let s=o(i);return e.set(s,a),t},alias(i,a){let s=o(i),l=o(a);if(!e.has(l)&&!r.has(l))throw new Error(`Cannot create alias '${i}' for non-existent widget type '${a}'`);return r.set(s,l),t},has(i){let a=n(i);return e.has(a)},get(i){let a=n(i);return e.get(a)},create(i,a,s){let l=d$1(i);return t.createWithEntity(i,l,a,s)},createWithEntity(i,a,s,l){let u=t.get(s);if(!u){let d=t.list().join(", ");throw new Error(`Unknown widget type '${s}'. Available types: ${d||"none"}`)}return u.factory(i,a,l)},list(){return Array.from(e.keys()).sort()},listByTag(i){let a=i.toLowerCase();return Array.from(e.entries()).filter(([,s])=>s.tags?.some(l=>l.toLowerCase()===a)).map(([s])=>s).sort()},unregister(i){let a=o(i);for(let[s,l]of r.entries())l===a&&r.delete(s);return e.delete(a)},clear(){e.clear(),r.clear();}};return t}var wW=[{name:"bigText",factory:e,description:"Large ASCII art text display widget",tags:["display","text"],aliases:["bigtext"]},{name:"box",factory:Tt,description:"Basic container widget with optional border and padding",tags:["container","layout","basic"]},{name:"text",factory:jr,description:"Simple text display widget",tags:["display","text","basic"]},{name:"line",factory:ys,description:"Horizontal or vertical line separator",tags:["display","decoration","basic"]},{name:"layout",factory:bs,description:"Auto-arranging container with flex/grid/inline modes",tags:["container","layout"]},{name:"panel",factory:Bs,description:"Container with title bar and optional close/collapse buttons",tags:["container","layout","interactive"]},{name:"tabs",factory:qr,description:"Tabbed container with navigation",tags:["container","layout","navigation","interactive"]},{name:"scrollableBox",factory:xo,description:"Scrollable container with scrollbar support",tags:["container","scrolling"],aliases:["scrollbox","scroll"]},{name:"scrollableText",factory:ks,description:"Scrollable text display optimized for logs and documents",tags:["display","text","scrolling"],aliases:["log","textarea"]},{name:"list",factory:Qr,description:"Selectable list of items",tags:["selection","interactive","data"]},{name:"listbar",factory:xs,description:"Horizontal menu bar with selectable items",tags:["navigation","interactive","menu"],aliases:["menubar","menu"]},{name:"table",factory:Rs,description:"Data table with rows and columns",tags:["display","data"]},{name:"listTable",factory:Ss,description:"Selectable data table combining list and table features",tags:["selection","interactive","data"],aliases:["datatable","grid"]},{name:"tree",factory:_s,description:"Hierarchical tree view with expandable nodes",tags:["selection","interactive","data","hierarchy"],aliases:["treeview"]},{name:"loading",factory:ra,description:"Loading indicator with spinner animation",tags:["display","feedback","animation"],aliases:["spinner","progress"]},{name:"hoverText",factory:ds,description:"Tooltip/hover text manager",tags:["feedback","tooltip"],aliases:["tooltip"]},{name:"viewport3d",factory:Ns,description:"3D rendering viewport with camera and mesh management",tags:["display","3d","rendering"],aliases:["3d","viewport"]}];function mm(e){for(let r of wW)if(e.register(r.name,{factory:r.factory,description:r.description,tags:r.tags}),r.aliases)for(let o of r.aliases)e.alias(o,r.name);return e}var ma=mm(gm());function zW(){return ma.list()}function HW(e){return ma.has(e)}function UW(e){return ma.listByTag(e)}n();var $W=30,jW=10,Gs=1e4,fm=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default($W),height:z.number().int().positive().default(jW),items:z.array(z.string()).default([]),enableSearch:z.boolean().default(true),placeholder:z.string().default("Filter..."),selected:z.number().int().min(-1).default(0),fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),selectedFg:z.number().int().nonnegative().optional(),selectedBg:z.number().int().nonnegative().optional(),disabledFg:z.number().int().nonnegative().optional(),filterFg:z.number().int().nonnegative().optional(),filterBg:z.number().int().nonnegative().optional()}),st={isSearchableList:new Uint8Array(Gs),visible:new Uint8Array(Gs),focused:new Uint8Array(Gs)},Lo=new Map;function jn(e){if(e.filterQuery.length===0)e.filteredItems=[...e.items],e.filteredToOriginalMap=e.items.map((r,o)=>o);else {let r=e.filterQuery.toLowerCase();e.filteredItems=[],e.filteredToOriginalMap=[];for(let o=0;o<e.items.length;o++){let n=e.items[o];n?.text.toLowerCase().includes(r)&&(e.filteredItems.push(n),e.filteredToOriginalMap.push(o));}}e.filteredItems.length===0?e.selectedFilteredIndex=-1:(e.selectedFilteredIndex>=e.filteredItems.length||e.selectedFilteredIndex<0&&e.filteredItems.length>0)&&(e.selectedFilteredIndex=0),e.firstVisible=0;}function wt(e){for(let r of e.callbacks)r(e.filteredItems,e.selectedFilteredIndex);}function fa(e){e.selectedFilteredIndex<e.firstVisible?e.firstVisible=e.selectedFilteredIndex:e.selectedFilteredIndex>=e.firstVisible+e.visibleCount&&(e.firstVisible=e.selectedFilteredIndex-e.visibleCount+1);}function YW(e,r,o){if(e==="up"||e==="k")return o.selectPrev(),true;if(e==="down"||e==="j")return o.selectNext(),true;if(e==="home")return o.selectFirst(),true;if(e==="end")return o.selectLast(),true;if(e==="pageup"){let n=Math.max(0,r.selectedFilteredIndex-r.visibleCount);return o.select(n),wt(r),true}if(e==="pagedown"){let n=Math.min(r.filteredItems.length-1,r.selectedFilteredIndex+r.visibleCount);return o.select(n),wt(r),true}return false}function KW(e,r,o,n){return e==="backspace"?(o.filterQuery.length>0&&(o.filterQuery=o.filterQuery.slice(0,-1),jn(o),wt(o)),true):r&&e==="u"?(n.clearFilter(),true):e.length===1&&!r?(o.filterQuery+=e,jn(o),wt(o),true):false}function QW(e,r={}){let o=fm.parse(r),n=d$1(e);st.isSearchableList[n]=1,st.visible[n]=1,st.focused[n]=0;let t=o.items.map(u=>({text:u,value:u})),i=o.enableSearch?1:0,a=Math.max(1,o.height-i),s={items:t,filterQuery:"",filteredItems:[...t],filteredToOriginalMap:t.map((u,d)=>d),selectedFilteredIndex:t.length>0?Math.min(o.selected,t.length-1):-1,searchEnabled:o.enableSearch,placeholder:o.placeholder,visibleCount:a,firstVisible:0,width:o.width,fg:o.fg??4294967295,bg:o.bg??255,selectedFg:o.selectedFg??255,selectedBg:o.selectedBg??8978431,disabledFg:o.disabledFg??2290649343,filterFg:o.filterFg??4294967295,filterBg:o.filterBg??572662527,callbacks:[]};Lo.set(n,s);let l={eid:n,show(){return st.visible[n]=1,l},hide(){return st.visible[n]=0,l},focus(){return st.focused[n]=1,l},blur(){return st.focused[n]=0,l},isFocused(){return st.focused[n]===1},setItems(u){return s.items=u.map(d=>({text:d,value:d})),jn(s),wt(s),l},getItems(){return s.items},setFilter(u){return s.filterQuery=u,jn(s),wt(s),l},getFilter(){return s.filterQuery},clearFilter(){return s.filterQuery="",jn(s),wt(s),l},getFilteredItems(){return s.filteredItems},getFilteredCount(){return s.filteredItems.length},getFilterStatus(){return s.filterQuery.length===0?`${s.items.length} items`:`${s.filteredItems.length} of ${s.items.length} items`},isSearchEnabled(){return s.searchEnabled},setSearchEnabled(u){s.searchEnabled=u;let d=u?1:0;return s.visibleCount=Math.max(1,o.height-d),u||(s.filterQuery="",jn(s)),l},select(u){return u>=0&&u<s.filteredItems.length&&(s.selectedFilteredIndex=u,fa(s)),l},getSelectedIndex(){return s.selectedFilteredIndex},getSelectedItem(){if(!(s.selectedFilteredIndex<0||s.selectedFilteredIndex>=s.filteredItems.length))return s.filteredItems[s.selectedFilteredIndex]},getOriginalSelectedIndex(){return s.selectedFilteredIndex<0?-1:s.filteredToOriginalMap[s.selectedFilteredIndex]??-1},selectPrev(){return s.selectedFilteredIndex>0&&(s.selectedFilteredIndex--,fa(s),wt(s)),l},selectNext(){return s.selectedFilteredIndex<s.filteredItems.length-1&&(s.selectedFilteredIndex++,fa(s),wt(s)),l},selectFirst(){return s.filteredItems.length>0&&(s.selectedFilteredIndex=0,s.firstVisible=0,wt(s)),l},selectLast(){return s.filteredItems.length>0&&(s.selectedFilteredIndex=s.filteredItems.length-1,fa(s),wt(s)),l},onChange(u){return s.callbacks.push(u),()=>{let d=s.callbacks.indexOf(u);d!==-1&&s.callbacks.splice(d,1);}},handleKey(u,d=false,b=false){return YW(u,s,l)?true:u==="escape"?(s.filterQuery.length>0?l.clearFilter():l.blur(),true):s.searchEnabled?KW(u,d,s,l):false},destroy(){st.isSearchableList[n]=0,st.visible[n]=0,st.focused[n]=0,Lo.delete(n),e$2(e,n);}};return l}function XW(e,r){return Lo.get(r)?.filteredItems??[]}function qW(e,r,o){let n=Lo.get(r);n&&(n.filterQuery=o,jn(n),wt(n));}function JW(e,r){return st.isSearchableList[r]===1}function ZW(){st.isSearchableList.fill(0),st.visible.fill(0),st.focused.fill(0),Lo.clear();}n();var e0=40,bm=1e4,pm=z.object({width:z.number().int().positive().default(e0),mode:z.enum(["plain","regex"]).default("plain"),caseSensitive:z.boolean().default(false),fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),matchFg:z.number().int().nonnegative().optional(),matchBg:z.number().int().nonnegative().optional(),currentMatchFg:z.number().int().nonnegative().optional(),currentMatchBg:z.number().int().nonnegative().optional()}),zt={isSearchOverlay:new Uint8Array(bm),visible:new Uint8Array(bm)},Er=new Map;function t0(e,r,o){return o==="r"?(e.toggleMode(),true):o==="i"?(e.setCaseSensitive(!r.caseSensitive),true):false}function n0(e,r,o,n,t){return e.isVisible()?o==="escape"?(e.hide(),true):o==="enter"||o==="return"?(t?e.prevMatch():e.nextMatch(),true):n?t0(e,r,o):o==="backspace"?(e.backspace(),true):o.length===1?(e.appendChar(o),true):false:n&&o==="f"?(e.show(),true):false}function r0(e){let r=e.caseSensitive?"g":"gi";try{let o=e.mode==="regex"?e.query:a0(e.query);return new RegExp(o,r)}catch{return null}}function o0(e,r,o){let n=[];e.lastIndex=0;let t=e.exec(r);for(;t!==null;)n.push({lineIndex:o,charOffset:t.index,length:t[0].length}),t[0].length===0&&e.lastIndex++,t=e.exec(r);return n}function i0(e){if(!e.content||e.query.length===0)return [];let r=r0(e);if(!r)return [];let o=[],n=e.content.getLineCount();for(let t=0;t<n;t++){let i=e.content.getLine(t);if(!i)continue;let a=o0(r,i,t);for(let s of a)o.push(s);}return o}function a0(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bn(e){e.matches=i0(e),e.matches.length===0?e.currentMatchIndex=-1:(e.currentMatchIndex>=e.matches.length||e.currentMatchIndex<0)&&(e.currentMatchIndex=0);for(let r of e.matchCallbacks)r(e.matches,e.currentMatchIndex);}function s0(e,r={}){let o=pm.parse(r),n=d$1(e);zt.isSearchOverlay[n]=1,zt.visible[n]=0;let t={query:"",mode:o.mode,caseSensitive:o.caseSensitive,matches:[],currentMatchIndex:-1,content:null,targetEid:null,width:o.width,fg:o.fg??4294967295,bg:o.bg??858993663,matchFg:o.matchFg??255,matchBg:o.matchBg??4294902015,currentMatchFg:o.currentMatchFg??255,currentMatchBg:o.currentMatchBg??4287103231,matchCallbacks:[],closeCallbacks:[]};Er.set(n,t);let i={eid:n,show(){return zt.visible[n]=1,bn(t),i},hide(){zt.visible[n]=0,t.query="",t.matches=[],t.currentMatchIndex=-1;for(let a of t.closeCallbacks)a();return i},isVisible(){return zt.visible[n]===1},setQuery(a){return t.query=a,bn(t),i},getQuery(){return t.query},appendChar(a){return t.query+=a,bn(t),i},backspace(){return t.query.length>0&&(t.query=t.query.slice(0,-1),bn(t)),i},clearQuery(){return t.query="",bn(t),i},setMode(a){return t.mode=a,bn(t),i},getMode(){return t.mode},toggleMode(){return t.mode=t.mode==="plain"?"regex":"plain",bn(t),i},setCaseSensitive(a){return t.caseSensitive=a,bn(t),i},isCaseSensitive(){return t.caseSensitive},nextMatch(){if(t.matches.length===0)return i;t.currentMatchIndex=(t.currentMatchIndex+1)%t.matches.length;for(let a of t.matchCallbacks)a(t.matches,t.currentMatchIndex);return i},prevMatch(){if(t.matches.length===0)return i;t.currentMatchIndex=t.currentMatchIndex<=0?t.matches.length-1:t.currentMatchIndex-1;for(let a of t.matchCallbacks)a(t.matches,t.currentMatchIndex);return i},getMatches(){return t.matches},getCurrentMatchIndex(){return t.currentMatchIndex},getMatchCount(){return t.matches.length},getMatchStatus(){return t.matches.length===0?t.query.length>0?"No matches":"":`${t.currentMatchIndex+1} of ${t.matches.length}`},attachContent(a){return t.content=a,t.query.length>0&&bn(t),i},detachContent(){return t.content=null,t.matches=[],t.currentMatchIndex=-1,i},onMatchChange(a){return t.matchCallbacks.push(a),()=>{let s=t.matchCallbacks.indexOf(a);s!==-1&&t.matchCallbacks.splice(s,1);}},onClose(a){return t.closeCallbacks.push(a),()=>{let s=t.closeCallbacks.indexOf(a);s!==-1&&t.closeCallbacks.splice(s,1);}},handleKey(a,s=false,l=false){return n0(i,t,a,s,l)},destroy(){zt.visible[n]===1&&i.hide(),zt.isSearchOverlay[n]=0,zt.visible[n]=0,Er.delete(n),e$2(e,n);}};return i}function l0(e,r,o,n){let t=Er.get(r.eid);return t&&(t.targetEid=o),r.attachContent(n)}function u0(e,r){return zt.isSearchOverlay[r]===1}function d0(e){return Er.get(e)?.targetEid??null}function c0(e){let r=Er.get(e);return r?{fg:r.fg,bg:r.bg,matchFg:r.matchFg,matchBg:r.matchBg,currentMatchFg:r.currentMatchFg,currentMatchBg:r.currentMatchBg}:null}function g0(){zt.isSearchOverlay.fill(0),zt.visible.fill(0),Er.clear();}n();t();var ym=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),data:z.array(z.number()).default([]),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),showMin:z.boolean().default(false),showMax:z.boolean().default(false),gradient:z.boolean().default(false),gradientStart:z.union([z.string(),z.number()]).optional(),gradientEnd:z.union([z.string(),z.number()]).optional()}),ba=1e4,lt={isSparkline:new Uint8Array(ba),showMin:new Uint8Array(ba),showMax:new Uint8Array(ba),gradient:new Uint8Array(ba)},An=new Map;function m0(e){let r=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let n of e)n<r&&(r=n),n>o&&(o=n);return {min:r,max:o}}function f0(e,r,o,n,t,i,a,s){let l=[];return l.push([0,Math.max(0,Math.min(3,a))]),l.push([1,Math.max(0,Math.min(3,s))]),t&&(e===o||r===o)&&(l.push([0,3]),l.push([1,3])),i&&(e===n||r===n)&&(l.push([0,0]),l.push([1,0])),l}function b0(e,r,o,n,t,i,a){let s=o*2,l=r*2,u=r*2+1,d=Math.floor(l/s*e.length),b=Math.floor(u/s*e.length),f=e[d]??0,c=e[b]??0,g=Math.round(St(f,n,t,3,0)),p=Math.round(St(c,n,t,3,0)),h=f0(f,c,n,t,i,a,g,p);return $a(h)}function p0(e,r,o,n){if(e.length===0)return " ".repeat(r);let{min:t,max:i}=m0(e);if(t===i)return String.fromCharCode(10308).repeat(r);let a=[];for(let s=0;s<r;s++)a.push(b0(e,s,r,t,i,o,n));return a.join("")}function pa(e,r){let o=An.get(r);if(!o)return;let n=g(e,r);if(!n)return;let t=lt.showMin[r]===1,i=lt.showMax[r]===1,a=p0(o.data,n.width,t,i);e$1(e,r,a),oa$1(e,r);}function y0(e,r={}){let o=ym.parse(r),n=d$1(e);U(e,n,o.x,o.y),f(e,n,o.width,1),lt.isSparkline[n]=1,lt.showMin[n]=o.showMin?1:0,lt.showMax[n]=o.showMax?1:0,lt.gradient[n]=o.gradient?1:0;let t=en(1),i=en(3);An.set(n,{data:[...o.data],gradientStart:o.gradientStart?s(o.gradientStart):t,gradientEnd:o.gradientEnd?s(o.gradientEnd):i}),(o.fg!==void 0||o.bg!==void 0)&&la$1(e,n,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),pa(e,n);let a={eid:n,setData(s){let l=An.get(n);return l&&(l.data=[...s],pa(e,n)),a},getData(){return An.get(n)?.data??[]},append(s){let l=An.get(n);return l&&(l.data.push(s),pa(e,n)),a},clear(){let s=An.get(n);return s&&(s.data=[],pa(e,n)),a},setPosition(s,l){return U(e,n,s,l),oa$1(e,n),a},destroy(){lt.isSparkline[n]=0,lt.showMin[n]=0,lt.showMax[n]=0,lt.gradient[n]=0,An.delete(n),e$2(e,n);}};return a}function h0(e,r){return lt.isSparkline[r]===1}function x0(){lt.isSparkline.fill(0),lt.showMin.fill(0),lt.showMax.fill(0),lt.gradient.fill(0),An.clear();}n();var hm=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),xm=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Tm=z.object({left:hm.optional(),top:hm.optional(),width:xm.optional(),height:xm.optional(),direction:z.enum(["horizontal","vertical"]).optional(),ratios:z.array(z.number().min(0).max(1)).optional(),minPaneSize:z.number().int().nonnegative().optional(),dividerSize:z.number().int().nonnegative().optional(),resizable:z.boolean().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),dividerFg:z.union([z.string(),z.number()]).optional(),dividerBg:z.union([z.string(),z.number()]).optional(),dividerChar:z.string().optional()}),Br=1e4,We={isSplitPane:new Uint8Array(Br),direction:new Uint8Array(Br),paneCount:new Uint8Array(Br),minPaneSize:new Uint8Array(Br),dividerSize:new Uint8Array(Br),resizable:new Uint8Array(Br)},Ae=new Map,an=new Map,xa=new Map,sn=new Map,It=new Map;function ya(e){return typeof e=="string"?q$7(e):e}function Sm(e){if(e===void 0)return 0;if(typeof e=="number")return e;if(e==="left"||e==="top")return 0;if(e==="center")return 50;if(e==="right"||e==="bottom")return 100;if(typeof e=="string"&&e.endsWith("%")){let r=Number.parseFloat(e.slice(0,-1));if(!Number.isNaN(r))return r}return 0}function Cm(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function Wm(e){let r=e.reduce((o,n)=>o+n,0);return r===0?e.map(()=>1/e.length):e.map(o=>o/r)}function S0(e){return e<=0?[]:new Array(e).fill(1/e)}function C0(e,r,o,n,t,i,a){let s=i.length;if(s===0)return [];let l=a*(s-1),u=t==="horizontal"?o-l:n-l,d=Math.max(0,u),b=[],f=0,c=0;for(let g=0;g<s;g++){let p=g===s-1,h=p?Math.max(1,d-c):Math.max(1,Math.round(d*(i[g]??0)));t==="horizontal"?b.push({x:e+f,y:r,width:h,height:n}):b.push({x:e,y:r+f,width:o,height:h}),f+=h,c+=h,p||(f+=a);}return b}function W0(e,r,o,n,t){let i=[...e],a=t>0?n/t:0,s=(i[r]??0)+o,l=(i[r+1]??0)-o;if(s<a){let u=a-(i[r]??0);i[r]=a,i[r+1]=(i[r+1]??0)-u;}else if(l<a){let u=(i[r+1]??0)-a;i[r]=(i[r]??0)+u,i[r+1]=a;}else i[r]=s,i[r+1]=l;return i}function T0(e,r,o,n,t,i){let a=[];for(let s=0;s<Math.max(e.length,r.length);s++){let l=e[s],u=r[s];if(!l||!u){let d=u??l;d&&a.push(d);continue}if(l.x!==u.x||l.y!==u.y||l.width!==u.width||l.height!==u.height){let d=Math.min(l.x,u.x),b=Math.min(l.y,u.y),f=Math.max(l.x+l.width,u.x+u.width),c=Math.max(l.y+l.height,u.y+u.height);a.push({x:Math.max(o,d),y:Math.max(n,b),width:Math.min(o+t,f)-Math.max(o,d),height:Math.min(n+i,c)-Math.max(n,b)});}}return a}function v0(){return {scrollX:0,scrollY:0,contentWidth:0,contentHeight:0}}function ha(e,r){let o=Math.max(0,e.contentWidth-r.width),n=Math.max(0,e.contentHeight-r.height);e.scrollX=Math.max(0,Math.min(e.scrollX,o)),e.scrollY=Math.max(0,Math.min(e.scrollY,n));}function L0(e,r,o,n,t,i,a){We.isSplitPane[r]=1,We.direction[r]=n==="horizontal"?0:1,We.paneCount[r]=0,We.minPaneSize[r]=t,We.dividerSize[r]=i,We.resizable[r]=a?1:0,Ae.set(r,[]),an.set(r,[]),It.set(r,[]),xa.set(r,{fg:o.dividerFg!==void 0?ya(o.dividerFg):void 0,bg:o.dividerBg!==void 0?ya(o.dividerBg):void 0,char:o.dividerChar??(n==="horizontal"?"\u2502":"\u2500")});let s=Sm(o.left),l=Sm(o.top);U(e,r,s,l);let u=Cm(o.width),d$1=Cm(o.height);f(e,r,u,d$1),(o.fg!==void 0||o.bg!==void 0)&&la$1(e,r,{fg:o.fg!==void 0?ya(o.fg):void 0,bg:o.bg!==void 0?ya(o.bg):void 0}),d(e,r,{focusable:true});}function E0(e,r,o={}){let n=Tm.parse(o),t=r,i$1=n.direction??"horizontal",a=n.minPaneSize??3,s=n.dividerSize??1,l=n.resizable!==false;L0(e,t,n,i$1,a,s,l);let u=n.ratios?Wm(n.ratios):[];function d(W){let B=sn.get(W);B&&(B.refCount--,B.refCount<=0&&sn.delete(W));}function b(){let W=g(e,t);return {x:0,y:0,width:W?.width??80,height:W?.height??24}}function f$2(W,B){for(let D=0;D<W.length;D++){let I=W[D],L=B[D];!I||!L||(I.viewport=L,ha(I.scroll,L),I.dirty=true);}}function c(W){let B=an.get(t)??[];for(let D=0;D<B.length;D++){let I=B[D];if(!I)continue;let L=0;for(let N=0;N<=D;N++)L+=W[N]??0;I.ratio=L;}}function g$1(W,B){for(let D=0;D<W.length;D++){let I=W[D],L=B[D];!I||!L||(U(e,I.entity,L.x,L.y),f(e,I.entity,L.width,L.height));}}function p(){let W=Ae.get(t);if(!W||W.length===0)return;let B=b(),D=C0(B.x,B.y,B.width,B.height,i$1,u,s);f$2(W,D),c(u),g$1(W,D),We.paneCount[t]=W.length,oa$1(e,t);}function h$1(W){let B=Ae.get(t)??[],D={entity:W,viewport:{x:0,y:0,width:0,height:0},scroll:v0(),sharedBufferId:void 0,dirty:true};B.push(D),Ae.set(t,B),u.length<B.length&&(u=S0(B.length));let I=an.get(t)??[];if(B.length>1&&I.length<B.length-1){let L=0;for(let N=0;N<I.length+1;N++)L+=u[N]??0;I.push({ratio:L,dragging:false,dragStartPos:0,dragStartRatio:0,dragStartRatios:[]}),an.set(t,I);}q$2(e,t,W),p();}let E={eid:t,show(){return ra$1(e,t,true),E},hide(){return ra$1(e,t,false),E},move(W,B){return Z$1(e,t,W,B),oa$1(e,t),E},setPosition(W,B){return U(e,t,W,B),p(),E},getDirection(){return i$1},getRatios(){return [...u]},setRatios(W){let B=Ae.get(t)??[];return W.length!==B.length||(u=Wm(W),p()),E},getPaneCount(){return (Ae.get(t)??[]).length},getPaneViewport(W){return (Ae.get(t)??[])[W]?.viewport},getAllPaneViewports(){return (Ae.get(t)??[]).map(W=>W.viewport)},scrollPane(W,B,D){let L=(Ae.get(t)??[])[W];if(!L)return E;L.scroll.scrollX+=B,L.scroll.scrollY+=D,ha(L.scroll,L.viewport),L.dirty=true;let N=It.get(t)??[];return N.push(L.viewport),It.set(t,N),oa$1(e,t),E},setPaneScroll(W,B,D){let L=(Ae.get(t)??[])[W];if(!L)return E;L.scroll.scrollX=B,L.scroll.scrollY=D,ha(L.scroll,L.viewport),L.dirty=true;let N=It.get(t)??[];return N.push(L.viewport),It.set(t,N),oa$1(e,t),E},getPaneScroll(W){let D=(Ae.get(t)??[])[W];if(D)return {...D.scroll}},setPaneContentSize(W,B,D){let L=(Ae.get(t)??[])[W];return L&&(L.scroll.contentWidth=B,L.scroll.contentHeight=D,ha(L.scroll,L.viewport)),E},attachBuffer(W,B){let I=(Ae.get(t)??[])[W];if(!I)return E;I.sharedBufferId&&d(I.sharedBufferId),I.sharedBufferId=B.id,sn.has(B.id)||sn.set(B.id,B);let L=sn.get(B.id);return L&&L.refCount++,I.scroll.contentHeight=B.lines.length,I.dirty=true,oa$1(e,t),E},detachBuffer(W){let D=(Ae.get(t)??[])[W];return !D||!D.sharedBufferId||(d(D.sharedBufferId),D.sharedBufferId=void 0,D.dirty=true,oa$1(e,t)),E},getBuffer(W){let D=(Ae.get(t)??[])[W];if(!(!D||!D.sharedBufferId))return sn.get(D.sharedBufferId)},beginDrag(W,B){if(!l)return E;let I=(an.get(t)??[])[W];return I&&(I.dragging=true,I.dragStartPos=B,I.dragStartRatio=I.ratio,I.dragStartRatios=[...u]),E},updateDrag(W,B){if(!l)return;let I=(an.get(t)??[])[W];if(!I||!I.dragging)return;let L=b(),N=i$1==="horizontal"?L.width:L.height,pe=s*(u.length-1),xe=Math.max(1,N-pe),In=(B-I.dragStartPos)/xe,Xt=(Ae.get(t)??[]).map(Ta=>Ta.viewport);u=W0(I.dragStartRatios,W,In,a,xe),p();let Dr=(Ae.get(t)??[]).map(Ta=>Ta.viewport),Fo=T0(Xt,Dr,L.x,L.y,L.width,L.height),Js=It.get(t)??[];return Js.push(...Fo),It.set(t,Js),{dividerIndex:W,ratios:[...u],dirtyRects:Fo}},endDrag(W){let D=(an.get(t)??[])[W];return D&&(D.dragging=false,D.dragStartPos=0,D.dragStartRatio=0,D.dragStartRatios=[]),E},isDragging(){return (an.get(t)??[]).some(B=>B.dragging)},getDirtyRects(){return [...It.get(t)??[]]},markPaneDirty(W){let D=(Ae.get(t)??[])[W];if(!D)return E;D.dirty=true;let I=It.get(t)??[];return I.push(D.viewport),It.set(t,I),oa$1(e,t),E},flushDirty(){let W=Ae.get(t)??[];for(let B of W)B.dirty=false;return It.set(t,[]),E},recalculate(){return p(),E},focus(){return h(e,t),E},blur(){return i(e,t),E},isFocused(){return f$1(e,t)},append(W){return h$1(W),E},getChildren(){return s$1(e,t)},destroy(){let W=Ae.get(t)??[];for(let B of W)B.sharedBufferId&&d(B.sharedBufferId);We.isSplitPane[t]=0,We.direction[t]=0,We.paneCount[t]=0,We.minPaneSize[t]=0,We.dividerSize[t]=0,We.resizable[t]=0,Ae.delete(t),an.delete(t),xa.delete(t),It.delete(t),e$2(e,t);}};return E}function B0(e,r){return We.isSplitPane[r]===1}function P0(e,r){return We.direction[r]===0?"horizontal":"vertical"}function M0(e,r){let o=sn.get(e);if(o)return o;let n={id:e,lines:r,refCount:0};return sn.set(e,n),n}function D0(e){return sn.get(e)}function F0(e,r,o,n,t){for(let i=0;i<e.length-1;i++){let a=e[i];if(!a)continue;let s=r?a.viewport.x+a.viewport.width:a.viewport.y+a.viewport.height,l=r?n:t;if(l>=s&&l<s+o)return i}return -1}function A0(e,r,o,n){if(We.isSplitPane[r]!==1)return -1;let t=Ae.get(r);if(!t||t.length<2)return -1;let i=We.direction[r]===0,a=We.dividerSize[r]??1;return F0(t,i,a,o,n)}function I0(e,r){if(We.isSplitPane[r]!==1)return [];let o=Ae.get(r);if(!o||o.length<2)return [];let n=We.direction[r]===0?"horizontal":"vertical",t=We.dividerSize[r]??1,i=xa.get(r)??{fg:void 0,bg:void 0,char:"\u2502"},a=[];for(let s=0;s<o.length-1;s++){let l=o[s];l&&(n==="horizontal"?a.push({x:l.viewport.x+l.viewport.width,y:l.viewport.y,width:t,height:l.viewport.height,char:i.char,fg:i.fg,bg:i.bg}):a.push({x:l.viewport.x,y:l.viewport.y+l.viewport.height,width:l.viewport.width,height:t,char:i.char,fg:i.fg,bg:i.bg}));}return a}function k0(){We.isSplitPane.fill(0),We.direction.fill(0),We.paneCount.fill(0),We.minPaneSize.fill(0),We.dividerSize.fill(0),We.resizable.fill(0),Ae.clear(),an.clear(),xa.clear(),It.clear(),sn.clear();}var R0=z.object({maxLines:z.number().int().nonnegative().default(1e4),wrapWidth:z.number().int().positive().default(80),autoScroll:z.boolean().default(true),stripAnsi:z.boolean().default(false)}),V0={maxLines:1e4,wrapWidth:80,autoScroll:true,stripAnsi:false};function zs(e,r){if(r<=0)return [e];if(e.length<=r)return [e];let o=[],n=e;for(;n.length>r;)o.push(n.slice(0,r)),n=n.slice(r);return n.length>0&&o.push(n),o}function vm(e){return e.replace(/\x1b(?:\[[0-9;?]*[a-zA-Z~]|\][^\x07\x1b]*(?:\x07|\x1b\\)?|[^[\]])/g,"")}function ws(e,r=24){return {lines:[],scrollTop:0,viewportHeight:r,totalBytes:0,isStreaming:false,config:{...V0,...e},partialLine:"",dirty:null}}function Sa(e,r){let o=r;e.config.stripAnsi&&(o=vm(o));let n=e.totalBytes+o.length,i=(e.partialLine+o).split(`
19
+ `),a=i.pop()??"",s=[];for(let c of i){let g=zs(c,e.config.wrapWidth);for(let p of g)s.push(p);}let l=[...e.lines,...s],u=0;e.config.maxLines>0&&l.length>e.config.maxLines&&(u=l.length-e.config.maxLines,l=l.slice(u));let b={startLine:Math.max(0,l.length-s.length),lineCount:s.length,fullRedraw:u>0},f=e.scrollTop;return u>0&&(f=Math.max(0,f-u)),e.config.autoScroll&&(f=Math.max(0,l.length-e.viewportHeight)),{...e,lines:l,scrollTop:f,totalBytes:n,partialLine:a,dirty:b}}function Lm(e){return {...e,lines:[],scrollTop:0,totalBytes:0,partialLine:"",dirty:{startLine:0,lineCount:0,fullRedraw:true}}}function Em(e){let r=e.scrollTop,o=Math.min(r+e.viewportHeight,e.lines.length);return e.lines.slice(r,o)}function Bo(e,r){let o=Math.max(0,e.lines.length-e.viewportHeight),n=Math.max(0,Math.min(r,o));return n===e.scrollTop?e:{...e,scrollTop:n,dirty:{startLine:0,lineCount:e.viewportHeight,fullRedraw:true}}}function Bm(e,r){return Bo(e,e.scrollTop+r)}function O0(e,r,o){let n=r,t=ws(o),i={eid:n,append(a){return t=Sa(t,a),oa$1(e,n),i},appendLine(a){return t=Sa(t,`${a}
20
+ `),oa$1(e,n),i},clear(){return t=Lm(t),oa$1(e,n),i},getState(){return t},getVisibleLines(){return Em(t)},getProgress(){return {totalBytes:t.totalBytes,totalLines:t.lines.length,visibleLines:Math.min(t.viewportHeight,t.lines.length),isAutoScrolling:t.config.autoScroll,isStreaming:t.isStreaming}},consumeDirty(){let a=t.dirty;return t={...t,dirty:null},a},scrollTo(a){return t=Bo(t,a),oa$1(e,n),i},scrollBy(a){return t=Bm(t,a),oa$1(e,n),i},scrollToBottom(){let a=Math.max(0,t.lines.length-t.viewportHeight);return t=Bo(t,a),oa$1(e,n),i},scrollToTop(){return t=Bo(t,0),oa$1(e,n),i},setViewportHeight(a){return t={...t,viewportHeight:a},i},setWrapWidth(a){let s={...t.config,wrapWidth:a},l=t.lines.join(`
21
+ `)+(t.partialLine?t.partialLine:"");return t=ws(s,t.viewportHeight),l.length>0&&(t=Sa(t,l)),oa$1(e,n),i},setAutoScroll(a){return t={...t,config:{...t.config,autoScroll:a}},i},startStream(){return t={...t,isStreaming:true},i},endStream(){if(t.partialLine.length>0){let a=zs(t.partialLine,t.config.wrapWidth),s=[...t.lines,...a];t={...t,lines:s,partialLine:"",isStreaming:false,dirty:{startLine:Math.max(0,s.length-a.length),lineCount:a.length,fullRedraw:false}},t.config.autoScroll&&(t={...t,scrollTop:Math.max(0,s.length-t.viewportHeight)}),oa$1(e,n);}else t={...t,isStreaming:false};return i}};return i}n();t();var Mm=z.object({x:z.number().int().default(0),y:z.number().int().default(0),checked:z.boolean().default(false),onLabel:z.string().default("ON"),offLabel:z.string().default("OFF"),onFg:z.union([z.string(),z.number()]).optional(),onBg:z.union([z.string(),z.number()]).optional(),offFg:z.union([z.string(),z.number()]).optional(),offBg:z.union([z.string(),z.number()]).optional(),focusable:z.boolean().default(true),visible:z.boolean().default(true)}),Pm=1e4,_0="#ffffff",N0="#4caf50",G0="#000000",w0="#757575",et={isSwitch:new Uint8Array(Pm),checked:new Uint8Array(Pm)},Ht=new Map;function Pr(e,r){let o=Ht.get(r);if(!o)return;let n=et.checked[r]===1,t=n?o.onLabel:o.offLabel,i=n?o.onFg:o.offFg,a=n?o.onBg:o.offBg;e$1(e,r,` ${t} `),la$1(e,r,{fg:i,bg:a}),oa$1(e,r);}function z0(e,r={}){let o=Mm.parse(r),n=d$1(e);et.isSwitch[n]=1,et.checked[n]=o.checked?1:0;let t=o.onFg!==void 0?s(o.onFg):s(_0),i=o.onBg!==void 0?s(o.onBg):s(N0),a=o.offFg!==void 0?s(o.offFg):s(G0),s$1=o.offBg!==void 0?s(o.offBg):s(w0);Ht.set(n,{onLabel:o.onLabel,offLabel:o.offLabel,onFg:t,onBg:i,offFg:a,offBg:s$1}),U(e,n,o.x,o.y);let l=Math.max(o.onLabel.length,o.offLabel.length);f(e,n,l+2,1),d(e,n,{focusable:o.focusable}),Pr(e,n),o.visible||ra$1(e,n,false);let u={eid:n,isChecked(){return et.checked[n]===1},setChecked(d){let b=et.checked[n]===1;if(et.checked[n]=d?1:0,Pr(e,n),b!==d){let f=Ht.get(n);f?.onChangeCallback&&f.onChangeCallback(d);}return u},toggle(){let d=et.checked[n]===0;return u.setChecked(d)},setOnLabel(d){let b=Ht.get(n);return b&&(b.onLabel=d,Pr(e,n)),u},setOffLabel(d){let b=Ht.get(n);return b&&(b.offLabel=d,Pr(e,n)),u},getOnLabel(){return Ht.get(n)?.onLabel??""},getOffLabel(){return Ht.get(n)?.offLabel??""},onChange(d){let b=Ht.get(n);return b&&(b.onChangeCallback=d),u},show(){return ra$1(e,n,true),u},hide(){return ra$1(e,n,false),u},setPosition(d,b){return U(e,n,d,b),oa$1(e,n),u},destroy(){et.isSwitch[n]=0,et.checked[n]=0,Ht.delete(n),e$2(e,n);}};return u}function Hs(e,r){return et.isSwitch[r]===1}function H0(e,r,o){if(!Hs(e,r)||o!==" "&&o!=="enter")return false;let t=!(et.checked[r]===1);et.checked[r]=t?1:0,Pr(e,r);let i=Ht.get(r);return i?.onChangeCallback&&i.onChangeCallback(t),true}function U0(e,r){if(!Hs(e,r))return false;let n=!(et.checked[r]===1);et.checked[r]=n?1:0,Pr(e,r);let t=Ht.get(r);return t?.onChangeCallback&&t.onChangeCallback(n),true}function $0(){et.isSwitch.fill(0),et.checked.fill(0),Ht.clear();}u();n();t();var Fm=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),j0=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),Im=z.object({shell:z.string().min(1).optional(),args:z.array(z.string()).optional(),env:z.record(z.string(),z.string()).optional(),cwd:z.string().min(1).optional(),term:z.string().min(1).default("xterm-256color"),cols:z.number().int().positive().optional(),rows:z.number().int().positive().optional(),autoResize:z.boolean().default(true)}),km=z.object({width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),scrollback:z.number().int().nonnegative().default(1e3),cursorBlink:z.boolean().default(true),cursorShape:z.enum(["block","underline","bar"]).default("block"),left:Fm.optional(),top:Fm.optional(),border:j0,style:z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}).optional(),mouse:z.boolean().default(true),keys:z.boolean().default(true)}),$s=1e4,kt={isTerminal:new Uint8Array($s),mouseEnabled:new Uint8Array($s),keysEnabled:new Uint8Array($s)},js=new Map;function Am(e){return e===void 0?0:typeof e=="number"?e:0}function Y0(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function K0(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$2;case "bold":return e$3;case "ascii":return f$3}}function Q0(e){let r=process.env.SHELL??"/bin/sh",o={...process.env};if(typeof e=="string")return {shell:e,args:[],env:o,cwd:void 0,term:"xterm-256color",cols:void 0,rows:void 0,autoResize:true};if(!e)return {shell:r,args:[],env:o,cwd:void 0,term:"xterm-256color",cols:void 0,rows:void 0,autoResize:true};let n=Im.parse(e);return {shell:n.shell??r,args:n.args??[],env:n.env?{...process.env,...n.env}:o,cwd:n.cwd,term:n.term,cols:n.cols,rows:n.rows,autoResize:n.autoResize}}function X0(){let e=[()=>createRequire(pathToFileURL(`${process.cwd()}/`).href)("node-pty"),()=>createRequire(import.meta.url)("node-pty"),()=>{let r=process.argv[1];if(r)return createRequire(pathToFileURL(r).href)("node-pty");throw new Error("No main module")}];for(let r of e)try{return r()}catch{}return null}function q0(e,r,o){if(!o)return;let n=o.type?Y0(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?K0(o.ch):o.ch;m$1(e,r,t);}}function J0(e,r,o){o&&la$1(e,r,{fg:o.fg!==void 0?s(o.fg):void 0,bg:o.bg!==void 0?s(o.bg):void 0});}function Z0(e,r,o){let n=o!==void 0&&o.type!=="none";return {displayWidth:e+(n?2:0),displayHeight:r+(n?2:0)}}function eT(e,r={}){let o=km.parse(r),n=d$1(e);kt.isTerminal[n]=1,kt.mouseEnabled[n]=o.mouse?1:0,kt.keysEnabled[n]=o.keys?1:0;let t=Am(o.left),i$1=Am(o.top);U(e,n,t,i$1);let{displayWidth:a,displayHeight:s}=Z0(o.width,o.height,o.border);f(e,n,a,s);let l={width:o.width,height:o.height,scrollbackLines:o.scrollback,cursorBlink:o.cursorBlink,cursorShape:o.cursorShape,cursorVisible:true};hc$1(e,n,l),J0(e,n,o.style),ra$1(e,n,true),q0(e,n,o.border),d(e,n,{focusable:true});let u={pty:null,onDataCallback:null,onExitCallback:null,autoResize:true};js.set(n,u);let d$2={eid:n,write(b){return mc$1(e,n,b),d$2},writeln(b){return mc$1(e,n,`${b}
22
+ `),d$2},clear(){return nc$1(e,n),d$2},reset(){return oc$1(e,n),d$2},scrollUp(b=1){return rc$1(e,n,b),d$2},scrollDown(b=1){return sc$1(e,n,b),d$2},scrollToTop(){return tc$1(e,n),d$2},scrollToBottom(){return uc$1(e,n),d$2},setCursor(b,f){return pc$1(e,n,b,f),d$2},showCursor(){return qc$1(e,n,true),d$2},hideCursor(){return qc$1(e,n,false),d$2},spawn(b){let f=X0();if(!f)return console.warn("node-pty is not installed. Install it with: pnpm add node-pty"),d$2;u.pty&&d$2.kill();let{shell:c,args:g,env:p,cwd:h,term:E,cols:W,rows:B,autoResize:D}=Q0(b),I=kc$1(n),L=W??I?.width??80,N=B??I?.height??24;u.autoResize=D;let pe=f.spawn(c,g,{name:E,cols:L,rows:N,...h!==void 0?{cwd:h}:{},env:p});return u.pty=pe,pe.onData(xe=>{mc$1(e,n,xe),u.onDataCallback&&u.onDataCallback(xe);}),pe.onExit(({exitCode:xe,signal:ft})=>{u.pty=null,u.onExitCallback&&u.onExitCallback(xe,ft);}),d$2},input(b){let f=u.pty;return f&&f.write(b),d$2},resize(b,f$1){vc$1(e,n,b,f$1);let c=u.pty;c&&u.autoResize&&c.resize(b,f$1);let g=o.border!==void 0&&o.border.type!=="none",p=b+(g?2:0),h=f$1+(g?2:0);return f(e,n,p,h),oa$1(e,n),d$2},kill(b="SIGTERM"){let f=u.pty;return f&&(f.kill(b),u.pty=null),d$2},isRunning(){return u.pty!==null},getPtyHandle(){return u.pty},onData(b){return u.onDataCallback=b,d$2},onExit(b){return u.onExitCallback=b,d$2},show(){return ra$1(e,n,true),d$2},hide(){return ra$1(e,n,false),d$2},focus(){return h(e,n),d$2},blur(){return i(e,n),d$2},isFocused(){return f$1(e,n)},getDimensions(){let b=kc$1(n);return {width:b?.width??0,height:b?.height??0}},getCursor(){let b=kc$1(n);return {x:b?.cursorX??0,y:b?.cursorY??0}},getState(){return jc$1(n)},getCells(){return yc$1(n)},destroy(){d$2.kill(),kt.isTerminal[n]=0,kt.mouseEnabled[n]=0,kt.keysEnabled[n]=0,wc$1(n),js.delete(n),e$2(e,n);},refresh(){return oa$1(e,n),d$2}};return oa$1(e,n),d$2}var tT={return:"\r",enter:"\r",backspace:"\x7F",tab:" ",escape:"\x1B",up:"\x1B[A",down:"\x1B[B",right:"\x1B[C",left:"\x1B[D",home:"\x1B[H",end:"\x1B[F",pageup:"\x1B[5~",pagedown:"\x1B[6~",delete:"\x1B[3~",insert:"\x1B[2~"};function nT(e,r){let o=tT[r];return o?(e.input(o),true):false}function rT(e,r){if(!r)return false;let o=r.toUpperCase().charCodeAt(0)-64;return o>=0&&o<=31?(e.input(String.fromCharCode(o)),true):false}function oT(e,r){return r?(e.input(`\x1B${r}`),true):false}function iT(e,r,o,n,t){return nT(e,r)||n&&rT(e,o)||t&&oT(e,o)?true:o&&!n&&!t?(e.input(o),true):false}function aT(e,r,o){return r==="pageup"?(e.scrollUp(e.getDimensions().height),true):r==="pagedown"?(e.scrollDown(e.getDimensions().height),true):r==="home"&&o?(e.scrollToTop(),true):r==="end"&&o?(e.scrollToBottom(),true):false}function sT(e,r,o,n=false,t=false,i=false){return e.isRunning()?iT(e,r,o,n,t):aT(e,r,n)}function lT(e,r){return kt.isTerminal[r]===1}function uT(e,r){return kt.mouseEnabled[r]===1}function dT(e,r){return kt.keysEnabled[r]===1}function cT(){kt.isTerminal.fill(0),kt.mouseEnabled.fill(0),kt.keysEnabled.fill(0),js.clear();}n();var Rm=z.object({x:z.number().int().default(0),y:z.number().int().default(0),duration:z.number().positive(),format:z.enum(["ss","mm:ss","hh:mm:ss"]).default("mm:ss"),autoStart:z.boolean().default(false),onComplete:z.function().optional()}),Vm=z.object({x:z.number().int().default(0),y:z.number().int().default(0),format:z.enum(["ss","mm:ss","hh:mm:ss"]).default("mm:ss"),lapSupport:z.boolean().default(false),autoStart:z.boolean().default(false)}),Po=1e4,ut={isTimer:new Uint8Array(Po),running:new Uint8Array(Po)},Ye={isStopwatch:new Uint8Array(Po),running:new Uint8Array(Po),lapSupport:new Uint8Array(Po)},Yn=new Map,pn=new Map;function Om(e,r){let o=Math.max(0,Math.floor(e/1e3)),n=Math.floor(o/3600),t=Math.floor(o%3600/60),i=o%60,a=s=>s.toString().padStart(2,"0");switch(r){case "ss":return a(o);case "mm:ss":return `${a(t)}:${a(i)}`;case "hh:mm:ss":return `${a(n)}:${a(t)}:${a(i)}`}}function Ys(e,r){let o=Yn.get(r);if(!o)return;let n=Om(o.remaining,o.format);e$1(e,r,n);}function Ks(e,r){let o=pn.get(r);if(!o)return;let n=Om(o.elapsed,o.format);e$1(e,r,n);}function _m(e){switch(e){case "ss":return 2;case "mm:ss":return 5;case "hh:mm:ss":return 8}}function gT(e,r){let o=Rm.parse(r),n=d$1(e);ut.isTimer[n]=1,ut.running[n]=o.autoStart?1:0;let t=_m(o.format);f(e,n,t,1),U(e,n,o.x,o.y),Yn.set(n,{remaining:o.duration,duration:o.duration,format:o.format,onComplete:o.onComplete}),Ys(e,n);let i={eid:n,start(){return ut.running[n]=1,i},pause(){return ut.running[n]=0,i},reset(){let a=Yn.get(n);return a&&(a.remaining=a.duration,ut.running[n]=0,Ys(e,n),oa$1(e,n)),i},getState(){let a=Yn.get(n);return a?{remaining:a.remaining,duration:a.duration,running:ut.running[n]===1}:{remaining:0,duration:0,running:false}},setPosition(a,s){return U(e,n,a,s),oa$1(e,n),i},move(a,s){return Z$1(e,n,a,s),oa$1(e,n),i},destroy(){ut.isTimer[n]=0,ut.running[n]=0,Yn.delete(n),e$2(e,n);}};return i}function mT(e,r={}){let o=Vm.parse(r),n=d$1(e);Ye.isStopwatch[n]=1,Ye.running[n]=o.autoStart?1:0,Ye.lapSupport[n]=o.lapSupport?1:0;let t=_m(o.format);f(e,n,t,1),U(e,n,o.x,o.y),pn.set(n,{elapsed:0,format:o.format,laps:[]}),Ks(e,n);let i={eid:n,start(){return Ye.running[n]=1,i},pause(){return Ye.running[n]=0,i},reset(){let a=pn.get(n);return a&&(a.elapsed=0,a.laps=[],Ye.running[n]=0,Ks(e,n),oa$1(e,n)),i},lap(){if(Ye.lapSupport[n]!==1)return i;let a=pn.get(n);return a&&a.laps.push(a.elapsed),i},getState(){let a=pn.get(n);return a?{elapsed:a.elapsed,running:Ye.running[n]===1,laps:[...a.laps]}:{elapsed:0,running:false,laps:[]}},getLaps(){return pn.get(n)?.laps??[]},setPosition(a,s){return U(e,n,a,s),oa$1(e,n),i},move(a,s){return Z$1(e,n,a,s),oa$1(e,n),i},destroy(){Ye.isStopwatch[n]=0,Ye.running[n]=0,Ye.lapSupport[n]=0,pn.delete(n),e$2(e,n);}};return i}function fT(e,r,o){let n=Yn.get(r);n&&(n.remaining=Math.max(0,n.remaining-o),n.remaining===0&&(ut.running[r]=0,n.onComplete&&n.onComplete()),Ys(e,r),oa$1(e,r));}function bT(e,r,o){let n=pn.get(r);n&&(n.elapsed+=o,Ks(e,r),oa$1(e,r));}function pT(e,r){for(let o=0;o<ut.isTimer.length;o++)ut.isTimer[o]===1&&ut.running[o]===1&&fT(e,o,r);for(let o=0;o<Ye.isStopwatch.length;o++)Ye.isStopwatch[o]===1&&Ye.running[o]===1&&bT(e,o,r);}function yT(e,r){return ut.isTimer[r]===1}function hT(e,r){return Ye.isStopwatch[r]===1}function xT(){ut.isTimer.fill(0),ut.running.fill(0),Yn.clear();}function ST(){Ye.isStopwatch.fill(0),Ye.running.fill(0),Ye.lapSupport.fill(0),pn.clear();}u();n();t();var CT=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","rounded"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),Ca=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),borderFg:z.union([z.string(),z.number()]).optional()}).optional(),wm=z.object({content:z.string().optional(),type:z.enum(["info","success","warning","error"]).optional(),timeout:z.number().int().nonnegative().optional(),position:z.enum(["top-right","top-center","top-left","bottom-right","bottom-center","bottom-left"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:CT,padding:z.number().int().nonnegative().optional(),width:z.number().int().positive().optional(),infoStyle:Ca,successStyle:Ca,warningStyle:Ca,errorStyle:Ca}),zm=3e3,Xs=1,Qs=1,Hm={info:{fg:"#ffffff",bg:"#2196f3",borderFg:"#64b5f6"},success:{fg:"#ffffff",bg:"#4caf50",borderFg:"#81c784"},warning:{fg:"#000000",bg:"#ff9800",borderFg:"#ffb74d"},error:{fg:"#ffffff",bg:"#f44336",borderFg:"#e57373"}},Nm=1e4,Qt={isToast:new Uint8Array(Nm),dismissed:new Uint8Array(Nm)},ln=new Map,Mr={"top-right":new Set,"top-center":new Set,"top-left":new Set,"bottom-right":new Set,"bottom-center":new Set,"bottom-left":new Set};function WT(e){switch(e){case "single":return b$1;case "rounded":return d$2}}function TT(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Um(e,r){return {info:r.infoStyle,success:r.successStyle,warning:r.warningStyle,error:r.errorStyle}[e]??Hm[e]}function vT(e,r){let o=e.split(`
23
+ `),n=Math.max(...o.map(s=>s.length),10),t=o.length,i=n+r*2+2,a=t+r*2+2;return {width:i,height:a}}function Gm(e,r,o,n){let t=Array.from(Mr[r]),i=0;r.startsWith("bottom")&&(i=n);for(let a of t){let s=g(e,a),l=s?.width??0,u=s?.height??0,d=0,b=0;r.endsWith("right")?d=o-l:r.endsWith("center")?d=Math.floor((o-l)/2):d=0,r.startsWith("top")?(b=i,i+=u+Qs):(i-=u,b=i,i-=Qs),U(e,a,d,b),oa$1(e,a);}}function LT(e,r,o){Qt.isToast[e]=1,Qt.dismissed[e]=0,ln.set(e,{content:r.content??"",position:o}),Mr[o].add(e);}function ET(e,r,o){let n=o.content??"",t=o.padding??Xs,{width:i,height:a}=vT(n,t),s=o.width??i;f(e,r,s,a),U(e,r,0,0);}function BT(e,r,o){let n=o.type??"info",t=Um(n,o),i=o.fg??t.fg,a=o.bg??t.bg;(i!==void 0||a!==void 0)&&la$1(e,r,{fg:i!==void 0?s(i):void 0,bg:a!==void 0?s(a):void 0});}function PT(e,r,o){let n=o.type??"info",t=Um(n,o),i=o.border?.type?TT(o.border.type):1,a=o.border?.fg??t.borderFg;l(e,r,{type:i,fg:a!==void 0?s(a):void 0,bg:o.border?.bg!==void 0?s(o.border.bg):void 0});let s$1=o.border?.ch?typeof o.border.ch=="string"?WT(o.border.ch):o.border.ch:d$2;m$1(e,r,s$1);}function MT(e,r,o){let n=o.content??"";e$1(e,r,n,{align:1,valign:1});}function DT(e,r,o,n){let t=o.timeout??zm;if(t<=0)return;let i=ln.get(r);i&&(i.timerId=setTimeout(()=>{n();},t));}function Mo(e,r={},o=80,n=24){let t=wm.parse(r),i=d$1(e),a=t.position??"top-right";LT(i,t,a),ET(e,i,t),BT(e,i,t),PT(e,i,t),MT(e,i,t);let s=t.padding??Xs;b(e,i,{left:s,top:s,right:s,bottom:s}),Gm(e,a,o,n);let l=()=>{if(Qt.dismissed[i]===1)return;Qt.dismissed[i]=1,ra$1(e,i,false);let d=ln.get(i);d&&(Mr[d.position].delete(i),Gm(e,d.position,o,n),d.timerId&&(clearTimeout(d.timerId),d.timerId=void 0),d.onDismissCallback&&d.onDismissCallback());};DT(e,i,t,l);let u={eid:i,setContent(d){let b=ln.get(i);return b&&(b.content=d),e$1(e,i,d,{align:1,valign:1}),oa$1(e,i),u},getContent(){return ln.get(i)?.content??""},show(){return ra$1(e,i,true),u},hide(){return ra$1(e,i,false),u},move(d,b){return Z$1(e,i,d,b),oa$1(e,i),u},dismiss:l,isDismissed(){return Qt.dismissed[i]===1},onDismiss(d){let b=ln.get(i);return b&&(b.onDismissCallback=d),u},destroy(){let d=ln.get(i);d&&(d.timerId&&clearTimeout(d.timerId),Mr[d.position].delete(i)),Qt.isToast[i]=0,Qt.dismissed[i]=0,ln.delete(i),e$2(e,i);}};return u}function FT(e,r,o={},n=80,t=24){return Mo(e,{...o,content:r,type:"info"},n,t)}function AT(e,r,o={},n=80,t=24){return Mo(e,{...o,content:r,type:"success"},n,t)}function IT(e,r,o={},n=80,t=24){return Mo(e,{...o,content:r,type:"warning"},n,t)}function kT(e,r,o={},n=80,t=24){return Mo(e,{...o,content:r,type:"error"},n,t)}function RT(e,r){return Qt.isToast[r]===1}function VT(){for(let e of ln.values())e.timerId&&clearTimeout(e.timerId);Qt.isToast.fill(0),Qt.dismissed.fill(0),ln.clear();for(let e of Object.keys(Mr))Mr[e].clear();}n();var $m=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),path:z.string().default(""),player:z.enum(["mpv","mplayer"]).optional(),outputDriver:z.enum(["caca","tct","sixel"]).default("caca"),speed:z.number().positive().default(1),autoPlay:z.boolean().default(false),loop:z.boolean().default(false),mute:z.boolean().default(true),visible:z.boolean().default(true)}),OT=1e4,Do={isVideo:new Uint8Array(OT)},be=new Map,jm=["/usr/bin/mpv","/usr/local/bin/mpv","/opt/homebrew/bin/mpv","/snap/bin/mpv"],Ym=["/usr/bin/mplayer","/usr/local/bin/mplayer","/opt/homebrew/bin/mplayer"];function Km(e=Qm){for(let r of jm)if(e(r))return {player:"mpv",path:r};for(let r of Ym)if(e(r))return {player:"mplayer",path:r}}function Qm(e){try{return a$1("fs").existsSync(e)}catch{return false}}function Xm(e,r,o){let n=[];return e.outputDriver==="caca"?n.push("--vo=caca"):e.outputDriver==="tct"?(n.push("--vo=tct"),n.push(`--vo-tct-width=${r}`),n.push(`--vo-tct-height=${o}`)):e.outputDriver==="sixel"&&(n.push("--vo=sixel"),n.push(`--vo-sixel-width=${r*8}`),n.push(`--vo-sixel-height=${o*14}`)),n.push("--no-osc"),n.push("--no-input-default-bindings"),n.push("--terminal=no"),n.push("--no-input-terminal"),e.speed!==1&&n.push(`--speed=${e.speed}`),e.loop&&n.push("--loop=inf"),e.mute&&n.push("--mute=yes"),e.seekPosition>0&&n.push(`--start=${e.seekPosition}`),n.push(e.path),n}function qm(e,r,o){let n=[];return e.outputDriver,n.push("-vo","caca"),n.push("-slave"),n.push("-quiet"),e.speed!==1&&n.push("-speed",String(e.speed)),e.loop&&n.push("-loop","0"),e.mute&&n.push("-nosound"),e.seekPosition>0&&n.push("-ss",String(e.seekPosition)),n.push(e.path),n}function Jm(e,r,o,n){return e==="mpv"?Xm(r,o,n):qm(r)}function qs(e,r){r==="mplayer"&&e.write(`pause
24
+ `);}function Zm(e,r,o){r==="mplayer"&&e.write(`seek ${o} 2
25
+ `);}function _T(e,r={},o){let n=$m.parse(r),t=d$1(e);U(e,t,n.x,n.y),f(e,t,n.width,n.height),Do.isVideo[t]=1;let i={path:n.path,player:n.player,outputDriver:n.outputDriver,speed:n.speed,loop:n.loop,mute:n.mute,playbackState:"stopped",visible:n.visible,process:null,seekPosition:0,onEndCallback:null,onErrorCallback:null,onDataCallback:null};be.set(t,i),n.visible||ra$1(e,t,false);let a=UT(e,t,o);return n.autoPlay&&n.path&&a.play(),a}function NT(e){return e.playbackState!=="paused"||!e.process||e.player!=="mplayer"?false:(qs(e.process,"mplayer"),e.playbackState="playing",true)}function GT(e){e.process&&(e.process.kill(),e.process=null);}function wT(e,r){if(e.player)return true;let o=r?.exists??Qm,n=Km(o);return n?(e.player=n.player,true):false}function zT(e,r,o,n,t,i){let a=Jm(e.player,e,t,i),s=r.spawn(e.player,a);e.process=s,e.playbackState="playing",s.onData(l=>{e$1(o,n,l),oa$1(o,n),e.onDataCallback?.(l);}),s.onExit(l=>{e.process=null,e.playbackState="stopped",l===0?e.onEndCallback?.():e.onErrorCallback?.(`Player exited with code ${l}`);});}function HT(e,r,o,n){if(!e.path)return "No video path set";if(GT(e),!wT(e,r))return "No video player found (mpv or mplayer required)";if(!r)return "No process spawner available";let t=e$4.width[n]||80,i=e$4.height[n]||24;try{zT(e,r,o,n,t,i);}catch(a){return a instanceof Error?a.message:String(a)}return null}function UT(e,r,o){let n=()=>{let s=be.get(r);if(!s||NT(s))return a;let l=HT(s,o,e,r);return l&&s.onErrorCallback?.(l),a},t=()=>{let s=be.get(r);return !s||s.playbackState!=="playing"||(s.process&&s.player==="mplayer"&&qs(s.process,"mplayer"),s.playbackState="paused"),a},i=()=>{let s=be.get(r);return s&&(s.process&&(s.process.kill(),s.process=null),s.playbackState="stopped",s.seekPosition=0,e$1(e,r,""),oa$1(e,r)),a},a={get eid(){return r},show(){let s=be.get(r);return s&&(s.visible=true),ra$1(e,r,true),oa$1(e,r),a},hide(){let s=be.get(r);return s&&(s.visible=false),ra$1(e,r,false),oa$1(e,r),a},isVisible(){return be.get(r)?.visible??false},move(s,l){let u=T$1.x[r]??0,d=T$1.y[r]??0;return U(e,r,u+s,d+l),oa$1(e,r),a},setPosition(s,l){return U(e,r,s,l),oa$1(e,r),a},getPosition(){return {x:T$1.x[r]??0,y:T$1.y[r]??0}},setPath(s){let l=be.get(r);return l&&(l.path=s),a},getPath(){return be.get(r)?.path??""},play:n,pause:t,stop:i,togglePlayback(){let s=be.get(r);return s?s.playbackState==="playing"?t():n():a},seek(s){let l=be.get(r);return l&&(l.seekPosition=Math.max(0,s),l.process&&l.player==="mplayer"?Zm(l.process,"mplayer",s):l.playbackState==="playing"&&(i(),l.seekPosition=Math.max(0,s),n())),a},getPlaybackState(){return be.get(r)?.playbackState??"stopped"},setSpeed(s){let l=be.get(r);return l&&(l.speed=s),a},getSpeed(){return be.get(r)?.speed??1},setLoop(s){let l=be.get(r);return l&&(l.loop=s),a},getLoop(){return be.get(r)?.loop??false},setMute(s){let l=be.get(r);return l&&(l.mute=s),a},getMute(){return be.get(r)?.mute??true},getPlayer(){return be.get(r)?.player},isRunning(){return be.get(r)?.process!==null},resize(s,l){f(e,r,s,l);let u=be.get(r);return u?.process?.resize&&u.process.resize(s,l),oa$1(e,r),a},onEnd(s){let l=be.get(r);return l&&(l.onEndCallback=s),a},onError(s){let l=be.get(r);return l&&(l.onErrorCallback=s),a},onData(s){let l=be.get(r);return l&&(l.onDataCallback=s),a},destroy(){let s=be.get(r);s?.process&&s.process.kill(),Do.isVideo[r]=0,be.delete(r),e$2(e,r);}};return a}function $T(e,r){return Do.isVideo[r]===1}function jT(e){return be.get(e)?.playbackState}function YT(e){return be.get(e)?.player}function KT(){for(let e of be.values())e.process&&e.process.kill();Do.isVideo.fill(0),be.clear();}u();n();var nf=z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),selectedFg:z.number().int().nonnegative().optional(),selectedBg:z.number().int().nonnegative().optional(),cursorFg:z.number().int().nonnegative().optional(),cursorBg:z.number().int().nonnegative().optional(),showLineNumbers:z.boolean().optional(),lineNumberWidth:z.number().int().nonnegative().optional()}),rf=z.object({type:z.nativeEnum(a).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),of=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive(),height:z.number().int().positive(),lines:z.array(z.string()).optional(),mouse:z.boolean().default(true),keys:z.boolean().default(true),style:nf.optional(),border:rf.optional(),overscan:z.number().int().nonnegative().default(5),maxLines:z.number().int().nonnegative().default(0)}),QT=["fg","bg","selectedFg","selectedBg","cursorFg","cursorBg","showLineNumbers","lineNumberWidth"];function XT(e){let r={};for(let o of QT){let n=e[o];n!==void 0&&(r[o]=n);}return r}var ef=new WeakMap;function Wa(e,r){if(e.store=r,h$5(e.eid,r),r$1(e.world,e.eid,r.lineCount),e.maxLines>0&&r.lineCount>e.maxLines){let o=w$2(r,e.maxLines);e.store=o,h$5(e.eid,o),r$1(e.world,e.eid,o.lineCount);}e.followMode&&p$2(e.world,e.eid),oa$1(e.world,e.eid);}function tf(e,r){return Math.max(1,e-(r?2:0))}function qT(e,r){let o=of.parse(r),n=d$1(e);U(e,n,o.x,o.y),f(e,n,o.width,o.height),a$2.x[n]=o.x,a$2.y[n]=o.y,a$2.width[n]=o.width,a$2.height[n]=o.height,a$2.valid[n]=1;let t=o.border!==void 0&&o.border.type!==0,i=tf(o.height,t),a;o.lines&&o.lines.length>0?a=g$1(o.lines):a=h$3(),e$5(n,a),e$6(e,n,{totalLineCount:a.lineCount,visibleLineCount:i,overscanBefore:o.overscan,overscanAfter:o.overscan,selectedLine:-1,cursorLine:-1});let s={fg:o.style?.fg??4294967295,bg:o.style?.bg??255};la$1(e,n,s),ra$1(e,n,true);let l$1={};o.style?.fg!==void 0&&(l$1.fg=o.style.fg),o.style?.bg!==void 0&&(l$1.bg=o.style.bg),o.style?.selectedFg!==void 0&&(l$1.selectedFg=o.style.selectedFg),o.style?.selectedBg!==void 0&&(l$1.selectedBg=o.style.selectedBg),o.style?.cursorFg!==void 0&&(l$1.cursorFg=o.style.cursorFg),o.style?.cursorBg!==void 0&&(l$1.cursorBg=o.style.cursorBg),o.style?.showLineNumbers!==void 0&&(l$1.showLineNumbers=o.style.showLineNumbers),o.style?.lineNumberWidth!==void 0&&(l$1.lineNumberWidth=o.style.lineNumberWidth),i$2(n,l$1),o.border&&l(e,n,o.border);let u={world:e,eid:n,store:a,followMode:false,maxLines:o.maxLines,mouseEnabled:o.mouse,keysEnabled:o.keys},d={eid:n};ef.set(d,u),oa$1(e,n);let b={eid:n,show(){return ra$1(e,n,true),oa$1(e,n),b},hide(){return ra$1(e,n,false),oa$1(e,n),b},setPosition(f,c){return U(e,n,f,c),a$2.x[n]=f,a$2.y[n]=c,oa$1(e,n),b},setDimensions(f$1,c){f(e,n,f$1,c),a$2.width[n]=f$1,a$2.height[n]=c;let g=tf(c,t);return s$4(e,n,g),oa$1(e,n),b},setLines(f){let c=f.length>0?g$1(f):h$3();return Wa(u,c),b},appendLine(f){let c=m$4(u.store,u.store.byteSize>0?`
26
+ ${f}`:f);return Wa(u,c),b},appendLines(f){if(f.length===0)return b;let c=n$4(u.store,f);return Wa(u,c),b},getLineCount(){return o$3(u.store)},getLine(f){return i$3(u.store,f)},clear(){return Wa(u,h$3()),b},scrollToLine(f){return l$2(e,n,f),b},scrollToTop(){return o$2(e,n),b},scrollToBottom(){return p$2(e,n),b},scrollBy(f){return m$3(e,n,f),b},scrollPage(f){return n$3(e,n,f),b},getScrollInfo(){return q$6(e,n)},select(f){return u$2(e,n,f),b},getSelected(){return d$7.selectedLine[n]},clearSelection(){return u$2(e,n,-1),b},cursorUp(f=1){return y$3(e,n,-f),b},cursorDown(f=1){return y$3(e,n,f),b},setCursor(f){return d$7.cursorLine[n]=f,oa$1(e,n),b},getCursor(){return d$7.cursorLine[n]},follow(f){return u.followMode=f,f&&p$2(e,n),b},isFollowing(){return u.followMode},setStyle(f){return i$2(n,XT(f)),oa$1(e,n),b},destroy(){o$1(n),ef.delete(d),e$2(e,n);},refresh(){return oa$1(e,n),b}};return b}function JT(e,r,o=false,n=false){switch(r){case "up":case "k":return e.cursorUp(n?5:1),true;case "down":case "j":return e.cursorDown(n?5:1),true;case "pageup":return e.scrollPage(-1),true;case "pagedown":return e.scrollPage(1),true;case "home":return o?(e.scrollToTop(),e.setCursor(0)):e.scrollToTop(),true;case "end":if(o){e.scrollToBottom();let t=e.getLineCount();e.setCursor(t-1);}else e.scrollToBottom();return true;case "g":return !o&&!n?(e.scrollToTop(),e.setCursor(0),true):false;case "G":return e.scrollToBottom(),e.setCursor(e.getLineCount()-1),true;case "enter":case "return":return e.select(e.getCursor()),true;default:return false}}function ZT(e,r,o=3){return r==="up"?e.scrollBy(-o):e.scrollBy(o),true}function ev(e,r){return d$7.totalLineCount[r]!==void 0&&d$7.visibleLineCount[r]!==void 0}export{ob as $,dp as $a,dh as $b,eg as $c,Tg as $d,jg as $e,E0 as $f,IT as $g,Uf as A,Kr as Aa,je as Ab,tx as Ac,fg as Ad,RC as Ae,mm as Af,kt as Ag,$f as B,Ob as Ba,gy as Bb,nx as Bc,Cs as Bd,Rg as Be,ma as Bf,eT as Bg,jf as C,_b as Ca,Cy as Cb,Oc as Cc,bg as Cd,Vg as Ce,zW as Cf,sT as Cg,Sn as D,Nb as Da,Wy as Db,q as Dc,Ie as Dd,Og as De,HW as Df,lT as Dg,_n as E,Dd as Ea,Ty as Eb,_c as Ec,uo as Ed,_g as Ee,UW as Ef,uT as Eg,Yf as F,Qr as Fa,vy as Fb,Nc as Fc,ES as Fd,Fs as Fe,fm as Ff,dT as Fg,$a as G,wb as Ga,ns as Gb,Gc,BS as Gd,fo as Ge,st as Gf,cT as Gg,fd as H,Xi as Ha,ec as Hb,bs as Hc,PS as Hd,it as He,QW as Hf,Rm as Hg,_r as I,Ad as Ia,Ry as Ib,dx as Ic,MS as Id,Ng as Ie,XW as If,Vm as Ig,St as J,$b as Ja,Vy as Jb,cx as Jc,Ws as Jd,zC as Je,qW as Jf,ut as Jg,cr as K,Zb as Ka,Oy as Kb,gx as Kc,yg as Kd,HC as Ke,JW as Kf,Ye as Kg,ja as L,ep as La,_y as Lb,ta as Lc,hg as Ld,UC as Le,ZW as Lf,gT as Lg,$i as M,jt as Ma,nc as Mb,Uc as Mc,DS as Md,$C as Me,pm as Mf,mT as Mg,en as N,np as Na,rc as Nb,$c as Nc,FS as Nd,YC as Ne,zt as Nf,pT as Ng,Kf as O,kd as Oa,Gy as Ob,jc as Oc,AS as Od,KC as Oe,s0 as Of,yT as Og,Qf as P,Rd as Pa,ic as Pb,rt as Pc,xg as Pd,Gg as Pe,l0 as Pf,hT as Pg,Nr as Q,rp as Qa,Zr as Qb,ys as Qc,Fe as Qd,wg as Qe,u0 as Qf,xT as Qg,pd as R,op as Ra,Yy as Rb,bx as Rc,Sg as Rd,zg as Re,d0 as Rf,ST as Rg,yd as S,Xa as Sa,Ky as Sb,px as Sc,US as Sd,bo as Se,c0 as Sf,wm as Sg,hd as T,Vd as Ta,Qy as Tb,yx as Tc,sa as Td,at as Te,g0 as Tf,zm as Tg,He as U,Od as Ua,sc as Ub,hx as Uc,$S as Ud,Hg as Ue,ym as Uf,Xs as Ug,Zf as V,qa as Va,Et as Vb,xx as Vc,jS as Vd,Ug as Ve,lt as Vf,Qs as Vg,eb as W,ip as Wa,rh as Wb,Yc as Wc,YS as Wd,rW as We,y0 as Wf,Hm as Wg,tb as X,ap as Xa,oh as Xb,Mt as Xc,KS as Xd,oW as Xe,h0 as Xf,Qt as Xg,Sd as Y,sp as Ya,ih as Yb,Ax as Yc,QS as Yd,iW as Ye,x0 as Yf,Mo as Yg,zr as Z,lp as Za,us as Zb,Ix as Zc,XS as Zd,aW as Ze,Tm as Zf,FT as Zg,rb as _,up as _a,cc as _b,kx as _c,qS as _d,$g as _e,We as _f,AT as _g,hr as a,ib as aa,cp as ab,ch as ac,Ox as ad,ot as ae,yo as af,B0 as ag,kT as ah,rP as b,Cd as ba,gp as bb,gh as bc,xs as bd,lC as be,ho as bf,P0 as bg,RT as bh,oP as c,lb as ca,mp as cb,mh as cc,_x as cd,uC as ce,sW as cf,M0 as cg,VT as ch,ld as d,mb as da,fp as db,gc as dc,rg as dd,dC as de,Kg as df,D0 as dg,$m as dh,Or as e,fb as ea,bp as eb,mc as ec,Ss as ed,cC as ee,lW as ef,A0 as eg,Do as eh,Tt as f,bb as fa,pp as fb,bh as fc,Nx as fd,gC as fe,uW as ff,I0 as fg,jm as fh,Cf as g,Ld as ga,xp as gb,pc as gc,Gx as gd,la as ge,dW as gf,k0 as gg,Ym as gh,Wf as h,$r as ha,Sp as hb,yc as hc,wx as hd,Pg as he,Jg as hf,R0 as hg,Km as hh,Tf as i,jr as ia,Ud as ib,hc as ic,og as id,Mg as ie,At as if,zs as ig,Xm as ih,vf as j,Qa as ja,$d as jb,xc as jc,ig as jd,Dg as je,xo as jf,vm as jg,qm as jh,Ef as k,Wb as ka,jd as kb,Sc as kc,ra as kd,Fg as ke,Is as kf,ws as kg,Jm as kh,Bf as l,Tb as la,ce as lb,Cc as lc,Hx as ld,X as le,LW as lf,Sa as lg,qs as lh,Pf as m,vb as ma,qr as mb,Wc as mc,Ux as md,Bs as me,EW as mf,Lm as mg,Zm as mh,If as n,Ki as na,Fp as nb,ds as nc,$x as nd,TC as ne,BW as nf,Em as ng,_T as nh,Ha as o,Ed as oa,Ap as ob,Sh as oc,ag as od,vC as oe,ks as of,Bo as og,$T as oh,cd as p,nt as pa,Ip as pb,Ch as pc,jx as pd,LC as pe,em as pf,Bm as pg,jT as ph,kf as q,Bb as qa,kp as qb,Wh as qc,Yx as qd,EC as qe,Rs as qf,O0 as qg,YT as qh,Rf as r,Pb as ra,Rp as rb,Th as rc,cg as rd,BC as re,PW as rf,Mm as rg,KT as rh,Vf as s,Mb as sa,Vp as sb,vh as sc,ue as sd,PC as se,lm as sf,et as sg,nf as sh,Nf as t,Db as ta,Za as tb,Lh as tc,dS as td,MC as te,DW as tf,z0 as tg,rf as th,Gf as u,Fb as ua,Kd as ub,Eh as uc,cS as ud,kg as ue,_s as uf,Hs as ug,of as uh,gd as v,Ab as va,zp as vb,Ac as vc,gS as vd,qe as ve,_W as vf,H0 as vg,qT as vh,wf as w,Ib as wa,Hp as wb,oo as wc,mS as wd,DC as we,ga as wf,U0 as wg,JT as wh,zf as x,kb as xa,Up as xb,qh as xc,fS as xd,FC as xe,Ns as xf,$0 as xg,ZT as xh,Ua as y,Rb as ya,qd as yb,Zh as yc,bS as yd,AC as ye,GW as yf,Im as yg,ev as yh,md as z,Md as za,Be as zb,ex as zc,mg as zd,kC as ze,gm as zf,km as zg};