@margoengine/points 0.1.0 → 1.0.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/laz.js CHANGED
@@ -1,6 +1,7 @@
1
- import { MargoError as e } from "@margoengine/math/errors";
1
+ import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./laz-model-DCphHLqH.js";
2
+ import { MargoError as d } from "@margoengine/math/errors";
2
3
  //#region src/laz.ts
3
- var t = [
4
+ var f = [
4
5
  "BYTE",
5
6
  "SHORT",
6
7
  "INT",
@@ -16,122 +17,79 @@ var t = [
16
17
  "RGBNIR14",
17
18
  "WAVEPACKET14",
18
19
  "BYTE14"
19
- ], n = 0, r = 6, i = 7, a = 8, o = 9, s = 10, c = 11, l = 12, u = 13, d = 14, f = 4294967295;
20
- function p(e) {
21
- let n = e.find((e) => e.userId === "laszip encoded" && e.recordId === 22204);
22
- if (!n) throw TypeError("LAZ file has no LASzip record (user id \"laszip encoded\", record 22204); the file is corrupt or not LAZ");
23
- let r = n.data, i = new DataView(r.buffer, r.byteOffset, r.byteLength);
24
- if (r.byteLength < 34) throw TypeError("LASzip record is shorter than 34 bytes; the file is corrupt");
25
- let a = i.getUint16(32, !0);
26
- if (r.byteLength < 34 + a * 6) throw TypeError(`LASzip record lists ${a} items but holds fewer; the file is corrupt`);
27
- let o = [];
28
- for (let e = 0; e < a; e++) {
29
- let n = i.getUint16(34 + e * 6, !0);
30
- o.push({
31
- type: n,
32
- name: t[n] ?? `item ${n}`,
33
- size: i.getUint16(36 + e * 6, !0),
34
- version: i.getUint16(38 + e * 6, !0)
20
+ ], p = 0, m = 6, h = 7, g = 8, _ = 9, v = 10, y = 11, b = 12, x = 13, S = 14, C = 4294967295;
21
+ function w(e) {
22
+ let t = e.find((e) => e.userId === "laszip encoded" && e.recordId === 22204);
23
+ if (!t) throw TypeError("LAZ file has no LASzip record (user id \"laszip encoded\", record 22204); the file is corrupt or not LAZ");
24
+ let n = t.data, r = new DataView(n.buffer, n.byteOffset, n.byteLength);
25
+ if (n.byteLength < 34) throw TypeError("LASzip record is shorter than 34 bytes; the file is corrupt");
26
+ let i = r.getUint16(32, !0);
27
+ if (n.byteLength < 34 + i * 6) throw TypeError(`LASzip record lists ${i} items but holds fewer; the file is corrupt`);
28
+ let a = [];
29
+ for (let e = 0; e < i; e++) {
30
+ let t = r.getUint16(34 + e * 6, !0);
31
+ a.push({
32
+ type: t,
33
+ name: f[t] ?? `item ${t}`,
34
+ size: r.getUint16(36 + e * 6, !0),
35
+ version: r.getUint16(38 + e * 6, !0)
35
36
  });
36
37
  }
37
- let s = i.getUint32(12, !0), c = i.getUint16(0, !0);
38
+ let o = r.getUint32(12, !0), s = r.getUint16(0, !0);
38
39
  return {
39
- compressor: c,
40
- coder: i.getUint16(2, !0),
41
- version: `${i.getUint8(4)}.${i.getUint8(5)}.${i.getUint16(6, !0)}`,
42
- options: i.getUint32(8, !0),
43
- chunkSize: s === f || s === 0 && c >= 2 ? "variable" : s,
44
- items: o
40
+ compressor: s,
41
+ coder: r.getUint16(2, !0),
42
+ version: `${r.getUint8(4)}.${r.getUint8(5)}.${r.getUint16(6, !0)}`,
43
+ options: r.getUint32(8, !0),
44
+ chunkSize: o === C || o === 0 && s >= 2 ? "variable" : o,
45
+ items: a
45
46
  };
46
47
  }
47
- function m(e, t) {
48
- return t ? [s, ...e === 7 ? [c] : e === 8 || e === 10 ? [l] : []].concat(e === 9 || e === 10 ? [u] : []) : [
49
- r,
48
+ function T(e, t) {
49
+ return t ? [v, ...e === 7 ? [y] : e === 8 || e === 10 ? [b] : []].concat(e === 9 || e === 10 ? [x] : []) : [
50
+ m,
50
51
  ...[
51
52
  1,
52
53
  3,
53
54
  4,
54
55
  5
55
- ].includes(e) ? [i] : [],
56
+ ].includes(e) ? [h] : [],
56
57
  ...[
57
58
  2,
58
59
  3,
59
60
  5
60
- ].includes(e) ? [a] : [],
61
- ...e === 4 || e === 5 ? [o] : []
61
+ ].includes(e) ? [g] : [],
62
+ ...e === 4 || e === 5 ? [_] : []
62
63
  ];
63
64
  }
64
- var h = (t) => new e("unsupported", `LAZ ${t} is not supported by this decoder; decompress the file to LAS first (for example with laszip or PDAL)`);
65
- function g(e, t) {
66
- if (e.coder !== 0) throw h(`coder ${e.coder} (only arithmetic coding, 0, is defined)`);
67
- if (e.compressor > 3) throw h(`compressor ${e.compressor}`);
65
+ var E = (e) => new d("unsupported", `LAZ ${e} is not supported by this decoder; decompress the file to LAS first (for example with laszip or PDAL)`);
66
+ function D(e, t) {
67
+ if (e.coder !== 0) throw E(`coder ${e.coder} (only arithmetic coding, 0, is defined)`);
68
+ if (e.compressor > 3) throw E(`compressor ${e.compressor}`);
68
69
  if (e.compressor === 0) return;
69
- let f = e.compressor === 3, p = t.pointFormat;
70
- if (f !== p >= 6) throw h(`point format ${p} with compressor ${e.compressor} (formats 0 to 5 use 1 or 2, formats 6 to 10 use 3)`);
71
- let g = m(p, f), _ = e.items.map((e) => e.type), v = _.slice(g.length), y = e.items.reduce((e, t) => e + t.size, 0), b = f ? d : n;
72
- if (g.some((e, t) => _[t] !== e) || v.some((e) => e !== b) || y !== t.pointRecordLength) throw TypeError(`LASzip items ${e.items.map((e) => `${e.name}(${e.size})`).join(" ")} do not match point format ${p} with ${t.pointRecordLength}-byte records; the file is corrupt`);
73
- let x = {
74
- [r]: 20,
75
- [i]: 8,
76
- [a]: 6,
77
- [s]: 30,
78
- [c]: 6,
79
- [l]: 8,
80
- [o]: 29,
81
- [u]: 29
70
+ let n = e.compressor === 3, r = t.pointFormat;
71
+ if (n !== r >= 6) throw E(`point format ${r} with compressor ${e.compressor} (formats 0 to 5 use 1 or 2, formats 6 to 10 use 3)`);
72
+ let i = T(r, n), a = e.items.map((e) => e.type), o = a.slice(i.length), s = e.items.reduce((e, t) => e + t.size, 0), c = n ? S : p;
73
+ if (i.some((e, t) => a[t] !== e) || o.some((e) => e !== c) || s !== t.pointRecordLength) throw TypeError(`LASzip items ${e.items.map((e) => `${e.name}(${e.size})`).join(" ")} do not match point format ${r} with ${t.pointRecordLength}-byte records; the file is corrupt`);
74
+ let l = {
75
+ [m]: 20,
76
+ [h]: 8,
77
+ [g]: 6,
78
+ [v]: 30,
79
+ [y]: 6,
80
+ [b]: 8,
81
+ [_]: 29,
82
+ [x]: 29
82
83
  };
83
84
  for (let t of e.items) {
84
- if (x[t.type] !== void 0 && x[t.type] !== t.size) throw TypeError(`LASzip item ${t.name} has size ${t.size}, not ${x[t.type]}; the file is corrupt`);
85
- let e = f ? 3 : t.type === o ? 1 : 2;
86
- if (t.version !== e) throw h(t.version === 1 && e === 2 ? `item ${t.name} version 1 (the coding of LASzip 1.0, which neither the LAZ specification 1.4 nor the LASzip paper describes, so a clean room decoder has nothing to follow)` : `item ${t.name} version ${t.version} (this decoder reads version ${e}, what LASzip 2 and 3 write)`);
85
+ if (l[t.type] !== void 0 && l[t.type] !== t.size) throw TypeError(`LASzip item ${t.name} has size ${t.size}, not ${l[t.type]}; the file is corrupt`);
86
+ let e = n ? 3 : t.type === _ ? 1 : 2;
87
+ if (t.version !== e) throw E(t.version === 1 && e === 2 ? `item ${t.name} version 1 (the coding of LASzip 1.0, which neither the LAZ specification 1.4 nor the LASzip paper describes, so a clean room decoder has nothing to follow)` : `item ${t.name} version ${t.version} (this decoder reads version ${e}, what LASzip 2 and 3 write)`);
87
88
  }
88
89
  }
89
- var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
90
+ var ee = /* @__PURE__ */ new Uint8Array(), O = class {
90
91
  constructor() {
91
- this.prob = 0, this.zeros = 0, this.total = 0, this.cycle = 0, this.until = 0, this.reset();
92
- }
93
- reset() {
94
- this.zeros = 1, this.total = 2, this.prob = 4096, this.cycle = this.until = 4;
95
- }
96
- update() {
97
- (this.total += this.cycle) > y && (this.total = this.total + 1 >>> 1, this.zeros = this.zeros + 1 >>> 1, this.zeros === this.total && this.total++);
98
- let e = Math.floor(2147483648 / this.total);
99
- this.prob = Math.floor(this.zeros * e / 2 ** 18), this.cycle = Math.min(5 * this.cycle >>> 2, 64), this.until = this.cycle;
100
- }
101
- }, C = class {
102
- constructor(e) {
103
- if (this.total = 0, this.cycle = 0, this.until = 0, this.symbols = e, this.last = e - 1, this.dist = new Uint32Array(e), this.counts = new Uint32Array(e), e > 16) {
104
- let t = 3;
105
- for (; e > 1 << t + 2;) t++;
106
- this.tableSize = 1 << t, this.tableShift = b - t, this.table = new Uint32Array(this.tableSize + 2);
107
- } else this.tableSize = 0, this.tableShift = 0;
108
- this.reset();
109
- }
110
- reset() {
111
- this.total = 0, this.cycle = this.symbols, this.counts.fill(1), this.update(), this.cycle = this.until = this.symbols + 6 >>> 1;
112
- }
113
- update() {
114
- let { counts: e, dist: t, symbols: n } = this;
115
- if ((this.total += this.cycle) > x) {
116
- let t = 0;
117
- for (let r = 0; r < n; r++) t += e[r] = e[r] + 1 >>> 1;
118
- this.total = t;
119
- }
120
- let r = Math.floor(2147483648 / this.total), i = 2 ** 16, a = 0, o = this.table;
121
- if (o) {
122
- let s = 0;
123
- for (let c = 0; c < n; c++) {
124
- t[c] = Math.floor(r * a / i), a += e[c];
125
- let n = t[c] >>> this.tableShift;
126
- for (; s < n;) o[++s] = c - 1;
127
- }
128
- for (o[0] = 0; s <= this.tableSize;) o[++s] = n - 1;
129
- } else for (let o = 0; o < n; o++) t[o] = Math.floor(r * a / i), a += e[o];
130
- this.cycle = Math.min(5 * this.cycle >>> 2, n + 6 << 3), this.until = this.cycle;
131
- }
132
- }, w = /* @__PURE__ */ new Uint8Array(), T = class {
133
- constructor() {
134
- this.bytes = w, this.at = 0, this.end = 0, this.over = 0, this.value = 0, this.length = 0, this.label = "";
92
+ this.bytes = ee, this.at = 0, this.end = 0, this.over = 0, this.value = 0, this.length = 0, this.label = "";
135
93
  }
136
94
  init(e, t, n, r) {
137
95
  if (this.bytes = e, this.at = t, this.end = n, this.over = 0, this.label = r, this.length = 4294967295, this.value = this.byte() * 16777216 + this.byte() * 65536 + this.byte() * 256 + this.byte(), this.value === 4294967295) throw RangeError(`LAZ ${r} starts with an invalid code; the file is corrupt`);
@@ -144,14 +102,14 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
144
102
  renorm() {
145
103
  do
146
104
  this.value = this.value * 256 + this.byte(), this.length *= 256;
147
- while (this.length < _);
105
+ while (this.length < o);
148
106
  }
149
107
  decodeBit(e) {
150
- let t = e.prob * (this.length >>> v), n;
151
- return this.value < t ? (n = 0, this.length = t, e.zeros++) : (n = 1, this.value -= t, this.length -= t), this.length < _ && this.renorm(), --e.until === 0 && e.update(), n;
108
+ let t = e.prob * (this.length >>> 13), n;
109
+ return this.value < t ? (n = 0, this.length = t, e.zeros++) : (n = 1, this.value -= t, this.length -= t), this.length < 16777216 && this.renorm(), --e.until === 0 && e.update(), n;
152
110
  }
153
111
  decodeSymbol(e) {
154
- let t, n, r = this.length, i = this.length >>>= b, a = e.dist;
112
+ let t, n, r = this.length, i = this.length >>>= 15, a = e.dist;
155
113
  if (e.table) {
156
114
  let o = Math.floor(this.value / i), s = Math.min(o >>> e.tableShift, e.tableSize);
157
115
  t = e.table[s];
@@ -169,7 +127,7 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
169
127
  e > this.value ? (o = s, r = e) : (t = s, n = e);
170
128
  } while ((s = t + o >>> 1) !== t);
171
129
  }
172
- return this.value -= n, this.length = r - n, this.length < _ && this.renorm(), e.counts[t]++, --e.until === 0 && e.update(), t;
130
+ return this.value -= n, this.length = r - n, this.length < 16777216 && this.renorm(), e.counts[t]++, --e.until === 0 && e.update(), t;
173
131
  }
174
132
  readBits(e) {
175
133
  if (e > 19) {
@@ -177,7 +135,7 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
177
135
  return this.readBits(e - 16) * 65536 + t;
178
136
  }
179
137
  let t = this.length >>>= e, n = Math.floor(this.value / t);
180
- return this.value -= t * n, this.length < _ && this.renorm(), n;
138
+ return this.value -= t * n, this.length < 16777216 && this.renorm(), n;
181
139
  }
182
140
  readInt() {
183
141
  let e = this.readBits(16);
@@ -187,10 +145,10 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
187
145
  let e = this.readInt();
188
146
  return BigInt(this.readInt()) << 32n | BigInt(e);
189
147
  }
190
- }, E = class {
148
+ }, k = class {
191
149
  constructor(e, t = 16, n = 1, r = 8) {
192
- this.dec = e, this.bitsHigh = r, this.k = 0, this.zero = new S(), this.corrector = [], t && t < 32 ? (this.corrBits = t, this.corrRange = 2 ** t, this.corrMin = -(this.corrRange / 2)) : (this.corrBits = 32, this.corrRange = 0, this.corrMin = -2147483648), this.kModels = Array.from({ length: n }, () => new C(this.corrBits + 1));
193
- for (let e = 1; e <= this.corrBits; e++) this.corrector[e] = new C(1 << Math.min(e, r));
150
+ this.dec = e, this.bitsHigh = r, this.k = 0, this.zero = new l(), this.corrector = [], t && t < 32 ? (this.corrBits = t, this.corrRange = 2 ** t, this.corrMin = -(this.corrRange / 2)) : (this.corrBits = 32, this.corrRange = 0, this.corrMin = -2147483648), this.kModels = Array.from({ length: n }, () => new c(this.corrBits + 1));
151
+ for (let e = 1; e <= this.corrBits; e++) this.corrector[e] = new c(1 << Math.min(e, r));
194
152
  }
195
153
  reset() {
196
154
  for (let e of this.kModels) e.reset();
@@ -213,354 +171,16 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
213
171
  }
214
172
  return r >= 2 ** (n - 1) ? r + 1 : r - (2 ** n - 1);
215
173
  }
216
- }, ee = class {
217
- constructor() {
218
- this.v = /* @__PURE__ */ new Int32Array(5), this.high = !0;
219
- }
220
- reset() {
221
- this.v.fill(0), this.high = !0;
222
- }
223
- get() {
224
- return this.v[2];
225
- }
226
- add(e) {
227
- let t = this.v;
228
- this.high ? e < t[2] ? (t[4] = t[3], t[3] = t[2], e < t[0] ? (t[2] = t[1], t[1] = t[0], t[0] = e) : e < t[1] ? (t[2] = t[1], t[1] = e) : t[2] = e) : (e < t[3] ? (t[4] = t[3], t[3] = e) : t[4] = e, this.high = !1) : t[2] < e ? (t[0] = t[1], t[1] = t[2], t[4] < e ? (t[2] = t[3], t[3] = t[4], t[4] = e) : t[3] < e ? (t[2] = t[3], t[3] = e) : t[2] = e) : (t[1] < e ? (t[0] = t[1], t[1] = e) : t[0] = e, this.high = !0);
229
- }
230
- }, D = (e) => Array.from({ length: e }, () => new ee()), O = (e) => e <= 0 ? 0 : e >= 255 ? 255 : e, k = (e, t, n) => e[t] ??= new C(n), A = (e) => {
231
- for (let t of e) t?.reset();
232
- }, te = new Uint8Array([
233
- 15,
234
- 14,
235
- 13,
236
- 12,
237
- 11,
238
- 10,
239
- 9,
240
- 8,
241
- 14,
242
- 0,
243
- 1,
244
- 3,
245
- 6,
246
- 10,
247
- 10,
248
- 9,
249
- 13,
250
- 1,
251
- 2,
252
- 4,
253
- 7,
254
- 11,
255
- 11,
256
- 10,
257
- 12,
258
- 3,
259
- 4,
260
- 5,
261
- 8,
262
- 12,
263
- 12,
264
- 11,
265
- 11,
266
- 6,
267
- 7,
268
- 8,
269
- 9,
270
- 13,
271
- 13,
272
- 12,
273
- 10,
274
- 10,
275
- 11,
276
- 12,
277
- 13,
278
- 14,
279
- 14,
280
- 13,
281
- 9,
282
- 10,
283
- 11,
284
- 12,
285
- 13,
286
- 14,
287
- 15,
288
- 14,
289
- 8,
290
- 9,
291
- 10,
292
- 11,
293
- 12,
294
- 13,
295
- 14,
296
- 15
297
- ]), ne = (/* @__PURE__ */ new Uint8Array(64)).map((e, t) => Math.abs((t >> 3) - (t & 7))), re = new Uint8Array([
298
- 0,
299
- 1,
300
- 2,
301
- 3,
302
- 4,
303
- 5,
304
- 3,
305
- 4,
306
- 4,
307
- 5,
308
- 5,
309
- 5,
310
- 5,
311
- 5,
312
- 5,
313
- 5,
314
- 1,
315
- 0,
316
- 1,
317
- 3,
318
- 4,
319
- 5,
320
- 3,
321
- 4,
322
- 4,
323
- 5,
324
- 5,
325
- 5,
326
- 5,
327
- 5,
328
- 5,
329
- 5,
330
- 2,
331
- 1,
332
- 2,
333
- 4,
334
- 5,
335
- 3,
336
- 4,
337
- 4,
338
- 5,
339
- 5,
340
- 5,
341
- 5,
342
- 5,
343
- 5,
344
- 5,
345
- 5,
346
- 3,
347
- 3,
348
- 4,
349
- 5,
350
- 4,
351
- 5,
352
- 4,
353
- 4,
354
- 5,
355
- 5,
356
- 5,
357
- 5,
358
- 5,
359
- 5,
360
- 5,
361
- 5,
362
- 4,
363
- 3,
364
- 4,
365
- 4,
366
- 5,
367
- 5,
368
- 4,
369
- 4,
370
- 5,
371
- 5,
372
- 5,
373
- 5,
374
- 5,
375
- 5,
376
- 5,
377
- 5,
378
- 5,
379
- 3,
380
- 4,
381
- 4,
382
- 4,
383
- 5,
384
- 4,
385
- 4,
386
- 5,
387
- 5,
388
- 5,
389
- 5,
390
- 5,
391
- 5,
392
- 5,
393
- 5,
394
- 3,
395
- 3,
396
- 4,
397
- 4,
398
- 4,
399
- 4,
400
- 5,
401
- 4,
402
- 5,
403
- 5,
404
- 5,
405
- 5,
406
- 5,
407
- 5,
408
- 5,
409
- 5,
410
- 4,
411
- 3,
412
- 4,
413
- 4,
414
- 4,
415
- 4,
416
- 4,
417
- 5,
418
- 5,
419
- 5,
420
- 5,
421
- 5,
422
- 5,
423
- 5,
424
- 5,
425
- 5,
426
- 4,
427
- 3,
428
- 4,
429
- 4,
430
- 4,
431
- 4,
432
- 4,
433
- 4,
434
- 5,
435
- 5,
436
- 5,
437
- 5,
438
- 5,
439
- 5,
440
- 5,
441
- 5,
442
- 5,
443
- 3,
444
- 4,
445
- 4,
446
- 4,
447
- 4,
448
- 4,
449
- 4,
450
- 4,
451
- 5,
452
- 5,
453
- 5,
454
- 5,
455
- 5,
456
- 5,
457
- 5,
458
- 5,
459
- 3,
460
- 4,
461
- 4,
462
- 4,
463
- 4,
464
- 4,
465
- 4,
466
- 4,
467
- 4,
468
- 5,
469
- 5,
470
- 5,
471
- 5,
472
- 5,
473
- 5,
474
- 5,
475
- 3,
476
- 4,
477
- 4,
478
- 4,
479
- 4,
480
- 4,
481
- 4,
482
- 4,
483
- 4,
484
- 4,
485
- 5,
486
- 5,
487
- 5,
488
- 5,
489
- 5,
490
- 5,
491
- 3,
492
- 4,
493
- 4,
494
- 4,
495
- 4,
496
- 4,
497
- 4,
498
- 4,
499
- 4,
500
- 4,
501
- 4,
502
- 5,
503
- 5,
504
- 5,
505
- 5,
506
- 5,
507
- 3,
508
- 4,
509
- 4,
510
- 4,
511
- 4,
512
- 4,
513
- 4,
514
- 4,
515
- 4,
516
- 4,
517
- 4,
518
- 4,
519
- 5,
520
- 5,
521
- 5,
522
- 5,
523
- 3,
524
- 4,
525
- 4,
526
- 4,
527
- 4,
528
- 4,
529
- 4,
530
- 4,
531
- 4,
532
- 4,
533
- 4,
534
- 4,
535
- 4,
536
- 5,
537
- 5,
538
- 5,
539
- 3,
540
- 4,
541
- 4,
542
- 4,
543
- 4,
544
- 4,
545
- 4,
546
- 4,
547
- 4,
548
- 4,
549
- 4,
550
- 4,
551
- 4,
552
- 4,
553
- 5
554
- ]), ie = (/* @__PURE__ */ new Uint8Array(256)).map((e, t) => Math.min(Math.abs((t >> 4) - (t & 15)), 7)), ae = class {
174
+ }, te = class {
555
175
  constructor(e) {
556
- this.dec = e, this.size = 20, this.x = 0, this.y = 0, this.z = 0, this.intensity = 0, this.bits = 0, this.cls = 0, this.angle = 0, this.user = 0, this.psid = 0, this.lastIntensity = /* @__PURE__ */ new Uint16Array(16), this.lastHeight = /* @__PURE__ */ new Int32Array(8), this.medianX = D(16), this.medianY = D(16), this.changed = new C(64), this.angleModels = [new C(256), new C(256)], this.bitByte = [], this.classes = [], this.userData = [], this.icIntensity = new E(e, 16, 4), this.icPsid = new E(e, 16), this.icX = new E(e, 32, 2), this.icY = new E(e, 32, 22), this.icZ = new E(e, 32, 20);
176
+ this.dec = e, this.size = 20, this.x = 0, this.y = 0, this.z = 0, this.intensity = 0, this.bits = 0, this.cls = 0, this.angle = 0, this.user = 0, this.psid = 0, this.lastIntensity = /* @__PURE__ */ new Uint16Array(16), this.lastHeight = /* @__PURE__ */ new Int32Array(8), this.medianX = u(16), this.medianY = u(16), this.changed = new c(64), this.angleModels = [new c(256), new c(256)], this.bitByte = [], this.classes = [], this.userData = [], this.icIntensity = new k(e, 16, 4), this.icPsid = new k(e, 16), this.icX = new k(e, 32, 2), this.icY = new k(e, 32, 22), this.icZ = new k(e, 32, 20);
557
177
  }
558
178
  init(e, t) {
559
179
  for (let e of this.medianX) e.reset();
560
180
  for (let e of this.medianY) e.reset();
561
181
  this.lastIntensity.fill(0), this.lastHeight.fill(0), this.changed.reset();
562
182
  for (let e of this.angleModels) e.reset();
563
- A(this.bitByte), A(this.classes), A(this.userData);
183
+ n(this.bitByte), n(this.classes), n(this.userData);
564
184
  for (let e of [
565
185
  this.icIntensity,
566
186
  this.icPsid,
@@ -571,18 +191,18 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
571
191
  this.x = e.getInt32(t, !0), this.y = e.getInt32(t + 4, !0), this.z = e.getInt32(t + 8, !0), this.intensity = 0, this.bits = e.getUint8(t + 14), this.cls = e.getUint8(t + 15), this.angle = e.getUint8(t + 16), this.user = e.getUint8(t + 17), this.psid = e.getUint16(t + 18, !0);
572
192
  }
573
193
  read(e, t) {
574
- let n = this.dec, r = n.decodeSymbol(this.changed);
575
- r & 32 && (this.bits = n.decodeSymbol(k(this.bitByte, this.bits, 256)));
576
- let i = this.bits & 7, a = this.bits >> 3 & 7, o = te[a * 8 + i], s = ne[a * 8 + i], c = +(a === 1);
577
- r && (r & 16 ? (this.intensity = this.icIntensity.decompress(this.lastIntensity[o], o < 3 ? o : 3), this.lastIntensity[o] = this.intensity) : this.intensity = this.lastIntensity[o], r & 8 && (this.cls = n.decodeSymbol(k(this.classes, this.cls, 256))), r & 4 && (this.angle = n.decodeSymbol(this.angleModels[this.bits >> 6 & 1]) + this.angle & 255), r & 2 && (this.user = n.decodeSymbol(k(this.userData, this.user, 256))), r & 1 && (this.psid = this.icPsid.decompress(this.psid)));
578
- let l = this.icX.decompress(this.medianX[o].get(), c);
579
- this.x = this.x + l | 0, this.medianX[o].add(l);
580
- let u = this.icX.k;
581
- l = this.icY.decompress(this.medianY[o].get(), c + (u < 20 ? u & -2 : 20)), this.y = this.y + l | 0, this.medianY[o].add(l), u = this.icX.k + this.icY.k >>> 1, this.z = this.icZ.decompress(this.lastHeight[s], c + (u < 18 ? u & -2 : 18)), this.lastHeight[s] = this.z, e.setInt32(t, this.x, !0), e.setInt32(t + 4, this.y, !0), e.setInt32(t + 8, this.z, !0), e.setUint16(t + 12, this.intensity, !0), e.setUint8(t + 14, this.bits), e.setUint8(t + 15, this.cls), e.setUint8(t + 16, this.angle), e.setUint8(t + 17, this.user), e.setUint16(t + 18, this.psid, !0);
582
- }
583
- }, j = 500, M = -10, N = 511, P = class {
194
+ let n = this.dec, o = n.decodeSymbol(this.changed);
195
+ o & 32 && (this.bits = n.decodeSymbol(i(this.bitByte, this.bits, 256)));
196
+ let s = this.bits & 7, c = this.bits >> 3 & 7, l = r[c * 8 + s], u = a[c * 8 + s], d = +(c === 1);
197
+ o && (o & 16 ? (this.intensity = this.icIntensity.decompress(this.lastIntensity[l], l < 3 ? l : 3), this.lastIntensity[l] = this.intensity) : this.intensity = this.lastIntensity[l], o & 8 && (this.cls = n.decodeSymbol(i(this.classes, this.cls, 256))), o & 4 && (this.angle = n.decodeSymbol(this.angleModels[this.bits >> 6 & 1]) + this.angle & 255), o & 2 && (this.user = n.decodeSymbol(i(this.userData, this.user, 256))), o & 1 && (this.psid = this.icPsid.decompress(this.psid)));
198
+ let f = this.icX.decompress(this.medianX[l].get(), d);
199
+ this.x = this.x + f | 0, this.medianX[l].add(f);
200
+ let p = this.icX.k;
201
+ f = this.icY.decompress(this.medianY[l].get(), d + (p < 20 ? p & -2 : 20)), this.y = this.y + f | 0, this.medianY[l].add(f), p = this.icX.k + this.icY.k >>> 1, this.z = this.icZ.decompress(this.lastHeight[u], d + (p < 18 ? p & -2 : 18)), this.lastHeight[u] = this.z, e.setInt32(t, this.x, !0), e.setInt32(t + 4, this.y, !0), e.setInt32(t + 8, this.z, !0), e.setUint16(t + 12, this.intensity, !0), e.setUint8(t + 14, this.bits), e.setUint8(t + 15, this.cls), e.setUint8(t + 16, this.angle), e.setUint8(t + 17, this.user), e.setUint16(t + 18, this.psid, !0);
202
+ }
203
+ }, A = 500, j = -10, M = 511, N = class {
584
204
  constructor(e, t) {
585
- this.dec = e, this.layered = t, this.last = 0, this.next = 0, this.low = /* @__PURE__ */ new Uint32Array(4), this.high = /* @__PURE__ */ new Uint32Array(4), this.diff = /* @__PURE__ */ new Int32Array(4), this.extreme = /* @__PURE__ */ new Int32Array(4), this.fullCode = t ? N : 512, this.multi = new C(this.fullCode + 4), this.zero = new C(t ? 5 : 6), this.ic = new E(e, 32, 9);
205
+ this.dec = e, this.layered = t, this.last = 0, this.next = 0, this.low = /* @__PURE__ */ new Uint32Array(4), this.high = /* @__PURE__ */ new Uint32Array(4), this.diff = /* @__PURE__ */ new Int32Array(4), this.extreme = /* @__PURE__ */ new Int32Array(4), this.fullCode = t ? M : 512, this.multi = new c(this.fullCode + 4), this.zero = new c(t ? 5 : 6), this.ic = new k(e, 32, 9);
586
206
  }
587
207
  reset(e, t) {
588
208
  this.multi.reset(), this.zero.reset(), this.ic.reset(), this.last = this.next = 0, this.diff.fill(0), this.extreme.fill(0), this.low.fill(0), this.high.fill(0), this.low[0] = e, this.high[0] = t;
@@ -619,9 +239,9 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
619
239
  if (i === 1) {
620
240
  let e = t.decompress(this.diff[r], 1);
621
241
  this.add(r, e), this.extreme[r] = 0;
622
- } else if (i < N) {
242
+ } else if (i < M) {
623
243
  let e;
624
- i === 0 ? (e = t.decompress(0, 7), this.extremeDiff(e)) : i < j ? e = t.decompress(Math.imul(i, this.diff[r]), i < 10 ? 2 : 3) : i === j ? (e = t.decompress(Math.imul(j, this.diff[r]), 4), this.extremeDiff(e)) : (i = j - i, i > M ? e = t.decompress(Math.imul(i, this.diff[r]), 5) : (e = t.decompress(Math.imul(M, this.diff[r]), 6), this.extremeDiff(e))), this.add(r, e);
244
+ i === 0 ? (e = t.decompress(0, 7), this.extremeDiff(e)) : i < A ? e = t.decompress(Math.imul(i, this.diff[r]), i < 10 ? 2 : 3) : i === A ? (e = t.decompress(Math.imul(A, this.diff[r]), 4), this.extremeDiff(e)) : (i = A - i, i > j ? e = t.decompress(Math.imul(i, this.diff[r]), 5) : (e = t.decompress(Math.imul(j, this.diff[r]), 6), this.extremeDiff(e))), this.add(r, e);
625
245
  } else if (i === this.fullCode) this.full();
626
246
  else if (i > this.fullCode) {
627
247
  this.last = r + i - this.fullCode & 3;
@@ -630,9 +250,9 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
630
250
  return;
631
251
  }
632
252
  }
633
- }, oe = class {
253
+ }, ne = class {
634
254
  constructor(e) {
635
- this.size = 8, this.gps = new P(e, !1);
255
+ this.size = 8, this.gps = new N(e, !1);
636
256
  }
637
257
  init(e, t) {
638
258
  this.gps.reset(e.getUint32(t, !0), e.getUint32(t + 4, !0));
@@ -641,50 +261,50 @@ var _ = 16777216, v = 13, y = 8192, b = 15, x = 32768, S = class {
641
261
  let n = this.gps;
642
262
  n.read(), e.setUint32(t, n.low[n.last], !0), e.setUint32(t + 4, n.high[n.last], !0);
643
263
  }
644
- }, F = class {
264
+ }, P = class {
645
265
  constructor() {
646
- this.used = new C(128), this.diff = Array.from({ length: 6 }, () => new C(256));
266
+ this.used = new c(128), this.diff = Array.from({ length: 6 }, () => new c(256));
647
267
  }
648
268
  reset() {
649
269
  this.used.reset();
650
270
  for (let e of this.diff) e.reset();
651
271
  }
652
272
  };
653
- function I(e, t, n) {
654
- let r = e.decodeSymbol(t.used), i = n[0], a = n[1], o = n[2], s = r & 1 ? e.decodeSymbol(t.diff[0]) + (i & 255) & 255 : i & 255;
655
- s |= r & 2 ? (e.decodeSymbol(t.diff[1]) + (i >> 8) & 255) << 8 : i & 65280;
656
- let c = s, l = s;
657
- if (r & 64) {
658
- let n = (s & 255) - (i & 255);
659
- c = r & 4 ? e.decodeSymbol(t.diff[2]) + O(n + (a & 255)) & 255 : a & 255, r & 16 ? (n = Math.trunc((n + (c & 255) - (a & 255)) / 2), l = e.decodeSymbol(t.diff[4]) + O(n + (o & 255)) & 255) : l = o & 255, n = (s >> 8) - (i >> 8), c |= r & 8 ? (e.decodeSymbol(t.diff[3]) + O(n + (a >> 8)) & 255) << 8 : a & 65280, r & 32 ? (n = Math.trunc((n + (c >> 8) - (a >> 8)) / 2), l |= (e.decodeSymbol(t.diff[5]) + O(n + (o >> 8)) & 255) << 8) : l |= o & 65280;
660
- }
661
- n[0] = s, n[1] = c, n[2] = l;
273
+ function re(e, n, r) {
274
+ let i = e.decodeSymbol(n.used), a = r[0], o = r[1], s = r[2], c = i & 1 ? e.decodeSymbol(n.diff[0]) + (a & 255) & 255 : a & 255;
275
+ c |= i & 2 ? (e.decodeSymbol(n.diff[1]) + (a >> 8) & 255) << 8 : a & 65280;
276
+ let l = c, u = c;
277
+ if (i & 64) {
278
+ let r = (c & 255) - (a & 255);
279
+ l = i & 4 ? e.decodeSymbol(n.diff[2]) + t(r + (o & 255)) & 255 : o & 255, i & 16 ? (r = Math.trunc((r + (l & 255) - (o & 255)) / 2), u = e.decodeSymbol(n.diff[4]) + t(r + (s & 255)) & 255) : u = s & 255, r = (c >> 8) - (a >> 8), l |= i & 8 ? (e.decodeSymbol(n.diff[3]) + t(r + (o >> 8)) & 255) << 8 : o & 65280, i & 32 ? (r = Math.trunc((r + (l >> 8) - (o >> 8)) / 2), u |= (e.decodeSymbol(n.diff[5]) + t(r + (s >> 8)) & 255) << 8) : u |= s & 65280;
280
+ }
281
+ r[0] = c, r[1] = l, r[2] = u;
662
282
  }
663
- var L = (e, t, n) => {
283
+ var ie = (e, t, n) => {
664
284
  e.setUint16(t, n[0], !0), e.setUint16(t + 2, n[1], !0), e.setUint16(t + 4, n[2], !0);
665
- }, se = class {
285
+ }, ae = class {
666
286
  constructor(e) {
667
- this.dec = e, this.size = 6, this.last = /* @__PURE__ */ new Uint16Array(3), this.models = new F();
287
+ this.dec = e, this.size = 6, this.last = /* @__PURE__ */ new Uint16Array(3), this.models = new P();
668
288
  }
669
289
  init(e, t) {
670
290
  this.models.reset();
671
291
  for (let n = 0; n < 3; n++) this.last[n] = e.getUint16(t + n * 2, !0);
672
292
  }
673
293
  read(e, t) {
674
- I(this.dec, this.models, this.last), L(e, t, this.last);
294
+ re(this.dec, this.models, this.last), ie(e, t, this.last);
675
295
  }
676
- }, ce = class {
296
+ }, oe = class {
677
297
  constructor(e, t) {
678
- this.dec = e, this.size = t, this.last = new Uint8Array(t), this.models = Array.from({ length: t }, () => new C(256));
298
+ this.dec = e, this.size = t, this.last = new Uint8Array(t), this.models = Array.from({ length: t }, () => new c(256));
679
299
  }
680
300
  init(e, t) {
681
- A(this.models);
301
+ n(this.models);
682
302
  for (let n = 0; n < this.size; n++) this.last[n] = e.getUint8(t + n);
683
303
  }
684
304
  read(e, t) {
685
305
  for (let n = 0; n < this.size; n++) this.last[n] = this.last[n] + this.dec.decodeSymbol(this.models[n]) & 255, e.setUint8(t + n, this.last[n]);
686
306
  }
687
- }, R = class {
307
+ }, F = class {
688
308
  constructor() {
689
309
  this.index = 0, this.offset = 0n, this.size = 0, this.location = 0, this.dx = 0, this.dy = 0, this.dz = 0;
690
310
  }
@@ -697,30 +317,30 @@ var L = (e, t, n) => {
697
317
  writeTo(e, t) {
698
318
  e.setUint8(t, this.index), e.setBigUint64(t + 1, this.offset, !0), e.setInt32(t + 9, this.size, !0), e.setInt32(t + 13, this.location, !0), e.setInt32(t + 17, this.dx, !0), e.setInt32(t + 21, this.dy, !0), e.setInt32(t + 25, this.dz, !0);
699
319
  }
700
- }, z = class {
320
+ }, I = class {
701
321
  constructor(e) {
702
- this.index = new C(256), this.offsetType = Array.from({ length: 4 }, () => new C(4)), this.lastType = 0, this.lastDiff = 0, this.offsetDiff = new E(e, 32), this.size = new E(e, 32), this.location = new E(e, 32), this.direction = new E(e, 32, 3);
322
+ this.index = new c(256), this.offsetType = Array.from({ length: 4 }, () => new c(4)), this.lastType = 0, this.lastDiff = 0, this.offsetDiff = new k(e, 32), this.size = new k(e, 32), this.location = new k(e, 32), this.direction = new k(e, 32, 3);
703
323
  }
704
324
  reset() {
705
- this.lastType = this.lastDiff = 0, this.index.reset(), A(this.offsetType), this.offsetDiff.reset(), this.size.reset(), this.location.reset(), this.direction.reset();
325
+ this.lastType = this.lastDiff = 0, this.index.reset(), n(this.offsetType), this.offsetDiff.reset(), this.size.reset(), this.location.reset(), this.direction.reset();
706
326
  }
707
327
  };
708
- function B(e, t, n) {
328
+ function L(e, t, n) {
709
329
  n.index = e.decodeSymbol(t.index);
710
330
  let r = t.lastType = e.decodeSymbol(t.offsetType[t.lastType]);
711
331
  r === 1 ? n.offset = BigInt.asUintN(64, n.offset + BigInt(n.size >>> 0)) : r === 2 ? (t.lastDiff = t.offsetDiff.decompress(t.lastDiff), n.offset = BigInt.asUintN(64, n.offset + BigInt(t.lastDiff))) : r === 3 && (n.offset = e.readInt64()), n.size = t.size.decompress(n.size), n.location = t.location.decompress(n.location), n.dx = t.direction.decompress(n.dx, 0), n.dy = t.direction.decompress(n.dy, 1), n.dz = t.direction.decompress(n.dz, 2);
712
332
  }
713
- var le = class {
333
+ var se = class {
714
334
  constructor(e) {
715
- this.dec = e, this.size = 29, this.last = new R(), this.models = new z(e);
335
+ this.dec = e, this.size = 29, this.last = new F(), this.models = new I(e);
716
336
  }
717
337
  init(e, t) {
718
338
  this.models.reset(), this.last.readFrom(e, t);
719
339
  }
720
340
  read(e, t) {
721
- B(this.dec, this.models, this.last), this.last.writeTo(e, t);
341
+ L(this.dec, this.models, this.last), this.last.writeTo(e, t);
722
342
  }
723
- }, V = class {
343
+ }, R = class {
724
344
  constructor() {
725
345
  this.x = 0, this.y = 0, this.z = 0, this.intensity = 0, this.ret = 0, this.returns = 0, this.classFlags = 0, this.channel = 0, this.scanDirection = 0, this.edge = 0, this.cls = 0, this.user = 0, this.angle = 0, this.psid = 0, this.gpsLow = 0, this.gpsHigh = 0, this.gpsChange = !1;
726
346
  }
@@ -735,13 +355,13 @@ var le = class {
735
355
  writeTo(e, t) {
736
356
  e.setInt32(t, this.x, !0), e.setInt32(t + 4, this.y, !0), e.setInt32(t + 8, this.z, !0), e.setUint16(t + 12, this.intensity, !0), e.setUint8(t + 14, this.ret | this.returns << 4), e.setUint8(t + 15, this.classFlags | this.channel << 4 | this.scanDirection << 6 | this.edge << 7), e.setUint8(t + 16, this.cls), e.setUint8(t + 17, this.user), e.setInt16(t + 18, this.angle, !0), e.setUint16(t + 20, this.psid, !0), e.setUint32(t + 22, this.gpsLow, !0), e.setUint32(t + 26, this.gpsHigh, !0);
737
357
  }
738
- }, H = 0, U = 1, W = 2, G = 3, K = 4, q = 5, J = 6, Y = 7, ue = 8, de = class {
358
+ }, z = 0, B = 1, V = 2, H = 3, U = 4, W = 5, G = 6, K = 7, q = 8, ce = class {
739
359
  constructor(e) {
740
- this.unused = !0, this.last = new V(), this.lastIntensity = /* @__PURE__ */ new Uint16Array(8), this.lastZ = /* @__PURE__ */ new Int32Array(8), this.medianX = D(12), this.medianY = D(12), this.changed = Array.from({ length: 8 }, () => new C(128)), this.channel = new C(3), this.returns = [], this.ret = [], this.retGpsSame = new C(13), this.classes = [], this.flags = [], this.userData = [], this.icX = new E(e[H], 32, 2), this.icY = new E(e[H], 32, 22), this.icZ = new E(e[U], 32, 20), this.icIntensity = new E(e[K], 16, 4), this.icAngle = new E(e[q], 16, 2), this.icPsid = new E(e[Y], 16), this.gps = new P(e[ue], !0);
360
+ this.unused = !0, this.last = new R(), this.lastIntensity = /* @__PURE__ */ new Uint16Array(8), this.lastZ = /* @__PURE__ */ new Int32Array(8), this.medianX = u(12), this.medianY = u(12), this.changed = Array.from({ length: 8 }, () => new c(128)), this.channel = new c(3), this.returns = [], this.ret = [], this.retGpsSame = new c(13), this.classes = [], this.flags = [], this.userData = [], this.icX = new k(e[z], 32, 2), this.icY = new k(e[z], 32, 22), this.icZ = new k(e[B], 32, 20), this.icIntensity = new k(e[U], 16, 4), this.icAngle = new k(e[W], 16, 2), this.icPsid = new k(e[K], 16), this.gps = new N(e[q], !0);
741
361
  }
742
362
  reset(e) {
743
363
  for (let e of this.changed) e.reset();
744
- this.channel.reset(), this.retGpsSame.reset(), A(this.returns), A(this.ret), A(this.classes), A(this.flags), A(this.userData);
364
+ this.channel.reset(), this.retGpsSame.reset(), n(this.returns), n(this.ret), n(this.classes), n(this.flags), n(this.userData);
745
365
  for (let e of [
746
366
  this.icX,
747
367
  this.icY,
@@ -754,15 +374,15 @@ var le = class {
754
374
  for (let e of this.medianY) e.reset();
755
375
  this.lastZ.fill(e.z), this.lastIntensity.fill(e.intensity), this.gps.reset(e.gpsLow, e.gpsHigh), this.last.copy(e), this.last.gpsChange = !1, this.unused = !1;
756
376
  }
757
- }, fe = class {
377
+ }, le = class {
758
378
  constructor(e) {
759
- this.channel = e, this.size = 30, this.layers = 9, this.dec = Array.from({ length: 9 }, () => new T()), this.has = Array(9).fill(!1), this.contexts = [], this.first = new V();
379
+ this.channel = e, this.size = 30, this.layers = 9, this.dec = Array.from({ length: 9 }, () => new O()), this.has = Array(9).fill(!1), this.contexts = [], this.first = new R();
760
380
  }
761
381
  layer(e, t, n, r, i) {
762
- this.has[e] = e === H || r > n, this.has[e] && this.dec[e].init(t, n, r, i);
382
+ this.has[e] = e === z || r > n, this.has[e] && this.dec[e].init(t, n, r, i);
763
383
  }
764
384
  context(e, t) {
765
- let n = this.contexts[e] ??= new de(this.dec);
385
+ let n = this.contexts[e] ??= new ce(this.dec);
766
386
  return n.reset(t), n;
767
387
  }
768
388
  init(e, t) {
@@ -770,39 +390,39 @@ var le = class {
770
390
  for (let e of this.contexts) e && (e.unused = !0);
771
391
  this.channel.current = this.channel.item = this.first.channel, this.context(this.first.channel, this.first);
772
392
  }
773
- read(e, t) {
774
- let n = this.dec, r = this.has, i = this.contexts[this.channel.current], a = i.last, o = +(a.ret === 1) + (a.ret >= a.returns ? 2 : 0) + (a.gpsChange ? 4 : 0), s = n[H].decodeSymbol(i.changed[o]);
775
- if (this.channel.item = 0, s & 64) {
776
- let e = this.channel.current + n[H].decodeSymbol(i.channel) + 1 & 3, t = this.contexts[e];
777
- i = t && !t.unused ? t : this.context(e, a), this.channel.current = this.channel.item = e, a = i.last, a.channel = e;
393
+ read(t, n) {
394
+ let r = this.dec, a = this.has, o = this.contexts[this.channel.current], c = o.last, l = +(c.ret === 1) + (c.ret >= c.returns ? 2 : 0) + (c.gpsChange ? 4 : 0), u = r[z].decodeSymbol(o.changed[l]);
395
+ if (this.channel.item = 0, u & 64) {
396
+ let e = this.channel.current + r[z].decodeSymbol(o.channel) + 1 & 3, t = this.contexts[e];
397
+ o = t && !t.unused ? t : this.context(e, c), this.channel.current = this.channel.item = e, c = o.last, c.channel = e;
778
398
  }
779
- let c = !!(s & 32), l = !!(s & 16), u = !!(s & 8), d = +!!l, f = a.returns, p = a.ret;
780
- s & 4 && (a.returns = n[H].decodeSymbol(k(i.returns, f, 16)));
781
- let m = s & 3;
782
- m === 1 ? a.ret = p + 1 & 15 : m === 2 ? a.ret = p + 15 & 15 : m === 3 && (a.ret = l ? n[H].decodeSymbol(k(i.ret, p, 16)) : p + n[H].decodeSymbol(i.retGpsSame) + 2 & 15);
783
- let h = a.returns, g = a.ret, _ = re[h * 16 + g], v = ie[h * 16 + g], y = +(h === 1), b = (g === 1 ? 2 : 0) + +(g >= h), x = i.medianX[_ << 1 | d], S = i.medianY[_ << 1 | d], C = i.icX.decompress(x.get(), y);
784
- a.x = a.x + C | 0, x.add(C);
785
- let w = i.icX.k;
786
- if (C = i.icY.decompress(S.get(), y + (w < 20 ? w & -2 : 20)), a.y = a.y + C | 0, S.add(C), r[U] && (w = i.icX.k + i.icY.k >>> 1, a.z = i.icZ.decompress(i.lastZ[v], y + (w < 18 ? w & -2 : 18)), i.lastZ[v] = a.z), r[W]) {
787
- let e = ((a.cls & 31) << 1) + +(b === 3);
788
- a.cls = n[W].decodeSymbol(k(i.classes, e, 256));
399
+ let d = !!(u & 32), f = !!(u & 16), p = !!(u & 8), m = +!!f, h = c.returns, g = c.ret;
400
+ u & 4 && (c.returns = r[z].decodeSymbol(i(o.returns, h, 16)));
401
+ let _ = u & 3;
402
+ _ === 1 ? c.ret = g + 1 & 15 : _ === 2 ? c.ret = g + 15 & 15 : _ === 3 && (c.ret = f ? r[z].decodeSymbol(i(o.ret, g, 16)) : g + r[z].decodeSymbol(o.retGpsSame) + 2 & 15);
403
+ let v = c.returns, y = c.ret, b = e[v * 16 + y], x = s[v * 16 + y], S = +(v === 1), C = (y === 1 ? 2 : 0) + +(y >= v), w = o.medianX[b << 1 | m], T = o.medianY[b << 1 | m], E = o.icX.decompress(w.get(), S);
404
+ c.x = c.x + E | 0, w.add(E);
405
+ let D = o.icX.k;
406
+ if (E = o.icY.decompress(T.get(), S + (D < 20 ? D & -2 : 20)), c.y = c.y + E | 0, T.add(E), a[B] && (D = o.icX.k + o.icY.k >>> 1, c.z = o.icZ.decompress(o.lastZ[x], S + (D < 18 ? D & -2 : 18)), o.lastZ[x] = c.z), a[V]) {
407
+ let e = ((c.cls & 31) << 1) + +(C === 3);
408
+ c.cls = r[V].decodeSymbol(i(o.classes, e, 256));
789
409
  }
790
- if (r[G]) {
791
- let e = a.edge << 5 | a.scanDirection << 4 | a.classFlags, t = n[G].decodeSymbol(k(i.flags, e, 64));
792
- a.edge = t >> 5 & 1, a.scanDirection = t >> 4 & 1, a.classFlags = t & 15;
410
+ if (a[H]) {
411
+ let e = c.edge << 5 | c.scanDirection << 4 | c.classFlags, t = r[H].decodeSymbol(i(o.flags, e, 64));
412
+ c.edge = t >> 5 & 1, c.scanDirection = t >> 4 & 1, c.classFlags = t & 15;
793
413
  }
794
- if (r[K]) {
795
- let e = b << 1 | d;
796
- a.intensity = i.icIntensity.decompress(i.lastIntensity[e], b), i.lastIntensity[e] = a.intensity;
414
+ if (a[U]) {
415
+ let e = C << 1 | m;
416
+ c.intensity = o.icIntensity.decompress(o.lastIntensity[e], C), o.lastIntensity[e] = c.intensity;
797
417
  }
798
- r[q] && u && (a.angle = i.icAngle.decompress(a.angle, d) << 16 >> 16), r[J] && (a.user = n[J].decodeSymbol(k(i.userData, a.user >> 2, 256))), r[Y] && c && (a.psid = i.icPsid.decompress(a.psid)), r[ue] && l && (i.gps.read(), a.gpsLow = i.gps.low[i.gps.last], a.gpsHigh = i.gps.high[i.gps.last]), a.writeTo(e, t), a.gpsChange = l;
418
+ a[W] && p && (c.angle = o.icAngle.decompress(c.angle, m) << 16 >> 16), a[G] && (c.user = r[G].decodeSymbol(i(o.userData, c.user >> 2, 256))), a[K] && d && (c.psid = o.icPsid.decompress(c.psid)), a[q] && f && (o.gps.read(), c.gpsLow = o.gps.low[o.gps.last], c.gpsHigh = o.gps.high[o.gps.last]), c.writeTo(t, n), c.gpsChange = f;
799
419
  }
800
- }, X = class {
420
+ }, J = class {
801
421
  constructor(e) {
802
422
  this.channel = e, this.dec = [], this.has = [], this.contexts = [], this.current = 0;
803
423
  }
804
424
  layer(e, t, n, r, i) {
805
- this.dec[e] ??= new T(), this.has[e] = r > n, this.has[e] && this.dec[e].init(t, n, r, i);
425
+ this.dec[e] ??= new O(), this.has[e] = r > n, this.has[e] && this.dec[e].init(t, n, r, i);
806
426
  }
807
427
  context(e, t, n) {
808
428
  let r = this.contexts[e] ??= this.create();
@@ -821,16 +441,16 @@ var le = class {
821
441
  }
822
442
  this.decode(this.contexts[n], r, e, t);
823
443
  }
824
- }, pe = class {
444
+ }, ue = class {
825
445
  constructor() {
826
- this.unused = !0, this.last = /* @__PURE__ */ new Uint16Array(4), this.rgb = new F(), this.nirUsed = new C(4), this.nir = [new C(256), new C(256)];
446
+ this.unused = !0, this.last = /* @__PURE__ */ new Uint16Array(4), this.rgb = new P(), this.nirUsed = new c(4), this.nir = [new c(256), new c(256)];
827
447
  }
828
- }, me = class extends X {
448
+ }, de = class extends J {
829
449
  constructor(e, t) {
830
450
  super(e), this.size = t, this.layers = t === 8 ? 2 : 1;
831
451
  }
832
452
  create() {
833
- return new pe();
453
+ return new ue();
834
454
  }
835
455
  start(e, t, n) {
836
456
  e.rgb.reset(), e.nirUsed.reset();
@@ -840,7 +460,7 @@ var le = class {
840
460
  }
841
461
  decode(e, t, n, r) {
842
462
  let i = t.last;
843
- if (this.has[0] && I(this.dec[0], e.rgb, i), L(n, r, i), this.layers === 2) {
463
+ if (this.has[0] && re(this.dec[0], e.rgb, i), ie(n, r, i), this.layers === 2) {
844
464
  if (this.has[1]) {
845
465
  let t = this.dec[1], n = t.decodeSymbol(e.nirUsed), r = i[3], a = n & 1 ? t.decodeSymbol(e.nir[0]) + (r & 255) & 255 : r & 255;
846
466
  a |= n & 2 ? (t.decodeSymbol(e.nir[1]) + (r >> 8) & 255) << 8 : r & 65280, i[3] = a;
@@ -848,93 +468,93 @@ var le = class {
848
468
  n.setUint16(r + 6, i[3], !0);
849
469
  }
850
470
  }
851
- }, he = class {
471
+ }, fe = class {
852
472
  constructor(e) {
853
- this.unused = !0, this.last = new Uint8Array(e), this.models = Array.from({ length: e }, () => new C(256));
473
+ this.unused = !0, this.last = new Uint8Array(e), this.models = Array.from({ length: e }, () => new c(256));
854
474
  }
855
- }, ge = class extends X {
475
+ }, pe = class extends J {
856
476
  constructor(e, t) {
857
477
  super(e), this.size = t, this.layers = t;
858
478
  }
859
479
  create() {
860
- return new he(this.size);
480
+ return new fe(this.size);
861
481
  }
862
- start(e, t, n) {
863
- if (A(e.models), t instanceof DataView) for (let r = 0; r < this.size; r++) e.last[r] = t.getUint8(n + r);
482
+ start(e, t, r) {
483
+ if (n(e.models), t instanceof DataView) for (let n = 0; n < this.size; n++) e.last[n] = t.getUint8(r + n);
864
484
  else e.last.set(t.last);
865
485
  }
866
486
  decode(e, t, n, r) {
867
487
  let i = t.last;
868
488
  for (let t = 0; t < this.size; t++) this.has[t] && (i[t] = i[t] + this.dec[t].decodeSymbol(e.models[t]) & 255), n.setUint8(r + t, i[t]);
869
489
  }
870
- }, _e = class {
490
+ }, me = class {
871
491
  constructor(e) {
872
- this.unused = !0, this.last = new R(), this.models = new z(e);
492
+ this.unused = !0, this.last = new F(), this.models = new I(e);
873
493
  }
874
- }, ve = class extends X {
494
+ }, he = class extends J {
875
495
  constructor(...e) {
876
496
  super(...e), this.size = 29, this.layers = 1;
877
497
  }
878
498
  create() {
879
- return new _e(this.dec[0]);
499
+ return new me(this.dec[0]);
880
500
  }
881
501
  start(e, t, n) {
882
502
  e.models.reset(), t instanceof DataView ? e.last.readFrom(t, n) : e.last.copy(t.last);
883
503
  }
884
504
  decode(e, t, n, r) {
885
- this.has[0] && B(this.dec[0], e.models, t.last), t.last.writeTo(n, r);
505
+ this.has[0] && L(this.dec[0], e.models, t.last), t.last.writeTo(n, r);
886
506
  }
887
507
  };
888
- function ye(e, t, n) {
508
+ function ge(e, t, n) {
889
509
  let r = new DataView(e.buffer, e.byteOffset, e.byteLength), i = t.pointDataOffset + 8;
890
510
  if (i > e.byteLength) throw RangeError("LAZ point data is shorter than its 8-byte chunk table offset; the file is truncated");
891
511
  let a = Number(r.getBigInt64(t.pointDataOffset, !0));
892
512
  if (a === -1 && e.byteLength >= i + 8 && (a = Number(r.getBigInt64(e.byteLength - 8, !0))), !(a >= i && a + 8 <= e.byteLength)) throw RangeError(`LAZ chunk table offset ${a} lies outside the file; the file is truncated or corrupt (LAZ is read through its chunk table)`);
893
513
  let o = r.getUint32(a, !0), s = r.getUint32(a + 4, !0), c = n.chunkSize === "variable";
894
- if (o !== 0) throw h(`chunk table version ${o}`);
514
+ if (o !== 0) throw E(`chunk table version ${o}`);
895
515
  let l = c ? void 0 : Math.ceil(t.pointCount / n.chunkSize);
896
516
  if (l === void 0 ? s > t.pointCount : s !== l) throw RangeError(`LAZ chunk table lists ${s} chunks for ${t.pointCount} points${l === void 0 ? "" : ` (expected ${l})`}; the file is corrupt`);
897
517
  let u = [];
898
518
  if (!s) return u;
899
- let d = new T(), f = new E(d, 32, 2);
519
+ let d = new O(), f = new k(d, 32, 2);
900
520
  d.init(e, a + 8, e.byteLength, "chunk table");
901
- let p = 0, m = 0, g = i, _ = 0;
521
+ let p = 0, m = 0, h = i, g = 0;
902
522
  for (let e = 0; e < s; e++) {
903
- if (p = c ? f.decompress(p, 0) : Math.min(n.chunkSize, t.pointCount - _), m = f.decompress(m, 1), p < 0 || m < 0 || g + m > a || _ + p > t.pointCount) throw RangeError(`LAZ chunk ${e} (${p} points, ${m} bytes at ${g}) does not fit the point data; the file is corrupt`);
523
+ if (p = c ? f.decompress(p, 0) : Math.min(n.chunkSize, t.pointCount - g), m = f.decompress(m, 1), p < 0 || m < 0 || h + m > a || g + p > t.pointCount) throw RangeError(`LAZ chunk ${e} (${p} points, ${m} bytes at ${h}) does not fit the point data; the file is corrupt`);
904
524
  u.push({
905
- start: g,
906
- end: g + m,
525
+ start: h,
526
+ end: h + m,
907
527
  count: p
908
- }), g += m, _ += p;
528
+ }), h += m, g += p;
909
529
  }
910
- if (_ !== t.pointCount) throw RangeError(`LAZ chunks hold ${_} points but the header says ${t.pointCount}; the file is corrupt`);
530
+ if (g !== t.pointCount) throw RangeError(`LAZ chunks hold ${g} points but the header says ${t.pointCount}; the file is corrupt`);
911
531
  return u;
912
532
  }
913
- function be(e) {
914
- let t = new T(), d = e.compressor === 3, f = {
533
+ function Y(e) {
534
+ let t = new O(), n = e.compressor === 3, r = {
915
535
  current: 0,
916
536
  item: 0
917
537
  };
918
538
  return {
919
539
  readers: e.items.map((e) => {
920
540
  switch (e.type) {
921
- case r: return new ae(t);
922
- case i: return new oe(t);
923
- case a: return new se(t);
924
- case o: return new le(t);
925
- case n: return new ce(t, e.size);
926
- case s: return new fe(f);
927
- case c:
928
- case l: return new me(f, e.size);
929
- case u: return new ve(f);
930
- default: return new ge(f, e.size);
541
+ case m: return new te(t);
542
+ case h: return new ne(t);
543
+ case g: return new ae(t);
544
+ case _: return new se(t);
545
+ case p: return new oe(t, e.size);
546
+ case v: return new le(r);
547
+ case y:
548
+ case b: return new de(r, e.size);
549
+ case x: return new he(r);
550
+ default: return new pe(r, e.size);
931
551
  }
932
552
  }),
933
553
  dec: t,
934
- layered: d
554
+ layered: n
935
555
  };
936
556
  }
937
- function Z(e, t, n, r, i, a) {
557
+ function X(e, t, n, r, i, a) {
938
558
  let { readers: o, dec: s, layered: c } = i, l = `chunk ${n}`, u = new DataView(a.buffer, a.byteOffset, a.byteLength);
939
559
  if (!t.count) return;
940
560
  let d = t.start + r;
@@ -953,58 +573,58 @@ function Z(e, t, n, r, i, a) {
953
573
  } else s.init(e, d, t.end, l);
954
574
  d = 0;
955
575
  for (let e of o) e.init(u, d), d += e.size;
956
- xe(o, u, 1, t.count, r);
576
+ Z(o, u, 1, t.count, r);
957
577
  }
958
- function xe(e, t, n, r, i) {
578
+ function Z(e, t, n, r, i) {
959
579
  for (let a = n; a < r; a++) {
960
580
  let n = a * i;
961
581
  for (let r of e) r.read(t, n), n += r.size;
962
582
  }
963
583
  }
964
584
  var Q = 5e4;
965
- function* Se(e, t, n) {
585
+ function* _e(e, t, n) {
966
586
  let r = t.pointRecordLength, i = t.pointCount;
967
587
  if (!i) return;
968
588
  let a = Math.min(Q, i), o = new Uint8Array(a * r);
969
589
  if (t.pointDataOffset + r > e.byteLength) throw RangeError("LAZ point data is shorter than its first point; the file is truncated");
970
- Z(e, {
590
+ X(e, {
971
591
  start: t.pointDataOffset,
972
592
  end: e.byteLength,
973
593
  count: a
974
594
  }, 0, r, n, o), yield o;
975
595
  for (let e = a; e < i;) {
976
596
  let t = Math.min(Q, i - e), a = new Uint8Array(t * r);
977
- xe(n.readers, new DataView(a.buffer), 0, t, r), e += t, yield a;
597
+ Z(n.readers, new DataView(a.buffer), 0, t, r), e += t, yield a;
978
598
  }
979
599
  }
980
600
  var $ = () => globalThis.performance?.now() ?? Date.now();
981
- async function* Ce(e, t, n, r = {}) {
601
+ async function* ve(e, t, n, r = {}) {
982
602
  let i = r.signal;
983
603
  if (i?.throwIfAborted(), !t.compressed) throw TypeError("LAS file is not compressed (no LAZ bit in the point format); use parseLAS");
984
- let a = p(n);
985
- g(a, t);
604
+ let a = w(n);
605
+ D(a, t);
986
606
  let o = t.pointRecordLength;
987
607
  if (a.compressor === 0) {
988
608
  yield e.subarray(t.pointDataOffset, t.pointDataOffset + t.pointCount * o);
989
609
  return;
990
610
  }
991
- let s = be(a), c = $(), l = async () => {
611
+ let s = Y(a), c = $(), l = async () => {
992
612
  i?.throwIfAborted(), $() - c > 30 && (await new Promise((e) => setTimeout(e, 0)), i?.throwIfAborted(), c = $());
993
613
  };
994
614
  if (a.compressor === 1) {
995
- for (let n of Se(e, t, s)) yield n, await l();
615
+ for (let n of _e(e, t, s)) yield n, await l();
996
616
  return;
997
617
  }
998
- let u = ye(e, t, a);
618
+ let u = ge(e, t, a);
999
619
  for (let t = 0; t < u.length; t++) {
1000
620
  await l();
1001
621
  let n = new Uint8Array(u[t].count * o);
1002
- Z(e, u[t], t, o, s, n), yield n;
622
+ X(e, u[t], t, o, s, n), yield n;
1003
623
  }
1004
624
  }
1005
- function we(e, t, n, r) {
1006
- let i = p(r);
1007
- g(i, n);
625
+ function ye(e, t, n, r) {
626
+ let i = w(r);
627
+ D(i, n);
1008
628
  let a = n.pointRecordLength;
1009
629
  if (!Number.isSafeInteger(t) || t < 0) throw RangeError(`LAZ chunk point count ${t} is not a whole number of 0 or more; pass the count its index gives`);
1010
630
  if (t && i.compressor === 3 && e.byteLength >= a + 4) {
@@ -1012,14 +632,14 @@ function we(e, t, n, r) {
1012
632
  if (n !== t) throw RangeError(`LAZ chunk 0 holds ${n} points but its table says ${t}; the file is corrupt`);
1013
633
  }
1014
634
  let o = new Uint8Array(t * a);
1015
- return Z(e, {
635
+ return X(e, {
1016
636
  start: 0,
1017
637
  end: e.byteLength,
1018
638
  count: t
1019
- }, 0, a, be(i), o), o;
639
+ }, 0, a, Y(i), o), o;
1020
640
  }
1021
- function Te() {
1022
- return (e, t, n, r) => Ce(e, t, n, { signal: r });
641
+ function be() {
642
+ return (e, t, n, r) => ve(e, t, n, { signal: r });
1023
643
  }
1024
644
  //#endregion
1025
- export { Te as createLazDecoder, we as decodeLazChunk, Ce as lazChunks, p as lazInfo };
645
+ export { be as createLazDecoder, ye as decodeLazChunk, ve as lazChunks, w as lazInfo };