let wasm;
let WASM_VECTOR_LEN = 0;
let cachedUint8Memory0;
function getUint8Memory0() {
if (cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
}
const cachedTextEncoder = new TextEncoder("utf-8");
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length);
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len);
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3);
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
let cachedInt32Memory0;
function getInt32Memory0() {
if (cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachedInt32Memory0;
}
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) {
return heap[idx];
}
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
const cachedTextDecoder = new TextDecoder("utf-8", {
ignoreBOM: true,
fatal: true,
});
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
export function parse(content, options) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(
content,
wasm.__wbindgen_malloc,
wasm.__wbindgen_realloc,
);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm0(
options,
wasm.__wbindgen_malloc,
wasm.__wbindgen_realloc,
);
const len1 = WASM_VECTOR_LEN;
wasm.parse(retptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
var ptr2 = r0;
var len2 = r1;
if (r3) {
ptr2 = 0;
len2 = 0;
throw takeObject(r2);
}
return getStringFromWasm0(ptr2, len2);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(ptr2, len2);
}
}
const imports = {
__wbindgen_placeholder__: {},
};
const wasm_url = new URL("dynamic_html_bg.wasm", import.meta.url);
export async function instantiate(transform) {
return (await instantiateWithInstance(transform)).exports;
}
let instanceWithExports;
let lastLoadPromise;
export function instantiateWithInstance(transform) {
if (instanceWithExports != null) {
return Promise.resolve(instanceWithExports);
}
if (lastLoadPromise == null) {
lastLoadPromise = (async () => {
try {
const instance = (await instantiateModule(transform)).instance;
wasm = instance.exports;
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
instanceWithExports = {
instance,
exports: getWasmInstanceExports(),
};
return instanceWithExports;
} finally {
lastLoadPromise = null;
}
})();
}
return lastLoadPromise;
}
function getWasmInstanceExports() {
return { parse };
}
export function isInstantiated() {
return instanceWithExports != null;
}
async function instantiateModule(transform) {
switch (wasm_url.protocol) {
case "file:": {
if (typeof Deno !== "object") {
throw new Error("file urls are not supported in this environment");
}
if ("permissions" in Deno) {
Deno.permissions.request({ name: "read", path: wasm_url });
}
const wasmCode = await Deno.readFile(wasm_url);
return WebAssembly.instantiate(
!transform ? wasmCode : transform(wasmCode),
imports,
);
}
case "https:":
case "http:": {
if (typeof Deno === "object" && "permissions" in Deno) {
Deno.permissions.request({ name: "net", host: wasm_url.host });
}
const wasmResponse = await fetch(wasm_url);
if (transform) {
const wasmCode = new Uint8Array(await wasmResponse.arrayBuffer());
return WebAssembly.instantiate(transform(wasmCode), imports);
}
if (
wasmResponse.headers.get("content-type")?.toLowerCase().startsWith(
"application/wasm",
)
) {
return WebAssembly.instantiateStreaming(wasmResponse, imports);
} else {
return WebAssembly.instantiate(
await wasmResponse.arrayBuffer(),
imports,
);
}
}
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
}