@vitessce/neuroglancer 3.7.0 → 3.7.1

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.
@@ -1,6 +1,8 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1
4
  import React__default from "react";
2
- import { g as getDefaultExportFromCjs, c as commonjsGlobal, a as getAugmentedNamespace, r as requirePropTypes } from "./index-BNCfoEHv.js";
3
- var lib = {};
5
+ import { g as getDefaultExportFromCjs, c as commonjsGlobal, d as diffCameraState } from "./index-w8xI9TWU.js";
4
6
  var es6_object_assign = {};
5
7
  var _global = { exports: {} };
6
8
  var hasRequired_global;
@@ -1889,7 +1891,7 @@ function requireEs6_set() {
1889
1891
  var validate = require_validateCollection();
1890
1892
  var SET = "Set";
1891
1893
  es6_set = require_collection()(SET, function(get) {
1892
- return function Set() {
1894
+ return function Set2() {
1893
1895
  return get(this, arguments.length > 0 ? arguments[0] : void 0);
1894
1896
  };
1895
1897
  }, {
@@ -4219,8 +4221,8 @@ function serializeColor(x) {
4219
4221
  function srgbGammaExpand(value) {
4220
4222
  return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
4221
4223
  }
4222
- function getRelativeLuminance(color2) {
4223
- var _color = _slicedToArray(color2, 3);
4224
+ function getRelativeLuminance(color) {
4225
+ var _color = _slicedToArray(color, 3);
4224
4226
  const r = _color[0], g = _color[1], b = _color[2];
4225
4227
  return 0.2126 * srgbGammaExpand(r) + 0.7152 * srgbGammaExpand(g) + 0.0722 * srgbGammaExpand(b);
4226
4228
  }
@@ -4281,21 +4283,6 @@ class TrackableOptionalRGB extends WatchableValue {
4281
4283
  }
4282
4284
  }
4283
4285
  }
4284
- const color = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4285
- __proto__: null,
4286
- TrackableOptionalRGB,
4287
- TrackableRGB,
4288
- getRelativeLuminance,
4289
- packColor,
4290
- parseColorSerialization,
4291
- parseRGBAColorSpecification,
4292
- parseRGBColorSpecification,
4293
- serializeColor,
4294
- srgbGammaExpand,
4295
- unpackRGB,
4296
- unpackRGBA,
4297
- useWhiteBackground
4298
- }, Symbol.toStringTag, { value: "Module" }));
4299
4286
  /**
4300
4287
  * @license
4301
4288
  * Copyright 2016 Google Inc.
@@ -4616,73 +4603,10 @@ function stableStringify(x) {
4616
4603
  }
4617
4604
  return _JSON$stringify(x);
4618
4605
  }
4619
- function swapQuotes(x) {
4620
- return x.replace(/['"]/g, (s) => {
4621
- return s === '"' ? "'" : '"';
4622
- });
4623
- }
4624
- function urlSafeStringifyString(x) {
4625
- return swapQuotes(_JSON$stringify(swapQuotes(x)));
4626
- }
4627
- const URL_SAFE_COMMA = "_";
4628
- function urlSafeStringify(x) {
4629
- if (typeof x === "object") {
4630
- if (x === null) {
4631
- return "null";
4632
- }
4633
- let toJSON = x["toJSON"];
4634
- if (typeof toJSON === "function") {
4635
- return urlSafeStringify(toJSON.call(x));
4636
- }
4637
- if (Array.isArray(x)) {
4638
- let s2 = "[";
4639
- let size = x.length;
4640
- let i = 0;
4641
- if (i < size) {
4642
- s2 += urlSafeStringify(x[i]);
4643
- while (++i < size) {
4644
- s2 += URL_SAFE_COMMA;
4645
- s2 += urlSafeStringify(x[i]);
4646
- }
4647
- }
4648
- s2 += "]";
4649
- return s2;
4650
- }
4651
- let s = "{";
4652
- let keys2 = _Object$keys(x);
4653
- let first = true;
4654
- for (let key of keys2) {
4655
- let value = x[key];
4656
- if (value === void 0) {
4657
- continue;
4658
- }
4659
- let valueString = urlSafeStringify(value);
4660
- if (!valueString) {
4661
- continue;
4662
- }
4663
- if (!first) {
4664
- s += URL_SAFE_COMMA;
4665
- } else {
4666
- first = false;
4667
- }
4668
- s += urlSafeStringifyString(key);
4669
- s += ":";
4670
- s += valueString;
4671
- }
4672
- s += "}";
4673
- return s;
4674
- }
4675
- if (typeof x === "string") {
4676
- return urlSafeStringifyString(x);
4677
- }
4678
- return _JSON$stringify(x);
4679
- }
4680
4606
  const SINGLE_QUOTE_STRING_PATTERN = /('(?:[^'\\]|(?:\\.))*')/;
4681
4607
  const DOUBLE_QUOTE_STRING_PATTERN = /("(?:[^"\\]|(?:\\.))*")/;
4682
4608
  const SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN = new RegExp(`${SINGLE_QUOTE_STRING_PATTERN.source}|${DOUBLE_QUOTE_STRING_PATTERN.source}`);
4683
- const DOUBLE_OR_SINGLE_QUOTE_STRING_PATTERN = new RegExp(`${DOUBLE_QUOTE_STRING_PATTERN.source}|${SINGLE_QUOTE_STRING_PATTERN.source}`);
4684
4609
  const DOUBLE_QUOTE_PATTERN = /^((?:[^"'\\]|(?:\\[^']))*)("|\\')/;
4685
- const SINGLE_QUOTE_PATTERN = /^((?:[^"'\\]|(?:\\.))*)'/;
4686
4610
  function convertStringLiteral(x, quoteInitial, quoteReplace, quoteSearch) {
4687
4611
  if (x.length >= 2 && x.charAt(0) === quoteInitial && x.charAt(x.length - 1) === quoteInitial) {
4688
4612
  let inner = x.substr(1, x.length - 2);
@@ -4707,22 +4631,15 @@ function convertStringLiteral(x, quoteInitial, quoteReplace, quoteSearch) {
4707
4631
  }
4708
4632
  return x;
4709
4633
  }
4710
- function normalizeStringLiteral(x) {
4711
- return convertStringLiteral(x, "'", '"', DOUBLE_QUOTE_PATTERN);
4712
- }
4713
4634
  function convertJsonHelper(x, desiredCommaChar, desiredQuoteChar) {
4714
4635
  const commaSearch = /[&_,]/g;
4715
4636
  let quoteInitial;
4716
4637
  let quoteSearch;
4717
4638
  let stringLiteralPattern;
4718
- if (desiredQuoteChar === '"') {
4639
+ {
4719
4640
  quoteInitial = "'";
4720
4641
  quoteSearch = DOUBLE_QUOTE_PATTERN;
4721
4642
  stringLiteralPattern = SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN;
4722
- } else {
4723
- quoteInitial = '"';
4724
- quoteSearch = SINGLE_QUOTE_PATTERN;
4725
- stringLiteralPattern = DOUBLE_OR_SINGLE_QUOTE_STRING_PATTERN;
4726
4643
  }
4727
4644
  let s = "";
4728
4645
  while (x.length > 0) {
@@ -4751,40 +4668,9 @@ function convertJsonHelper(x, desiredCommaChar, desiredQuoteChar) {
4751
4668
  function urlSafeToJSON(x) {
4752
4669
  return convertJsonHelper(x, ",", '"');
4753
4670
  }
4754
- function jsonToUrlSafe(x) {
4755
- return convertJsonHelper(x, "_", "'");
4756
- }
4757
4671
  function urlSafeParse(x) {
4758
4672
  return JSON.parse(urlSafeToJSON(x));
4759
4673
  }
4760
- function pythonLiteralToJSON(x) {
4761
- let s = "";
4762
- while (x.length > 0) {
4763
- let m = x.match(SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN);
4764
- let before;
4765
- let replacement;
4766
- if (m === null) {
4767
- before = x;
4768
- x = "";
4769
- replacement = "";
4770
- } else {
4771
- before = x.substr(0, m.index);
4772
- x = x.substr(m.index + m[0].length);
4773
- let singleQuoteString = m[1];
4774
- if (singleQuoteString !== void 0) {
4775
- replacement = normalizeStringLiteral(singleQuoteString);
4776
- } else {
4777
- replacement = m[2];
4778
- }
4779
- }
4780
- s += before.replace(/\(/g, "[").replace(/\)/g, "]").replace("True", "true").replace("False", "false").replace(/,\s*([\}\]])/g, "$1");
4781
- s += replacement;
4782
- }
4783
- return s;
4784
- }
4785
- function pythonLiteralParse(x) {
4786
- return JSON.parse(pythonLiteralToJSON(x));
4787
- }
4788
4674
  function expectArray(x, length2) {
4789
4675
  if (!Array.isArray(x)) {
4790
4676
  throw new Error(`Expected array, but received: ${_JSON$stringify(x)}.`);
@@ -4856,29 +4742,6 @@ function verifyOptionalString(obj) {
4856
4742
  }
4857
4743
  return verifyString(obj);
4858
4744
  }
4859
- function verifyOptionalInt(obj) {
4860
- if (obj === void 0) {
4861
- return void 0;
4862
- }
4863
- return verifyInt(obj);
4864
- }
4865
- function verifyOptionalBoolean(obj) {
4866
- if (obj === void 0) {
4867
- return void 0;
4868
- }
4869
- if (typeof obj === "boolean") {
4870
- return obj;
4871
- } else if (obj === "true") {
4872
- return true;
4873
- } else if (obj === "false") {
4874
- return false;
4875
- } else {
4876
- throw new Error(`Expected string or boolean but received: ${_JSON$stringify(obj)}`);
4877
- }
4878
- }
4879
- function valueOr(value, defaultValue) {
4880
- return value === void 0 ? defaultValue : value;
4881
- }
4882
4745
  function verifyObjectProperty(obj, propertyName, validator) {
4883
4746
  let value = Object.prototype.hasOwnProperty.call(obj, propertyName) ? obj[propertyName] : void 0;
4884
4747
  try {
@@ -4948,12 +4811,6 @@ function verifyEnumString(obj, enumType) {
4948
4811
  function verify3dVec(obj) {
4949
4812
  return parseFixedLengthArray(create$3(), obj, verifyFiniteFloat);
4950
4813
  }
4951
- function verify3dScale(obj) {
4952
- return parseFixedLengthArray(create$3(), obj, verifyFinitePositiveFloat);
4953
- }
4954
- function verify3dDimensions(obj) {
4955
- return parseFixedLengthArray(create$3(), obj, verifyPositiveInt);
4956
- }
4957
4814
  function verifyStringArray(a) {
4958
4815
  if (!Array.isArray(a)) {
4959
4816
  throw new Error(`Expected array, received: ${_JSON$stringify(a)}.`);
@@ -4988,52 +4845,6 @@ function emptyToUndefined(x) {
4988
4845
  }
4989
4846
  return void 0;
4990
4847
  }
4991
- const json = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4992
- __proto__: null,
4993
- emptyToUndefined,
4994
- expectArray,
4995
- jsonToUrlSafe,
4996
- normalizeStringLiteral,
4997
- parseArray,
4998
- parseFiniteVec,
4999
- parseFixedLengthArray,
5000
- parseIntVec,
5001
- parseQueryStringParameters,
5002
- parseXYZ,
5003
- pythonLiteralParse,
5004
- pythonLiteralToJSON,
5005
- stableStringify,
5006
- unparseQueryStringParameters,
5007
- urlSafeParse,
5008
- urlSafeStringify,
5009
- urlSafeStringifyString,
5010
- urlSafeToJSON,
5011
- valueOr,
5012
- verify3dDimensions,
5013
- verify3dScale,
5014
- verify3dVec,
5015
- verifyBoolean,
5016
- verifyEnumString,
5017
- verifyFiniteFloat,
5018
- verifyFiniteNonNegativeFloat,
5019
- verifyFinitePositiveFloat,
5020
- verifyFloat,
5021
- verifyFloat01,
5022
- verifyInt,
5023
- verifyIntegerArray,
5024
- verifyMapKey,
5025
- verifyNonnegativeInt,
5026
- verifyObject,
5027
- verifyObjectAsMap,
5028
- verifyObjectProperty,
5029
- verifyOptionalBoolean,
5030
- verifyOptionalInt,
5031
- verifyOptionalObjectProperty,
5032
- verifyOptionalString,
5033
- verifyPositiveInt,
5034
- verifyString,
5035
- verifyStringArray
5036
- }, Symbol.toStringTag, { value: "Module" }));
5037
4848
  /**
5038
4849
  * @license
5039
4850
  * Copyright 2021 Google Inc.
@@ -5425,10 +5236,6 @@ class Uint64 {
5425
5236
  }
5426
5237
  Uint64.ZERO = new Uint64(0, 0);
5427
5238
  Uint64.ONE = new Uint64(1, 0);
5428
- const uint64 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5429
- __proto__: null,
5430
- Uint64
5431
- }, Symbol.toStringTag, { value: "Module" }));
5432
5239
  const defaultDataTypeRange = {
5433
5240
  [DataType.UINT8]: [0, 255],
5434
5241
  [DataType.INT8]: [-128, 127],
@@ -7073,20 +6880,20 @@ function coordinateSpaceToJson(coordinateSpace) {
7073
6880
  const rank = coordinateSpace.rank;
7074
6881
  if (rank === 0) return void 0;
7075
6882
  const names = coordinateSpace.names, units = coordinateSpace.units, scales = coordinateSpace.scales, coordinateArrays = coordinateSpace.coordinateArrays;
7076
- const json2 = {};
6883
+ const json = {};
7077
6884
  for (let i = 0; i < rank; ++i) {
7078
6885
  const name2 = names[i];
7079
6886
  const coordinateArray = coordinateArrays[i];
7080
6887
  if (coordinateArray === null || coordinateArray === void 0 ? void 0 : coordinateArray.explicit) {
7081
- json2[name2] = {
6888
+ json[name2] = {
7082
6889
  coordinates: _Array$from(coordinateArray.coordinates),
7083
6890
  labels: coordinateArray.labels
7084
6891
  };
7085
6892
  } else {
7086
- json2[name2] = [scales[i], units[i]];
6893
+ json[name2] = [scales[i], units[i]];
7087
6894
  }
7088
6895
  }
7089
- return json2;
6896
+ return json;
7090
6897
  }
7091
6898
  class TrackableCoordinateSpace extends WatchableValue {
7092
6899
  constructor() {
@@ -11500,7 +11307,7 @@ function shaderCodeWithLineDirective(code, sourceStringNumber = 1, line = 0) {
11500
11307
  * See the License for the specific language governing permissions and
11501
11308
  * limitations under the License.
11502
11309
  */
11503
- class Buffer {
11310
+ class Buffer2 {
11504
11311
  constructor(gl, bufferType = WebGL2RenderingContext.ARRAY_BUFFER) {
11505
11312
  this.gl = gl;
11506
11313
  this.bufferType = bufferType;
@@ -11531,14 +11338,14 @@ class Buffer {
11531
11338
  this.gl = void 0;
11532
11339
  }
11533
11340
  static fromData(gl, data, bufferType, usage) {
11534
- let buffer = new Buffer(gl, bufferType);
11341
+ let buffer = new Buffer2(gl, bufferType);
11535
11342
  buffer.setData(data, usage);
11536
11343
  return buffer;
11537
11344
  }
11538
11345
  }
11539
11346
  function getMemoizedBuffer(gl, bufferType, getter, ...args) {
11540
11347
  return gl.memoize.get(stableStringify({ id: "getMemoizedBuffer", getter: getObjectId(getter), args }), () => {
11541
- const result = new RefCountedValue(Buffer.fromData(gl, getter(...args), bufferType, WebGL2RenderingContext.STATIC_DRAW));
11348
+ const result = new RefCountedValue(Buffer2.fromData(gl, getter(...args), bufferType, WebGL2RenderingContext.STATIC_DRAW));
11542
11349
  result.registerDisposer(result.value);
11543
11350
  return result;
11544
11351
  });
@@ -14643,8 +14450,8 @@ if (ng_discardValue) {
14643
14450
  gl.uniform1ui(shader.uniform("uPickID"), context.basePickId);
14644
14451
  }
14645
14452
  if (renderContext.emitColor) {
14646
- const color2 = annotationLayer.state.displayState.color.value;
14647
- gl.uniform3f(shader.uniform("uColor"), color2[0], color2[1], color2[2]);
14453
+ const color = annotationLayer.state.displayState.color.value;
14454
+ gl.uniform3f(shader.uniform("uColor"), color[0], color[1], color[2]);
14648
14455
  gl.uniform1ui(shader.uniform("uSelectedIndex"), context.selectedIndex);
14649
14456
  }
14650
14457
  const binder = shader.vertexShaderInputBinders["properties"];
@@ -17155,12 +16962,12 @@ function requireThrottle() {
17155
16962
  }
17156
16963
  var throttleExports = requireThrottle();
17157
16964
  const throttle = /* @__PURE__ */ getDefaultExportFromCjs(throttleExports);
17158
- function parseDataSubsourceSpecificationFromJson(json2) {
17159
- if (typeof json2 === "boolean") {
17160
- return { enabled: json2 };
16965
+ function parseDataSubsourceSpecificationFromJson(json) {
16966
+ if (typeof json === "boolean") {
16967
+ return { enabled: json };
17161
16968
  }
17162
- verifyObject(json2);
17163
- return { enabled: verifyOptionalObjectProperty(json2, "enabled", verifyBoolean) };
16969
+ verifyObject(json);
16970
+ return { enabled: verifyOptionalObjectProperty(json, "enabled", verifyBoolean) };
17164
16971
  }
17165
16972
  function layerDataSourceSpecificationFromJson(obj, legacyTransform = void 0) {
17166
16973
  if (typeof obj === "string") {
@@ -17986,19 +17793,19 @@ class Position extends RefCounted {
17986
17793
  };
17987
17794
  }
17988
17795
  }
17989
- function restoreLinkedFromJson(link, value, json2) {
17990
- if (json2 === void 0 || _Object$keys(json2).length === 0) {
17796
+ function restoreLinkedFromJson(link, value, json) {
17797
+ if (json === void 0 || _Object$keys(json).length === 0) {
17991
17798
  link.value = NavigationLinkType.LINKED;
17992
17799
  return;
17993
17800
  }
17994
- verifyObject(json2);
17801
+ verifyObject(json);
17995
17802
  link.value = NavigationLinkType.UNLINKED;
17996
- verifyObjectProperty(json2, "value", (x) => {
17803
+ verifyObjectProperty(json, "value", (x) => {
17997
17804
  if (x !== void 0) {
17998
17805
  value.restoreState(x);
17999
17806
  }
18000
17807
  });
18001
- verifyObjectProperty(json2, "link", (x) => link.restoreState(x));
17808
+ verifyObjectProperty(json, "link", (x) => link.restoreState(x));
18002
17809
  }
18003
17810
  class LinkedBase {
18004
17811
  constructor(peer, link = new TrackableNavigationLink()) {
@@ -18183,7 +17990,7 @@ class TrackableRelativeDisplayScales extends RefCounted {
18183
17990
  this.changed.dispatch();
18184
17991
  }
18185
17992
  toJSON() {
18186
- const json2 = {};
17993
+ const json = {};
18187
17994
  let nonEmpty = false;
18188
17995
  const value = this.value;
18189
17996
  const factors = value.factors;
@@ -18192,19 +17999,19 @@ class TrackableRelativeDisplayScales extends RefCounted {
18192
17999
  for (let i = 0; i < rank; ++i) {
18193
18000
  const factor = factors[i];
18194
18001
  if (factor === 1) continue;
18195
- json2[names[i]] = factor;
18002
+ json[names[i]] = factor;
18196
18003
  nonEmpty = true;
18197
18004
  }
18198
- if (nonEmpty) return json2;
18005
+ if (nonEmpty) return json;
18199
18006
  return void 0;
18200
18007
  }
18201
- restoreState(json2) {
18008
+ restoreState(json) {
18202
18009
  const coordinateSpace = this.coordinateSpace.value;
18203
18010
  const names = coordinateSpace.names, rank = coordinateSpace.rank;
18204
18011
  const factors = new Float64Array(rank);
18205
18012
  factors.fill(-1);
18206
- if (json2 !== void 0) {
18207
- const obj = verifyObject(json2);
18013
+ if (json !== void 0) {
18014
+ const obj = verifyObject(json);
18208
18015
  for (let i = 0; i < rank; ++i) {
18209
18016
  factors[i] = verifyObjectProperty(obj, names[i], (x) => x === void 0 ? 1 : verifyFinitePositiveFloat(x));
18210
18017
  }
@@ -20276,8 +20083,8 @@ vec3 ${this.prefix}(uint64_t x) {
20276
20083
  }
20277
20084
  }
20278
20085
  let tempColor$1 = new Float32Array(3);
20279
- function getCssColor(color2) {
20280
- return `rgb(${color2[0] * 100}%,${color2[1] * 100}%,${color2[2] * 100}%)`;
20086
+ function getCssColor(color) {
20087
+ return `rgb(${color[0] * 100}%,${color[1] * 100}%,${color[2] * 100}%)`;
20281
20088
  }
20282
20089
  class SegmentColorHash {
20283
20090
  constructor(hashSeed = getRandomUint32()) {
@@ -22369,21 +22176,21 @@ class SegmentWidgetFactory {
22369
22176
  const unmappedIdIndex = template.unmappedIdIndex;
22370
22177
  if (unmappedIdIndex !== -1) {
22371
22178
  let unmappedIdString;
22372
- let color2;
22179
+ let color;
22373
22180
  if (displayState.baseSegmentColoring.value && (unmappedIdString = container.dataset.unmappedId) !== void 0) {
22374
22181
  const unmappedId = tempStatedColor;
22375
22182
  unmappedId.parseString(unmappedIdString);
22376
- color2 = getBaseObjectColor(this.displayState, unmappedId);
22183
+ color = getBaseObjectColor(this.displayState, unmappedId);
22377
22184
  } else {
22378
- color2 = kOneVec;
22185
+ color = kOneVec;
22379
22186
  }
22380
- setSegmentIdElementStyle(idContainer.children[unmappedIdIndex], color2);
22187
+ setSegmentIdElementStyle(idContainer.children[unmappedIdIndex], color);
22381
22188
  }
22382
22189
  }
22383
22190
  }
22384
- function setSegmentIdElementStyle(element, color2) {
22385
- element.style.backgroundColor = getCssColor(color2);
22386
- element.style.color = useWhiteBackground(color2) ? "white" : "black";
22191
+ function setSegmentIdElementStyle(element, color) {
22192
+ element.style.backgroundColor = getCssColor(color);
22193
+ element.style.color = useWhiteBackground(color) ? "white" : "black";
22387
22194
  }
22388
22195
  class SegmentWidgetWithExtraColumnsFactory extends SegmentWidgetFactory {
22389
22196
  constructor(displayState, parentElement, includeProperty) {
@@ -22507,33 +22314,33 @@ function registerRedrawWhenSegmentationDisplayState3DChanged(displayState, rende
22507
22314
  }
22508
22315
  const tempColor = create$2();
22509
22316
  const tempStatedColor = new Uint64();
22510
- function getBaseObjectColor(displayState, objectId, color2 = tempColor) {
22317
+ function getBaseObjectColor(displayState, objectId, color = tempColor) {
22511
22318
  if (displayState == null) {
22512
- color2.fill(1);
22513
- return color2;
22319
+ color.fill(1);
22320
+ return color;
22514
22321
  }
22515
22322
  const colorGroupState = displayState.segmentationColorGroupState.value;
22516
22323
  const segmentStatedColors = colorGroupState.segmentStatedColors;
22517
22324
  if (segmentStatedColors.size !== 0 && colorGroupState.segmentStatedColors.get(objectId, tempStatedColor)) {
22518
- color2[0] = (tempStatedColor.low & 255) / 255;
22519
- color2[1] = ((tempStatedColor.low & 65280) >>> 8) / 255;
22520
- color2[2] = ((tempStatedColor.low & 16711680) >>> 16) / 255;
22521
- return color2;
22325
+ color[0] = (tempStatedColor.low & 255) / 255;
22326
+ color[1] = ((tempStatedColor.low & 65280) >>> 8) / 255;
22327
+ color[2] = ((tempStatedColor.low & 16711680) >>> 16) / 255;
22328
+ return color;
22522
22329
  }
22523
22330
  const segmentDefaultColor = colorGroupState.segmentDefaultColor.value;
22524
22331
  if (segmentDefaultColor !== void 0) {
22525
- color2[0] = segmentDefaultColor[0];
22526
- color2[1] = segmentDefaultColor[1];
22527
- color2[2] = segmentDefaultColor[2];
22528
- return color2;
22332
+ color[0] = segmentDefaultColor[0];
22333
+ color[1] = segmentDefaultColor[1];
22334
+ color[2] = segmentDefaultColor[2];
22335
+ return color;
22529
22336
  }
22530
- colorGroupState.segmentColorHash.compute(color2, objectId);
22531
- return color2;
22337
+ colorGroupState.segmentColorHash.compute(color, objectId);
22338
+ return color;
22532
22339
  }
22533
22340
  function getObjectColor(displayState, objectId, alpha = 1) {
22534
- const color2 = tempColor;
22535
- color2[3] = alpha;
22536
- getBaseObjectColor(displayState, objectId, color2);
22341
+ const color = tempColor;
22342
+ color[3] = alpha;
22343
+ getBaseObjectColor(displayState, objectId, color);
22537
22344
  let saturation = displayState.saturation.value;
22538
22345
  if (displayState.segmentSelectionState.isSelected(objectId)) {
22539
22346
  if (saturation > 0.5) {
@@ -22543,12 +22350,12 @@ function getObjectColor(displayState, objectId, alpha = 1) {
22543
22350
  }
22544
22351
  }
22545
22352
  for (let i = 0; i < 3; ++i) {
22546
- color2[i] = color2[i] * saturation + (1 - saturation);
22353
+ color[i] = color[i] * saturation + (1 - saturation);
22547
22354
  }
22548
- color2[0] *= alpha;
22549
- color2[1] *= alpha;
22550
- color2[2] *= alpha;
22551
- return color2;
22355
+ color[0] *= alpha;
22356
+ color[1] *= alpha;
22357
+ color[2] *= alpha;
22358
+ return color;
22552
22359
  }
22553
22360
  function sendVisibleSegmentsState(state, options = {}) {
22554
22361
  for (const property of VISIBLE_SEGMENTS_STATE_PROPERTIES) {
@@ -22577,33 +22384,10 @@ function forEachVisibleSegmentToDraw(displayState, renderLayer, emitColor, pickI
22577
22384
  const baseSegmentColoring = displayState.baseSegmentColoring.value;
22578
22385
  forEachVisibleSegment(displayState.segmentationGroupState.value, (objectId, rootObjectId) => {
22579
22386
  let pickIndex = pickIDs === null || pickIDs === void 0 ? void 0 : pickIDs.registerUint64(renderLayer, objectId);
22580
- let color2 = emitColor ? getObjectColor(displayState, baseSegmentColoring ? objectId : rootObjectId, alpha) : void 0;
22581
- callback(objectId, color2, pickIndex, rootObjectId);
22387
+ let color = emitColor ? getObjectColor(displayState, baseSegmentColoring ? objectId : rootObjectId, alpha) : void 0;
22388
+ callback(objectId, color, pickIndex, rootObjectId);
22582
22389
  });
22583
22390
  }
22584
- const frontend = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22585
- __proto__: null,
22586
- SegmentSelectionState,
22587
- SegmentWidgetFactory,
22588
- SegmentWidgetWithExtraColumnsFactory,
22589
- SegmentationLayerSharedObject,
22590
- Uint64MapEntry,
22591
- augmentSegmentId,
22592
- bindSegmentListWidth,
22593
- forEachVisibleSegmentToDraw,
22594
- getBaseObjectColor,
22595
- getObjectColor,
22596
- makeSegmentWidget,
22597
- maybeAugmentSegmentId,
22598
- registerCallbackWhenSegmentationDisplayStateChanged,
22599
- registerRedrawWhenSegmentationDisplayState3DChanged,
22600
- registerRedrawWhenSegmentationDisplayStateChanged,
22601
- registerRedrawWhenSegmentationDisplayStateWithAlphaChanged,
22602
- resetTemporaryVisibleSegmentsState,
22603
- segmentWidgetTemplateWithExtraColumns,
22604
- sendVisibleSegmentsState,
22605
- updateIdStringWidth
22606
- }, Symbol.toStringTag, { value: "Module" }));
22607
22391
  /**
22608
22392
  * @license
22609
22393
  * Copyright 2016 Google Inc.
@@ -22628,9 +22412,9 @@ var __decorate$5 = function(decorators, target, key, desc) {
22628
22412
  const tempMat4$5 = create$4();
22629
22413
  const tempMat3$1 = create$5();
22630
22414
  function copyMeshDataToGpu(gl, chunk) {
22631
- chunk.vertexBuffer = Buffer.fromData(gl, chunk.meshData.vertexPositions, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
22632
- chunk.indexBuffer = Buffer.fromData(gl, chunk.meshData.indices, gl.ELEMENT_ARRAY_BUFFER, gl.STATIC_DRAW);
22633
- chunk.normalBuffer = Buffer.fromData(gl, chunk.meshData.vertexNormals, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
22415
+ chunk.vertexBuffer = Buffer2.fromData(gl, chunk.meshData.vertexPositions, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
22416
+ chunk.indexBuffer = Buffer2.fromData(gl, chunk.meshData.indices, gl.ELEMENT_ARRAY_BUFFER, gl.STATIC_DRAW);
22417
+ chunk.normalBuffer = Buffer2.fromData(gl, chunk.meshData.vertexNormals, gl.ARRAY_BUFFER, gl.STATIC_DRAW);
22634
22418
  }
22635
22419
  function freeGpuMeshData(chunk) {
22636
22420
  chunk.vertexBuffer.dispose();
@@ -22710,8 +22494,8 @@ class MeshShaderManager {
22710
22494
  gl.uniform1f(shader.uniform("uSilhouettePower"), silhouetteRendering);
22711
22495
  }
22712
22496
  }
22713
- setColor(gl, shader, color2) {
22714
- gl.uniform4fv(shader.uniform("uColor"), color2);
22497
+ setColor(gl, shader, color) {
22498
+ gl.uniform4fv(shader.uniform("uColor"), color);
22715
22499
  }
22716
22500
  setPickID(gl, shader, pickID) {
22717
22501
  gl.uniform1ui(shader.uniform("uPickID"), pickID);
@@ -22861,14 +22645,14 @@ class MeshLayer extends PerspectiveViewRenderLayer {
22861
22645
  let totalChunks = 0, presentChunks = 0;
22862
22646
  const renderScaleHistogram = this.displayState.renderScaleHistogram;
22863
22647
  const fragmentChunks = this.source.fragmentSource.chunks;
22864
- forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color2, pickIndex) => {
22648
+ forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color, pickIndex) => {
22865
22649
  const key = getObjectKey(objectId);
22866
22650
  const manifestChunk = manifestChunks.get(key);
22867
22651
  ++totalChunks;
22868
22652
  if (manifestChunk === void 0) return;
22869
22653
  ++presentChunks;
22870
22654
  if (renderContext.emitColor) {
22871
- meshShaderManager.setColor(gl, shader, color2);
22655
+ meshShaderManager.setColor(gl, shader, color);
22872
22656
  }
22873
22657
  if (renderContext.emitPickID) {
22874
22658
  meshShaderManager.setPickID(gl, shader, pickIndex);
@@ -23032,7 +22816,7 @@ class MultiscaleMeshLayer extends PerspectiveViewRenderLayer {
23032
22816
  meshShaderManager.beginModel(gl, shader, renderContext, modelMatrix);
23033
22817
  let totalManifestChunks = 0;
23034
22818
  let presentManifestChunks = 0;
23035
- forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color2, pickIndex) => {
22819
+ forEachVisibleSegmentToDraw(displayState, this, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color, pickIndex) => {
23036
22820
  const key = getObjectKey(objectId);
23037
22821
  const manifestChunk = chunks.get(key);
23038
22822
  ++totalManifestChunks;
@@ -23041,7 +22825,7 @@ class MultiscaleMeshLayer extends PerspectiveViewRenderLayer {
23041
22825
  const manifest = manifestChunk.manifest;
23042
22826
  const octree = manifest.octree, chunkShape = manifest.chunkShape, chunkGridSpatialOrigin = manifest.chunkGridSpatialOrigin, vertexOffsets = manifest.vertexOffsets;
23043
22827
  if (renderContext.emitColor) {
23044
- meshShaderManager.setColor(gl, shader, color2);
22828
+ meshShaderManager.setColor(gl, shader, color);
23045
22829
  }
23046
22830
  if (renderContext.emitPickID) {
23047
22831
  meshShaderManager.setPickID(gl, shader, pickIndex);
@@ -23580,7 +23364,7 @@ int getVertexId () {
23580
23364
  class VertexIdHelper extends RefCounted {
23581
23365
  constructor(gl) {
23582
23366
  super();
23583
- this.buffer = new Buffer(gl);
23367
+ this.buffer = new Buffer2(gl);
23584
23368
  this.size = 0;
23585
23369
  }
23586
23370
  disposed() {
@@ -23759,8 +23543,8 @@ void emitDefault() {
23759
23543
  gl.uniformMatrix4fv(shader.uniform("uProjection"), false, mat);
23760
23544
  this.vertexIdHelper.enable();
23761
23545
  }
23762
- setColor(gl, shader, color2) {
23763
- gl.uniform4fv(shader.uniform("uColor"), color2);
23546
+ setColor(gl, shader, color) {
23547
+ gl.uniform4fv(shader.uniform("uColor"), color);
23764
23548
  }
23765
23549
  setPickID(gl, shader, pickID) {
23766
23550
  gl.uniform1ui(shader.uniform("uPickID"), pickID);
@@ -23927,17 +23711,17 @@ class SkeletonLayer extends RefCounted {
23927
23711
  gl.uniform1f(nodeShader.uniform("uNodeDiameter"), pointDiameter);
23928
23712
  setControlsInShader(gl, nodeShader, shaderControlState, nodeShaderParameters.parseResult.controls);
23929
23713
  const skeletons = source.chunks;
23930
- forEachVisibleSegmentToDraw(displayState, layer, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color2, pickIndex) => {
23714
+ forEachVisibleSegmentToDraw(displayState, layer, renderContext.emitColor, renderContext.emitPickID ? renderContext.pickIDs : void 0, (objectId, color, pickIndex) => {
23931
23715
  const key = getObjectKey(objectId);
23932
23716
  const skeleton = skeletons.get(key);
23933
23717
  if (skeleton === void 0 || skeleton.state !== ChunkState.GPU_MEMORY) {
23934
23718
  return;
23935
23719
  }
23936
- if (color2 !== void 0) {
23720
+ if (color !== void 0) {
23937
23721
  edgeShader.bind();
23938
- renderHelper.setColor(gl, edgeShader, color2);
23722
+ renderHelper.setColor(gl, edgeShader, color);
23939
23723
  nodeShader.bind();
23940
- renderHelper.setColor(gl, nodeShader, color2);
23724
+ renderHelper.setColor(gl, nodeShader, color);
23941
23725
  }
23942
23726
  if (pickIndex !== void 0) {
23943
23727
  edgeShader.bind();
@@ -24057,7 +23841,7 @@ class SkeletonChunk extends Chunk {
24057
23841
  vertexAttributeTextures[i] = texture;
24058
23842
  }
24059
23843
  gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);
24060
- this.indexBuffer = Buffer.fromData(gl, this.indices, WebGL2RenderingContext.ARRAY_BUFFER, WebGL2RenderingContext.STATIC_DRAW);
23844
+ this.indexBuffer = Buffer2.fromData(gl, this.indices, WebGL2RenderingContext.ARRAY_BUFFER, WebGL2RenderingContext.STATIC_DRAW);
24061
23845
  }
24062
23846
  freeGPUMemory(gl) {
24063
23847
  super.freeGPUMemory(gl);
@@ -27302,19 +27086,19 @@ class ToolBinder extends RefCounted {
27302
27086
  }
27303
27087
  if (tool !== void 0) {
27304
27088
  const layerToolBinder = tool.layer.toolBinder;
27305
- const json2 = _JSON$stringify(tool.toJSON());
27306
- const existingKey = layerToolBinder.jsonToKey.get(json2);
27089
+ const json = _JSON$stringify(tool.toJSON());
27090
+ const existingKey = layerToolBinder.jsonToKey.get(json);
27307
27091
  if (existingKey !== void 0) {
27308
27092
  const existingTool2 = layerToolBinder.bindings.get(existingKey);
27309
27093
  existingTool2.keyBinding = void 0;
27310
27094
  bindings.delete(existingKey);
27311
27095
  layerToolBinder.bindings.delete(existingKey);
27312
- layerToolBinder.jsonToKey.delete(json2);
27096
+ layerToolBinder.jsonToKey.delete(json);
27313
27097
  this.destroyTool(existingTool2);
27314
27098
  }
27315
27099
  layerToolBinder.bindings.set(key, tool);
27316
27100
  tool.keyBinding = key;
27317
- layerToolBinder.jsonToKey.set(json2, key);
27101
+ layerToolBinder.jsonToKey.set(json, key);
27318
27102
  bindings.set(key, tool);
27319
27103
  layerToolBinder.changed.dispatch();
27320
27104
  }
@@ -27751,9 +27535,9 @@ class AxesLineHelper extends RefCounted {
27751
27535
  constructor(gl) {
27752
27536
  super();
27753
27537
  this.gl = gl;
27754
- this.vertexBuffer = this.registerDisposer(Buffer.fromData(gl, new Float32Array([0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1]), gl.ARRAY_BUFFER, gl.STATIC_DRAW));
27538
+ this.vertexBuffer = this.registerDisposer(Buffer2.fromData(gl, new Float32Array([0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1]), gl.ARRAY_BUFFER, gl.STATIC_DRAW));
27755
27539
  let alpha = 0.5;
27756
- this.colorBuffer = this.registerDisposer(Buffer.fromData(gl, new Float32Array([1, 0, 0, alpha, 1, 0, 0, alpha, 0, 1, 0, alpha, 0, 1, 0, alpha, 0, 0, 1, alpha, 0, 0, 1, alpha]), gl.ARRAY_BUFFER, gl.STATIC_DRAW));
27540
+ this.colorBuffer = this.registerDisposer(Buffer2.fromData(gl, new Float32Array([1, 0, 0, alpha, 1, 0, 0, alpha, 0, 1, 0, alpha, 0, 1, 0, alpha, 0, 0, 1, alpha, 0, 0, 1, alpha]), gl.ARRAY_BUFFER, gl.STATIC_DRAW));
27757
27541
  this.trivialColorShader = this.registerDisposer(trivialColorShader(gl));
27758
27542
  }
27759
27543
  static get(gl) {
@@ -46702,8 +46486,8 @@ class StateEditorDialog extends Overlay {
46702
46486
  this.debouncedValueUpdater = debounce(() => {
46703
46487
  const value = this.textEditor.getValue();
46704
46488
  try {
46705
- const json2 = JSON.parse(value);
46706
- this.parsedValue = json2;
46489
+ const json = JSON.parse(value);
46490
+ this.parsedValue = json;
46707
46491
  this.applyButton.disabled = false;
46708
46492
  this.textEditor.setOption("lint", void 0);
46709
46493
  } catch (parseError) {
@@ -47397,92 +47181,6 @@ function encodeFragment(fragment) {
47397
47181
  return "%" + c.charCodeAt(0).toString(16).toUpperCase();
47398
47182
  });
47399
47183
  }
47400
- class UrlHashBinding extends RefCounted {
47401
- constructor(root, credentialsManager, options = {}) {
47402
- super();
47403
- this.root = root;
47404
- this.credentialsManager = credentialsManager;
47405
- this.parseError = new WatchableValue(void 0);
47406
- var _options$updateDelayM = options.updateDelayMilliseconds;
47407
- const updateDelayMilliseconds = _options$updateDelayM === void 0 ? 200 : _options$updateDelayM;
47408
- var _options$defaultFragm = options.defaultFragment;
47409
- const defaultFragment = _options$defaultFragm === void 0 ? "{}" : _options$defaultFragm;
47410
- this.registerEventListener(window, "hashchange", () => this.updateFromUrlHash());
47411
- const throttledSetUrlHash = debounce(() => this.setUrlHash(), updateDelayMilliseconds);
47412
- this.registerDisposer(root.changed.add(throttledSetUrlHash));
47413
- this.registerDisposer(() => throttledSetUrlHash.cancel());
47414
- this.defaultFragment = defaultFragment;
47415
- }
47416
- /**
47417
- * Sets the URL hash to match the current state.
47418
- */
47419
- setUrlHash() {
47420
- const cacheState = getCachedJson(this.root);
47421
- const generation = cacheState.generation;
47422
- if (generation !== this.prevStateGeneration) {
47423
- this.prevStateGeneration = cacheState.generation;
47424
- let stateString = encodeFragment(_JSON$stringify(cacheState.value));
47425
- if (stateString !== this.prevStateString) {
47426
- this.prevStateString = stateString;
47427
- if (decodeURIComponent(stateString) === "{}") {
47428
- history.replaceState(null, "", "#");
47429
- } else {
47430
- history.replaceState(null, "", "#!" + stateString);
47431
- }
47432
- }
47433
- }
47434
- }
47435
- /**
47436
- * Sets the current state to match the URL hash. If it is desired to initialize the state based
47437
- * on the URL hash, then this should be called immediately after construction.
47438
- */
47439
- updateFromUrlHash() {
47440
- try {
47441
- let s = location.href.replace(/^[^#]+/, "");
47442
- if (s === "" || s === "#" || s === "#!") {
47443
- s = "#!" + this.defaultFragment;
47444
- }
47445
- if (s.match(/^#!([a-z][a-z\d+-.]*):\/\//)) {
47446
- const url = s.substring(2);
47447
- var _parseSpecialUrl = parseSpecialUrl(url, this.credentialsManager);
47448
- const parsedUrl = _parseSpecialUrl.url, credentialsProvider = _parseSpecialUrl.credentialsProvider;
47449
- StatusMessage.forPromise(cancellableFetchSpecialOk(credentialsProvider, parsedUrl, {}, responseJson).then((json2) => {
47450
- verifyObject(json2);
47451
- this.root.reset();
47452
- this.root.restoreState(json2);
47453
- }), { initialMessage: `Loading state from ${url}`, errorPrefix: `Error loading state:` });
47454
- } else if (s.startsWith("#!+")) {
47455
- s = s.slice(3);
47456
- s = decodeURIComponent(s);
47457
- let state = urlSafeParse(s);
47458
- verifyObject(state);
47459
- this.root.restoreState(state);
47460
- this.prevStateString = void 0;
47461
- } else if (s.startsWith("#!")) {
47462
- s = s.slice(2);
47463
- s = decodeURIComponent(s);
47464
- if (s === this.prevStateString) {
47465
- return;
47466
- }
47467
- this.prevStateString = s;
47468
- this.root.reset();
47469
- let state = urlSafeParse(s);
47470
- verifyObject(state);
47471
- this.root.restoreState(state);
47472
- } else {
47473
- throw new Error(`URL hash is expected to be of the form "#!{...}" or "#!+{...}".`);
47474
- }
47475
- this.parseError.value = void 0;
47476
- } catch (parseError) {
47477
- this.parseError.value = parseError;
47478
- }
47479
- }
47480
- }
47481
- const url_hash_binding = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47482
- __proto__: null,
47483
- UrlHashBinding,
47484
- encodeFragment
47485
- }, Symbol.toStringTag, { value: "Module" }));
47486
47184
  class DataManagementContext extends RefCounted {
47487
47185
  constructor(gl, frameNumberCounter, bundleRoot = "") {
47488
47186
  super();
@@ -48127,11 +47825,11 @@ class UserLayer extends RefCounted {
48127
47825
  state.annotationId = void 0;
48128
47826
  state.value = void 0;
48129
47827
  }
48130
- selectionStateFromJson(state, json2) {
47828
+ selectionStateFromJson(state, json) {
48131
47829
  const localCoordinateSpace = state.localCoordinateSpace = this.localCoordinateSpace.value;
48132
47830
  const rank = localCoordinateSpace.rank;
48133
47831
  if (rank !== 0) {
48134
- const localPosition = verifyOptionalObjectProperty(json2, LOCAL_POSITION_JSON_KEY, (positionObj) => parseFixedLengthArray(new Float32Array(rank), positionObj, verifyFiniteFloat));
47832
+ const localPosition = verifyOptionalObjectProperty(json, LOCAL_POSITION_JSON_KEY, (positionObj) => parseFixedLengthArray(new Float32Array(rank), positionObj, verifyFiniteFloat));
48135
47833
  if (localPosition === void 0) {
48136
47834
  state.localPositionValid = false;
48137
47835
  } else {
@@ -48139,36 +47837,36 @@ class UserLayer extends RefCounted {
48139
47837
  state.localPosition = localPosition;
48140
47838
  }
48141
47839
  }
48142
- const annotationId = state.annotationId = verifyOptionalObjectProperty(json2, "annotationId", verifyString);
47840
+ const annotationId = state.annotationId = verifyOptionalObjectProperty(json, "annotationId", verifyString);
48143
47841
  if (annotationId !== void 0) {
48144
- state.annotationSourceIndex = verifyOptionalObjectProperty(json2, "annotationSource", verifyInt, 0);
48145
- state.annotationPartIndex = verifyOptionalObjectProperty(json2, "annotationPart", verifyInt);
48146
- state.annotationSubsource = verifyOptionalObjectProperty(json2, "annotationSubsource", verifyString);
47842
+ state.annotationSourceIndex = verifyOptionalObjectProperty(json, "annotationSource", verifyInt, 0);
47843
+ state.annotationPartIndex = verifyOptionalObjectProperty(json, "annotationPart", verifyInt);
47844
+ state.annotationSubsource = verifyOptionalObjectProperty(json, "annotationSubsource", verifyString);
48147
47845
  }
48148
- state.value = json2.value;
47846
+ state.value = json.value;
48149
47847
  }
48150
47848
  // Derived classes should override.
48151
47849
  displaySelectionState(state, parent, context) {
48152
47850
  return false;
48153
47851
  }
48154
47852
  selectionStateToJson(state, forPython) {
48155
- const json2 = {};
47853
+ const json = {};
48156
47854
  if (state.localPositionValid) {
48157
47855
  const localPosition = state.localPosition;
48158
47856
  if (localPosition.length > 0) {
48159
- json2.localPosition = _Array$from(localPosition);
47857
+ json.localPosition = _Array$from(localPosition);
48160
47858
  }
48161
47859
  }
48162
47860
  if (state.annotationId !== void 0) {
48163
- json2.annotationId = state.annotationId;
48164
- json2.annotationPart = state.annotationPartIndex;
48165
- json2.annotationSource = state.annotationSourceIndex;
48166
- json2.annotationSubsource = state.annotationSubsource;
47861
+ json.annotationId = state.annotationId;
47862
+ json.annotationPart = state.annotationPartIndex;
47863
+ json.annotationSource = state.annotationSourceIndex;
47864
+ json.annotationSubsource = state.annotationSubsource;
48167
47865
  }
48168
47866
  if (state.value != null) {
48169
- json2.value = state.value;
47867
+ json.value = state.value;
48170
47868
  }
48171
- return json2;
47869
+ return json;
48172
47870
  }
48173
47871
  captureSelectionState(state, mouseState) {
48174
47872
  state.localCoordinateSpace = this.localCoordinateSpace.value;
@@ -48370,8 +48068,8 @@ class UserLayer extends RefCounted {
48370
48068
  selectedValueToJson(value) {
48371
48069
  return value;
48372
48070
  }
48373
- selectedValueFromJson(json2) {
48374
- return json2;
48071
+ selectedValueFromJson(json) {
48072
+ return json;
48375
48073
  }
48376
48074
  setLayerPosition(modelTransform, layerPosition) {
48377
48075
  const globalPosition = this.manager.root.globalPosition;
@@ -48908,13 +48606,13 @@ class TrackableDataSelectionState extends RefCounted {
48908
48606
  if (value !== this.value_) {
48909
48607
  this.value_ = value;
48910
48608
  if (value !== void 0 && this.pin.value) {
48911
- const history2 = this.history;
48912
- history2.length = Math.min(history2.length, this.historyIndex + 1);
48913
- history2.push(value);
48914
- if (history2.length > maxSelectionHistorySize) {
48915
- history2.splice(0, history2.length - maxSelectionHistorySize);
48609
+ const history = this.history;
48610
+ history.length = Math.min(history.length, this.historyIndex + 1);
48611
+ history.push(value);
48612
+ if (history.length > maxSelectionHistorySize) {
48613
+ history.splice(0, history.length - maxSelectionHistorySize);
48916
48614
  }
48917
- this.historyIndex = history2.length - 1;
48615
+ this.historyIndex = history.length - 1;
48918
48616
  }
48919
48617
  this.changed.dispatch();
48920
48618
  }
@@ -52223,7 +51921,7 @@ void setBoundingBoxFillColor(vec4 color) {
52223
51921
  class PerspectiveViewRenderHelper extends RenderHelper$4 {
52224
51922
  constructor() {
52225
51923
  super(...arguments);
52226
- this.edgeBoxCornerOffsetsBuffer = this.registerDisposer(Buffer.fromData(this.gl, tile2dArray(
51924
+ this.edgeBoxCornerOffsetsBuffer = this.registerDisposer(Buffer2.fromData(this.gl, tile2dArray(
52227
51925
  edgeBoxCornerOffsetData,
52228
51926
  /*majorDimension=*/
52229
51927
  7,
@@ -52263,7 +51961,7 @@ ${this.setPartIndex(builder, "uint(aBoxCornerOffset2.w)")};
52263
51961
  emitAnnotation(vec4(vColor.rgb, getLineAlpha() * vClipCoefficient));
52264
51962
  `);
52265
51963
  });
52266
- this.boxCornerOffsetsBuffer = this.registerDisposer(Buffer.fromData(this.gl, tile2dArray(
51964
+ this.boxCornerOffsetsBuffer = this.registerDisposer(Buffer2.fromData(this.gl, tile2dArray(
52267
51965
  vertexBasePositions,
52268
51966
  /*majorDimension=*/
52269
51967
  3,
@@ -53759,7 +53457,7 @@ class AnnotationLayer extends RefCounted {
53759
53457
  if (this.generation !== generation) {
53760
53458
  let buffer = this.buffer;
53761
53459
  if (buffer === void 0) {
53762
- buffer = this.buffer = this.registerDisposer(new Buffer(this.chunkManager.gl));
53460
+ buffer = this.buffer = this.registerDisposer(new Buffer2(this.chunkManager.gl));
53763
53461
  }
53764
53462
  this.generation = generation;
53765
53463
  const serializedAnnotations = this.serializedAnnotations = serializeAnnotationSet(source, segmentationFilter(this.segmentationStates.value));
@@ -53886,7 +53584,7 @@ function AnnotationRenderLayer(Base2, renderHelperType) {
53886
53584
  if (!chunk.bufferValid) {
53887
53585
  let buffer = chunk.buffer;
53888
53586
  if (buffer === void 0) {
53889
- buffer = chunk.buffer = new Buffer(this.gl);
53587
+ buffer = chunk.buffer = new Buffer2(this.gl);
53890
53588
  }
53891
53589
  const serializedAnnotations = chunk.serializedAnnotations;
53892
53590
  buffer.setData(serializedAnnotations.data);
@@ -59348,8 +59046,8 @@ class SegmentationUserLayerColorGroupState extends RefCounted {
59348
59046
  let idStr = _ref2[0];
59349
59047
  let colorVec = _ref2[1];
59350
59048
  const id = Uint64.parseString(String(idStr));
59351
- const color2 = new Uint64(packColor(colorVec));
59352
- this.segmentStatedColors.set(id, color2);
59049
+ const color = new Uint64(packColor(colorVec));
59050
+ this.segmentStatedColors.set(id, color);
59353
59051
  }
59354
59052
  });
59355
59053
  }
@@ -59741,8 +59439,8 @@ class SegmentationUserLayer extends Base$2 {
59741
59439
  }
59742
59440
  }
59743
59441
  }
59744
- selectionStateFromJson(state, json2) {
59745
- super.selectionStateFromJson(state, json2);
59442
+ selectionStateFromJson(state, json) {
59443
+ super.selectionStateFromJson(state, json);
59746
59444
  const v = new Uint64();
59747
59445
  let value = state.value;
59748
59446
  if (typeof value === "number") value = value.toString();
@@ -59753,22 +59451,22 @@ class SegmentationUserLayer extends Base$2 {
59753
59451
  }
59754
59452
  }
59755
59453
  selectionStateToJson(state, forPython) {
59756
- const json2 = super.selectionStateToJson(state, forPython);
59454
+ const json = super.selectionStateToJson(state, forPython);
59757
59455
  let value = state.value;
59758
59456
  if (value instanceof Uint64MapEntry) {
59759
59457
  if (forPython) {
59760
- json2.value = {
59458
+ json.value = {
59761
59459
  key: value.key.toString(),
59762
59460
  value: value.value ? value.value.toString() : void 0,
59763
59461
  label: value.label
59764
59462
  };
59765
59463
  } else {
59766
- json2.value = (value.value || value.key).toString();
59464
+ json.value = (value.value || value.key).toString();
59767
59465
  }
59768
59466
  } else if (value instanceof Uint64) {
59769
- json2.value = value.toString();
59467
+ json.value = value.toString();
59770
59468
  }
59771
- return json2;
59469
+ return json;
59772
59470
  }
59773
59471
  displaySegmentationSelection(state, parent, context) {
59774
59472
  const value = state.value;
@@ -59900,14 +59598,6 @@ registerLayerShaderControlsTool(SegmentationUserLayer, (layer) => ({
59900
59598
  }), SKELETON_RENDERING_SHADER_CONTROL_TOOL_ID);
59901
59599
  registerSegmentSplitMergeTools();
59902
59600
  registerSegmentSelectTools();
59903
- const segmentation_user_layer = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
59904
- __proto__: null,
59905
- LAYER_CONTROLS: LAYER_CONTROLS$1,
59906
- SKELETON_RENDERING_SHADER_CONTROL_TOOL_ID,
59907
- SegmentationUserLayer,
59908
- SegmentationUserLayerColorGroupState,
59909
- SegmentationUserLayerGroupState
59910
- }, Symbol.toStringTag, { value: "Module" }));
59911
59601
  /**
59912
59602
  * @license
59913
59603
  * Copyright 2018 Google Inc.
@@ -60102,9 +59792,9 @@ class LinkedSegmentationLayers extends RefCounted {
60102
59792
  [FILTER_BY_SEGMENTATION_JSON_KEY]: filterBySegmentation.length === 0 ? void 0 : filterBySegmentation
60103
59793
  };
60104
59794
  }
60105
- restoreState(json2) {
59795
+ restoreState(json) {
60106
59796
  const isLoading = this.annotationStates.isLoading;
60107
- verifyOptionalObjectProperty(json2, LINKED_SEGMENTATION_LAYER_JSON_KEY, (linkedJson) => {
59797
+ verifyOptionalObjectProperty(json, LINKED_SEGMENTATION_LAYER_JSON_KEY, (linkedJson) => {
60108
59798
  if (typeof linkedJson === "string") {
60109
59799
  linkedJson = { "segments": linkedJson };
60110
59800
  }
@@ -60127,7 +59817,7 @@ class LinkedSegmentationLayers extends RefCounted {
60127
59817
  }
60128
59818
  }
60129
59819
  });
60130
- verifyOptionalObjectProperty(json2, FILTER_BY_SEGMENTATION_JSON_KEY, (filterJson) => {
59820
+ verifyOptionalObjectProperty(json, FILTER_BY_SEGMENTATION_JSON_KEY, (filterJson) => {
60131
59821
  if (typeof filterJson === "boolean") {
60132
59822
  filterJson = filterJson === true ? ["segments"] : [];
60133
59823
  }
@@ -60477,14 +60167,6 @@ registerLayerTypeDetector((subsource) => {
60477
60167
  registerLayerShaderControlsTool(AnnotationUserLayer, (layer) => ({
60478
60168
  shaderControlState: layer.annotationDisplayState.shaderControls
60479
60169
  }));
60480
- const user_layer = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
60481
- __proto__: null,
60482
- AnnotationUserLayer
60483
- }, Symbol.toStringTag, { value: "Module" }));
60484
- const require$$2 = /* @__PURE__ */ getAugmentedNamespace(user_layer);
60485
- const require$$3 = /* @__PURE__ */ getAugmentedNamespace(frontend);
60486
- const require$$4 = /* @__PURE__ */ getAugmentedNamespace(segmentation_user_layer);
60487
- const require$$5 = /* @__PURE__ */ getAugmentedNamespace(color);
60488
60170
  function bindDefaultCopyHandler(viewer) {
60489
60171
  viewer.registerEventListener(document, "copy", (event) => {
60490
60172
  if (isInputTextTarget(event.target)) {
@@ -61986,7 +61668,7 @@ async function getAnnotationChunkSource$1(options, sourceParameters, dataInstanc
61986
61668
  let multiscaleVolumeInfo = new MultiscaleVolumeInfo$1(dataInstanceInfo.volumeInfo);
61987
61669
  return getChunkSource(multiscaleVolumeInfo, sourceParameters);
61988
61670
  }
61989
- async function getAnnotationSource$1(options, sourceParameters, dataInstanceInfo, credentialsProvider) {
61671
+ async function getAnnotationSource$2(options, sourceParameters, dataInstanceInfo, credentialsProvider) {
61990
61672
  const box2 = {
61991
61673
  lowerBounds: new Float64Array(dataInstanceInfo.lowerVoxelBound),
61992
61674
  upperBounds: Float64Array.from(dataInstanceInfo.upperVoxelBound)
@@ -62112,7 +61794,7 @@ function getDataSource$1(options) {
62112
61794
  max: 1,
62113
61795
  step: 0.01
62114
61796
  }];
62115
- return getAnnotationSource$1(options, annotationSourceParameters, dataInstanceInfo, credentialsProvider);
61797
+ return getAnnotationSource$2(options, annotationSourceParameters, dataInstanceInfo, credentialsProvider);
62116
61798
  } else {
62117
61799
  if (!(dataInstanceInfo instanceof VolumeDataInstanceInfo)) {
62118
61800
  throw new Error(`Invalid data instance ${dataInstanceKey}.`);
@@ -63154,7 +62836,7 @@ async function getAnnotationChunkSource(options, sourceParameters, dataInfo, cre
63154
62836
  });
63155
62837
  return getChunkSource(dataInfo, sourceParameters);
63156
62838
  }
63157
- async function getAnnotationSource(options, sourceParameters, credentialsProvider) {
62839
+ async function getAnnotationSource$1(options, sourceParameters, credentialsProvider) {
63158
62840
  const dataInfo = await getAnnotationDataInfo(sourceParameters);
63159
62841
  const box2 = {
63160
62842
  lowerBounds: new Float64Array(dataInfo.lowerVoxelBound),
@@ -63266,7 +62948,7 @@ async function getDataSource(options, getCredentialsProvider) {
63266
62948
  step: 1
63267
62949
  }];
63268
62950
  const credentialsProvider = getCredentialsProvider(sourceParameters.authServer);
63269
- return getAnnotationSource(options, annotationSourceParameters, credentialsProvider);
62951
+ return getAnnotationSource$1(options, annotationSourceParameters, credentialsProvider);
63270
62952
  });
63271
62953
  }
63272
62954
  async function completeHttpPath$1(_1) {
@@ -65886,9 +65568,9 @@ class MultiscaleVolumeChunkSource4 extends MultiscaleVolumeChunkSource$3 {
65886
65568
  function getAttributes(chunkManager, credentialsProvider, url) {
65887
65569
  return chunkManager.memoize.getUncounted({ type: "zarr:.zattrs json", url, credentialsProvider: getObjectId(credentialsProvider) }, async () => {
65888
65570
  try {
65889
- const json2 = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zattrs", {}, responseJson);
65890
- verifyObject(json2);
65891
- return json2;
65571
+ const json = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zattrs", {}, responseJson);
65572
+ verifyObject(json);
65573
+ return json;
65892
65574
  } catch (e) {
65893
65575
  if (isNotFoundError(e)) return {};
65894
65576
  throw e;
@@ -65897,8 +65579,8 @@ function getAttributes(chunkManager, credentialsProvider, url) {
65897
65579
  }
65898
65580
  function getMetadata(chunkManager, credentialsProvider, url) {
65899
65581
  return chunkManager.memoize.getUncounted({ type: "zarr:.zarray json", url, credentialsProvider: getObjectId(credentialsProvider) }, async () => {
65900
- const json2 = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zarray", {}, responseJson);
65901
- return parseZarrMetadata(json2);
65582
+ const json = await cancellableFetchSpecialOk(credentialsProvider, url + "/.zarray", {}, responseJson);
65583
+ return parseZarrMetadata(json);
65902
65584
  });
65903
65585
  }
65904
65586
  const supportedQueryParameters = [{
@@ -66880,860 +66562,627 @@ function setupDefaultViewer(options) {
66880
66562
  disableContextMenu(options.target);
66881
66563
  return viewer;
66882
66564
  }
66883
- class Neuroglancer {
66884
- version() {
66885
- return "0.0.1";
66886
- }
66887
- }
66888
- const main_module = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
66889
- __proto__: null,
66890
- default: Neuroglancer,
66891
- setupDefaultViewer
66892
- }, Symbol.toStringTag, { value: "Module" }));
66893
- const require$$6 = /* @__PURE__ */ getAugmentedNamespace(main_module);
66894
- const require$$7 = /* @__PURE__ */ getAugmentedNamespace(uint64);
66895
- const require$$8 = /* @__PURE__ */ getAugmentedNamespace(json);
66896
- const require$$9 = /* @__PURE__ */ getAugmentedNamespace(url_hash_binding);
66897
- var hasRequiredLib;
66898
- function requireLib() {
66899
- if (hasRequiredLib) return lib;
66900
- hasRequiredLib = 1;
66901
- (function(exports) {
66902
- function _typeof(obj) {
66903
- "@babel/helpers - typeof";
66904
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
66905
- _typeof = function _typeof2(obj2) {
66906
- return typeof obj2;
66907
- };
66908
- } else {
66909
- _typeof = function _typeof2(obj2) {
66910
- return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
66911
- };
66912
- }
66913
- return _typeof(obj);
66914
- }
66915
- Object.defineProperty(exports, "__esModule", {
66916
- value: true
66917
- });
66918
- exports.parseUrlHash = parseUrlHash;
66919
- exports.getNeuroglancerViewerState = getNeuroglancerViewerState;
66920
- exports.getNeuroglancerColor = getNeuroglancerColor;
66921
- exports.closeSelectionTab = closeSelectionTab;
66922
- exports.getLayerManager = getLayerManager;
66923
- exports.getManagedLayer = getManagedLayer;
66924
- exports.getAnnotationLayer = getAnnotationLayer;
66925
- exports.getAnnotationSource = getAnnotationSource2;
66926
- exports.addLayerSignalRemover = addLayerSignalRemover;
66927
- exports.unsubscribeLayersChangedSignals = unsubscribeLayersChangedSignals;
66928
- exports.configureLayersChangedSignals = configureLayersChangedSignals;
66929
- exports.configureAnnotationLayer = configureAnnotationLayer;
66930
- exports.configureAnnotationLayerChanged = configureAnnotationLayerChanged;
66931
- exports.getAnnotationSelectionHost = getAnnotationSelectionHost;
66932
- exports.getSelectedAnnotationId = getSelectedAnnotationId;
66933
- exports["default"] = void 0;
66934
- var _react = _interopRequireDefault(React__default);
66935
- var _propTypes = _interopRequireDefault(/* @__PURE__ */ requirePropTypes());
66936
- var _user_layer = require$$2;
66937
- var _frontend = require$$3;
66938
- var _segmentation_user_layer = require$$4;
66939
- var _color = require$$5;
66940
- var _neuroglancer = require$$6;
66941
- var _uint = require$$7;
66942
- var _json = require$$8;
66943
- var _url_hash_binding = require$$9;
66944
- function _interopRequireDefault(obj) {
66945
- return obj && obj.__esModule ? obj : { "default": obj };
66946
- }
66947
- function ownKeys(object, enumerableOnly) {
66948
- var keys2 = Object.keys(object);
66949
- if (Object.getOwnPropertySymbols) {
66950
- var symbols = Object.getOwnPropertySymbols(object);
66951
- if (enumerableOnly) symbols = symbols.filter(function(sym) {
66952
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
66953
- });
66954
- keys2.push.apply(keys2, symbols);
66955
- }
66956
- return keys2;
66957
- }
66958
- function _objectSpread(target) {
66959
- for (var i = 1; i < arguments.length; i++) {
66960
- var source = arguments[i] != null ? arguments[i] : {};
66961
- if (i % 2) {
66962
- ownKeys(Object(source), true).forEach(function(key) {
66963
- _defineProperty(target, key, source[key]);
66964
- });
66965
- } else if (Object.getOwnPropertyDescriptors) {
66966
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
66967
- } else {
66968
- ownKeys(Object(source)).forEach(function(key) {
66969
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
66970
- });
66565
+ const GREY_HEX = "#323232";
66566
+ const viewersKeyed = {};
66567
+ let viewerNoKey;
66568
+ function parseUrlHash(url) {
66569
+ let state = null;
66570
+ let s = url.replace(/^[^#]+/, "");
66571
+ if (s === "" || s === "#" || s === "#!") {
66572
+ s = "#!{}";
66573
+ }
66574
+ if (s.startsWith("#!+")) {
66575
+ s = s.slice(3);
66576
+ s = decodeURIComponent(s);
66577
+ state = urlSafeParse(s);
66578
+ } else if (s.startsWith("#!")) {
66579
+ s = s.slice(2);
66580
+ s = decodeURIComponent(s);
66581
+ state = urlSafeParse(s);
66582
+ } else {
66583
+ throw new Error("URL hash is expected to be of the form '#!{...}' or '#!+{...}'.");
66584
+ }
66585
+ return state;
66586
+ }
66587
+ function getNeuroglancerViewerState(key) {
66588
+ const v = key ? viewersKeyed[key] : viewerNoKey;
66589
+ return v ? v.state.toJSON() : {};
66590
+ }
66591
+ function getNeuroglancerColor(idStr, key) {
66592
+ try {
66593
+ const id = Uint64.parseString(idStr);
66594
+ const v = key ? viewersKeyed[key] : viewerNoKey;
66595
+ if (v) {
66596
+ for (const layer of v.layerManager.managedLayers) {
66597
+ if (layer.layer instanceof SegmentationUserLayer) {
66598
+ const { displayState } = layer.layer;
66599
+ const colorVec = getObjectColor(displayState, id);
66600
+ if (displayState.segmentSelectionState.isSelected(id)) {
66601
+ for (let i = 0; i < 3; i += 1) {
66602
+ colorVec[i] = (colorVec[i] - 0.5) / 0.5;
66603
+ }
66604
+ }
66605
+ const colorStr = serializeColor(colorVec);
66606
+ return colorStr;
66971
66607
  }
66972
66608
  }
66973
- return target;
66974
66609
  }
66975
- function _classCallCheck(instance, Constructor) {
66976
- if (!(instance instanceof Constructor)) {
66977
- throw new TypeError("Cannot call a class as a function");
66978
- }
66610
+ } catch {
66611
+ }
66612
+ return "";
66613
+ }
66614
+ function closeSelectionTab(key) {
66615
+ const v = key ? viewersKeyed[key] : viewerNoKey;
66616
+ if (v && v.closeSelectionTab) {
66617
+ v.closeSelectionTab();
66618
+ }
66619
+ }
66620
+ function getLayerManager(key) {
66621
+ const v = key ? viewersKeyed[key] : viewerNoKey;
66622
+ if (v) {
66623
+ return v.layerManager;
66624
+ }
66625
+ return void 0;
66626
+ }
66627
+ function getManagedLayer(key, name2) {
66628
+ const layerManager = getLayerManager(key);
66629
+ if (layerManager) {
66630
+ return layerManager.managedLayers.filter((layer) => layer.name === name2)[0];
66631
+ }
66632
+ return void 0;
66633
+ }
66634
+ function getAnnotationLayer(key, name2) {
66635
+ const layer = getManagedLayer(key, name2);
66636
+ if (layer && layer.layer instanceof AnnotationUserLayer) {
66637
+ return layer.layer;
66638
+ }
66639
+ return void 0;
66640
+ }
66641
+ function getAnnotationSource(key, name2) {
66642
+ const layer = getAnnotationLayer(key, name2);
66643
+ if (layer && layer.dataSources && layer.dataSources[0].loadState_) {
66644
+ const { dataSource } = layer.dataSources[0].loadState_;
66645
+ if (dataSource) {
66646
+ return dataSource.subsources[0].subsource.annotation;
66979
66647
  }
66980
- function _defineProperties(target, props) {
66981
- for (var i = 0; i < props.length; i++) {
66982
- var descriptor = props[i];
66983
- descriptor.enumerable = descriptor.enumerable || false;
66984
- descriptor.configurable = true;
66985
- if ("value" in descriptor) descriptor.writable = true;
66986
- Object.defineProperty(target, descriptor.key, descriptor);
66987
- }
66648
+ }
66649
+ return void 0;
66650
+ }
66651
+ function addLayerSignalRemover(key, name2, remover) {
66652
+ const layerManager = getLayerManager(key);
66653
+ if (layerManager && name2 && remover) {
66654
+ if (!layerManager.customSignalHandlerRemovers) {
66655
+ layerManager.customSignalHandlerRemovers = {};
66988
66656
  }
66989
- function _createClass(Constructor, protoProps, staticProps) {
66990
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
66991
- return Constructor;
66657
+ if (!layerManager.customSignalHandlerRemovers[name2]) {
66658
+ layerManager.customSignalHandlerRemovers[name2] = [];
66992
66659
  }
66993
- function _inherits(subClass, superClass) {
66994
- if (typeof superClass !== "function" && superClass !== null) {
66995
- throw new TypeError("Super expression must either be null or a function");
66660
+ layerManager.customSignalHandlerRemovers[name2].push(remover);
66661
+ }
66662
+ }
66663
+ function unsubscribeLayersChangedSignals(layerManager, signalKey) {
66664
+ if (layerManager) {
66665
+ if (layerManager.customSignalHandlerRemovers) {
66666
+ if (layerManager.customSignalHandlerRemovers[signalKey]) {
66667
+ layerManager.customSignalHandlerRemovers[signalKey].forEach(
66668
+ (remover) => {
66669
+ remover();
66670
+ }
66671
+ );
66672
+ delete layerManager.customSignalHandlerRemovers[signalKey];
66996
66673
  }
66997
- subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
66998
- if (superClass) _setPrototypeOf(subClass, superClass);
66999
66674
  }
67000
- function _setPrototypeOf(o, p) {
67001
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
67002
- o2.__proto__ = p2;
67003
- return o2;
67004
- };
67005
- return _setPrototypeOf(o, p);
67006
- }
67007
- function _createSuper(Derived) {
67008
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
67009
- return function _createSuperInternal() {
67010
- var Super = _getPrototypeOf(Derived), result;
67011
- if (hasNativeReflectConstruct) {
67012
- var NewTarget = _getPrototypeOf(this).constructor;
67013
- result = Reflect.construct(Super, arguments, NewTarget);
67014
- } else {
67015
- result = Super.apply(this, arguments);
66675
+ }
66676
+ }
66677
+ function configureLayersChangedSignals(key, layerConfig) {
66678
+ const layerManager = getLayerManager(key);
66679
+ if (layerManager) {
66680
+ const { layerName } = layerConfig;
66681
+ unsubscribeLayersChangedSignals(layerManager, layerName);
66682
+ if (layerConfig.process) {
66683
+ const recordRemover = (remover) => addLayerSignalRemover(void 0, layerName, remover);
66684
+ recordRemover(
66685
+ layerManager.layersChanged.add(() => {
66686
+ const layer2 = getManagedLayer(void 0, layerName);
66687
+ if (layer2) {
66688
+ layerConfig.process(layer2);
66689
+ }
66690
+ })
66691
+ );
66692
+ const layer = getManagedLayer(void 0, layerName);
66693
+ if (layer) {
66694
+ layerConfig.process(layer);
66695
+ }
66696
+ return () => {
66697
+ if (layerConfig.cancel) {
66698
+ layerConfig.cancel();
67016
66699
  }
67017
- return _possibleConstructorReturn(this, result);
66700
+ unsubscribeLayersChangedSignals(layerManager, layerName);
67018
66701
  };
67019
66702
  }
67020
- function _possibleConstructorReturn(self2, call) {
67021
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
67022
- return call;
67023
- }
67024
- return _assertThisInitialized(self2);
67025
- }
67026
- function _assertThisInitialized(self2) {
67027
- if (self2 === void 0) {
67028
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
67029
- }
67030
- return self2;
66703
+ }
66704
+ return layerConfig.cancel;
66705
+ }
66706
+ function configureAnnotationSource(source, props, recordRemover) {
66707
+ if (source && !source.signalReady) {
66708
+ if (props.onAnnotationAdded) {
66709
+ recordRemover(
66710
+ source.childAdded.add((annotation) => {
66711
+ props.onAnnotationAdded(annotation);
66712
+ })
66713
+ );
67031
66714
  }
67032
- function _isNativeReflectConstruct() {
67033
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
67034
- if (Reflect.construct.sham) return false;
67035
- if (typeof Proxy === "function") return true;
67036
- try {
67037
- Date.prototype.toString.call(Reflect.construct(Date, [], function() {
67038
- }));
67039
- return true;
67040
- } catch (e) {
67041
- return false;
67042
- }
66715
+ if (props.onAnnotationDeleted) {
66716
+ recordRemover(
66717
+ source.childDeleted.add((id) => {
66718
+ props.onAnnotationDeleted(id);
66719
+ })
66720
+ );
67043
66721
  }
67044
- function _getPrototypeOf(o) {
67045
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
67046
- return o2.__proto__ || Object.getPrototypeOf(o2);
67047
- };
67048
- return _getPrototypeOf(o);
66722
+ if (props.onAnnotationUpdated) {
66723
+ recordRemover(
66724
+ source.childUpdated.add((annotation) => {
66725
+ props.onAnnotationUpdated(annotation);
66726
+ })
66727
+ );
67049
66728
  }
67050
- function _defineProperty(obj, key, value) {
67051
- if (key in obj) {
67052
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
67053
- } else {
67054
- obj[key] = value;
67055
- }
67056
- return obj;
66729
+ if (props.onAnnotationChanged && source.referencesChanged) {
66730
+ recordRemover(source.referencesChanged.add(props.onAnnotationChanged));
67057
66731
  }
67058
- function _createForOfIteratorHelper(o, allowArrayLike) {
67059
- var it;
67060
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
67061
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) {
67062
- if (it) o = it;
67063
- var i = 0;
67064
- var F = function F2() {
67065
- };
67066
- return { s: F, n: function n() {
67067
- if (i >= o.length) return { done: true };
67068
- return { done: false, value: o[i++] };
67069
- }, e: function e(_e) {
67070
- throw _e;
67071
- }, f: F };
67072
- }
67073
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
67074
- }
67075
- var normalCompletion = true, didErr = false, err;
67076
- return { s: function s() {
67077
- it = o[Symbol.iterator]();
67078
- }, n: function n() {
67079
- var step = it.next();
67080
- normalCompletion = step.done;
67081
- return step;
67082
- }, e: function e(_e2) {
67083
- didErr = true;
67084
- err = _e2;
67085
- }, f: function f() {
67086
- try {
67087
- if (!normalCompletion && it["return"] != null) it["return"]();
67088
- } finally {
67089
- if (didErr) throw err;
67090
- }
67091
- } };
66732
+ source.signalReady = true;
66733
+ recordRemover(() => {
66734
+ source.signalReady = false;
66735
+ });
66736
+ }
66737
+ }
66738
+ function getLoadedDataSource(layer) {
66739
+ if (layer.dataSources && layer.dataSources.length > 0 && layer.dataSources[0].loadState_ && layer.dataSources[0].loadState_.dataSource) {
66740
+ return layer.dataSources[0].loadState_.dataSource;
66741
+ }
66742
+ }
66743
+ function getAnnotationSourceFromLayer(layer) {
66744
+ const dataSource = getLoadedDataSource(layer);
66745
+ if (dataSource) {
66746
+ return dataSource.subsources[0].subsource.annotation;
66747
+ }
66748
+ }
66749
+ function configureAnnotationSourceChange(annotationLayer, props, recordRemover) {
66750
+ const configure = () => {
66751
+ const source = getAnnotationSourceFromLayer(annotationLayer);
66752
+ if (source) {
66753
+ configureAnnotationSource(source, props, recordRemover);
67092
66754
  }
67093
- function _unsupportedIterableToArray(o, minLen) {
67094
- if (!o) return;
67095
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
67096
- var n = Object.prototype.toString.call(o).slice(8, -1);
67097
- if (n === "Object" && o.constructor) n = o.constructor.name;
67098
- if (n === "Map" || n === "Set") return Array.from(o);
67099
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
67100
- }
67101
- function _arrayLikeToArray(arr, len2) {
67102
- if (len2 == null || len2 > arr.length) len2 = arr.length;
67103
- for (var i = 0, arr2 = new Array(len2); i < len2; i++) {
67104
- arr2[i] = arr[i];
67105
- }
67106
- return arr2;
67107
- }
67108
- var viewersKeyed = {};
67109
- var viewerNoKey;
67110
- function parseUrlHash(url) {
67111
- var state = null;
67112
- var s = url.replace(/^[^#]+/, "");
67113
- if (s === "" || s === "#" || s === "#!") {
67114
- s = "#!{}";
67115
- }
67116
- if (s.startsWith("#!+")) {
67117
- s = s.slice(3);
67118
- s = decodeURIComponent(s);
67119
- state = (0, _json.urlSafeParse)(s);
67120
- } else if (s.startsWith("#!")) {
67121
- s = s.slice(2);
67122
- s = decodeURIComponent(s);
67123
- state = (0, _json.urlSafeParse)(s);
67124
- } else {
67125
- throw new Error('URL hash is expected to be of the form "#!{...}" or "#!+{...}".');
66755
+ };
66756
+ const sourceChanged = annotationLayer.dataSourcesChanged;
66757
+ if (sourceChanged && !sourceChanged.signalReady) {
66758
+ recordRemover(sourceChanged.add(configure));
66759
+ sourceChanged.signalReady = true;
66760
+ recordRemover(() => {
66761
+ sourceChanged.signalReady = false;
66762
+ });
66763
+ configure();
66764
+ }
66765
+ }
66766
+ function configureAnnotationLayer(layer, props, recordRemover) {
66767
+ if (layer) {
66768
+ layer.expectingExternalTable = true;
66769
+ if (layer.selectedAnnotation && !layer.selectedAnnotation.changed.signalReady) {
66770
+ if (props.onAnnotationSelectionChanged) {
66771
+ recordRemover(
66772
+ layer.selectedAnnotation.changed.add(() => {
66773
+ props.onAnnotationSelectionChanged(layer.selectedAnnotation.value);
66774
+ })
66775
+ );
66776
+ recordRemover(() => {
66777
+ layer.selectedAnnotation.changed.signalReady = false;
66778
+ });
66779
+ layer.selectedAnnotation.changed.signalReady = true;
67126
66780
  }
67127
- return state;
67128
66781
  }
67129
- function getNeuroglancerViewerState(key) {
67130
- var v = key ? viewersKeyed[key] : viewerNoKey;
67131
- return v ? v.state.toJSON() : {};
66782
+ configureAnnotationSourceChange(layer, props, recordRemover);
66783
+ }
66784
+ }
66785
+ function configureAnnotationLayerChanged(layer, props, recordRemover) {
66786
+ if (!layer.layerChanged.signalReady) {
66787
+ const remover = layer.layerChanged.add(() => {
66788
+ configureAnnotationLayer(layer.layer, props, recordRemover);
66789
+ });
66790
+ layer.layerChanged.signalReady = true;
66791
+ recordRemover(remover);
66792
+ recordRemover(() => {
66793
+ layer.layerChanged.signalReady = false;
66794
+ });
66795
+ configureAnnotationLayer(layer.layer, props, recordRemover);
66796
+ }
66797
+ }
66798
+ function getAnnotationSelectionHost(key) {
66799
+ const viewer = key ? viewersKeyed[key] : viewerNoKey;
66800
+ if (viewer) {
66801
+ if (viewer.selectionDetailsState) {
66802
+ return "viewer";
67132
66803
  }
67133
- function getNeuroglancerColor(idStr, key) {
67134
- try {
67135
- var id = _uint.Uint64.parseString(idStr);
67136
- var v = key ? viewersKeyed[key] : viewerNoKey;
67137
- if (v) {
67138
- var _iterator = _createForOfIteratorHelper(v.layerManager.managedLayers), _step;
67139
- try {
67140
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
67141
- var layer = _step.value;
67142
- if (layer.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
67143
- var displayState = layer.layer.displayState;
67144
- var colorVec = (0, _frontend.getObjectColor)(displayState, id);
67145
- if (displayState.segmentSelectionState.isSelected(id)) {
67146
- for (var i = 0; i < 3; i += 1) {
67147
- colorVec[i] = (colorVec[i] - 0.5) / 0.5;
67148
- }
67149
- }
67150
- var colorStr = (0, _color.serializeColor)(colorVec);
67151
- return colorStr;
67152
- }
67153
- }
67154
- } catch (err) {
67155
- _iterator.e(err);
67156
- } finally {
67157
- _iterator.f();
66804
+ return "layer";
66805
+ }
66806
+ return null;
66807
+ }
66808
+ function getSelectedAnnotationId(key, layerName) {
66809
+ const viewer = key ? viewersKeyed[key] : viewerNoKey;
66810
+ if (viewer) {
66811
+ if (viewer.selectionDetailsState) {
66812
+ if (viewer.selectionDetailsState.value) {
66813
+ const { layers } = viewer.selectionDetailsState.value;
66814
+ if (layers) {
66815
+ const layer = layers.find(
66816
+ (_layer) => _layer.layer.managedLayer.name === layerName
66817
+ );
66818
+ if (layer && layer.state) {
66819
+ return layer.state.annotationId;
67158
66820
  }
67159
66821
  }
67160
- } catch (_unused) {
67161
- }
67162
- return "";
67163
- }
67164
- function closeSelectionTab(key) {
67165
- var v = key ? viewersKeyed[key] : viewerNoKey;
67166
- if (v && v.closeSelectionTab) {
67167
- v.closeSelectionTab();
67168
66822
  }
67169
- }
67170
- function getLayerManager(key) {
67171
- var v = key ? viewersKeyed[key] : viewerNoKey;
67172
- if (v) {
67173
- return v.layerManager;
67174
- }
67175
- return void 0;
67176
- }
67177
- function getManagedLayer(key, name2) {
67178
- var layerManager = getLayerManager(key);
67179
- if (layerManager) {
67180
- return layerManager.managedLayers.filter(function(layer) {
67181
- return layer.name === name2;
67182
- })[0];
67183
- }
67184
- return void 0;
67185
- }
67186
- function getAnnotationLayer(key, name2) {
67187
- var layer = getManagedLayer(key, name2);
67188
- if (layer && layer.layer instanceof _user_layer.AnnotationUserLayer) {
67189
- return layer.layer;
67190
- }
67191
- return void 0;
67192
- }
67193
- function getAnnotationSource2(key, name2) {
67194
- var layer = getAnnotationLayer(key, name2);
67195
- if (layer && layer.dataSources && layer.dataSources[0].loadState_) {
67196
- var dataSource = layer.dataSources[0].loadState_.dataSource;
67197
- if (dataSource) {
67198
- return dataSource.subsources[0].subsource.annotation;
67199
- }
66823
+ } else {
66824
+ const layer = getAnnotationLayer(void 0, layerName);
66825
+ if (layer && layer.selectedAnnotation && layer.selectedAnnotation.value) {
66826
+ return layer.selectedAnnotation.value.id;
67200
66827
  }
67201
- return void 0;
67202
66828
  }
67203
- function addLayerSignalRemover(key, name2, remover) {
67204
- var layerManager = getLayerManager(key);
67205
- if (layerManager && name2 && remover) {
67206
- if (!layerManager.customSignalHandlerRemovers) {
67207
- layerManager.customSignalHandlerRemovers = {};
67208
- }
67209
- if (!layerManager.customSignalHandlerRemovers[name2]) {
67210
- layerManager.customSignalHandlerRemovers[name2] = [];
67211
- }
67212
- layerManager.customSignalHandlerRemovers[name2].push(remover);
66829
+ }
66830
+ return null;
66831
+ }
66832
+ class Neuroglancer extends React__default.Component {
66833
+ constructor(props) {
66834
+ super(props);
66835
+ __publicField(this, "minimalPoseSnapshot", () => {
66836
+ var _a, _b;
66837
+ const v = this.viewer;
66838
+ const projScale = (_a = v.projectionScale) == null ? void 0 : _a.value;
66839
+ const projQuat = (_b = v.projectionOrientation) == null ? void 0 : _b.orientation;
66840
+ return {
66841
+ position: Array.from(v.position.value || []),
66842
+ projectionScale: projScale,
66843
+ projectionOrientation: Array.from(projQuat || [])
66844
+ };
66845
+ });
66846
+ // Coalesce many NG changes → one upstream update per frame.
66847
+ __publicField(this, "scheduleEmit", () => {
66848
+ let raf = null;
66849
+ return () => {
66850
+ if (this.muteViewerChanged) return;
66851
+ if (raf !== null) return;
66852
+ raf = requestAnimationFrame(() => {
66853
+ var _a, _b;
66854
+ raf = null;
66855
+ (_b = (_a = this.props).onViewerStateChanged) == null ? void 0 : _b.call(_a, this.minimalPoseSnapshot());
66856
+ });
66857
+ };
66858
+ });
66859
+ // Guard to mute outgoing emits we are programmatically making changes
66860
+ __publicField(this, "withoutEmitting", (fn) => {
66861
+ this.muteViewerChanged = true;
66862
+ try {
66863
+ fn();
66864
+ } finally {
66865
+ requestAnimationFrame(() => {
66866
+ this.muteViewerChanged = false;
66867
+ });
67213
66868
  }
67214
- }
67215
- function unsubscribeLayersChangedSignals(layerManager, signalKey) {
67216
- if (layerManager) {
67217
- if (layerManager.customSignalHandlerRemovers) {
67218
- if (layerManager.customSignalHandlerRemovers[signalKey]) {
67219
- layerManager.customSignalHandlerRemovers[signalKey].forEach(function(remover) {
67220
- remover();
67221
- });
67222
- delete layerManager.customSignalHandlerRemovers[signalKey];
66869
+ });
66870
+ // Only consider actual changes in camera settings, i.e., position/rotation/zoom
66871
+ __publicField(this, "didLayersChange", (prevVS, nextVS) => {
66872
+ const stripColors = (layers) => (layers || []).map((l) => {
66873
+ if (!l) return l;
66874
+ const { segmentColors, ...rest } = l;
66875
+ return rest;
66876
+ });
66877
+ const prevLayers = stripColors(prevVS == null ? void 0 : prevVS.layers);
66878
+ const nextLayers = stripColors(nextVS == null ? void 0 : nextVS.layers);
66879
+ return JSON.stringify(prevLayers) !== JSON.stringify(nextLayers);
66880
+ });
66881
+ /* To add colors to the segments, turning unselected to grey */
66882
+ __publicField(this, "applyColorsAndVisibility", (cellColorMapping) => {
66883
+ var _a, _b, _c, _d;
66884
+ if (!this.viewer) return;
66885
+ const selected = { ...cellColorMapping || {} };
66886
+ for (const id of Object.keys(selected)) this.allKnownIds.add(id);
66887
+ if (this.allKnownIds.size === 0) {
66888
+ const init = ((_c = (_b = (_a = this.props.viewerState) == null ? void 0 : _a.layers) == null ? void 0 : _b[0]) == null ? void 0 : _c.segmentColors) || {};
66889
+ for (const id of Object.keys(init)) this.allKnownIds.add(id);
66890
+ }
66891
+ const fullSegmentColors = {};
66892
+ for (const id of this.allKnownIds) {
66893
+ fullSegmentColors[id] = selected[id] || GREY_HEX;
66894
+ }
66895
+ const baseLayers = ((_d = this.props.viewerState) == null ? void 0 : _d.layers) ?? (this.viewer.state.toJSON().layers || []);
66896
+ const newLayers = baseLayers.map((layer, idx) => {
66897
+ if (idx === 0 || (layer == null ? void 0 : layer.type) === "segmentation") {
66898
+ return { ...layer, segmentColors: fullSegmentColors };
66899
+ }
66900
+ return layer;
66901
+ });
66902
+ this.withoutEmitting(() => {
66903
+ this.viewer.state.restoreState({ layers: newLayers });
66904
+ });
66905
+ });
66906
+ __publicField(this, "updateEventBindings", (eventBindingsToUpdate) => {
66907
+ const root = this.viewer.inputEventBindings;
66908
+ const traverse = (current) => {
66909
+ const replace = (eaMap, event0, event1) => {
66910
+ const action = eaMap.get(event0);
66911
+ if (action) {
66912
+ eaMap.delete(event0);
66913
+ if (event1) {
66914
+ eaMap.set(event1, action);
66915
+ }
67223
66916
  }
66917
+ };
66918
+ const eventActionMap = current.bindings;
66919
+ eventBindingsToUpdate.forEach((oldNewBinding) => {
66920
+ const eventOldBase = Array.isArray(oldNewBinding) ? oldNewBinding[0] : oldNewBinding;
66921
+ const eventOldA = `at:${eventOldBase}`;
66922
+ const eventNewA = oldNewBinding[1] ? `at:${oldNewBinding[1]}` : void 0;
66923
+ replace(eventActionMap, eventOldA, eventNewA);
66924
+ const eventOldB = `bubble:${eventOldBase}`;
66925
+ const eventNewB = oldNewBinding[1] ? `bubble:${oldNewBinding[1]}` : void 0;
66926
+ replace(eventActionMap, eventOldB, eventNewB);
66927
+ });
66928
+ current.parents.forEach((parent) => {
66929
+ traverse(parent);
66930
+ });
66931
+ };
66932
+ traverse(root.global);
66933
+ traverse(root.perspectiveView);
66934
+ traverse(root.sliceView);
66935
+ });
66936
+ __publicField(this, "selectionDetailsStateChanged", () => {
66937
+ if (this.viewer) {
66938
+ const { onSelectionDetailsStateChanged } = this.props;
66939
+ if (onSelectionDetailsStateChanged) {
66940
+ onSelectionDetailsStateChanged();
67224
66941
  }
67225
66942
  }
67226
- }
67227
- function configureLayersChangedSignals(key, layerConfig) {
67228
- var layerManager = getLayerManager(key);
67229
- if (layerManager) {
67230
- var layerName = layerConfig.layerName;
67231
- unsubscribeLayersChangedSignals(layerManager, layerName);
67232
- if (layerConfig.process) {
67233
- var recordRemover = function recordRemover2(remover) {
67234
- return addLayerSignalRemover(void 0, layerName, remover);
67235
- };
67236
- recordRemover(layerManager.layersChanged.add(function() {
67237
- var layer2 = getManagedLayer(void 0, layerName);
67238
- if (layer2) {
67239
- layerConfig.process(layer2);
66943
+ });
66944
+ __publicField(this, "layersChanged", () => {
66945
+ if (this.handlerRemovers) {
66946
+ this.handlerRemovers.forEach((remover) => remover());
66947
+ }
66948
+ if (this.viewer) {
66949
+ const { onSelectedChanged, onVisibleChanged } = this.props;
66950
+ if (onSelectedChanged || onVisibleChanged) {
66951
+ this.handlerRemovers = [];
66952
+ for (const layer of this.viewer.layerManager.managedLayers) {
66953
+ if (layer.layer instanceof SegmentationUserLayer) {
66954
+ const { segmentSelectionState } = layer.layer.displayState;
66955
+ const { visibleSegments } = layer.layer.displayState.segmentationGroupState.value;
66956
+ if (segmentSelectionState && onSelectedChanged) {
66957
+ const selectedChanged = this.selectedChanged.bind(
66958
+ void 0,
66959
+ layer
66960
+ );
66961
+ const remover = segmentSelectionState.changed.add(selectedChanged);
66962
+ this.handlerRemovers.push(remover);
66963
+ layer.registerDisposer(remover);
66964
+ }
66965
+ if (visibleSegments && onVisibleChanged) {
66966
+ const visibleChanged = this.visibleChanged.bind(void 0, layer);
66967
+ const remover = visibleSegments.changed.add(visibleChanged);
66968
+ this.handlerRemovers.push(remover);
66969
+ layer.registerDisposer(remover);
66970
+ }
67240
66971
  }
67241
- }));
67242
- var layer = getManagedLayer(void 0, layerName);
67243
- if (layer) {
67244
- layerConfig.process(layer);
67245
66972
  }
67246
- return function() {
67247
- if (layerConfig.cancel) {
67248
- layerConfig.cancel();
67249
- }
67250
- unsubscribeLayersChangedSignals(layerManager, layerName);
67251
- };
67252
66973
  }
67253
66974
  }
67254
- return layerConfig.cancel;
67255
- }
67256
- function configureAnnotationSource(source, props, recordRemover) {
67257
- if (source && !source.signalReady) {
67258
- if (props.onAnnotationAdded) {
67259
- recordRemover(source.childAdded.add(function(annotation) {
67260
- props.onAnnotationAdded(annotation);
67261
- }));
67262
- }
67263
- if (props.onAnnotationDeleted) {
67264
- recordRemover(source.childDeleted.add(function(id) {
67265
- props.onAnnotationDeleted(id);
67266
- }));
67267
- }
67268
- if (props.onAnnotationUpdated) {
67269
- recordRemover(source.childUpdated.add(function(annotation) {
67270
- props.onAnnotationUpdated(annotation);
67271
- }));
67272
- }
67273
- if (props.onAnnotationChanged && source.referencesChanged) {
67274
- recordRemover(source.referencesChanged.add(props.onAnnotationChanged));
66975
+ });
66976
+ /* ** Vitessce Integration update start ** */
66977
+ __publicField(this, "selectedChanged", (layer) => {
66978
+ if (!this.viewer) return;
66979
+ const { onSelectedChanged } = this.props;
66980
+ if (onSelectedChanged) {
66981
+ const { segmentSelectionState } = layer.layer.displayState;
66982
+ if (!segmentSelectionState) return;
66983
+ const selected = segmentSelectionState.selectedSegment;
66984
+ if (selected) {
66985
+ onSelectedChanged(selected, layer);
67275
66986
  }
67276
- source.signalReady = true;
67277
- recordRemover(function() {
67278
- source.signalReady = false;
67279
- });
67280
66987
  }
67281
- }
67282
- function getLoadedDataSource(layer) {
67283
- if (layer.dataSources && layer.dataSources.length > 0 && layer.dataSources[0].loadState_ && layer.dataSources[0].loadState_.dataSource) {
67284
- return layer.dataSources[0].loadState_.dataSource;
66988
+ });
66989
+ __publicField(this, "visibleChanged", (layer) => {
66990
+ if (this.viewer) {
66991
+ const { onVisibleChanged } = this.props;
66992
+ if (onVisibleChanged) {
66993
+ const { visibleSegments } = layer.layer.displayState.segmentationGroupState.value;
66994
+ if (visibleSegments) {
66995
+ onVisibleChanged(visibleSegments, layer);
66996
+ }
66997
+ }
67285
66998
  }
66999
+ });
67000
+ this.ngContainer = React__default.createRef();
67001
+ this.viewer = null;
67002
+ this.muteViewerChanged = false;
67003
+ this.prevVisibleIds = /* @__PURE__ */ new Set();
67004
+ this.prevColorMap = null;
67005
+ this.disposers = [];
67006
+ this.prevColorOverrides = /* @__PURE__ */ new Set();
67007
+ this.overrideColorsById = /* @__PURE__ */ Object.create(null);
67008
+ this.allKnownIds = /* @__PURE__ */ new Set();
67009
+ }
67010
+ componentDidMount() {
67011
+ const {
67012
+ viewerState,
67013
+ brainMapsClientId,
67014
+ eventBindingsToUpdate,
67015
+ callbacks,
67016
+ // ngServer,
67017
+ key,
67018
+ bundleRoot
67019
+ } = this.props;
67020
+ this.viewer = setupDefaultViewer({
67021
+ brainMapsClientId,
67022
+ target: this.ngContainer.current,
67023
+ bundleRoot
67024
+ });
67025
+ this.setCallbacks(callbacks);
67026
+ if (eventBindingsToUpdate) {
67027
+ this.updateEventBindings(eventBindingsToUpdate);
67028
+ }
67029
+ this.viewer.expectingExternalUI = true;
67030
+ if (this.viewer.selectionDetailsState) {
67031
+ this.viewer.selectionDetailsState.changed.add(
67032
+ this.selectionDetailsStateChanged
67033
+ );
67286
67034
  }
67287
- function getAnnotationSourceFromLayer(layer) {
67288
- var dataSource = getLoadedDataSource(layer);
67289
- if (dataSource) {
67290
- return dataSource.subsources[0].subsource.annotation;
67291
- }
67035
+ this.viewer.layerManager.layersChanged.add(this.layersChanged);
67036
+ const emit = this.scheduleEmit();
67037
+ this.disposers.push(this.viewer.projectionScale.changed.add(emit));
67038
+ this.disposers.push(this.viewer.projectionOrientation.changed.add(emit));
67039
+ this.disposers.push(this.viewer.position.changed.add(emit));
67040
+ if (viewerState) {
67041
+ this.withoutEmitting(() => {
67042
+ this.viewer.state.restoreState(viewerState);
67043
+ });
67292
67044
  }
67293
- function configureAnnotationSourceChange(annotationLayer, props, recordRemover) {
67294
- var configure = function configure2() {
67295
- var source = getAnnotationSourceFromLayer(annotationLayer);
67296
- if (source) {
67297
- configureAnnotationSource(source, props, recordRemover);
67298
- }
67299
- };
67300
- var sourceChanged = annotationLayer.dataSourcesChanged;
67301
- if (sourceChanged && !sourceChanged.signalReady) {
67302
- recordRemover(sourceChanged.add(configure));
67303
- sourceChanged.signalReady = true;
67304
- recordRemover(function() {
67305
- sourceChanged.signalReady = false;
67306
- });
67307
- configure();
67308
- }
67045
+ if (key) {
67046
+ viewersKeyed[key] = this.viewer;
67047
+ } else {
67048
+ viewerNoKey = this.viewer;
67309
67049
  }
67310
- function configureAnnotationLayer(layer, props, recordRemover) {
67311
- if (layer) {
67312
- layer.expectingExternalTable = true;
67313
- if (layer.selectedAnnotation && !layer.selectedAnnotation.changed.signalReady) {
67314
- if (props.onAnnotationSelectionChanged) {
67315
- recordRemover(layer.selectedAnnotation.changed.add(function() {
67316
- props.onAnnotationSelectionChanged(layer.selectedAnnotation.value);
67317
- }));
67318
- recordRemover(function() {
67319
- layer.selectedAnnotation.changed.signalReady = false;
67320
- });
67321
- layer.selectedAnnotation.changed.signalReady = true;
67322
- }
67050
+ }
67051
+ componentDidUpdate(prevProps, prevState) {
67052
+ var _a;
67053
+ const { viewerState, cellColorMapping } = this.props;
67054
+ const selectedSegments = {};
67055
+ for (const layer of this.viewer.layerManager.managedLayers) {
67056
+ if (layer.layer instanceof SegmentationUserLayer) {
67057
+ const { segmentSelectionState } = layer.layer.displayState;
67058
+ selectedSegments[layer.name] = segmentSelectionState.selectedSegment;
67059
+ }
67060
+ }
67061
+ for (const layer of this.viewer.layerManager.managedLayers) {
67062
+ if (layer.layer instanceof SegmentationUserLayer) {
67063
+ const { segmentSelectionState } = layer.layer.displayState;
67064
+ segmentSelectionState.set(selectedSegments[layer.name]);
67065
+ }
67066
+ }
67067
+ if (!viewerState) return;
67068
+ const prevVS = prevProps.viewerState;
67069
+ const camState = diffCameraState(prevVS, viewerState);
67070
+ if (camState.changed) {
67071
+ const patch = {};
67072
+ if (camState.scale) {
67073
+ patch.projectionScale = viewerState.projectionScale;
67074
+ if (Array.isArray(viewerState.position)) patch.position = viewerState.position;
67075
+ } else if (camState.pos) {
67076
+ patch.position = viewerState.position;
67077
+ }
67078
+ if (camState.rot) patch.projectionOrientation = viewerState.projectionOrientation;
67079
+ this.withoutEmitting(() => this.viewer.state.restoreState(patch));
67080
+ }
67081
+ if (this.didLayersChange(prevVS, viewerState)) {
67082
+ this.withoutEmitting(() => {
67083
+ const layers = Array.isArray(viewerState.layers) ? viewerState.layers : [];
67084
+ this.viewer.state.restoreState({ layers });
67085
+ if (cellColorMapping && Object.keys(cellColorMapping).length) {
67086
+ this.applyColorsAndVisibility(cellColorMapping);
67323
67087
  }
67324
- configureAnnotationSourceChange(layer, props, recordRemover);
67325
- }
67088
+ });
67326
67089
  }
67327
- function configureAnnotationLayerChanged(layer, props, recordRemover) {
67328
- if (!layer.layerChanged.signalReady) {
67329
- var remover = layer.layerChanged.add(function() {
67330
- configureAnnotationLayer(layer.layer, props, recordRemover);
67331
- });
67332
- layer.layerChanged.signalReady = true;
67333
- recordRemover(remover);
67334
- recordRemover(function() {
67335
- layer.layerChanged.signalReady = false;
67336
- });
67337
- configureAnnotationLayer(layer.layer, props, recordRemover);
67338
- }
67090
+ const prevSize = prevProps.cellColorMapping ? Object.keys(prevProps.cellColorMapping).length : 0;
67091
+ const currSize = cellColorMapping ? Object.keys(cellColorMapping).length : 0;
67092
+ const mappingRefChanged = prevProps.cellColorMapping !== cellColorMapping;
67093
+ if (!this.didLayersChange(prevVS, viewerState) && (mappingRefChanged || prevSize !== currSize)) {
67094
+ this.withoutEmitting(() => {
67095
+ this.applyColorsAndVisibility(cellColorMapping);
67096
+ });
67339
67097
  }
67340
- function getAnnotationSelectionHost(key) {
67341
- var viewer = key ? viewersKeyed[key] : viewerNoKey;
67342
- if (viewer) {
67343
- if (viewer.selectionDetailsState) {
67344
- return "viewer";
67345
- }
67346
- return "layer";
67347
- }
67348
- return null;
67098
+ const stripSegFields = (layers) => (layers || []).map((l) => {
67099
+ if (!l) return l;
67100
+ const { segments, segmentColors, ...rest } = l;
67101
+ return rest;
67102
+ });
67103
+ const prevLayers = (_a = prevProps.viewerState) == null ? void 0 : _a.layers;
67104
+ const nextLayers = viewerState == null ? void 0 : viewerState.layers;
67105
+ const prevCore = JSON.stringify(stripSegFields(prevLayers));
67106
+ const nextCore = JSON.stringify(stripSegFields(nextLayers));
67107
+ const sourcesChanged = prevCore !== nextCore;
67108
+ const prevSegCount = prevLayers && prevLayers[0] && Array.isArray(prevLayers[0].segments) ? prevLayers[0].segments.length : 0;
67109
+ const nextSegCount = nextLayers && nextLayers[0] && Array.isArray(nextLayers[0].segments) ? nextLayers[0].segments.length : 0;
67110
+ const initialSegmentsAdded = prevSegCount === 0 && nextSegCount > 0;
67111
+ if (sourcesChanged || initialSegmentsAdded) {
67112
+ this.withoutEmitting(() => {
67113
+ this.viewer.state.restoreState({ layers: nextLayers });
67114
+ });
67349
67115
  }
67350
- function getSelectedAnnotationId(key, layerName) {
67351
- var viewer = key ? viewersKeyed[key] : viewerNoKey;
67352
- if (viewer) {
67353
- if (viewer.selectionDetailsState) {
67354
- if (viewer.selectionDetailsState.value) {
67355
- var layers = viewer.selectionDetailsState.value.layers;
67356
- if (layers) {
67357
- var layer = layers.find(function(_layer) {
67358
- return _layer.layer.managedLayer.name === layerName;
67359
- });
67360
- if (layer && layer.state) {
67361
- return layer.state.annotationId;
67362
- }
67363
- }
67364
- }
67365
- } else {
67366
- var _layer2 = getAnnotationLayer(void 0, layerName);
67367
- if (_layer2 && _layer2.selectedAnnotation && _layer2.selectedAnnotation.value) {
67368
- return _layer2.selectedAnnotation.value.id;
67369
- }
67370
- }
67116
+ }
67117
+ componentWillUnmount() {
67118
+ this.disposers.forEach((off) => {
67119
+ try {
67120
+ off();
67121
+ } catch {
67371
67122
  }
67372
- return null;
67373
- }
67374
- var Neuroglancer2 = /* @__PURE__ */ function(_React$Component) {
67375
- _inherits(Neuroglancer3, _React$Component);
67376
- var _super = _createSuper(Neuroglancer3);
67377
- function Neuroglancer3(props) {
67378
- var _this;
67379
- _classCallCheck(this, Neuroglancer3);
67380
- _this = _super.call(this, props);
67381
- _defineProperty(_assertThisInitialized(_this), "updateEventBindings", function(eventBindingsToUpdate) {
67382
- var root = _this.viewer.inputEventBindings;
67383
- var traverse = function traverse2(current) {
67384
- var replace = function replace2(eaMap, event0, event1) {
67385
- var action = eaMap.get(event0);
67386
- if (action) {
67387
- eaMap["delete"](event0);
67388
- if (event1) {
67389
- eaMap.set(event1, action);
67390
- }
67391
- }
67392
- };
67393
- var eventActionMap = current.bindings;
67394
- eventBindingsToUpdate.forEach(function(oldNewBinding) {
67395
- var eventOldBase = Array.isArray(oldNewBinding) ? oldNewBinding[0] : oldNewBinding;
67396
- var eventOldA = "at:".concat(eventOldBase);
67397
- var eventNewA = oldNewBinding[1] ? "at:".concat(oldNewBinding[1]) : void 0;
67398
- replace(eventActionMap, eventOldA, eventNewA);
67399
- var eventOldB = "bubble:".concat(eventOldBase);
67400
- var eventNewB = oldNewBinding[1] ? "bubble:".concat(oldNewBinding[1]) : void 0;
67401
- replace(eventActionMap, eventOldB, eventNewB);
67402
- });
67403
- current.parents.forEach(function(parent) {
67404
- traverse2(parent);
67405
- });
67406
- };
67407
- traverse(root.global);
67408
- traverse(root.perspectiveView);
67409
- traverse(root.sliceView);
67410
- });
67411
- _defineProperty(_assertThisInitialized(_this), "selectionDetailsStateChanged", function() {
67412
- if (_this.viewer) {
67413
- var onSelectionDetailsStateChanged = _this.props.onSelectionDetailsStateChanged;
67414
- if (onSelectionDetailsStateChanged) {
67415
- onSelectionDetailsStateChanged();
67416
- }
67417
- }
67418
- });
67419
- _defineProperty(_assertThisInitialized(_this), "layersChanged", function() {
67420
- if (_this.handlerRemovers) {
67421
- _this.handlerRemovers.forEach(function(remover2) {
67422
- return remover2();
67423
- });
67424
- }
67425
- if (_this.viewer) {
67426
- var _this$props = _this.props, onSelectedChanged = _this$props.onSelectedChanged, onVisibleChanged = _this$props.onVisibleChanged;
67427
- if (onSelectedChanged || onVisibleChanged) {
67428
- _this.handlerRemovers = [];
67429
- var _iterator2 = _createForOfIteratorHelper(_this.viewer.layerManager.managedLayers), _step2;
67430
- try {
67431
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
67432
- var layer = _step2.value;
67433
- if (layer.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
67434
- var segmentSelectionState = layer.layer.displayState.segmentSelectionState;
67435
- var visibleSegments = layer.layer.displayState.segmentationGroupState.value.visibleSegments;
67436
- if (segmentSelectionState && onSelectedChanged) {
67437
- var selectedChanged = _this.selectedChanged.bind(void 0, layer);
67438
- var remover = segmentSelectionState.changed.add(selectedChanged);
67439
- _this.handlerRemovers.push(remover);
67440
- layer.registerDisposer(remover);
67441
- }
67442
- if (visibleSegments && onVisibleChanged) {
67443
- var visibleChanged = _this.visibleChanged.bind(void 0, layer);
67444
- var _remover = visibleSegments.changed.add(visibleChanged);
67445
- _this.handlerRemovers.push(_remover);
67446
- layer.registerDisposer(_remover);
67447
- }
67448
- }
67449
- }
67450
- } catch (err) {
67451
- _iterator2.e(err);
67452
- } finally {
67453
- _iterator2.f();
67454
- }
67455
- }
67456
- }
67457
- });
67458
- _defineProperty(_assertThisInitialized(_this), "selectedChanged", function(layer) {
67459
- if (_this.viewer) {
67460
- var onSelectedChanged = _this.props.onSelectedChanged;
67461
- if (onSelectedChanged) {
67462
- var segmentSelectionState = layer.layer.displayState.segmentSelectionState;
67463
- if (segmentSelectionState) {
67464
- var segment = segmentSelectionState.hasSelectedSegment ? segmentSelectionState.selectedSegment : null;
67465
- onSelectedChanged(segment, layer);
67466
- }
67467
- }
67468
- }
67469
- });
67470
- _defineProperty(_assertThisInitialized(_this), "visibleChanged", function(layer) {
67471
- if (_this.viewer) {
67472
- var onVisibleChanged = _this.props.onVisibleChanged;
67473
- if (onVisibleChanged) {
67474
- var visibleSegments = layer.layer.displayState.segmentationGroupState.value.visibleSegments;
67475
- if (visibleSegments) {
67476
- onVisibleChanged(visibleSegments, layer);
67477
- }
67478
- }
67479
- }
67480
- });
67481
- _this.ngContainer = /* @__PURE__ */ _react["default"].createRef();
67482
- _this.viewer = null;
67483
- return _this;
67484
- }
67485
- _createClass(Neuroglancer3, [{
67486
- key: "componentDidMount",
67487
- value: function componentDidMount() {
67488
- var _this2 = this;
67489
- var _this$props2 = this.props, perspectiveZoom = _this$props2.perspectiveZoom, viewerState = _this$props2.viewerState, brainMapsClientId = _this$props2.brainMapsClientId, eventBindingsToUpdate = _this$props2.eventBindingsToUpdate, onViewerStateChanged = _this$props2.onViewerStateChanged, callbacks = _this$props2.callbacks, ngServer = _this$props2.ngServer, key = _this$props2.key, bundleRoot = _this$props2.bundleRoot;
67490
- this.viewer = (0, _neuroglancer.setupDefaultViewer)({
67491
- brainMapsClientId,
67492
- target: this.ngContainer.current,
67493
- bundleRoot: bundleRoot || "/"
67494
- });
67495
- this.setCallbacks(callbacks);
67496
- if (eventBindingsToUpdate) {
67497
- this.updateEventBindings(eventBindingsToUpdate);
67498
- }
67499
- this.viewer.expectingExternalUI = true;
67500
- if (ngServer) {
67501
- this.viewer.makeUrlFromState = function(state) {
67502
- var newState = _objectSpread({}, state);
67503
- if (state.layers) {
67504
- newState.layers = state.layers.filter(function(layer) {
67505
- if (layer.source) {
67506
- var sourceUrl = layer.source.url || layer.source;
67507
- if (typeof sourceUrl === "string") {
67508
- return !sourceUrl.startsWith("clio://");
67509
- }
67510
- }
67511
- return true;
67512
- });
67513
- }
67514
- return "".concat(ngServer, "/#!").concat((0, _url_hash_binding.encodeFragment)(JSON.stringify(newState)));
67515
- };
67516
- }
67517
- if (this.viewer.selectionDetailsState) {
67518
- this.viewer.selectionDetailsState.changed.add(this.selectionDetailsStateChanged);
67519
- }
67520
- this.viewer.layerManager.layersChanged.add(this.layersChanged);
67521
- if (viewerState) {
67522
- var newViewerState = viewerState;
67523
- if (newViewerState.projectionScale === null) {
67524
- delete newViewerState.projectionScale;
67525
- }
67526
- if (newViewerState.crossSectionScale === null) {
67527
- delete newViewerState.crossSectionScale;
67528
- }
67529
- if (newViewerState.projectionOrientation === null) {
67530
- delete newViewerState.projectionOrientation;
67531
- }
67532
- if (newViewerState.crossSectionOrientation === null) {
67533
- delete newViewerState.crossSectionOrientation;
67534
- }
67535
- this.viewer.state.restoreState(newViewerState);
67536
- } else {
67537
- this.viewer.state.restoreState({
67538
- layers: {
67539
- grayscale: {
67540
- type: "image",
67541
- source: "dvid://https://flyem.dvid.io/ab6e610d4fe140aba0e030645a1d7229/grayscalejpeg"
67542
- },
67543
- segmentation: {
67544
- type: "segmentation",
67545
- source: "dvid://https://flyem.dvid.io/d925633ed0974da78e2bb5cf38d01f4d/segmentation"
67546
- }
67547
- },
67548
- perspectiveZoom,
67549
- navigation: {
67550
- zoomFactor: 8
67551
- }
67552
- });
67553
- }
67554
- this.viewer.state.changed.add(function() {
67555
- if (onViewerStateChanged) {
67556
- try {
67557
- if (_this2.viewer.state.viewer.position) {
67558
- onViewerStateChanged(_this2.viewer.state.toJSON());
67559
- }
67560
- } catch (error) {
67561
- console.debug(error);
67562
- }
67563
- }
67564
- });
67565
- if (key) {
67566
- viewersKeyed[key] = this.viewer;
67567
- } else {
67568
- viewerNoKey = this.viewer;
67569
- }
67570
- window.viewer = this.viewer;
67571
- }
67572
- }, {
67573
- key: "componentDidUpdate",
67574
- value: function componentDidUpdate() {
67575
- var _this3 = this;
67576
- var selectedSegments = {};
67577
- var _iterator3 = _createForOfIteratorHelper(this.viewer.layerManager.managedLayers), _step3;
67578
- try {
67579
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
67580
- var layer = _step3.value;
67581
- if (layer.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
67582
- var segmentSelectionState = layer.layer.displayState.segmentSelectionState;
67583
- selectedSegments[layer.name] = segmentSelectionState.selectedSegment;
67584
- }
67585
- }
67586
- } catch (err) {
67587
- _iterator3.e(err);
67588
- } finally {
67589
- _iterator3.f();
67590
- }
67591
- var viewerState = this.props.viewerState;
67592
- if (viewerState) {
67593
- var newViewerState = _objectSpread({}, viewerState);
67594
- var restoreStates = [function() {
67595
- _this3.viewer.state.restoreState(newViewerState);
67596
- }];
67597
- if (viewerState.projectionScale === null) {
67598
- delete newViewerState.projectionScale;
67599
- restoreStates.push(function() {
67600
- _this3.viewer.projectionScale.reset();
67601
- });
67602
- }
67603
- if (viewerState.crossSectionScale === null) {
67604
- delete newViewerState.crossSectionScale;
67605
- }
67606
- restoreStates.forEach(function(restore) {
67607
- return restore();
67608
- });
67609
- }
67610
- var _iterator4 = _createForOfIteratorHelper(this.viewer.layerManager.managedLayers), _step4;
67611
- try {
67612
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
67613
- var _layer3 = _step4.value;
67614
- if (_layer3.layer instanceof _segmentation_user_layer.SegmentationUserLayer) {
67615
- var _segmentSelectionState = _layer3.layer.displayState.segmentSelectionState;
67616
- _segmentSelectionState.set(selectedSegments[_layer3.name]);
67617
- }
67618
- }
67619
- } catch (err) {
67620
- _iterator4.e(err);
67621
- } finally {
67622
- _iterator4.f();
67623
- }
67624
- if ("position" in viewerState) {
67625
- if (Array.isArray(viewerState.position)) {
67626
- if (viewerState.position.length === 0) {
67627
- this.viewer.position.reset();
67628
- }
67629
- }
67630
- }
67631
- }
67632
- }, {
67633
- key: "componentWillUnmount",
67634
- value: function componentWillUnmount() {
67635
- var key = this.props.key;
67636
- if (key) {
67637
- delete viewersKeyed[key];
67638
- } else {
67639
- viewerNoKey = void 0;
67640
- }
67641
- }
67642
- /* setCallbacks allows us to set a callback on a neuroglancer event
67643
- * each callback created should be in the format:
67644
- * [
67645
- * {
67646
- * name: 'unique-name',
67647
- * event: 'the neuroglancer event to target, eg: click0, keyt',
67648
- * function: (slice) => { slice.whatever }
67649
- * },
67650
- * {...}
67651
- * ]
67652
- *
67653
- */
67654
- }, {
67655
- key: "setCallbacks",
67656
- value: function setCallbacks(callbacks) {
67657
- var _this4 = this;
67658
- callbacks.forEach(function(callback) {
67659
- _this4.viewer.bindCallback(callback.name, callback["function"]);
67660
- _this4.viewer.inputEventBindings.sliceView.set(callback.event, callback.name);
67661
- });
67662
- }
67663
- }, {
67664
- key: "render",
67665
- value: function render() {
67666
- var perspectiveZoom = this.props.perspectiveZoom;
67667
- return /* @__PURE__ */ _react["default"].createElement("div", {
67668
- className: "neuroglancer-container",
67669
- ref: this.ngContainer
67670
- }, /* @__PURE__ */ _react["default"].createElement("p", null, "Neuroglancer here with zoom ", perspectiveZoom));
67671
- }
67672
- }]);
67673
- return Neuroglancer3;
67674
- }(_react["default"].Component);
67675
- exports["default"] = Neuroglancer2;
67676
- Neuroglancer2.propTypes = {
67677
- perspectiveZoom: _propTypes["default"].number,
67678
- viewerState: _propTypes["default"].object,
67679
- brainMapsClientId: _propTypes["default"].string,
67680
- key: _propTypes["default"].string,
67681
- /**
67682
- * An array of event bindings to change in Neuroglancer. The array format is as follows:
67683
- * [[old-event1, new-event1], [old-event2], old-event3]
67684
- * Here, `old-event1`'s will be unbound and its action will be re-bound to `new-event1`.
67685
- * The bindings for `old-event2` and `old-event3` will be removed.
67686
- * Neuroglancer has its own syntax for event descriptors, and here are some examples:
67687
- * 'keya', 'shift+keyb' 'control+keyc', 'digit4', 'space', 'arrowleft', 'comma', 'period',
67688
- * 'minus', 'equal', 'bracketleft'.
67689
- */
67690
- eventBindingsToUpdate: _propTypes["default"].array,
67691
- /**
67692
- * A function of the form `(segment, layer) => {}`, called each time there is a change to
67693
- * the segment the user has "selected" (i.e., hovered over) in Neuroglancer.
67694
- * The `segment` argument will be a Neuroglancer `Uint64` with the ID of the now-selected
67695
- * segment, or `null` if no segment is now selected.
67696
- * The `layer` argument will be a Neuroglaner `ManagedUserLayer`, whose `layer` property
67697
- * will be a Neuroglancer `SegmentationUserLayer`.
67698
- */
67699
- onSelectedChanged: _propTypes["default"].func,
67700
- /**
67701
- * A function of the form `(segments, layer) => {}`, called each time there is a change to
67702
- * the segments the user has designated as "visible" (i.e., double-clicked on) in Neuroglancer.
67703
- * The `segments` argument will be a Neuroglancer `Uint64Set` whose elements are `Uint64`
67704
- * instances for the IDs of the now-visible segments.
67705
- * The `layer` argument will be a Neuroglaner `ManagedUserLayer`, whose `layer` property
67706
- * will be a Neuroglancer `SegmentationUserLayer`.
67707
- */
67708
- onVisibleChanged: _propTypes["default"].func,
67709
- /**
67710
- * A function of the form `() => {}` to respond to selection changes in the viewer.
67711
- */
67712
- onSelectionDetailsStateChanged: _propTypes["default"].func,
67713
- onViewerStateChanged: _propTypes["default"].func,
67714
- callbacks: _propTypes["default"].arrayOf(_propTypes["default"].object),
67715
- ngServer: _propTypes["default"].string
67716
- };
67717
- Neuroglancer2.defaultProps = {
67718
- perspectiveZoom: 20,
67719
- eventBindingsToUpdate: null,
67720
- brainMapsClientId: "NOT_A_VALID_ID",
67721
- viewerState: null,
67722
- onSelectedChanged: null,
67723
- onVisibleChanged: null,
67724
- onSelectionDetailsStateChanged: null,
67725
- onViewerStateChanged: null,
67726
- key: null,
67727
- callbacks: [],
67728
- ngServer: "https://neuroglancer-demo.appspot.com/"
67729
- };
67730
- })(lib);
67731
- return lib;
67732
- }
67733
- var libExports = requireLib();
67734
- const ReactNeuroglancer = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
67735
- const Component = typeof ReactNeuroglancer.default === "function" ? ReactNeuroglancer.default : ReactNeuroglancer;
67736
- const ReactNeuroglancerWrapper = React__default.forwardRef((props, ref) => /* @__PURE__ */ React__default.createElement(Component, { ref, ...props }));
67123
+ });
67124
+ this.disposers = [];
67125
+ const { key } = this.props;
67126
+ if (key) {
67127
+ delete viewersKeyed[key];
67128
+ } else {
67129
+ viewerNoKey = void 0;
67130
+ }
67131
+ }
67132
+ /* setCallbacks allows us to set a callback on a neuroglancer event
67133
+ * each callback created should be in the format:
67134
+ * [
67135
+ * {
67136
+ * name: 'unique-name',
67137
+ * event: 'the neuroglancer event to target, eg: click0, keyt',
67138
+ * function: (slice) => { slice.whatever }
67139
+ * },
67140
+ * {...}
67141
+ * ]
67142
+ *
67143
+ */
67144
+ setCallbacks(callbacks) {
67145
+ callbacks.forEach((callback) => {
67146
+ this.viewer.bindCallback(callback.name, callback.function);
67147
+ this.viewer.inputEventBindings.sliceView.set(
67148
+ callback.event,
67149
+ callback.name
67150
+ );
67151
+ });
67152
+ }
67153
+ render() {
67154
+ const { perspectiveZoom } = this.props;
67155
+ return /* @__PURE__ */ React__default.createElement("div", { className: "neuroglancer-container", ref: this.ngContainer }, /* @__PURE__ */ React__default.createElement("p", null, "Neuroglancer here with zoom ", perspectiveZoom));
67156
+ }
67157
+ }
67158
+ __publicField(Neuroglancer, "defaultProps", {
67159
+ perspectiveZoom: 20,
67160
+ eventBindingsToUpdate: null,
67161
+ brainMapsClientId: "NOT_A_VALID_ID",
67162
+ viewerState: null,
67163
+ onSelectedChanged: null,
67164
+ onVisibleChanged: null,
67165
+ onSelectionDetailsStateChanged: null,
67166
+ onViewerStateChanged: null,
67167
+ key: null,
67168
+ callbacks: [],
67169
+ ngServer: "https://neuroglancer-demo.appspot.com/"
67170
+ });
67737
67171
  export {
67738
- ReactNeuroglancerWrapper as default
67172
+ addLayerSignalRemover,
67173
+ closeSelectionTab,
67174
+ configureAnnotationLayer,
67175
+ configureAnnotationLayerChanged,
67176
+ configureLayersChangedSignals,
67177
+ Neuroglancer as default,
67178
+ getAnnotationLayer,
67179
+ getAnnotationSelectionHost,
67180
+ getAnnotationSource,
67181
+ getLayerManager,
67182
+ getManagedLayer,
67183
+ getNeuroglancerColor,
67184
+ getNeuroglancerViewerState,
67185
+ getSelectedAnnotationId,
67186
+ parseUrlHash,
67187
+ unsubscribeLayersChangedSignals
67739
67188
  };