@vitessce/gl 4.0.8 → 4.0.9

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 (37) hide show
  1. package/dist/{deflate-DNngSh3q.js → deflate-DD4d--xe.js} +1 -1
  2. package/dist/{index-_UASQg2S.js → index-D4C8DA1x.js} +1324 -109
  3. package/dist/index.js +18 -13
  4. package/dist/{jpeg-BrGNk507.js → jpeg-CZeZBc_8.js} +1 -1
  5. package/dist/{lerc-A9bnCzoN.js → lerc-Ct7C32yr.js} +1 -1
  6. package/dist/{lzw-_IYIPfiq.js → lzw-BgdxJ7Qg.js} +1 -1
  7. package/dist/{packbits-CxQQOChS.js → packbits-BhOBFsGy.js} +1 -1
  8. package/dist/{raw-ti2YIR09.js → raw-B5_2TWMK.js} +1 -1
  9. package/dist/{webimage-DgRcFzf_.js → webimage-DcEapRkY.js} +1 -1
  10. package/dist-tsc/AnnotationLayer.d.ts +91 -0
  11. package/dist-tsc/AnnotationLayer.d.ts.map +1 -0
  12. package/dist-tsc/AnnotationLayer.js +71 -0
  13. package/dist-tsc/AnnotationLayer.js.map +1 -0
  14. package/dist-tsc/AnnotationLayer.test.d.ts +2 -0
  15. package/dist-tsc/AnnotationLayer.test.d.ts.map +1 -0
  16. package/dist-tsc/AnnotationLayer.test.js +59 -0
  17. package/dist-tsc/AnnotationLayer.test.js.map +1 -0
  18. package/dist-tsc/annotation-layer-utils.d.ts +25 -0
  19. package/dist-tsc/annotation-layer-utils.d.ts.map +1 -0
  20. package/dist-tsc/annotation-layer-utils.js +1110 -0
  21. package/dist-tsc/annotation-layer-utils.js.map +1 -0
  22. package/dist-tsc/annotation-layer-utils.test.d.ts +2 -0
  23. package/dist-tsc/annotation-layer-utils.test.d.ts.map +1 -0
  24. package/dist-tsc/annotation-layer-utils.test.js +153 -0
  25. package/dist-tsc/annotation-layer-utils.test.js.map +1 -0
  26. package/dist-tsc/deck.js +2 -2
  27. package/dist-tsc/deck.js.map +1 -1
  28. package/dist-tsc/index.d.ts +2 -0
  29. package/dist-tsc/index.js +2 -0
  30. package/dist-tsc/index.js.map +1 -1
  31. package/package.json +4 -3
  32. package/src/AnnotationLayer.js +91 -0
  33. package/src/AnnotationLayer.test.js +67 -0
  34. package/src/annotation-layer-utils.js +1137 -0
  35. package/src/annotation-layer-utils.test.js +180 -0
  36. package/src/deck.js +2 -1
  37. package/src/index.js +2 -0
@@ -11084,8 +11084,8 @@ class Vector extends MathArray {
11084
11084
  distanceSquared(mathArray) {
11085
11085
  let length2 = 0;
11086
11086
  for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
11087
- const dist = this[i2] - mathArray[i2];
11088
- length2 += dist * dist;
11087
+ const dist2 = this[i2] - mathArray[i2];
11088
+ length2 += dist2 * dist2;
11089
11089
  }
11090
11090
  return checkNumber(length2);
11091
11091
  }
@@ -11406,6 +11406,12 @@ function multiply$3(out, a2, b) {
11406
11406
  out[2] = a2[2] * b[2];
11407
11407
  return out;
11408
11408
  }
11409
+ function distance$3(a2, b) {
11410
+ var x = b[0] - a2[0];
11411
+ var y = b[1] - a2[1];
11412
+ var z = b[2] - a2[2];
11413
+ return Math.hypot(x, y, z);
11414
+ }
11409
11415
  function squaredLength$2(a2) {
11410
11416
  var x = a2[0];
11411
11417
  var y = a2[1];
@@ -11529,6 +11535,7 @@ function angle$2(a2, b) {
11529
11535
  }
11530
11536
  var sub = subtract;
11531
11537
  var mul = multiply$3;
11538
+ var dist = distance$3;
11532
11539
  var len = length$4;
11533
11540
  var sqrLen = squaredLength$2;
11534
11541
  (function() {
@@ -26032,7 +26039,7 @@ function noop$2() {
26032
26039
  const getCursor = ({
26033
26040
  isDragging
26034
26041
  }) => isDragging ? "grabbing" : "grab";
26035
- const defaultProps$P = {
26042
+ const defaultProps$Q = {
26036
26043
  id: "",
26037
26044
  width: "100%",
26038
26045
  height: "100%",
@@ -26163,7 +26170,7 @@ class Deck {
26163
26170
  this._lastPointerDownInfo = pickedInfo.result[0] || pickedInfo.emptyInfo;
26164
26171
  });
26165
26172
  this.props = {
26166
- ...defaultProps$P,
26173
+ ...defaultProps$Q,
26167
26174
  ...props
26168
26175
  };
26169
26176
  props = this.props;
@@ -26665,7 +26672,7 @@ class Deck {
26665
26672
  metrics.gpuMemory = memoryStats.get("GPU Memory").count;
26666
26673
  }
26667
26674
  }
26668
- _defineProperty(Deck, "defaultProps", defaultProps$P);
26675
+ _defineProperty(Deck, "defaultProps", defaultProps$Q);
26669
26676
  _defineProperty(Deck, "VERSION", deckGlobal.VERSION);
26670
26677
  class ShaderAttribute {
26671
26678
  constructor(dataColumn, opts) {
@@ -29420,7 +29427,7 @@ const areViewportsEqual = memoize$1(({
29420
29427
  return oldViewport.equals(viewport);
29421
29428
  });
29422
29429
  let pickingColorCache = new Uint8ClampedArray(0);
29423
- const defaultProps$O = {
29430
+ const defaultProps$P = {
29424
29431
  data: {
29425
29432
  type: "data",
29426
29433
  value: EMPTY_ARRAY$1,
@@ -30295,7 +30302,7 @@ class Layer extends Component {
30295
30302
  this.setNeedsUpdate();
30296
30303
  }
30297
30304
  }
30298
- _defineProperty(Layer, "defaultProps", defaultProps$O);
30305
+ _defineProperty(Layer, "defaultProps", defaultProps$P);
30299
30306
  _defineProperty(Layer, "layerName", "Layer");
30300
30307
  const TRACE_RENDER_LAYERS = "compositeLayer.renderLayers";
30301
30308
  class CompositeLayer extends Layer {
@@ -31454,7 +31461,7 @@ const parameters = {
31454
31461
  blendEquation: [32774, 32774],
31455
31462
  depthTest: false
31456
31463
  };
31457
- const defaultProps$N = {
31464
+ const defaultProps$O = {
31458
31465
  getFilterValue: {
31459
31466
  type: "accessor",
31460
31467
  value: 0
@@ -31630,8 +31637,126 @@ class DataFilterExtension extends LayerExtension {
31630
31637
  }
31631
31638
  }
31632
31639
  }
31633
- _defineProperty(DataFilterExtension, "defaultProps", defaultProps$N);
31640
+ _defineProperty(DataFilterExtension, "defaultProps", defaultProps$O);
31634
31641
  _defineProperty(DataFilterExtension, "extensionName", "DataFilterExtension");
31642
+ const dashShaders = {
31643
+ inject: {
31644
+ "vs:#decl": "\nattribute vec2 instanceDashArrays;\nattribute float instanceDashOffsets;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n",
31645
+ "vs:#main-end": "\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n",
31646
+ "fs:#decl": "\nuniform float dashAlignMode;\nuniform float capType;\nuniform bool dashGapPickable;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n\nfloat round(float x) {\n return floor(x + 0.5);\n}\n",
31647
+ "fs:#main-start": "\n float solidLength = vDashArray.x;\n float gapLength = vDashArray.y;\n float unitLength = solidLength + gapLength;\n\n float offset;\n\n if (unitLength > 0.0) {\n if (dashAlignMode == 0.0) {\n offset = vDashOffset;\n } else {\n unitLength = vPathLength / round(vPathLength / unitLength);\n offset = solidLength / 2.0;\n }\n\n float unitOffset = mod(clamp(vPathPosition.y, 0.0, vPathLength) + offset, unitLength);\n\n if (gapLength > 0.0 && unitOffset > solidLength) {\n if (capType <= 0.5) {\n if (!(dashGapPickable && picking_uActive)) {\n discard;\n }\n } else {\n // caps are rounded, test the distance to solid ends\n float distToEnd = length(vec2(\n min(unitOffset - solidLength, unitLength - unitOffset),\n vPathPosition.x\n ));\n if (distToEnd > 1.0) {\n if (!(dashGapPickable && picking_uActive)) {\n discard;\n }\n }\n }\n }\n }\n"
31648
+ }
31649
+ };
31650
+ const offsetShaders = {
31651
+ inject: {
31652
+ "vs:#decl": "\nattribute float instanceOffsets;\n",
31653
+ "vs:DECKGL_FILTER_SIZE": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n",
31654
+ "vCornerOffset = offsetVec;": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n vec2 offsetCenter = -instanceOffsets * (isCap ? perp : miterVec * miterSize) * 2.0;\n vCornerOffset = vCornerOffset * offsetWidth - offsetCenter;\n",
31655
+ "fs:#main-start": "\n float isInside;\n isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);\n if (isInside == 0.0) {\n discard;\n }\n"
31656
+ }
31657
+ };
31658
+ const defaultProps$N = {
31659
+ getDashArray: {
31660
+ type: "accessor",
31661
+ value: [0, 0]
31662
+ },
31663
+ getOffset: {
31664
+ type: "accessor",
31665
+ value: 0
31666
+ },
31667
+ dashJustified: false,
31668
+ dashGapPickable: false
31669
+ };
31670
+ class PathStyleExtension extends LayerExtension {
31671
+ constructor({
31672
+ dash = false,
31673
+ offset = false,
31674
+ highPrecisionDash = false
31675
+ } = {}) {
31676
+ super({
31677
+ dash: dash || highPrecisionDash,
31678
+ offset,
31679
+ highPrecisionDash
31680
+ });
31681
+ }
31682
+ isEnabled(layer) {
31683
+ return "pathTesselator" in layer.state;
31684
+ }
31685
+ getShaders(extension) {
31686
+ if (!extension.isEnabled(this)) {
31687
+ return null;
31688
+ }
31689
+ let result = {};
31690
+ if (extension.opts.dash) {
31691
+ result = mergeShaders(result, dashShaders);
31692
+ }
31693
+ if (extension.opts.offset) {
31694
+ result = mergeShaders(result, offsetShaders);
31695
+ }
31696
+ return result;
31697
+ }
31698
+ initializeState(context, extension) {
31699
+ const attributeManager = this.getAttributeManager();
31700
+ if (!attributeManager || !extension.isEnabled(this)) {
31701
+ return;
31702
+ }
31703
+ if (extension.opts.dash) {
31704
+ attributeManager.addInstanced({
31705
+ instanceDashArrays: {
31706
+ size: 2,
31707
+ accessor: "getDashArray"
31708
+ }
31709
+ });
31710
+ }
31711
+ if (extension.opts.highPrecisionDash) {
31712
+ attributeManager.addInstanced({
31713
+ instanceDashOffsets: {
31714
+ size: 1,
31715
+ accessor: "getPath",
31716
+ transform: extension.getDashOffsets.bind(this)
31717
+ }
31718
+ });
31719
+ }
31720
+ if (extension.opts.offset) {
31721
+ attributeManager.addInstanced({
31722
+ instanceOffsets: {
31723
+ size: 1,
31724
+ accessor: "getOffset"
31725
+ }
31726
+ });
31727
+ }
31728
+ }
31729
+ updateState(params, extension) {
31730
+ if (!extension.isEnabled(this)) {
31731
+ return;
31732
+ }
31733
+ const uniforms = {};
31734
+ if (extension.opts.dash) {
31735
+ uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
31736
+ uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
31737
+ }
31738
+ this.state.model.setUniforms(uniforms);
31739
+ }
31740
+ getDashOffsets(path) {
31741
+ const result = [0];
31742
+ const positionSize = this.props.positionFormat === "XY" ? 2 : 3;
31743
+ const isNested2 = Array.isArray(path[0]);
31744
+ const geometrySize = isNested2 ? path.length : path.length / positionSize;
31745
+ let p;
31746
+ let prevP;
31747
+ for (let i2 = 0; i2 < geometrySize - 1; i2++) {
31748
+ p = isNested2 ? path[i2] : path.slice(i2 * positionSize, i2 * positionSize + positionSize);
31749
+ p = this.projectPosition(p);
31750
+ if (i2 > 0) {
31751
+ result[i2] = result[i2 - 1] + dist(prevP, p);
31752
+ }
31753
+ prevP = p;
31754
+ }
31755
+ return result;
31756
+ }
31757
+ }
31758
+ _defineProperty(PathStyleExtension, "defaultProps", defaultProps$N);
31759
+ _defineProperty(PathStyleExtension, "extensionName", "PathStyleExtension");
31635
31760
  const defaultProps$M = {
31636
31761
  clipBounds: [0, 0, 1, 1]
31637
31762
  };
@@ -88128,8 +88253,8 @@ function requireJs$b() {
88128
88253
  var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi12 / 2 + Math.PI / 4));
88129
88254
  var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi12);
88130
88255
  var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda);
88131
- var dist = delta * R;
88132
- return dist;
88256
+ var dist2 = delta * R;
88257
+ return dist2;
88133
88258
  }
88134
88259
  js$a.default = rhumbDistance;
88135
88260
  return js$a;
@@ -88442,7 +88567,7 @@ function requireUtils$2() {
88442
88567
  var x;
88443
88568
  var y;
88444
88569
  var segmentIdx;
88445
- var dist;
88570
+ var dist2;
88446
88571
  if (coords.length > 1 && pointCoords.length) {
88447
88572
  var lineCoordinates;
88448
88573
  var pointCoordinate;
@@ -88459,17 +88584,17 @@ function requireUtils$2() {
88459
88584
  if (lineCoordinates[n2][0] !== lineCoordinates[n2 - 1][0]) {
88460
88585
  var slope = (lineCoordinates[n2][1] - lineCoordinates[n2 - 1][1]) / (lineCoordinates[n2][0] - lineCoordinates[n2 - 1][0]);
88461
88586
  var inverseSlope = lineCoordinates[n2][1] - slope * lineCoordinates[n2][0];
88462
- dist = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
88463
- } else dist = Math.abs(pointCoordinate[0] - lineCoordinates[n2][0]);
88587
+ dist2 = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
88588
+ } else dist2 = Math.abs(pointCoordinate[0] - lineCoordinates[n2][0]);
88464
88589
  var rl2 = Math.pow(lineCoordinates[n2][1] - lineCoordinates[n2 - 1][1], 2) + Math.pow(lineCoordinates[n2][0] - lineCoordinates[n2 - 1][0], 2);
88465
88590
  var ln2 = Math.pow(lineCoordinates[n2][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n2][0] - pointCoordinate[0], 2);
88466
88591
  var lnm12 = Math.pow(lineCoordinates[n2 - 1][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n2 - 1][0] - pointCoordinate[0], 2);
88467
- var dist2 = Math.pow(dist, 2);
88468
- var calcrl2 = ln2 - dist2 + lnm12 - dist2;
88592
+ var dist22 = Math.pow(dist2, 2);
88593
+ var calcrl2 = ln2 - dist22 + lnm12 - dist22;
88469
88594
  if (calcrl2 > rl2) {
88470
- dist = Math.sqrt(Math.min(ln2, lnm12));
88595
+ dist2 = Math.sqrt(Math.min(ln2, lnm12));
88471
88596
  }
88472
- if (minDist === null || minDist === void 0 || minDist > dist) {
88597
+ if (minDist === null || minDist === void 0 || minDist > dist2) {
88473
88598
  if (calcrl2 > rl2) {
88474
88599
  if (lnm12 < ln2) {
88475
88600
  to = 0;
@@ -88479,10 +88604,10 @@ function requireUtils$2() {
88479
88604
  to = 1;
88480
88605
  }
88481
88606
  } else {
88482
- to = Math.sqrt(lnm12 - dist2) / Math.sqrt(rl2);
88483
- from = Math.sqrt(ln2 - dist2) / Math.sqrt(rl2);
88607
+ to = Math.sqrt(lnm12 - dist22) / Math.sqrt(rl2);
88608
+ from = Math.sqrt(ln2 - dist22) / Math.sqrt(rl2);
88484
88609
  }
88485
- minDist = dist;
88610
+ minDist = dist2;
88486
88611
  segmentIdx = n2;
88487
88612
  }
88488
88613
  }
@@ -105588,22 +105713,22 @@ async function getDecoder(fileDirectory) {
105588
105713
  const Decoder = await importFn();
105589
105714
  return new Decoder(fileDirectory);
105590
105715
  }
105591
- addDecoder([void 0, 1], () => import("./raw-ti2YIR09.js").then((m) => m.default));
105592
- addDecoder(5, () => import("./lzw-_IYIPfiq.js").then((m) => m.default));
105716
+ addDecoder([void 0, 1], () => import("./raw-B5_2TWMK.js").then((m) => m.default));
105717
+ addDecoder(5, () => import("./lzw-BgdxJ7Qg.js").then((m) => m.default));
105593
105718
  addDecoder(6, () => {
105594
105719
  throw new Error("old style JPEG compression is not supported.");
105595
105720
  });
105596
- addDecoder(7, () => import("./jpeg-BrGNk507.js").then((m) => m.default));
105597
- addDecoder([8, 32946], () => import("./deflate-DNngSh3q.js").then((m) => m.default));
105598
- addDecoder(32773, () => import("./packbits-CxQQOChS.js").then((m) => m.default));
105721
+ addDecoder(7, () => import("./jpeg-CZeZBc_8.js").then((m) => m.default));
105722
+ addDecoder([8, 32946], () => import("./deflate-DD4d--xe.js").then((m) => m.default));
105723
+ addDecoder(32773, () => import("./packbits-BhOBFsGy.js").then((m) => m.default));
105599
105724
  addDecoder(
105600
105725
  34887,
105601
- () => import("./lerc-A9bnCzoN.js").then(async (m) => {
105726
+ () => import("./lerc-Ct7C32yr.js").then(async (m) => {
105602
105727
  await m.zstd.init();
105603
105728
  return m;
105604
105729
  }).then((m) => m.default)
105605
105730
  );
105606
- addDecoder(50001, () => import("./webimage-DgRcFzf_.js").then((m) => m.default));
105731
+ addDecoder(50001, () => import("./webimage-DcEapRkY.js").then((m) => m.default));
105607
105732
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
105608
105733
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
105609
105734
  }
@@ -112242,8 +112367,8 @@ function TreeDesc(dyn_tree, stat_desc) {
112242
112367
  this.max_code = 0;
112243
112368
  this.stat_desc = stat_desc;
112244
112369
  }
112245
- const d_code = (dist) => {
112246
- return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
112370
+ const d_code = (dist2) => {
112371
+ return dist2 < 256 ? _dist_code[dist2] : _dist_code[256 + (dist2 >>> 7)];
112247
112372
  };
112248
112373
  const put_short = (s2, w2) => {
112249
112374
  s2.pending_buf[s2.pending++] = w2 & 255;
@@ -112377,7 +112502,7 @@ const tr_static_init = () => {
112377
112502
  let bits;
112378
112503
  let length2;
112379
112504
  let code;
112380
- let dist;
112505
+ let dist2;
112381
112506
  const bl_count = new Array(MAX_BITS + 1);
112382
112507
  length2 = 0;
112383
112508
  for (code = 0; code < LENGTH_CODES - 1; code++) {
@@ -112387,18 +112512,18 @@ const tr_static_init = () => {
112387
112512
  }
112388
112513
  }
112389
112514
  _length_code[length2 - 1] = code;
112390
- dist = 0;
112515
+ dist2 = 0;
112391
112516
  for (code = 0; code < 16; code++) {
112392
- base_dist[code] = dist;
112517
+ base_dist[code] = dist2;
112393
112518
  for (n2 = 0; n2 < 1 << extra_dbits[code]; n2++) {
112394
- _dist_code[dist++] = code;
112519
+ _dist_code[dist2++] = code;
112395
112520
  }
112396
112521
  }
112397
- dist >>= 7;
112522
+ dist2 >>= 7;
112398
112523
  for (; code < D_CODES; code++) {
112399
- base_dist[code] = dist << 7;
112524
+ base_dist[code] = dist2 << 7;
112400
112525
  for (n2 = 0; n2 < 1 << extra_dbits[code] - 7; n2++) {
112401
- _dist_code[256 + dist++] = code;
112526
+ _dist_code[256 + dist2++] = code;
112402
112527
  }
112403
112528
  }
112404
112529
  for (bits = 0; bits <= MAX_BITS; bits++) {
@@ -112489,17 +112614,17 @@ const pqdownheap = (s2, tree, k) => {
112489
112614
  s2.heap[k] = v;
112490
112615
  };
112491
112616
  const compress_block = (s2, ltree, dtree) => {
112492
- let dist;
112617
+ let dist2;
112493
112618
  let lc;
112494
112619
  let lx = 0;
112495
112620
  let code;
112496
112621
  let extra;
112497
112622
  if (s2.last_lit !== 0) {
112498
112623
  do {
112499
- dist = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
112624
+ dist2 = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
112500
112625
  lc = s2.pending_buf[s2.l_buf + lx];
112501
112626
  lx++;
112502
- if (dist === 0) {
112627
+ if (dist2 === 0) {
112503
112628
  send_code(s2, lc, ltree);
112504
112629
  } else {
112505
112630
  code = _length_code[lc];
@@ -112509,13 +112634,13 @@ const compress_block = (s2, ltree, dtree) => {
112509
112634
  lc -= base_length[code];
112510
112635
  send_bits(s2, lc, extra);
112511
112636
  }
112512
- dist--;
112513
- code = d_code(dist);
112637
+ dist2--;
112638
+ code = d_code(dist2);
112514
112639
  send_code(s2, code, dtree);
112515
112640
  extra = extra_dbits[code];
112516
112641
  if (extra !== 0) {
112517
- dist -= base_dist[code];
112518
- send_bits(s2, dist, extra);
112642
+ dist2 -= base_dist[code];
112643
+ send_bits(s2, dist2, extra);
112519
112644
  }
112520
112645
  }
112521
112646
  } while (lx < s2.last_lit);
@@ -112786,18 +112911,18 @@ const _tr_flush_block = (s2, buf, stored_len, last) => {
112786
112911
  bi_windup(s2);
112787
112912
  }
112788
112913
  };
112789
- const _tr_tally = (s2, dist, lc) => {
112790
- s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist >>> 8 & 255;
112791
- s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist & 255;
112914
+ const _tr_tally = (s2, dist2, lc) => {
112915
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist2 >>> 8 & 255;
112916
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist2 & 255;
112792
112917
  s2.pending_buf[s2.l_buf + s2.last_lit] = lc & 255;
112793
112918
  s2.last_lit++;
112794
- if (dist === 0) {
112919
+ if (dist2 === 0) {
112795
112920
  s2.dyn_ltree[lc * 2]++;
112796
112921
  } else {
112797
112922
  s2.matches++;
112798
- dist--;
112923
+ dist2--;
112799
112924
  s2.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++;
112800
- s2.dyn_dtree[d_code(dist) * 2]++;
112925
+ s2.dyn_dtree[d_code(dist2) * 2]++;
112801
112926
  }
112802
112927
  return s2.last_lit === s2.lit_bufsize - 1;
112803
112928
  };
@@ -114302,7 +114427,7 @@ var inffast = function inflate_fast(strm, start) {
114302
114427
  let here;
114303
114428
  let op;
114304
114429
  let len2;
114305
- let dist;
114430
+ let dist2;
114306
114431
  let from;
114307
114432
  let from_source;
114308
114433
  let input, output;
@@ -114368,7 +114493,7 @@ var inffast = function inflate_fast(strm, start) {
114368
114493
  bits -= op;
114369
114494
  op = here >>> 16 & 255;
114370
114495
  if (op & 16) {
114371
- dist = here & 65535;
114496
+ dist2 = here & 65535;
114372
114497
  op &= 15;
114373
114498
  if (bits < op) {
114374
114499
  hold += input[_in++] << bits;
@@ -114378,8 +114503,8 @@ var inffast = function inflate_fast(strm, start) {
114378
114503
  bits += 8;
114379
114504
  }
114380
114505
  }
114381
- dist += hold & (1 << op) - 1;
114382
- if (dist > dmax) {
114506
+ dist2 += hold & (1 << op) - 1;
114507
+ if (dist2 > dmax) {
114383
114508
  strm.msg = "invalid distance too far back";
114384
114509
  state.mode = BAD;
114385
114510
  break top;
@@ -114387,8 +114512,8 @@ var inffast = function inflate_fast(strm, start) {
114387
114512
  hold >>>= op;
114388
114513
  bits -= op;
114389
114514
  op = _out - beg;
114390
- if (dist > op) {
114391
- op = dist - op;
114515
+ if (dist2 > op) {
114516
+ op = dist2 - op;
114392
114517
  if (op > whave) {
114393
114518
  if (state.sane) {
114394
114519
  strm.msg = "invalid distance too far back";
@@ -114405,7 +114530,7 @@ var inffast = function inflate_fast(strm, start) {
114405
114530
  do {
114406
114531
  output[_out++] = s_window[from++];
114407
114532
  } while (--op);
114408
- from = _out - dist;
114533
+ from = _out - dist2;
114409
114534
  from_source = output;
114410
114535
  }
114411
114536
  } else if (wnext < op) {
@@ -114423,7 +114548,7 @@ var inffast = function inflate_fast(strm, start) {
114423
114548
  do {
114424
114549
  output[_out++] = s_window[from++];
114425
114550
  } while (--op);
114426
- from = _out - dist;
114551
+ from = _out - dist2;
114427
114552
  from_source = output;
114428
114553
  }
114429
114554
  }
@@ -114434,7 +114559,7 @@ var inffast = function inflate_fast(strm, start) {
114434
114559
  do {
114435
114560
  output[_out++] = s_window[from++];
114436
114561
  } while (--op);
114437
- from = _out - dist;
114562
+ from = _out - dist2;
114438
114563
  from_source = output;
114439
114564
  }
114440
114565
  }
@@ -114451,7 +114576,7 @@ var inffast = function inflate_fast(strm, start) {
114451
114576
  }
114452
114577
  }
114453
114578
  } else {
114454
- from = _out - dist;
114579
+ from = _out - dist2;
114455
114580
  do {
114456
114581
  output[_out++] = output[from++];
114457
114582
  output[_out++] = output[from++];
@@ -115009,7 +115134,7 @@ const fixedtables = (state) => {
115009
115134
  state.distbits = 5;
115010
115135
  };
115011
115136
  const updatewindow = (strm, src, end, copy2) => {
115012
- let dist;
115137
+ let dist2;
115013
115138
  const state = strm.state;
115014
115139
  if (state.window === null) {
115015
115140
  state.wsize = 1 << state.wbits;
@@ -115022,23 +115147,23 @@ const updatewindow = (strm, src, end, copy2) => {
115022
115147
  state.wnext = 0;
115023
115148
  state.whave = state.wsize;
115024
115149
  } else {
115025
- dist = state.wsize - state.wnext;
115026
- if (dist > copy2) {
115027
- dist = copy2;
115150
+ dist2 = state.wsize - state.wnext;
115151
+ if (dist2 > copy2) {
115152
+ dist2 = copy2;
115028
115153
  }
115029
- state.window.set(src.subarray(end - copy2, end - copy2 + dist), state.wnext);
115030
- copy2 -= dist;
115154
+ state.window.set(src.subarray(end - copy2, end - copy2 + dist2), state.wnext);
115155
+ copy2 -= dist2;
115031
115156
  if (copy2) {
115032
115157
  state.window.set(src.subarray(end - copy2, end), 0);
115033
115158
  state.wnext = copy2;
115034
115159
  state.whave = state.wsize;
115035
115160
  } else {
115036
- state.wnext += dist;
115161
+ state.wnext += dist2;
115037
115162
  if (state.wnext === state.wsize) {
115038
115163
  state.wnext = 0;
115039
115164
  }
115040
115165
  if (state.whave < state.wsize) {
115041
- state.whave += dist;
115166
+ state.whave += dist2;
115042
115167
  }
115043
115168
  }
115044
115169
  }
@@ -119685,7 +119810,7 @@ function padColors({ colors, channelsVisible }) {
119685
119810
  ).reduce((acc, val) => acc.concat(val), []);
119686
119811
  return paddedColors;
119687
119812
  }
119688
- const defaultProps$3$1 = {
119813
+ const defaultProps$3$2 = {
119689
119814
  colors: { type: "array", value: null, compare: true },
119690
119815
  opacity: { type: "number", value: 1, compare: true },
119691
119816
  transparentColor: { type: "array", value: null, compare: true },
@@ -119702,9 +119827,9 @@ const ColorPaletteExtension = class extends LayerExtension {
119702
119827
  const {
119703
119828
  colors,
119704
119829
  channelsVisible,
119705
- opacity = defaultProps$3$1.opacity.value,
119706
- transparentColor = defaultProps$3$1.transparentColor.value,
119707
- useTransparentColor = defaultProps$3$1.useTransparentColor.value
119830
+ opacity = defaultProps$3$2.opacity.value,
119831
+ transparentColor = defaultProps$3$2.transparentColor.value,
119832
+ useTransparentColor = defaultProps$3$2.useTransparentColor.value
119708
119833
  } = this.props;
119709
119834
  const paddedColors = padColors({
119710
119835
  channelsVisible: channelsVisible || this.selections.map(() => true),
@@ -119720,7 +119845,7 @@ const ColorPaletteExtension = class extends LayerExtension {
119720
119845
  }
119721
119846
  };
119722
119847
  ColorPaletteExtension.extensionName = "ColorPaletteExtension";
119723
- ColorPaletteExtension.defaultProps = defaultProps$3$1;
119848
+ ColorPaletteExtension.defaultProps = defaultProps$3$2;
119724
119849
  const fs$4 = `// lens bounds for ellipse
119725
119850
  uniform float majorLensAxis;
119726
119851
  uniform float minorLensAxis;
@@ -121024,7 +121149,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
121024
121149
  };
121025
121150
  MultiscaleImageLayer.layerName = "MultiscaleImageLayer";
121026
121151
  MultiscaleImageLayer.defaultProps = defaultProps$4;
121027
- const defaultProps$3 = {
121152
+ const defaultProps$3$1 = {
121028
121153
  pickable: { type: "boolean", value: true, compare: true },
121029
121154
  loader: {
121030
121155
  type: "object",
@@ -121111,7 +121236,7 @@ const OverviewLayer = class extends CompositeLayer {
121111
121236
  }
121112
121237
  };
121113
121238
  OverviewLayer.layerName = "OverviewLayer";
121114
- OverviewLayer.defaultProps = defaultProps$3;
121239
+ OverviewLayer.defaultProps = defaultProps$3$1;
121115
121240
  function getPosition(boundingBox, position, length2) {
121116
121241
  const viewWidth = boundingBox[2][0] - boundingBox[0][0];
121117
121242
  const viewHeight = boundingBox[2][1] - boundingBox[0][1];
@@ -122124,7 +122249,7 @@ function padWithDefault$1(arr, defaultValue2, padWidth) {
122124
122249
  }
122125
122250
  return newArr;
122126
122251
  }
122127
- const defaultProps$2 = {
122252
+ const defaultProps$3 = {
122128
122253
  hoveredCell: { type: "number", value: null, compare: true },
122129
122254
  // We do not want to deep-compare cellColorData,
122130
122255
  // as it is potentially a TypedArray with millions of elements.
@@ -122262,7 +122387,7 @@ let BitmaskLayer$1 = class BitmaskLayer extends XRLayer {
122262
122387
  }
122263
122388
  };
122264
122389
  BitmaskLayer$1.layerName = "BitmaskLayer";
122265
- BitmaskLayer$1.defaultProps = defaultProps$2;
122390
+ BitmaskLayer$1.defaultProps = defaultProps$3;
122266
122391
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
122267
122392
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
122268
122393
  var root = freeGlobal || freeSelf || Function("return this")();
@@ -123045,7 +123170,7 @@ function isEqualShallow(prevArr, nextArr) {
123045
123170
  }
123046
123171
  return prevArr === nextArr;
123047
123172
  }
123048
- const defaultProps$1 = {
123173
+ const defaultProps$2 = {
123049
123174
  channelStrokeWidths: { type: "array", value: null, compare: true },
123050
123175
  channelsFilled: { type: "array", value: null, compare: true },
123051
123176
  channelOpacities: { type: "array", value: null, compare: true },
@@ -123353,7 +123478,7 @@ class BitmaskLayer2 extends XRLayer {
123353
123478
  }
123354
123479
  }
123355
123480
  BitmaskLayer2.layerName = "BitmaskLayer";
123356
- BitmaskLayer2.defaultProps = defaultProps$1;
123481
+ BitmaskLayer2.defaultProps = defaultProps$2;
123357
123482
  var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 1e14, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, MAX = 1e9;
123358
123483
  function clone(configObject) {
123359
123484
  var div, convertBase, parseNumeric, P = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
@@ -126296,7 +126421,7 @@ function ringArea(coords) {
126296
126421
  return total * FACTOR;
126297
126422
  }
126298
126423
  const DEFAULT_THRESHOLD = 1;
126299
- const defaultProps = {
126424
+ const defaultProps$1 = {
126300
126425
  // for text
126301
126426
  obsSetPath: { type: "object" },
126302
126427
  sampleSetPath: { type: "object" },
@@ -126393,9 +126518,9 @@ class ContourLayerWithText extends ContourLayer {
126393
126518
  const circlePoint = point(circleCoord);
126394
126519
  polygonVertices.forEach((polyCoord) => {
126395
126520
  const polyPoint = point(polyCoord);
126396
- const dist = distance$1(circlePoint, polyPoint);
126397
- if (dist < minDist) {
126398
- minDist = dist;
126521
+ const dist2 = distance$1(circlePoint, polyPoint);
126522
+ if (dist2 < minDist) {
126523
+ minDist = dist2;
126399
126524
  minCirclePoint = circleCoord;
126400
126525
  minCirclePointI = circlePointI;
126401
126526
  minPolygonPoint = polyCoord;
@@ -126475,7 +126600,1106 @@ class ContourLayerWithText extends ContourLayer {
126475
126600
  }
126476
126601
  }
126477
126602
  ContourLayerWithText.layerName = "ContourLayerWithText";
126478
- ContourLayerWithText.defaultProps = defaultProps;
126603
+ ContourLayerWithText.defaultProps = defaultProps$1;
126604
+ const ViewType = {
126605
+ SCATTERPLOT: "scatterplot",
126606
+ SPATIAL: "spatial"
126607
+ };
126608
+ const deck = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
126609
+ __proto__: null,
126610
+ COORDINATE_SYSTEM,
126611
+ ContourLayer,
126612
+ DataFilterExtension,
126613
+ DeckGL,
126614
+ LineLayer,
126615
+ OrbitView,
126616
+ OrthographicView,
126617
+ PathLayer,
126618
+ PathStyleExtension,
126619
+ PolygonLayer,
126620
+ ScatterplotLayer,
126621
+ TextLayer,
126622
+ TileLayer
126623
+ }, Symbol.toStringTag, { value: "Module" }));
126624
+ const ARROW_SCREEN_PX = 14;
126625
+ const LABEL_FONT_FAMILY = '"Roboto", "Helvetica", "Arial", sans-serif';
126626
+ const LABEL_FONT_WEIGHT = "bold";
126627
+ const LABEL_FONT_SIZE = 14;
126628
+ const RATIO_CLUSTER = 0.1;
126629
+ const RATIO_DOT = 0.3;
126630
+ const RATIO_GEO_FADE = 0.55;
126631
+ const RATIO_TIPS = 0.7;
126632
+ const RATIO_LABEL = 0.55;
126633
+ const RATIO_LABEL_FULL = 0.75;
126634
+ function textBgColor(strokeColor) {
126635
+ const [r2, g2, b] = strokeColor;
126636
+ const lum = (0.299 * r2 + 0.587 * g2 + 0.114 * b) / 255;
126637
+ return lum > 0.45 ? [20, 20, 20, 210] : [245, 245, 245, 210];
126638
+ }
126639
+ function parseDashArray(strokeDashArray) {
126640
+ if (!strokeDashArray || strokeDashArray === "none") return null;
126641
+ const nums = strokeDashArray.trim().split(/\s+/).map(Number).filter((n2) => !Number.isNaN(n2) && n2 >= 0);
126642
+ return nums.length >= 2 ? [nums[0], nums[1]] : null;
126643
+ }
126644
+ function computeEllipsePolygon(cx, cy, rx, ry, numSegments = 64) {
126645
+ const pts = [];
126646
+ for (let i2 = 0; i2 < numSegments; i2++) {
126647
+ const angle2 = 2 * Math.PI * i2 / numSegments;
126648
+ pts.push([cx + rx * Math.cos(angle2), cy + ry * Math.sin(angle2)]);
126649
+ }
126650
+ return pts;
126651
+ }
126652
+ function createPreviewLayer(inProgress, hoverCoord, strokeColor = [255, 255, 0]) {
126653
+ if (!inProgress || inProgress.vertices.length === 0) return null;
126654
+ const { type, vertices } = inProgress;
126655
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
126656
+ const previewColor = [...strokeColor, 160];
126657
+ const cursor = hoverCoord ?? vertices[vertices.length - 1];
126658
+ if (type === "rectangle" && vertices.length === 1) {
126659
+ const [ax, ay] = vertices[0];
126660
+ const [bx, by] = cursor;
126661
+ const path = [[ax, ay], [bx, ay], [bx, by], [ax, by], [ax, ay]];
126662
+ return new PathLayer({
126663
+ ...base,
126664
+ id: "annotation-preview-rectangle",
126665
+ data: [{ path }],
126666
+ getPath: (d) => d.path,
126667
+ getColor: previewColor,
126668
+ getWidth: 1,
126669
+ widthUnits: "pixels",
126670
+ extensions: [new PathStyleExtension({ dash: true })],
126671
+ getDashArray: [8, 4]
126672
+ });
126673
+ }
126674
+ if (type === "line" && vertices.length === 1) {
126675
+ const path = [vertices[0], cursor];
126676
+ return new PathLayer({
126677
+ ...base,
126678
+ id: "annotation-preview-line",
126679
+ data: [{ path }],
126680
+ getPath: (d) => d.path,
126681
+ getColor: previewColor,
126682
+ getWidth: 1,
126683
+ widthUnits: "pixels",
126684
+ extensions: [new PathStyleExtension({ dash: true })],
126685
+ getDashArray: [8, 4]
126686
+ });
126687
+ }
126688
+ if (type === "ellipse" && vertices.length === 1) {
126689
+ const [cx, cy] = vertices[0];
126690
+ const [ex, ey] = cursor;
126691
+ const rx = Math.abs(ex - cx);
126692
+ const ry = Math.abs(ey - cy);
126693
+ if (rx < 1 && ry < 1) return null;
126694
+ const pts = computeEllipsePolygon(cx, cy, Math.max(rx, 1), Math.max(ry, 1));
126695
+ const path = [...pts, pts[0]];
126696
+ return new PathLayer({
126697
+ ...base,
126698
+ id: "annotation-preview-ellipse",
126699
+ data: [{ path }],
126700
+ getPath: (d) => d.path,
126701
+ getColor: previewColor,
126702
+ getWidth: 1,
126703
+ widthUnits: "pixels",
126704
+ extensions: [new PathStyleExtension({ dash: true })],
126705
+ getDashArray: [8, 4]
126706
+ });
126707
+ }
126708
+ if ((type === "polygon" || type === "polyline") && vertices.length >= 1) {
126709
+ const path = [...vertices, cursor];
126710
+ if (type === "polygon" && vertices.length >= 2) path.push(vertices[0]);
126711
+ return new PathLayer({
126712
+ ...base,
126713
+ id: `annotation-preview-${type}`,
126714
+ data: [{ path }],
126715
+ getPath: (d) => d.path,
126716
+ getColor: previewColor,
126717
+ getWidth: 1,
126718
+ widthUnits: "pixels",
126719
+ jointRounded: true,
126720
+ capRounded: true,
126721
+ extensions: [new PathStyleExtension({ dash: true })],
126722
+ getDashArray: [8, 4]
126723
+ });
126724
+ }
126725
+ return null;
126726
+ }
126727
+ function computeTickCap(tipX, tipY, dirX, dirY, dataSize) {
126728
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
126729
+ if (len2 === 0) return null;
126730
+ const ux = dirX / len2;
126731
+ const uy = dirY / len2;
126732
+ const px = -uy;
126733
+ const py = ux;
126734
+ const half = dataSize * 0.55;
126735
+ return [
126736
+ [tipX + px * half, tipY + py * half],
126737
+ [tipX - px * half, tipY - py * half]
126738
+ ];
126739
+ }
126740
+ function computeArrowhead(tipX, tipY, dirX, dirY, dataSize) {
126741
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
126742
+ if (len2 === 0) return null;
126743
+ const ux = dirX / len2;
126744
+ const uy = dirY / len2;
126745
+ const px = -uy;
126746
+ const py = ux;
126747
+ const halfBase = dataSize * 0.4;
126748
+ const bx = tipX - ux * dataSize;
126749
+ const by = tipY - uy * dataSize;
126750
+ return [
126751
+ [tipX, tipY],
126752
+ [bx + px * halfBase, by + py * halfBase],
126753
+ [bx - px * halfBase, by - py * halfBase]
126754
+ ];
126755
+ }
126756
+ function fmtCommas(n2) {
126757
+ return Math.round(n2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
126758
+ }
126759
+ function getMeasurementLabel(shape, physicalPixelSize, viewType = ViewType.SPATIAL) {
126760
+ const pps = physicalPixelSize;
126761
+ const px = pps?.x ?? 1;
126762
+ const py = pps?.y ?? 1;
126763
+ const unit = pps ? pps.unit ?? "" : null;
126764
+ const hasPhys = !!pps;
126765
+ const isEmbedding = viewType === ViewType.SCATTERPLOT;
126766
+ const fmtDist = (d) => {
126767
+ if (hasPhys) return `${d.toFixed(2)} ${unit}`;
126768
+ if (isEmbedding) return d.toFixed(2);
126769
+ return `${fmtCommas(d)} px`;
126770
+ };
126771
+ const fmtArea = (a2) => {
126772
+ if (hasPhys) return `${a2.toFixed(2)} ${unit}²`;
126773
+ if (isEmbedding) return a2.toFixed(2);
126774
+ return `${fmtCommas(a2)} px²`;
126775
+ };
126776
+ if (shape.type === "line") {
126777
+ const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
126778
+ const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
126779
+ const dist2 = hasPhys ? Math.sqrt((dx * px) ** 2 + (dy * py) ** 2) : Math.sqrt(dx * dx + dy * dy);
126780
+ return fmtDist(dist2);
126781
+ }
126782
+ if (shape.type === "rectangle") {
126783
+ return fmtArea(hasPhys ? Math.abs(shape.width ?? 0) * px * Math.abs(shape.height ?? 0) * py : Math.abs((shape.width ?? 0) * (shape.height ?? 0)));
126784
+ }
126785
+ if (shape.type === "ellipse") {
126786
+ const rx = Math.abs(shape.radiusX ?? 0);
126787
+ const ry = Math.abs(shape.radiusY ?? 0);
126788
+ return fmtArea(hasPhys ? Math.PI * rx * px * ry * py : Math.PI * rx * ry);
126789
+ }
126790
+ if (shape.type === "polygon" && shape.points?.length >= 3) {
126791
+ const pts = shape.points;
126792
+ let shoelace = 0;
126793
+ for (let i2 = 0; i2 < pts.length; i2++) {
126794
+ const [ax, ay] = pts[i2];
126795
+ const [bx, by] = pts[(i2 + 1) % pts.length];
126796
+ shoelace += (hasPhys ? ax * px : ax) * (hasPhys ? by * py : by) - (hasPhys ? bx * px : bx) * (hasPhys ? ay * py : ay);
126797
+ }
126798
+ return fmtArea(Math.abs(shoelace / 2));
126799
+ }
126800
+ if (shape.type === "polyline" && shape.points?.length >= 2) {
126801
+ let total = 0;
126802
+ for (let i2 = 0; i2 < shape.points.length - 1; i2++) {
126803
+ const [ax, ay] = shape.points[i2];
126804
+ const [bx, by] = shape.points[i2 + 1];
126805
+ total += hasPhys ? Math.sqrt(((bx - ax) * px) ** 2 + ((by - ay) * py) ** 2) : Math.sqrt((bx - ax) ** 2 + (by - ay) ** 2);
126806
+ }
126807
+ return fmtDist(total);
126808
+ }
126809
+ return null;
126810
+ }
126811
+ function pickBelowPerp(ux, uy) {
126812
+ const rp = [uy, -ux];
126813
+ const lp = [-uy, ux];
126814
+ return rp[1] > lp[1] || rp[1] === lp[1] && rp[0] > lp[0] ? rp : lp;
126815
+ }
126816
+ function readableAngle(deg) {
126817
+ let a2 = deg;
126818
+ if (a2 > 90) a2 -= 180;
126819
+ if (a2 < -90) a2 += 180;
126820
+ return a2;
126821
+ }
126822
+ function getShapeCentroid(shape) {
126823
+ if (shape.type === "rectangle") {
126824
+ return [(shape.x ?? 0) + (shape.width ?? 0) / 2, (shape.y ?? 0) + (shape.height ?? 0) / 2];
126825
+ }
126826
+ if (shape.type === "line") {
126827
+ return [((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2, ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2];
126828
+ }
126829
+ if (shape.type === "ellipse") {
126830
+ return [shape.x1 ?? 0, shape.y1 ?? 0];
126831
+ }
126832
+ if ((shape.type === "polygon" || shape.type === "polyline") && shape.points?.length >= 1) {
126833
+ const mx = shape.points.reduce((s2, p) => s2 + p[0], 0) / shape.points.length;
126834
+ const my = shape.points.reduce((s2, p) => s2 + p[1], 0) / shape.points.length;
126835
+ return [mx, my];
126836
+ }
126837
+ return [0, 0];
126838
+ }
126839
+ function computeClusters(shapeList, zoom, cellPx = 50) {
126840
+ const cellSize = cellPx / 2 ** Math.floor(zoom);
126841
+ const cells = /* @__PURE__ */ new Map();
126842
+ shapeList.forEach(({ shape }) => {
126843
+ const [cx, cy] = getShapeCentroid(shape);
126844
+ const key = `${Math.floor(cx / cellSize)},${Math.floor(cy / cellSize)}`;
126845
+ if (!cells.has(key)) {
126846
+ cells.set(key, { sumX: 0, sumY: 0, count: 0, color: shape.strokeColor ?? [255, 255, 255] });
126847
+ }
126848
+ const c = cells.get(key);
126849
+ c.sumX += cx;
126850
+ c.sumY += cy;
126851
+ c.count++;
126852
+ });
126853
+ return Array.from(cells.values()).map((c) => ({
126854
+ position: [c.sumX / c.count, c.sumY / c.count, 0],
126855
+ count: c.count,
126856
+ color: c.color
126857
+ }));
126858
+ }
126859
+ function createAnnotationLayers(shapes = [], zoom = 0, selectedShapeUid = null, physicalPixelSize = null, authoredZoom = null, semanticZoom = true, viewType = ViewType.SPATIAL) {
126860
+ const selectionLayers = [];
126861
+ if (selectedShapeUid) {
126862
+ const sel = shapes.find((s2) => s2.uid === selectedShapeUid);
126863
+ if (sel) {
126864
+ const { uid: sUid, type: sType, strokeWidth: sStrokeWidth = 3 } = sel;
126865
+ const haloColor = [255, 220, 50, 70];
126866
+ const haloWidth = Math.max(sStrokeWidth + 8, 10);
126867
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
126868
+ if (sType === "rectangle") {
126869
+ const { x, y, width, height } = sel;
126870
+ selectionLayers.push(new PathLayer({
126871
+ ...base,
126872
+ id: `annotation-select-${sUid}`,
126873
+ data: [{
126874
+ path: [
126875
+ [x, y],
126876
+ [x + width, y],
126877
+ [x + width, y + height],
126878
+ [x, y + height],
126879
+ [x, y]
126880
+ ]
126881
+ }],
126882
+ getPath: (d) => d.path,
126883
+ getColor: haloColor,
126884
+ getWidth: haloWidth,
126885
+ widthUnits: "pixels",
126886
+ jointRounded: true,
126887
+ capRounded: true
126888
+ }));
126889
+ }
126890
+ if (sType === "line") {
126891
+ const { x1: x12, y1: y12, x2, y2 } = sel;
126892
+ selectionLayers.push(new PathLayer({
126893
+ ...base,
126894
+ id: `annotation-select-${sUid}`,
126895
+ data: [{ path: [[x12, y12], [x2, y2]] }],
126896
+ getPath: (d) => d.path,
126897
+ getColor: haloColor,
126898
+ getWidth: haloWidth,
126899
+ widthUnits: "pixels",
126900
+ capRounded: true
126901
+ }));
126902
+ }
126903
+ if (sType === "ellipse") {
126904
+ const polygon2 = computeEllipsePolygon(sel.x1, sel.y1, sel.radiusX, sel.radiusY);
126905
+ selectionLayers.push(new PathLayer({
126906
+ ...base,
126907
+ id: `annotation-select-${sUid}`,
126908
+ data: [{ path: [...polygon2, polygon2[0]] }],
126909
+ getPath: (d) => d.path,
126910
+ getColor: haloColor,
126911
+ getWidth: haloWidth,
126912
+ widthUnits: "pixels",
126913
+ jointRounded: true
126914
+ }));
126915
+ }
126916
+ if (sType === "polygon" && sel.points?.length >= 3) {
126917
+ selectionLayers.push(new PathLayer({
126918
+ ...base,
126919
+ id: `annotation-select-${sUid}`,
126920
+ data: [{ path: [...sel.points, sel.points[0]] }],
126921
+ getPath: (d) => d.path,
126922
+ getColor: haloColor,
126923
+ getWidth: haloWidth,
126924
+ widthUnits: "pixels",
126925
+ jointRounded: true
126926
+ }));
126927
+ }
126928
+ if (sType === "polyline" && sel.points?.length >= 2) {
126929
+ selectionLayers.push(new PathLayer({
126930
+ ...base,
126931
+ id: `annotation-select-${sUid}`,
126932
+ data: [{ path: sel.points }],
126933
+ getPath: (d) => d.path,
126934
+ getColor: haloColor,
126935
+ getWidth: haloWidth,
126936
+ widthUnits: "pixels",
126937
+ jointRounded: true,
126938
+ capRounded: true
126939
+ }));
126940
+ }
126941
+ }
126942
+ }
126943
+ const layers = [];
126944
+ const dotShapes = [];
126945
+ const clusterDotShapes = [];
126946
+ shapes.forEach((shape, i2) => {
126947
+ const {
126948
+ uid: uid2,
126949
+ type,
126950
+ strokeColor = [255, 255, 255],
126951
+ strokeWidth = 3,
126952
+ strokeDashArray
126953
+ } = shape;
126954
+ const isSelected = uid2 === selectedShapeUid;
126955
+ let shapeOpacity = 1;
126956
+ let tipsOpacity = 1;
126957
+ let labelOpacity = 0;
126958
+ if (isSelected || !semanticZoom || authoredZoom === null) {
126959
+ tipsOpacity = 1;
126960
+ labelOpacity = 1;
126961
+ } else {
126962
+ const zoomRatio = 2 ** (zoom - authoredZoom);
126963
+ if (zoomRatio < RATIO_CLUSTER) {
126964
+ clusterDotShapes.push({ shape });
126965
+ return;
126966
+ }
126967
+ if (zoomRatio < RATIO_DOT) {
126968
+ dotShapes.push({ shape, alpha: 200 });
126969
+ return;
126970
+ }
126971
+ if (zoomRatio < RATIO_GEO_FADE) {
126972
+ const t = (zoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
126973
+ shapeOpacity = t;
126974
+ dotShapes.push({ shape, alpha: Math.round((1 - t) * 200) });
126975
+ }
126976
+ tipsOpacity = zoomRatio >= RATIO_TIPS ? shapeOpacity : Math.max(
126977
+ 0,
126978
+ (zoomRatio - RATIO_GEO_FADE) / (RATIO_TIPS - RATIO_GEO_FADE) * shapeOpacity
126979
+ );
126980
+ if (zoomRatio >= RATIO_LABEL_FULL) {
126981
+ labelOpacity = shapeOpacity;
126982
+ } else if (zoomRatio >= RATIO_LABEL) {
126983
+ labelOpacity = (zoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL) * shapeOpacity;
126984
+ }
126985
+ }
126986
+ const arrowDataSize = Math.max(ARROW_SCREEN_PX, strokeWidth * 4) / 2 ** zoom;
126987
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: shapeOpacity };
126988
+ const tipsBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: tipsOpacity };
126989
+ const labelBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: labelOpacity };
126990
+ const labelBgProps = shape.labelBackground ? {
126991
+ background: true,
126992
+ getBackgroundColor: textBgColor(strokeColor),
126993
+ backgroundPadding: [3, 1, 3, 2]
126994
+ } : {};
126995
+ const labelProps = { ...labelBgProps };
126996
+ const dashArray = parseDashArray(strokeDashArray);
126997
+ const dashExt = [new PathStyleExtension({ dash: true })];
126998
+ const getDash = dashArray ?? [0, 0];
126999
+ if (type === "rectangle") {
127000
+ const { x, y, width, height, fillColor = strokeColor, fillOpacity = 0 } = shape;
127001
+ const filled = fillOpacity > 0;
127002
+ const rectPolygon = [[x, y], [x + width, y], [x + width, y + height], [x, y + height]];
127003
+ layers.push(new PolygonLayer({
127004
+ ...base,
127005
+ id: `annotation-rect-${uid2}-${i2}`,
127006
+ data: [{ polygon: rectPolygon }],
127007
+ getPolygon: (d) => d.polygon,
127008
+ filled,
127009
+ stroked: true,
127010
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
127011
+ getLineColor: strokeColor,
127012
+ getLineWidth: strokeWidth,
127013
+ lineWidthUnits: "pixels",
127014
+ ...dashArray ? {
127015
+ extensions: [new PathStyleExtension({ dash: true })],
127016
+ getDashArray: dashArray
127017
+ } : {}
127018
+ }));
127019
+ if (shape.text && labelOpacity > 0) {
127020
+ layers.push(new TextLayer({
127021
+ ...labelBase,
127022
+ ...labelProps,
127023
+ id: `annotation-rect-text-${uid2}-${i2}`,
127024
+ data: [{ position: [x, y], text: shape.text }],
127025
+ getPosition: (d) => d.position,
127026
+ getText: (d) => d.text,
127027
+ getColor: strokeColor,
127028
+ getSize: LABEL_FONT_SIZE,
127029
+ sizeUnits: "pixels",
127030
+ fontFamily: LABEL_FONT_FAMILY,
127031
+ fontWeight: LABEL_FONT_WEIGHT,
127032
+ getPixelOffset: [3, -7],
127033
+ getTextAnchor: "start",
127034
+ getAlignmentBaseline: "bottom"
127035
+ }));
127036
+ }
127037
+ }
127038
+ if (type === "line") {
127039
+ const { x1: x12, y1: y12, x2, y2, markerStart, markerEnd } = shape;
127040
+ const dx = x2 - x12;
127041
+ const dy = y2 - y12;
127042
+ const len2 = Math.sqrt(dx * dx + dy * dy);
127043
+ const ux = len2 > 0 ? dx / len2 : 0;
127044
+ const uy = len2 > 0 ? dy / len2 : 0;
127045
+ const srcX = markerStart === "Arrow" ? x12 + ux * arrowDataSize : x12;
127046
+ const srcY = markerStart === "Arrow" ? y12 + uy * arrowDataSize : y12;
127047
+ const tgtX = markerEnd === "Arrow" ? x2 - ux * arrowDataSize : x2;
127048
+ const tgtY = markerEnd === "Arrow" ? y2 - uy * arrowDataSize : y2;
127049
+ layers.push(new PathLayer({
127050
+ ...base,
127051
+ id: `annotation-line-${uid2}-${i2}`,
127052
+ extensions: [new PathStyleExtension({ dash: true })],
127053
+ getDashArray: dashArray ?? [0, 0],
127054
+ data: [{ path: [[srcX, srcY], [tgtX, tgtY]] }],
127055
+ getPath: (d) => d.path,
127056
+ getColor: strokeColor,
127057
+ getWidth: strokeWidth,
127058
+ widthUnits: "pixels",
127059
+ capRounded: true
127060
+ }));
127061
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
127062
+ const head = computeArrowhead(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
127063
+ if (head) {
127064
+ layers.push(new PolygonLayer({
127065
+ ...tipsBase,
127066
+ id: `annotation-end-arrow-${uid2}-${i2}`,
127067
+ data: [{ polygon: head }],
127068
+ getPolygon: (d) => d.polygon,
127069
+ filled: true,
127070
+ stroked: false,
127071
+ getFillColor: strokeColor
127072
+ }));
127073
+ }
127074
+ }
127075
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
127076
+ const head = computeArrowhead(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
127077
+ if (head) {
127078
+ layers.push(new PolygonLayer({
127079
+ ...tipsBase,
127080
+ id: `annotation-start-arrow-${uid2}-${i2}`,
127081
+ data: [{ polygon: head }],
127082
+ getPolygon: (d) => d.polygon,
127083
+ filled: true,
127084
+ stroked: false,
127085
+ getFillColor: strokeColor
127086
+ }));
127087
+ }
127088
+ }
127089
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
127090
+ const tick = computeTickCap(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
127091
+ if (tick) {
127092
+ layers.push(new PathLayer({
127093
+ ...tipsBase,
127094
+ id: `annotation-end-tick-${uid2}-${i2}`,
127095
+ data: [{ path: tick }],
127096
+ getPath: (d) => d.path,
127097
+ getColor: strokeColor,
127098
+ getWidth: strokeWidth,
127099
+ widthUnits: "pixels",
127100
+ capRounded: true
127101
+ }));
127102
+ }
127103
+ }
127104
+ if (markerStart === "Tick" && tipsOpacity > 0) {
127105
+ const tick = computeTickCap(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
127106
+ if (tick) {
127107
+ layers.push(new PathLayer({
127108
+ ...tipsBase,
127109
+ id: `annotation-start-tick-${uid2}-${i2}`,
127110
+ data: [{ path: tick }],
127111
+ getPath: (d) => d.path,
127112
+ getColor: strokeColor,
127113
+ getWidth: strokeWidth,
127114
+ widthUnits: "pixels",
127115
+ capRounded: true
127116
+ }));
127117
+ }
127118
+ }
127119
+ if (shape.text) {
127120
+ const pos = shape.textPosition ?? "start";
127121
+ let textX;
127122
+ let textY;
127123
+ if (pos === "start") {
127124
+ textX = x12;
127125
+ textY = y12;
127126
+ } else if (pos === "end") {
127127
+ textX = x2;
127128
+ textY = y2;
127129
+ } else {
127130
+ textX = (x12 + x2) / 2;
127131
+ textY = (y12 + y2) / 2;
127132
+ }
127133
+ let pixelOffset = [0, 0];
127134
+ let textAnchor = "middle";
127135
+ let alignmentBaseline = "center";
127136
+ if (pos !== "middle") {
127137
+ const dxT = x2 - x12;
127138
+ const dyT = y2 - y12;
127139
+ const lenT = Math.sqrt(dxT * dxT + dyT * dyT);
127140
+ if (lenT > 0) {
127141
+ const uxT = dxT / lenT;
127142
+ const uyT = dyT / lenT;
127143
+ const sign2 = pos === "start" ? -1 : 1;
127144
+ const bufferPx = shape.textBufferPx ?? 8;
127145
+ const offsetX = sign2 * uxT * bufferPx;
127146
+ const offsetY = sign2 * uyT * bufferPx;
127147
+ pixelOffset = [offsetX, offsetY];
127148
+ const absX = Math.abs(offsetX);
127149
+ const absY = Math.abs(offsetY);
127150
+ if (absX >= absY) {
127151
+ textAnchor = offsetX > 0 ? "start" : "end";
127152
+ }
127153
+ if (absY >= absX) {
127154
+ alignmentBaseline = offsetY > 0 ? "top" : "bottom";
127155
+ }
127156
+ }
127157
+ } else if (len2 > 0) {
127158
+ const belowPerp = pickBelowPerp(ux, uy);
127159
+ const bufferPx = shape.textBufferPx ?? 14;
127160
+ pixelOffset = [-belowPerp[0] * bufferPx, -belowPerp[1] * bufferPx];
127161
+ textAnchor = "middle";
127162
+ alignmentBaseline = "center";
127163
+ }
127164
+ const middleAngle = pos === "middle" && len2 > 0 ? -readableAngle(Math.atan2(dy, dx) * 180 / Math.PI) : null;
127165
+ if (labelOpacity <= 0) return;
127166
+ layers.push(new TextLayer({
127167
+ ...labelBase,
127168
+ ...labelProps,
127169
+ id: `annotation-line-text-${uid2}-${i2}`,
127170
+ data: [{ position: [textX, textY], text: shape.text }],
127171
+ getPosition: (d) => d.position,
127172
+ getText: (d) => d.text,
127173
+ getColor: strokeColor,
127174
+ getSize: LABEL_FONT_SIZE,
127175
+ sizeUnits: "pixels",
127176
+ fontFamily: LABEL_FONT_FAMILY,
127177
+ fontWeight: LABEL_FONT_WEIGHT,
127178
+ getPixelOffset: pixelOffset,
127179
+ getTextAnchor: textAnchor,
127180
+ getAlignmentBaseline: alignmentBaseline,
127181
+ ...middleAngle !== null && { getAngle: middleAngle }
127182
+ }));
127183
+ }
127184
+ }
127185
+ if (type === "ellipse") {
127186
+ const { x1: x12, y1: y12, radiusX, radiusY, fillColor = strokeColor, fillOpacity = 0 } = shape;
127187
+ const polygon2 = computeEllipsePolygon(x12, y12, radiusX, radiusY);
127188
+ const filled = fillOpacity > 0;
127189
+ layers.push(new PolygonLayer({
127190
+ ...base,
127191
+ id: `annotation-ellipse-${uid2}-${i2}`,
127192
+ data: [{ polygon: polygon2 }],
127193
+ getPolygon: (d) => d.polygon,
127194
+ filled,
127195
+ stroked: true,
127196
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
127197
+ getLineColor: strokeColor,
127198
+ getLineWidth: strokeWidth,
127199
+ lineWidthUnits: "pixels",
127200
+ ...dashArray ? {
127201
+ extensions: [new PathStyleExtension({ dash: true })],
127202
+ getDashArray: dashArray
127203
+ } : {}
127204
+ }));
127205
+ if (shape.text && labelOpacity > 0) {
127206
+ layers.push(new TextLayer({
127207
+ ...labelBase,
127208
+ ...labelProps,
127209
+ id: `annotation-ellipse-text-${uid2}-${i2}`,
127210
+ data: [{ position: [x12, y12 - radiusY], text: shape.text }],
127211
+ getPosition: (d) => d.position,
127212
+ getText: (d) => d.text,
127213
+ getColor: strokeColor,
127214
+ getSize: LABEL_FONT_SIZE,
127215
+ sizeUnits: "pixels",
127216
+ fontFamily: LABEL_FONT_FAMILY,
127217
+ fontWeight: LABEL_FONT_WEIGHT,
127218
+ getPixelOffset: [0, -4],
127219
+ getTextAnchor: "middle",
127220
+ getAlignmentBaseline: "bottom"
127221
+ }));
127222
+ }
127223
+ }
127224
+ if (type === "polygon") {
127225
+ const { points, fillColor = strokeColor, fillOpacity = 0 } = shape;
127226
+ if (!points || points.length < 3) return;
127227
+ const closedPath = [...points, points[0]];
127228
+ if (fillOpacity > 0) {
127229
+ layers.push(new PolygonLayer({
127230
+ ...base,
127231
+ id: `annotation-polygon-fill-${uid2}-${i2}`,
127232
+ data: [{ polygon: points }],
127233
+ getPolygon: (d) => d.polygon,
127234
+ stroked: false,
127235
+ filled: true,
127236
+ getFillColor: [...fillColor, Math.round(fillOpacity * 255)]
127237
+ }));
127238
+ }
127239
+ layers.push(new PathLayer({
127240
+ ...base,
127241
+ id: `annotation-polygon-${uid2}-${i2}`,
127242
+ extensions: dashExt,
127243
+ getDashArray: getDash,
127244
+ data: [{ path: closedPath }],
127245
+ getPath: (d) => d.path,
127246
+ getColor: strokeColor,
127247
+ getWidth: strokeWidth,
127248
+ widthUnits: "pixels",
127249
+ jointRounded: true
127250
+ }));
127251
+ if (shape.text && labelOpacity > 0) {
127252
+ const minX = Math.min(...points.map((p) => p[0]));
127253
+ const maxX = Math.max(...points.map((p) => p[0]));
127254
+ const minY = Math.min(...points.map((p) => p[1]));
127255
+ const topCenterX = (minX + maxX) / 2;
127256
+ layers.push(new TextLayer({
127257
+ ...labelBase,
127258
+ ...labelProps,
127259
+ id: `annotation-polygon-text-${uid2}-${i2}`,
127260
+ data: [{ position: [topCenterX, minY], text: shape.text }],
127261
+ getPosition: (d) => d.position,
127262
+ getText: (d) => d.text,
127263
+ getColor: strokeColor,
127264
+ getSize: LABEL_FONT_SIZE,
127265
+ sizeUnits: "pixels",
127266
+ fontFamily: LABEL_FONT_FAMILY,
127267
+ fontWeight: LABEL_FONT_WEIGHT,
127268
+ getPixelOffset: [0, -4],
127269
+ getTextAnchor: "middle",
127270
+ getAlignmentBaseline: "bottom"
127271
+ }));
127272
+ }
127273
+ }
127274
+ if (type === "polyline") {
127275
+ const { points, markerStart, markerEnd } = shape;
127276
+ if (!points || points.length < 2) return;
127277
+ let pathPoints = points;
127278
+ if (markerStart === "Arrow") {
127279
+ const [x02, y02] = points[0];
127280
+ const [x12, y12] = points[1];
127281
+ const dx = x02 - x12;
127282
+ const dy = y02 - y12;
127283
+ const len2 = Math.sqrt(dx * dx + dy * dy);
127284
+ if (len2 > 0) {
127285
+ const ux = dx / len2;
127286
+ const uy = dy / len2;
127287
+ pathPoints = [[x02 - ux * arrowDataSize, y02 - uy * arrowDataSize], ...pathPoints.slice(1)];
127288
+ }
127289
+ }
127290
+ if (markerEnd === "Arrow") {
127291
+ const last = pathPoints[pathPoints.length - 1];
127292
+ const prev = pathPoints[pathPoints.length - 2];
127293
+ const dx = last[0] - prev[0];
127294
+ const dy = last[1] - prev[1];
127295
+ const len2 = Math.sqrt(dx * dx + dy * dy);
127296
+ if (len2 > 0) {
127297
+ const ux = dx / len2;
127298
+ const uy = dy / len2;
127299
+ const shortened = [last[0] - ux * arrowDataSize, last[1] - uy * arrowDataSize];
127300
+ pathPoints = [...pathPoints.slice(0, -1), shortened];
127301
+ }
127302
+ }
127303
+ layers.push(new PathLayer({
127304
+ ...base,
127305
+ id: `annotation-polyline-${uid2}-${i2}`,
127306
+ extensions: dashExt,
127307
+ getDashArray: getDash,
127308
+ data: [{ path: pathPoints }],
127309
+ getPath: (d) => d.path,
127310
+ getColor: strokeColor,
127311
+ getWidth: strokeWidth,
127312
+ widthUnits: "pixels",
127313
+ jointRounded: true,
127314
+ capRounded: true
127315
+ }));
127316
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
127317
+ const [x02, y02] = points[0];
127318
+ const [x12, y12] = points[1];
127319
+ const head = computeArrowhead(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
127320
+ if (head) {
127321
+ layers.push(new PolygonLayer({
127322
+ ...tipsBase,
127323
+ id: `annotation-polyline-start-arrow-${uid2}-${i2}`,
127324
+ data: [{ polygon: head }],
127325
+ getPolygon: (d) => d.polygon,
127326
+ filled: true,
127327
+ stroked: false,
127328
+ getFillColor: strokeColor
127329
+ }));
127330
+ }
127331
+ }
127332
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
127333
+ const last = points[points.length - 1];
127334
+ const prev = points[points.length - 2];
127335
+ const dxArrow = last[0] - prev[0];
127336
+ const dyArrow = last[1] - prev[1];
127337
+ const head = computeArrowhead(last[0], last[1], dxArrow, dyArrow, arrowDataSize);
127338
+ if (head) {
127339
+ layers.push(new PolygonLayer({
127340
+ ...tipsBase,
127341
+ id: `annotation-polyline-end-arrow-${uid2}-${i2}`,
127342
+ data: [{ polygon: head }],
127343
+ getPolygon: (d) => d.polygon,
127344
+ filled: true,
127345
+ stroked: false,
127346
+ getFillColor: strokeColor
127347
+ }));
127348
+ }
127349
+ }
127350
+ if (markerStart === "Tick" && tipsOpacity > 0) {
127351
+ const [x02, y02] = points[0];
127352
+ const [x12, y12] = points[1];
127353
+ const tick = computeTickCap(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
127354
+ if (tick) {
127355
+ layers.push(new PathLayer({
127356
+ ...tipsBase,
127357
+ id: `annotation-polyline-start-tick-${uid2}-${i2}`,
127358
+ data: [{ path: tick }],
127359
+ getPath: (d) => d.path,
127360
+ getColor: strokeColor,
127361
+ getWidth: strokeWidth,
127362
+ widthUnits: "pixels",
127363
+ capRounded: true
127364
+ }));
127365
+ }
127366
+ }
127367
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
127368
+ const last = points[points.length - 1];
127369
+ const prev = points[points.length - 2];
127370
+ const dxTick = last[0] - prev[0];
127371
+ const dyTick = last[1] - prev[1];
127372
+ const tick = computeTickCap(last[0], last[1], dxTick, dyTick, arrowDataSize);
127373
+ if (tick) {
127374
+ layers.push(new PathLayer({
127375
+ ...tipsBase,
127376
+ id: `annotation-polyline-end-tick-${uid2}-${i2}`,
127377
+ data: [{ path: tick }],
127378
+ getPath: (d) => d.path,
127379
+ getColor: strokeColor,
127380
+ getWidth: strokeWidth,
127381
+ widthUnits: "pixels",
127382
+ capRounded: true
127383
+ }));
127384
+ }
127385
+ }
127386
+ if (shape.text) {
127387
+ const pos = shape.textPosition ?? "start";
127388
+ const bufferPx = shape.textBufferPx ?? 8;
127389
+ let textPt;
127390
+ let dirX;
127391
+ let dirY;
127392
+ if (pos === "end") {
127393
+ const last = points[points.length - 1];
127394
+ const prev = points[points.length - 2];
127395
+ textPt = last;
127396
+ dirX = last[0] - prev[0];
127397
+ dirY = last[1] - prev[1];
127398
+ } else if (pos === "middle") {
127399
+ const mx = points.reduce((s2, p) => s2 + p[0], 0) / points.length;
127400
+ const my = points.reduce((s2, p) => s2 + p[1], 0) / points.length;
127401
+ textPt = [mx, my];
127402
+ dirX = 0;
127403
+ dirY = 0;
127404
+ } else {
127405
+ [textPt] = points;
127406
+ dirX = points[0][0] - points[1][0];
127407
+ dirY = points[0][1] - points[1][1];
127408
+ }
127409
+ const [textX, textY] = textPt;
127410
+ const lenT = Math.sqrt(dirX * dirX + dirY * dirY);
127411
+ let polylinePixelOffset = [0, 0];
127412
+ let polylineTextAnchor = "middle";
127413
+ let polylineAlignmentBaseline = pos === "middle" ? "center" : "bottom";
127414
+ if (lenT > 0) {
127415
+ const uxT = dirX / lenT;
127416
+ const uyT = dirY / lenT;
127417
+ const offX = uxT * bufferPx;
127418
+ const offY = uyT * bufferPx;
127419
+ polylinePixelOffset = [offX, offY];
127420
+ if (Math.abs(offX) >= Math.abs(offY)) {
127421
+ polylineTextAnchor = offX > 0 ? "start" : "end";
127422
+ }
127423
+ if (Math.abs(offY) >= Math.abs(offX)) {
127424
+ polylineAlignmentBaseline = offY > 0 ? "top" : "bottom";
127425
+ }
127426
+ }
127427
+ if (labelOpacity <= 0) return;
127428
+ layers.push(new TextLayer({
127429
+ ...labelBase,
127430
+ ...labelProps,
127431
+ id: `annotation-polyline-text-${uid2}-${i2}`,
127432
+ data: [{ position: [textX, textY], text: shape.text }],
127433
+ getPosition: (d) => d.position,
127434
+ getText: (d) => d.text,
127435
+ getColor: strokeColor,
127436
+ getSize: LABEL_FONT_SIZE,
127437
+ sizeUnits: "pixels",
127438
+ fontFamily: LABEL_FONT_FAMILY,
127439
+ fontWeight: LABEL_FONT_WEIGHT,
127440
+ getPixelOffset: polylinePixelOffset,
127441
+ getTextAnchor: polylineTextAnchor,
127442
+ getAlignmentBaseline: polylineAlignmentBaseline
127443
+ }));
127444
+ }
127445
+ }
127446
+ });
127447
+ if (dotShapes.length > 0) {
127448
+ layers.push(new ScatterplotLayer({
127449
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127450
+ id: "annotation-dots",
127451
+ data: dotShapes.map(({ shape: s2, alpha: alpha2 }) => ({
127452
+ position: getShapeCentroid(s2),
127453
+ color: [...s2.strokeColor ?? [255, 255, 255], alpha2]
127454
+ })),
127455
+ getPosition: (d) => d.position,
127456
+ getFillColor: (d) => d.color,
127457
+ getRadius: 4,
127458
+ radiusUnits: "pixels",
127459
+ filled: true,
127460
+ stroked: false
127461
+ }));
127462
+ }
127463
+ if (clusterDotShapes.length > 0) {
127464
+ const clusters = computeClusters(clusterDotShapes, zoom);
127465
+ layers.push(new ScatterplotLayer({
127466
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127467
+ id: "annotation-clusters",
127468
+ data: clusters,
127469
+ getPosition: (d) => d.position,
127470
+ getFillColor: (d) => [...d.color, 180],
127471
+ getRadius: (d) => Math.max(6, 4 + Math.sqrt(d.count) * 2),
127472
+ radiusUnits: "pixels",
127473
+ filled: true,
127474
+ stroked: true,
127475
+ getLineColor: (d) => [...d.color, 220],
127476
+ lineWidthMinPixels: 1.5
127477
+ }));
127478
+ const multiClusters = clusters.filter((c) => c.count > 1);
127479
+ if (multiClusters.length > 0) {
127480
+ layers.push(new TextLayer({
127481
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127482
+ id: "annotation-cluster-counts",
127483
+ data: multiClusters,
127484
+ getPosition: (d) => d.position,
127485
+ getText: (d) => String(d.count),
127486
+ getColor: [255, 255, 255],
127487
+ getSize: 10,
127488
+ sizeUnits: "pixels",
127489
+ fontWeight: "bold",
127490
+ getTextAnchor: "middle",
127491
+ getAlignmentBaseline: "center"
127492
+ }));
127493
+ }
127494
+ }
127495
+ const measureLayers = [];
127496
+ shapes.forEach((shape) => {
127497
+ if (!shape.showMeasure) return;
127498
+ const mIsSelected = shape.uid === selectedShapeUid;
127499
+ const label = getMeasurementLabel(shape, physicalPixelSize, viewType);
127500
+ if (!label) return;
127501
+ const color = shape.strokeColor ?? [255, 255, 255];
127502
+ let mShapeOpacity = 1;
127503
+ let mLabelFactor = 0;
127504
+ if (mIsSelected || !semanticZoom || authoredZoom === null) {
127505
+ mLabelFactor = 1;
127506
+ } else {
127507
+ const mZoomRatio = 2 ** (zoom - authoredZoom);
127508
+ if (mZoomRatio < RATIO_DOT) return;
127509
+ if (mZoomRatio < RATIO_GEO_FADE) {
127510
+ mShapeOpacity = (mZoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
127511
+ }
127512
+ if (mZoomRatio >= RATIO_LABEL_FULL) {
127513
+ mLabelFactor = 1;
127514
+ } else if (mZoomRatio >= RATIO_LABEL) {
127515
+ mLabelFactor = (mZoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL);
127516
+ }
127517
+ }
127518
+ const measureOpacity = mShapeOpacity * mLabelFactor;
127519
+ if (measureOpacity <= 0) return;
127520
+ const base = {
127521
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127522
+ opacity: measureOpacity,
127523
+ getText: (d) => d.text,
127524
+ getPosition: (d) => d.position,
127525
+ getColor: color,
127526
+ getSize: 13,
127527
+ sizeUnits: "pixels",
127528
+ fontFamily: LABEL_FONT_FAMILY,
127529
+ fontWeight: "bold",
127530
+ // 'auto' builds the font atlas from the actual rendered characters (e.g. µ, ²)
127531
+ // instead of deck.gl's default ASCII-only atlas.
127532
+ characterSet: "auto",
127533
+ ...shape.measureBackground ? {
127534
+ background: true,
127535
+ getBackgroundColor: textBgColor(color),
127536
+ backgroundPadding: [3, 1, 3, 2]
127537
+ } : {}
127538
+ };
127539
+ if (shape.type === "line") {
127540
+ const mx = ((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2;
127541
+ const my = ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2;
127542
+ const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
127543
+ const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
127544
+ const len2 = Math.sqrt(dx * dx + dy * dy);
127545
+ if (len2 === 0) return;
127546
+ const perp = pickBelowPerp(dx / len2, dy / len2);
127547
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
127548
+ measureLayers.push(new TextLayer({
127549
+ ...base,
127550
+ id: `annotation-measure-${shape.uid}`,
127551
+ data: [{ position: [mx, my], text: label }],
127552
+ getAngle: -angle2,
127553
+ getTextAnchor: "middle",
127554
+ getAlignmentBaseline: "center",
127555
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
127556
+ }));
127557
+ } else if (shape.type === "polyline" && shape.points?.length >= 2) {
127558
+ const pts = shape.points;
127559
+ const mi = Math.floor((pts.length - 1) / 2);
127560
+ const [ax, ay] = pts[mi];
127561
+ const [bx, by] = pts[mi + 1];
127562
+ const dx = bx - ax;
127563
+ const dy = by - ay;
127564
+ const len2 = Math.sqrt(dx * dx + dy * dy);
127565
+ if (len2 === 0) return;
127566
+ const perp = pickBelowPerp(dx / len2, dy / len2);
127567
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
127568
+ measureLayers.push(new TextLayer({
127569
+ ...base,
127570
+ id: `annotation-measure-${shape.uid}`,
127571
+ data: [{ position: [(ax + bx) / 2, (ay + by) / 2], text: label }],
127572
+ getAngle: -angle2,
127573
+ getTextAnchor: "middle",
127574
+ getAlignmentBaseline: "center",
127575
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
127576
+ }));
127577
+ } else if (shape.type === "rectangle") {
127578
+ const x02 = shape.x ?? 0;
127579
+ const y02 = shape.y ?? 0;
127580
+ const w2 = shape.width ?? 0;
127581
+ const h = shape.height ?? 0;
127582
+ const rx = x02 + (w2 >= 0 ? w2 : 0);
127583
+ const ry = y02 + (h >= 0 ? h : 0);
127584
+ measureLayers.push(new TextLayer({
127585
+ ...base,
127586
+ id: `annotation-measure-${shape.uid}`,
127587
+ data: [{ position: [rx, ry], text: label }],
127588
+ getTextAnchor: "end",
127589
+ getAlignmentBaseline: "bottom",
127590
+ getPixelOffset: [-6, -6]
127591
+ }));
127592
+ } else if (shape.type === "ellipse") {
127593
+ const cx = shape.x1 ?? 0;
127594
+ const cy = shape.y1 ?? 0;
127595
+ const ry = Math.abs(shape.radiusY ?? 0);
127596
+ measureLayers.push(new TextLayer({
127597
+ ...base,
127598
+ id: `annotation-measure-${shape.uid}`,
127599
+ data: [{ position: [cx, cy + ry], text: label }],
127600
+ getTextAnchor: "middle",
127601
+ getAlignmentBaseline: "top",
127602
+ getPixelOffset: [0, 8]
127603
+ }));
127604
+ } else if (shape.type === "polygon" && shape.points?.length >= 3) {
127605
+ const xs = shape.points.map((p) => p[0]);
127606
+ const ys = shape.points.map((p) => p[1]);
127607
+ const cx = (Math.min(...xs) + Math.max(...xs)) / 2;
127608
+ const maxY = Math.max(...ys);
127609
+ measureLayers.push(new TextLayer({
127610
+ ...base,
127611
+ id: `annotation-measure-${shape.uid}`,
127612
+ data: [{ position: [cx, maxY], text: label }],
127613
+ getTextAnchor: "middle",
127614
+ getAlignmentBaseline: "top",
127615
+ getPixelOffset: [0, 8]
127616
+ }));
127617
+ }
127618
+ });
127619
+ return [...selectionLayers, ...layers, ...measureLayers];
127620
+ }
127621
+ const defaultProps = {
127622
+ // Array of annotation shape objects (see annotationShapeObj in @vitessce/schemas).
127623
+ data: { type: "object", value: [], compare: true },
127624
+ // UID of the shape to highlight with a selection halo.
127625
+ selectedShapeUid: { type: "string", value: null },
127626
+ // { x, y, unit } used to format measurement labels in physical units.
127627
+ physicalPixelSize: { type: "object", value: null, compare: true },
127628
+ // The zoom level at which the shapes were authored (reference for semantic zoom).
127629
+ authoredZoom: { type: "number", value: null },
127630
+ // Whether to apply semantic zoom (level-of-detail) based on authoredZoom.
127631
+ semanticZoom: { type: "boolean", value: true },
127632
+ // The view type in which the layer is rendered (affects measurement label formatting).
127633
+ viewType: { type: "string", value: ViewType.SPATIAL },
127634
+ // In-progress shape being drawn, as { type, vertices }.
127635
+ inProgressShape: { type: "object", value: null, compare: true },
127636
+ // Current mouse position (in data coordinates) while drawing.
127637
+ hoverCoord: { type: "array", value: null, compare: true },
127638
+ // Stroke color [r, g, b] of the in-progress shape preview.
127639
+ previewStrokeColor: { type: "color", value: [255, 255, 0] }
127640
+ };
127641
+ class AnnotationLayer extends CompositeLayer {
127642
+ // The semantic zoom and arrowhead sizes depend on the current zoom level,
127643
+ // so the sublayers must also be re-rendered when the viewport changes.
127644
+ // eslint-disable-next-line class-methods-use-this
127645
+ shouldUpdateState({ changeFlags }) {
127646
+ return changeFlags.propsOrDataChanged || changeFlags.viewportChanged;
127647
+ }
127648
+ /**
127649
+ * Prefix the sublayer ID with this layer's ID (so that multiple
127650
+ * AnnotationLayers can co-exist), and combine this layer's
127651
+ * opacity with the per-shape opacity of the sublayer.
127652
+ * Note: we avoid getSubLayerProps here, since it would
127653
+ * overwrite the sublayer extensions (e.g., PathStyleExtension)
127654
+ * and opacity values.
127655
+ * @param {object} layer A DeckGL layer instance.
127656
+ * @returns {object} The cloned layer instance.
127657
+ */
127658
+ wrapSubLayer(layer) {
127659
+ const { id, opacity, pickable, visible } = this.props;
127660
+ return layer.clone({
127661
+ id: `${id}-${layer.id}`,
127662
+ opacity: layer.props.opacity * opacity,
127663
+ pickable,
127664
+ visible
127665
+ });
127666
+ }
127667
+ renderLayers() {
127668
+ const {
127669
+ data,
127670
+ selectedShapeUid,
127671
+ physicalPixelSize,
127672
+ authoredZoom,
127673
+ semanticZoom,
127674
+ viewType,
127675
+ inProgressShape,
127676
+ hoverCoord,
127677
+ previewStrokeColor
127678
+ } = this.props;
127679
+ const zoom = this.context.viewport?.zoom ?? 0;
127680
+ const visibleShapes = (data ?? []).filter((shape) => shape.visible !== false);
127681
+ const annotationLayers = createAnnotationLayers(
127682
+ visibleShapes,
127683
+ zoom,
127684
+ selectedShapeUid,
127685
+ physicalPixelSize,
127686
+ authoredZoom,
127687
+ semanticZoom,
127688
+ viewType
127689
+ );
127690
+ const previewLayer = createPreviewLayer(
127691
+ inProgressShape,
127692
+ hoverCoord,
127693
+ previewStrokeColor.slice(0, 3)
127694
+ );
127695
+ return [
127696
+ ...annotationLayers,
127697
+ ...previewLayer ? [previewLayer] : []
127698
+ ].map((layer) => this.wrapSubLayer(layer));
127699
+ }
127700
+ }
127701
+ AnnotationLayer.layerName = "AnnotationLayer";
127702
+ AnnotationLayer.defaultProps = defaultProps;
126479
127703
  const viv = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
126480
127704
  __proto__: null,
126481
127705
  AdditiveColormap3DExtensions,
@@ -126502,20 +127726,6 @@ const luma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty
126502
127726
  GL: GL$1,
126503
127727
  Texture2D
126504
127728
  }, Symbol.toStringTag, { value: "Module" }));
126505
- const deck = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
126506
- __proto__: null,
126507
- COORDINATE_SYSTEM,
126508
- ContourLayer,
126509
- DataFilterExtension,
126510
- DeckGL,
126511
- LineLayer,
126512
- OrbitView,
126513
- OrthographicView,
126514
- PolygonLayer,
126515
- ScatterplotLayer,
126516
- TextLayer,
126517
- TileLayer
126518
- }, Symbol.toStringTag, { value: "Module" }));
126519
127729
  const math = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
126520
127730
  __proto__: null,
126521
127731
  Matrix4,
@@ -126523,12 +127733,15 @@ const math = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty
126523
127733
  Vector3
126524
127734
  }, Symbol.toStringTag, { value: "Module" }));
126525
127735
  export {
126526
- AXIS_MARGIN as A,
127736
+ AnnotationLayer as A,
126527
127737
  BaseDecoder as B,
126528
127738
  ContourLayerWithText as C,
126529
127739
  DEFAULT_GL_OPTIONS as D,
127740
+ computeArrowhead as E,
127741
+ getMeasurementLabel as F,
126530
127742
  GLSL_COLORMAPS as G,
126531
127743
  HeatmapBitmapLayer as H,
127744
+ math as I,
126532
127745
  LercParameters as L,
126533
127746
  MAX_ROW_AGG as M,
126534
127747
  PixelatedBitmapLayer as P,
@@ -126547,15 +127760,17 @@ export {
126547
127760
  BitmaskLayer2 as k,
126548
127761
  MIN_ROW_AGG as l,
126549
127762
  COLOR_BAR_SIZE as m,
126550
- DATA_TEXTURE_SIZE as n,
126551
- PIXELATED_TEXTURE_PARAMETERS as o,
126552
- AXIS_LABEL_TEXT_SIZE as p,
126553
- AXIS_FONT_FAMILY as q,
126554
- AXIS_PADDING as r,
126555
- AXIS_MIN_SIZE as s,
126556
- AXIS_MAX_SIZE as t,
126557
- luma as u,
127763
+ AXIS_MARGIN as n,
127764
+ DATA_TEXTURE_SIZE as o,
127765
+ PIXELATED_TEXTURE_PARAMETERS as p,
127766
+ AXIS_LABEL_TEXT_SIZE as q,
127767
+ AXIS_FONT_FAMILY as r,
127768
+ AXIS_PADDING as s,
127769
+ AXIS_MIN_SIZE as t,
127770
+ AXIS_MAX_SIZE as u,
126558
127771
  viv as v,
126559
- deck as w,
126560
- math as x
127772
+ luma as w,
127773
+ deck as x,
127774
+ createAnnotationLayers as y,
127775
+ createPreviewLayer as z
126561
127776
  };