blecsd 0.1.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.
- package/LICENSE +20 -0
- package/README.md +220 -0
- package/dist/3d/index.d.ts +5 -0
- package/dist/3d/index.js +1 -0
- package/dist/audio/index.d.ts +177 -0
- package/dist/audio/index.js +1 -0
- package/dist/border-D_Jb4ZJV.d.ts +257 -0
- package/dist/cell-DwIu2ryP.d.ts +505 -0
- package/dist/chunk-2UBBZFE4.js +1 -0
- package/dist/chunk-35LCBY6P.js +1 -0
- package/dist/chunk-3B7MIVW6.js +1 -0
- package/dist/chunk-3EGGGI5J.js +3 -0
- package/dist/chunk-4LWWONFK.js +1 -0
- package/dist/chunk-4X4N4HNQ.js +2 -0
- package/dist/chunk-5PELJRUQ.js +1 -0
- package/dist/chunk-AEJIX2MW.js +1 -0
- package/dist/chunk-AQ7LW75B.js +1 -0
- package/dist/chunk-AXZQAH4X.js +1 -0
- package/dist/chunk-B6Z2JFRY.js +1 -0
- package/dist/chunk-BCADUCOZ.js +1 -0
- package/dist/chunk-C5PCEQ6G.js +1 -0
- package/dist/chunk-CIK4AMUA.js +1 -0
- package/dist/chunk-DNRXW56C.js +1 -0
- package/dist/chunk-FC5FFAAC.js +12 -0
- package/dist/chunk-FGHEFXLK.js +1 -0
- package/dist/chunk-FYEBZAWN.js +1 -0
- package/dist/chunk-G7GIWWLE.js +1 -0
- package/dist/chunk-GYHI26UE.js +1 -0
- package/dist/chunk-H2YAOJDW.js +1 -0
- package/dist/chunk-J4JZ2NU2.js +1 -0
- package/dist/chunk-JKVHO4LH.js +1 -0
- package/dist/chunk-K2B2OXQ5.js +5 -0
- package/dist/chunk-K37L3G4Z.js +4 -0
- package/dist/chunk-KD55INV7.js +1 -0
- package/dist/chunk-KFAK4A3G.js +1 -0
- package/dist/chunk-LCN2ZITE.js +1 -0
- package/dist/chunk-LYSK5S63.js +1 -0
- package/dist/chunk-NZ55KBM6.js +1 -0
- package/dist/chunk-OMMJ7B5P.js +1 -0
- package/dist/chunk-OUXUPF3V.js +33 -0
- package/dist/chunk-OVT2PPGW.js +19 -0
- package/dist/chunk-P6CJO3BC.js +1 -0
- package/dist/chunk-PSXXMBVJ.js +1 -0
- package/dist/chunk-PXXGH3BV.js +1 -0
- package/dist/chunk-QIKIOVP2.js +1 -0
- package/dist/chunk-SHUC6JWA.js +1 -0
- package/dist/chunk-TDXJDLY6.js +6 -0
- package/dist/chunk-TWSWTBYL.js +1 -0
- package/dist/chunk-TYMY2TBR.js +3 -0
- package/dist/chunk-VNZ6CWJA.js +2 -0
- package/dist/chunk-VOCM5T2G.js +5 -0
- package/dist/chunk-W5OU7Z6J.js +1 -0
- package/dist/chunk-WNG4A3K7.js +4 -0
- package/dist/chunk-XQIGERNI.js +1 -0
- package/dist/chunk-XZA63ZPO.js +1 -0
- package/dist/chunk-YAMOSPWB.js +4 -0
- package/dist/chunk-YD6ULIUR.js +1 -0
- package/dist/chunk-Z4EZERNE.js +1 -0
- package/dist/cli/init.d.ts +86 -0
- package/dist/cli/init.js +179 -0
- package/dist/color-B78w3zH-.d.ts +79 -0
- package/dist/components/index.d.ts +10298 -0
- package/dist/components/index.js +1 -0
- package/dist/core/index.d.ts +6700 -0
- package/dist/core/index.js +1 -0
- package/dist/debug/index.d.ts +711 -0
- package/dist/debug/index.js +1 -0
- package/dist/doubleBuffer-CKQFmlPN.d.ts +95 -0
- package/dist/errors/index.d.ts +1110 -0
- package/dist/errors/index.js +1 -0
- package/dist/events-BbbxkgvX.d.ts +125 -0
- package/dist/game/index.d.ts +486 -0
- package/dist/game/index.js +1 -0
- package/dist/gameLoop-BIPW7-OY.d.ts +219 -0
- package/dist/index-zSGJ2eUk.d.ts +3156 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +1 -0
- package/dist/input/index.d.ts +158 -0
- package/dist/input/index.js +1 -0
- package/dist/inputActions-CefRUBuT.d.ts +2637 -0
- package/dist/keyParser-Bwm8-l7v.d.ts +229 -0
- package/dist/mouseParser-Cfrbn3AX.d.ts +177 -0
- package/dist/parser-iMHmQuUh.d.ts +265 -0
- package/dist/program-BZaKqDKH.d.ts +141 -0
- package/dist/renderable-jTMOA-GK.d.ts +302 -0
- package/dist/scheduler-DcfoFuum.d.ts +86 -0
- package/dist/schemas/index.d.ts +936 -0
- package/dist/schemas/index.js +1 -0
- package/dist/systems/index.d.ts +4036 -0
- package/dist/systems/index.js +1 -0
- package/dist/terminal/index.d.ts +7357 -0
- package/dist/terminal/index.js +1 -0
- package/dist/terminus-14-bold-HWSPRLJD.js +1 -0
- package/dist/terminus-14-normal-T3SWMH4D.js +1 -0
- package/dist/tilemap-D1HJvKy3.d.ts +1211 -0
- package/dist/types-BcsvoKzf.d.ts +68 -0
- package/dist/utils/index.d.ts +6104 -0
- package/dist/utils/index.js +1 -0
- package/dist/viewport3d-xI33-_wq.d.ts +182 -0
- package/dist/virtualScrollback-DvZTRU8a.d.ts +274 -0
- package/dist/virtualViewport-Dx2iJliO.d.ts +2334 -0
- package/dist/virtualizedLineStore-DwPEvPkk.d.ts +297 -0
- package/dist/widgets/bigText.d.ts +230 -0
- package/dist/widgets/bigText.js +1 -0
- package/dist/widgets/fonts/index.d.ts +211 -0
- package/dist/widgets/fonts/index.js +1 -0
- package/dist/widgets/index.d.ts +8591 -0
- package/dist/widgets/index.js +1 -0
- package/package.json +213 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {e as e$4,i,o as o$1,h as h$2}from'./chunk-QIKIOVP2.js';import {a as a$2}from'./chunk-XZA63ZPO.js';import {a as a$3}from'./chunk-AXZQAH4X.js';import {e}from'./chunk-3EGGGI5J.js';import {mb as mb$1,Q,z as z$1,Z,q,Y,qb as qb$2,y as y$1,P,J as J$1,G as G$2,E as E$2}from'./chunk-LYSK5S63.js';import {j as j$1,fa as fa$1,eb as eb$1,hb as hb$1,vb as vb$1,Bb as Bb$1,Ha as Ha$1,Na as Na$1,Da as Da$1,xa as xa$1,Ea as Ea$1,za as za$1,wa as wa$1,va as va$1,sa as sa$1,ra,r as r$1,L as L$1,R,I,H as H$1,G as G$1,F as F$1,Aa as Aa$1,Ca as Ca$1,Ba as Ba$1,l as l$1,qa as qa$1,ta,D as D$1,C as C$1,E as E$1,B as B$1,x as x$2,u as u$1,v as v$1,q as q$2,gb as gb$1,Jb as Jb$1,Cb as Cb$1,Gb as Gb$1,Hb as Hb$1,Eb as Eb$1,Fb as Fb$1,yb as yb$1,xb as xb$1,Ab as Ab$1,zb as zb$1,Ib as Ib$1,qb as qb$1,wb as wb$1,pb as pb$1,tb as tb$1,sb as sb$1,rb as rb$1,nb as nb$1,mb as mb$2,lb as lb$1,kb as kb$1,ub as ub$1,ib as ib$1,jb as jb$1,Qa as Qa$1,Oa as Oa$1,Wa as Wa$1,Sa as Sa$1,Ta as Ta$1,k as k$1,fb as fb$1,Pa as Pa$1,Va as Va$1,Qb as Qb$1,dc,fc as fc$1,Sb as Sb$1,Tb as Tb$1,cc as cc$1,Vb as Vb$1,Zb as Zb$1,Yb as Yb$1,bc as bc$1,ac as ac$1,$b as $b$1,_b as _b$1,Xb as Xb$1,Wb as Wb$1}from'./chunk-K37L3G4Z.js';import {e as e$5,d as d$4,p as p$1,y as y$2,u as u$2,q as q$3,n as n$2,m as m$1,o as o$2,l as l$2,s as s$3,r as r$4}from'./chunk-TWSWTBYL.js';import {g as g$1,h as h$1,i as i$1,o as o$3,n as n$3,m as m$2,w as w$1}from'./chunk-VOCM5T2G.js';import {b,l,H,G,F,E,D,C,B,A,z as z$2,y,x as x$1,s as s$2,v,u,n as n$1,q as q$1,r,o,p,t as t$1,m}from'./chunk-PSXXMBVJ.js';import {s,a,j as j$2,k,r as r$3,b as b$1,d as d$5,f as f$3,e as e$6,c}from'./chunk-LCN2ZITE.js';import {e as e$2,f as f$2}from'./chunk-FYEBZAWN.js';import {W,s as s$1,L,d,M,j,Y as Y$1,$,_ as _$1,g,x,O,r as r$2,t,K as K$1}from'./chunk-W5OU7Z6J.js';import {f,e as e$1,c as c$1}from'./chunk-SHUC6JWA.js';import {f as f$1,d as d$2}from'./chunk-G7GIWWLE.js';import {n,d as d$1,e as e$3,h}from'./chunk-PXXGH3BV.js';import {a as a$1,d as d$3}from'./chunk-5PELJRUQ.js';import {z}from'zod';import {readdirSync,statSync}from'fs';import {resolve,dirname,join,basename}from'path';import {createRequire}from'module';import {pathToFileURL}from'url';s();n();f();var ia=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Ar=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Nl=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(),wl=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(),la=z.object({left:Ar.optional(),top:Ar.optional(),right:Ar.optional(),bottom:Ar.optional(),width:ia.optional(),height:ia.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:Nl,padding:wl,content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional()}),Ul=1e4,rn={isBox:new Uint8Array(Ul)};function Hl(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function zl(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function Gl(e){let{BORDER_DOUBLE:n,BORDER_ROUNDED:r,BORDER_BOLD:o,BORDER_ASCII:t}=(s(),d$3(r$3));switch(e){case "single":return b$1;case "double":return n;case "rounded":return r;case "bold":return o;case "ascii":return t}}function $l(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function aa(e){return e===void 0?0:typeof e=="number"?e:0}function sa(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function jl(e,n,r){let o=aa(r.left),t=aa(r.top);s$1(e,n,o,t);let i=sa(r.width),a=sa(r.height);L(e,n,i,a);}function Yl(e,n,r){r.fg===void 0&&r.bg===void 0||d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function Kl(e,n,r){let o=r.type?$l(r.type):1;if(j$2(e,n,{type:o,fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0}),r.ch){let t=typeof r.ch=="string"?Gl(r.ch):r.ch;k(e,n,t);}}function Ql(e,n,r){typeof r=="number"?b(e,n,{left:r,top:r,right:r,bottom:r}):b(e,n,r);}function Xl(e,n,r){if(r.content===void 0)return;let o={};r.align&&(o.align=Hl(r.align)),r.valign&&(o.valign=zl(r.valign)),e$2(e,n,r.content,o);}function bo(e,n,r={}){let o=la.parse(r),t=n;rn.isBox[t]=1,jl(e,t,o),Yl(e,t,o),o.border&&Kl(e,t,o.border),o.padding!==void 0&&Ql(e,t,o.padding),Xl(e,t,o),W(e,t,{focusable:true});let i={eid:t,show(){return j(e,t,true),i},hide(){return j(e,t,false),i},move(a,s){return x(e,t,a,s),g(e,t),i},setPosition(a,s){return s$1(e,t,a,s),g(e,t),i},setContent(a){return e$2(e,t,a),g(e,t),i},getContent(){return f$2(e,t)},focus(){return _$1(e,t),i},blur(){return $(e,t),i},isFocused(){return Y$1(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},destroy(){rn.isBox[t]=0,e$3(e,t);}};return i}function ql(e,n,r){return e$2(e,n,r),g(e,n),n}function Jl(e,n){return f$2(e,n)}function Zl(e,n){return rn.isBox[n]===1}function eu(){rn.isBox.fill(0);}function tu(e){return e===""?[]:e.split(`
|
|
2
|
+
`)}function mt(e){return e.join(`
|
|
3
|
+
`)}function et(e,n){let r=f$2(e,n);return tu(r)}function nu(e,n){let r=f$2(e,n);if(r==="")return 0;let o=1;for(let t of r)t===`
|
|
4
|
+
`&&o++;return o}function ua(e,n,r){let o=et(e,n);return r<0||r>=o.length?"":o[r]??""}function da(e,n,r,o){let t=et(e,n);return r<0||r>=t.length||(t[r]=o,e$2(e,n,mt(t)),g(e,n)),n}function ru(e,n,r){return ua(e,n,r)}function ou(e,n,r,o){return da(e,n,r,o)}function fo(e,n,r,o){let t=et(e,n),i=Math.max(0,Math.min(r,t.length));if(t.splice(i,0,o),e$2(e,n,mt(t)),g(e,n),t$1(e,n)){let a=n$1(e,n);i<=a.y&&m(e,n,a.x,a.y+1);}return n}function ca(e,n,r){return fo(e,n,0,r)}function ga(e,n,r){let o=et(e,n);return fo(e,n,o.length,r)}function po(e,n,r,o=1){let t=et(e,n);if(r<0||r>=t.length||o<=0)return n;let i=Math.min(o,t.length-r);if(t.splice(r,i),e$2(e,n,mt(t)),g(e,n),t$1(e,n)){let a=n$1(e,n),s=Math.max(0,t.length-1),l=a.y;if(r<a.y){let d=Math.min(i,a.y-r);l=a.y-d;}l=Math.max(0,Math.min(l,s)),m(e,n,a.x,l);}return n}function iu(e,n,r=1){return po(e,n,0,r)}function au(e,n,r=1){let o=et(e,n);if(o.length===0)return n;let t=Math.max(0,o.length-r);return po(e,n,t,r)}function su(e,n){return e$2(e,n,""),g(e,n),t$1(e,n)&&m(e,n,0,0),n}function lu(e,n,r){if(e$2(e,n,mt(r)),g(e,n),t$1(e,n)){let o=n$1(e,n),t=Math.max(0,r.length-1);o.y>t&&m(e,n,o.x,t);}return n}function uu(e,n,r){return ga(e,n,r)}function du(e,n){let r=et(e,n);if(r.length===0)return "";let o=r.pop()??"";if(e$2(e,n,mt(r)),g(e,n),t$1(e,n)){let t=n$1(e,n),i=Math.max(0,r.length-1);t.y>i&&m(e,n,t.x,i);}return o}function cu(e,n){let r=et(e,n);if(r.length===0)return "";let o=r.shift()??"";if(e$2(e,n,mt(r)),g(e,n),t$1(e,n)){let t=n$1(e,n);t.y>0&&m(e,n,t.x,t.y-1);}return o}function gu(e,n,r){return ca(e,n,r)}function mu(e,n,r,o){let t=et(e,n);if(r<0||r>=t.length)return n;for(let i=0;i<o.length;i++){let a=r+i;if(a>=t.length)break;t[a]=o[i]??"";}return e$2(e,n,mt(t)),g(e,n),n}function bu(e,n,r,o,t){let i=et(e,n),a=t?i.splice(r,o,...t):i.splice(r,o);if(e$2(e,n,mt(i)),g(e,n),t$1(e,n)){let s=(t?.length??0)-a.length,l=n$1(e,n);if(r<=l.y&&s!==0){let d=Math.max(0,l.y+s),m$1=Math.max(0,i.length-1);m(e,n,l.x,Math.min(d,m$1));}else {let d=Math.max(0,i.length-1);l.y>d&&m(e,n,l.x,d);}}return a}s();n();f();var ma=1e4,Tu=40,Su=20,Cu="/",Wu="..",Lu=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()}),Eu=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()})]),fa=z.object({cwd:z.string().optional(),showHidden:z.boolean().optional().default(false),filePattern:z.string().optional(),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:Lu.optional(),padding:Eu.optional()}),Te={isFileManager:new Uint8Array(ma),selectedIndex:new Uint32Array(ma)},Ie=new Map;function Pu(e){return typeof e=="object"?e:e===void 0||e==="single"?b$1:b$1}function vu(e,n){let o=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${o}$`,"i").test(e)}function Bu(e){try{let n=readdirSync(e),r=[];for(let o of n){let t=join(e,o);try{let i=statSync(t);r.push({name:o,path:t,isDirectory:i.isDirectory(),size:i.isDirectory()?0:i.size});}catch{}}return r}catch{return []}}function Du(e){return [...e].sort((n,r)=>n.isDirectory!==r.isDirectory?n.isDirectory?-1:1:n.name.localeCompare(r.name))}function Mu(e,n,r){return e.filter(o=>!(!n&&o.name.startsWith(".")||r&&!o.isDirectory&&!vu(o.name,r)))}function Rr(e){let n;try{n=e.readDirFn(e.cwd);}catch{return []}let r=Mu(n,e.showHidden,e.filePattern);return Du(r)}function Au(e){let n=[],r=basename(e.cwd)||e.cwd;n.push(`[${r}]`),n.push(Wu);for(let o=0;o<e.entries.length;o++){let t=e.entries[o],i=o===Te.selectedIndex[0]?"> ":" ",a=t.isDirectory?Cu:"";n.push(`${i}${t.name}${a}`);}return n.join(`
|
|
5
|
+
`)}function Ru(e,n,r,o){r===void 0&&o===void 0||d(e,n,{fg:r!==void 0?e$1(r):void 0,bg:o!==void 0?e$1(o):void 0});}function Vu(e,n,r){if(r?.type==="none")return;let o=r?.type==="bg"?2:1;j$2(e,n,{type:o,fg:r?.fg!==void 0?e$1(r.fg):void 0,bg:r?.bg!==void 0?e$1(r.bg):void 0}),k(e,n,Pu(r?.ch));}function Iu(e,n,r){if(typeof r=="number"){b(e,n,{left:r,top:r,right:r,bottom:r});return}r&&b(e,n,{left:r.left??0,top:r.top??0,right:r.right??0,bottom:r.bottom??0});}function Ht(e,n,r){let o=Au(r);e$2(e,n,o,{align:0,valign:0}),g(e,n);}function ku(e,n={}){let r=fa.parse(n),o=d$1(e),t=r.width??Tu,i=r.height??Su,a=r.cwd?resolve(r.cwd):process.cwd();Te.isFileManager[o]=1,Te.selectedIndex[o]=0;let s={cwd:a,showHidden:r.showHidden,filePattern:r.filePattern,width:t,height:i,entries:[],onSelectCallbacks:[],onNavigateCallbacks:[],readDirFn:Bu};return Ie.set(o,s),s.entries=Rr(s),s$1(e,o,r.left??0,r.top??0),L(e,o,t,i),Ru(e,o,r.fg,r.bg),Vu(e,o,r.border),Iu(e,o,r.padding),Ht(e,o,s),j(e,o,true),Fu(e,o)}function Fu(e,n){let r={eid:n,show(){return j(e,n,true),g(e,n),r},hide(){return j(e,n,false),g(e,n),r},move(o,t){return x(e,n,o,t),g(e,n),r},setPosition(o,t){return s$1(e,n,o,t),g(e,n),r},center(o,t){let i=Ie.get(n);if(!i)return r;let a=Math.max(0,Math.floor((o-i.width)/2)),s=Math.max(0,Math.floor((t-i.height)/2));return s$1(e,n,a,s),g(e,n),r},setCwd(o){let t=Ie.get(n);return t&&(t.cwd=resolve(o),t.entries=Rr(t),Te.selectedIndex[n]=0,Ht(e,n,t)),r},getCwd(){return Ie.get(n)?.cwd??""},getSelected(){let o=Ie.get(n);if(!o)return;let t=Te.selectedIndex[n]??0;return o.entries[t]},refresh(){let o=Ie.get(n);if(!o)return r;o.entries=Rr(o);let t=Math.max(0,o.entries.length-1);return (Te.selectedIndex[n]??0)>t&&(Te.selectedIndex[n]=t),Ht(e,n,o),r},getEntries(){return Ie.get(n)?.entries??[]},onSelect(o){let t=Ie.get(n);return t&&t.onSelectCallbacks.push(o),r},onNavigate(o){let t=Ie.get(n);return t&&t.onNavigateCallbacks.push(o),r},destroy(){Te.isFileManager[n]=0,Te.selectedIndex[n]=0,Ie.delete(n),e$3(e,n);}};return r}function _u(e,n,r){let o=Te.selectedIndex[n]??0,t=r.entries[o];if(t)if(t.isDirectory)pa(e,n,r,t.path);else for(let i of r.onSelectCallbacks)i(t);}function pa(e,n,r,o){r.cwd=o,r.entries=Rr(r),Te.selectedIndex[n]=0,Ht(e,n,r);for(let t of r.onNavigateCallbacks)t(o);}function Ou(e,n,r){if(Te.isFileManager[n]!==1)return false;let o=Ie.get(n);if(!o)return false;switch(r){case "up":{let t=Te.selectedIndex[n]??0;return t>0&&(Te.selectedIndex[n]=t-1,Ht(e,n,o)),true}case "down":{let t=Te.selectedIndex[n]??0;return t<o.entries.length-1&&(Te.selectedIndex[n]=t+1,Ht(e,n,o)),true}case "enter":return _u(e,n,o),true;case "backspace":{let t=dirname(o.cwd);return t!==o.cwd&&pa(e,n,o,t),true}default:return false}}function Nu(e,n){return Te.isFileManager[n]===1}function wu(){Te.isFileManager.fill(0),Te.selectedIndex.fill(0),Ie.clear();}function Uu(e,n){let r=Ie.get(e);r&&(r.readDirFn=n);}var Hu=500,zu=100,Gu=2,$u=1,ju=4294967295,Yu=4281545523,Ku=4287137928,Ee=new Map;function xa(e){return typeof e=="string"?{text:e}:e}function Qu(e){return e.split(`
|
|
6
|
+
`)}function ya(e,n){let r=0;for(let o of e)o.length>r&&(r=o.length);return r+n*2}function ha(e,n){return e.length+n*2}function Xu(e,n,r,o,t,i){let a=e,s=n;return a+r>t&&(a=t-r),a<0&&(a=0),s+o>i&&(s=i-o),s<0&&(s=0),{x:a,y:s}}function yo(e={}){let n=e.showDelay??500,r=e.hideDelay??100,o=e.offsetX??2,t=e.offsetY??1,i=e.screenWidth??80,a=e.screenHeight??24,s={fg:e.style?.fg??4294967295,bg:e.style?.bg??4281545523,border:e.style?.border??4287137928,padding:e.style?.padding??1},l=false,d=null,m="",f=[],g={x:0,y:0},u=null,b=null,p=null,W=0,P=0,y=false,T={setHoverText(S,C){Ee.set(S,xa(C));},clearHoverText(S){Ee.delete(S),d===S&&T.hideNow();},getHoverText(S){return Ee.get(S)},hasHoverText(S){return Ee.has(S)},updateMouse(S,C,H){W=S,P=C,H!==p&&(p=H,H!==null&&Ee.has(H)?(u=Date.now(),b=null,y=true):l?(b=Date.now(),u=null,y=false):(u=null,b=null,y=false)),l&&d!==null&&L(S,C);},update(S){let C=Date.now();if(y&&u!==null&&p!==null){let Me=Ee.get(p)?.delay??n;C-u>=Me&&(T.showNow(p,W,P),y=false);}b!==null&&l&&C-b>=r&&T.hideNow();},showNow(S,C,H){let Me=Ee.get(S);Me&&(l=true,d=S,m=Me.text,f=Qu(Me.text),u=null,b=null,y=false,L(C,H));},hideNow(){l=false,d=null,m="",f=[],u=null,b=null,y=false;},getState(){return {visible:l,sourceEntity:d,text:m,position:g,hoverStartTime:u}},isVisible(){return l},getRenderData(){if(!l||d===null)return null;let S=Ee.get(d),C={fg:S?.style?.fg??s.fg,bg:S?.style?.bg??s.bg,border:S?.style?.border??s.border,padding:S?.style?.padding??s.padding},H=ya(f,C.padding),Me=ha(f,C.padding);return {x:g.x,y:g.y,width:H,height:Me,text:m,lines:f,style:C}},setScreenSize(S,C){i=S,a=C;},clearAll(){Ee.clear(),T.hideNow();}};function L(S,C){let H=d!==null?Ee.get(d):void 0,Me={fg:H?.style?.fg??s.fg,bg:H?.style?.bg??s.bg,border:H?.style?.border??s.border,padding:H?.style?.padding??s.padding},vt=ya(f,Me.padding),Bn=ha(f,Me.padding),Kt=S+o,Qt=C+t;g=Xu(Kt,Qt,vt,Bn,i,a);}return T}function qu(e,n){Ee.set(e,xa(n));}function Ju(e){Ee.delete(e);}function Zu(e){return Ee.get(e)}function ed(e){return Ee.has(e)}function td(){Ee.clear();}function nd(){return Ee.size}function rd(){Ee.clear();}n();z.number().int().min(0).max(255).transform(e=>e);var od=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)});od.extend({a:z.number().min(0).max(1)});var id=z.object({h:z.number().min(0).max(360),s:z.number().min(0).max(100),l:z.number().min(0).max(100)});id.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 ad=[{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 sd(){let e=[0,95,135,175,215,255],n=[];for(let r=0;r<6;r++)for(let o=0;o<6;o++)for(let t=0;t<6;t++)n.push({r:e[r]??0,g:e[o]??0,b:e[t]??0});return n}function ld(){let e=[];for(let n=0;n<24;n++){let r=8+n*10;e.push({r,g:r,b:r});}return e}var ud=sd(),dd=ld(),on=[...ad,...ud,...dd];function cd(e){let n=r=>r.toString(16).padStart(2,"0");return `#${n(e.r)}${n(e.g)}${n(e.b)}`}on.map(cd);function bt(e){let n=0,r=Number.POSITIVE_INFINITY;for(let o=0;o<256;o++){let t=on[o];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<r&&(r=l,n=o),l===0)break}return n}function Ta(e){return `38;5;${e}`}function Sa(e){return `48;5;${e}`}function Ca(e,n){let r=e.a,o=1-r;return {r:Math.round(e.r*r+n.r*o),g:Math.round(e.g*r+n.g*o),b:Math.round(e.b*r+n.b*o)}}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 Wa=" .:-=+*#%@",La="\u2580",md=10240;function bd(e){let n=Math.max(0,Math.min(1,e)),r=Math.round(n*(Wa.length-1));return Wa[r]??" "}function Ea(e,n,r){return (e*.299+n*.587+r*.114)/255}function fd(e,n,r){if(n<=0||r<=0)return {width:0,height:0,data:new Uint8Array(0)};let o=new Uint8Array(n*r*4),t=e.width/n,i=e.height/r;for(let a=0;a<r;a++){let s=Math.min(Math.floor(a*i),e.height-1);for(let l=0;l<n;l++){let d=Math.min(Math.floor(l*t),e.width-1),m=(s*e.width+d)*4,f=(a*n+l)*4;o[f]=e.data[m]??0,o[f+1]=e.data[m+1]??0,o[f+2]=e.data[m+2]??0,o[f+3]=e.data[m+3]??0;}}return {width:n,height:r,data:o}}function pd(e,n){let r=e.a/255;return Ca({r:e.r,g:e.g,b:e.b,a:r},n)}function yd(e,n,r){let o=(r*e.width+n)*4;return {r:e.data[o]??0,g:e.data[o+1]??0,b:e.data[o+2]??0,a:e.data[o+3]??0}}function an(e,n,r,o){let t=yd(e,n,r);return t.a===255?{r:t.r,g:t.g,b:t.b}:t.a===0?o:pd(t,o)}function hd(e,n,r){for(let o=0;o<r;o++)for(let t=0;t<n;t++){let i=o*n+t,a=e[i];if(!a)continue;let s=bt(a),l=on[s];if(!l)continue;let d=a.r-l.r,m=a.g-l.g,f=a.b-l.b;Vr(e,n,r,t+1,o,d,m,f,7/16),Vr(e,n,r,t-1,o+1,d,m,f,3/16),Vr(e,n,r,t,o+1,d,m,f,5/16),Vr(e,n,r,t+1,o+1,d,m,f,1/16);}}function Vr(e,n,r,o,t,i,a,s,l){if(o<0||o>=n||t<0||t>=r)return;let d=t*n+o,m=e[d];m&&(m.r=Math.max(0,Math.min(255,Math.round(m.r+i*l))),m.g=Math.max(0,Math.min(255,Math.round(m.g+a*l))),m.b=Math.max(0,Math.min(255,Math.round(m.b+s*l))));}function xd(e,n,r){let o=Math.ceil(e.height/2),t=e.width;if(r)return Td(e,n,t,o);let i=[];for(let a=0;a<o;a++){let s=[];for(let l=0;l<t;l++){let d=a*2,m=a*2+1,f=an(e,l,d,n),g=m<e.height?an(e,l,m,n):n,u=bt(f),b=bt(g);s.push({char:La,fg:u,bg:b});}i.push(s);}return {width:t,height:o,cells:i}}function Td(e,n,r,o){let t=[];for(let a=0;a<e.height;a++)for(let s=0;s<e.width;s++){let l=an(e,s,a,n);t.push({r:l.r,g:l.g,b:l.b});}hd(t,e.width,e.height);let i=[];for(let a=0;a<o;a++){let s=[];for(let l=0;l<r;l++){let d=a*2,m=a*2+1,f=t[d*e.width+l]??{r:0,g:0,b:0},g=m<e.height?t[m*e.width+l]??{r:0,g:0,b:0}:n,u=bt(f),b=bt(g);s.push({char:La,fg:u,bg:b});}i.push(s);}return {width:r,height:o,cells:i}}function Sd(e,n){let r=[];for(let o=0;o<e.height;o++){let t=[];for(let i=0;i<e.width;i++){let a=an(e,i,o,n),s=Ea(a.r,a.g,a.b),l=bd(s),d=bt(a);t.push({char:l,fg:d,bg:0});}r.push(t);}return {width:e.width,height:e.height,cells:r}}var Cd=[[1,8],[2,16],[4,32],[64,128]];function Wd(e,n,r,o,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=n*2+s,d=r*4+a;if(l>=e.width||d>=e.height)continue;let m=an(e,l,d,o);if(Ea(m.r,m.g,m.b)>=t){let g=Cd[a];g&&(i.pattern|=g[s]??0);}i.totalR+=m.r,i.totalG+=m.g,i.totalB+=m.b,i.count++;}return i}function Ld(e){let n=String.fromCodePoint(md+e.pattern),r=e.count>0?bt({r:Math.round(e.totalR/e.count),g:Math.round(e.totalG/e.count),b:Math.round(e.totalB/e.count)}):0;return {char:n,fg:r,bg:0}}function Ed(e,n){let r=Math.ceil(e.width/2),o=Math.ceil(e.height/4),t=[],i=.5;for(let a=0;a<o;a++){let s=[];for(let l=0;l<r;l++){let d=Wd(e,l,a,n,i);s.push(Ld(d));}t.push(s);}return {width:r,height:o,cells:t}}function ho(e,n){let r=n?.mode??"color",o=n?.dither??false,t=n?.background??{r:0,g:0,b:0},i=n?.width??e.width,a=n?.height;a!==void 0&&r==="color"&&(a=a*2),a!==void 0&&r==="braille"&&(a=a*4);let l=(r==="braille"&&n?.width?n.width*2:void 0)??i,d=a??e.height,m=l!==e.width||d!==e.height?fd(e,l,d):e;switch(r){case "color":return xd(m,t,o);case "ascii":return Sd(m,t);case "braille":return Ed(m,t)}}function xo(e){let n=[];for(let r of e.cells){let o="",t=-1,i=-1;for(let a of r)(a.fg!==t||a.bg!==i)&&(o+=`\x1B[${Ta(a.fg)};${Sa(a.bg)}m`,t=a.fg,i=a.bg),o+=a.char;n.push(o);}return `${n.join(`
|
|
7
|
+
`)}\x1B[0m`}var Pa=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)}),Pd=1e4,un={isImage:new Uint8Array(Pd)},ft=new Map,sn=new Map,St=new Map,ln=new Map,Gt=new Map,zt=new Map;function To(e,n){let r=ft.get(n);if(!r){e$2(e,n,""),Gt.delete(n);return}if((sn.get(n)??"ansi")!=="ansi"){e$2(e,n,"");return}let t=St.get(n)??"color",i=ln.get(n)??false,a=ho(r,{width:void 0,height:void 0,mode:t,dither:i});Gt.set(n,a);let s=xo(a);e$2(e,n,s);}function vd(e,n={}){let r=Pa.parse(n),o=d$1(e);s$1(e,o,r.x,r.y);let t=r.width??r.bitmap?.width??0,i=r.height??r.bitmap?.height??0;return L(e,o,t,i),un.isImage[o]=1,sn.set(o,r.type),St.set(o,r.renderMode),ln.set(o,r.dither),zt.set(o,r.visible),r.bitmap&&(ft.set(o,r.bitmap),To(e,o)),r.visible||j(e,o,false),Bd(e,o)}function Bd(e,n){return {get eid(){return n},show(){return zt.set(n,true),j(e,n,true),g(e,n),this},hide(){return zt.set(n,false),j(e,n,false),g(e,n),this},isVisible(){return zt.get(n)??false},move(r,o){let t=r$2.x[n]??0,i=r$2.y[n]??0;return s$1(e,n,t+r,i+o),g(e,n),this},setPosition(r,o){return s$1(e,n,r,o),g(e,n),this},getPosition(){return {x:r$2.x[n]??0,y:r$2.y[n]??0}},setImage(r){return ft.set(n,r),To(e,n),g(e,n),this},getImage(){return ft.get(n)},getType(){return sn.get(n)??"ansi"},getCellMap(){return Gt.get(n)},setRenderMode(r){return St.set(n,r),To(e,n),g(e,n),this},getRenderMode(){return St.get(n)??"color"},render(){let r=ft.get(n);if(!r)return "";let o=St.get(n)??"color",t=ln.get(n)??false,i=ho(r,{mode:o,dither:t});return xo(i)},destroy(){un.isImage[n]=0,ft.delete(n),sn.delete(n),St.delete(n),ln.delete(n),Gt.delete(n),zt.delete(n),e$3(e,n);}}}function Dd(e,n){return un.isImage[n]===1}function Md(e){return ft.get(e)}function Ad(e){return Gt.get(e)}function Rd(){un.isImage.fill(0),ft.clear(),sn.clear(),St.clear(),ln.clear(),Gt.clear(),zt.clear();}n();f();var va=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Ba=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Aa=z.object({left:va.optional(),top:va.optional(),width:Ba.optional(),height:Ba.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()}),pt=1e4,w={isLayout:new Uint8Array(pt),mode:new Uint8Array(pt),gap:new Float32Array(pt),wrap:new Uint8Array(pt),justify:new Uint8Array(pt),align:new Uint8Array(pt),cols:new Uint8Array(pt),direction:new Uint8Array(pt)};function Da(e){return e===void 0?0:typeof e=="number"?e:0}function Ma(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function Vd(e){switch(e){case "inline":return 0;case "grid":return 1;case "flex":return 2}}function So(e){switch(e){case 0:return "inline";case 1:return "grid";case 2:return "flex";default:return "inline"}}function Id(e){switch(e){case "start":return 0;case "center":return 1;case "end":return 2;case "space-between":return 3}}function kd(e){switch(e){case "start":return 0;case "center":return 1;case "end":return 2}}function Fd(e,n){return n.map(r=>{let o=M(e,r);return {eid:r,width:o?.width??1,height:o?.height??1}})}function Ra(e,n,r,o){let t=new Map,i=0,a=0,s=0;for(let l of e)o&&i>0&&i+l.width>n&&(i=0,a+=s+r,s=0),t.set(l.eid,{x:i,y:a}),i+=l.width+r,s=Math.max(s,l.height);return t}function Va(e,n,r){let o=new Map,t=new Array(n).fill(0),i=[];return e.forEach((a,s)=>{let l=s%n,d=Math.floor(s/n);t[l]=Math.max(t[l],a.width),i[d]||(i[d]=0),i[d]=Math.max(i[d],a.height);}),e.forEach((a,s)=>{let l=s%n,d=Math.floor(s/n),m=0;for(let g=0;g<l;g++)m+=t[g]+r;let f=0;for(let g=0;g<d;g++)f+=i[g]+r;o.set(a.eid,{x:m,y:f});}),o}function Ia(e,n,r,o,t,i){let a=new Map;if(e.length===0)return a;let s=o==="row",l=e.reduce((p,W)=>p+(s?W.width:W.height),0),d=r*(e.length-1),m=l+d,f=Math.max(0,n-m),g=Math.max(...e.map(p=>s?p.height:p.width)),u=0,b=0;switch(t){case "start":u=0;break;case "center":u=f/2;break;case "end":u=f;break;case "space-between":u=0,e.length>1&&(b=f/(e.length-1));break}for(let p of e){let W=s?p.width:p.height,P=s?p.height:p.width,y=0;switch(i){case "start":y=0;break;case "center":y=(g-P)/2;break;case "end":y=g-P;break}s?a.set(p.eid,{x:u,y}):a.set(p.eid,{x:y,y:u}),u+=W+r+b;}return a}function Co(e,n,r={}){let o=Aa.parse(r),t=n,i=o.layout??"inline";w.isLayout[t]=1,w.mode[t]=Vd(i),w.gap[t]=o.gap??0,w.wrap[t]=o.wrap!==false?1:0,w.justify[t]=Id(o.justify??"start"),w.align[t]=kd(o.align??"start"),w.cols[t]=o.cols??3,w.direction[t]=o.direction==="column"?1:0;let a=Da(o.left),s=Da(o.top);s$1(e,t,a,s);let l=Ma(o.width),d$1=Ma(o.height);L(e,t,l,d$1),(o.fg!==void 0||o.bg!==void 0)&&d(e,t,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),W(e,t,{focusable:true});function m(){let g$1=f$1(e,t);if(g$1.length===0)return;let u=Fd(e,g$1),b=_d(e,t),p=Od(e,t,u,b.width,b.height);Nd(e,t,p),g(e,t);}let f={eid:t,show(){return j(e,t,true),f},hide(){return j(e,t,false),f},move(g$1,u){return x(e,t,g$1,u),g(e,t),f},setPosition(g$1,u){return s$1(e,t,g$1,u),g(e,t),f},getLayoutMode(){return So(w.mode[t])},setGap(g$1){return w.gap[t]=g$1,g(e,t),f},getGap(){return w.gap[t]},recalculate(){return m(),f},focus(){return _$1(e,t),f},blur(){return $(e,t),f},isFocused(){return Y$1(e,t)},append(g){return d$2(e,t,g),f},getChildren(){return f$1(e,t)},destroy(){w.isLayout[t]=0,w.mode[t]=0,w.gap[t]=0,w.wrap[t]=0,w.justify[t]=0,w.align[t]=0,w.cols[t]=0,w.direction[t]=0,e$3(e,t);}};return f}function _d(e,n){let r=M(e,n);return {width:r?.width??80,height:r?.height??24}}function Od(e,n,r,o,t){let i=w.gap[n];switch(So(w.mode[n])){case "inline":{let s=w.wrap[n]===1;return Ra(r,o,i,s)}case "grid":{let s=w.cols[n];return Va(r,s,i)}case "flex":{let s=w.direction[n]===0?"row":"column",l=["start","center","end","space-between"][w.justify[n]]??"start",d=["start","center","end"][w.align[n]]??"start";return Ia(r,s==="row"?o:t,i,s,l,d)}}}function Nd(e,n,r){let o=t(e,n),t$1=o?.x??0,i=o?.y??0;for(let[a,s]of r)s$1(e,a,t$1+s.x,i+s.y),g(e,a);}function wd(e,n){return w.isLayout[n]===1}function Ud(e,n){return So(w.mode[n])}function Hd(){w.isLayout.fill(0),w.mode.fill(0),w.gap.fill(0),w.wrap.fill(0),w.justify.fill(0),w.align.fill(0),w.cols.fill(0),w.direction.fill(0);}n();f();var Ir="\u2500",Oa="\u2502",Na=10,ka=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),wa=z.object({left:ka.optional(),top:ka.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()}),Wo=1e4,ve={isLine:new Uint8Array(Wo),orientation:new Uint8Array(Wo),length:new Float32Array(Wo)},Ct=new Map;function Fa(e){return e===void 0?0:typeof e=="number"?e:0}function zd(e,n,r){let o=Fa(r.left),t=Fa(r.top);s$1(e,n,o,t);}function _a(e,n,r,o){r==="horizontal"?L(e,n,o,1):L(e,n,1,o);}function Gd(e,n,r){r.fg===void 0&&r.bg===void 0||d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function Lo(e,n,r={}){let o=wa.parse(r),t=n,i=o.orientation??"horizontal",a=o.length??Na,s=o.char??(i==="horizontal"?Ir:Oa);ve.isLine[t]=1,ve.orientation[t]=i==="horizontal"?0:1,ve.length[t]=a,Ct.set(t,s),zd(e,t,o),_a(e,t,i,a),Gd(e,t,o),W(e,t,{focusable:false});let l={eid:t,show(){return j(e,t,true),l},hide(){return j(e,t,false),l},move(d,m){return x(e,t,d,m),g(e,t),l},setPosition(d,m){return s$1(e,t,d,m),g(e,t),l},setChar(d){return Ct.set(t,d),g(e,t),l},getChar(){return Ct.get(t)??Ir},getOrientation(){return ve.orientation[t]===0?"horizontal":"vertical"},setLength(d){ve.length[t]=d;let m=ve.orientation[t]===0?"horizontal":"vertical";return _a(e,t,m,d),g(e,t),l},getLength(){return ve.length[t]},focus(){return _$1(e,t),l},blur(){return $(e,t),l},isFocused(){return Y$1(e,t)},append(d){return d$2(e,t,d),l},getChildren(){return f$1(e,t)},destroy(){ve.isLine[t]=0,ve.orientation[t]=0,ve.length[t]=0,Ct.delete(t),e$3(e,t);}};return l}function $d(e,n){return ve.isLine[n]===1}function jd(e,n){return Ct.get(n)??Ir}function Yd(e,n,r){return Ct.set(n,r),g(e,n),n}function Kd(e,n){return ve.orientation[n]===0?"horizontal":"vertical"}function Qd(){ve.isLine.fill(0),ve.orientation.fill(0),ve.length.fill(0),Ct.clear();}n();var Ua=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)});function Eo(e,n,r={}){let o=Ua.parse(r),t=n;s$1(e,t,o.x,o.y),L(e,t,o.width,o.height);let i=o.items.map(s=>({text:s,value:s}));if(j$1(e,t,i,{interactive:o.interactive,mouse:o.mouse,keys:o.keys,search:o.search,selectedIndex:o.selected,visibleCount:o.height}),o.style){let s={};o.style.selected?.prefix!==void 0&&(s.selectedPrefix=o.style.selected.prefix),o.style.unselectedPrefix!==void 0&&(s.unselectedPrefix=o.style.unselectedPrefix),o.style.selected?.fg!==void 0&&(s.selectedFg=o.style.selected.fg),o.style.selected?.bg!==void 0&&(s.selectedBg=o.style.selected.bg),o.style.item?.fg!==void 0&&(s.itemFg=o.style.item.fg),o.style.item?.bg!==void 0&&(s.itemBg=o.style.item.bg),o.style.disabledFg!==void 0&&(s.disabledFg=o.style.disabledFg),fa$1(t,s);}let a={eid:t,show(){return j(e,t,true),a},hide(){return j(e,t,false),a},move(s,l){return r$2.x[t]=(r$2.x[t]??0)+s,r$2.y[t]=(r$2.y[t]??0)+l,g(e,t),a},setPosition(s,l){return s$1(e,t,s,l),a},focus(){return q$2(e,t),a},blur(){return r$1(e,t),a},setItems(s){let l=s.map(d=>({text:d,value:d}));return v$1(e,t,l),a},getItems(){return u$1(t)},addItem(s,l){let d=[...u$1(t)];return d.push({text:s,value:l??s}),v$1(e,t,d),a},removeItem(s){return x$2(e,t,s),a},clearItems(){return B$1(e,t),a},select(s){return E$1(e,t,s),a},getSelectedIndex(){return C$1(t)},getSelectedItem(){return D$1(t)},selectPrev(){return F$1(e,t),a},selectNext(){return G$1(e,t),a},selectFirst(){return H$1(e,t),a},selectLast(){return I(e,t),a},activate(){return L$1(e,t),a},pageUp(){return R(e,t,-1),a},pageDown(){return R(e,t,1),a},startSearch(){return ra(e,t),a},endSearch(){return sa$1(e,t),a},getSearchQuery(){return ta(t)},isSearching(){return qa$1(e,t)},getState(){return l$1(e,t)},onSelect(s){return Ba$1(t,s)},onActivate(s){return Ca$1(t,s)},onSearchChange(s){return Aa$1(t,s)},handleKey(s){let l=Ea$1(e,t,s);if(l)switch(l.type){case "selectPrev":F$1(e,t);break;case "selectNext":G$1(e,t);break;case "selectFirst":H$1(e,t);break;case "selectLast":I(e,t);break;case "pageUp":R(e,t,-1);break;case "pageDown":R(e,t,1);break;case "confirm":L$1(e,t);break;case "cancel":r$1(e,t);break;case "startSearch":ra(e,t);break;case "endSearch":sa$1(e,t);break;case "searchChar":va$1(e,t,l.char);break;case "searchBackspace":wa$1(e,t);break;case "searchNextMatch":za$1(e,t);break}return l},destroy(){Da$1(t),xa$1(e,t),e$3(e,t);}};return a}function Xd(e,n){return k$1(e,n)}n();var Wt=1e4,qd=z.object({text:z.string(),key:z.string().optional(),callback:z.function().optional(),value:z.string().optional()}),Ka=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),items:z.array(qd).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)}),V={isListbar:new Uint8Array(Wt),selectedIndex:new Int32Array(Wt).fill(-1),itemCount:new Uint32Array(Wt),state:new Uint8Array(Wt),autoCommandKeys:new Uint8Array(Wt),mouse:new Uint8Array(Wt),keys:new Uint8Array(Wt)},Ne=new Map,ut=new Map,cn=new Map,gn=new Map,Ha=3435973887,za=255,Ga=255,$a=16777215,ja=4294902015,Ya=255,dn=" | ",Jd={0:"idle",1:"focused"};function Zd(){V.isListbar.fill(0),V.selectedIndex.fill(-1),V.itemCount.fill(0),V.state.fill(0),V.autoCommandKeys.fill(0),V.mouse.fill(0),V.keys.fill(0),Ne.clear(),ut.clear(),cn.clear(),gn.clear();}function Po(e,n,r={}){let o=Ka.parse(r),t=n;V.isListbar[t]=1,s$1(e,t,o.x,o.y),V.autoCommandKeys[t]=o.autoCommandKeys?1:0,V.mouse[t]=o.mouse?1:0,V.keys[t]=o.keys?1:0;let i=[...o.items];Ne.set(t,i),V.itemCount[t]=i.length,o.selected>=0&&o.selected<i.length?V.selectedIndex[t]=o.selected:i.length>0&&(V.selectedIndex[t]=0);let a={itemFg:o.style?.item?.fg??Ha,itemBg:o.style?.item?.bg??za,selectedFg:o.style?.selected?.fg??Ga,selectedBg:o.style?.selected?.bg??$a,prefixFg:o.style?.prefix?.fg??ja,prefixBg:o.style?.prefix?.bg??Ya,separator:o.style?.separator??dn};ut.set(t,a);let s=()=>{let u=Ne.get(t)??[],p=ut.get(t)?.separator??dn,W=0;for(let P=0;P<u.length;P++){let y=u[P];if(y){let T=d(y,P,V.autoCommandKeys[t]===1);W+=T.length+y.text.length;}P<u.length-1&&(W+=p.length);}return W},l=o.width??s();L(e,t,l,1),cn.set(t,new Set),gn.set(t,new Set);function d(u,b,p){return u.key?`[${u.key}]`:p&&b<9?`[${b+1}]`:""}let m=()=>{let u=V.selectedIndex[t]??-1,p=(Ne.get(t)??[])[u];if(p&&u>=0){let W=cn.get(t);if(W)for(let P of W)P(u,p);}},f=()=>{let u=V.selectedIndex[t]??-1,p=(Ne.get(t)??[])[u];if(p&&u>=0){p.callback&&p.callback();let W=gn.get(t);if(W)for(let P of W)P(u,p);}},g$1={eid:t,show(){return j(e,t,true),g$1},hide(){return j(e,t,false),g$1},move(u,b){return r$2.x[t]=(r$2.x[t]??0)+u,r$2.y[t]=(r$2.y[t]??0)+b,g(e,t),g$1},setPosition(u,b){return s$1(e,t,u,b),g$1},focus(){return V.state[t]=1,g(e,t),g$1},blur(){return V.state[t]=0,g(e,t),g$1},setItems(u){let b=[...u];return Ne.set(t,b),V.itemCount[t]=b.length,(V.selectedIndex[t]??-1)>=b.length&&(V.selectedIndex[t]=Math.max(0,b.length-1)),g(e,t),g$1},getItems(){return Ne.get(t)??[]},addItem(u){let b=Ne.get(t)??[];return b.push(u),V.itemCount[t]=b.length,g(e,t),g$1},removeItem(u){let b=Ne.get(t)??[];if(u>=0&&u<b.length){b.splice(u,1),V.itemCount[t]=b.length;let p=V.selectedIndex[t]??-1;p>=b.length?V.selectedIndex[t]=Math.max(0,b.length-1):p>u&&(V.selectedIndex[t]=p-1),g(e,t);}return g$1},getItemCount(){return V.itemCount[t]??0},select(u){let b=V.itemCount[t]??0;return u>=0&&u<b&&V.selectedIndex[t]!==u&&(V.selectedIndex[t]=u,g(e,t),m()),g$1},getSelectedIndex(){return V.selectedIndex[t]??-1},getSelectedItem(){let u=V.selectedIndex[t]??-1;return (Ne.get(t)??[])[u]},selectPrev(){let u=V.selectedIndex[t]??0,b=V.itemCount[t]??0;if(b>0){let p=u<=0?b-1:u-1;g$1.select(p);}return g$1},selectNext(){let u=V.selectedIndex[t]??0,b=V.itemCount[t]??0;if(b>0){let p=u>=b-1?0:u+1;g$1.select(p);}return g$1},selectFirst(){return (V.itemCount[t]??0)>0&&g$1.select(0),g$1},selectLast(){let u=V.itemCount[t]??0;return u>0&&g$1.select(u-1),g$1},selectByKey(u){let b=Ne.get(t)??[],p=V.autoCommandKeys[t]===1;for(let W=0;W<b.length;W++)if(b[W]?.key?.toLowerCase()===u.toLowerCase())return g$1.select(W),true;if(p){let W=Number.parseInt(u,10);if(W>=1&&W<=9&&W<=b.length)return g$1.select(W-1),true}return false},activate(){return f(),g$1},getState(){let u=V.state[t]??0;return Jd[u]??"idle"},setStyle(u){let b=ut.get(t)??{itemFg:Ha,itemBg:za,selectedFg:Ga,selectedBg:$a,prefixFg:ja,prefixBg:Ya,separator:dn};return u.item?.fg!==void 0&&(b.itemFg=u.item.fg),u.item?.bg!==void 0&&(b.itemBg=u.item.bg),u.selected?.fg!==void 0&&(b.selectedFg=u.selected.fg),u.selected?.bg!==void 0&&(b.selectedBg=u.selected.bg),u.prefix?.fg!==void 0&&(b.prefixFg=u.prefix.fg),u.prefix?.bg!==void 0&&(b.prefixBg=u.prefix.bg),u.separator!==void 0&&(b.separator=u.separator),ut.set(t,b),g(e,t),g$1},getSeparator(){return ut.get(t)?.separator??dn},setSeparator(u){let b=ut.get(t);return b&&(b.separator=u,g(e,t)),g$1},renderLine(){let u=Ne.get(t)??[],b=V.selectedIndex[t]??-1,p=V.autoCommandKeys[t]===1,P=ut.get(t)?.separator??dn,y=[];for(let T=0;T<u.length;T++){let L=u[T];if(!L)continue;let S=d(L,T,p),C=T===b,H=S+L.text;C?y.push(`[${H}]`):y.push(` ${H} `);}return y.join(P)},calculateWidth(){return s()},onSelect(u){let b=cn.get(t);return b&&b.add(u),()=>{b?.delete(u);}},onActivate(u){let b=gn.get(t);return b&&b.add(u),()=>{b?.delete(u);}},handleKey(u){let b=V.state[t]??0,p=V.keys[t]===1;if(b!==1||!p)return null;switch(u.toLowerCase()){case "left":case "h":return g$1.selectPrev(),{type:"selectPrev"};case "right":case "l":return g$1.selectNext(),{type:"selectNext"};case "home":return g$1.selectFirst(),{type:"selectFirst"};case "end":return g$1.selectLast(),{type:"selectLast"};case "enter":case " ":return g$1.activate(),{type:"confirm"};case "escape":return g$1.blur(),{type:"cancel"}}return g$1.selectByKey(u)?{type:"selectByKey",key:u}:null},destroy(){V.isListbar[t]=0,V.selectedIndex[t]=-1,V.itemCount[t]=0,V.state[t]=0,Ne.delete(t),ut.delete(t),cn.delete(t),gn.delete(t),e$3(e,t);}};return g$1}function ec(e,n){return V.isListbar[n]===1}n();var qa=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 Qa(e,n){let r=[];for(let o=n;o<e.length;o++){let t=e[o];if(t){let i=t[0]??"";r.push({text:i,value:t.join(" ")});}}return r}function Xa(e){let n=e.border?.fg,r=e.border?.bg,o=e.header?.fg,t=e.header?.bg,i=e.cell?.fg,a=e.cell?.bg,s=e.altRowBg,l=e.selected?.fg,d=e.selected?.bg;return {...n!==void 0?{borderFg:n}:{},...r!==void 0?{borderBg:r}:{},...o!==void 0?{headerFg:o}:{},...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}:{},...d!==void 0?{selectedBg:d}:{}}}function vo(e,n,r={}){let o=qa.parse(r),t=n;s$1(e,t,o.x,o.y),o.width!==void 0&&L(e,t,o.width,o.height),eb$1(e,t,{headerRows:o.headerRows,pad:o.pad,cellBorders:o.cellBorders}),o.data.length>0&&hb$1(e,t,o.data),o.columns&&vb$1(e,t,o.columns),o.style&&Bb$1(t,Xa(o.style));let i=Qa(o.data,o.headerRows);j$1(e,t,i,{interactive:o.interactive,mouse:o.mouse,keys:o.keys,search:o.search,selectedIndex:o.selected,visibleCount:Math.max(1,o.height-o.headerRows)});let a=()=>{let l=jb$1(t),d=Ab$1(t),m=Qa(l,d);v$1(e,t,m);},s={eid:t,show(){return j(e,t,true),s},hide(){return j(e,t,false),s},move(l,d){return r$2.x[t]=(r$2.x[t]??0)+l,r$2.y[t]=(r$2.y[t]??0)+d,g(e,t),s},setPosition(l,d){return s$1(e,t,l,d),s},focus(){return q$2(e,t),s},blur(){return r$1(e,t),s},setData(l){return hb$1(e,t,l),a(),s},getData(){return jb$1(t)},getFullData(){return ib$1(t)},clearData(){return ub$1(e,t),a(),s},setCell(l,d,m){return kb$1(e,t,l,d,m),a(),s},getCell(l,d){return lb$1(t,l,d)},getCellValue(l,d){return mb$2(t,l,d)},getRow(l){return nb$1(t,l)},getRowCount(){return pb$1(t)},getDataRowCount(){return Math.max(0,pb$1(t)-Ab$1(t))},setColumns(l){return vb$1(e,t,l),s},getColumns(){return wb$1(t)},getColCount(){return qb$1(t)},setHeaderRowCount(l){return zb$1(e,t,l),a(),s},getHeaderRowCount(){return Ab$1(t)},getHeaderRows(){return xb$1(t)},getDataRows(){return yb$1(t)},setCellPadding(l){return Fb$1(e,t,l),s},getCellPadding(){return Eb$1(t)},setCellBorders(l){return Hb$1(e,t,l),s},hasCellBorders(){return Gb$1(t)},setStyle(l){return Bb$1(t,Xa(l)),g(e,t),s},getDisplay(){return Cb$1(t)},select(l){return E$1(e,t,l),s},getSelectedIndex(){return C$1(t)},getSelectedRow(){let l=C$1(t);if(l<0)return;let d=Ab$1(t);return nb$1(t,d+l)},selectPrev(){return F$1(e,t),s},selectNext(){return G$1(e,t),s},selectFirst(){return H$1(e,t),s},selectLast(){return I(e,t),s},activate(){return L$1(e,t),s},pageUp(){return R(e,t,-1),s},pageDown(){return R(e,t,1),s},startSearch(){return ra(e,t),s},endSearch(){return sa$1(e,t),s},getSearchQuery(){return ta(t)},isSearching(){return qa$1(e,t)},getState(){return l$1(e,t)},onSelect(l){return Ba$1(t,l)},onActivate(l){return Ca$1(t,l)},onSearchChange(l){return Aa$1(t,l)},handleKey(l){let d=Ea$1(e,t,l);if(d)switch(d.type){case "selectPrev":F$1(e,t);break;case "selectNext":G$1(e,t);break;case "selectFirst":H$1(e,t);break;case "selectLast":I(e,t);break;case "pageUp":R(e,t,-1);break;case "pageDown":R(e,t,1);break;case "confirm":L$1(e,t);break;case "cancel":r$1(e,t);break;case "startSearch":ra(e,t);break;case "endSearch":sa$1(e,t);break;case "searchChar":va$1(e,t,d.char);break;case "searchBackspace":wa$1(e,t);break;case "searchNextMatch":za$1(e,t);break}return d},destroy(){Da$1(t),xa$1(e,t),gb$1(e,t),e$3(e,t);}};return s}function tc(e,n){return fb$1(e,n)}n();var nc=4294967295,rc=0,Ja=z.object({fg:z.number().int().optional(),bg:z.number().int().optional()}),Za=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:Ja.optional(),width:z.number().int().positive().optional(),visible:z.boolean().default(true)}),Lt=new Map,$t=new Map;function kr(e,n={}){let r=Za.parse(n),o=d$1(e);s$1(e,o,r.x,r.y);let t=r.message,i=r.spinnerChars??Ha$1,a=Math.max(...i.map(l=>l.length)),s=r.width??t.length+a+1;return L(e,o,s,1),Na$1(e,o,{frames:i,interval:r.interval}),Lt.set(o,t),$t.set(o,r.visible),mn(e,o),r.visible||j(e,o,false),oc(e,o)}function oc(e,n){return {get eid(){return n},show(){return $t.set(n,true),j(e,n,true),g(e,n),this},hide(){return $t.set(n,false),j(e,n,false),g(e,n),this},isVisible(){return $t.get(n)??false},move(r,o){let t=r$2.x[n]??0,i=r$2.y[n]??0;return s$1(e,n,t+r,i+o),g(e,n),this},setPosition(r,o){return s$1(e,n,r,o),g(e,n),this},getPosition(){return {x:r$2.x[n]??0,y:r$2.y[n]??0}},setMessage(r){return Lt.set(n,r),mn(e,n),g(e,n),this},getMessage(){return Lt.get(n)??""},setSpinnerChars(r){return Ta$1(n,r),mn(e,n),g(e,n),this},setInterval(r){return Sa$1(n,r),this},getSpinnerChar(){return Qa$1(n)},reset(){return Wa$1(n),mn(e,n),g(e,n),this},destroy(){Oa$1(e,n),Lt.delete(n),$t.delete(n),e$3(e,n);}}}function mn(e,n){let r=Lt.get(n)??"",t=`${Qa$1(n)} ${r}`;e$2(e,n,t);}function ic(e,n,r={}){return kr(e,{...r,message:n,visible:true})}function ac(e){e.destroy();}function sc(e,n){e.setMessage(n);}function es(e,n){return Pa$1(e,n)&&Lt.has(n)}function lc(e,n,r){if(!es(e,n))return false;let o=Va$1(n,r);return o&&(mn(e,n),g(e,n)),o}function uc(){Lt.clear(),$t.clear();}s();n();f();var ts=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Fr=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),cc=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(),gc=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(),mc=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(),is=z.object({left:Fr.optional(),top:Fr.optional(),right:Fr.optional(),bottom:Fr.optional(),width:ts.optional(),height:ts.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:cc,padding:gc,scrollbar:mc,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()}),Et=1e4,K={isLog:new Uint8Array(Et),mouseEnabled:new Uint8Array(Et),keysEnabled:new Uint8Array(Et),scrollOnInput:new Uint8Array(Et),timestamps:new Uint8Array(Et),scrollback:new Uint32Array(Et),lineCount:new Uint32Array(Et)},yt=new Map;function bc(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$5;case "bold":return e$6;case "ascii":return f$3}}function fc(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function ns(e){return e===void 0?0:typeof e=="number"?e:0}function rs(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function pc(e){switch(e){case "auto":return 2;case "visible":return 1;case "hidden":return 0}}function yc(...e){if(e.length===0)return "";if(e.length===1)return String(e[0]);let n=String(e[0]),r=1;return n.replace(/%([sdfjioO%])/g,(o,t)=>{if(t==="%")return "%";if(r>=e.length)return o;let i=e[r++];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 o}})}function hc(e){return a$3(new Date,e)}function os(e,n){let r=yt.get(n);if(!r)return;let o=r.lines.join(`
|
|
8
|
+
`);e$2(e,n,o);let t=r.lines.length;u(e,n,0,t),K.lineCount[n]=t,g(e,n);}function xc(e){let n=yt.get(e);if(!n)return;let r=K.scrollback[e]??0;if(r!==0)for(;n.lines.length>r;)n.lines.shift();}function Tc(e,n){K.isLog[e]=1,K.scrollback[e]=n.scrollback??1e3,K.scrollOnInput[e]=n.scrollOnInput!==false?1:0,K.timestamps[e]=n.timestamps?1:0,K.mouseEnabled[e]=n.mouse!==false?1:0,K.keysEnabled[e]=n.keys!==false?1:0,K.lineCount[e]=0,yt.set(e,{lines:[],timestampFormat:n.timestampFormat??"HH:mm:ss"});}function Sc(e,n,r){let o=ns(r.left),t=ns(r.top);s$1(e,n,o,t);let i=rs(r.width),a=rs(r.height);L(e,n,i,a);}function Cc(e,n,r){r.fg===void 0&&r.bg===void 0||d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function Wc(e,n,r){let o=r.type?fc(r.type):1;if(j$2(e,n,{type:o,fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0}),r.ch){let t=typeof r.ch=="string"?bc(r.ch):r.ch;k(e,n,t);}}function Lc(e,n,r){typeof r=="number"?b(e,n,{left:r,top:r,right:r,bottom:r}):b(e,n,r);}function Ec(e,n,r){let o=2;r.scrollbar===false?o=0:typeof r.scrollbar=="object"&&r.scrollbar.mode&&(o=pc(r.scrollbar.mode)),l(e,n,{alwaysScroll:true,scrollbarVisible:o});}function Pc(e,n,r$1={}){let o$1=is.parse(r$1),t=n;Tc(t,o$1),Sc(e,t,o$1),Cc(e,t,o$1),o$1.border&&Wc(e,t,o$1.border),o$1.padding!==void 0&&Lc(e,t,o$1.padding),Ec(e,t,o$1),W(e,t,{focusable:true}),e$2(e,t,"");let i={eid:t,log(...a){let s=yt.get(t);if(!s)return i;let l=yc(...a);return K.timestamps[t]===1&&(l=`[${hc(s.timestampFormat)}] ${l}`),s.lines.push(l),xc(t),os(e,t),K.scrollOnInput[t]===1&&y(e,t),i},clear(){let a=yt.get(t);return a&&(a.lines=[],K.lineCount[t]=0,os(e,t),x$1(e,t)),i},getLines(){let a=yt.get(t);return a?[...a.lines]:[]},getLineCount(){return K.lineCount[t]??0},show(){return j(e,t,true),i},hide(){return j(e,t,false),i},move(a,s){return x(e,t,a,s),g(e,t),i},setPosition(a,s){return s$1(e,t,a,s),g(e,t),i},focus(){return _$1(e,t),i},blur(){return $(e,t),i},isFocused(){return Y$1(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},scrollTo(a,s){return p(e,t,a,s),g(e,t),i},scrollBy(a,s){return o(e,t,a,s),g(e,t),i},setScrollPerc(a,s){return r(e,t,a,s),g(e,t),i},getScrollPerc(){return q$1(e,t)},getScroll(){return n$1(e,t)},setViewport(a,s){return v(e,t,a,s),g(e,t),i},getScrollable(){return s$2(e,t)},scrollToTop(){return x$1(e,t),g(e,t),i},scrollToBottom(){return y(e,t),g(e,t),i},scrollToLeft(){return z$2(e,t),g(e,t),i},scrollToRight(){return A(e,t),g(e,t),i},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(){K.isLog[t]=0,K.mouseEnabled[t]=0,K.keysEnabled[t]=0,K.scrollOnInput[t]=0,K.timestamps[t]=0,K.scrollback[t]=0,K.lineCount[t]=0,yt.delete(t),e$3(e,t);}};return i}function vc(e,n){return K.isLog[n]===1}function Bc(e,n){return K.mouseEnabled[n]===1}function Dc(e,n){return K.keysEnabled[n]===1}function Mc(e,n){return K.scrollback[n]??0}function Ac(){K.isLog.fill(0),K.mouseEnabled.fill(0),K.keysEnabled.fill(0),K.scrollOnInput.fill(0),K.timestamps.fill(0),K.scrollback.fill(0),K.lineCount.fill(0),yt.clear();}s();n();f();var as=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Rc=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(),_r=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(),ss=z.object({left:as.optional(),top:as.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:Rc,padding:z.number().int().nonnegative().optional(),infoStyle:_r,warningStyle:_r,errorStyle:_r,successStyle:_r}),ls=3e3,Bo=1,us={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"}},Or=1e4,ce={isMessage:new Uint8Array(Or),dismissOnClick:new Uint8Array(Or),dismissOnKey:new Uint8Array(Or),dismissed:new Uint8Array(Or)},Xe=new Map;function Vc(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$5;case "bold":return e$6;case "ascii":return f$3}}function Ic(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function ds(e,n){return {info:n.infoStyle,warning:n.warningStyle,error:n.errorStyle,success:n.successStyle}[e]??us[e]}function kc(e,n){let r=e.split(`
|
|
9
|
+
`),o=Math.max(...r.map(s=>s.length),10),t=r.length,i=o+n*2+2,a=t+n*2+2;return {width:i,height:a}}function Fc(e,n){ce.isMessage[e]=1,ce.dismissOnClick[e]=n.dismissOnClick!==false?1:0,ce.dismissOnKey[e]=n.dismissOnKey!==false?1:0,ce.dismissed[e]=0,Xe.set(e,{content:n.content??""});}function _c(e,n,r){let o=r.content??"",t=r.padding??Bo,{width:i,height:a}=kc(o,t),s=r.width??i,l=r.height??a;L(e,n,s,l);let d=0,m=0;r.left!==void 0&&(typeof r.left=="number"?d=r.left:r.left==="center"&&(d=0)),r.top!==void 0&&(typeof r.top=="number"?m=r.top:r.top==="center"&&(m=0)),s$1(e,n,d,m);}function Oc(e,n,r){let o=r.type??"info",t=ds(o,r),i=r.fg??t.fg,a=r.bg??t.bg;(i!==void 0||a!==void 0)&&d(e,n,{fg:i!==void 0?e$1(i):void 0,bg:a!==void 0?e$1(a):void 0});}function Nc(e,n,r){let o=r.type??"info",t=ds(o,r),i=r.border?.type?Ic(r.border.type):1,a=r.border?.fg??t.borderFg;j$2(e,n,{type:i,fg:a!==void 0?e$1(a):void 0,bg:r.border?.bg!==void 0?e$1(r.border.bg):void 0});let s=r.border?.ch?typeof r.border.ch=="string"?Vc(r.border.ch):r.border.ch:d$5;k(e,n,s);}function wc(e,n,r){let o=r.content??"";e$2(e,n,o,{align:1,valign:1});}function Uc(e,n,r,o){let t=r.timeout??ls;if(t<=0)return;let i=Xe.get(n);i&&(i.timerId=setTimeout(()=>{o();},t));}function bn(e,n={}){let r=ss.parse(n),o=d$1(e);Fc(o,r),_c(e,o,r),Oc(e,o,r),Nc(e,o,r),wc(e,o,r);let t=r.padding??Bo;b(e,o,{left:t,top:t,right:t,bottom:t}),W(e,o,{focusable:true});let i=()=>{if(ce.dismissed[o]===1)return;ce.dismissed[o]=1,j(e,o,false);let s=Xe.get(o);s&&(s.timerId&&(clearTimeout(s.timerId),s.timerId=void 0),s.onDismissCallback&&s.onDismissCallback());};Uc(e,o,r,i);let a={eid:o,setContent(s){let l=Xe.get(o);return l&&(l.content=s),e$2(e,o,s,{align:1,valign:1}),g(e,o),a},getContent(){return Xe.get(o)?.content??""},show(){return j(e,o,true),a},hide(){return j(e,o,false),a},move(s,l){return x(e,o,s,l),g(e,o),a},setPosition(s,l){return s$1(e,o,s,l),g(e,o),a},center(s,l){let d=M(e,o),m=d?.width??20,f=d?.height??5,g$1=Math.floor((s-m)/2),u=Math.floor((l-f)/2);return s$1(e,o,g$1,u),g(e,o),a},dismiss:i,isDismissed(){return ce.dismissed[o]===1},onDismiss(s){let l=Xe.get(o);return l&&(l.onDismissCallback=s),a},destroy(){let s=Xe.get(o);s?.timerId&&clearTimeout(s.timerId),ce.isMessage[o]=0,ce.dismissOnClick[o]=0,ce.dismissOnKey[o]=0,ce.dismissed[o]=0,Xe.delete(o),e$3(e,o);}};return a}function Hc(e,n,r={}){return bn(e,{...r,content:n,type:"info"})}function zc(e,n,r={}){return bn(e,{...r,content:n,type:"warning"})}function Gc(e,n,r={}){return bn(e,{...r,content:n,type:"error"})}function $c(e,n,r={}){return bn(e,{...r,content:n,type:"success"})}function Do(e,n){return ce.isMessage[n]===1}function cs(e,n){return ce.dismissOnClick[n]===1}function gs(e,n){return ce.dismissOnKey[n]===1}function jc(e,n){if(!Do(e,n)||!cs(e,n)||ce.dismissed[n]===1)return false;let r=Xe.get(n);return r&&(ce.dismissed[n]=1,j(e,n,false),r.timerId&&(clearTimeout(r.timerId),r.timerId=void 0),r.onDismissCallback&&r.onDismissCallback()),true}function Yc(e,n){if(!Do(e,n)||!gs(e,n)||ce.dismissed[n]===1)return false;let r=Xe.get(n);return r&&(ce.dismissed[n]=1,j(e,n,false),r.timerId&&(clearTimeout(r.timerId),r.timerId=void 0),r.onDismissCallback&&r.onDismissCallback()),true}function Kc(){for(let e of Xe.values())e.timerId&&clearTimeout(e.timerId);ce.isMessage.fill(0),ce.dismissOnClick.fill(0),ce.dismissOnKey.fill(0),ce.dismissed.fill(0),Xe.clear();}s();n();f();var Mo=1e4,Qc=40,Xc=10,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.object({}).passthrough()]).optional()}),Jc=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()})]),ms=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:qc.optional(),padding:Jc.optional(),content:z.string().optional()}),le={isModal:new Uint8Array(Mo),isOpen:new Uint8Array(Mo),backdropEnabled:new Uint8Array(Mo)},we=new Map,dt=[];function Zc(e){if(typeof e=="object")return e;switch(e){case "double":return c;case "rounded":return d$5;case "bold":return e$6;case "ascii":return f$3;default:return b$1}}function eg(e){return e==="bg"?2:e==="none"?0:1}function tg(e,n,r){if(typeof r=="number"){b(e,n,{left:r,top:r,right:r,bottom:r});return}if(r){b(e,n,{left:r.left??0,top:r.top??0,right:r.right??0,bottom:r.bottom??0});return}}function ng(e){let n=dt.indexOf(e);n!==-1&&dt.splice(n,1),dt.push(e);}function Ao(e){let n=dt.indexOf(e);n!==-1&&dt.splice(n,1);}function rg(e,n,r,o){r===void 0&&o===void 0||d(e,n,{fg:r!==void 0?e$1(r):void 0,bg:o!==void 0?e$1(o):void 0});}function og(e,n,r){r?.type!=="none"&&(j$2(e,n,{type:eg(r?.type),fg:r?.fg!==void 0?e$1(r.fg):void 0,bg:r?.bg!==void 0?e$1(r.bg):void 0}),k(e,n,Zc(r?.ch)));}function bs(e,n={}){let r=ms.parse(n),o=d$1(e),t=r.width??Qc,i=r.height??Xc;return le.isModal[o]=1,le.isOpen[o]=0,le.backdropEnabled[o]=r.backdrop?1:0,we.set(o,{content:r.content??"",backdropColor:e$1(r.backdropColor),backdropOpacity:r.backdropOpacity,closeOnBackdropClick:r.closeOnBackdropClick,closeOnEscape:r.closeOnEscape,width:t,height:i,onCloseCallbacks:[],onOpenCallbacks:[]}),s$1(e,o,r.left??0,r.top??0),L(e,o,t,i),rg(e,o,r.fg,r.bg),og(e,o,r.border),tg(e,o,r.padding),r.content&&e$2(e,o,r.content,{align:0,valign:0}),j(e,o,false),ig(e,o)}function ig(e,n){let r={eid:n,show(){le.isOpen[n]=1,j(e,n,true),ng(n),g(e,n);let o=we.get(n);if(o)for(let t of o.onOpenCallbacks)t();return r},hide(){return le.isOpen[n]=0,j(e,n,false),Ao(n),g(e,n),r},move(o,t){return x(e,n,o,t),g(e,n),r},setPosition(o,t){return s$1(e,n,o,t),g(e,n),r},center(o,t){let i=we.get(n);if(!i)return r;let a=Math.max(0,Math.floor((o-i.width)/2)),s=Math.max(0,Math.floor((t-i.height)/2));return s$1(e,n,a,s),g(e,n),r},setContent(o){let t=we.get(n);return t&&(t.content=o),e$2(e,n,o,{align:0,valign:0}),g(e,n),r},getContent(){return we.get(n)?.content??""},close(){if(le.isOpen[n]===0)return;le.isOpen[n]=0,j(e,n,false),Ao(n),g(e,n);let o=we.get(n);if(o)for(let t of o.onCloseCallbacks)t();},isOpen(){return le.isOpen[n]===1},onClose(o){let t=we.get(n);return t&&t.onCloseCallbacks.push(o),r},onOpen(o){let t=we.get(n);return t&&t.onOpenCallbacks.push(o),r},destroy(){le.isOpen[n]===1&&r.close(),le.isModal[n]=0,le.isOpen[n]=0,le.backdropEnabled[n]=0,we.delete(n),e$3(e,n);}};return r}function ag(e,n={}){let r=bs(e,n);return r.show(),r}function Nr(e,n){if(le.isModal[n]!==1||le.isOpen[n]===0)return;le.isOpen[n]=0,j(e,n,false),Ao(n),g(e,n);let r=we.get(n);if(r)for(let o of r.onCloseCallbacks)o();}function sg(e){let n=[...dt];for(let r=n.length-1;r>=0;r--){let o=n[r];Nr(e,o);}}function lg(e){return dt.length>0}function ug(e){return [...dt]}function dg(e,n){return le.isModal[n]===1}function cg(){le.isModal.fill(0),le.isOpen.fill(0),le.backdropEnabled.fill(0),we.clear(),dt.length=0;}function gg(e,n){return le.isModal[n]!==1||le.isOpen[n]!==1||!we.get(n)?.closeOnBackdropClick?false:(Nr(e,n),true)}function mg(e,n){return le.isModal[n]!==1||le.isOpen[n]!==1||!we.get(n)?.closeOnEscape?false:(Nr(e,n),true)}s();n();f();var wr="",xs="\u2715",Ts="\u25BC",Ss="\u25B6",fs=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),ps=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),bg=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()}),fg=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()}),pg=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),yg=z.object({title:fg.optional(),content:pg.optional(),border:bg.optional()}),hg=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()})]),Cs=z.object({left:fs.optional(),top:fs.optional(),width:ps.optional(),height:ps.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:yg.optional(),padding:hg.optional(),content:z.string().optional()}),jt=1e4,N={isPanel:new Uint8Array(jt),collapsed:new Uint8Array(jt),closable:new Uint8Array(jt),collapsible:new Uint8Array(jt),originalHeight:new Float32Array(jt),titleAlign:new Uint8Array(jt)},ht=new Map,fn=new Map;function ys(e){return e===void 0?0:typeof e=="number"?e:0}function hs(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function xg(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function Ws(e){switch(e){case 0:return "left";case 1:return "center";case 2:return "right";default:return "left"}}function Tg(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 Sg(e){return e===void 0||e==="single"?b$1:typeof e=="object"?e:b$1}function Cg(e,n,r){(r.fg!==void 0||r.bg!==void 0)&&d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function Wg(e,n,r){let o=r.style?.border;o?.type!=="none"&&j$2(e,n,{type:o?.type==="bg"?2:1,fg:o?.fg!==void 0?e$1(o.fg):void 0,bg:o?.bg!==void 0?e$1(o.bg):void 0}),k(e,n,Sg(o?.ch));}function Ro(e,n,r={}){let o=Cs.parse(r),t=n;N.isPanel[t]=1,N.collapsed[t]=o.collapsed?1:0,N.closable[t]=o.closable?1:0,N.collapsible[t]=o.collapsible?1:0,N.titleAlign[t]=xg(o.titleAlign??o.style?.title?.align??"left"),ht.set(t,o.title??wr),fn.set(t,o.content??"");let i=ys(o.left),a=ys(o.top);s$1(e,t,i,a);let s=hs(o.width),l=hs(o.height);L(e,t,s,l);let d=M(e,t);N.originalHeight[t]=d?.height??10,Cg(e,t,o),Wg(e,t,o),b(e,t,Tg(o.padding)),o.content&&e$2(e,t,o.content,{align:0,valign:0}),W(e,t,{focusable:true}),j(e,t,true),o.collapsed&&L(e,t,s,3);let m={eid:t,show(){return j(e,t,true),m},hide(){return j(e,t,false),m},move(f,g$1){return x(e,t,f,g$1),g(e,t),m},setPosition(f,g$1){return s$1(e,t,f,g$1),g(e,t),m},setTitle(f){return ht.set(t,f),g(e,t),m},getTitle(){return ht.get(t)??wr},setContent(f){return fn.set(t,f),e$2(e,t,f,{align:0,valign:0}),g(e,t),m},getContent(){return fn.get(t)??""},collapse(){if(N.collapsible[t]===0||N.collapsed[t]===1)return m;let f=M(e,t);f&&(N.originalHeight[t]=f.height);let g$1=M(e,t);return L(e,t,g$1?.width??"auto",3),N.collapsed[t]=1,g(e,t),m},expand(){if(N.collapsible[t]===0||N.collapsed[t]===0)return m;let f=N.originalHeight[t],g$1=M(e,t);return L(e,t,g$1?.width??"auto",f),N.collapsed[t]=0,g(e,t),m},toggle(){return N.collapsed[t]===1?m.expand():m.collapse()},isCollapsed(){return N.collapsed[t]===1},isClosable(){return N.closable[t]===1},close(){N.closable[t]===1&&j(e,t,false);},focus(){return _$1(e,t),m},blur(){return $(e,t),m},isFocused(){return Y$1(e,t)},append(f){return d$2(e,t,f),m},getChildren(){return f$1(e,t)},destroy(){N.isPanel[t]=0,N.collapsed[t]=0,N.closable[t]=0,N.collapsible[t]=0,N.originalHeight[t]=0,N.titleAlign[t]=0,ht.delete(t),fn.delete(t),e$3(e,t);}};return m}function Lg(e,n){return N.isPanel[n]===1}function Eg(e,n){return ht.get(n)??wr}function Pg(e,n,r){return ht.set(n,r),g(e,n),n}function vg(e,n){return N.collapsed[n]===1}function Bg(e,n){return Ws(N.titleAlign[n])}function Dg(e,n,r){let o=ht.get(n)??"",t=N.closable[n]===1,i=N.collapsible[n]===1,a=N.collapsed[n]===1,s=Ws(N.titleAlign[n]),l=(t?2:0)+(i?2:0),d=Math.max(0,r-l),m=o;m.length>d&&(m=`${m.slice(0,d-1)}\u2026`);let f="";i&&(f+=a?`${Ss} `:`${Ts} `),t&&(f+=`${xs} `),f=f.trimEnd();let g=d-m.length,u=0,b=0;switch(s){case "left":b=g;break;case "center":u=Math.floor(g/2),b=g-u;break;case "right":u=g;break}return `${" ".repeat(u)}${m}${" ".repeat(b)}${f}`}function Mg(){N.isPanel.fill(0),N.collapsed.fill(0),N.closable.fill(0),N.collapsible.fill(0),N.originalHeight.fill(0),N.titleAlign.fill(0),ht.clear(),fn.clear();}s();n();f();var Ag=1e4,Rg=4294967295,Vg=255,Ls=40,Es=5,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(),vs=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(),Io=z.object({message:z.string().default(""),defaultValue:z.string().default(""),placeholder:z.string().default(""),width:z.number().int().positive().default(Ls),height:z.number().int().positive().default(Es),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:Ps,padding:vs}),pn={isPrompt:new Uint8Array(Ag)},Be=new Map;function Ig(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$5;case "bold":return e$6;case "ascii":return f$3}}function kg(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Fg(e,n,r,o){r===void 0&&o===void 0||d(e,n,{fg:r!==void 0?e$1(r):void 0,bg:o!==void 0?e$1(o):void 0});}function _g(e,n,r){let o=r.type?kg(r.type):1;if(j$2(e,n,{type:o,fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0}),r.ch){let t=typeof r.ch=="string"?Ig(r.ch):r.ch;k(e,n,t);}}function Og(e,n,r){typeof r=="number"?b(e,n,{left:r,top:r,right:r,bottom:r}):b(e,n,r);}function Vo(e,n){let r=Be.get(n);if(!r)return;let o=r.value||r.placeholder,t=r.message?`${r.message}
|
|
10
|
+
${o}`:o;e$2(e,n,t);}function Bs(e,n={}){let r=Io.parse(n),o=d$1(e);return pn.isPrompt[o]=1,s$1(e,o,r.left,r.top),L(e,o,r.width,r.height),Fg(e,o,r.fg,r.bg),r.border&&_g(e,o,r.border),r.padding!==void 0&&Og(e,o,r.padding),Be.set(o,{message:r.message,value:r.defaultValue,placeholder:r.placeholder,visible:true,validator:n.validator,submitCallbacks:[],cancelCallbacks:[]}),Vo(e,o),Ng(e,o)}function Ng(e,n){let r={get eid(){return n},show(){let o=Be.get(n);return o&&(o.visible=true),j(e,n,true),g(e,n),r},hide(){let o=Be.get(n);return o&&(o.visible=false),j(e,n,false),g(e,n),r},move(o,t){let i=r$2.x[n]??0,a=r$2.y[n]??0;return s$1(e,n,i+o,a+t),g(e,n),r},setPosition(o,t){return s$1(e,n,o,t),g(e,n),r},center(o,t){if(!Be.get(n))return r;let a=Io.parse({}),s=a.width,l=a.height,d=Math.floor((o-s)/2),m=Math.floor((t-l)/2);return s$1(e,n,d,m),g(e,n),r},setMessage(o){let t=Be.get(n);return t&&(t.message=o,Vo(e,n),g(e,n)),r},getMessage(){return Be.get(n)?.message??""},setValue(o){let t=Be.get(n);return t&&(t.value=o,Vo(e,n),g(e,n)),r},getValue(){return Be.get(n)?.value??""},submit(){let o=Be.get(n);if(!o)return r;if(o.validator){let t=o.validator(o.value);if(t!==true&&typeof t=="string"||t===false)return r}for(let t of o.submitCallbacks)t(o.value);return r},cancel(){let o=Be.get(n);if(!o)return r;for(let t of o.cancelCallbacks)t();return r},onSubmit(o){let t=Be.get(n);return t&&t.submitCallbacks.push(o),r},onCancel(o){let t=Be.get(n);return t&&t.cancelCallbacks.push(o),r},destroy(){pn.isPrompt[n]=0,Be.delete(n),e$3(e,n);}};return r}function wg(e,n,r={}){return new Promise(o=>{let t=Bs(e,{...r,message:n});t.onSubmit(i=>{t.destroy(),o(i);}),t.onCancel(()=>{t.destroy(),o(null);});})}function Ug(e){return pn.isPrompt[e]===1}function Hg(){pn.isPrompt.fill(0),Be.clear();}function zg(e,n){return n==="return"||n==="enter"?(e.submit(),true):n==="escape"?(e.cancel(),true):false}s();n();f();var Gg=1e4,$g=4294967295,jg=0,Ds=40,Ms=5,Yg=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(),Kg=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(),As=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(Ds),height:z.number().int().positive().default(Ms),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:Yg,padding:Kg}),yn={isQuestion:new Uint8Array(Gg)},De=new Map;function Qg(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$5;case "bold":return e$6;case "ascii":return f$3}}function Xg(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Ur(e,n){let r=De.get(n);if(!r)return;let o=r.selectedAnswer?`[${r.yesText}]`:` ${r.yesText} `,t=r.selectedAnswer?` ${r.noText} `:`[${r.noText}]`,i=`${r.message}
|
|
11
|
+
|
|
12
|
+
${o} ${t}`;e$2(e,n,i);}function qg(e,n,r){r.fg===void 0&&r.bg===void 0||d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function Jg(e,n,r){let o=r.type?Xg(r.type):1;if(j$2(e,n,{type:o,fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0}),r.ch){let t=typeof r.ch=="string"?Qg(r.ch):r.ch;k(e,n,t);}}function Zg(e,n,r){typeof r=="number"?b(e,n,{left:r,top:r,right:r,bottom:r}):b(e,n,r);}function Rs(e,n={}){let r=As.parse(n),o=d$1(e);return yn.isQuestion[o]=1,s$1(e,o,r.left,r.top),L(e,o,r.width,r.height),qg(e,o,r),r.border&&Jg(e,o,r.border),r.padding!==void 0&&Zg(e,o,r.padding),De.set(o,{message:r.message,yesText:r.yesText,noText:r.noText,selectedAnswer:r.defaultAnswer,visible:true,confirmCallbacks:[],cancelCallbacks:[]}),Ur(e,o),em(e,o)}function em(e,n){let r={get eid(){return n},show(){let o=De.get(n);return o&&(o.visible=true),j(e,n,true),g(e,n),r},hide(){let o=De.get(n);return o&&(o.visible=false),j(e,n,false),g(e,n),r},move(o,t){let i=r$2.x[n]??0,a=r$2.y[n]??0;return s$1(e,n,i+o,a+t),g(e,n),r},setPosition(o,t){return s$1(e,n,o,t),g(e,n),r},center(o,t){let i=M(e,n);if(!i)return r;let a=Math.floor((o-i.width)/2),s=Math.floor((t-i.height)/2);return s$1(e,n,a,s),g(e,n),r},setMessage(o){let t=De.get(n);return t&&(t.message=o,Ur(e,n),g(e,n)),r},getMessage(){return De.get(n)?.message??""},selectYes(){let o=De.get(n);return o&&(o.selectedAnswer=true,Ur(e,n),g(e,n)),r},selectNo(){let o=De.get(n);return o&&(o.selectedAnswer=false,Ur(e,n),g(e,n)),r},getSelectedAnswer(){return De.get(n)?.selectedAnswer??true},confirm(){let o=De.get(n);if(o)for(let t of o.confirmCallbacks)t(o.selectedAnswer);return r},cancel(){let o=De.get(n);if(o)for(let t of o.cancelCallbacks)t();return r},onConfirm(o){let t=De.get(n);return t&&t.confirmCallbacks.push(o),r},onCancel(o){let t=De.get(n);return t&&t.cancelCallbacks.push(o),r},destroy(){yn.isQuestion[n]=0,De.delete(n),e$3(e,n);}};return r}function Vs(e,n,r={}){return new Promise(o=>{let t=Rs(e,{...r,message:n});t.onConfirm(i=>{t.destroy(),o(i);}),t.onCancel(()=>{t.destroy(),o(false);});})}function tm(e,n){return Vs(e,n)}function nm(e,n){return yn.isQuestion[n]===1}function rm(e,n){switch(n){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 om(){yn.isQuestion.fill(0),De.clear();}s();n();f();var Is=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Hr=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),im=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(),am=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(),sm=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(),_s=z.object({left:Hr.optional(),top:Hr.optional(),right:Hr.optional(),bottom:Hr.optional(),width:Is.optional(),height:Is.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:im,padding:am,content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional(),scrollbar:sm,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()}),ko=1e4,Ue={isScrollableBox:new Uint8Array(ko),mouseEnabled:new Uint8Array(ko),keysEnabled:new Uint8Array(ko)};function lm(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function um(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function dm(e){let{BORDER_DOUBLE:n,BORDER_ROUNDED:r,BORDER_BOLD:o,BORDER_ASCII:t}=(s(),d$3(r$3));switch(e){case "single":return b$1;case "double":return n;case "rounded":return r;case "bold":return o;case "ascii":return t}}function cm(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function ks(e){return e===void 0?0:typeof e=="number"?e:0}function Fs(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function gm(e){switch(e){case "auto":return 2;case "visible":return 1;case "hidden":return 0}}function mm(e,n,r){let o=ks(r.left),t=ks(r.top);s$1(e,n,o,t);let i=Fs(r.width),a=Fs(r.height);L(e,n,i,a);}function bm(e,n,r){r.fg===void 0&&r.bg===void 0||d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function fm(e,n,r){let o=r.type?cm(r.type):1;if(j$2(e,n,{type:o,fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0}),r.ch){let t=typeof r.ch=="string"?dm(r.ch):r.ch;k(e,n,t);}}function pm(e,n,r){typeof r=="number"?b(e,n,{left:r,top:r,right:r,bottom:r}):b(e,n,r);}function ym(e,n,r){if(r.content===void 0)return;let o={};r.align&&(o.align=lm(r.align)),r.valign&&(o.valign=um(r.valign)),e$2(e,n,r.content,o);}function hm(e,n,r){let o={};r.scrollWidth!==void 0&&(o.scrollWidth=r.scrollWidth),r.scrollHeight!==void 0&&(o.scrollHeight=r.scrollHeight),r.scrollX!==void 0&&(o.scrollX=r.scrollX),r.scrollY!==void 0&&(o.scrollY=r.scrollY),r.alwaysScroll!==void 0&&(o.alwaysScroll=r.alwaysScroll),r.scrollbar===true?o.scrollbarVisible=2:r.scrollbar===false?o.scrollbarVisible=0:typeof r.scrollbar=="object"&&r.scrollbar.mode&&(o.scrollbarVisible=gm(r.scrollbar.mode)),l(e,n,o),Ue.mouseEnabled[n]=r.mouse!==false?1:0,Ue.keysEnabled[n]=r.keys!==false?1:0;}function hn(e,n,r$1={}){let o$1=_s.parse(r$1),t=n;Ue.isScrollableBox[t]=1,mm(e,t,o$1),bm(e,t,o$1),o$1.border&&fm(e,t,o$1.border),o$1.padding!==void 0&&pm(e,t,o$1.padding),ym(e,t,o$1),hm(e,t,o$1),W(e,t,{focusable:true});let i={eid:t,show(){return j(e,t,true),i},hide(){return j(e,t,false),i},move(a,s){return x(e,t,a,s),g(e,t),i},setPosition(a,s){return s$1(e,t,a,s),g(e,t),i},setContent(a){return e$2(e,t,a),g(e,t),i},getContent(){return f$2(e,t)},focus(){return _$1(e,t),i},blur(){return $(e,t),i},isFocused(){return Y$1(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},scrollTo(a,s){return p(e,t,a,s),g(e,t),i},scrollBy(a,s){return o(e,t,a,s),g(e,t),i},setScrollPerc(a,s){return r(e,t,a,s),g(e,t),i},getScrollPerc(){return q$1(e,t)},getScroll(){return n$1(e,t)},setScrollSize(a,s){return u(e,t,a,s),g(e,t),i},setViewport(a,s){return v(e,t,a,s),g(e,t),i},getScrollable(){return s$2(e,t)},scrollToTop(){return x$1(e,t),g(e,t),i},scrollToBottom(){return y(e,t),g(e,t),i},scrollToLeft(){return z$2(e,t),g(e,t),i},scrollToRight(){return A(e,t),g(e,t),i},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.isScrollableBox[t]=0,Ue.mouseEnabled[t]=0,Ue.keysEnabled[t]=0,e$3(e,t);}};return i}function Fo(e,n){return Ue.isScrollableBox[n]===1}function xm(e,n){return Ue.mouseEnabled[n]===1}function Tm(e,n){return Ue.keysEnabled[n]===1}function Sm(){Ue.isScrollableBox.fill(0),Ue.mouseEnabled.fill(0),Ue.keysEnabled.fill(0);}function _o(e,n,r={}){return hn(e,n,{...r,alwaysScroll:true})}n();function Os(e){let n={};return e.border?.fg!==void 0&&(n.borderFg=e.border.fg),e.border?.bg!==void 0&&(n.borderBg=e.border.bg),e.header?.fg!==void 0&&(n.headerFg=e.header.fg),e.header?.bg!==void 0&&(n.headerBg=e.header.bg),e.cell?.fg!==void 0&&(n.cellFg=e.cell.fg),e.cell?.bg!==void 0&&(n.cellBg=e.cell.bg),e.altRowBg!==void 0&&(n.altRowBg=e.altRowBg),e.selected?.fg!==void 0&&(n.selectedFg=e.selected.fg),e.selected?.bg!==void 0&&(n.selectedBg=e.selected.bg),n}var Ns=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 Oo(e,n,r={}){let o=Ns.parse(r),t=n;s$1(e,t,o.x,o.y),o.width!==void 0&&o.height!==void 0&&L(e,t,o.width,o.height),eb$1(e,t,{headerRows:o.headerRows,pad:o.pad,cellBorders:!o.noCellBorders}),o.data.length>0&&hb$1(e,t,o.data),o.columns&&vb$1(e,t,o.columns),o.style&&Bb$1(t,Os(o.style));let i={eid:t,show(){return j(e,t,true),i},hide(){return j(e,t,false),i},move(a,s){return r$2.x[t]=(r$2.x[t]??0)+a,r$2.y[t]=(r$2.y[t]??0)+s,g(e,t),i},setPosition(a,s){return s$1(e,t,a,s),i},setData(a){return hb$1(e,t,a),i},getData(){return jb$1(t)},getFullData(){return ib$1(t)},clearData(){return ub$1(e,t),i},setCell(a,s,l){return kb$1(e,t,a,s,l),i},getCell(a,s){return lb$1(t,a,s)},getCellValue(a,s){return mb$2(t,a,s)},getRow(a){return nb$1(t,a)},appendRow(a){return rb$1(e,t,a),i},insertRow(a,s){return sb$1(e,t,a,s),i},removeRow(a){return tb$1(e,t,a),i},getRowCount(){return pb$1(t)},setColumns(a){return vb$1(e,t,a),i},getColumns(){return wb$1(t)},getColCount(){return qb$1(t)},calculateColumnWidths(a){return Ib$1(t,a)},setHeaderRowCount(a){return zb$1(e,t,a),i},getHeaderRowCount(){return Ab$1(t)},getHeaderRows(){return xb$1(t)},getDataRows(){return yb$1(t)},setCellPadding(a){return Fb$1(e,t,a),i},getCellPadding(){return Eb$1(t)},setCellBorders(a){return Hb$1(e,t,a),i},hasCellBorders(){return Gb$1(t)},setStyle(a){return Bb$1(t,Os(a)),g(e,t),i},getDisplay(){return Cb$1(t)},renderLines(a){return Jb$1(t,a)},destroy(){gb$1(e,t),e$3(e,t);}};return i}function Cm(e,n){return fb$1(e,n)}s();n();f();var Wm="top",$s=" \u2502 ",js="\u2715",ws=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Us=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Lm=z.object({label:z.string(),content:z.union([z.number(),z.function()]).optional(),closable:z.boolean().optional()}),Em=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()}),Pm=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),vm=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()}),Bm=z.object({tab:Em.optional(),content:Pm.optional(),border:vm.optional()}),Ys=z.object({left:ws.optional(),top:ws.optional(),width:Us.optional(),height:Us.optional(),tabs:z.array(Lm).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:Bm.optional()}),zr=1e4,X={isTabs:new Uint8Array(zr),activeTab:new Uint16Array(zr),position:new Uint8Array(zr),tabCount:new Uint16Array(zr)},qe=new Map;function Dm(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 Mm(e,n){let r=n?n.map(Dm):[];return qe.set(e,r),r}function Hs(e){return e===void 0?0:typeof e=="number"?e:0}function zs(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function Am(e,n){if(e==="Tab"||e==="right")return n.nextTab(),{type:"next"};if(e==="S-Tab"||e==="left")return n.prevTab(),{type:"prev"};if(e>="1"&&e<="9"){let r=Number.parseInt(e,10)-1,o=n.getTabCount();if(r<o)return n.setActiveTab(r),{type:"goto",index:r}}return null}function Rm(e,n,r){(r.fg!==void 0||r.bg!==void 0)&&d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function Vm(e,n,r){let o=r.style?.border;o?.type!=="none"&&j$2(e,n,{type:o?.type==="bg"?2:1,fg:o?.fg!==void 0?e$1(o.fg):void 0,bg:o?.bg!==void 0?e$1(o.bg):void 0});}function Gs(e,n,r){let o=qe.get(n);if(!o||r<0||r>=o.length)return;let t=o[r];t&&!t.loaded&&t.lazyLoader&&(t.contentEntity=t.lazyLoader(),t.loaded=true,t.contentEntity!==null&&d$2(e,n,t.contentEntity));}function No(e,n){let r=qe.get(n);if(!r)return;let o=X.activeTab[n];for(let t=0;t<r.length;t++){let i=r[t];i?.contentEntity!==null&&i?.contentEntity!==void 0&&j(e,i.contentEntity,t===o);}}function wo(e,n,r={}){let o=Ys.parse(r),t=n;X.isTabs[t]=1,X.position[t]=o.position==="bottom"?1:0;let i=Mm(t,o.tabs);X.tabCount[t]=i.length;let a=Math.min(o.activeTab??0,Math.max(0,i.length-1));X.activeTab[t]=a,s$1(e,t,Hs(o.left),Hs(o.top)),L(e,t,zs(o.width),zs(o.height)),Rm(e,t,o),Vm(e,t,o),W(e,t,{focusable:true}),j(e,t,true),i.length>0&&(Gs(e,t,a),No(e,t));let s={eid:t,show(){return j(e,t,true),s},hide(){return j(e,t,false),s},move(l,d){return x(e,t,l,d),g(e,t),s},setPosition(l,d){return s$1(e,t,l,d),g(e,t),s},addTab(l){let d=qe.get(t)??[],m={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 d.push(m),qe.set(t,d),X.tabCount[t]=d.length,g(e,t),s},removeTab(l){let d=qe.get(t);return !d||l<0||l>=d.length||(d.splice(l,1),X.tabCount[t]=d.length,X.activeTab[t]>=d.length&&d.length>0?X.activeTab[t]=d.length-1:d.length===0&&(X.activeTab[t]=0),No(e,t),g(e,t)),s},getActiveTab(){return X.activeTab[t]},setActiveTab(l){let d=qe.get(t);return !d||l<0||l>=d.length||(X.activeTab[t]=l,Gs(e,t,l),No(e,t),g(e,t)),s},getTabCount(){return X.tabCount[t]},getTab(l){let d=qe.get(t);if(!(!d||l<0||l>=d.length))return d[l]},setTabLabel(l,d){let m=qe.get(t);if(!m||l<0||l>=m.length)return s;let f=m[l];return f&&(f.label=d),g(e,t),s},nextTab(){let l=X.tabCount[t];if(l===0)return s;let m=(X.activeTab[t]+1)%l;return s.setActiveTab(m)},prevTab(){let l=X.tabCount[t];if(l===0)return s;let d=X.activeTab[t],m=d===0?l-1:d-1;return s.setActiveTab(m)},focus(){return _$1(e,t),s},blur(){return $(e,t),s},isFocused(){return Y$1(e,t)},getChildren(){return f$1(e,t)},handleKey(l){return s.isFocused()?Am(l,s):null},destroy(){X.isTabs[t]=0,X.activeTab[t]=0,X.position[t]=0,X.tabCount[t]=0,qe.delete(t),e$3(e,t);}};return s}function Im(e,n){return X.isTabs[n]===1}function km(e,n){return X.activeTab[n]}function Fm(e,n){return X.tabCount[n]}function _m(e,n){return X.position[n]===1?"bottom":"top"}function Om(e,n,r){let o=qe.get(n);if(!o||o.length===0)return " ".repeat(r);let t=X.activeTab[n],i="";for(let a=0;a<o.length;a++){let s=o[a];if(!s)continue;a>0&&(i+=$s);let l=a===t?`[${s.label}]`:` ${s.label} `,d=s.closable?` ${js}`:"";i+=l+d;}return i.length>r?i=`${i.slice(0,r-1)}\u2026`:i.length<r&&(i=i+" ".repeat(r-i.length)),i}function Nm(){X.isTabs.fill(0),X.activeTab.fill(0),X.position.fill(0),X.tabCount.fill(0),qe.clear();}n();f();var Ks=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Gr=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),qs=z.object({left:Gr.optional(),top:Gr.optional(),right:Gr.optional(),bottom:Gr.optional(),width:Ks.optional(),height:Ks.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()}),wm=1e4,xn={isText:new Uint8Array(wm)};function Um(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function Hm(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function Qs(e){return e===void 0?0:typeof e=="number"?e:0}function Xs(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function zm(e,n,r){let o=Qs(r.left),t=Qs(r.top);s$1(e,n,o,t);let i=Xs(r.width),a=Xs(r.height);L(e,n,i,a);let s=r.shrink!==false;O(e,n,s);}function Gm(e,n,r){r.fg===void 0&&r.bg===void 0||d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function $m(e,n,r){if(r.content===void 0)return;let o={};r.align&&(o.align=Um(r.align)),r.valign&&(o.valign=Hm(r.valign)),e$2(e,n,r.content,o);}function Uo(e,n,r={}){let o=qs.parse(r),t=n;xn.isText[t]=1,zm(e,t,o),Gm(e,t,o),$m(e,t,o),W(e,t,{focusable:true});let i={eid:t,show(){return j(e,t,true),i},hide(){return j(e,t,false),i},move(a,s){return x(e,t,a,s),g(e,t),i},setPosition(a,s){return s$1(e,t,a,s),g(e,t),i},setContent(a){return e$2(e,t,a),g(e,t),i},getContent(){return f$2(e,t)},focus(){return _$1(e,t),i},blur(){return $(e,t),i},isFocused(){return Y$1(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},destroy(){xn.isText[t]=0,e$3(e,t);}};return i}function jm(e,n,r){return e$2(e,n,r),g(e,n),n}function Ym(e,n){return f$2(e,n)}function Km(e,n){return xn.isText[n]===1}function Qm(){xn.isText.fill(0);}n();var Pt=1e4,ct={VERTICAL:"\u2502",HORIZONTAL:"\u2500",BRANCH:"\u251C",CORNER:"\u2514",EXPANDED:"\u25BC",COLLAPSED:"\u25B6",SPACE:" "},ol=z.lazy(()=>z.object({label:z.string(),value:z.unknown().optional(),children:z.array(ol).optional(),expanded:z.boolean().optional(),icon:z.string().optional(),id:z.string().optional()})),il=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(ol).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)}),_={isTree:new Uint8Array(Pt),state:new Uint8Array(Pt),showLines:new Uint8Array(Pt),keys:new Uint8Array(Pt),indent:new Uint8Array(Pt),firstVisible:new Uint32Array(Pt),visibleCount:new Uint32Array(Pt)},Le=new Map,Pe=new Map,Tn=new Map,Sn=new Map,Cn=new Map,Wn=new Map,Js=3435973887,Zs=255,el=255,tl=16777215,nl=2298448127,rl=2290679807,Xm={0:"idle",1:"focused"};function qm(){_.isTree.fill(0),_.state.fill(0),_.showLines.fill(0),_.keys.fill(0),_.indent.fill(0),_.firstVisible.fill(0),_.visibleCount.fill(0),Le.clear(),Pe.clear(),Tn.clear(),Sn.clear(),Cn.clear(),Wn.clear();}var Jm=0;function Zm(){return `node_${++Jm}`}function zo(e,n,r=0){let o={label:e.label,value:e.value,children:[],expanded:e.expanded??false,icon:e.icon,id:e.id??Zm(),parent:n,depth:r};return e.children&&(o.children=e.children.map(t=>zo(t,o,r+1))),o}function eb(e,n,r){return n?.expanded?(e.collapse(r),{type:"collapse"}):(e.selectParent(),{type:"selectParent"})}function tb(e,n,r){return n&&n.children.length>0&&!n.expanded?(e.expand(r),{type:"expand"}):null}function nb(e,n,r,o){return n&&n.children.length>0?(e.toggle(r),{type:"toggle"}):(o(),{type:"confirm"})}function rb(e,n,r,o,t){if(e===0)return "";if(!r)return ct.SPACE.repeat(e*n);let i="";for(let a=0;a<e-1;a++)t[a]?i+=ct.SPACE.repeat(n):i+=ct.VERTICAL+ct.SPACE.repeat(n-1);return i+=o?ct.CORNER:ct.BRANCH,i+=ct.HORIZONTAL.repeat(n-1),i}function ob(e,n,r,o){let t=n;return e.children.length>0?(t+=e.expanded?ct.EXPANDED:ct.COLLAPSED,t+=" "):t+=" ",e.icon&&(t+=`${e.icon} `),t+=e.label,t.length>o&&(t=`${t.slice(0,o-1)}\u2026`),r?t=`[${t.padEnd(o-2)}]`:t=` ${t.padEnd(o-2)} `,t}function al(e,n="",r=[]){let o=[];for(let t=0;t<e.length;t++){let i=e[t];if(!i)continue;let a=t===e.length-1,s=n?`${n}.${t}`:`${t}`;o.push({node:i,path:s,depth:i.depth,isLastChild:a,parentIsLast:[...r]}),i.expanded&&i.children.length>0&&o.push(...al(i.children,s,[...r,a]));}return o}function rt(e,n){if(!n)return e[0];let r=n.split(".").map(Number),o=e[r[0]??0];for(let t=1;t<r.length&&o;t++){let i=r[t];i!==void 0&&(o=o.children[i]);}return o}function Ho(e,n){e.expanded=n;}function sl(e){for(let n of e)n.expanded=true,n.children.length>0&&sl(n.children);}function ll(e){for(let n of e)n.expanded=false,n.children.length>0&&ll(n.children);}function Go(e,n,r={}){let o=il.parse(r),t=n;_.isTree[t]=1,s$1(e,t,o.x,o.y),L(e,t,o.width,o.height),_.showLines[t]=o.showLines?1:0,_.keys[t]=o.keys?1:0,_.indent[t]=o.indent,_.visibleCount[t]=o.height;let i=o.nodes.map(u=>zo(u));for(let u=0;u<i.length;u++){let b=i[u];b&&(b.rootIndex=u);}Le.set(t,i),o.selected?Pe.set(t,o.selected):i.length>0&&Pe.set(t,"0");let a={nodeFg:o.style?.node?.fg??Js,nodeBg:o.style?.node?.bg??Zs,selectedFg:o.style?.selected?.fg??el,selectedBg:o.style?.selected?.bg??tl,expandedFg:o.style?.expanded?.fg??nl,collapsedFg:o.style?.collapsed?.fg??rl};Tn.set(t,a),Sn.set(t,new Set),Cn.set(t,new Set),Wn.set(t,new Set);let s=()=>{let u=Pe.get(t)??"",b=Le.get(t)??[],p=rt(b,u);if(p){let W=Sn.get(t);if(W)for(let P of W)P(u,p);}},l=()=>{let u=Pe.get(t)??"",b=Le.get(t)??[],p=rt(b,u);if(p){let W=Cn.get(t);if(W)for(let P of W)P(u,p);}},d=(u,b)=>{let p=Wn.get(t);if(p)for(let W of p)W(u,b);},m=()=>{let u=Le.get(t)??[];return al(u)},f=()=>{let u=m(),b=Pe.get(t)??"",p=u.findIndex(T=>T.path===b);if(p<0)return;let W=_.firstVisible[t]??0,P=_.visibleCount[t]??0,y=W+P-1;p<W?_.firstVisible[t]=p:p>y&&(_.firstVisible[t]=Math.max(0,p-P+1));},g$1={eid:t,show(){return j(e,t,true),g$1},hide(){return j(e,t,false),g$1},move(u,b){return r$2.x[t]=(r$2.x[t]??0)+u,r$2.y[t]=(r$2.y[t]??0)+b,g(e,t),g$1},setPosition(u,b){return s$1(e,t,u,b),g$1},focus(){return _.state[t]=1,g(e,t),g$1},blur(){return _.state[t]=0,g(e,t),g$1},setNodes(u){let b=u.map(p=>zo(p));return Le.set(t,b),b.length>0?Pe.set(t,"0"):Pe.delete(t),_.firstVisible[t]=0,g(e,t),g$1},getNodes(){return Le.get(t)??[]},getNode(u){let b=Le.get(t)??[];return rt(b,u)},getVisibleNodes(){return m()},select(u){let b=Le.get(t)??[];return rt(b,u)&&(Pe.set(t,u),f(),g(e,t),s()),g$1},getSelectedPath(){return Pe.get(t)??""},getSelectedNode(){let u=Pe.get(t)??"",b=Le.get(t)??[];return rt(b,u)},selectPrev(){let u=m(),b=Pe.get(t)??"",p=u.findIndex(W=>W.path===b);if(p>0){let W=u[p-1];W&&g$1.select(W.path);}return g$1},selectNext(){let u=m(),b=Pe.get(t)??"",p=u.findIndex(W=>W.path===b);if(p<u.length-1){let W=u[p+1];W&&g$1.select(W.path);}return g$1},selectFirst(){let u=m();if(u.length>0){let b=u[0];b&&g$1.select(b.path);}return g$1},selectLast(){let u=m();if(u.length>0){let b=u[u.length-1];b&&g$1.select(b.path);}return g$1},selectParent(){let b=(Pe.get(t)??"").split(".");return b.length>1&&(b.pop(),g$1.select(b.join("."))),g$1},expand(u){let b=Le.get(t)??[],p=rt(b,u);return p&&p.children.length>0&&!p.expanded&&(Ho(p,true),g(e,t),d(u,true)),g$1},collapse(u){let b=Le.get(t)??[],p=rt(b,u);return p?.expanded&&(Ho(p,false),g(e,t),d(u,false)),g$1},toggle(u){let b=Le.get(t)??[],p=rt(b,u);if(p&&p.children.length>0){let W=!p.expanded;Ho(p,W),g(e,t),d(u,W);}return g$1},expandAll(){let u=Le.get(t)??[];return sl(u),g(e,t),g$1},collapseAll(){let u=Le.get(t)??[];return ll(u),g(e,t),g$1},isExpanded(u){let b=Le.get(t)??[];return rt(b,u)?.expanded??false},getState(){let u=_.state[t]??0;return Xm[u]??"idle"},setStyle(u){let b=Tn.get(t)??{nodeFg:Js,nodeBg:Zs,selectedFg:el,selectedBg:tl,expandedFg:nl,collapsedFg:rl};return u.node?.fg!==void 0&&(b.nodeFg=u.node.fg),u.node?.bg!==void 0&&(b.nodeBg=u.node.bg),u.selected?.fg!==void 0&&(b.selectedFg=u.selected.fg),u.selected?.bg!==void 0&&(b.selectedBg=u.selected.bg),u.expanded?.fg!==void 0&&(b.expandedFg=u.expanded.fg),u.collapsed?.fg!==void 0&&(b.collapsedFg=u.collapsed.fg),Tn.set(t,b),g(e,t),g$1},setShowLines(u){return _.showLines[t]=u?1:0,g(e,t),g$1},getShowLines(){return _.showLines[t]===1},getFirstVisible(){return _.firstVisible[t]??0},setFirstVisible(u){return _.firstVisible[t]=Math.max(0,u),g(e,t),g$1},getVisibleCount(){return _.visibleCount[t]??0},renderLines(u){let b=m(),p=Pe.get(t)??"",W=_.showLines[t]===1,P=_.indent[t]??2,y=_.firstVisible[t]??0,T=_.visibleCount[t]??b.length,L=[],S=Math.min(y+T,b.length);for(let C=y;C<S;C++){let H=b[C];if(!H)continue;let{node:Me,path:vt,isLastChild:Bn,parentIsLast:Kt}=H,Qt=vt===p,Jr=rb(Me.depth,P,W,Bn,Kt),Dn=ob(Me,Jr,Qt,u);L.push(Dn);}return L},onSelect(u){let b=Sn.get(t);return b&&b.add(u),()=>{b?.delete(u);}},onActivate(u){let b=Cn.get(t);return b&&b.add(u),()=>{b?.delete(u);}},onToggle(u){let b=Wn.get(t);return b&&b.add(u),()=>{b?.delete(u);}},handleKey(u){let b=_.state[t]??0,p=_.keys[t]===1;if(b!==1||!p)return null;let W=Pe.get(t)??"",P=Le.get(t)??[],y=rt(P,W);if(u==="G")return g$1.selectLast(),{type:"selectLast"};switch(u.toLowerCase()){case "up":case "k":return g$1.selectPrev(),{type:"selectPrev"};case "down":case "j":return g$1.selectNext(),{type:"selectNext"};case "left":case "h":return eb(g$1,y,W);case "right":case "l":return tb(g$1,y,W);case "enter":case " ":return nb(g$1,y,W,l);case "escape":return g$1.blur(),{type:"cancel"};case "g":return g$1.selectFirst(),{type:"selectFirst"}}return null},destroy(){_.isTree[t]=0,_.state[t]=0,_.showLines[t]=0,_.keys[t]=0,_.indent[t]=0,_.firstVisible[t]=0,_.visibleCount[t]=0,Le.delete(t),Pe.delete(t),Tn.delete(t),Sn.delete(t),Cn.delete(t),Wn.delete(t),e$3(e,t);}};return g$1}function ib(e,n){return _.isTree[n]===1}n();var ab=1e4,$r={isViewport3D:new Uint8Array(ab)},Ln=new Map;function $o(e,n,r={}){let o=mb$1.parse(r),t=n;$r.isViewport3D[t]=1;let i=d$1(e);Q(e,i,{}),z$1(e,i,{fov:o.fov,near:o.near,far:o.far,aspect:o.width/o.height,projectionMode:o.projectionMode}),Z(e,t,{left:o.left,top:o.top,width:o.width,height:o.height,cameraEntity:i,backendType:o.backend});let a=o.backend==="auto"?"braille":o.backend,s=q(a),l=s.getPixelDimensions(o.width,o.height);Y.pixelWidth[t]=l.width,Y.pixelHeight[t]=l.height,s$1(e,t,o.left,o.top),L(e,t,o.width,o.height),Ln.set(t,new Set);let d={eid:t,cameraEid:i,addMesh(m,f,g){if(!J$1(m))throw new Error(`Mesh ID ${m} not found in mesh store`);let b=d$1(e);return Q(e,b,f??{}),h(e,b,G$2),G$2.meshId[b]=m,g&&E$2(e,b,g),Ln.get(t)?.add(b),b},removeMesh(m){Ln.get(t)?.delete(m),e$3(e,m);},setCameraPosition(m,f,g){return P.tx[i]=m,P.ty[i]=f,P.tz[i]=g,P.dirty[i]=1,d},setCameraRotation(m,f,g){return P.rx[i]=m,P.ry[i]=f,P.rz[i]=g,P.dirty[i]=1,d},setFov(m){return y$1.fov[i]=m,y$1.dirty[i]=1,d},resize(m,f){Y.width[t]=m,Y.height[t]=f;let g$1=s.getPixelDimensions(m,f);return Y.pixelWidth[t]=g$1.width,Y.pixelHeight[t]=g$1.height,y$1.aspect[i]=m/f,L(e,t,m,f),g(e,t),d},show(){return j(e,t,true),d},hide(){return j(e,t,false),d},destroy(){let m=Ln.get(t);if(m){for(let f of m)e$3(e,f);Ln.delete(t);}qb$2.delete(t),e$3(e,i),$r.isViewport3D[t]=0,e$3(e,t);}};return d}function sb(e){return $r.isViewport3D[e]===1}function ul(){let e=new Map,n=new Map;function r(i){return i.toLowerCase()}function o(i){let a=r(i);return n.get(a)??a}let t={register(i,a){let s=r(i);return e.set(s,a),t},alias(i,a){let s=r(i),l=r(a);if(!e.has(l)&&!n.has(l))throw new Error(`Cannot create alias '${i}' for non-existent widget type '${a}'`);return n.set(s,l),t},has(i){let a=o(i);return e.has(a)},get(i){let a=o(i);return e.get(a)},create(i,a,s){let{addEntity:l}=a$1("bitecs"),d=l(i);return t.createWithEntity(i,d,a,s)},createWithEntity(i,a,s,l){let d=t.get(s);if(!d){let m=t.list().join(", ");throw new Error(`Unknown widget type '${s}'. Available types: ${m||"none"}`)}return d.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=r(i);for(let[s,l]of n.entries())l===a&&n.delete(s);return e.delete(a)},clear(){e.clear(),n.clear();}};return t}var lb=[{name:"bigText",factory:e,description:"Large ASCII art text display widget",tags:["display","text"],aliases:["bigtext"]},{name:"box",factory:bo,description:"Basic container widget with optional border and padding",tags:["container","layout","basic"]},{name:"text",factory:Uo,description:"Simple text display widget",tags:["display","text","basic"]},{name:"line",factory:Lo,description:"Horizontal or vertical line separator",tags:["display","decoration","basic"]},{name:"layout",factory:Co,description:"Auto-arranging container with flex/grid/inline modes",tags:["container","layout"]},{name:"panel",factory:Ro,description:"Container with title bar and optional close/collapse buttons",tags:["container","layout","interactive"]},{name:"tabs",factory:wo,description:"Tabbed container with navigation",tags:["container","layout","navigation","interactive"]},{name:"scrollableBox",factory:hn,description:"Scrollable container with scrollbar support",tags:["container","scrolling"],aliases:["scrollbox","scroll"]},{name:"scrollableText",factory:_o,description:"Scrollable text display optimized for logs and documents",tags:["display","text","scrolling"],aliases:["log","textarea"]},{name:"list",factory:Eo,description:"Selectable list of items",tags:["selection","interactive","data"]},{name:"listbar",factory:Po,description:"Horizontal menu bar with selectable items",tags:["navigation","interactive","menu"],aliases:["menubar","menu"]},{name:"table",factory:Oo,description:"Data table with rows and columns",tags:["display","data"]},{name:"listTable",factory:vo,description:"Selectable data table combining list and table features",tags:["selection","interactive","data"],aliases:["datatable","grid"]},{name:"tree",factory:Go,description:"Hierarchical tree view with expandable nodes",tags:["selection","interactive","data","hierarchy"],aliases:["treeview"]},{name:"loading",factory:kr,description:"Loading indicator with spinner animation",tags:["display","feedback","animation"],aliases:["spinner","progress"]},{name:"hoverText",factory:yo,description:"Tooltip/hover text manager",tags:["feedback","tooltip"],aliases:["tooltip"]},{name:"viewport3d",factory:$o,description:"3D rendering viewport with camera and mesh management",tags:["display","3d","rendering"],aliases:["3d","viewport"]}];function dl(e){for(let n of lb)if(e.register(n.name,{factory:n.factory,description:n.description,tags:n.tags}),n.aliases)for(let r of n.aliases)e.alias(r,n.name);return e}var jr=dl(ul());function ub(){return jr.list()}function db(e){return jr.has(e)}function cb(e){return jr.listByTag(e)}n();var cl=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),gl=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),pl=z.object({left:cl.optional(),top:cl.optional(),width:gl.optional(),height:gl.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()}),Yt=1e4,te={isSplitPane:new Uint8Array(Yt),direction:new Uint8Array(Yt),paneCount:new Uint8Array(Yt),minPaneSize:new Uint8Array(Yt),dividerSize:new Uint8Array(Yt),resizable:new Uint8Array(Yt)},ue=new Map,ot=new Map,Qr=new Map,it=new Map,He=new Map;function Yr(e){return typeof e=="string"?c$1(e):e}function ml(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 n=Number.parseFloat(e.slice(0,-1));if(!Number.isNaN(n))return n}return 0}function bl(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function fl(e){let n=e.reduce((r,o)=>r+o,0);return n===0?e.map(()=>1/e.length):e.map(r=>r/n)}function gb(e){return e<=0?[]:new Array(e).fill(1/e)}function mb(e,n,r,o,t,i,a){let s=i.length;if(s===0)return [];let l=a*(s-1),d=t==="horizontal"?r-l:o-l,m=Math.max(0,d),f=[],g=0,u=0;for(let b=0;b<s;b++){let p=b===s-1,W=p?Math.max(1,m-u):Math.max(1,Math.round(m*(i[b]??0)));t==="horizontal"?f.push({x:e+g,y:n,width:W,height:o}):f.push({x:e,y:n+g,width:r,height:W}),g+=W,u+=W,p||(g+=a);}return f}function bb(e,n,r,o,t){let i=[...e],a=t>0?o/t:0,s=(i[n]??0)+r,l=(i[n+1]??0)-r;if(s<a){let d=a-(i[n]??0);i[n]=a,i[n+1]=(i[n+1]??0)-d;}else if(l<a){let d=(i[n+1]??0)-a;i[n]=(i[n]??0)+d,i[n+1]=a;}else i[n]=s,i[n+1]=l;return i}function fb(e,n,r,o,t,i){let a=[];for(let s=0;s<Math.max(e.length,n.length);s++){let l=e[s],d=n[s];if(!l||!d){let m=d??l;m&&a.push(m);continue}if(l.x!==d.x||l.y!==d.y||l.width!==d.width||l.height!==d.height){let m=Math.min(l.x,d.x),f=Math.min(l.y,d.y),g=Math.max(l.x+l.width,d.x+d.width),u=Math.max(l.y+l.height,d.y+d.height);a.push({x:Math.max(r,m),y:Math.max(o,f),width:Math.min(r+t,g)-Math.max(r,m),height:Math.min(o+i,u)-Math.max(o,f)});}}return a}function pb(){return {scrollX:0,scrollY:0,contentWidth:0,contentHeight:0}}function Kr(e,n){let r=Math.max(0,e.contentWidth-n.width),o=Math.max(0,e.contentHeight-n.height);e.scrollX=Math.max(0,Math.min(e.scrollX,r)),e.scrollY=Math.max(0,Math.min(e.scrollY,o));}function yb(e,n,r,o,t,i,a){te.isSplitPane[n]=1,te.direction[n]=o==="horizontal"?0:1,te.paneCount[n]=0,te.minPaneSize[n]=t,te.dividerSize[n]=i,te.resizable[n]=a?1:0,ue.set(n,[]),ot.set(n,[]),He.set(n,[]),Qr.set(n,{fg:r.dividerFg!==void 0?Yr(r.dividerFg):void 0,bg:r.dividerBg!==void 0?Yr(r.dividerBg):void 0,char:r.dividerChar??(o==="horizontal"?"\u2502":"\u2500")});let s=ml(r.left),l=ml(r.top);s$1(e,n,s,l);let d$1=bl(r.width),m=bl(r.height);L(e,n,d$1,m),(r.fg!==void 0||r.bg!==void 0)&&d(e,n,{fg:r.fg!==void 0?Yr(r.fg):void 0,bg:r.bg!==void 0?Yr(r.bg):void 0}),W(e,n,{focusable:true});}function hb(e,n,r={}){let o=pl.parse(r),t=n,i=o.direction??"horizontal",a=o.minPaneSize??3,s=o.dividerSize??1,l=o.resizable!==false;yb(e,t,o,i,a,s,l);let d=o.ratios?fl(o.ratios):[];function m(y){let T=it.get(y);T&&(T.refCount--,T.refCount<=0&&it.delete(y));}function f(){let y=M(e,t);return {x:0,y:0,width:y?.width??80,height:y?.height??24}}function g$1(y,T){for(let L=0;L<y.length;L++){let S=y[L],C=T[L];!S||!C||(S.viewport=C,Kr(S.scroll,C),S.dirty=true);}}function u(y){let T=ot.get(t)??[];for(let L=0;L<T.length;L++){let S=T[L];if(!S)continue;let C=0;for(let H=0;H<=L;H++)C+=y[H]??0;S.ratio=C;}}function b(y,T){for(let L$1=0;L$1<y.length;L$1++){let S=y[L$1],C=T[L$1];!S||!C||(s$1(e,S.entity,C.x,C.y),L(e,S.entity,C.width,C.height));}}function p(){let y=ue.get(t);if(!y||y.length===0)return;let T=f(),L=mb(T.x,T.y,T.width,T.height,i,d,s);g$1(y,L),u(d),b(y,L),te.paneCount[t]=y.length,g(e,t);}function W(y){let T=ue.get(t)??[],L={entity:y,viewport:{x:0,y:0,width:0,height:0},scroll:pb(),sharedBufferId:void 0,dirty:true};T.push(L),ue.set(t,T),d.length<T.length&&(d=gb(T.length));let S=ot.get(t)??[];if(T.length>1&&S.length<T.length-1){let C=0;for(let H=0;H<S.length+1;H++)C+=d[H]??0;S.push({ratio:C,dragging:false,dragStartPos:0,dragStartRatio:0,dragStartRatios:[]}),ot.set(t,S);}d$2(e,t,y),p();}let P={eid:t,show(){return j(e,t,true),P},hide(){return j(e,t,false),P},move(y,T){return x(e,t,y,T),g(e,t),P},setPosition(y,T){return s$1(e,t,y,T),p(),P},getDirection(){return i},getRatios(){return [...d]},setRatios(y){let T=ue.get(t)??[];return y.length!==T.length||(d=fl(y),p()),P},getPaneCount(){return (ue.get(t)??[]).length},getPaneViewport(y){return (ue.get(t)??[])[y]?.viewport},getAllPaneViewports(){return (ue.get(t)??[]).map(y=>y.viewport)},scrollPane(y,T,L){let C=(ue.get(t)??[])[y];if(!C)return P;C.scroll.scrollX+=T,C.scroll.scrollY+=L,Kr(C.scroll,C.viewport),C.dirty=true;let H=He.get(t)??[];return H.push(C.viewport),He.set(t,H),g(e,t),P},setPaneScroll(y,T,L){let C=(ue.get(t)??[])[y];if(!C)return P;C.scroll.scrollX=T,C.scroll.scrollY=L,Kr(C.scroll,C.viewport),C.dirty=true;let H=He.get(t)??[];return H.push(C.viewport),He.set(t,H),g(e,t),P},getPaneScroll(y){let L=(ue.get(t)??[])[y];if(L)return {...L.scroll}},setPaneContentSize(y,T,L){let C=(ue.get(t)??[])[y];return C&&(C.scroll.contentWidth=T,C.scroll.contentHeight=L,Kr(C.scroll,C.viewport)),P},attachBuffer(y,T){let S=(ue.get(t)??[])[y];if(!S)return P;S.sharedBufferId&&m(S.sharedBufferId),S.sharedBufferId=T.id,it.has(T.id)||it.set(T.id,T);let C=it.get(T.id);return C&&C.refCount++,S.scroll.contentHeight=T.lines.length,S.dirty=true,g(e,t),P},detachBuffer(y){let L=(ue.get(t)??[])[y];return !L||!L.sharedBufferId||(m(L.sharedBufferId),L.sharedBufferId=void 0,L.dirty=true,g(e,t)),P},getBuffer(y){let L=(ue.get(t)??[])[y];if(!(!L||!L.sharedBufferId))return it.get(L.sharedBufferId)},beginDrag(y,T){if(!l)return P;let S=(ot.get(t)??[])[y];return S&&(S.dragging=true,S.dragStartPos=T,S.dragStartRatio=S.ratio,S.dragStartRatios=[...d]),P},updateDrag(y,T){if(!l)return;let S=(ot.get(t)??[])[y];if(!S||!S.dragging)return;let C=f(),H=i==="horizontal"?C.width:C.height,Me=s*(d.length-1),vt=Math.max(1,H-Me),Kt=(T-S.dragStartPos)/vt,Qt=(ue.get(t)??[]).map(Zr=>Zr.viewport);d=bb(S.dragStartRatios,y,Kt,a,vt),p();let Jr=(ue.get(t)??[]).map(Zr=>Zr.viewport),Dn=fb(Qt,Jr,C.x,C.y,C.width,C.height),Jo=He.get(t)??[];return Jo.push(...Dn),He.set(t,Jo),{dividerIndex:y,ratios:[...d],dirtyRects:Dn}},endDrag(y){let L=(ot.get(t)??[])[y];return L&&(L.dragging=false,L.dragStartPos=0,L.dragStartRatio=0,L.dragStartRatios=[]),P},isDragging(){return (ot.get(t)??[]).some(T=>T.dragging)},getDirtyRects(){return [...He.get(t)??[]]},markPaneDirty(y){let L=(ue.get(t)??[])[y];if(!L)return P;L.dirty=true;let S=He.get(t)??[];return S.push(L.viewport),He.set(t,S),g(e,t),P},flushDirty(){let y=ue.get(t)??[];for(let T of y)T.dirty=false;return He.set(t,[]),P},recalculate(){return p(),P},focus(){return _$1(e,t),P},blur(){return $(e,t),P},isFocused(){return Y$1(e,t)},append(y){return W(y),P},getChildren(){return f$1(e,t)},destroy(){let y=ue.get(t)??[];for(let T of y)T.sharedBufferId&&m(T.sharedBufferId);te.isSplitPane[t]=0,te.direction[t]=0,te.paneCount[t]=0,te.minPaneSize[t]=0,te.dividerSize[t]=0,te.resizable[t]=0,ue.delete(t),ot.delete(t),Qr.delete(t),He.delete(t),e$3(e,t);}};return P}function xb(e,n){return te.isSplitPane[n]===1}function Tb(e,n){return te.direction[n]===0?"horizontal":"vertical"}function Sb(e,n){let r=it.get(e);if(r)return r;let o={id:e,lines:n,refCount:0};return it.set(e,o),o}function Cb(e){return it.get(e)}function Wb(e,n,r,o,t){for(let i=0;i<e.length-1;i++){let a=e[i];if(!a)continue;let s=n?a.viewport.x+a.viewport.width:a.viewport.y+a.viewport.height,l=n?o:t;if(l>=s&&l<s+r)return i}return -1}function Lb(e,n,r,o){if(te.isSplitPane[n]!==1)return -1;let t=ue.get(n);if(!t||t.length<2)return -1;let i=te.direction[n]===0,a=te.dividerSize[n]??1;return Wb(t,i,a,r,o)}function Eb(e,n){if(te.isSplitPane[n]!==1)return [];let r=ue.get(n);if(!r||r.length<2)return [];let o=te.direction[n]===0?"horizontal":"vertical",t=te.dividerSize[n]??1,i=Qr.get(n)??{fg:void 0,bg:void 0,char:"\u2502"},a=[];for(let s=0;s<r.length-1;s++){let l=r[s];l&&(o==="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 Pb(){te.isSplitPane.fill(0),te.direction.fill(0),te.paneCount.fill(0),te.minPaneSize.fill(0),te.dividerSize.fill(0),te.resizable.fill(0),ue.clear(),ot.clear(),Qr.clear(),He.clear(),it.clear();}var vb=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)}),Bb={maxLines:1e4,wrapWidth:80,autoScroll:true,stripAnsi:false};function Yo(e,n){if(n<=0)return [e];if(e.length<=n)return [e];let r=[],o=e;for(;o.length>n;)r.push(o.slice(0,n)),o=o.slice(n);return o.length>0&&r.push(o),r}function yl(e){return e.replace(/\x1b(?:\[[0-9;?]*[a-zA-Z~]|\][^\x07\x1b]*(?:\x07|\x1b\\)?|[^[\]])/g,"")}function jo(e,n=24){return {lines:[],scrollTop:0,viewportHeight:n,totalBytes:0,isStreaming:false,config:{...Bb,...e},partialLine:"",dirty:null}}function Xr(e,n){let r=n;e.config.stripAnsi&&(r=yl(r));let o=e.totalBytes+r.length,i=(e.partialLine+r).split(`
|
|
13
|
+
`),a=i.pop()??"",s=[];for(let u of i){let b=Yo(u,e.config.wrapWidth);for(let p of b)s.push(p);}let l=[...e.lines,...s],d=0;e.config.maxLines>0&&l.length>e.config.maxLines&&(d=l.length-e.config.maxLines,l=l.slice(d));let f={startLine:Math.max(0,l.length-s.length),lineCount:s.length,fullRedraw:d>0},g=e.scrollTop;return d>0&&(g=Math.max(0,g-d)),e.config.autoScroll&&(g=Math.max(0,l.length-e.viewportHeight)),{...e,lines:l,scrollTop:g,totalBytes:o,partialLine:a,dirty:f}}function hl(e){return {...e,lines:[],scrollTop:0,totalBytes:0,partialLine:"",dirty:{startLine:0,lineCount:0,fullRedraw:true}}}function xl(e){let n=e.scrollTop,r=Math.min(n+e.viewportHeight,e.lines.length);return e.lines.slice(n,r)}function Pn(e,n){let r=Math.max(0,e.lines.length-e.viewportHeight),o=Math.max(0,Math.min(n,r));return o===e.scrollTop?e:{...e,scrollTop:o,dirty:{startLine:0,lineCount:e.viewportHeight,fullRedraw:true}}}function Tl(e,n){return Pn(e,e.scrollTop+n)}function Db(e,n,r){let o=n,t=jo(r),i={eid:o,append(a){return t=Xr(t,a),g(e,o),i},appendLine(a){return t=Xr(t,`${a}
|
|
14
|
+
`),g(e,o),i},clear(){return t=hl(t),g(e,o),i},getState(){return t},getVisibleLines(){return xl(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=Pn(t,a),g(e,o),i},scrollBy(a){return t=Tl(t,a),g(e,o),i},scrollToBottom(){let a=Math.max(0,t.lines.length-t.viewportHeight);return t=Pn(t,a),g(e,o),i},scrollToTop(){return t=Pn(t,0),g(e,o),i},setViewportHeight(a){return t={...t,viewportHeight:a},i},setWrapWidth(a){let s={...t.config,wrapWidth:a},l=t.lines.join(`
|
|
15
|
+
`)+(t.partialLine?t.partialLine:"");return t=jo(s,t.viewportHeight),l.length>0&&(t=Xr(t,l)),g(e,o),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=Yo(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)}),g(e,o);}else t={...t,isStreaming:false};return i}};return i}s();n();f();var Cl=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Mb=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(),Ll=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:Cl.optional(),top:Cl.optional(),border:Mb,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)}),Qo=1e4,ze={isTerminal:new Uint8Array(Qo),mouseEnabled:new Uint8Array(Qo),keysEnabled:new Uint8Array(Qo)},Xo=new Map;function Wl(e){return e===void 0?0:typeof e=="number"?e:0}function Ab(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Rb(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$5;case "bold":return e$6;case "ascii":return f$3}}function Vb(e){let n=process.env.SHELL??"/bin/sh",r={...process.env};return typeof e=="string"?{shell:e,args:[],env:r,cwd:void 0}:e?{shell:e.shell??n,args:e.args?[...e.args]:[],env:e.env?{...process.env,...e.env}:r,cwd:e.cwd}:{shell:n,args:[],env:r,cwd:void 0}}function Ib(){let e=[()=>createRequire(pathToFileURL(`${process.cwd()}/`).href)("node-pty"),()=>createRequire(import.meta.url)("node-pty"),()=>{let n=process.argv[1];if(n)return createRequire(pathToFileURL(n).href)("node-pty");throw new Error("No main module")}];for(let n of e)try{return n()}catch{}return null}function kb(e,n,r){if(!r)return;let o=r.type?Ab(r.type):1;if(j$2(e,n,{type:o,fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0}),r.ch){let t=typeof r.ch=="string"?Rb(r.ch):r.ch;k(e,n,t);}}function Fb(e,n,r){r&&d(e,n,{fg:r.fg!==void 0?e$1(r.fg):void 0,bg:r.bg!==void 0?e$1(r.bg):void 0});}function _b(e,n,r){let o=r!==void 0&&r.type!=="none";return {displayWidth:e+(o?2:0),displayHeight:n+(o?2:0)}}function Ob(e,n={}){let r=Ll.parse(n),o=d$1(e);ze.isTerminal[o]=1,ze.mouseEnabled[o]=r.mouse?1:0,ze.keysEnabled[o]=r.keys?1:0;let t=Wl(r.left),i=Wl(r.top);s$1(e,o,t,i);let{displayWidth:a,displayHeight:s}=_b(r.width,r.height,r.border);L(e,o,a,s);let l={width:r.width,height:r.height,scrollbackLines:r.scrollback,cursorBlink:r.cursorBlink,cursorShape:r.cursorShape,cursorVisible:true};Qb$1(e,o,l),Fb(e,o,r.style),j(e,o,true),kb(e,o,r.border),W(e,o,{focusable:true});let d={pty:null,onDataCallback:null,onExitCallback:null};Xo.set(o,d);let m={eid:o,write(f){return Vb$1(e,o,f),m},writeln(f){return Vb$1(e,o,`${f}
|
|
16
|
+
`),m},clear(){return Wb$1(e,o),m},reset(){return Xb$1(e,o),m},scrollUp(f=1){return _b$1(e,o,f),m},scrollDown(f=1){return $b$1(e,o,f),m},scrollToTop(){return ac$1(e,o),m},scrollToBottom(){return bc$1(e,o),m},setCursor(f,g){return Yb$1(e,o,f,g),m},showCursor(){return Zb$1(e,o,true),m},hideCursor(){return Zb$1(e,o,false),m},spawn(f){let g=Ib();if(!g)return console.warn("node-pty is not installed. Install it with: pnpm add node-pty"),m;d.pty&&m.kill();let{shell:u,args:b,env:p,cwd:W}=Vb(f),P=Tb$1(o),y=P?.width??80,T=P?.height??24,L=g.spawn(u,b,{name:"xterm-256color",cols:y,rows:T,cwd:W,env:p});return d.pty=L,L.onData(S=>{Vb$1(e,o,S),d.onDataCallback&&d.onDataCallback(S);}),L.onExit(({exitCode:S,signal:C})=>{d.pty=null,d.onExitCallback&&d.onExitCallback(S,C);}),m},input(f){let g=d.pty;return g&&g.write(f),m},resize(f,g$1){cc$1(e,o,f,g$1);let u=d.pty;u&&u.resize(f,g$1);let b=r.border!==void 0&&r.border.type!=="none",p=f+(b?2:0),W=g$1+(b?2:0);return L(e,o,p,W),g(e,o),m},kill(f="SIGTERM"){let g=d.pty;return g&&(g.kill(f),d.pty=null),m},isRunning(){return d.pty!==null},onData(f){return d.onDataCallback=f,m},onExit(f){return d.onExitCallback=f,m},show(){return j(e,o,true),m},hide(){return j(e,o,false),m},focus(){return _$1(e,o),m},blur(){return $(e,o),m},isFocused(){return Y$1(e,o)},getDimensions(){let f=Tb$1(o);return {width:f?.width??0,height:f?.height??0}},getCursor(){let f=Tb$1(o);return {x:f?.cursorX??0,y:f?.cursorY??0}},getState(){return Sb$1(o)},getCells(){return fc$1(o)},destroy(){m.kill(),ze.isTerminal[o]=0,ze.mouseEnabled[o]=0,ze.keysEnabled[o]=0,dc(o),Xo.delete(o),e$3(e,o);},refresh(){return g(e,o),m}};return g(e,o),m}var Nb={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 wb(e,n){let r=Nb[n];return r?(e.input(r),true):false}function Ub(e,n){if(!n)return false;let r=n.toUpperCase().charCodeAt(0)-64;return r>=0&&r<=31?(e.input(String.fromCharCode(r)),true):false}function Hb(e,n){return n?(e.input(`\x1B${n}`),true):false}function zb(e,n,r,o,t){return wb(e,n)||o&&Ub(e,r)||t&&Hb(e,r)?true:r&&!o&&!t?(e.input(r),true):false}function Gb(e,n,r){return n==="pageup"?(e.scrollUp(e.getDimensions().height),true):n==="pagedown"?(e.scrollDown(e.getDimensions().height),true):n==="home"&&r?(e.scrollToTop(),true):n==="end"&&r?(e.scrollToBottom(),true):false}function $b(e,n,r,o=false,t=false,i=false){return e.isRunning()?zb(e,n,r,o,t):Gb(e,n,o)}function jb(e,n){return ze.isTerminal[n]===1}function Yb(e,n){return ze.mouseEnabled[n]===1}function Kb(e,n){return ze.keysEnabled[n]===1}function Qb(){ze.isTerminal.fill(0),ze.mouseEnabled.fill(0),ze.keysEnabled.fill(0),Xo.clear();}n();var El=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)}),Xb=1e4,vn={isVideo:new Uint8Array(Xb)},J=new Map,Pl=["/usr/bin/mpv","/usr/local/bin/mpv","/opt/homebrew/bin/mpv","/snap/bin/mpv"],vl=["/usr/bin/mplayer","/usr/local/bin/mplayer","/opt/homebrew/bin/mplayer"];function Bl(e=Dl){for(let n of Pl)if(e(n))return {player:"mpv",path:n};for(let n of vl)if(e(n))return {player:"mplayer",path:n}}function Dl(e){try{return a$1("fs").existsSync(e)}catch{return false}}function Ml(e,n,r){let o=[];return e.outputDriver==="caca"?o.push("--vo=caca"):e.outputDriver==="tct"?(o.push("--vo=tct"),o.push(`--vo-tct-width=${n}`),o.push(`--vo-tct-height=${r}`)):e.outputDriver==="sixel"&&(o.push("--vo=sixel"),o.push(`--vo-sixel-width=${n*8}`),o.push(`--vo-sixel-height=${r*14}`)),o.push("--no-osc"),o.push("--no-input-default-bindings"),o.push("--terminal=no"),o.push("--no-input-terminal"),e.speed!==1&&o.push(`--speed=${e.speed}`),e.loop&&o.push("--loop=inf"),e.mute&&o.push("--mute=yes"),e.seekPosition>0&&o.push(`--start=${e.seekPosition}`),o.push(e.path),o}function Al(e,n,r){let o=[];return e.outputDriver,o.push("-vo","caca"),o.push("-slave"),o.push("-quiet"),e.speed!==1&&o.push("-speed",String(e.speed)),e.loop&&o.push("-loop","0"),e.mute&&o.push("-nosound"),e.seekPosition>0&&o.push("-ss",String(e.seekPosition)),o.push(e.path),o}function Rl(e,n,r,o){return e==="mpv"?Ml(n,r,o):Al(n)}function qo(e,n){n==="mplayer"&&e.write(`pause
|
|
17
|
+
`);}function Vl(e,n,r){n==="mplayer"&&e.write(`seek ${r} 2
|
|
18
|
+
`);}function qb(e,n={},r){let o=El.parse(n),t=d$1(e);s$1(e,t,o.x,o.y),L(e,t,o.width,o.height),vn.isVideo[t]=1;let i={path:o.path,player:o.player,outputDriver:o.outputDriver,speed:o.speed,loop:o.loop,mute:o.mute,playbackState:"stopped",visible:o.visible,process:null,seekPosition:0,onEndCallback:null,onErrorCallback:null,onDataCallback:null};J.set(t,i),o.visible||j(e,t,false);let a=rf(e,t,r);return o.autoPlay&&o.path&&a.play(),a}function Jb(e){return e.playbackState!=="paused"||!e.process||e.player!=="mplayer"?false:(qo(e.process,"mplayer"),e.playbackState="playing",true)}function Zb(e){e.process&&(e.process.kill(),e.process=null);}function ef(e,n){if(e.player)return true;let r=n?.exists??Dl,o=Bl(r);return o?(e.player=o.player,true):false}function tf(e,n,r,o,t,i){let a=Rl(e.player,e,t,i),s=n.spawn(e.player,a);e.process=s,e.playbackState="playing",s.onData(l=>{e$2(r,o,l),g(r,o),e.onDataCallback?.(l);}),s.onExit(l=>{e.process=null,e.playbackState="stopped",l===0?e.onEndCallback?.():e.onErrorCallback?.(`Player exited with code ${l}`);});}function nf(e,n,r,o){if(!e.path)return "No video path set";if(Zb(e),!ef(e,n))return "No video player found (mpv or mplayer required)";if(!n)return "No process spawner available";let t=K$1.width[o]||80,i=K$1.height[o]||24;try{tf(e,n,r,o,t,i);}catch(a){return a instanceof Error?a.message:String(a)}return null}function rf(e,n,r){return {get eid(){return n},show(){let o=J.get(n);return o&&(o.visible=true),j(e,n,true),g(e,n),this},hide(){let o=J.get(n);return o&&(o.visible=false),j(e,n,false),g(e,n),this},isVisible(){return J.get(n)?.visible??false},move(o,t){let i=r$2.x[n]??0,a=r$2.y[n]??0;return s$1(e,n,i+o,a+t),g(e,n),this},setPosition(o,t){return s$1(e,n,o,t),g(e,n),this},getPosition(){return {x:r$2.x[n]??0,y:r$2.y[n]??0}},setPath(o){let t=J.get(n);return t&&(t.path=o),this},getPath(){return J.get(n)?.path??""},play(){let o=J.get(n);if(!o)return this;if(Jb(o))return this;let t=nf(o,r,e,n);return t&&o.onErrorCallback?.(t),this},pause(){let o=J.get(n);return o?o.playbackState!=="playing"?this:(o.process&&o.player==="mplayer"&&qo(o.process,"mplayer"),o.playbackState="paused",this):this},stop(){let o=J.get(n);return o?(o.process&&(o.process.kill(),o.process=null),o.playbackState="stopped",o.seekPosition=0,e$2(e,n,""),g(e,n),this):this},togglePlayback(){let o=J.get(n);return o?o.playbackState==="playing"?this.pause():this.play():this},seek(o){let t=J.get(n);return t?(t.seekPosition=Math.max(0,o),t.process&&t.player==="mplayer"?Vl(t.process,"mplayer",o):t.playbackState==="playing"&&(this.stop(),t.seekPosition=Math.max(0,o),this.play()),this):this},getPlaybackState(){return J.get(n)?.playbackState??"stopped"},setSpeed(o){let t=J.get(n);return t&&(t.speed=o),this},getSpeed(){return J.get(n)?.speed??1},setLoop(o){let t=J.get(n);return t&&(t.loop=o),this},getLoop(){return J.get(n)?.loop??false},setMute(o){let t=J.get(n);return t&&(t.mute=o),this},getMute(){return J.get(n)?.mute??true},getPlayer(){return J.get(n)?.player},isRunning(){return J.get(n)?.process!==null},resize(o,t){L(e,n,o,t);let i=J.get(n);return i?.process?.resize&&i.process.resize(o,t),g(e,n),this},onEnd(o){let t=J.get(n);return t&&(t.onEndCallback=o),this},onError(o){let t=J.get(n);return t&&(t.onErrorCallback=o),this},onData(o){let t=J.get(n);return t&&(t.onDataCallback=o),this},destroy(){let o=J.get(n);o?.process&&o.process.kill(),vn.isVideo[n]=0,J.delete(n),e$3(e,n);}}}function of(e,n){return vn.isVideo[n]===1}function af(e){return J.get(e)?.playbackState}function sf(e){return J.get(e)?.player}function lf(){for(let e of J.values())e.process&&e.process.kill();vn.isVideo.fill(0),J.clear();}s();n();var Fl=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()}),_l=z.object({type:z.nativeEnum(a).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),Ol=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:Fl.optional(),border:_l.optional(),overscan:z.number().int().nonnegative().default(5),maxLines:z.number().int().nonnegative().default(0)}),uf=["fg","bg","selectedFg","selectedBg","cursorFg","cursorBg","showLineNumbers","lineNumberWidth"];function df(e){let n={};for(let r of uf){let o=e[r];o!==void 0&&(n[r]=o);}return n}var Il=new WeakMap;function qr(e,n){if(e.store=n,h$2(e.eid,n),r$4(e.world,e.eid,n.lineCount),e.maxLines>0&&n.lineCount>e.maxLines){let r=w$1(n,e.maxLines);e.store=r,h$2(e.eid,r),r$4(e.world,e.eid,r.lineCount);}e.followMode&&p$1(e.world,e.eid),g(e.world,e.eid);}function kl(e,n){return Math.max(1,e-(n?2:0))}function cf(e,n){let r=Ol.parse(n),o=d$1(e);s$1(e,o,r.x,r.y),L(e,o,r.width,r.height),a$2.x[o]=r.x,a$2.y[o]=r.y,a$2.width[o]=r.width,a$2.height[o]=r.height,a$2.valid[o]=1;let t=r.border!==void 0&&r.border.type!==0,i$2=kl(r.height,t),a;r.lines&&r.lines.length>0?a=g$1(r.lines):a=h$1(),e$4(o,a),e$5(e,o,{totalLineCount:a.lineCount,visibleLineCount:i$2,overscanBefore:r.overscan,overscanAfter:r.overscan,selectedLine:-1,cursorLine:-1});let s={fg:r.style?.fg??4294967295,bg:r.style?.bg??255};d(e,o,s),j(e,o,true);let l={};r.style?.fg!==void 0&&(l.fg=r.style.fg),r.style?.bg!==void 0&&(l.bg=r.style.bg),r.style?.selectedFg!==void 0&&(l.selectedFg=r.style.selectedFg),r.style?.selectedBg!==void 0&&(l.selectedBg=r.style.selectedBg),r.style?.cursorFg!==void 0&&(l.cursorFg=r.style.cursorFg),r.style?.cursorBg!==void 0&&(l.cursorBg=r.style.cursorBg),r.style?.showLineNumbers!==void 0&&(l.showLineNumbers=r.style.showLineNumbers),r.style?.lineNumberWidth!==void 0&&(l.lineNumberWidth=r.style.lineNumberWidth),i(o,l),r.border&&j$2(e,o,r.border);let d$2={world:e,eid:o,store:a,followMode:false,maxLines:r.maxLines,mouseEnabled:r.mouse,keysEnabled:r.keys},m={eid:o};Il.set(m,d$2),g(e,o);let f={eid:o,show(){return j(e,o,true),g(e,o),f},hide(){return j(e,o,false),g(e,o),f},setPosition(g$1,u){return s$1(e,o,g$1,u),a$2.x[o]=g$1,a$2.y[o]=u,g(e,o),f},setDimensions(g$1,u){L(e,o,g$1,u),a$2.width[o]=g$1,a$2.height[o]=u;let b=kl(u,t);return s$3(e,o,b),g(e,o),f},setLines(g){let u=g.length>0?g$1(g):h$1();return qr(d$2,u),f},appendLine(g){let u=m$2(d$2.store,d$2.store.byteSize>0?`
|
|
19
|
+
${g}`:g);return qr(d$2,u),f},appendLines(g){if(g.length===0)return f;let u=n$3(d$2.store,g);return qr(d$2,u),f},getLineCount(){return o$3(d$2.store)},getLine(g){return i$1(d$2.store,g)},clear(){return qr(d$2,h$1()),f},scrollToLine(g){return l$2(e,o,g),f},scrollToTop(){return o$2(e,o),f},scrollToBottom(){return p$1(e,o),f},scrollBy(g){return m$1(e,o,g),f},scrollPage(g){return n$2(e,o,g),f},getScrollInfo(){return q$3(e,o)},select(g){return u$2(e,o,g),f},getSelected(){return d$4.selectedLine[o]},clearSelection(){return u$2(e,o,-1),f},cursorUp(g=1){return y$2(e,o,-g),f},cursorDown(g=1){return y$2(e,o,g),f},setCursor(g$1){return d$4.cursorLine[o]=g$1,g(e,o),f},getCursor(){return d$4.cursorLine[o]},follow(g){return d$2.followMode=g,g&&p$1(e,o),f},isFollowing(){return d$2.followMode},setStyle(g$1){return i(o,df(g$1)),g(e,o),f},destroy(){o$1(o),Il.delete(m),e$3(e,o);},refresh(){return g(e,o),f}};return f}function gf(e,n,r=false,o=false){switch(n){case "up":case "k":return e.cursorUp(o?5:1),true;case "down":case "j":return e.cursorDown(o?5:1),true;case "pageup":return e.scrollPage(-1),true;case "pagedown":return e.scrollPage(1),true;case "home":return r?(e.scrollToTop(),e.setCursor(0)):e.scrollToTop(),true;case "end":if(r){e.scrollToBottom();let t=e.getLineCount();e.setCursor(t-1);}else e.scrollToBottom();return true;case "g":return !r&&!o?(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 mf(e,n,r=3){return n==="up"?e.scrollBy(-r):e.scrollBy(r),true}function bf(e,n){return d$4.totalLineCount[n]!==void 0&&d$4.visibleLineCount[n]!==void 0}export{Dd as $,ls as $a,zg as $b,ub as $c,bu as A,Ka as Aa,wr as Ab,js as Ac,jb as Ad,fa as B,Zd as Ba,xs as Bb,Ys as Bc,Yb as Bd,Te as C,Po as Ca,Ts as Cb,X as Cc,Kb as Cd,Ie as D,ec as Da,Ss as Db,wo as Dc,Qb as Dd,ku as E,qa as Ea,Cs as Eb,Im as Ec,El as Ed,Ou as F,vo as Fa,N as Fb,km as Fc,vn as Fd,Nu as G,tc as Ga,Ro as Gb,Fm as Gc,Pl as Gd,wu as H,nc as Ha,Lg as Hb,_m as Hc,vl as Hd,Uu as I,rc as Ia,Eg as Ib,Om as Ic,Bl as Id,Hu as J,Ja,Pg as Jb,Nm as Jc,Ml as Jd,zu as K,Za as Ka,vg as Kb,qs as Kc,Al as Kd,Gu as L,kr as La,Bg as Lb,xn as Lc,Rl as Ld,$u as M,ic as Ma,Dg as Mb,Uo as Mc,qo as Md,ju as N,ac as Na,Mg as Nb,jm as Nc,Vl as Nd,Yu as O,sc as Oa,Rg as Ob,Ym as Oc,qb as Od,Ku as P,es as Pa,Vg as Pb,Km as Pc,of as Pd,yo as Q,lc as Qa,Ls as Qb,Qm as Qc,af as Qd,qu as R,uc as Ra,Es as Rb,il as Rc,sf as Rd,Ju as S,is as Sa,Ps as Sb,qm as Sc,lf as Sd,Zu as T,K as Ta,vs as Tb,Go as Tc,Fl as Td,ed as U,Pc as Ua,Io as Ub,ib as Uc,_l as Ud,td as V,vc as Va,pn as Vb,$r as Vc,Ol as Vd,nd as W,Bc as Wa,Be as Wb,$o as Wc,cf as Wd,rd as X,Dc as Xa,Bs as Xb,sb as Xc,gf as Xd,Pa as Y,Mc as Ya,wg as Yb,ul as Yc,mf as Yd,un as Z,Ac as Za,Ug as Zb,dl as Zc,bf as Zd,vd as _,ss as _a,Hg as _b,jr as _c,la as a,Md as aa,Bo as ab,$g as ac,db as ad,rn as b,Ad as ba,us as bb,jg as bc,cb as bd,bo as c,Rd as ca,ce as cb,Ds as cc,pl as cd,ql as d,Aa as da,bn as db,Ms as dc,te as dd,Jl as e,w as ea,Hc as eb,As as ec,hb as ed,Zl as f,Ra as fa,zc as fb,yn as fc,xb as fd,eu as g,Va as ga,Gc as gb,De as gc,Tb as gd,et as h,Ia as ha,$c as hb,Rs as hc,Sb as hd,nu as i,Co as ia,Do as ib,Vs as ic,Cb as id,ua as j,wd as ja,cs as jb,tm as jc,Lb as jd,da as k,Ud as ka,gs as kb,nm as kc,Eb as kd,ru as l,Hd as la,jc as lb,rm as lc,Pb as ld,ou as m,Ir as ma,Yc as mb,om as mc,vb as md,fo as n,Oa as na,Kc as nb,_s as nc,Yo as nd,ca as o,Na as oa,ms as ob,Ue as oc,yl as od,ga as p,wa as pa,le as pb,hn as pc,jo as pd,po as q,ve as qa,bs as qb,Fo as qc,Xr as qd,iu as r,Lo as ra,ag as rb,xm as rc,hl as rd,au as s,$d as sa,Nr as sb,Tm as sc,xl as sd,su as t,jd as ta,sg as tb,Sm as tc,Pn as td,lu as u,Yd as ua,lg as ub,_o as uc,Tl as ud,uu as v,Kd as va,ug as vb,Ns as vc,Db as vd,du as w,Qd as wa,dg as wb,Oo as wc,Ll as wd,cu as x,Ua as xa,cg as xb,Cm as xc,ze as xd,gu as y,Eo as ya,gg as yb,Wm as yc,Ob as yd,mu as z,Xd as za,mg as zb,$s as zc,$b as zd};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b as b$1,k as k$1,d,f as f$1,i}from'./chunk-KFAK4A3G.js';import {f as f$2,e}from'./chunk-FYEBZAWN.js';import {g,Z as Z$1,ha,ia,ga}from'./chunk-W5OU7Z6J.js';import {m,n}from'./chunk-Z4EZERNE.js';import {h}from'./chunk-G7GIWWLE.js';import {z as z$1}from'zod';var _e={initial:"idle",states:{idle:{on:{mouseenter:"hovered",focus:"focused",disable:"disabled"}},hovered:{on:{mousedown:"pressed",mouseleave:"idle",focus:"focused",disable:"disabled"}},pressed:{on:{mouseup:"hovered",mouseleave:"idle"}},focused:{on:{blur:"idle",mouseenter:"hovered",disable:"disabled"}},disabled:{on:{enable:"idle"}}}},Oe=1e4;function Ue(e=Oe){return {isButton:new Uint8Array(e),machineId:new Uint32Array(e)}}var et=Ue(),R=new Map;function tr(){et.isButton.fill(0),et.machineId.fill(0),R.clear();}function er(e,t){let n=b$1(e,t,_e);return et.isButton[t]=1,et.machineId[t]=n,n}function I(e,t){return (et.isButton[t]??0)===1&&k$1(e,t)}function gt(e,t){if(I(e,t))return d(e,t)}function Ht(e,t,n){if(!I(e,t))return false;let r=d(e,t),o=f$1(e,t,n);return o&&(g(e,t),r==="pressed"&&n==="mouseup"&&wt(t)),o}function xt(e,t,n){return I(e,t)?i(e,t,n):false}function nr(e,t){return xt(e,t,"hovered")}function rr(e,t){return xt(e,t,"pressed")}function or(e,t){return xt(e,t,"focused")}function ir(e,t){return xt(e,t,"disabled")}function lr(e,t){return Ht(e,t,"disable")}function ar(e,t){return Ht(e,t,"enable")}function sr(e,t){let n=R.get(e);return n||(n=[],R.set(e,n)),n.push(t),()=>{let r=R.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function wt(e){let t=R.get(e);if(t)for(let n of t)n();}function Le(e,t){return !I(e,t)||gt(e,t)==="disabled"?false:(wt(t),true)}function cr(e){R.delete(e);}function ur(e,t,n){if(!I(e,t))return false;let r=gt(e,t);return r==="disabled"||r!=="focused"?false:n==="return"||n==="enter"||n==="space"?(Le(e,t),true):false}var Ve={initial:"unchecked",states:{unchecked:{on:{toggle:"checked",check:"checked",disable:"disabled"}},checked:{on:{toggle:"unchecked",uncheck:"unchecked",disable:"disabled"}},disabled:{on:{enable:"unchecked"}}}},He=1e4;function we(e=He){return {isCheckbox:new Uint8Array(e),machineId:new Uint32Array(e)}}var nt=we(),P=new Map,Nt="\u2611",Kt="\u2610",rt=new Map;function gr(){nt.isCheckbox.fill(0),nt.machineId.fill(0),P.clear(),rt.clear();}function xr(e,t,n=false){let r=b$1(e,t,Ve);return nt.isCheckbox[t]=1,nt.machineId[t]=r,n&&f$1(e,t,"check"),r}function C(e,t){return (nt.isCheckbox[t]??0)===1&&k$1(e,t)}function vt(e,t){if(C(e,t))return d(e,t)}function ot(e,t,n){if(!C(e,t))return false;let r=d(e,t),o=f$1(e,t,n);if(o){g(e,t);let i=d(e,t);(r==="checked"||r==="unchecked")&&(i==="checked"||i==="unchecked")&&r!==i&&ze(t,i==="checked");}return o}function kt(e,t,n){return C(e,t)?i(e,t,n):false}function Gt(e,t){return kt(e,t,"checked")}function yr(e,t){return kt(e,t,"unchecked")}function br(e,t){return kt(e,t,"disabled")}function Ne(e,t){return ot(e,t,"toggle")}function Ke(e,t){return ot(e,t,"check")}function Ge(e,t){return ot(e,t,"uncheck")}function hr(e,t){return ot(e,t,"disable")}function mr(e,t){return ot(e,t,"enable")}function zt(e,t,n){if(!C(e,t))return false;let r=vt(e,t);return r==="disabled"?false:n&&r==="unchecked"?Ke(e,t):!n&&r==="checked"?Ge(e,t):false}function Er(e,t){let n=P.get(e);return n||(n=[],P.set(e,n)),n.push(t),()=>{let r=P.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function ze(e,t){let n=P.get(e);if(n)for(let r of n)r(t);}function Sr(e){P.delete(e);}function Cr(e,t,n){return !C(e,t)||vt(e,t)==="disabled"?false:n==="return"||n==="enter"||n==="space"?(Ne(e,t),true):false}function vr(e,t){let n=rt.get(e)??{checkedChar:Nt,uncheckedChar:Kt};rt.set(e,{checkedChar:t.checkedChar??n.checkedChar,uncheckedChar:t.uncheckedChar??n.uncheckedChar});}function Ye(e){return rt.get(e)??{checkedChar:Nt,uncheckedChar:Kt}}function kr(e,t){let n=Ye(t);return vt(e,t)==="checked"?n.checkedChar:n.uncheckedChar}function Ir(e){rt.delete(e);}var Xe={initial:"idle",states:{idle:{on:{focus:"focused",disable:"disabled"}},focused:{on:{startEdit:"editing",blur:"idle",error:"error",disable:"disabled"}},editing:{on:{endEdit:"focused",blur:"idle",error:"error"}},error:{on:{clearError:"focused",blur:"idle",disable:"disabled"}},disabled:{on:{enable:"idle"}}}},$e=1e4,_={Line:0,Block:1},je=530;function qe(e=$e){return {isTextInput:new Uint8Array(e),machineId:new Uint32Array(e),cursorPos:new Uint32Array(e),selectionStart:new Int32Array(e).fill(-1),selectionEnd:new Int32Array(e).fill(-1),inputMode:new Uint8Array(e),cursorMode:new Uint8Array(e),cursorBlink:new Uint8Array(e).fill(1),cursorBlinkStart:new Float64Array(e)}}var c=qe(),It="*",At="",V=new Map,O=new Map,U=new Map,L=new Map;function Tr(){c.isTextInput.fill(0),c.machineId.fill(0),c.cursorPos.fill(0),c.selectionStart.fill(-1),c.selectionEnd.fill(-1),c.inputMode.fill(0),c.cursorMode.fill(0),c.cursorBlink.fill(1),c.cursorBlinkStart.fill(0),V.clear(),O.clear(),U.clear(),L.clear(),Wt.clear();}function Wr(e,t){let n=b$1(e,t,Xe);return c.isTextInput[t]=1,c.machineId[t]=n,c.cursorPos[t]=0,c.selectionStart[t]=-1,c.selectionEnd[t]=-1,c.inputMode[t]=0,c.cursorMode[t]=_.Line,c.cursorBlink[t]=1,c.cursorBlinkStart[t]=Date.now(),V.set(t,{secret:false,censor:It,placeholder:At,maxLength:0,multiline:false}),n}function b(e,t){return (c.isTextInput[t]??0)===1&&k$1(e,t)}function Bt(e,t){if(b(e,t))return d(e,t)}function k(e,t,n){if(!b(e,t))return false;let r=f$1(e,t,n);if(r){g(e,t);let o=d(e,t);c.inputMode[t]=o==="editing"?1:0;}return r}function Ft(e,t,n){return b(e,t)?i(e,t,n):false}function Mr(e,t){let n=Bt(e,t);return n==="focused"||n==="editing"}function Dr(e,t){return Ft(e,t,"editing")}function Rr(e,t){return Ft(e,t,"error")}function Pr(e,t){return Ft(e,t,"disabled")}function Je(e,t){return k(e,t,"focus")}function _r(e,t){return k(e,t,"blur")}function Or(e,t){return k(e,t,"startEdit")}function Ur(e,t){return k(e,t,"endEdit")}function Lr(e,t){return k(e,t,"disable")}function Vr(e,t){return k(e,t,"enable")}function Hr(e,t){return k(e,t,"error")}function wr(e,t){return k(e,t,"clearError")}function Tt(e){return c.cursorPos[e]??0}function Qe(e,t,n){b(e,t)&&(c.cursorPos[t]=Math.max(0,n),c.cursorBlinkStart[t]=Date.now(),g(e,t));}function Nr(e,t,n){let r=Tt(t);Qe(e,t,r+n);}function Yt(e){let t=c.selectionStart[e],n=c.selectionEnd[e];return t===void 0||n===void 0||t<0||n<0?null:[t,n]}function Kr(e,t,n,r){b(e,t)&&(c.selectionStart[t]=n,c.selectionEnd[t]=r,g(e,t));}function Gr(e,t){b(e,t)&&(c.selectionStart[t]=-1,c.selectionEnd[t]=-1,g(e,t));}function zr(e){return Yt(e)!==null}var Ze="\u2502",tn="\u2588",Wt=new Map;function Mt(e){return Wt.get(e)??{blink:true,blinkIntervalMs:je,lineChar:Ze,blockChar:tn}}function Yr(e,t){let n=Mt(e);Wt.set(e,{blink:t.blink??n.blink,blinkIntervalMs:t.blinkIntervalMs??n.blinkIntervalMs,lineChar:t.lineChar??n.lineChar,blockChar:t.blockChar??n.blockChar});}function Dt(e){return c.cursorMode[e]??0}function en(e,t,n){b(e,t)&&(c.cursorMode[t]=n,g(e,t));}function Xr(e,t){let r=Dt(t)===_.Line?_.Block:_.Line;return en(e,t,r),r}function nn(e){return (c.cursorBlink[e]??1)===1}function $r(e,t,n){b(e,t)&&(c.cursorBlink[t]=n?1:0,n&&(c.cursorBlinkStart[t]=Date.now()),g(e,t));}function jr(e){c.cursorBlinkStart[e]=Date.now();}function rn(e,t){let n=Bt(e,t);if(n!=="focused"&&n!=="editing")return false;if(!nn(t))return true;let r=Mt(t),o=c.cursorBlinkStart[t]??Date.now(),i=Date.now()-o;return Math.floor(i/r.blinkIntervalMs)%2===0}function on(e){let t=Mt(e);return Dt(e)===_.Block?t.blockChar:t.lineChar}function qr(e,t,n){let r=A(t),o=Tt(t),i=n;if(r.secret&&(i=r.censor.repeat(n.length)),i.length===0&&r.placeholder)return {displayText:r.placeholder,cursorVisible:false,cursorPosition:0};if(!rn(e,t))return {displayText:i,cursorVisible:false,cursorPosition:o};let p=on(t),h=Dt(t),g;return h===_.Block&&o<i.length?g=i.substring(0,o)+p+i.substring(o+1):g=i.substring(0,o)+p+i.substring(o),{displayText:g,cursorVisible:true,cursorPosition:o}}function Jr(e){let t=Yt(e);if(!t)return null;let[n,r]=t;return {start:Math.min(n,r),end:Math.max(n,r)}}function Qr(e,t){let n=V.get(e)??{secret:false,censor:It,placeholder:At,maxLength:0,multiline:false};V.set(e,{secret:t.secret??n.secret,censor:t.censor??n.censor,placeholder:t.placeholder??n.placeholder,maxLength:t.maxLength??n.maxLength,multiline:t.multiline??n.multiline});}function A(e){return V.get(e)??{secret:false,censor:It,placeholder:At,maxLength:0,multiline:false}}function ln(e){return A(e).secret}function an(e){return A(e).censor}function Zr(e){return A(e).placeholder}function to(e){return A(e).maxLength}function eo(e){return A(e).multiline}function no(e,t){return ln(e)?an(e).repeat(t.length):t}function ro(e,t){let n=O.get(e);return n||(n=[],O.set(e,n)),n.push(t),()=>{let r=O.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function oo(e,t){let n=U.get(e);return n||(n=[],U.set(e,n)),n.push(t),()=>{let r=U.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function io(e,t){let n=L.get(e);return n||(n=[],L.set(e,n)),n.push(t),()=>{let r=L.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function lo(e,t){let n=O.get(e);if(n)for(let r of n)r(t);}function ao(e,t){let n=U.get(e);if(n)for(let r of n)r(t);}function so(e){let t=L.get(e);if(t)for(let n of t)n();}function co(e){O.delete(e),U.delete(e),L.delete(e),V.delete(e);}function sn(e,t,n){return e.multiline?e.maxLength>0&&n.length>=e.maxLength?null:{type:"newline",position:t}:{type:"submit",value:n}}function cn(e,t){return e.multiline?{type:"submit",value:t}:{type:"cancel"}}function un(e,t,n){return e==="left"&&t>0?{type:"moveCursor",position:t-1}:e==="right"&&t<n?{type:"moveCursor",position:t+1}:e==="home"&&t!==0?{type:"moveCursor",position:0}:e==="end"&&t!==n?{type:"moveCursor",position:n}:null}function fn(e,t,n){return e==="backspace"&&t>0?{type:"delete",start:t-1,end:t}:e==="delete"&&t<n?{type:"delete",start:t,end:t+1}:null}function pn(e,t,n,r){return e.length!==1||n.maxLength>0&&r>=n.maxLength?null:{type:"insert",char:e,position:t}}function uo(e,t,n,r){if(!b(e,t))return null;let o=Bt(e,t);if(o==="disabled")return null;if(o==="idle")return Je(e,t),null;let i=Tt(t),u=A(t),p=r.length;if(n==="return"||n==="enter")return sn(u,i,r);if(n==="escape")return cn(u,r);let h=fn(n,i,p);if(h)return h;let g=un(n,i,p);return g||pn(n,i,u,p)}var dn=1e4,Xt=1,$t=2;function gn(e=dn){return {isForm:new Uint8Array(e),flags:new Uint8Array(e)}}var B=gn(),F=new Map,it=new Map,H=new Map,w=new Map;function Eo(){B.isForm.fill(0),B.flags.fill(0),F.clear(),it.clear(),H.clear(),w.clear();}function So(e,t,n={}){B.isForm[t]=1;let r=0;n.keys!==false&&(r|=Xt),n.submitOnEnter!==false&&(r|=$t),B.flags[t]=r,F.set(t,new Map),it.set(t,new Map),g(e,t);}function jt(e,t){return B.isForm[t]===1}function xn(e){return (B.flags[e]&Xt)!==0}function yn(e){return (B.flags[e]&$t)!==0}function bn(e,t,n,r,o){if(!jt(e,t))return;let i=F.get(t),u=it.get(t);i&&u&&(i.set(n,r),o!==void 0?u.set(n,o):u.set(n,Jt(e,n)));}function Co(e,t,n){let r=F.get(t),o=it.get(t);r&&r.delete(n),o&&o.delete(n);}function qt(e,t){let n=F.get(t);return n?Array.from(n.keys()):[]}function vo(e,t){return F.get(e)?.get(t)}function Jt(e,t){return b(e,t)?f$2(e,t)??"":C(e,t)?Gt(e,t):I(e,t)?gt(e,t)==="pressed":f$2(e,t)??null}function hn(e$1,t,n){if(b(e$1,t)){e(e$1,t,String(n??""));return}if(C(e$1,t)){zt(e$1,t,!!n);return}n!==null&&e(e$1,t,String(n));}function mn(e,t){let n={},r=F.get(t);if(!r)return n;for(let[o,i]of r)n[i]=Jt(e,o);return n}function ko(e,t){let n=it.get(t);if(!n)return;for(let[o,i]of n)hn(e,o,i);let r=w.get(t);if(r)for(let o of r)o();g(e,t);}function En(e,t){let n=mn(e,t),r=H.get(t);if(r)for(let o of r)o(n);return n}function Io(e,t){let n=H.get(e)??[];return n.push(t),H.set(e,n),()=>{let r=H.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function Ao(e,t){let n=w.get(e)??[];return n.push(t),w.set(e,n),()=>{let r=w.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function Bo(e){H.delete(e),w.delete(e);}function Sn(e,t){let r=qt(e,t).filter(o=>Z$1(e,o));return ha(e,r)}function Cn(e,t){let r=qt(e,t).filter(o=>Z$1(e,o));return ia(e,r)}function Fo(e,t){let r=h(e,t).filter(o=>Z$1(e,o));return ga(e,r)}function To(e,t,n,r){return !jt(e,t)||!xn(t)?false:n==="tab"?(r?Cn(e,t):Sn(e,t),true):(n==="return"||n==="enter")&&yn(t)?(En(e,t),true):false}function Wo(e,t,n="field_"){let r=h(e,t);for(let o of r)if(b(e,o)||C(e,o)){let i=`${n}${o}`;bn(e,t,o,i);}}var vn=1e4,lt={Horizontal:0,Vertical:1};function kn(e=vn){return {isProgressBar:new Uint8Array(e),value:new Float32Array(e),min:new Float32Array(e),max:new Float32Array(e),orientation:new Uint8Array(e),showPercentage:new Uint8Array(e)}}var s=kn(),Qt="\u2588",Zt="\u2591",te="\u2588",ee="\u2591",at=new Map,N=new Map,K=new Map;function Ro(){s.isProgressBar.fill(0),s.value.fill(0),s.min.fill(0),s.max.fill(0),s.orientation.fill(0),s.showPercentage.fill(0),at.clear(),N.clear(),K.clear();}function Po(e,t,n={}){s.isProgressBar[t]=1,s.min[t]=n.min??0,s.max[t]=n.max??100,s.value[t]=n.value??0,s.orientation[t]=n.orientation??lt.Horizontal,s.showPercentage[t]=n.showPercentage?1:0,In(t,{}),g(e,t);}function _o(e,t){return s.isProgressBar[t]===1}function Oo(e){return s.value[e]}function Uo(e){return s.min[e]}function Lo(e){return s.max[e]}function ne(e){let t=s.min[e],n=s.max[e],r=s.value[e];return n===t?0:(r-t)/(n-t)*100}function Vo(e){return s.orientation[e]}function Ho(e){return s.showPercentage[e]===1}function st(e,t,n){let r=s.min[t],o=s.max[t],i=s.value[t],u=Math.max(r,Math.min(o,n));if(s.value[t]=u,g(e,t),u!==i){let p=ne(t);Bn(t,u,p),u===o&&i<o&&An(t);}}function wo(e,t,n=1){let r=s.value[t];st(e,t,r+n);}function No(e,t,n=1){let r=s.value[t];st(e,t,r-n);}function Ko(e,t){let n=s.min[t];st(e,t,n);}function Go(e,t){let n=s.max[t];st(e,t,n);}function zo(e){let t=s.max[e];return s.value[e]>=t}function In(e,t){let n=at.get(e),r=s.orientation[e],o=r===lt.Vertical?te:Qt,i=r===lt.Vertical?ee:Zt;at.set(e,{fillChar:t.fillChar??n?.fillChar??o,emptyChar:t.emptyChar??n?.emptyChar??i,fillFg:t.fillFg??n?.fillFg??16711935,fillBg:t.fillBg??n?.fillBg??255,emptyFg:t.emptyFg??n?.emptyFg??1717987071,emptyBg:t.emptyBg??n?.emptyBg??255});}function Rt(e){let t=at.get(e);if(t)return t;let n=s.orientation[e],r=n===lt.Vertical?te:Qt,o=n===lt.Vertical?ee:Zt;return {fillChar:r,emptyChar:o,fillFg:16711935,fillBg:255,emptyFg:1717987071,emptyBg:255}}function Yo(e){at.delete(e);}function Xo(e){return Rt(e).fillChar}function $o(e){return Rt(e).emptyChar}function jo(e,t){let n=ne(e)/100,r=Rt(e),o=Math.round(t*n),i=t-o;return r.fillChar.repeat(o)+r.emptyChar.repeat(i)}function qo(e,t){let n=N.get(e)??[];return n.push(t),N.set(e,n),()=>{let r=N.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function Jo(e,t){let n=K.get(e)??[];return n.push(t),K.set(e,n),()=>{let r=K.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function An(e){let t=N.get(e);if(t)for(let n of t)n();}function Bn(e,t,n){let r=K.get(e);if(r)for(let o of r)o(t,n);}function Qo(e){N.delete(e),K.delete(e);}function Zo(e,t,n){s.orientation[t]=n,g(e,t);}function ti(e,t,n){s.showPercentage[t]=n?1:0,g(e,t);}function ei(e,t,n,r){s.min[t]=n,s.max[t]=r;let o=s.value[t];(o<n||o>r)&&st(e,t,Math.max(n,Math.min(r,o))),g(e,t);}var Fn={initial:"unselected",states:{unselected:{on:{select:"selected",disable:"disabled"}},selected:{on:{deselect:"unselected",disable:"disabled"}},disabled:{on:{enable:"unselected"}}}},re=1e4;function Tn(e=re){return {isRadioButton:new Uint8Array(e),machineId:new Uint32Array(e),radioSetId:new Uint32Array(e)}}var x=Tn();function Wn(e=re){return {isRadioSet:new Uint8Array(e),selectedButton:new Uint32Array(e)}}var S=Wn(),oe="\u25C9",ie="\u25CB",ct=new Map,z=new Map,G=new Map;function ii(){x.isRadioButton.fill(0),x.machineId.fill(0),x.radioSetId.fill(0),S.isRadioSet.fill(0),S.selectedButton.fill(0),ct.clear(),z.clear(),G.clear();}function li(e,t){S.isRadioSet[t]=1,S.selectedButton[t]=0,g(e,t);}function ai(e,t){return S.isRadioSet[t]===1}function Mn(e){return S.selectedButton[e]}function si(e){let t=S.selectedButton[e];return t===0?null:z.get(t)??null}function ci(e,t){let n=G.get(e)??[];return n.push(t),G.set(e,n),()=>{let r=G.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function le(e){let t=G.get(e);if(t){let n=Mn(e),r=n!==0?z.get(n)??null:null;for(let o of t)o(r,n!==0?n:null);}}function ui(e){G.delete(e);}function fi(e,t,n){x.isRadioButton[t]=1,x.radioSetId[t]=n??0;let r=b$1(e,t,Fn);return x.machineId[t]=r,Rn(t,{}),g(e,t),r}function Y(e,t){return x.isRadioButton[t]===1}function pi(e,t){if(Y(e,t)&&k$1(e,t))return d(e,t)}function ut(e,t,n){return Y(e,t)?f$1(e,t,n):false}function ae(e,t,n){return Y(e,t)?i(e,t,n):false}function Dn(e,t){return ae(e,t,"selected")}function se(e,t){return ae(e,t,"disabled")}function di(e){return x.radioSetId[e]}function gi(e,t){x.radioSetId[e]=t;}function xi(e){return z.get(e)}function yi(e,t){z.set(e,t);}function ce(e,t){if(!Y(e,t)||se(e,t))return;let n=x.radioSetId[t];if(n!==0){let r=S.selectedButton[n];r!==0&&r!==t&&ut(e,r,"deselect"),S.selectedButton[n]=t;}ut(e,t,"select"),g(e,t),n!==0&&le(n);}function bi(e,t){if(!Y(e,t))return;ut(e,t,"deselect");let n=x.radioSetId[t];n!==0&&S.selectedButton[n]===t&&(S.selectedButton[n]=0,le(n)),g(e,t);}function hi(e,t){ut(e,t,"disable"),g(e,t);}function mi(e,t){ut(e,t,"enable"),g(e,t);}function Rn(e,t){let n=ct.get(e);ct.set(e,{selectedChar:t.selectedChar??n?.selectedChar??oe,unselectedChar:t.unselectedChar??n?.unselectedChar??ie});}function Pn(e){return ct.get(e)??{selectedChar:oe,unselectedChar:ie}}function Ei(e,t){let n=Pn(t);return Dn(e,t)?n.selectedChar:n.unselectedChar}function Si(e){ct.delete(e);}function Ci(e,t,n){return !Y(e,t)||se(e,t)?false:n==="space"||n==="return"||n==="enter"?(ce(e,t),true):false}function _n(e){let t=[];for(let n=0;n<x.isRadioButton.length;n++)x.isRadioButton[n]===1&&x.radioSetId[n]===e&&t.push(n);return t}function vi(e,t,n){let r=_n(t);for(let o of r)if(z.get(o)===n)return ce(e,o),true;return false}var fe="\u25BC",pe="\u25B2",de="\u25CF",ge=" ",yt=1e4,f={isSelect:new Uint8Array(yt),selectedIndex:new Int32Array(yt).fill(-1),highlightedIndex:new Int32Array(yt).fill(0),optionCount:new Uint32Array(yt)},T=new Map,ft=new Map,X=new Map,$=new Map,j=new Map,On={initial:"closed",states:{closed:{on:{open:"open",toggle:"open",disable:"disabled"}},open:{on:{close:"closed",select:"closed",toggle:"closed",disable:"disabled"}},disabled:{on:{enable:"closed"}}}};function Bi(e,t,n=[],r=-1){f.isSelect[t]=1,f.selectedIndex[t]=r,f.highlightedIndex[t]=r>=0?r:0,f.optionCount[t]=n.length,T.set(t,[...n]),b$1(e,t,On);}function xe(e,t){return f.isSelect[t]===1&&k$1(e,t)}function bt(e,t){return d(e,t)??"closed"}function ye(e,t,n){return bt(e,t)===n}function Un(e,t){return ye(e,t,"open")}function Ln(e,t){return ye(e,t,"disabled")}function ue(e,t){let n=t.get(e);if(n)for(let r of n)r();}function Vn(e,t,n){t!=="open"&&n==="open"?ue(e,$):t==="open"&&n!=="open"&&ue(e,j);}function q(e,t,n){if(!xe(e,t))return false;let r=bt(e,t),o=f$1(e,t,n);if(o){let i=bt(e,t);g(e,t),Vn(t,r,i);}return o}function Fi(e,t){return q(e,t,"open")}function Ti(e,t){return q(e,t,"close")}function Wi(e,t){return q(e,t,"toggle")}function Mi(e,t){return q(e,t,"disable")}function Di(e,t){return q(e,t,"enable")}function Ri(e){return T.get(e)??[]}function Pi(e,t,n){T.set(t,[...n]),f.optionCount[t]=n.length,(f.selectedIndex[t]??-1)>=n.length&&(f.selectedIndex[t]=n.length>0?0:-1),f.highlightedIndex[t]=0,g(e,t);}function _i(e){return f.optionCount[e]??0}function Hn(e,t){return T.get(e)?.[t]}function Oi(e){return f.selectedIndex[e]??-1}function be(e){let t=f.selectedIndex[e]??-1;if(!(t<0))return Hn(e,t)}function Ui(e){return be(e)?.value}function Li(e){return be(e)?.label}function he(e,t,n){let r=T.get(t);if(!r||n<0||n>=r.length||(f.selectedIndex[t]??-1)===n)return false;f.selectedIndex[t]=n,f.highlightedIndex[t]=n,g(e,t);let i=r[n],u=X.get(t);if(u&&i)for(let p of u)p(i.value,i.label,n);return q(e,t,"select"),true}function Vi(e,t,n){let r=T.get(t);if(!r)return false;let o=r.findIndex(i=>i.value===n);return o<0?false:he(e,t,o)}function Hi(e,t){f.selectedIndex[t]=-1,g(e,t);}function wn(e){return f.highlightedIndex[e]??0}function me(e,t,n){let r=f.optionCount[t]??0;if(r===0)return;let o=Math.max(0,Math.min(n,r-1));f.highlightedIndex[t]=o,g(e,t);}function wi(e,t,n=true){let r=f.optionCount[t]??0;if(r===0)return;let o=(f.highlightedIndex[t]??0)+1;o>=r&&(o=n?0:r-1),me(e,t,o);}function Ni(e,t,n=true){let r=f.optionCount[t]??0;if(r===0)return;let o=(f.highlightedIndex[t]??0)-1;o<0&&(o=n?r-1:0),me(e,t,o);}function Ki(e,t){let n=f.highlightedIndex[t]??0;return he(e,t,n)}function Gi(e,t){let n=ft.get(e);ft.set(e,{closedIndicator:t.closedIndicator??n?.closedIndicator??fe,openIndicator:t.openIndicator??n?.openIndicator??pe,selectedMark:t.selectedMark??n?.selectedMark??de,separator:t.separator??n?.separator??ge});}function Nn(e){return ft.get(e)??{closedIndicator:fe,openIndicator:pe,selectedMark:de,separator:ge}}function zi(e){ft.delete(e);}function Yi(e,t){let n=Nn(t);return bt(e,t)==="open"?n.openIndicator:n.closedIndicator}function Xi(e,t){let n=X.get(e)??[];return n.push(t),X.set(e,n),()=>{let r=X.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function $i(e,t){let n=$.get(e)??[];return n.push(t),$.set(e,n),()=>{let r=$.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function ji(e,t){let n=j.get(e)??[];return n.push(t),j.set(e,n),()=>{let r=j.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function qi(e){X.delete(e),$.delete(e),j.delete(e);}function Ji(e,t,n){if(!xe(e,t)||Ln(e,t))return null;let r=Un(e,t);switch(n){case "return":case "enter":case "space":return r?{type:"select",index:wn(t)}:{type:"open"};case "escape":return r?{type:"close"}:null;case "up":return r?{type:"highlightPrev"}:{type:"open"};case "down":return r?{type:"highlightNext"}:{type:"open"};case "home":return r?{type:"highlightFirst"}:null;case "end":return r?{type:"highlightLast"}:null;default:return null}}function Qi(){f.isSelect.fill(0),f.selectedIndex.fill(-1),f.highlightedIndex.fill(0),f.optionCount.fill(0),T.clear(),ft.clear(),X.clear(),$.clear(),j.clear();}var M={Horizontal:0,Vertical:1},Se="\u2500",Ce="\u2502",ve="\u25CF",ke="\u2501",Ie="\u2503",Ae=1717987071,Be=255,Fe=4294967295,Te=6750207,We=16711935,Me=255,W=1e4,l={isSlider:new Uint8Array(W),value:new Float32Array(W),min:new Float32Array(W),max:new Float32Array(W).fill(100),step:new Float32Array(W).fill(1),orientation:new Uint8Array(W),showValue:new Uint8Array(W)},pt=new Map,J=new Map,Q=new Map,Z=new Map,Gn={initial:"idle",states:{idle:{on:{focus:"focused",disable:"disabled"}},focused:{on:{blur:"idle",dragStart:"dragging",disable:"disabled"}},dragging:{on:{dragEnd:"focused",blur:"idle",disable:"disabled"}},disabled:{on:{enable:"idle"}}}};function ol(e,t,n=0,r=100,o=0,i=1){l.isSlider[t]=1,l.min[t]=n,l.max[t]=r,l.value[t]=Pt(o,n,r),l.step[t]=i,l.orientation[t]=M.Horizontal,l.showValue[t]=0,b$1(e,t,Gn);}function Pt(e,t,n){return Math.max(t,Math.min(n,e))}function De(e,t,n){return t<=0?e:n+Math.round((e-n)/t)*t}function Re(e,t){return l.isSlider[t]===1&&k$1(e,t)}function ht(e,t){return d(e,t)??"idle"}function Pe(e,t,n){return ht(e,t)===n}function il(e,t){let n=ht(e,t);return n==="focused"||n==="dragging"}function ll(e,t){return Pe(e,t,"dragging")}function zn(e,t){return Pe(e,t,"disabled")}function Ee(e,t){let n=t.get(e);if(n)for(let r of n)r();}function Yn(e,t,n){t!=="dragging"&&n==="dragging"?Ee(e,Q):t==="dragging"&&n!=="dragging"&&Ee(e,Z);}function tt(e,t,n){if(!Re(e,t))return false;let r=ht(e,t),o=f$1(e,t,n);if(o){let i=ht(e,t);g(e,t),Yn(t,r,i);}return o}function al(e,t){return tt(e,t,"focus")}function sl(e,t){return tt(e,t,"blur")}function cl(e,t){return tt(e,t,"dragStart")}function ul(e,t){return tt(e,t,"dragEnd")}function fl(e,t){return tt(e,t,"disable")}function pl(e,t){return tt(e,t,"enable")}function Xn(e){return l.value[e]??0}function D(e,t,n){let r=l.min[t]??0,o=l.max[t]??100,i=l.step[t]??1,u=Pt(De(n,i,r),r,o),p=l.value[t]??0;if(u!==p){l.value[t]=u,g(e,t);let h=J.get(t);if(h)for(let g of h)g(u);}}function dl(e){return l.min[e]??0}function gl(e){return l.max[e]??100}function xl(e){return l.step[e]??1}function yl(e,t,n,r){m.parse({min:n,max:r}),l.min[t]=n,l.max[t]=r;let o=l.value[t]??0,i=Pt(o,n,r);i!==o&&D(e,t,i),g(e,t);}function bl(e,t,n$1){n.parse(n$1),l.step[t]=n$1;let r=l.value[t]??0,o=l.min[t]??0,i=De(r,n$1,o);i!==r&&D(e,t,i),g(e,t);}function $n(e){let t=l.min[e]??0,n=l.max[e]??100,r=l.value[e]??0;return n===t?0:(r-t)/(n-t)}function hl(e,t,n){z$1.number().finite().parse(n);let r=l.min[t]??0,o=l.max[t]??100,i=Math.max(0,Math.min(1,n)),u=r+i*(o-r);D(e,t,u);}function ml(e,t,n=1){let r=l.step[t]??1,o=l.value[t]??0;D(e,t,o+r*n);}function El(e,t,n=1){let r=l.step[t]??1,o=l.value[t]??0;D(e,t,o-r*n);}function Sl(e,t){D(e,t,l.min[t]??0);}function Cl(e,t){D(e,t,l.max[t]??100);}function mt(e){return l.orientation[e]}function vl(e,t,n){l.orientation[t]=n,g(e,t);}function jn(e){return mt(e)===M.Horizontal}function kl(e){return mt(e)===M.Vertical}function qn(e){return l.showValue[e]===1}function Il(e,t,n){l.showValue[t]=n?1:0,g(e,t);}function Al(e,t){let n=pt.get(e),r=mt(e),o=r===M.Vertical?Ce:Se,i=r===M.Vertical?Ie:ke;pt.set(e,{trackChar:t.trackChar??n?.trackChar??o,thumbChar:t.thumbChar??n?.thumbChar??ve,fillChar:t.fillChar??n?.fillChar??i,trackFg:t.trackFg??n?.trackFg??Ae,trackBg:t.trackBg??n?.trackBg??Be,thumbFg:t.thumbFg??n?.thumbFg??Fe,thumbBg:t.thumbBg??n?.thumbBg??Te,fillFg:t.fillFg??n?.fillFg??We,fillBg:t.fillBg??n?.fillBg??Me});}function Jn(e){let t=mt(e),n=t===M.Vertical?Ce:Se,r=t===M.Vertical?Ie:ke;return pt.get(e)??{trackChar:n,thumbChar:ve,fillChar:r,trackFg:Ae,trackBg:Be,thumbFg:Fe,thumbBg:Te,fillFg:We,fillBg:Me}}function Bl(e){pt.delete(e);}function Fl(e,t){let n=J.get(e)??[];return n.push(t),J.set(e,n),()=>{let r=J.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function Tl(e,t){let n=Q.get(e)??[];return n.push(t),Q.set(e,n),()=>{let r=Q.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function Wl(e,t){let n=Z.get(e)??[];return n.push(t),Z.set(e,n),()=>{let r=Z.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function Ml(e){J.delete(e),Q.delete(e),Z.delete(e);}function Dl(e,t,n){if(!Re(e,t)||zn(e,t))return null;let r=jn(t);switch(n){case "right":return r?{type:"increment",multiplier:1}:null;case "left":return r?{type:"decrement",multiplier:1}:null;case "up":return r?null:{type:"increment",multiplier:1};case "down":return r?null:{type:"decrement",multiplier:1};case "pageup":return {type:"increment",multiplier:10};case "pagedown":return {type:"decrement",multiplier:10};case "home":return {type:"toMin"};case "end":return {type:"toMax"};default:return null}}function Rl(e,t){if(t<=0)return "";let n=$n(e),r=Jn(e),o=qn(e),i="",u=t;o&&(i=` ${Xn(e)}`,u=Math.max(1,t-i.length));let p=Math.round(n*(u-1)),h="";for(let g=0;g<u;g++)g===p?h+=r.thumbChar:g<p?h+=r.fillChar:h+=r.trackChar;return h+i}function Pl(){l.isSlider.fill(0),l.value.fill(0),l.min.fill(0),l.max.fill(100),l.step.fill(1),l.orientation.fill(0),l.showValue.fill(0),pt.clear(),J.clear(),Q.clear(),Z.clear();}export{Bt as $,So as $a,Fn as $b,_i as $c,dl as $d,ot as A,en as Aa,Ro as Ab,Rn as Ac,ve as Ad,kt as B,Xr as Ba,Po as Bb,Pn as Bc,ke as Bd,Gt as C,nn as Ca,_o as Cb,Ei as Cc,Ie as Cd,yr as D,$r as Da,Oo as Db,Si as Dc,Ae as Dd,br as E,jr as Ea,Uo as Eb,Ci as Ec,Be as Ed,Ne as F,rn as Fa,Lo as Fb,_n as Fc,Fe as Fd,Ke as G,on as Ga,ne as Gb,vi as Gc,Te as Gd,Ge as H,qr as Ha,Vo as Hb,fe as Hc,We as Hd,hr as I,Jr as Ia,Ho as Ib,pe as Ic,Me as Id,mr as J,Qr as Ja,st as Jb,de as Jc,l as Jd,zt as K,A as Ka,wo as Kb,ge as Kc,Gn as Kd,Er as L,ln as La,No as Lb,f as Lc,ol as Ld,Sr as M,an as Ma,Ko as Mb,On as Mc,Re as Md,Cr as N,Zr as Na,Go as Nb,Bi as Nc,ht as Nd,vr as O,to as Oa,zo as Ob,xe as Oc,Pe as Od,Ye as P,eo as Pa,In as Pb,bt as Pc,il as Pd,kr as Q,no as Qa,Rt as Qb,ye as Qc,ll as Qd,Ir as R,ro as Ra,Yo as Rb,Un as Rc,zn as Rd,Xe as S,oo as Sa,Xo as Sb,Ln as Sc,tt as Sd,_ as T,io as Ta,$o as Tb,q as Tc,al as Td,je as U,lo as Ua,jo as Ub,Fi as Uc,sl as Ud,c as V,ao as Va,qo as Vb,Ti as Vc,cl as Vd,It as W,so as Wa,Jo as Wb,Wi as Wc,ul as Wd,At as X,co as Xa,Qo as Xb,Mi as Xc,fl as Xd,Tr as Y,uo as Ya,Zo as Yb,Di as Yc,pl as Yd,Wr as Z,B as Za,ti as Zb,Ri as Zc,Xn as Zd,b as _,Eo as _a,ei as _b,Pi as _c,D as _d,_e as a,k as aa,jt as ab,x as ac,Hn as ad,gl as ae,et as b,Ft as ba,xn as bb,S as bc,Oi as bd,xl as be,tr as c,Mr as ca,yn as cb,oe as cc,be as cd,yl as ce,er as d,Dr as da,bn as db,ie as dc,Ui as dd,bl as de,I as e,Rr as ea,Co as eb,ii as ec,Li as ed,$n as ee,gt as f,Pr as fa,qt as fb,li as fc,he as fd,hl as fe,Ht as g,Je as ga,vo as gb,ai as gc,Vi as gd,ml as ge,xt as h,_r as ha,Jt as hb,Mn as hc,Hi as hd,El as he,nr as i,Or as ia,hn as ib,si as ic,wn as id,Sl as ie,rr as j,Ur as ja,mn as jb,ci as jc,me as jd,Cl as je,or as k,Lr as ka,ko as kb,ui as kc,wi as kd,mt as ke,ir as l,Vr as la,En as lb,fi as lc,Ni as ld,vl as le,lr as m,Hr as ma,Io as mb,Y as mc,Ki as md,jn as me,ar as n,wr as na,Ao as nb,pi as nc,Gi as nd,kl as ne,sr as o,Tt as oa,Bo as ob,ut as oc,Nn as od,qn as oe,Le as p,Qe as pa,Sn as pb,ae as pc,zi as pd,Il as pe,cr as q,Nr as qa,Cn as qb,Dn as qc,Yi as qd,Al as qe,ur as r,Yt as ra,Fo as rb,se as rc,Xi as rd,Jn as re,Ve as s,Kr as sa,To as sb,di as sc,$i as sd,Bl as se,nt as t,Gr as ta,Wo as tb,gi as tc,ji as td,Fl as te,Nt as u,zr as ua,lt as ub,xi as uc,qi as ud,Tl as ue,Kt as v,Ze as va,s as vb,yi as vc,Ji as vd,Wl as ve,gr as w,tn as wa,Qt as wb,ce as wc,Qi as wd,Ml as we,xr as x,Mt as xa,Zt as xb,bi as xc,M as xd,Dl as xe,C as y,Yr as ya,te as yb,hi as yc,Se as yd,Rl as ye,vt as z,Dt as za,ee as zb,mi as zc,Ce as zd,Pl as ze};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {g as g$1,f,j as j$1}from'./chunk-Z4EZERNE.js';import {n,i as i$1,h}from'./chunk-PXXGH3BV.js';n();var g=1e4,e={left:new Uint8Array(g),top:new Uint8Array(g),right:new Uint8Array(g),bottom:new Uint8Array(g)};function S(r){e.left[r]=0,e.top[r]=0,e.right[r]=0,e.bottom[r]=0;}function w(r,t){i$1(r,t,e)||(h(r,t,e),S(t));}function U(r,t,n){return g$1.parse(n),w(r,t),n.left!==void 0&&(e.left[t]=n.left),n.top!==void 0&&(e.top[t]=n.top),n.right!==void 0&&(e.right[t]=n.right),n.bottom!==void 0&&(e.bottom[t]=n.bottom),t}function k(r,t,n){return f.parse(n),w(r,t),e.left[t]=n,e.top[t]=n,e.right[t]=n,e.bottom[t]=n,t}function C(r,t,n,o){return f.parse(n),f.parse(o),w(r,t),e.left[t]=n,e.right[t]=n,e.top[t]=o,e.bottom[t]=o,t}function F(r,t){if(i$1(r,t,e))return {left:e.left[t],top:e.top[t],right:e.right[t],bottom:e.bottom[t]}}function D(r,t){return i$1(r,t,e)}function B(r,t){return i$1(r,t,e)?e.left[t]+e.right[t]:0}function L(r,t){return i$1(r,t,e)?e.top[t]+e.bottom[t]:0}function I(r,t){return i$1(r,t,e)?e.left[t]>0||e.top[t]>0||e.right[t]>0||e.bottom[t]>0:false}n();var u=1e4,Y=(o=>(o[o.Hidden=0]="Hidden",o[o.Visible=1]="Visible",o[o.Auto=2]="Auto",o))(Y||{}),l={scrollX:new Float32Array(u),scrollY:new Float32Array(u),scrollWidth:new Float32Array(u),scrollHeight:new Float32Array(u),viewportWidth:new Float32Array(u),viewportHeight:new Float32Array(u),scrollbarVisible:new Uint8Array(u),trackVisible:new Uint8Array(u),alwaysScroll:new Uint8Array(u),clampEnabled:new Uint8Array(u)};function X(r){l.scrollX[r]=0,l.scrollY[r]=0,l.scrollWidth[r]=0,l.scrollHeight[r]=0,l.viewportWidth[r]=0,l.viewportHeight[r]=0,l.scrollbarVisible[r]=2,l.trackVisible[r]=1,l.alwaysScroll[r]=0,l.clampEnabled[r]=1;}function i(r,t){i$1(r,t,l)||(h(r,t,l),X(t));}function m(r){if(!(l.clampEnabled[r]===1))return;let n=l.viewportWidth[r],o=l.viewportHeight[r],c=l.scrollWidth[r],s=l.scrollHeight[r];if(n>0){let b=Math.max(0,c-n);l.scrollX[r]=Math.max(0,Math.min(b,l.scrollX[r]));}else l.scrollX[r]=Math.max(0,l.scrollX[r]);if(o>0){let b=Math.max(0,s-o);l.scrollY[r]=Math.max(0,Math.min(b,l.scrollY[r]));}else l.scrollY[r]=Math.max(0,l.scrollY[r]);}function A(r,t){t.scrollWidth!==void 0&&(l.scrollWidth[r]=t.scrollWidth),t.scrollHeight!==void 0&&(l.scrollHeight[r]=t.scrollHeight),t.viewportWidth!==void 0&&(l.viewportWidth[r]=t.viewportWidth),t.viewportHeight!==void 0&&(l.viewportHeight[r]=t.viewportHeight),t.scrollbarVisible!==void 0&&(l.scrollbarVisible[r]=t.scrollbarVisible);}function P(r,t){t.trackVisible!==void 0&&(l.trackVisible[r]=t.trackVisible?1:0),t.alwaysScroll!==void 0&&(l.alwaysScroll[r]=t.alwaysScroll?1:0),t.clampEnabled!==void 0&&(l.clampEnabled[r]=t.clampEnabled?1:0);}function V(r,t){A(r,t),P(r,t),t.scrollX!==void 0&&(l.scrollX[r]=t.scrollX),t.scrollY!==void 0&&(l.scrollY[r]=t.scrollY),m(r);}function j(r,t,n){return j$1.parse(n),i(r,t),V(t,n),t}function M(r,t,n,o){return i(r,t),l.scrollX[t]=n,l.scrollY[t]=o,m(t),t}function q(r,t){return i$1(r,t,l)?{x:l.scrollX[t],y:l.scrollY[t]}:{x:0,y:0}}function z(r,t,n,o){return i(r,t),l.scrollX[t]=l.scrollX[t]+n,l.scrollY[t]=l.scrollY[t]+o,m(t),t}function G(r,t,n,o){return M(r,t,n,o)}function J(r,t){if(!i$1(r,t,l))return {x:0,y:0};let n=l.scrollX[t],o=l.scrollY[t],c=l.scrollWidth[t],s=l.scrollHeight[t],b=l.viewportWidth[t],W=l.viewportHeight[t],h=c-b,p=s-W,E=h>0?n/h*100:0,x=p>0?o/p*100:0;return {x:Math.min(100,Math.max(0,E)),y:Math.min(100,Math.max(0,x))}}function K(r,t,n,o){i(r,t);let c=l.scrollWidth[t],s=l.scrollHeight[t],b=l.viewportWidth[t],W=l.viewportHeight[t],h=Math.min(100,Math.max(0,n)),p=Math.min(100,Math.max(0,o)),E=Math.max(0,c-b),x=Math.max(0,s-W);return l.scrollX[t]=h/100*E,l.scrollY[t]=p/100*x,t}function Q(r,t){if(i$1(r,t,l))return {scrollX:l.scrollX[t],scrollY:l.scrollY[t],scrollWidth:l.scrollWidth[t],scrollHeight:l.scrollHeight[t],viewportWidth:l.viewportWidth[t],viewportHeight:l.viewportHeight[t],scrollbarVisible:l.scrollbarVisible[t],trackVisible:l.trackVisible[t]===1,alwaysScroll:l.alwaysScroll[t]===1,clampEnabled:l.clampEnabled[t]===1}}function Z(r,t){return i$1(r,t,l)}function $(r,t,n,o){return i(r,t),l.scrollWidth[t]=n,l.scrollHeight[t]=o,m(t),t}function tt(r,t,n,o){return i(r,t),l.viewportWidth[t]=n,l.viewportHeight[t]=o,m(t),t}function rt(r,t,n){return i(r,t),l.scrollbarVisible[t]=n,t}function lt(r,t){return i(r,t),l.scrollY[t]=0,t}function nt(r,t){i(r,t);let n=l.scrollHeight[t],o=l.viewportHeight[t];return l.scrollY[t]=Math.max(0,n-o),t}function ot(r,t){return i(r,t),l.scrollX[t]=0,t}function et(r,t){i(r,t);let n=l.scrollWidth[t],o=l.viewportWidth[t];return l.scrollX[t]=Math.max(0,n-o),t}function at(r,t){if(!i$1(r,t,l))return false;let n=l.scrollWidth[t],o=l.scrollHeight[t],c=l.viewportWidth[t],s=l.viewportHeight[t];return c>0||s>0?n>c||o>s:n>0||o>0}function ct(r,t){if(!i$1(r,t,l))return false;let n=l.scrollWidth[t],o=l.viewportWidth[t];return n>o}function st(r,t){if(!i$1(r,t,l))return false;let n=l.scrollHeight[t],o=l.viewportHeight[t];return n>o}function it(r,t){return i$1(r,t,l)?l.scrollY[t]<=0:true}function ut(r,t){if(!i$1(r,t,l))return true;let n=l.scrollY[t],o=l.scrollHeight[t],c=l.viewportHeight[t],s=Math.max(0,o-c);return n>=s}function bt(r,t){return i$1(r,t,l)?l.scrollX[t]<=0:true}function mt(r,t){if(!i$1(r,t,l))return true;let n=l.scrollX[t],o=l.scrollWidth[t],c=l.viewportWidth[t],s=Math.max(0,o-c);return n>=s}export{et as A,at as B,ct as C,st as D,it as E,ut as F,bt as G,mt as H,e as a,U as b,k as c,C as d,F as e,D as f,B as g,L as h,I as i,Y as j,l as k,j as l,M as m,q as n,z as o,G as p,J as q,K as r,Q as s,Z as t,$ as u,tt as v,rt as w,lt as x,nt as y,ot as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b}from'./chunk-5PELJRUQ.js';import {createWorld,resetWorld,addEntity,removeEntity,entityExists,getAllEntities,addComponent,hasComponent,removeComponent,query,registerComponent,withStore}from'bitecs';function p(){return createWorld()}function d(t){resetWorld(t);}var n=b(()=>{});function Q(t){return addEntity(t)}function g(t,e){removeEntity(t,e);}function h(t,e){return entityExists(t,e)}function A(t){return getAllEntities(t)}function S(t,e,o){addComponent(t,e,o);}function T(t,e,o){return hasComponent(t,e,o)}function q(t,e,o){removeComponent(t,e,o);}function w(t,e){return query(t,e)}var G,H,C=b(()=>{n();G=registerComponent,H=withStore;});export{p as a,d as b,n as c,Q as d,g as e,h as f,A as g,S as h,T as i,q as j,w as k,G as l,H as m,C as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b,d as d$2}from'./chunk-4LWWONFK.js';import {c as c$1,a as a$1}from'./chunk-XZA63ZPO.js';import {d as d$1,A,i,B as B$1}from'./chunk-TWSWTBYL.js';import {a,e as e$1,r as r$1,o,t}from'./chunk-C5PCEQ6G.js';import {k as k$1}from'./chunk-VOCM5T2G.js';import {s,n as n$1,i as i$1}from'./chunk-LCN2ZITE.js';import {r,c,p as p$1,h,e}from'./chunk-W5OU7Z6J.js';import {n,k,i as i$2}from'./chunk-PXXGH3BV.js';import {z}from'zod';s();n();var d=z.number().int().min(0).max(4294967295),J=z.number().int().min(0).max(65535),ne=z.object({fg:d.optional(),bg:d.optional(),selectedFg:d.optional(),selectedBg:d.optional(),cursorFg:d.optional(),cursorBg:d.optional(),showLineNumbers:z.boolean().optional(),lineNumberWidth:z.number().int().nonnegative().max(20).optional(),attrs:J.optional()}),Re=z.object({fg:d.default(4294967295),bg:d.default(255),selectedFg:d.default(255),selectedBg:d.default(4294967295),cursorFg:d.default(255),cursorBg:d.default(16711935),showLineNumbers:z.boolean().default(false),lineNumberWidth:z.number().int().nonnegative().max(20).default(0),attrs:J.default(a.NONE)}),Q={fg:4294967295,bg:255,selectedFg:255,selectedBg:4294967295,cursorFg:255,cursorBg:16711935,showLineNumbers:false,lineNumberWidth:0,attrs:a.NONE},p=null,L=new Map,B=new Map;function Ne(t){p=t;}function Se(){return p}function Ve(){p=null;}function ve(t,e){L.set(t,e);}function we(t){return L.get(t)}function De(t){L.delete(t);}function ze(t,e){L.set(t,e);}function We(t,e){let r=ne.parse(e),f={};for(let[n,o]of Object.entries(r))o!==void 0&&(f[n]=o);let i=B.get(t)??Q;B.set(t,{...i,...f});}function re(t){return B.get(t)??Q}function Fe(t){B.delete(t);}function ie(t,e){if(!i$2(t,e,c))return a.NONE;let r=a.NONE;return c.bold[e]===1&&(r|=a.BOLD),c.underline[e]===1&&(r|=a.UNDERLINE),c.blink[e]===1&&(r|=a.BLINK),c.inverse[e]===1&&(r|=a.INVERSE),r}function oe(t,e){if(c$1(t,e))return {x:a$1.x[e],y:a$1.y[e],width:a$1.width[e],height:a$1.height[e]}}function fe(t,e){return n$1(t,e)?{top:i$1.top[e]===1?1:0,right:i$1.right[e]===1?1:0,bottom:i$1.bottom[e]===1?1:0,left:i$1.left[e]===1?1:0}:{top:0,right:0,bottom:0,left:0}}function ue(t,e){return {x:t.x+e.left,y:t.y+e.top,width:Math.max(0,t.width-e.left-e.right),height:Math.max(0,t.height-e.top-e.bottom)}}function M(t$1,e,r,f,i,n,o$1,u){let m=e$1(" ",n,o$1,u);for(let l=0;l<f;l++)o(t$1,e+l,r,m);let a=i.length>f?i.slice(0,f):i;a.length>0&&t(t$1,e,r,a,n,o$1,u);}function le(t$1,e,r,f,i,n,o){let u=`${String(i+1).padStart(f-1," ")} `;t(t$1,e,r,u.slice(0,f),n,o,a.DIM);}function ae(t,e,r,f,i,n){let{buffer:o}=t,{x:u,y:m,width:a$1,height:l}=r,x=k$1(i,f.start,f.end),S=n.showLineNumbers?u+n.lineNumberWidth:u,V=n.showLineNumbers?Math.max(0,a$1-n.lineNumberWidth):a$1,b=d$1.selectedLine[e],v=d$1.cursorLine[e];for(let c=0;c<x.lines.length;c++){let E=m+c;if(c>=l)break;let D=x.startLine+c,Z=x.lines[c]??"",z=n.fg,W=n.bg;D===v?(z=n.cursorFg,W=n.cursorBg):D===b&&(z=n.selectedFg,W=n.selectedBg),n.showLineNumbers&&le(o,u,E,n.lineNumberWidth,D,n.fg,n.bg),M(o,S,E,V,Z,z,W,n.attrs);}let T=Math.min(x.lines.length,l);for(let c=T;c<l;c++){let E=m+c;n.showLineNumbers&&M(o,u,E,n.lineNumberWidth,"",n.fg,n.bg,a.NONE),M(o,S,E,V,"",n.fg,n.bg,a.NONE);}}function se(t,e,r,f,i){if(r<=i)return;let{buffer:n}=t,o$1=e.height,u=e.x+e.width-1,m=e.y,a=i/r,l=Math.max(1,Math.floor(o$1*a)),x=Math.floor(f/r*o$1),S=e$1("\u2502",1717987071,255);for(let b=0;b<o$1;b++)o(n,u,m+b,S);let V=e$1("\u2588",2863311615,255);for(let b=0;b<l;b++){let v=m+x+b;v<m+o$1&&o(n,u,v,V);}}function de(t,e$2,r){let{world:f,buffer:i}=t,n=e(f,e$2);if(!n||n.transparent)return;let o=ie(f,e$2),u=e$1(" ",n.fg,n.bg,o);r$1(i,r.x,r.y,r.width,r.height,u);}function me(t,e){let{world:r,doubleBuffer:f}=t,i$1=oe(r,e);if(!i$1||i$1.width<=0||i$1.height<=0)return;let n=L.get(e);if(!n)return;let o=i(r,e);if(!o)return;let u=re(e);de(t,e,i$1);let m=fe(r,e),a=ue(i$1,m);a.width>0&&a.height>0&&ae(t,e,a,o,n,u);let l={firstVisibleLine:d$1.firstVisibleLine[e],visibleLineCount:d$1.visibleLineCount[e],totalLineCount:d$1.totalLineCount[e]};l.totalLineCount>l.visibleLineCount&&se(t,a,l.totalLineCount,l.firstVisibleLine,l.visibleLineCount),d$2(f,i$1.x,i$1.y,i$1.width,i$1.height),B$1(r,e),h(r,e);}var ce=t=>{if(!p)return t;let e=b(p),r$1={world:t,buffer:e,doubleBuffer:p},f=k(t,[d$1,r,c]);for(let i of f)p$1(t,i)&&(!A(t,i)&&c.dirty[i]!==1||me(r$1,i));return t};function Me(){return ce}function Oe(){p=null,L.clear(),B.clear();}function ke(t){L.delete(t),B.delete(t);}export{Re as a,Ne as b,Se as c,Ve as d,ve as e,we as f,De as g,ze as h,We as i,re as j,Fe as k,ce as l,Me as m,Oe as n,ke as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b}from'./chunk-5PELJRUQ.js';function m(e,r,t,n=255){return ((n&255)<<24|(e&255)<<16|(r&255)<<8|t&255)>>>0}function i(e){return {r:e>>16&255,g:e>>8&255,b:e&255,a:e>>24&255}}function p(e){let r=e.replace("#",""),t,n,u,a=255;if(r.length===3||r.length===4){let s=r.charAt(0),b=r.charAt(1),f=r.charAt(2);if(t=Number.parseInt(s+s,16),n=Number.parseInt(b+b,16),u=Number.parseInt(f+f,16),r.length===4){let c=r.charAt(3);a=Number.parseInt(c+c,16);}}else if(r.length===6||r.length===8)t=Number.parseInt(r.slice(0,2),16),n=Number.parseInt(r.slice(2,4),16),u=Number.parseInt(r.slice(4,6),16),r.length===8&&(a=Number.parseInt(r.slice(6,8),16));else return 0;return m(t,n,u,a)}function l(e,r=false){let{r:t,g:n,b:u,a}=i(e),s=t.toString(16).padStart(2,"0"),b=n.toString(16).padStart(2,"0"),f=u.toString(16).padStart(2,"0");if(r){let c=a.toString(16).padStart(2,"0");return `#${s}${b}${f}${c}`}return `#${s}${b}${f}`}function x(e){return typeof e=="string"?p(e):e}var g=b(()=>{});export{m as a,i as b,p as c,l as d,x as e,g as f};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {c as c$2,a as a$1,b as b$2}from'./chunk-OMMJ7B5P.js';import {i as i$1}from'./chunk-CIK4AMUA.js';import {ha,A,Q,I}from'./chunk-JKVHO4LH.js';import {c as c$1,i as i$4,j}from'./chunk-KD55INV7.js';import {a,k}from'./chunk-PSXXMBVJ.js';import {s,i,m as m$1}from'./chunk-LCN2ZITE.js';import {d,e}from'./chunk-FYEBZAWN.js';import {r,K,c,V,s as s$1,L as L$1,d as d$2,m,n as n$1,Y}from'./chunk-W5OU7Z6J.js';import {b as b$1}from'./chunk-SHUC6JWA.js';import {b,i as i$3,f}from'./chunk-G7GIWWLE.js';import {n,i as i$2,g,d as d$1,e as e$1}from'./chunk-PXXGH3BV.js';s();n();n();var Se={snapshotInterval:5e3,maxSnapshots:100,entityLeakThreshold:10,heapLeakThreshold:1024*1024,trackedComponents:[]};function xe(t){let e={...Se,...t},n=[],o=null;function r(s){let a=g(s),u={};for(let{component:C,name:R}of e.trackedComponents){let $=0;for(let M of a)i$2(s,M,C)&&$++;u[R]=$;}let l=process.memoryUsage(),f={timestamp:Date.now(),entityCount:a.length,componentCounts:u,heapUsed:l.heapUsed,heapTotal:l.heapTotal,rss:l.rss,external:l.external};for(n.push(f);n.length>e.maxSnapshots;)n.shift();return f}function m(s,a){let u={},l=new Set([...Object.keys(s.componentCounts),...Object.keys(a.componentCounts)]);for(let f of l)u[f]=(a.componentCounts[f]??0)-(s.componentCounts[f]??0);return u}function c(s,a,u,l){let f=s/a;return f<=e.entityLeakThreshold?null:{type:"entity",message:`Entity count growing at ${f.toFixed(1)}/sec (${u.entityCount} -> ${l.entityCount})`,growthRate:f}}function g$1(s,a){let u=s/a;return u<=e.heapLeakThreshold?null:{type:"heap",message:`Heap growing at ${(u/1024).toFixed(1)}KB/sec`,growthRate:u}}function b(s,a){let u=[];for(let[l,f]of Object.entries(s)){let C=f/a;C>e.entityLeakThreshold&&u.push({type:"component",message:`${l} component growing at ${C.toFixed(1)}/sec`,growthRate:C});}return u}function d(s,a){let u=a.timestamp-s.timestamp,l=u/1e3,f=a.entityCount-s.entityCount,C=a.heapUsed-s.heapUsed,R=a.rss-s.rss,$=m(s,a),M=[];if(l>0){let N=c(f,l,s,a);N&&M.push(N);let K=g$1(C,l);K&&M.push(K);let he=b($,l);M.push(...he);}return {elapsed:u,entityCountDelta:f,componentDeltas:$,heapUsedDelta:C,rssDelta:R,possibleLeaks:M}}function i(s){return Math.abs(s)<1024?`${s}B`:Math.abs(s)<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}function p(s,a){s.push("Memory Profile Report"),s.push("\u2550".repeat(40)),s.push(`Entities: ${a.entityCount}`),s.push(`Heap Used: ${i(a.heapUsed)}`),s.push(`Heap Total: ${i(a.heapTotal)}`),s.push(`RSS: ${i(a.rss)}`),s.push(`External: ${i(a.external)}`);}function S(s,a){if(Object.keys(a.componentCounts).length!==0){s.push(""),s.push("Component Counts:");for(let[u,l]of Object.entries(a.componentCounts))s.push(` ${u}: ${l}`);}}function x(s,a){if(n.length<2)return;let u=n[0];if(!u)return;let l=d(u,a);if(s.push(""),s.push(`Trends (over ${(l.elapsed/1e3).toFixed(0)}s):`),s.push(` Entity delta: ${l.entityCountDelta>0?"+":""}${l.entityCountDelta}`),s.push(` Heap delta: ${l.heapUsedDelta>0?"+":""}${i(l.heapUsedDelta)}`),l.possibleLeaks.length>0){s.push(""),s.push("WARNINGS:");for(let f of l.possibleLeaks)s.push(` [${f.type}] ${f.message}`);}}return {snapshot(s){return r(s)},diff(s,a){return d(s,a)},getSnapshots(){return n},getLatestSnapshot(){return n.length>0?n[n.length-1]??null:null},getReport(s){let a=r(s),u=[];return p(u,a),S(u,a),x(u,a),u.join(`
|
|
2
|
+
`)},startAutoSnapshot(s){o===null&&(e.snapshotInterval<=0||(r(s),o=setInterval(()=>{r(s);},e.snapshotInterval)));},stopAutoSnapshot(){o!==null&&(clearInterval(o),o=null);},reset(){n.length=0,o!==null&&(clearInterval(o),o=null);}}}n();var Ce={x:0,y:0,width:35,toggleKey:"F12",showFPS:true,showEntityCount:true,showMemory:true,showSystemTimings:true,maxSystemsShown:5,bgColor:33023,fgColor:4294967295,visibleOnStart:false};function Me(t,e$2={}){let n={...Ce,...e$2},o=n.visibleOnStart,r=null;n.showSystemTimings&&!ye()&&ge(true);function m$1(){let i=d$1(t);return s$1(t,i,n.x,n.y,9999),L$1(t,i,n.width,10),d$2(t,i,{fg:n.fgColor,bg:n.bgColor}),m(t,i),e(t,i,"Loading..."),b$2(i,"name","__debug_overlay__"),i}function c(i,p){return `\u2502 FPS: \x1B[${i>=55?"32":i>=30?"33":"31"}m${i.toString().padStart(3)}\x1B[0m (${p.toFixed(1)}ms)`}function g(i){let p=H(),S=Object.entries(p).filter(([,s])=>s>0).sort(([,s],[,a])=>a-s).slice(0,i);if(S.length===0)return [];let x=["\u251C\u2500 Systems \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"];for(let[s,a]of S){let u=a.toFixed(2).padStart(6),l=s.length>20?`${s.slice(0,17)}...`:s;x.push(`\u2502 ${l.padEnd(20)} ${u}ms`);}return x}function b(i){let p=["\u250C\u2500 Debug \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"];return n.showFPS&&p.push(c(i.fps,i.frameTime)),n.showEntityCount&&p.push(`\u2502 Entities: ${i.entityCount}`),n.showMemory&&i.memoryUsageMB!==null&&p.push(`\u2502 Memory: ${i.memoryUsageMB.toFixed(1)}MB`),n.showSystemTimings&&p.push(...g(n.maxSystemsShown)),p.push(`\u2502 Frame: ${i.frameCount}`),p.push(`\u2502 Time: ${i.runningTime.toFixed(1)}s`),p.push("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),p.join(`
|
|
3
|
+
`)}let d={get visible(){return o},get entity(){return r},get config(){return n},show(){o=true,r||(r=m$1()),m(t,r);},hide(){o=false,r&&n$1(t,r);},toggle(){o?d.hide():d.show();},update(i,p){if(!o||!r)return;let S=de(i,p),x=b(S);e(i,r,x);let s=x.split(`
|
|
4
|
+
`).length;L$1(i,r,n.width,s);},destroy(){r&&(e$1(t,r),r=null),o=false;}};return o&&(r=m$1()),d}function Ee(t=20){let e=[];return {get entries(){return e},get maxEntries(){return t},log(n,o){for(e.push({type:n,detail:o,timestamp:Date.now()});e.length>t;)e.shift();},clear(){e.length=0;},getRecentEntries(n=5){return e.slice(-n)}}}function ve(){let t=new Map,e=new Map;return {start(n){t.set(n,performance.now());},end(n){let o=t.get(n);if(o===void 0)return 0;let r=performance.now()-o;t.delete(n);let m=e.get(n);return m?(m.total+=r,m.min=Math.min(m.min,r),m.max=Math.max(m.max,r),m.count++):e.set(n,{total:r,min:r,max:r,count:1}),r},getAverage(n){let o=e.get(n);return !o||o.count===0?0:o.total/o.count},getAll(){let n={};for(let[o,r]of e)n[o]={avg:r.count>0?r.total/r.count:0,min:r.min,max:r.max,count:r.count};return n},reset(){t.clear(),e.clear();}}}function Te(t=60){let e=[],n=0;return {addSample(o){for(e.push(o),n+=o;e.length>t;){let r=e.shift();r!==void 0&&(n-=r);}},getSamples(){return e},getCurrentFPS(){if(e.length===0)return 0;let o=e[e.length-1]??0;return o>0?1e3/o:0},getAverageFPS(){if(e.length===0)return 0;let o=n/e.length;return o>0?1e3/o:0},getMinMaxFPS(){if(e.length===0)return {min:0,max:0};let o=Number.MAX_VALUE,r=0;for(let m of e)o=Math.min(o,m),r=Math.max(r,m);return {min:r>0?1e3/r:0,max:o>0?1e3/o:0}},reset(){e.length=0,n=0;}}}var L=false,P=new Map,w=null,G=0,$e=100,_=[{component:r,name:"Position"},{component:K,name:"Dimensions"},{component:c,name:"Renderable"},{component:d,name:"Content"},{component:i,name:"Border"},{component:a,name:"Padding"},{component:b,name:"Hierarchy"},{component:c$1,name:"Interactive"},{component:V,name:"Focusable"},{component:k,name:"Scrollable"},{component:ha,name:"Velocity"},{component:A,name:"Animation"},{component:Q,name:"Collider"},{component:i$1,name:"Shadow"}];function De(t,e,n,o){if(!i$2(t,e,n))return null;let r={},m=n;for(let[c,g]of Object.entries(m))if(ArrayBuffer.isView(g)||Array.isArray(g)){let b=g;r[c]=b[e];}return {name:o,data:r}}function we(t,e){let n=[];for(let{component:c,name:g}of _){let b=De(t,e,c,g);b&&n.push(b);}let o=i$2(t,e,b)?i$3(t,e):null,r=i$2(t,e,b)?f(t,e):[],m=c$2(e,"name")?a$1(e,"name")??null:null;return {entity:e,name:m,components:n,parent:o===0?null:o,children:r}}function Pe(t){let e=[],n=t.name?` (${t.name})`:"";e.push(`Entity ${t.entity}${n}`),t.parent!==null&&e.push(`\u251C\u2500 Parent: ${t.parent}`),t.children.length>0&&e.push(`\u251C\u2500 Children: [${t.children.join(", ")}]`);let o=t.components.length;return t.components.forEach((r,m)=>{let g=m===o-1?"\u2514\u2500":"\u251C\u2500",b=Object.entries(r.data).map(([d,i])=>{if(typeof i=="number"){if(d==="fg"||d==="bg"){let{r:p,g:S,b:x,a:s}=b$1(i>>>0),a=u=>u.toString(16).padStart(2,"0");return `${d}=#${a(p)}${a(S)}${a(x)}${a(Math.round(s*255))}`}if(!Number.isInteger(i))return `${d}=${i.toFixed(2)}`}return `${d}=${i}`}).join(", ");e.push(`${g} ${r.name}: ${b}`);}),e.join(`
|
|
5
|
+
`)}function Le(t){let e=g(t),n={},o=[];for(let{name:r}of _)n[r]=0;for(let r of e){for(let{component:m,name:c}of _)if(i$2(t,r,m)){let g=n[c]??0;n[c]=g+1;}i$2(t,r,b)&&i$3(t,r)===0&&o.push(r);}return {entityCount:e.length,componentCounts:n,hierarchyRoots:o}}function Re(t){let e=[];e.push("World Statistics"),e.push("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),e.push(`Entities: ${t.entityCount}`),e.push(""),e.push("Components:");let n=Object.entries(t.componentCounts).filter(([,o])=>o>0).sort(([,o],[,r])=>r-o);for(let[o,r]of n){let m=(r/t.entityCount*100).toFixed(0);e.push(` ${o}: ${r} (${m}%)`);}return t.hierarchyRoots.length>0&&(e.push(""),e.push(`Hierarchy Roots: [${t.hierarchyRoots.join(", ")}]`)),e.join(`
|
|
6
|
+
`)}function ge(t){L=t,t||P.clear();}function ye(){return L}function ke(t,e){if(!L)return;let n=P.get(t);n?(n.totalTime+=e,n.callCount++):P.set(t,{name:t,totalTime:e,callCount:1});}function an(t,e){return(o=>{if(!L)return e(o);let r=performance.now(),m=e(o),c=performance.now()-r;return ke(t,c),m})}function H(){let t={};for(let[e,n]of P)t[e]=n.callCount>0?n.totalTime/n.callCount:0;return t}function mn(){P.clear();}function un(){w=null,G=0;}function de(t,e){let n=performance.now();if(w&&n-G<$e)return w;let o=e?.getStats()??{fps:0,frameTime:0,frameCount:0,runningTime:0},m=g(t).length,c=null;typeof process<"u"&&process.memoryUsage&&(c=process.memoryUsage().heapUsed/(1024*1024));let g$1=H();return w={fps:o.fps,frameTime:o.frameTime,frameCount:o.frameCount,runningTime:o.runningTime,entityCount:m,memoryUsageMB:c,systemTimings:g$1},G=n,w}var h={enabled:false,showHitboxes:true,showPadding:false,showMargins:false,color:4278255360};function ln(t,e){h.enabled=t,e&&(h.showHitboxes=e.showHitboxes??h.showHitboxes,h.showPadding=e.showPadding??h.showPadding,h.showMargins=e.showMargins??h.showMargins,h.color=e.color??h.color);}function cn(){return h.enabled}function pn(){return {...h}}function fn(t){return h.enabled?g(t).filter(n=>i$2(t,n,r)&&i$2(t,n,K)):[]}function We(t,e){let n=[];return i$2(t,e,V)&&Y(t,e)&&n.push("focused"),i$2(t,e,c$1)&&(i$4(t,e)&&n.push("hovered"),j(t,e)&&n.push("pressed")),I(t,e)&&n.push("animated"),m$1(t,e)&&n.push("bordered"),n}function gn(t,e){let n=[],o=c$2(e,"name")?a$1(e,"name"):null;if(n.push(`Entity ${e}${o?` (${o})`:""}`),i$2(t,e,r)){let m=Math.round(r.x[e]??0),c=Math.round(r.y[e]??0);n.push(`@ ${m},${c}`);}i$2(t,e,K)&&n.push(`[${K.width[e]}x${K.height[e]}]`);let r$1=We(t,e);return r$1.length>0&&n.push(r$1.join(" ")),n.join(" ")}function yn(t,e){let n=we(t,e),o=Pe(n);console.log(`[DEBUG] ${o}`);}function dn(t){let e=Le(t),n=Re(e);console.log(`[DEBUG] ${n}`);}export{xe as a,Me as b,Ee as c,ve as d,Te as e,_ as f,we as g,Pe as h,Le as i,Re as j,ge as k,ye as l,ke as m,an as n,H as o,mn as p,un as q,de as r,ln as s,cn as t,pn as u,fn as v,gn as w,yn as x,dn as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {n,i,h as h$1}from'./chunk-PXXGH3BV.js';import {z as z$1}from'zod';n();var c=1e4,E=5,C=5,x=1,g=z$1.object({firstVisibleLine:z$1.number().int().nonnegative().optional(),visibleLineCount:z$1.number().int().nonnegative().optional(),totalLineCount:z$1.number().int().nonnegative().optional(),overscanBefore:z$1.number().int().min(0).max(255).optional(),overscanAfter:z$1.number().int().min(0).max(255).optional(),estimatedLineHeight:z$1.number().int().min(1).max(255).optional(),isVariableHeight:z$1.boolean().optional(),selectedLine:z$1.number().int().min(-1).optional(),cursorLine:z$1.number().int().min(-1).optional()}),D=z$1.object({start:z$1.number().int().nonnegative(),end:z$1.number().int().nonnegative(),visibleStart:z$1.number().int().nonnegative(),visibleEnd:z$1.number().int().nonnegative(),count:z$1.number().int().nonnegative()}),M=z$1.object({currentLine:z$1.number().int().nonnegative(),totalLines:z$1.number().int().nonnegative(),viewportSize:z$1.number().int().nonnegative(),maxScrollLine:z$1.number().int().nonnegative(),scrollPercent:z$1.number().min(0).max(100),atTop:z$1.boolean(),atBottom:z$1.boolean()}),t={firstVisibleLine:new Uint32Array(c),visibleLineCount:new Uint32Array(c),totalLineCount:new Uint32Array(c),overscanBefore:new Uint8Array(c),overscanAfter:new Uint8Array(c),estimatedLineHeight:new Uint8Array(c),isVariableHeight:new Uint8Array(c),isDirty:new Uint8Array(c),selectedLine:new Int32Array(c),cursorLine:new Int32Array(c)};function h(e){t.firstVisibleLine[e]=0,t.visibleLineCount[e]=0,t.totalLineCount[e]=0,t.overscanBefore[e]=E,t.overscanAfter[e]=C,t.estimatedLineHeight[e]=x,t.isVariableHeight[e]=0,t.isDirty[e]=1,t.selectedLine[e]=-1,t.cursorLine[e]=-1;}function b(e,n){i(e,n,t)||(h$1(e,n,t),h(n));}function f(e){let n=t.totalLineCount[e],i=t.visibleLineCount[e],r=t.firstVisibleLine[e],s=Math.max(0,n-i);t.firstVisibleLine[e]=Math.max(0,Math.min(s,r));}function u(e){t.isDirty[e]=1;}function T(e,n,i){let r=g.parse(i);return b(e,n),r.totalLineCount!==void 0&&(t.totalLineCount[n]=r.totalLineCount),r.visibleLineCount!==void 0&&(t.visibleLineCount[n]=r.visibleLineCount),r.firstVisibleLine!==void 0&&(t.firstVisibleLine[n]=r.firstVisibleLine),r.overscanBefore!==void 0&&(t.overscanBefore[n]=r.overscanBefore),r.overscanAfter!==void 0&&(t.overscanAfter[n]=r.overscanAfter),r.estimatedLineHeight!==void 0&&(t.estimatedLineHeight[n]=r.estimatedLineHeight),r.isVariableHeight!==void 0&&(t.isVariableHeight[n]=r.isVariableHeight?1:0),r.selectedLine!==void 0&&(t.selectedLine[n]=r.selectedLine),r.cursorLine!==void 0&&(t.cursorLine[n]=r.cursorLine),f(n),u(n),n}function U(e,n){if(i(e,n,t))return {firstVisibleLine:t.firstVisibleLine[n],visibleLineCount:t.visibleLineCount[n],totalLineCount:t.totalLineCount[n],overscanBefore:t.overscanBefore[n],overscanAfter:t.overscanAfter[n],estimatedLineHeight:t.estimatedLineHeight[n],isVariableHeight:t.isVariableHeight[n]===1,isDirty:t.isDirty[n]===1,selectedLine:t.selectedLine[n],cursorLine:t.cursorLine[n]}}function F(e,n){return i(e,n,t)}function A(e,n,i){return b(e,n),t.firstVisibleLine[n]=i,f(n),u(n),n}function w(e,n){if(!i(e,n,t))return;let i$1=t.firstVisibleLine[n],r=t.visibleLineCount[n],s=t.totalLineCount[n],l=t.overscanBefore[n],m=t.overscanAfter[n],L=Math.min(s,i$1+r),y=Math.max(0,i$1-l),v=Math.min(s,L+m);return {start:y,end:v,visibleStart:i$1,visibleEnd:L,count:v-y}}function R(e,n,i$1){if(!i(e,n,t))return false;let r=t.firstVisibleLine[n],s=t.visibleLineCount[n];return i$1>=r&&i$1<r+s}function I(e,n,i){let r=w(e,n);return r?i>=r.start&&i<r.end:false}function O(e,n,i){b(e,n);let r=t.visibleLineCount[n],s=Math.max(0,i-Math.floor(r/2));return t.firstVisibleLine[n]=s,f(n),u(n),n}function W(e,n,i){b(e,n);let r=t.firstVisibleLine[n],s=t.totalLineCount[n],l=t.visibleLineCount[n],m=r+i,L=Math.max(0,s-l);return t.firstVisibleLine[n]=Math.max(0,Math.min(L,m)),u(n),n}function _(e,n,i){b(e,n);let r=t.visibleLineCount[n],s=i*Math.max(1,r-1);return W(e,n,s)}function d(e,n){return A(e,n,0)}function P(e,n){b(e,n);let i=t.totalLineCount[n],r=t.visibleLineCount[n];return t.firstVisibleLine[n]=Math.max(0,i-r),u(n),n}function z(e,n){if(!i(e,n,t))return;let i$1=t.firstVisibleLine[n],r=t.totalLineCount[n],s=t.visibleLineCount[n],l=Math.max(0,r-s),m=l>0?i$1/l*100:0;return {currentLine:i$1,totalLines:r,viewportSize:s,maxScrollLine:l,scrollPercent:Math.min(100,Math.max(0,m)),atTop:i$1<=0,atBottom:i$1>=l}}function j(e,n,i){return b(e,n),t.totalLineCount[n]=i,f(n),u(n),n}function N(e,n,i){return b(e,n),t.visibleLineCount[n]=i,f(n),u(n),n}function k(e,n,i,r){return b(e,n),t.overscanBefore[n]=i,t.overscanAfter[n]=r,u(n),n}function G(e,n,i){return b(e,n),t.selectedLine[n]=i,u(n),n}function Y(e,n){return i(e,n,t)?t.selectedLine[n]:-1}function q(e,n,i){return b(e,n),t.cursorLine[n]=i,u(n),n}function J(e,n){return i(e,n,t)?t.cursorLine[n]:-1}function K(e,n,i){b(e,n);let r=t.totalLineCount[n],s=t.cursorLine[n],l=s<0?0:s,m=Math.max(0,Math.min(r-1,l+i));return t.cursorLine[n]=m,H(e,n),u(n),n}function H(e,n){if(!i(e,n,t))return n;let i$1=t.cursorLine[n];if(i$1<0)return n;let r=t.firstVisibleLine[n],s=t.visibleLineCount[n];i$1<r&&(t.firstVisibleLine[n]=i$1,u(n));let l=r+s-1;return i$1>l&&(t.firstVisibleLine[n]=i$1-s+1,f(n),u(n)),n}function Q(e,n){return i(e,n,t)?t.isDirty[n]===1:false}function X(e,n){return i(e,n,t)&&(t.isDirty[n]=0),n}function Z(e,n){return i(e,n,t)&&(t.isDirty[n]=1),n}export{Q as A,X as B,Z as C,g as a,D as b,M as c,t as d,T as e,U as f,F as g,A as h,w as i,R as j,I as k,O as l,W as m,_ as n,d as o,P as p,z as q,j as r,N as s,k as t,G as u,Y as v,q as w,J as x,K as y,H as z};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var R=1e3,T=100,E=209715200;var _=.5;function O(e={}){return {config:{chunkSize:e.chunkSize??1e3,maxCachedChunks:e.maxCachedChunks??100,enableCompression:e.enableCompression??true,maxLines:e.maxLines??0,maxMemory:e.maxMemory??209715200},chunks:new Map,lruOrder:[],totalLines:0,memoryBytes:0,nextChunkId:0}}function z(e){e.chunks.clear(),e.lruOrder.length=0,e.totalLines=0,e.memoryBytes=0,e.nextChunkId=0;}function S(e){let n=e.text.length*2;return e.ansi&&(n+=e.ansi.length*2),e.meta&&(n+=JSON.stringify(e.meta).length*2),n+50}function L(e){if(e.compressed&&e.compressedData)return e.compressedData.length*2+100;let n=0;for(let o of e.lines)n+=S(o);return n+100}function x(e){return JSON.stringify(e.lines).replace(/(.)\1{3,}/g,(o,r)=>`${r}\0${o.length}\0`)}function g(e){let n=e.replace(/(.)\x00(\d+)\x00/g,(o,r,t)=>r.repeat(parseInt(t,10)));return JSON.parse(n)}function k(e,n){let o=e.lruOrder.indexOf(n);o!==-1&&e.lruOrder.splice(o,1),e.lruOrder.push(n);let r=e.chunks.get(n);r&&(r.lastAccess=Date.now());}function p(e){let{maxCachedChunks:n,maxMemory:o,enableCompression:r}=e.config;if(r){let t=e.lruOrder.slice(0,-n);for(let s of t){let c=e.chunks.get(s);c&&!c.compressed&&y(e,c);}}for(;e.memoryBytes>o&&e.lruOrder.length>1;){let t=e.lruOrder[0];if(t===void 0)break;let s=e.chunks.get(t);s&&(e.memoryBytes-=s.memorySize,e.chunks.delete(t),e.lruOrder.shift());}}function y(e,n){if(n.compressed)return;let o=n.memorySize;n.compressedData=x(n),n.compressed=true,n.lines.length=0,n.memorySize=n.compressedData.length*2+100,e.memoryBytes+=n.memorySize-o;}function m(e,n){if(!n.compressed||!n.compressedData)return;let o=n.memorySize,r=g(n.compressedData);n.lines.push(...r),n.compressed=false,n.compressedData=void 0,n.memorySize=L(n),e.memoryBytes+=n.memorySize-o;}function B(e){let n,o=-1;for(let t of e.chunks.values())t.startLine>o&&(o=t.startLine,n=t);if(n&&n.lineCount<e.config.chunkSize)return n.compressed&&m(e,n),n;let r={id:e.nextChunkId++,lines:[],startLine:e.totalLines,lineCount:0,compressed:false,memorySize:100,lastAccess:Date.now()};return e.chunks.set(r.id,r),e.lruOrder.push(r.id),e.memoryBytes+=r.memorySize,r}function f(e,n){for(let o of e.chunks.values())if(n>=o.startLine&&n<o.startLine+o.lineCount)return o}function b(e,n,o,r){let t={text:n,ansi:o,timestamp:Date.now(),meta:r},s=B(e);s.lines.push(t),s.lineCount++;let c=S(t);s.memorySize+=c,e.memoryBytes+=c,e.totalLines++,k(e,s.id),p(e);}function M(e,n){for(let o of n)b(e,o);}function A(e,n){if(n<0||n>=e.totalLines)return;let o=f(e,n);if(!o)return;o.compressed&&m(e,o),k(e,o.id),p(e);let r=n-o.startLine;return o.lines[r]}function i(e,n,o){let r=performance.now(),t=Math.max(0,n),s=Math.min(e.totalLines,o);if(t>=s)return {lines:[],startLine:t,endLine:t,complete:true,loadTimeMs:performance.now()-r};let c=[],u=[];for(let a of e.chunks.values()){let l=a.startLine+a.lineCount;a.startLine>=s||l<=t||u.push(a);}u.sort((a,l)=>a.startLine-l.startLine);for(let a of u){a.compressed&&m(e,a),k(e,a.id);let l=Math.max(0,t-a.startLine),C=Math.min(a.lineCount,s-a.startLine);for(let d=l;d<C;d++){let h=a.lines[d];h&&c.push(h);}}return p(e),{lines:c,startLine:t,endLine:s,complete:c.length===s-t,loadTimeMs:performance.now()-r}}function v(e,n,o){return i(e,n,n+o)}function D(e,n,o=100){let r=Math.max(0,n-o),t=Math.min(e.totalLines,n+o);return i(e,r,t)}function w(e,n,o,r){let t=Math.max(0,Math.min(e.totalLines-r,n+o));return i(e,t,t+r)}function H(e,n){return i(e,0,n)}function P(e,n){let o=Math.max(0,e.totalLines-n);return i(e,o,e.totalLines)}function I(e){let n=0,o=0;for(let r of e.chunks.values())r.compressed?n++:o++;return {totalLines:e.totalLines,totalChunks:e.chunks.size,cachedChunks:o,compressedChunks:n,memoryBytes:e.memoryBytes,memoryMB:Math.round(e.memoryBytes/(1024*1024)*100)/100}}function U(e){return e.memoryBytes}function F(e,n){let o=n.split(`
|
|
2
|
+
`);M(e,o);}function Y(e,n=0,o){let r=o??e.totalLines;return i(e,n,r).lines.map(s=>s.text).join(`
|
|
3
|
+
`)}function N(e,n){if(e.totalLines<=n)return;let o=e.totalLines-n,r=0,t=[];for(let[s,c]of e.chunks){if(r>=o)break;t.push(s),r+=c.lineCount,e.memoryBytes-=c.memorySize;}for(let s of t){e.chunks.delete(s);let c=e.lruOrder.indexOf(s);c!==-1&&e.lruOrder.splice(c,1);}e.totalLines-=r;for(let s of e.chunks.values())s.startLine-=r;}function X(e,n=10){if(!e.config.enableCompression)return;let o=e.lruOrder.slice(0,-n);for(let r of o){let t=e.chunks.get(r);t&&!t.compressed&&y(e,t);}}function J(e){for(let n of e.chunks.values())n.compressed&&m(e,n);}export{R as a,T as b,E as c,_ as d,O as e,z as f,b as g,M as h,A as i,i as j,v as k,D as l,w as m,H as n,P as o,I as p,U as q,F as r,Y as s,N as t,X as u,J as v};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {Oa,va,ka,la,qa,sa,ra,oa,pa,ia,ua,ma,ta,na,ja,ha,K,Qa,jb,ib,db,Z,S,Q,U,T,bb,ab,L as L$1,E,z,H as H$1,sb,pb,nb,Pa,La,Ma,Da,ya,Ga,Ha,Ca,Ba,Aa,za,xa,Ja,Fa,wa,Ia,Ka,Ea,W,Na,_a,X,V,_,C,R as R$1,B as B$1,$a,J,N,M as M$1,F as F$1,cb,A,qb,lb,kb,eb,gb,hb,fb,r,p,o,Ya,I as I$1,n,m,l,q,ob,O,rb,Za,Ra,fa,mb,v,Y,$,aa,Va,s,P,i,h,Ua,Sa,da,ea,x,G as G$1,u,D as D$1,ba,Ta,j,g,ca,d,c as c$1,Wa,ga,t,y as y$1,f,a,e,k as k$1,b as b$1,w,Xa}from'./chunk-LYSK5S63.js';import {b as b$2}from'./chunk-H2YAOJDW.js';import {b as b$3,a as a$1,f as f$1}from'./chunk-G7GIWWLE.js';import {n as n$1,i as i$1,h as h$1,j as j$1,k as k$2}from'./chunk-PXXGH3BV.js';import {c}from'./chunk-5PELJRUQ.js';import {z as z$1}from'zod';var fn={};c(fn,{AmbientLightSchema:()=>Xa,Animation3D:()=>y,Animation3DConfigSchema:()=>w,BackendCapabilitiesSchema:()=>b$1,BackendPreferenceSchema:()=>k$1,BackendSelectionSchema:()=>e,BackendTypeSchema:()=>a,BrailleConfigSchema:()=>f,Camera3D:()=>y$1,Camera3DConfigSchema:()=>t,ClipRectSchema:()=>ga,CubeMeshOptionsSchema:()=>ue,CylinderMeshOptionsSchema:()=>fe,DirectionalLightSchema:()=>Wa,EncodedCellSchema:()=>c$1,EncodedOutputSchema:()=>d,EulerAnglesSchema:()=>ca,HalfBlockConfigSchema:()=>g,KittyConfigSchema:()=>j,LineEndpointSchema:()=>Ta,Mat4Schema:()=>ba,Material3D:()=>D$1,Material3DConfigSchema:()=>u,Mesh:()=>G$1,MouseInteraction3D:()=>b,MouseInteraction3DConfigSchema:()=>x,ObjLoadOptionsSchema:()=>ce,OrthographicConfigSchema:()=>ea,PerspectiveConfigSchema:()=>da,PixelBufferConfigSchema:()=>Sa,PlaneMeshOptionsSchema:()=>le,RGBAColorSchema:()=>Ua,SextantConfigSchema:()=>h,SixelConfigSchema:()=>i,SphereMeshOptionsSchema:()=>pe,Transform3D:()=>P,Transform3DConfigSchema:()=>s,TriangleVertexSchema:()=>Va,Vec3InputSchema:()=>aa,Vec3Schema:()=>$,Viewport3D:()=>Y,Viewport3DConfigSchema:()=>v,Viewport3DWidgetConfigSchema:()=>mb,ViewportConfigSchema:()=>fa,animation3DSystem:()=>Hr,backendStore:()=>G,blendPixel:()=>M,buildMVP:()=>Ra,clearBackendStore:()=>Jr,clearFramebuffer:()=>Za,clearFramebufferStore:()=>rb,clearMeshStore:()=>O,clearMouseInputStore:()=>me,clearOutputStore:()=>Qr,clearProjectionStore:()=>ob,clipLine:()=>Tr,computeBoundingBox:()=>ye,computeFaceNormal:()=>de,computeFlatShading:()=>he,computeOutcode:()=>L,createBackendByType:()=>q,createBrailleBackend:()=>l,createCubeMesh:()=>Nr,createCylinderMesh:()=>Gr,createHalfBlockBackend:()=>m,createKittyBackend:()=>n,createMeshFromArrays:()=>I$1,createPixelFramebuffer:()=>Ya,createPlaneMesh:()=>Xr,createSextantBackend:()=>o,createSixelBackend:()=>p,createSphereMesh:()=>Zr,detectBestBackend:()=>r,disableMouseInteraction:()=>Fr,drawLine:()=>fb,drawLineAA:()=>Yr,drawLineColor:()=>hb,drawLineDepth:()=>gb,enableMouseInteraction:()=>Ir,extractFrustumPlanes:()=>kr,feedMouseDrag:()=>Ar,feedMouseScroll:()=>zr,fillRect:()=>eb,fillTriangle:()=>kb,fillTriangleFlat:()=>lb,framebufferStore:()=>qb,getAnimation3D:()=>Or,getCamera3D:()=>A,getDepth:()=>cb,getMaterial3D:()=>F$1,getMesh:()=>M$1,getMeshCount:()=>N,getMeshData:()=>J,getMouseInteraction3D:()=>Pr,getPixel:()=>$a,getProjMatrix:()=>B$1,getTransform3D:()=>R$1,getViewMatrix:()=>C,getViewport3D:()=>_,getWorldMatrix:()=>V,isDirty:()=>X,isInBounds:()=>_a,isPointInFrustum:()=>Lr,isSphereInFrustum:()=>Rr,loadObjAsMesh:()=>Br,lookAt:()=>Na,markDirty:()=>W,mat4Determinant:()=>Ea,mat4Equals:()=>Ka,mat4FromTRS:()=>Ia,mat4Identity:()=>wa,mat4Invert:()=>Fa,mat4IsIdentity:()=>Ja,mat4Multiply:()=>xa,mat4RotateX:()=>za,mat4RotateY:()=>Aa,mat4RotateZ:()=>Ba,mat4Scale:()=>Ca,mat4TransformDirection:()=>Ha,mat4TransformVec3:()=>Ga,mat4Translate:()=>ya,mat4Transpose:()=>Da,mouseInputStore:()=>I,mouseInteraction3DSystem:()=>Ur,orthographicMatrix:()=>Ma,outputStore:()=>H,parseObj:()=>be,perspectiveMatrix:()=>La,projectVertex:()=>Pa,projectionStore:()=>nb,projectionSystem:()=>pb,rasterSystem:()=>sb,registerMesh:()=>H$1,sceneGraphSystem:()=>Kr,setAnimation3D:()=>vr,setCamera3D:()=>z,setMaterial3D:()=>E,setMesh:()=>L$1,setPixel:()=>ab,setPixelUnsafe:()=>bb,setRotation:()=>T,setScale:()=>U,setTransform3D:()=>Q,setTranslation:()=>S,setViewport3D:()=>Z,shadeFace:()=>Wr,testAndSetDepth:()=>db,triangleArea2:()=>ib,triangleBoundingBox:()=>jb,unprojectVertex:()=>Qa,unregisterMesh:()=>K,vec3:()=>ha,vec3Add:()=>ja,vec3Cross:()=>na,vec3Distance:()=>ta,vec3Dot:()=>ma,vec3Equals:()=>ua,vec3FromArray:()=>ia,vec3Length:()=>pa,vec3LengthSq:()=>oa,vec3Lerp:()=>ra,vec3Negate:()=>sa,vec3Normalize:()=>qa,vec3Scale:()=>la,vec3Sub:()=>ka,vec3Zero:()=>va,viewportOutputSystem:()=>$r,viewportTransform:()=>Oa});n$1();var D=1e4,y={rotateSpeedX:new Float32Array(D),rotateSpeedY:new Float32Array(D),rotateSpeedZ:new Float32Array(D),orbitCenterX:new Float32Array(D),orbitCenterY:new Float32Array(D),orbitCenterZ:new Float32Array(D),orbitSpeed:new Float32Array(D),orbitRadius:new Float32Array(D),orbitAngle:new Float32Array(D),orbitEnabled:new Uint8Array(D)};function vr(t,e,n){let r=w.parse(n);return i$1(t,e,y)||h$1(t,e,y),y.rotateSpeedX[e]=r.rotateSpeed.x,y.rotateSpeedY[e]=r.rotateSpeed.y,y.rotateSpeedZ[e]=r.rotateSpeed.z,r.orbitCenter&&(y.orbitCenterX[e]=r.orbitCenter[0],y.orbitCenterY[e]=r.orbitCenter[1],y.orbitCenterZ[e]=r.orbitCenter[2],y.orbitEnabled[e]=1),y.orbitSpeed[e]=r.orbitSpeed,r.orbitRadius!==void 0&&(y.orbitRadius[e]=r.orbitRadius),e}function Or(t,e){if(i$1(t,e,y))return {rotateSpeedX:y.rotateSpeedX[e],rotateSpeedY:y.rotateSpeedY[e],rotateSpeedZ:y.rotateSpeedZ[e],orbitCenterX:y.orbitCenterX[e],orbitCenterY:y.orbitCenterY[e],orbitCenterZ:y.orbitCenterZ[e],orbitSpeed:y.orbitSpeed[e],orbitRadius:y.orbitRadius[e],orbitAngle:y.orbitAngle[e],orbitEnabled:y.orbitEnabled[e]===1}}n$1();var B=1e4,b={rotationSensitivity:new Float32Array(B),zoomSensitivity:new Float32Array(B),zoomMin:new Float32Array(B),zoomMax:new Float32Array(B),invertY:new Uint8Array(B),distance:new Float32Array(B),yaw:new Float32Array(B),pitch:new Float32Array(B)},I=new Map;function me(){I.clear();}function Ar(t,e,n){let r=I.get(t);r?(r.dragDx+=e,r.dragDy+=n):I.set(t,{dragDx:e,dragDy:n,scrollDelta:0});}function zr(t,e){let n=I.get(t);n?n.scrollDelta+=e:I.set(t,{dragDx:0,dragDy:0,scrollDelta:e});}function Ir(t,e,n={},r=5){let o=x.parse(n);i$1(t,e,b)||h$1(t,e,b),b.rotationSensitivity[e]=o.rotationSensitivity,b.zoomSensitivity[e]=o.zoomSensitivity,b.zoomMin[e]=o.zoomMin,b.zoomMax[e]=o.zoomMax,b.invertY[e]=o.invertY?1:0;let a=Math.max(o.zoomMin,Math.min(o.zoomMax,r));return b.distance[e]=a,b.yaw[e]=0,b.pitch[e]=0,e}function Fr(t,e){i$1(t,e,b)&&j$1(t,e,b);}function Pr(t,e){if(i$1(t,e,b))return {rotationSensitivity:b.rotationSensitivity[e],zoomSensitivity:b.zoomSensitivity[e],zoomMin:b.zoomMin[e],zoomMax:b.zoomMax[e],invertY:b.invertY[e]===1,distance:b.distance[e],yaw:b.yaw[e],pitch:b.pitch[e]}}var ce=z$1.object({name:z$1.string().min(1).describe("Name for the mesh in meshStore"),flipYZ:z$1.boolean().default(false).describe("Swap Y and Z axes (some models use Z-up)"),scale:z$1.number().positive().default(1).describe("Uniform scale factor"),centerOrigin:z$1.boolean().default(true).describe("Center model at origin")}),ue=z$1.object({size:z$1.number().positive().default(1).describe("Half-extent of cube"),name:z$1.string().default("cube")}),pe=z$1.object({radius:z$1.number().positive().default(1),widthSegments:z$1.number().int().min(3).max(128).default(16),heightSegments:z$1.number().int().min(2).max(64).default(12),name:z$1.string().default("sphere")}),le=z$1.object({width:z$1.number().positive().default(2),height:z$1.number().positive().default(2),widthSegments:z$1.number().int().min(1).max(128).default(1),heightSegments:z$1.number().int().min(1).max(128).default(1),name:z$1.string().default("plane")}),fe=z$1.object({radiusTop:z$1.number().nonnegative().default(1),radiusBottom:z$1.number().nonnegative().default(1),height:z$1.number().positive().default(2),segments:z$1.number().int().min(3).max(128).default(16),name:z$1.string().default("cylinder")}).refine(t=>t.radiusTop>0||t.radiusBottom>0,{message:"At least one radius must be positive"});function wr(t){return t.length<4?null:{x:Number.parseFloat(t[1]),y:Number.parseFloat(t[2]),z:Number.parseFloat(t[3])}}function tn(t){return t.length<3?null:{u:Number.parseFloat(t[1]),v:Number.parseFloat(t[2])}}function rn(t,e,n,r){let o=t.split("/"),a=Number.parseInt(o[0],10);a=a<0?e+a:a-1;let s={vi:a};if(o.length>=2&&o[1]!==""){let i=Number.parseInt(o[1],10);i=i<0?n+i:i-1,s.ti=i;}if(o.length>=3&&o[2]!==""){let i=Number.parseInt(o[2],10);i=i<0?r+i:i-1,s.ni=i;}return s}function nn(t,e,n,r){if(t.length<4)return null;let o=[],a=[],s=[],i=false,c=false;for(let p=1;p<t.length;p++){let m=rn(t[p],e,n,r);o.push(m.vi),m.ti!==void 0&&(s.push(m.ti),c=true),m.ni!==void 0&&(a.push(m.ni),i=true);}return {vertexIndices:o,...i?{normalIndices:a}:{},...c?{texCoordIndices:s}:{}}}function on(t,e){let n=t[0];if(n==="v"){let r=wr(t);r&&e.vertices.push(r);return}if(n==="vn"){let r=wr(t);r&&e.normals.push(r);return}if(n==="vt"){let r=tn(t);r&&e.texCoords.push(r);return}if(n==="f"){let r=nn(t,e.vertices.length,e.texCoords.length,e.normals.length);r&&e.faces.push(r);return}(n==="g"||n==="o")&&t.length>=2&&e.groups.push({name:t.slice(1).join(" "),startFace:e.faces.length});}function be(t){let e={vertices:[],normals:[],texCoords:[],faces:[],groups:[]},n=t.split(`
|
|
2
|
+
`);for(let r of n){let o=r.trim();if(o.length===0||o.startsWith("#"))continue;let a=o.split(/\s+/);on(a,e);}return e}function ye(t){if(t.length===0)return {min:{x:0,y:0,z:0},max:{x:0,y:0,z:0},center:{x:0,y:0,z:0}};let e=1/0,n=1/0,r=1/0,o=-1/0,a=-1/0,s=-1/0;for(let i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.z<r&&(r=i.z),i.x>o&&(o=i.x),i.y>a&&(a=i.y),i.z>s&&(s=i.z);return {min:{x:e,y:n,z:r},max:{x:o,y:a,z:s},center:{x:(e+o)/2,y:(n+a)/2,z:(r+s)/2}}}function Br(t,e){let n=ce.parse(e),r=be(t),o=[...r.vertices];if(n.flipYZ&&(o=o.map(s=>({x:s.x,y:s.z,z:s.y}))),n.scale!==1){let s=n.scale;o=o.map(i=>({x:i.x*s,y:i.y*s,z:i.z*s}));}if(n.centerOrigin&&o.length>0){let s=ye(o),i=s.center.x,c=s.center.y,p=s.center.z;o=o.map(m=>({x:m.x-i,y:m.y-c,z:m.z-p}));}let a=r.faces.map(s=>[...s.vertexIndices]);return I$1(n.name,o,a)}var an=0,sn=1,Er=2,Vr=4,jr=8;function L(t,e,n){let r=an;return t<n.xMin?r|=sn:t>n.xMax&&(r|=Er),e<n.yMin?r|=Vr:e>n.yMax&&(r|=jr),r}function mn(t,e,n,r,o,a){return t&jr?{x:e+r*(a.yMax-n)/o,y:a.yMax}:t&Vr?{x:e+r*(a.yMin-n)/o,y:a.yMin}:t&Er?{x:a.xMax,y:n+o*(a.xMax-e)/r}:{x:a.xMin,y:n+o*(a.xMin-e)/r}}function Tr(t,e,n,r,o){let a=t,s=e,i=n,c=r,p=L(a,s,o),m=L(i,c,o);for(;;){if((p|m)===0)return {x0:a,y0:s,x1:i,y1:c};if((p&m)!==0)return null;let u=p!==0?p:m,f=i-a,h=c-s,d=mn(u,a,s,f,h,o);u===p?(a=d.x,s=d.y,p=L(a,s,o)):(i=d.x,c=d.y,m=L(i,c,o));}}function kr(t){let e=t,n=[];return n.push(k(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12])),n.push(k(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12])),n.push(k(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13])),n.push(k(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13])),n.push(k(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14])),n.push(k(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])),n}function k(t,e,n,r){let o=Math.sqrt(t*t+e*e+n*n);if(o===0)return {normal:ha(0,0,0),distance:0};let a=1/o;return {normal:ha(t*a,e*a,n*a),distance:r*a}}function Lr(t,e){for(let n of e)if(ma(n.normal,t)+n.distance<0)return false;return true}function Rr(t,e,n){for(let r of n)if(ma(r.normal,t)+r.distance<-e)return false;return true}function M(t,e,n,r,o,a,s,i){if(!_a(t,e,n)||i<=0)return;if(i>=1){bb(t,e,n,r,o,a,s);return}let c=$a(t,e,n),p=1-i,m=Math.round(c.r*p+r*i),u=Math.round(c.g*p+o*i),f=Math.round(c.b*p+a*i),h=Math.round(c.a*p+s*i);bb(t,e,n,m,u,f,h);}function Yr(t,e,n,r,o,a,s,i,c=255){let p=Math.abs(o-n)>Math.abs(r-e),m=e,u=n,f=r,h=o;p&&([m,u]=[u,m],[f,h]=[h,f]),m>f&&([m,f]=[f,m],[u,h]=[h,u]);let d=f-m,v=h-u,P=d===0?1:v/d,E=Math.round(m),S=u+P*(E-m),O=1-F(m+.5),Y=E,q=Math.floor(S);p?(M(t,q,Y,a,s,i,c,R(S)*O),M(t,q+1,Y,a,s,i,c,F(S)*O)):(M(t,Y,q,a,s,i,c,R(S)*O),M(t,Y,q+1,a,s,i,c,F(S)*O));let V=S+P;E=Math.round(f),S=h+P*(E-f),O=F(f+.5);let W=E,U=Math.floor(S);p?(M(t,U,W,a,s,i,c,R(S)*O),M(t,U+1,W,a,s,i,c,F(S)*O)):(M(t,W,U,a,s,i,c,R(S)*O),M(t,W,U+1,a,s,i,c,F(S)*O));for(let j=Y+1;j<W;j++){let _=Math.floor(V);p?(M(t,_,j,a,s,i,c,R(V)),M(t,_+1,j,a,s,i,c,F(V))):(M(t,j,_,a,s,i,c,R(V)),M(t,j,_+1,a,s,i,c,F(V))),V+=P;}}function F(t){return t-Math.floor(t)}function R(t){return 1-F(t)}function de(t,e,n){let r=ka(e,t),o=ka(n,t);return qa(na(r,o))}function he(t,e,n,r){let o=e.direction,a=e.intensity??1,s=n.intensity??.1,i=-(t[0]*o[0]+t[1]*o[1]+t[2]*o[2]),c=Math.max(0,i)*a,p=Math.min(1,s+c),m=e.color??{r:255,g:255,b:255},u=n.color??{r:255,g:255,b:255},f=(u.r*s+m.r*c)/Math.max(.001,p),h=(u.g*s+m.g*c)/Math.max(.001,p),d=(u.b*s+m.b*c)/Math.max(.001,p);return {r:Math.round(Math.min(255,r.r*p*f/255)),g:Math.round(Math.min(255,r.g*p*h/255)),b:Math.round(Math.min(255,r.b*p*d/255)),a:r.a}}function Wr(t,e,n,r,o,a){let s=de(t,e,n);return he(s,r,o,a)}function Nr(t){let e=ue.parse(t??{}),n=e.size,r=[{x:-n,y:-n,z:-n},{x:n,y:-n,z:-n},{x:n,y:n,z:-n},{x:-n,y:n,z:-n},{x:-n,y:-n,z:n},{x:n,y:-n,z:n},{x:n,y:n,z:n},{x:-n,y:n,z:n}],o=[[0,1,2,3],[5,4,7,6],[4,0,3,7],[1,5,6,2],[3,2,6,7],[4,5,1,0]];return I$1(e.name,r,o)}function Zr(t){let e=pe.parse(t??{}),{radius:n,widthSegments:r,heightSegments:o,name:a}=e,s=[],i=[];for(let c=0;c<=o;c++){let p=c*Math.PI/o,m=Math.sin(p),u=Math.cos(p);for(let f=0;f<=r;f++){let h=f*2*Math.PI/r,d=n*m*Math.cos(h),v=n*u,P=n*m*Math.sin(h);s.push({x:d,y:v,z:P});}}for(let c=0;c<o;c++)for(let p=0;p<r;p++){let m=c*(r+1)+p,u=m+r+1;c!==0&&i.push([m,u,m+1]),c!==o-1&&i.push([u,u+1,m+1]);}return I$1(a,s,i)}function Xr(t){let e=le.parse(t??{}),{width:n,height:r,widthSegments:o,heightSegments:a,name:s}=e,i=[],c=[],p=n/2,m=r/2;for(let f=0;f<=a;f++){let h=f/a*r-m;for(let d=0;d<=o;d++){let v=d/o*n-p;i.push({x:v,y:0,z:h});}}let u=o+1;for(let f=0;f<a;f++)for(let h=0;h<o;h++){let d=f*u+h,v=d+1,P=d+u+1,E=d+u;c.push([d,v,P,E]);}return I$1(s,i,c)}function Gr(t){let e=fe.parse(t??{}),{radiusTop:n,radiusBottom:r,height:o,segments:a,name:s}=e,i=[],c=[],p=o/2;for(let m=0;m<a;m++){let u=m/a*Math.PI*2;i.push({x:n*Math.cos(u),y:p,z:n*Math.sin(u)});}for(let m=0;m<a;m++){let u=m/a*Math.PI*2;i.push({x:r*Math.cos(u),y:-p,z:r*Math.sin(u)});}for(let m=0;m<a;m++){let u=(m+1)%a,f=m,h=u,d=m+a,v=u+a;c.push([f,h,v,d]);}if(n>0){let m=i.length;i.push({x:0,y:p,z:0});for(let u=0;u<a;u++){let f=(u+1)%a;c.push([m,u,f]);}}if(r>0){let m=i.length;i.push({x:0,y:-p,z:0});for(let u=0;u<a;u++){let f=(u+1)%a;c.push([m,f+a,u+a]);}}return I$1(s,i,c)}n$1();var Hr=t=>{let e=b$2();if(e<=0)return t;let n=k$2(t,[y,P]);for(let r of n){let o=false,a=y.rotateSpeedX[r],s=y.rotateSpeedY[r],i=y.rotateSpeedZ[r];a!==0&&(P.rx[r]=P.rx[r]+a*e,o=true),s!==0&&(P.ry[r]=P.ry[r]+s*e,o=true),i!==0&&(P.rz[r]=P.rz[r]+i*e,o=true);let c=y.orbitEnabled[r],p=y.orbitSpeed[r];if(c===1&&p!==0){let m=y.orbitRadius[r],u=y.orbitCenterX[r],f=y.orbitCenterY[r],h=y.orbitCenterZ[r],d=y.orbitAngle[r]+p*e;y.orbitAngle[r]=d,P.tx[r]=u+Math.cos(d)*m,P.ty[r]=f,P.tz[r]=h+Math.sin(d)*m,o=true;}o&&(P.dirty[r]=1);}return t};n$1();var qr=Math.PI/2-.01,Ur=t=>{let e=k$2(t,[Y]);for(let n of e){let r=I.get(n);if(!r)continue;let o=Y.cameraEntity[n];if(o===0||!i$1(t,o,b))continue;let a=b.rotationSensitivity[o];if(r.dragDx!==0||r.dragDy!==0){let m=b.invertY[o]===1?-1:1,u=r.dragDx*a,f=r.dragDy*a*m,h=b.yaw[o]+u,d=Math.max(-qr,Math.min(qr,b.pitch[o]+f));b.yaw[o]=h,b.pitch[o]=d;}if(r.scrollDelta!==0){let m=b.zoomSensitivity[o],u=b.zoomMin[o],f=b.zoomMax[o],h=b.distance[o],d=Math.max(u,Math.min(f,h+r.scrollDelta*m));b.distance[o]=d;}let s=b.yaw[o],i=b.pitch[o],c=b.distance[o],p=Math.cos(i);P.tx[o]=Math.sin(s)*p*c,P.ty[o]=Math.sin(i)*c,P.tz[o]=Math.cos(s)*p*c,P.rx[o]=-i,P.ry[o]=-s,P.rz[o]=0,P.dirty[o]=1;}return me(),t};n$1();function cn(t){let e=ha(P.tx[t],P.ty[t],P.tz[t]),n=ha(P.rx[t],P.ry[t],P.rz[t]),r=ha(P.sx[t],P.sy[t],P.sz[t]);return Ia(e,n,r)}function un(t,e){let n=t*16;for(let r=0;r<16;r++)P.worldMatrix[n+r]=e[r];}function _r(t,e,n){if(!i$1(t,e,P))return;let r=P.dirty[e]!==0;if(r){let s=cn(e),i=n?xa(n,s):s;un(e,i),P.dirty[e]=0;}let o=e*16,a=P.worldMatrix.subarray(o,o+16);if(i$1(t,e,b$3)){let s=f$1(t,e);for(let i of s)r&&i$1(t,i,P)&&(P.dirty[i]=1),_r(t,i,a);}}var Kr=t=>{let e=k$2(t,[P]),n=[];for(let r of e){if(!i$1(t,r,b$3)){n.push(r);continue}let o=b$3.parent[r];(o===a$1||!i$1(t,o,P))&&n.push(r);}for(let r of n)_r(t,r,null);return t};n$1();var pn=["braille","braille","halfblock","sextant","sixel","kitty"],G=new Map,H=new Map;function Jr(){G.clear();}function Qr(){H.clear();}function ln(t){let e=Y.backendType[t],n=pn[e]??"braille",r=G.get(t);if(r&&r.type===n)return r;let o=q(n);return G.set(t,o),o}var $r=t=>{H.clear();let e=k$2(t,[Y]);for(let n of e){let r=qb.get(n);if(!r)continue;let o=ln(n),a=Y.left[n],s=Y.top[n],i=o.encode(r,a,s);H.set(n,{viewportEid:n,screenX:a,screenY:s,backendType:o.type,encoded:i});}return t};export{de as A,he as B,Wr as C,Nr as D,Zr as E,Xr as F,Gr as G,Hr as H,Ur as I,Kr as J,G as K,H as L,Jr as M,Qr as N,$r as O,fn as P,y as a,vr as b,Or as c,b as d,I as e,me as f,Ar as g,zr as h,Ir as i,Fr as j,Pr as k,ce as l,ue as m,pe as n,le as o,fe as p,be as q,ye as r,Br as s,L as t,Tr as u,kr as v,Lr as w,Rr as x,M as y,Yr as z};
|