/* gen-city has synchronous internals; only this Worker may execute its bundle. */ 'use strict'; importScripts('/static/vendor/city-generator/gen-city.bundle.js?v=1.4.6.2'); let busy = false; self.onmessage = async event => { if (busy) return; const {id, key, width, height} = event.data || {}; if (!Number.isInteger(id) || typeof key !== 'string' || !key || key.length > 256 || !Number.isInteger(width) || !Number.isInteger(height) || width < 64 || width > 320 || height < 64 || height > 240) { self.postMessage({id, error: 'Invalid City generation bounds'}); return; } busy = true; try { const fabric = await self.PagesWikiGenCity.generateFabric(key, width, height); if (fabric.roads.length > 4096 || fabric.buildings.length > 4096) throw new Error('City geometry budget exceeded'); self.postMessage({id, fabric}); } catch (_) { self.postMessage({id, error: 'City generation failed'}); } finally { busy = false; } };