@shieldbattery/broodmap 0.0.0-stage → 0.2.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.
@@ -0,0 +1,1659 @@
1
+ /* @ts-self-types="./broodmap_wasm.d.ts" */
2
+
3
+ /**
4
+ * Owned terrain-only components and evidence for the supplied boundary spans.
5
+ * Labels remain valid after the source analysis is freed or its obstacle mode changes.
6
+ */
7
+ export class AreaSnapshot {
8
+ static __wrap(ptr) {
9
+ const obj = Object.create(AreaSnapshot.prototype);
10
+ obj.__wbg_ptr = ptr;
11
+ AreaSnapshotFinalization.register(obj, obj.__wbg_ptr, obj);
12
+ return obj;
13
+ }
14
+ __destroy_into_raw() {
15
+ const ptr = this.__wbg_ptr;
16
+ this.__wbg_ptr = 0;
17
+ AreaSnapshotFinalization.unregister(this);
18
+ return ptr;
19
+ }
20
+ free() {
21
+ const ptr = this.__destroy_into_raw();
22
+ wasm.__wbg_areasnapshot_free(ptr, 0);
23
+ }
24
+ /**
25
+ * Returns an owned row-major Uint32Array: zero for blocked terrain, positive component IDs
26
+ * for every original walkable cell. Spans remove graph crossings, not cells.
27
+ * @returns {Uint32Array}
28
+ */
29
+ labels() {
30
+ const ret = wasm.areasnapshot_labels(this.__wbg_ptr);
31
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
32
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
33
+ return v1;
34
+ }
35
+ /**
36
+ * Per-component cell counts and per-input-span effects with all supplied cuts applied.
37
+ * A separating edge count is not evidence that this span alone disconnects the terrain.
38
+ * @returns {string}
39
+ */
40
+ metadataJson() {
41
+ let deferred2_0;
42
+ let deferred2_1;
43
+ try {
44
+ const ret = wasm.areasnapshot_metadataJson(this.__wbg_ptr);
45
+ var ptr1 = ret[0];
46
+ var len1 = ret[1];
47
+ if (ret[3]) {
48
+ ptr1 = 0; len1 = 0;
49
+ throw takeFromExternrefTable0(ret[2]);
50
+ }
51
+ deferred2_0 = ptr1;
52
+ deferred2_1 = len1;
53
+ return getStringFromWasm0(ptr1, len1);
54
+ } finally {
55
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
56
+ }
57
+ }
58
+ }
59
+ if (Symbol.dispose) AreaSnapshot.prototype[Symbol.dispose] = AreaSnapshot.prototype.free;
60
+
61
+ /**
62
+ * Incremental terrain-only topology. Owns its grid; dropping/freeing cancels unfinished work.
63
+ */
64
+ export class BaseTopologyJob {
65
+ static __wrap(ptr) {
66
+ const obj = Object.create(BaseTopologyJob.prototype);
67
+ obj.__wbg_ptr = ptr;
68
+ BaseTopologyJobFinalization.register(obj, obj.__wbg_ptr, obj);
69
+ return obj;
70
+ }
71
+ __destroy_into_raw() {
72
+ const ptr = this.__wbg_ptr;
73
+ this.__wbg_ptr = 0;
74
+ BaseTopologyJobFinalization.unregister(this);
75
+ return ptr;
76
+ }
77
+ free() {
78
+ const ptr = this.__destroy_into_raw();
79
+ wasm.__wbg_basetopologyjob_free(ptr, 0);
80
+ }
81
+ /**
82
+ * Prepares clearance or executes one origin/consolidation pass. No hard CPU-time budget.
83
+ * Returns completion status; completed jobs can be advanced again without changing results.
84
+ * @returns {boolean}
85
+ */
86
+ advance() {
87
+ const ret = wasm.basetopologyjob_advance(this.__wbg_ptr);
88
+ if (ret[2]) {
89
+ throw takeFromExternrefTable0(ret[1]);
90
+ }
91
+ return ret[0] !== 0;
92
+ }
93
+ /**
94
+ * Owned final labels; errors before successful completion, including after any failed step.
95
+ * @returns {Uint32Array}
96
+ */
97
+ labels() {
98
+ const ret = wasm.basetopologyjob_labels(this.__wbg_ptr);
99
+ if (ret[3]) {
100
+ throw takeFromExternrefTable0(ret[2]);
101
+ }
102
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
103
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
104
+ return v1;
105
+ }
106
+ /**
107
+ * @returns {string}
108
+ */
109
+ metadataJson() {
110
+ let deferred2_0;
111
+ let deferred2_1;
112
+ try {
113
+ const ret = wasm.basetopologyjob_metadataJson(this.__wbg_ptr);
114
+ var ptr1 = ret[0];
115
+ var len1 = ret[1];
116
+ if (ret[3]) {
117
+ ptr1 = 0; len1 = 0;
118
+ throw takeFromExternrefTable0(ret[2]);
119
+ }
120
+ deferred2_0 = ptr1;
121
+ deferred2_1 = len1;
122
+ return getStringFromWasm0(ptr1, len1);
123
+ } finally {
124
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
125
+ }
126
+ }
127
+ /**
128
+ * @returns {string}
129
+ */
130
+ progressJson() {
131
+ let deferred2_0;
132
+ let deferred2_1;
133
+ try {
134
+ const ret = wasm.basetopologyjob_progressJson(this.__wbg_ptr);
135
+ var ptr1 = ret[0];
136
+ var len1 = ret[1];
137
+ if (ret[3]) {
138
+ ptr1 = 0; len1 = 0;
139
+ throw takeFromExternrefTable0(ret[2]);
140
+ }
141
+ deferred2_0 = ptr1;
142
+ deferred2_1 = len1;
143
+ return getStringFromWasm0(ptr1, len1);
144
+ } finally {
145
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
146
+ }
147
+ }
148
+ }
149
+ if (Symbol.dispose) BaseTopologyJob.prototype[Symbol.dispose] = BaseTopologyJob.prototype.free;
150
+
151
+ /**
152
+ * A SC:R install's CASC storage, read through host-provided file callbacks. Pass it to
153
+ * `MapRenderer.loadAssets` in place of the `requiredAssets`/`addAsset` prefetch.
154
+ *
155
+ * `files` provides sync access to the install directory (the one containing `.build.info`).
156
+ * Paths are relative to it and use `/` separators:
157
+ *
158
+ * - `open(path)`: opens a file for reading and returns any handle value; throws if it can't.
159
+ * - `size(handle)`: the file's length in bytes.
160
+ * - `read(handle, buffer, position)`: reads up to `buffer.length` bytes at `position` into the
161
+ * `Uint8Array` `buffer`, returning how many were read (0 only at end of file).
162
+ * - `close(handle)`: closes a handle `open` returned.
163
+ * - `listDir(path)`: the names of the entries in a directory, or `[]` if it doesn't exist.
164
+ *
165
+ * In Node these map one to one onto `fs.openSync`, `fs.fstatSync(fd).size`, `fs.readSync`,
166
+ * `fs.closeSync` and `fs.readdirSync`. Every callback is called with `files` as `this`. `read`'s
167
+ * `buffer` is a view of WASM memory that's filled in place, so the callbacks must not call back
168
+ * into this module.
169
+ *
170
+ * `options` is optional `CascStorageOptions` JSON: `{ "cacheBytes": 134217728 }` bounds the
171
+ * shared cache of decoded assets (least recently used are evicted first; 0 disables caching).
172
+ *
173
+ * Data archives stay open until the storage is freed (`free()`).
174
+ */
175
+ export class CascStorage {
176
+ __destroy_into_raw() {
177
+ const ptr = this.__wbg_ptr;
178
+ this.__wbg_ptr = 0;
179
+ CascStorageFinalization.unregister(this);
180
+ return ptr;
181
+ }
182
+ free() {
183
+ const ptr = this.__destroy_into_raw();
184
+ wasm.__wbg_cascstorage_free(ptr, 0);
185
+ }
186
+ /**
187
+ * The total size of the decoded assets currently cached.
188
+ * @returns {number}
189
+ */
190
+ get cachedBytes() {
191
+ const ret = wasm.cascstorage_cachedBytes(this.__wbg_ptr);
192
+ return ret >>> 0;
193
+ }
194
+ /**
195
+ * Opens the storage, reading the install's build info, indices, encoding table and root
196
+ * catalog (a few MB). Throws if `files` lacks a callback or the directory isn't a readable
197
+ * SC:R install.
198
+ * @param {CascFiles} files
199
+ * @param {string | null} [options]
200
+ */
201
+ constructor(files, options) {
202
+ var ptr0 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
203
+ var len0 = WASM_VECTOR_LEN;
204
+ const ret = wasm.cascstorage_new(files, ptr0, len0);
205
+ if (ret[2]) {
206
+ throw takeFromExternrefTable0(ret[1]);
207
+ }
208
+ this.__wbg_ptr = ret[0];
209
+ CascStorageFinalization.register(this, this.__wbg_ptr, this);
210
+ return this;
211
+ }
212
+ /**
213
+ * The install's game version from its build info (e.g. `"1.23.10.13515"`), if recorded.
214
+ * Useful in cache keys for rendered images, since a game patch can change the assets.
215
+ * @returns {string | undefined}
216
+ */
217
+ get version() {
218
+ const ret = wasm.cascstorage_version(this.__wbg_ptr);
219
+ let v1;
220
+ if (ret[0] !== 0) {
221
+ v1 = getStringFromWasm0(ret[0], ret[1]);
222
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
223
+ }
224
+ return v1;
225
+ }
226
+ }
227
+ if (Symbol.dispose) CascStorage.prototype[Symbol.dispose] = CascStorage.prototype.free;
228
+
229
+ /**
230
+ * A parsed map plus the assets fed to it so far. See the module docs for the prefetch/render
231
+ * flow.
232
+ */
233
+ export class MapRenderer {
234
+ __destroy_into_raw() {
235
+ const ptr = this.__wbg_ptr;
236
+ this.__wbg_ptr = 0;
237
+ MapRendererFinalization.unregister(this);
238
+ return ptr;
239
+ }
240
+ free() {
241
+ const ptr = this.__destroy_into_raw();
242
+ wasm.__wbg_maprenderer_free(ptr, 0);
243
+ }
244
+ /**
245
+ * Feeds one fetched asset back in, keyed by the CASC path `requiredAssets`/
246
+ * `requiredGraphics` returned. Unknown paths are an error (they'd silently never be read).
247
+ * @param {string} casc_path
248
+ * @param {Uint8Array} bytes
249
+ */
250
+ addAsset(casc_path, bytes) {
251
+ const ptr0 = passStringToWasm0(casc_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
252
+ const len0 = WASM_VECTOR_LEN;
253
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
254
+ const len1 = WASM_VECTOR_LEN;
255
+ const ret = wasm.maprenderer_addAsset(this.__wbg_ptr, ptr0, len0, ptr1, len1);
256
+ if (ret[1]) {
257
+ throw takeFromExternrefTable0(ret[0]);
258
+ }
259
+ }
260
+ /**
261
+ * Resolves terrain and initial static melee obstacles from UNIT/THG2.
262
+ * Caller-supplied units.dat defines collision bounds; no artwork is needed.
263
+ * Neutral buildings and resources block routes by default. This is a conservative
264
+ * 8-pixel approximation, not a simulation of moving units or destruction. Missing UNIT
265
+ * or THG2 chunks contribute no objects. Their parsers are permissive: incomplete trailing
266
+ * records are ignored, and obstacleCount is not a map-integrity check.
267
+ * @param {Uint8Array} cv5
268
+ * @param {Uint8Array} vf4
269
+ * @param {Uint8Array} units
270
+ * @returns {TerrainAnalysis}
271
+ */
272
+ analyzeMap(cv5, vf4, units) {
273
+ const ptr0 = passArray8ToWasm0(cv5, wasm.__wbindgen_malloc);
274
+ const len0 = WASM_VECTOR_LEN;
275
+ const ptr1 = passArray8ToWasm0(vf4, wasm.__wbindgen_malloc);
276
+ const len1 = WASM_VECTOR_LEN;
277
+ const ptr2 = passArray8ToWasm0(units, wasm.__wbindgen_malloc);
278
+ const len2 = WASM_VECTOR_LEN;
279
+ const ret = wasm.maprenderer_analyzeMap(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
280
+ if (ret[2]) {
281
+ throw takeFromExternrefTable0(ret[1]);
282
+ }
283
+ return TerrainAnalysis.__wrap(ret[0]);
284
+ }
285
+ /**
286
+ * Resolves terrain without loading any artwork or unit data. The returned snapshot
287
+ * owns its grid and remains valid independently of this renderer and its asset cache.
288
+ * Missing tile references and incomplete table records are errors: analysis must not
289
+ * silently turn absent terrain metadata into traversable ground.
290
+ * @param {Uint8Array} cv5
291
+ * @param {Uint8Array} vf4
292
+ * @returns {TerrainAnalysis}
293
+ */
294
+ analyzeTerrain(cv5, vf4) {
295
+ const ptr0 = passArray8ToWasm0(cv5, wasm.__wbindgen_malloc);
296
+ const len0 = WASM_VECTOR_LEN;
297
+ const ptr1 = passArray8ToWasm0(vf4, wasm.__wbindgen_malloc);
298
+ const len1 = WASM_VECTOR_LEN;
299
+ const ret = wasm.maprenderer_analyzeTerrain(this.__wbg_ptr, ptr0, len0, ptr1, len1);
300
+ if (ret[2]) {
301
+ throw takeFromExternrefTable0(ret[1]);
302
+ }
303
+ return TerrainAnalysis.__wrap(ret[0]);
304
+ }
305
+ /**
306
+ * Map height in tiles (0 if the map has no readable terrain).
307
+ * @returns {number}
308
+ */
309
+ get heightTiles() {
310
+ const ret = wasm.maprenderer_heightTiles(this.__wbg_ptr);
311
+ return ret >>> 0;
312
+ }
313
+ /**
314
+ * Loads every asset a render under `options` needs straight from `storage`, in place of
315
+ * the `requiredAssets`/`requiredGraphics`/`addAsset` prefetch. Returns the CASC paths of
316
+ * art assets the install doesn't have: those drawables degrade and the render still
317
+ * succeeds. Throws if a base asset (tileset or `.dat` table) is missing or any read fails.
318
+ * @param {CascStorage} storage
319
+ * @param {string} options
320
+ * @returns {string[]}
321
+ */
322
+ loadAssets(storage, options) {
323
+ _assertClass(storage, CascStorage);
324
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
325
+ const len0 = WASM_VECTOR_LEN;
326
+ const ret = wasm.maprenderer_loadAssets(this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0);
327
+ if (ret[3]) {
328
+ throw takeFromExternrefTable0(ret[2]);
329
+ }
330
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]);
331
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
332
+ return v2;
333
+ }
334
+ /**
335
+ * Renders the zero-asset minimap and encodes it as a PNG.
336
+ * @param {string} options
337
+ * @returns {Uint8Array}
338
+ */
339
+ minimapPng(options) {
340
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
+ const len0 = WASM_VECTOR_LEN;
342
+ const ret = wasm.maprenderer_minimapPng(this.__wbg_ptr, ptr0, len0);
343
+ if (ret[3]) {
344
+ throw takeFromExternrefTable0(ret[2]);
345
+ }
346
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
347
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
348
+ return v2;
349
+ }
350
+ /**
351
+ * Renders the zero-asset minimap to RGBA pixels. Needs no assets at all; if round 1's
352
+ * `.dat` tables happen to be loaded they refine dot sizing and melee filtering.
353
+ * @param {string} options
354
+ * @returns {RenderedImage}
355
+ */
356
+ minimapRgba(options) {
357
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
358
+ const len0 = WASM_VECTOR_LEN;
359
+ const ret = wasm.maprenderer_minimapRgba(this.__wbg_ptr, ptr0, len0);
360
+ if (ret[2]) {
361
+ throw takeFromExternrefTable0(ret[1]);
362
+ }
363
+ return RenderedImage.__wrap(ret[0]);
364
+ }
365
+ /**
366
+ * Parses a `.scm`/`.scx` map file (MPQ + CHK). `options` is optional `MapLimitOptions` JSON
367
+ * overriding broodmap's default resource limits.
368
+ * @param {Uint8Array} map_bytes
369
+ * @param {string | null} [options]
370
+ */
371
+ constructor(map_bytes, options) {
372
+ const ptr0 = passArray8ToWasm0(map_bytes, wasm.__wbindgen_malloc);
373
+ const len0 = WASM_VECTOR_LEN;
374
+ var ptr1 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
375
+ var len1 = WASM_VECTOR_LEN;
376
+ const ret = wasm.maprenderer_new(ptr0, len0, ptr1, len1);
377
+ if (ret[2]) {
378
+ throw takeFromExternrefTable0(ret[1]);
379
+ }
380
+ this.__wbg_ptr = ret[0];
381
+ MapRendererFinalization.register(this, this.__wbg_ptr, this);
382
+ return this;
383
+ }
384
+ /**
385
+ * Builds the render plan (the decide/draw split — see `broodmap-render`'s `plan` module)
386
+ * as JSON, for external executors like a GPU renderer. Requires round 1's assets.
387
+ * @param {string} options
388
+ * @returns {string}
389
+ */
390
+ planJson(options) {
391
+ let deferred3_0;
392
+ let deferred3_1;
393
+ try {
394
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
395
+ const len0 = WASM_VECTOR_LEN;
396
+ const ret = wasm.maprenderer_planJson(this.__wbg_ptr, ptr0, len0);
397
+ var ptr2 = ret[0];
398
+ var len2 = ret[1];
399
+ if (ret[3]) {
400
+ ptr2 = 0; len2 = 0;
401
+ throw takeFromExternrefTable0(ret[2]);
402
+ }
403
+ deferred3_0 = ptr2;
404
+ deferred3_1 = len2;
405
+ return getStringFromWasm0(ptr2, len2);
406
+ } finally {
407
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
408
+ }
409
+ }
410
+ /**
411
+ * Renders the map preview and encodes it as a PNG.
412
+ * @param {string} options
413
+ * @returns {Uint8Array}
414
+ */
415
+ renderPng(options) {
416
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
417
+ const len0 = WASM_VECTOR_LEN;
418
+ const ret = wasm.maprenderer_renderPng(this.__wbg_ptr, ptr0, len0);
419
+ if (ret[3]) {
420
+ throw takeFromExternrefTable0(ret[2]);
421
+ }
422
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
423
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
424
+ return v2;
425
+ }
426
+ /**
427
+ * Renders the map preview to RGBA pixels.
428
+ * @param {string} options
429
+ * @returns {RenderedImage}
430
+ */
431
+ renderRgba(options) {
432
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
433
+ const len0 = WASM_VECTOR_LEN;
434
+ const ret = wasm.maprenderer_renderRgba(this.__wbg_ptr, ptr0, len0);
435
+ if (ret[2]) {
436
+ throw takeFromExternrefTable0(ret[1]);
437
+ }
438
+ return RenderedImage.__wrap(ret[0]);
439
+ }
440
+ /**
441
+ * The CV5 and VF4 paths, in that order. Fetch these and pass their bytes to
442
+ * `analyzeTerrain`; they do not need to be registered with `addAsset`.
443
+ * @returns {string[]}
444
+ */
445
+ requiredAnalysisAssets() {
446
+ const ret = wasm.maprenderer_requiredAnalysisAssets(this.__wbg_ptr);
447
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
448
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
449
+ return v1;
450
+ }
451
+ /**
452
+ * Round 1 of the prefetch: the CASC paths of the base assets (tileset tables + `.dat`
453
+ * tables) this map needs under `options`. Fetch and [`add_asset`](Self::add_asset) all of
454
+ * them before calling [`required_graphics`](Self::required_graphics).
455
+ * @param {string} options
456
+ * @returns {string[]}
457
+ */
458
+ requiredAssets(options) {
459
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
460
+ const len0 = WASM_VECTOR_LEN;
461
+ const ret = wasm.maprenderer_requiredAssets(this.__wbg_ptr, ptr0, len0);
462
+ if (ret[3]) {
463
+ throw takeFromExternrefTable0(ret[2]);
464
+ }
465
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]);
466
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
467
+ return v2;
468
+ }
469
+ /**
470
+ * Round 2 of the prefetch: the CASC paths of the art assets (anims, SD canvas GRPs) the
471
+ * map's units and sprites need under `options`. Requires round 1's tables to already be
472
+ * added. A path that fails to fetch can simply be skipped — that one drawable degrades,
473
+ * the render still succeeds.
474
+ * @param {string} options
475
+ * @returns {string[]}
476
+ */
477
+ requiredGraphics(options) {
478
+ const ptr0 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
479
+ const len0 = WASM_VECTOR_LEN;
480
+ const ret = wasm.maprenderer_requiredGraphics(this.__wbg_ptr, ptr0, len0);
481
+ if (ret[3]) {
482
+ throw takeFromExternrefTable0(ret[2]);
483
+ }
484
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]);
485
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
486
+ return v2;
487
+ }
488
+ /**
489
+ * CV5, VF4, and units.dat, in that order, for `analyzeMap`.
490
+ * @returns {string[]}
491
+ */
492
+ requiredMapAnalysisAssets() {
493
+ const ret = wasm.maprenderer_requiredMapAnalysisAssets(this.__wbg_ptr);
494
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
495
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
496
+ return v1;
497
+ }
498
+ /**
499
+ * The map's scenario facts as a JSON `MapSummary`, like `summarizeMapJson`.
500
+ * @returns {string}
501
+ */
502
+ summaryJson() {
503
+ let deferred2_0;
504
+ let deferred2_1;
505
+ try {
506
+ const ret = wasm.maprenderer_summaryJson(this.__wbg_ptr);
507
+ var ptr1 = ret[0];
508
+ var len1 = ret[1];
509
+ if (ret[3]) {
510
+ ptr1 = 0; len1 = 0;
511
+ throw takeFromExternrefTable0(ret[2]);
512
+ }
513
+ deferred2_0 = ptr1;
514
+ deferred2_1 = len1;
515
+ return getStringFromWasm0(ptr1, len1);
516
+ } finally {
517
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
518
+ }
519
+ }
520
+ /**
521
+ * Map width in tiles (0 if the map has no readable terrain).
522
+ * @returns {number}
523
+ */
524
+ get widthTiles() {
525
+ const ret = wasm.maprenderer_widthTiles(this.__wbg_ptr);
526
+ return ret >>> 0;
527
+ }
528
+ }
529
+ if (Symbol.dispose) MapRenderer.prototype[Symbol.dispose] = MapRenderer.prototype.free;
530
+
531
+ /**
532
+ * An immutable region result detached from its source [`TerrainAnalysis`] snapshot.
533
+ *
534
+ * Labels are row-major 8-pixel walk cells. Zero denotes blocked terrain; positive labels are
535
+ * one-based region IDs. Passages describe one representative connection per adjacent region pair.
536
+ */
537
+ export class RegionSnapshot {
538
+ static __wrap(ptr) {
539
+ const obj = Object.create(RegionSnapshot.prototype);
540
+ obj.__wbg_ptr = ptr;
541
+ RegionSnapshotFinalization.register(obj, obj.__wbg_ptr, obj);
542
+ return obj;
543
+ }
544
+ __destroy_into_raw() {
545
+ const ptr = this.__wbg_ptr;
546
+ this.__wbg_ptr = 0;
547
+ RegionSnapshotFinalization.unregister(this);
548
+ return ptr;
549
+ }
550
+ free() {
551
+ const ptr = this.__destroy_into_raw();
552
+ wasm.__wbg_regionsnapshot_free(ptr, 0);
553
+ }
554
+ /**
555
+ * Returns an independently owned row-major `Uint32Array` of region labels.
556
+ *
557
+ * Zero is blocked terrain; region IDs begin at one and correspond to `metadataJson` entries.
558
+ * @returns {Uint32Array}
559
+ */
560
+ labels() {
561
+ const ret = wasm.regionsnapshot_labels(this.__wbg_ptr);
562
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
563
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
564
+ return v1;
565
+ }
566
+ /**
567
+ * Serializes compact region and passage metadata, without duplicating the full label buffer.
568
+ * @returns {string}
569
+ */
570
+ metadataJson() {
571
+ let deferred2_0;
572
+ let deferred2_1;
573
+ try {
574
+ const ret = wasm.regionsnapshot_metadataJson(this.__wbg_ptr);
575
+ var ptr1 = ret[0];
576
+ var len1 = ret[1];
577
+ if (ret[3]) {
578
+ ptr1 = 0; len1 = 0;
579
+ throw takeFromExternrefTable0(ret[2]);
580
+ }
581
+ deferred2_0 = ptr1;
582
+ deferred2_1 = len1;
583
+ return getStringFromWasm0(ptr1, len1);
584
+ } finally {
585
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
586
+ }
587
+ }
588
+ }
589
+ if (Symbol.dispose) RegionSnapshot.prototype[Symbol.dispose] = RegionSnapshot.prototype.free;
590
+
591
+ /**
592
+ * A rendered RGBA image, ready for `new ImageData(new Uint8ClampedArray(data), width, height)`.
593
+ */
594
+ export class RenderedImage {
595
+ static __wrap(ptr) {
596
+ const obj = Object.create(RenderedImage.prototype);
597
+ obj.__wbg_ptr = ptr;
598
+ RenderedImageFinalization.register(obj, obj.__wbg_ptr, obj);
599
+ return obj;
600
+ }
601
+ __destroy_into_raw() {
602
+ const ptr = this.__wbg_ptr;
603
+ this.__wbg_ptr = 0;
604
+ RenderedImageFinalization.unregister(this);
605
+ return ptr;
606
+ }
607
+ free() {
608
+ const ptr = this.__destroy_into_raw();
609
+ wasm.__wbg_renderedimage_free(ptr, 0);
610
+ }
611
+ /**
612
+ * The RGBA8 pixels, row-major (copies out of WASM memory).
613
+ * @returns {Uint8Array}
614
+ */
615
+ get data() {
616
+ const ret = wasm.renderedimage_data(this.__wbg_ptr);
617
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
618
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
619
+ return v1;
620
+ }
621
+ /**
622
+ * @returns {number}
623
+ */
624
+ get height() {
625
+ const ret = wasm.renderedimage_height(this.__wbg_ptr);
626
+ return ret >>> 0;
627
+ }
628
+ /**
629
+ * Non-fatal notes about things the render skipped.
630
+ * @returns {string[]}
631
+ */
632
+ get warnings() {
633
+ const ret = wasm.renderedimage_warnings(this.__wbg_ptr);
634
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
635
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
636
+ return v1;
637
+ }
638
+ /**
639
+ * @returns {number}
640
+ */
641
+ get width() {
642
+ const ret = wasm.renderedimage_width(this.__wbg_ptr);
643
+ return ret >>> 0;
644
+ }
645
+ }
646
+ if (Symbol.dispose) RenderedImage.prototype[Symbol.dispose] = RenderedImage.prototype.free;
647
+
648
+ /**
649
+ * An 8-pixel point-movement snapshot, optionally including initial static melee obstacles.
650
+ * Moving units and mover size are not represented. This does not certify engine pathing or walls.
651
+ */
652
+ export class TerrainAnalysis {
653
+ static __wrap(ptr) {
654
+ const obj = Object.create(TerrainAnalysis.prototype);
655
+ obj.__wbg_ptr = ptr;
656
+ TerrainAnalysisFinalization.register(obj, obj.__wbg_ptr, obj);
657
+ return obj;
658
+ }
659
+ __destroy_into_raw() {
660
+ const ptr = this.__wbg_ptr;
661
+ this.__wbg_ptr = 0;
662
+ TerrainAnalysisFinalization.unregister(this);
663
+ return ptr;
664
+ }
665
+ free() {
666
+ const ptr = this.__destroy_into_raw();
667
+ wasm.__wbg_terrainanalysis_free(ptr, 0);
668
+ }
669
+ /**
670
+ * Computes clearance-derived regions for the currently active terrain/obstacle grid.
671
+ *
672
+ * `minProminencePixels` must be from 8 through 4096. An omitted
673
+ * `minRelativeProminencePercent` uses the core default of 40; supplied values must be from 0
674
+ * through 100. The returned result owns its labels and metadata, so it remains valid after
675
+ * this analysis snapshot is freed or its obstacle toggle changes. Regions are a static
676
+ * square-clearance graph, not unit-fit or engine pathing data.
677
+ * @param {number} min_prominence_pixels
678
+ * @param {number | null} [min_relative_prominence_percent]
679
+ * @returns {RegionSnapshot}
680
+ */
681
+ analyzeRegions(min_prominence_pixels, min_relative_prominence_percent) {
682
+ const ret = wasm.terrainanalysis_analyzeRegions(this.__wbg_ptr, min_prominence_pixels, !isLikeNone(min_relative_prominence_percent), isLikeNone(min_relative_prominence_percent) ? 0 : min_relative_prominence_percent);
683
+ if (ret[2]) {
684
+ throw takeFromExternrefTable0(ret[1]);
685
+ }
686
+ return RegionSnapshot.__wrap(ret[0]);
687
+ }
688
+ /**
689
+ * Ground and air distances between the selected candidates' near-center walk anchors.
690
+ * Respects the current obstacle toggle. Hypothetical depots are not added as obstacles.
691
+ * Disconnected bases return null ground distance; undiscovered/out-of-range IDs are errors.
692
+ * @param {number} start_id
693
+ * @param {number} end_id
694
+ * @returns {string}
695
+ */
696
+ baseRouteJson(start_id, end_id) {
697
+ let deferred2_0;
698
+ let deferred2_1;
699
+ try {
700
+ const ret = wasm.terrainanalysis_baseRouteJson(this.__wbg_ptr, start_id, end_id);
701
+ var ptr1 = ret[0];
702
+ var len1 = ret[1];
703
+ if (ret[3]) {
704
+ ptr1 = 0; len1 = 0;
705
+ throw takeFromExternrefTable0(ret[2]);
706
+ }
707
+ deferred2_0 = ptr1;
708
+ deferred2_1 = len1;
709
+ return getStringFromWasm0(ptr1, len1);
710
+ } finally {
711
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
712
+ }
713
+ }
714
+ /**
715
+ * Starts reusable map-wide analysis from JSON [{id,routeAnchor:[walkX,walkY]|null}].
716
+ * At most 256 unique IDs and 32KiB JSON. Uses terrain alone, independent of obstacle mode.
717
+ * A missing routeAnchor is skipped like null. Advance between event-loop yields;
718
+ * completion is required for results.
719
+ * @param {string} bases_json
720
+ * @param {number | null} [min_widening_percent]
721
+ * @returns {BaseTopologyJob}
722
+ */
723
+ beginBaseTopology(bases_json, min_widening_percent) {
724
+ const ptr0 = passStringToWasm0(bases_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
725
+ const len0 = WASM_VECTOR_LEN;
726
+ const ret = wasm.terrainanalysis_beginBaseTopology(this.__wbg_ptr, ptr0, len0, !isLikeNone(min_widening_percent), isLikeNone(min_widening_percent) ? 0 : min_widening_percent);
727
+ if (ret[2]) {
728
+ throw takeFromExternrefTable0(ret[1]);
729
+ }
730
+ return BaseTopologyJob.__wrap(ret[0]);
731
+ }
732
+ /**
733
+ * Row-major bytes: bit 0 walkable, bit 1 CV5 terrain-buildability hint,
734
+ * bit 2 ramp, bits 3..4 minitile elevation (0..2), bit 5 terrain cell obstructed by a
735
+ * static map object (retained even when objects are ignored). Bit 0 respects the current
736
+ * obstacle toggle. Buildability excludes occupancy,
737
+ * footprint, creep/power, resources, and other placement restrictions.
738
+ * @returns {Uint8Array}
739
+ */
740
+ cellFlags() {
741
+ const ret = wasm.terrainanalysis_cellFlags(this.__wbg_ptr);
742
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
743
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
744
+ return v1;
745
+ }
746
+ /**
747
+ * Check proposed building rectangles and mover passage in an explicitly bounded pixel window.
748
+ * Uses original terrain plus exact static object rectangles when the obstacle toggle is enabled.
749
+ * Static placement checks omit race rules, power, creep, resource spacing, and dynamic state.
750
+ * A blocked result is local to this window and model, not a certified game wall.
751
+ * @param {string} query_json
752
+ * @returns {string}
753
+ */
754
+ checkWallJson(query_json) {
755
+ let deferred3_0;
756
+ let deferred3_1;
757
+ try {
758
+ const ptr0 = passStringToWasm0(query_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
759
+ const len0 = WASM_VECTOR_LEN;
760
+ const ret = wasm.terrainanalysis_checkWallJson(this.__wbg_ptr, ptr0, len0);
761
+ var ptr2 = ret[0];
762
+ var len2 = ret[1];
763
+ if (ret[3]) {
764
+ ptr2 = 0; len2 = 0;
765
+ throw takeFromExternrefTable0(ret[2]);
766
+ }
767
+ deferred3_0 = ptr2;
768
+ deferred3_1 = len2;
769
+ return getStringFromWasm0(ptr2, len2);
770
+ } finally {
771
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
772
+ }
773
+ }
774
+ /**
775
+ * Row-major logical-pixel radii of empty, axis-aligned squares centered on walk cells.
776
+ * Blocked cells are zero; walkable cells adjacent to a blocker or map edge are 4px.
777
+ * Values follow the obstacle toggle and include the map boundary. This is a square
778
+ * (Chebyshev) distance measure of the raster, not Euclidean distance, corridor width,
779
+ * or proof that a StarCraft unit can pass. The returned buffer is independently owned.
780
+ * @returns {Uint16Array}
781
+ */
782
+ clearancePixels() {
783
+ const ret = wasm.terrainanalysis_clearancePixels(this.__wbg_ptr);
784
+ var v1 = getArrayU16FromWasm0(ret[0], ret[1]).slice();
785
+ wasm.__wbindgen_free(ret[0], ret[1] * 2, 2);
786
+ return v1;
787
+ }
788
+ /**
789
+ * Batches up to 256 terrain-only entrance surveys without rebuilding the immutable terrain
790
+ * preparation. Input is JSON `[[[startX,startY],[endX,endY]], ...]` with strict unsigned
791
+ * integer coordinates and a 32 KiB limit. Results preserve input order and use the same
792
+ * objects returned by `entrancesJson`. Aggregate route output is capped at 2,097,152 points.
793
+ * These limits do not bound CPU time: each distinct origin can require a full-grid search.
794
+ * Callers needing responsive cancellation should submit smaller origin groups and yield
795
+ * between synchronous calls. An empty batch returns `[]` without preparing a survey.
796
+ * @param {string} queries_json
797
+ * @param {number | null} [min_widening_percent]
798
+ * @returns {string}
799
+ */
800
+ entrancesBatchJson(queries_json, min_widening_percent) {
801
+ let deferred3_0;
802
+ let deferred3_1;
803
+ try {
804
+ const ptr0 = passStringToWasm0(queries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
805
+ const len0 = WASM_VECTOR_LEN;
806
+ const ret = wasm.terrainanalysis_entrancesBatchJson(this.__wbg_ptr, ptr0, len0, !isLikeNone(min_widening_percent), isLikeNone(min_widening_percent) ? 0 : min_widening_percent);
807
+ var ptr2 = ret[0];
808
+ var len2 = ret[1];
809
+ if (ret[3]) {
810
+ ptr2 = 0; len2 = 0;
811
+ throw takeFromExternrefTable0(ret[2]);
812
+ }
813
+ deferred3_0 = ptr2;
814
+ deferred3_1 = len2;
815
+ return getStringFromWasm0(ptr2, len2);
816
+ } finally {
817
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
818
+ }
819
+ }
820
+ /**
821
+ * Finds local width transitions along a clearance-favoring route from start to end.
822
+ *
823
+ * Coordinates are 8-pixel walk cells. This always surveys terrain alone, regardless of the
824
+ * obstacle toggle: resources and neutral objects do not define geological entrances.
825
+ * `minWideningPercent` defaults to 25 and accepts integral values from 0 through 200.
826
+ * Candidate centers lie within the first 1024 logical pixels; profiles may look 192px farther.
827
+ * `outwardSampleCount` is 3 normally, or 2 when a late turn excludes the +160px sample.
828
+ * Cross-section endpoints in the JSON are logical pixels; route points are walk cells. Spans
829
+ * are raster approximations, not certified chokepoints, construction legality, unit fit, or
830
+ * shortest movement routes.
831
+ * @param {number} start_x
832
+ * @param {number} start_y
833
+ * @param {number} end_x
834
+ * @param {number} end_y
835
+ * @param {number | null} [min_widening_percent]
836
+ * @returns {string}
837
+ */
838
+ entrancesJson(start_x, start_y, end_x, end_y, min_widening_percent) {
839
+ let deferred2_0;
840
+ let deferred2_1;
841
+ try {
842
+ const ret = wasm.terrainanalysis_entrancesJson(this.__wbg_ptr, start_x, start_y, end_x, end_y, !isLikeNone(min_widening_percent), isLikeNone(min_widening_percent) ? 0 : min_widening_percent);
843
+ var ptr1 = ret[0];
844
+ var len1 = ret[1];
845
+ if (ret[3]) {
846
+ ptr1 = 0; len1 = 0;
847
+ throw takeFromExternrefTable0(ret[2]);
848
+ }
849
+ deferred2_0 = ptr1;
850
+ deferred2_1 = len1;
851
+ return getStringFromWasm0(ptr1, len1);
852
+ } finally {
853
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
854
+ }
855
+ }
856
+ /**
857
+ * Discovers and caches resource-base candidates in a snapshot made by `analyzeMap`.
858
+ * Options: `{depotWidthTiles:4,depotHeightTiles:3,maxMineralBlockerAmount:8}`.
859
+ * Set maxMineralBlockerAmount to null to disallow clearing; unknown amounts never qualify.
860
+ * allowDestructibleClearing and allowStartObstacleClearing default to true.
861
+ * requiredObstacles lists overlapping buildings requiring destruction; startClearedObstacles
862
+ * lists overlaps removed automatically if that exact start is occupied (including invincible ones).
863
+ * Candidate requiredMinerals lists direct placement prerequisites. All objects remain
864
+ * blockers for current route queries; routeAnchor is null if the whole depot area is blocked.
865
+ * IDs are zero-based in top-to-bottom, left-to-right depot order. Discovery always uses
866
+ * the initial static obstacles, independently of the route toggle. This is a heuristic:
867
+ * stock resource IDs, no creep/power or complete placement rules, and no main/natural roles.
868
+ * Unknown options and unsupported inputs fail without replacing the last successful catalog.
869
+ * @param {string} options_json
870
+ * @returns {string}
871
+ */
872
+ findBasesJson(options_json) {
873
+ let deferred3_0;
874
+ let deferred3_1;
875
+ try {
876
+ const ptr0 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
877
+ const len0 = WASM_VECTOR_LEN;
878
+ const ret = wasm.terrainanalysis_findBasesJson(this.__wbg_ptr, ptr0, len0);
879
+ var ptr2 = ret[0];
880
+ var len2 = ret[1];
881
+ if (ret[3]) {
882
+ ptr2 = 0; len2 = 0;
883
+ throw takeFromExternrefTable0(ret[2]);
884
+ }
885
+ deferred3_0 = ptr2;
886
+ deferred3_1 = len2;
887
+ return getStringFromWasm0(ptr2, len2);
888
+ } finally {
889
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
890
+ }
891
+ }
892
+ /**
893
+ * @returns {number}
894
+ */
895
+ get heightWalkTiles() {
896
+ const ret = wasm.terrainanalysis_heightWalkTiles(this.__wbg_ptr);
897
+ return ret >>> 0;
898
+ }
899
+ /**
900
+ * Number of static obstacle rectangles identified in this snapshot.
901
+ * @returns {number}
902
+ */
903
+ get obstacleCount() {
904
+ const ret = wasm.terrainanalysis_obstacleCount(this.__wbg_ptr);
905
+ return ret >>> 0;
906
+ }
907
+ /**
908
+ * Partitions terrain alone using up to 256 finite pixel-coordinate spans.
909
+ *
910
+ * Input is JSON `[[[x1,y1],[x2,y2]], ...]`, at most 32 KiB; coordinates must be
911
+ * nonnegative integers within inclusive map edges, and each span must have distinct ends.
912
+ * An empty list returns ordinary terrain components. This does not mutate routing,
913
+ * the base catalog, or obstacle mode, and does not validate wall placement.
914
+ * @param {string} spans_json
915
+ * @returns {AreaSnapshot}
916
+ */
917
+ partitionAreas(spans_json) {
918
+ const ptr0 = passStringToWasm0(spans_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
919
+ const len0 = WASM_VECTOR_LEN;
920
+ const ret = wasm.terrainanalysis_partitionAreas(this.__wbg_ptr, ptr0, len0);
921
+ if (ret[2]) {
922
+ throw takeFromExternrefTable0(ret[1]);
923
+ }
924
+ return AreaSnapshot.__wrap(ret[0]);
925
+ }
926
+ /**
927
+ * Two wall-contact spans at the ends of each recognized terrain ramp.
928
+ *
929
+ * Always uses the original terrain, independent of obstacle mode. Positions are walk cells;
930
+ * span endpoints and widths are logical pixels. These are elevation/ramp-flag observations,
931
+ * not route-local widening claims or certified movement/building-placement boundaries.
932
+ * @returns {string}
933
+ */
934
+ rampsJson() {
935
+ let deferred2_0;
936
+ let deferred2_1;
937
+ try {
938
+ const ret = wasm.terrainanalysis_rampsJson(this.__wbg_ptr);
939
+ var ptr1 = ret[0];
940
+ var len1 = ret[1];
941
+ if (ret[3]) {
942
+ ptr1 = 0; len1 = 0;
943
+ throw takeFromExternrefTable0(ret[2]);
944
+ }
945
+ deferred2_0 = ptr1;
946
+ deferred2_1 = len1;
947
+ return getStringFromWasm0(ptr1, len1);
948
+ } finally {
949
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
950
+ }
951
+ }
952
+ /**
953
+ * Routes between 8-pixel cell centers. Both endpoints must be walkable; they are
954
+ * never silently moved. Points include both endpoints. Disconnected endpoints return
955
+ * an empty point list and null groundDistancePixels. Distances use logical pixels,
956
+ * independent of preview resolution. Ground costs are 8 / 11.312 pixels per step
957
+ * (fixed-point octile approximation), with no diagonal corner cutting.
958
+ * @param {number} start_x
959
+ * @param {number} start_y
960
+ * @param {number} end_x
961
+ * @param {number} end_y
962
+ * @returns {string}
963
+ */
964
+ routeJson(start_x, start_y, end_x, end_y) {
965
+ let deferred2_0;
966
+ let deferred2_1;
967
+ try {
968
+ const ret = wasm.terrainanalysis_routeJson(this.__wbg_ptr, start_x, start_y, end_x, end_y);
969
+ var ptr1 = ret[0];
970
+ var len1 = ret[1];
971
+ if (ret[3]) {
972
+ ptr1 = 0; len1 = 0;
973
+ throw takeFromExternrefTable0(ret[2]);
974
+ }
975
+ deferred2_0 = ptr1;
976
+ deferred2_1 = len1;
977
+ return getStringFromWasm0(ptr1, len1);
978
+ } finally {
979
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
980
+ }
981
+ }
982
+ /**
983
+ * Choose object-aware routing or the original terrain-only model. Turning this off
984
+ * ignores every obstacle, including invincible buildings; it does not simulate removal.
985
+ * @param {boolean} enabled
986
+ */
987
+ setObstaclesEnabled(enabled) {
988
+ wasm.terrainanalysis_setObstaclesEnabled(this.__wbg_ptr, enabled);
989
+ }
990
+ /**
991
+ * Starts a bounded, resumable search for static wall layouts. Construction prepares terrain
992
+ * and candidates synchronously, so its bounded preprocessing can still occupy one event-loop turn.
993
+ * The job snapshots the selected
994
+ * terrain/obstacle model, so later obstacle-toggle changes do not affect it.
995
+ * @param {string} query_json
996
+ * @returns {WallSearchJob}
997
+ */
998
+ startWallSearch(query_json) {
999
+ const ptr0 = passStringToWasm0(query_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1000
+ const len0 = WASM_VECTOR_LEN;
1001
+ const ret = wasm.terrainanalysis_startWallSearch(this.__wbg_ptr, ptr0, len0);
1002
+ if (ret[2]) {
1003
+ throw takeFromExternrefTable0(ret[1]);
1004
+ }
1005
+ return WallSearchJob.__wrap(ret[0]);
1006
+ }
1007
+ /**
1008
+ * Chooses collision-safe walk-cell-center endpoints around a selected entrance. Search query
1009
+ * start/end are placeholders here; the explicit entrance controls the direction.
1010
+ * @param {string} query_json
1011
+ * @param {string} entrance_json
1012
+ * @returns {string}
1013
+ */
1014
+ suggestWallEndpointsJson(query_json, entrance_json) {
1015
+ let deferred4_0;
1016
+ let deferred4_1;
1017
+ try {
1018
+ const ptr0 = passStringToWasm0(query_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1019
+ const len0 = WASM_VECTOR_LEN;
1020
+ const ptr1 = passStringToWasm0(entrance_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1021
+ const len1 = WASM_VECTOR_LEN;
1022
+ const ret = wasm.terrainanalysis_suggestWallEndpointsJson(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1023
+ var ptr3 = ret[0];
1024
+ var len3 = ret[1];
1025
+ if (ret[3]) {
1026
+ ptr3 = 0; len3 = 0;
1027
+ throw takeFromExternrefTable0(ret[2]);
1028
+ }
1029
+ deferred4_0 = ptr3;
1030
+ deferred4_1 = len3;
1031
+ return getStringFromWasm0(ptr3, len3);
1032
+ } finally {
1033
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1034
+ }
1035
+ }
1036
+ /**
1037
+ * Returns terrain-only walk-cell connectivity reachable from an entrance near a bounded
1038
+ * pixel window. The result is local to the returned rectangle and ignores objects,
1039
+ * buildability, and terrain height.
1040
+ * @param {string} input_json
1041
+ * @returns {string}
1042
+ */
1043
+ wallPlacementReachJson(input_json) {
1044
+ let deferred3_0;
1045
+ let deferred3_1;
1046
+ try {
1047
+ const ptr0 = passStringToWasm0(input_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1048
+ const len0 = WASM_VECTOR_LEN;
1049
+ const ret = wasm.terrainanalysis_wallPlacementReachJson(this.__wbg_ptr, ptr0, len0);
1050
+ var ptr2 = ret[0];
1051
+ var len2 = ret[1];
1052
+ if (ret[3]) {
1053
+ ptr2 = 0; len2 = 0;
1054
+ throw takeFromExternrefTable0(ret[2]);
1055
+ }
1056
+ deferred3_0 = ptr2;
1057
+ deferred3_1 = len2;
1058
+ return getStringFromWasm0(ptr2, len2);
1059
+ } finally {
1060
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1061
+ }
1062
+ }
1063
+ /**
1064
+ * Conventional melee palette with dimensions from the caller's units.dat. Empty for terrain-only snapshots.
1065
+ * @returns {string}
1066
+ */
1067
+ wallProfilesJson() {
1068
+ let deferred2_0;
1069
+ let deferred2_1;
1070
+ try {
1071
+ const ret = wasm.terrainanalysis_wallProfilesJson(this.__wbg_ptr);
1072
+ var ptr1 = ret[0];
1073
+ var len1 = ret[1];
1074
+ if (ret[3]) {
1075
+ ptr1 = 0; len1 = 0;
1076
+ throw takeFromExternrefTable0(ret[2]);
1077
+ }
1078
+ deferred2_0 = ptr1;
1079
+ deferred2_1 = len1;
1080
+ return getStringFromWasm0(ptr1, len1);
1081
+ } finally {
1082
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1083
+ }
1084
+ }
1085
+ /**
1086
+ * @returns {number}
1087
+ */
1088
+ get widthWalkTiles() {
1089
+ const ret = wasm.terrainanalysis_widthWalkTiles(this.__wbg_ptr);
1090
+ return ret >>> 0;
1091
+ }
1092
+ }
1093
+ if (Symbol.dispose) TerrainAnalysis.prototype[Symbol.dispose] = TerrainAnalysis.prototype.free;
1094
+
1095
+ /**
1096
+ * Incremental bounded wall search. It owns the core search snapshot, so it can safely outlive
1097
+ * its TerrainAnalysis creator. Dropping/freeing it abandons unfinished work.
1098
+ */
1099
+ export class WallSearchJob {
1100
+ static __wrap(ptr) {
1101
+ const obj = Object.create(WallSearchJob.prototype);
1102
+ obj.__wbg_ptr = ptr;
1103
+ WallSearchJobFinalization.register(obj, obj.__wbg_ptr, obj);
1104
+ return obj;
1105
+ }
1106
+ __destroy_into_raw() {
1107
+ const ptr = this.__wbg_ptr;
1108
+ this.__wbg_ptr = 0;
1109
+ WallSearchJobFinalization.unregister(this);
1110
+ return ptr;
1111
+ }
1112
+ free() {
1113
+ const ptr = this.__destroy_into_raw();
1114
+ wasm.__wbg_wallsearchjob_free(ptr, 0);
1115
+ }
1116
+ /**
1117
+ * @returns {number}
1118
+ */
1119
+ get exploredStates() {
1120
+ const ret = wasm.wallsearchjob_exploredStates(this.__wbg_ptr);
1121
+ return ret >>> 0;
1122
+ }
1123
+ /**
1124
+ * @returns {number}
1125
+ */
1126
+ get layoutCount() {
1127
+ const ret = wasm.wallsearchjob_layoutCount(this.__wbg_ptr);
1128
+ return ret >>> 0;
1129
+ }
1130
+ /**
1131
+ * Serializes the completed result. Calling this before a terminal step is an error so callers
1132
+ * do not accidentally copy route data while reporting progress.
1133
+ * @returns {string}
1134
+ */
1135
+ resultJson() {
1136
+ let deferred2_0;
1137
+ let deferred2_1;
1138
+ try {
1139
+ const ret = wasm.wallsearchjob_resultJson(this.__wbg_ptr);
1140
+ var ptr1 = ret[0];
1141
+ var len1 = ret[1];
1142
+ if (ret[3]) {
1143
+ ptr1 = 0; len1 = 0;
1144
+ throw takeFromExternrefTable0(ret[2]);
1145
+ }
1146
+ deferred2_0 = ptr1;
1147
+ deferred2_1 = len1;
1148
+ return getStringFromWasm0(ptr1, len1);
1149
+ } finally {
1150
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1151
+ }
1152
+ }
1153
+ /**
1154
+ * Advances at most 16 search states. Call between browser event-loop yields.
1155
+ * Returns true when a terminal result is available.
1156
+ * @param {number} max_states
1157
+ * @returns {boolean}
1158
+ */
1159
+ step(max_states) {
1160
+ const ret = wasm.wallsearchjob_step(this.__wbg_ptr, max_states);
1161
+ if (ret[2]) {
1162
+ throw takeFromExternrefTable0(ret[1]);
1163
+ }
1164
+ return ret[0] !== 0;
1165
+ }
1166
+ }
1167
+ if (Symbol.dispose) WallSearchJob.prototype[Symbol.dispose] = WallSearchJob.prototype.free;
1168
+
1169
+ /**
1170
+ * Summarizes a map file's scenario as a JSON `MapSummary` (see the README for the fields).
1171
+ * `options` is optional `MapLimitOptions` JSON raising (or lowering) broodmap's default resource
1172
+ * limits. Fails if the file isn't a readable map within those limits, or lacks the scenario name,
1173
+ * player or force sections every playable map has. To also render the map, construct a
1174
+ * `MapRenderer` and call its `summaryJson()` instead, which parses the map only once.
1175
+ * @param {Uint8Array} map_bytes
1176
+ * @param {string | null} [options]
1177
+ * @returns {string}
1178
+ */
1179
+ export function summarizeMapJson(map_bytes, options) {
1180
+ let deferred4_0;
1181
+ let deferred4_1;
1182
+ try {
1183
+ const ptr0 = passArray8ToWasm0(map_bytes, wasm.__wbindgen_malloc);
1184
+ const len0 = WASM_VECTOR_LEN;
1185
+ var ptr1 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1186
+ var len1 = WASM_VECTOR_LEN;
1187
+ const ret = wasm.summarizeMapJson(ptr0, len0, ptr1, len1);
1188
+ var ptr3 = ret[0];
1189
+ var len3 = ret[1];
1190
+ if (ret[3]) {
1191
+ ptr3 = 0; len3 = 0;
1192
+ throw takeFromExternrefTable0(ret[2]);
1193
+ }
1194
+ deferred4_0 = ptr3;
1195
+ deferred4_1 = len3;
1196
+ return getStringFromWasm0(ptr3, len3);
1197
+ } finally {
1198
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1199
+ }
1200
+ }
1201
+ function __wbg_get_imports() {
1202
+ const import0 = {
1203
+ __proto__: null,
1204
+ __wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
1205
+ const ret = debugString(arg1);
1206
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1207
+ const len1 = WASM_VECTOR_LEN;
1208
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1209
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1210
+ },
1211
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
1212
+ const ret = typeof(arg0) === 'function';
1213
+ return ret;
1214
+ },
1215
+ __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
1216
+ const obj = arg1;
1217
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1218
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1219
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1220
+ },
1221
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
1222
+ const obj = arg1;
1223
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1224
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1225
+ var len1 = WASM_VECTOR_LEN;
1226
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1227
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1228
+ },
1229
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
1230
+ throw new Error(getStringFromWasm0(arg0, arg1));
1231
+ },
1232
+ __wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
1233
+ const ret = arg0.call(arg1, arg2);
1234
+ return ret;
1235
+ }, arguments); },
1236
+ __wbg_call_939a2607c4484b0b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1237
+ const ret = arg0.call(arg1, arg2, arg3, arg4);
1238
+ return ret;
1239
+ }, arguments); },
1240
+ __wbg_from_296ca31f8d0f1c52: function(arg0) {
1241
+ const ret = Array.from(arg0);
1242
+ return ret;
1243
+ },
1244
+ __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
1245
+ const ret = Reflect.get(arg0, arg1);
1246
+ return ret;
1247
+ }, arguments); },
1248
+ __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
1249
+ const ret = arg0[arg1 >>> 0];
1250
+ return ret;
1251
+ },
1252
+ __wbg_instanceof_Error_80a725f81f2e102d: function(arg0) {
1253
+ let result;
1254
+ try {
1255
+ result = arg0 instanceof Error;
1256
+ } catch (_) {
1257
+ result = false;
1258
+ }
1259
+ const ret = result;
1260
+ return ret;
1261
+ },
1262
+ __wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
1263
+ const ret = Array.isArray(arg0);
1264
+ return ret;
1265
+ },
1266
+ __wbg_length_d4bdea10311bd9cf: function(arg0) {
1267
+ const ret = arg0.length;
1268
+ return ret;
1269
+ },
1270
+ __wbg_message_5f8387f0c32b90a7: function(arg0) {
1271
+ const ret = arg0.message;
1272
+ return ret;
1273
+ },
1274
+ __wbindgen_generic_0000000000000001: function(arg0) {
1275
+ // Cast intrinsic for `F64 -> Externref`.
1276
+ const ret = arg0;
1277
+ return ret;
1278
+ },
1279
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
1280
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1281
+ const ret = getArrayU8FromWasm0(arg0, arg1);
1282
+ return ret;
1283
+ },
1284
+ __wbindgen_generic_0000000000000003: function(arg0, arg1) {
1285
+ // Cast intrinsic for `Ref(String) -> Externref`.
1286
+ const ret = getStringFromWasm0(arg0, arg1);
1287
+ return ret;
1288
+ },
1289
+ __wbindgen_init_externref_table: function() {
1290
+ const table = wasm.__wbindgen_externrefs;
1291
+ const offset = table.grow(4);
1292
+ table.set(0, undefined);
1293
+ table.set(offset + 0, undefined);
1294
+ table.set(offset + 1, null);
1295
+ table.set(offset + 2, true);
1296
+ table.set(offset + 3, false);
1297
+ },
1298
+ };
1299
+ return {
1300
+ __proto__: null,
1301
+ "./broodmap_wasm_bg.js": import0,
1302
+ };
1303
+ }
1304
+
1305
+ const AreaSnapshotFinalization = (typeof FinalizationRegistry === 'undefined')
1306
+ ? { register: () => {}, unregister: () => {} }
1307
+ : new FinalizationRegistry(ptr => wasm.__wbg_areasnapshot_free(ptr, 1));
1308
+ const BaseTopologyJobFinalization = (typeof FinalizationRegistry === 'undefined')
1309
+ ? { register: () => {}, unregister: () => {} }
1310
+ : new FinalizationRegistry(ptr => wasm.__wbg_basetopologyjob_free(ptr, 1));
1311
+ const CascStorageFinalization = (typeof FinalizationRegistry === 'undefined')
1312
+ ? { register: () => {}, unregister: () => {} }
1313
+ : new FinalizationRegistry(ptr => wasm.__wbg_cascstorage_free(ptr, 1));
1314
+ const MapRendererFinalization = (typeof FinalizationRegistry === 'undefined')
1315
+ ? { register: () => {}, unregister: () => {} }
1316
+ : new FinalizationRegistry(ptr => wasm.__wbg_maprenderer_free(ptr, 1));
1317
+ const RegionSnapshotFinalization = (typeof FinalizationRegistry === 'undefined')
1318
+ ? { register: () => {}, unregister: () => {} }
1319
+ : new FinalizationRegistry(ptr => wasm.__wbg_regionsnapshot_free(ptr, 1));
1320
+ const RenderedImageFinalization = (typeof FinalizationRegistry === 'undefined')
1321
+ ? { register: () => {}, unregister: () => {} }
1322
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderedimage_free(ptr, 1));
1323
+ const TerrainAnalysisFinalization = (typeof FinalizationRegistry === 'undefined')
1324
+ ? { register: () => {}, unregister: () => {} }
1325
+ : new FinalizationRegistry(ptr => wasm.__wbg_terrainanalysis_free(ptr, 1));
1326
+ const WallSearchJobFinalization = (typeof FinalizationRegistry === 'undefined')
1327
+ ? { register: () => {}, unregister: () => {} }
1328
+ : new FinalizationRegistry(ptr => wasm.__wbg_wallsearchjob_free(ptr, 1));
1329
+
1330
+ function addToExternrefTable0(obj) {
1331
+ const idx = wasm.__externref_table_alloc();
1332
+ wasm.__wbindgen_externrefs.set(idx, obj);
1333
+ return idx;
1334
+ }
1335
+
1336
+ function _assertClass(instance, klass) {
1337
+ if (!(instance instanceof klass)) {
1338
+ throw new Error(`expected instance of ${klass.name}`);
1339
+ }
1340
+ }
1341
+
1342
+ function debugString(val) {
1343
+ // primitive types
1344
+ const type = typeof val;
1345
+ if (type == 'number' || type == 'boolean' || val == null) {
1346
+ return `${val}`;
1347
+ }
1348
+ if (type == 'string') {
1349
+ return `"${val}"`;
1350
+ }
1351
+ if (type == 'symbol') {
1352
+ const description = val.description;
1353
+ if (description == null) {
1354
+ return 'Symbol';
1355
+ } else {
1356
+ return `Symbol(${description})`;
1357
+ }
1358
+ }
1359
+ if (type == 'function') {
1360
+ const name = val.name;
1361
+ if (typeof name == 'string' && name.length > 0) {
1362
+ return `Function(${name})`;
1363
+ } else {
1364
+ return 'Function';
1365
+ }
1366
+ }
1367
+ // objects
1368
+ if (Array.isArray(val)) {
1369
+ const length = val.length;
1370
+ let debug = '[';
1371
+ if (length > 0) {
1372
+ debug += debugString(val[0]);
1373
+ }
1374
+ for(let i = 1; i < length; i++) {
1375
+ debug += ', ' + debugString(val[i]);
1376
+ }
1377
+ debug += ']';
1378
+ return debug;
1379
+ }
1380
+ // Test for built-in
1381
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1382
+ let className;
1383
+ if (builtInMatches && builtInMatches.length > 1) {
1384
+ className = builtInMatches[1];
1385
+ } else {
1386
+ // Failed to match the standard '[object ClassName]'
1387
+ return toString.call(val);
1388
+ }
1389
+ if (className == 'Object') {
1390
+ // we're a user defined class or Object
1391
+ // JSON.stringify avoids problems with cycles, and is generally much
1392
+ // easier than looping through ownProperties of `val`.
1393
+ try {
1394
+ return 'Object(' + JSON.stringify(val) + ')';
1395
+ } catch (_) {
1396
+ return 'Object';
1397
+ }
1398
+ }
1399
+ // errors
1400
+ if (val instanceof Error) {
1401
+ return `${val.name}: ${val.message}\n${val.stack}`;
1402
+ }
1403
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1404
+ return className;
1405
+ }
1406
+
1407
+ function getArrayJsValueFromWasm0(ptr, len) {
1408
+ ptr = ptr >>> 0;
1409
+ const mem = getDataViewMemory0();
1410
+ const result = [];
1411
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
1412
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
1413
+ }
1414
+ wasm.__externref_drop_slice(ptr, len);
1415
+ return result;
1416
+ }
1417
+
1418
+ function getArrayU16FromWasm0(ptr, len) {
1419
+ ptr = ptr >>> 0;
1420
+ return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
1421
+ }
1422
+
1423
+ function getArrayU32FromWasm0(ptr, len) {
1424
+ ptr = ptr >>> 0;
1425
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1426
+ }
1427
+
1428
+ function getArrayU8FromWasm0(ptr, len) {
1429
+ ptr = ptr >>> 0;
1430
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1431
+ }
1432
+
1433
+ let cachedDataViewMemory0 = null;
1434
+ function getDataViewMemory0() {
1435
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1436
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1437
+ }
1438
+ return cachedDataViewMemory0;
1439
+ }
1440
+
1441
+ function getStringFromWasm0(ptr, len) {
1442
+ return decodeText(ptr >>> 0, len);
1443
+ }
1444
+
1445
+ let cachedUint16ArrayMemory0 = null;
1446
+ function getUint16ArrayMemory0() {
1447
+ if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
1448
+ cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
1449
+ }
1450
+ return cachedUint16ArrayMemory0;
1451
+ }
1452
+
1453
+ let cachedUint32ArrayMemory0 = null;
1454
+ function getUint32ArrayMemory0() {
1455
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
1456
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
1457
+ }
1458
+ return cachedUint32ArrayMemory0;
1459
+ }
1460
+
1461
+ let cachedUint8ArrayMemory0 = null;
1462
+ function getUint8ArrayMemory0() {
1463
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1464
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1465
+ }
1466
+ return cachedUint8ArrayMemory0;
1467
+ }
1468
+
1469
+ function handleError(f, args) {
1470
+ try {
1471
+ return f.apply(this, args);
1472
+ } catch (e) {
1473
+ const idx = addToExternrefTable0(e);
1474
+ wasm.__wbindgen_exn_store(idx);
1475
+ }
1476
+ }
1477
+
1478
+ function isLikeNone(x) {
1479
+ return x === undefined || x === null;
1480
+ }
1481
+
1482
+ function passArray8ToWasm0(arg, malloc) {
1483
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1484
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1485
+ WASM_VECTOR_LEN = arg.length;
1486
+ return ptr;
1487
+ }
1488
+
1489
+ function passStringToWasm0(arg, malloc, realloc) {
1490
+ if (realloc === undefined) {
1491
+ const buf = cachedTextEncoder.encode(arg);
1492
+ const ptr = malloc(buf.length, 1) >>> 0;
1493
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1494
+ WASM_VECTOR_LEN = buf.length;
1495
+ return ptr;
1496
+ }
1497
+
1498
+ let len = arg.length;
1499
+ let ptr = malloc(len, 1) >>> 0;
1500
+
1501
+ const mem = getUint8ArrayMemory0();
1502
+
1503
+ let offset = 0;
1504
+
1505
+ for (; offset < len; offset++) {
1506
+ const code = arg.charCodeAt(offset);
1507
+ if (code > 0x7F) break;
1508
+ mem[ptr + offset] = code;
1509
+ }
1510
+ if (offset !== len) {
1511
+ if (offset !== 0) {
1512
+ arg = arg.slice(offset);
1513
+ }
1514
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1515
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1516
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1517
+
1518
+ offset += ret.written;
1519
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1520
+ }
1521
+
1522
+ WASM_VECTOR_LEN = offset;
1523
+ return ptr;
1524
+ }
1525
+
1526
+ function takeFromExternrefTable0(idx) {
1527
+ const value = wasm.__wbindgen_externrefs.get(idx);
1528
+ wasm.__externref_table_dealloc(idx);
1529
+ return value;
1530
+ }
1531
+
1532
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1533
+ cachedTextDecoder.decode();
1534
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1535
+ let numBytesDecoded = 0;
1536
+ function decodeText(ptr, len) {
1537
+ numBytesDecoded += len;
1538
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1539
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1540
+ cachedTextDecoder.decode();
1541
+ numBytesDecoded = len;
1542
+ }
1543
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1544
+ }
1545
+
1546
+ const cachedTextEncoder = new TextEncoder();
1547
+
1548
+ if (!('encodeInto' in cachedTextEncoder)) {
1549
+ cachedTextEncoder.encodeInto = function (arg, view) {
1550
+ const buf = cachedTextEncoder.encode(arg);
1551
+ view.set(buf);
1552
+ return {
1553
+ read: arg.length,
1554
+ written: buf.length
1555
+ };
1556
+ };
1557
+ }
1558
+
1559
+ let WASM_VECTOR_LEN = 0;
1560
+
1561
+ let wasmModule, wasmInstance, wasm;
1562
+ function __wbg_finalize_init(instance, module) {
1563
+ wasmInstance = instance;
1564
+ wasm = instance.exports;
1565
+ wasmModule = module;
1566
+ cachedDataViewMemory0 = null;
1567
+ cachedUint16ArrayMemory0 = null;
1568
+ cachedUint32ArrayMemory0 = null;
1569
+ cachedUint8ArrayMemory0 = null;
1570
+ wasm.__wbindgen_start();
1571
+ return wasm;
1572
+ }
1573
+
1574
+ async function __wbg_load(module, imports) {
1575
+ if (typeof Response === 'function' && module instanceof Response) {
1576
+ if (!module.ok) {
1577
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1578
+ }
1579
+
1580
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1581
+ try {
1582
+ return await WebAssembly.instantiateStreaming(module, imports);
1583
+ } catch (e) {
1584
+ const validResponse = expectedResponseType(module.type);
1585
+
1586
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1587
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1588
+
1589
+ } else { throw e; }
1590
+ }
1591
+ }
1592
+
1593
+ const bytes = await module.arrayBuffer();
1594
+ return await WebAssembly.instantiate(bytes, imports);
1595
+ } else {
1596
+ const instance = await WebAssembly.instantiate(module, imports);
1597
+
1598
+ if (instance instanceof WebAssembly.Instance) {
1599
+ return { instance, module };
1600
+ } else {
1601
+ return instance;
1602
+ }
1603
+ }
1604
+
1605
+ function expectedResponseType(type) {
1606
+ switch (type) {
1607
+ case 'basic': case 'cors': case 'default': return true;
1608
+ }
1609
+ return false;
1610
+ }
1611
+ }
1612
+
1613
+ function initSync(module) {
1614
+ if (wasm !== undefined) return wasm;
1615
+
1616
+
1617
+ if (module !== undefined) {
1618
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1619
+ ({module} = module)
1620
+ } else {
1621
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1622
+ }
1623
+ }
1624
+
1625
+ const imports = __wbg_get_imports();
1626
+ if (!(module instanceof WebAssembly.Module)) {
1627
+ module = new WebAssembly.Module(module);
1628
+ }
1629
+ const instance = new WebAssembly.Instance(module, imports);
1630
+ return __wbg_finalize_init(instance, module);
1631
+ }
1632
+
1633
+ async function __wbg_init(module_or_path) {
1634
+ if (wasm !== undefined) return wasm;
1635
+
1636
+
1637
+ if (module_or_path !== undefined) {
1638
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1639
+ ({module_or_path} = module_or_path)
1640
+ } else {
1641
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1642
+ }
1643
+ }
1644
+
1645
+ if (module_or_path === undefined) {
1646
+ module_or_path = new URL('broodmap_wasm_bg.wasm', import.meta.url);
1647
+ }
1648
+ const imports = __wbg_get_imports();
1649
+
1650
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1651
+ module_or_path = fetch(module_or_path);
1652
+ }
1653
+
1654
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1655
+
1656
+ return __wbg_finalize_init(instance, module);
1657
+ }
1658
+
1659
+ export { initSync, __wbg_init as default };