deepbom 0.1.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,1222 @@
1
+ /* @ts-self-types="./tflite_wasm_audit.d.ts" */
2
+
3
+ /**
4
+ * @param {Uint8Array} bytes
5
+ * @param {string} filename
6
+ * @returns {any}
7
+ */
8
+ export function analyze_tflite(bytes, filename) {
9
+ try {
10
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
11
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
12
+ const len0 = WASM_VECTOR_LEN;
13
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
14
+ const len1 = WASM_VECTOR_LEN;
15
+ wasm.analyze_tflite(retptr, ptr0, len0, ptr1, len1);
16
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
17
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
18
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
19
+ if (r2) {
20
+ throw takeObject(r1);
21
+ }
22
+ return takeObject(r0);
23
+ } finally {
24
+ wasm.__wbindgen_add_to_stack_pointer(16);
25
+ }
26
+ }
27
+
28
+ /**
29
+ * @param {Uint8Array} bytes
30
+ * @param {string} filename
31
+ * @param {string} target_id
32
+ * @returns {any}
33
+ */
34
+ export function analyze_tflite_for_target(bytes, filename, target_id) {
35
+ try {
36
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
37
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
40
+ const len1 = WASM_VECTOR_LEN;
41
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
42
+ const len2 = WASM_VECTOR_LEN;
43
+ wasm.analyze_tflite_for_target(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
44
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
45
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
46
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
47
+ if (r2) {
48
+ throw takeObject(r1);
49
+ }
50
+ return takeObject(r0);
51
+ } finally {
52
+ wasm.__wbindgen_add_to_stack_pointer(16);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Compute activation Haar energy for each CONV/DEPTHWISE op via synthetic forward pass.
58
+ * Uses a 32×32 (max) synthetic input with a deterministic spatial pattern.
59
+ * Works entirely in f64; INT8 weights are dequantized using full per-channel scales.
60
+ * @param {Uint8Array} bytes
61
+ * @param {string} filename
62
+ * @param {string} target_id
63
+ * @returns {any}
64
+ */
65
+ export function compute_activation_haar(bytes, filename, target_id) {
66
+ try {
67
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
68
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
69
+ const len0 = WASM_VECTOR_LEN;
70
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
71
+ const len1 = WASM_VECTOR_LEN;
72
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
73
+ const len2 = WASM_VECTOR_LEN;
74
+ wasm.compute_activation_haar(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
75
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
76
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
77
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
78
+ if (r2) {
79
+ throw takeObject(r1);
80
+ }
81
+ return takeObject(r0);
82
+ } finally {
83
+ wasm.__wbindgen_add_to_stack_pointer(16);
84
+ }
85
+ }
86
+
87
+ /**
88
+ * @param {Uint8Array} model_bytes
89
+ * @param {string} filename
90
+ * @param {string} target_id
91
+ * @returns {any}
92
+ */
93
+ export function compute_delegation_repair(model_bytes, filename, target_id) {
94
+ try {
95
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
96
+ const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_export);
97
+ const len0 = WASM_VECTOR_LEN;
98
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
99
+ const len1 = WASM_VECTOR_LEN;
100
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
101
+ const len2 = WASM_VECTOR_LEN;
102
+ wasm.compute_delegation_repair(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
103
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
104
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
105
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
106
+ if (r2) {
107
+ throw takeObject(r1);
108
+ }
109
+ return takeObject(r0);
110
+ } finally {
111
+ wasm.__wbindgen_add_to_stack_pointer(16);
112
+ }
113
+ }
114
+
115
+ /**
116
+ * @param {Uint8Array} baseline_bytes
117
+ * @param {string} baseline_filename
118
+ * @param {Uint8Array} candidate_bytes
119
+ * @param {string} candidate_filename
120
+ * @param {string} target_ids_json
121
+ * @returns {any}
122
+ */
123
+ export function compute_deployment_delta(baseline_bytes, baseline_filename, candidate_bytes, candidate_filename, target_ids_json) {
124
+ try {
125
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
126
+ const ptr0 = passArray8ToWasm0(baseline_bytes, wasm.__wbindgen_export);
127
+ const len0 = WASM_VECTOR_LEN;
128
+ const ptr1 = passStringToWasm0(baseline_filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
129
+ const len1 = WASM_VECTOR_LEN;
130
+ const ptr2 = passArray8ToWasm0(candidate_bytes, wasm.__wbindgen_export);
131
+ const len2 = WASM_VECTOR_LEN;
132
+ const ptr3 = passStringToWasm0(candidate_filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
133
+ const len3 = WASM_VECTOR_LEN;
134
+ const ptr4 = passStringToWasm0(target_ids_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
135
+ const len4 = WASM_VECTOR_LEN;
136
+ wasm.compute_deployment_delta(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
137
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
138
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
139
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
140
+ if (r2) {
141
+ throw takeObject(r1);
142
+ }
143
+ return takeObject(r0);
144
+ } finally {
145
+ wasm.__wbindgen_add_to_stack_pointer(16);
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @param {Uint8Array} bytes
151
+ * @param {string} filename
152
+ * @param {string} target_ids_json
153
+ * @returns {any}
154
+ */
155
+ export function compute_deployment_frontier(bytes, filename, target_ids_json) {
156
+ try {
157
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
158
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
159
+ const len0 = WASM_VECTOR_LEN;
160
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
161
+ const len1 = WASM_VECTOR_LEN;
162
+ const ptr2 = passStringToWasm0(target_ids_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
163
+ const len2 = WASM_VECTOR_LEN;
164
+ wasm.compute_deployment_frontier(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
165
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
166
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
167
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
168
+ if (r2) {
169
+ throw takeObject(r1);
170
+ }
171
+ return takeObject(r0);
172
+ } finally {
173
+ wasm.__wbindgen_add_to_stack_pointer(16);
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Backward (input) influence: spatial BFS from clicked op's output → model inputs.
179
+ * @param {Uint8Array} bytes
180
+ * @param {string} filename
181
+ * @param {number} op_index
182
+ * @param {string} target_id
183
+ * @returns {any}
184
+ */
185
+ export function compute_input_influence(bytes, filename, op_index, target_id) {
186
+ try {
187
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
188
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
189
+ const len0 = WASM_VECTOR_LEN;
190
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
191
+ const len1 = WASM_VECTOR_LEN;
192
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
193
+ const len2 = WASM_VECTOR_LEN;
194
+ wasm.compute_input_influence(retptr, ptr0, len0, ptr1, len1, op_index, ptr2, len2);
195
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
196
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
197
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
198
+ if (r2) {
199
+ throw takeObject(r1);
200
+ }
201
+ return takeObject(r0);
202
+ } finally {
203
+ wasm.__wbindgen_add_to_stack_pointer(16);
204
+ }
205
+ }
206
+
207
+ /**
208
+ * @param {Uint8Array} bytes
209
+ * @param {string} filename
210
+ * @param {string} target_id
211
+ * @returns {any}
212
+ */
213
+ export function compute_kernel_haar_decomposition(bytes, filename, target_id) {
214
+ try {
215
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
216
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
217
+ const len0 = WASM_VECTOR_LEN;
218
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
219
+ const len1 = WASM_VECTOR_LEN;
220
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
221
+ const len2 = WASM_VECTOR_LEN;
222
+ wasm.compute_kernel_haar_decomposition(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
223
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
224
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
225
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
226
+ if (r2) {
227
+ throw takeObject(r1);
228
+ }
229
+ return takeObject(r0);
230
+ } finally {
231
+ wasm.__wbindgen_add_to_stack_pointer(16);
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Per-layer weight statistics + activation Haar for triplanar model viewer.
237
+ * Returns one entry per CONV_2D / DEPTHWISE_CONV_2D / FULLY_CONNECTED op.
238
+ * @param {Uint8Array} bytes
239
+ * @param {string} filename
240
+ * @param {string} target_id
241
+ * @returns {any}
242
+ */
243
+ export function compute_model_tomography(bytes, filename, target_id) {
244
+ try {
245
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
246
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
247
+ const len0 = WASM_VECTOR_LEN;
248
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
249
+ const len1 = WASM_VECTOR_LEN;
250
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
251
+ const len2 = WASM_VECTOR_LEN;
252
+ wasm.compute_model_tomography(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
253
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
254
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
255
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
256
+ if (r2) {
257
+ throw takeObject(r1);
258
+ }
259
+ return takeObject(r0);
260
+ } finally {
261
+ wasm.__wbindgen_add_to_stack_pointer(16);
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Forward (output) influence: spatial BFS from clicked op's output → model outputs.
267
+ * @param {Uint8Array} bytes
268
+ * @param {string} filename
269
+ * @param {number} op_index
270
+ * @param {string} target_id
271
+ * @returns {any}
272
+ */
273
+ export function compute_output_influence(bytes, filename, op_index, target_id) {
274
+ try {
275
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
276
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
277
+ const len0 = WASM_VECTOR_LEN;
278
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
279
+ const len1 = WASM_VECTOR_LEN;
280
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
281
+ const len2 = WASM_VECTOR_LEN;
282
+ wasm.compute_output_influence(retptr, ptr0, len0, ptr1, len1, op_index, ptr2, len2);
283
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
284
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
285
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
286
+ if (r2) {
287
+ throw takeObject(r1);
288
+ }
289
+ return takeObject(r0);
290
+ } finally {
291
+ wasm.__wbindgen_add_to_stack_pointer(16);
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Fast low-norm-filter count for an op weight tensor (L2 < 2% of max).
297
+ * @param {Uint8Array} bytes
298
+ * @param {string} filename
299
+ * @param {number} tensor_index
300
+ * @param {string} target_id
301
+ * @returns {any}
302
+ */
303
+ export function compute_quick_low_norm_stat(bytes, filename, tensor_index, target_id) {
304
+ try {
305
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
306
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
307
+ const len0 = WASM_VECTOR_LEN;
308
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
309
+ const len1 = WASM_VECTOR_LEN;
310
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
311
+ const len2 = WASM_VECTOR_LEN;
312
+ wasm.compute_quick_low_norm_stat(retptr, ptr0, len0, ptr1, len1, tensor_index, ptr2, len2);
313
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
314
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
315
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
316
+ if (r2) {
317
+ throw takeObject(r1);
318
+ }
319
+ return takeObject(r0);
320
+ } finally {
321
+ wasm.__wbindgen_add_to_stack_pointer(16);
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Compute correction factor between static latency estimate and WASM-measured runtime.
327
+ * Pass measured_ms = 0.0 if no runtime data is available (returns static estimate only).
328
+ * @param {Uint8Array} bytes
329
+ * @param {string} filename
330
+ * @param {string} target_id
331
+ * @param {number} measured_ms
332
+ * @returns {any}
333
+ */
334
+ export function compute_static_runtime_calibration(bytes, filename, target_id, measured_ms) {
335
+ try {
336
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
337
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
338
+ const len0 = WASM_VECTOR_LEN;
339
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
340
+ const len1 = WASM_VECTOR_LEN;
341
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
342
+ const len2 = WASM_VECTOR_LEN;
343
+ wasm.compute_static_runtime_calibration(retptr, ptr0, len0, ptr1, len1, ptr2, len2, measured_ms);
344
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
345
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
346
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
347
+ if (r2) {
348
+ throw takeObject(r1);
349
+ }
350
+ return takeObject(r0);
351
+ } finally {
352
+ wasm.__wbindgen_add_to_stack_pointer(16);
353
+ }
354
+ }
355
+
356
+ /**
357
+ * Compute weight histogram + filter stats for a specific tensor by index.
358
+ * Returns null if the tensor is not a constant buffer or is unsupported dtype.
359
+ * @param {Uint8Array} bytes
360
+ * @param {string} filename
361
+ * @param {number} tensor_index
362
+ * @param {string} target_id
363
+ * @returns {any}
364
+ */
365
+ export function compute_weight_histogram(bytes, filename, tensor_index, target_id) {
366
+ try {
367
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
368
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
369
+ const len0 = WASM_VECTOR_LEN;
370
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
371
+ const len1 = WASM_VECTOR_LEN;
372
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
373
+ const len2 = WASM_VECTOR_LEN;
374
+ wasm.compute_weight_histogram(retptr, ptr0, len0, ptr1, len1, tensor_index, ptr2, len2);
375
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
376
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
377
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
378
+ if (r2) {
379
+ throw takeObject(r1);
380
+ }
381
+ return takeObject(r0);
382
+ } finally {
383
+ wasm.__wbindgen_add_to_stack_pointer(16);
384
+ }
385
+ }
386
+
387
+ /**
388
+ * @param {Uint8Array} bytes
389
+ * @param {string} filename
390
+ * @param {string} target_id
391
+ * @param {any} request
392
+ * @returns {any}
393
+ */
394
+ export function explore_tflite_redesign_pareto(bytes, filename, target_id, request) {
395
+ try {
396
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
397
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
398
+ const len0 = WASM_VECTOR_LEN;
399
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
400
+ const len1 = WASM_VECTOR_LEN;
401
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
402
+ const len2 = WASM_VECTOR_LEN;
403
+ wasm.explore_tflite_redesign_pareto(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(request));
404
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
405
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
406
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
407
+ if (r2) {
408
+ throw takeObject(r1);
409
+ }
410
+ return takeObject(r0);
411
+ } finally {
412
+ wasm.__wbindgen_add_to_stack_pointer(16);
413
+ }
414
+ }
415
+
416
+ /**
417
+ * Generate two filter-normalized random directions in weight space (one per seed parameter).
418
+ * Returns d1, d2 as flat Float32Arrays and per-tensor metadata needed for JS-side perturbation.
419
+ * Call once per seed; JS applies alpha*d1+beta*d2 directly on the model Uint8Array.
420
+ * @param {Uint8Array} bytes
421
+ * @param {number} seed1
422
+ * @param {number} seed2
423
+ * @returns {any}
424
+ */
425
+ export function landscape_directions(bytes, seed1, seed2) {
426
+ try {
427
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
428
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
429
+ const len0 = WASM_VECTOR_LEN;
430
+ wasm.landscape_directions(retptr, ptr0, len0, seed1, seed2);
431
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
432
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
433
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
434
+ if (r2) {
435
+ throw takeObject(r1);
436
+ }
437
+ return takeObject(r0);
438
+ } finally {
439
+ wasm.__wbindgen_add_to_stack_pointer(16);
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Run K independent 2D landscape projections in a single WASM call.
445
+ * analyze_with_target is called only once; K × G² forward passes follow.
446
+ * Each projection uses a distinct filter-normalized direction pair.
447
+ * @param {Uint8Array} bytes
448
+ * @param {number} num_projections
449
+ * @param {number} grid_size
450
+ * @param {number} radius
451
+ * @returns {any}
452
+ */
453
+ export function landscape_tomography(bytes, num_projections, grid_size, radius) {
454
+ try {
455
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
456
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
457
+ const len0 = WASM_VECTOR_LEN;
458
+ wasm.landscape_tomography(retptr, ptr0, len0, num_projections, grid_size, radius);
459
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
460
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
461
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
462
+ if (r2) {
463
+ throw takeObject(r1);
464
+ }
465
+ return takeObject(r0);
466
+ } finally {
467
+ wasm.__wbindgen_add_to_stack_pointer(16);
468
+ }
469
+ }
470
+
471
+ /**
472
+ * Single-layer 2D landscape grid — perturbs only the weight tensor of the given op.
473
+ * Much faster than full-model landscape for interactive per-layer exploration.
474
+ * @param {Uint8Array} bytes
475
+ * @param {number} op_index
476
+ * @param {number} seed1
477
+ * @param {number} seed2
478
+ * @param {number} grid_size
479
+ * @param {number} radius
480
+ * @returns {any}
481
+ */
482
+ export function layer_landscape_grid(bytes, op_index, seed1, seed2, grid_size, radius) {
483
+ try {
484
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
485
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
486
+ const len0 = WASM_VECTOR_LEN;
487
+ wasm.layer_landscape_grid(retptr, ptr0, len0, op_index, seed1, seed2, grid_size, radius);
488
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
489
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
490
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
491
+ if (r2) {
492
+ throw takeObject(r1);
493
+ }
494
+ return takeObject(r0);
495
+ } finally {
496
+ wasm.__wbindgen_add_to_stack_pointer(16);
497
+ }
498
+ }
499
+
500
+ /**
501
+ * @param {Uint8Array} rgba
502
+ * @param {number} channels
503
+ * @param {number} mean_r
504
+ * @param {number} mean_g
505
+ * @param {number} mean_b
506
+ * @param {number} std_r
507
+ * @param {number} std_g
508
+ * @param {number} std_b
509
+ * @param {boolean} bgr
510
+ * @returns {Float32Array}
511
+ */
512
+ export function preprocess_rgba_to_float32(rgba, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, bgr) {
513
+ try {
514
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
515
+ const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_export);
516
+ const len0 = WASM_VECTOR_LEN;
517
+ wasm.preprocess_rgba_to_float32(retptr, ptr0, len0, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, bgr);
518
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
519
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
520
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
521
+ if (r2) {
522
+ throw takeObject(r1);
523
+ }
524
+ return takeObject(r0);
525
+ } finally {
526
+ wasm.__wbindgen_add_to_stack_pointer(16);
527
+ }
528
+ }
529
+
530
+ /**
531
+ * @param {Uint8Array} rgba
532
+ * @param {number} channels
533
+ * @param {number} mean_r
534
+ * @param {number} mean_g
535
+ * @param {number} mean_b
536
+ * @param {number} std_r
537
+ * @param {number} std_g
538
+ * @param {number} std_b
539
+ * @param {number} scale
540
+ * @param {number} zero_point
541
+ * @param {boolean} bgr
542
+ * @returns {Int8Array}
543
+ */
544
+ export function preprocess_rgba_to_int8(rgba, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr) {
545
+ try {
546
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
547
+ const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_export);
548
+ const len0 = WASM_VECTOR_LEN;
549
+ wasm.preprocess_rgba_to_int8(retptr, ptr0, len0, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr);
550
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
551
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
552
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
553
+ if (r2) {
554
+ throw takeObject(r1);
555
+ }
556
+ return takeObject(r0);
557
+ } finally {
558
+ wasm.__wbindgen_add_to_stack_pointer(16);
559
+ }
560
+ }
561
+
562
+ /**
563
+ * @param {Uint8Array} rgba
564
+ * @param {number} channels
565
+ * @param {number} mean_r
566
+ * @param {number} mean_g
567
+ * @param {number} mean_b
568
+ * @param {number} std_r
569
+ * @param {number} std_g
570
+ * @param {number} std_b
571
+ * @param {number} scale
572
+ * @param {number} zero_point
573
+ * @param {boolean} bgr
574
+ * @returns {Uint8Array}
575
+ */
576
+ export function preprocess_rgba_to_uint8(rgba, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr) {
577
+ try {
578
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
579
+ const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_export);
580
+ const len0 = WASM_VECTOR_LEN;
581
+ wasm.preprocess_rgba_to_uint8(retptr, ptr0, len0, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr);
582
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
583
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
584
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
585
+ if (r2) {
586
+ throw takeObject(r1);
587
+ }
588
+ return takeObject(r0);
589
+ } finally {
590
+ wasm.__wbindgen_add_to_stack_pointer(16);
591
+ }
592
+ }
593
+
594
+ /**
595
+ * @param {Uint8Array} bytes
596
+ * @param {string} filename
597
+ * @param {string} target_id
598
+ * @param {any} request
599
+ * @returns {any}
600
+ */
601
+ export function project_tflite_redesign(bytes, filename, target_id, request) {
602
+ try {
603
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
604
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
605
+ const len0 = WASM_VECTOR_LEN;
606
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
607
+ const len1 = WASM_VECTOR_LEN;
608
+ const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
609
+ const len2 = WASM_VECTOR_LEN;
610
+ wasm.project_tflite_redesign(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(request));
611
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
612
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
613
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
614
+ if (r2) {
615
+ throw takeObject(r1);
616
+ }
617
+ return takeObject(r0);
618
+ } finally {
619
+ wasm.__wbindgen_add_to_stack_pointer(16);
620
+ }
621
+ }
622
+
623
+ /**
624
+ * @returns {number}
625
+ */
626
+ export function runtime_guard() {
627
+ const ret = wasm.runtime_guard();
628
+ return ret >>> 0;
629
+ }
630
+
631
+ /**
632
+ * Compute full G×G synthetic f64 loss landscape for one seed.
633
+ * Weights perturbed in float domain (no requantization). Returns drift vs center.
634
+ * @param {Uint8Array} bytes
635
+ * @param {number} seed1
636
+ * @param {number} seed2
637
+ * @param {number} grid_size
638
+ * @param {number} radius
639
+ * @returns {any}
640
+ */
641
+ export function synthetic_landscape_grid(bytes, seed1, seed2, grid_size, radius) {
642
+ try {
643
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
644
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
645
+ const len0 = WASM_VECTOR_LEN;
646
+ wasm.synthetic_landscape_grid(retptr, ptr0, len0, seed1, seed2, grid_size, radius);
647
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
648
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
649
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
650
+ if (r2) {
651
+ throw takeObject(r1);
652
+ }
653
+ return takeObject(r0);
654
+ } finally {
655
+ wasm.__wbindgen_add_to_stack_pointer(16);
656
+ }
657
+ }
658
+
659
+ /**
660
+ * @returns {any}
661
+ */
662
+ export function target_profiles() {
663
+ try {
664
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
665
+ wasm.target_profiles(retptr);
666
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
667
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
668
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
669
+ if (r2) {
670
+ throw takeObject(r1);
671
+ }
672
+ return takeObject(r0);
673
+ } finally {
674
+ wasm.__wbindgen_add_to_stack_pointer(16);
675
+ }
676
+ }
677
+ function __wbg_get_imports() {
678
+ const import0 = {
679
+ __proto__: null,
680
+ __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
681
+ const ret = Error(getStringFromWasm0(arg0, arg1));
682
+ return addHeapObject(ret);
683
+ },
684
+ __wbg_Number_c4bdf66bb78f7977: function(arg0) {
685
+ const ret = Number(getObject(arg0));
686
+ return ret;
687
+ },
688
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
689
+ const ret = String(getObject(arg1));
690
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
691
+ const len1 = WASM_VECTOR_LEN;
692
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
693
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
694
+ },
695
+ __wbg___wbindgen_bigint_get_as_i64_d9e915702856f831: function(arg0, arg1) {
696
+ const v = getObject(arg1);
697
+ const ret = typeof(v) === 'bigint' ? v : undefined;
698
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
699
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
700
+ },
701
+ __wbg___wbindgen_boolean_get_edaed31a367ce1bd: function(arg0) {
702
+ const v = getObject(arg0);
703
+ const ret = typeof(v) === 'boolean' ? v : undefined;
704
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
705
+ },
706
+ __wbg___wbindgen_debug_string_8a447059637473e2: function(arg0, arg1) {
707
+ const ret = debugString(getObject(arg1));
708
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
709
+ const len1 = WASM_VECTOR_LEN;
710
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
711
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
712
+ },
713
+ __wbg___wbindgen_in_4990f46af709e33c: function(arg0, arg1) {
714
+ const ret = getObject(arg0) in getObject(arg1);
715
+ return ret;
716
+ },
717
+ __wbg___wbindgen_is_bigint_90b5ccfe67c78460: function(arg0) {
718
+ const ret = typeof(getObject(arg0)) === 'bigint';
719
+ return ret;
720
+ },
721
+ __wbg___wbindgen_is_function_acc5528be2b923f2: function(arg0) {
722
+ const ret = typeof(getObject(arg0)) === 'function';
723
+ return ret;
724
+ },
725
+ __wbg___wbindgen_is_object_0beba4a1980d3eea: function(arg0) {
726
+ const val = getObject(arg0);
727
+ const ret = typeof(val) === 'object' && val !== null;
728
+ return ret;
729
+ },
730
+ __wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
731
+ const ret = getObject(arg0) === undefined;
732
+ return ret;
733
+ },
734
+ __wbg___wbindgen_jsval_eq_4e8c38722cb8ff51: function(arg0, arg1) {
735
+ const ret = getObject(arg0) === getObject(arg1);
736
+ return ret;
737
+ },
738
+ __wbg___wbindgen_jsval_loose_eq_4b9aba9e5b3c4582: function(arg0, arg1) {
739
+ const ret = getObject(arg0) == getObject(arg1);
740
+ return ret;
741
+ },
742
+ __wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
743
+ const obj = getObject(arg1);
744
+ const ret = typeof(obj) === 'number' ? obj : undefined;
745
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
746
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
747
+ },
748
+ __wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
749
+ const obj = getObject(arg1);
750
+ const ret = typeof(obj) === 'string' ? obj : undefined;
751
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
752
+ var len1 = WASM_VECTOR_LEN;
753
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
754
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
755
+ },
756
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
757
+ throw new Error(getStringFromWasm0(arg0, arg1));
758
+ },
759
+ __wbg_call_8e98ed2f3c86c4b5: function() { return handleError(function (arg0, arg1) {
760
+ const ret = getObject(arg0).call(getObject(arg1));
761
+ return addHeapObject(ret);
762
+ }, arguments); },
763
+ __wbg_done_b62d4a7d2286852a: function(arg0) {
764
+ const ret = getObject(arg0).done;
765
+ return ret;
766
+ },
767
+ __wbg_get_9a29be2cb383ed9a: function() { return handleError(function (arg0, arg1) {
768
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
769
+ return addHeapObject(ret);
770
+ }, arguments); },
771
+ __wbg_get_unchecked_54a4374c38e08460: function(arg0, arg1) {
772
+ const ret = getObject(arg0)[arg1 >>> 0];
773
+ return addHeapObject(ret);
774
+ },
775
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
776
+ const ret = getObject(arg0)[getObject(arg1)];
777
+ return addHeapObject(ret);
778
+ },
779
+ __wbg_instanceof_ArrayBuffer_2a7bb09fee70c2da: function(arg0) {
780
+ let result;
781
+ try {
782
+ result = getObject(arg0) instanceof ArrayBuffer;
783
+ } catch (_) {
784
+ result = false;
785
+ }
786
+ const ret = result;
787
+ return ret;
788
+ },
789
+ __wbg_instanceof_Uint8Array_f080092dc70f5d58: function(arg0) {
790
+ let result;
791
+ try {
792
+ result = getObject(arg0) instanceof Uint8Array;
793
+ } catch (_) {
794
+ result = false;
795
+ }
796
+ const ret = result;
797
+ return ret;
798
+ },
799
+ __wbg_isArray_145a34fd0a38d37b: function(arg0) {
800
+ const ret = Array.isArray(getObject(arg0));
801
+ return ret;
802
+ },
803
+ __wbg_isSafeInteger_a3389a198582f5f6: function(arg0) {
804
+ const ret = Number.isSafeInteger(getObject(arg0));
805
+ return ret;
806
+ },
807
+ __wbg_iterator_cc47ba25a2be735a: function() {
808
+ const ret = Symbol.iterator;
809
+ return addHeapObject(ret);
810
+ },
811
+ __wbg_length_589238bdcf171f0e: function(arg0) {
812
+ const ret = getObject(arg0).length;
813
+ return ret;
814
+ },
815
+ __wbg_length_c6054974c0a6cdb9: function(arg0) {
816
+ const ret = getObject(arg0).length;
817
+ return ret;
818
+ },
819
+ __wbg_new_2e117a478906f062: function() {
820
+ const ret = new Object();
821
+ return addHeapObject(ret);
822
+ },
823
+ __wbg_new_36e147a8ced3c6e0: function() {
824
+ const ret = new Array();
825
+ return addHeapObject(ret);
826
+ },
827
+ __wbg_new_81880fb5002cb255: function(arg0) {
828
+ const ret = new Uint8Array(getObject(arg0));
829
+ return addHeapObject(ret);
830
+ },
831
+ __wbg_new_from_slice_11a22f36c0757610: function(arg0, arg1) {
832
+ const ret = new Int8Array(getArrayI8FromWasm0(arg0, arg1));
833
+ return addHeapObject(ret);
834
+ },
835
+ __wbg_new_from_slice_543b875b27789a8f: function(arg0, arg1) {
836
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
837
+ return addHeapObject(ret);
838
+ },
839
+ __wbg_new_from_slice_6696ab0c133d3f19: function(arg0, arg1) {
840
+ const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
841
+ return addHeapObject(ret);
842
+ },
843
+ __wbg_next_0c4066e251d2eff9: function() { return handleError(function (arg0) {
844
+ const ret = getObject(arg0).next();
845
+ return addHeapObject(ret);
846
+ }, arguments); },
847
+ __wbg_next_402fa10b59ab20c3: function(arg0) {
848
+ const ret = getObject(arg0).next;
849
+ return addHeapObject(ret);
850
+ },
851
+ __wbg_now_d2e0afbad4edbe82: function() {
852
+ const ret = Date.now();
853
+ return ret;
854
+ },
855
+ __wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
856
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
857
+ },
858
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
859
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
860
+ },
861
+ __wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
862
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
863
+ },
864
+ __wbg_value_49f783bb59765962: function(arg0) {
865
+ const ret = getObject(arg0).value;
866
+ return addHeapObject(ret);
867
+ },
868
+ __wbindgen_cast_0000000000000001: function(arg0) {
869
+ // Cast intrinsic for `F64 -> Externref`.
870
+ const ret = arg0;
871
+ return addHeapObject(ret);
872
+ },
873
+ __wbindgen_cast_0000000000000002: function(arg0) {
874
+ // Cast intrinsic for `I64 -> Externref`.
875
+ const ret = arg0;
876
+ return addHeapObject(ret);
877
+ },
878
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
879
+ // Cast intrinsic for `Ref(String) -> Externref`.
880
+ const ret = getStringFromWasm0(arg0, arg1);
881
+ return addHeapObject(ret);
882
+ },
883
+ __wbindgen_cast_0000000000000004: function(arg0) {
884
+ // Cast intrinsic for `U64 -> Externref`.
885
+ const ret = BigInt.asUintN(64, arg0);
886
+ return addHeapObject(ret);
887
+ },
888
+ __wbindgen_object_clone_ref: function(arg0) {
889
+ const ret = getObject(arg0);
890
+ return addHeapObject(ret);
891
+ },
892
+ __wbindgen_object_drop_ref: function(arg0) {
893
+ takeObject(arg0);
894
+ },
895
+ };
896
+ return {
897
+ __proto__: null,
898
+ "./tflite_wasm_audit_bg.js": import0,
899
+ };
900
+ }
901
+
902
+ function addHeapObject(obj) {
903
+ if (heap_next === heap.length) heap.push(heap.length + 1);
904
+ const idx = heap_next;
905
+ heap_next = heap[idx];
906
+
907
+ heap[idx] = obj;
908
+ return idx;
909
+ }
910
+
911
+ function debugString(val) {
912
+ // primitive types
913
+ const type = typeof val;
914
+ if (type == 'number' || type == 'boolean' || val == null) {
915
+ return `${val}`;
916
+ }
917
+ if (type == 'string') {
918
+ return `"${val}"`;
919
+ }
920
+ if (type == 'symbol') {
921
+ const description = val.description;
922
+ if (description == null) {
923
+ return 'Symbol';
924
+ } else {
925
+ return `Symbol(${description})`;
926
+ }
927
+ }
928
+ if (type == 'function') {
929
+ const name = val.name;
930
+ if (typeof name == 'string' && name.length > 0) {
931
+ return `Function(${name})`;
932
+ } else {
933
+ return 'Function';
934
+ }
935
+ }
936
+ // objects
937
+ if (Array.isArray(val)) {
938
+ const length = val.length;
939
+ let debug = '[';
940
+ if (length > 0) {
941
+ debug += debugString(val[0]);
942
+ }
943
+ for(let i = 1; i < length; i++) {
944
+ debug += ', ' + debugString(val[i]);
945
+ }
946
+ debug += ']';
947
+ return debug;
948
+ }
949
+ // Test for built-in
950
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
951
+ let className;
952
+ if (builtInMatches && builtInMatches.length > 1) {
953
+ className = builtInMatches[1];
954
+ } else {
955
+ // Failed to match the standard '[object ClassName]'
956
+ return toString.call(val);
957
+ }
958
+ if (className == 'Object') {
959
+ // we're a user defined class or Object
960
+ // JSON.stringify avoids problems with cycles, and is generally much
961
+ // easier than looping through ownProperties of `val`.
962
+ try {
963
+ return 'Object(' + JSON.stringify(val) + ')';
964
+ } catch (_) {
965
+ return 'Object';
966
+ }
967
+ }
968
+ // errors
969
+ if (val instanceof Error) {
970
+ return `${val.name}: ${val.message}\n${val.stack}`;
971
+ }
972
+ // TODO we could test for more things here, like `Set`s and `Map`s.
973
+ return className;
974
+ }
975
+
976
+ function dropObject(idx) {
977
+ if (idx < 1028) return;
978
+ heap[idx] = heap_next;
979
+ heap_next = idx;
980
+ }
981
+
982
+ function getArrayF32FromWasm0(ptr, len) {
983
+ ptr = ptr >>> 0;
984
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
985
+ }
986
+
987
+ function getArrayI8FromWasm0(ptr, len) {
988
+ ptr = ptr >>> 0;
989
+ return getInt8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
990
+ }
991
+
992
+ function getArrayU8FromWasm0(ptr, len) {
993
+ ptr = ptr >>> 0;
994
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
995
+ }
996
+
997
+ let cachedDataViewMemory0 = null;
998
+ function getDataViewMemory0() {
999
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1000
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1001
+ }
1002
+ return cachedDataViewMemory0;
1003
+ }
1004
+
1005
+ let cachedFloat32ArrayMemory0 = null;
1006
+ function getFloat32ArrayMemory0() {
1007
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
1008
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
1009
+ }
1010
+ return cachedFloat32ArrayMemory0;
1011
+ }
1012
+
1013
+ let cachedInt8ArrayMemory0 = null;
1014
+ function getInt8ArrayMemory0() {
1015
+ if (cachedInt8ArrayMemory0 === null || cachedInt8ArrayMemory0.byteLength === 0) {
1016
+ cachedInt8ArrayMemory0 = new Int8Array(wasm.memory.buffer);
1017
+ }
1018
+ return cachedInt8ArrayMemory0;
1019
+ }
1020
+
1021
+ function getStringFromWasm0(ptr, len) {
1022
+ return decodeText(ptr >>> 0, len);
1023
+ }
1024
+
1025
+ let cachedUint8ArrayMemory0 = null;
1026
+ function getUint8ArrayMemory0() {
1027
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1028
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1029
+ }
1030
+ return cachedUint8ArrayMemory0;
1031
+ }
1032
+
1033
+ function getObject(idx) { return heap[idx]; }
1034
+
1035
+ function handleError(f, args) {
1036
+ try {
1037
+ return f.apply(this, args);
1038
+ } catch (e) {
1039
+ wasm.__wbindgen_export3(addHeapObject(e));
1040
+ }
1041
+ }
1042
+
1043
+ let heap = new Array(1024).fill(undefined);
1044
+ heap.push(undefined, null, true, false);
1045
+
1046
+ let heap_next = heap.length;
1047
+
1048
+ function isLikeNone(x) {
1049
+ return x === undefined || x === null;
1050
+ }
1051
+
1052
+ function passArray8ToWasm0(arg, malloc) {
1053
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1054
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1055
+ WASM_VECTOR_LEN = arg.length;
1056
+ return ptr;
1057
+ }
1058
+
1059
+ function passStringToWasm0(arg, malloc, realloc) {
1060
+ if (realloc === undefined) {
1061
+ const buf = cachedTextEncoder.encode(arg);
1062
+ const ptr = malloc(buf.length, 1) >>> 0;
1063
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1064
+ WASM_VECTOR_LEN = buf.length;
1065
+ return ptr;
1066
+ }
1067
+
1068
+ let len = arg.length;
1069
+ let ptr = malloc(len, 1) >>> 0;
1070
+
1071
+ const mem = getUint8ArrayMemory0();
1072
+
1073
+ let offset = 0;
1074
+
1075
+ for (; offset < len; offset++) {
1076
+ const code = arg.charCodeAt(offset);
1077
+ if (code > 0x7F) break;
1078
+ mem[ptr + offset] = code;
1079
+ }
1080
+ if (offset !== len) {
1081
+ if (offset !== 0) {
1082
+ arg = arg.slice(offset);
1083
+ }
1084
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1085
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1086
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1087
+
1088
+ offset += ret.written;
1089
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1090
+ }
1091
+
1092
+ WASM_VECTOR_LEN = offset;
1093
+ return ptr;
1094
+ }
1095
+
1096
+ function takeObject(idx) {
1097
+ const ret = getObject(idx);
1098
+ dropObject(idx);
1099
+ return ret;
1100
+ }
1101
+
1102
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1103
+ cachedTextDecoder.decode();
1104
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1105
+ let numBytesDecoded = 0;
1106
+ function decodeText(ptr, len) {
1107
+ numBytesDecoded += len;
1108
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1109
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1110
+ cachedTextDecoder.decode();
1111
+ numBytesDecoded = len;
1112
+ }
1113
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1114
+ }
1115
+
1116
+ const cachedTextEncoder = new TextEncoder();
1117
+
1118
+ if (!('encodeInto' in cachedTextEncoder)) {
1119
+ cachedTextEncoder.encodeInto = function (arg, view) {
1120
+ const buf = cachedTextEncoder.encode(arg);
1121
+ view.set(buf);
1122
+ return {
1123
+ read: arg.length,
1124
+ written: buf.length
1125
+ };
1126
+ };
1127
+ }
1128
+
1129
+ let WASM_VECTOR_LEN = 0;
1130
+
1131
+ let wasmModule, wasmInstance, wasm;
1132
+ function __wbg_finalize_init(instance, module) {
1133
+ wasmInstance = instance;
1134
+ wasm = instance.exports;
1135
+ wasmModule = module;
1136
+ cachedDataViewMemory0 = null;
1137
+ cachedFloat32ArrayMemory0 = null;
1138
+ cachedInt8ArrayMemory0 = null;
1139
+ cachedUint8ArrayMemory0 = null;
1140
+ return wasm;
1141
+ }
1142
+
1143
+ async function __wbg_load(module, imports) {
1144
+ if (typeof Response === 'function' && module instanceof Response) {
1145
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1146
+ try {
1147
+ return await WebAssembly.instantiateStreaming(module, imports);
1148
+ } catch (e) {
1149
+ const validResponse = module.ok && expectedResponseType(module.type);
1150
+
1151
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1152
+ 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);
1153
+
1154
+ } else { throw e; }
1155
+ }
1156
+ }
1157
+
1158
+ const bytes = await module.arrayBuffer();
1159
+ return await WebAssembly.instantiate(bytes, imports);
1160
+ } else {
1161
+ const instance = await WebAssembly.instantiate(module, imports);
1162
+
1163
+ if (instance instanceof WebAssembly.Instance) {
1164
+ return { instance, module };
1165
+ } else {
1166
+ return instance;
1167
+ }
1168
+ }
1169
+
1170
+ function expectedResponseType(type) {
1171
+ switch (type) {
1172
+ case 'basic': case 'cors': case 'default': return true;
1173
+ }
1174
+ return false;
1175
+ }
1176
+ }
1177
+
1178
+ function initSync(module) {
1179
+ if (wasm !== undefined) return wasm;
1180
+
1181
+
1182
+ if (module !== undefined) {
1183
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1184
+ ({module} = module)
1185
+ } else {
1186
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1187
+ }
1188
+ }
1189
+
1190
+ const imports = __wbg_get_imports();
1191
+ if (!(module instanceof WebAssembly.Module)) {
1192
+ module = new WebAssembly.Module(module);
1193
+ }
1194
+ const instance = new WebAssembly.Instance(module, imports);
1195
+ return __wbg_finalize_init(instance, module);
1196
+ }
1197
+
1198
+ async function __wbg_init(module_or_path) {
1199
+ if (wasm !== undefined) return wasm;
1200
+
1201
+
1202
+ if (module_or_path !== undefined) {
1203
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1204
+ ({module_or_path} = module_or_path)
1205
+ } else {
1206
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1207
+ }
1208
+ }
1209
+
1210
+
1211
+ const imports = __wbg_get_imports();
1212
+
1213
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1214
+ module_or_path = fetch(module_or_path);
1215
+ }
1216
+
1217
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1218
+
1219
+ return __wbg_finalize_init(instance, module);
1220
+ }
1221
+
1222
+ export { initSync, __wbg_init as default };