(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['loaders'] = factory(); else root['loaders'] = factory();})(globalThis, function () { "use strict"; var __exports__ = (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // external-global-plugin:@loaders.gl/core var require_core = __commonJS({ "external-global-plugin:@loaders.gl/core"(exports, module) { module.exports = globalThis.loaders; } }); // bundle.ts var bundle_exports = {}; __export(bundle_exports, { CRC32CHash: () => CRC32CHash, CRC32Hash: () => CRC32Hash, CryptoHash: () => CryptoHash, CryptoJSWorker: () => CryptoJSWorker, CryptoWorker: () => CryptoWorker, Hash: () => Hash, MD5Hash: () => MD5Hash, NodeHash: () => NodeHash, SHA256Hash: () => SHA256Hash, asciiToBase64: () => asciiToBase64, base64ToAscii: () => base64ToAscii, encodeBase64: () => encodeBase64, encodeHex: () => encodeHex, encodeNumber: () => encodeNumber }); __reExport(bundle_exports, __toESM(require_core(), 1)); // ../loader-utils/src/lib/module-utils/js-module-utils.ts function registerJSModules(modules) { globalThis.loaders ||= {}; globalThis.loaders.modules ||= {}; Object.assign(globalThis.loaders.modules, modules); } function getJSModule(name, caller) { const module = globalThis.loaders?.modules?.[name]; if (!module) { throw new Error(`${caller}: ${name} library not installed`); } return module; } // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts function concatenateArrayBuffers(...sources) { return concatenateArrayBuffersFromArray(sources); } function concatenateArrayBuffersFromArray(sources) { const sourceArrays = sources.map( (source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2 ); const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0); const result = new Uint8Array(byteLength); let offset = 0; for (const sourceArray of sourceArrays) { result.set(sourceArray, offset); offset += sourceArray.byteLength; } return result.buffer; } // ../loader-utils/src/lib/iterators/async-iteration.ts async function concatenateArrayBuffersAsync(asyncIterator) { const arrayBuffers = []; for await (const chunk of asyncIterator) { arrayBuffers.push(chunk); } return concatenateArrayBuffers(...arrayBuffers); } // src/lib/hash.ts var Hash = class { constructor(options = {}) { this.hashBatches = this.hashBatches.bind(this); } async preload() { return; } async *hashBatches(asyncIterator, encoding = "base64") { const arrayBuffers = []; for await (const arrayBuffer of asyncIterator) { arrayBuffers.push(arrayBuffer); yield arrayBuffer; } const output = await this.concatenate(arrayBuffers); const hash = await this.hash(output, encoding); this.options.crypto?.onEnd?.({ hash }); } // HELPERS async concatenate(asyncIterator) { return await concatenateArrayBuffersAsync(asyncIterator); } }; // src/lib/algorithms/crc32.ts var CRC32 = class { crc; constructor() { this.crc = ~0; } update(arrayBuffer) { const CRC32_TABLE = getCRC32Table(); const byteArray = new Uint8Array(arrayBuffer); for (let i = 0; i < byteArray.byteLength; i++) { this.crc = this.crc >>> 8 ^ CRC32_TABLE[(this.crc ^ byteArray[i]) & 255]; } return this; } finalize() { this.crc = (this.crc ^ -1) >>> 0; return this.crc; } }; var CRC32TAB = Uint32Array.of( 0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918e3, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117 ); function getCRC32Table() { return CRC32TAB; } // src/lib/utils/base64-utils.ts function asciiToBase64(string) { string = `${string}`; for (let i = 0; i < string.length; i++) { if (string.charCodeAt(i) > 255) { return null; } } let out = ""; for (let i = 0; i < string.length; i += 3) { const groupsOfSix = [void 0, void 0, void 0, void 0]; groupsOfSix[0] = string.charCodeAt(i) >> 2; groupsOfSix[1] = (string.charCodeAt(i) & 3) << 4; if (string.length > i + 1) { groupsOfSix[1] |= string.charCodeAt(i + 1) >> 4; groupsOfSix[2] = (string.charCodeAt(i + 1) & 15) << 2; } if (string.length > i + 2) { groupsOfSix[2] |= string.charCodeAt(i + 2) >> 6; groupsOfSix[3] = string.charCodeAt(i + 2) & 63; } for (let j = 0; j < groupsOfSix.length; j++) { if (typeof groupsOfSix[j] === "undefined") { out += "="; } else { out += btoaLookup(groupsOfSix[j]); } } } return out; } function base64ToAscii(data) { data = `${data}`; data = data.replace(/[ \t\n\f\r]/g, ""); if (data.length % 4 === 0) { data = data.replace(/[=]=?$/, ""); } if (data.length % 4 === 1 || /[^+/0-9A-Za-z]/.test(data)) { return ""; } let output = ""; let buffer = 0; let accumulatedBits = 0; for (let i = 0; i < data.length; i++) { buffer <<= 6; buffer |= atobLookup(data[i]); accumulatedBits += 6; if (accumulatedBits === 24) { output += String.fromCharCode((buffer & 16711680) >> 16); output += String.fromCharCode((buffer & 65280) >> 8); output += String.fromCharCode(buffer & 255); buffer = accumulatedBits = 0; } } if (accumulatedBits === 12) { buffer >>= 4; output += String.fromCharCode(buffer); } else if (accumulatedBits === 18) { buffer >>= 2; output += String.fromCharCode((buffer & 65280) >> 8); output += String.fromCharCode(buffer & 255); } return output; } var keystr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function atobLookup(chr) { const index = keystr.indexOf(chr); return index < 0 ? void 0 : index; } function btoaLookup(idx) { if (idx < 26) { return String.fromCharCode(idx + "A".charCodeAt(0)); } if (idx < 52) { return String.fromCharCode(idx - 26 + "a".charCodeAt(0)); } if (idx < 62) { return String.fromCharCode(idx - 52 + "0".charCodeAt(0)); } if (idx === 62) { return "+"; } if (idx === 63) { return "/"; } return void 0; } // src/lib/utils/digest-utils.ts function encodeNumber(number, encoding) { switch (encoding) { case "hex": return convertNumberToHex(number); case "base64": return convertHexToBase64(convertNumberToHex(number)); default: throw new Error(encoding); } } function encodeHex(hex, encoding) { switch (encoding) { case "hex": return hex; case "base64": return convertHexToBase64(hex); default: throw new Error(encoding); } } function encodeBase64(base64, encoding) { switch (encoding) { case "hex": return convertBase64ToHex(base64); case "base64": return base64; default: throw new Error(encoding); } } function convertHexToBase64(hexstring) { if (hexstring.length % 2 !== 0) { hexstring = `0${hexstring}`; } const matches = hexstring.match(/\w{2}/g) || []; const string = matches.map((a) => String.fromCharCode(parseInt(a, 16))).join(""); return asciiToBase64(string) || ""; } function convertBase64ToHex(base64String) { return [...base64ToAscii(base64String)].map((c) => c.charCodeAt(0).toString(16).padStart(2, "0")).join(""); } function convertNumberToHex(cipher) { const hexString = cipher.toString(16); return hexString === "0" ? `0${hexString}` : hexString; } // src/lib/crc32-hash.ts var CRC32Hash = class extends Hash { name = "crc32"; options; constructor(options = {}) { super(); this.options = { crypto: {}, ...options }; this.hashBatches = this.hashBatches.bind(this); } /** * Atomic hash calculation * @returns base64 encoded hash */ async hash(input, encoding) { return this.hashSync(input, encoding); } hashSync(input, encoding) { const hash = new CRC32(); hash.update(input); const digest = hash.finalize(); return encodeNumber(digest, encoding); } async *hashBatches(asyncIterator, encoding = "base64") { const hash = new CRC32(); for await (const chunk of asyncIterator) { hash.update(chunk); yield chunk; } const digest = hash.finalize(); this.options.crypto?.onEnd?.({ hash: encodeNumber(digest, encoding) }); } }; // src/lib/algorithms/crc32c.ts var CRC32C = class { options; crc; constructor(options = {}) { this.options = options; this.crc = ~0; } update(arrayBuffer) { const byteArray = new Uint8Array(arrayBuffer); const CRC32_TABLE = getCRC32Table2(); for (let i = 0; i < byteArray.length; i++) { this.crc = CRC32_TABLE[(this.crc ^ byteArray[i]) & 255] ^ this.crc >>> 8; } return this; } finalize() { this.crc = (this.crc ^ -1) >>> 0; return this.crc; } }; var CRC32C_TABLE = Int32Array.of( 0, 4067132163, 3778769143, 324072436, 3348797215, 904991772, 648144872, 3570033899, 2329499855, 2024987596, 1809983544, 2575936315, 1296289744, 3207089363, 2893594407, 1578318884, 274646895, 3795141740, 4049975192, 51262619, 3619967088, 632279923, 922689671, 3298075524, 2592579488, 1760304291, 2075979607, 2312596564, 1562183871, 2943781820, 3156637768, 1313733451, 549293790, 3537243613, 3246849577, 871202090, 3878099393, 357341890, 102525238, 4101499445, 2858735121, 1477399826, 1264559846, 3107202533, 1845379342, 2677391885, 2361733625, 2125378298, 820201905, 3263744690, 3520608582, 598981189, 4151959214, 85089709, 373468761, 3827903834, 3124367742, 1213305469, 1526817161, 2842354314, 2107672161, 2412447074, 2627466902, 1861252501, 1098587580, 3004210879, 2688576843, 1378610760, 2262928035, 1955203488, 1742404180, 2511436119, 3416409459, 969524848, 714683780, 3639785095, 205050476, 4266873199, 3976438427, 526918040, 1361435347, 2739821008, 2954799652, 1114974503, 2529119692, 1691668175, 2005155131, 2247081528, 3690758684, 697762079, 986182379, 3366744552, 476452099, 3993867776, 4250756596, 255256311, 1640403810, 2477592673, 2164122517, 1922457750, 2791048317, 1412925310, 1197962378, 3037525897, 3944729517, 427051182, 170179418, 4165941337, 746937522, 3740196785, 3451792453, 1070968646, 1905808397, 2213795598, 2426610938, 1657317369, 3053634322, 1147748369, 1463399397, 2773627110, 4215344322, 153784257, 444234805, 3893493558, 1021025245, 3467647198, 3722505002, 797665321, 2197175160, 1889384571, 1674398607, 2443626636, 1164749927, 3070701412, 2757221520, 1446797203, 137323447, 4198817972, 3910406976, 461344835, 3484808360, 1037989803, 781091935, 3705997148, 2460548119, 1623424788, 1939049696, 2180517859, 1429367560, 2807687179, 3020495871, 1180866812, 410100952, 3927582683, 4182430767, 186734380, 3756733383, 763408580, 1053836080, 3434856499, 2722870694, 1344288421, 1131464017, 2971354706, 1708204729, 2545590714, 2229949006, 1988219213, 680717673, 3673779818, 3383336350, 1002577565, 4010310262, 493091189, 238226049, 4233660802, 2987750089, 1082061258, 1395524158, 2705686845, 1972364758, 2279892693, 2494862625, 1725896226, 952904198, 3399985413, 3656866545, 731699698, 4283874585, 222117402, 510512622, 3959836397, 3280807620, 837199303, 582374963, 3504198960, 68661723, 4135334616, 3844915500, 390545967, 1230274059, 3141532936, 2825850620, 1510247935, 2395924756, 2091215383, 1878366691, 2644384480, 3553878443, 565732008, 854102364, 3229815391, 340358836, 3861050807, 4117890627, 119113024, 1493875044, 2875275879, 3090270611, 1247431312, 2660249211, 1828433272, 2141937292, 2378227087, 3811616794, 291187481, 34330861, 4032846830, 615137029, 3603020806, 3314634738, 939183345, 1776939221, 2609017814, 2295496738, 2058945313, 2926798794, 1545135305, 1330124605, 3173225534, 4084100981, 17165430, 307568514, 3762199681, 888469610, 3332340585, 3587147933, 665062302, 2042050490, 2346497209, 2559330125, 1793573966, 3190661285, 1279665062, 1595330642, 2910671697 ); function getCRC32Table2() { return CRC32C_TABLE; } // src/lib/crc32c-hash.ts var CRC32CHash = class extends Hash { name = "crc32c"; options; /** * Atomic hash calculation * @returns base64 encoded hash */ constructor(options = {}) { super(); this.options = { crypto: {}, ...options }; } /** * Atomic hash calculation * @returns base64 encoded hash */ async hash(input, encoding) { return this.hashSync(input, encoding); } hashSync(input, encoding) { const hash = new CRC32C(this.options); hash.update(input); const digest = hash.finalize(); return encodeNumber(digest, encoding); } // runInBatches inherited async *hashBatches(asyncIterator, encoding = "base64") { const hash = new CRC32C(this.options); for await (const chunk of asyncIterator) { hash.update(chunk); yield chunk; } const digest = hash.finalize(); this.options.crypto?.onEnd?.({ hash: encodeNumber(digest, encoding) }); } }; // src/lib/algorithms/md5-wasm.ts var atb = typeof atob === "function" ? atob : typeof Buffer === "function" ? nodeATOB : identity; var wasmB64 = atb( "AGFzbQEAAAABDANgAX8AYAAAYAABfwIeAgdpbXBvcnRzA2xvZwAAB2ltcG9ydHMDbWVtAgABAzIxAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAAAAAAAAAAAAAAAAAAAAAAgICAgIAAAAAAAaYARt/AUGBxpS6Bgt/AUGJ17b+fgt/AUH+uevFeQt/AUH2qMmBAQt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALB7oCJQhvbmVGdWxsQQAYCG9uZUZ1bGxCABkIb25lRnVsbEMAGghvbmVGdWxsRAAbBWxvb3BzAAEEbG9vcAACBXByaW1lAAMFbG9vcEEABAZsb29wQTEABQZsb29wQTIABg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OAA8AEAARABIAEwAUABUAFgAXABgCAAABAW4ZAgAAAQFuGgIAAAEBbhsCAAABAW4cAgAAAQFuHQIAAAEBbh4CAAABAW4fAgAAAQFuIAIAAAEBbiECAAABAW4iAgAAAQFuIwIAAAEBbiQCAAABAW4lAgAAAQFuJgIAAAEBbicCAAABAW4oACkAKgArACwALQEAAC4BAAAvAQAAMAEAADEBAAA=" ); var wasm = WebAssembly && atb !== identity ? str2AB(wasmB64).buffer : false; var crypt = makeCrypt(); var biteSize = 240 * 16 * 16; var bounder = Math.floor(biteSize * 16 * 1.066666667); var upperLimit = 268435456 - 65536; var parmTypeErrStr = "Parameter must be Buffer, ArrayBuffer or Uint8Array"; var tooBigErrStr = "Parameter exceeds max size of 255.9 Mbytes"; if (!wasm) { console.log( "WebAssembly not available or WASM module could not be decoded; md5WASM will fall back to JavaScript" ); } function md5WASM(data) { var mem, memView, importObj, imports, len, buff, thenFun, catchFun, result, endTime; const md5JS = makeMD5JS(), md5WA = makeMD5WA(), returnObj = {}, startTime = new Date().getTime(); returnObj["then"] = function(fun) { thenFun = fun; getThen(); return returnObj; }; returnObj["catch"] = function(fun) { catchFun = fun; return returnObj; }; if (true) { if (data && typeof data === "object") { if (typeof Buffer === "function" && data.constructor === Buffer) { buff = data; } else { if (data.constructor === Uint8Array || data.constructor === ArrayBuffer) { buff = data.constructor === ArrayBuffer ? new Uint8Array(data) : data; } else { getCatch(new TypeError(parmTypeErrStr)); } } } else { getCatch(new TypeError(parmTypeErrStr)); } } if (buff) { len = buff.length; if (wasm && len > bounder) { if (len > upperLimit) { getCatch(new Error(tooBigErrStr)); } else { mem = new WebAssembly.Memory({ initial: len > 32e6 ? len > 64e6 ? len > 128e6 ? 4096 : 2048 : 1024 : 512 }); memView = new Uint32Array(mem.buffer); imports = { mem, log: console.log }; importObj = { imports }; WebAssembly.instantiate(wasm, importObj).then(giterdone); } } else { getThen(md5JS(buff)); } } return returnObj; function giterdone(obj) { getThen(md5WA(buff, obj.instance.exports, memView)); } function getThen(r) { var res = Boolean(r) ? r : result; if (Boolean(r)) { endTime = new Date().getTime(); } if (typeof thenFun === "function") { if (Boolean(res)) { thenFun(res, endTime - startTime); thenFun = catchFun = null; } } else { if (Boolean(r)) { result = r; } } } function getCatch(err) { if (typeof catchFun === "function") { catchFun(err); } } } function makeMD5WA() { var loop, loops; var getA, setA, getB, setB, getC, setC, getD, setD, getX, setX, memView; var md5WA = function(message) { var m00, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12, m13, m14, m15, aa, bb, cc, dd, m, k; var qwerty = new Date().getTime(); var md5Used = 0; var a = 1732584193, b = -271733879, c = -1732584194, d = 271733878, i = 0, l = message.length * 8, len; len = bytesToWordsNewer(message, memView); memView[l >>> 5] |= 128 << l % 32; memView[(l + 64 >>> 9 << 4) + 14] = l; len = (l + 64 >>> 9 << 4) + 15; m = memView; while (i < len) { if (len > i + bounder) { setA(a); setB(b); setC(c); setD(d); loops(biteSize); i = i + biteSize * 16; a = getA(); b = getB(); c = getC(); d = getD(); md5Used++; } else { aa = a; bb = b; cc = c; dd = d; m00 = m[i + 0] >>> 0; m01 = m[i + 1] >>> 0; m02 = m[i + 2] >>> 0; m03 = m[i + 3] >>> 0; m04 = m[i + 4] >>> 0; m05 = m[i + 5] >>> 0; m06 = m[i + 6] >>> 0; m07 = m[i + 7] >>> 0; m08 = m[i + 8] >>> 0; m09 = m[i + 9] >>> 0; m10 = m[i + 10] >>> 0; m11 = m[i + 11] >>> 0; m12 = m[i + 12] >>> 0; m13 = m[i + 13] >>> 0; m14 = m[i + 14] >>> 0; m15 = m[i + 15] >>> 0; a = ____(7, 25, a + (b & c | ~b & d) + m00 - 680876936) + b; d = ____(12, 20, d + (a & b | ~a & c) + m01 - 389564586) + a; c = ____(17, 15, c + (d & a | ~d & b) + m02 + 606105819) + d; b = ____(22, 10, b + (c & d | ~c & a) + m03 - 1044525330) + c; a = ____(7, 25, a + (b & c | ~b & d) + m04 - 176418897) + b; d = ____(12, 20, d + (a & b | ~a & c) + m05 + 1200080426) + a; c = ____(17, 15, c + (d & a | ~d & b) + m06 - 1473231341) + d; b = ____(22, 10, b + (c & d | ~c & a) + m07 - 45705983) + c; a = ____(7, 25, a + (b & c | ~b & d) + m08 + 1770035416) + b; d = ____(12, 20, d + (a & b | ~a & c) + m09 - 1958414417) + a; c = ____(17, 15, c + (d & a | ~d & b) + m10 - 42063) + d; b = ____(22, 10, b + (c & d | ~c & a) + m11 - 1990404162) + c; a = ____(7, 25, a + (b & c | ~b & d) + m12 + 1804603682) + b; d = ____(12, 20, d + (a & b | ~a & c) + m13 - 40341101) + a; c = ____(17, 15, c + (d & a | ~d & b) + m14 - 1502002290) + d; b = ____(22, 10, b + (c & d | ~c & a) + m15 + 1236535329) + c; a = ____(5, 27, a + (b & d | c & ~d) + m01 - 165796510) + b; d = ____(9, 23, d + (a & c | b & ~c) + m06 - 1069501632) + a; c = ____(14, 18, c + (d & b | a & ~b) + m11 + 643717713) + d; b = ____(20, 12, b + (c & a | d & ~a) + m00 - 373897302) + c; a = ____(5, 27, a + (b & d | c & ~d) + m05 - 701558691) + b; d = ____(9, 23, d + (a & c | b & ~c) + m10 + 38016083) + a; c = ____(14, 18, c + (d & b | a & ~b) + m15 - 660478335) + d; b = ____(20, 12, b + (c & a | d & ~a) + m04 - 405537848) + c; a = ____(5, 27, a + (b & d | c & ~d) + m09 + 568446438) + b; d = ____(9, 23, d + (a & c | b & ~c) + m14 - 1019803690) + a; c = ____(14, 18, c + (d & b | a & ~b) + m03 - 187363961) + d; b = ____(20, 12, b + (c & a | d & ~a) + m08 + 1163531501) + c; a = ____(5, 27, a + (b & d | c & ~d) + m13 - 1444681467) + b; d = ____(9, 23, d + (a & c | b & ~c) + m02 - 51403784) + a; c = ____(14, 18, c + (d & b | a & ~b) + m07 + 1735328473) + d; b = ____(20, 12, b + (c & a | d & ~a) + m12 - 1926607734) + c; a = ____(4, 28, a + (b ^ c ^ d) + m05 - 378558) + b; d = ____(11, 21, d + (a ^ b ^ c) + m08 - 2022574463) + a; c = ____(16, 16, c + (d ^ a ^ b) + m11 + 1839030562) + d; b = ____(23, 9, b + (c ^ d ^ a) + m14 - 35309556) + c; a = ____(4, 28, a + (b ^ c ^ d) + m01 - 1530992060) + b; d = ____(11, 21, d + (a ^ b ^ c) + m04 + 1272893353) + a; c = ____(16, 16, c + (d ^ a ^ b) + m07 - 155497632) + d; b = ____(23, 9, b + (c ^ d ^ a) + m10 - 1094730640) + c; a = ____(4, 28, a + (b ^ c ^ d) + m13 + 681279174) + b; d = ____(11, 21, d + (a ^ b ^ c) + m00 - 358537222) + a; c = ____(16, 16, c + (d ^ a ^ b) + m03 - 722521979) + d; b = ____(23, 9, b + (c ^ d ^ a) + m06 + 76029189) + c; a = ____(4, 28, a + (b ^ c ^ d) + m09 - 640364487) + b; d = ____(11, 21, d + (a ^ b ^ c) + m12 - 421815835) + a; c = ____(16, 16, c + (d ^ a ^ b) + m15 + 530742520) + d; b = ____(23, 9, b + (c ^ d ^ a) + m02 - 995338651) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m00 - 198630844) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m07 + 1126891415) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m14 - 1416354905) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m05 - 57434055) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m12 + 1700485571) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m03 - 1894986606) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m10 - 1051523) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m01 - 2054922799) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m08 + 1873313359) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m15 - 30611744) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m06 - 1560198380) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m13 + 1309151649) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m04 - 145523070) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m11 - 1120210379) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m02 + 718787259) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m09 - 343485551) + c; i = i + 16; a = a + aa >>> 0; b = b + bb >>> 0; c = c + cc >>> 0; d = d + dd >>> 0; } } return crypt.endian([a, b, c, d]); function ____(s, t, n) { return n << s | n >>> t; } function bytesToWordsNewer(bytes, words) { var i2 = -1, l2 = Math.floor((bytes.length - 1) / 4), j = 0, b0, b1, b2, b3; while (l2 - 8 > i2++) { j = i2 << 2; words[i2] = bytes[j + 0] | bytes[j + 1] << 8 | bytes[j + 2] << 16 | bytes[j + 3] << 24; } i2--; while (l2 > i2++) { j = i2 << 2; b0 = typeof bytes[j + 0] === "undefined" ? 0 : bytes[j + 0]; b1 = typeof bytes[j + 1] === "undefined" ? 0 : bytes[j + 1]; b2 = typeof bytes[j + 2] === "undefined" ? 0 : bytes[j + 2]; b3 = typeof bytes[j + 3] === "undefined" ? 0 : bytes[j + 3]; words[i2] = b0 | b1 << 8 | b2 << 16 | b3 << 24; } return l2 + 1; } }; return function(message, exports, mView, options) { var digestbytes; loops = exports.loops; loop = exports.loop; getA = exports.getA; getB = exports.getB; getC = exports.getC; getD = exports.getD; getX = exports.getX; setA = exports.setA; setB = exports.setB; setC = exports.setC; setD = exports.setD; setX = exports.setX; memView = mView; digestbytes = crypt.wordsToBytes(md5WA(message)); return options && options.asBytes ? digestbytes : crypt.bytesconvertNumberToHex(digestbytes); }; } function makeMD5JS() { var md5JS = function(message, options) { var m00, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12, m13, m14, m15, aa, bb, cc, dd, m; var qwerty = new Date().getTime(); var a = 1732584193, b = -271733879, c = -1732584194, d = 271733878, l = message.length * 8; m = crypt.bytesToWords(message); for (var j = 0; j < m.length; j++) { m[j] = (m[j] << 8 | m[j] >>> 24) & 16711935 | (m[j] << 24 | m[j] >>> 8) & 4278255360; } m[l >>> 5] |= 128 << l % 32; m[(l + 64 >>> 9 << 4) + 14] = l; for (var i = 0; i < m.length; i += 16) { aa = a; bb = b; cc = c; dd = d; m00 = m[i + 0] >>> 0; m01 = m[i + 1] >>> 0; m02 = m[i + 2] >>> 0; m03 = m[i + 3] >>> 0; m04 = m[i + 4] >>> 0; m05 = m[i + 5] >>> 0; m06 = m[i + 6] >>> 0; m07 = m[i + 7] >>> 0; m08 = m[i + 8] >>> 0; m09 = m[i + 9] >>> 0; m10 = m[i + 10] >>> 0; m11 = m[i + 11] >>> 0; m12 = m[i + 12] >>> 0; m13 = m[i + 13] >>> 0; m14 = m[i + 14] >>> 0; m15 = m[i + 15] >>> 0; a = ____(7, 25, a + (b & c | ~b & d) + m00 - 680876936) + b; d = ____(12, 20, d + (a & b | ~a & c) + m01 - 389564586) + a; c = ____(17, 15, c + (d & a | ~d & b) + m02 + 606105819) + d; b = ____(22, 10, b + (c & d | ~c & a) + m03 - 1044525330) + c; a = ____(7, 25, a + (b & c | ~b & d) + m04 - 176418897) + b; d = ____(12, 20, d + (a & b | ~a & c) + m05 + 1200080426) + a; c = ____(17, 15, c + (d & a | ~d & b) + m06 - 1473231341) + d; b = ____(22, 10, b + (c & d | ~c & a) + m07 - 45705983) + c; a = ____(7, 25, a + (b & c | ~b & d) + m08 + 1770035416) + b; d = ____(12, 20, d + (a & b | ~a & c) + m09 - 1958414417) + a; c = ____(17, 15, c + (d & a | ~d & b) + m10 - 42063) + d; b = ____(22, 10, b + (c & d | ~c & a) + m11 - 1990404162) + c; a = ____(7, 25, a + (b & c | ~b & d) + m12 + 1804603682) + b; d = ____(12, 20, d + (a & b | ~a & c) + m13 - 40341101) + a; c = ____(17, 15, c + (d & a | ~d & b) + m14 - 1502002290) + d; b = ____(22, 10, b + (c & d | ~c & a) + m15 + 1236535329) + c; a = ____(5, 27, a + (b & d | c & ~d) + m01 - 165796510) + b; d = ____(9, 23, d + (a & c | b & ~c) + m06 - 1069501632) + a; c = ____(14, 18, c + (d & b | a & ~b) + m11 + 643717713) + d; b = ____(20, 12, b + (c & a | d & ~a) + m00 - 373897302) + c; a = ____(5, 27, a + (b & d | c & ~d) + m05 - 701558691) + b; d = ____(9, 23, d + (a & c | b & ~c) + m10 + 38016083) + a; c = ____(14, 18, c + (d & b | a & ~b) + m15 - 660478335) + d; b = ____(20, 12, b + (c & a | d & ~a) + m04 - 405537848) + c; a = ____(5, 27, a + (b & d | c & ~d) + m09 + 568446438) + b; d = ____(9, 23, d + (a & c | b & ~c) + m14 - 1019803690) + a; c = ____(14, 18, c + (d & b | a & ~b) + m03 - 187363961) + d; b = ____(20, 12, b + (c & a | d & ~a) + m08 + 1163531501) + c; a = ____(5, 27, a + (b & d | c & ~d) + m13 - 1444681467) + b; d = ____(9, 23, d + (a & c | b & ~c) + m02 - 51403784) + a; c = ____(14, 18, c + (d & b | a & ~b) + m07 + 1735328473) + d; b = ____(20, 12, b + (c & a | d & ~a) + m12 - 1926607734) + c; a = ____(4, 28, a + (b ^ c ^ d) + m05 - 378558) + b; d = ____(11, 21, d + (a ^ b ^ c) + m08 - 2022574463) + a; c = ____(16, 16, c + (d ^ a ^ b) + m11 + 1839030562) + d; b = ____(23, 9, b + (c ^ d ^ a) + m14 - 35309556) + c; a = ____(4, 28, a + (b ^ c ^ d) + m01 - 1530992060) + b; d = ____(11, 21, d + (a ^ b ^ c) + m04 + 1272893353) + a; c = ____(16, 16, c + (d ^ a ^ b) + m07 - 155497632) + d; b = ____(23, 9, b + (c ^ d ^ a) + m10 - 1094730640) + c; a = ____(4, 28, a + (b ^ c ^ d) + m13 + 681279174) + b; d = ____(11, 21, d + (a ^ b ^ c) + m00 - 358537222) + a; c = ____(16, 16, c + (d ^ a ^ b) + m03 - 722521979) + d; b = ____(23, 9, b + (c ^ d ^ a) + m06 + 76029189) + c; a = ____(4, 28, a + (b ^ c ^ d) + m09 - 640364487) + b; d = ____(11, 21, d + (a ^ b ^ c) + m12 - 421815835) + a; c = ____(16, 16, c + (d ^ a ^ b) + m15 + 530742520) + d; b = ____(23, 9, b + (c ^ d ^ a) + m02 - 995338651) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m00 - 198630844) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m07 + 1126891415) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m14 - 1416354905) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m05 - 57434055) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m12 + 1700485571) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m03 - 1894986606) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m10 - 1051523) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m01 - 2054922799) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m08 + 1873313359) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m15 - 30611744) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m06 - 1560198380) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m13 + 1309151649) + c; a = ____(6, 26, a + (c ^ (b | ~d)) + m04 - 145523070) + b; d = ____(10, 22, d + (b ^ (a | ~c)) + m11 - 1120210379) + a; c = ____(15, 17, c + (a ^ (d | ~b)) + m02 + 718787259) + d; b = ____(21, 11, b + (d ^ (c | ~a)) + m09 - 343485551) + c; a = a + aa >>> 0; b = b + bb >>> 0; c = c + cc >>> 0; d = d + dd >>> 0; } return crypt.endian([a, b, c, d]); function ____(s, t, n) { return n << s | n >>> t; } }; return function(message, options) { var digestbytes = crypt.wordsToBytes(md5JS(message, options)), result = options && options.asBytes ? digestbytes : crypt.bytesconvertNumberToHex(digestbytes); return result; }; } function str2AB(str) { var l, buff, buffView, i = -1; l = str.length - 1; buff = new ArrayBuffer(str.length); buffView = new Uint8Array(buff); while (l > i++) { buffView[i] = str.charCodeAt(i); } return buffView; } function nodeATOB(str) { return Buffer.from(str, "base64").toString("binary"); } function identity(x) { return x; } function makeCrypt() { var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; return { rotl: function(n, b) { return n << b | n >>> 32 - b; }, endian: function(n) { if (n.constructor == Number) { return crypt.rotl(n, 8) & 16711935 | crypt.rotl(n, 24) & 4278255360; } for (var i = 0; i < n.length; i++) n[i] = crypt.endian(n[i]); return n; }, bytesToWords: function(bytes) { for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8) words[b >>> 5] |= bytes[i] << 24 - b % 32; return words; }, wordsToBytes: function(words) { for (var bytes = [], b = 0; b < words.length * 32; b += 8) bytes.push(words[b >>> 5] >>> 24 - b % 32 & 255); return bytes; }, bytesconvertNumberToHex: function(bytes) { for (var hex = [], i = 0; i < bytes.length; i++) { hex.push((bytes[i] >>> 4).toString(16)); hex.push((bytes[i] & 15).toString(16)); } return hex.join(""); } }; } // src/lib/md5-hash.ts var MD5Hash = class extends Hash { name = "md5"; options; constructor(options = {}) { super(); this.options = options; } /** * Atomic hash calculation * @returns base64 encoded hash */ async hash(input, encoding) { const md5Promise = new Promise( (resolve, reject) => ( // @ts-expect-error md5WASM(input).then(resolve).catch(reject) ) ); const hex = await md5Promise; return encodeHex(hex, encoding); } }; // src/lib/crypto-hash.ts var CryptoHash = class extends Hash { name; options; /** Name of digest algorithm */ _algorithm; /** CryptoJS algorithm */ _algo; constructor(options) { super(); this.options = options; registerJSModules(options?.modules); this._algorithm = this.options?.crypto?.algorithm; if (!this._algorithm) { throw new Error(this.name); } this.name = this._algorithm.toLowerCase(); } async preload() { const CryptoJS = getJSModule("CryptoJS", this.name); this._algo = CryptoJS.algo[this._algorithm]; } /** * Atomic hash calculation * @returns base64 encoded hash */ async hash(input, encoding) { await this.preload(); const hash = this._algo.create(); if (!hash) { throw new Error(this.name); } const CryptoJS = getJSModule("CryptoJS", this.name); const typedWordArray = CryptoJS.lib.WordArray.create(input); const enc = encoding === "base64" ? CryptoJS.enc.Base64 : CryptoJS.enc.Hex; return hash.update(typedWordArray).finalize().toString(enc); } async *hashBatches(asyncIterator, encoding = "base64") { await this.preload(); const CryptoJS = getJSModule("CryptoJS", this.name); const hash = this._algo.create(); if (!hash) { throw new Error(this.name); } for await (const chunk of asyncIterator) { const typedWordArray = CryptoJS.lib.WordArray.create(chunk); hash.update(typedWordArray); yield chunk; } const enc = encoding === "base64" ? CryptoJS.enc.Base64 : CryptoJS.enc.Hex; const digest = hash.finalize().toString(enc); this.options?.crypto?.onEnd?.({ hash: digest }); } }; // src/lib/sha256-hash.ts var SHA256Hash = class extends CryptoHash { constructor(options) { super({ ...options, crypto: { ...options.crypto, algorithm: "SHA256" } }); } }; // src/lib/node-hash.ts var NodeHash = class extends Hash { name; options; constructor(options) { super(); this.options = options; if (!globalThis.loaders.NodeHash) { throw new Error("install @loaders.gl/crypto on Node.js to use NodeHash"); } return new globalThis.loaders.NodeHash(options); } /** * Atomic hash calculation * @returns base64 encoded hash */ async hash(input, encoding) { throw new Error("Not implemented"); } }; // src/index.ts var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest"; var CryptoWorker = { id: "crypto", name: "CRC32, CRC32c and MD5 Hashes", module: "crypto", version: VERSION, options: { crypto: {} } }; var CryptoJSWorker = { id: "cryptojs", name: "Cryptographic Hashes", module: "crypto", version: VERSION, options: { cryptojs: {} } }; return __toCommonJS(bundle_exports); })(); return __exports__; });