blecsd 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/3d/index.js +1 -1
- package/dist/{border-Jb7TrMob.d.ts → border-DGNDfT6T.d.ts} +1 -1
- package/dist/chunk-25OEBENM.js +3 -0
- package/dist/chunk-26STV7ZS.js +1 -0
- package/dist/chunk-2NMGUEFC.js +4 -0
- package/dist/{chunk-LYSK5S63.js → chunk-4PRDJTCM.js} +1 -1
- package/dist/chunk-5VEKHA3B.js +5 -0
- package/dist/chunk-6KEM3OS2.js +11 -0
- package/dist/chunk-6PX5R326.js +1 -0
- package/dist/{chunk-3LHLSY3Y.js → chunk-6XWY6GB7.js} +1 -1
- package/dist/{chunk-FCMTWFSE.js → chunk-735KKTP3.js} +1 -1
- package/dist/chunk-7SWJNDOL.js +26 -0
- package/dist/chunk-APKUNIMB.js +1 -0
- package/dist/{chunk-FGHEFXLK.js → chunk-CJCSZRV6.js} +1 -1
- package/dist/chunk-DMBMCCLN.js +1 -0
- package/dist/{chunk-OR3BZY7C.js → chunk-DQTVJITR.js} +1 -1
- package/dist/chunk-DSKQ5J4R.js +1 -0
- package/dist/{chunk-OB66FB4F.js → chunk-EF4DC6IN.js} +1 -1
- package/dist/chunk-EJAKECSN.js +1 -0
- package/dist/chunk-FNQRUMFD.js +1 -0
- package/dist/chunk-GJ3RS2VG.js +1 -0
- package/dist/{chunk-G437VE43.js → chunk-KTVEMB2I.js} +1 -1
- package/dist/chunk-KYAPE44E.js +8 -0
- package/dist/chunk-LI4Y7TBZ.js +1 -0
- package/dist/chunk-NHOL4BN6.js +1 -0
- package/dist/chunk-NPNUUSIB.js +1 -0
- package/dist/chunk-OFRWGW2G.js +1 -0
- package/dist/chunk-OMU5BSAS.js +2 -0
- package/dist/chunk-P3ZLIQJP.js +1 -0
- package/dist/chunk-PWI36BQJ.js +1 -0
- package/dist/{chunk-R7AICVRN.js → chunk-QQMUDJ32.js} +2 -2
- package/dist/chunk-R3ICZOE4.js +1 -0
- package/dist/chunk-RJULLVTH.js +1 -0
- package/dist/chunk-S6WS46FE.js +1 -0
- package/dist/{chunk-TWSWTBYL.js → chunk-TSARUU56.js} +1 -1
- package/dist/{chunk-MKMFUXLB.js → chunk-WJRVUAZR.js} +2 -2
- package/dist/{chunk-XZJRWFOS.js → chunk-WY5EZOOL.js} +1 -1
- package/dist/chunk-YY6RZCZH.js +4 -0
- package/dist/chunk-ZPGJCHXH.js +1 -0
- package/dist/chunk-ZPL2J25N.js +1 -0
- package/dist/components/index.d.ts +6886 -6763
- package/dist/components/index.js +1 -1
- package/dist/core/index.d.ts +3621 -3217
- package/dist/core/index.js +1 -1
- package/dist/debug/index.d.ts +2 -2
- package/dist/debug/index.js +1 -1
- package/dist/game/index.d.ts +6 -6
- package/dist/game/index.js +1 -1
- package/dist/{gameLoop-C-Ez_i54.d.ts → gameLoop-CSTb7e0L.d.ts} +1 -1
- package/dist/index.d.ts +741 -23
- package/dist/index.js +3 -3
- package/dist/input/index.d.ts +1 -1
- package/dist/{inputActions-CRsUtTHM.d.ts → inputActions-Fyw14_Gm.d.ts} +3 -3
- package/dist/{keyParser-BnHbg2iD.d.ts → keyParser-m7fWto6g.d.ts} +18 -18
- package/dist/{mouseParser-Cfrbn3AX.d.ts → mouseParser-B7p5ow7K.d.ts} +1 -1
- package/dist/{scheduler-CMcYew9Z.d.ts → scheduler-DeeZleia.d.ts} +2 -0
- package/dist/systems/index.d.ts +351 -4
- package/dist/systems/index.js +1 -1
- package/dist/terminal/index.d.ts +329 -7
- package/dist/terminal/index.js +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +1 -1
- package/dist/widgets/bigText.js +1 -1
- package/dist/widgets/index.d.ts +1222 -101
- package/dist/widgets/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2IEMMRUO.js +0 -1
- package/dist/chunk-3AV52GY5.js +0 -1
- package/dist/chunk-3O4TQHGK.js +0 -4
- package/dist/chunk-3UJWZ5ZN.js +0 -1
- package/dist/chunk-6M2J5QUA.js +0 -1
- package/dist/chunk-7IQEUVGF.js +0 -1
- package/dist/chunk-A6M6TFBL.js +0 -1
- package/dist/chunk-CIK4AMUA.js +0 -1
- package/dist/chunk-CUEUJAHK.js +0 -3
- package/dist/chunk-D42Q2KKR.js +0 -1
- package/dist/chunk-DYEXOFUU.js +0 -2
- package/dist/chunk-DYU72XLL.js +0 -1
- package/dist/chunk-EAY7B5GL.js +0 -1
- package/dist/chunk-FL56THSI.js +0 -25
- package/dist/chunk-G7GIWWLE.js +0 -1
- package/dist/chunk-GGXNWT36.js +0 -8
- package/dist/chunk-HLFORKXS.js +0 -1
- package/dist/chunk-J7MBKEBY.js +0 -1
- package/dist/chunk-K3SX2LY5.js +0 -1
- package/dist/chunk-LDAFEXN5.js +0 -1
- package/dist/chunk-MQWPHPUM.js +0 -1
- package/dist/chunk-MTI376CU.js +0 -5
- package/dist/chunk-MTV2RJZD.js +0 -1
- package/dist/chunk-PXXGH3BV.js +0 -1
- package/dist/chunk-SHUC6JWA.js +0 -1
- package/dist/chunk-UMGTXSQB.js +0 -11
- package/dist/chunk-X3Q3T2SS.js +0 -4
- package/dist/chunk-ZAHG7Y3X.js +0 -1
- package/dist/{virtualViewport-Bpv6jlKt.d.ts → virtualViewport-DTSN6jFk.d.ts} +152 -152
package/README.md
CHANGED
|
@@ -323,8 +323,7 @@ Choose blECSd if you want data-oriented design, physics-based animations, or gam
|
|
|
323
323
|
- [Keyboard Shortcuts](./docs/guides/keyboard-shortcuts.md): Custom keybindings
|
|
324
324
|
|
|
325
325
|
### Examples
|
|
326
|
-
- [Examples](
|
|
327
|
-
- [Examples Repository](https://github.com/Kadajett/blECSd-Examples): Standalone runnable examples
|
|
326
|
+
- [Examples Repository](https://github.com/Kadajett/blECSd-Examples): File manager, multiplexer, system monitor, ANSI viewer, telnet server, and more
|
|
328
327
|
|
|
329
328
|
## Development
|
|
330
329
|
|
package/dist/3d/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as Animation3D,m as CubeMeshOptionsSchema,p as CylinderMeshOptionsSchema,d as MouseInteraction3D,l as ObjLoadOptionsSchema,o as PlaneMeshOptionsSchema,n as SphereMeshOptionsSchema,H as animation3DSystem,K as backendStore,y as blendPixel,M as clearBackendStore,f as clearMouseInputStore,N as clearOutputStore,u as clipLine,r as computeBoundingBox,A as computeFaceNormal,B as computeFlatShading,t as computeOutcode,D as createCubeMesh,G as createCylinderMesh,F as createPlaneMesh,E as createSphereMesh,j as disableMouseInteraction,z as drawLineAA,i as enableMouseInteraction,v as extractFrustumPlanes,g as feedMouseDrag,h as feedMouseScroll,c as getAnimation3D,k as getMouseInteraction3D,w as isPointInFrustum,x as isSphereInFrustum,s as loadObjAsMesh,e as mouseInputStore,I as mouseInteraction3DSystem,L as outputStore,q as parseObj,J as sceneGraphSystem,b as setAnimation3D,C as shadeFace,O as viewportOutputSystem}from'../chunk-
|
|
1
|
+
export{a as Animation3D,m as CubeMeshOptionsSchema,p as CylinderMeshOptionsSchema,d as MouseInteraction3D,l as ObjLoadOptionsSchema,o as PlaneMeshOptionsSchema,n as SphereMeshOptionsSchema,H as animation3DSystem,K as backendStore,y as blendPixel,M as clearBackendStore,f as clearMouseInputStore,N as clearOutputStore,u as clipLine,r as computeBoundingBox,A as computeFaceNormal,B as computeFlatShading,t as computeOutcode,D as createCubeMesh,G as createCylinderMesh,F as createPlaneMesh,E as createSphereMesh,j as disableMouseInteraction,z as drawLineAA,i as enableMouseInteraction,v as extractFrustumPlanes,g as feedMouseDrag,h as feedMouseScroll,c as getAnimation3D,k as getMouseInteraction3D,w as isPointInFrustum,x as isSphereInFrustum,s as loadObjAsMesh,e as mouseInputStore,I as mouseInteraction3DSystem,L as outputStore,q as parseObj,J as sceneGraphSystem,b as setAnimation3D,C as shadeFace,O as viewportOutputSystem}from'../chunk-QQMUDJ32.js';export{Xa as AmbientLightSchema,w as Animation3DConfigSchema,b as BackendCapabilitiesSchema,k as BackendPreferenceSchema,e as BackendSelectionSchema,a as BackendTypeSchema,f as BrailleConfigSchema,y as Camera3D,t as Camera3DConfigSchema,ga as ClipRectSchema,Wa as DirectionalLightSchema,c as EncodedCellSchema,d as EncodedOutputSchema,ca as EulerAnglesSchema,g as HalfBlockConfigSchema,j as KittyConfigSchema,Ta as LineEndpointSchema,ba as Mat4Schema,D as Material3D,u as Material3DConfigSchema,G as Mesh,x as MouseInteraction3DConfigSchema,ea as OrthographicConfigSchema,da as PerspectiveConfigSchema,Sa as PixelBufferConfigSchema,Ua as RGBAColorSchema,h as SextantConfigSchema,i as SixelConfigSchema,P as Transform3D,s as Transform3DConfigSchema,Va as TriangleVertexSchema,aa as Vec3InputSchema,$ as Vec3Schema,Y as Viewport3D,v as Viewport3DConfigSchema,mb as Viewport3DWidgetConfigSchema,fa as ViewportConfigSchema,Ra as buildMVP,Za as clearFramebuffer,rb as clearFramebufferStore,O as clearMeshStore,ob as clearProjectionStore,q as createBackendByType,l as createBrailleBackend,m as createHalfBlockBackend,n as createKittyBackend,I as createMeshFromArrays,Ya as createPixelFramebuffer,o as createSextantBackend,p as createSixelBackend,r as detectBestBackend,fb as drawLine,hb as drawLineColor,gb as drawLineDepth,eb as fillRect,kb as fillTriangle,lb as fillTriangleFlat,qb as framebufferStore,A as getCamera3D,cb as getDepth,F as getMaterial3D,M as getMesh,N as getMeshCount,J as getMeshData,$a as getPixel,B as getProjMatrix,R as getTransform3D,C as getViewMatrix,_ as getViewport3D,V as getWorldMatrix,X as isDirty,_a as isInBounds,Na as lookAt,W as markDirty,Ea as mat4Determinant,Ka as mat4Equals,Ia as mat4FromTRS,wa as mat4Identity,Fa as mat4Invert,Ja as mat4IsIdentity,xa as mat4Multiply,za as mat4RotateX,Aa as mat4RotateY,Ba as mat4RotateZ,Ca as mat4Scale,Ha as mat4TransformDirection,Ga as mat4TransformVec3,ya as mat4Translate,Da as mat4Transpose,Ma as orthographicMatrix,La as perspectiveMatrix,Pa as projectVertex,nb as projectionStore,pb as projectionSystem,sb as rasterSystem,H as registerMesh,z as setCamera3D,E as setMaterial3D,L as setMesh,ab as setPixel,bb as setPixelUnsafe,T as setRotation,U as setScale,Q as setTransform3D,S as setTranslation,Z as setViewport3D,db as testAndSetDepth,ib as triangleArea2,jb as triangleBoundingBox,Qa as unprojectVertex,K as unregisterMesh,ha as vec3,ja as vec3Add,na as vec3Cross,ta as vec3Distance,ma as vec3Dot,ua as vec3Equals,ia as vec3FromArray,pa as vec3Length,oa as vec3LengthSq,ra as vec3Lerp,sa as vec3Negate,qa as vec3Normalize,la as vec3Scale,ka as vec3Sub,va as vec3Zero,Oa as viewportTransform}from'../chunk-4PRDJTCM.js';import'../chunk-NPNUUSIB.js';import'../chunk-DMBMCCLN.js';import'../chunk-5N3O25O7.js';import'../chunk-GJ3RS2VG.js';import'../chunk-Z4EZERNE.js';import'../chunk-P3ZLIQJP.js';import'../chunk-5PELJRUQ.js';
|
|
@@ -264,4 +264,4 @@ declare function disableAllBorders(world: World, eid: Entity): Entity;
|
|
|
264
264
|
*/
|
|
265
265
|
declare function getBorderChar(world: World, eid: Entity, position: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'horizontal' | 'vertical'): number | undefined;
|
|
266
266
|
|
|
267
|
-
export {
|
|
267
|
+
export { type BorderCharset as B, DEFAULT_BORDER_BG as D, BORDER_ASCII as a, BORDER_BOLD as b, BORDER_DASHED as c, BORDER_DASHED_HEAVY as d, BORDER_DOUBLE as e, BORDER_ROUNDED as f, BORDER_SINGLE as g, Border as h, type BorderData as i, type BorderOptions as j, BorderType as k, DEFAULT_BORDER_FG as l, disableAllBorders as m, enableAllBorders as n, getBorder as o, getBorderChar as p, hasBorder as q, hasBorderVisible as r, setBorder as s, setBorderChars as t };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {b,e as e$2,d as d$1,f as f$3,g}from'./chunk-DNRXW56C.js';import {e}from'./chunk-735KKTP3.js';import {d,f as f$1,i,h}from'./chunk-APKUNIMB.js';import {oa,s,q as q$1,U as U$1,Z as Z$1,ra,f as f$2,i as i$1,la}from'./chunk-GJ3RS2VG.js';import {n,t,e as e$1,s as s$1}from'./chunk-P3ZLIQJP.js';import {readFileSync}from'fs';import {z}from'zod';n();t();var N=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),f=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),J=z.object({left:f.optional(),top:f.optional(),right:f.optional(),bottom:f.optional(),width:N.optional(),height:N.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),text:z.string(),font:z.union([z.string(),b]).optional(),shrink:z.boolean().optional()}),Y=1e4,c={isBigText:new Uint8Array(Y)},U="terminus-14-bold",T=new Map,a=new Map;function _(t){if(t===void 0)return 0;if(typeof t=="number")return t;switch(t){case "left":case "top":return 0;case "center":return 0;case "right":case "bottom":return 0}return 0}function M(t){return t===void 0||typeof t=="string"&&t==="auto"?"auto":t}async function j(t){return t?typeof t!="string"?t:t==="terminus-14-bold"||t==="terminus-14-normal"?d$1(t):H(t):d$1(U)}function q(t){return t?typeof t!="string"?t:t==="terminus-14-bold"||t==="terminus-14-normal"?e$2(t):T.get(t):e$2(U)}function K(t,i){let n=" ".repeat(t);return Array.from({length:i},()=>n)}function Q(t,i){let n=t.charHeight,r=Array.from({length:n},()=>"");for(let e of Array.from(i)){let u=f$3(t,e)?g(t,e):K(t.charWidth,t.charHeight);for(let g=0;g<n;g+=1){let O=u[g]??"";r[g]=`${r[g]}${O}`;}}return r}function B(t,i){let n=i.split(`
|
|
2
|
+
`),r=[];for(let e of n)r.push(...Q(t,e));return r.join(`
|
|
3
|
+
`)}function H(t){let i=T.get(t);if(i)return i;let n=readFileSync(t,"utf8"),r=JSON.parse(n),e=b.parse(r);return T.set(t,e),e}var ft=H;function R(t,i,n){let r=_(n.left),e=_(n.top);U$1(t,i,r,e);let s=M(n.width),u=M(n.height);f$2(t,i,s,u);let g=n.shrink!==false;i$1(t,i,g);}function X(t,i,n){n.fg===void 0&&n.bg===void 0||la(t,i,{fg:n.fg!==void 0?s$1(n.fg):void 0,bg:n.bg!==void 0?s$1(n.bg):void 0});}async function Z(t,i,n){let r=await j(n.font),e$1=B(r,n.text);a.set(i,n.text),e(t,i,e$1);}async function ct(t,i$1,n){let r=J.parse(n),e=i$1;c.isBigText[e]=1,R(t,e,r),X(t,e,r),await Z(t,e,r),d(t,e,{focusable:true});let s$1={eid:e,show(){return ra(t,e,true),s$1},hide(){return ra(t,e,false),s$1},move(u,g){return Z$1(t,e,u,g),oa(t,e),s$1},setPosition(u,g){return U$1(t,e,u,g),oa(t,e),s$1},setText(u){return tt(t,e,u,r.font),s$1},getText(){return a.get(e)??""},focus(){return h(t,e),s$1},blur(){return i(t,e),s$1},isFocused(){return f$1(t,e)},append(u){return q$1(t,e,u),s$1},getChildren(){return s(t,e)},destroy(){c.isBigText[e]=0,a.delete(e),e$1(t,e);}};return s$1}function w(t,i,n,r){let e$1=q(r);if(e$1){let s=B(e$1,n);a.set(i,n),e(t,i,s),oa(t,i);return}j(r).then(s=>{let u=B(s,n);a.set(i,n),e(t,i,u),oa(t,i);});}function tt(t,i,n,r){return w(t,i,n,r),i}function pt(t,i){return c.isBigText[i]===1}function lt(){c.isBigText.fill(0),a.clear();}export{J as a,c as b,H as c,ft as d,ct as e,w as f,pt as g,lt as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b,d as d$2}from'./chunk-4LWWONFK.js';import {c,a as a$1}from'./chunk-FNQRUMFD.js';import {d as d$1,A,i,B as B$1}from'./chunk-TSARUU56.js';import {a,e,r,o,t}from'./chunk-C5PCEQ6G.js';import {k as k$2}from'./chunk-VOCM5T2G.js';import {u,p as p$1,k as k$1}from'./chunk-ZPGJCHXH.js';import {T,ka,xa,pa,ma}from'./chunk-GJ3RS2VG.js';import {n,k,i as i$1}from'./chunk-P3ZLIQJP.js';import {z}from'zod';u();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$1(t,e,ka))return a.NONE;let r=a.NONE;return ka.bold[e]===1&&(r|=a.BOLD),ka.underline[e]===1&&(r|=a.UNDERLINE),ka.blink[e]===1&&(r|=a.BLINK),ka.inverse[e]===1&&(r|=a.INVERSE),r}function oe(t,e){if(c(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 p$1(t,e)?{top:k$1.top[e]===1?1:0,right:k$1.right[e]===1?1:0,bottom:k$1.bottom[e]===1?1:0,left:k$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$1,r,f,i,n,o$1,u){let m=e(" ",n,o$1,u);for(let l=0;l<f;l++)o(t$1,e$1+l,r,m);let a=i.length>f?i.slice(0,f):i;a.length>0&&t(t$1,e$1,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$2(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$1,r,f,i){if(r<=i)return;let{buffer:n}=t,o$1=e$1.height,u=e$1.x+e$1.width-1,m=e$1.y,a=i/r,l=Math.max(1,Math.floor(o$1*a)),x=Math.floor(f/r*o$1),S=e("\u2502",1717987071,255);for(let b=0;b<o$1;b++)o(n,u,m+b,S);let V=e("\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$1,r$1){let{world:f,buffer:i}=t,n=ma(f,e$1);if(!n||n.transparent)return;let o=ie(f,e$1),u=e(" ",n.fg,n.bg,o);r(i,r$1.x,r$1.y,r$1.width,r$1.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),pa(r,e);}var ce=t=>{if(!p)return t;let e=b(p),r={world:t,buffer:e,doubleBuffer:p},f=k(t,[d$1,T,ka]);for(let i of f)xa(t,i)&&(!A(t,i)&&ka.dirty[i]!==1||me(r,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,4 @@
|
|
|
1
|
+
import {f as f$2,e as e$1}from'./chunk-AEJIX2MW.js';import {e,f as f$4,k as k$2,c as c$1,b as b$1}from'./chunk-C5PCEQ6G.js';import {f as f$3,e as e$2,g as g$1,j}from'./chunk-JHCKPCUH.js';import {m}from'./chunk-RJULLVTH.js';import {b,k as k$1,d as d$1,f as f$1}from'./chunk-DSKQ5J4R.js';import {oa}from'./chunk-GJ3RS2VG.js';import {q as q$1,p as p$1}from'./chunk-Z4EZERNE.js';import {n,i as i$1,h as h$1}from'./chunk-P3ZLIQJP.js';import {z as z$1}from'zod';n();var Nt=1e4,h={role:new Uint8Array(Nt),labelId:new Uint32Array(Nt)},fe={button:1,checkbox:2,list:3,listitem:4,textbox:5,dialog:6,menu:7,menuitem:8,tree:9,treeitem:10},me={1:"button",2:"checkbox",3:"list",4:"listitem",5:"textbox",6:"dialog",7:"menu",8:"menuitem",9:"tree",10:"treeitem"},rt=new Map,Ot=1;function _n(e,t,r){i$1(e,t,h)||(h$1(e,t,h),h.labelId[t]=0),h.role[t]=fe[r];}function kn(e,t){if(!i$1(e,t,h))return;let r=h.role[t];if(!(r===void 0||r===0))return me[r]}function Mn(e,t,r){i$1(e,t,h)||(h$1(e,t,h),h.role[t]=0);let n=h.labelId[t];if(n&&n>0)rt.set(n,r);else {let o=Ot++;rt.set(o,r),h.labelId[t]=o;}}function Rn(e,t){if(!i$1(e,t,h))return;let r=h.labelId[t];if(!(r===void 0||r===0))return rt.get(r)}function Un(e){if(typeof process<"u"&&process.stdout){let t=e.replace(/[\x00-\x1F\x7F]/g,"");process.stdout.write(`\x1B]2;${t}\x07`);}}function Xn(){rt.clear(),Ot=1;}var mt="> ",bt=" ",pt=4294967295,dt=6750207,gt=3435973887,yt=255,xt=1717987071;var Gt="Loading...";var c={isList:new Uint8Array(1e4),selectedIndex:new Int32Array(1e4).fill(-1),itemCount:new Uint32Array(1e4),firstVisible:new Uint32Array(1e4),visibleCount:new Uint32Array(1e4),interactive:new Uint8Array(1e4),mouse:new Uint8Array(1e4),keys:new Uint8Array(1e4),searchEnabled:new Uint8Array(1e4),totalCount:new Uint32Array(1e4),isLoading:new Uint8Array(1e4)},d=m({iterable:true}),X=new Map,H=new Map,Z=new Map,V=new Map,D=new Map,B=new Map,A=new Map,P=new Map,_=new Map,J=new Map,I=new Map,z=new Map,Y=new Map;function k(e){return d.get(e)??[]}function be(e,t,r){d.set(t,[...r]),c.itemCount[t]=r.length,(c.selectedIndex[t]??-1)>=r.length&&(c.selectedIndex[t]=r.length>0?r.length-1:-1),(c.firstVisible[t]??0)>=r.length&&(c.firstVisible[t]=Math.max(0,r.length-1)),oa(e,t);}function pe(e,t,r,n){let o=d.get(t)??[],l=n??o.length;o.splice(l,0,r),d.set(t,o),c.itemCount[t]=o.length;let s=c.selectedIndex[t]??-1;s>=0&&l<=s&&(c.selectedIndex[t]=s+1),oa(e,t);}function de(e,t,r){let n=d.get(t)??[];if(r<0||r>=n.length)return;let o=n.splice(r,1)[0];c.itemCount[t]=n.length;let l=c.selectedIndex[t]??-1;return l>=0&&(r<l?c.selectedIndex[t]=l-1:r===l&&(c.selectedIndex[t]=n.length>0?Math.min(r,n.length-1):-1)),oa(e,t),o}function w(e,t){return d.get(e)?.[t]}function ge(e,t,r,n){let o=d.get(t);return !o||r<0||r>=o.length?false:(o[r]=n,oa(e,t),true)}function ye(e){return c.itemCount[e]??0}function xe(e,t){d.set(t,[]),c.itemCount[t]=0,c.selectedIndex[t]=-1,c.firstVisible[t]=0,oa(e,t);}function he(e){return c.firstVisible[e]??0}function Ee(e,t){let r=H.get(e);if(!r||r.size===0)return;let n=c.firstVisible[e]??0,o=c.visibleCount[e]??0,l=c.itemCount[e]??0,s=c.totalCount[e]??l,a=o,m={firstVisible:n,visibleCount:o,loadedCount:l,totalCount:s,nearEnd:n+o>=l-a,nearStart:n<=a};for(let b of r)b(m);}function nt(e,t,r){let n=c.itemCount[t]??0,o=c.totalCount[t]??n,l=Math.max(0,Math.max(n,o)-1),s=Math.max(0,Math.min(r,l));c.firstVisible[t]=s,oa(e,t),Ee(t);}function Ce(e){return c.visibleCount[e]??0}function Le(e,t,r){c.visibleCount[t]=Math.max(1,r),oa(e,t);}function Ct(e,t,r){if(r<0)return;let n=c.firstVisible[t]??0,o=c.visibleCount[t]??0,l=n+o-1;r<n?nt(e,t,r):r>l&&nt(e,t,r-o+1);}var ht=null;function Ht(e){ht=e;}function Se(e,t,r){let n=c.firstVisible[t]??0,o=c.visibleCount[t]??0,l=c.itemCount[t]??0,s=n+r*o;if(s<0||s>=l)return false;nt(e,t,s);let a=c.selectedIndex[t]??-1;if(a>=0&&ht){let m=a+r*o;ht(e,t,Math.max(0,Math.min(m,l-1)));}return true}function Lt(e){let t=d.get(e)??[],r=c.firstVisible[e]??0,n=c.visibleCount[e]??t.length,o=[];for(let l=0;l<n&&r+l<t.length;l++){let s=r+l,a=t[s];a&&o.push({index:s,item:a});}return o}function ve(e,t,r){c.totalCount[t]=r,oa(e,t);}function zt(e){let t=c.totalCount[e]??0;return t===0?c.itemCount[e]??0:t}function Te(e,t){X.set(e,t);}function Ae(e){return X.get(e)}function Ie(e){X.delete(e);}function we(e,t){let r=H.get(e);return r||(r=new Set,H.set(e,r)),r.add(t),()=>{r?.delete(t);}}function Et(e,t,r){c.isLoading[t]=r?1:0,oa(e,t);}function We(e){return c.isLoading[e]===1}function Fe(e,t){Z.set(e,t);}function De(e){return Z.get(e)??Gt}async function Be(e,t,r,n){let o=X.get(t);if(o&&c.isLoading[t]!==1){Et(e,t,true);try{let l=await o(r,n),s=d.get(t)??[];for(;s.length<r+l.length;)s.push({text:"",disabled:!0});for(let a=0;a<l.length;a++){let m=l[a];m&&(s[r+a]=m);}d.set(t,s),c.itemCount[t]=s.length,oa(e,t);}finally{Et(e,t,false);}}}function _e(e){let t=c.firstVisible[e]??0,r=c.visibleCount[e]??0,n=c.totalCount[e]??0,o=d.get(e)??[],l=Math.min(t+r,n);for(let s=t;s<l;s++){let a=o[s];if(!a||a.text==="")return {needsLoad:true,startIndex:t,count:r}}return {needsLoad:false,startIndex:0,count:0}}function ke(e,t){let r=c.firstVisible[e]??0,n=c.visibleCount[e]??0,o=c.itemCount[e]??0,l=zt(e),s=t??n;return {firstVisible:r,visibleCount:n,loadedCount:o,totalCount:l,nearEnd:r+n>=o-s,nearStart:r<=s}}function Me(e,t,r){let n=d.get(t)??[];n.push(...r),d.set(t,n),c.itemCount[t]=n.length,oa(e,t);}function Re(e){return c.selectedIndex[e]??-1}function Ue(e){let t=c.selectedIndex[e]??-1;if(!(t<0))return w(e,t)}function Xe(e,t,r){return t<-1||t>=r?false:t<0?true:!w(e,t)?.disabled}function Ve(e,t){if(t<0)return;let r=w(e,t);if(!r)return;let n=D.get(e);if(n)for(let o of n)o(t,r);}function E(e,t,r){let n=c.itemCount[t]??0,o=c.selectedIndex[t]??-1;return !Xe(t,r,n)||o===r?false:(c.selectedIndex[t]=r,oa(e,t),Ve(t,r),Ct(e,t,r),true)}function Pe(e,t,r=true){let n=c.itemCount[t]??0;if(n===0)return false;let o=c.selectedIndex[t]??-1,l=o;do{if(o--,o<0)if(r)o=n-1;else return false;if(!w(t,o)?.disabled)return E(e,t,o)}while(o!==l);return false}function Ye(e,t,r=true){let n=c.itemCount[t]??0;if(n===0)return false;let o=c.selectedIndex[t]??-1,l=o;do{if(o++,o>=n)if(r)o=0;else return false;if(!w(t,o)?.disabled)return E(e,t,o)}while(o!==l);return false}function Ne(e,t){let r=c.itemCount[t]??0;for(let n=0;n<r;n++)if(!w(t,n)?.disabled)return E(e,t,n);return false}function Oe(e,t){let r=c.itemCount[t]??0;for(let n=r-1;n>=0;n--)if(!w(t,n)?.disabled)return E(e,t,n);return false}function Ge(e,t,r){let o=(d.get(t)??[]).findIndex(l=>l.value===r);return o>=0?E(e,t,o):false}function He(e,t){E(e,t,-1);}function ze(e,t){let r=c.selectedIndex[t]??-1;if(r<0)return false;let n=w(t,r);if(!n||n.disabled)return false;let o=B.get(t);if(o)for(let l of o)l(r,n);return true}function Qe(e,t){let r=D.get(e)??[];return r.push(t),D.set(e,r),()=>{let n=D.get(e);if(n){let o=n.indexOf(t);o!==-1&&n.splice(o,1);}}}function Ke(e,t){let r=B.get(e)??[];return r.push(t),B.set(e,r),()=>{let n=B.get(e);if(n){let o=n.indexOf(t);o!==-1&&n.splice(o,1);}}}function $e(e,t){let r=_.get(e)??[];return r.push(t),_.set(e,r),()=>{let n=_.get(e);if(n){let o=n.indexOf(t);o!==-1&&n.splice(o,1);}}}function je(e){let t=_.get(e);if(t)for(let r of t)r();}function Ze(e){D.delete(e),B.delete(e),_.delete(e);}var St={initial:"idle",states:{idle:{on:{focus:"focused",disable:"disabled"}},focused:{on:{blur:"idle",startSelect:"selecting",startSearch:"searching",disable:"disabled"}},selecting:{on:{endSelect:"focused",blur:"idle",disable:"disabled"}},searching:{on:{endSearch:"focused",blur:"idle",disable:"disabled"}},disabled:{on:{enable:"idle"}}}};function qe(e,t,r=[],n={}){z$1.array(q$1).parse(r),p$1.parse(n),c.isList[t]=1,c.selectedIndex[t]=n.selectedIndex??-1,c.itemCount[t]=r.length,c.firstVisible[t]=0,c.visibleCount[t]=n.visibleCount??r.length,c.interactive[t]=n.interactive!==false?1:0,c.mouse[t]=n.mouse!==false?1:0,c.keys[t]=n.keys!==false?1:0,c.searchEnabled[t]=n.search===true?1:0,d.set(t,[...r]),b(e,t,St);}function N(e,t){return c.isList[t]===1&&k$1(e,t)}function vt(e,t){return d$1(e,t)??"idle"}function ot(e,t,r){return vt(e,t)===r}function tr(e,t){let r=vt(e,t);return r==="focused"||r==="selecting"}function Tt(e,t){return ot(e,t,"disabled")}function M(e,t,r){if(!N(e,t))return false;let n=f$1(e,t,r);return n&&oa(e,t),n}function er(e,t){return M(e,t,"focus")}function rr(e,t){return M(e,t,"blur")}function nr(e,t){return M(e,t,"disable")}function or(e,t){return M(e,t,"enable")}function lr(e,t){let r=V.get(e);V.set(e,{selectedPrefix:t.selectedPrefix??r?.selectedPrefix??"> ",unselectedPrefix:t.unselectedPrefix??r?.unselectedPrefix??" ",selectedFg:t.selectedFg??r?.selectedFg??4294967295,selectedBg:t.selectedBg??r?.selectedBg??6750207,itemFg:t.itemFg??r?.itemFg??3435973887,itemBg:t.itemBg??r?.itemBg??255,disabledFg:t.disabledFg??r?.disabledFg??1717987071});}function At(e){return V.get(e)??{selectedPrefix:"> ",unselectedPrefix:" ",selectedFg:4294967295,selectedBg:6750207,itemFg:3435973887,itemBg:255,disabledFg:1717987071}}function sr(e){V.delete(e);}function ir(e,t,r){let n=r.toLowerCase();z.set(t,n);let o=k(t),l=n===""?[...o]:o.filter(s=>s.text.toLowerCase().includes(n));Y.set(t,l),l.length>0?c.selectedIndex[t]=0:c.selectedIndex[t]=-1,c.firstVisible[t]=0,oa(e,t);}function cr(e,t){z.delete(t),Y.delete(t),c.firstVisible[t]=0,k(t).length>0&&(c.selectedIndex[t]=0),oa(e,t);}function ar(e){let t=z.get(e);if(t===void 0||t==="")return k(e);let r=Y.get(e);if(r)return r;let o=k(e).filter(l=>l.text.toLowerCase().includes(t.toLowerCase()));return Y.set(e,o),o}function ur(e,t){J.set(e,t),t&&!I.has(e)&&I.set(e,new Set);}function R(e){return J.get(e)??false}function fr(e,t){if(!R(e))throw new Error("Multi-select is not enabled for this list");let r=I.get(e);return r?r.has(t)?(r.delete(t),false):(r.add(t),true):false}function mr(e){if(!R(e))throw new Error("Multi-select is not enabled for this list");let t=I.get(e);return t?Array.from(t).sort((r,n)=>r-n):[]}function br(e){if(!R(e))return;let t=k(e),r=I.get(e);if(r){r.clear();for(let n=0;n<t.length;n++)r.add(n);}}function pr(e){if(!R(e))return;let t=I.get(e);t&&t.clear();}function dr(e,t){return R(e)?I.get(e)?.has(t)??false:false}function gr(e){return c.interactive[e]===1}function yr(e,t,r){c.interactive[t]=r?1:0,oa(e,t);}function xr(e){return c.mouse[e]===1}function hr(e,t,r){c.mouse[t]=r?1:0,oa(e,t);}function It(e){return c.keys[e]===1}function Er(e,t,r){c.keys[t]=r?1:0,oa(e,t);}function Qt(e){return c.searchEnabled[e]===1}function Cr(e,t,r){c.searchEnabled[t]=r?1:0,oa(e,t);}function wt(e,t){return ot(e,t,"searching")}function Lr(e,t){if(!N(e,t)||!Qt(t))return false;let r=M(e,t,"startSearch");return r&&A.set(t,""),r}function Sr(e,t){if(!N(e,t))return false;let r=M(e,t,"endSearch");return r&&A.delete(t),r}function vr(e){return A.get(e)??""}function lt(e,t,r){A.set(t,r),oa(e,t);let n=P.get(t);if(n)for(let o of n)o(r);return r.length>0?Kt(e,t,r):false}function Tr(e,t,r){let n=A.get(t)??"";return lt(e,t,n+r)}function Ar(e,t){let r=A.get(t)??"";return r.length===0?false:lt(e,t,r.slice(0,-1))}function Ir(e,t){lt(e,t,"");}function Kt(e,t,r){let n=d.get(t)??[],o=r.toLowerCase();for(let l=0;l<n.length;l++){let s=n[l];if(s&&!s.disabled&&s.text.toLowerCase().startsWith(o))return E(e,t,l)}return false}function wr(e,t){let r=A.get(t);if(!r||r.length===0)return false;let n=d.get(t)??[],o=c.selectedIndex[t]??-1,l=r.toLowerCase();for(let s=o+1;s<n.length;s++){let a=n[s];if(a&&!a.disabled&&a.text.toLowerCase().startsWith(l))return E(e,t,s)}for(let s=0;s<=o;s++){let a=n[s];if(a&&!a.disabled&&a.text.toLowerCase().startsWith(l))return E(e,t,s)}return false}function Wr(e,t){let r=P.get(e)??[];return r.push(t),P.set(e,r),()=>{let n=P.get(e);if(n){let o=n.indexOf(t);o!==-1&&n.splice(o,1);}}}function Fr(e,t,r){if(!N(e,t)||Tt(e,t)||!It(t))return null;if(wt(e,t))return Dr(r);switch(r){case "up":case "k":return {type:"selectPrev"};case "down":case "j":return {type:"selectNext"};case "home":case "g":return {type:"selectFirst"};case "end":case "G":return {type:"selectLast"};case "pageup":return {type:"pageUp"};case "pagedown":return {type:"pageDown"};case "enter":return {type:"confirm"};case " ":case "space":return R(t)?{type:"toggleSelect"}:{type:"confirm"};case "escape":return {type:"cancel"};case "/":return {type:"startSearch"};default:return null}}function Dr(e){switch(e){case "escape":return {type:"endSearch"};case "enter":return {type:"endSearch"};case "backspace":return {type:"searchBackspace"};case "up":case "down":return {type:"endSearch"};case "tab":case "C-n":return {type:"searchNextMatch"};default:return e.length===1&&e>=" "?{type:"searchChar",char:e}:null}}function Br(e,t){let r=At(e),n=Lt(e),o=c.selectedIndex[e]??-1,l=[];for(let{index:s,item:a}of n){let b=s===o?r.selectedPrefix:r.unselectedPrefix,y=a.text,L=t-b.length,S=y.length>L?`${y.slice(0,L-1)}\u2026`:y;l.push(b+S);}return l}function _r(){c.isList.fill(0),c.selectedIndex.fill(-1),c.itemCount.fill(0),c.firstVisible.fill(0),c.visibleCount.fill(0),c.interactive.fill(0),c.mouse.fill(0),c.keys.fill(0),c.searchEnabled.fill(0),c.totalCount.fill(0),c.isLoading.fill(0),d.clear(),V.clear(),D.clear(),B.clear(),_.clear(),J.clear(),I.clear(),z.clear(),Y.clear(),A.clear(),P.clear(),X.clear(),H.clear(),Z.clear();}Ht(E);var kr=["|","/","-","\\"],sl=[". ",".. ","..."," .."," ."," "],il=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],cl=["\u2596","\u2598","\u259D","\u2597"],al=100,p={frame:new Uint8Array(1e4),frameCount:new Uint8Array(1e4),interval:new Uint16Array(1e4),elapsed:new Float32Array(1e4)},Q=new Map,q=new Set;function ul(e,t,r={}){let n=r.frames??kr,o=r.interval??100;p.frame[t]=0,p.frameCount[t]=n.length,p.interval[t]=o,p.elapsed[t]=0,Q.set(t,n),q.add(t);}function fl(e,t){q.has(t)&&(p.frame[t]=0,p.frameCount[t]=0,p.interval[t]=0,p.elapsed[t]=0,Q.delete(t),q.delete(t));}function ml(e,t){return q.has(t)}function bl(e){let t=Q.get(e);if(!t)return "";let r=p.frame[e]??0;return t[r%t.length]??""}function pl(e){let t=Q.get(e);return t?{frame:p.frame[e]??0,frameCount:p.frameCount[e]??0,interval:p.interval[e]??100,elapsed:p.elapsed[e]??0,frames:t}:null}function dl(e,t){p.interval[e]=t;}function gl(e,t){Q.set(e,t),p.frameCount[e]=t.length,(p.frame[e]??0)>=t.length&&(p.frame[e]=0);}function Mr(e){let t=p.frameCount[e]??1,r=((p.frame[e]??0)+1)%t;return p.frame[e]=r,r}function yl(e,t){let r=(p.elapsed[e]??0)+t,n=p.interval[e]??100;return r>=n?(Mr(e),p.elapsed[e]=r%n,true):(p.elapsed[e]=r,false)}function xl(e){p.frame[e]=0,p.elapsed[e]=0;}function hl(){Q.clear(),q.clear();}var $t=4294967295,jt=858993663,Zt=3435973887,Jt=255,qt=1717987071,te=255,v=1e4,W={rowCount:new Uint32Array(v),colCount:new Uint16Array(v),headerRows:new Uint8Array(v).fill(1),pad:new Uint8Array(v).fill(1),cellBorders:new Uint8Array(v)},f={isTable:new Uint8Array(v),rowCount:new Uint32Array(v),colCount:new Uint16Array(v),headerRows:new Uint8Array(v).fill(1),pad:new Uint8Array(v).fill(1),cellBorders:new Uint8Array(v)},g=new Map,$=new Map,K=new Map;function Ll(e,t,r={}){f.isTable[t]=1,f.rowCount[t]=0,f.colCount[t]=0,f.headerRows[t]=r.headerRows??1,f.pad[t]=r.pad??1,f.cellBorders[t]=r.cellBorders===true?1:0,W.rowCount[t]=0,W.colCount[t]=0,W.headerRows[t]=r.headerRows??1,W.pad[t]=r.pad??1,W.cellBorders[t]=r.cellBorders===true?1:0,g.set(t,[]),$.set(t,[]);}function Sl(e,t){return f.isTable[t]===1}function vl(e,t){f.isTable[t]=0,f.rowCount[t]=0,f.colCount[t]=0,f.headerRows[t]=1,f.pad[t]=1,f.cellBorders[t]=0,W.rowCount[t]=0,W.colCount[t]=0,W.headerRows[t]=1,W.pad[t]=1,W.cellBorders[t]=0,g.delete(t),$.delete(t),K.delete(t);}function Tl(e,t,r){let n=r.map(o=>o.map(l=>typeof l=="string"?{value:l}:l));g.set(t,n),f.rowCount[t]=n.length,f.colCount[t]=n.reduce((o,l)=>Math.max(o,l.length),0),oa(e,t);}function Al(e,t){return g.get(t)??[]}function Il(e,t){return (g.get(t)??[]).map(n=>n.map(o=>o.value))}function wl(e,t,r,n,o){let l=g.get(t);if(!l||r<0||n<0)return false;for(;l.length<=r;)l.push([]);let s=l[r];if(!s)return false;for(;s.length<=n;)s.push({value:""});s[n]=typeof o=="string"?{value:o}:o;let a=l.reduce((m,b)=>Math.max(m,b.length),0);return f.colCount[t]=a,f.rowCount[t]=l.length,oa(e,t),true}function Rr(e,t,r,n){let o=g.get(t);if(!(!o||r<0||n<0))return o[r]?.[n]}function Wl(e,t,r,n){return Rr(e,t,r,n)?.value}function Fl(e,t,r){return g.get(t)?.[r]}function Dl(e,t,r){return (g.get(t)??[]).map(o=>o[r]??{value:""})}function Bl(e,t){return f.rowCount[t]??0}function _l(e,t){return f.colCount[t]??0}function kl(e,t,r){let n=g.get(t)??[],o=r.map(l=>typeof l=="string"?{value:l}:l);n.push(o),f.rowCount[t]=n.length,f.colCount[t]=Math.max(f.colCount[t]??0,o.length),oa(e,t);}function Ml(e,t,r,n){let o=g.get(t)??[],l=n.map(a=>typeof a=="string"?{value:a}:a),s=Math.max(0,Math.min(r,o.length));o.splice(s,0,l),f.rowCount[t]=o.length,f.colCount[t]=Math.max(f.colCount[t]??0,l.length),oa(e,t);}function Rl(e,t,r){let n=g.get(t);if(!n||r<0||r>=n.length)return;let o=n.splice(r,1)[0];return f.rowCount[t]=n.length,f.colCount[t]=n.reduce((l,s)=>Math.max(l,s.length),0),oa(e,t),o}function Ul(e,t){g.set(t,[]),f.rowCount[t]=0,f.colCount[t]=0,oa(e,t);}function Xl(e,t,r){$.set(t,[...r]);let n=g.get(t)??[];if((f.headerRows[t]??1)>0){let l=r.map(s=>({value:s.header,align:s.align??"left"}));n.length===0?n.unshift(l):n[0]=l,f.rowCount[t]=n.length,f.colCount[t]=r.length;}oa(e,t);}function Vl(e,t){return $.get(t)??[]}function Pl(e,t){let r=g.get(t)??[],n=f.headerRows[t]??1;return r.slice(0,n)}function Yl(e,t){let r=g.get(t)??[],n=f.headerRows[t]??1;return r.slice(n)}function Nl(e,t,r){f.headerRows[t]=Math.max(0,Math.min(255,r)),oa(e,t);}function Ol(e,t){return f.headerRows[t]??1}function Gl(e,t,r){let n=K.get(t),o=r.altRowBg??n?.altRowBg,l=r.selectedFg??n?.selectedFg,s=r.selectedBg??n?.selectedBg,a={headerFg:r.headerFg??n?.headerFg??$t,headerBg:r.headerBg??n?.headerBg??jt,cellFg:r.cellFg??n?.cellFg??Zt,cellBg:r.cellBg??n?.cellBg??Jt,borderFg:r.borderFg??n?.borderFg??qt,borderBg:r.borderBg??n?.borderBg??te,...o!==void 0&&{altRowBg:o},...l!==void 0&&{selectedFg:l},...s!==void 0&&{selectedBg:s}};K.set(t,a);}function Hl(e,t){return K.get(t)??{headerFg:$t,headerBg:jt,cellFg:Zt,cellBg:Jt,borderFg:qt,borderBg:te}}function zl(e,t){K.delete(t);}function Ql(e,t){return f.pad[t]??1}function Kl(e,t,r){f.pad[t]=Math.max(0,Math.min(255,r)),oa(e,t);}function $l(e,t){return f.cellBorders[t]===1}function jl(e,t,r){f.cellBorders[t]=r?1:0,oa(e,t);}function Ur(e,t,r){let n=new Array(t).fill(0);for(let o of e)for(let l=0;l<o.length;l++){let s=o[l];s&&(n[l]=Math.max(n[l]??0,s.value.length+r*2));}return n}function Xr(e,t){for(let r=0;r<t.length;r++){let n=t[r];n&&(n.width!==void 0?e[r]=n.width:(n.minWidth!==void 0&&(e[r]=Math.max(e[r]??0,n.minWidth)),n.maxWidth!==void 0&&(e[r]=Math.min(e[r]??0,n.maxWidth))));}}function Vr(e,t){let r=e.reduce((n,o)=>n+o,0);if(r>t){let n=t/r;for(let o=0;o<e.length;o++)e[o]=Math.floor((e[o]??0)*n);}}function Pr(e,t,r){let n=g.get(t)??[],o=$.get(t)??[],l=f.colCount[t]??0,s=f.pad[t]??1,a=Ur(n,l,s);return Xr(a,o),r!==void 0&&Vr(a,r),a}function Yr(e,t,r){if(r==="right")return e.padStart(t);if(r==="center"){let n=Math.floor((t-e.length)/2);return e.padStart(n+e.length).padEnd(t)}return e.padEnd(t)}function Nr(e,t,r,n){let o=t-r*2,l=e.value;l.length>o&&(l=`${l.slice(0,o-1)}\u2026`);let s=Yr(l,o,e.align??"left");return n+s+n}function Or(e,t,r,n){let o=" ".repeat(r),l=n?"\u2502":"",s="";for(let a=0;a<t.length;a++){let m=e[a]??{value:""};a>0&&n&&(s+=l),s+=Nr(m,t[a]??0,r,o);}return s}function Zl(e,t,r){let n=g.get(t)??[],o=Pr(e,t,r),l=f.pad[t]??1,s=f.cellBorders[t]===1,a=f.headerRows[t]??1,m=[];for(let b=0;b<n.length;b++)m.push(Or(n[b]??[],o,l,s)),s&&b===a-1&&b<n.length-1&&m.push(o.map(y=>"\u2500".repeat(y)).join("\u253C"));return m}function Jl(){f.isTable.fill(0),f.rowCount.fill(0),f.colCount.fill(0),f.headerRows.fill(1),f.pad.fill(1),f.cellBorders.fill(0),g.clear(),$.clear(),K.clear();}var U=1e4,Gr=80,Hr=24,zr=1e3,i={isTerminal:new Uint8Array(U),width:new Uint16Array(U),height:new Uint16Array(U),cursorX:new Uint16Array(U),cursorY:new Uint16Array(U),cursorVisible:new Uint8Array(U),scrollOffset:new Uint32Array(U),altScreenActive:new Uint8Array(U)},C=new Map,Qr=z$1.object({width:z$1.number().int().positive().default(Gr),height:z$1.number().int().positive().default(Hr),scrollbackLines:z$1.number().int().nonnegative().default(zr),cursorVisible:z$1.boolean().default(true),cursorShape:z$1.enum(["block","underline","bar"]).default("block"),cursorBlink:z$1.boolean().default(true)});function Kr(e,t,r,n,o){let l={maxLines:r,chunkSize:Math.min(r,1e3)};return {buffer:k$2(e,t),scrollback:e$2(l),currentAttr:e$1(),escapeBuffer:"",inEscape:false,savedCursorX:0,savedCursorY:0,savedAttr:e$1(),altBuffer:null,cursorShape:n,cursorBlink:o}}function $r(e,t,r){return r*e+t}function jr(e){let t=b$1,r=c$1,n=[255,2852126975,11141375,2863268095,43775,2852170495,11184895,2863311615,1431655935,4283782655,1442797055,4294923775,1431699455,4283826175,1442840575,4294967295];return e.fg.type===1?t=n[e.fg.value]??b$1:e.fg.type===3&&(t=e.fg.value<<8|255),e.bg.type===1?r=n[e.bg.value]??c$1:e.bg.type===3&&(r=e.bg.value<<8|255),{fg:t,bg:r,attrs:e.styles}}function Ft(e$1,t,r){let n=Zr(e$1.buffer,0,t);g$1(e$1.scrollback,n);for(let l=0;l<r-1;l++)for(let s=0;s<t;s++){let a=(l+1)*t+s,m=l*t+s,b=e$1.buffer.cells[a];b&&(e$1.buffer.cells[m]=f$4(b));}let o=e();for(let l=0;l<t;l++){let s=(r-1)*t+l;e$1.buffer.cells[s]=f$4(o);}}function Zr(e,t,r){let n="";for(let o=0;o<r;o++){let l=t*r+o,s=e.cells[l];n+=s?.char??" ";}return n.trimEnd()}function ls(e,t,r={}){let n=Qr.parse(r);i.isTerminal[t]=1,i.width[t]=n.width,i.height[t]=n.height,i.cursorX[t]=0,i.cursorY[t]=0,i.cursorVisible[t]=n.cursorVisible?1:0,i.scrollOffset[t]=0,i.altScreenActive[t]=0;let o=Kr(n.width,n.height,n.scrollbackLines,n.cursorShape,n.cursorBlink);C.set(t,o),oa(e,t);}function Jr(e){return i.isTerminal[e]===1}function ss(e){return C.get(e)}function is(e){if(Jr(e))return {width:i.width[e]??0,height:i.height[e]??0,cursorX:i.cursorX[e]??0,cursorY:i.cursorY[e]??0,cursorVisible:i.cursorVisible[e]===1,scrollOffset:i.scrollOffset[e]??0}}function qr(e,t,r,n,o){let l=(i.cursorY[t]??0)+1;l>=o&&(Ft(r,n,o),l=o-1),i.cursorX[t]=0,i.cursorY[t]=l,oa(e,t);}function tn(e,t,r){let n=i.cursorX[t]??0,o=Math.min((Math.floor(n/8)+1)*8,r-1);i.cursorX[t]=o,oa(e,t);}function en(e$1,t,r,n,o,l){let s=i.cursorX[t]??0,a=i.cursorY[t]??0,{fg:m,bg:b,attrs:y}=jr(r.currentAttr),L=$r(o,s,a);r.buffer.cells[L]=e(n,m,b,y);let S=s+1;S>=o&&(S=0,a++,a>=l&&(Ft(r,o,l),a=l-1)),i.cursorX[t]=S,i.cursorY[t]=a,oa(e$1,t);}function rn(e,t,r){let n=C.get(t);if(!n)return;let o=i.width[t]??0,l=i.height[t]??0;if(r===`
|
|
2
|
+
`){qr(e,t,n,o,l);return}if(r==="\r"){i.cursorX[t]=0,oa(e,t);return}if(r==="\b"){let s=i.cursorX[t]??0;s>0&&(i.cursorX[t]=s-1),oa(e,t);return}if(r===" "){tn(e,t,o);return}en(e,t,n,r,o,l);}function cs(e,t,r){let n=C.get(t);if(n)for(let o=0;o<r.length;o++){let l=r[o];if(l!==void 0){if(l==="\x1B"){n.inEscape=true,n.escapeBuffer=l;continue}if(n.inEscape){n.escapeBuffer+=l,nn(n.escapeBuffer)&&(on(e,t,n,n.escapeBuffer),n.inEscape=false,n.escapeBuffer="");continue}rn(e,t,l);}}}function nn(e){if(e.length<2)return false;if(e[1]==="["){let t=e[e.length-1];return t===void 0?false:/[A-Za-z@`~]/.test(t)}return e[1]==="]"?e.endsWith("\x07")||e.endsWith("\x1B\\"):e.length>=2}function on(e,t,r,n){if(n.length<2)return;let o=n[1];if(o==="["){ln(e,t,r,n);return}switch(o){case "c":Wn(e,t);break;case "7":r.savedCursorX=i.cursorX[t]??0,r.savedCursorY=i.cursorY[t]??0,r.savedAttr=f$2(r.currentAttr);break;case "8":i.cursorX[t]=r.savedCursorX,i.cursorY[t]=r.savedCursorY,r.currentAttr=f$2(r.savedAttr),oa(e,t);break;case "D":st(e,t,r,1);break;case "M":Wt(e,t,1);break;case "E":i.cursorX[t]=0,st(e,t,r,1);break}}function ln(e,t,r,n){let o=n.match(/^\x1b\[(\??[\d;]*)([A-Za-z@`~])$/);if(!o)return;let l=o[1]??"",s=o[2],a=l===""?[]:l.split(";").map(S=>parseInt(S,10)||0),m=a[0]??1,b=a[1]??1,y=i.width[t]??0,L=i.height[t]??0;switch(s){case "A":Wt(e,t,m);break;case "B":st(e,t,r,m);break;case "C":un(e,t,m,y);break;case "D":fn(e,t,m);break;case "E":i.cursorX[t]=0,st(e,t,r,m);break;case "F":i.cursorX[t]=0,Wt(e,t,m);break;case "G":i.cursorX[t]=Math.min(Math.max(m-1,0),y-1),oa(e,t);break;case "H":case "f":i.cursorY[t]=Math.min(Math.max(m-1,0),L-1),i.cursorX[t]=Math.min(Math.max(b-1,0),y-1),oa(e,t);break;case "J":pn(e,t,r,a[0]??0);break;case "K":dn(e,t,r,a[0]??0);break;case "m":In(r,a.length===0?[0]:a);break;case "h":ee(e,t,r,l,true);break;case "l":ee(e,t,r,l,false);break;case "s":r.savedCursorX=i.cursorX[t]??0,r.savedCursorY=i.cursorY[t]??0;break;case "u":i.cursorX[t]=r.savedCursorX,i.cursorY[t]=r.savedCursorY,oa(e,t);break}}function sn(e,t,r){i.cursorVisible[t]=r?1:0,oa(e,t);}function cn(e,t,r,n){n?(r.savedCursorX=i.cursorX[t]??0,r.savedCursorY=i.cursorY[t]??0,ne(e,t,r)):(oe(e,t,r),i.cursorX[t]=r.savedCursorX,i.cursorY[t]=r.savedCursorY),oa(e,t);}function an(e,t,r,n,o){o?(ne(e,t,r),n==="1047"&&le(r,0,r.buffer.cells.length)):oe(e,t,r),oa(e,t);}function ee(e,t,r,n,o){let l=n.startsWith("?")?n.slice(1):n;if(l==="25"){sn(e,t,o);return}if(l==="1049"){cn(e,t,r,o);return}if(l==="47"||l==="1047"){an(e,t,r,l,o);return}}function ne(e$1,t,r){if(i.altScreenActive[t]===1)return;let n=i.width[t]??0,o=i.height[t]??0;r.altBuffer||(r.altBuffer=k$2(n,o));for(let s=0;s<r.buffer.cells.length&&s<r.altBuffer.cells.length;s++){let a=r.buffer.cells[s];a&&(r.altBuffer.cells[s]=f$4(a));}let l=e();for(let s=0;s<r.buffer.cells.length;s++)r.buffer.cells[s]=f$4(l);i.cursorX[t]=0,i.cursorY[t]=0,i.altScreenActive[t]=1;}function oe(e,t,r){if(i.altScreenActive[t]!==0){if(r.altBuffer)for(let n=0;n<r.altBuffer.cells.length&&n<r.buffer.cells.length;n++){let o=r.altBuffer.cells[n];o&&(r.buffer.cells[n]=f$4(o));}i.altScreenActive[t]=0;}}function Wt(e,t,r){let n=i.cursorY[t]??0;i.cursorY[t]=Math.max(0,n-r),oa(e,t);}function st(e,t,r,n){let o=i.width[t]??0,l=i.height[t]??0,s=i.cursorY[t]??0;for(s+=n;s>=l;)Ft(r,o,l),s--;i.cursorY[t]=s,oa(e,t);}function un(e,t,r,n){let o=i.cursorX[t]??0;i.cursorX[t]=Math.min(n-1,o+r),oa(e,t);}function fn(e,t,r){let n=i.cursorX[t]??0;i.cursorX[t]=Math.max(0,n-r),oa(e,t);}function le(e$1,t,r){let n=e();for(let o=t;o<r;o++)e$1.buffer.cells[o]=f$4(n);}function se(e$1,t,r,n,o){let l=e();for(let s=n;s<=o;s++){let a=r*t+s;e$1.buffer.cells[a]=f$4(l);}}function ie(e$1,t,r,n){let o=e();for(let l=r;l<n;l++)for(let s=0;s<t;s++){let a=l*t+s;e$1.buffer.cells[a]=f$4(o);}}function mn(e,t,r,n,o){se(e,t,o,n,t-1),ie(e,t,o+1,r);}function bn(e,t,r,n){ie(e,t,0,n),se(e,t,n,0,r);}function pn(e,t,r,n){let o=i.width[t]??0,l=i.height[t]??0,s=i.cursorX[t]??0,a=i.cursorY[t]??0;n===0?mn(r,o,l,s,a):n===1?bn(r,o,s,a):(n===2||n===3)&&(le(r,0,r.buffer.cells.length),n===3&&f$3(r.scrollback)),oa(e,t);}function dn(e$1,t,r,n){let o=i.width[t]??0,l=i.cursorX[t]??0,s=i.cursorY[t]??0,a=e();switch(n){case 0:for(let m=l;m<o;m++){let b=s*o+m;r.buffer.cells[b]=f$4(a);}break;case 1:for(let m=0;m<=l;m++){let b=s*o+m;r.buffer.cells[b]=f$4(a);}break;case 2:for(let m=0;m<o;m++){let b=s*o+m;r.buffer.cells[b]=f$4(a);}break}oa(e$1,t);}function gn(e){return e.currentAttr=e$1(),1}function yn(e,t,r){let n=t[r]??0;return e.currentAttr.styles|=1<<n-1,1}function xn(e,t,r){let n=t[r]??0;return e.currentAttr.styles&=~(1<<n-22+1),1}function hn(e,t,r){let n=t[r]??0;return e.currentAttr.fg={type:1,value:n-30},1}function En(e){return e.currentAttr.fg={type:0,value:0},1}function Cn(e,t,r){let n=t[r]??0;return e.currentAttr.bg={type:1,value:n-40},1}function Ln(e){return e.currentAttr.bg={type:0,value:0},1}function Sn(e,t,r){let n=t[r]??0;return e.currentAttr.fg={type:1,value:n-90+8},1}function vn(e,t,r){let n=t[r]??0;return e.currentAttr.bg={type:1,value:n-100+8},1}function Tn(e){return e===0?gn:e>=1&&e<=9?yn:e>=22&&e<=29?xn:e>=30&&e<=37?hn:e===39?En:e>=90&&e<=97?Sn:e>=40&&e<=47?Cn:e===49?Ln:e>=100&&e<=107?vn:null}function An(e,t,r){let n=t[r]??0;if(n===38){let l=re(e,t,r,"fg");return l>0?l:1}if(n===48){let l=re(e,t,r,"bg");return l>0?l:1}let o=Tn(n);return o?o(e,t,r):1}function re(e,t,r,n){if(r+1>=t.length)return 0;let o=t[r+1];if(o===5&&r+2<t.length){let l=t[r+2]??0;return e.currentAttr[n]={type:2,value:l},3}if(o===2&&r+4<t.length){let l=t[r+2]??0,s=t[r+3]??0,a=t[r+4]??0;return e.currentAttr[n]={type:3,value:l<<16|s<<8|a},5}return 0}function In(e,t){let r=0;for(;r<t.length;){let n=An(e,t,r);r+=n;}}function wn(e$2,t){let r=C.get(t);if(!r)return;let n=e();for(let o=0;o<r.buffer.cells.length;o++)r.buffer.cells[o]=f$4(n);i.cursorX[t]=0,i.cursorY[t]=0,r.currentAttr=e$1(),oa(e$2,t);}function Wn(e,t){let r=C.get(t);r&&(wn(e,t),f$3(r.scrollback),r.escapeBuffer="",r.inEscape=false,r.savedCursorX=0,r.savedCursorY=0,r.savedAttr=e$1(),i.cursorVisible[t]=1,i.scrollOffset[t]=0,oa(e,t));}function as(e,t,r,n){let o=i.width[t]??0,l=i.height[t]??0;i.cursorX[t]=Math.min(Math.max(r,0),o-1),i.cursorY[t]=Math.min(Math.max(n,0),l-1),oa(e,t);}function us(e,t,r){i.cursorVisible[t]=r?1:0,oa(e,t);}function fs(e,t,r){let n=C.get(t);if(!n)return;let o=i.scrollOffset[t]??0,l=n.scrollback.totalLines;i.scrollOffset[t]=Math.min(o+r,l),oa(e,t);}function ms(e,t,r){let n=i.scrollOffset[t]??0;i.scrollOffset[t]=Math.max(0,n-r),oa(e,t);}function bs(e,t){let r=C.get(t);r&&(i.scrollOffset[t]=r.scrollback.totalLines,oa(e,t));}function ps(e,t){i.scrollOffset[t]=0,oa(e,t);}function ds(e,t,r,n){let o=C.get(t);if(!o)return;let l=i.width[t]??0,s=i.height[t]??0,a=k$2(r,n),m=Math.min(l,r),b=Math.min(s,n);for(let S=0;S<b;S++)for(let tt=0;tt<m;tt++){let ce=S*l+tt,ae=S*r+tt,Dt=o.buffer.cells[ce];Dt&&(a.cells[ae]=f$4(Dt));}o.buffer=a,i.width[t]=r,i.height[t]=n;let y=i.cursorX[t]??0,L=i.cursorY[t]??0;i.cursorX[t]=Math.min(y,r-1),i.cursorY[t]=Math.min(L,n-1),oa(e,t);}function gs(e){i.isTerminal[e]=0,i.width[e]=0,i.height[e]=0,i.cursorX[e]=0,i.cursorY[e]=0,i.cursorVisible[e]=0,i.scrollOffset[e]=0,i.altScreenActive[e]=0,C.delete(e);}function Fn(e,t,r){let n=j(e.scrollback,e.scrollback.totalLines-r,e.scrollback.totalLines-r+t),o="";for(let l of n.lines)o+=l.ansi??l.text,o+=`
|
|
3
|
+
`;return o}function Dn(e,t){let r="";return (e.fg!==t.fg||e.bg!==t.bg)&&(r+="\x1B[0m",t.fg=e.fg,t.bg=e.bg),r+=e.char,{output:r,fg:t.fg,bg:t.bg}}function ys(e){let t=C.get(e);if(!t)return "";let r=i.width[e]??0,n=i.height[e]??0,o=i.scrollOffset[e]??0;if(o>0)return Fn(t,n,o);let l="",s={fg:-1,bg:-1};for(let a=0;a<n;a++){for(let m=0;m<r;m++){let b=a*r+m,y=t.buffer.cells[b];if(!y)continue;let L=Dn(y,s);l+=L.output,s.fg=L.fg,s.bg=L.bg;}a<n-1&&(l+=`
|
|
4
|
+
`);}return l}function xs(e){return C.get(e)?.buffer.cells}function hs(){i.isTerminal.fill(0),i.width.fill(0),i.height.fill(0),i.cursorX.fill(0),i.cursorY.fill(0),i.cursorVisible.fill(0),i.scrollOffset.fill(0),i.altScreenActive.fill(0),C.clear();}export{ze as $,sl as $a,Pr as $b,Le as A,mr as Aa,Tl as Ab,Ct as B,br as Ba,Al as Bb,Se as C,pr as Ca,Il as Cb,Lt as D,dr as Da,wl as Db,ve as E,gr as Ea,Rr as Eb,zt as F,yr as Fa,Wl as Fb,Te as G,xr as Ga,Fl as Gb,Ae as H,hr as Ha,Dl as Hb,Ie as I,It as Ia,Bl as Ib,we as J,Er as Ja,_l as Jb,Et as K,Qt as Ka,kl as Kb,We as L,Cr as La,Ml as Lb,Fe as M,wt as Ma,Rl as Mb,De as N,Lr as Na,Ul as Nb,Be as O,Sr as Oa,Xl as Ob,_e as P,vr as Pa,Vl as Pb,ke as Q,lt as Qa,Pl as Qb,Me as R,Tr as Ra,Yl as Rb,Re as S,Ar as Sa,Nl as Sb,Ue as T,Ir as Ta,Ol as Tb,E as U,Kt as Ua,Gl as Ub,Pe as V,wr as Va,Hl as Vb,Ye as W,Wr as Wa,zl as Wb,Ne as X,Fr as Xa,Ql as Xb,Oe as Y,Br as Ya,Kl as Yb,Ge as Z,_r as Za,$l as Zb,He as _,kr as _a,jl as _b,h as a,Qe as aa,il as ab,Zl as ac,_n as b,Ke as ba,cl as bb,Jl as bc,kn as c,$e as ca,al as cb,Gr as cc,Mn as d,je as da,p as db,Hr as dc,Rn as e,Ze as ea,ul as eb,zr as ec,Un as f,St as fa,fl as fb,i as fc,Xn as g,qe as ga,ml as gb,Qr as gc,mt as h,N as ha,bl as hb,ls as hc,bt as i,vt as ia,pl as ib,Jr as ic,pt as j,ot as ja,dl as jb,ss as jc,dt as k,tr as ka,gl as kb,is as kc,gt as l,Tt as la,Mr as lb,rn as lc,yt as m,M as ma,yl as mb,cs as mc,xt as n,er as na,xl as nb,wn as nc,c as o,rr as oa,hl as ob,Wn as oc,k as p,nr as pa,$t as pb,as as pc,be as q,or as qa,jt as qb,us as qc,pe as r,lr as ra,Zt as rb,fs as rc,de as s,At as sa,Jt as sb,ms as sc,w as t,sr as ta,qt as tb,bs as tc,ge as u,ir as ua,te as ub,ps as uc,ye as v,cr as va,W as vb,ds as vc,xe as w,ar as wa,f as wb,gs as wc,he as x,ur as xa,Ll as xb,ys as xc,nt as y,R as ya,Sl as yb,xs as yc,Ce as z,fr as za,vl as zb,hs as zc};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {n,i,h,k}from'./chunk-PXXGH3BV.js';import {z}from'zod';var ie=z.enum(["braille","halfblock","sextant","sixel","kitty"]),Pt=z.object({maxColors:z.number().int().positive().describe("Max simultaneous colors"),supportsAlpha:z.boolean().describe("Whether backend supports alpha transparency"),pixelsPerCellX:z.number().int().positive().describe("Horizontal pixel resolution per terminal cell"),pixelsPerCellY:z.number().int().positive().describe("Vertical pixel resolution per terminal cell"),supportsAnimation:z.boolean().describe("Whether backend supports efficient frame updates"),requiresEscapeSequences:z.boolean().describe("True if output is raw escape sequences vs cell-based")}),ur=z.object({x:z.number().int().nonnegative(),y:z.number().int().nonnegative(),char:z.string().min(1).max(4),fg:z.number().int().nonnegative(),bg:z.number().int().nonnegative()}),kt=z.object({cells:z.array(ur).optional(),escape:z.string().optional(),cursorX:z.number().int().nonnegative().optional(),cursorY:z.number().int().nonnegative().optional()}).refine(e=>e.cells!==void 0||e.escape!==void 0,{message:"EncodedOutput must have either cells or escape"}),cr=z.union([ie,z.literal("auto")]),Se=z.object({threshold:z.number().int().min(0).max(255).default(128).describe("Alpha threshold: pixels with alpha >= threshold are lit"),colorMode:z.enum(["average","dominant","brightness"]).default("average").describe("How to pick fg color from the lit pixels in a 2x4 block"),backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),Ae=z.object({backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),Be=z.object({threshold:z.number().int().min(0).max(255).default(128).describe("Alpha threshold: pixels with alpha >= threshold are lit"),backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),we=z.object({maxColors:z.number().int().min(2).max(256).default(256).describe("Maximum palette colors"),rleEnabled:z.boolean().default(true).describe("Enable run-length encoding for repeated columns")}),Pe=z.object({imageId:z.number().int().positive().default(1).describe("Unique image ID for reuse"),chunkSize:z.number().int().positive().default(4096).describe("Max base64 bytes per chunk")}),ke=z.object({preferred:cr.default("auto"),fallback:ie.default("braille"),forceBackend:z.boolean().default(false).describe("Skip detection, use preferred directly")});var mr=10240,q=[1,8,2,16,4,32,64,128],lr=(()=>{let e=new Array(256);for(let r=0;r<256;r++)e[r]=String.fromCharCode(mr+r);return e})(),br=q[0],fr=q[1],pr=q[2],dr=q[3],xr=q[4],hr=q[5],yr=q[6],gr=q[7];function H(e,r,n,t,o){e[r+3]>=n&&(o.dotPattern|=t,o.rSum+=e[r],o.gSum+=e[r+1],o.bSum+=e[r+2],o.litCount++);}function Cr(e){if(e.litCount===0)return 0;let r=1/e.litCount;return (e.rSum*r+.5|0)<<16|(e.gSum*r+.5|0)<<8|(e.bSum*r+.5|0)}function De(e){let r=Se.parse(e??{}),n=r.threshold,t=r.backgroundColor;return {type:"braille",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:2,pixelsPerCellY:4,supportsAnimation:true,requiresEscapeSequences:false},encode(a,i,s){let u=Math.floor(a.width/2),c=Math.floor(a.height/4),m=u*c,l=new Array(m),b=a.colorBuffer,h=a.width*4,p={dotPattern:0,rSum:0,gSum:0,bSum:0,litCount:0},M=0;for(let S=0;S<c;S++){let F=S*4*h,v=F+h,j=v+h,W=j+h;for(let z=0;z<u;z++){let E=z*2*4;p.dotPattern=0,p.rSum=0,p.gSum=0,p.bSum=0,p.litCount=0,H(b,F+E,n,br,p),H(b,F+E+4,n,fr,p),H(b,v+E,n,pr,p),H(b,v+E+4,n,dr,p),H(b,j+E,n,xr,p),H(b,j+E+4,n,hr,p),H(b,W+E,n,yr,p),H(b,W+E+4,n,gr,p),l[M++]={x:i+z,y:s+S,char:lr[p.dotPattern]??"\u2800",fg:Cr(p),bg:t};}}return {cells:l}},getPixelDimensions(a,i){return {width:a*2,height:i*4}}}}var Mr="\u2580",Sr="\u2588";function Ee(e,r){return e[r]<<16|e[r+1]<<8|e[r+2]}function Ve(e,r){return e[r+3]===0}function Ar(e,r,n){return e===r?e===n?{char:" ",fg:n,bg:n}:{char:Sr,fg:e,bg:n}:{char:Mr,fg:e,bg:r}}function Fe(e){let n=Ae.parse(e??{}).backgroundColor;return {type:"halfblock",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:1,pixelsPerCellY:2,supportsAnimation:true,requiresEscapeSequences:false},encode(o,a,i){let s=o.width,u=Math.floor(o.height/2),c=[],m=o.colorBuffer,l=o.width;for(let b=0;b<u;b++)for(let d=0;d<s;d++){let h=(b*2*l+d)*4,p=((b*2+1)*l+d)*4,M=Ve(m,h)?n:Ee(m,h),S=Ve(m,p)?n:Ee(m,p),k=Ar(M,S,n);c.push({x:a+d,y:i+b,char:k.char,fg:k.fg,bg:k.bg});}return {cells:c}},getPixelDimensions(o,a){return {width:o,height:a*2}}}}var se="\x1B_G",ue="\x1B\\";function Br(e){if(typeof Buffer<"u")return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");let r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return btoa(r)}function wr(e,r){if(e.length<=r)return [e];let n=[];for(let t=0;t<e.length;t+=r)n.push(e.slice(t,t+r));return n}function Pr(e,r,n,t){if(e.length===0)return "";let o=[],a=e[0],i=e.length>1?1:0;o.push(`${se}a=t,f=32,s=${r},v=${n},i=${t},m=${i};${a}${ue}`);for(let s=1;s<e.length;s++){let u=s===e.length-1;o.push(`${se}m=${u?0:1};${e[s]}${ue}`);}return o.join("")}function kr(e,r){return `${se}a=p,i=${e},p=1,C=1;${ue}${se}a=d,d=i,i=${r};${ue}`}function me(e){let r=Pe.parse(e??{}),n=r.imageId,t=r.chunkSize,o={maxColors:16777216,supportsAlpha:true,pixelsPerCellX:1,pixelsPerCellY:1,supportsAnimation:true,requiresEscapeSequences:true},a=0,i=[n,n+1];return {type:"kitty",capabilities:o,encode(s,u,c){let m=s.width,l=s.height,b=Br(s.colorBuffer),d=wr(b,t),h=a;a=a===0?1:0;let p=i[a]??n,M=i[h]??n+1,S=Pr(d,m,l,p),k=kr(p,M);return {escape:S+k,cursorX:u,cursorY:c}},getPixelDimensions(s,u){return {width:s*8,height:u*16}}}}var Dr=129792,Er="\u2588";function Vr(e,r,n,t,o,a){for(let i=0;i<3;i++)for(let s=0;s<2;s++){let u=r+s,m=((n+i)*t+u)*4;if(e[m+3]>=o){let b=i*2+s;a.pattern|=1<<b,a.rSum+=e[m],a.gSum+=e[m+1],a.bSum+=e[m+2],a.litCount++;}}}function Fr(e){return e===0?" ":e===63?Er:String.fromCodePoint(Dr+e-1)}function Tr(e){if(e.litCount===0)return 0;let r=Math.round(e.rSum/e.litCount),n=Math.round(e.gSum/e.litCount),t=Math.round(e.bSum/e.litCount);return r<<16|n<<8|t}function le(e){let r=Be.parse(e??{}),n=r.threshold,t=r.backgroundColor;return {type:"sextant",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:2,pixelsPerCellY:3,supportsAnimation:true,requiresEscapeSequences:false},encode(a,i,s){let u=Math.floor(a.width/2),c=Math.floor(a.height/3),m=[],l=a.colorBuffer,b=a.width,d={pattern:0,rSum:0,gSum:0,bSum:0,litCount:0};for(let h=0;h<c;h++)for(let p=0;p<u;p++)d.pattern=0,d.rSum=0,d.gSum=0,d.bSum=0,d.litCount=0,Vr(l,p*2,h*3,b,n,d),m.push({x:i+p,y:s+h,char:Fr(d.pattern),fg:Tr(d),bg:t});return {cells:m}},getPixelDimensions(a,i){return {width:a*2,height:i*3}}}}var zr="\x1BPq",vr="\x1B\\";function jr(e,r){let n=new Map;for(let t=0;t<r;t++){let o=t*4;if(e[o+3]===0)continue;let i=e[o]<<16|e[o+1]<<8|e[o+2];n.set(i,(n.get(i)??0)+1);}return n}function Rr(e,r){let n=[];for(let a of e)n.push(a);n.sort((a,i)=>i[1]-a[1]);let t=Math.min(n.length,r)||1,o=new Uint8Array(t*3);for(let a=0;a<t;a++){let i=n[a];if(i){let s=i[0];o[a*3]=s>>16&255,o[a*3+1]=s>>8&255,o[a*3+2]=s&255;}}return {paletteFlat:o,paletteCount:t}}function Wr(e,r,n,t,o){let a=2147483647,i=0;for(let s=0;s<o;s++){let u=s*3,c=e-t[u],m=r-t[u+1],l=n-t[u+2],b=c*c+m*m+l*l;if(b<a&&(a=b,i=s,b===0))break}return i}function Ur(e,r,n,t,o){let a=o&&o.length===r?o:new Uint8Array(r);for(let i=0;i<r;i++){let s=i*4;if(e[s+3]===0){a[i]=0;continue}a[i]=Wr(e[s],e[s+1],e[s+2],n,t);}return a}function Ir(e,r,n){let t=e.colorBuffer,o=e.width*e.height,a=jr(t,o),{paletteFlat:i,paletteCount:s}=Rr(a,r),u=Ur(t,o,i,s,n);return {paletteFlat:i,paletteCount:s,indexMap:u}}function Lr(e,r,n){let t=false,o=0;for(;o<r;){let a=e[o],i=1;for(;o+i<r&&e[o+i]===a;)i++;let s=String.fromCharCode(63+a);if(a>0&&(t=true),i>=3)n.push("!",String(i),s);else for(let u=0;u<i;u++)n.push(s);o+=i;}return t}function Or(e,r){let n=[];for(let t=0;t<r;t++){let o=t*3,a=Math.round(e[o]/255*100),i=Math.round(e[o+1]/255*100),s=Math.round(e[o+2]/255*100);n.push("#",String(t),";2;",String(a),";",String(i),";",String(s));}return n}function Yr(e,r,n,t,o,a){let i=0;for(let s=0;s<t;s++){let u=(n+s)*o+a;e[u]===r&&(i|=1<<s);}return i}function Xr(e,r){let n=[],t=false;for(let o=0;o<r;o++){let a=e[o];a>0&&(t=true),n.push(String.fromCharCode(63+a));}return {chars:n,hasPixels:t}}function Te(e,r,n,t){if(t){e.push("#",String(r));for(let o of n)e.push(o);e.push("$");}}function _r(e,r,n,t,o,a,i,s){for(let u=0;u<o;u++)a[u]=Yr(e,r,n,t,o,u);if(i){let u=[],c=Lr(a,o,u);Te(s,r,u,c);}else {let{chars:u,hasPixels:c}=Xr(a,o);Te(s,r,u,c);}}function Hr(e,r,n,t,o,a,i){let s=Math.ceil(t/6);for(let u=0;u<s;u++){let c=u*6,m=Math.min(6,t-c);for(let l=0;l<r;l++)_r(e,l,c,m,n,o,a,i);u<s-1&&i.push("-");}}function be(e){let r=we.parse(e??{}),n=r.maxColors,t=r.rleEnabled,o={maxColors:n,supportsAlpha:false,pixelsPerCellX:1,pixelsPerCellY:1,supportsAnimation:false,requiresEscapeSequences:true},a=null,i=null;return {type:"sixel",capabilities:o,encode(s,u,c){let{paletteFlat:m,paletteCount:l,indexMap:b}=Ir(s,n,a);a=b;let d=s.width,h=s.height,p=[zr];return p.push(...Or(m,l)),(!i||i.length<d)&&(i=new Uint8Array(d)),Hr(b,l,d,h,i,t,p),p.push(vr),{escape:p.join(""),cursorX:u,cursorY:c}},getPixelDimensions(s,u){return {width:s*8,height:u*16}}}}function fe(e){switch(ie.parse(e),e){case "braille":return De();case "halfblock":return Fe();case "sextant":return le();case "sixel":return be();case "kitty":return me()}}function Ht(e,r){let n=ke.parse(r??{});if(n.forceBackend&&n.preferred!=="auto"||n.preferred!=="auto")return fe(n.preferred);let t=e.graphics;return t==="kitty"?me():t==="sixel"?be():e.truecolor?le():fe(n.fallback)}var ze=z.object({tx:z.number().default(0),ty:z.number().default(0),tz:z.number().default(0),rx:z.number().default(0),ry:z.number().default(0),rz:z.number().default(0),sx:z.number().default(1),sy:z.number().default(1),sz:z.number().default(1)}).describe("3D transform: translation (t), rotation in radians (r), scale (s)"),ve=z.object({fov:z.number().positive().max(Math.PI).default(Math.PI/3),near:z.number().positive().default(.1),far:z.number().positive().default(100),aspect:z.number().positive().default(16/9),projectionMode:z.enum(["perspective","orthographic"]).default("perspective")}).refine(e=>e.near<e.far,{message:"near must be less than far"}),je=z.object({wireColor:z.number().int().min(0).max(16777215).default(16777215),fillColor:z.number().int().min(0).max(16777215).default(8421504),renderMode:z.enum(["wireframe","filled","both"]).default("wireframe"),backfaceCull:z.boolean().default(true),flatShading:z.boolean().default(false),antiAlias:z.boolean().default(false)}).describe("3D material configuration"),Re=z.object({left:z.number().int().min(0).default(0),top:z.number().int().min(0).default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),cameraEntity:z.number().int().min(0),backendType:z.enum(["auto","braille","halfblock","sextant","sixel","kitty"]).default("auto")}).describe("3D viewport configuration"),Nt=z.object({rotateSpeed:z.object({x:z.number().default(0),y:z.number().default(0),z:z.number().default(0)}).default(()=>({x:0,y:0,z:0})).describe("Radians per second of continuous rotation"),orbitCenter:z.tuple([z.number(),z.number(),z.number()]).optional().describe("Point to orbit around"),orbitSpeed:z.number().default(0).describe("Radians per second of orbit"),orbitRadius:z.number().positive().optional().describe("Distance from orbit center")}).describe("3D animation configuration"),Kt=z.object({rotationSensitivity:z.number().positive().default(.01).describe("Radians per pixel of mouse movement"),zoomSensitivity:z.number().positive().default(.5).describe("Units per scroll tick"),zoomMin:z.number().positive().default(1),zoomMax:z.number().positive().default(100),invertY:z.boolean().default(false)}).describe("Mouse-based 3D camera interaction");n();var $=1e4,w={fov:new Float32Array($),near:new Float32Array($),far:new Float32Array($),aspect:new Float32Array($),projectionMode:new Uint8Array($),projMatrix:new Float32Array($*16),viewMatrix:new Float32Array($*16),dirty:new Uint8Array($)};function Qt(e,r,n){let t=ve.parse(n);return i(e,r,w)||h(e,r,w),w.fov[r]=t.fov,w.near[r]=t.near,w.far[r]=t.far,w.aspect[r]=t.aspect,w.projectionMode[r]=t.projectionMode==="orthographic"?1:0,w.dirty[r]=1,r}function en(e,r){if(i(e,r,w))return {fov:w.fov[r],near:w.near[r],far:w.far[r],aspect:w.aspect[r],projectionMode:w.projectionMode[r]===1?"orthographic":"perspective"}}function rn(e){let r=e*16;return w.projMatrix.subarray(r,r+16)}function tn(e){let r=e*16;return w.viewMatrix.subarray(r,r+16)}n();var ee=1e4,qr=0,We=1,Ue=2,P={wireColor:new Uint32Array(ee),fillColor:new Uint32Array(ee),renderMode:new Uint8Array(ee),backfaceCull:new Uint8Array(ee),flatShading:new Uint8Array(ee),antiAlias:new Uint8Array(ee)};function sn(e,r,n){let t=je.parse(n);return i(e,r,P)||h(e,r,P),P.wireColor[r]=t.wireColor,P.fillColor[r]=t.fillColor,t.renderMode==="filled"?P.renderMode[r]=We:t.renderMode==="both"?P.renderMode[r]=Ue:P.renderMode[r]=qr,P.backfaceCull[r]=t.backfaceCull?1:0,P.flatShading[r]=t.flatShading?1:0,P.antiAlias[r]=t.antiAlias?1:0,r}function un(e,r){if(!i(e,r,P))return;let n=P.renderMode[r],t="wireframe";return n===We?t="filled":n===Ue&&(t="both"),{wireColor:P.wireColor[r],fillColor:P.fillColor[r],renderMode:t,backfaceCull:P.backfaceCull[r]===1,flatShading:P.flatShading[r]===1,antiAlias:P.antiAlias[r]===1}}n();var $r=1e4,N={meshId:new Uint32Array($r)},Ie=1,ne=new Map;function Nr(e,r,n,t){let o=Ie++;return ne.set(o,{name:e,vertices:r,vertexCount:Math.floor(r.length/3),indices:n,triangleCount:Math.floor(n.length/3),normals:t}),o}function ln(e,r,n){let t=new Float32Array(r.length*3);for(let i=0;i<r.length;i++){let s=r[i];s&&(t[i*3]=s.x,t[i*3+1]=s.y,t[i*3+2]=s.z);}let o=[];for(let i of n)if(!(i.length<3))for(let s=1;s<i.length-1;s++)o.push(i[0],i[s],i[s+1]);let a=new Uint32Array(o);return Nr(e,t,a)}function Le(e){return ne.get(e)}function bn(e){return ne.delete(e)}function fn(e,r,n){return i(e,r,N)||h(e,r,N),N.meshId[r]=n,r}function pn(e,r){if(i(e,r,N))return N.meshId[r]}function dn(){return ne.size}function xn(){ne.clear(),Ie=1;}n();var Y=1e4,f={tx:new Float32Array(Y),ty:new Float32Array(Y),tz:new Float32Array(Y),rx:new Float32Array(Y),ry:new Float32Array(Y),rz:new Float32Array(Y),sx:new Float32Array(Y),sy:new Float32Array(Y),sz:new Float32Array(Y),worldMatrix:new Float32Array(Y*16),dirty:new Uint8Array(Y)};function Cn(e,r,n){let t=ze.parse(n);return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.tx[r]=t.tx,f.ty[r]=t.ty,f.tz[r]=t.tz,f.rx[r]=t.rx,f.ry[r]=t.ry,f.rz[r]=t.rz,f.sx[r]=t.sx,f.sy[r]=t.sy,f.sz[r]=t.sz,f.dirty[r]=1,r}function Mn(e,r){if(i(e,r,f))return {tx:f.tx[r],ty:f.ty[r],tz:f.tz[r],rx:f.rx[r],ry:f.ry[r],rz:f.rz[r],sx:f.sx[r],sy:f.sy[r],sz:f.sz[r]}}function Sn(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.tx[r]=n,f.ty[r]=t,f.tz[r]=o,f.dirty[r]=1,r}function An(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.rx[r]=n,f.ry[r]=t,f.rz[r]=o,f.dirty[r]=1,r}function Bn(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.sx[r]=n,f.sy[r]=t,f.sz[r]=o,f.dirty[r]=1,r}function wn(e){let r=e*16;return f.worldMatrix.subarray(r,r+16)}function Pn(e){f.dirty[e]=1;}function kn(e){return f.dirty[e]===1}n();var K=1e4,pe=0,Oe=1,Ye=2,Xe=3,_e=4,He=5,A={left:new Uint16Array(K),top:new Uint16Array(K),width:new Uint16Array(K),height:new Uint16Array(K),cameraEntity:new Uint32Array(K),backendType:new Uint8Array(K),pixelWidth:new Uint16Array(K),pixelHeight:new Uint16Array(K)},Kr={auto:pe,braille:Oe,halfblock:Ye,sextant:Xe,sixel:_e,kitty:He},Gr={[pe]:"auto",[Oe]:"braille",[Ye]:"halfblock",[Xe]:"sextant",[_e]:"sixel",[He]:"kitty"};function Fn(e,r,n){let t=Re.parse(n);return i(e,r,A)||h(e,r,A),A.left[r]=t.left,A.top[r]=t.top,A.width[r]=t.width,A.height[r]=t.height,A.cameraEntity[r]=t.cameraEntity,A.backendType[r]=Kr[t.backendType]??pe,r}function Tn(e,r){if(i(e,r,A))return {left:A.left[r],top:A.top[r],width:A.width[r],height:A.height[r],cameraEntity:A.cameraEntity[r],backendType:Gr[A.backendType[r]]??"auto",pixelWidth:A.pixelWidth[r],pixelHeight:A.pixelHeight[r]}}var de=z.tuple([z.number().finite(),z.number().finite(),z.number().finite()]),jn=z.union([de,z.object({x:z.number().finite(),y:z.number().finite(),z:z.number().finite()})]),Rn=z.instanceof(Float32Array).refine(e=>e.length===16,{message:"Mat4 must be Float32Array of length 16"}),Wn=z.object({x:z.number().finite().describe("Rotation around X axis in radians"),y:z.number().finite().describe("Rotation around Y axis in radians"),z:z.number().finite().describe("Rotation around Z axis in radians")}),qe=z.object({fov:z.number().positive().max(Math.PI).describe("Field of view in radians"),aspect:z.number().positive().describe("Width / height ratio"),near:z.number().positive().describe("Near clipping plane"),far:z.number().positive().describe("Far clipping plane")}).refine(e=>e.near<e.far,{message:"Near plane must be less than far plane"}),$e=z.object({left:z.number().finite(),right:z.number().finite(),bottom:z.number().finite(),top:z.number().finite(),near:z.number().finite(),far:z.number().finite()}).refine(e=>e.left<e.right&&e.bottom<e.top&&e.near<e.far,{message:"Invalid orthographic bounds: left < right, bottom < top, near < far required"}),xe=z.object({x:z.number().int().nonnegative(),y:z.number().int().nonnegative(),width:z.number().int().positive(),height:z.number().int().positive()}),Un=z.object({xMin:z.number().finite(),xMax:z.number().finite(),yMin:z.number().finite(),yMax:z.number().finite()}).refine(e=>e.xMin<e.xMax&&e.yMin<e.yMax,{message:"Invalid clip rectangle: xMin < xMax and yMin < yMax required"});function T(e,r,n){let t=new Float32Array(3);return t[0]=e,t[1]=r,t[2]=n,t}function On(e){let r=de.parse(e);return T(r[0],r[1],r[2])}function Yn(e,r){return T(e[0]+r[0],e[1]+r[1],e[2]+r[2])}function he(e,r){return T(e[0]-r[0],e[1]-r[1],e[2]-r[2])}function Xn(e,r){return T(e[0]*r,e[1]*r,e[2]*r)}function _n(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]}function ye(e,r){let n=e[0],t=e[1],o=e[2],a=r[0],i=r[1],s=r[2];return T(t*s-o*i,o*a-n*s,n*i-t*a)}function Zr(e){let r=e[0],n=e[1],t=e[2];return r*r+n*n+t*t}function Ne(e){return Math.sqrt(Zr(e))}function ge(e){let r=Ne(e);if(r===0)return T(0,0,0);let n=1/r;return T(e[0]*n,e[1]*n,e[2]*n)}function Hn(e,r,n){let t=Math.max(0,Math.min(1,n)),o=1-t;return T(e[0]*o+r[0]*t,e[1]*o+r[1]*t,e[2]*o+r[2]*t)}function qn(e){return T(-e[0],-e[1],-e[2])}function $n(e,r){return Ne(he(e,r))}function Nn(e,r,n=1e-6){return Math.abs(e[0]-r[0])<=n&&Math.abs(e[1]-r[1])<=n&&Math.abs(e[2]-r[2])<=n}function Kn(){return T(0,0,0)}function G(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function X(e,r){let n=new Float32Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++){let a=t*4+o;n[a]=e[o]*r[t*4]+e[4+o]*r[t*4+1]+e[8+o]*r[t*4+2]+e[12+o]*r[t*4+3];}return n}function Jr(e,r,n,t){let o=G();return o[12]=r,o[13]=n,o[14]=t,X(e,o)}function Qr(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[5]=n,o[6]=t,o[9]=-t,o[10]=n,X(e,o)}function et(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[0]=n,o[2]=-t,o[8]=t,o[10]=n,X(e,o)}function rt(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[0]=n,o[1]=t,o[4]=-t,o[5]=n,X(e,o)}function tt(e,r,n,t){let o=G();return o[0]=r,o[5]=n,o[10]=t,X(e,o)}function Jn(e){let r=new Float32Array(16);for(let n=0;n<4;n++)for(let t=0;t<4;t++)r[n*4+t]=e[t*4+n];return r}function Qn(e){let r=e[0],n=e[1],t=e[2],o=e[3],a=e[4],i=e[5],s=e[6],u=e[7],c=e[8],m=e[9],l=e[10],b=e[11],d=e[12],h=e[13],p=e[14],M=e[15],S=r*i-n*a,k=r*s-t*a,F=r*u-o*a,v=n*s-t*i,j=n*u-o*i,W=t*u-o*s,z=c*h-m*d,E=c*p-l*d,U=c*M-b*d,I=m*p-l*h,L=m*M-b*h,O=l*M-b*p;return S*O-k*L+F*I+v*U-j*E+W*z}function Ke(e){let r=e[0],n=e[1],t=e[2],o=e[3],a=e[4],i=e[5],s=e[6],u=e[7],c=e[8],m=e[9],l=e[10],b=e[11],d=e[12],h=e[13],p=e[14],M=e[15],S=r*i-n*a,k=r*s-t*a,F=r*u-o*a,v=n*s-t*i,j=n*u-o*i,W=t*u-o*s,z=c*h-m*d,E=c*p-l*d,U=c*M-b*d,I=m*p-l*h,L=m*M-b*h,O=l*M-b*p,ae=S*O-k*L+F*I+v*U-j*E+W*z;if(Math.abs(ae)<1e-10)return null;let D=1/ae,V=new Float32Array(16);return V[0]=(i*O-s*L+u*I)*D,V[1]=(t*L-n*O-o*I)*D,V[2]=(h*W-p*j+M*v)*D,V[3]=(l*j-m*W-b*v)*D,V[4]=(s*U-a*O-u*E)*D,V[5]=(r*O-t*U+o*E)*D,V[6]=(p*F-d*W-M*k)*D,V[7]=(c*W-l*F+b*k)*D,V[8]=(a*L-i*U+u*z)*D,V[9]=(n*U-r*L-o*z)*D,V[10]=(d*j-h*F+M*S)*D,V[11]=(m*F-c*j-b*S)*D,V[12]=(i*E-a*I-s*z)*D,V[13]=(r*I-n*E+t*z)*D,V[14]=(h*k-d*v-p*S)*D,V[15]=(c*v-m*k+l*S)*D,V}function Ce(e,r){let n=r[0],t=r[1],o=r[2],a=e[3]*n+e[7]*t+e[11]*o+e[15],i=a!==0?1/a:1;return T((e[0]*n+e[4]*t+e[8]*o+e[12])*i,(e[1]*n+e[5]*t+e[9]*o+e[13])*i,(e[2]*n+e[6]*t+e[10]*o+e[14])*i)}function eo(e,r){let n=r[0],t=r[1],o=r[2];return T(e[0]*n+e[4]*t+e[8]*o,e[1]*n+e[5]*t+e[9]*o,e[2]*n+e[6]*t+e[10]*o)}function ro(e,r,n){let t=G();return t=Jr(t,e[0],e[1],e[2]),t=Qr(t,r[0]),t=et(t,r[1]),t=rt(t,r[2]),t=tt(t,n[0],n[1],n[2]),t}function to(e,r=1e-6){for(let n=0;n<4;n++)for(let t=0;t<4;t++){let o=n*4+t,a=n===t?1:0;if(Math.abs(e[o]-a)>r)return false}return true}function no(e,r,n=1e-5){for(let t=0;t<16;t++)if(Math.abs(e[t]-r[t])>n)return false;return true}function Ge(e){let r=qe.parse(e),{fov:n,aspect:t,near:o,far:a}=r,i=1/Math.tan(n/2),s=1/(o-a),u=new Float32Array(16);return u[0]=i/t,u[5]=i,u[10]=(o+a)*s,u[11]=-1,u[14]=2*o*a*s,u}function Ze(e){let r=$e.parse(e),{left:n,right:t,bottom:o,top:a,near:i,far:s}=r,u=1/(n-t),c=1/(o-a),m=1/(i-s),l=new Float32Array(16);return l[0]=-2*u,l[5]=-2*c,l[10]=2*m,l[12]=(n+t)*u,l[13]=(a+o)*c,l[14]=(s+i)*m,l[15]=1,l}function uo(e,r,n){let t=ge(he(e,r)),o=ge(ye(n,t)),a=ye(t,o),i=G();return i[0]=o[0],i[4]=o[1],i[8]=o[2],i[1]=a[0],i[5]=a[1],i[9]=a[2],i[2]=t[0],i[6]=t[1],i[10]=t[2],i[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),i[13]=-(a[0]*e[0]+a[1]*e[1]+a[2]*e[2]),i[14]=-(t[0]*e[0]+t[1]*e[1]+t[2]*e[2]),i}function Je(e){let r=xe.parse(e),{x:n,y:t,width:o,height:a}=r,i=o/2,s=a/2;return u=>({x:u[0]*i+(n+i),y:-u[1]*s+(t+s),depth:(u[2]+1)/2})}function co(e,r){return Ce(e,r)}function mo(e,r,n){let t=xe.parse(n),{x:o,y:a,width:i,height:s}=t,u=(r[0]-o)/i*2-1,c=-((r[1]-a)/s*2-1),m=r[2]*2-1,l=T(u,c,m);return Ce(e,l)}function lo(e,r,n){return X(n,X(r,e))}var Qe=z.object({width:z.number().int().positive().max(4096).describe("Buffer width in pixels"),height:z.number().int().positive().max(4096).describe("Buffer height in pixels"),enableDepthBuffer:z.boolean().default(true)}),po=z.object({x:z.number(),y:z.number(),depth:z.number().min(0).max(1).optional(),r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255),a:z.number().int().min(0).max(255).default(255)}),er=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),a:z.number().int().min(0).max(255).default(255)}),xo=z.object({x:z.number(),y:z.number(),depth:z.number().min(0).max(1),r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255),a:z.number().int().min(0).max(255).default(255)}),ho=z.object({direction:z.tuple([z.number(),z.number(),z.number()]).describe("Normalized light direction"),intensity:z.number().min(0).max(1).default(1),color:er.optional()}),yo=z.object({intensity:z.number().min(0).max(1).default(.1),color:er.optional()});function rr(e){let r=Qe.parse(e),{width:n,height:t,enableDepthBuffer:o}=r,a=n*t,i=new Uint8ClampedArray(a*4),s=o?new Float32Array(a):null;return s&&s.fill(1),{width:n,height:t,colorBuffer:i,depthBuffer:s}}function tr(e,r,n){let t=e.colorBuffer;if(!r||r.r===0&&r.g===0&&r.b===0&&r.a===0)t.fill(0);else {let o=r.r,a=r.g,i=r.b,s=r.a;for(let u=0;u<t.length;u+=4)t[u]=o,t[u+1]=a,t[u+2]=i,t[u+3]=s;}e.depthBuffer&&e.depthBuffer.fill(n??1);}function Z(e,r,n){return r>=0&&r<e.width&&n>=0&&n<e.height}function Mo(e,r,n){if(!Z(e,r,n))return {r:0,g:0,b:0,a:0};let t=(n*e.width+r)*4;return {r:e.colorBuffer[t],g:e.colorBuffer[t+1],b:e.colorBuffer[t+2],a:e.colorBuffer[t+3]}}function So(e,r,n,t){if(!Z(e,r,n))return;let o=(n*e.width+r)*4;e.colorBuffer[o]=t.r,e.colorBuffer[o+1]=t.g,e.colorBuffer[o+2]=t.b,e.colorBuffer[o+3]=t.a;}function Q(e,r,n,t,o,a,i){let s=(n*e.width+r)*4;e.colorBuffer[s]=t,e.colorBuffer[s+1]=o,e.colorBuffer[s+2]=a,e.colorBuffer[s+3]=i;}function Ao(e,r,n){if(!e.depthBuffer||!Z(e,r,n))return 1;let t=n*e.width+r;return e.depthBuffer[t]}function re(e,r,n,t){if(!e.depthBuffer||!Z(e,r,n))return false;let o=n*e.width+r;return t<e.depthBuffer[o]?(e.depthBuffer[o]=t,true):false}function Bo(e,r,n,t,o,a){let i=Math.max(0,Math.floor(r)),s=Math.max(0,Math.floor(n)),u=Math.min(e.width,Math.floor(r+t)),c=Math.min(e.height,Math.floor(n+o));for(let m=s;m<c;m++)for(let l=i;l<u;l++){let b=(m*e.width+l)*4;e.colorBuffer[b]=a.r,e.colorBuffer[b+1]=a.g,e.colorBuffer[b+2]=a.b,e.colorBuffer[b+3]=a.a;}}function nr(e,r,n,t,o,a,i){if(e.x===r&&e.y===n)return true;let s=2*e.err;return s>-o&&(e.err-=o,e.x+=a),s<t&&(e.err+=t,e.y+=i),e.step++,false}function nt(e,r,n,t,o,a,i,s){Z(e,r,n)&&re(e,r,n,t)&&Q(e,r,n,o,a,i,s);}function ot(e,r,n,t,o,a,i,s,u){return {r:Math.round(e+(o-e)*u),g:Math.round(r+(a-r)*u),b:Math.round(n+(i-n)*u),a:Math.round(t+(s-t)*u)}}function at(e,r,n,t,o){return !o||!e.depthBuffer?true:re(e,r,n,t)}function it(e,r,n,t,o,a){let i=ot(t.r,t.g,t.b,t.a??255,o.r,o.g,o.b,o.a??255,a);Q(e,r,n,i.r,i.g,i.b,i.a);}function ko(e,r,n,t,o,a,i,s,u=255){let c=Math.round(r),m=Math.round(n),l=Math.round(t),b=Math.round(o),d=Math.abs(l-c),h=Math.abs(b-m),p=c<l?1:-1,M=m<b?1:-1,S=d-h;for(;Z(e,c,m)&&Q(e,c,m,a,i,s,u),!(c===l&&m===b);){let k=2*S;k>-h&&(S-=h,c+=p),k<d&&(S+=d,m+=M);}}function or(e,r,n){let t=Math.round(n.x),o=Math.round(n.y),a={x:Math.round(r.x),y:Math.round(r.y),err:0,step:0},i=Math.abs(t-a.x),s=Math.abs(o-a.y),u=a.x<t?1:-1,c=a.y<o?1:-1;a.err=i-s;let m=Math.max(i,s),l=m>0?1/m:0,b=r.depth??0,d=n.depth??0,h=r.r,p=r.g,M=r.b,S=r.a??255;for(;;){let k=a.step*l,F=b+(d-b)*k;if(nt(e,a.x,a.y,F,h,p,M,S),nr(a,t,o,i,s,u,c))break}}function Do(e,r,n){let t=Math.round(n.x),o=Math.round(n.y),a={x:Math.round(r.x),y:Math.round(r.y),err:0,step:0},i=Math.abs(t-a.x),s=Math.abs(o-a.y),u=a.x<t?1:-1,c=a.y<o?1:-1;a.err=i-s;let m=Math.max(i,s),l=m>0?1/m:0,b=r.depth??0,d=n.depth??0,h=r.depth!==void 0||n.depth!==void 0;for(;;){if(Z(e,a.x,a.y)){let p=a.step*l,M=b+(d-b)*p;at(e,a.x,a.y,M,h)&&it(e,a.x,a.y,r,n,p);}if(nr(a,t,o,i,s,u,c))break}}function ar(e,r,n,t){let o=ct(r,n,t);if(Math.abs(o)<.5)return null;let a=1/o,i=Math.max(0,Math.floor(Math.min(r.x,n.x,t.x))),s=Math.max(0,Math.floor(Math.min(r.y,n.y,t.y))),u=Math.min(e.width-1,Math.ceil(Math.max(r.x,n.x,t.x))),c=Math.min(e.height-1,Math.ceil(Math.max(r.y,n.y,t.y)));if(i>u||s>c)return null;let m=i+.5,l=s+.5;return {invArea:a,minX:i,minY:s,maxX:u,maxY:c,A01:(n.y-t.y)*a,B01:(t.x-n.x)*a,A12:(t.y-r.y)*a,B12:(r.x-t.x)*a,hasDepth:e.depthBuffer!==null&&e.depthBuffer!==void 0,startW0:((n.y-t.y)*(m-t.x)+(t.x-n.x)*(l-t.y))*a,startW1:((t.y-r.y)*(m-t.x)+(r.x-t.x)*(l-t.y))*a}}function st(e,r,n,t,o,a,i,s,u,c,m,l){let b=1-t-o;if(t<0||o<0||b<0)return;let d=a.depth*t+i.depth*o+s.depth*b;if(l&&!re(e,r,n,d))return;let h=a.r*t+i.r*o+s.r*b+.5|0,p=a.g*t+i.g*o+s.g*b+.5|0,M=a.b*t+i.b*o+s.b*b+.5|0,S=u*t+c*o+m*b+.5|0;Q(e,r,n,h,p,M,S);}function ut(e,r,n,t,o,a,i,s,u,c){let m=1-t-o;if(t<0||o<0||m<0)return;let l=a.depth*t+i.depth*o+s.depth*m;c&&!re(e,r,n,l)||Q(e,r,n,u.r,u.g,u.b,u.a);}function ct(e,r,n){return (r.x-e.x)*(n.y-e.y)-(n.x-e.x)*(r.y-e.y)}function Fo(e,r,n){return {minX:Math.min(e.x,r.x,n.x),minY:Math.min(e.y,r.y,n.y),maxX:Math.max(e.x,r.x,n.x),maxY:Math.max(e.y,r.y,n.y)}}function To(e,r,n,t){let o=ar(e,r,n,t);if(!o)return;let a=r.a??255,i=n.a??255,s=t.a??255,u=o.startW0,c=o.startW1;for(let m=o.minY;m<=o.maxY;m++){let l=u,b=c;for(let d=o.minX;d<=o.maxX;d++)st(e,d,m,l,b,r,n,t,a,i,s,o.hasDepth),l+=o.A01,b+=o.A12;u+=o.B01,c+=o.B12;}}function ir(e,r,n,t,o){let a=ar(e,r,n,t);if(!a)return;let i=a.startW0,s=a.startW1;for(let u=a.minY;u<=a.maxY;u++){let c=i,m=s;for(let l=a.minX;l<=a.maxX;l++)ut(e,l,u,c,m,r,n,t,o,a.hasDepth),c+=a.A01,m+=a.A12;i+=a.B01,s+=a.B12;}}var jo=z.object({left:z.number().int().nonnegative().default(0),top:z.number().int().nonnegative().default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),fov:z.number().positive().max(Math.PI).default(Math.PI/3),near:z.number().positive().default(.1),far:z.number().positive().default(1e3),projectionMode:z.enum(["perspective","orthographic"]).default("perspective"),backend:z.enum(["auto","braille","halfblock","sextant","sixel","kitty"]).default("auto"),label:z.string().optional()}).refine(e=>e.near<e.far,{message:"Near plane must be less than far plane"});n();var ce=new Float32Array(3),oe=new Map;function _o(){oe.clear();}function mt(e){let r=w.projectionMode[e],n=w.fov[e],t=w.near[e],o=w.far[e],a=w.aspect[e];if(r===1){let i=n,s=i*a;return Ze({left:-s,right:s,bottom:-i,top:i,near:t,far:o})}return Ge({fov:n,aspect:a,near:t,far:o})}function lt(e){let r=e*16,n=f.worldMatrix.subarray(r,r+16);return Ke(n)}function bt(e,r,n,t,o){let a=t[0],i=t[1],s=t[2],u=t[3],c=t[4],m=t[5],l=t[6],b=t[7],d=t[8],h=t[9],p=t[10],M=t[11],S=t[12],k=t[13],F=t[14],v=t[15],j=a*e+c*r+d*n+S,W=i*e+m*r+h*n+k,z=s*e+l*r+p*n+F,E=u*e+b*r+M*n+v,U=E!==0?1/E:0,I=j*U,L=W*U,O=z*U,ae=I>=-1&&I<=1&&L>=-1&&L<=1&&O>=-1&&O<=1;ce[0]=I,ce[1]=L,ce[2]=O;let D=o(ce);return {x:D.x,y:D.y,depth:D.depth,visible:ae}}function ft(e,r,n){let t=N.meshId[e],o=Le(t);if(!o)return null;let a=e*16,i=f.worldMatrix.subarray(a,a+16),s=X(r,i),u=o.vertexCount,c=new Array(u),m=o.vertices;for(let l=0;l<u;l++){let b=l*3;c[l]=bt(m[b],m[b+1],m[b+2],s,n);}return {meshEid:e,projectedVertices:c,triangleIndices:o.indices,mvpMatrix:s}}function pt(e,r){return i(e,r,w)&&i(e,r,f)}function dt(e,r,n){let t=A.cameraEntity[r];if(!pt(e,t))return null;let o=mt(t),a=lt(t);if(!a)return null;let i=X(o,a),s=A.pixelWidth[r],u=A.pixelHeight[r],c=Je({x:0,y:0,width:s,height:u}),m=[];for(let l of n){let b=ft(l,i,c);b&&m.push(b);}return {viewportEid:r,cameraEid:t,meshes:m,vpMatrix:i,pixelWidth:s,pixelHeight:u}}var Ho=e=>{oe.clear();let r=k(e,[A]),n=k(e,[N,f]);for(let t of r){let o=dt(e,t,n);o&&oe.set(t,o);}return e};n();var Me=new Map;function ea(){Me.clear();}function sr(e){return {r:e>>16&255,g:e>>8&255,b:e&255,a:255}}function xt(e,r,n){let t=Me.get(e);if(t&&t.width===r&&t.height===n)return t;let o=rr({width:r,height:n,enableDepthBuffer:true});return Me.set(e,o),o}function ht(e){let r=new Set,n=[];for(let t=0;t<e.length;t+=3){let o=e[t],a=e[t+1],i=e[t+2],s=[[o,a],[a,i],[i,o]];for(let[u,c]of s){let m=u<c?`${u}_${c}`:`${c}_${u}`;r.has(m)||(r.add(m),n.push([u,c]));}}return n}function yt(e,r){return i(e,r,P)?{renderMode:P.renderMode[r],wireColor:P.wireColor[r],fillColor:P.fillColor[r],backfaceCull:P.backfaceCull[r]!==0}:{renderMode:0,wireColor:16777215,fillColor:8421504,backfaceCull:true}}function gt(e,r,n){return (r.x-e.x)*(n.y-e.y)-(r.y-e.y)*(n.x-e.x)>0}function Ct(e,r,n,t,o){ir(e,{x:r.x,y:r.y,depth:r.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:n.x,y:n.y,depth:n.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:t.x,y:t.y,depth:t.depth,r:o.r,g:o.g,b:o.b,a:o.a},o);}function Mt(e,r,n,t,o){let a=sr(t);for(let i=0;i<n.length;i+=3){let s=r[n[i]],u=r[n[i+1]],c=r[n[i+2]];!s||!u||!c||o&&!gt(s,u,c)||Ct(e,s,u,c,a);}}function St(e,r,n,t){let o=sr(t),a=ht(n);for(let[i,s]of a){let u=r[i],c=r[s];!u||!c||or(e,{x:Math.round(u.x),y:Math.round(u.y),depth:u.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:Math.round(c.x),y:Math.round(c.y),depth:c.depth,r:o.r,g:o.g,b:o.b,a:o.a});}}function At(e,r,n,t,o){let a=yt(e,n),i=a.renderMode===1||a.renderMode===2,s=a.renderMode===0||a.renderMode===2;i&&Mt(r,t,o,a.fillColor,a.backfaceCull),s&&St(r,t,o,a.wireColor);}function Bt(e,r){let n=oe.get(r);if(!n)return;let t=n.pixelWidth,o=n.pixelHeight;if(t<=0||o<=0)return;let a=xt(r,t,o);tr(a);for(let i of n.meshes)At(e,a,i.meshEid,i.projectedVertices,i.triangleIndices);}var ra=e=>{let r=k(e,[A]);for(let n of r)Bt(e,n);return e};export{de as $,Mo as $a,en as A,et as Aa,rn as B,rt as Ba,tn as C,tt as Ca,P as D,Jn as Da,sn as E,Qn as Ea,un as F,Ke as Fa,N as G,Ce as Ga,Nr as H,eo as Ha,ln as I,ro as Ia,Le as J,to as Ja,bn as K,no as Ka,fn as L,Ge as La,pn as M,Ze as Ma,dn as N,uo as Na,xn as O,Je as Oa,f as P,co as Pa,Cn as Q,mo as Qa,Mn as R,lo as Ra,Sn as S,Qe as Sa,An as T,po as Ta,Bn as U,er as Ua,wn as V,xo as Va,Pn as W,ho as Wa,kn as X,yo as Xa,A as Y,rr as Ya,Fn as Z,tr as Za,Tn as _,Z as _a,ie as a,jn as aa,So as ab,Pt as b,Rn as ba,Q as bb,ur as c,Wn as ca,Ao as cb,kt as d,qe as da,re as db,cr as e,$e as ea,Bo as eb,Se as f,xe as fa,ko as fb,Ae as g,Un as ga,or as gb,Be as h,T as ha,Do as hb,we as i,On as ia,ct as ib,Pe as j,Yn as ja,Fo as jb,ke as k,he as ka,To as kb,De as l,Xn as la,ir as lb,Fe as m,_n as ma,jo as mb,me as n,ye as na,oe as nb,le as o,Zr as oa,_o as ob,be as p,Ne as pa,Ho as pb,fe as q,ge as qa,Me as qb,Ht as r,Hn as ra,ea as rb,ze as s,qn as sa,ra as sb,ve as t,$n as ta,je as u,Nn as ua,Re as v,Kn as va,Nt as w,G as wa,Kt as x,X as xa,w as y,Jr as ya,Qt as z,Qr as za};
|
|
1
|
+
import {n,i,h,k}from'./chunk-P3ZLIQJP.js';import {z}from'zod';var ie=z.enum(["braille","halfblock","sextant","sixel","kitty"]),Pt=z.object({maxColors:z.number().int().positive().describe("Max simultaneous colors"),supportsAlpha:z.boolean().describe("Whether backend supports alpha transparency"),pixelsPerCellX:z.number().int().positive().describe("Horizontal pixel resolution per terminal cell"),pixelsPerCellY:z.number().int().positive().describe("Vertical pixel resolution per terminal cell"),supportsAnimation:z.boolean().describe("Whether backend supports efficient frame updates"),requiresEscapeSequences:z.boolean().describe("True if output is raw escape sequences vs cell-based")}),ur=z.object({x:z.number().int().nonnegative(),y:z.number().int().nonnegative(),char:z.string().min(1).max(4),fg:z.number().int().nonnegative(),bg:z.number().int().nonnegative()}),kt=z.object({cells:z.array(ur).optional(),escape:z.string().optional(),cursorX:z.number().int().nonnegative().optional(),cursorY:z.number().int().nonnegative().optional()}).refine(e=>e.cells!==void 0||e.escape!==void 0,{message:"EncodedOutput must have either cells or escape"}),cr=z.union([ie,z.literal("auto")]),Se=z.object({threshold:z.number().int().min(0).max(255).default(128).describe("Alpha threshold: pixels with alpha >= threshold are lit"),colorMode:z.enum(["average","dominant","brightness"]).default("average").describe("How to pick fg color from the lit pixels in a 2x4 block"),backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),Ae=z.object({backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),Be=z.object({threshold:z.number().int().min(0).max(255).default(128).describe("Alpha threshold: pixels with alpha >= threshold are lit"),backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),we=z.object({maxColors:z.number().int().min(2).max(256).default(256).describe("Maximum palette colors"),rleEnabled:z.boolean().default(true).describe("Enable run-length encoding for repeated columns")}),Pe=z.object({imageId:z.number().int().positive().default(1).describe("Unique image ID for reuse"),chunkSize:z.number().int().positive().default(4096).describe("Max base64 bytes per chunk")}),ke=z.object({preferred:cr.default("auto"),fallback:ie.default("braille"),forceBackend:z.boolean().default(false).describe("Skip detection, use preferred directly")});var mr=10240,q=[1,8,2,16,4,32,64,128],lr=(()=>{let e=new Array(256);for(let r=0;r<256;r++)e[r]=String.fromCharCode(mr+r);return e})(),br=q[0],fr=q[1],pr=q[2],dr=q[3],xr=q[4],hr=q[5],yr=q[6],gr=q[7];function H(e,r,n,t,o){e[r+3]>=n&&(o.dotPattern|=t,o.rSum+=e[r],o.gSum+=e[r+1],o.bSum+=e[r+2],o.litCount++);}function Cr(e){if(e.litCount===0)return 0;let r=1/e.litCount;return (e.rSum*r+.5|0)<<16|(e.gSum*r+.5|0)<<8|(e.bSum*r+.5|0)}function De(e){let r=Se.parse(e??{}),n=r.threshold,t=r.backgroundColor;return {type:"braille",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:2,pixelsPerCellY:4,supportsAnimation:true,requiresEscapeSequences:false},encode(a,i,s){let u=Math.floor(a.width/2),c=Math.floor(a.height/4),m=u*c,l=new Array(m),b=a.colorBuffer,h=a.width*4,p={dotPattern:0,rSum:0,gSum:0,bSum:0,litCount:0},M=0;for(let S=0;S<c;S++){let F=S*4*h,v=F+h,j=v+h,W=j+h;for(let z=0;z<u;z++){let E=z*2*4;p.dotPattern=0,p.rSum=0,p.gSum=0,p.bSum=0,p.litCount=0,H(b,F+E,n,br,p),H(b,F+E+4,n,fr,p),H(b,v+E,n,pr,p),H(b,v+E+4,n,dr,p),H(b,j+E,n,xr,p),H(b,j+E+4,n,hr,p),H(b,W+E,n,yr,p),H(b,W+E+4,n,gr,p),l[M++]={x:i+z,y:s+S,char:lr[p.dotPattern]??"\u2800",fg:Cr(p),bg:t};}}return {cells:l}},getPixelDimensions(a,i){return {width:a*2,height:i*4}}}}var Mr="\u2580",Sr="\u2588";function Ee(e,r){return e[r]<<16|e[r+1]<<8|e[r+2]}function Ve(e,r){return e[r+3]===0}function Ar(e,r,n){return e===r?e===n?{char:" ",fg:n,bg:n}:{char:Sr,fg:e,bg:n}:{char:Mr,fg:e,bg:r}}function Fe(e){let n=Ae.parse(e??{}).backgroundColor;return {type:"halfblock",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:1,pixelsPerCellY:2,supportsAnimation:true,requiresEscapeSequences:false},encode(o,a,i){let s=o.width,u=Math.floor(o.height/2),c=[],m=o.colorBuffer,l=o.width;for(let b=0;b<u;b++)for(let d=0;d<s;d++){let h=(b*2*l+d)*4,p=((b*2+1)*l+d)*4,M=Ve(m,h)?n:Ee(m,h),S=Ve(m,p)?n:Ee(m,p),k=Ar(M,S,n);c.push({x:a+d,y:i+b,char:k.char,fg:k.fg,bg:k.bg});}return {cells:c}},getPixelDimensions(o,a){return {width:o,height:a*2}}}}var se="\x1B_G",ue="\x1B\\";function Br(e){if(typeof Buffer<"u")return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");let r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return btoa(r)}function wr(e,r){if(e.length<=r)return [e];let n=[];for(let t=0;t<e.length;t+=r)n.push(e.slice(t,t+r));return n}function Pr(e,r,n,t){if(e.length===0)return "";let o=[],a=e[0],i=e.length>1?1:0;o.push(`${se}a=t,f=32,s=${r},v=${n},i=${t},m=${i};${a}${ue}`);for(let s=1;s<e.length;s++){let u=s===e.length-1;o.push(`${se}m=${u?0:1};${e[s]}${ue}`);}return o.join("")}function kr(e,r){return `${se}a=p,i=${e},p=1,C=1;${ue}${se}a=d,d=i,i=${r};${ue}`}function me(e){let r=Pe.parse(e??{}),n=r.imageId,t=r.chunkSize,o={maxColors:16777216,supportsAlpha:true,pixelsPerCellX:1,pixelsPerCellY:1,supportsAnimation:true,requiresEscapeSequences:true},a=0,i=[n,n+1];return {type:"kitty",capabilities:o,encode(s,u,c){let m=s.width,l=s.height,b=Br(s.colorBuffer),d=wr(b,t),h=a;a=a===0?1:0;let p=i[a]??n,M=i[h]??n+1,S=Pr(d,m,l,p),k=kr(p,M);return {escape:S+k,cursorX:u,cursorY:c}},getPixelDimensions(s,u){return {width:s*8,height:u*16}}}}var Dr=129792,Er="\u2588";function Vr(e,r,n,t,o,a){for(let i=0;i<3;i++)for(let s=0;s<2;s++){let u=r+s,m=((n+i)*t+u)*4;if(e[m+3]>=o){let b=i*2+s;a.pattern|=1<<b,a.rSum+=e[m],a.gSum+=e[m+1],a.bSum+=e[m+2],a.litCount++;}}}function Fr(e){return e===0?" ":e===63?Er:String.fromCodePoint(Dr+e-1)}function Tr(e){if(e.litCount===0)return 0;let r=Math.round(e.rSum/e.litCount),n=Math.round(e.gSum/e.litCount),t=Math.round(e.bSum/e.litCount);return r<<16|n<<8|t}function le(e){let r=Be.parse(e??{}),n=r.threshold,t=r.backgroundColor;return {type:"sextant",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:2,pixelsPerCellY:3,supportsAnimation:true,requiresEscapeSequences:false},encode(a,i,s){let u=Math.floor(a.width/2),c=Math.floor(a.height/3),m=[],l=a.colorBuffer,b=a.width,d={pattern:0,rSum:0,gSum:0,bSum:0,litCount:0};for(let h=0;h<c;h++)for(let p=0;p<u;p++)d.pattern=0,d.rSum=0,d.gSum=0,d.bSum=0,d.litCount=0,Vr(l,p*2,h*3,b,n,d),m.push({x:i+p,y:s+h,char:Fr(d.pattern),fg:Tr(d),bg:t});return {cells:m}},getPixelDimensions(a,i){return {width:a*2,height:i*3}}}}var zr="\x1BPq",vr="\x1B\\";function jr(e,r){let n=new Map;for(let t=0;t<r;t++){let o=t*4;if(e[o+3]===0)continue;let i=e[o]<<16|e[o+1]<<8|e[o+2];n.set(i,(n.get(i)??0)+1);}return n}function Rr(e,r){let n=[];for(let a of e)n.push(a);n.sort((a,i)=>i[1]-a[1]);let t=Math.min(n.length,r)||1,o=new Uint8Array(t*3);for(let a=0;a<t;a++){let i=n[a];if(i){let s=i[0];o[a*3]=s>>16&255,o[a*3+1]=s>>8&255,o[a*3+2]=s&255;}}return {paletteFlat:o,paletteCount:t}}function Wr(e,r,n,t,o){let a=2147483647,i=0;for(let s=0;s<o;s++){let u=s*3,c=e-t[u],m=r-t[u+1],l=n-t[u+2],b=c*c+m*m+l*l;if(b<a&&(a=b,i=s,b===0))break}return i}function Ur(e,r,n,t,o){let a=o&&o.length===r?o:new Uint8Array(r);for(let i=0;i<r;i++){let s=i*4;if(e[s+3]===0){a[i]=0;continue}a[i]=Wr(e[s],e[s+1],e[s+2],n,t);}return a}function Ir(e,r,n){let t=e.colorBuffer,o=e.width*e.height,a=jr(t,o),{paletteFlat:i,paletteCount:s}=Rr(a,r),u=Ur(t,o,i,s,n);return {paletteFlat:i,paletteCount:s,indexMap:u}}function Lr(e,r,n){let t=false,o=0;for(;o<r;){let a=e[o],i=1;for(;o+i<r&&e[o+i]===a;)i++;let s=String.fromCharCode(63+a);if(a>0&&(t=true),i>=3)n.push("!",String(i),s);else for(let u=0;u<i;u++)n.push(s);o+=i;}return t}function Or(e,r){let n=[];for(let t=0;t<r;t++){let o=t*3,a=Math.round(e[o]/255*100),i=Math.round(e[o+1]/255*100),s=Math.round(e[o+2]/255*100);n.push("#",String(t),";2;",String(a),";",String(i),";",String(s));}return n}function Yr(e,r,n,t,o,a){let i=0;for(let s=0;s<t;s++){let u=(n+s)*o+a;e[u]===r&&(i|=1<<s);}return i}function Xr(e,r){let n=[],t=false;for(let o=0;o<r;o++){let a=e[o];a>0&&(t=true),n.push(String.fromCharCode(63+a));}return {chars:n,hasPixels:t}}function Te(e,r,n,t){if(t){e.push("#",String(r));for(let o of n)e.push(o);e.push("$");}}function _r(e,r,n,t,o,a,i,s){for(let u=0;u<o;u++)a[u]=Yr(e,r,n,t,o,u);if(i){let u=[],c=Lr(a,o,u);Te(s,r,u,c);}else {let{chars:u,hasPixels:c}=Xr(a,o);Te(s,r,u,c);}}function Hr(e,r,n,t,o,a,i){let s=Math.ceil(t/6);for(let u=0;u<s;u++){let c=u*6,m=Math.min(6,t-c);for(let l=0;l<r;l++)_r(e,l,c,m,n,o,a,i);u<s-1&&i.push("-");}}function be(e){let r=we.parse(e??{}),n=r.maxColors,t=r.rleEnabled,o={maxColors:n,supportsAlpha:false,pixelsPerCellX:1,pixelsPerCellY:1,supportsAnimation:false,requiresEscapeSequences:true},a=null,i=null;return {type:"sixel",capabilities:o,encode(s,u,c){let{paletteFlat:m,paletteCount:l,indexMap:b}=Ir(s,n,a);a=b;let d=s.width,h=s.height,p=[zr];return p.push(...Or(m,l)),(!i||i.length<d)&&(i=new Uint8Array(d)),Hr(b,l,d,h,i,t,p),p.push(vr),{escape:p.join(""),cursorX:u,cursorY:c}},getPixelDimensions(s,u){return {width:s*8,height:u*16}}}}function fe(e){switch(ie.parse(e),e){case "braille":return De();case "halfblock":return Fe();case "sextant":return le();case "sixel":return be();case "kitty":return me()}}function Ht(e,r){let n=ke.parse(r??{});if(n.forceBackend&&n.preferred!=="auto"||n.preferred!=="auto")return fe(n.preferred);let t=e.graphics;return t==="kitty"?me():t==="sixel"?be():e.truecolor?le():fe(n.fallback)}var ze=z.object({tx:z.number().default(0),ty:z.number().default(0),tz:z.number().default(0),rx:z.number().default(0),ry:z.number().default(0),rz:z.number().default(0),sx:z.number().default(1),sy:z.number().default(1),sz:z.number().default(1)}).describe("3D transform: translation (t), rotation in radians (r), scale (s)"),ve=z.object({fov:z.number().positive().max(Math.PI).default(Math.PI/3),near:z.number().positive().default(.1),far:z.number().positive().default(100),aspect:z.number().positive().default(16/9),projectionMode:z.enum(["perspective","orthographic"]).default("perspective")}).refine(e=>e.near<e.far,{message:"near must be less than far"}),je=z.object({wireColor:z.number().int().min(0).max(16777215).default(16777215),fillColor:z.number().int().min(0).max(16777215).default(8421504),renderMode:z.enum(["wireframe","filled","both"]).default("wireframe"),backfaceCull:z.boolean().default(true),flatShading:z.boolean().default(false),antiAlias:z.boolean().default(false)}).describe("3D material configuration"),Re=z.object({left:z.number().int().min(0).default(0),top:z.number().int().min(0).default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),cameraEntity:z.number().int().min(0),backendType:z.enum(["auto","braille","halfblock","sextant","sixel","kitty"]).default("auto")}).describe("3D viewport configuration"),Nt=z.object({rotateSpeed:z.object({x:z.number().default(0),y:z.number().default(0),z:z.number().default(0)}).default(()=>({x:0,y:0,z:0})).describe("Radians per second of continuous rotation"),orbitCenter:z.tuple([z.number(),z.number(),z.number()]).optional().describe("Point to orbit around"),orbitSpeed:z.number().default(0).describe("Radians per second of orbit"),orbitRadius:z.number().positive().optional().describe("Distance from orbit center")}).describe("3D animation configuration"),Kt=z.object({rotationSensitivity:z.number().positive().default(.01).describe("Radians per pixel of mouse movement"),zoomSensitivity:z.number().positive().default(.5).describe("Units per scroll tick"),zoomMin:z.number().positive().default(1),zoomMax:z.number().positive().default(100),invertY:z.boolean().default(false)}).describe("Mouse-based 3D camera interaction");n();var $=1e4,w={fov:new Float32Array($),near:new Float32Array($),far:new Float32Array($),aspect:new Float32Array($),projectionMode:new Uint8Array($),projMatrix:new Float32Array($*16),viewMatrix:new Float32Array($*16),dirty:new Uint8Array($)};function Qt(e,r,n){let t=ve.parse(n);return i(e,r,w)||h(e,r,w),w.fov[r]=t.fov,w.near[r]=t.near,w.far[r]=t.far,w.aspect[r]=t.aspect,w.projectionMode[r]=t.projectionMode==="orthographic"?1:0,w.dirty[r]=1,r}function en(e,r){if(i(e,r,w))return {fov:w.fov[r],near:w.near[r],far:w.far[r],aspect:w.aspect[r],projectionMode:w.projectionMode[r]===1?"orthographic":"perspective"}}function rn(e){let r=e*16;return w.projMatrix.subarray(r,r+16)}function tn(e){let r=e*16;return w.viewMatrix.subarray(r,r+16)}n();var ee=1e4,qr=0,We=1,Ue=2,P={wireColor:new Uint32Array(ee),fillColor:new Uint32Array(ee),renderMode:new Uint8Array(ee),backfaceCull:new Uint8Array(ee),flatShading:new Uint8Array(ee),antiAlias:new Uint8Array(ee)};function sn(e,r,n){let t=je.parse(n);return i(e,r,P)||h(e,r,P),P.wireColor[r]=t.wireColor,P.fillColor[r]=t.fillColor,t.renderMode==="filled"?P.renderMode[r]=We:t.renderMode==="both"?P.renderMode[r]=Ue:P.renderMode[r]=qr,P.backfaceCull[r]=t.backfaceCull?1:0,P.flatShading[r]=t.flatShading?1:0,P.antiAlias[r]=t.antiAlias?1:0,r}function un(e,r){if(!i(e,r,P))return;let n=P.renderMode[r],t="wireframe";return n===We?t="filled":n===Ue&&(t="both"),{wireColor:P.wireColor[r],fillColor:P.fillColor[r],renderMode:t,backfaceCull:P.backfaceCull[r]===1,flatShading:P.flatShading[r]===1,antiAlias:P.antiAlias[r]===1}}n();var $r=1e4,N={meshId:new Uint32Array($r)},Ie=1,ne=new Map;function Nr(e,r,n,t){let o=Ie++;return ne.set(o,{name:e,vertices:r,vertexCount:Math.floor(r.length/3),indices:n,triangleCount:Math.floor(n.length/3),normals:t}),o}function ln(e,r,n){let t=new Float32Array(r.length*3);for(let i=0;i<r.length;i++){let s=r[i];s&&(t[i*3]=s.x,t[i*3+1]=s.y,t[i*3+2]=s.z);}let o=[];for(let i of n)if(!(i.length<3))for(let s=1;s<i.length-1;s++)o.push(i[0],i[s],i[s+1]);let a=new Uint32Array(o);return Nr(e,t,a)}function Le(e){return ne.get(e)}function bn(e){return ne.delete(e)}function fn(e,r,n){return i(e,r,N)||h(e,r,N),N.meshId[r]=n,r}function pn(e,r){if(i(e,r,N))return N.meshId[r]}function dn(){return ne.size}function xn(){ne.clear(),Ie=1;}n();var Y=1e4,f={tx:new Float32Array(Y),ty:new Float32Array(Y),tz:new Float32Array(Y),rx:new Float32Array(Y),ry:new Float32Array(Y),rz:new Float32Array(Y),sx:new Float32Array(Y),sy:new Float32Array(Y),sz:new Float32Array(Y),worldMatrix:new Float32Array(Y*16),dirty:new Uint8Array(Y)};function Cn(e,r,n){let t=ze.parse(n);return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.tx[r]=t.tx,f.ty[r]=t.ty,f.tz[r]=t.tz,f.rx[r]=t.rx,f.ry[r]=t.ry,f.rz[r]=t.rz,f.sx[r]=t.sx,f.sy[r]=t.sy,f.sz[r]=t.sz,f.dirty[r]=1,r}function Mn(e,r){if(i(e,r,f))return {tx:f.tx[r],ty:f.ty[r],tz:f.tz[r],rx:f.rx[r],ry:f.ry[r],rz:f.rz[r],sx:f.sx[r],sy:f.sy[r],sz:f.sz[r]}}function Sn(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.tx[r]=n,f.ty[r]=t,f.tz[r]=o,f.dirty[r]=1,r}function An(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.rx[r]=n,f.ry[r]=t,f.rz[r]=o,f.dirty[r]=1,r}function Bn(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.sx[r]=n,f.sy[r]=t,f.sz[r]=o,f.dirty[r]=1,r}function wn(e){let r=e*16;return f.worldMatrix.subarray(r,r+16)}function Pn(e){f.dirty[e]=1;}function kn(e){return f.dirty[e]===1}n();var K=1e4,pe=0,Oe=1,Ye=2,Xe=3,_e=4,He=5,A={left:new Uint16Array(K),top:new Uint16Array(K),width:new Uint16Array(K),height:new Uint16Array(K),cameraEntity:new Uint32Array(K),backendType:new Uint8Array(K),pixelWidth:new Uint16Array(K),pixelHeight:new Uint16Array(K)},Kr={auto:pe,braille:Oe,halfblock:Ye,sextant:Xe,sixel:_e,kitty:He},Gr={[pe]:"auto",[Oe]:"braille",[Ye]:"halfblock",[Xe]:"sextant",[_e]:"sixel",[He]:"kitty"};function Fn(e,r,n){let t=Re.parse(n);return i(e,r,A)||h(e,r,A),A.left[r]=t.left,A.top[r]=t.top,A.width[r]=t.width,A.height[r]=t.height,A.cameraEntity[r]=t.cameraEntity,A.backendType[r]=Kr[t.backendType]??pe,r}function Tn(e,r){if(i(e,r,A))return {left:A.left[r],top:A.top[r],width:A.width[r],height:A.height[r],cameraEntity:A.cameraEntity[r],backendType:Gr[A.backendType[r]]??"auto",pixelWidth:A.pixelWidth[r],pixelHeight:A.pixelHeight[r]}}var de=z.tuple([z.number().finite(),z.number().finite(),z.number().finite()]),jn=z.union([de,z.object({x:z.number().finite(),y:z.number().finite(),z:z.number().finite()})]),Rn=z.instanceof(Float32Array).refine(e=>e.length===16,{message:"Mat4 must be Float32Array of length 16"}),Wn=z.object({x:z.number().finite().describe("Rotation around X axis in radians"),y:z.number().finite().describe("Rotation around Y axis in radians"),z:z.number().finite().describe("Rotation around Z axis in radians")}),qe=z.object({fov:z.number().positive().max(Math.PI).describe("Field of view in radians"),aspect:z.number().positive().describe("Width / height ratio"),near:z.number().positive().describe("Near clipping plane"),far:z.number().positive().describe("Far clipping plane")}).refine(e=>e.near<e.far,{message:"Near plane must be less than far plane"}),$e=z.object({left:z.number().finite(),right:z.number().finite(),bottom:z.number().finite(),top:z.number().finite(),near:z.number().finite(),far:z.number().finite()}).refine(e=>e.left<e.right&&e.bottom<e.top&&e.near<e.far,{message:"Invalid orthographic bounds: left < right, bottom < top, near < far required"}),xe=z.object({x:z.number().int().nonnegative(),y:z.number().int().nonnegative(),width:z.number().int().positive(),height:z.number().int().positive()}),Un=z.object({xMin:z.number().finite(),xMax:z.number().finite(),yMin:z.number().finite(),yMax:z.number().finite()}).refine(e=>e.xMin<e.xMax&&e.yMin<e.yMax,{message:"Invalid clip rectangle: xMin < xMax and yMin < yMax required"});function T(e,r,n){let t=new Float32Array(3);return t[0]=e,t[1]=r,t[2]=n,t}function On(e){let r=de.parse(e);return T(r[0],r[1],r[2])}function Yn(e,r){return T(e[0]+r[0],e[1]+r[1],e[2]+r[2])}function he(e,r){return T(e[0]-r[0],e[1]-r[1],e[2]-r[2])}function Xn(e,r){return T(e[0]*r,e[1]*r,e[2]*r)}function _n(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]}function ye(e,r){let n=e[0],t=e[1],o=e[2],a=r[0],i=r[1],s=r[2];return T(t*s-o*i,o*a-n*s,n*i-t*a)}function Zr(e){let r=e[0],n=e[1],t=e[2];return r*r+n*n+t*t}function Ne(e){return Math.sqrt(Zr(e))}function ge(e){let r=Ne(e);if(r===0)return T(0,0,0);let n=1/r;return T(e[0]*n,e[1]*n,e[2]*n)}function Hn(e,r,n){let t=Math.max(0,Math.min(1,n)),o=1-t;return T(e[0]*o+r[0]*t,e[1]*o+r[1]*t,e[2]*o+r[2]*t)}function qn(e){return T(-e[0],-e[1],-e[2])}function $n(e,r){return Ne(he(e,r))}function Nn(e,r,n=1e-6){return Math.abs(e[0]-r[0])<=n&&Math.abs(e[1]-r[1])<=n&&Math.abs(e[2]-r[2])<=n}function Kn(){return T(0,0,0)}function G(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function X(e,r){let n=new Float32Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++){let a=t*4+o;n[a]=e[o]*r[t*4]+e[4+o]*r[t*4+1]+e[8+o]*r[t*4+2]+e[12+o]*r[t*4+3];}return n}function Jr(e,r,n,t){let o=G();return o[12]=r,o[13]=n,o[14]=t,X(e,o)}function Qr(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[5]=n,o[6]=t,o[9]=-t,o[10]=n,X(e,o)}function et(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[0]=n,o[2]=-t,o[8]=t,o[10]=n,X(e,o)}function rt(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[0]=n,o[1]=t,o[4]=-t,o[5]=n,X(e,o)}function tt(e,r,n,t){let o=G();return o[0]=r,o[5]=n,o[10]=t,X(e,o)}function Jn(e){let r=new Float32Array(16);for(let n=0;n<4;n++)for(let t=0;t<4;t++)r[n*4+t]=e[t*4+n];return r}function Qn(e){let r=e[0],n=e[1],t=e[2],o=e[3],a=e[4],i=e[5],s=e[6],u=e[7],c=e[8],m=e[9],l=e[10],b=e[11],d=e[12],h=e[13],p=e[14],M=e[15],S=r*i-n*a,k=r*s-t*a,F=r*u-o*a,v=n*s-t*i,j=n*u-o*i,W=t*u-o*s,z=c*h-m*d,E=c*p-l*d,U=c*M-b*d,I=m*p-l*h,L=m*M-b*h,O=l*M-b*p;return S*O-k*L+F*I+v*U-j*E+W*z}function Ke(e){let r=e[0],n=e[1],t=e[2],o=e[3],a=e[4],i=e[5],s=e[6],u=e[7],c=e[8],m=e[9],l=e[10],b=e[11],d=e[12],h=e[13],p=e[14],M=e[15],S=r*i-n*a,k=r*s-t*a,F=r*u-o*a,v=n*s-t*i,j=n*u-o*i,W=t*u-o*s,z=c*h-m*d,E=c*p-l*d,U=c*M-b*d,I=m*p-l*h,L=m*M-b*h,O=l*M-b*p,ae=S*O-k*L+F*I+v*U-j*E+W*z;if(Math.abs(ae)<1e-10)return null;let D=1/ae,V=new Float32Array(16);return V[0]=(i*O-s*L+u*I)*D,V[1]=(t*L-n*O-o*I)*D,V[2]=(h*W-p*j+M*v)*D,V[3]=(l*j-m*W-b*v)*D,V[4]=(s*U-a*O-u*E)*D,V[5]=(r*O-t*U+o*E)*D,V[6]=(p*F-d*W-M*k)*D,V[7]=(c*W-l*F+b*k)*D,V[8]=(a*L-i*U+u*z)*D,V[9]=(n*U-r*L-o*z)*D,V[10]=(d*j-h*F+M*S)*D,V[11]=(m*F-c*j-b*S)*D,V[12]=(i*E-a*I-s*z)*D,V[13]=(r*I-n*E+t*z)*D,V[14]=(h*k-d*v-p*S)*D,V[15]=(c*v-m*k+l*S)*D,V}function Ce(e,r){let n=r[0],t=r[1],o=r[2],a=e[3]*n+e[7]*t+e[11]*o+e[15],i=a!==0?1/a:1;return T((e[0]*n+e[4]*t+e[8]*o+e[12])*i,(e[1]*n+e[5]*t+e[9]*o+e[13])*i,(e[2]*n+e[6]*t+e[10]*o+e[14])*i)}function eo(e,r){let n=r[0],t=r[1],o=r[2];return T(e[0]*n+e[4]*t+e[8]*o,e[1]*n+e[5]*t+e[9]*o,e[2]*n+e[6]*t+e[10]*o)}function ro(e,r,n){let t=G();return t=Jr(t,e[0],e[1],e[2]),t=Qr(t,r[0]),t=et(t,r[1]),t=rt(t,r[2]),t=tt(t,n[0],n[1],n[2]),t}function to(e,r=1e-6){for(let n=0;n<4;n++)for(let t=0;t<4;t++){let o=n*4+t,a=n===t?1:0;if(Math.abs(e[o]-a)>r)return false}return true}function no(e,r,n=1e-5){for(let t=0;t<16;t++)if(Math.abs(e[t]-r[t])>n)return false;return true}function Ge(e){let r=qe.parse(e),{fov:n,aspect:t,near:o,far:a}=r,i=1/Math.tan(n/2),s=1/(o-a),u=new Float32Array(16);return u[0]=i/t,u[5]=i,u[10]=(o+a)*s,u[11]=-1,u[14]=2*o*a*s,u}function Ze(e){let r=$e.parse(e),{left:n,right:t,bottom:o,top:a,near:i,far:s}=r,u=1/(n-t),c=1/(o-a),m=1/(i-s),l=new Float32Array(16);return l[0]=-2*u,l[5]=-2*c,l[10]=2*m,l[12]=(n+t)*u,l[13]=(a+o)*c,l[14]=(s+i)*m,l[15]=1,l}function uo(e,r,n){let t=ge(he(e,r)),o=ge(ye(n,t)),a=ye(t,o),i=G();return i[0]=o[0],i[4]=o[1],i[8]=o[2],i[1]=a[0],i[5]=a[1],i[9]=a[2],i[2]=t[0],i[6]=t[1],i[10]=t[2],i[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),i[13]=-(a[0]*e[0]+a[1]*e[1]+a[2]*e[2]),i[14]=-(t[0]*e[0]+t[1]*e[1]+t[2]*e[2]),i}function Je(e){let r=xe.parse(e),{x:n,y:t,width:o,height:a}=r,i=o/2,s=a/2;return u=>({x:u[0]*i+(n+i),y:-u[1]*s+(t+s),depth:(u[2]+1)/2})}function co(e,r){return Ce(e,r)}function mo(e,r,n){let t=xe.parse(n),{x:o,y:a,width:i,height:s}=t,u=(r[0]-o)/i*2-1,c=-((r[1]-a)/s*2-1),m=r[2]*2-1,l=T(u,c,m);return Ce(e,l)}function lo(e,r,n){return X(n,X(r,e))}var Qe=z.object({width:z.number().int().positive().max(4096).describe("Buffer width in pixels"),height:z.number().int().positive().max(4096).describe("Buffer height in pixels"),enableDepthBuffer:z.boolean().default(true)}),po=z.object({x:z.number(),y:z.number(),depth:z.number().min(0).max(1).optional(),r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255),a:z.number().int().min(0).max(255).default(255)}),er=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),a:z.number().int().min(0).max(255).default(255)}),xo=z.object({x:z.number(),y:z.number(),depth:z.number().min(0).max(1),r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255),a:z.number().int().min(0).max(255).default(255)}),ho=z.object({direction:z.tuple([z.number(),z.number(),z.number()]).describe("Normalized light direction"),intensity:z.number().min(0).max(1).default(1),color:er.optional()}),yo=z.object({intensity:z.number().min(0).max(1).default(.1),color:er.optional()});function rr(e){let r=Qe.parse(e),{width:n,height:t,enableDepthBuffer:o}=r,a=n*t,i=new Uint8ClampedArray(a*4),s=o?new Float32Array(a):null;return s&&s.fill(1),{width:n,height:t,colorBuffer:i,depthBuffer:s}}function tr(e,r,n){let t=e.colorBuffer;if(!r||r.r===0&&r.g===0&&r.b===0&&r.a===0)t.fill(0);else {let o=r.r,a=r.g,i=r.b,s=r.a;for(let u=0;u<t.length;u+=4)t[u]=o,t[u+1]=a,t[u+2]=i,t[u+3]=s;}e.depthBuffer&&e.depthBuffer.fill(n??1);}function Z(e,r,n){return r>=0&&r<e.width&&n>=0&&n<e.height}function Mo(e,r,n){if(!Z(e,r,n))return {r:0,g:0,b:0,a:0};let t=(n*e.width+r)*4;return {r:e.colorBuffer[t],g:e.colorBuffer[t+1],b:e.colorBuffer[t+2],a:e.colorBuffer[t+3]}}function So(e,r,n,t){if(!Z(e,r,n))return;let o=(n*e.width+r)*4;e.colorBuffer[o]=t.r,e.colorBuffer[o+1]=t.g,e.colorBuffer[o+2]=t.b,e.colorBuffer[o+3]=t.a;}function Q(e,r,n,t,o,a,i){let s=(n*e.width+r)*4;e.colorBuffer[s]=t,e.colorBuffer[s+1]=o,e.colorBuffer[s+2]=a,e.colorBuffer[s+3]=i;}function Ao(e,r,n){if(!e.depthBuffer||!Z(e,r,n))return 1;let t=n*e.width+r;return e.depthBuffer[t]}function re(e,r,n,t){if(!e.depthBuffer||!Z(e,r,n))return false;let o=n*e.width+r;return t<e.depthBuffer[o]?(e.depthBuffer[o]=t,true):false}function Bo(e,r,n,t,o,a){let i=Math.max(0,Math.floor(r)),s=Math.max(0,Math.floor(n)),u=Math.min(e.width,Math.floor(r+t)),c=Math.min(e.height,Math.floor(n+o));for(let m=s;m<c;m++)for(let l=i;l<u;l++){let b=(m*e.width+l)*4;e.colorBuffer[b]=a.r,e.colorBuffer[b+1]=a.g,e.colorBuffer[b+2]=a.b,e.colorBuffer[b+3]=a.a;}}function nr(e,r,n,t,o,a,i){if(e.x===r&&e.y===n)return true;let s=2*e.err;return s>-o&&(e.err-=o,e.x+=a),s<t&&(e.err+=t,e.y+=i),e.step++,false}function nt(e,r,n,t,o,a,i,s){Z(e,r,n)&&re(e,r,n,t)&&Q(e,r,n,o,a,i,s);}function ot(e,r,n,t,o,a,i,s,u){return {r:Math.round(e+(o-e)*u),g:Math.round(r+(a-r)*u),b:Math.round(n+(i-n)*u),a:Math.round(t+(s-t)*u)}}function at(e,r,n,t,o){return !o||!e.depthBuffer?true:re(e,r,n,t)}function it(e,r,n,t,o,a){let i=ot(t.r,t.g,t.b,t.a??255,o.r,o.g,o.b,o.a??255,a);Q(e,r,n,i.r,i.g,i.b,i.a);}function ko(e,r,n,t,o,a,i,s,u=255){let c=Math.round(r),m=Math.round(n),l=Math.round(t),b=Math.round(o),d=Math.abs(l-c),h=Math.abs(b-m),p=c<l?1:-1,M=m<b?1:-1,S=d-h;for(;Z(e,c,m)&&Q(e,c,m,a,i,s,u),!(c===l&&m===b);){let k=2*S;k>-h&&(S-=h,c+=p),k<d&&(S+=d,m+=M);}}function or(e,r,n){let t=Math.round(n.x),o=Math.round(n.y),a={x:Math.round(r.x),y:Math.round(r.y),err:0,step:0},i=Math.abs(t-a.x),s=Math.abs(o-a.y),u=a.x<t?1:-1,c=a.y<o?1:-1;a.err=i-s;let m=Math.max(i,s),l=m>0?1/m:0,b=r.depth??0,d=n.depth??0,h=r.r,p=r.g,M=r.b,S=r.a??255;for(;;){let k=a.step*l,F=b+(d-b)*k;if(nt(e,a.x,a.y,F,h,p,M,S),nr(a,t,o,i,s,u,c))break}}function Do(e,r,n){let t=Math.round(n.x),o=Math.round(n.y),a={x:Math.round(r.x),y:Math.round(r.y),err:0,step:0},i=Math.abs(t-a.x),s=Math.abs(o-a.y),u=a.x<t?1:-1,c=a.y<o?1:-1;a.err=i-s;let m=Math.max(i,s),l=m>0?1/m:0,b=r.depth??0,d=n.depth??0,h=r.depth!==void 0||n.depth!==void 0;for(;;){if(Z(e,a.x,a.y)){let p=a.step*l,M=b+(d-b)*p;at(e,a.x,a.y,M,h)&&it(e,a.x,a.y,r,n,p);}if(nr(a,t,o,i,s,u,c))break}}function ar(e,r,n,t){let o=ct(r,n,t);if(Math.abs(o)<.5)return null;let a=1/o,i=Math.max(0,Math.floor(Math.min(r.x,n.x,t.x))),s=Math.max(0,Math.floor(Math.min(r.y,n.y,t.y))),u=Math.min(e.width-1,Math.ceil(Math.max(r.x,n.x,t.x))),c=Math.min(e.height-1,Math.ceil(Math.max(r.y,n.y,t.y)));if(i>u||s>c)return null;let m=i+.5,l=s+.5;return {invArea:a,minX:i,minY:s,maxX:u,maxY:c,A01:(n.y-t.y)*a,B01:(t.x-n.x)*a,A12:(t.y-r.y)*a,B12:(r.x-t.x)*a,hasDepth:e.depthBuffer!==null&&e.depthBuffer!==void 0,startW0:((n.y-t.y)*(m-t.x)+(t.x-n.x)*(l-t.y))*a,startW1:((t.y-r.y)*(m-t.x)+(r.x-t.x)*(l-t.y))*a}}function st(e,r,n,t,o,a,i,s,u,c,m,l){let b=1-t-o;if(t<0||o<0||b<0)return;let d=a.depth*t+i.depth*o+s.depth*b;if(l&&!re(e,r,n,d))return;let h=a.r*t+i.r*o+s.r*b+.5|0,p=a.g*t+i.g*o+s.g*b+.5|0,M=a.b*t+i.b*o+s.b*b+.5|0,S=u*t+c*o+m*b+.5|0;Q(e,r,n,h,p,M,S);}function ut(e,r,n,t,o,a,i,s,u,c){let m=1-t-o;if(t<0||o<0||m<0)return;let l=a.depth*t+i.depth*o+s.depth*m;c&&!re(e,r,n,l)||Q(e,r,n,u.r,u.g,u.b,u.a);}function ct(e,r,n){return (r.x-e.x)*(n.y-e.y)-(n.x-e.x)*(r.y-e.y)}function Fo(e,r,n){return {minX:Math.min(e.x,r.x,n.x),minY:Math.min(e.y,r.y,n.y),maxX:Math.max(e.x,r.x,n.x),maxY:Math.max(e.y,r.y,n.y)}}function To(e,r,n,t){let o=ar(e,r,n,t);if(!o)return;let a=r.a??255,i=n.a??255,s=t.a??255,u=o.startW0,c=o.startW1;for(let m=o.minY;m<=o.maxY;m++){let l=u,b=c;for(let d=o.minX;d<=o.maxX;d++)st(e,d,m,l,b,r,n,t,a,i,s,o.hasDepth),l+=o.A01,b+=o.A12;u+=o.B01,c+=o.B12;}}function ir(e,r,n,t,o){let a=ar(e,r,n,t);if(!a)return;let i=a.startW0,s=a.startW1;for(let u=a.minY;u<=a.maxY;u++){let c=i,m=s;for(let l=a.minX;l<=a.maxX;l++)ut(e,l,u,c,m,r,n,t,o,a.hasDepth),c+=a.A01,m+=a.A12;i+=a.B01,s+=a.B12;}}var jo=z.object({left:z.number().int().nonnegative().default(0),top:z.number().int().nonnegative().default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),fov:z.number().positive().max(Math.PI).default(Math.PI/3),near:z.number().positive().default(.1),far:z.number().positive().default(1e3),projectionMode:z.enum(["perspective","orthographic"]).default("perspective"),backend:z.enum(["auto","braille","halfblock","sextant","sixel","kitty"]).default("auto"),label:z.string().optional()}).refine(e=>e.near<e.far,{message:"Near plane must be less than far plane"});n();var ce=new Float32Array(3),oe=new Map;function _o(){oe.clear();}function mt(e){let r=w.projectionMode[e],n=w.fov[e],t=w.near[e],o=w.far[e],a=w.aspect[e];if(r===1){let i=n,s=i*a;return Ze({left:-s,right:s,bottom:-i,top:i,near:t,far:o})}return Ge({fov:n,aspect:a,near:t,far:o})}function lt(e){let r=e*16,n=f.worldMatrix.subarray(r,r+16);return Ke(n)}function bt(e,r,n,t,o){let a=t[0],i=t[1],s=t[2],u=t[3],c=t[4],m=t[5],l=t[6],b=t[7],d=t[8],h=t[9],p=t[10],M=t[11],S=t[12],k=t[13],F=t[14],v=t[15],j=a*e+c*r+d*n+S,W=i*e+m*r+h*n+k,z=s*e+l*r+p*n+F,E=u*e+b*r+M*n+v,U=E!==0?1/E:0,I=j*U,L=W*U,O=z*U,ae=I>=-1&&I<=1&&L>=-1&&L<=1&&O>=-1&&O<=1;ce[0]=I,ce[1]=L,ce[2]=O;let D=o(ce);return {x:D.x,y:D.y,depth:D.depth,visible:ae}}function ft(e,r,n){let t=N.meshId[e],o=Le(t);if(!o)return null;let a=e*16,i=f.worldMatrix.subarray(a,a+16),s=X(r,i),u=o.vertexCount,c=new Array(u),m=o.vertices;for(let l=0;l<u;l++){let b=l*3;c[l]=bt(m[b],m[b+1],m[b+2],s,n);}return {meshEid:e,projectedVertices:c,triangleIndices:o.indices,mvpMatrix:s}}function pt(e,r){return i(e,r,w)&&i(e,r,f)}function dt(e,r,n){let t=A.cameraEntity[r];if(!pt(e,t))return null;let o=mt(t),a=lt(t);if(!a)return null;let i=X(o,a),s=A.pixelWidth[r],u=A.pixelHeight[r],c=Je({x:0,y:0,width:s,height:u}),m=[];for(let l of n){let b=ft(l,i,c);b&&m.push(b);}return {viewportEid:r,cameraEid:t,meshes:m,vpMatrix:i,pixelWidth:s,pixelHeight:u}}var Ho=e=>{oe.clear();let r=k(e,[A]),n=k(e,[N,f]);for(let t of r){let o=dt(e,t,n);o&&oe.set(t,o);}return e};n();var Me=new Map;function ea(){Me.clear();}function sr(e){return {r:e>>16&255,g:e>>8&255,b:e&255,a:255}}function xt(e,r,n){let t=Me.get(e);if(t&&t.width===r&&t.height===n)return t;let o=rr({width:r,height:n,enableDepthBuffer:true});return Me.set(e,o),o}function ht(e){let r=new Set,n=[];for(let t=0;t<e.length;t+=3){let o=e[t],a=e[t+1],i=e[t+2],s=[[o,a],[a,i],[i,o]];for(let[u,c]of s){let m=u<c?`${u}_${c}`:`${c}_${u}`;r.has(m)||(r.add(m),n.push([u,c]));}}return n}function yt(e,r){return i(e,r,P)?{renderMode:P.renderMode[r],wireColor:P.wireColor[r],fillColor:P.fillColor[r],backfaceCull:P.backfaceCull[r]!==0}:{renderMode:0,wireColor:16777215,fillColor:8421504,backfaceCull:true}}function gt(e,r,n){return (r.x-e.x)*(n.y-e.y)-(r.y-e.y)*(n.x-e.x)>0}function Ct(e,r,n,t,o){ir(e,{x:r.x,y:r.y,depth:r.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:n.x,y:n.y,depth:n.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:t.x,y:t.y,depth:t.depth,r:o.r,g:o.g,b:o.b,a:o.a},o);}function Mt(e,r,n,t,o){let a=sr(t);for(let i=0;i<n.length;i+=3){let s=r[n[i]],u=r[n[i+1]],c=r[n[i+2]];!s||!u||!c||o&&!gt(s,u,c)||Ct(e,s,u,c,a);}}function St(e,r,n,t){let o=sr(t),a=ht(n);for(let[i,s]of a){let u=r[i],c=r[s];!u||!c||or(e,{x:Math.round(u.x),y:Math.round(u.y),depth:u.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:Math.round(c.x),y:Math.round(c.y),depth:c.depth,r:o.r,g:o.g,b:o.b,a:o.a});}}function At(e,r,n,t,o){let a=yt(e,n),i=a.renderMode===1||a.renderMode===2,s=a.renderMode===0||a.renderMode===2;i&&Mt(r,t,o,a.fillColor,a.backfaceCull),s&&St(r,t,o,a.wireColor);}function Bt(e,r){let n=oe.get(r);if(!n)return;let t=n.pixelWidth,o=n.pixelHeight;if(t<=0||o<=0)return;let a=xt(r,t,o);tr(a);for(let i of n.meshes)At(e,a,i.meshEid,i.projectedVertices,i.triangleIndices);}var ra=e=>{let r=k(e,[A]);for(let n of r)Bt(e,n);return e};export{de as $,Mo as $a,en as A,et as Aa,rn as B,rt as Ba,tn as C,tt as Ca,P as D,Jn as Da,sn as E,Qn as Ea,un as F,Ke as Fa,N as G,Ce as Ga,Nr as H,eo as Ha,ln as I,ro as Ia,Le as J,to as Ja,bn as K,no as Ka,fn as L,Ge as La,pn as M,Ze as Ma,dn as N,uo as Na,xn as O,Je as Oa,f as P,co as Pa,Cn as Q,mo as Qa,Mn as R,lo as Ra,Sn as S,Qe as Sa,An as T,po as Ta,Bn as U,er as Ua,wn as V,xo as Va,Pn as W,ho as Wa,kn as X,yo as Xa,A as Y,rr as Ya,Fn as Z,tr as Za,Tn as _,Z as _a,ie as a,jn as aa,So as ab,Pt as b,Rn as ba,Q as bb,ur as c,Wn as ca,Ao as cb,kt as d,qe as da,re as db,cr as e,$e as ea,Bo as eb,Se as f,xe as fa,ko as fb,Ae as g,Un as ga,or as gb,Be as h,T as ha,Do as hb,we as i,On as ia,ct as ib,Pe as j,Yn as ja,Fo as jb,ke as k,he as ka,To as kb,De as l,Xn as la,ir as lb,Fe as m,_n as ma,jo as mb,me as n,ye as na,oe as nb,le as o,Zr as oa,_o as ob,be as p,Ne as pa,Ho as pb,fe as q,ge as qa,Me as qb,Ht as r,Hn as ra,ea as rb,ze as s,qn as sa,ra as sb,ve as t,$n as ta,je as u,Nn as ua,Re as v,Kn as va,Nt as w,G as wa,Kt as x,X as xa,w as y,Jr as ya,Qt as z,Qr as za};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {c as c$1}from'./chunk-S6WS46FE.js';import {i as i$2,k as k$2}from'./chunk-VOCM5T2G.js';import {A as A$1,ha,Q}from'./chunk-WY5EZOOL.js';import {a}from'./chunk-6XWY6GB7.js';import {c as c$2}from'./chunk-DQTVJITR.js';import {u,k as k$1}from'./chunk-ZPGJCHXH.js';import {c as c$3}from'./chunk-APKUNIMB.js';import {T as T$1,e,ka,o as o$1}from'./chunk-GJ3RS2VG.js';import {n,t,i as i$1,h,j,s,k as k$3}from'./chunk-P3ZLIQJP.js';import {z}from'zod';u();n();var H=1e4,i={current:new Float32Array(H),max:new Float32Array(H),regen:new Float32Array(H),invulnerable:new Uint8Array(H),invulnerableTime:new Float32Array(H)};function he(t){i.current[t]=0,i.max[t]=0,i.regen[t]=0,i.invulnerable[t]=0,i.invulnerableTime[t]=0;}function ge(t,e,r){return i$1(t,e,i)||(h(t,e,i),he(e)),i.max[e]=r.max,i.current[e]=r.current??r.max,i.regen[e]=r.regen??0,e}function Te(t,e){if(i$1(t,e,i))return {current:i.current[e],max:i.max[e],regen:i.regen[e],invulnerable:i.invulnerable[e]===1,invulnerableTime:i.invulnerableTime[e]}}function ye(t,e){return i$1(t,e,i)}function xe(t,e){return i$1(t,e,i)&&j(t,e,i),e}function Ee(t,e,r){return i$1(t,e,i)?r<=0?i.current[e]<=0:i.invulnerable[e]===1?false:(i.current[e]=Math.max(0,i.current[e]-r),i.current[e]<=0):false}function Le(t,e,r){i$1(t,e,i)&&(r<=0||(i.current[e]=Math.min(i.max[e],i.current[e]+r)));}function De(t,e,r){i$1(t,e,i)&&(i.invulnerable[e]=1,i.invulnerableTime[e]=r);}function Ae(t,e){i$1(t,e,i)&&(i.invulnerable[e]=0,i.invulnerableTime[e]=0);}function Ie(t,e){return i$1(t,e,i)?i.current[e]<=0:false}function ve(t,e){return i$1(t,e,i)?i.invulnerable[e]===1:false}function _e(t,e){if(!i$1(t,e,i))return 0;let r=i.max[e];return r<=0?0:i.current[e]/r}function Be(t,e,r){i$1(t,e,i)&&(i.current[e]=Math.max(0,Math.min(i.max[e],r)));}function Re(t,e,r){i$1(t,e,i)&&(i.max[e]=r,i.current[e]>r&&(i.current[e]=r));}function Fe(t,e,r){i$1(t,e,i)&&(i.regen[e]=r);}function Pe(t,e,r){if(!i$1(t,e,i))return;if(i.invulnerable[e]===1){let a=i.invulnerableTime[e];a>0&&(i.invulnerableTime[e]=a-r,i.invulnerableTime[e]<=0&&(i.invulnerable[e]=0,i.invulnerableTime[e]=0));}let n=i.regen[e];n>0&&i.current[e]<i.max[e]&&(i.current[e]=Math.min(i.max[e],i.current[e]+n*r));}n();var N=1e4,ae=(u=>(u[u.TopLeft=0]="TopLeft",u[u.TopCenter=1]="TopCenter",u[u.TopRight=2]="TopRight",u[u.BottomLeft=3]="BottomLeft",u[u.BottomCenter=4]="BottomCenter",u[u.BottomRight=5]="BottomRight",u[u.Left=6]="Left",u[u.Right=7]="Right",u))(ae||{}),k=new Map,oe=1,I={set(t){let e=oe++;return k.set(e,t),e},update(t,e){t>0&&k.set(t,e);},get(t){return k.get(t)??""},delete(t){k.delete(t);},clear(){k.clear(),oe=1;}};function Oe(){I.clear();}var p={labelId:new Uint32Array(N),position:new Uint8Array(N),offsetX:new Int8Array(N),offsetY:new Int8Array(N)};function Me(t,e){return i$1(t,e,p)}function Ue(t,e,r,n={}){i$1(t,e,p)||(h(t,e,p),p.labelId[e]=0,p.position[e]=0,p.offsetX[e]=0,p.offsetY[e]=0);let a=p.labelId[e]??0;return a>0?I.update(a,r):p.labelId[e]=I.set(r),n.position!==void 0&&(p.position[e]=n.position),n.offsetX!==void 0&&(p.offsetX[e]=n.offsetX),n.offsetY!==void 0&&(p.offsetY[e]=n.offsetY),e}function He(t,e){if(!i$1(t,e,p))return "";let r=p.labelId[e]??0;return I.get(r)}function ke(t,e){return i$1(t,e,p)?{text:I.get(p.labelId[e]??0),position:p.position[e]??0,offsetX:p.offsetX[e]??0,offsetY:p.offsetY[e]??0}:null}function Ve(t,e){return i$1(t,e,p)?p.position[e]:0}function we(t,e,r){return i$1(t,e,p)&&(p.position[e]=r),e}function Ne(t,e,r,n){return i$1(t,e,p)&&(p.offsetX[e]=r,p.offsetY[e]=n),e}function We(t,e){if(!i$1(t,e,p))return e;let r=p.labelId[e]??0;return r>0&&I.delete(r),j(t,e,p),e}function Ke(t,e){if(!i$1(t,e,p))return false;let r=p.labelId[e]??0;return r>0&&I.get(r).length>0}u();function Ge(){c$1(T$1,"Position"),c$1(e,"Dimensions"),c$1(ka,"Renderable"),c$1(o$1,"Hierarchy"),c$1(k$1,"Border"),c$1(a,"Padding"),c$1(p,"Label"),c$1(c$2,"Interactive"),c$1(c$3,"Focusable"),c$1(A$1,"Animation"),c$1(ha,"Velocity"),c$1(Q,"Collider");}n();t();var E=1e4,ie=9474,te=9608,le=9472,se=4281545523,ce=4287137928,c={enabled:new Uint8Array(E),vertical:new Uint8Array(E),horizontal:new Uint8Array(E),trackChar:new Uint32Array(E),thumbChar:new Uint32Array(E),trackCharH:new Uint32Array(E),thumbCharH:new Uint32Array(E),trackColor:new Uint32Array(E),thumbColor:new Uint32Array(E),alwaysShow:new Uint8Array(E)};function Ye(t){c.enabled[t]=1,c.vertical[t]=1,c.horizontal[t]=1,c.trackChar[t]=ie,c.thumbChar[t]=te,c.trackCharH[t]=le,c.thumbCharH[t]=te,c.trackColor[t]=se,c.thumbColor[t]=ce,c.alwaysShow[t]=0;}function W(t,e){i$1(t,e,c)||(h(t,e,c),Ye(e));}function ze(t,e){e.enabled!==void 0&&(c.enabled[t]=e.enabled?1:0),e.vertical!==void 0&&(c.vertical[t]=e.vertical?1:0),e.horizontal!==void 0&&(c.horizontal[t]=e.horizontal?1:0),e.alwaysShow!==void 0&&(c.alwaysShow[t]=e.alwaysShow?1:0);}function Xe(t,e){e.trackChar!==void 0&&(c.trackChar[t]=e.trackChar),e.thumbChar!==void 0&&(c.thumbChar[t]=e.thumbChar),e.trackCharH!==void 0&&(c.trackCharH[t]=e.trackCharH),e.thumbCharH!==void 0&&(c.thumbCharH[t]=e.thumbCharH);}function je(t,e){e.trackColor!==void 0&&(c.trackColor[t]=s(e.trackColor)),e.thumbColor!==void 0&&(c.thumbColor[t]=s(e.thumbColor));}function Ze(t,e){ze(t,e),Xe(t,e),je(t,e);}function Qe(t,e,r){return W(t,e),Ze(e,r),e}function qe(t,e){if(i$1(t,e,c))return {enabled:c.enabled[e]===1,vertical:c.vertical[e]===1,horizontal:c.horizontal[e]===1,trackChar:c.trackChar[e],thumbChar:c.thumbChar[e],trackCharH:c.trackCharH[e],thumbCharH:c.thumbCharH[e],trackColor:c.trackColor[e],thumbColor:c.thumbColor[e],alwaysShow:c.alwaysShow[e]===1}}function Je(t,e){return i$1(t,e,c)}function $e(t,e){return i$1(t,e,c)?c.enabled[e]===1:false}function et(t,e){return W(t,e),c.enabled[e]=1,e}function tt(t,e){return i$1(t,e,c)&&(c.enabled[e]=0),e}function rt(t,e,r,n){return W(t,e),c.trackChar[e]=r,c.thumbChar[e]=n,e}function nt(t,e,r,n){return W(t,e),c.trackColor[e]=s(r),c.thumbColor[e]=s(n),e}function ot(t,e,r,n,a,l,m,d,u,y){let S=[];if(r<=0||a<=0||l<=0)return S;let b=Math.max(0,a-l);if(b===0)return S;let h=Math.min(1,l/a),f=Math.max(1,Math.round(r*h)),B=b>0?n/b:0,L=Math.round((r-f)*B);for(let g=0;g<r;g++){let R=g>=L&&g<L+f;S.push({x:t,y:e+g,char:R?d:m,color:R?y:u,isThumb:R});}return S}function at(t,e,r,n,a,l,m,d,u,y){let S=[];if(r<=0||a<=0||l<=0)return S;let b=Math.max(0,a-l);if(b===0)return S;let h=Math.min(1,l/a),f=Math.max(1,Math.round(r*h)),B=b>0?n/b:0,L=Math.round((r-f)*B);for(let g=0;g<r;g++){let R=g>=L&&g<L+f;S.push({x:t+g,y:e,char:R?d:m,color:R?y:u,isThumb:R});}return S}function it(t,e,r){return r?true:t>e}function lt(t,e,r){return r?true:t>e}var st=5e4,ue=1e4,ct=2**31-1;function T(t){if(!Number.isFinite(t))return 0;let e=Math.trunc(t);return Math.max(0,Math.min(e,ct))}var ut=z.object({line:z.number().int().nonnegative(),col:z.number().int().nonnegative()}),mt=z.enum(["stream","rectangular"]),V=new Map;function me(){return {anchorLine:0,anchorCol:0,focusLine:0,focusCol:0,active:false,mode:"stream"}}function pt(t){let e=me();return V.set(t,e),e}function dt(t){return V.get(t)}function St(t){return V.has(t)}function bt(t){V.delete(t);}function ft(){V.clear();}function Ct(t,e,r,n="stream"){let a=T(e),l=T(r);t.anchorLine=a,t.anchorCol=l,t.focusLine=a,t.focusCol=l,t.active=true,t.mode=n;}function ht(t,e,r){t.active&&(t.focusLine=T(e),t.focusCol=T(r));}function gt(t){t.active=false,t.anchorLine=0,t.anchorCol=0,t.focusLine=0,t.focusCol=0,t.mode="stream";}function Tt(t){return t.active?t.anchorLine!==t.focusLine||t.anchorCol!==t.focusCol:false}function yt(t,e,r){let n=T(e),a=T(r);t.anchorLine=n,t.anchorCol=0,t.focusLine=n,t.focusCol=a,t.active=true,t.mode="stream";}function xt(t,e,r,n){let a=T(e),l=T(r),m=T(n);t.anchorLine=a,t.anchorCol=0,t.focusLine=l,t.focusCol=m,t.active=true,t.mode="stream";}function Et(t,e,r){let n=T(e);if(n===0)return;let a=T(r);t.anchorLine=0,t.anchorCol=0,t.focusLine=n-1,t.focusCol=a,t.active=true,t.mode="stream";}function Lt(t,e){t.mode=e;}function D(t){return t.active?t.anchorLine<t.focusLine||t.anchorLine===t.focusLine&&t.anchorCol<=t.focusCol?{start:{line:t.anchorLine,col:t.anchorCol},end:{line:t.focusLine,col:t.focusCol},mode:t.mode}:{start:{line:t.focusLine,col:t.focusCol},end:{line:t.anchorLine,col:t.anchorCol},mode:t.mode}:null}function Dt(t){let e=D(t);return e?e.end.line-e.start.line+1:0}function At(t,e){let r=D(t);return r?e>=r.start.line&&e<=r.end.line:false}function It(t,e,r){let n=D(t);if(!n||e<n.start.line||e>n.end.line)return {fullLine:false,startCol:-1,endCol:-1};if(n.mode==="rectangular"){let l=Math.min(n.start.col,n.end.col),m=Math.max(n.start.col,n.end.col),d=Math.min(l,r),u=Math.min(m,r);return {fullLine:d===0&&u>=r,startCol:d,endCol:u}}return n.start.line===n.end.line?{fullLine:n.start.col===0&&n.end.col>=r,startCol:Math.min(n.start.col,r),endCol:Math.min(n.end.col,r)}:e===n.start.line?{fullLine:n.start.col===0,startCol:Math.min(n.start.col,r),endCol:r}:e===n.end.line?{fullLine:n.end.col>=r,startCol:0,endCol:Math.min(n.end.col,r)}:{fullLine:true,startCol:0,endCol:r}}function vt(t,e,r){let n=D(t);if(!n)return [];let a=Math.max(n.start.line,e),l=Math.min(n.end.line,r-1);if(a>l)return [];let m=[];for(let d=a;d<=l;d++)m.push(d);return m}function _t(t,e){let r=D(t);if(!r)return "";let n=e.lineCount-1;if(n<0)return "";let a={start:{line:Math.max(0,Math.min(r.start.line,n)),col:r.start.col},end:{line:Math.max(0,Math.min(r.end.line,n)),col:r.end.col},mode:r.mode};return a.start.line>a.end.line?"":a.mode==="rectangular"?Rt(a,e):Bt(a,e)}function Bt(t,e){let{start:r,end:n}=t;if(r.line===n.line){let d=i$2(e,r.line);return d?d.slice(r.col,n.col):""}let a=[],l=i$2(e,r.line);if(a.push(l!==void 0?l.slice(r.col):""),n.line-r.line>1){let d=k$2(e,r.line+1,n.line);for(let u of d.lines)a.push(u);}let m=i$2(e,n.line);return a.push(m!==void 0?m.slice(0,n.col):""),a.join(`
|
|
2
|
+
`)}function Rt(t,e){let r=Math.min(t.start.col,t.end.col),n=Math.max(t.start.col,t.end.col),a=k$2(e,t.start.line,t.end.line+1),l=[];for(let m of a.lines){let d=Math.min(r,m.length),u=Math.min(n,m.length);l.push(m.slice(d,u));}return l.join(`
|
|
3
|
+
`)}function Ft(t,e){let r=e.lineCount-1;if(r<0)return null;let n=Math.max(0,Math.min(t.start.line,r)),a=Math.max(0,Math.min(t.end.line,r));return n>a?null:{startLine:n,endLine:a,totalLines:a-n+1}}function*Pt(t,e,r,n,a,l){let m=Math.min(t.start.col,t.end.col),d=Math.max(t.start.col,t.end.col),u=[],y=0;for(let S=r;S<=n;S+=l){let b=Math.min(S+l,n+1),h=k$2(e,S,b);for(let f of h.lines){let B=Math.min(m,f.length),L=Math.min(d,f.length);u.push(f.slice(B,L));}y+=b-S,b<=n&&(yield {done:false,linesProcessed:y,totalLines:a,text:""});}yield {done:true,linesProcessed:y,totalLines:a,text:u.join(`
|
|
4
|
+
`)};}function*Ot(t,e,r,n,a,l){let m=[],d=0,u=i$2(e,r);if(u!==void 0){if(r===n){m.push(u.slice(t.start.col,t.end.col)),yield {done:true,linesProcessed:1,totalLines:a,text:m[0]??""};return}m.push(u.slice(t.start.col));}d=1;let y=r+1,S=n;for(let h=y;h<S;h+=l){let f=Math.min(h+l,S),B=k$2(e,h,f);for(let L of B.lines)m.push(L);d+=f-h,f<S&&(yield {done:false,linesProcessed:d,totalLines:a,text:""});}let b=i$2(e,n);b!==void 0&&m.push(b.slice(0,t.end.col)),d=a,yield {done:true,linesProcessed:d,totalLines:a,text:m.join(`
|
|
5
|
+
`)};}function*Mt(t,e,r=ue){let n=D(t);if(!n){yield {done:true,linesProcessed:0,totalLines:0,text:""};return}let a=Ft(n,e);if(!a){yield {done:true,linesProcessed:0,totalLines:0,text:""};return}let{startLine:l,endLine:m,totalLines:d}=a;if(n.mode==="rectangular"){yield*Pt(n,e,l,m,d,r);return}yield*Ot(n,e,l,m,d,r);}function Ut(t,e,r,n){let a=[],l=Math.min(t.start.line,e.start.line);l<r&&a.push([l,r-1]);let m=Math.max(t.end.line,e.end.line);return n<m&&a.push([n+1,m]),a}function Ht(t,e,r,n){if(r>n)return [];if(t.mode==="rectangular")return t.start.col!==e.start.col||t.end.col!==e.end.col?[[r,n]]:[];let a=[],l=t.start.line===e.start.line,m=t.start.col!==e.start.col;l&&m&&a.push([t.start.line,t.start.line]);let d=t.end.line===e.end.line,u=t.end.col!==e.end.col;return d&&u&&a.push([t.end.line,t.end.line]),a}function kt(t,e){if(t.mode!==e.mode)return [[Math.min(t.start.line,e.start.line),Math.max(t.end.line,e.end.line)]];let r=Math.max(t.start.line,e.start.line),n=Math.min(t.end.line,e.end.line),a=[...Ut(t,e,r,n),...Ht(t,e,r,n)];return Vt(a)}function Vt(t){if(t.length<=1)return t;t.sort((r,n)=>r[0]-n[0]);let e=[];for(let r of t){let n=e[e.length-1];if(!n){e.push(r);continue}r[0]<=n[1]+1?r[1]>n[1]&&(n[1]=r[1]):e.push(r);}return e}function wt(t,e){let r=t?D(t):null,n=D(e);return !r&&!n?[]:!r&&n?[[n.start.line,n.end.line]]:r&&!n?[[r.start.line,r.end.line]]:r&&n?kt(r,n):[]}function Nt(t){return {anchorLine:t.anchorLine,anchorCol:t.anchorCol,focusLine:t.focusLine,focusCol:t.focusCol,active:t.active,mode:t.mode}}n();var v=1e4,o={duration:new Float32Array(v),elapsed:new Float32Array(v),remaining:new Float32Array(v),repeat:new Uint16Array(v),repeatCount:new Uint16Array(v),active:new Uint8Array(v),paused:new Uint8Array(v),autoDestroy:new Uint8Array(v)},pe=65535,_=new Map;function Wt(t){o.duration[t]=0,o.elapsed[t]=0,o.remaining[t]=0,o.repeat[t]=0,o.repeatCount[t]=0,o.active[t]=0,o.paused[t]=0,o.autoDestroy[t]=0;}function Kt(t,e,r){return i$1(t,e,o)||(h(t,e,o),Wt(e)),o.duration[e]=r.duration,o.elapsed[e]=0,o.remaining[e]=r.duration,o.repeat[e]=r.repeat??0,o.repeatCount[e]=0,o.active[e]=r.active!==false?1:0,o.autoDestroy[e]=r.autoDestroy?1:0,o.paused[e]=0,e}function Gt(t,e){i$1(t,e,o)&&(o.active[e]=1,o.paused[e]=0);}function Yt(t,e){i$1(t,e,o)&&(o.paused[e]=1);}function zt(t,e){i$1(t,e,o)&&(o.paused[e]=0);}function Xt(t,e){i$1(t,e,o)&&(o.active[e]=0,o.paused[e]=0,o.elapsed[e]=0,o.remaining[e]=o.duration[e],o.repeatCount[e]=0);}function jt(t,e){i$1(t,e,o)&&(o.elapsed[e]=0,o.remaining[e]=o.duration[e],o.repeatCount[e]=0,o.active[e]=1,o.paused[e]=0);}function de(t,e){i$1(t,e,o)&&j(t,e,o),_.delete(e);}function Zt(t,e){if(i$1(t,e,o))return {duration:o.duration[e],elapsed:o.elapsed[e],remaining:o.remaining[e],repeat:o.repeat[e],repeatCount:o.repeatCount[e],active:o.active[e]===1,paused:o.paused[e]===1,autoDestroy:o.autoDestroy[e]===1}}function Qt(t,e){return i$1(t,e,o)}function qt(t,e){return i$1(t,e,o)?o.active[e]===1&&o.paused[e]===0:false}function Jt(t,e){return i$1(t,e,o)?o.active[e]===0&&o.elapsed[e]>0:false}function $t(t,e){if(!i$1(t,e,o))return 0;let r=o.duration[e];if(r<=0)return 0;let n=o.remaining[e];return Math.max(0,Math.min(1,1-n/r))}function er(t,e){let r=_.get(t)??{};r.onFire=e,_.set(t,r);}function tr(t,e){let r=_.get(t)??{};r.onComplete=e,_.set(t,r);}function rr(t){_.delete(t);}function nr(){_.clear();}function or(t,e){let r=[],n=[],a=ir(t);for(let l of a)o.active[l]!==1||o.paused[l]===1||(o.elapsed[l]=o.elapsed[l]+e,o.remaining[l]=o.remaining[l]-e,o.remaining[l]<=0&&(r.push(l),ar(t,l,n)));for(let l of n)de(t,l);return r}function ar(t,e,r){o.repeatCount[e]=o.repeatCount[e]+1;let n=_.get(e);n?.onFire&&n.onFire(t,e);let a=o.repeat[e],l=o.repeatCount[e];if(a===pe||l<=a){o.remaining[e]=o.duration[e];return}o.active[e]=0,o.remaining[e]=0,n?.onComplete&&n.onComplete(t,e),o.autoDestroy[e]===1&&r.push(e);}function ir(t){return k$3(t,[o])}n();var lr=1e4,A={hasData:new Uint8Array(lr)},w=new Map;function Se(t,e,r){return i$1(t,e,A)||h(t,e,A),A.hasData[e]=1,w.set(e,r),e}function be(t,e){if(!(!i$1(t,e,A)||A.hasData[e]===0))return w.get(e)}function sr(t,e){let r=be(t,e);return r||(r={},Se(t,e,r)),r}function fe(t,e){return i$1(t,e,A)&&A.hasData[e]===1}function cr(t,e){return fe(t,e)?(A.hasData[e]=0,w.delete(e)):false}function ur(){w.clear();}function mr(){return w.size}export{pt as $,Ne as A,zt as Aa,We as B,Xt as Ba,Ke as C,jt as Ca,Ge as D,de as Da,ie as E,Zt as Ea,te as F,Qt as Fa,le as G,qt as Ga,se as H,Jt as Ha,ce as I,$t as Ia,c as J,er as Ja,Qe as K,tr as Ka,qe as L,rr as La,Je as M,nr as Ma,$e as N,or as Na,et as O,A as Oa,tt as P,Se as Pa,rt as Q,be as Qa,nt as R,sr as Ra,ot as S,fe as Sa,at as T,cr as Ta,it as U,ur as Ua,lt as V,mr as Va,st as W,ue as X,ut as Y,mt as Z,me as _,i as a,dt as aa,ge as b,St as ba,Te as c,bt as ca,ye as d,ft as da,xe as e,Ct as ea,Ee as f,ht as fa,Le as g,gt as ga,De as h,Tt as ha,Ae as i,yt as ia,Ie as j,xt as ja,ve as k,Et as ka,_e as l,Lt as la,Be as m,D as ma,Re as n,Dt as na,Fe as o,At as oa,Pe as p,It as pa,ae as q,vt as qa,I as r,_t as ra,Oe as s,Mt as sa,p as t,wt as ta,Me as u,Nt as ua,Ue as v,o as va,He as w,pe as wa,ke as x,Kt as xa,Ve as y,Gt as ya,we as z,Yt as za};
|