
import { VoxelGrid } from "../grid/VoxelGrid.js";
import { VoidSeepDepthsGenerator } from "./VoidSeepDepthsGenerator.js";

console.log("Starting Void Seep Lighting Verification...");

try {
    const grid = new VoxelGrid(40, 40, 40);
    const generator = new VoidSeepDepthsGenerator(grid, 12345);
    
    // Stub OffscreenCanvas if running in Node (already handled in Generator but good to be safe)
    if (typeof global.OffscreenCanvas === 'undefined') {
        global.OffscreenCanvas = class {
            constructor() {}
            getContext() { return { fillRect:()=>{}, fillStyle:"", strokeStyle:"", beginPath:()=>{}, moveTo:()=>{}, lineTo:()=>{}, stroke:()=>{}, transferToImageBitmap:()=>({}) }; }
        };
    }

    console.log("Generating...");
    generator.generate(1);
    
    let glowingPillarCount = 0;
    
    for(let x=0; x<40; x++) {
        for(let y=0; y<40; y++) {
            for(let z=0; z<40; z++) {
                const id = grid.getCell(x, y, z);
                if (id === 53) glowingPillarCount++;
            }
        }
    }
    
    console.log(`Generation Complete.`);
    console.log(`Glowing Pillar Voxels: ${glowingPillarCount}`);
    
    if (glowingPillarCount === 0) {
        console.warn("No Glowing Pillars found! (Might be bad luck or logic error, but 30% chance should produce some)");
        // Don't throw, just warn, as it is procedural.
    } else {
        console.log("Verified: Glowing Pillars exist.");
    }
    
    console.log("Lighting Verification Passed!");
} catch (e) {
    console.error("Verification Failed:", e);
    process.exit(1);
}
