@walkthru-earth/objex-utils 1.0.0 → 1.1.0

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.
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Field, Float64, FixedSizeList, Schema, Struct, makeData, RecordBatch, Table, List, Utf8 } from 'apache-arrow';
2
+ import YAML from 'yaml';
2
3
 
3
4
  // ../../src/lib/constants.ts
4
5
  var STORAGE_KEYS = {
@@ -1057,959 +1058,6 @@ var QueryCancelledError = class extends Error {
1057
1058
  }
1058
1059
  };
1059
1060
 
1060
- // ../../src/lib/storage/url-adapter.ts
1061
- var UrlAdapter = class {
1062
- supportsWrite = false;
1063
- async read(url, offset, length, signal) {
1064
- const headers = {};
1065
- if (offset !== void 0 && length !== void 0) {
1066
- headers.Range = `bytes=${offset}-${offset + length - 1}`;
1067
- } else if (offset !== void 0) {
1068
- headers.Range = `bytes=${offset}-`;
1069
- }
1070
- const res = await fetch(url, { headers, signal });
1071
- if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
1072
- return new Uint8Array(await res.arrayBuffer());
1073
- }
1074
- async head(url, signal) {
1075
- const res = await fetch(url, { method: "HEAD", signal });
1076
- if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
1077
- const name = url.split("/").pop()?.split("?")[0] || "file";
1078
- const ext = name.includes(".") ? name.split(".").pop().toLowerCase() : "";
1079
- return {
1080
- name,
1081
- path: url,
1082
- is_dir: false,
1083
- size: Number(res.headers.get("content-length") || 0),
1084
- modified: new Date(res.headers.get("last-modified") || 0).getTime(),
1085
- extension: ext
1086
- };
1087
- }
1088
- async list() {
1089
- return [];
1090
- }
1091
- async put() {
1092
- throw new Error("Write not supported for direct URL sources");
1093
- }
1094
- async delete() {
1095
- throw new Error("Delete not supported for direct URL sources");
1096
- }
1097
- async deletePrefix() {
1098
- throw new Error("Delete not supported for direct URL sources");
1099
- }
1100
- async copy() {
1101
- throw new Error("Copy not supported for direct URL sources");
1102
- }
1103
- };
1104
-
1105
- // ../../src/lib/utils/column-types.ts
1106
- var NUMBER_TYPES = [
1107
- "TINYINT",
1108
- "SMALLINT",
1109
- "INTEGER",
1110
- "BIGINT",
1111
- "HUGEINT",
1112
- "UTINYINT",
1113
- "USMALLINT",
1114
- "UINTEGER",
1115
- "UBIGINT",
1116
- "FLOAT",
1117
- "DOUBLE",
1118
- "DECIMAL",
1119
- "NUMERIC",
1120
- "REAL",
1121
- "INT",
1122
- "INT1",
1123
- "INT2",
1124
- "INT4",
1125
- "INT8",
1126
- "SIGNED",
1127
- "SHORT",
1128
- "LONG"
1129
- ];
1130
- var STRING_TYPES = ["VARCHAR", "TEXT", "STRING", "CHAR", "BPCHAR", "NAME", "UUID", "ENUM"];
1131
- var DATE_TYPES = [
1132
- "DATE",
1133
- "TIME",
1134
- "TIMESTAMP",
1135
- "TIMESTAMP_S",
1136
- "TIMESTAMP_MS",
1137
- "TIMESTAMP_NS",
1138
- "TIMESTAMP WITH TIME ZONE",
1139
- "TIMESTAMPTZ",
1140
- "INTERVAL",
1141
- "TIMESTAMP_TZ"
1142
- ];
1143
- var BOOLEAN_TYPES = ["BOOLEAN", "BOOL", "LOGICAL"];
1144
- var GEO_TYPES = [
1145
- "GEOMETRY",
1146
- "POINT",
1147
- "LINESTRING",
1148
- "POLYGON",
1149
- "MULTIPOINT",
1150
- "MULTILINESTRING",
1151
- "MULTIPOLYGON",
1152
- "GEOMETRYCOLLECTION",
1153
- "WKB_GEOMETRY"
1154
- ];
1155
- var BINARY_TYPES = ["BLOB", "BYTEA", "BINARY", "VARBINARY"];
1156
- var JSON_TYPES = ["JSON", "JSONB"];
1157
- function classifyType(duckdbType) {
1158
- const upper = duckdbType.toUpperCase().trim();
1159
- const base = upper.replace(/\(.*\)/, "").trim();
1160
- if (NUMBER_TYPES.includes(base)) return "number";
1161
- if (STRING_TYPES.includes(base)) return "string";
1162
- if (DATE_TYPES.includes(base)) return "date";
1163
- if (BOOLEAN_TYPES.includes(base)) return "boolean";
1164
- if (GEO_TYPES.includes(base)) return "geo";
1165
- if (BINARY_TYPES.includes(base)) return "binary";
1166
- if (JSON_TYPES.includes(base)) return "json";
1167
- if (base.startsWith("STRUCT") || base.startsWith("MAP") || base.startsWith("UNION"))
1168
- return "json";
1169
- if (base.endsWith("[]") || base.startsWith("LIST")) return "json";
1170
- if (upper.includes("INT") || upper.includes("FLOAT") || upper.includes("DOUBLE") || upper.includes("DECIMAL") || upper.includes("NUMERIC"))
1171
- return "number";
1172
- if (upper.includes("CHAR") || upper.includes("TEXT") || upper.includes("STRING")) return "string";
1173
- if (upper.includes("TIME") || upper.includes("DATE")) return "date";
1174
- if (upper.includes("BOOL")) return "boolean";
1175
- if (upper.includes("GEOMETRY") || upper.includes("GEO") || upper.includes("WKB")) return "geo";
1176
- if (upper.includes("BLOB") || upper.includes("BINARY")) return "binary";
1177
- if (upper.includes("JSON") || upper.includes("STRUCT") || upper.includes("MAP") || upper.includes("LIST"))
1178
- return "json";
1179
- return "other";
1180
- }
1181
- var TYPE_COLORS = {
1182
- number: "text-blue-500",
1183
- string: "text-green-500",
1184
- date: "text-amber-500",
1185
- boolean: "text-purple-500",
1186
- geo: "text-teal-500",
1187
- binary: "text-zinc-500",
1188
- json: "text-orange-500",
1189
- other: "text-zinc-400"
1190
- };
1191
- var TYPE_BADGE_CLASSES = {
1192
- number: "bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",
1193
- string: "bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/20",
1194
- date: "bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",
1195
- boolean: "bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20",
1196
- geo: "bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/20",
1197
- binary: "bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 border-zinc-500/20",
1198
- json: "bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20",
1199
- other: "bg-zinc-500/10 text-zinc-500 dark:text-zinc-400 border-zinc-500/20"
1200
- };
1201
- var TYPE_LABELS = {
1202
- number: "#",
1203
- string: "Aa",
1204
- date: "dt",
1205
- boolean: "T/F",
1206
- geo: "geo",
1207
- binary: "01",
1208
- json: "{}",
1209
- other: "?"
1210
- };
1211
- function typeColor(category) {
1212
- return TYPE_COLORS[category];
1213
- }
1214
- function typeBadgeClass(category) {
1215
- return TYPE_BADGE_CLASSES[category];
1216
- }
1217
- function typeLabel(category) {
1218
- return TYPE_LABELS[category];
1219
- }
1220
-
1221
- // ../../src/lib/utils/error.ts
1222
- function handleLoadError(err) {
1223
- if (err instanceof DOMException && err.name === "AbortError") return null;
1224
- return err instanceof Error ? err.message : String(err);
1225
- }
1226
-
1227
- // ../../src/lib/utils/format.ts
1228
- function formatFileSize(bytes) {
1229
- if (bytes < 0) return "0 B";
1230
- if (bytes === 0) return "0 B";
1231
- const units = ["B", "KB", "MB", "GB", "TB"];
1232
- const base = 1024;
1233
- const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(base)), units.length - 1);
1234
- const value = bytes / base ** exponent;
1235
- if (exponent === 0) return `${bytes} B`;
1236
- return `${value.toFixed(1)} ${units[exponent]}`;
1237
- }
1238
- function formatDate(timestamp) {
1239
- if (!timestamp || timestamp <= 0 || !Number.isFinite(timestamp)) return "--";
1240
- const date = new Date(timestamp);
1241
- const now = Date.now();
1242
- const diffMs = now - timestamp;
1243
- const diffSeconds = Math.floor(diffMs / 1e3);
1244
- const diffMinutes = Math.floor(diffSeconds / 60);
1245
- const diffHours = Math.floor(diffMinutes / 60);
1246
- const diffDays = Math.floor(diffHours / 24);
1247
- if (diffSeconds < 60) return "Just now";
1248
- if (diffMinutes < 60) return `${diffMinutes}m ago`;
1249
- if (diffHours < 24) return `${diffHours}h ago`;
1250
- if (diffDays < 7) return `${diffDays}d ago`;
1251
- return date.toLocaleDateString(void 0, {
1252
- year: "numeric",
1253
- month: "short",
1254
- day: "numeric"
1255
- });
1256
- }
1257
- function getFileExtension(filename) {
1258
- const lastDot = filename.lastIndexOf(".");
1259
- if (lastDot <= 0) return "";
1260
- return filename.slice(lastDot).toLowerCase();
1261
- }
1262
- function jsonReplacerBigInt(_key, value) {
1263
- return typeof value === "bigint" ? value.toString() : value;
1264
- }
1265
- function formatValue(value) {
1266
- if (value === null || value === void 0) return "NULL";
1267
- if (value instanceof Date) return value.toISOString();
1268
- if (typeof value === "bigint") return value.toString();
1269
- if (typeof value === "object") return JSON.stringify(value, jsonReplacerBigInt);
1270
- return String(value);
1271
- }
1272
- function normalizeGeomType(raw) {
1273
- const s = raw.toUpperCase().replace(/\s+/g, "");
1274
- if (s === "POINT") return "point";
1275
- if (s === "LINESTRING") return "linestring";
1276
- if (s === "POLYGON") return "polygon";
1277
- if (s === "MULTIPOINT") return "multipoint";
1278
- if (s === "MULTILINESTRING") return "multilinestring";
1279
- if (s === "MULTIPOLYGON") return "multipolygon";
1280
- return "polygon";
1281
- }
1282
- var EXTENSION_NAMES = {
1283
- point: "geoarrow.point",
1284
- linestring: "geoarrow.linestring",
1285
- polygon: "geoarrow.polygon",
1286
- multipoint: "geoarrow.multipoint",
1287
- multilinestring: "geoarrow.multilinestring",
1288
- multipolygon: "geoarrow.multipolygon"
1289
- };
1290
- function readWkbHeader(wkb) {
1291
- if (wkb.length < 5) return null;
1292
- const le = wkb[0] === 1;
1293
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1294
- const rawType = dv.getUint32(1, le);
1295
- let headerSize = 5;
1296
- if ((rawType & 536870912) !== 0) headerSize += 4;
1297
- const ewkbZ = (rawType & 2147483648) !== 0;
1298
- const ewkbM = (rawType & 1073741824) !== 0;
1299
- let type = rawType & 268435455;
1300
- let isoZ = false;
1301
- let isoM = false;
1302
- if (type > 3e3) {
1303
- isoZ = true;
1304
- isoM = true;
1305
- type -= 3e3;
1306
- } else if (type > 2e3) {
1307
- isoM = true;
1308
- type -= 2e3;
1309
- } else if (type > 1e3) {
1310
- isoZ = true;
1311
- type -= 1e3;
1312
- }
1313
- const dims = (ewkbZ || isoZ ? 1 : 0) + (ewkbM || isoM ? 1 : 0);
1314
- const coordStride = (2 + dims) * 8;
1315
- return { type, le, coordStride, dataOffset: headerSize };
1316
- }
1317
- function classifyWkbType(wkb) {
1318
- const h = readWkbHeader(wkb);
1319
- if (!h) return null;
1320
- switch (h.type) {
1321
- case 1:
1322
- return "point";
1323
- case 2:
1324
- return "linestring";
1325
- case 3:
1326
- return "polygon";
1327
- case 4:
1328
- return "multipoint";
1329
- case 5:
1330
- return "multilinestring";
1331
- case 6:
1332
- return "multipolygon";
1333
- default:
1334
- return null;
1335
- }
1336
- }
1337
- function newBounds() {
1338
- return { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity };
1339
- }
1340
- function expandBounds(b, x, y) {
1341
- if (Number.isNaN(x) || Number.isNaN(y)) return;
1342
- if (x < b.minX) b.minX = x;
1343
- if (y < b.minY) b.minY = y;
1344
- if (x > b.maxX) b.maxX = x;
1345
- if (y > b.maxY) b.maxY = y;
1346
- }
1347
- var coordField = new Field("xy", new Float64());
1348
- var coordType = new FixedSizeList(2, coordField);
1349
- function makeCoordData(coords, numPoints) {
1350
- const floatData = makeData({ type: new Float64(), length: coords.length, data: coords });
1351
- return makeData({ type: coordType, length: numPoints, nullCount: 0, child: floatData });
1352
- }
1353
- function buildPointData(wkbs, b) {
1354
- const n = wkbs.length;
1355
- const coords = new Float64Array(n * 2);
1356
- for (let i = 0; i < n; i++) {
1357
- const wkb = wkbs[i];
1358
- const h = readWkbHeader(wkb);
1359
- if (!h || h.type !== 1) {
1360
- coords[i * 2] = 0;
1361
- coords[i * 2 + 1] = 0;
1362
- continue;
1363
- }
1364
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1365
- const x = dv.getFloat64(h.dataOffset, h.le);
1366
- const y = dv.getFloat64(h.dataOffset + 8, h.le);
1367
- coords[i * 2] = x;
1368
- coords[i * 2 + 1] = y;
1369
- expandBounds(b, x, y);
1370
- }
1371
- return makeCoordData(coords, n);
1372
- }
1373
- function buildLineStringData(wkbs, b) {
1374
- const n = wkbs.length;
1375
- const geomOffsets = new Int32Array(n + 1);
1376
- let totalCoords = 0;
1377
- for (let i = 0; i < n; i++) {
1378
- geomOffsets[i] = totalCoords;
1379
- const h = readWkbHeader(wkbs[i]);
1380
- if (!h || h.type !== 2) continue;
1381
- const dv = new DataView(wkbs[i].buffer, wkbs[i].byteOffset, wkbs[i].byteLength);
1382
- const numPts = dv.getUint32(h.dataOffset, h.le);
1383
- totalCoords += numPts;
1384
- }
1385
- geomOffsets[n] = totalCoords;
1386
- const coords = new Float64Array(totalCoords * 2);
1387
- let ci = 0;
1388
- for (const wkb of wkbs) {
1389
- const h = readWkbHeader(wkb);
1390
- if (!h || h.type !== 2) continue;
1391
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1392
- const numPts = dv.getUint32(h.dataOffset, h.le);
1393
- let off = h.dataOffset + 4;
1394
- for (let j = 0; j < numPts; j++) {
1395
- const x = dv.getFloat64(off, h.le);
1396
- const y = dv.getFloat64(off + 8, h.le);
1397
- coords[ci++] = x;
1398
- coords[ci++] = y;
1399
- expandBounds(b, x, y);
1400
- off += h.coordStride;
1401
- }
1402
- }
1403
- const fslData = makeCoordData(coords, totalCoords);
1404
- const listType = new List(new Field("vertices", coordType));
1405
- return makeData({
1406
- type: listType,
1407
- length: n,
1408
- nullCount: 0,
1409
- valueOffsets: geomOffsets,
1410
- child: fslData
1411
- });
1412
- }
1413
- function buildPolygonData(wkbs, b) {
1414
- const n = wkbs.length;
1415
- const geomOffsets = new Int32Array(n + 1);
1416
- let totalRings = 0;
1417
- let totalCoords = 0;
1418
- for (let i = 0; i < n; i++) {
1419
- geomOffsets[i] = totalRings;
1420
- const h = readWkbHeader(wkbs[i]);
1421
- if (!h || h.type !== 3) continue;
1422
- const dv = new DataView(wkbs[i].buffer, wkbs[i].byteOffset, wkbs[i].byteLength);
1423
- const numRings = dv.getUint32(h.dataOffset, h.le);
1424
- let off = h.dataOffset + 4;
1425
- for (let r = 0; r < numRings; r++) {
1426
- const numPts = dv.getUint32(off, h.le);
1427
- off += 4 + numPts * h.coordStride;
1428
- totalCoords += numPts;
1429
- totalRings++;
1430
- }
1431
- }
1432
- geomOffsets[n] = totalRings;
1433
- const ringOffsets = new Int32Array(totalRings + 1);
1434
- const coords = new Float64Array(totalCoords * 2);
1435
- let ri = 0;
1436
- let ci = 0;
1437
- for (const wkb of wkbs) {
1438
- const h = readWkbHeader(wkb);
1439
- if (!h || h.type !== 3) continue;
1440
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1441
- const numRings = dv.getUint32(h.dataOffset, h.le);
1442
- let off = h.dataOffset + 4;
1443
- for (let r = 0; r < numRings; r++) {
1444
- ringOffsets[ri++] = ci >> 1;
1445
- const numPts = dv.getUint32(off, h.le);
1446
- off += 4;
1447
- for (let j = 0; j < numPts; j++) {
1448
- const x = dv.getFloat64(off, h.le);
1449
- const y = dv.getFloat64(off + 8, h.le);
1450
- coords[ci++] = x;
1451
- coords[ci++] = y;
1452
- expandBounds(b, x, y);
1453
- off += h.coordStride;
1454
- }
1455
- }
1456
- }
1457
- ringOffsets[totalRings] = ci >> 1;
1458
- const coordCount = ci >> 1;
1459
- const fslData = makeCoordData(coords, coordCount);
1460
- const ringListType = new List(new Field("vertices", coordType));
1461
- const ringListData = makeData({
1462
- type: ringListType,
1463
- length: totalRings,
1464
- nullCount: 0,
1465
- valueOffsets: ringOffsets,
1466
- child: fslData
1467
- });
1468
- const polyType = new List(new Field("rings", ringListType));
1469
- return makeData({
1470
- type: polyType,
1471
- length: n,
1472
- nullCount: 0,
1473
- valueOffsets: geomOffsets,
1474
- child: ringListData
1475
- });
1476
- }
1477
- function buildMultiPointData(wkbs, b) {
1478
- const n = wkbs.length;
1479
- const geomOffsets = new Int32Array(n + 1);
1480
- let totalCoords = 0;
1481
- for (let i = 0; i < n; i++) {
1482
- geomOffsets[i] = totalCoords;
1483
- const h = readWkbHeader(wkbs[i]);
1484
- if (!h || h.type !== 4) continue;
1485
- const dv = new DataView(wkbs[i].buffer, wkbs[i].byteOffset, wkbs[i].byteLength);
1486
- totalCoords += dv.getUint32(h.dataOffset, h.le);
1487
- }
1488
- geomOffsets[n] = totalCoords;
1489
- const coords = new Float64Array(totalCoords * 2);
1490
- let ci = 0;
1491
- for (const wkb of wkbs) {
1492
- const h = readWkbHeader(wkb);
1493
- if (!h || h.type !== 4) continue;
1494
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1495
- const numPts = dv.getUint32(h.dataOffset, h.le);
1496
- let off = h.dataOffset + 4;
1497
- for (let j = 0; j < numPts; j++) {
1498
- const innerH = readWkbHeader(
1499
- new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1500
- );
1501
- if (innerH) {
1502
- const x = dv.getFloat64(off + innerH.dataOffset, innerH.le);
1503
- const y = dv.getFloat64(off + innerH.dataOffset + 8, innerH.le);
1504
- coords[ci++] = x;
1505
- coords[ci++] = y;
1506
- expandBounds(b, x, y);
1507
- off += innerH.dataOffset + innerH.coordStride;
1508
- } else {
1509
- coords[ci++] = 0;
1510
- coords[ci++] = 0;
1511
- off += 21;
1512
- }
1513
- }
1514
- }
1515
- const fslData = makeCoordData(coords, totalCoords);
1516
- const listType = new List(new Field("vertices", coordType));
1517
- return makeData({
1518
- type: listType,
1519
- length: n,
1520
- nullCount: 0,
1521
- valueOffsets: geomOffsets,
1522
- child: fslData
1523
- });
1524
- }
1525
- function buildMultiLineStringData(wkbs, b) {
1526
- const n = wkbs.length;
1527
- const geomOffsetsArr = [0];
1528
- let totalLines = 0;
1529
- let totalCoords = 0;
1530
- for (const wkb of wkbs) {
1531
- const h = readWkbHeader(wkb);
1532
- if (!h || h.type !== 5) {
1533
- geomOffsetsArr.push(totalLines);
1534
- continue;
1535
- }
1536
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1537
- const numLines = dv.getUint32(h.dataOffset, h.le);
1538
- let off = h.dataOffset + 4;
1539
- for (let l = 0; l < numLines; l++) {
1540
- const innerH = readWkbHeader(
1541
- new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1542
- );
1543
- if (!innerH) break;
1544
- const innerDv = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off);
1545
- const numPts = innerDv.getUint32(innerH.dataOffset, innerH.le);
1546
- totalCoords += numPts;
1547
- off += innerH.dataOffset + 4 + numPts * innerH.coordStride;
1548
- totalLines++;
1549
- }
1550
- geomOffsetsArr.push(totalLines);
1551
- }
1552
- const geomOffsets = new Int32Array(geomOffsetsArr);
1553
- const lineOffsets = new Int32Array(totalLines + 1);
1554
- const coords = new Float64Array(totalCoords * 2);
1555
- let li = 0;
1556
- let ci = 0;
1557
- for (const wkb of wkbs) {
1558
- const h = readWkbHeader(wkb);
1559
- if (!h || h.type !== 5) continue;
1560
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1561
- const numLines = dv.getUint32(h.dataOffset, h.le);
1562
- let off = h.dataOffset + 4;
1563
- for (let l = 0; l < numLines; l++) {
1564
- lineOffsets[li++] = ci >> 1;
1565
- const innerH = readWkbHeader(
1566
- new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1567
- );
1568
- if (!innerH) break;
1569
- const numPts = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off).getUint32(
1570
- innerH.dataOffset,
1571
- innerH.le
1572
- );
1573
- let ptOff = off + innerH.dataOffset + 4;
1574
- for (let j = 0; j < numPts; j++) {
1575
- const x = dv.getFloat64(ptOff, innerH.le);
1576
- const y = dv.getFloat64(ptOff + 8, innerH.le);
1577
- coords[ci++] = x;
1578
- coords[ci++] = y;
1579
- expandBounds(b, x, y);
1580
- ptOff += innerH.coordStride;
1581
- }
1582
- off = ptOff;
1583
- }
1584
- }
1585
- lineOffsets[totalLines] = ci >> 1;
1586
- const fslData = makeCoordData(coords, ci >> 1);
1587
- const lineListType = new List(new Field("vertices", coordType));
1588
- const lineListData = makeData({
1589
- type: lineListType,
1590
- length: totalLines,
1591
- nullCount: 0,
1592
- valueOffsets: lineOffsets,
1593
- child: fslData
1594
- });
1595
- const multiLineType = new List(new Field("lines", lineListType));
1596
- return makeData({
1597
- type: multiLineType,
1598
- length: n,
1599
- nullCount: 0,
1600
- valueOffsets: geomOffsets,
1601
- child: lineListData
1602
- });
1603
- }
1604
- function buildMultiPolygonData(wkbs, b) {
1605
- const n = wkbs.length;
1606
- const geomOffsetsArr = [0];
1607
- let totalPolys = 0;
1608
- let totalRings = 0;
1609
- let totalCoords = 0;
1610
- for (const wkb of wkbs) {
1611
- const h = readWkbHeader(wkb);
1612
- if (!h || h.type !== 6) {
1613
- geomOffsetsArr.push(totalPolys);
1614
- continue;
1615
- }
1616
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1617
- const numPolys = dv.getUint32(h.dataOffset, h.le);
1618
- let off = h.dataOffset + 4;
1619
- for (let p = 0; p < numPolys; p++) {
1620
- const innerH = readWkbHeader(
1621
- new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1622
- );
1623
- if (!innerH) break;
1624
- const innerDv = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off);
1625
- const numRings = innerDv.getUint32(innerH.dataOffset, innerH.le);
1626
- let ringOff = innerH.dataOffset + 4;
1627
- for (let r = 0; r < numRings; r++) {
1628
- const numPts = innerDv.getUint32(ringOff, innerH.le);
1629
- ringOff += 4 + numPts * innerH.coordStride;
1630
- totalCoords += numPts;
1631
- totalRings++;
1632
- }
1633
- off += ringOff;
1634
- totalPolys++;
1635
- }
1636
- geomOffsetsArr.push(totalPolys);
1637
- }
1638
- const geomOffsets = new Int32Array(geomOffsetsArr);
1639
- const polyOffsets = new Int32Array(totalPolys + 1);
1640
- const ringOffsets = new Int32Array(totalRings + 1);
1641
- const coords = new Float64Array(totalCoords * 2);
1642
- let pi = 0;
1643
- let ri = 0;
1644
- let ci = 0;
1645
- for (const wkb of wkbs) {
1646
- const h = readWkbHeader(wkb);
1647
- if (!h || h.type !== 6) continue;
1648
- const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1649
- const numPolys = dv.getUint32(h.dataOffset, h.le);
1650
- let off = h.dataOffset + 4;
1651
- for (let p = 0; p < numPolys; p++) {
1652
- polyOffsets[pi++] = ri;
1653
- const innerH = readWkbHeader(
1654
- new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1655
- );
1656
- if (!innerH) break;
1657
- const innerDv = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off);
1658
- const numRings = innerDv.getUint32(innerH.dataOffset, innerH.le);
1659
- let ringOff = off + innerH.dataOffset + 4;
1660
- for (let r = 0; r < numRings; r++) {
1661
- ringOffsets[ri++] = ci >> 1;
1662
- const numPts = dv.getUint32(ringOff, innerH.le);
1663
- ringOff += 4;
1664
- for (let j = 0; j < numPts; j++) {
1665
- const x = dv.getFloat64(ringOff, innerH.le);
1666
- const y = dv.getFloat64(ringOff + 8, innerH.le);
1667
- coords[ci++] = x;
1668
- coords[ci++] = y;
1669
- expandBounds(b, x, y);
1670
- ringOff += innerH.coordStride;
1671
- }
1672
- }
1673
- off = ringOff;
1674
- }
1675
- }
1676
- polyOffsets[totalPolys] = ri;
1677
- ringOffsets[totalRings] = ci >> 1;
1678
- const fslData = makeCoordData(coords, ci >> 1);
1679
- const ringListType = new List(new Field("vertices", coordType));
1680
- const ringListData = makeData({
1681
- type: ringListType,
1682
- length: totalRings,
1683
- nullCount: 0,
1684
- valueOffsets: ringOffsets,
1685
- child: fslData
1686
- });
1687
- const polyListType = new List(new Field("rings", ringListType));
1688
- const polyListData = makeData({
1689
- type: polyListType,
1690
- length: totalPolys,
1691
- nullCount: 0,
1692
- valueOffsets: polyOffsets,
1693
- child: ringListData
1694
- });
1695
- const multiPolyType = new List(new Field("polygons", polyListType));
1696
- return makeData({
1697
- type: multiPolyType,
1698
- length: n,
1699
- nullCount: 0,
1700
- valueOffsets: geomOffsets,
1701
- child: polyListData
1702
- });
1703
- }
1704
- function buildAttributeColumns(indices, attributes) {
1705
- const n = indices.length;
1706
- const fields = [];
1707
- const dataArr = [];
1708
- for (const [name, col] of attributes) {
1709
- const { values } = col;
1710
- let isNumeric = true;
1711
- const sampleEnd = Math.min(n, 100);
1712
- for (let i = 0; i < sampleEnd; i++) {
1713
- if (values[indices[i]] != null && typeof values[indices[i]] !== "number") {
1714
- isNumeric = false;
1715
- break;
1716
- }
1717
- }
1718
- if (isNumeric) {
1719
- const arr = new Float64Array(n);
1720
- for (let i = 0; i < n; i++) arr[i] = values[indices[i]] ?? NaN;
1721
- const data = makeData({ type: new Float64(), length: n, data: arr });
1722
- fields.push(new Field(name, new Float64(), true));
1723
- dataArr.push(data);
1724
- } else {
1725
- const encoder = new TextEncoder();
1726
- const offsets = new Int32Array(n + 1);
1727
- let totalBytes = 0;
1728
- const strParts = [];
1729
- for (let i = 0; i < n; i++) {
1730
- offsets[i] = totalBytes;
1731
- const s = values[indices[i]] != null ? String(values[indices[i]]) : "";
1732
- const encoded = encoder.encode(s);
1733
- strParts.push(encoded);
1734
- totalBytes += encoded.length;
1735
- }
1736
- offsets[n] = totalBytes;
1737
- const valueBuffer = new Uint8Array(totalBytes);
1738
- let pos = 0;
1739
- for (const sv of strParts) {
1740
- valueBuffer.set(sv, pos);
1741
- pos += sv.length;
1742
- }
1743
- const data = makeData({
1744
- type: new Utf8(),
1745
- length: n,
1746
- valueOffsets: offsets,
1747
- data: valueBuffer
1748
- });
1749
- fields.push(new Field(name, new Utf8(), true));
1750
- dataArr.push(data);
1751
- }
1752
- }
1753
- return { fields, data: dataArr };
1754
- }
1755
- function buildSingleTable(geomType, wkbs, indices, attributes, b) {
1756
- const n = wkbs.length;
1757
- let geomData;
1758
- switch (geomType) {
1759
- case "point":
1760
- geomData = buildPointData(wkbs, b);
1761
- break;
1762
- case "linestring":
1763
- geomData = buildLineStringData(wkbs, b);
1764
- break;
1765
- case "polygon":
1766
- geomData = buildPolygonData(wkbs, b);
1767
- break;
1768
- case "multipoint":
1769
- geomData = buildMultiPointData(wkbs, b);
1770
- break;
1771
- case "multilinestring":
1772
- geomData = buildMultiLineStringData(wkbs, b);
1773
- break;
1774
- case "multipolygon":
1775
- geomData = buildMultiPolygonData(wkbs, b);
1776
- break;
1777
- }
1778
- const extensionName = EXTENSION_NAMES[geomType];
1779
- const geomMetadata = /* @__PURE__ */ new Map([
1780
- ["ARROW:extension:name", extensionName],
1781
- [
1782
- "ARROW:extension:metadata",
1783
- JSON.stringify({
1784
- crs: {
1785
- type: "name",
1786
- properties: { name: "urn:ogc:def:crs:OGC:1.3:CRS84" }
1787
- }
1788
- })
1789
- ]
1790
- ]);
1791
- const geomField = new Field("geometry", geomData.type, false, geomMetadata);
1792
- const attrCols = buildAttributeColumns(indices, attributes);
1793
- const fields = [geomField, ...attrCols.fields];
1794
- const childrenData = [geomData, ...attrCols.data];
1795
- const arrowSchema = new Schema(fields);
1796
- const structType = new Struct(fields);
1797
- const structData = makeData({
1798
- type: structType,
1799
- length: n,
1800
- nullCount: 0,
1801
- children: childrenData
1802
- });
1803
- const batch = new RecordBatch(arrowSchema, structData);
1804
- const table = new Table(arrowSchema, batch);
1805
- return {
1806
- table,
1807
- geometryType: geomType,
1808
- bounds: [b.minX, b.minY, b.maxX, b.maxY],
1809
- sourceIndices: indices
1810
- };
1811
- }
1812
- function buildGeoArrowTables(wkbArrays, attributes, knownGeomType) {
1813
- if (wkbArrays.length === 0) return [];
1814
- if (knownGeomType) {
1815
- const globalBounds2 = newBounds();
1816
- const indices = Array.from({ length: wkbArrays.length }, (_, i) => i);
1817
- const result = buildSingleTable(knownGeomType, wkbArrays, indices, attributes, globalBounds2);
1818
- return [result];
1819
- }
1820
- const groups = /* @__PURE__ */ new Map();
1821
- for (let i = 0; i < wkbArrays.length; i++) {
1822
- const geomType = classifyWkbType(wkbArrays[i]);
1823
- if (!geomType) continue;
1824
- let group = groups.get(geomType);
1825
- if (!group) {
1826
- group = { wkbs: [], indices: [] };
1827
- groups.set(geomType, group);
1828
- }
1829
- group.wkbs.push(wkbArrays[i]);
1830
- group.indices.push(i);
1831
- }
1832
- if (groups.size === 0) return [];
1833
- const globalBounds = newBounds();
1834
- const results = [];
1835
- for (const [geomType, { wkbs, indices }] of groups) {
1836
- const result = buildSingleTable(geomType, wkbs, indices, attributes, globalBounds);
1837
- results.push(result);
1838
- }
1839
- const mergedBounds = [
1840
- globalBounds.minX,
1841
- globalBounds.minY,
1842
- globalBounds.maxX,
1843
- globalBounds.maxY
1844
- ];
1845
- for (const r of results) r.bounds = mergedBounds;
1846
- return results;
1847
- }
1848
-
1849
- // ../../src/lib/utils/hex.ts
1850
- function generateHexDump(data, bytesPerRow = 16) {
1851
- const rows = [];
1852
- for (let i = 0; i < data.length; i += bytesPerRow) {
1853
- const slice = data.slice(i, i + bytesPerRow);
1854
- const offset = i.toString(16).padStart(8, "0");
1855
- const hex = [];
1856
- for (let j = 0; j < bytesPerRow; j++) {
1857
- if (j < slice.length) {
1858
- hex.push(slice[j].toString(16).padStart(2, "0"));
1859
- } else {
1860
- hex.push(" ");
1861
- }
1862
- }
1863
- let ascii = "";
1864
- for (let j = 0; j < slice.length; j++) {
1865
- const byte = slice[j];
1866
- ascii += byte >= 32 && byte <= 126 ? String.fromCharCode(byte) : ".";
1867
- }
1868
- rows.push({ offset, hex, ascii });
1869
- }
1870
- return rows;
1871
- }
1872
-
1873
- // ../../src/lib/utils/parquet-metadata.ts
1874
- function mapParquetType(col) {
1875
- const lt = col.logical_type;
1876
- if (lt) {
1877
- if (lt.type === "GEOMETRY" || lt.type === "GEOGRAPHY") return "GEOMETRY";
1878
- if (lt.type === "STRING" || lt.type === "UTF8") return "VARCHAR";
1879
- if (lt.type === "JSON") return "JSON";
1880
- if (lt.type === "UUID") return "UUID";
1881
- if (lt.type === "ENUM") return "VARCHAR";
1882
- if (lt.type === "INT" || lt.type === "INTEGER") {
1883
- const bits = lt.bitWidth ?? 32;
1884
- const signed = lt.isSigned !== false;
1885
- if (bits <= 8) return signed ? "TINYINT" : "UTINYINT";
1886
- if (bits <= 16) return signed ? "SMALLINT" : "USMALLINT";
1887
- if (bits <= 32) return signed ? "INTEGER" : "UINTEGER";
1888
- return signed ? "BIGINT" : "UBIGINT";
1889
- }
1890
- if (lt.type === "DECIMAL") return `DECIMAL(${lt.precision ?? 18},${lt.scale ?? 0})`;
1891
- if (lt.type === "DATE") return "DATE";
1892
- if (lt.type === "TIME") return "TIME";
1893
- if (lt.type === "TIMESTAMP") return "TIMESTAMP";
1894
- if (lt.type === "BSON") return "BLOB";
1895
- }
1896
- const ct = col.converted_type;
1897
- if (ct === "UTF8") return "VARCHAR";
1898
- if (ct === "JSON") return "JSON";
1899
- if (ct === "DATE") return "DATE";
1900
- if (ct === "TIMESTAMP_MILLIS" || ct === "TIMESTAMP_MICROS") return "TIMESTAMP";
1901
- if (ct === "DECIMAL") return `DECIMAL(${col.precision ?? 18},${col.scale ?? 0})`;
1902
- if (ct === "INT_8") return "TINYINT";
1903
- if (ct === "INT_16") return "SMALLINT";
1904
- if (ct === "INT_32") return "INTEGER";
1905
- if (ct === "INT_64") return "BIGINT";
1906
- if (ct === "UINT_8") return "UTINYINT";
1907
- if (ct === "UINT_16") return "USMALLINT";
1908
- if (ct === "UINT_32") return "UINTEGER";
1909
- if (ct === "UINT_64") return "UBIGINT";
1910
- const pt = col.type;
1911
- if (pt === "BOOLEAN") return "BOOLEAN";
1912
- if (pt === "INT32") return "INTEGER";
1913
- if (pt === "INT64") return "BIGINT";
1914
- if (pt === "INT96") return "TIMESTAMP";
1915
- if (pt === "FLOAT") return "FLOAT";
1916
- if (pt === "DOUBLE") return "DOUBLE";
1917
- if (pt === "BYTE_ARRAY") return "BLOB";
1918
- if (pt === "FIXED_LEN_BYTE_ARRAY") return "BLOB";
1919
- return "VARCHAR";
1920
- }
1921
- async function readParquetMetadata(url) {
1922
- const { parquetMetadataAsync, asyncBufferFromUrl } = await import('hyparquet');
1923
- const file = await asyncBufferFromUrl({ url });
1924
- const metadata = await parquetMetadataAsync(file);
1925
- const rowCount = metadata.row_groups.reduce(
1926
- (sum, rg) => sum + Number(rg.num_rows),
1927
- 0
1928
- );
1929
- const schema = metadata.schema.slice(1).filter((col) => col.num_children === void 0).map((col) => ({
1930
- name: col.name,
1931
- type: mapParquetType(col)
1932
- }));
1933
- let geo = null;
1934
- let legacyGeoParquet = false;
1935
- const geoKv = metadata.key_value_metadata?.find((kv) => kv.key === "geo");
1936
- if (geoKv) {
1937
- try {
1938
- const geoJson = JSON.parse(geoKv.value ?? "");
1939
- if (geoJson.schema_version && !geoJson.version) {
1940
- legacyGeoParquet = true;
1941
- }
1942
- geo = {
1943
- primaryColumn: geoJson.primary_column ?? "geometry",
1944
- columns: {}
1945
- };
1946
- if (geoJson.columns) {
1947
- for (const [colName, colMeta] of Object.entries(geoJson.columns)) {
1948
- geo.columns[colName] = {
1949
- encoding: colMeta.encoding ?? "WKB",
1950
- geometryTypes: colMeta.geometry_types ?? [],
1951
- crs: colMeta.crs ?? null,
1952
- bbox: colMeta.bbox
1953
- };
1954
- }
1955
- }
1956
- } catch {
1957
- }
1958
- }
1959
- const createdBy = metadata.created_by ?? null;
1960
- const numRowGroups = metadata.row_groups.length;
1961
- let compression = null;
1962
- if (numRowGroups > 0 && metadata.row_groups[0].columns) {
1963
- const codecs = /* @__PURE__ */ new Set();
1964
- for (const col of metadata.row_groups[0].columns) {
1965
- const codec = col.meta_data?.codec;
1966
- if (codec) codecs.add(codec);
1967
- }
1968
- if (codecs.size === 1) {
1969
- compression = [...codecs][0];
1970
- } else if (codecs.size > 1) {
1971
- compression = [...codecs].join(", ");
1972
- }
1973
- }
1974
- return { rowCount, schema, geo, legacyGeoParquet, createdBy, numRowGroups, compression };
1975
- }
1976
- function extractEpsgFromGeoMeta(geo) {
1977
- const primaryCol = geo.columns[geo.primaryColumn];
1978
- if (!primaryCol?.crs) return null;
1979
- const crs = primaryCol.crs;
1980
- if (crs.type === "name" && crs.properties?.name?.includes("CRS84")) return null;
1981
- if (crs.id?.authority === "EPSG") {
1982
- const code = crs.id.code;
1983
- if (WGS84_CODES.has(code)) return null;
1984
- return `EPSG:${code}`;
1985
- }
1986
- return null;
1987
- }
1988
- function extractGeometryTypes(geo) {
1989
- const primaryCol = geo.columns[geo.primaryColumn];
1990
- if (!primaryCol?.geometryTypes?.length) return [];
1991
- const typeMap = {
1992
- Point: "point",
1993
- LineString: "linestring",
1994
- Polygon: "polygon",
1995
- MultiPoint: "multipoint",
1996
- MultiLineString: "multilinestring",
1997
- MultiPolygon: "multipolygon"
1998
- };
1999
- const types = [];
2000
- for (const raw of primaryCol.geometryTypes) {
2001
- const base = raw.split(" ")[0];
2002
- const mapped = typeMap[base];
2003
- if (mapped && !types.includes(mapped)) types.push(mapped);
2004
- }
2005
- return types;
2006
- }
2007
- function extractBounds(geo) {
2008
- const primaryCol = geo.columns[geo.primaryColumn];
2009
- if (!primaryCol?.bbox || primaryCol.bbox.length < 4) return null;
2010
- return [primaryCol.bbox[0], primaryCol.bbox[1], primaryCol.bbox[2], primaryCol.bbox[3]];
2011
- }
2012
-
2013
1061
  // ../../src/lib/storage/providers.ts
2014
1062
  var PROVIDERS = {
2015
1063
  s3: {
@@ -2269,7 +1317,1165 @@ var PROVIDERS = {
2269
1317
  endpointPlaceholder: "https://s3.gra.io.cloud.ovh.net",
2270
1318
  schemes: []
2271
1319
  }
2272
- };
1320
+ };
1321
+ var PROVIDER_IDS = [
1322
+ "s3",
1323
+ "gcs",
1324
+ "r2",
1325
+ "azure",
1326
+ "b2",
1327
+ "digitalocean",
1328
+ "wasabi",
1329
+ "storj",
1330
+ "hetzner",
1331
+ "contabo",
1332
+ "linode",
1333
+ "ovhcloud",
1334
+ "minio"
1335
+ ];
1336
+ function getProvider(id) {
1337
+ return PROVIDERS[id] ?? PROVIDERS.s3;
1338
+ }
1339
+ function buildEndpointFromTemplate(id, region) {
1340
+ const def = PROVIDERS[id];
1341
+ if (!def?.endpointTemplate) return "";
1342
+ return def.endpointTemplate.replace("{region}", region);
1343
+ }
1344
+ function buildProviderBaseUrl(provider, endpoint, bucket, region) {
1345
+ if (endpoint) {
1346
+ return `${endpoint.replace(/\/$/, "")}/${bucket}`;
1347
+ }
1348
+ const def = PROVIDERS[provider];
1349
+ if (def?.endpointTemplate) {
1350
+ const resolved = def.endpointTemplate.replace("{region}", region || def.defaultRegion);
1351
+ return `${resolved}/${bucket}`;
1352
+ }
1353
+ return `https://s3.${region || "us-east-1"}.amazonaws.com/${bucket}`;
1354
+ }
1355
+ function isGcsProvider(provider, endpoint) {
1356
+ return provider === "gcs" || !!endpoint && /storage\.googleapis\.com/i.test(endpoint);
1357
+ }
1358
+
1359
+ // ../../src/lib/storage/url-adapter.ts
1360
+ var UrlAdapter = class {
1361
+ supportsWrite = false;
1362
+ async read(url, offset, length, signal) {
1363
+ const headers = {};
1364
+ if (offset !== void 0 && length !== void 0) {
1365
+ headers.Range = `bytes=${offset}-${offset + length - 1}`;
1366
+ } else if (offset !== void 0) {
1367
+ headers.Range = `bytes=${offset}-`;
1368
+ }
1369
+ const res = await fetch(url, { headers, signal });
1370
+ if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
1371
+ return new Uint8Array(await res.arrayBuffer());
1372
+ }
1373
+ async head(url, signal) {
1374
+ const res = await fetch(url, { method: "HEAD", signal });
1375
+ if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
1376
+ const name = url.split("/").pop()?.split("?")[0] || "file";
1377
+ const ext = name.includes(".") ? name.split(".").pop().toLowerCase() : "";
1378
+ return {
1379
+ name,
1380
+ path: url,
1381
+ is_dir: false,
1382
+ size: Number(res.headers.get("content-length") || 0),
1383
+ modified: new Date(res.headers.get("last-modified") || 0).getTime(),
1384
+ extension: ext
1385
+ };
1386
+ }
1387
+ async list() {
1388
+ return [];
1389
+ }
1390
+ async put() {
1391
+ throw new Error("Write not supported for direct URL sources");
1392
+ }
1393
+ async delete() {
1394
+ throw new Error("Delete not supported for direct URL sources");
1395
+ }
1396
+ async deletePrefix() {
1397
+ throw new Error("Delete not supported for direct URL sources");
1398
+ }
1399
+ async copy() {
1400
+ throw new Error("Copy not supported for direct URL sources");
1401
+ }
1402
+ };
1403
+
1404
+ // ../../src/lib/utils/cloud-url.ts
1405
+ var AWS_REGION_RE = /^(us|eu|ap|sa|ca|me|af|il)-(north|south|east|west|central|northeast|southeast|northwest|southwest)-\d+/;
1406
+ function getNativeScheme(provider) {
1407
+ const def = PROVIDERS[provider];
1408
+ if (def?.schemes.length) return def.schemes[0];
1409
+ return "s3";
1410
+ }
1411
+ function safeDecodeURIComponent(s) {
1412
+ try {
1413
+ return decodeURIComponent(s);
1414
+ } catch {
1415
+ return s;
1416
+ }
1417
+ }
1418
+ function resolveCloudUrl(url) {
1419
+ const s3Match = url.match(/^s3[an]?:\/\/([^/]+)\/?(.*)$/);
1420
+ if (s3Match) {
1421
+ const [, bucket, key] = s3Match;
1422
+ const regionMatch = bucket.match(AWS_REGION_RE);
1423
+ const region = regionMatch ? regionMatch[0] : "us-east-1";
1424
+ const base = buildProviderBaseUrl("s3", "", bucket, region);
1425
+ return key ? `${base}/${key}` : base;
1426
+ }
1427
+ const gcsMatch = url.match(/^gcs?:\/\/([^/]+)\/?(.*)$/);
1428
+ if (gcsMatch) {
1429
+ const [, bucket, key] = gcsMatch;
1430
+ const base = buildProviderBaseUrl("gcs", "", bucket, "");
1431
+ return key ? `${base}/${key}` : base;
1432
+ }
1433
+ return url;
1434
+ }
1435
+
1436
+ // ../../src/lib/utils/column-types.ts
1437
+ var NUMBER_TYPES = [
1438
+ "TINYINT",
1439
+ "SMALLINT",
1440
+ "INTEGER",
1441
+ "BIGINT",
1442
+ "HUGEINT",
1443
+ "UTINYINT",
1444
+ "USMALLINT",
1445
+ "UINTEGER",
1446
+ "UBIGINT",
1447
+ "FLOAT",
1448
+ "DOUBLE",
1449
+ "DECIMAL",
1450
+ "NUMERIC",
1451
+ "REAL",
1452
+ "INT",
1453
+ "INT1",
1454
+ "INT2",
1455
+ "INT4",
1456
+ "INT8",
1457
+ "SIGNED",
1458
+ "SHORT",
1459
+ "LONG"
1460
+ ];
1461
+ var STRING_TYPES = ["VARCHAR", "TEXT", "STRING", "CHAR", "BPCHAR", "NAME", "UUID", "ENUM"];
1462
+ var DATE_TYPES = [
1463
+ "DATE",
1464
+ "TIME",
1465
+ "TIMESTAMP",
1466
+ "TIMESTAMP_S",
1467
+ "TIMESTAMP_MS",
1468
+ "TIMESTAMP_NS",
1469
+ "TIMESTAMP WITH TIME ZONE",
1470
+ "TIMESTAMPTZ",
1471
+ "INTERVAL",
1472
+ "TIMESTAMP_TZ"
1473
+ ];
1474
+ var BOOLEAN_TYPES = ["BOOLEAN", "BOOL", "LOGICAL"];
1475
+ var GEO_TYPES = [
1476
+ "GEOMETRY",
1477
+ "POINT",
1478
+ "LINESTRING",
1479
+ "POLYGON",
1480
+ "MULTIPOINT",
1481
+ "MULTILINESTRING",
1482
+ "MULTIPOLYGON",
1483
+ "GEOMETRYCOLLECTION",
1484
+ "WKB_GEOMETRY"
1485
+ ];
1486
+ var BINARY_TYPES = ["BLOB", "BYTEA", "BINARY", "VARBINARY"];
1487
+ var JSON_TYPES = ["JSON", "JSONB"];
1488
+ function classifyType(duckdbType) {
1489
+ const upper = duckdbType.toUpperCase().trim();
1490
+ const base = upper.replace(/\(.*\)/, "").trim();
1491
+ if (NUMBER_TYPES.includes(base)) return "number";
1492
+ if (STRING_TYPES.includes(base)) return "string";
1493
+ if (DATE_TYPES.includes(base)) return "date";
1494
+ if (BOOLEAN_TYPES.includes(base)) return "boolean";
1495
+ if (GEO_TYPES.includes(base)) return "geo";
1496
+ if (BINARY_TYPES.includes(base)) return "binary";
1497
+ if (JSON_TYPES.includes(base)) return "json";
1498
+ if (base.startsWith("STRUCT") || base.startsWith("MAP") || base.startsWith("UNION"))
1499
+ return "json";
1500
+ if (base.endsWith("[]") || base.startsWith("LIST")) return "json";
1501
+ if (upper.includes("INT") || upper.includes("FLOAT") || upper.includes("DOUBLE") || upper.includes("DECIMAL") || upper.includes("NUMERIC"))
1502
+ return "number";
1503
+ if (upper.includes("CHAR") || upper.includes("TEXT") || upper.includes("STRING")) return "string";
1504
+ if (upper.includes("TIME") || upper.includes("DATE")) return "date";
1505
+ if (upper.includes("BOOL")) return "boolean";
1506
+ if (upper.includes("GEOMETRY") || upper.includes("GEO") || upper.includes("WKB")) return "geo";
1507
+ if (upper.includes("BLOB") || upper.includes("BINARY")) return "binary";
1508
+ if (upper.includes("JSON") || upper.includes("STRUCT") || upper.includes("MAP") || upper.includes("LIST"))
1509
+ return "json";
1510
+ return "other";
1511
+ }
1512
+ var TYPE_COLORS = {
1513
+ number: "text-blue-500",
1514
+ string: "text-green-500",
1515
+ date: "text-amber-500",
1516
+ boolean: "text-purple-500",
1517
+ geo: "text-teal-500",
1518
+ binary: "text-zinc-500",
1519
+ json: "text-orange-500",
1520
+ other: "text-zinc-400"
1521
+ };
1522
+ var TYPE_BADGE_CLASSES = {
1523
+ number: "bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",
1524
+ string: "bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/20",
1525
+ date: "bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",
1526
+ boolean: "bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20",
1527
+ geo: "bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/20",
1528
+ binary: "bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 border-zinc-500/20",
1529
+ json: "bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20",
1530
+ other: "bg-zinc-500/10 text-zinc-500 dark:text-zinc-400 border-zinc-500/20"
1531
+ };
1532
+ var TYPE_LABELS = {
1533
+ number: "#",
1534
+ string: "Aa",
1535
+ date: "dt",
1536
+ boolean: "T/F",
1537
+ geo: "geo",
1538
+ binary: "01",
1539
+ json: "{}",
1540
+ other: "?"
1541
+ };
1542
+ function typeColor(category) {
1543
+ return TYPE_COLORS[category];
1544
+ }
1545
+ function typeBadgeClass(category) {
1546
+ return TYPE_BADGE_CLASSES[category];
1547
+ }
1548
+ function typeLabel(category) {
1549
+ return TYPE_LABELS[category];
1550
+ }
1551
+
1552
+ // ../../src/lib/utils/error.ts
1553
+ function handleLoadError(err) {
1554
+ if (err instanceof DOMException && err.name === "AbortError") return null;
1555
+ return err instanceof Error ? err.message : String(err);
1556
+ }
1557
+
1558
+ // ../../src/lib/utils/format.ts
1559
+ function formatFileSize(bytes) {
1560
+ if (bytes < 0) return "0 B";
1561
+ if (bytes === 0) return "0 B";
1562
+ const units = ["B", "KB", "MB", "GB", "TB"];
1563
+ const base = 1024;
1564
+ const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(base)), units.length - 1);
1565
+ const value = bytes / base ** exponent;
1566
+ if (exponent === 0) return `${bytes} B`;
1567
+ return `${value.toFixed(1)} ${units[exponent]}`;
1568
+ }
1569
+ function formatDate(timestamp) {
1570
+ if (!timestamp || timestamp <= 0 || !Number.isFinite(timestamp)) return "--";
1571
+ const date = new Date(timestamp);
1572
+ const now = Date.now();
1573
+ const diffMs = now - timestamp;
1574
+ const diffSeconds = Math.floor(diffMs / 1e3);
1575
+ const diffMinutes = Math.floor(diffSeconds / 60);
1576
+ const diffHours = Math.floor(diffMinutes / 60);
1577
+ const diffDays = Math.floor(diffHours / 24);
1578
+ if (diffSeconds < 60) return "Just now";
1579
+ if (diffMinutes < 60) return `${diffMinutes}m ago`;
1580
+ if (diffHours < 24) return `${diffHours}h ago`;
1581
+ if (diffDays < 7) return `${diffDays}d ago`;
1582
+ return date.toLocaleDateString(void 0, {
1583
+ year: "numeric",
1584
+ month: "short",
1585
+ day: "numeric"
1586
+ });
1587
+ }
1588
+ function getFileExtension(filename) {
1589
+ const lastDot = filename.lastIndexOf(".");
1590
+ if (lastDot <= 0) return "";
1591
+ return filename.slice(lastDot).toLowerCase();
1592
+ }
1593
+ function jsonReplacerBigInt(_key, value) {
1594
+ return typeof value === "bigint" ? value.toString() : value;
1595
+ }
1596
+ function formatValue(value) {
1597
+ if (value === null || value === void 0) return "NULL";
1598
+ if (value instanceof Date) return value.toISOString();
1599
+ if (typeof value === "bigint") return value.toString();
1600
+ if (typeof value === "object") return JSON.stringify(value, jsonReplacerBigInt);
1601
+ return String(value);
1602
+ }
1603
+
1604
+ // ../../src/lib/utils/export.ts
1605
+ function formatCellValue(value) {
1606
+ if (value === null || value === void 0) return "";
1607
+ if (value instanceof Date) return value.toISOString();
1608
+ if (typeof value === "bigint") return value.toString();
1609
+ if (typeof value === "object") return JSON.stringify(value, jsonReplacerBigInt);
1610
+ return String(value);
1611
+ }
1612
+ function escapeCsvField(value) {
1613
+ if (value.includes(",") || value.includes('"') || value.includes("\n") || value.includes("\r")) {
1614
+ return `"${value.replace(/"/g, '""')}"`;
1615
+ }
1616
+ return value;
1617
+ }
1618
+ function serializeToCsv(columns, rows) {
1619
+ const header = columns.map(escapeCsvField).join(",");
1620
+ const body = rows.map((row) => columns.map((col) => escapeCsvField(formatCellValue(row[col]))).join(",")).join("\n");
1621
+ return `${header}
1622
+ ${body}`;
1623
+ }
1624
+ function serializeToJson(columns, rows) {
1625
+ const data = rows.map((row) => {
1626
+ const obj = {};
1627
+ for (const col of columns) {
1628
+ const val = row[col];
1629
+ if (val instanceof Date) {
1630
+ obj[col] = val.toISOString();
1631
+ } else {
1632
+ obj[col] = val ?? null;
1633
+ }
1634
+ }
1635
+ return obj;
1636
+ });
1637
+ return JSON.stringify(data, jsonReplacerBigInt, 2);
1638
+ }
1639
+
1640
+ // ../../src/lib/utils/file-sort.ts
1641
+ function sortFileEntries(entries, config) {
1642
+ const sorted = [...entries];
1643
+ const dir = config.direction === "asc" ? 1 : -1;
1644
+ sorted.sort((a, b) => {
1645
+ if (a.is_dir && !b.is_dir) return -1;
1646
+ if (!a.is_dir && b.is_dir) return 1;
1647
+ switch (config.field) {
1648
+ case "name":
1649
+ return dir * a.name.localeCompare(b.name, void 0, { sensitivity: "base" });
1650
+ case "size":
1651
+ return dir * (a.size - b.size);
1652
+ case "modified":
1653
+ return dir * (a.modified - b.modified);
1654
+ case "extension":
1655
+ return dir * a.extension.localeCompare(b.extension, void 0, { sensitivity: "base" });
1656
+ default:
1657
+ return 0;
1658
+ }
1659
+ });
1660
+ return sorted;
1661
+ }
1662
+ function toggleSortField(current, field) {
1663
+ if (current.field === field) {
1664
+ return { field, direction: current.direction === "asc" ? "desc" : "asc" };
1665
+ }
1666
+ return { field, direction: "asc" };
1667
+ }
1668
+ function normalizeGeomType(raw) {
1669
+ const s = raw.toUpperCase().replace(/\s+/g, "");
1670
+ if (s === "POINT") return "point";
1671
+ if (s === "LINESTRING") return "linestring";
1672
+ if (s === "POLYGON") return "polygon";
1673
+ if (s === "MULTIPOINT") return "multipoint";
1674
+ if (s === "MULTILINESTRING") return "multilinestring";
1675
+ if (s === "MULTIPOLYGON") return "multipolygon";
1676
+ return "polygon";
1677
+ }
1678
+ var EXTENSION_NAMES = {
1679
+ point: "geoarrow.point",
1680
+ linestring: "geoarrow.linestring",
1681
+ polygon: "geoarrow.polygon",
1682
+ multipoint: "geoarrow.multipoint",
1683
+ multilinestring: "geoarrow.multilinestring",
1684
+ multipolygon: "geoarrow.multipolygon"
1685
+ };
1686
+ function readWkbHeader(wkb) {
1687
+ if (wkb.length < 5) return null;
1688
+ const le = wkb[0] === 1;
1689
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1690
+ const rawType = dv.getUint32(1, le);
1691
+ let headerSize = 5;
1692
+ if ((rawType & 536870912) !== 0) headerSize += 4;
1693
+ const ewkbZ = (rawType & 2147483648) !== 0;
1694
+ const ewkbM = (rawType & 1073741824) !== 0;
1695
+ let type = rawType & 268435455;
1696
+ let isoZ = false;
1697
+ let isoM = false;
1698
+ if (type > 3e3) {
1699
+ isoZ = true;
1700
+ isoM = true;
1701
+ type -= 3e3;
1702
+ } else if (type > 2e3) {
1703
+ isoM = true;
1704
+ type -= 2e3;
1705
+ } else if (type > 1e3) {
1706
+ isoZ = true;
1707
+ type -= 1e3;
1708
+ }
1709
+ const dims = (ewkbZ || isoZ ? 1 : 0) + (ewkbM || isoM ? 1 : 0);
1710
+ const coordStride = (2 + dims) * 8;
1711
+ return { type, le, coordStride, dataOffset: headerSize };
1712
+ }
1713
+ function classifyWkbType(wkb) {
1714
+ const h = readWkbHeader(wkb);
1715
+ if (!h) return null;
1716
+ switch (h.type) {
1717
+ case 1:
1718
+ return "point";
1719
+ case 2:
1720
+ return "linestring";
1721
+ case 3:
1722
+ return "polygon";
1723
+ case 4:
1724
+ return "multipoint";
1725
+ case 5:
1726
+ return "multilinestring";
1727
+ case 6:
1728
+ return "multipolygon";
1729
+ default:
1730
+ return null;
1731
+ }
1732
+ }
1733
+ function newBounds() {
1734
+ return { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity };
1735
+ }
1736
+ function expandBounds(b, x, y) {
1737
+ if (Number.isNaN(x) || Number.isNaN(y)) return;
1738
+ if (x < b.minX) b.minX = x;
1739
+ if (y < b.minY) b.minY = y;
1740
+ if (x > b.maxX) b.maxX = x;
1741
+ if (y > b.maxY) b.maxY = y;
1742
+ }
1743
+ var coordField = new Field("xy", new Float64());
1744
+ var coordType = new FixedSizeList(2, coordField);
1745
+ function makeCoordData(coords, numPoints) {
1746
+ const floatData = makeData({ type: new Float64(), length: coords.length, data: coords });
1747
+ return makeData({ type: coordType, length: numPoints, nullCount: 0, child: floatData });
1748
+ }
1749
+ function buildPointData(wkbs, b) {
1750
+ const n = wkbs.length;
1751
+ const coords = new Float64Array(n * 2);
1752
+ for (let i = 0; i < n; i++) {
1753
+ const wkb = wkbs[i];
1754
+ const h = readWkbHeader(wkb);
1755
+ if (!h || h.type !== 1) {
1756
+ coords[i * 2] = 0;
1757
+ coords[i * 2 + 1] = 0;
1758
+ continue;
1759
+ }
1760
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1761
+ const x = dv.getFloat64(h.dataOffset, h.le);
1762
+ const y = dv.getFloat64(h.dataOffset + 8, h.le);
1763
+ coords[i * 2] = x;
1764
+ coords[i * 2 + 1] = y;
1765
+ expandBounds(b, x, y);
1766
+ }
1767
+ return makeCoordData(coords, n);
1768
+ }
1769
+ function buildLineStringData(wkbs, b) {
1770
+ const n = wkbs.length;
1771
+ const geomOffsets = new Int32Array(n + 1);
1772
+ let totalCoords = 0;
1773
+ for (let i = 0; i < n; i++) {
1774
+ geomOffsets[i] = totalCoords;
1775
+ const h = readWkbHeader(wkbs[i]);
1776
+ if (!h || h.type !== 2) continue;
1777
+ const dv = new DataView(wkbs[i].buffer, wkbs[i].byteOffset, wkbs[i].byteLength);
1778
+ const numPts = dv.getUint32(h.dataOffset, h.le);
1779
+ totalCoords += numPts;
1780
+ }
1781
+ geomOffsets[n] = totalCoords;
1782
+ const coords = new Float64Array(totalCoords * 2);
1783
+ let ci = 0;
1784
+ for (const wkb of wkbs) {
1785
+ const h = readWkbHeader(wkb);
1786
+ if (!h || h.type !== 2) continue;
1787
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1788
+ const numPts = dv.getUint32(h.dataOffset, h.le);
1789
+ let off = h.dataOffset + 4;
1790
+ for (let j = 0; j < numPts; j++) {
1791
+ const x = dv.getFloat64(off, h.le);
1792
+ const y = dv.getFloat64(off + 8, h.le);
1793
+ coords[ci++] = x;
1794
+ coords[ci++] = y;
1795
+ expandBounds(b, x, y);
1796
+ off += h.coordStride;
1797
+ }
1798
+ }
1799
+ const fslData = makeCoordData(coords, totalCoords);
1800
+ const listType = new List(new Field("vertices", coordType));
1801
+ return makeData({
1802
+ type: listType,
1803
+ length: n,
1804
+ nullCount: 0,
1805
+ valueOffsets: geomOffsets,
1806
+ child: fslData
1807
+ });
1808
+ }
1809
+ function buildPolygonData(wkbs, b) {
1810
+ const n = wkbs.length;
1811
+ const geomOffsets = new Int32Array(n + 1);
1812
+ let totalRings = 0;
1813
+ let totalCoords = 0;
1814
+ for (let i = 0; i < n; i++) {
1815
+ geomOffsets[i] = totalRings;
1816
+ const h = readWkbHeader(wkbs[i]);
1817
+ if (!h || h.type !== 3) continue;
1818
+ const dv = new DataView(wkbs[i].buffer, wkbs[i].byteOffset, wkbs[i].byteLength);
1819
+ const numRings = dv.getUint32(h.dataOffset, h.le);
1820
+ let off = h.dataOffset + 4;
1821
+ for (let r = 0; r < numRings; r++) {
1822
+ const numPts = dv.getUint32(off, h.le);
1823
+ off += 4 + numPts * h.coordStride;
1824
+ totalCoords += numPts;
1825
+ totalRings++;
1826
+ }
1827
+ }
1828
+ geomOffsets[n] = totalRings;
1829
+ const ringOffsets = new Int32Array(totalRings + 1);
1830
+ const coords = new Float64Array(totalCoords * 2);
1831
+ let ri = 0;
1832
+ let ci = 0;
1833
+ for (const wkb of wkbs) {
1834
+ const h = readWkbHeader(wkb);
1835
+ if (!h || h.type !== 3) continue;
1836
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1837
+ const numRings = dv.getUint32(h.dataOffset, h.le);
1838
+ let off = h.dataOffset + 4;
1839
+ for (let r = 0; r < numRings; r++) {
1840
+ ringOffsets[ri++] = ci >> 1;
1841
+ const numPts = dv.getUint32(off, h.le);
1842
+ off += 4;
1843
+ for (let j = 0; j < numPts; j++) {
1844
+ const x = dv.getFloat64(off, h.le);
1845
+ const y = dv.getFloat64(off + 8, h.le);
1846
+ coords[ci++] = x;
1847
+ coords[ci++] = y;
1848
+ expandBounds(b, x, y);
1849
+ off += h.coordStride;
1850
+ }
1851
+ }
1852
+ }
1853
+ ringOffsets[totalRings] = ci >> 1;
1854
+ const coordCount = ci >> 1;
1855
+ const fslData = makeCoordData(coords, coordCount);
1856
+ const ringListType = new List(new Field("vertices", coordType));
1857
+ const ringListData = makeData({
1858
+ type: ringListType,
1859
+ length: totalRings,
1860
+ nullCount: 0,
1861
+ valueOffsets: ringOffsets,
1862
+ child: fslData
1863
+ });
1864
+ const polyType = new List(new Field("rings", ringListType));
1865
+ return makeData({
1866
+ type: polyType,
1867
+ length: n,
1868
+ nullCount: 0,
1869
+ valueOffsets: geomOffsets,
1870
+ child: ringListData
1871
+ });
1872
+ }
1873
+ function buildMultiPointData(wkbs, b) {
1874
+ const n = wkbs.length;
1875
+ const geomOffsets = new Int32Array(n + 1);
1876
+ let totalCoords = 0;
1877
+ for (let i = 0; i < n; i++) {
1878
+ geomOffsets[i] = totalCoords;
1879
+ const h = readWkbHeader(wkbs[i]);
1880
+ if (!h || h.type !== 4) continue;
1881
+ const dv = new DataView(wkbs[i].buffer, wkbs[i].byteOffset, wkbs[i].byteLength);
1882
+ totalCoords += dv.getUint32(h.dataOffset, h.le);
1883
+ }
1884
+ geomOffsets[n] = totalCoords;
1885
+ const coords = new Float64Array(totalCoords * 2);
1886
+ let ci = 0;
1887
+ for (const wkb of wkbs) {
1888
+ const h = readWkbHeader(wkb);
1889
+ if (!h || h.type !== 4) continue;
1890
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1891
+ const numPts = dv.getUint32(h.dataOffset, h.le);
1892
+ let off = h.dataOffset + 4;
1893
+ for (let j = 0; j < numPts; j++) {
1894
+ const innerH = readWkbHeader(
1895
+ new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1896
+ );
1897
+ if (innerH) {
1898
+ const x = dv.getFloat64(off + innerH.dataOffset, innerH.le);
1899
+ const y = dv.getFloat64(off + innerH.dataOffset + 8, innerH.le);
1900
+ coords[ci++] = x;
1901
+ coords[ci++] = y;
1902
+ expandBounds(b, x, y);
1903
+ off += innerH.dataOffset + innerH.coordStride;
1904
+ } else {
1905
+ coords[ci++] = 0;
1906
+ coords[ci++] = 0;
1907
+ off += 21;
1908
+ }
1909
+ }
1910
+ }
1911
+ const fslData = makeCoordData(coords, totalCoords);
1912
+ const listType = new List(new Field("vertices", coordType));
1913
+ return makeData({
1914
+ type: listType,
1915
+ length: n,
1916
+ nullCount: 0,
1917
+ valueOffsets: geomOffsets,
1918
+ child: fslData
1919
+ });
1920
+ }
1921
+ function buildMultiLineStringData(wkbs, b) {
1922
+ const n = wkbs.length;
1923
+ const geomOffsetsArr = [0];
1924
+ let totalLines = 0;
1925
+ let totalCoords = 0;
1926
+ for (const wkb of wkbs) {
1927
+ const h = readWkbHeader(wkb);
1928
+ if (!h || h.type !== 5) {
1929
+ geomOffsetsArr.push(totalLines);
1930
+ continue;
1931
+ }
1932
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1933
+ const numLines = dv.getUint32(h.dataOffset, h.le);
1934
+ let off = h.dataOffset + 4;
1935
+ for (let l = 0; l < numLines; l++) {
1936
+ const innerH = readWkbHeader(
1937
+ new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1938
+ );
1939
+ if (!innerH) break;
1940
+ const innerDv = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off);
1941
+ const numPts = innerDv.getUint32(innerH.dataOffset, innerH.le);
1942
+ totalCoords += numPts;
1943
+ off += innerH.dataOffset + 4 + numPts * innerH.coordStride;
1944
+ totalLines++;
1945
+ }
1946
+ geomOffsetsArr.push(totalLines);
1947
+ }
1948
+ const geomOffsets = new Int32Array(geomOffsetsArr);
1949
+ const lineOffsets = new Int32Array(totalLines + 1);
1950
+ const coords = new Float64Array(totalCoords * 2);
1951
+ let li = 0;
1952
+ let ci = 0;
1953
+ for (const wkb of wkbs) {
1954
+ const h = readWkbHeader(wkb);
1955
+ if (!h || h.type !== 5) continue;
1956
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
1957
+ const numLines = dv.getUint32(h.dataOffset, h.le);
1958
+ let off = h.dataOffset + 4;
1959
+ for (let l = 0; l < numLines; l++) {
1960
+ lineOffsets[li++] = ci >> 1;
1961
+ const innerH = readWkbHeader(
1962
+ new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
1963
+ );
1964
+ if (!innerH) break;
1965
+ const numPts = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off).getUint32(
1966
+ innerH.dataOffset,
1967
+ innerH.le
1968
+ );
1969
+ let ptOff = off + innerH.dataOffset + 4;
1970
+ for (let j = 0; j < numPts; j++) {
1971
+ const x = dv.getFloat64(ptOff, innerH.le);
1972
+ const y = dv.getFloat64(ptOff + 8, innerH.le);
1973
+ coords[ci++] = x;
1974
+ coords[ci++] = y;
1975
+ expandBounds(b, x, y);
1976
+ ptOff += innerH.coordStride;
1977
+ }
1978
+ off = ptOff;
1979
+ }
1980
+ }
1981
+ lineOffsets[totalLines] = ci >> 1;
1982
+ const fslData = makeCoordData(coords, ci >> 1);
1983
+ const lineListType = new List(new Field("vertices", coordType));
1984
+ const lineListData = makeData({
1985
+ type: lineListType,
1986
+ length: totalLines,
1987
+ nullCount: 0,
1988
+ valueOffsets: lineOffsets,
1989
+ child: fslData
1990
+ });
1991
+ const multiLineType = new List(new Field("lines", lineListType));
1992
+ return makeData({
1993
+ type: multiLineType,
1994
+ length: n,
1995
+ nullCount: 0,
1996
+ valueOffsets: geomOffsets,
1997
+ child: lineListData
1998
+ });
1999
+ }
2000
+ function buildMultiPolygonData(wkbs, b) {
2001
+ const n = wkbs.length;
2002
+ const geomOffsetsArr = [0];
2003
+ let totalPolys = 0;
2004
+ let totalRings = 0;
2005
+ let totalCoords = 0;
2006
+ for (const wkb of wkbs) {
2007
+ const h = readWkbHeader(wkb);
2008
+ if (!h || h.type !== 6) {
2009
+ geomOffsetsArr.push(totalPolys);
2010
+ continue;
2011
+ }
2012
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
2013
+ const numPolys = dv.getUint32(h.dataOffset, h.le);
2014
+ let off = h.dataOffset + 4;
2015
+ for (let p = 0; p < numPolys; p++) {
2016
+ const innerH = readWkbHeader(
2017
+ new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
2018
+ );
2019
+ if (!innerH) break;
2020
+ const innerDv = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off);
2021
+ const numRings = innerDv.getUint32(innerH.dataOffset, innerH.le);
2022
+ let ringOff = innerH.dataOffset + 4;
2023
+ for (let r = 0; r < numRings; r++) {
2024
+ const numPts = innerDv.getUint32(ringOff, innerH.le);
2025
+ ringOff += 4 + numPts * innerH.coordStride;
2026
+ totalCoords += numPts;
2027
+ totalRings++;
2028
+ }
2029
+ off += ringOff;
2030
+ totalPolys++;
2031
+ }
2032
+ geomOffsetsArr.push(totalPolys);
2033
+ }
2034
+ const geomOffsets = new Int32Array(geomOffsetsArr);
2035
+ const polyOffsets = new Int32Array(totalPolys + 1);
2036
+ const ringOffsets = new Int32Array(totalRings + 1);
2037
+ const coords = new Float64Array(totalCoords * 2);
2038
+ let pi = 0;
2039
+ let ri = 0;
2040
+ let ci = 0;
2041
+ for (const wkb of wkbs) {
2042
+ const h = readWkbHeader(wkb);
2043
+ if (!h || h.type !== 6) continue;
2044
+ const dv = new DataView(wkb.buffer, wkb.byteOffset, wkb.byteLength);
2045
+ const numPolys = dv.getUint32(h.dataOffset, h.le);
2046
+ let off = h.dataOffset + 4;
2047
+ for (let p = 0; p < numPolys; p++) {
2048
+ polyOffsets[pi++] = ri;
2049
+ const innerH = readWkbHeader(
2050
+ new Uint8Array(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off)
2051
+ );
2052
+ if (!innerH) break;
2053
+ const innerDv = new DataView(wkb.buffer, wkb.byteOffset + off, wkb.byteLength - off);
2054
+ const numRings = innerDv.getUint32(innerH.dataOffset, innerH.le);
2055
+ let ringOff = off + innerH.dataOffset + 4;
2056
+ for (let r = 0; r < numRings; r++) {
2057
+ ringOffsets[ri++] = ci >> 1;
2058
+ const numPts = dv.getUint32(ringOff, innerH.le);
2059
+ ringOff += 4;
2060
+ for (let j = 0; j < numPts; j++) {
2061
+ const x = dv.getFloat64(ringOff, innerH.le);
2062
+ const y = dv.getFloat64(ringOff + 8, innerH.le);
2063
+ coords[ci++] = x;
2064
+ coords[ci++] = y;
2065
+ expandBounds(b, x, y);
2066
+ ringOff += innerH.coordStride;
2067
+ }
2068
+ }
2069
+ off = ringOff;
2070
+ }
2071
+ }
2072
+ polyOffsets[totalPolys] = ri;
2073
+ ringOffsets[totalRings] = ci >> 1;
2074
+ const fslData = makeCoordData(coords, ci >> 1);
2075
+ const ringListType = new List(new Field("vertices", coordType));
2076
+ const ringListData = makeData({
2077
+ type: ringListType,
2078
+ length: totalRings,
2079
+ nullCount: 0,
2080
+ valueOffsets: ringOffsets,
2081
+ child: fslData
2082
+ });
2083
+ const polyListType = new List(new Field("rings", ringListType));
2084
+ const polyListData = makeData({
2085
+ type: polyListType,
2086
+ length: totalPolys,
2087
+ nullCount: 0,
2088
+ valueOffsets: polyOffsets,
2089
+ child: ringListData
2090
+ });
2091
+ const multiPolyType = new List(new Field("polygons", polyListType));
2092
+ return makeData({
2093
+ type: multiPolyType,
2094
+ length: n,
2095
+ nullCount: 0,
2096
+ valueOffsets: geomOffsets,
2097
+ child: polyListData
2098
+ });
2099
+ }
2100
+ function buildAttributeColumns(indices, attributes) {
2101
+ const n = indices.length;
2102
+ const fields = [];
2103
+ const dataArr = [];
2104
+ for (const [name, col] of attributes) {
2105
+ const { values } = col;
2106
+ let isNumeric = true;
2107
+ const sampleEnd = Math.min(n, 100);
2108
+ for (let i = 0; i < sampleEnd; i++) {
2109
+ if (values[indices[i]] != null && typeof values[indices[i]] !== "number") {
2110
+ isNumeric = false;
2111
+ break;
2112
+ }
2113
+ }
2114
+ if (isNumeric) {
2115
+ const arr = new Float64Array(n);
2116
+ for (let i = 0; i < n; i++) arr[i] = values[indices[i]] ?? NaN;
2117
+ const data = makeData({ type: new Float64(), length: n, data: arr });
2118
+ fields.push(new Field(name, new Float64(), true));
2119
+ dataArr.push(data);
2120
+ } else {
2121
+ const encoder = new TextEncoder();
2122
+ const offsets = new Int32Array(n + 1);
2123
+ let totalBytes = 0;
2124
+ const strParts = [];
2125
+ for (let i = 0; i < n; i++) {
2126
+ offsets[i] = totalBytes;
2127
+ const s = values[indices[i]] != null ? String(values[indices[i]]) : "";
2128
+ const encoded = encoder.encode(s);
2129
+ strParts.push(encoded);
2130
+ totalBytes += encoded.length;
2131
+ }
2132
+ offsets[n] = totalBytes;
2133
+ const valueBuffer = new Uint8Array(totalBytes);
2134
+ let pos = 0;
2135
+ for (const sv of strParts) {
2136
+ valueBuffer.set(sv, pos);
2137
+ pos += sv.length;
2138
+ }
2139
+ const data = makeData({
2140
+ type: new Utf8(),
2141
+ length: n,
2142
+ valueOffsets: offsets,
2143
+ data: valueBuffer
2144
+ });
2145
+ fields.push(new Field(name, new Utf8(), true));
2146
+ dataArr.push(data);
2147
+ }
2148
+ }
2149
+ return { fields, data: dataArr };
2150
+ }
2151
+ function buildSingleTable(geomType, wkbs, indices, attributes, b) {
2152
+ const n = wkbs.length;
2153
+ let geomData;
2154
+ switch (geomType) {
2155
+ case "point":
2156
+ geomData = buildPointData(wkbs, b);
2157
+ break;
2158
+ case "linestring":
2159
+ geomData = buildLineStringData(wkbs, b);
2160
+ break;
2161
+ case "polygon":
2162
+ geomData = buildPolygonData(wkbs, b);
2163
+ break;
2164
+ case "multipoint":
2165
+ geomData = buildMultiPointData(wkbs, b);
2166
+ break;
2167
+ case "multilinestring":
2168
+ geomData = buildMultiLineStringData(wkbs, b);
2169
+ break;
2170
+ case "multipolygon":
2171
+ geomData = buildMultiPolygonData(wkbs, b);
2172
+ break;
2173
+ }
2174
+ const extensionName = EXTENSION_NAMES[geomType];
2175
+ const geomMetadata = /* @__PURE__ */ new Map([
2176
+ ["ARROW:extension:name", extensionName],
2177
+ [
2178
+ "ARROW:extension:metadata",
2179
+ JSON.stringify({
2180
+ crs: {
2181
+ type: "name",
2182
+ properties: { name: "urn:ogc:def:crs:OGC:1.3:CRS84" }
2183
+ }
2184
+ })
2185
+ ]
2186
+ ]);
2187
+ const geomField = new Field("geometry", geomData.type, false, geomMetadata);
2188
+ const attrCols = buildAttributeColumns(indices, attributes);
2189
+ const fields = [geomField, ...attrCols.fields];
2190
+ const childrenData = [geomData, ...attrCols.data];
2191
+ const arrowSchema = new Schema(fields);
2192
+ const structType = new Struct(fields);
2193
+ const structData = makeData({
2194
+ type: structType,
2195
+ length: n,
2196
+ nullCount: 0,
2197
+ children: childrenData
2198
+ });
2199
+ const batch = new RecordBatch(arrowSchema, structData);
2200
+ const table = new Table(arrowSchema, batch);
2201
+ return {
2202
+ table,
2203
+ geometryType: geomType,
2204
+ bounds: [b.minX, b.minY, b.maxX, b.maxY],
2205
+ sourceIndices: indices
2206
+ };
2207
+ }
2208
+ function buildGeoArrowTables(wkbArrays, attributes, knownGeomType) {
2209
+ if (wkbArrays.length === 0) return [];
2210
+ if (knownGeomType) {
2211
+ const globalBounds2 = newBounds();
2212
+ const indices = Array.from({ length: wkbArrays.length }, (_, i) => i);
2213
+ const result = buildSingleTable(knownGeomType, wkbArrays, indices, attributes, globalBounds2);
2214
+ return [result];
2215
+ }
2216
+ const groups = /* @__PURE__ */ new Map();
2217
+ for (let i = 0; i < wkbArrays.length; i++) {
2218
+ const geomType = classifyWkbType(wkbArrays[i]);
2219
+ if (!geomType) continue;
2220
+ let group = groups.get(geomType);
2221
+ if (!group) {
2222
+ group = { wkbs: [], indices: [] };
2223
+ groups.set(geomType, group);
2224
+ }
2225
+ group.wkbs.push(wkbArrays[i]);
2226
+ group.indices.push(i);
2227
+ }
2228
+ if (groups.size === 0) return [];
2229
+ const globalBounds = newBounds();
2230
+ const results = [];
2231
+ for (const [geomType, { wkbs, indices }] of groups) {
2232
+ const result = buildSingleTable(geomType, wkbs, indices, attributes, globalBounds);
2233
+ results.push(result);
2234
+ }
2235
+ const mergedBounds = [
2236
+ globalBounds.minX,
2237
+ globalBounds.minY,
2238
+ globalBounds.maxX,
2239
+ globalBounds.maxY
2240
+ ];
2241
+ for (const r of results) r.bounds = mergedBounds;
2242
+ return results;
2243
+ }
2244
+
2245
+ // ../../src/lib/utils/hex.ts
2246
+ function generateHexDump(data, bytesPerRow = 16) {
2247
+ const rows = [];
2248
+ for (let i = 0; i < data.length; i += bytesPerRow) {
2249
+ const slice = data.slice(i, i + bytesPerRow);
2250
+ const offset = i.toString(16).padStart(8, "0");
2251
+ const hex = [];
2252
+ for (let j = 0; j < bytesPerRow; j++) {
2253
+ if (j < slice.length) {
2254
+ hex.push(slice[j].toString(16).padStart(2, "0"));
2255
+ } else {
2256
+ hex.push(" ");
2257
+ }
2258
+ }
2259
+ let ascii = "";
2260
+ for (let j = 0; j < slice.length; j++) {
2261
+ const byte = slice[j];
2262
+ ascii += byte >= 32 && byte <= 126 ? String.fromCharCode(byte) : ".";
2263
+ }
2264
+ rows.push({ offset, hex, ascii });
2265
+ }
2266
+ return rows;
2267
+ }
2268
+
2269
+ // ../../src/lib/utils/local-storage.ts
2270
+ function loadFromStorage(key, defaultValue) {
2271
+ if (typeof window === "undefined") return defaultValue;
2272
+ try {
2273
+ const raw = localStorage.getItem(key);
2274
+ if (raw) return JSON.parse(raw);
2275
+ } catch {
2276
+ }
2277
+ return defaultValue;
2278
+ }
2279
+ function persistToStorage(key, value) {
2280
+ if (typeof window === "undefined") return;
2281
+ try {
2282
+ localStorage.setItem(key, JSON.stringify(value));
2283
+ } catch {
2284
+ }
2285
+ }
2286
+ function parseMarkdownDocument(markdown) {
2287
+ let frontmatter = {};
2288
+ let content = markdown;
2289
+ const fmMatch = markdown.match(/^---\n([\s\S]*?)\n---\n/);
2290
+ if (fmMatch) {
2291
+ try {
2292
+ frontmatter = YAML.parse(fmMatch[1]) || {};
2293
+ } catch {
2294
+ }
2295
+ content = markdown.slice(fmMatch[0].length);
2296
+ }
2297
+ const sqlBlocks = [];
2298
+ const lines = content.split("\n");
2299
+ let i = 0;
2300
+ while (i < lines.length) {
2301
+ const line = lines[i];
2302
+ const match = line.match(/^```sql\s+(\w[\w-]*)\s*$/);
2303
+ if (match) {
2304
+ const name = match[1];
2305
+ const startLine = i;
2306
+ const sqlLines = [];
2307
+ i++;
2308
+ while (i < lines.length && lines[i] !== "```") {
2309
+ sqlLines.push(lines[i]);
2310
+ i++;
2311
+ }
2312
+ sqlBlocks.push({
2313
+ name,
2314
+ sql: sqlLines.join("\n"),
2315
+ startLine,
2316
+ endLine: i
2317
+ });
2318
+ }
2319
+ i++;
2320
+ }
2321
+ return { frontmatter, content, sqlBlocks };
2322
+ }
2323
+ function interpolateTemplates(text, queryResults) {
2324
+ return text.replace(/\{(\w+)\.rows\[(\d+)\]\.(\w+)\}/g, (match, queryName, rowIdx, colName) => {
2325
+ const rows = queryResults.get(queryName);
2326
+ if (!rows) return match;
2327
+ const row = rows[parseInt(rowIdx, 10)];
2328
+ if (!row) return match;
2329
+ const value = row[colName];
2330
+ return value !== void 0 ? String(value) : match;
2331
+ });
2332
+ }
2333
+ function markSqlBlocks(content) {
2334
+ return content.replace(
2335
+ /```sql\s+(\w[\w-]*)\s*\n([\s\S]*?)```/g,
2336
+ (_, name) => `<div data-sql-block="${name}"></div>`
2337
+ );
2338
+ }
2339
+
2340
+ // ../../src/lib/utils/parquet-metadata.ts
2341
+ function mapParquetType(col) {
2342
+ const lt = col.logical_type;
2343
+ if (lt) {
2344
+ if (lt.type === "GEOMETRY" || lt.type === "GEOGRAPHY") return "GEOMETRY";
2345
+ if (lt.type === "STRING" || lt.type === "UTF8") return "VARCHAR";
2346
+ if (lt.type === "JSON") return "JSON";
2347
+ if (lt.type === "UUID") return "UUID";
2348
+ if (lt.type === "ENUM") return "VARCHAR";
2349
+ if (lt.type === "INT" || lt.type === "INTEGER") {
2350
+ const bits = lt.bitWidth ?? 32;
2351
+ const signed = lt.isSigned !== false;
2352
+ if (bits <= 8) return signed ? "TINYINT" : "UTINYINT";
2353
+ if (bits <= 16) return signed ? "SMALLINT" : "USMALLINT";
2354
+ if (bits <= 32) return signed ? "INTEGER" : "UINTEGER";
2355
+ return signed ? "BIGINT" : "UBIGINT";
2356
+ }
2357
+ if (lt.type === "DECIMAL") return `DECIMAL(${lt.precision ?? 18},${lt.scale ?? 0})`;
2358
+ if (lt.type === "DATE") return "DATE";
2359
+ if (lt.type === "TIME") return "TIME";
2360
+ if (lt.type === "TIMESTAMP") return "TIMESTAMP";
2361
+ if (lt.type === "BSON") return "BLOB";
2362
+ }
2363
+ const ct = col.converted_type;
2364
+ if (ct === "UTF8") return "VARCHAR";
2365
+ if (ct === "JSON") return "JSON";
2366
+ if (ct === "DATE") return "DATE";
2367
+ if (ct === "TIMESTAMP_MILLIS" || ct === "TIMESTAMP_MICROS") return "TIMESTAMP";
2368
+ if (ct === "DECIMAL") return `DECIMAL(${col.precision ?? 18},${col.scale ?? 0})`;
2369
+ if (ct === "INT_8") return "TINYINT";
2370
+ if (ct === "INT_16") return "SMALLINT";
2371
+ if (ct === "INT_32") return "INTEGER";
2372
+ if (ct === "INT_64") return "BIGINT";
2373
+ if (ct === "UINT_8") return "UTINYINT";
2374
+ if (ct === "UINT_16") return "USMALLINT";
2375
+ if (ct === "UINT_32") return "UINTEGER";
2376
+ if (ct === "UINT_64") return "UBIGINT";
2377
+ const pt = col.type;
2378
+ if (pt === "BOOLEAN") return "BOOLEAN";
2379
+ if (pt === "INT32") return "INTEGER";
2380
+ if (pt === "INT64") return "BIGINT";
2381
+ if (pt === "INT96") return "TIMESTAMP";
2382
+ if (pt === "FLOAT") return "FLOAT";
2383
+ if (pt === "DOUBLE") return "DOUBLE";
2384
+ if (pt === "BYTE_ARRAY") return "BLOB";
2385
+ if (pt === "FIXED_LEN_BYTE_ARRAY") return "BLOB";
2386
+ return "VARCHAR";
2387
+ }
2388
+ async function readParquetMetadata(url) {
2389
+ const { parquetMetadataAsync, asyncBufferFromUrl } = await import('hyparquet');
2390
+ const file = await asyncBufferFromUrl({ url });
2391
+ const metadata = await parquetMetadataAsync(file);
2392
+ const rowCount = metadata.row_groups.reduce(
2393
+ (sum, rg) => sum + Number(rg.num_rows),
2394
+ 0
2395
+ );
2396
+ const schema = metadata.schema.slice(1).filter((col) => col.num_children === void 0).map((col) => ({
2397
+ name: col.name,
2398
+ type: mapParquetType(col)
2399
+ }));
2400
+ let geo = null;
2401
+ let legacyGeoParquet = false;
2402
+ const geoKv = metadata.key_value_metadata?.find((kv) => kv.key === "geo");
2403
+ if (geoKv) {
2404
+ try {
2405
+ const geoJson = JSON.parse(geoKv.value ?? "");
2406
+ if (geoJson.schema_version && !geoJson.version) {
2407
+ legacyGeoParquet = true;
2408
+ }
2409
+ geo = {
2410
+ primaryColumn: geoJson.primary_column ?? "geometry",
2411
+ columns: {}
2412
+ };
2413
+ if (geoJson.columns) {
2414
+ for (const [colName, colMeta] of Object.entries(geoJson.columns)) {
2415
+ geo.columns[colName] = {
2416
+ encoding: colMeta.encoding ?? "WKB",
2417
+ geometryTypes: colMeta.geometry_types ?? [],
2418
+ crs: colMeta.crs ?? null,
2419
+ bbox: colMeta.bbox
2420
+ };
2421
+ }
2422
+ }
2423
+ } catch {
2424
+ }
2425
+ }
2426
+ const createdBy = metadata.created_by ?? null;
2427
+ const numRowGroups = metadata.row_groups.length;
2428
+ let compression = null;
2429
+ if (numRowGroups > 0 && metadata.row_groups[0].columns) {
2430
+ const codecs = /* @__PURE__ */ new Set();
2431
+ for (const col of metadata.row_groups[0].columns) {
2432
+ const codec = col.meta_data?.codec;
2433
+ if (codec) codecs.add(codec);
2434
+ }
2435
+ if (codecs.size === 1) {
2436
+ compression = [...codecs][0];
2437
+ } else if (codecs.size > 1) {
2438
+ compression = [...codecs].join(", ");
2439
+ }
2440
+ }
2441
+ return { rowCount, schema, geo, legacyGeoParquet, createdBy, numRowGroups, compression };
2442
+ }
2443
+ function extractEpsgFromGeoMeta(geo) {
2444
+ const primaryCol = geo.columns[geo.primaryColumn];
2445
+ if (!primaryCol?.crs) return null;
2446
+ const crs = primaryCol.crs;
2447
+ if (crs.type === "name" && crs.properties?.name?.includes("CRS84")) return null;
2448
+ if (crs.id?.authority === "EPSG") {
2449
+ const code = crs.id.code;
2450
+ if (WGS84_CODES.has(code)) return null;
2451
+ return `EPSG:${code}`;
2452
+ }
2453
+ return null;
2454
+ }
2455
+ function extractGeometryTypes(geo) {
2456
+ const primaryCol = geo.columns[geo.primaryColumn];
2457
+ if (!primaryCol?.geometryTypes?.length) return [];
2458
+ const typeMap = {
2459
+ Point: "point",
2460
+ LineString: "linestring",
2461
+ Polygon: "polygon",
2462
+ MultiPoint: "multipoint",
2463
+ MultiLineString: "multilinestring",
2464
+ MultiPolygon: "multipolygon"
2465
+ };
2466
+ const types = [];
2467
+ for (const raw of primaryCol.geometryTypes) {
2468
+ const base = raw.split(" ")[0];
2469
+ const mapped = typeMap[base];
2470
+ if (mapped && !types.includes(mapped)) types.push(mapped);
2471
+ }
2472
+ return types;
2473
+ }
2474
+ function extractBounds(geo) {
2475
+ const primaryCol = geo.columns[geo.primaryColumn];
2476
+ if (!primaryCol?.bbox || primaryCol.bbox.length < 4) return null;
2477
+ return [primaryCol.bbox[0], primaryCol.bbox[1], primaryCol.bbox[2], primaryCol.bbox[3]];
2478
+ }
2273
2479
 
2274
2480
  // ../../src/lib/utils/storage-url.ts
2275
2481
  function buildSchemeMap() {
@@ -2847,6 +3053,6 @@ function isWKT(value) {
2847
3053
  return WKT_TYPES.some((t) => s.startsWith(t) || s.startsWith(`MULTI${t}`));
2848
3054
  }
2849
3055
 
2850
- export { COPY_FEEDBACK_MS, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, LAYER_HUE_MULTIPLIER, MAX_QUERY_HISTORY_ENTRIES, QueryCancelledError, SQL_PREVIEW_LENGTH, STORAGE_KEYS, UrlAdapter, VIEWER_DIR_EXTENSIONS, WGS84_CODES, buildDuckDbSource, buildGeoArrowTables, classifyType, describeParseResult, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, formatValue, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getViewerKind, handleLoadError, isCloudNativeFormat, isQueryable, jsonReplacerBigInt, looksLikeUrl, normalizeGeomType, parseStorageUrl, parseWKB, readParquetMetadata, toBinary, typeBadgeClass, typeColor, typeLabel };
3056
+ export { COPY_FEEDBACK_MS, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, LAYER_HUE_MULTIPLIER, MAX_QUERY_HISTORY_ENTRIES, PROVIDERS, PROVIDER_IDS, QueryCancelledError, SQL_PREVIEW_LENGTH, STORAGE_KEYS, UrlAdapter, VIEWER_DIR_EXTENSIONS, WGS84_CODES, buildDuckDbSource, buildEndpointFromTemplate, buildGeoArrowTables, buildProviderBaseUrl, classifyType, describeParseResult, escapeCsvField, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, formatValue, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getNativeScheme, getProvider, getViewerKind, handleLoadError, interpolateTemplates, isCloudNativeFormat, isGcsProvider, isQueryable, jsonReplacerBigInt, loadFromStorage, looksLikeUrl, markSqlBlocks, normalizeGeomType, parseMarkdownDocument, parseStorageUrl, parseWKB, persistToStorage, readParquetMetadata, resolveCloudUrl, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
2851
3057
  //# sourceMappingURL=index.js.map
2852
3058
  //# sourceMappingURL=index.js.map