rm-graphical-computing-node 1.0.97 → 1.0.99

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.
Files changed (2) hide show
  1. package/dist/index.mjs +2108 -83
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -7,6 +7,10 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
10
14
  var __copyProps = (to, from, except, desc) => {
11
15
  if (from && typeof from === "object" || typeof from === "function") {
12
16
  for (let key of __getOwnPropNames(from))
@@ -304,8 +308,8 @@ var require_rbush = __commonJS({
304
308
  }
305
309
  return node;
306
310
  };
307
- RBush.prototype._insert = function _insert(item, level, isNode) {
308
- var bbox2 = isNode ? item : this.toBBox(item);
311
+ RBush.prototype._insert = function _insert(item, level, isNode2) {
312
+ var bbox2 = isNode2 ? item : this.toBBox(item);
309
313
  var insertPath = [];
310
314
  var node = this._chooseSubtree(bbox2, this.data, level, insertPath);
311
315
  node.children.push(item);
@@ -4240,11 +4244,11 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
4240
4244
  if (Math.abs(tmpRegion.facePoints[0].z - line2.start.z) < doorSill) {
4241
4245
  let isInsert = false;
4242
4246
  for (let k = 0; k < runDataList.length; k++) {
4243
- let next = k + 1;
4244
- if (next >= runDataList.length)
4247
+ let next2 = k + 1;
4248
+ if (next2 >= runDataList.length)
4245
4249
  continue;
4246
4250
  let start = new THREE5.Vector3(runDataList[k].x, runDataList[k].y, runDataList[k].z);
4247
- let end = new THREE5.Vector3(runDataList[next].x, runDataList[next].y, runDataList[next].z);
4251
+ let end = new THREE5.Vector3(runDataList[next2].x, runDataList[next2].y, runDataList[next2].z);
4248
4252
  let insertPt = segmentsIntersect2D(
4249
4253
  new THREE5.Vector3(start.x, start.y, 0),
4250
4254
  new THREE5.Vector3(end.x, end.y, 0),
@@ -7799,26 +7803,26 @@ function computeContour(points) {
7799
7803
  contour.push(uniq[cur]);
7800
7804
  visited[cur] = 1;
7801
7805
  const nb = adj.get(cur) || [];
7802
- let next = -1;
7806
+ let next2 = -1;
7803
7807
  for (let i = 0; i < nb.length; i++) {
7804
7808
  const v2 = nb[i];
7805
7809
  if (v2 !== prev && !visited[v2]) {
7806
- next = v2;
7810
+ next2 = v2;
7807
7811
  break;
7808
7812
  }
7809
7813
  }
7810
- if (next === -1) {
7814
+ if (next2 === -1) {
7811
7815
  for (let i = 0; i < nb.length; i++) {
7812
7816
  const v2 = nb[i];
7813
7817
  if (v2 !== prev) {
7814
- next = v2;
7818
+ next2 = v2;
7815
7819
  break;
7816
7820
  }
7817
7821
  }
7818
7822
  }
7819
- if (next === -1) break;
7823
+ if (next2 === -1) break;
7820
7824
  prev = cur;
7821
- cur = next;
7825
+ cur = next2;
7822
7826
  } while (cur !== start && contour.length <= boundaryLength + 1);
7823
7827
  if (contour.length > 0) {
7824
7828
  contour.push(contour[0]);
@@ -7940,8 +7944,8 @@ function isObject(input) {
7940
7944
  // node_modules/@turf/meta/dist/esm/index.js
7941
7945
  function coordEach(geojson, callback, excludeWrapCoord) {
7942
7946
  if (geojson === null) return;
7943
- var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
7944
- for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
7947
+ var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop2 = isFeatureCollection ? geojson.features.length : 1;
7948
+ for (var featureIndex = 0; featureIndex < stop2; featureIndex++) {
7945
7949
  geometryMaybeCollection = isFeatureCollection ? (
7946
7950
  // @ts-expect-error: Known type conflict
7947
7951
  geojson.features[featureIndex].geometry
@@ -8063,8 +8067,8 @@ function coordAll(geojson) {
8063
8067
  return coords;
8064
8068
  }
8065
8069
  function geomEach(geojson, callback) {
8066
- var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection, featureProperties, featureBBox, featureId, featureIndex = 0, isFeatureCollection = geojson.type === "FeatureCollection", isFeature = geojson.type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
8067
- for (i = 0; i < stop; i++) {
8070
+ var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection, featureProperties, featureBBox, featureId, featureIndex = 0, isFeatureCollection = geojson.type === "FeatureCollection", isFeature = geojson.type === "Feature", stop2 = isFeatureCollection ? geojson.features.length : 1;
8071
+ for (i = 0; i < stop2; i++) {
8068
8072
  geometryMaybeCollection = isFeatureCollection ? (
8069
8073
  // @ts-expect-error: Known type conflict
8070
8074
  geojson.features[i].geometry
@@ -11108,11 +11112,11 @@ function computeContour2(points) {
11108
11112
  contour.push(uniq[cur]);
11109
11113
  visited.add(cur);
11110
11114
  const nb = adj.get(cur) || [];
11111
- let next = nb.find((n) => n !== prev && !visited.has(n));
11112
- if (next === void 0) next = nb.find((n) => n !== prev);
11113
- if (next === void 0) break;
11115
+ let next2 = nb.find((n) => n !== prev && !visited.has(n));
11116
+ if (next2 === void 0) next2 = nb.find((n) => n !== prev);
11117
+ if (next2 === void 0) break;
11114
11118
  prev = cur;
11115
- cur = next;
11119
+ cur = next2;
11116
11120
  } while (cur !== start && contour.length <= boundary.length + 1);
11117
11121
  if (contour.length > 0)
11118
11122
  contour.push(contour[0]);
@@ -11122,28 +11126,2060 @@ function computeContour2(points) {
11122
11126
  // src/geometry/slabLine.mjs
11123
11127
  import * as THREE9 from "three";
11124
11128
  import { max, min } from "three/tsl";
11125
- var getSlabData = (lines, runDataList, pointCloudCluster = null, getOblique = false) => {
11126
- const flatSlabPoints = [];
11127
- const obliqueSlabPoints = [];
11128
- if (getOblique) {
11129
- for (let i = 0; i < lines.length; i++) {
11130
- const normal = lines[i][0];
11131
- if (normal.length != 3) continue;
11132
- if (normal[2] > 0.98)
11133
- flatSlabPoints.push(lines[i]);
11134
- else {
11135
- obliqueSlabPoints.push(lines[i]);
11129
+
11130
+ // node_modules/stream-chain/src/index.js
11131
+ import { Readable, Writable, Duplex as Duplex2 } from "node:stream";
11132
+
11133
+ // node_modules/stream-chain/src/defs.js
11134
+ var defs_exports = {};
11135
+ __export(defs_exports, {
11136
+ Stop: () => Stop,
11137
+ clearFunctionList: () => clearFunctionList,
11138
+ combineMany: () => combineMany,
11139
+ combineManyMut: () => combineManyMut,
11140
+ fListSymbol: () => fListSymbol,
11141
+ final: () => final,
11142
+ finalSymbol: () => finalSymbol,
11143
+ finalValue: () => finalValue,
11144
+ flushSymbol: () => flushSymbol,
11145
+ flushable: () => flushable,
11146
+ getFinalValue: () => getFinalValue,
11147
+ getFunctionList: () => getFunctionList,
11148
+ getManyValues: () => getManyValues,
11149
+ isDuplexNodeStream: () => isDuplexNodeStream,
11150
+ isDuplexWebStream: () => isDuplexWebStream,
11151
+ isFinalValue: () => isFinalValue,
11152
+ isFlushable: () => isFlushable,
11153
+ isFunctionList: () => isFunctionList,
11154
+ isMany: () => isMany,
11155
+ isReadableNodeStream: () => isReadableNodeStream,
11156
+ isReadableWebStream: () => isReadableWebStream,
11157
+ isWritableNodeStream: () => isWritableNodeStream,
11158
+ isWritableWebStream: () => isWritableWebStream,
11159
+ many: () => many,
11160
+ manySymbol: () => manySymbol,
11161
+ none: () => none,
11162
+ normalizeMany: () => normalizeMany,
11163
+ setFunctionList: () => setFunctionList,
11164
+ stop: () => stop,
11165
+ toMany: () => toMany
11166
+ });
11167
+ var none = /* @__PURE__ */ Symbol.for("object-stream.none");
11168
+ var stop = /* @__PURE__ */ Symbol.for("object-stream.stop");
11169
+ var finalSymbol = /* @__PURE__ */ Symbol.for("object-stream.final");
11170
+ var manySymbol = /* @__PURE__ */ Symbol.for("object-stream.many");
11171
+ var flushSymbol = /* @__PURE__ */ Symbol.for("object-stream.flush");
11172
+ var fListSymbol = /* @__PURE__ */ Symbol.for("object-stream.fList");
11173
+ var finalValue = (value) => ({ [finalSymbol]: 1, value });
11174
+ var many = (values) => ({ [manySymbol]: 1, values });
11175
+ var isFinalValue = (o) => o && o[finalSymbol] === 1;
11176
+ var isMany = (o) => o && o[manySymbol] === 1;
11177
+ var isFlushable = (o) => o && o[flushSymbol] === 1;
11178
+ var isFunctionList = (o) => o && o[fListSymbol] === 1;
11179
+ var getFinalValue = (o) => o.value;
11180
+ var getManyValues = (o) => o.values;
11181
+ var getFunctionList = (o) => o.fList;
11182
+ var flushable = (write2, final3 = null) => {
11183
+ const fn = final3 ? (value) => value === none ? final3() : write2(value) : write2;
11184
+ fn[flushSymbol] = 1;
11185
+ return fn;
11186
+ };
11187
+ var setFunctionList = (o, fns) => {
11188
+ o.fList = fns;
11189
+ o[fListSymbol] = 1;
11190
+ return o;
11191
+ };
11192
+ var clearFunctionList = (o) => {
11193
+ delete o.fList;
11194
+ delete o[fListSymbol];
11195
+ return o;
11196
+ };
11197
+ var Stop = class extends Error {
11198
+ };
11199
+ var toMany = (value) => value === none ? many([]) : value && value[manySymbol] === 1 ? value : many([value]);
11200
+ var normalizeMany = (o) => {
11201
+ if (o?.[manySymbol] === 1) {
11202
+ switch (o.values.length) {
11203
+ case 0:
11204
+ return none;
11205
+ case 1:
11206
+ return o.values[0];
11207
+ }
11208
+ }
11209
+ return o;
11210
+ };
11211
+ var combineMany = (...args) => {
11212
+ const values = [];
11213
+ for (let i = 0; i < args.length; ++i) {
11214
+ const a = args[i];
11215
+ if (a === none) continue;
11216
+ if (a?.[manySymbol] === 1) {
11217
+ values.push(...a.values);
11218
+ } else {
11219
+ values.push(a);
11220
+ }
11221
+ }
11222
+ return many(values);
11223
+ };
11224
+ var combineManyMut = (a, ...args) => {
11225
+ const values = a === none ? [] : a?.[manySymbol] === 1 ? a.values : [a];
11226
+ for (let i = 0; i < args.length; ++i) {
11227
+ const b = args[i];
11228
+ if (b === none) continue;
11229
+ if (b?.[manySymbol] === 1) {
11230
+ values.push(...b.values);
11231
+ } else {
11232
+ values.push(b);
11233
+ }
11234
+ }
11235
+ return many(values);
11236
+ };
11237
+ var isReadableWebStream = (x) => !!(x && typeof x === "object" && typeof x.getReader === "function" && typeof x.pipeTo === "function");
11238
+ var isWritableWebStream = (x) => !!(x && typeof x === "object" && typeof x.getWriter === "function" && typeof x.abort === "function");
11239
+ var isDuplexWebStream = (x) => !!(x && typeof x === "object" && isReadableWebStream(x.readable) && isWritableWebStream(x.writable));
11240
+ var isReadableNodeStream = (obj) => obj && typeof obj.pipe === "function" && typeof obj.on === "function" && (!obj._writableState || (typeof obj._readableState === "object" ? obj._readableState.readable : null) !== false) && (!obj._writableState || obj._readableState);
11241
+ var isWritableNodeStream = (obj) => obj && typeof obj.write === "function" && typeof obj.on === "function" && (!obj._readableState || (typeof obj._writableState === "object" ? obj._writableState.writable : null) !== false);
11242
+ var isDuplexNodeStream = (obj) => obj && typeof obj.pipe === "function" && obj._readableState && typeof obj.on === "function" && typeof obj.write === "function";
11243
+ var final = finalValue;
11244
+
11245
+ // node_modules/stream-chain/src/exec.js
11246
+ var next = (value, fns, index, push) => {
11247
+ for (let i = index; ; ) {
11248
+ if (value && typeof value.then == "function") {
11249
+ const ii = i;
11250
+ return value.then((v2) => next(v2, fns, ii, push));
11251
+ }
11252
+ if (value == null || value === none) return;
11253
+ if (value === stop) throw new Stop();
11254
+ if (isFinalValue(value)) {
11255
+ return push(getFinalValue(value));
11256
+ }
11257
+ if (isMany(value)) {
11258
+ return nextMany(getManyValues(value), fns, i, push);
11259
+ }
11260
+ if (value && typeof value.next == "function") {
11261
+ return nextGen(value, fns, i, push);
11262
+ }
11263
+ if (i >= fns.length) {
11264
+ return push(value);
11265
+ }
11266
+ value = fns[i++](value);
11267
+ }
11268
+ };
11269
+ var nextMany = (values, fns, i, push) => {
11270
+ const step = (j) => {
11271
+ for (; j < values.length; ++j) {
11272
+ const r = next(values[j], fns, i, push);
11273
+ if (r && typeof r.then == "function") {
11274
+ const jj = j;
11275
+ return r.then(() => step(jj + 1));
11276
+ }
11277
+ }
11278
+ };
11279
+ return step(0);
11280
+ };
11281
+ var nextGen = (it, fns, i, push) => {
11282
+ const step = () => {
11283
+ for (; ; ) {
11284
+ let data = it.next();
11285
+ if (data && typeof data.then == "function") {
11286
+ return data.then((d) => {
11287
+ if (d.done) return;
11288
+ const r3 = next(d.value, fns, i, push);
11289
+ return r3 && typeof r3.then == "function" ? r3.then(step) : step();
11290
+ });
11291
+ }
11292
+ if (data.done) return;
11293
+ const r2 = next(data.value, fns, i, push);
11294
+ if (r2 && typeof r2.then == "function") return r2.then(step);
11295
+ }
11296
+ };
11297
+ const abort = (err) => {
11298
+ const onCleanupError = (cleanupErr) => err instanceof Error ? new AggregateError([err, cleanupErr], "pipeline error; generator cleanup also failed") : err;
11299
+ let ret;
11300
+ try {
11301
+ ret = it.return ? it.return() : void 0;
11302
+ } catch (cleanupErr) {
11303
+ throw onCleanupError(cleanupErr);
11304
+ }
11305
+ if (ret && typeof ret.then == "function") {
11306
+ return ret.then(
11307
+ () => {
11308
+ throw err;
11309
+ },
11310
+ (cleanupErr) => {
11311
+ throw onCleanupError(cleanupErr);
11312
+ }
11313
+ );
11314
+ }
11315
+ throw err;
11316
+ };
11317
+ let r;
11318
+ try {
11319
+ r = step();
11320
+ } catch (err) {
11321
+ return abort(err);
11322
+ }
11323
+ return r && typeof r.then == "function" ? r.then(void 0, abort) : r;
11324
+ };
11325
+ var flush = (fns, index, push) => {
11326
+ const step = (i) => {
11327
+ for (; i < fns.length; ++i) {
11328
+ const f = fns[i];
11329
+ if (!isFlushable(f)) continue;
11330
+ const r = next(f(none), fns, i + 1, push);
11331
+ if (r && typeof r.then == "function") {
11332
+ const ii = i;
11333
+ return r.then(() => step(ii + 1));
11334
+ }
11335
+ }
11336
+ };
11337
+ return step(index);
11338
+ };
11339
+
11340
+ // node_modules/stream-chain/src/gen.js
11341
+ var gen = (...fns) => {
11342
+ fns = fns.filter((fn) => fn).flat(Infinity).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
11343
+ if (!fns.length) {
11344
+ fns = [(x) => x];
11345
+ }
11346
+ let flushed = false;
11347
+ let g = async function* (value) {
11348
+ if (flushed) throw Error("Call to a flushed pipe.");
11349
+ const isFlush = value === none;
11350
+ if (isFlush) flushed = true;
11351
+ const pending = [];
11352
+ let wakeConsumer = null;
11353
+ let resolveProducer = null;
11354
+ let rejectProducer = null;
11355
+ let done = false, error = null, cancelled = false;
11356
+ const CANCEL = /* @__PURE__ */ Symbol("cancel");
11357
+ const push = (v2) => {
11358
+ if (cancelled) throw CANCEL;
11359
+ pending.push(v2);
11360
+ if (wakeConsumer) {
11361
+ const w = wakeConsumer;
11362
+ wakeConsumer = null;
11363
+ w();
11364
+ }
11365
+ return new Promise((res, rej) => {
11366
+ resolveProducer = res;
11367
+ rejectProducer = rej;
11368
+ });
11369
+ };
11370
+ Promise.resolve().then(() => isFlush ? flush(fns, 0, push) : next(value, fns, 0, push)).then(
11371
+ () => {
11372
+ },
11373
+ (e) => {
11374
+ if (e !== CANCEL) error = e;
11375
+ }
11376
+ ).finally(() => {
11377
+ done = true;
11378
+ if (wakeConsumer) {
11379
+ const w = wakeConsumer;
11380
+ wakeConsumer = null;
11381
+ w();
11382
+ }
11383
+ });
11384
+ try {
11385
+ for (; ; ) {
11386
+ while (pending.length) {
11387
+ const v2 = pending.shift();
11388
+ if (resolveProducer) {
11389
+ const r = resolveProducer;
11390
+ resolveProducer = rejectProducer = null;
11391
+ r();
11392
+ }
11393
+ yield v2;
11394
+ }
11395
+ if (error) throw error;
11396
+ if (done) return;
11397
+ await new Promise((res) => wakeConsumer = res);
11398
+ }
11399
+ } finally {
11400
+ cancelled = true;
11401
+ if (rejectProducer) {
11402
+ const rj = rejectProducer;
11403
+ resolveProducer = rejectProducer = null;
11404
+ rj(CANCEL);
11405
+ }
11406
+ }
11407
+ };
11408
+ const needToFlush = fns.some((fn) => isFlushable(fn));
11409
+ if (needToFlush) g = flushable(g);
11410
+ return setFunctionList(g, fns);
11411
+ };
11412
+ var gen_default = gen;
11413
+
11414
+ // node_modules/stream-chain/src/asStream.js
11415
+ import { Duplex } from "node:stream";
11416
+ var asStream = (fn, options) => {
11417
+ if (typeof fn != "function") {
11418
+ throw TypeError("Only a function is accepted as the first argument");
11419
+ }
11420
+ const innerFns = isFunctionList(fn) ? fn.fList : null;
11421
+ let stopped = false;
11422
+ let nullPushed = false;
11423
+ let resolvePaused = null;
11424
+ let stream = null;
11425
+ const resume = () => {
11426
+ if (!resolvePaused) return;
11427
+ const resolve = resolvePaused;
11428
+ resolvePaused = null;
11429
+ resolve();
11430
+ };
11431
+ const signalEnd = () => {
11432
+ if (nullPushed) return;
11433
+ nullPushed = true;
11434
+ stream.push(null);
11435
+ };
11436
+ const enqueue = (value) => {
11437
+ if (stopped) return;
11438
+ if (!stream.push(value)) {
11439
+ return new Promise((resolve) => {
11440
+ resolvePaused = resolve;
11441
+ });
11442
+ }
11443
+ };
11444
+ const queue = [];
11445
+ const pump = async () => {
11446
+ while (queue.length) {
11447
+ const g = queue[queue.length - 1];
11448
+ let result = g.next();
11449
+ if (result && typeof result.then == "function") result = await result;
11450
+ if (result.done) {
11451
+ queue.pop();
11452
+ continue;
11453
+ }
11454
+ let value = result.value;
11455
+ if (value && typeof value.then == "function") value = await value;
11456
+ const r = processValue(value);
11457
+ if (r) await r;
11458
+ }
11459
+ };
11460
+ const processValue = (value) => {
11461
+ if (value && typeof value.then == "function") {
11462
+ return value.then(processValue);
11463
+ }
11464
+ if (value == null || value === none) return;
11465
+ if (value === stop) throw new Stop();
11466
+ if (isMany(value)) {
11467
+ const values = getManyValues(value);
11468
+ let promise;
11469
+ for (let i = 0; i < values.length; ++i) {
11470
+ if (promise) {
11471
+ const ii = i;
11472
+ promise = promise.then(() => processValue(values[ii]));
11473
+ } else {
11474
+ const r = processValue(values[i]);
11475
+ if (r) promise = r;
11476
+ }
11477
+ }
11478
+ return promise;
11479
+ }
11480
+ if (isFinalValue(value)) {
11481
+ return processValue(getFinalValue(value));
11482
+ }
11483
+ if (value && typeof value.next == "function") {
11484
+ queue.push(value);
11485
+ return pump();
11486
+ }
11487
+ return enqueue(value);
11488
+ };
11489
+ const absorbStop = (error) => {
11490
+ if (error instanceof Stop) {
11491
+ stopped = true;
11492
+ signalEnd();
11493
+ return true;
11494
+ }
11495
+ return false;
11496
+ };
11497
+ const finishWrite = (callback, error) => {
11498
+ if (!error) return callback(null);
11499
+ if (absorbStop(error)) return callback(null);
11500
+ callback(error);
11501
+ };
11502
+ stream = new Duplex({
11503
+ writableObjectMode: true,
11504
+ readableObjectMode: true,
11505
+ ...options,
11506
+ write(chunk, encoding, callback) {
11507
+ if (stopped) return callback(null);
11508
+ if (innerFns) {
11509
+ let r2;
11510
+ try {
11511
+ r2 = next(chunk, innerFns, 0, enqueue);
11512
+ } catch (error) {
11513
+ return finishWrite(callback, error);
11514
+ }
11515
+ if (r2 && typeof r2.then == "function") {
11516
+ r2.then(
11517
+ () => callback(null),
11518
+ (error) => finishWrite(callback, error)
11519
+ );
11520
+ } else {
11521
+ callback(null);
11522
+ }
11523
+ return;
11524
+ }
11525
+ let r;
11526
+ try {
11527
+ r = processValue(fn(chunk, encoding));
11528
+ } catch (error) {
11529
+ return finishWrite(callback, error);
11530
+ }
11531
+ if (r) {
11532
+ r.then(
11533
+ () => callback(null),
11534
+ (error) => finishWrite(callback, error)
11535
+ );
11536
+ } else {
11537
+ callback(null);
11538
+ }
11539
+ },
11540
+ final(callback) {
11541
+ const onComplete = () => {
11542
+ signalEnd();
11543
+ callback(null);
11544
+ };
11545
+ if (innerFns) {
11546
+ let r2;
11547
+ try {
11548
+ r2 = flush(innerFns, 0, enqueue);
11549
+ } catch (error) {
11550
+ return finishWrite(callback, error);
11551
+ }
11552
+ if (r2 && typeof r2.then == "function") {
11553
+ r2.then(onComplete, (error) => finishWrite(callback, error));
11554
+ } else {
11555
+ onComplete();
11556
+ }
11557
+ return;
11558
+ }
11559
+ if (!isFlushable(fn)) {
11560
+ onComplete();
11561
+ return;
11562
+ }
11563
+ let r;
11564
+ try {
11565
+ r = processValue(fn(none, null));
11566
+ } catch (error) {
11567
+ return finishWrite(callback, error);
11568
+ }
11569
+ if (r) {
11570
+ r.then(onComplete, (error) => finishWrite(callback, error));
11571
+ } else {
11572
+ onComplete();
11573
+ }
11574
+ },
11575
+ read() {
11576
+ resume();
11577
+ },
11578
+ // Unblock any pending paused-promise so an in-flight write can settle —
11579
+ // mirrors asWebStream's controller.signal listener for writer.abort().
11580
+ destroy(error, callback) {
11581
+ stopped = true;
11582
+ resume();
11583
+ callback(error);
11584
+ }
11585
+ });
11586
+ return stream;
11587
+ };
11588
+ var asStream_default = asStream;
11589
+
11590
+ // node_modules/stream-chain/src/asWebStream.js
11591
+ var asWebStream = (fn, options) => {
11592
+ if (isDuplexWebStream(fn) || isReadableWebStream(fn) || isWritableWebStream(fn)) {
11593
+ return fn;
11594
+ }
11595
+ if (typeof fn !== "function") {
11596
+ throw new TypeError("Only a function or Web Streams object is accepted as the first argument");
11597
+ }
11598
+ const strategy = options?.strategy;
11599
+ const readableStrategy = options?.readableStrategy ?? strategy;
11600
+ const writableStrategy = options?.writableStrategy ?? strategy;
11601
+ const innerFns = isFunctionList(fn) ? fn.fList : null;
11602
+ let stopped = false;
11603
+ let readableClosed = false;
11604
+ let writableErrored = false;
11605
+ let readableController;
11606
+ let writableController;
11607
+ let pendingDrain = null;
11608
+ const unblockDrain = () => {
11609
+ if (!pendingDrain) return;
11610
+ const resolve = pendingDrain;
11611
+ pendingDrain = null;
11612
+ resolve();
11613
+ };
11614
+ const closeReadable = () => {
11615
+ if (readableClosed) return;
11616
+ readableClosed = true;
11617
+ readableController.close();
11618
+ };
11619
+ const errorReadable = (reason) => {
11620
+ if (readableClosed) return;
11621
+ readableClosed = true;
11622
+ readableController.error(reason);
11623
+ };
11624
+ const errorWritable = (reason) => {
11625
+ if (writableErrored || !writableController) return;
11626
+ writableErrored = true;
11627
+ writableController.error(reason);
11628
+ };
11629
+ const readable = new ReadableStream(
11630
+ {
11631
+ start(c) {
11632
+ readableController = c;
11633
+ },
11634
+ pull() {
11635
+ unblockDrain();
11636
+ },
11637
+ cancel(reason) {
11638
+ stopped = true;
11639
+ readableClosed = true;
11640
+ unblockDrain();
11641
+ errorWritable(reason);
11642
+ }
11643
+ },
11644
+ readableStrategy
11645
+ );
11646
+ const enqueue = (value) => {
11647
+ if (stopped) return;
11648
+ readableController.enqueue(value);
11649
+ if (readableController.desiredSize <= 0) {
11650
+ return new Promise((resolve) => {
11651
+ pendingDrain = resolve;
11652
+ });
11653
+ }
11654
+ };
11655
+ const queue = [];
11656
+ const pump = async () => {
11657
+ while (queue.length) {
11658
+ const g = queue[queue.length - 1];
11659
+ let result = g.next();
11660
+ if (result && typeof result.then == "function") result = await result;
11661
+ if (result.done) {
11662
+ queue.pop();
11663
+ continue;
11664
+ }
11665
+ let value = result.value;
11666
+ if (value && typeof value.then == "function") value = await value;
11667
+ const r = processValue(value);
11668
+ if (r) await r;
11669
+ }
11670
+ };
11671
+ const processValue = (value) => {
11672
+ if (value && typeof value.then == "function") {
11673
+ return value.then(processValue);
11674
+ }
11675
+ if (value == null || value === none) return;
11676
+ if (value === stop) throw new Stop();
11677
+ if (isMany(value)) {
11678
+ const values = getManyValues(value);
11679
+ let promise;
11680
+ for (let i = 0; i < values.length; ++i) {
11681
+ if (promise) {
11682
+ const ii = i;
11683
+ promise = promise.then(() => processValue(values[ii]));
11684
+ } else {
11685
+ const r = processValue(values[i]);
11686
+ if (r) promise = r;
11687
+ }
11136
11688
  }
11689
+ return promise;
11690
+ }
11691
+ if (isFinalValue(value)) {
11692
+ return processValue(getFinalValue(value));
11693
+ }
11694
+ if (value && typeof value.next == "function") {
11695
+ queue.push(value);
11696
+ return pump();
11697
+ }
11698
+ return enqueue(value);
11699
+ };
11700
+ const absorbStop = (error) => {
11701
+ if (error instanceof Stop) {
11702
+ stopped = true;
11703
+ return true;
11137
11704
  }
11705
+ return false;
11706
+ };
11707
+ const writable = new WritableStream(
11708
+ {
11709
+ // `controller.signal` aborts during writer.abort() BEFORE the sink's
11710
+ // abort() callback runs. The spec waits for in-flight write() to
11711
+ // settle first — so if write() is awaiting pendingDrain, we'd
11712
+ // deadlock unless the signal listener wakes it.
11713
+ // Optional-chained because Bun ≤1.3.14 returns `undefined` for the
11714
+ // controller's signal (spec-required per WHATWG Streams §4.5.2 but
11715
+ // missing in Bun's builtin — see oven-sh/bun#31156 / PR #31157).
11716
+ // Fixed upstream (present in Bun 1.4.0); the chaining stays for older
11717
+ // Bun, which only loses the abort wakeup.
11718
+ start(controller) {
11719
+ writableController = controller;
11720
+ controller.signal?.addEventListener("abort", () => {
11721
+ stopped = true;
11722
+ unblockDrain();
11723
+ });
11724
+ },
11725
+ async write(chunk) {
11726
+ if (stopped) return;
11727
+ try {
11728
+ if (innerFns) {
11729
+ const r2 = next(chunk, innerFns, 0, enqueue);
11730
+ if (r2) await r2;
11731
+ return;
11732
+ }
11733
+ const r = processValue(fn(chunk));
11734
+ if (r) await r;
11735
+ } catch (error) {
11736
+ if (absorbStop(error)) return;
11737
+ errorReadable(error);
11738
+ throw error;
11739
+ }
11740
+ },
11741
+ async close() {
11742
+ try {
11743
+ if (!stopped) {
11744
+ if (innerFns) {
11745
+ const r = flush(innerFns, 0, enqueue);
11746
+ if (r) await r;
11747
+ } else if (isFlushable(fn)) {
11748
+ const r = processValue(fn(none));
11749
+ if (r) await r;
11750
+ }
11751
+ }
11752
+ } catch (error) {
11753
+ if (!absorbStop(error)) {
11754
+ errorReadable(error);
11755
+ throw error;
11756
+ }
11757
+ }
11758
+ closeReadable();
11759
+ },
11760
+ abort(reason) {
11761
+ stopped = true;
11762
+ unblockDrain();
11763
+ errorReadable(reason);
11764
+ }
11765
+ },
11766
+ writableStrategy
11767
+ );
11768
+ return { readable, writable };
11769
+ };
11770
+ var asWebStream_default = asWebStream;
11771
+
11772
+ // node_modules/stream-chain/src/dataSource.js
11773
+ var dataSource = (fn) => {
11774
+ if (typeof fn == "function") return fn;
11775
+ if (fn) {
11776
+ if (typeof fn[Symbol.asyncIterator] == "function") return fn[Symbol.asyncIterator].bind(fn);
11777
+ if (typeof fn[Symbol.iterator] == "function") return fn[Symbol.iterator].bind(fn);
11778
+ }
11779
+ throw new TypeError("The argument should be a function or an iterable object.");
11780
+ };
11781
+ var dataSource_default = dataSource;
11782
+
11783
+ // node_modules/stream-chain/src/index.js
11784
+ var {
11785
+ isReadableWebStream: isReadableWebStream2,
11786
+ isWritableWebStream: isWritableWebStream2,
11787
+ isDuplexWebStream: isDuplexWebStream2,
11788
+ isReadableNodeStream: isReadableNodeStream2,
11789
+ isWritableNodeStream: isWritableNodeStream2,
11790
+ isDuplexNodeStream: isDuplexNodeStream2
11791
+ } = defs_exports;
11792
+ var groupFunctions = (output, fn, index, fns) => {
11793
+ if (isDuplexNodeStream2(fn) || !index && isReadableNodeStream2(fn) || index === fns.length - 1 && isWritableNodeStream2(fn)) {
11794
+ output.push(fn);
11795
+ return output;
11796
+ }
11797
+ if (isDuplexWebStream2(fn)) {
11798
+ output.push(Duplex2.fromWeb(fn, { objectMode: true }));
11799
+ return output;
11800
+ }
11801
+ if (!index && isReadableWebStream2(fn)) {
11802
+ output.push(Readable.fromWeb(fn, { objectMode: true }));
11803
+ return output;
11804
+ }
11805
+ if (index === fns.length - 1 && isWritableWebStream2(fn)) {
11806
+ output.push(Writable.fromWeb(fn, { objectMode: true }));
11807
+ return output;
11808
+ }
11809
+ if (typeof fn != "function")
11810
+ throw TypeError("Item #" + index + " is not a proper stream, nor a function.");
11811
+ if (!output.length) output.push([]);
11812
+ const last = output[output.length - 1];
11813
+ if (Array.isArray(last)) {
11814
+ last.push(fn);
11138
11815
  } else {
11139
- for (let i = 0; i < lines.length; i++)
11140
- flatSlabPoints.push(lines[i]);
11816
+ output.push([fn]);
11817
+ }
11818
+ return output;
11819
+ };
11820
+ var produceStreams = (item) => {
11821
+ if (Array.isArray(item)) {
11822
+ if (!item.length) return null;
11823
+ if (item.length == 1) return item[0] && /** @type {any} */
11824
+ chain.asStream(item[0]);
11825
+ return (
11826
+ /** @type {any} */
11827
+ chain.asStream(
11828
+ /** @type {any} */
11829
+ chain.gen(...item)
11830
+ )
11831
+ );
11832
+ }
11833
+ return item;
11834
+ };
11835
+ var wrapFunctions = (fn, index, fns) => {
11836
+ if (isDuplexNodeStream2(fn) || !index && isReadableNodeStream2(fn) || index === fns.length - 1 && isWritableNodeStream2(fn)) {
11837
+ return fn;
11838
+ }
11839
+ if (isDuplexWebStream2(fn)) {
11840
+ return Duplex2.fromWeb(fn, { objectMode: true });
11841
+ }
11842
+ if (!index && isReadableWebStream2(fn)) {
11843
+ return Readable.fromWeb(fn, { objectMode: true });
11844
+ }
11845
+ if (index === fns.length - 1 && isWritableWebStream2(fn)) {
11846
+ return Writable.fromWeb(fn, { objectMode: true });
11847
+ }
11848
+ if (typeof fn == "function") return (
11849
+ /** @type {any} */
11850
+ chain.asStream(fn)
11851
+ );
11852
+ throw TypeError("Item #" + index + " is not a proper stream, nor a function.");
11853
+ };
11854
+ var write = (input, chunk, encoding, callback) => {
11855
+ let error = null;
11856
+ try {
11857
+ input.write(chunk, encoding, (e) => callback(e || error));
11858
+ } catch (e) {
11859
+ error = e;
11860
+ }
11861
+ };
11862
+ var final2 = (input, callback) => {
11863
+ let error = null;
11864
+ try {
11865
+ input.end(null, null, (e) => callback(e || error));
11866
+ } catch (e) {
11867
+ error = e;
11868
+ }
11869
+ };
11870
+ var read = (output) => {
11871
+ output.resume();
11872
+ };
11873
+ var chain = (fns, options) => {
11874
+ if (!Array.isArray(fns) || !fns.length) {
11875
+ throw TypeError("Chain's first argument should be a non-empty array.");
11876
+ }
11877
+ fns = fns.flat(Infinity).filter((fn) => fn);
11878
+ const streams = (options?.noGrouping ? fns.map(wrapFunctions) : fns.map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity).reduce(groupFunctions, []).map(produceStreams)).filter((s) => s), input = streams[0], output = streams.reduce((output2, item) => output2 && output2.pipe(item) || item);
11879
+ let stream = null;
11880
+ let writeMethod = (chunk, encoding, callback) => write(input, chunk, encoding, callback), finalMethod = (callback) => final2(input, callback), readMethod = () => read(output);
11881
+ if (!isWritableNodeStream2(input)) {
11882
+ writeMethod = (_1, _2, callback) => callback(null);
11883
+ finalMethod = (callback) => callback(null);
11884
+ input.on("end", () => stream.end());
11885
+ }
11886
+ if (isReadableNodeStream2(output)) {
11887
+ output.on("data", (chunk) => !stream.push(chunk) && output.pause());
11888
+ output.on("end", () => stream.push(null));
11889
+ } else {
11890
+ readMethod = () => {
11891
+ };
11892
+ output.on("finish", () => stream.push(null));
11893
+ }
11894
+ stream = /** @type {Duplex & {streams: any[], input: any, output: any}} */
11895
+ new Duplex2({
11896
+ writableObjectMode: true,
11897
+ readableObjectMode: true,
11898
+ ...options,
11899
+ readable: isReadableNodeStream2(output),
11900
+ writable: isWritableNodeStream2(input),
11901
+ write: writeMethod,
11902
+ final: finalMethod,
11903
+ read: readMethod
11904
+ });
11905
+ stream.streams = streams;
11906
+ stream.input = input;
11907
+ stream.output = output;
11908
+ if (!isReadableNodeStream2(output)) {
11909
+ stream.resume();
11910
+ }
11911
+ if (!options?.skipEvents) {
11912
+ streams.forEach((item) => item.on("error", (error) => stream.emit("error", error)));
11913
+ }
11914
+ return stream;
11915
+ };
11916
+ chain.none = none;
11917
+ chain.stop = stop;
11918
+ chain.Stop = Stop;
11919
+ chain.finalSymbol = finalSymbol;
11920
+ chain.finalValue = finalValue;
11921
+ chain.final = final;
11922
+ chain.isFinalValue = isFinalValue;
11923
+ chain.getFinalValue = getFinalValue;
11924
+ chain.manySymbol = manySymbol;
11925
+ chain.many = many;
11926
+ chain.isMany = isMany;
11927
+ chain.getManyValues = getManyValues;
11928
+ chain.flushSymbol = flushSymbol;
11929
+ chain.flushable = flushable;
11930
+ chain.isFlushable = isFlushable;
11931
+ chain.fListSymbol = fListSymbol;
11932
+ chain.isFunctionList = isFunctionList;
11933
+ chain.getFunctionList = getFunctionList;
11934
+ chain.setFunctionList = setFunctionList;
11935
+ chain.clearFunctionList = clearFunctionList;
11936
+ chain.toMany = toMany;
11937
+ chain.normalizeMany = normalizeMany;
11938
+ chain.combineMany = combineMany;
11939
+ chain.combineManyMut = combineManyMut;
11940
+ chain.chain = chain;
11941
+ chain.chainUnchecked = chain;
11942
+ chain.gen = gen_default;
11943
+ chain.asStream = asStream_default;
11944
+ chain.asWebStream = asWebStream_default;
11945
+ chain.dataSource = dataSource_default;
11946
+
11947
+ // node_modules/stream-chain/src/fun.js
11948
+ var asArray = (...fns) => {
11949
+ fns = fns.filter((fn) => fn).flat(Infinity).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
11950
+ if (!fns.length) {
11951
+ fns = [(x) => x];
11952
+ }
11953
+ let flushed = false;
11954
+ let g = (value) => {
11955
+ if (flushed) throw Error("Call to a flushed pipe.");
11956
+ const results = [], push = (v2) => {
11957
+ results.push(v2);
11958
+ };
11959
+ let pending;
11960
+ if (value !== none) {
11961
+ pending = next(value, fns, 0, push);
11962
+ } else {
11963
+ flushed = true;
11964
+ pending = flush(fns, 0, push);
11965
+ }
11966
+ return pending && typeof pending.then == "function" ? pending.then(() => results) : results;
11967
+ };
11968
+ const needToFlush = fns.some((fn) => isFlushable(fn));
11969
+ if (needToFlush) g = flushable(g);
11970
+ return setFunctionList(g, fns);
11971
+ };
11972
+ var fun = (...fns) => {
11973
+ const f = asArray(...fns);
11974
+ let g = (value) => {
11975
+ const result = (
11976
+ /** @type {any} */
11977
+ f(value)
11978
+ );
11979
+ if (result && typeof result.then == "function") {
11980
+ return result.then((results) => many(results));
11981
+ }
11982
+ return many(result);
11983
+ };
11984
+ if (isFlushable(f)) g = flushable(g);
11985
+ return setFunctionList(g, getFunctionList(f));
11986
+ };
11987
+ var fun_default = fun;
11988
+
11989
+ // node_modules/stream-chain/src/web/index.js
11990
+ var groupFunctions2 = (output, item, index, items) => {
11991
+ if (isDuplexWebStream(item)) {
11992
+ output.push(item);
11993
+ return output;
11994
+ }
11995
+ if (!index && isReadableWebStream(item)) {
11996
+ output.push({ readable: item, writable: null });
11997
+ return output;
11998
+ }
11999
+ if (index === items.length - 1 && isWritableWebStream(item)) {
12000
+ output.push({ readable: null, writable: item });
12001
+ return output;
12002
+ }
12003
+ if (typeof item !== "function") {
12004
+ throw new TypeError(`Item #${index} is not a Web Streams object or function.`);
12005
+ }
12006
+ if (!output.length) output.push([]);
12007
+ const last = output[output.length - 1];
12008
+ if (Array.isArray(last)) {
12009
+ last.push(item);
12010
+ } else {
12011
+ output.push([item]);
11141
12012
  }
11142
- const flatSlabDatas = getFlatSlabData(flatSlabPoints, runDataList, pointCloudCluster);
11143
- const flatFloorDatas = getFlatFloorData(flatSlabPoints, runDataList, pointCloudCluster);
11144
- const obliqueSlabDatas = getObliqueSlabData(obliqueSlabPoints, runDataList, pointCloudCluster);
11145
- return { flatSlabDatas, obliqueSlabDatas, flatFloorDatas };
12013
+ return output;
12014
+ };
12015
+ var makeProduceStages = (options) => (item) => {
12016
+ if (Array.isArray(item)) {
12017
+ if (!item.length) return null;
12018
+ if (item.length === 1) return (
12019
+ /** @type {any} */
12020
+ chain2.asWebStream(item[0], options)
12021
+ );
12022
+ return (
12023
+ /** @type {any} */
12024
+ chain2.asWebStream(
12025
+ /** @type {any} */
12026
+ chain2.gen(...item),
12027
+ options
12028
+ )
12029
+ );
12030
+ }
12031
+ return item;
12032
+ };
12033
+ var chain2 = (fns, options) => {
12034
+ if (!Array.isArray(fns) || !fns.length) {
12035
+ throw new TypeError("Chain's first argument should be a non-empty array.");
12036
+ }
12037
+ fns = fns.flat(Infinity).filter(Boolean).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
12038
+ if (!fns.length) {
12039
+ throw new TypeError("Chain's first argument is empty after flattening.");
12040
+ }
12041
+ const stages = fns.reduce(groupFunctions2, []).map(makeProduceStages(options)).filter((s) => s);
12042
+ for (let i = 0; i < stages.length - 1; ++i) {
12043
+ const from = stages[i].readable;
12044
+ const to = stages[i + 1].writable;
12045
+ if (!from) {
12046
+ throw new TypeError(`Stage #${i} has no readable side; cannot pipe to next stage.`);
12047
+ }
12048
+ if (!to) {
12049
+ throw new TypeError(`Stage #${i + 1} has no writable side; cannot accept input.`);
12050
+ }
12051
+ from.pipeTo(to).catch(() => {
12052
+ });
12053
+ }
12054
+ const c = {
12055
+ readable: stages[stages.length - 1].readable,
12056
+ writable: stages[0].writable,
12057
+ streams: stages,
12058
+ input: stages[0],
12059
+ output: stages[stages.length - 1]
12060
+ };
12061
+ return c;
12062
+ };
12063
+ chain2.none = none;
12064
+ chain2.stop = stop;
12065
+ chain2.Stop = Stop;
12066
+ chain2.finalSymbol = finalSymbol;
12067
+ chain2.finalValue = finalValue;
12068
+ chain2.final = final;
12069
+ chain2.isFinalValue = isFinalValue;
12070
+ chain2.getFinalValue = getFinalValue;
12071
+ chain2.manySymbol = manySymbol;
12072
+ chain2.many = many;
12073
+ chain2.isMany = isMany;
12074
+ chain2.getManyValues = getManyValues;
12075
+ chain2.flushSymbol = flushSymbol;
12076
+ chain2.flushable = flushable;
12077
+ chain2.isFlushable = isFlushable;
12078
+ chain2.fListSymbol = fListSymbol;
12079
+ chain2.isFunctionList = isFunctionList;
12080
+ chain2.getFunctionList = getFunctionList;
12081
+ chain2.setFunctionList = setFunctionList;
12082
+ chain2.clearFunctionList = clearFunctionList;
12083
+ chain2.toMany = toMany;
12084
+ chain2.normalizeMany = normalizeMany;
12085
+ chain2.combineMany = combineMany;
12086
+ chain2.combineManyMut = combineManyMut;
12087
+ chain2.chain = chain2;
12088
+ chain2.chainUnchecked = chain2;
12089
+ chain2.gen = gen_default;
12090
+ chain2.fun = fun_default;
12091
+ chain2.asWebStream = asWebStream_default;
12092
+ chain2.dataSource = dataSource_default;
12093
+
12094
+ // node_modules/stream-chain/src/core/index.js
12095
+ var chain3 = (fns, _options) => {
12096
+ const flat = (Array.isArray(fns) ? fns : []).flat(Infinity).filter(Boolean).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
12097
+ const g = gen_default(...flat);
12098
+ const c = async function* (input) {
12099
+ if (input == null) return;
12100
+ if (typeof input === "string" || input[Symbol.asyncIterator] === void 0 && input[Symbol.iterator] === void 0) {
12101
+ yield* g(input);
12102
+ return;
12103
+ }
12104
+ for await (const value of input) yield* g(value);
12105
+ };
12106
+ c.streams = null;
12107
+ c.input = null;
12108
+ c.output = null;
12109
+ return c;
12110
+ };
12111
+ chain3.none = none;
12112
+ chain3.stop = stop;
12113
+ chain3.Stop = Stop;
12114
+ chain3.finalSymbol = finalSymbol;
12115
+ chain3.finalValue = finalValue;
12116
+ chain3.final = final;
12117
+ chain3.isFinalValue = isFinalValue;
12118
+ chain3.getFinalValue = getFinalValue;
12119
+ chain3.manySymbol = manySymbol;
12120
+ chain3.many = many;
12121
+ chain3.isMany = isMany;
12122
+ chain3.getManyValues = getManyValues;
12123
+ chain3.flushSymbol = flushSymbol;
12124
+ chain3.flushable = flushable;
12125
+ chain3.isFlushable = isFlushable;
12126
+ chain3.fListSymbol = fListSymbol;
12127
+ chain3.isFunctionList = isFunctionList;
12128
+ chain3.getFunctionList = getFunctionList;
12129
+ chain3.setFunctionList = setFunctionList;
12130
+ chain3.clearFunctionList = clearFunctionList;
12131
+ chain3.toMany = toMany;
12132
+ chain3.normalizeMany = normalizeMany;
12133
+ chain3.combineMany = combineMany;
12134
+ chain3.combineManyMut = combineManyMut;
12135
+ chain3.chain = chain3;
12136
+ chain3.chainUnchecked = chain3;
12137
+ chain3.gen = gen_default;
12138
+ chain3.fun = fun_default;
12139
+ chain3.dataSource = dataSource_default;
12140
+
12141
+ // node_modules/stream-chain/src/utils/fixUtf8Stream.js
12142
+ var makeTextDecoderImpl = () => {
12143
+ const textDecoder = new TextDecoder();
12144
+ return flushable((chunk) => {
12145
+ if (chunk === none) return textDecoder.decode();
12146
+ if (typeof chunk == "string") return chunk;
12147
+ if (chunk instanceof Uint8Array) return textDecoder.decode(chunk, { stream: true });
12148
+ throw new TypeError("Expected a string or a Uint8Array");
12149
+ });
12150
+ };
12151
+ var makeStringDecoderImpl = (StringDecoder) => () => {
12152
+ const stringDecoder = new StringDecoder();
12153
+ return flushable((chunk) => {
12154
+ if (chunk === none) return stringDecoder.end();
12155
+ if (typeof chunk == "string") return chunk;
12156
+ if (chunk instanceof Uint8Array) return stringDecoder.write(chunk);
12157
+ throw new TypeError("Expected a string or a Uint8Array");
12158
+ });
11146
12159
  };
12160
+ var impl = makeTextDecoderImpl;
12161
+ var isDeno = typeof globalThis["Deno"] == "object" && globalThis["Deno"]?.version;
12162
+ var isBun = typeof globalThis["Bun"] == "object" && globalThis["Bun"]?.version;
12163
+ var isNode = !isDeno && !isBun && typeof process == "object" && process?.versions?.node;
12164
+ var readyPromise = isNode ? import("node:string_decoder").then(
12165
+ ({ StringDecoder }) => {
12166
+ impl = makeStringDecoderImpl(StringDecoder);
12167
+ },
12168
+ () => {
12169
+ }
12170
+ // squelch — stick with TextDecoder
12171
+ ) : Promise.resolve();
12172
+ var fixUtf8Stream = () => impl();
12173
+ var fixUtf8Stream_default = fixUtf8Stream;
12174
+
12175
+ // node_modules/stream-json/src/core/parser.js
12176
+ var patterns = {
12177
+ value1: /[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256}/y,
12178
+ string: /[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\"/y,
12179
+ numberStart: /\d/y,
12180
+ numberDigit: /\d{0,256}/y,
12181
+ numberFraction: /[\.eE]/y,
12182
+ numberExponent: /[eE]/y,
12183
+ numberExpSign: /[-+]/y
12184
+ };
12185
+ var MAX_PATTERN_SIZE = 16;
12186
+ patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
12187
+ patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
12188
+ var expected = { object: "objectStop", array: "arrayStop", "": "done" };
12189
+ var tokenStartObject = { name: "startObject" };
12190
+ var tokenEndObject = { name: "endObject" };
12191
+ var tokenStartArray = { name: "startArray" };
12192
+ var tokenEndArray = { name: "endArray" };
12193
+ var tokenStartString = { name: "startString" };
12194
+ var tokenEndString = { name: "endString" };
12195
+ var tokenStartNumber = { name: "startNumber" };
12196
+ var tokenEndNumber = { name: "endNumber" };
12197
+ var tokenStartKey = { name: "startKey" };
12198
+ var tokenEndKey = { name: "endKey" };
12199
+ var literalTokens = {
12200
+ true: { name: "trueValue", value: true },
12201
+ false: { name: "falseValue", value: false },
12202
+ null: { name: "nullValue", value: null }
12203
+ };
12204
+ var fromHex = (s) => String.fromCharCode(parseInt(s.slice(2), 16));
12205
+ var codes = { b: "\b", f: "\f", n: "\n", r: "\r", t: " ", '"': '"', "\\": "\\", "/": "/" };
12206
+ var ASCII_TAB = " ".charCodeAt(0);
12207
+ var ASCII_LF = "\n".charCodeAt(0);
12208
+ var ASCII_CR = "\r".charCodeAt(0);
12209
+ var ASCII_SPACE = " ".charCodeAt(0);
12210
+ var ASCII_QUOTE = '"'.charCodeAt(0);
12211
+ var ASCII_BACKSLASH = "\\".charCodeAt(0);
12212
+ var ASCII_OPEN_BRACE = "{".charCodeAt(0);
12213
+ var ASCII_CLOSE_BRACE = "}".charCodeAt(0);
12214
+ var ASCII_OPEN_BRACKET = "[".charCodeAt(0);
12215
+ var ASCII_CLOSE_BRACKET = "]".charCodeAt(0);
12216
+ var ASCII_MINUS = "-".charCodeAt(0);
12217
+ var ASCII_COLON = ":".charCodeAt(0);
12218
+ var ASCII_COMMA = ",".charCodeAt(0);
12219
+ var ASCII_ZERO = "0".charCodeAt(0);
12220
+ var ASCII_NINE = "9".charCodeAt(0);
12221
+ var ASCII_UPPER_A = "A".charCodeAt(0);
12222
+ var ASCII_UPPER_F = "F".charCodeAt(0);
12223
+ var ASCII_LOWER_A = "a".charCodeAt(0);
12224
+ var ASCII_LOWER_F = "f".charCodeAt(0);
12225
+ var ASCII_LOWER_N = "n".charCodeAt(0);
12226
+ var ASCII_LOWER_T = "t".charCodeAt(0);
12227
+ var ASCII_LOWER_U = "u".charCodeAt(0);
12228
+ var TERM = [];
12229
+ for (const ch of ",}] \n\r") TERM[ch.charCodeAt(0)] = 1;
12230
+ var numberFull = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/y;
12231
+ var HEX = (c) => c >= ASCII_ZERO && c <= ASCII_NINE || c >= ASCII_UPPER_A && c <= ASCII_UPPER_F || c >= ASCII_LOWER_A && c <= ASCII_LOWER_F;
12232
+ var jsonParser = (options) => {
12233
+ let packKeys = true, packStrings = true, packNumbers = true, streamKeys = true, streamStrings = true, streamNumbers = true, jsonStreaming = false;
12234
+ if (options) {
12235
+ "packValues" in options && (packKeys = packStrings = packNumbers = options.packValues);
12236
+ "packKeys" in options && (packKeys = options.packKeys);
12237
+ "packStrings" in options && (packStrings = options.packStrings);
12238
+ "packNumbers" in options && (packNumbers = options.packNumbers);
12239
+ "streamValues" in options && (streamKeys = streamStrings = streamNumbers = options.streamValues);
12240
+ "streamKeys" in options && (streamKeys = options.streamKeys);
12241
+ "streamStrings" in options && (streamStrings = options.streamStrings);
12242
+ "streamNumbers" in options && (streamNumbers = options.streamNumbers);
12243
+ jsonStreaming = options.jsonStreaming;
12244
+ }
12245
+ !packKeys && (streamKeys = true);
12246
+ !packStrings && (streamStrings = true);
12247
+ !packNumbers && (streamNumbers = true);
12248
+ let done = false, expect = jsonStreaming ? "done" : "value", parent = "", openNumber = false, accumulator = "", buffer = "";
12249
+ const stack = [];
12250
+ return flushable((buf) => {
12251
+ const tokens = [];
12252
+ if (buf === none) {
12253
+ done = true;
12254
+ } else {
12255
+ buffer += buf;
12256
+ }
12257
+ let match, fm, s, e, q, rs, cc2, value, index = 0;
12258
+ main: for (; ; ) {
12259
+ switch (expect) {
12260
+ case "value1":
12261
+ case "value": {
12262
+ while (index < buffer.length) {
12263
+ cc2 = buffer.charCodeAt(index);
12264
+ if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
12265
+ ++index;
12266
+ continue;
12267
+ }
12268
+ break;
12269
+ }
12270
+ if (index >= buffer.length) {
12271
+ if (done) throw new Error("Parser has expected a value");
12272
+ break main;
12273
+ }
12274
+ cc2 = buffer.charCodeAt(index);
12275
+ if (cc2 === ASCII_QUOTE) {
12276
+ q = index + 1;
12277
+ rs = q;
12278
+ s = "";
12279
+ for (; ; ) {
12280
+ if (q >= buffer.length) {
12281
+ q = -1;
12282
+ break;
12283
+ }
12284
+ e = buffer.charCodeAt(q);
12285
+ if (e === ASCII_QUOTE) {
12286
+ s += buffer.slice(rs, q);
12287
+ break;
12288
+ }
12289
+ if (e < ASCII_SPACE) {
12290
+ q = -1;
12291
+ break;
12292
+ }
12293
+ if (e === ASCII_BACKSLASH) {
12294
+ if (q + 1 >= buffer.length) {
12295
+ q = -1;
12296
+ break;
12297
+ }
12298
+ cc2 = buffer.charCodeAt(q + 1);
12299
+ if (cc2 === ASCII_LOWER_U) {
12300
+ if (q + 6 > buffer.length || !(HEX(buffer.charCodeAt(q + 2)) && HEX(buffer.charCodeAt(q + 3)) && HEX(buffer.charCodeAt(q + 4)) && HEX(buffer.charCodeAt(q + 5)))) {
12301
+ q = -1;
12302
+ break;
12303
+ }
12304
+ s += buffer.slice(rs, q) + String.fromCharCode(parseInt(buffer.slice(q + 2, q + 6), 16));
12305
+ q += 6;
12306
+ } else {
12307
+ value = codes[buffer.charAt(q + 1)];
12308
+ if (value === void 0) {
12309
+ q = -1;
12310
+ break;
12311
+ }
12312
+ s += buffer.slice(rs, q) + value;
12313
+ q += 2;
12314
+ }
12315
+ rs = q;
12316
+ continue;
12317
+ }
12318
+ ++q;
12319
+ }
12320
+ if (q >= 0) {
12321
+ if (streamStrings) {
12322
+ tokens.push(tokenStartString);
12323
+ if (s) tokens.push({ name: "stringChunk", value: s });
12324
+ tokens.push(tokenEndString);
12325
+ }
12326
+ if (packStrings) tokens.push({ name: "stringValue", value: s });
12327
+ index = q + 1;
12328
+ expect = expected[parent];
12329
+ continue main;
12330
+ }
12331
+ if (streamStrings) tokens.push(tokenStartString);
12332
+ expect = "string";
12333
+ ++index;
12334
+ continue main;
12335
+ }
12336
+ if (cc2 === ASCII_OPEN_BRACE) {
12337
+ tokens.push(tokenStartObject);
12338
+ stack.push(parent);
12339
+ parent = "object";
12340
+ expect = "key1";
12341
+ ++index;
12342
+ continue main;
12343
+ }
12344
+ if (cc2 === ASCII_OPEN_BRACKET) {
12345
+ tokens.push(tokenStartArray);
12346
+ stack.push(parent);
12347
+ parent = "array";
12348
+ expect = "value1";
12349
+ ++index;
12350
+ continue main;
12351
+ }
12352
+ if (cc2 === ASCII_CLOSE_BRACKET) {
12353
+ if (expect !== "value1") throw new Error("Parser cannot parse input: unexpected token ']'");
12354
+ tokens.push(tokenEndArray);
12355
+ parent = stack.pop();
12356
+ expect = expected[parent];
12357
+ ++index;
12358
+ continue main;
12359
+ }
12360
+ if (cc2 === ASCII_MINUS || cc2 >= ASCII_ZERO && cc2 <= ASCII_NINE) {
12361
+ numberFull.lastIndex = index;
12362
+ fm = numberFull.exec(buffer);
12363
+ if (fm) {
12364
+ e = index + fm[0].length;
12365
+ if (e < buffer.length && TERM[buffer.charCodeAt(e)]) {
12366
+ s = fm[0];
12367
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: s }, tokenEndNumber);
12368
+ if (packNumbers) tokens.push({ name: "numberValue", value: s });
12369
+ index = e;
12370
+ expect = expected[parent];
12371
+ continue main;
12372
+ }
12373
+ }
12374
+ openNumber = true;
12375
+ if (cc2 === ASCII_MINUS) {
12376
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: "-" });
12377
+ packNumbers && (accumulator = "-");
12378
+ expect = "numberStart";
12379
+ } else if (cc2 === ASCII_ZERO) {
12380
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: "0" });
12381
+ packNumbers && (accumulator = "0");
12382
+ expect = "numberFraction";
12383
+ } else {
12384
+ s = buffer.charAt(index);
12385
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: s });
12386
+ packNumbers && (accumulator = s);
12387
+ expect = "numberDigit";
12388
+ }
12389
+ ++index;
12390
+ continue main;
12391
+ }
12392
+ if (cc2 === ASCII_LOWER_T || cc2 === ASCII_LOWER_F || cc2 === ASCII_LOWER_N) {
12393
+ patterns.value1.lastIndex = index;
12394
+ match = patterns.value1.exec(buffer);
12395
+ if (!match) {
12396
+ if (done || index + MAX_PATTERN_SIZE < buffer.length) {
12397
+ throw new Error("Parser cannot parse input: expected a value");
12398
+ }
12399
+ break main;
12400
+ }
12401
+ value = match[0];
12402
+ if (buffer.length - index === value.length && !done) break main;
12403
+ tokens.push(literalTokens[value]);
12404
+ expect = expected[parent];
12405
+ index += value.length;
12406
+ continue main;
12407
+ }
12408
+ throw new Error("Parser cannot parse input: expected a value");
12409
+ }
12410
+ // incremental string body (escapes / long / cross-chunk)
12411
+ case "keyVal":
12412
+ case "string":
12413
+ patterns.string.lastIndex = index;
12414
+ match = patterns.string.exec(buffer);
12415
+ if (!match) {
12416
+ if (index < buffer.length && (done || buffer.length - index >= 6)) throw new Error("Parser cannot parse input: escaped characters");
12417
+ if (done) throw new Error("Parser has expected a string value");
12418
+ break main;
12419
+ }
12420
+ value = match[0];
12421
+ if (value === '"') {
12422
+ if (expect === "keyVal") {
12423
+ if (streamKeys) tokens.push(tokenEndKey);
12424
+ if (packKeys) {
12425
+ tokens.push({ name: "keyValue", value: accumulator });
12426
+ accumulator = "";
12427
+ }
12428
+ expect = "colon";
12429
+ } else {
12430
+ if (streamStrings) tokens.push(tokenEndString);
12431
+ if (packStrings) {
12432
+ tokens.push({ name: "stringValue", value: accumulator });
12433
+ accumulator = "";
12434
+ }
12435
+ expect = expected[parent];
12436
+ }
12437
+ } else if (value.length > 1 && value.charAt(0) === "\\") {
12438
+ const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value);
12439
+ if (expect === "keyVal" ? streamKeys : streamStrings) {
12440
+ tokens.push({ name: "stringChunk", value: t });
12441
+ }
12442
+ if (expect === "keyVal" ? packKeys : packStrings) {
12443
+ accumulator += t;
12444
+ }
12445
+ } else {
12446
+ if (expect === "keyVal" ? streamKeys : streamStrings) {
12447
+ tokens.push({ name: "stringChunk", value });
12448
+ }
12449
+ if (expect === "keyVal" ? packKeys : packStrings) {
12450
+ accumulator += value;
12451
+ }
12452
+ }
12453
+ index += value.length;
12454
+ break;
12455
+ case "key1":
12456
+ case "key": {
12457
+ while (index < buffer.length) {
12458
+ cc2 = buffer.charCodeAt(index);
12459
+ if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
12460
+ ++index;
12461
+ continue;
12462
+ }
12463
+ break;
12464
+ }
12465
+ if (index >= buffer.length) {
12466
+ if (done) throw new Error("Parser cannot parse input: expected an object key");
12467
+ break main;
12468
+ }
12469
+ cc2 = buffer.charCodeAt(index);
12470
+ if (cc2 === ASCII_QUOTE) {
12471
+ q = index + 1;
12472
+ rs = q;
12473
+ s = "";
12474
+ for (; ; ) {
12475
+ if (q >= buffer.length) {
12476
+ q = -1;
12477
+ break;
12478
+ }
12479
+ e = buffer.charCodeAt(q);
12480
+ if (e === ASCII_QUOTE) {
12481
+ s += buffer.slice(rs, q);
12482
+ break;
12483
+ }
12484
+ if (e < ASCII_SPACE) {
12485
+ q = -1;
12486
+ break;
12487
+ }
12488
+ if (e === ASCII_BACKSLASH) {
12489
+ if (q + 1 >= buffer.length) {
12490
+ q = -1;
12491
+ break;
12492
+ }
12493
+ cc2 = buffer.charCodeAt(q + 1);
12494
+ if (cc2 === ASCII_LOWER_U) {
12495
+ if (q + 6 > buffer.length || !(HEX(buffer.charCodeAt(q + 2)) && HEX(buffer.charCodeAt(q + 3)) && HEX(buffer.charCodeAt(q + 4)) && HEX(buffer.charCodeAt(q + 5)))) {
12496
+ q = -1;
12497
+ break;
12498
+ }
12499
+ s += buffer.slice(rs, q) + String.fromCharCode(parseInt(buffer.slice(q + 2, q + 6), 16));
12500
+ q += 6;
12501
+ } else {
12502
+ value = codes[buffer.charAt(q + 1)];
12503
+ if (value === void 0) {
12504
+ q = -1;
12505
+ break;
12506
+ }
12507
+ s += buffer.slice(rs, q) + value;
12508
+ q += 2;
12509
+ }
12510
+ rs = q;
12511
+ continue;
12512
+ }
12513
+ ++q;
12514
+ }
12515
+ if (q >= 0) {
12516
+ if (streamKeys) {
12517
+ tokens.push(tokenStartKey);
12518
+ if (s) tokens.push({ name: "stringChunk", value: s });
12519
+ tokens.push(tokenEndKey);
12520
+ }
12521
+ if (packKeys) tokens.push({ name: "keyValue", value: s });
12522
+ index = q + 1;
12523
+ expect = "colon";
12524
+ continue main;
12525
+ }
12526
+ if (streamKeys) tokens.push(tokenStartKey);
12527
+ expect = "keyVal";
12528
+ ++index;
12529
+ continue main;
12530
+ }
12531
+ if (cc2 === ASCII_CLOSE_BRACE) {
12532
+ if (expect !== "key1") throw new Error("Parser cannot parse input: unexpected token '}'");
12533
+ tokens.push(tokenEndObject);
12534
+ parent = stack.pop();
12535
+ expect = expected[parent];
12536
+ ++index;
12537
+ continue main;
12538
+ }
12539
+ throw new Error("Parser cannot parse input: expected an object key");
12540
+ }
12541
+ case "colon": {
12542
+ while (index < buffer.length) {
12543
+ cc2 = buffer.charCodeAt(index);
12544
+ if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
12545
+ ++index;
12546
+ continue;
12547
+ }
12548
+ break;
12549
+ }
12550
+ if (index >= buffer.length) {
12551
+ if (done) throw new Error("Parser cannot parse input: expected ':'");
12552
+ break main;
12553
+ }
12554
+ cc2 = buffer.charCodeAt(index);
12555
+ if (cc2 === ASCII_COLON) {
12556
+ expect = "value";
12557
+ ++index;
12558
+ continue main;
12559
+ }
12560
+ throw new Error("Parser cannot parse input: expected ':'");
12561
+ }
12562
+ case "arrayStop":
12563
+ case "objectStop": {
12564
+ while (index < buffer.length) {
12565
+ cc2 = buffer.charCodeAt(index);
12566
+ if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
12567
+ ++index;
12568
+ continue;
12569
+ }
12570
+ break;
12571
+ }
12572
+ if (index >= buffer.length) {
12573
+ if (done) throw new Error("Parser cannot parse input: expected ','");
12574
+ break main;
12575
+ }
12576
+ if (openNumber) {
12577
+ if (streamNumbers) tokens.push(tokenEndNumber);
12578
+ openNumber = false;
12579
+ if (packNumbers) {
12580
+ tokens.push({ name: "numberValue", value: accumulator });
12581
+ accumulator = "";
12582
+ }
12583
+ }
12584
+ cc2 = buffer.charCodeAt(index);
12585
+ if (cc2 === ASCII_COMMA) {
12586
+ expect = expect === "arrayStop" ? "value" : "key";
12587
+ ++index;
12588
+ continue main;
12589
+ }
12590
+ if (cc2 === ASCII_CLOSE_BRACE || cc2 === ASCII_CLOSE_BRACKET) {
12591
+ if (cc2 === ASCII_CLOSE_BRACE ? expect === "arrayStop" : expect !== "arrayStop") {
12592
+ throw new Error("Parser cannot parse input: expected '" + (expect === "arrayStop" ? "]" : "}") + "'");
12593
+ }
12594
+ tokens.push(cc2 === ASCII_CLOSE_BRACE ? tokenEndObject : tokenEndArray);
12595
+ parent = stack.pop();
12596
+ expect = expected[parent];
12597
+ ++index;
12598
+ continue main;
12599
+ }
12600
+ throw new Error("Parser cannot parse input: expected ','");
12601
+ }
12602
+ // number chunks — cross-chunk / fallback
12603
+ case "numberStart":
12604
+ patterns.numberStart.lastIndex = index;
12605
+ match = patterns.numberStart.exec(buffer);
12606
+ if (!match) {
12607
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a starting digit");
12608
+ break main;
12609
+ }
12610
+ value = match[0];
12611
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12612
+ packNumbers && (accumulator += value);
12613
+ expect = value === "0" ? "numberFraction" : "numberDigit";
12614
+ index += value.length;
12615
+ break;
12616
+ case "numberDigit":
12617
+ patterns.numberDigit.lastIndex = index;
12618
+ match = patterns.numberDigit.exec(buffer);
12619
+ if (!match) {
12620
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a digit");
12621
+ break main;
12622
+ }
12623
+ value = match[0];
12624
+ if (value) {
12625
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12626
+ packNumbers && (accumulator += value);
12627
+ index += value.length;
12628
+ } else {
12629
+ if (index < buffer.length) {
12630
+ expect = "numberFraction";
12631
+ break;
12632
+ }
12633
+ if (done) {
12634
+ expect = expected[parent];
12635
+ break;
12636
+ }
12637
+ break main;
12638
+ }
12639
+ break;
12640
+ case "numberFraction":
12641
+ patterns.numberFraction.lastIndex = index;
12642
+ match = patterns.numberFraction.exec(buffer);
12643
+ if (!match) {
12644
+ if (index < buffer.length || done) {
12645
+ expect = expected[parent];
12646
+ break;
12647
+ }
12648
+ break main;
12649
+ }
12650
+ value = match[0];
12651
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12652
+ packNumbers && (accumulator += value);
12653
+ expect = value === "." ? "numberFracStart" : "numberExpSign";
12654
+ index += value.length;
12655
+ break;
12656
+ case "numberFracStart":
12657
+ patterns.numberFracStart.lastIndex = index;
12658
+ match = patterns.numberFracStart.exec(buffer);
12659
+ if (!match) {
12660
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a fractional part of a number");
12661
+ break main;
12662
+ }
12663
+ value = match[0];
12664
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12665
+ packNumbers && (accumulator += value);
12666
+ expect = "numberFracDigit";
12667
+ index += value.length;
12668
+ break;
12669
+ case "numberFracDigit":
12670
+ patterns.numberFracDigit.lastIndex = index;
12671
+ match = patterns.numberFracDigit.exec(buffer);
12672
+ value = match[0];
12673
+ if (value) {
12674
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12675
+ packNumbers && (accumulator += value);
12676
+ index += value.length;
12677
+ } else {
12678
+ if (index < buffer.length) {
12679
+ expect = "numberExponent";
12680
+ break;
12681
+ }
12682
+ if (done) {
12683
+ expect = expected[parent];
12684
+ break;
12685
+ }
12686
+ break main;
12687
+ }
12688
+ break;
12689
+ case "numberExponent":
12690
+ patterns.numberExponent.lastIndex = index;
12691
+ match = patterns.numberExponent.exec(buffer);
12692
+ if (!match) {
12693
+ if (index < buffer.length) {
12694
+ expect = expected[parent];
12695
+ break;
12696
+ }
12697
+ if (done) {
12698
+ expect = expected[parent];
12699
+ break;
12700
+ }
12701
+ break main;
12702
+ }
12703
+ value = match[0];
12704
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12705
+ packNumbers && (accumulator += value);
12706
+ expect = "numberExpSign";
12707
+ index += value.length;
12708
+ break;
12709
+ case "numberExpSign":
12710
+ patterns.numberExpSign.lastIndex = index;
12711
+ match = patterns.numberExpSign.exec(buffer);
12712
+ if (!match) {
12713
+ if (index < buffer.length) {
12714
+ expect = "numberExpStart";
12715
+ break;
12716
+ }
12717
+ if (done) throw new Error("Parser has expected an exponent value of a number");
12718
+ break main;
12719
+ }
12720
+ value = match[0];
12721
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12722
+ packNumbers && (accumulator += value);
12723
+ expect = "numberExpStart";
12724
+ index += value.length;
12725
+ break;
12726
+ case "numberExpStart":
12727
+ patterns.numberExpStart.lastIndex = index;
12728
+ match = patterns.numberExpStart.exec(buffer);
12729
+ if (!match) {
12730
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected an exponent part of a number");
12731
+ break main;
12732
+ }
12733
+ value = match[0];
12734
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12735
+ packNumbers && (accumulator += value);
12736
+ expect = "numberExpDigit";
12737
+ index += value.length;
12738
+ break;
12739
+ case "numberExpDigit":
12740
+ patterns.numberExpDigit.lastIndex = index;
12741
+ match = patterns.numberExpDigit.exec(buffer);
12742
+ value = match[0];
12743
+ if (value) {
12744
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
12745
+ packNumbers && (accumulator += value);
12746
+ index += value.length;
12747
+ } else {
12748
+ if (index < buffer.length || done) {
12749
+ expect = expected[parent];
12750
+ break;
12751
+ }
12752
+ break main;
12753
+ }
12754
+ break;
12755
+ case "done": {
12756
+ while (index < buffer.length) {
12757
+ cc2 = buffer.charCodeAt(index);
12758
+ if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
12759
+ if (openNumber) {
12760
+ if (streamNumbers) tokens.push(tokenEndNumber);
12761
+ openNumber = false;
12762
+ if (packNumbers) {
12763
+ tokens.push({ name: "numberValue", value: accumulator });
12764
+ accumulator = "";
12765
+ }
12766
+ }
12767
+ ++index;
12768
+ continue;
12769
+ }
12770
+ break;
12771
+ }
12772
+ if (index >= buffer.length) break main;
12773
+ if (jsonStreaming) {
12774
+ if (openNumber) {
12775
+ if (streamNumbers) tokens.push(tokenEndNumber);
12776
+ openNumber = false;
12777
+ if (packNumbers) {
12778
+ tokens.push({ name: "numberValue", value: accumulator });
12779
+ accumulator = "";
12780
+ }
12781
+ }
12782
+ expect = "value";
12783
+ continue main;
12784
+ }
12785
+ throw new Error("Parser cannot parse input: unexpected characters");
12786
+ }
12787
+ }
12788
+ }
12789
+ if (done && openNumber) {
12790
+ if (streamNumbers) tokens.push(tokenEndNumber);
12791
+ openNumber = false;
12792
+ if (packNumbers) {
12793
+ tokens.push({ name: "numberValue", value: accumulator });
12794
+ accumulator = "";
12795
+ }
12796
+ }
12797
+ buffer = buffer.slice(index);
12798
+ return tokens.length ? many(tokens) : none;
12799
+ });
12800
+ };
12801
+ var parser = (options) => gen_default(fixUtf8Stream_default(), jsonParser(options));
12802
+ parser.parser = parser;
12803
+ var parser_default = parser;
12804
+
12805
+ // node_modules/stream-json/src/parser.js
12806
+ parser_default.asStream = (options) => asStream_default(parser_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
12807
+ parser_default.asWebStream = (options) => asWebStream_default(parser_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
12808
+ var parser_default2 = parser_default;
12809
+
12810
+ // node_modules/stream-json/src/index.js
12811
+ var parserStream = parser_default2.asStream;
12812
+
12813
+ // node_modules/stream-json/src/core/assembler.js
12814
+ var startObject = (Ctr) => (
12815
+ /** @this {Assembler} */
12816
+ function() {
12817
+ if (this.done) {
12818
+ this.done = false;
12819
+ } else {
12820
+ this.stack.push(this.current, this.key);
12821
+ }
12822
+ this.current = new Ctr();
12823
+ this.key = null;
12824
+ }
12825
+ );
12826
+ var Assembler = class _Assembler {
12827
+ static connectTo(stream, options) {
12828
+ return new _Assembler(options).connectTo(stream);
12829
+ }
12830
+ constructor(options) {
12831
+ this.stack = [];
12832
+ this.current = this.key = null;
12833
+ this.done = true;
12834
+ this._onDone = null;
12835
+ if (options) {
12836
+ this.reviver = typeof options.reviver == "function" && options.reviver;
12837
+ if (this.reviver) {
12838
+ this.stringValue = this._saveValue = this._saveValueWithReviver;
12839
+ }
12840
+ if (options.numberAsString) {
12841
+ this.numberValue = this.stringValue;
12842
+ }
12843
+ if (typeof options.onDone == "function") {
12844
+ this._onDone = options.onDone;
12845
+ }
12846
+ }
12847
+ this.tapChain = (chunk) => {
12848
+ if (this[chunk.name]) {
12849
+ this[chunk.name](chunk.value);
12850
+ if (this.done) return this.current;
12851
+ }
12852
+ return none;
12853
+ };
12854
+ }
12855
+ connectTo(stream) {
12856
+ const consume = (chunk) => {
12857
+ if (this[chunk.name]) {
12858
+ this[chunk.name](chunk.value);
12859
+ if (this.done) this._onDone?.(this);
12860
+ }
12861
+ };
12862
+ if (typeof stream?.getReader === "function") {
12863
+ const reader = stream.getReader();
12864
+ (async () => {
12865
+ try {
12866
+ for (; ; ) {
12867
+ const { done, value } = await reader.read();
12868
+ if (done) return;
12869
+ consume(value);
12870
+ }
12871
+ } finally {
12872
+ reader.releaseLock();
12873
+ }
12874
+ })();
12875
+ } else {
12876
+ stream.on("data", consume);
12877
+ }
12878
+ return this;
12879
+ }
12880
+ onDone(fn) {
12881
+ this._onDone = typeof fn == "function" ? fn : null;
12882
+ return this;
12883
+ }
12884
+ get depth() {
12885
+ return (this.stack.length >> 1) + (this.done ? 0 : 1);
12886
+ }
12887
+ get path() {
12888
+ const path3 = [];
12889
+ for (let i = 0; i < this.stack.length; i += 2) {
12890
+ const key = this.stack[i + 1];
12891
+ path3.push(key === null ? this.stack[i].length : key);
12892
+ }
12893
+ return path3;
12894
+ }
12895
+ dropToLevel(level) {
12896
+ if (level < this.depth) {
12897
+ if (level > 0) {
12898
+ const index = level - 1 << 1;
12899
+ this.current = this.stack[index];
12900
+ this.key = this.stack[index + 1];
12901
+ this.stack.splice(index);
12902
+ } else {
12903
+ this.stack = [];
12904
+ this.current = this.key = null;
12905
+ this.done = true;
12906
+ }
12907
+ }
12908
+ return this;
12909
+ }
12910
+ consume(chunk) {
12911
+ this[chunk.name]?.(chunk.value);
12912
+ return this;
12913
+ }
12914
+ keyValue(value) {
12915
+ this.key = value;
12916
+ }
12917
+ //stringValue() - aliased below to _saveValue()
12918
+ numberValue(value) {
12919
+ this._saveValue(parseFloat(value));
12920
+ }
12921
+ nullValue() {
12922
+ this._saveValue(null);
12923
+ }
12924
+ trueValue() {
12925
+ this._saveValue(true);
12926
+ }
12927
+ falseValue() {
12928
+ this._saveValue(false);
12929
+ }
12930
+ //startObject() - assigned below
12931
+ endObject() {
12932
+ if (this.stack.length) {
12933
+ const value = this.current;
12934
+ this.key = this.stack.pop();
12935
+ this.current = this.stack.pop();
12936
+ this._saveValue(value);
12937
+ } else {
12938
+ if (this.reviver) {
12939
+ this.current = this.reviver.call({ "": this.current }, "", this.current);
12940
+ }
12941
+ this.done = true;
12942
+ }
12943
+ }
12944
+ //startArray() - assigned below
12945
+ //endArray() - aliased below to endObject()
12946
+ _saveValue(value) {
12947
+ if (this.done) {
12948
+ this.current = value;
12949
+ return;
12950
+ }
12951
+ if (this.current instanceof Array) {
12952
+ this.current.push(value);
12953
+ } else {
12954
+ if (this.key === "__proto__") {
12955
+ Object.defineProperty(this.current, this.key, { value, writable: true, enumerable: true, configurable: true });
12956
+ } else {
12957
+ this.current[this.key] = value;
12958
+ }
12959
+ this.key = null;
12960
+ }
12961
+ }
12962
+ _saveValueWithReviver(value) {
12963
+ if (this.done) {
12964
+ this.current = this.reviver.call({ "": value }, "", value);
12965
+ return;
12966
+ }
12967
+ if (this.current instanceof Array) {
12968
+ this.current.push(value);
12969
+ value = this.reviver.call(this.current, String(this.current.length - 1), value);
12970
+ if (value === void 0) {
12971
+ delete this.current[this.current.length - 1];
12972
+ } else {
12973
+ this.current[this.current.length - 1] = value;
12974
+ }
12975
+ } else {
12976
+ value = this.reviver.call(this.current, this.key, value);
12977
+ if (value !== void 0) {
12978
+ if (this.key === "__proto__") {
12979
+ Object.defineProperty(this.current, this.key, { value, writable: true, enumerable: true, configurable: true });
12980
+ } else {
12981
+ this.current[this.key] = value;
12982
+ }
12983
+ }
12984
+ this.key = null;
12985
+ }
12986
+ }
12987
+ };
12988
+ var proto = (
12989
+ /** @type {any} */
12990
+ Assembler.prototype
12991
+ );
12992
+ proto.stringValue = Assembler.prototype._saveValue;
12993
+ proto.startObject = startObject(Object);
12994
+ proto.startArray = startObject(Array);
12995
+ proto.endArray = Assembler.prototype.endObject;
12996
+ var assembler = (options) => new Assembler(options);
12997
+ Assembler.assembler = assembler;
12998
+
12999
+ // node_modules/stream-json/src/core/streamers/stream-base.js
13000
+ var Counter = class {
13001
+ constructor(initialDepth) {
13002
+ this.depth = initialDepth;
13003
+ }
13004
+ startObject() {
13005
+ ++this.depth;
13006
+ }
13007
+ endObject() {
13008
+ --this.depth;
13009
+ }
13010
+ startArray() {
13011
+ ++this.depth;
13012
+ }
13013
+ endArray() {
13014
+ --this.depth;
13015
+ }
13016
+ };
13017
+ var streamBase = ({ push, first, level }) => (options = {}) => {
13018
+ const { objectFilter, includeUndecided } = options;
13019
+ let asm = assembler(options);
13020
+ let state = first ? "first" : "check", savedAsm = null;
13021
+ if (typeof objectFilter != "function") {
13022
+ if (state === "check")
13023
+ return (chunk) => {
13024
+ if (asm[chunk.name]) {
13025
+ asm[chunk.name](chunk.value);
13026
+ if (asm.depth === level) {
13027
+ return push(asm);
13028
+ }
13029
+ }
13030
+ return none;
13031
+ };
13032
+ return (chunk) => {
13033
+ switch (state) {
13034
+ case "first":
13035
+ first(chunk);
13036
+ state = "accept";
13037
+ // fall through
13038
+ case "accept":
13039
+ if (asm[chunk.name]) {
13040
+ asm[chunk.name](chunk.value);
13041
+ if (asm.depth === level) {
13042
+ return push(asm);
13043
+ }
13044
+ }
13045
+ break;
13046
+ }
13047
+ return none;
13048
+ };
13049
+ }
13050
+ return (chunk) => {
13051
+ switch (state) {
13052
+ case "first":
13053
+ first(chunk);
13054
+ state = "check";
13055
+ // fall through
13056
+ case "check":
13057
+ if (asm[chunk.name]) {
13058
+ asm[chunk.name](chunk.value);
13059
+ const result = objectFilter(asm);
13060
+ if (result) {
13061
+ state = "accept";
13062
+ if (asm.depth === level) return push(asm);
13063
+ } else if (result === false) {
13064
+ if (asm.depth === level) return push(asm, true);
13065
+ state = "reject";
13066
+ savedAsm = asm;
13067
+ asm = new Counter(savedAsm.depth);
13068
+ savedAsm.dropToLevel(level);
13069
+ } else {
13070
+ if (asm.depth === level) return push(asm, !includeUndecided);
13071
+ }
13072
+ }
13073
+ break;
13074
+ case "accept":
13075
+ if (asm[chunk.name]) {
13076
+ asm[chunk.name](chunk.value);
13077
+ if (asm.depth === level) {
13078
+ state = "check";
13079
+ return push(asm);
13080
+ }
13081
+ }
13082
+ break;
13083
+ case "reject":
13084
+ if (asm[chunk.name]) {
13085
+ asm[chunk.name](chunk.value);
13086
+ if (asm.depth === level) {
13087
+ state = "check";
13088
+ asm = savedAsm;
13089
+ savedAsm = null;
13090
+ return push(asm, true);
13091
+ }
13092
+ }
13093
+ break;
13094
+ }
13095
+ return none;
13096
+ };
13097
+ };
13098
+ var stream_base_default = streamBase;
13099
+
13100
+ // node_modules/stream-json/src/core/streamers/stream-array.js
13101
+ var streamArray = (options) => {
13102
+ let key = 0;
13103
+ return stream_base_default({
13104
+ level: 1,
13105
+ first(chunk) {
13106
+ if (chunk.name !== "startArray") throw new Error("Top-level object should be an array.");
13107
+ },
13108
+ push(asm, discard) {
13109
+ const current = (
13110
+ /** @type {unknown[]} */
13111
+ asm.current
13112
+ );
13113
+ if (current.length) {
13114
+ if (discard) {
13115
+ ++key;
13116
+ current.pop();
13117
+ } else {
13118
+ return { key: key++, value: current.pop() };
13119
+ }
13120
+ }
13121
+ return none;
13122
+ }
13123
+ })(options);
13124
+ };
13125
+ streamArray.streamArray = streamArray;
13126
+ var stream_array_default = streamArray;
13127
+
13128
+ // node_modules/stream-json/src/core/utils/with-parser.js
13129
+ var withParser = (fn, options) => gen_default(parser_default(options), fn(options));
13130
+ withParser.withParser = withParser;
13131
+ var with_parser_default = withParser;
13132
+
13133
+ // node_modules/stream-json/src/utils/with-parser.js
13134
+ with_parser_default.asStream = (fn, options) => asStream_default(with_parser_default(fn, options), { ...options, writableObjectMode: false, readableObjectMode: true });
13135
+ with_parser_default.asWebStream = (fn, options) => asWebStream_default(with_parser_default(fn, options), { ...options, writableObjectMode: false, readableObjectMode: true });
13136
+ var with_parser_default2 = with_parser_default;
13137
+
13138
+ // node_modules/stream-json/src/streamers/stream-array.js
13139
+ stream_array_default.asStream = (options) => asStream_default(stream_array_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
13140
+ stream_array_default.asWebStream = (options) => asWebStream_default(stream_array_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
13141
+ stream_array_default.withParser = (options) => with_parser_default2(stream_array_default, { packKeys: true, ...options });
13142
+ stream_array_default.withParserAsStream = (options) => (
13143
+ /** @type {any} */
13144
+ with_parser_default2.asStream(stream_array_default, { packKeys: true, ...options })
13145
+ );
13146
+ stream_array_default.withParserAsWebStream = (options) => (
13147
+ /** @type {any} */
13148
+ with_parser_default2.asWebStream(stream_array_default, { packKeys: true, ...options })
13149
+ );
13150
+
13151
+ // src/geometry/slabLine.mjs
13152
+ var getSlabData = (
13153
+ /**async */
13154
+ (lines, runDataList, pointCloudCluster = null, getFlatSlab = true, getFlatFloor = false, getOblique = false) => {
13155
+ const flatSlabPoints = [];
13156
+ const obliqueSlabPoints = [];
13157
+ if (getOblique) {
13158
+ for (let i = 0; i < lines.length; i++) {
13159
+ const normal = lines[i][0];
13160
+ if (normal.length != 3) continue;
13161
+ if (normal[2] > 0.98)
13162
+ flatSlabPoints.push(lines[i]);
13163
+ else {
13164
+ obliqueSlabPoints.push(lines[i]);
13165
+ }
13166
+ }
13167
+ } else {
13168
+ for (let i = 0; i < lines.length; i++)
13169
+ flatSlabPoints.push(lines[i]);
13170
+ }
13171
+ let flatSlabDatas = [];
13172
+ let flatFloorDatas = [];
13173
+ let obliqueSlabDatas = [];
13174
+ if (getFlatSlab)
13175
+ flatSlabDatas = getFlatSlabData(flatSlabPoints, runDataList, pointCloudCluster);
13176
+ if (getFlatFloor)
13177
+ flatFloorDatas = getFlatFloorData(flatSlabPoints, runDataList, pointCloudCluster);
13178
+ if (getOblique)
13179
+ obliqueSlabDatas = getObliqueSlabData(obliqueSlabPoints, runDataList, pointCloudCluster);
13180
+ return { flatSlabDatas, obliqueSlabDatas, flatFloorDatas };
13181
+ }
13182
+ );
11147
13183
  var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
11148
13184
  if (lines.length === 0) return;
11149
13185
  let slabDatas = [];
@@ -11226,33 +13262,22 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
11226
13262
  for (let j = 0; j < newSlabDatas.length; j++) {
11227
13263
  if (delIndex.has(j)) continue;
11228
13264
  const slabData1 = newSlabDatas[j];
11229
- let mergeSlabArray = [slabData1];
11230
13265
  for (let k = 0; k < newSlabDatas.length; k++) {
11231
13266
  if (j == k || delIndex.has(k))
11232
13267
  continue;
11233
13268
  const slabData2 = newSlabDatas[k];
11234
- for (let c = 0; c < mergeSlabArray.length; c++) {
11235
- const slabData3 = mergeSlabArray[c];
11236
- if (Math.abs(slabData3.averagePz - slabData2.averagePz) > 0.05) continue;
11237
- const isIntersect = contoursIntersect(slabData3.contour, slabData2.contour, 1e-3);
11238
- if (isIntersect) {
11239
- mergeSlabArray.push(slabData2);
11240
- delIndex.add(k);
11241
- k = -1;
11242
- break;
11243
- }
11244
- }
11245
- }
11246
- if (mergeSlabArray.length > 1) {
11247
- for (let c = 1; c < mergeSlabArray.length; c++) {
11248
- const slabData2 = mergeSlabArray[c];
13269
+ if (Math.abs(slabData1.averagePz - slabData2.averagePz) > 0.05) continue;
13270
+ const isIntersect = contoursIntersect(slabData1.contour, slabData2.contour, 1e-3);
13271
+ if (isIntersect) {
11249
13272
  for (let b = 0; b < slabData2.points.length; b++)
11250
13273
  slabData1.points.push(slabData2.points[b]);
13274
+ let tmpPoints = slabData1.points.map((p) => [p.x, p.y]);
13275
+ tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.2);
13276
+ let path3 = computeContour(tmpPoints);
13277
+ slabData1.contour = path3;
13278
+ delIndex.add(k);
13279
+ k = -1;
11251
13280
  }
11252
- let tmpPoints = slabData1.points.map((p) => [p.x, p.y]);
11253
- tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.2);
11254
- let path3 = computeContour(tmpPoints);
11255
- slabData1.contour = path3;
11256
13281
  }
11257
13282
  }
11258
13283
  slabDatas = [];
@@ -11358,7 +13383,7 @@ var getFlatFloorData = (lines, runDataList, pointCloudCluster = null) => {
11358
13383
  for (let b = 0; b < floorData2.points.length; b++)
11359
13384
  floorData1.points.push(floorData2.points[b]);
11360
13385
  let tmpPoints = floorData1.points.map((p) => [p.x, p.y]);
11361
- tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.1);
13386
+ tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.2);
11362
13387
  let path3 = computeContour(tmpPoints);
11363
13388
  floorData1.contour = path3;
11364
13389
  delIndex.add(k);
@@ -12532,7 +14557,7 @@ var getWindowPcdData = (lines, pcdData) => {
12532
14557
  groundClearance,
12533
14558
  height,
12534
14559
  width: ptWindowSt.distanceTo(ptWindowEd),
12535
- pcd_id: pcd.obj_id
14560
+ obj_id: pcd.obj_id
12536
14561
  });
12537
14562
  line2.isWindow = true;
12538
14563
  pcd.isWindowDoor = true;
@@ -12574,7 +14599,7 @@ var getWindowPcdData = (lines, pcdData) => {
12574
14599
  groundClearance,
12575
14600
  height,
12576
14601
  width: ptWindowSt.distanceTo(ptWindowEd),
12577
- pcd_id: pcd.obj_id
14602
+ obj_id: pcd.obj_id
12578
14603
  });
12579
14604
  line2.isWindow = true;
12580
14605
  pcd.isWindowDoor = true;
@@ -12621,7 +14646,7 @@ var getWindowPcdData = (lines, pcdData) => {
12621
14646
  groundClearance,
12622
14647
  height,
12623
14648
  width: ptWindowSt.distanceTo(ptWindowEd),
12624
- pcd_id: pcd.obj_id
14649
+ obj_id: pcd.obj_id
12625
14650
  });
12626
14651
  line2.isWindow = true;
12627
14652
  pcd.isWindowDoor = true;
@@ -16676,15 +18701,15 @@ function smoothPolyline(pts) {
16676
18701
  if (pts.length < 4) return pts;
16677
18702
  let cur = pts.map((p) => ({ x: p.x, z: p.z }));
16678
18703
  for (let iter = 0; iter < 3; iter++) {
16679
- const next = [{ ...cur[0] }];
18704
+ const next2 = [{ ...cur[0] }];
16680
18705
  for (let i = 1; i < cur.length - 1; i++) {
16681
- next.push({
18706
+ next2.push({
16682
18707
  x: (cur[i - 1].x + cur[i].x + cur[i + 1].x) / 3,
16683
18708
  z: (cur[i - 1].z + cur[i].z + cur[i + 1].z) / 3
16684
18709
  });
16685
18710
  }
16686
- next.push({ ...cur[cur.length - 1] });
16687
- cur = next;
18711
+ next2.push({ ...cur[cur.length - 1] });
18712
+ cur = next2;
16688
18713
  }
16689
18714
  return cur;
16690
18715
  }
@@ -17580,11 +19605,11 @@ function segmentContourCurves(contour, config) {
17580
19605
  const sorted = [...survivors].sort((a, b) => a.start - b.start);
17581
19606
  let cur = sorted[0];
17582
19607
  for (let i = 1; i < sorted.length; i++) {
17583
- const next = sorted[i];
17584
- let gap = next.start - cur.end;
19608
+ const next2 = sorted[i];
19609
+ let gap = next2.start - cur.end;
17585
19610
  if (gap < 0) {
17586
- if (cur.end > n * 0.5 && next.start < n * 0.5) {
17587
- gap = next.start + n - cur.end;
19611
+ if (cur.end > n * 0.5 && next2.start < n * 0.5) {
19612
+ gap = next2.start + n - cur.end;
17588
19613
  } else {
17589
19614
  gap = 0;
17590
19615
  }
@@ -17592,15 +19617,15 @@ function segmentContourCurves(contour, config) {
17592
19617
  const isOverlap = gap === 0;
17593
19618
  let canMerge = gap <= MERGE_GAP_MAX && isOverlap;
17594
19619
  if (!canMerge && gap <= MERGE_GAP_MAX) {
17595
- const cdist = Math.sqrt((cur.seg.centerX - next.seg.centerX) ** 2 + (cur.seg.centerZ - next.seg.centerZ) ** 2);
17596
- const rMax = Math.max(cur.seg.radius, next.seg.radius);
17597
- const rMin = Math.min(cur.seg.radius, next.seg.radius);
19620
+ const cdist = Math.sqrt((cur.seg.centerX - next2.seg.centerX) ** 2 + (cur.seg.centerZ - next2.seg.centerZ) ** 2);
19621
+ const rMax = Math.max(cur.seg.radius, next2.seg.radius);
19622
+ const rMin = Math.min(cur.seg.radius, next2.seg.radius);
17598
19623
  const rRatio = rMin > 0 ? rMax / rMin : 99;
17599
19624
  canMerge = cdist < MERGE_CENTER_DIST && rRatio < MERGE_RADIUS_RATIO;
17600
19625
  }
17601
19626
  if (canMerge) {
17602
- const uStart = Math.min(cur.start, next.start);
17603
- const uEnd = Math.max(cur.end, next.end);
19627
+ const uStart = Math.min(cur.start, next2.start);
19628
+ const uEnd = Math.max(cur.end, next2.end);
17604
19629
  const allPts = [];
17605
19630
  for (let j = uStart; ; j = (j + 1) % n) {
17606
19631
  allPts.push({ ...contour[j] });
@@ -17616,13 +19641,13 @@ function segmentContourCurves(contour, config) {
17616
19641
  cur = {
17617
19642
  seg: { points: allPts, type: "C_curve", radius: r, centerX: cx, centerZ: cz, arcAngle: arcAng, arcLength: calcTotalLength(allPts) },
17618
19643
  start: cur.start,
17619
- end: next.end,
19644
+ end: next2.end,
17620
19645
  source: cur.source
17621
19646
  };
17622
19647
  mergeCount++;
17623
19648
  } else {
17624
19649
  merged.push(cur);
17625
- cur = next;
19650
+ cur = next2;
17626
19651
  }
17627
19652
  }
17628
19653
  merged.push(cur);
@@ -17881,9 +19906,9 @@ function processFromPointCloud(points3D, rawLines, pcConfig) {
17881
19906
  const n = pts.length;
17882
19907
  const result = pts.map((p) => ({ x: p.x, z: p.z }));
17883
19908
  for (let i = 0; i < n; i++) {
17884
- const prev = pts[(i - 1 + n) % n], curr = pts[i], next = pts[(i + 1) % n];
19909
+ const prev = pts[(i - 1 + n) % n], curr = pts[i], next2 = pts[(i + 1) % n];
17885
19910
  const v1x = curr.x - prev.x, v1z = curr.z - prev.z;
17886
- const v2x = next.x - curr.x, v2z = next.z - curr.z;
19911
+ const v2x = next2.x - curr.x, v2z = next2.z - curr.z;
17887
19912
  const l1 = Math.sqrt(v1x * v1x + v1z * v1z);
17888
19913
  const l2 = Math.sqrt(v2x * v2x + v2z * v2z);
17889
19914
  if (l1 < 1e-3 || l2 < 1e-3) continue;
@@ -17938,9 +19963,9 @@ function processFromPointCloud(points3D, rawLines, pcConfig) {
17938
19963
  const isCW = polySignedArea(pts) >= 0;
17939
19964
  return pts.map((p, i) => {
17940
19965
  const prev = pts[(i - 1 + pts.length) % pts.length];
17941
- const next = pts[(i + 1) % pts.length];
17942
- const dx = next.x - prev.x;
17943
- const dz = next.z - prev.z;
19966
+ const next2 = pts[(i + 1) % pts.length];
19967
+ const dx = next2.x - prev.x;
19968
+ const dz = next2.z - prev.z;
17944
19969
  const len = Math.sqrt(dx * dx + dz * dz);
17945
19970
  if (len < 1e-3) return { ...p };
17946
19971
  const nx = isCW ? dz : -dz;
@@ -18039,9 +20064,9 @@ function processFromSegments(segments, config) {
18039
20064
  const isCW = signedArea2(pts) >= 0;
18040
20065
  const expanded = pts.map((p, i) => {
18041
20066
  const prev = pts[(i - 1 + pts.length) % pts.length];
18042
- const next = pts[(i + 1) % pts.length];
18043
- const dx = next.x - prev.x;
18044
- const dz = next.z - prev.z;
20067
+ const next2 = pts[(i + 1) % pts.length];
20068
+ const dx = next2.x - prev.x;
20069
+ const dz = next2.z - prev.z;
18045
20070
  const len = Math.sqrt(dx * dx + dz * dz);
18046
20071
  if (len < 1e-3) return { ...p };
18047
20072
  const nx = isCW ? dz : -dz;