OXYGENHUB
# f7bcee49bf24 oxygenhub / assets / backdrop / backdrop.js
25.5 KiB · JavaScript · last changed feat(web): Backdrops, the engine in Rust and WASM, and the dashboard's Your sky (refs #157) 22 days ago source blame history raw
17ca6cdd Andy McCall ↶ 1
/**
2
 * Start the dashboard's sky on `canvas` with the page's `data`. `still`
3
 * is the viewer's choice of a still backdrop; reduced motion asks for
4
 * one too. Without WebGL2 there is no backdrop, and nothing breaks.
5
 * @param {HTMLCanvasElement} canvas
6
 * @param {any} data
7
 * @param {boolean} still
8
 */
9
export function start(canvas, data, still) {
10
    const ret = wasm.start(canvas, data, still);
11
    if (ret[1]) {
12
        throw takeFromExternrefTable0(ret[0]);
13
    }
14
}
15
function __wbg_get_imports() {
16
    const import0 = {
17
        __proto__: null,
18
        __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
19
            const v = arg0;
20
            const ret = typeof(v) === 'boolean' ? v : undefined;
21
            return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
22
        },
23
        __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
24
            const ret = arg0 === undefined;
25
            return ret;
26
        },
27
        __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
28
            const obj = arg1;
29
            const ret = typeof(obj) === 'number' ? obj : undefined;
30
            getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
31
            getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
32
        },
33
        __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
34
            const obj = arg1;
35
            const ret = typeof(obj) === 'string' ? obj : undefined;
36
            var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
37
            var len1 = WASM_VECTOR_LEN;
38
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
39
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
40
        },
41
        __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
42
            throw new Error(getStringFromWasm0(arg0, arg1));
43
        },
44
        __wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
45
            arg0._wbg_cb_unref();
46
        },
47
        __wbg_addEventListener_4d0db17c671ea324: function() { return handleError(function (arg0, arg1, arg2, arg3) {
48
            arg0.addEventListener(getStringFromWasm0(arg1, arg2), arg3);
49
        }, arguments); },
50
        __wbg_appendChild_fb8c52e7dd8484ea: function() { return handleError(function (arg0, arg1) {
51
            const ret = arg0.appendChild(arg1);
52
            return ret;
53
        }, arguments); },
54
        __wbg_attachShader_9567ae57af6746d5: function(arg0, arg1, arg2) {
55
            arg0.attachShader(arg1, arg2);
56
        },
57
        __wbg_bindBuffer_0324f62b876c4403: function(arg0, arg1, arg2) {
58
            arg0.bindBuffer(arg1 >>> 0, arg2);
59
        },
60
        __wbg_bindVertexArray_f58af0a346185ec5: function(arg0, arg1) {
61
            arg0.bindVertexArray(arg1);
62
        },
63
        __wbg_blendFunc_589e4252bb396484: function(arg0, arg1, arg2) {
64
            arg0.blendFunc(arg1 >>> 0, arg2 >>> 0);
65
        },
66
        __wbg_body_e549239eaff082e1: function(arg0) {
67
            const ret = arg0.body;
68
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
69
        },
70
        __wbg_bufferData_5fa44d94fe7a3878: function(arg0, arg1, arg2, arg3) {
71
            arg0.bufferData(arg1 >>> 0, arg2, arg3 >>> 0);
72
        },
73
        __wbg_clearColor_796427e8ac60fe14: function(arg0, arg1, arg2, arg3, arg4) {
74
            arg0.clearColor(arg1, arg2, arg3, arg4);
75
        },
76
        __wbg_clear_cb96796cc568b7c8: function(arg0, arg1) {
77
            arg0.clear(arg1 >>> 0);
78
        },
79
        __wbg_clientX_5075231ed45e8ef5: function(arg0) {
80
            const ret = arg0.clientX;
81
            return ret;
82
        },
83
        __wbg_clientY_846c39814ce02ab2: function(arg0) {
84
            const ret = arg0.clientY;
85
            return ret;
86
        },
87
        __wbg_compileShader_c2b53ff3a8851f60: function(arg0, arg1) {
88
            arg0.compileShader(arg1);
89
        },
90
        __wbg_createBuffer_ffe613371d42cfd3: function(arg0) {
91
            const ret = arg0.createBuffer();
92
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
93
        },
94
        __wbg_createElement_74049073a11f9c31: function() { return handleError(function (arg0, arg1, arg2) {
95
            const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
96
            return ret;
97
        }, arguments); },
98
        __wbg_createProgram_cbf448e6f18a9402: function(arg0) {
99
            const ret = arg0.createProgram();
100
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
101
        },
102
        __wbg_createShader_6c1a2295587878a5: function(arg0, arg1) {
103
            const ret = arg0.createShader(arg1 >>> 0);
104
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
105
        },
106
        __wbg_createVertexArray_b223ea69dd08fcab: function(arg0) {
107
            const ret = arg0.createVertexArray();
108
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
109
        },
110
        __wbg_devicePixelRatio_7d39e9af5448d3d4: function(arg0) {
111
            const ret = arg0.devicePixelRatio;
112
            return ret;
113
        },
114
        __wbg_document_9854e03c05fc8834: function(arg0) {
115
            const ret = arg0.document;
116
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
117
        },
118
        __wbg_drawArraysInstanced_9b44aa78a087154d: function(arg0, arg1, arg2, arg3, arg4) {
119
            arg0.drawArraysInstanced(arg1 >>> 0, arg2, arg3, arg4);
120
        },
121
        __wbg_drawArrays_08872e02fb57b847: function(arg0, arg1, arg2, arg3) {
122
            arg0.drawArrays(arg1 >>> 0, arg2, arg3);
123
        },
124
        __wbg_enableVertexAttribArray_d52693866bc8b8dd: function(arg0, arg1) {
125
            arg0.enableVertexAttribArray(arg1 >>> 0);
126
        },
127
        __wbg_enable_cb4fc19b51148c37: function(arg0, arg1) {
128
            arg0.enable(arg1 >>> 0);
129
        },
130
        __wbg_from_296ca31f8d0f1c52: function(arg0) {
131
            const ret = Array.from(arg0);
132
            return ret;
133
        },
134
        __wbg_getComputedStyle_dd0f456804795fd6: function() { return handleError(function (arg0, arg1) {
135
            const ret = arg0.getComputedStyle(arg1);
136
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
137
        }, arguments); },
138
        __wbg_getContext_051324720aa5b7e8: function() { return handleError(function (arg0, arg1, arg2, arg3) {
139
            const ret = arg0.getContext(getStringFromWasm0(arg1, arg2), arg3);
140
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
141
        }, arguments); },
142
        __wbg_getProgramInfoLog_3276b294d6d42fe2: function(arg0, arg1, arg2) {
143
            const ret = arg1.getProgramInfoLog(arg2);
144
            var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
145
            var len1 = WASM_VECTOR_LEN;
146
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
147
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
148
        },
149
        __wbg_getProgramParameter_fc7124bb9fb7c675: function(arg0, arg1, arg2) {
150
            const ret = arg0.getProgramParameter(arg1, arg2 >>> 0);
151
            return ret;
152
        },
153
        __wbg_getPropertyValue_e90a3628c2de4fb6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
154
            const ret = arg1.getPropertyValue(getStringFromWasm0(arg2, arg3));
155
            const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
156
            const len1 = WASM_VECTOR_LEN;
157
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
158
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
159
        }, arguments); },
160
        __wbg_getShaderInfoLog_7e0cbba353ca95da: function(arg0, arg1, arg2) {
161
            const ret = arg1.getShaderInfoLog(arg2);
162
            var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
163
            var len1 = WASM_VECTOR_LEN;
164
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
165
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
166
        },
167
        __wbg_getShaderParameter_745acf10b8e45e31: function(arg0, arg1, arg2) {
168
            const ret = arg0.getShaderParameter(arg1, arg2 >>> 0);
169
            return ret;
170
        },
171
        __wbg_getUniformLocation_50ba45dade572703: function(arg0, arg1, arg2, arg3) {
172
            const ret = arg0.getUniformLocation(arg1, getStringFromWasm0(arg2, arg3));
173
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
174
        },
175
        __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
176
            const ret = Reflect.get(arg0, arg1);
177
            return ret;
178
        }, arguments); },
179
        __wbg_get_6c896e0571ddae51: function(arg0, arg1) {
180
            const ret = arg0[arg1 >>> 0];
181
            return ret;
182
        },
183
        __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
184
            const ret = arg0[arg1 >>> 0];
185
            return ret;
186
        },
187
        __wbg_hidden_2ba371ecafe013fa: function(arg0) {
188
            const ret = arg0.hidden;
189
            return ret;
190
        },
191
        __wbg_innerHeight_7f20e0f1a7c5a573: function() { return handleError(function (arg0) {
192
            const ret = arg0.innerHeight;
193
            return ret;
194
        }, arguments); },
195
        __wbg_innerWidth_1bc526614080537c: function() { return handleError(function (arg0) {
196
            const ret = arg0.innerWidth;
197
            return ret;
198
        }, arguments); },
199
        __wbg_instanceof_HtmlElement_32fb153a5a0e2349: function(arg0) {
200
            let result;
201
            try {
202
                result = arg0 instanceof HTMLElement;
203
            } catch (_) {
204
                result = false;
205
            }
206
            const ret = result;
207
            return ret;
208
        },
209
        __wbg_instanceof_WebGl2RenderingContext_64c994c14c0790fb: function(arg0) {
210
            let result;
211
            try {
212
                result = arg0 instanceof WebGL2RenderingContext;
213
            } catch (_) {
214
                result = false;
215
            }
216
            const ret = result;
217
            return ret;
218
        },
219
        __wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
220
            let result;
221
            try {
222
                result = arg0 instanceof Window;
223
            } catch (_) {
224
                result = false;
225
            }
226
            const ret = result;
227
            return ret;
228
        },
229
        __wbg_length_d4bdea10311bd9cf: function(arg0) {
230
            const ret = arg0.length;
231
            return ret;
232
        },
233
        __wbg_linkProgram_acdc299c43d734a0: function(arg0, arg1) {
234
            arg0.linkProgram(arg1);
235
        },
236
        __wbg_matchMedia_8a4857f947f11f82: function() { return handleError(function (arg0, arg1, arg2) {
237
            const ret = arg0.matchMedia(getStringFromWasm0(arg1, arg2));
238
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
239
        }, arguments); },
240
        __wbg_matches_778d0873b064b1bf: function(arg0) {
241
            const ret = arg0.matches;
242
            return ret;
243
        },
244
        __wbg_new_617a8cdb8bb1130e: function() {
245
            const ret = new Object();
246
            return ret;
247
        },
248
        __wbg_now_d0b7f4bea9f38490: function(arg0) {
249
            const ret = arg0.now();
250
            return ret;
251
        },
252
        __wbg_performance_d0d7b03fc649b694: function(arg0) {
253
            const ret = arg0.performance;
254
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
255
        },
256
        __wbg_relatedTarget_520fe88b1de28b43: function(arg0) {
257
            const ret = arg0.relatedTarget;
258
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
259
        },
260
        __wbg_requestAnimationFrame_7b526ab7aa550c74: function() { return handleError(function (arg0, arg1) {
261
            const ret = arg0.requestAnimationFrame(arg1);
262
            return ret;
263
        }, arguments); },
264
        __wbg_setAttribute_9e7d603908f63705: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
265
            arg0.setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
266
        }, arguments); },
267
        __wbg_setProperty_097bc3d55ce44513: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
268
            arg0.setProperty(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
269
        }, arguments); },
270
        __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
271
            const ret = Reflect.set(arg0, arg1, arg2);
272
            return ret;
273
        }, arguments); },
274
        __wbg_set_className_541fce5cd31918aa: function(arg0, arg1, arg2) {
275
            arg0.className = getStringFromWasm0(arg1, arg2);
276
        },
277
        __wbg_set_height_c9789c1c77eaedff: function(arg0, arg1) {
278
            arg0.height = arg1 >>> 0;
279
        },
280
        __wbg_set_textContent_6d6fc559f198055f: function(arg0, arg1, arg2) {
281
            arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
282
        },
283
        __wbg_set_width_b0e1267db4b196b5: function(arg0, arg1) {
284
            arg0.width = arg1 >>> 0;
285
        },
286
        __wbg_shaderSource_c8812639b47d87b9: function(arg0, arg1, arg2, arg3) {
287
            arg0.shaderSource(arg1, getStringFromWasm0(arg2, arg3));
288
        },
289
        __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
290
            const ret = typeof global === 'undefined' ? null : global;
291
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
292
        },
293
        __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
294
            const ret = typeof globalThis === 'undefined' ? null : globalThis;
295
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
296
        },
297
        __wbg_static_accessor_SELF_0b583911f537483a: function() {
298
            const ret = typeof self === 'undefined' ? null : self;
299
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
300
        },
301
        __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
302
            const ret = typeof window === 'undefined' ? null : window;
303
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
304
        },
305
        __wbg_style_4bce24230e493a7c: function(arg0) {
306
            const ret = arg0.style;
307
            return ret;
308
        },
309
        __wbg_uniform2f_a92b5bb95dc5b4d9: function(arg0, arg1, arg2, arg3) {
310
            arg0.uniform2f(arg1, arg2, arg3);
311
        },
312
        __wbg_useProgram_e075c2902e420761: function(arg0, arg1) {
313
            arg0.useProgram(arg1);
314
        },
315
        __wbg_vertexAttribDivisor_7575d382215322f7: function(arg0, arg1, arg2) {
316
            arg0.vertexAttribDivisor(arg1 >>> 0, arg2 >>> 0);
317
        },
318
        __wbg_vertexAttribPointer_24b495e18df325dc: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
319
            arg0.vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6);
320
        },
321
        __wbg_viewport_16936692526e2ce6: function(arg0, arg1, arg2, arg3, arg4) {
322
            arg0.viewport(arg1, arg2, arg3, arg4);
323
        },
324
        __wbindgen_generic_0000000000000001: function(arg0, arg1) {
325
            // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [F64], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
326
            const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___f64______true_);
327
            return ret;
328
        },
329
        __wbindgen_generic_0000000000000002: function(arg0, arg1) {
330
            // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MouseEvent")], shim_idx: 5, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
331
            const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___web_sys_793942649ef82f98___features__gen_MouseEvent__MouseEvent______true_);
332
            return ret;
333
        },
334
        __wbindgen_generic_0000000000000003: function(arg0, arg1) {
335
            // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 4, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
336
            const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke_______true_);
337
            return ret;
338
        },
339
        __wbindgen_generic_0000000000000004: function(arg0, arg1) {
340
            // Cast intrinsic for `Ref(Slice(F32)) -> NamedExternref("Float32Array")`.
341
            const ret = getArrayF32FromWasm0(arg0, arg1);
342
            return ret;
343
        },
344
        __wbindgen_generic_0000000000000005: function(arg0, arg1) {
345
            // Cast intrinsic for `Ref(String) -> Externref`.
346
            const ret = getStringFromWasm0(arg0, arg1);
347
            return ret;
348
        },
349
        __wbindgen_init_externref_table: function() {
350
            const table = wasm.__wbindgen_externrefs;
351
            const offset = table.grow(4);
352
            table.set(0, undefined);
353
            table.set(offset + 0, undefined);
354
            table.set(offset + 1, null);
355
            table.set(offset + 2, true);
356
            table.set(offset + 3, false);
357
        },
358
    };
359
    return {
360
        __proto__: null,
361
        "./backdrop_bg.js": import0,
362
    };
363
}
364
365
function wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke_______true_(arg0, arg1) {
366
    wasm.wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke_______true_(arg0, arg1);
367
}
368
369
function wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___web_sys_793942649ef82f98___features__gen_MouseEvent__MouseEvent______true_(arg0, arg1, arg2) {
370
    wasm.wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___web_sys_793942649ef82f98___features__gen_MouseEvent__MouseEvent______true_(arg0, arg1, arg2);
371
}
372
373
function wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___f64______true_(arg0, arg1, arg2) {
374
    wasm.wasm_bindgen_ef67fbc5f0a8b406___convert__closures_____invoke___f64______true_(arg0, arg1, arg2);
375
}
376
377
function addToExternrefTable0(obj) {
378
    const idx = wasm.__externref_table_alloc();
379
    wasm.__wbindgen_externrefs.set(idx, obj);
380
    return idx;
381
}
382
383
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
384
    ? { register: () => {}, unregister: () => {} }
385
    : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
386
387
function getArrayF32FromWasm0(ptr, len) {
388
    ptr = ptr >>> 0;
389
    return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
390
}
391
392
let cachedDataViewMemory0 = null;
393
function getDataViewMemory0() {
394
    if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
395
        cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
396
    }
397
    return cachedDataViewMemory0;
398
}
399
400
let cachedFloat32ArrayMemory0 = null;
401
function getFloat32ArrayMemory0() {
402
    if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
403
        cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
404
    }
405
    return cachedFloat32ArrayMemory0;
406
}
407
408
function getStringFromWasm0(ptr, len) {
409
    return decodeText(ptr >>> 0, len);
410
}
411
412
let cachedUint8ArrayMemory0 = null;
413
function getUint8ArrayMemory0() {
414
    if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
415
        cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
416
    }
417
    return cachedUint8ArrayMemory0;
418
}
419
420
function handleError(f, args) {
421
    try {
422
        return f.apply(this, args);
423
    } catch (e) {
424
        const idx = addToExternrefTable0(e);
425
        wasm.__wbindgen_exn_store(idx);
426
    }
427
}
428
429
function isLikeNone(x) {
430
    return x === undefined || x === null;
431
}
432
433
function makeMutClosure(arg0, arg1, f) {
434
    const state = { a: arg0, b: arg1, cnt: 1 };
435
    const real = (...args) => {
436
437
        // First up with a closure we increment the internal reference
438
        // count. This ensures that the Rust closure environment won't
439
        // be deallocated while we're invoking it.
440
        state.cnt++;
441
        const a = state.a;
442
        state.a = 0;
443
        try {
444
            return f(a, state.b, ...args);
445
        } finally {
446
            state.a = a;
447
            real._wbg_cb_unref();
448
        }
449
    };
450
    real._wbg_cb_unref = () => {
451
        if (--state.cnt === 0) {
452
            wasm.__wbindgen_destroy_closure(state.a, state.b);
453
            state.a = 0;
454
            CLOSURE_DTORS.unregister(state);
455
        }
456
    };
457
    CLOSURE_DTORS.register(real, state, state);
458
    return real;
459
}
460
461
function passStringToWasm0(arg, malloc, realloc) {
462
    if (realloc === undefined) {
463
        const buf = cachedTextEncoder.encode(arg);
464
        const ptr = malloc(buf.length, 1) >>> 0;
465
        getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
466
        WASM_VECTOR_LEN = buf.length;
467
        return ptr;
468
    }
469
470
    let len = arg.length;
471
    let ptr = malloc(len, 1) >>> 0;
472
473
    const mem = getUint8ArrayMemory0();
474
475
    let offset = 0;
476
477
    for (; offset < len; offset++) {
478
        const code = arg.charCodeAt(offset);
479
        if (code > 0x7F) break;
480
        mem[ptr + offset] = code;
481
    }
482
    if (offset !== len) {
483
        if (offset !== 0) {
484
            arg = arg.slice(offset);
485
        }
486
        ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
487
        const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
488
        const ret = cachedTextEncoder.encodeInto(arg, view);
489
490
        offset += ret.written;
491
        ptr = realloc(ptr, len, offset, 1) >>> 0;
492
    }
493
494
    WASM_VECTOR_LEN = offset;
495
    return ptr;
496
}
497
498
function takeFromExternrefTable0(idx) {
499
    const value = wasm.__wbindgen_externrefs.get(idx);
500
    wasm.__externref_table_dealloc(idx);
501
    return value;
502
}
503
504
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
505
cachedTextDecoder.decode();
506
const MAX_SAFARI_DECODE_BYTES = 2146435072;
507
let numBytesDecoded = 0;
508
function decodeText(ptr, len) {
509
    numBytesDecoded += len;
510
    if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
511
        cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
512
        cachedTextDecoder.decode();
513
        numBytesDecoded = len;
514
    }
515
    return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
516
}
517
518
const cachedTextEncoder = new TextEncoder();
519
520
if (!('encodeInto' in cachedTextEncoder)) {
521
    cachedTextEncoder.encodeInto = function (arg, view) {
522
        const buf = cachedTextEncoder.encode(arg);
523
        view.set(buf);
524
        return {
525
            read: arg.length,
526
            written: buf.length
527
        };
528
    };
529
}
530
531
let WASM_VECTOR_LEN = 0;
532
533
let wasmModule, wasmInstance, wasm;
534
function __wbg_finalize_init(instance, module) {
535
    wasmInstance = instance;
536
    wasm = instance.exports;
537
    wasmModule = module;
538
    cachedDataViewMemory0 = null;
539
    cachedFloat32ArrayMemory0 = null;
540
    cachedUint8ArrayMemory0 = null;
541
    wasm.__wbindgen_start();
542
    return wasm;
543
}
544
545
async function __wbg_load(module, imports) {
546
    if (typeof Response === 'function' && module instanceof Response) {
547
        if (!module.ok) {
548
            throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
549
        }
550
551
        if (typeof WebAssembly.instantiateStreaming === 'function') {
552
            try {
553
                return await WebAssembly.instantiateStreaming(module, imports);
554
            } catch (e) {
555
                const validResponse = expectedResponseType(module.type);
556
557
                if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
558
                    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);
559
560
                } else { throw e; }
561
            }
562
        }
563
564
        const bytes = await module.arrayBuffer();
565
        return await WebAssembly.instantiate(bytes, imports);
566
    } else {
567
        const instance = await WebAssembly.instantiate(module, imports);
568
569
        if (instance instanceof WebAssembly.Instance) {
570
            return { instance, module };
571
        } else {
572
            return instance;
573
        }
574
    }
575
576
    function expectedResponseType(type) {
577
        switch (type) {
578
            case 'basic': case 'cors': case 'default': return true;
579
        }
580
        return false;
581
    }
582
}
583
584
function initSync(module) {
585
    if (wasm !== undefined) return wasm;
586
587
588
    if (module !== undefined) {
589
        if (Object.getPrototypeOf(module) === Object.prototype) {
590
            ({module} = module)
591
        } else {
592
            console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
593
        }
594
    }
595
596
    const imports = __wbg_get_imports();
597
    if (!(module instanceof WebAssembly.Module)) {
598
        module = new WebAssembly.Module(module);
599
    }
600
    const instance = new WebAssembly.Instance(module, imports);
601
    return __wbg_finalize_init(instance, module);
602
}
603
604
async function __wbg_init(module_or_path) {
605
    if (wasm !== undefined) return wasm;
606
607
608
    if (module_or_path !== undefined) {
609
        if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
610
            ({module_or_path} = module_or_path)
611
        } else {
612
            console.warn('using deprecated parameters for the initialization function; pass a single object instead')
613
        }
614
    }
615
616
    if (module_or_path === undefined) {
617
        module_or_path = new URL('backdrop_bg.wasm', import.meta.url);
618
    }
619
    const imports = __wbg_get_imports();
620
621
    if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
622
        module_or_path = fetch(module_or_path);
623
    }
624
625
    const { instance, module } = await __wbg_load(await module_or_path, imports);
626
627
    return __wbg_finalize_init(instance, module);
628
}
629
630
export { initSync, __wbg_init as default };