From a0be9107e3ed7e84a0eac09714196ef5a90f1ae5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 16:07:22 +0000 Subject: [PATCH 1/2] build(deps): bump the ui-minor-and-patch group in /ui with 2 updates Bumps the ui-minor-and-patch group in /ui with 2 updates: [pixi.js](https://github.com/pixijs/pixijs) and [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node). Updates `pixi.js` from 8.19.0 to 8.22.0 - [Release notes](https://github.com/pixijs/pixijs/releases) - [Commits](https://github.com/pixijs/pixijs/compare/v8.19.0...v8.22.0) Updates `@types/node` from 26.1.2 to 26.6.5 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: pixi.js dependency-version: 8.22.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ui-minor-and-patch - dependency-name: "@types/node" dependency-version: 26.6.5 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: ui-minor-and-patch ... Signed-off-by: dependabot[bot] --- ui/package-lock.json | 40 ++++++++++++++++------------------------ ui/package.json | 4 ++-- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/ui/package-lock.json b/ui/package-lock.json index b4e2f93..000daf6 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -11,12 +11,12 @@ "dependencies": { "chess.js": "^1.4.0", "chessground": "^9.1.1", - "pixi.js": "^8.6.6", + "pixi.js": "^8.22.0", "react": "^18.3.1", "react-dom": "^18.3.1" }, "devDependencies": { - "@types/node": "^26.1.2", + "@types/node": "^26.6.5", "@types/react": "^18.3.17", "@types/react-dom": "^18.3.5", "@vitejs/plugin-react": "^4.3.4", @@ -60,7 +60,6 @@ "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.7", @@ -1268,14 +1267,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "26.1.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.2.tgz", - "integrity": "sha512-Vu4a5UFA9rIIFJ7rB/Vaafh9lrCQszopTCx6KjFboXTGQbPNasehVR5TEiithSDGyd1DEiUByggTZsg8jukeIg==", + "version": "26.6.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz", + "integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "undici-types": "~8.3.0" + "undici-types": "~8.9.0" } }, "node_modules/@types/prop-types": { @@ -1291,7 +1289,6 @@ "integrity": "sha512-vfEqpXTvwT91yhmwdfouStN2hSKwTvyRs8qpLfADyrq/kxDw0hZM7Wk9Ug1FELj8hIby+S/+kQCSRFF32nv2Qw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.2.2" @@ -1448,9 +1445,9 @@ "license": "BSD-3-Clause" }, "node_modules/@xmldom/xmldom": { - "version": "0.8.13", - "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.13.tgz", - "integrity": "sha512-KRYzxepc14G/CEpEGc3Yn+JKaAeT63smlDr+vjB8jRfgTBBI9wRj/nkQEO+ucV8p8I9bfKLWp37uHgFrbntPvw==", + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.15.tgz", + "integrity": "sha512-/5NV/vDALVFDXgLmfsy9TRCBlKwO2LNBFzpzvb9iIj+jR+eSc6DLYYvVOdivT/jm7MtU6TebYuRmzEOI7w40UA==", "license": "MIT", "engines": { "node": ">=10.0.0" @@ -1512,7 +1509,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.10.44", "caniuse-lite": "^1.0.30001806", @@ -1958,7 +1954,6 @@ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -1967,9 +1962,9 @@ } }, "node_modules/pixi.js": { - "version": "8.19.0", - "resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-8.19.0.tgz", - "integrity": "sha512-pq1O6emA/GFjjeF+8d3Pb5t7knD8FsnfWGqQcRjYjsqFZ7QdzG1XgjLDUu0DFJRbafjV5+g8iNLFBx0b9649lg==", + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-8.22.0.tgz", + "integrity": "sha512-QbTANHMZ751MIjLiLSUSM8a7LNMWwMIf0KbRCqlW+SPS9hNLfSVS+cl1O2SEp9g1K/wyLzj/OJHv+1TUfiPr/w==", "license": "MIT", "workspaces": [ "examples", @@ -1979,7 +1974,7 @@ "@pixi/colord": "^2.9.6", "@types/earcut": "^3.0.0", "@webgpu/types": "^0.1.69", - "@xmldom/xmldom": "^0.8.13", + "@xmldom/xmldom": "^0.8.15", "earcut": "^3.0.2", "eventemitter3": "^5.0.1", "gifuct-js": "^2.1.2", @@ -2026,7 +2021,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", - "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -2063,7 +2057,6 @@ "integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/estree": "1.0.9" }, @@ -2235,9 +2228,9 @@ } }, "node_modules/undici-types": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz", - "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==", + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", "dev": true, "license": "MIT" }, @@ -2278,7 +2271,6 @@ "integrity": "sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", diff --git a/ui/package.json b/ui/package.json index b51e9f3..7f5f07f 100644 --- a/ui/package.json +++ b/ui/package.json @@ -15,12 +15,12 @@ "dependencies": { "chess.js": "^1.4.0", "chessground": "^9.1.1", - "pixi.js": "^8.6.6", + "pixi.js": "^8.22.0", "react": "^18.3.1", "react-dom": "^18.3.1" }, "devDependencies": { - "@types/node": "^26.1.2", + "@types/node": "^26.6.5", "@types/react": "^18.3.17", "@types/react-dom": "^18.3.5", "@vitejs/plugin-react": "^4.3.4", From 7b2c5899c7043514c1064b53f6699036c74c50f7 Mon Sep 17 00:00:00 2001 From: Soumik15630m Date: Mon, 19 Oct 2026 21:53:37 +0530 Subject: [PATCH 2/2] Refresh UI bundle for dependency update --- ui/dist/index.html | 309 ++++++++++++++++++++++++++------------------- 1 file changed, 177 insertions(+), 132 deletions(-) diff --git a/ui/dist/index.html b/ui/dist/index.html index 19fd8be..6926fd9 100644 --- a/ui/dist/index.html +++ b/ui/dist/index.html @@ -4,7 +4,7 @@ Vector Scope — STK-Vector-64 - + `})),t=this._device.createRenderPipeline({layout:"auto",vertex:{module:this._mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this._mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:e}]}}),this._pipelines[e]=t),t}generateMipmap(e){if(e.dimension==="3d")throw new Error("[GpuMipmapGenerator] a 3D texture uses Gpu3dMipmapGenerator.");if(e.dimension==="1d")throw new Error("Generating mipmaps for 1d textures is currently unsupported!");const t=this._getMipmapPipeline(e.format);let n=e;const s=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){const h={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:s},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};n=this._device.createTexture(h)}const l=this._device.createCommandEncoder({}),c=t.getBindGroupLayout(0);for(let h=0;h1?(t=GPUTextureUsage.RENDER_ATTACHMENT,e.transient&&this._renderer.device.extensions.transientAttachment&&(t|=GPUTextureUsage.TRANSIENT_ATTACHMENT)):(t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,e.uploadMethodId!=="compressed"&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC),e.storage&&(t|=GPUTextureUsage.STORAGE_BINDING),n=RR(e.format));const s=h1[e.format]||{blockWidth:1,blockHeight:1},i=Math.ceil(e.pixelWidth/s.blockWidth)*s.blockWidth,l=Math.ceil(e.pixelHeight/s.blockHeight)*s.blockHeight,c={label:e.label,size:{width:i,height:l,depthOrArrayLayers:e.depthOrArrayLayers},format:e.format,viewFormats:n,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},h=this._gpu.device.createTexture(c);return e._gpuData[this._renderer.uid]=new MR(h),this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceResize,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),h}onSourceUpdate(e){const t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onUpdateMipmaps(e){const t=this.getGpuSource(e);if(e.dimension==="3d"){this._mipmap3dGenerator??(this._mipmap3dGenerator=new PR(this._gpu.device)),this._mipmap3dGenerator.generateMipmap(t);return}this._mipmapGenerator??(this._mipmapGenerator=new kR(this._gpu.device)),this._mipmapGenerator.generateMipmap(t)}onSourceUnload(e){e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceResize,this),e.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(e){e._gcLastUsed=this._renderer.gc.now;const t=e._gpuData[this._renderer.uid],n=t==null?void 0:t.gpuTexture;n?(n.width!==e.pixelWidth||n.height!==e.pixelHeight)&&(t.destroy(),this._bindGroupHash[e.uid]=null,e._gpuData[this._renderer.uid]=null,this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuTexture)||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){const t=e.source;return this._bindGroupHash[e.uid]=new _s({0:t,1:t.style,2:new hr({uTextureMatrix:{type:"mat3x3",value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e,t){var n;const s=e.source;s._gcLastUsed=this._renderer.gc.now;let i=s._gpuData[this._renderer.uid];i||(this.initSource(s),i=s._gpuData[this._renderer.uid]);const l=t?fx(t):0;return(n=i.textureViews)[l]||(n[l]=i.gpuTexture.createView({dimension:s.viewDimension,...t})),i.textureViews[l]}getTextureRenderTargetView(e,t=0,n=0,s){var i;const l=e.source;l._gcLastUsed=this._renderer.gc.now;let c=l._gpuData[this._renderer.uid];c||(this.initSource(l),c=l._gpuData[this._renderer.uid]);const h=l.dimension==="3d";h&&(n=0);let d=n*(l.mipLevelCount||1)+t+1;return s&&(d=`${d}.${fx(s)}`),(i=c.textureViews)[d]||(i[d]=c.gpuTexture.createView({dimension:h?"3d":"2d",baseMipLevel:t,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1,...s})),c.textureViews[d]}generateCanvas(e){const t=this._renderer,n=t.gpu.device.createCommandEncoder(),s=je.get().createCanvas();s.width=e.source.pixelWidth,s.height=e.source.pixelHeight;const i=s.getContext("webgpu");return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:je.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),n.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:s.width,height:s.height}),t.gpu.device.queue.submit([n.finish()]),s}getPixels(e){const t=this.generateCanvas(e),n=xs.getOptimalCanvasAndContext(t.width,t.height),s=n.context;s.drawImage(t,0,0);const{width:i,height:l}=t,c=s.getImageData(0,0,i,l),h=new Uint8ClampedArray(c.data.buffer);return xs.returnCanvasAndContext(n),{pixels:h,width:i,height:l}}destroy(){this._managedTextures.destroy();for(const e of Object.keys(this._bindGroupHash)){const t=Number(e),n=this._bindGroupHash[t];n==null||n.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._mipmap3dGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}};vp.extension={type:[U.WebGPUSystem],name:"texture"};vp.uploadExtensions=Object.create(null);let m1=vp;Ie.handleByMap(U.TextureUploaderWebGPU,m1.uploadExtensions);class g1{constructor(){this._maxTextures=0}contextChange(e){const t=new hr({uTransformMatrix:{value:new ve,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}});this._maxTextures=e.limits.maxBatchableTextures;const n=Df({name:"graphics",bits:[a0,c0(this._maxTextures),N2,Of]});this.shader=new Dr({gpuProgram:n,resources:{localUniforms:t}})}execute(e,t){const n=t.context,s=n.customShader||this.shader,i=e.renderer,l=i.graphicsContext,{batcher:c,instructions:h}=l.getContextRenderData(n),d=i.encoder;d.setGeometry(c.geometry,s.gpuProgram);const f=i.globalUniforms.bindGroup;d.setBindGroup(0,f,s.gpuProgram);const m=i.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);d.setBindGroup(2,m,s.gpuProgram);const g=h.instructions;let y=null;for(let v=0;v",value:new ve}}}})}execute(e,t){const n=e.renderer;let s=t._shader;if(!s)s=this._shader,s.groups[2]=n.texture.getTextureBindGroup(t.texture);else if(!s.gpuProgram){Ee("Mesh shader has no gpuProgram",t.shader);return}const i=s.gpuProgram;if(i.autoAssignGlobalUniforms&&(s.groups[0]=n.globalUniforms.bindGroup),i.autoAssignLocalUniforms){const l=e.localUniforms;s.groups[1]=n.renderPipes.uniformBatch.getUniformBindGroup(l,!0)}n.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(),this._shader=null}}_1.extension={type:[U.WebGPUPipesAdaptor],name:"mesh"};const BR=[...fp,i1,n1,xp,r1,e1,m1,l1,c1,u1,a1,t1,s1,Jb],IR=[..._b,o1],NR=[X0,_1,g1],y1=[],x1=[],v1=[],b1=[];Ie.handleByNamedList(U.WebGPUSystem,y1);Ie.handleByNamedList(U.WebGPUPipes,x1);Ie.handleByNamedList(U.WebGPUPipesAdaptor,v1);Ie.handleByNamedList(U.WebGPULoader,b1);Ie.add(...BR,...IR,...NR);class FR extends Ba{constructor(){const e={name:"webgpu",type:Qn.WEBGPU,systems:y1,renderPipes:x1,renderPipeAdaptors:v1,loaders:b1};super(e)}}const DR=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:FR},Symbol.toStringTag,{value:"Module"}));Ie.add(yC,xC);const Ue={neg:6990079,pos:16761446,zero:3356221,accent:7332863,white:15855860,black:12237508,label:9671583};function Ed(r,e,t){return r+(e-r)*t}function _a(r,e,t){const n=r>>16&255,s=r>>8&255,i=r&255,l=e>>16&255,c=e>>8&255,h=e&255;return Math.round(Ed(n,l,t))<<16|Math.round(Ed(s,c,t))<<8|Math.round(Ed(i,h,t))}function px(r){const e=Math.max(-1,Math.min(1,r));return e<0?_a(Ue.zero,Ue.neg,-e):_a(Ue.zero,Ue.pos,e)}function GR(r){const e=document.createElement("canvas");e.width=e.height=r;const t=e.getContext("2d"),n=t.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.5,"rgba(255,255,255,0.9)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,r,r),Pe.from(e)}const OR=new ka({fontFamily:"ui-monospace, Menlo, Consolas, monospace",fontSize:9,letterSpacing:1.6,fill:16777215});class LR{constructor(){we(this,"app",new Zv);we(this,"ready",!1);we(this,"tex");we(this,"backdrop",new ti);we(this,"edges",new ti);we(this,"highlight",new ti);we(this,"nodes",new Yt);we(this,"labels",new Yt);we(this,"accW");we(this,"accB");we(this,"pairW");we(this,"pairB");we(this,"l1",[]);we(this,"l2",[]);we(this,"out");we(this,"squares",[]);we(this,"arch");we(this,"persp","both");we(this,"frame");we(this,"hover",null);we(this,"selected",null);we(this,"onHover");we(this,"w",0);we(this,"h",0);we(this,"pointerMove",e=>{var i;const t=this.app.canvas.getBoundingClientRect(),n=this.hitTest(e.clientX-t.left,e.clientY-t.top);(n&&this.hover?n.layer===this.hover.layer&&n.index===this.hover.index:n===this.hover)||(this.hover=n,this.app.canvas.style.cursor=n?"pointer":"crosshair",this.selected||(i=this.onHover)==null||i.call(this,n),this.frame&&this.drawEdges(this.frame))});we(this,"pointerLeave",()=>{var e;this.hover&&(this.hover=null,this.selected||(e=this.onHover)==null||e.call(this,null),this.frame&&this.drawEdges(this.frame))});we(this,"pointerDown",e=>{var i;const t=this.app.canvas.getBoundingClientRect(),n=this.hitTest(e.clientX-t.left,e.clientY-t.top),s=n&&this.selected&&n.layer===this.selected.layer&&n.index===this.selected.index;this.selected=s?null:n,(i=this.onHover)==null||i.call(this,this.selected??n),this.frame&&this.drawEdges(this.frame)})}async init(e,t,n){await this.app.init({canvas:e,backgroundAlpha:0,antialias:!0,resolution:Math.min(window.devicePixelRatio||1,2),autoDensity:!0,resizeTo:t}),this.onHover=n,this.tex=GR(48),this.app.stage.addChild(this.backdrop),this.app.stage.addChild(this.edges),this.app.stage.addChild(this.highlight),this.app.stage.addChild(this.nodes),this.app.stage.addChild(this.labels),e.addEventListener("pointermove",this.pointerMove),e.addEventListener("pointerleave",this.pointerLeave),e.addEventListener("pointerdown",this.pointerDown),e.style.cursor="crosshair",this.ready=!0}setPerspective(e){e!==this.persp&&(this.persp=e,this.w=0,this.arch&&(this.layout(this.arch),this.frame&&this.update(this.frame)))}destroy(){if(!this.ready)return;const e=this.app.canvas;e.removeEventListener("pointermove",this.pointerMove),e.removeEventListener("pointerleave",this.pointerLeave),e.removeEventListener("pointerdown",this.pointerDown),this.app.destroy(!0,{children:!0}),this.ready=!1}clearSelection(){var e;this.selected&&(this.selected=null,(e=this.onHover)==null||e.call(this,this.hover),this.frame&&this.drawEdges(this.frame))}hitTest(e,t){const n=(i,l)=>{if(!i)return null;const c=Math.floor((e-i.x)/i.cell),h=Math.floor((t-i.y)/i.cell);if(c<0||h<0||c>=i.cols||h>=i.rows)return null;const d=h*i.cols+c;return d>=i.count?null:{layer:l,index:d,x:i.x+c*i.cell+i.cell/2,y:i.y+h*i.cell+i.cell/2}},s=(i,l,c)=>{for(let h=0;h{const P=Math.ceil(b/w),M=40,I=f?Math.min(E/w,i/P):Math.min(E/w,(i-M)/2/P),A=I*w,N=I*P,z=T-A/2;if(f){const G=s+(i-N)/2,X=this.makeBlock(b,w,z,G,I),oe=this.persp==="white";return this.label(oe?"WHITE":"BLACK",z,G-12,oe?Ue.white:Ue.black),{a:oe?X:void 0,b:oe?void 0:X,x:z,bw:A,bh:N,top:G,gap:0,only:X}}const Y=s+(i-(N*2+M))/2,W=this.makeBlock(b,w,z,Y,I),D=this.makeBlock(b,w,z,Y+N+M,I);return this.label("WHITE",z,Y-12,Ue.white),this.label("BLACK",z,Y+N+M-12,Ue.black),{a:W,b:D,x:z,bw:A,bh:N,top:Y,gap:M,only:void 0}},g=m(e.hidden,32,t*.28,t*.2);this.accW=g.a,this.accB=g.b;const y=m(e.pair,16,t*.47,t*.1);this.pairW=y.a,this.pairB=y.b;const v=(b,w,T,E)=>{const P=Math.min(i*.92,b*T*3.4),M=b>1?P/(b-1):0,I=s+(i-P)/2;for(let A=0;A1?I+A*M:s+i/2,N.tint=Ue.zero,this.nodes.addChild(N),E.push(N)}};v(e.l1,t*.64,Math.max(7,i/78),this.l1),v(e.l2,t*.79,Math.max(5,i/118),this.l2),this.out=new cr(this.tex),this.out.anchor.set(.5),this.out.width=this.out.height=44,this.out.x=t*.92,this.out.y=s+i/2,this.out.tint=Ue.accent,this.nodes.addChild(this.out),this.drawBackdrop(g,y,h,d,l,f),this.frame&&this.update(this.frame)}drawBackdrop(e,t,n,s,i,l){const c=this.backdrop;c.clear();const h=9,d=(f,m,g,y)=>{c.roundRect(f-h,m-h,g+h*2,y+h*2,8),c.fill({color:1118740,alpha:.55}),c.roundRect(f-h,m-h,g+h*2,y+h*2,8),c.stroke({width:1,color:4277324,alpha:1})};d(n,s,i,i);for(const f of[e,t])d(f.x,f.top,f.bw,f.bh),l||d(f.x,f.top+f.bh+f.gap,f.bw,f.bh)}update(e){if(!this.ready||!this.arch)return;this.frame=e;const t=this.arch,n=t.actMax||127,s=e.sideToMove===0,i=s?e.accUs:e.accThem,l=s?e.accThem:e.accUs,c=s?0:t.pair,h=s?t.pair:0,d=g=>{let y=0;for(let v=0;v{const v=d(y);for(let b=0;b{for(let b=0;b{const E=T0&&e.l1Top.length>=s.l1*d*2,m=new Set,g=new Set,y=new Set;let v=!1,b=-1;if(i){switch(i.layer){case"square":b=i.index;break;case"accW":case"accB":{const T=i.index%s.pair,E=i.layer==="accW";m.add(T+(E===c?0:s.pair));break}case"pairW":case"pairB":{const T=i.layer==="pairW";m.add(i.index+(T===c?0:s.pair));break}case"l1":g.add(i.index);break;case"l2":y.add(i.index);break;case"out":v=!0;break}if(m.size&&f)for(let T=0;T{const N=T+(P-T)*.6,z=E+(M-E)*.6,Y=Math.hypot(P-T,M-E)||1,W=(P-T)/Y,D=(M-E)/Y,G=4.5;n.moveTo(N-W*G-D*G*.6,z-D*G+W*G*.6),n.lineTo(N,z),n.lineTo(N-W*G+D*G*.6,z-D*G-W*G*.6),n.stroke({width:1.1,color:I,alpha:A})};if(f){let T=1;for(let E=1;E=0?Ue.pos:Ue.neg;Y?(n.moveTo(W.x,W.y),n.lineTo(P.x,P.y),n.stroke({width:1.3+z*2.2,color:D,alpha:.65+z*.35}),m.size&&w(W.x,W.y,P.x,P.y,D,.85)):(t.moveTo(W.x,W.y),t.lineTo(P.x,P.y),t.stroke({width:.8+z*1.4,color:D,alpha:(.17+z*.5)*l}))}}}if(e.l2Contrib.length>=s.l2*s.l1){let T=1;for(let E=0;E=0?Ue.pos:Ue.neg;N?(n.moveTo(z.x,z.y),n.lineTo(P.x,P.y),n.stroke({width:1.2+A*1.8,color:Y,alpha:.55+A*.4}),g.has(M)&&A>.25&&w(z.x,z.y,P.x,P.y,Y,.8)):(t.moveTo(z.x,z.y),t.lineTo(P.x,P.y),t.stroke({width:.75+A*1,color:Y,alpha:(.13+A*.44)*l}))}}}if(this.out&&e.outContrib.length>=s.l2){let T=1;for(let E=0;E=0?Ue.pos:Ue.neg;I?(n.moveTo(A.x,A.y),n.lineTo(this.out.x,this.out.y),n.stroke({width:1.4+M*2.6,color:N,alpha:.6+M*.4}),M>.2&&w(A.x,A.y,this.out.x,this.out.y,N,.85)):(t.moveTo(A.x,A.y),t.lineTo(this.out.x,this.out.y),t.stroke({width:.9+M*2,color:N,alpha:(.2+M*.6)*l}))}}{const T=[this.accW,this.accB].filter(Boolean);for(const E of e.whiteFeatures){const P=this.squares[E.square];if(!P)continue;const M=b===E.square;for(const I of T){const A=I.x-8,N=I.y+I.rows*I.cell/2;M?(n.moveTo(P.x,P.y),n.lineTo(A,N),n.stroke({width:1.7,color:Ue.accent,alpha:.85}),w(P.x,P.y,A,N,Ue.accent,.85)):(t.moveTo(P.x,P.y),t.lineTo(A,N),t.stroke({width:.8,color:Ue.accent,alpha:.24*l}))}}}if(i){const T=this.selected!==null;n.circle(i.x,i.y,13),n.stroke({width:1.3,color:Ue.accent,alpha:.95}),T&&(n.circle(i.x,i.y,17),n.stroke({width:1,color:Ue.accent,alpha:.5}))}}}const UR=[{label:"input",hint:"active features",x:7},{label:"accumulator",hint:"2 × 1024 int16",x:27},{label:"pairwise",hint:"clipped ReLU",x:46},{label:"L1",hint:"16",x:64},{label:"L2",hint:"32",x:79},{label:"eval",hint:"centipawns",x:92}],jR="abcdefgh",zR=["","pawn","knight","bishop","rook","queen","king"],Ws=r=>`${r>0?"+":""}${r}`;function $R(r,e,t,n,s,i){switch(r.layer){case"out":{const l=e.eval>0?"pos":e.eval<0?"neg":void 0;return{head:i?"currently choosing":"engine plays",big:n[0]??"—",sub:`${Ws(e.eval)} cp · depth ${s}`,rows:[["psqt",Ws(e.psqt)],["positional",Ws(e.positional)],["bucket",`${e.bucket} / ${t.psqtBuckets}`]],line:n.length>1?n.join(" "):void 0,tone:l}}case"l1":{const l=e.l1out[r.index]??0;let c=0,h=-1,d=0;for(let g=0;gMath.abs(d)&&(d=y,h=g)}const f=e.l1TopK;let m=0;for(let g=0;gMath.abs(m)&&(m=y)}return{head:`L1 neuron ${r.index}`,big:`${l}`,sub:`activation · max ${t.actMax}`,rows:[["strongest input",Ws(m)],["drive into L2",Ws(c)],["feeds most",h>=0?`L2 ${h} (${Ws(d)})`:"—"]],move:n[0],line:`1 of ${t.l1} inputs to this evaluation`,tone:c>0?"pos":c<0?"neg":void 0}}case"l2":{const l=e.l2out[r.index]??0,c=e.outContrib[r.index]??0;let h=0;for(let d=0;d0?"raises eval":c<0?"lowers eval":"neutral"]],move:n[0],line:c>0?"raises this evaluation":c<0?"lowers this evaluation":"does not move this evaluation",tone:c>0?"pos":c<0?"neg":void 0}}default:return null}}function WR(r,e,t){const n=e.sideToMove===0,s=[];switch(r.layer){case"accW":case"accB":{const i=r.layer==="accW",l=i===n?e.accUs:e.accThem;return s.push(["value",`${l[r.index]??0}`]),s.push(["pairs with",`#${(r.index+t.pair)%t.hidden}`]),{title:`${i?"White":"Black"} accumulator #${r.index}`,rows:s}}case"pairW":case"pairB":{const i=r.layer==="pairW",l=i===n?0:t.pair,c=e.l1in[l+r.index]??0;return s.push(["activation",`${c} / ${t.actMax}`]),s.push(["feeds",`all ${t.l1} L1 neurons`]),{title:`${i?"White":"Black"} pairwise #${r.index}`,rows:s}}case"square":{const i=r.index,l=`${jR[i%8]}${Math.floor(i/8)+1}`,c=e.whiteFeatures.find(h=>h.square===i);return c?(s.push(["piece",`${c.pieceColor===0?"white":"black"} ${zR[c.pieceType]??"?"}`]),s.push(["feature index",`${c.featureIndex}`]),s.push(["oriented square",`${c.orientedSquare}`]),{title:l,rows:s}):{title:l,rows:[["","empty"]]}}default:return null}}function HR({frame:r,arch:e,nnueActive:t,pv:n,depth:s,thinking:i}){var w;const l=ue.useRef(null),c=ue.useRef(null),h=ue.useRef(null),[d,f]=ue.useState(null),[m,g]=ue.useState("both"),y=ue.useCallback(T=>f(T),[]);ue.useEffect(()=>{const T=l.current,E=c.current;if(!T||!E)return;let P=!1;const M=new LR;return M.init(T,E,y).then(()=>{if(P){M.destroy();return}h.current=M}),()=>{P=!0,h.current=null,M.destroy()}},[y]),ue.useEffect(()=>{const T=E=>{var P;E.key==="Escape"&&((P=h.current)==null||P.clearSelection())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),ue.useEffect(()=>{const T=c.current;if(!T)return;const E=new ResizeObserver(()=>{h.current&&e&&h.current.layout(e)});return E.observe(T),()=>E.disconnect()},[e]),ue.useEffect(()=>{const T=h.current;!T||!e||(T.layout(e),r&&T.update(r))},[r,e]),ue.useEffect(()=>{var T;(T=h.current)==null||T.setPerspective(m)},[m,r]);const v=d&&r&&e?$R(d,r,e,n,s,i):null,b=d&&r&&e&&!v?WR(d,r,e):null;return S.jsxs("div",{ref:c,className:"field-host",children:[S.jsx("canvas",{ref:l,className:"field-canvas"}),!t&&S.jsx("div",{className:"field-empty",children:"No NNUE net loaded — the engine is using the classical evaluation, so there is no network to show."}),S.jsx("div",{className:"persp-switch",role:"radiogroup","aria-label":"perspective",children:["white","both","black"].map(T=>S.jsx("button",{role:"radio","aria-checked":m===T,className:m===T?"on":"",onClick:()=>g(T),children:T},T))}),S.jsx("div",{className:"field-labels",children:UR.map(T=>S.jsxs("div",{style:{left:`${T.x}%`},children:[T.label,S.jsx("em",{children:T.hint})]},T.label))}),b&&d&&S.jsxs("div",{className:"field-tip",style:{left:Math.min(d.x+18,9999),top:d.y,transform:d.x>(((w=c.current)==null?void 0:w.clientWidth)??0)*.72?"translate(calc(-100% - 36px), -50%)":"translateY(-50%)"},children:[S.jsx("h4",{children:b.title}),b.rows.map(([T,E])=>S.jsxs("div",{children:[S.jsx("span",{children:T}),S.jsx("b",{className:"num",children:E})]},T))]}),v&&S.jsxs("div",{className:"decision",children:[S.jsx("h5",{children:v.head}),S.jsx("div",{className:`mv${v.tone?" "+v.tone:""}`,children:v.big}),S.jsx("div",{className:"sub",children:v.sub}),S.jsx("div",{className:"crows",children:v.rows.map(([T,E])=>S.jsxs("div",{children:[S.jsx("span",{children:T}),S.jsx("b",{className:"num",children:E})]},T))}),v.move&&S.jsxs("div",{className:"feeds",children:["feeds ",S.jsx("b",{children:v.move})]}),v.line&&S.jsx("div",{className:"line",children:v.line})]}),S.jsxs("div",{className:"field-legend",children:[S.jsxs("span",{className:"key",children:[S.jsx("span",{className:"sw neg"})," negative"]}),S.jsxs("span",{className:"key",children:[S.jsx("span",{className:"sw pos"})," positive"]}),S.jsx("span",{className:"sep"}),S.jsx("span",{className:"muted",children:"cells = value · edges = effect on eval"}),S.jsx("span",{className:"sep"}),S.jsx("span",{className:"muted",children:"width = |weight × activation|"}),S.jsx("span",{className:"sep"}),S.jsx("span",{className:"muted",children:"click a neuron to pin it · esc to release"})]})]})}function VR({source:r,state:e}){const[t,n]=ue.useState(null),[s,i]=ue.useState(null);if(ue.useEffect(()=>{let m=!0;return r.netInfo().then(g=>m&&n(g)).catch(g=>m&&i(String(g))),()=>{m=!1}},[r]),s)return S.jsxs("div",{className:"panel",children:[S.jsx("h3",{children:"Net inspector"}),S.jsx("div",{style:{color:"var(--bad)",fontSize:11},children:s})]});if(!t)return S.jsxs("div",{className:"panel",children:[S.jsx("h3",{children:"Net inspector"}),S.jsx("div",{style:{color:"var(--fg-faint)",fontSize:11},children:"loading…"})]});const l=(e==null?void 0:e.frame)??null,c=t.ftWeights,h=c?Math.max(...c.bins):1,d=t.arch.psqtBuckets??8,f=m=>m&&m.length?m.reduce((g,y)=>g+(y>0?1:0),0):0;return S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Active bucket ",S.jsx("i",{children:"live"})]}),S.jsx("div",{className:"bucket-bar",children:Array.from({length:d},(m,g)=>S.jsx("i",{className:l&&l.bucket===g?"on":"",children:g},g))}),S.jsx("div",{style:{height:8}}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"pieces on board"}),S.jsx("span",{className:"v num",children:l?l.white.featureCount+1:"—"})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"L1 firing"}),S.jsx("span",{className:"v num",children:l?`${f(l.l1out)} / ${t.arch.l1}`:"—"})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"L2 firing"}),S.jsx("span",{className:"v num",children:l?`${f(l.l2out)} / ${t.arch.l2}`:"—"})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"pairwise firing"}),S.jsx("span",{className:"v num",children:l?`${f(l.l1in)} / ${t.arch.hidden}`:"—"})]})]}),S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["King buckets ",S.jsx("i",{children:t.arch.kingBuckets})]}),S.jsx("div",{className:"kb-grid",children:Array.from({length:64},(m,g)=>{const y=(7-Math.floor(g/8))*8+g%8,v=t.kingBucketMap[y],b=v?v.bucket/(t.arch.kingBuckets-1||1):0,w=(l==null?void 0:l.white.kingSquare)===y,T=(l==null?void 0:l.black.kingSquare)===y;return S.jsx("div",{className:w?"king-w":T?"king-b":void 0,title:`square ${y} → bucket ${(v==null?void 0:v.bucket)??"?"}${v!=null&&v.mirror?" (mirrored)":""}`,style:{background:`color-mix(in srgb, var(--accent-deep) ${18+b*82}%, var(--panel-2))`},children:w?"W":T?"B":(v==null?void 0:v.bucket)??""},g)})}),S.jsxs("div",{className:"axis",children:[S.jsx("span",{children:"W / B = each side's king square"}),S.jsx("span",{children:l?`w ${l.white.kingBucket} · b ${l.black.kingBucket}`:"—"})]})]}),S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Feature transformer ",S.jsx("i",{children:"static"})]}),c?S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"hist",title:"distribution of every FT weight",children:c.bins.map((m,g)=>S.jsx("i",{style:{height:`${Math.max(1,m/h*100)}%`}},g))}),S.jsxs("div",{className:"axis",children:[S.jsx("span",{className:"num",children:c.min}),S.jsxs("span",{className:"num",children:[c.count.toLocaleString("en-US")," weights"]}),S.jsx("span",{className:"num",children:c.max})]})]}):S.jsx("div",{style:{color:"var(--fg-faint)",fontSize:11},children:"no net loaded"})]}),t.buckets&&S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Dense weights ",S.jsx("i",{children:"σ per bucket"})]}),t.buckets.map(m=>S.jsxs("div",{className:"row",style:l&&l.bucket===m.bucket?{color:"var(--accent)"}:void 0,children:[S.jsxs("span",{className:"k",style:l&&l.bucket===m.bucket?{color:"var(--accent)"}:void 0,children:["bucket ",m.bucket,l&&l.bucket===m.bucket?" ·":""]}),S.jsxs("span",{className:"v num",children:[m.l1.stddev.toFixed(1)," / ",m.l2.stddev.toFixed(1)," /"," ",m.out.stddev.toFixed(1)]})]},m.bucket)),S.jsx("div",{className:"axis",children:S.jsx("span",{children:"L1 / L2 / output"})})]})]})}function XR({s:r,send:e,probe:t}){const n=r.datagen,s=r.datagenDefaults,[i,l]=ue.useState(s.out),[c,h]=ue.useState(String(s.targetPositions)),[d,f]=ue.useState(String(s.targetGames)),[m,g]=ue.useState(String(s.nodes)),[y,v]=ue.useState(String(s.depth)),[b,w]=ue.useState(s.emit),[T,E]=ue.useState(String(s.lam)),[P,M]=ue.useState(String(s.skipPlies)),[I,A]=ue.useState(String(s.maxPlies)),[N,z]=ue.useState(String(s.openingPlies)),[Y,W]=ue.useState(String(s.balance)),[D,G]=ue.useState(String(s.shardPositions)),[X,oe]=ue.useState(String(s.seed)),[De,ee]=ue.useState(!1),[te,Z]=ue.useState(null);ue.useEffect(()=>{let ne=!0;if(n.running||!i.trim()){Z(null);return}const fe=setTimeout(()=>{t(i.trim()).then(Se=>ne&&Z(Se.resumable?Se:null)).catch(()=>ne&&Z(null))},400);return()=>{ne=!1,clearTimeout(fe)}},[i,n.running,t]);const H=(ne,fe,Se=0)=>{const ke=Number(ne.replace(/[_,\s]/g,""));return Number.isFinite(ke)&&ke>=Se?ke:fe},J=ne=>e({cmd:"datagen",action:"start",out:i.trim(),targetPositions:Math.max(1,H(c,s.targetPositions,1)),targetGames:H(d,s.targetGames),nodes:Math.max(1,H(m,s.nodes,1)),depth:Math.min(r.maxDepth,H(y,s.depth)),emit:b,lam:Math.min(1,Math.max(0,H(T,s.lam))),skipPlies:H(P,s.skipPlies),maxPlies:Math.max(1,H(I,s.maxPlies,1)),openingPlies:H(N,s.openingPlies),balance:H(Y,s.balance),seed:H(X,s.seed),shardPositions:H(D,s.shardPositions),resume:ne}),B=n.target>0?Math.min(100,n.positions/n.target*100):0,L=ne=>ne.toLocaleString("en-US"),[le,de]=ue.useState(!1);if(ue.useEffect(()=>{n.running&&de(!1)},[n.running]),(n.running||n.positions>0)&&!le){const ne=Math.max(1,n.wins+n.draws+n.losses);return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Datagen ",S.jsx("i",{children:n.running?r.paused?"paused":"running":"stopped"})]}),S.jsx("div",{className:"evalbar",style:{margin:"2px 0 8px"},children:S.jsx("div",{className:"fill",style:{left:0,width:`${B}%`}})}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"positions"}),S.jsxs("span",{className:"v num",children:[L(n.positions)," / ",L(n.target)]})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"games"}),S.jsx("span",{className:"v num",children:n.targetGames>0?`${L(n.games)} / ${L(n.targetGames)}`:L(n.games)})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"rate"}),S.jsxs("span",{className:"v num",children:[Math.round(n.positionsPerSec)," pos/s"]})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"eta"}),S.jsx("span",{className:"v num",children:n.running&&n.etaMinutes>0?`${n.etaMinutes.toFixed(1)} min`:"—"})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"w/d/l"}),S.jsxs("span",{className:"v num",children:[n.wins,"/",n.draws,"/",n.losses," ·"," ",((n.wins+n.draws/2)/ne*100).toFixed(0),"%"]})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"shard"}),S.jsx("span",{className:"v num",style:{fontSize:10},children:n.shardPath?n.shardPath.split(/[/\\]/).pop():"—"})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"dataset"}),S.jsx("span",{className:"v num",style:{fontSize:10},children:n.out.split(/[/\\]/).filter(Boolean).pop()})]}),S.jsx("div",{className:"controls",style:{marginTop:8},children:n.running?S.jsxs(S.Fragment,{children:[S.jsx("button",{className:`btn${r.paused?" on":""}`,onClick:()=>e({cmd:"pause",value:!r.paused}),children:r.paused?"resume":"pause"}),S.jsx("button",{className:"btn",onClick:()=>e({cmd:"datagen",action:"stop"}),children:"stop"})]}):S.jsx("button",{className:"btn",onClick:()=>{n.out&&l(n.out),de(!0)},children:"new run"})}),S.jsx("div",{className:"axis",style:{marginTop:6},children:S.jsx("span",{children:n.running?"settings locked while generating":`finished · ${L(n.positions)} positions in ${L(n.games)} games`})})]})}return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Datagen ",S.jsx("i",{children:"native generator"})]}),S.jsx("label",{className:"lbl",children:"output directory"}),S.jsx("input",{type:"text",value:i,onChange:ne=>l(ne.currentTarget.value)}),S.jsxs("div",{className:"field-row",children:[S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"target positions"}),S.jsx("input",{className:"numbox",type:"text",value:c,onChange:ne=>h(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"target games"}),S.jsx("input",{className:"numbox",type:"text",value:d,title:"stop after this many games as well; 0 = only the position target",onChange:ne=>f(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"nodes / move"}),S.jsx("input",{className:"numbox",type:"text",value:m,title:"node ceiling per move",onChange:ne=>g(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"depth"}),S.jsx("input",{className:"numbox",type:"text",value:y,title:"search depth; the node count caps it. 0 = node-limited only",onChange:ne=>v(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsxs("label",{className:"lbl",children:["defaults",S.jsx("b",{children:"engine"})]}),S.jsx("button",{className:"btn",style:{width:"100%",padding:"3px 6px",fontSize:10.5},title:"restore the engine's shipped settings",onClick:()=>{l(s.out),h(String(s.targetPositions)),f(String(s.targetGames)),g(String(s.nodes)),v(String(s.depth)),w(s.emit),E(String(s.lam)),M(String(s.skipPlies)),A(String(s.maxPlies)),z(String(s.openingPlies)),W(String(s.balance)),G(String(s.shardPositions)),oe(String(s.seed))},children:"reset"})]})]}),S.jsxs("div",{style:{marginTop:8},children:[S.jsx("label",{className:"lbl",children:"label format"}),S.jsx("div",{className:"seg",children:["raw","blend"].map(ne=>S.jsx("button",{className:b===ne?"on":"",onClick:()=>w(ne),title:ne==="raw"?"fen | eval | wdl (bullet-native)":"fen | blended cp",children:ne},ne))})]}),S.jsxs("button",{className:"btn",style:{marginTop:9,width:"100%"},onClick:()=>ee(ne=>!ne),children:[De?"hide":"show"," labelling options"]}),De&&S.jsxs("div",{className:"field-row",children:[S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"skip plies"}),S.jsx("input",{className:"numbox",type:"text",value:P,title:"opening plies left unlabelled",onChange:ne=>M(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"max plies"}),S.jsx("input",{className:"numbox",type:"text",value:I,title:"a game longer than this is scored a draw",onChange:ne=>A(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"opening plies"}),S.jsx("input",{className:"numbox",type:"text",value:N,title:"random balanced opening length",onChange:ne=>z(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"balance cp"}),S.jsx("input",{className:"numbox",type:"text",value:Y,title:"reject an opening more lopsided than this",onChange:ne=>W(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"rows / shard"}),S.jsx("input",{className:"numbox",type:"text",value:D,title:"rows per shard_NNNN.txt file; 0 writes one big file",onChange:ne=>G(ne.currentTarget.value)})]}),S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"seed"}),S.jsx("input",{className:"numbox",type:"text",value:X,title:"same seed reproduces the same games",onChange:ne=>oe(ne.currentTarget.value)})]}),b==="blend"&&S.jsxs("div",{children:[S.jsx("label",{className:"lbl",children:"lambda"}),S.jsx("input",{className:"numbox",type:"text",value:T,title:"WDL weight in the blend, 0..1",onChange:ne=>E(ne.currentTarget.value)})]})]}),te&&S.jsxs("div",{className:"resume-note",children:["A previous run left ",S.jsx("b",{children:L(te.positions)})," positions across"," ",S.jsx("b",{children:L(te.games)})," games here. Resuming appends to it; starting fresh overwrites it.",te.config&&S.jsxs(S.Fragment,{children:[" ","Resume keeps the settings that dataset was built with, so the fields above apply to ",S.jsx("b",{children:"start fresh"})," only:"," ",S.jsxs("b",{children:[te.config.nodes," nodes · depth ",te.config.depth," ·"," ",te.config.emit,te.config.shardPositions>0?` · shards of ${L(te.config.shardPositions)}`:" · single file"]}),"."]})]}),S.jsxs("div",{className:"controls",style:{marginTop:9},children:[S.jsx("button",{className:"btn on",onClick:()=>J(!1),children:te?"start fresh":"start"}),te&&S.jsx("button",{className:"btn",onClick:()=>J(!0),children:"resume"})]})]})}function mx({p:r,error:e}){const t=r&&r.total>0?Math.round(r.loaded/r.total*100):0;return S.jsx("div",{style:{height:"100%",display:"grid",placeItems:"center",gap:14},children:S.jsxs("div",{style:{width:420,maxWidth:"80vw",textAlign:"center"},children:[S.jsxs("div",{className:"brand",style:{fontSize:13,marginBottom:18},children:["STK",S.jsx("span",{children:"·"}),"Vector-64 ",S.jsx("span",{children:"/"})," Vector Scope"]}),e?S.jsxs("div",{role:"alert",children:[S.jsx("h2",{children:"Unable to start the engine"}),S.jsx("p",{children:e}),S.jsx("button",{onClick:()=>location.reload(),children:"Reload"})]}):S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"evalbar",style:{height:6},children:S.jsx("div",{className:"fill",style:{left:0,width:`${t}%`,transition:"width .2s linear"}})}),S.jsxs("div",{className:"num",style:{marginTop:10,fontSize:11,color:"var(--fg-dim)"},children:[(r==null?void 0:r.phase)==="net"?"network":"engine"," · ",t,"%"]}),(r==null?void 0:r.note)&&S.jsx("div",{style:{marginTop:6,fontSize:11,color:"var(--fg-faint)"},children:r.note})]})]})})}const KR="abcdefgh";function YR({plies:r,onSeek:e}){const[t,n]=ue.useState(null),s=268,i=74,{path:l,zero:c,pts:h,lo:d,hi:f}=ue.useMemo(()=>{if(r.length===0)return{path:"",zero:i/2,pts:[],lo:0,hi:0};const g=r.map(T=>T.evalWhite),y=Math.max(120,...g.map(T=>Math.abs(T))),v=T=>i/2-T/y*(i/2-4),b=T=>r.length===1?s/2:T/(r.length-1)*s,w=r.map((T,E)=>({x:b(E),y:v(T.evalWhite)}));return{path:w.map((T,E)=>`${E?"L":"M"}${T.x.toFixed(1)},${T.y.toFixed(1)}`).join(" "),zero:i/2,pts:w,lo:-y,hi:y}},[r]);if(r.length===0)return S.jsxs("div",{className:"panel",children:[S.jsx("h3",{children:"Evaluation graph"}),S.jsx("div",{className:"axis",children:"waiting for the first move…"})]});const m=t!=null?r[t]:null;return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Evaluation graph ",S.jsx("i",{children:m?`ply ${m.ply}`:`${r.length} plies`})]}),S.jsxs("svg",{className:"evalgraph",viewBox:`0 0 ${s} ${i}`,onMouseLeave:()=>n(null),children:[S.jsx("line",{x1:"0",y1:c,x2:s,y2:c,className:"zero"}),S.jsx("path",{d:`${l} L${s},${c} L0,${c} Z`,className:"fill"}),S.jsx("path",{d:l,className:"line"}),m&&t!=null&&S.jsxs(S.Fragment,{children:[S.jsx("line",{x1:h[t].x,y1:"0",x2:h[t].x,y2:i,className:"cursor"}),S.jsx("circle",{cx:h[t].x,cy:h[t].y,r:"3",className:"dot"})]}),h.map((g,y)=>S.jsx("rect",{x:g.x-s/r.length/2,y:"0",width:s/r.length,height:i,fill:"transparent",style:{cursor:"pointer"},onMouseEnter:()=>n(y),onClick:()=>e(r[y])},y))]}),S.jsxs("div",{className:"axis",children:[S.jsx("span",{className:"num",children:(d/100).toFixed(1)}),S.jsx("span",{children:m?`${m.move} · ${m.evalWhite>=0?"+":"−"}${Math.abs(m.evalWhite/100).toFixed(2)} · click to seek`:"click a point to seek there"}),S.jsxs("span",{className:"num",children:["+",(f/100).toFixed(1)]})]})]})}function qR({iters:r}){if(r.length===0)return S.jsxs("div",{className:"panel",children:[S.jsx("h3",{children:"Search shape"}),S.jsx("div",{className:"axis",children:"waiting for a search…"})]});const e=Math.max(...r.map(n=>n.seldepth),1),t=r[r.length-1];return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Search shape ",S.jsx("i",{children:"depth vs seldepth"})]}),S.jsx("div",{className:"tree",children:r.slice(-56).map((n,s)=>S.jsxs("div",{className:"col",title:`depth ${n.depth} · seldepth ${n.seldepth}`,children:[S.jsx("i",{className:"sel",style:{height:`${n.seldepth/e*100}%`}}),S.jsx("i",{className:"nom",style:{height:`${n.depth/e*100}%`}})]},s))}),S.jsxs("div",{className:"axis",children:[S.jsxs("span",{children:[S.jsx("b",{className:"sw nom"})," nominal ",S.jsx("b",{className:"sw sel"})," selective"]}),S.jsxs("span",{className:"num",children:[t.depth," / ",t.seldepth]})]})]})}function QR({s:r,send:e}){const[t,n]=ue.useState(null),[s,i]=ue.useState(null),l=r.frame?r.frame.eval*(r.frame.sideToMove===0?1:-1):r.search.scoreCp*(r.game.fen.split(" ")[1]==="b"?-1:1),c=ue.useMemo(()=>{const g=new Bc;try{g.load(r.game.fen)}catch{return[]}const y=[];for(let v=0;v<8;v++)for(let b=0;b<8;b++){const w=`${KR[b]}${8-v}`,T=g.get(w);T&&T.type!=="k"&&y.push({square:w,...T})}return y},[r.game.fen]),h=r.datagen.running,d=g=>{if(h)return;const y=new Bc;try{y.load(r.game.fen)}catch{return}t||n({fen:r.game.fen,evalWhite:l}),y.remove(g),i(g),e({cmd:"mode",value:"analysis"}),e({cmd:"position",fen:y.fen(),moves:[]})},f=()=>{h||!t||(e({cmd:"position",fen:t.fen,moves:[]}),i(null),n(null))},m=t&&s?l-t.evalWhite:null;return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Ablation ",S.jsx("i",{children:s?`without ${s}`:"remove a piece"})]}),s&&m!==null?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"with the piece"}),S.jsxs("span",{className:"v num",children:[t.evalWhite>=0?"+":"−",Math.abs(t.evalWhite/100).toFixed(2)]})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"without it"}),S.jsxs("span",{className:"v num",children:[l>=0?"+":"−",Math.abs(l/100).toFixed(2)]})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"the net values it at"}),S.jsx("span",{className:`v num ${m<0?"pos":"neg"}`,children:(Math.abs(m)/100).toFixed(2)})]}),S.jsx("button",{className:"btn",style:{marginTop:8},onClick:f,children:"put it back"})]}):S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"ablate-grid",children:c.map(g=>S.jsxs("button",{className:`ab ${g.color==="w"?"wp":"bp"}`,title:`remove the ${g.color==="w"?"white":"black"} ${g.type.toUpperCase()} on ${g.square}`,onClick:()=>d(g.square),children:[g.color==="w"?g.type.toUpperCase():g.type,S.jsx("em",{children:g.square})]},g.square))}),S.jsx("div",{className:"axis",children:S.jsx("span",{children:"switches to analysis on that position"})})]})]})}function ZR({s:r,send:e}){const t=r.record,[n,s]=ue.useState("frames.jsonl"),[i,l]=ue.useState(null),c=r.datagen.running,h=async()=>{if(l(null),t.recording){await e({cmd:"record",value:""});return}const f=n.trim();if(!f){l("needs a file name");return}await e({cmd:"record",value:f})||l("could not open that file")},d=t.recording?t.path:n;return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Recorder",S.jsx("i",{children:t.recording?`${t.frames.toLocaleString("en-US")} frames`:t.frames>0?`wrote ${t.frames.toLocaleString("en-US")} frames`:"jsonl · one line per frame"})]}),S.jsxs("label",{className:"lbl",children:["file",i&&S.jsx("b",{style:{color:"var(--bad)"},children:i})]}),S.jsx("input",{type:"text",value:d,disabled:c||t.recording,title:t.recording?"stop recording to change the file":"written relative to where the visualizer was started",onChange:f=>{s(f.currentTarget.value),l(null)}}),S.jsx("div",{className:"controls",style:{marginTop:8},children:S.jsx("button",{className:`btn${t.recording?" on":""}`,disabled:c,title:c?"locked while generating data":"append every frame",onClick:()=>void h(),children:t.recording?"stop":"record"})}),t.recording&&S.jsxs("div",{className:"row",style:{marginTop:6},children:[S.jsx("span",{className:"k",children:"writing"}),S.jsx("span",{className:"v num",style:{fontSize:10},children:t.path.split(/[/\\]/).pop()})]})]})}function JR(r){const[e,t]=ue.useState([]),[n,s]=ue.useState([]),i=ue.useRef(-1),l=ue.useRef(-1),c=ue.useRef("");return ue.useEffect(()=>{if(!r)return;const h=r.game;if(h.gameIndex!==l.current||h.ply[...m,{ply:h.ply,evalWhite:f,move:h.lastMove,fen:h.fen,depth:r.search.depth,seldepth:r.search.seldepth,nodes:r.search.nodes,nps:r.search.nps}].slice(-400))}const d=`${h.ply}:${r.search.depth}:${r.search.nodes}`;r.search.depth>0&&d!==c.current&&(c.current=d,s(f=>[...f,{depth:r.search.depth,seldepth:r.search.seldepth,nodes:r.search.nodes,ply:h.ply}].slice(-160)))},[r]),{plies:e,iters:n}}function pt({k:r,v:e,tone:t}){return S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:r}),S.jsx("span",{className:`v num${t?" "+t:""}`,children:e})]})}const Cc=r=>r.toLocaleString("en-US"),gx=r=>`${r>0?"+":""}${r}`;function eB({s:r}){const e=r.frame,t=r.game.fen.split(" ")[1]==="b"?-1:1,n=e?e.eval*(e.sideToMove===0?1:-1):r.search.scoreCp*t,s=50+50*Math.tanh(n/400),i=n>15?"pos":n<-15?"neg":void 0;return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Evaluation ",S.jsx("i",{children:"white"})]}),S.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[S.jsxs("span",{className:`eval-big${i?" "+i:""}`,children:[n>=0?"+":"−",Math.abs(n/100).toFixed(2)]}),S.jsx("span",{className:"eval-side",children:n>40?"white better":n<-40?"black better":"level"})]}),S.jsxs("div",{className:"evalbar",children:[S.jsx("div",{className:"fill",style:n>=0?{left:"50%",width:`${s-50}%`}:{left:`${s}%`,width:`${50-s}%`}}),S.jsx("div",{className:"mid"})]}),S.jsx(pt,{k:"psqt",v:e?gx(e.psqt):"—"}),S.jsx(pt,{k:"positional",v:e?gx(e.positional):"—"}),S.jsx(pt,{k:"bucket",v:e?`${e.bucket} / ${r.arch.psqtBuckets}`:"—"})]})}function S1({s:r,onHover:e}){const t=r.search.candidates;if(t.length===0)return null;const n=t.map(h=>h.scoreCp),s=Math.min(...n),i=Math.max(...n),l=Math.max(1,i-s),c=r.game.fen.split(" ")[1]==="b"?-1:1;return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Candidates ",S.jsxs("i",{children:[t.length," searched"]})]}),t.map((h,d)=>{const f=h.scoreCp*c;return S.jsxs("div",{className:`cand${d===0?" best":""}`,onMouseEnter:()=>e==null?void 0:e(h.move),onMouseLeave:()=>e==null?void 0:e(null),title:h.pv.join(" "),children:[S.jsx("span",{className:"rank num",children:d+1}),S.jsx("span",{className:"mv num",children:h.move}),S.jsx("span",{className:"bar",children:S.jsx("i",{style:{width:`${(h.scoreCp-s)/l*100}%`}})}),S.jsxs("span",{className:`sc num ${f>=0?"pos":"neg"}`,children:[f>=0?"+":"−",Math.abs(f/100).toFixed(2)]})]},h.move)}),S.jsx("div",{className:"axis",children:S.jsx("span",{children:"white perspective · exact scores, full window each"})})]})}const tB=r=>{const e=Math.max(0,Math.round(r/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`};function nB({s:r}){if(r.mode!=="human")return null;const e=r.game,t=e.fen.split(" ")[1]==="b"?1:0,n=s=>s<3e4;return S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Clock ",S.jsx("i",{children:e.clockRunning?"running":"paused"})]}),S.jsx("div",{className:"clocks",children:[0,1].map(s=>{const i=s===0?e.whiteMs:e.blackMs,l=r.engineColor===s;return S.jsxs("div",{className:`clk${t===s?" on":""}${n(i)?" low":""}`,children:[S.jsxs("span",{className:"who",children:[s===0?"white":"black",l?" · engine":" · you"]}),S.jsx("span",{className:"t num",children:tB(i)})]},s)})})]})}function rB({s:r}){const e=r.search;return S.jsxs("div",{className:"panel rz",style:{height:262},children:[S.jsxs("h3",{children:["Search ",S.jsx("i",{children:r.thinking?"thinking":"idle"})]}),S.jsx(pt,{k:"depth / seldepth",v:`${e.depth} / ${e.seldepth}`}),S.jsx(pt,{k:"nodes",v:Cc(e.nodes)}),S.jsx(pt,{k:"nps",v:e.nps?Cc(e.nps):"—"}),S.jsx(pt,{k:"time",v:`${e.elapsedMs} ms`}),S.jsx(pt,{k:"threads",v:`${r.threads}`}),S.jsx(pt,{k:"tt hit · main",v:`${e.negamaxTtHitRate.toFixed(1)}%`}),S.jsx(pt,{k:"tt hit · qsearch",v:`${e.qsearchTtHitRate.toFixed(1)}%`}),S.jsx(pt,{k:"tb hits",v:e.tbHits>0?Cc(e.tbHits):"—"}),S.jsx("div",{className:"pv",style:{marginTop:6},children:e.pv.join(" ")||"—"})]})}function sB({s:r}){const e=r.frame,t=r.arch;return S.jsxs("div",{className:"panel",children:[S.jsx("h3",{children:"Network"}),S.jsx(pt,{k:"features",v:`${Cc(t.features)} × 2`}),S.jsx(pt,{k:"accumulator",v:`${t.hidden} int16 × 2`}),S.jsx(pt,{k:"dense",v:`${t.pair*2} → ${t.l1} → ${t.l2} → 1`}),S.jsx(pt,{k:"king buckets",v:`${t.kingBuckets}`}),S.jsx(pt,{k:"active features w/b",v:e?`${e.white.featureCount} / ${e.black.featureCount}`:"—"}),S.jsx(pt,{k:"king bucket w/b",v:e?`${e.white.kingBucket} / ${e.black.kingBucket}`:"—"}),S.jsx(pt,{k:"mirrored w/b",v:e?`${e.white.mirrored?"yes":"no"} / ${e.black.mirrored?"yes":"no"}`:"—"})]})}function iB({s:r}){const e=r.game,t=Math.max(1,e.wins+e.draws+e.losses),n=ue.useRef(null);return ue.useEffect(()=>{const s=n.current;s&&(s.scrollTop=s.scrollHeight)},[e.ply,e.gameIndex]),S.jsxs("div",{className:"panel rz",style:{height:250},children:[S.jsxs("h3",{children:["Game ",S.jsxs("i",{children:["#",e.gameIndex]})]}),S.jsx(pt,{k:"ply",v:`${e.ply}`}),S.jsx(pt,{k:"result",v:e.over?`${e.result} · ${e.reason}`:"in progress"}),S.jsx(pt,{k:"session w/d/l",v:`${e.wins}/${e.draws}/${e.losses}`}),S.jsx(pt,{k:"white score",v:`${((e.wins+e.draws/2)/t*100).toFixed(1)}%`}),S.jsx("div",{className:"moves",ref:n,style:{marginTop:6},children:e.moves.length===0?"—":e.moves.map((s,i)=>S.jsxs("span",{className:`mv${i===e.moves.length-1?" last":""}`,children:[i%2===0?`${Math.floor(i/2)+1}.`:"",s," "]},`${i}-${s}`))})]})}function oB(){const[r,e]=ue.useState(null),[t,n]=ue.useState(null),[s,i]=ue.useState(null),[l,c]=ue.useState(null),[h,d]=ue.useState("connecting"),[f,m]=ue.useState(null),[g,y]=ue.useState(!1),[v,b]=ue.useState(!1),[w,T]=ue.useState("live"),[E,P]=ue.useState({left:332,right:300}),M=ue.useRef(null);ue.useEffect(()=>{const D=X=>{const oe=M.current;if(!oe)return;const De=X.clientX-oe.x0,ee=oe.side==="left"?oe.w0+De:oe.w0-De,te=Math.max(240,window.innerWidth*.34),Z=Math.min(te,Math.max(240,ee));P(H=>({...H,[oe.side]:Z}))},G=()=>{M.current=null,document.body.style.cursor="",document.querySelectorAll(".gutter.drag").forEach(X=>X.classList.remove("drag"))};return window.addEventListener("pointermove",D),window.addEventListener("pointerup",G),()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",G)}},[]);const I=D=>G=>{M.current={side:D,x0:G.clientX,w0:E[D]},document.body.style.cursor="col-resize",G.currentTarget.classList.add("drag")};ue.useEffect(()=>{let D=!0;return Sw(G=>D&&n(G)).then(G=>{D&&(e(G),n(null))}).catch(G=>{D&&(n(null),i(G instanceof Error?G.message:"The engine could not start."),d("error"))}),()=>{D=!1}},[]),ue.useEffect(()=>{if(!r)return;const D=r.subscribe(X=>{c(X),d("live")}),G=setTimeout(()=>d(X=>X==="connecting"?"error":X),12e3);return()=>{D(),clearTimeout(G)}},[r]);const{plies:A,iters:N}=JR(l),z=D=>r?r.send(D):Promise.resolve(!1),Y=D=>{!l||l.datagen.running||(z({cmd:"mode",value:"analysis"}),z({cmd:"position",fen:l.game.startFen,moves:l.game.moves.slice(0,D)}))},W=async D=>await(await fetch("/api/control",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cmd:"datagen",action:"probe",out:D})})).json();return s?S.jsx(mx,{error:s}):t?S.jsx(mx,{p:t}):S.jsxs("div",{className:"app",style:{gridTemplateColumns:`${E.left}px minmax(0, 1fr) ${E.right}px`},children:[S.jsxs("div",{className:"topbar",children:[S.jsxs("div",{className:"brand",children:["STK",S.jsx("span",{children:"·"}),"Vector-64 ",S.jsx("span",{children:"/"})," Vector Scope"]}),S.jsx("div",{style:{flex:1}}),l&&S.jsxs(S.Fragment,{children:[S.jsx("span",{className:`chip${l.thinking?" on":""}`,children:l.thinking?"thinking":l.paused?"paused":"idle"}),S.jsx("span",{className:"chip",children:l.nnueActive?"NNUE":"classical"}),S.jsxs("span",{className:"chip",children:[S.jsx("b",{children:l.threads})," thread",l.threads===1?"":"s"]}),S.jsxs("button",{className:`chip act${v?" on":""}`,onClick:()=>b(D=>!D),title:"speed and search counters",children:[S.jsx("b",{children:l.search.nps?(l.search.nps/1e6).toFixed(2):"0.00"})," ","Mnps"]})]}),S.jsx("button",{className:`btn${w==="net"?" on":""}`,onClick:()=>T(D=>D==="net"?"live":"net"),children:"net inspector"})]}),S.jsxs("div",{className:"col col-left",children:[S.jsx("div",{className:"board-slot",onClick:()=>y(!0),title:"click to enlarge",children:S.jsx(Kx,{state:l,highlight:f,onMove:D=>z({cmd:"move",value:D})})}),S.jsxs("div",{className:"col-scroll",children:[l&&l.mode==="datagen"&&S.jsx(XR,{s:l,send:z,probe:W}),l&&S.jsx(nB,{s:l}),l&&S.jsx(eB,{s:l}),l&&S.jsx(S1,{s:l,onHover:m}),l&&S.jsx(mC,{s:l,send:z}),l&&S.jsx(iB,{s:l})]})]}),S.jsx("div",{className:"gutter",style:{left:E.left+12},onPointerDown:I("left"),title:"drag to resize"}),S.jsx("div",{className:"gutter",style:{right:E.right+12,left:"auto"},onPointerDown:I("right"),title:"drag to resize"}),S.jsx("div",{className:"center",children:S.jsx(HR,{frame:(l==null?void 0:l.frame)??null,arch:(l==null?void 0:l.arch)??null,nnueActive:(l==null?void 0:l.nnueActive)??!1,pv:(l==null?void 0:l.search.pv)??[],depth:(l==null?void 0:l.search.depth)??0,thinking:(l==null?void 0:l.thinking)??!1})}),S.jsxs("div",{className:"col col-right",children:[S.jsx("div",{className:"seg",style:{marginBottom:0},children:["live","net","tools"].map(D=>S.jsx("button",{className:w===D?"on":"",onClick:()=>T(D),children:D},D))}),S.jsxs("div",{className:"col-scroll",children:[w==="net"&&r&&S.jsx(VR,{source:r,state:l}),w==="live"&&l&&S.jsxs(S.Fragment,{children:[S.jsx(rB,{s:l}),S.jsx(sB,{s:l})]}),w==="tools"&&l&&S.jsxs(S.Fragment,{children:[S.jsx(YR,{plies:A,onSeek:D=>Y(D.ply)}),S.jsx(qR,{iters:N}),S.jsx(QR,{s:l,send:z}),S.jsx(ZR,{s:l,send:z})]})]})]}),v&&l&&S.jsx(aB,{s:l,onClose:()=>b(!1)}),g&&l&&S.jsx(lB,{state:l,highlight:f,onMove:D=>z({cmd:"move",value:D}),onClose:()=>y(!1)}),S.jsxs("div",{className:"statusbar",children:[S.jsxs("span",{children:[S.jsx("span",{className:`dot ${h==="live"?"live":h==="error"?"err":""}`}),h==="live"?`live · ${(r==null?void 0:r.label)??""}`:h==="connecting"?"connecting…":"no engine — is ChessEngine-viz running?"]}),l&&S.jsxs(S.Fragment,{children:[S.jsxs("span",{className:"num",children:["seq ",l.seq.toLocaleString("en-US")]}),S.jsx("span",{className:"num fen",children:l.game.fen})]}),S.jsx("div",{style:{flex:1}}),S.jsx("span",{children:"every value shown is the engine's own output"})]})]})}function aB({s:r,onClose:e}){const t=r.search,n=[["speed",`${(t.nps/1e6).toFixed(3)} Mnps`],["nodes this search",t.nodes.toLocaleString("en-US")],["time",`${t.elapsedMs} ms`],["depth / seldepth",`${t.depth} / ${t.seldepth}`],["threads",`${r.threads} of ${r.hardwareThreads}`],["nps per thread",`${(t.nps/Math.max(1,r.threads)/1e6).toFixed(3)} Mnps`],["tt hit · main",`${t.negamaxTtHitRate.toFixed(1)}%`],["tt hit · qsearch",`${t.qsearchTtHitRate.toFixed(1)}%`],["tb hits",t.tbHits?t.tbHits.toLocaleString("en-US"):"—"],["candidates searched",`${t.candidates.length}`],["evaluation",r.nnueActive?"NNUE (H=1024)":"classical"]];return S.jsx("div",{className:"overlay",onClick:e,children:S.jsxs("div",{className:"sheet",onClick:s=>s.stopPropagation(),children:[S.jsxs("h3",{children:["Performance ",S.jsx("i",{children:"click anywhere to close"})]}),n.map(([s,i])=>S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:s}),S.jsx("span",{className:"v num",children:i})]},s)),S.jsx("div",{className:"pv",style:{marginTop:8},children:t.pv.join(" ")||"—"})]})})}function lB({state:r,highlight:e,onMove:t,onClose:n}){ue.useEffect(()=>{const c=h=>h.key==="Escape"&&n();return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n]);const s=r.game,i=s.fen.split(" ")[1]==="b"?-1:1,l=r.frame?r.frame.eval*(r.frame.sideToMove===0?1:-1):r.search.scoreCp*i;return S.jsx("div",{className:"overlay",onClick:n,children:S.jsxs("div",{className:"board-sheet",onClick:c=>c.stopPropagation(),children:[S.jsx("div",{className:"big-board",children:S.jsx(Kx,{state:r,highlight:e,onMove:t})}),S.jsxs("div",{className:"board-side",children:[S.jsxs("div",{className:"panel",children:[S.jsxs("h3",{children:["Position ",S.jsxs("i",{children:["game #",s.gameIndex]})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"evaluation"}),S.jsxs("span",{className:"v num",children:[l>=0?"+":"−",Math.abs(l/100).toFixed(2)]})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"to move"}),S.jsx("span",{className:"v",children:i===1?"white":"black"})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"ply"}),S.jsx("span",{className:"v num",children:s.ply})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"result"}),S.jsx("span",{className:"v",children:s.over?`${s.result} · ${s.reason}`:"in progress"})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"fen"}),S.jsx("span",{className:"v"})]}),S.jsx("div",{className:"pv",style:{height:34},children:s.fen})]}),r.search.candidates.length>0&&S.jsx(S1,{s:r}),S.jsxs("div",{className:"panel",style:{minHeight:0},children:[S.jsx("h3",{children:"Moves"}),S.jsx("div",{className:"moves",style:{height:150},children:s.moves.length===0?"—":s.moves.map((c,h)=>S.jsxs("span",{className:`mv${h===s.moves.length-1?" last":""}`,children:[h%2===0?`${Math.floor(h/2)+1}.`:"",c," "]},`${h}-${c}`))})]})]})]})})}mw.createRoot(document.getElementById("root")).render(S.jsx(ue.StrictMode,{children:S.jsx(oB,{})}));Ie.add(GE);Ie.mixin(Yt,OE);Ie.add(T0);Ie.add(C0);Ie.mixin(Yt,y2);Ie.add(R0,M0);Ie.add(A0);const cB=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),uB=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));