UNPKG

lazts

Version:

TypeScript package for loading LAS/LAZ, primary developed for for WebGL applications, intended for lazy people who just want to load their point clouds and don't care about the details.

1,115 lines 84.5 kB
var Wn = Object.defineProperty; var xn = (p, f, h) => f in p ? Wn(p, f, { enumerable: !0, configurable: !0, writable: !0, value: h }) : p[f] = h; var E = (p, f, h) => (xn(p, typeof f != "symbol" ? f + "" : f, h), h); function Hn(p, f) { const { attributes: h } = p, { position: d, intensity: b, classification: i } = h; console.log( `File size: ${f / 1024 / 1024} MB, Memory used ${Math.round( (d.value.length * 4 + b.value.length * 4 + i.value.length) / 1024 / 1024 )} MB` ); } const Lt = { 0: (p) => ({ position: [p.getInt32(0, !0), p.getInt32(4, !0), p.getInt32(8, !0)], intensity: p.getUint16(12, !0), classification: p.getUint8(15) }), 1: (p) => ({ position: [p.getInt32(0, !0), p.getInt32(4, !0), p.getInt32(8, !0)], intensity: p.getUint16(12, !0), classification: p.getUint8(15) }), 2: (p) => ({ position: [p.getInt32(0, !0), p.getInt32(4, !0), p.getInt32(8, !0)], intensity: p.getUint16(12, !0), classification: p.getUint8(15), color: [p.getUint16(20, !0), p.getUint16(22, !0), p.getUint16(24, !0)] }), 3: (p) => ({ position: [p.getInt32(0, !0), p.getInt32(4, !0), p.getInt32(8, !0)], intensity: p.getUint16(12, !0), classification: p.getUint8(15), color: [p.getUint16(28, !0), p.getUint16(30, !0), p.getUint16(32, !0)] }) }; function ee(p, f = {}, h, d) { d = d === void 0 || d === 0 ? 1 : d; const b = p.slice(h, h + f.BYTES_PER_ELEMENT * d), i = new f(b); if (d === 1) return i[0]; const P = []; for (let A = 0; A < d; A++) P.push(i[A]); return P; } function $t(p) { let f = 131; const h = { pointsOffset: ee(p, Uint32Array, 32 * 3), pointsFormatId: ee(p, Uint8Array, 32 * 3 + 8), pointsStructSize: ee(p, Uint16Array, 32 * 3 + 8 + 1), pointsCount: ee(p, Uint32Array, 32 * 3 + 11), scale: ee(p, Float64Array, f, 3) }; f += 24, h.offset = ee(p, Float64Array, f, 3), f += 24; const d = ee(p, Float64Array, f, 6); return f += 48, h.maxs = [d[0], d[2], d[4]], h.mins = [d[1], d[3], d[5]], h; } class jn { constructor(f, h, d) { E(this, "arrayb"); E(this, "decoder"); E(this, "pointsCount"); E(this, "pointSize"); E(this, "scale"); E(this, "offset"); E(this, "mins"); E(this, "maxs"); this.arrayb = f, this.decoder = Lt[d.pointsFormatId], this.pointsCount = h, this.pointSize = d.pointsStructSize, this.scale = d.scale, this.offset = d.offset, this.mins = d.mins, this.maxs = d.maxs; } /** * Decodes data depends on this point size * @param index * @returns New object */ getPoint(f) { if (f < 0 || f >= this.pointsCount) throw new Error("Point index out of range"); const h = new DataView(this.arrayb, f * this.pointSize, this.pointSize); return this.decoder(h); } } class zn { constructor(f) { E(this, "arraybuffer"); E(this, "readOffset", 0); E(this, "header", { pointsOffset: 0, pointsFormatId: 0, pointsStructSize: 0, pointsCount: 0, scale: [0, 0, 0], offset: [0, 0, 0], maxs: [0], mins: [0], totalToRead: 0, totalRead: 0, versionAsString: "", isCompressed: !0 }); this.arraybuffer = f; } /** * @returns boolean */ async open() { return !0; } /** * Parsing of incoming binary * @returns LASHeader */ getHeader() { return this.header = $t(this.arraybuffer), this.header; } /** * Reading data * @param count * @param skip * @returns new ArrayBuffer, count, hasMoreData */ readData(f, h) { const { header: d, arraybuffer: b } = this; if (!d) throw new Error("Cannot start reading data till a header request is issued"); let { readOffset: i } = this, P; if (h <= 1) { f = Math.min(f, d.pointsCount - i), P = d.pointsOffset + i * d.pointsStructSize; const $ = P + f * d.pointsStructSize; return i += f, this.readOffset = i, { buffer: b.slice(P, $), count: f, hasMoreData: i < d.pointsCount }; } const A = Math.min(f * h, d.pointsCount - i), M = Math.ceil(A / h); let D = 0; const I = new Uint8Array(M * d.pointsStructSize); for (let $ = 0; $ < A; $++) { if ($ % h === 0) { P = d.pointsOffset + i * d.pointsStructSize; const se = new Uint8Array(b, P, d.pointsStructSize); I.set(se, D * d.pointsStructSize), D++; } i++; } return this.readOffset = i, { buffer: I.buffer, count: D, hasMoreData: i < d.pointsCount }; } /** * Method which brings data to null to close the file * @returns */ close() { return this.arraybuffer = null, !0; } } var Ut = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, oe = {}, Nt = { exports: {} }; (function(p, f) { var h = (() => { var d = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0; return function(b) { b = b || {}; var i = typeof b < "u" ? b : {}, P, A; i.ready = new Promise(function(e, t) { P = e, A = t; }), ["_main", "___getTypeName", "__embind_initialize_bindings", "_fflush", "onRuntimeInitialized"].forEach((e) => { Object.getOwnPropertyDescriptor(i.ready, e) || Object.defineProperty(i.ready, e, { get: () => W("You are getting " + e + " on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"), set: () => W("You are setting " + e + " on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js") }); }); var M = Object.assign({}, i), D = "./this.program", I = !0, $ = !1, se = !1, Le = !1; if (i.ENVIRONMENT) throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"); var V = ""; function xt(e) { return i.locateFile ? i.locateFile(e, V) : V + e; } var Ht; if (typeof document < "u" && document.currentScript && (V = document.currentScript.src), d && (V = d), V.indexOf("blob:") !== 0 ? V = V.substr(0, V.replace(/[?#].*/, "").lastIndexOf("/") + 1) : V = "", !(typeof window == "object" || typeof importScripts == "function")) throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)"); var jt = i.print || console.log.bind(console), U = i.printErr || console.warn.bind(console); Object.assign(i, M), M = null, kn(), i.arguments && i.arguments, B("arguments", "arguments_"), i.thisProgram && (D = i.thisProgram), B("thisProgram", "thisProgram"), i.quit && i.quit, B("quit", "quit_"), m(typeof i.memoryInitializerPrefixURL > "u", "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"), m(typeof i.pthreadMainPrefixURL > "u", "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"), m(typeof i.cdInitializerPrefixURL > "u", "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"), m(typeof i.filePackagePrefixURL > "u", "Module.filePackagePrefixURL option was removed, use Module.locateFile instead"), m(typeof i.read > "u", "Module.read option was removed (modify read_ in JS)"), m(typeof i.readAsync > "u", "Module.readAsync option was removed (modify readAsync in JS)"), m(typeof i.readBinary > "u", "Module.readBinary option was removed (modify readBinary in JS)"), m(typeof i.setWindowTitle > "u", "Module.setWindowTitle option was removed (modify setWindowTitle in JS)"), m(typeof i.TOTAL_MEMORY > "u", "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"), B("read", "read_"), B("readAsync", "readAsync"), B("readBinary", "readBinary"), B("setWindowTitle", "setWindowTitle"), m(!$, "worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable."), m(!se, "node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable."), m(!Le, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable."); function B(e, t) { Object.getOwnPropertyDescriptor(i, e) || Object.defineProperty(i, e, { configurable: !0, get: function() { W("Module." + e + " has been replaced with plain " + t + " (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)"); } }); } function zt(e) { Object.getOwnPropertyDescriptor(i, e) && W("`Module." + e + "` was supplied but `" + e + "` not included in INCOMING_MODULE_JS_API"); } function at(e) { return e === "FS_createPath" || e === "FS_createDataFile" || e === "FS_createPreloadedFile" || e === "FS_unlink" || e === "addRunDependency" || e === "FS_createLazyFile" || e === "FS_createDevice" || e === "removeRunDependency"; } function Yt(e) { typeof globalThis < "u" && !Object.getOwnPropertyDescriptor(globalThis, e) && Object.defineProperty(globalThis, e, { configurable: !0, get: function() { var t = "`" + e + "` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line"; at(e) && (t += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"), ne(t); } }); } function Vt(e) { Object.getOwnPropertyDescriptor(i, e) || Object.defineProperty(i, e, { configurable: !0, get: function() { var t = "'" + e + "' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)"; at(e) && (t += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"), W(t); } }); } var ge; i.wasmBinary && (ge = i.wasmBinary), B("wasmBinary", "wasmBinary"), i.noExitRuntime, B("noExitRuntime", "noExitRuntime"), typeof WebAssembly != "object" && W("no native wasm support detected"); var he, Ce = !1; function m(e, t) { e || W("Assertion failed" + (t ? ": " + t : "")); } var ot = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0; function st(e, t, r) { for (var n = t + r, a = t; e[a] && !(a >= n); ) ++a; if (a - t > 16 && e.buffer && ot) return ot.decode(e.subarray(t, a)); for (var s = ""; t < a; ) { var u = e[t++]; if (!(u & 128)) { s += String.fromCharCode(u); continue; } var o = e[t++] & 63; if ((u & 224) == 192) { s += String.fromCharCode((u & 31) << 6 | o); continue; } var l = e[t++] & 63; if ((u & 240) == 224 ? u = (u & 15) << 12 | o << 6 | l : ((u & 248) != 240 && ne("Invalid UTF-8 leading byte 0x" + u.toString(16) + " encountered when deserializing a UTF-8 string in wasm memory to a JS string!"), u = (u & 7) << 18 | o << 12 | l << 6 | e[t++] & 63), u < 65536) s += String.fromCharCode(u); else { var g = u - 65536; s += String.fromCharCode(55296 | g >> 10, 56320 | g & 1023); } } return s; } function $e(e, t) { return e ? st(N, e, t) : ""; } function lt(e, t, r, n) { if (!(n > 0)) return 0; for (var a = r, s = r + n - 1, u = 0; u < e.length; ++u) { var o = e.charCodeAt(u); if (o >= 55296 && o <= 57343) { var l = e.charCodeAt(++u); o = 65536 + ((o & 1023) << 10) | l & 1023; } if (o <= 127) { if (r >= s) break; t[r++] = o; } else if (o <= 2047) { if (r + 1 >= s) break; t[r++] = 192 | o >> 6, t[r++] = 128 | o & 63; } else if (o <= 65535) { if (r + 2 >= s) break; t[r++] = 224 | o >> 12, t[r++] = 128 | o >> 6 & 63, t[r++] = 128 | o & 63; } else { if (r + 3 >= s) break; o > 1114111 && ne("Invalid Unicode code point 0x" + o.toString(16) + " encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."), t[r++] = 240 | o >> 18, t[r++] = 128 | o >> 12 & 63, t[r++] = 128 | o >> 6 & 63, t[r++] = 128 | o & 63; } } return t[r] = 0, r - a; } function Bt(e, t, r) { return m(typeof r == "number", "stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"), lt(e, N, t, r); } function ut(e) { for (var t = 0, r = 0; r < e.length; ++r) { var n = e.charCodeAt(r); n <= 127 ? t++ : n <= 2047 ? t += 2 : n >= 55296 && n <= 57343 ? (t += 4, ++r) : t += 3; } return t; } var Ee, G, N, le, Pe, C, S, ct, ft; function dt(e) { Ee = e, i.HEAP8 = G = new Int8Array(e), i.HEAP16 = le = new Int16Array(e), i.HEAP32 = C = new Int32Array(e), i.HEAPU8 = N = new Uint8Array(e), i.HEAPU16 = Pe = new Uint16Array(e), i.HEAPU32 = S = new Uint32Array(e), i.HEAPF32 = ct = new Float32Array(e), i.HEAPF64 = ft = new Float64Array(e); } var Ne = 65536; i.TOTAL_STACK && m(Ne === i.TOTAL_STACK, "the stack size can no longer be determined at runtime"); var We = i.INITIAL_MEMORY || 262144; B("INITIAL_MEMORY", "INITIAL_MEMORY"), m(We >= Ne, "INITIAL_MEMORY should be larger than TOTAL_STACK, was " + We + "! (TOTAL_STACK=" + Ne + ")"), m(typeof Int32Array < "u" && typeof Float64Array < "u" && Int32Array.prototype.subarray != null && Int32Array.prototype.set != null, "JS engine does not provide full typed array support"), m(!i.wasmMemory, "Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"), m(We == 262144, "Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"); var Fe; function Gt() { var e = nt(); m((e & 3) == 0), S[e >> 2] = 34821223, S[e + 4 >> 2] = 2310721022, S[0] = 1668509029; } function xe() { if (!Ce) { var e = nt(), t = S[e >> 2], r = S[e + 4 >> 2]; (t != 34821223 || r != 2310721022) && W("Stack overflow! Stack cookie has been overwritten at 0x" + e.toString(16) + ", expected hex dwords 0x89BACDFE and 0x2135467, but received 0x" + r.toString(16) + " 0x" + t.toString(16)), S[0] !== 1668509029 && W("Runtime error: The application has corrupted its heap memory area (address zero)!"); } } (function() { var e = new Int16Array(1), t = new Int8Array(e.buffer); if (e[0] = 25459, t[0] !== 115 || t[1] !== 99) throw "Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"; })(); var pt = [], gt = [], ht = [], He = !1; function Jt() { if (i.preRun) for (typeof i.preRun == "function" && (i.preRun = [i.preRun]); i.preRun.length; ) Xt(i.preRun.shift()); je(pt); } function Kt() { m(!He), He = !0, xe(), je(gt); } function qt() { if (xe(), i.postRun) for (typeof i.postRun == "function" && (i.postRun = [i.postRun]); i.postRun.length; ) Qt(i.postRun.shift()); je(ht); } function Xt(e) { pt.unshift(e); } function Zt(e) { gt.unshift(e); } function Qt(e) { ht.unshift(e); } m(Math.imul, "This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"), m(Math.fround, "This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"), m(Math.clz32, "This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"), m(Math.trunc, "This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"); var te = 0, re = null, me = null, ye = {}; function er(e) { te++, i.monitorRunDependencies && i.monitorRunDependencies(te), e ? (m(!ye[e]), ye[e] = 1, re === null && typeof setInterval < "u" && (re = setInterval(function() { if (Ce) { clearInterval(re), re = null; return; } var t = !1; for (var r in ye) t || (t = !0, U("still waiting on run dependencies:")), U("dependency: " + r); t && U("(end of list)"); }, 1e4))) : U("warning: run dependency added without ID"); } function tr(e) { if (te--, i.monitorRunDependencies && i.monitorRunDependencies(te), e ? (m(ye[e]), delete ye[e]) : U("warning: run dependency removed without ID"), te == 0 && (re !== null && (clearInterval(re), re = null), me)) { var t = me; me = null, t(); } } function W(e) { i.onAbort && i.onAbort(e), e = "Aborted(" + e + ")", U(e), Ce = !0; var t = new WebAssembly.RuntimeError(e); throw A(t), t; } var z = { error: function() { W("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM"); }, init: function() { z.error(); }, createDataFile: function() { z.error(); }, createPreloadedFile: function() { z.error(); }, createLazyFile: function() { z.error(); }, open: function() { z.error(); }, mkdev: function() { z.error(); }, registerDevice: function() { z.error(); }, analyzePath: function() { z.error(); }, loadFilesFromDB: function() { z.error(); }, ErrnoError: function() { z.error(); } }; i.FS_createDataFile = z.createDataFile, i.FS_createPreloadedFile = z.createPreloadedFile; var rr = "data:application/octet-stream;base64,"; function mt(e) { return e.startsWith(rr); } function nr(e) { return e.startsWith("file://"); } function O(e, t) { return function() { var r = e, n = t; return t || (n = i.asm), m(He, "native function `" + r + "` called before runtime initialization"), n[e] || m(n[e], "exported native function `" + r + "` not found"), n[e].apply(null, arguments); }; } var H; H = "laz-perf.wasm", mt(H) || (H = xt(H)); function yt(e) { try { if (e == H && ge) return new Uint8Array(ge); throw "both async and sync fetching of the wasm failed"; } catch (t) { W(t); } } function ir() { return !ge && I && typeof fetch == "function" ? fetch(H, { credentials: "same-origin" }).then(function(e) { if (!e.ok) throw "failed to load wasm binary file at '" + H + "'"; return e.arrayBuffer(); }).catch(function() { return yt(H); }) : Promise.resolve().then(function() { return yt(H); }); } function ar() { var e = { env: Rt, wasi_snapshot_preview1: Rt }; function t(o, l) { var g = o.exports; i.asm = g, he = i.asm.memory, m(he, "memory not found in wasm exports"), dt(he.buffer), Fe = i.asm.__indirect_function_table, m(Fe, "table not found in wasm exports"), Zt(i.asm.__wasm_call_ctors), tr("wasm-instantiate"); } er("wasm-instantiate"); var r = i; function n(o) { m(i === r, "the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"), r = null, t(o.instance); } function a(o) { return ir().then(function(l) { return WebAssembly.instantiate(l, e); }).then(function(l) { return l; }).then(o, function(l) { U("failed to asynchronously prepare wasm: " + l), nr(H) && U("warning: Loading from a file URI (" + H + ") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"), W(l); }); } function s() { return !ge && typeof WebAssembly.instantiateStreaming == "function" && !mt(H) && typeof fetch == "function" ? fetch(H, { credentials: "same-origin" }).then(function(o) { var l = WebAssembly.instantiateStreaming(o, e); return l.then(n, function(g) { return U("wasm streaming compile failed: " + g), U("falling back to ArrayBuffer instantiation"), a(n); }); }) : a(n); } if (i.instantiateWasm) try { var u = i.instantiateWasm(e, t); return u; } catch (o) { return U("Module.instantiateWasm callback failed with error: " + o), !1; } return s().catch(A), {}; } function je(e) { for (; e.length > 0; ) e.shift()(i); } function ne(e) { ne.shown || (ne.shown = {}), ne.shown[e] || (ne.shown[e] = 1, U(e)); } function or(e, t) { m(e.length >= 0, "writeArrayToMemory array must have a length (should be an array or typed array)"), G.set(e, t); } function sr(e) { return rt(e + 24) + 24; } function lr(e) { this.excPtr = e, this.ptr = e - 24, this.set_type = function(t) { S[this.ptr + 4 >> 2] = t; }, this.get_type = function() { return S[this.ptr + 4 >> 2]; }, this.set_destructor = function(t) { S[this.ptr + 8 >> 2] = t; }, this.get_destructor = function() { return S[this.ptr + 8 >> 2]; }, this.set_refcount = function(t) { C[this.ptr >> 2] = t; }, this.set_caught = function(t) { t = t ? 1 : 0, G[this.ptr + 12 >> 0] = t; }, this.get_caught = function() { return G[this.ptr + 12 >> 0] != 0; }, this.set_rethrown = function(t) { t = t ? 1 : 0, G[this.ptr + 13 >> 0] = t; }, this.get_rethrown = function() { return G[this.ptr + 13 >> 0] != 0; }, this.init = function(t, r) { this.set_adjusted_ptr(0), this.set_type(t), this.set_destructor(r), this.set_refcount(0), this.set_caught(!1), this.set_rethrown(!1); }, this.add_ref = function() { var t = C[this.ptr >> 2]; C[this.ptr >> 2] = t + 1; }, this.release_ref = function() { var t = C[this.ptr >> 2]; return C[this.ptr >> 2] = t - 1, m(t > 0), t === 1; }, this.set_adjusted_ptr = function(t) { S[this.ptr + 16 >> 2] = t; }, this.get_adjusted_ptr = function() { return S[this.ptr + 16 >> 2]; }, this.get_exception_ptr = function() { var t = Un(this.get_type()); if (t) return S[this.excPtr >> 2]; var r = this.get_adjusted_ptr(); return r !== 0 ? r : this.excPtr; }; } function ur(e, t, r) { var n = new lr(e); throw n.init(t, r), e + " - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch."; } function cr(e, t, r, n, a) { } function ze(e) { switch (e) { case 1: return 0; case 2: return 1; case 4: return 2; case 8: return 3; default: throw new TypeError("Unknown type size: " + e); } } function fr() { for (var e = new Array(256), t = 0; t < 256; ++t) e[t] = String.fromCharCode(t); _t = e; } var _t = void 0; function Y(e) { for (var t = "", r = e; N[r]; ) t += _t[N[r++]]; return t; } var ue = {}, ce = {}, Ae = {}, dr = 48, pr = 57; function Ye(e) { if (e === void 0) return "_unknown"; e = e.replace(/[^a-zA-Z0-9_]/g, "$"); var t = e.charCodeAt(0); return t >= dr && t <= pr ? "_" + e : e; } function Ve(e, t) { return e = Ye(e), new Function("body", "return function " + e + `() { "use strict"; return body.apply(this, arguments); }; `)(t); } function Be(e, t) { var r = Ve(t, function(n) { this.name = t, this.message = n; var a = new Error(n).stack; a !== void 0 && (this.stack = this.toString() + ` ` + a.replace(/^Error(:[^\n]*)?\n/, "")); }); return r.prototype = Object.create(e.prototype), r.prototype.constructor = r, r.prototype.toString = function() { return this.message === void 0 ? this.name : this.name + ": " + this.message; }, r; } var fe = void 0; function T(e) { throw new fe(e); } var vt = void 0; function Ie(e) { throw new vt(e); } function _e(e, t, r) { e.forEach(function(o) { Ae[o] = t; }); function n(o) { var l = r(o); l.length !== e.length && Ie("Mismatched type converter count"); for (var g = 0; g < e.length; ++g) q(e[g], l[g]); } var a = new Array(t.length), s = [], u = 0; t.forEach((o, l) => { ce.hasOwnProperty(o) ? a[l] = ce[o] : (s.push(o), ue.hasOwnProperty(o) || (ue[o] = []), ue[o].push(() => { a[l] = ce[o], ++u, u === s.length && n(a); })); }), s.length === 0 && n(a); } function q(e, t, r = {}) { if (!("argPackAdvance" in t)) throw new TypeError("registerType registeredInstance requires argPackAdvance"); var n = t.name; if (e || T('type "' + n + '" must have a positive integer typeid pointer'), ce.hasOwnProperty(e)) { if (r.ignoreDuplicateRegistrations) return; T("Cannot register type '" + n + "' twice"); } if (ce[e] = t, delete Ae[e], ue.hasOwnProperty(e)) { var a = ue[e]; delete ue[e], a.forEach((s) => s()); } } function gr(e, t, r, n, a) { var s = ze(r); t = Y(t), q(e, { name: t, fromWireType: function(u) { return !!u; }, toWireType: function(u, o) { return o ? n : a; }, argPackAdvance: 8, readValueFromPointer: function(u) { var o; if (r === 1) o = G; else if (r === 2) o = le; else if (r === 4) o = C; else throw new TypeError("Unknown boolean type size: " + t); return this.fromWireType(o[u >> s]); }, destructorFunction: null }); } function hr(e) { if (!(this instanceof Z) || !(e instanceof Z)) return !1; for (var t = this.$$.ptrType.registeredClass, r = this.$$.ptr, n = e.$$.ptrType.registeredClass, a = e.$$.ptr; t.baseClass; ) r = t.upcast(r), t = t.baseClass; for (; n.baseClass; ) a = n.upcast(a), n = n.baseClass; return t === n && r === a; } function mr(e) { return { count: e.count, deleteScheduled: e.deleteScheduled, preservePointerOnDelete: e.preservePointerOnDelete, ptr: e.ptr, ptrType: e.ptrType, smartPtr: e.smartPtr, smartPtrType: e.smartPtrType }; } function Ge(e) { function t(r) { return r.$$.ptrType.registeredClass.name; } T(t(e) + " instance already deleted"); } var Je = !1; function bt(e) { } function yr(e) { e.smartPtr ? e.smartPtrType.rawDestructor(e.smartPtr) : e.ptrType.registeredClass.rawDestructor(e.ptr); } function wt(e) { e.count.value -= 1; var t = e.count.value === 0; t && yr(e); } function Tt(e, t, r) { if (t === r) return e; if (r.baseClass === void 0) return null; var n = Tt(e, t, r.baseClass); return n === null ? null : r.downcast(n); } var St = {}; function _r() { return Object.keys(we).length; } function vr() { var e = []; for (var t in we) we.hasOwnProperty(t) && e.push(we[t]); return e; } var ve = []; function Ke() { for (; ve.length; ) { var e = ve.pop(); e.$$.deleteScheduled = !1, e.delete(); } } var be = void 0; function br(e) { be = e, ve.length && be && be(Ke); } function wr() { i.getInheritedInstanceCount = _r, i.getLiveInheritedInstances = vr, i.flushPendingDeletes = Ke, i.setDelayFunction = br; } var we = {}; function Tr(e, t) { for (t === void 0 && T("ptr should not be undefined"); e.baseClass; ) t = e.upcast(t), e = e.baseClass; return t; } function Sr(e, t) { return t = Tr(e, t), we[t]; } function Me(e, t) { (!t.ptrType || !t.ptr) && Ie("makeClassHandle requires ptr and ptrType"); var r = !!t.smartPtrType, n = !!t.smartPtr; return r !== n && Ie("Both smartPtrType and smartPtr must be specified"), t.count = { value: 1 }, Te(Object.create(e, { $$: { value: t } })); } function Ct(e) { var t = this.getPointee(e); if (!t) return this.destructor(e), null; var r = Sr(this.registeredClass, t); if (r !== void 0) { if (r.$$.count.value === 0) return r.$$.ptr = t, r.$$.smartPtr = e, r.clone(); var n = r.clone(); return this.destructor(e), n; } function a() { return this.isSmartPointer ? Me(this.registeredClass.instancePrototype, { ptrType: this.pointeeType, ptr: t, smartPtrType: this, smartPtr: e }) : Me(this.registeredClass.instancePrototype, { ptrType: this, ptr: e }); } var s = this.registeredClass.getActualType(t), u = St[s]; if (!u) return a.call(this); var o; this.isConst ? o = u.constPointerType : o = u.pointerType; var l = Tt(t, this.registeredClass, o.registeredClass); return l === null ? a.call(this) : this.isSmartPointer ? Me(o.registeredClass.instancePrototype, { ptrType: o, ptr: l, smartPtrType: this, smartPtr: e }) : Me(o.registeredClass.instancePrototype, { ptrType: o, ptr: l }); } function Te(e) { return typeof FinalizationRegistry > "u" ? (Te = (t) => t, e) : (Je = new FinalizationRegistry((t) => { console.warn(t.leakWarning.stack.replace(/^Error: /, "")), wt(t.$$); }), Te = (t) => { var r = t.$$, n = !!r.smartPtr; if (n) { var a = { $$: r }, s = r.ptrType.registeredClass; a.leakWarning = new Error("Embind found a leaked C++ instance " + s.name + " <0x" + r.ptr.toString(16) + `>. We'll free it automatically in this case, but this functionality is not reliable across various environments. Make sure to invoke .delete() manually once you're done with the instance instead. Originally allocated`), "captureStackTrace" in Error && Error.captureStackTrace(a.leakWarning, Ct), Je.register(t, a, t); } return t; }, bt = (t) => Je.unregister(t), Te(e)); } function Cr() { if (this.$$.ptr || Ge(this), this.$$.preservePointerOnDelete) return this.$$.count.value += 1, this; var e = Te(Object.create(Object.getPrototypeOf(this), { $$: { value: mr(this.$$) } })); return e.$$.count.value += 1, e.$$.deleteScheduled = !1, e; } function Er() { this.$$.ptr || Ge(this), this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && T("Object already scheduled for deletion"), bt(this), wt(this.$$), this.$$.preservePointerOnDelete || (this.$$.smartPtr = void 0, this.$$.ptr = void 0); } function Pr() { return !this.$$.ptr; } function Fr() { return this.$$.ptr || Ge(this), this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && T("Object already scheduled for deletion"), ve.push(this), ve.length === 1 && be && be(Ke), this.$$.deleteScheduled = !0, this; } function Ar() { Z.prototype.isAliasOf = hr, Z.prototype.clone = Cr, Z.prototype.delete = Er, Z.prototype.isDeleted = Pr, Z.prototype.deleteLater = Fr; } function Z() { } function Et(e, t, r) { if (e[t].overloadTable === void 0) { var n = e[t]; e[t] = function() { return e[t].overloadTable.hasOwnProperty(arguments.length) || T("Function '" + r + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + e[t].overloadTable + ")!"), e[t].overloadTable[arguments.length].apply(this, arguments); }, e[t].overloadTable = [], e[t].overloadTable[n.argCount] = n; } } function Ir(e, t, r) { i.hasOwnProperty(e) ? ((r === void 0 || i[e].overloadTable !== void 0 && i[e].overloadTable[r] !== void 0) && T("Cannot register public name '" + e + "' twice"), Et(i, e, e), i.hasOwnProperty(r) && T("Cannot register multiple overloads of a function with the same number of arguments (" + r + ")!"), i[e].overloadTable[r] = t) : (i[e] = t, r !== void 0 && (i[e].numArguments = r)); } function Mr(e, t, r, n, a, s, u, o) { this.name = e, this.constructor = t, this.instancePrototype = r, this.rawDestructor = n, this.baseClass = a, this.getActualType = s, this.upcast = u, this.downcast = o, this.pureVirtualFunctions = []; } function qe(e, t, r) { for (; t !== r; ) t.upcast || T("Expected null or instance of " + r.name + ", got an instance of " + t.name), e = t.upcast(e), t = t.baseClass; return e; } function Or(e, t) { if (t === null) return this.isReference && T("null is not a valid " + this.name), 0; t.$$ || T('Cannot pass "' + pe(t) + '" as a ' + this.name), t.$$.ptr || T("Cannot pass deleted object as a pointer of type " + this.name); var r = t.$$.ptrType.registeredClass, n = qe(t.$$.ptr, r, this.registeredClass); return n; } function Rr(e, t) { var r; if (t === null) return this.isReference && T("null is not a valid " + this.name), this.isSmartPointer ? (r = this.rawConstructor(), e !== null && e.push(this.rawDestructor, r), r) : 0; t.$$ || T('Cannot pass "' + pe(t) + '" as a ' + this.name), t.$$.ptr || T("Cannot pass deleted object as a pointer of type " + this.name), !this.isConst && t.$$.ptrType.isConst && T("Cannot convert argument of type " + (t.$$.smartPtrType ? t.$$.smartPtrType.name : t.$$.ptrType.name) + " to parameter type " + this.name); var n = t.$$.ptrType.registeredClass; if (r = qe(t.$$.ptr, n, this.registeredClass), this.isSmartPointer) switch (t.$$.smartPtr === void 0 && T("Passing raw pointer to smart pointer is illegal"), this.sharingPolicy) { case 0: t.$$.smartPtrType === this ? r = t.$$.smartPtr : T("Cannot convert argument of type " + (t.$$.smartPtrType ? t.$$.smartPtrType.name : t.$$.ptrType.name) + " to parameter type " + this.name); break; case 1: r = t.$$.smartPtr; break; case 2: if (t.$$.smartPtrType === this) r = t.$$.smartPtr; else { var a = t.clone(); r = this.rawShare(r, et.toHandle(function() { a.delete(); })), e !== null && e.push(this.rawDestructor, r); } break; default: T("Unsupporting sharing policy"); } return r; } function kr(e, t) { if (t === null) return this.isReference && T("null is not a valid " + this.name), 0; t.$$ || T('Cannot pass "' + pe(t) + '" as a ' + this.name), t.$$.ptr || T("Cannot pass deleted object as a pointer of type " + this.name), t.$$.ptrType.isConst && T("Cannot convert argument of type " + t.$$.ptrType.name + " to parameter type " + this.name); var r = t.$$.ptrType.registeredClass, n = qe(t.$$.ptr, r, this.registeredClass); return n; } function Oe(e) { return this.fromWireType(C[e >> 2]); } function Dr(e) { return this.rawGetPointee && (e = this.rawGetPointee(e)), e; } function Ur(e) { this.rawDestructor && this.rawDestructor(e); } function Lr(e) { e !== null && e.delete(); } function $r() { X.prototype.getPointee = Dr, X.prototype.destructor = Ur, X.prototype.argPackAdvance = 8, X.prototype.readValueFromPointer = Oe, X.prototype.deleteObject = Lr, X.prototype.fromWireType = Ct; } function X(e, t, r, n, a, s, u, o, l, g, w) { this.name = e, this.registeredClass = t, this.isReference = r, this.isConst = n, this.isSmartPointer = a, this.pointeeType = s, this.sharingPolicy = u, this.rawGetPointee = o, this.rawConstructor = l, this.rawShare = g, this.rawDestructor = w, !a && t.baseClass === void 0 ? n ? (this.toWireType = Or, this.destructorFunction = null) : (this.toWireType = kr, this.destructorFunction = null) : this.toWireType = Rr; } function Nr(e, t, r) { i.hasOwnProperty(e) || Ie("Replacing nonexistant public symbol"), i[e].overloadTable !== void 0 && r !== void 0 ? i[e].overloadTable[r] = t : (i[e] = t, i[e].argCount = r); } function Wr(e, t, r) { m("dynCall_" + e in i, "bad function pointer type - no table for sig '" + e + "'"), r && r.length ? m(r.length === e.substring(1).replace(/j/g, "--").length) : m(e.length == 1); var n = i["dynCall_" + e]; return r && r.length ? n.apply(null, [t].concat(r)) : n.call(null, t); } var Re = []; function Xe(e) { var t = Re[e]; return t || (e >= Re.length && (Re.length = e + 1), Re[e] = t = Fe.get(e)), m(Fe.get(e) == t, "JavaScript-side Wasm function table mirror is out of date!"), t; } function xr(e, t, r) { if (e.includes("j")) return Wr(e, t, r); m(Xe(t), "missing table entry in dynCall: " + t); var n = Xe(t).apply(null, r); return n; } function Hr(e, t) { m(e.includes("j") || e.includes("p"), "getDynCaller should only be called with i64 sigs"); var r = []; return function() { return r.length = 0, Object.assign(r, arguments), xr(e, t, r); }; } function de(e, t) { e = Y(e); function r() { return e.includes("j") ? Hr(e, t) : Xe(t); } var n = r(); return typeof n != "function" && T("unknown function pointer with signature " + e + ": " + t), n; } var Pt = void 0; function jr(e) { var t = Dn(e), r = Y(t); return Q(t), r; } function Ze(e, t) { var r = [], n = {}; function a(s) { if (!n[s] && !ce[s]) { if (Ae[s]) { Ae[s].forEach(a); return; } r.push(s), n[s] = !0; } } throw t.forEach(a), new Pt(e + ": " + r.map(jr).join([", "])); } function zr(e, t, r, n, a, s, u, o, l, g, w, v, _) { w = Y(w), s = de(a, s), o && (o = de(u, o)), g && (g = de(l, g)), _ = de(v, _); var F = Ye(w); Ir(F, function() { Ze("Cannot construct " + w + " due to unbound types", [n]); }), _e([e, t, r], n ? [n] : [], function(R) { R = R[0]; var L, j; n ? (L = R.registeredClass, j = L.instancePrototype) : j = Z.prototype; var K = Ve(F, function() { if (Object.getPrototypeOf(this) !== c) throw new fe("Use 'new' to construct " + w); if (y.constructor_body === void 0) throw new fe(w + " has no accessible constructor"); var Ue = y.constructor_body[arguments.length]; if (Ue === void 0) throw new fe("Tried to invoke ctor of " + w + " with invalid number of parameters (" + arguments.length + ") - expected (" + Object.keys(y.constructor_body).toString() + ") parameters instead!"); return Ue.apply(this, arguments); }), c = Object.create(j, { constructor: { value: K } }); K.prototype = c; var y = new Mr(w, K, c, _, L, s, o, g), x = new X(w, y, !0, !1, !1), k = new X(w + "*", y, !1, !1, !1), ie = new X(w + " const*", y, !1, !0, !1); return St[e] = { pointerType: k, constPointerType: ie }, Nr(F, K), [x, k, ie]; }); } function Ft(e, t) { for (var r = [], n = 0; n < e; n++) r.push(S[t + n * 4 >> 2]); return r; } function Yr(e) { for (; e.length; ) { var t = e.pop(), r = e.pop(); r(t); } } function Vr(e, t) { if (!(e instanceof Function)) throw new TypeError("new_ called with constructor type " + typeof e + " which is not a function"); var r = Ve(e.name || "unknownFunctionName", function() { }); r.prototype = e.prototype; var n = new r(), a = e.apply(n, t); return a instanceof Object ? a : n; } function At(e, t, r, n, a) { var s = t.length; s < 2 && T("argTypes array size mismatch! Must at least get return value and 'this' types!"); for (var u = t[1] !== null && r !== null, o = !1, l = 1; l < t.length; ++l) if (t[l] !== null && t[l].destructorFunction === void 0) { o = !0; break; } for (var g = t[0].name !== "void", w = "", v = "", l = 0; l < s - 2; ++l) w += (l !== 0 ? ", " : "") + "arg" + l, v += (l !== 0 ? ", " : "") + "arg" + l + "Wired"; var _ = "return function " + Ye(e) + "(" + w + `) { if (arguments.length !== ` + (s - 2) + `) { throwBindingError('function ` + e + " called with ' + arguments.length + ' arguments, expected " + (s - 2) + ` args!'); } `; o && (_ += `var destructors = []; `); var F = o ? "destructors" : "null", R = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"], L = [T, n, a, Yr, t[0], t[1]]; u && (_ += "var thisWired = classParam.toWireType(" + F + `, this); `); for (var l = 0; l < s - 2; ++l) _ += "var arg" + l + "Wired = argType" + l + ".toWireType(" + F + ", arg" + l + "); // " + t[l + 2].name + ` `, R.push("argType" + l), L.push(t[l + 2]); if (u && (v = "thisWired" + (v.length > 0 ? ", " : "") + v), _ += (g ? "var rv = " : "") + "invoker(fn" + (v.length > 0 ? ", " : "") + v + `); `, o) _ += `runDestructors(destructors); `; else for (var l = u ? 1 : 2; l < t.length; ++l) { var j = l === 1 ? "thisWired" : "arg" + (l - 2) + "Wired"; t[l].destructorFunction !== null && (_ += j + "_dtor(" + j + "); // " + t[l].name + ` `, R.push(j + "_dtor"), L.push(t[l].destructorFunction)); } g && (_ += `var ret = retType.fromWireType(rv); return ret; `), _ += `} `, R.push(_); var K = Vr(Function, R).apply(null, L); return K; } function Br(e, t, r, n, a, s) { m(t > 0); var u = Ft(t, r); a = de(n, a), _e([], [e], function(o) { o = o[0]; var l = "constructor " + o.name; if (o.registeredClass.constructor_body === void 0 && (o.registeredClass.constructor_body = []), o.registeredClass.constructor_body[t - 1] !== void 0) throw new fe("Cannot register multiple constructors with identical number of parameters (" + (t - 1) + ") for class '" + o.name + "'! Overload resolution is currently only performed using the parameter count, not actual type info!"); return o.registeredClass.constructor_body[t - 1] = () => { Ze("Cannot construct " + o.name + " due to unbound types", u); }, _e([], u, function(g) { return g.splice(1, 0, null), o.registeredClass.constructor_body[t - 1] = At(l, g, null, a, s), []; }), []; }); } function Gr(e, t, r, n, a, s, u, o) { var l = Ft(r, n); t = Y(t), s = de(a, s), _e([], [e], function(g) { g = g[0]; var w = g.name + "." + t; t.startsWith("@@") && (t = Symbol[t.substring(2)]), o && g.registeredClass.pureVirtualFunctions.push(t); function v() { Ze("Cannot call " + w + " due to unbound types", l); } var _ = g.registeredClass.instancePrototype, F = _[t]; return F === void 0 || F.overloadTable === void 0 && F.className !== g.name && F.argCount === r - 2 ? (v.argCount = r - 2, v.className = g.name, _[t] = v) : (Et(_, t, w), _[t].overloadTable[r - 2] = v), _e([], l, function(R) { var L = At(w, R, g, s, u); return _[t].overloadTable === void 0 ? (L.argCount = r - 2, _[t] = L) : _[t].overloadTable[r - 2] = L, []; }), []; }); } var Qe = [], J = [{}, { value: void 0 }, { value: null }, { value: !0 }, { value: !1 }]; function Jr(e) { e > 4 && --J[e].refcount === 0 && (J[e] = void 0, Qe.push(e)); } function Kr() { for (var e = 0, t = 5; t < J.length; ++t) J[t] !== void 0 && ++e; return e; } function qr() { for (var e = 5; e < J.length; ++e) if (J[e] !== void 0) return J[e]; return null; } function Xr() { i.count_emval_handles = Kr, i.get_first_emval = qr; } var et = { toValue: (e) => (e || T("Cannot use deleted val. handle = " + e), J[e].value), toHandle: (e) => { switch (e) { case void 0: return 1; case null: return 2; case !0: return 3; case !1: return 4; default: { var t = Qe.length ? Qe.pop() : J.length; return J[t] = { refcount: 1, value: e }, t; } } } }; function Zr(e, t) { t = Y(t), q(e, { name: t, fromWireType: function(r) { var n = et.toValue(r); return Jr(r), n; }, toWireType: function(r, n) { return et.toHandle(n); }, argPackAdvance: 8, readValueFromPointer: Oe, destructorFunction: null }); } function pe(e) { if (e === null) return "null"; var t = typeof e; return t === "object" || t === "array" || t === "function" ? e.toString() : "" + e; } function Qr(e, t) { switch (t) { case 2: return function(r) { return this.fromWireType(ct[r >> 2]); }; case 3: return function(r) { return this.fromWireType(ft[r >> 3]); }; default: throw new TypeError("Unknown float type: " + e); } } function en(e, t, r) { var n = ze(r); t = Y(t), q(e, { name: t, fromWireType: function(a) { return a; }, toWireType: function(a, s) { if (typeof s != "number" && typeof s != "boolean") throw new TypeError('Cannot convert "' + pe(s) + '" to ' + this.name); return s; }, argPackAdvance: 8, readValueFromPointer: Qr(t, n), destructorFunction: null }); } function tn(e, t, r) { switch (t) { case 0: return r ? function(a) { return G[a]; } : function(a) { return N[a]; }; case 1: return r ? function(a) { return le[a >> 1]; } : function(a) { return Pe[a >> 1]; }; case 2: return r ? function(a) { return C[a >> 2]; } : function(a) { return S[a >> 2]; }; default: throw new TypeError("Unknown integer type: " + e); } } function rn(e, t, r, n, a) { t = Y(t), a === -1 && (a = 4294967295); var s = ze(r), u = (v) => v; if (n === 0) { var o = 32 - 8 * r; u = (v) => v << o >>> o; } var l = t.includes("unsigned"), g = (v, _) => { if (typeof v != "number" && typeof v != "boolean") throw new TypeError('Cannot convert "' + pe(v) + '" to ' + _); if (v < n || v > a) throw new TypeError('Passing a number "' + pe(v) + '" from JS side to C/C++ side to an argument of type "' + t + '", which is outside the valid range [' + n + ", " + a + "]!"); }, w; l ? w = function(v, _) { return g(_, this.name), _ >>> 0; } : w = function(v, _) { return g(_, this.name), _; }, q(e, { name: t, fromWireType: u, toWireType: w, argPackAdvance: 8, readValueFromPointer: tn(t, s, n !== 0), destructorFunction: null }); } function nn(e, t, r) { var n = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uin