@kepler.gl/common-utils 3.3.0-alpha.2 → 3.3.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,486 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.COG_PROBE_TIMEOUT_MS = void 0;
8
+ exports.getTitilerCorsCacheOrigin = getTitilerCorsCacheOrigin;
9
+ exports.isCOGUrl = isCOGUrl;
10
+ exports.isGeoTiffContentType = isGeoTiffContentType;
11
+ exports.isPMTilesUrl = void 0;
12
+ exports.isTiffMagicBytes = isTiffMagicBytes;
13
+ exports.parseUri = parseUri;
14
+ exports.probeUrlIsCOG = probeUrlIsCOG;
15
+ exports.shouldProbeForCOG = shouldProbeForCOG;
16
+ exports.validateUrl = validateUrl;
17
+ exports.withPublicTitilerCorsCacheKey = withPublicTitilerCorsCacheKey;
18
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
19
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
20
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
21
+ // SPDX-License-Identifier: MIT
22
+ // Copyright contributors to the kepler.gl project
23
+
24
+ /**
25
+ * Allows to break down a url into multiple params
26
+ * from http://blog.stevenlevithan.com/archives/parseuri
27
+ */
28
+ function parseUri(str) {
29
+ var o = parseUri.options;
30
+ var m = o.parser[o.strictMode ? 'strict' : 'loose'].exec(str);
31
+ var uri = {};
32
+ var i = 14;
33
+ while (i--) uri[o.key[i]] = (m === null || m === void 0 ? void 0 : m[i]) || '';
34
+ uri[o.q.name] = {};
35
+ uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
36
+ if ($1) uri[o.q.name][$1] = $2;
37
+ });
38
+ return uri;
39
+ }
40
+ parseUri.options = {
41
+ strictMode: false,
42
+ key: ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'],
43
+ q: {
44
+ name: 'queryKey',
45
+ parser: /(?:^|&)([^&=]*)=?([^&]*)/g
46
+ },
47
+ parser: {
48
+ strict:
49
+ // eslint-disable-next-line no-useless-escape
50
+ /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
51
+ loose:
52
+ // eslint-disable-next-line no-useless-escape
53
+ /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
54
+ }
55
+ };
56
+
57
+ /**
58
+ * Validates an url
59
+ * @param str
60
+ */
61
+ function validateUrl(str) {
62
+ try {
63
+ new URL(str);
64
+ return true;
65
+ } catch (_unused) {
66
+ return false;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Checks whether a given URL points to a PMTiles file.
72
+ * @param url The URL to check.
73
+ * @returns True if the URL includes '.pmtiles', otherwise false.
74
+ */
75
+ var isPMTilesUrl = exports.isPMTilesUrl = function isPMTilesUrl(url) {
76
+ return url === null || url === void 0 ? void 0 : url.includes('.pmtiles');
77
+ };
78
+ var COG_EXTENSIONS = ['.tif', '.tiff', '.geotiff', '.geotif', '.gtiff', '.cog'];
79
+
80
+ /** Public TiTiler instance used for COG preview in the Add Data modal. */
81
+ var PUBLIC_TITILER_HOST = 'titiler.xyz';
82
+
83
+ /**
84
+ * Query param used to partition CloudFront's cache for titiler.xyz.
85
+ * The public service echoes Access-Control-Allow-Origin and caches with
86
+ * `public, max-age=3600` but without Vary: Origin. A request from
87
+ * http://localhost:8080 (or a file:// HTML export, origin `null`) can then
88
+ * be served to https://kepler.gl with a mismatched CORS header.
89
+ *
90
+ * Values must not contain `://` — CloudFront's WAF 403s query strings that
91
+ * look like nested URLs (`kepler_origin=http://localhost:8080`).
92
+ */
93
+ var PUBLIC_TITILER_CORS_CACHE_PARAM = 'kepler_origin';
94
+
95
+ /** CORS origin sent by file:// documents and other opaque origins. */
96
+ var OPAQUE_CORS_ORIGIN = 'null';
97
+ function isHttpUrlOrigin(origin) {
98
+ return /^https?:\/\//i.test(origin);
99
+ }
100
+
101
+ /** `http://localhost:8080` → `http_localhost_8080` */
102
+ function sanitizeTitilerCorsCacheKey(origin) {
103
+ return origin.replace(/:\/\//g, '_').replace(/:/g, '_');
104
+ }
105
+
106
+ /**
107
+ * Origin used to partition titiler.xyz CloudFront CORS caches.
108
+ * file:// HTML exports send `Origin: null`; use that same cache key so they
109
+ * do not inherit a header cached for https://kepler.gl after an npm release
110
+ * that includes this helper in the UMD bundle.
111
+ */
112
+ function getTitilerCorsCacheOrigin(locationOrigin) {
113
+ var _window$location$orig, _window$location, _window$location2;
114
+ var origin = locationOrigin === undefined ? typeof window === 'undefined' ? null : (_window$location$orig = (_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.origin) !== null && _window$location$orig !== void 0 ? _window$location$orig : null : locationOrigin;
115
+ if (origin && isHttpUrlOrigin(origin)) {
116
+ return sanitizeTitilerCorsCacheKey(origin);
117
+ }
118
+ if (origin === OPAQUE_CORS_ORIGIN || typeof origin === 'string' && origin.startsWith('file:')) {
119
+ return OPAQUE_CORS_ORIGIN;
120
+ }
121
+ if (locationOrigin === undefined && typeof window !== 'undefined' && ((_window$location2 = window.location) === null || _window$location2 === void 0 ? void 0 : _window$location2.protocol) === 'file:') {
122
+ return OPAQUE_CORS_ORIGIN;
123
+ }
124
+ return null;
125
+ }
126
+
127
+ /**
128
+ * Append the current page origin to public titiler.xyz URLs so CloudFront
129
+ * caches CORS responses per origin. No-ops for other hosts or when origin
130
+ * cannot be determined (Node).
131
+ */
132
+ function withPublicTitilerCorsCacheKey(url, origin) {
133
+ var cacheOrigin = getTitilerCorsCacheOrigin(origin);
134
+ if (!url || !cacheOrigin) {
135
+ return url;
136
+ }
137
+ try {
138
+ var parsed = new URL(url);
139
+ if (parsed.hostname !== PUBLIC_TITILER_HOST) {
140
+ return url;
141
+ }
142
+ parsed.searchParams.set(PUBLIC_TITILER_CORS_CACHE_PARAM, cacheOrigin);
143
+ return parsed.toString();
144
+ } catch (_unused2) {
145
+ return url;
146
+ }
147
+ }
148
+ function getUrlPathname(url) {
149
+ try {
150
+ return new URL(url).pathname.toLowerCase().replace(/\/+$/, '');
151
+ } catch (_unused3) {
152
+ return url.trim().toLowerCase().split(/[?#]/)[0].replace(/\/+$/, '');
153
+ }
154
+ }
155
+ function isAbortError(error) {
156
+ return Boolean(error && (0, _typeof2["default"])(error) === 'object' && 'name' in error && error.name === 'AbortError');
157
+ }
158
+
159
+ /**
160
+ * TIFF / BigTIFF magic numbers.
161
+ * Classic: little-endian II*\0 or big-endian MM\0*
162
+ * BigTIFF: little-endian II+\0 or big-endian MM\0+
163
+ */
164
+ function isTiffMagicBytes(bytes) {
165
+ if (!bytes) return false;
166
+ var view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
167
+ if (view.length < 4) return false;
168
+ var littleEndianClassic = view[0] === 0x49 && view[1] === 0x49 && view[2] === 0x2a && view[3] === 0x00;
169
+ var bigEndianClassic = view[0] === 0x4d && view[1] === 0x4d && view[2] === 0x00 && view[3] === 0x2a;
170
+ var littleEndianBigTiff = view[0] === 0x49 && view[1] === 0x49 && view[2] === 0x2b && view[3] === 0x00;
171
+ var bigEndianBigTiff = view[0] === 0x4d && view[1] === 0x4d && view[2] === 0x00 && view[3] === 0x2b;
172
+ return littleEndianClassic || bigEndianClassic || littleEndianBigTiff || bigEndianBigTiff;
173
+ }
174
+
175
+ /**
176
+ * True when a Content-Type header describes GeoTIFF / Cloud Optimized GeoTIFF.
177
+ * Matches values such as `image/tiff; application=geotiff; profile=cloud-optimized`.
178
+ */
179
+ function isGeoTiffContentType(contentType) {
180
+ if (!contentType) return false;
181
+ var ct = contentType.toLowerCase();
182
+ return ct.includes('image/tiff') || ct.includes('image/geotiff') || ct.includes('application=geotiff');
183
+ }
184
+ function isJsonContentType(contentType) {
185
+ if (!contentType) return false;
186
+ var ct = contentType.toLowerCase();
187
+ return ct.includes('json');
188
+ }
189
+
190
+ /**
191
+ * Synchronous COG URL detection from the path alone.
192
+ * Matches GeoTIFF extensions and APIs that expose the file as a `/cog` suffix
193
+ * (for example NextGIS Web: `/api/resource/{id}/cog`).
194
+ */
195
+ function isCOGUrl(url) {
196
+ if (!url) return false;
197
+ var pathname = getUrlPathname(url);
198
+ // Already a TiTiler STAC wrapper, not a raw COG.
199
+ if (pathname.includes('/cog/stac')) return false;
200
+ if (COG_EXTENSIONS.some(function (ext) {
201
+ return pathname.endsWith(ext);
202
+ })) return true;
203
+ var lastSegment = pathname.split('/').pop() || '';
204
+ return lastSegment === 'cog';
205
+ }
206
+
207
+ /**
208
+ * True when the URL is not obviously STAC/PMTiles/COG and a HEAD/range probe
209
+ * should be used to read Content-Type (or TIFF magic bytes).
210
+ */
211
+ function shouldProbeForCOG(url) {
212
+ if (!url || !validateUrl(url) || isPMTilesUrl(url) || isCOGUrl(url)) {
213
+ return false;
214
+ }
215
+ var pathname = getUrlPathname(url);
216
+ if (pathname.endsWith('.json') || pathname.endsWith('.geojson') || pathname.endsWith('.jsonl')) {
217
+ return false;
218
+ }
219
+ // Documented STAC collection examples; skip extra CORS-sensitive probes.
220
+ if (pathname.includes('/collections/') || pathname.includes('/cog/stac')) {
221
+ return false;
222
+ }
223
+ return true;
224
+ }
225
+ function readResponsePrefix(_x) {
226
+ return _readResponsePrefix.apply(this, arguments);
227
+ }
228
+ function _readResponsePrefix() {
229
+ _readResponsePrefix = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(response) {
230
+ var _response$body, _response$body$getRea;
231
+ var maxBytes,
232
+ reader,
233
+ buf,
234
+ chunks,
235
+ received,
236
+ _yield$reader$read,
237
+ done,
238
+ value,
239
+ out,
240
+ offset,
241
+ _i,
242
+ _chunks,
243
+ chunk,
244
+ n,
245
+ _args = arguments;
246
+ return _regenerator["default"].wrap(function _callee$(_context) {
247
+ while (1) switch (_context.prev = _context.next) {
248
+ case 0:
249
+ maxBytes = _args.length > 1 && _args[1] !== undefined ? _args[1] : 16;
250
+ reader = (_response$body = response.body) === null || _response$body === void 0 || (_response$body$getRea = _response$body.getReader) === null || _response$body$getRea === void 0 ? void 0 : _response$body$getRea.call(_response$body);
251
+ if (reader) {
252
+ _context.next = 7;
253
+ break;
254
+ }
255
+ _context.next = 5;
256
+ return response.arrayBuffer();
257
+ case 5:
258
+ buf = _context.sent;
259
+ return _context.abrupt("return", new Uint8Array(buf.slice(0, maxBytes)));
260
+ case 7:
261
+ chunks = [];
262
+ received = 0;
263
+ case 9:
264
+ if (!(received < maxBytes)) {
265
+ _context.next = 21;
266
+ break;
267
+ }
268
+ _context.next = 12;
269
+ return reader.read();
270
+ case 12:
271
+ _yield$reader$read = _context.sent;
272
+ done = _yield$reader$read.done;
273
+ value = _yield$reader$read.value;
274
+ if (!(done || !value)) {
275
+ _context.next = 17;
276
+ break;
277
+ }
278
+ return _context.abrupt("break", 21);
279
+ case 17:
280
+ chunks.push(value);
281
+ received += value.byteLength;
282
+ _context.next = 9;
283
+ break;
284
+ case 21:
285
+ _context.prev = 21;
286
+ _context.next = 24;
287
+ return reader.cancel();
288
+ case 24:
289
+ _context.next = 28;
290
+ break;
291
+ case 26:
292
+ _context.prev = 26;
293
+ _context.t0 = _context["catch"](21);
294
+ case 28:
295
+ if (chunks.length) {
296
+ _context.next = 30;
297
+ break;
298
+ }
299
+ return _context.abrupt("return", null);
300
+ case 30:
301
+ out = new Uint8Array(Math.min(received, maxBytes));
302
+ offset = 0;
303
+ _i = 0, _chunks = chunks;
304
+ case 33:
305
+ if (!(_i < _chunks.length)) {
306
+ _context.next = 43;
307
+ break;
308
+ }
309
+ chunk = _chunks[_i];
310
+ n = Math.min(chunk.byteLength, maxBytes - offset);
311
+ out.set(chunk.subarray(0, n), offset);
312
+ offset += n;
313
+ if (!(offset >= maxBytes)) {
314
+ _context.next = 40;
315
+ break;
316
+ }
317
+ return _context.abrupt("break", 43);
318
+ case 40:
319
+ _i++;
320
+ _context.next = 33;
321
+ break;
322
+ case 43:
323
+ return _context.abrupt("return", out);
324
+ case 44:
325
+ case "end":
326
+ return _context.stop();
327
+ }
328
+ }, _callee, null, [[21, 26]]);
329
+ }));
330
+ return _readResponsePrefix.apply(this, arguments);
331
+ }
332
+ function contentTypeFrom(response) {
333
+ return response.headers.get('content-type');
334
+ }
335
+
336
+ /** Default bound so a hanging HEAD/GET cannot leave Add Data probing forever. */
337
+ var COG_PROBE_TIMEOUT_MS = exports.COG_PROBE_TIMEOUT_MS = 4000;
338
+
339
+ /**
340
+ * Probe a remote URL to decide whether it is a Cloud Optimized GeoTIFF.
341
+ * Tries HEAD (Content-Type) first, then a small ranged GET for magic bytes.
342
+ * HEAD often fails due to storage CORS settings; that is treated as a miss,
343
+ * not an error, and the GET fallback is attempted.
344
+ * The whole probe is aborted after `timeoutMs` and treated as a miss.
345
+ */
346
+ function probeUrlIsCOG(_x2, _x3) {
347
+ return _probeUrlIsCOG.apply(this, arguments);
348
+ }
349
+ function _probeUrlIsCOG() {
350
+ _probeUrlIsCOG = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(url, signal) {
351
+ var timeoutMs,
352
+ timeoutController,
353
+ timeoutId,
354
+ onExternalAbort,
355
+ probeSignal,
356
+ head,
357
+ contentType,
358
+ response,
359
+ _contentType,
360
+ _response$body2,
361
+ _response$body2$cance,
362
+ _response$body3,
363
+ _response$body3$cance,
364
+ prefix,
365
+ _args2 = arguments;
366
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
367
+ while (1) switch (_context2.prev = _context2.next) {
368
+ case 0:
369
+ timeoutMs = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : COG_PROBE_TIMEOUT_MS;
370
+ if (!(signal !== null && signal !== void 0 && signal.aborted)) {
371
+ _context2.next = 3;
372
+ break;
373
+ }
374
+ return _context2.abrupt("return", false);
375
+ case 3:
376
+ timeoutController = new AbortController();
377
+ timeoutId = setTimeout(function () {
378
+ return timeoutController.abort();
379
+ }, timeoutMs);
380
+ onExternalAbort = function onExternalAbort() {
381
+ return timeoutController.abort();
382
+ };
383
+ signal === null || signal === void 0 || signal.addEventListener('abort', onExternalAbort);
384
+ probeSignal = timeoutController.signal;
385
+ _context2.prev = 8;
386
+ _context2.prev = 9;
387
+ _context2.next = 12;
388
+ return fetch(url, {
389
+ method: 'HEAD',
390
+ signal: probeSignal
391
+ });
392
+ case 12:
393
+ head = _context2.sent;
394
+ if (!head.ok) {
395
+ _context2.next = 19;
396
+ break;
397
+ }
398
+ contentType = contentTypeFrom(head);
399
+ if (!isGeoTiffContentType(contentType)) {
400
+ _context2.next = 17;
401
+ break;
402
+ }
403
+ return _context2.abrupt("return", true);
404
+ case 17:
405
+ if (!isJsonContentType(contentType)) {
406
+ _context2.next = 19;
407
+ break;
408
+ }
409
+ return _context2.abrupt("return", false);
410
+ case 19:
411
+ _context2.next = 25;
412
+ break;
413
+ case 21:
414
+ _context2.prev = 21;
415
+ _context2.t0 = _context2["catch"](9);
416
+ if (!isAbortError(_context2.t0)) {
417
+ _context2.next = 25;
418
+ break;
419
+ }
420
+ return _context2.abrupt("return", false);
421
+ case 25:
422
+ _context2.prev = 25;
423
+ _context2.next = 28;
424
+ return fetch(url, {
425
+ method: 'GET',
426
+ headers: {
427
+ Range: 'bytes=0-15'
428
+ },
429
+ signal: probeSignal
430
+ });
431
+ case 28:
432
+ response = _context2.sent;
433
+ if (response.ok) {
434
+ _context2.next = 31;
435
+ break;
436
+ }
437
+ return _context2.abrupt("return", false);
438
+ case 31:
439
+ _contentType = contentTypeFrom(response);
440
+ if (!isGeoTiffContentType(_contentType)) {
441
+ _context2.next = 35;
442
+ break;
443
+ }
444
+ (_response$body2 = response.body) === null || _response$body2 === void 0 || (_response$body2$cance = _response$body2.cancel) === null || _response$body2$cance === void 0 || _response$body2$cance.call(_response$body2)["catch"](function () {
445
+ return undefined;
446
+ });
447
+ return _context2.abrupt("return", true);
448
+ case 35:
449
+ if (!isJsonContentType(_contentType)) {
450
+ _context2.next = 38;
451
+ break;
452
+ }
453
+ (_response$body3 = response.body) === null || _response$body3 === void 0 || (_response$body3$cance = _response$body3.cancel) === null || _response$body3$cance === void 0 || _response$body3$cance.call(_response$body3)["catch"](function () {
454
+ return undefined;
455
+ });
456
+ return _context2.abrupt("return", false);
457
+ case 38:
458
+ _context2.next = 40;
459
+ return readResponsePrefix(response);
460
+ case 40:
461
+ prefix = _context2.sent;
462
+ return _context2.abrupt("return", isTiffMagicBytes(prefix));
463
+ case 44:
464
+ _context2.prev = 44;
465
+ _context2.t1 = _context2["catch"](25);
466
+ if (!isAbortError(_context2.t1)) {
467
+ _context2.next = 48;
468
+ break;
469
+ }
470
+ return _context2.abrupt("return", false);
471
+ case 48:
472
+ return _context2.abrupt("return", false);
473
+ case 49:
474
+ _context2.prev = 49;
475
+ clearTimeout(timeoutId);
476
+ signal === null || signal === void 0 || signal.removeEventListener('abort', onExternalAbort);
477
+ return _context2.finish(49);
478
+ case 53:
479
+ case "end":
480
+ return _context2.stop();
481
+ }
482
+ }, _callee2, null, [[8,, 49, 53], [9, 21], [25, 44]]);
483
+ }));
484
+ return _probeUrlIsCOG.apply(this, arguments);
485
+ }
486
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","names":["parseUri","str","o","options","m","parser","strictMode","exec","uri","i","key","q","name","replace","$0","$1","$2","strict","loose","validateUrl","URL","_unused","isPMTilesUrl","exports","url","includes","COG_EXTENSIONS","PUBLIC_TITILER_HOST","PUBLIC_TITILER_CORS_CACHE_PARAM","OPAQUE_CORS_ORIGIN","isHttpUrlOrigin","origin","test","sanitizeTitilerCorsCacheKey","getTitilerCorsCacheOrigin","locationOrigin","_window$location$orig","_window$location","_window$location2","undefined","window","location","startsWith","protocol","withPublicTitilerCorsCacheKey","cacheOrigin","parsed","hostname","searchParams","set","toString","_unused2","getUrlPathname","pathname","toLowerCase","_unused3","trim","split","isAbortError","error","Boolean","_typeof2","isTiffMagicBytes","bytes","view","Uint8Array","length","littleEndianClassic","bigEndianClassic","littleEndianBigTiff","bigEndianBigTiff","isGeoTiffContentType","contentType","ct","isJsonContentType","isCOGUrl","some","ext","endsWith","lastSegment","pop","shouldProbeForCOG","readResponsePrefix","_x","_readResponsePrefix","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","response","_response$body","_response$body$getRea","maxBytes","reader","buf","chunks","received","_yield$reader$read","done","value","out","offset","_i","_chunks","chunk","n","_args","wrap","_callee$","_context","prev","next","body","getReader","call","arrayBuffer","sent","abrupt","slice","read","push","byteLength","cancel","t0","Math","min","subarray","stop","contentTypeFrom","headers","get","COG_PROBE_TIMEOUT_MS","probeUrlIsCOG","_x2","_x3","_probeUrlIsCOG","_callee2","signal","timeoutMs","timeoutController","timeoutId","onExternalAbort","probeSignal","head","_contentType","_response$body2","_response$body2$cance","_response$body3","_response$body3$cance","prefix","_args2","_callee2$","_context2","aborted","AbortController","setTimeout","abort","addEventListener","fetch","method","ok","Range","t1","clearTimeout","removeEventListener","finish"],"sources":["../../src/url.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\n/**\n * Allows to break down a url into multiple params\n * from http://blog.stevenlevithan.com/archives/parseuri\n */\nexport function parseUri(str: string): {[key: string]: any} {\n const o = parseUri.options;\n const m = o.parser[o.strictMode ? 'strict' : 'loose'].exec(str);\n const uri = {};\n let i = 14;\n\n while (i--) uri[o.key[i]] = m?.[i] || '';\n\n uri[o.q.name] = {};\n uri[o.key[12]].replace(o.q.parser, ($0, $1, $2) => {\n if ($1) uri[o.q.name][$1] = $2;\n });\n\n return uri;\n}\n\nparseUri.options = {\n strictMode: false,\n key: [\n 'source',\n 'protocol',\n 'authority',\n 'userInfo',\n 'user',\n 'password',\n 'host',\n 'port',\n 'relative',\n 'path',\n 'directory',\n 'file',\n 'query',\n 'anchor'\n ],\n q: {\n name: 'queryKey',\n parser: /(?:^|&)([^&=]*)=?([^&]*)/g\n },\n parser: {\n strict:\n // eslint-disable-next-line no-useless-escape\n /^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,\n loose:\n // eslint-disable-next-line no-useless-escape\n /^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/\n }\n};\n\n/**\n * Validates an url\n * @param str\n */\nexport function validateUrl(str) {\n try {\n new URL(str);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Checks whether a given URL points to a PMTiles file.\n * @param url The URL to check.\n * @returns True if the URL includes '.pmtiles', otherwise false.\n */\nexport const isPMTilesUrl = (url?: string | null) => url?.includes('.pmtiles');\n\nconst COG_EXTENSIONS = ['.tif', '.tiff', '.geotiff', '.geotif', '.gtiff', '.cog'];\n\n/** Public TiTiler instance used for COG preview in the Add Data modal. */\nconst PUBLIC_TITILER_HOST = 'titiler.xyz';\n\n/**\n * Query param used to partition CloudFront's cache for titiler.xyz.\n * The public service echoes Access-Control-Allow-Origin and caches with\n * `public, max-age=3600` but without Vary: Origin. A request from\n * http://localhost:8080 (or a file:// HTML export, origin `null`) can then\n * be served to https://kepler.gl with a mismatched CORS header.\n *\n * Values must not contain `://` — CloudFront's WAF 403s query strings that\n * look like nested URLs (`kepler_origin=http://localhost:8080`).\n */\nconst PUBLIC_TITILER_CORS_CACHE_PARAM = 'kepler_origin';\n\n/** CORS origin sent by file:// documents and other opaque origins. */\nconst OPAQUE_CORS_ORIGIN = 'null';\n\nfunction isHttpUrlOrigin(origin: string): boolean {\n return /^https?:\\/\\//i.test(origin);\n}\n\n/** `http://localhost:8080` → `http_localhost_8080` */\nfunction sanitizeTitilerCorsCacheKey(origin: string): string {\n return origin.replace(/:\\/\\//g, '_').replace(/:/g, '_');\n}\n\n/**\n * Origin used to partition titiler.xyz CloudFront CORS caches.\n * file:// HTML exports send `Origin: null`; use that same cache key so they\n * do not inherit a header cached for https://kepler.gl after an npm release\n * that includes this helper in the UMD bundle.\n */\nexport function getTitilerCorsCacheOrigin(locationOrigin?: string | null): string | null {\n const origin =\n locationOrigin === undefined\n ? typeof window === 'undefined'\n ? null\n : window.location?.origin ?? null\n : locationOrigin;\n\n if (origin && isHttpUrlOrigin(origin)) {\n return sanitizeTitilerCorsCacheKey(origin);\n }\n if (origin === OPAQUE_CORS_ORIGIN || (typeof origin === 'string' && origin.startsWith('file:'))) {\n return OPAQUE_CORS_ORIGIN;\n }\n if (\n locationOrigin === undefined &&\n typeof window !== 'undefined' &&\n window.location?.protocol === 'file:'\n ) {\n return OPAQUE_CORS_ORIGIN;\n }\n return null;\n}\n\n/**\n * Append the current page origin to public titiler.xyz URLs so CloudFront\n * caches CORS responses per origin. No-ops for other hosts or when origin\n * cannot be determined (Node).\n */\nexport function withPublicTitilerCorsCacheKey(url: string, origin?: string | null): string {\n const cacheOrigin = getTitilerCorsCacheOrigin(origin);\n if (!url || !cacheOrigin) {\n return url;\n }\n\n try {\n const parsed = new URL(url);\n if (parsed.hostname !== PUBLIC_TITILER_HOST) {\n return url;\n }\n parsed.searchParams.set(PUBLIC_TITILER_CORS_CACHE_PARAM, cacheOrigin);\n return parsed.toString();\n } catch {\n return url;\n }\n}\n\nfunction getUrlPathname(url: string): string {\n try {\n return new URL(url).pathname.toLowerCase().replace(/\\/+$/, '');\n } catch {\n return url.trim().toLowerCase().split(/[?#]/)[0].replace(/\\/+$/, '');\n }\n}\n\nfunction isAbortError(error: unknown): boolean {\n return Boolean(\n error &&\n typeof error === 'object' &&\n 'name' in error &&\n (error as {name?: string}).name === 'AbortError'\n );\n}\n\n/**\n * TIFF / BigTIFF magic numbers.\n * Classic: little-endian II*\\0 or big-endian MM\\0*\n * BigTIFF: little-endian II+\\0 or big-endian MM\\0+\n */\nexport function isTiffMagicBytes(bytes?: ArrayBuffer | Uint8Array | null): boolean {\n if (!bytes) return false;\n const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);\n if (view.length < 4) return false;\n const littleEndianClassic =\n view[0] === 0x49 && view[1] === 0x49 && view[2] === 0x2a && view[3] === 0x00;\n const bigEndianClassic =\n view[0] === 0x4d && view[1] === 0x4d && view[2] === 0x00 && view[3] === 0x2a;\n const littleEndianBigTiff =\n view[0] === 0x49 && view[1] === 0x49 && view[2] === 0x2b && view[3] === 0x00;\n const bigEndianBigTiff =\n view[0] === 0x4d && view[1] === 0x4d && view[2] === 0x00 && view[3] === 0x2b;\n return littleEndianClassic || bigEndianClassic || littleEndianBigTiff || bigEndianBigTiff;\n}\n\n/**\n * True when a Content-Type header describes GeoTIFF / Cloud Optimized GeoTIFF.\n * Matches values such as `image/tiff; application=geotiff; profile=cloud-optimized`.\n */\nexport function isGeoTiffContentType(contentType?: string | null): boolean {\n if (!contentType) return false;\n const ct = contentType.toLowerCase();\n return (\n ct.includes('image/tiff') || ct.includes('image/geotiff') || ct.includes('application=geotiff')\n );\n}\n\nfunction isJsonContentType(contentType?: string | null): boolean {\n if (!contentType) return false;\n const ct = contentType.toLowerCase();\n return ct.includes('json');\n}\n\n/**\n * Synchronous COG URL detection from the path alone.\n * Matches GeoTIFF extensions and APIs that expose the file as a `/cog` suffix\n * (for example NextGIS Web: `/api/resource/{id}/cog`).\n */\nexport function isCOGUrl(url?: string | null): boolean {\n if (!url) return false;\n const pathname = getUrlPathname(url);\n // Already a TiTiler STAC wrapper, not a raw COG.\n if (pathname.includes('/cog/stac')) return false;\n if (COG_EXTENSIONS.some(ext => pathname.endsWith(ext))) return true;\n const lastSegment = pathname.split('/').pop() || '';\n return lastSegment === 'cog';\n}\n\n/**\n * True when the URL is not obviously STAC/PMTiles/COG and a HEAD/range probe\n * should be used to read Content-Type (or TIFF magic bytes).\n */\nexport function shouldProbeForCOG(url?: string | null): boolean {\n if (!url || !validateUrl(url) || isPMTilesUrl(url) || isCOGUrl(url)) {\n return false;\n }\n const pathname = getUrlPathname(url);\n if (pathname.endsWith('.json') || pathname.endsWith('.geojson') || pathname.endsWith('.jsonl')) {\n return false;\n }\n // Documented STAC collection examples; skip extra CORS-sensitive probes.\n if (pathname.includes('/collections/') || pathname.includes('/cog/stac')) {\n return false;\n }\n return true;\n}\n\nasync function readResponsePrefix(response: Response, maxBytes = 16): Promise<Uint8Array | null> {\n const reader = response.body?.getReader?.();\n if (!reader) {\n const buf = await response.arrayBuffer();\n return new Uint8Array(buf.slice(0, maxBytes));\n }\n\n const chunks: Uint8Array[] = [];\n let received = 0;\n while (received < maxBytes) {\n const {done, value} = await reader.read();\n if (done || !value) break;\n chunks.push(value);\n received += value.byteLength;\n }\n try {\n await reader.cancel();\n } catch {\n // ignore cancel errors\n }\n if (!chunks.length) return null;\n\n const out = new Uint8Array(Math.min(received, maxBytes));\n let offset = 0;\n for (const chunk of chunks) {\n const n = Math.min(chunk.byteLength, maxBytes - offset);\n out.set(chunk.subarray(0, n), offset);\n offset += n;\n if (offset >= maxBytes) break;\n }\n return out;\n}\n\nfunction contentTypeFrom(response: Response): string | null {\n return response.headers.get('content-type');\n}\n\n/** Default bound so a hanging HEAD/GET cannot leave Add Data probing forever. */\nexport const COG_PROBE_TIMEOUT_MS = 4000;\n\n/**\n * Probe a remote URL to decide whether it is a Cloud Optimized GeoTIFF.\n * Tries HEAD (Content-Type) first, then a small ranged GET for magic bytes.\n * HEAD often fails due to storage CORS settings; that is treated as a miss,\n * not an error, and the GET fallback is attempted.\n * The whole probe is aborted after `timeoutMs` and treated as a miss.\n */\nexport async function probeUrlIsCOG(\n url: string,\n signal?: AbortSignal,\n timeoutMs: number = COG_PROBE_TIMEOUT_MS\n): Promise<boolean> {\n if (signal?.aborted) return false;\n\n const timeoutController = new AbortController();\n const timeoutId = setTimeout(() => timeoutController.abort(), timeoutMs);\n const onExternalAbort = () => timeoutController.abort();\n signal?.addEventListener('abort', onExternalAbort);\n\n const probeSignal = timeoutController.signal;\n\n try {\n try {\n const head = await fetch(url, {method: 'HEAD', signal: probeSignal});\n if (head.ok) {\n const contentType = contentTypeFrom(head);\n if (isGeoTiffContentType(contentType)) return true;\n if (isJsonContentType(contentType)) return false;\n }\n } catch (error) {\n if (isAbortError(error)) return false;\n // Continue to ranged GET. Vector-tile form notes HEAD often fails on storage CORS.\n }\n\n try {\n const response = await fetch(url, {\n method: 'GET',\n headers: {Range: 'bytes=0-15'},\n signal: probeSignal\n });\n if (!response.ok) return false;\n\n const contentType = contentTypeFrom(response);\n if (isGeoTiffContentType(contentType)) {\n response.body?.cancel?.().catch(() => undefined);\n return true;\n }\n if (isJsonContentType(contentType)) {\n response.body?.cancel?.().catch(() => undefined);\n return false;\n }\n\n const prefix = await readResponsePrefix(response);\n return isTiffMagicBytes(prefix);\n } catch (error) {\n if (isAbortError(error)) return false;\n return false;\n }\n } finally {\n clearTimeout(timeoutId);\n signal?.removeEventListener('abort', onExternalAbort);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;;AAEA;AACA;AACA;AACA;AACO,SAASA,QAAQA,CAACC,GAAW,EAAwB;EAC1D,IAAMC,CAAC,GAAGF,QAAQ,CAACG,OAAO;EAC1B,IAAMC,CAAC,GAAGF,CAAC,CAACG,MAAM,CAACH,CAAC,CAACI,UAAU,GAAG,QA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